aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CREDITS5
-rw-r--r--Documentation/DMA-API.txt79
-rw-r--r--Documentation/DocBook/kernel-api.tmpl19
-rw-r--r--Documentation/block/barrier.txt6
-rw-r--r--Documentation/block/biodoc.txt10
-rw-r--r--Documentation/block/request.txt2
-rw-r--r--Documentation/dontdiff3
-rw-r--r--Documentation/feature-removal-schedule.txt16
-rw-r--r--Documentation/filesystems/hfsplus.txt59
-rw-r--r--Documentation/gpio.txt4
-rw-r--r--Documentation/hpet.txt2
-rw-r--r--Documentation/hwmon/adm10314
-rw-r--r--Documentation/hwmon/thmc5074
-rw-r--r--Documentation/iostats.txt2
-rw-r--r--Documentation/ja_JP/HOWTO66
-rw-r--r--Documentation/ja_JP/stable_api_nonsense.txt20
-rw-r--r--Documentation/kernel-parameters.txt145
-rw-r--r--Documentation/keys.txt5
-rw-r--r--Documentation/kobject.txt178
-rw-r--r--Documentation/lguest/Makefile3
-rw-r--r--Documentation/lguest/extract58
-rw-r--r--Documentation/lguest/lguest.c702
-rw-r--r--Documentation/sched-stats.txt195
-rw-r--r--Documentation/spi/spidev_test.c202
-rw-r--r--Documentation/stable_api_nonsense.txt2
-rw-r--r--Documentation/sysfs-rules.txt72
-rw-r--r--MAINTAINERS37
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/boot/Makefile2
-rw-r--r--arch/alpha/boot/main.c2
-rw-r--r--arch/alpha/boot/tools/mkbb.c5
-rw-r--r--arch/alpha/boot/tools/objstrip.c2
-rw-r--r--arch/alpha/kernel/head.S1
-rw-r--r--arch/alpha/kernel/pci.c10
-rw-r--r--arch/alpha/kernel/pci_iommu.c4
-rw-r--r--arch/alpha/kernel/smp.c7
-rw-r--r--arch/alpha/kernel/vmlinux.lds.S1
-rw-r--r--arch/alpha/mm/init.c3
-rw-r--r--arch/arm/Kconfig3
-rw-r--r--arch/arm/kernel/entry-common.S2
-rw-r--r--arch/arm/kernel/setup.c1
-rw-r--r--arch/arm/kernel/smp.c3
-rw-r--r--arch/arm/kernel/traps.c2
-rw-r--r--arch/arm/mach-sa1100/jornada720.c27
-rw-r--r--arch/arm/mach-sa1100/jornada720_ssp.c2
-rw-r--r--arch/arm/nwfpe/Makefile1
-rw-r--r--arch/arm/nwfpe/entry26.S112
-rw-r--r--arch/arm/plat-omap/mailbox.c8
-rw-r--r--arch/arm26/ACKNOWLEDGEMENTS29
-rw-r--r--arch/arm26/Kconfig253
-rw-r--r--arch/arm26/Kconfig.debug50
-rw-r--r--arch/arm26/Makefile107
-rw-r--r--arch/arm26/boot/Makefile83
-rw-r--r--arch/arm26/boot/compressed/Makefile50
-rw-r--r--arch/arm26/boot/compressed/head.S516
-rw-r--r--arch/arm26/boot/compressed/ll_char_wr.S162
-rw-r--r--arch/arm26/boot/compressed/misc.c316
-rw-r--r--arch/arm26/boot/compressed/uncompress.h110
-rw-r--r--arch/arm26/boot/compressed/vmlinux.lds.in60
-rw-r--r--arch/arm26/boot/install.sh62
-rw-r--r--arch/arm26/defconfig361
-rw-r--r--arch/arm26/kernel/Makefile17
-rw-r--r--arch/arm26/kernel/armksyms.c204
-rw-r--r--arch/arm26/kernel/asm-offsets.c55
-rw-r--r--arch/arm26/kernel/calls.S265
-rw-r--r--arch/arm26/kernel/compat.c173
-rw-r--r--arch/arm26/kernel/dma.c273
-rw-r--r--arch/arm26/kernel/ecard.c847
-rw-r--r--arch/arm26/kernel/entry.S951
-rw-r--r--arch/arm26/kernel/fiq.c201
-rw-r--r--arch/arm26/kernel/head.S112
-rw-r--r--arch/arm26/kernel/init_task.c49
-rw-r--r--arch/arm26/kernel/irq.c722
-rw-r--r--arch/arm26/kernel/process.c392
-rw-r--r--arch/arm26/kernel/ptrace.c670
-rw-r--r--arch/arm26/kernel/ptrace.h13
-rw-r--r--arch/arm26/kernel/semaphore.c222
-rw-r--r--arch/arm26/kernel/setup.c572
-rw-r--r--arch/arm26/kernel/signal.c538
-rw-r--r--arch/arm26/kernel/sys_arm.c323
-rw-r--r--arch/arm26/kernel/time.c210
-rw-r--r--arch/arm26/kernel/traps.c548
-rw-r--r--arch/arm26/kernel/vmlinux-arm26-xip.lds.in136
-rw-r--r--arch/arm26/kernel/vmlinux-arm26.lds.in129
-rw-r--r--arch/arm26/kernel/vmlinux.lds.S11
-rw-r--r--arch/arm26/lib/Makefile26
-rw-r--r--arch/arm26/lib/ashldi3.c61
-rw-r--r--arch/arm26/lib/ashrdi3.c61
-rw-r--r--arch/arm26/lib/backtrace.S144
-rw-r--r--arch/arm26/lib/changebit.S28
-rw-r--r--arch/arm26/lib/clearbit.S31
-rw-r--r--arch/arm26/lib/copy_page.S62
-rw-r--r--arch/arm26/lib/csumipv6.S32
-rw-r--r--arch/arm26/lib/csumpartial.S130
-rw-r--r--arch/arm26/lib/csumpartialcopy.S52
-rw-r--r--arch/arm26/lib/csumpartialcopygeneric.S352
-rw-r--r--arch/arm26/lib/csumpartialcopyuser.S114
-rw-r--r--arch/arm26/lib/delay.S57
-rw-r--r--arch/arm26/lib/ecard.S40
-rw-r--r--arch/arm26/lib/findbit.S67
-rw-r--r--arch/arm26/lib/floppydma.S32
-rw-r--r--arch/arm26/lib/gcclib.h21
-rw-r--r--arch/arm26/lib/getuser.S112
-rw-r--r--arch/arm26/lib/io-acorn.S70
-rw-r--r--arch/arm26/lib/io-readsb.S116
-rw-r--r--arch/arm26/lib/io-readsl.S78
-rw-r--r--arch/arm26/lib/io-readsw.S107
-rw-r--r--arch/arm26/lib/io-writesb.S122
-rw-r--r--arch/arm26/lib/io-writesl.S56
-rw-r--r--arch/arm26/lib/io-writesw.S127
-rw-r--r--arch/arm26/lib/kbd.c278
-rw-r--r--arch/arm26/lib/lib1funcs.S313
-rw-r--r--arch/arm26/lib/longlong.h184
-rw-r--r--arch/arm26/lib/lshrdi3.c61
-rw-r--r--arch/arm26/lib/memchr.S25
-rw-r--r--arch/arm26/lib/memcpy.S318
-rw-r--r--arch/arm26/lib/memset.S80
-rw-r--r--arch/arm26/lib/memzero.S80
-rw-r--r--arch/arm26/lib/muldi3.c77
-rw-r--r--arch/arm26/lib/putuser.S109
-rw-r--r--arch/arm26/lib/setbit.S29
-rw-r--r--arch/arm26/lib/strchr.S25
-rw-r--r--arch/arm26/lib/strrchr.S25
-rw-r--r--arch/arm26/lib/testchangebit.S29
-rw-r--r--arch/arm26/lib/testclearbit.S29
-rw-r--r--arch/arm26/lib/testsetbit.S29
-rw-r--r--arch/arm26/lib/uaccess-kernel.S173
-rw-r--r--arch/arm26/lib/uaccess-user.S718
-rw-r--r--arch/arm26/lib/ucmpdi2.c51
-rw-r--r--arch/arm26/lib/udivdi3.c242
-rw-r--r--arch/arm26/machine/Makefile8
-rw-r--r--arch/arm26/machine/dma.c214
-rw-r--r--arch/arm26/machine/irq.c164
-rw-r--r--arch/arm26/machine/latches.c72
-rw-r--r--arch/arm26/mm/Makefile6
-rw-r--r--arch/arm26/mm/extable.c24
-rw-r--r--arch/arm26/mm/fault.c312
-rw-r--r--arch/arm26/mm/fault.h5
-rw-r--r--arch/arm26/mm/init.c403
-rw-r--r--arch/arm26/mm/memc.c184
-rw-r--r--arch/arm26/mm/proc-funcs.S359
-rw-r--r--arch/arm26/mm/small_page.c192
-rw-r--r--arch/arm26/nwfpe/ARM-gcc.h120
-rw-r--r--arch/arm26/nwfpe/ChangeLog83
-rw-r--r--arch/arm26/nwfpe/Makefile15
-rw-r--r--arch/arm26/nwfpe/double_cpdo.c288
-rw-r--r--arch/arm26/nwfpe/entry.S114
-rw-r--r--arch/arm26/nwfpe/extended_cpdo.c273
-rw-r--r--arch/arm26/nwfpe/fpa11.c221
-rw-r--r--arch/arm26/nwfpe/fpa11.h87
-rw-r--r--arch/arm26/nwfpe/fpa11.inl51
-rw-r--r--arch/arm26/nwfpe/fpa11_cpdo.c117
-rw-r--r--arch/arm26/nwfpe/fpa11_cpdt.c368
-rw-r--r--arch/arm26/nwfpe/fpa11_cprt.c289
-rw-r--r--arch/arm26/nwfpe/fpmodule.c180
-rw-r--r--arch/arm26/nwfpe/fpmodule.h46
-rw-r--r--arch/arm26/nwfpe/fpmodule.inl84
-rw-r--r--arch/arm26/nwfpe/fpopcode.c148
-rw-r--r--arch/arm26/nwfpe/fpopcode.h390
-rw-r--r--arch/arm26/nwfpe/fpsr.h108
-rw-r--r--arch/arm26/nwfpe/milieu.h48
-rw-r--r--arch/arm26/nwfpe/single_cpdo.c255
-rw-r--r--arch/arm26/nwfpe/softfloat-macros740
-rw-r--r--arch/arm26/nwfpe/softfloat-specialize366
-rw-r--r--arch/arm26/nwfpe/softfloat.c3439
-rw-r--r--arch/arm26/nwfpe/softfloat.h232
-rw-r--r--arch/blackfin/Makefile4
-rw-r--r--arch/blackfin/kernel/dma-mapping.c3
-rw-r--r--arch/blackfin/kernel/setup.c5
-rw-r--r--arch/blackfin/kernel/traps.c2
-rw-r--r--arch/blackfin/kernel/vmlinux.lds.S16
-rw-r--r--arch/blackfin/mach-bf561/head.S10
-rw-r--r--arch/blackfin/mach-common/cacheinit.S3
-rw-r--r--arch/blackfin/mach-common/ints-priority-dc.c39
-rw-r--r--arch/blackfin/mach-common/ints-priority-sc.c48
-rw-r--r--arch/frv/kernel/sys_frv.c1
-rw-r--r--arch/i386/Kconfig5
-rw-r--r--arch/i386/Kconfig.debug4
-rw-r--r--arch/i386/boot/apm.c7
-rw-r--r--arch/i386/boot/code16gcc.h2
-rw-r--r--arch/i386/boot/edd.c5
-rw-r--r--arch/i386/boot/header.S4
-rw-r--r--arch/i386/boot/install.sh9
-rw-r--r--arch/i386/boot/main.c16
-rw-r--r--arch/i386/boot/pm.c2
-rw-r--r--arch/i386/boot/video-bios.c2
-rw-r--r--arch/i386/kernel/Makefile1
-rw-r--r--arch/i386/kernel/alternative.c14
-rw-r--r--arch/i386/kernel/apm.c2
-rw-r--r--arch/i386/kernel/cpu/bugs.c1
-rw-r--r--arch/i386/kernel/cpu/cpufreq/Kconfig2
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c4
-rw-r--r--arch/i386/kernel/e820.c2
-rw-r--r--arch/i386/kernel/legacy_serial.c67
-rw-r--r--arch/i386/kernel/microcode.c1
-rw-r--r--arch/i386/kernel/sys_i386.c1
-rw-r--r--arch/i386/kernel/sysenter.c1
-rw-r--r--arch/i386/mm/init.c16
-rw-r--r--arch/i386/power/Makefile2
-rw-r--r--arch/ia64/Kconfig3
-rw-r--r--arch/ia64/hp/common/sba_iommu.c7
-rw-r--r--arch/ia64/hp/sim/simscsi.c68
-rw-r--r--arch/ia64/ia32/ia32_support.c8
-rw-r--r--arch/ia64/ia32/ia32priv.h12
-rw-r--r--arch/ia64/ia32/sys_ia32.c81
-rw-r--r--arch/ia64/kernel/acpi.c28
-rw-r--r--arch/ia64/kernel/cyclone.c14
-rw-r--r--arch/ia64/kernel/head.S4
-rw-r--r--arch/ia64/kernel/init_task.c1
-rw-r--r--arch/ia64/kernel/irq_ia64.c31
-rw-r--r--arch/ia64/kernel/machvec.c27
-rw-r--r--arch/ia64/kernel/perfmon.c4
-rw-r--r--arch/ia64/kernel/process.c7
-rw-r--r--arch/ia64/kernel/setup.c11
-rw-r--r--arch/ia64/kernel/smp.c2
-rw-r--r--arch/ia64/kernel/smpboot.c6
-rw-r--r--arch/ia64/kernel/time.c4
-rw-r--r--arch/ia64/kernel/vmlinux.lds.S2
-rw-r--r--arch/ia64/pci/pci.c2
-rw-r--r--arch/m32r/kernel/ptrace.c1
-rw-r--r--arch/m32r/kernel/setup_mappi.c5
-rw-r--r--arch/m32r/kernel/smpboot.c1
-rw-r--r--arch/m32r/kernel/sys_m32r.c1
-rw-r--r--arch/m68k/kernel/process.c1
-rw-r--r--arch/m68k/kernel/sys_m68k.c1
-rw-r--r--arch/m68knommu/Kconfig24
-rw-r--r--arch/m68knommu/Makefile2
-rw-r--r--arch/m68knommu/kernel/dma.c1
-rw-r--r--arch/m68knommu/kernel/setup.c7
-rw-r--r--arch/m68knommu/platform/5206/config.c10
-rw-r--r--arch/m68knommu/platform/5206e/config.c10
-rw-r--r--arch/m68knommu/platform/520x/config.c9
-rw-r--r--arch/m68knommu/platform/523x/config.c10
-rw-r--r--arch/m68knommu/platform/5249/config.c10
-rw-r--r--arch/m68knommu/platform/5272/config.c9
-rw-r--r--arch/m68knommu/platform/527x/config.c10
-rw-r--r--arch/m68knommu/platform/528x/config.c10
-rw-r--r--arch/m68knommu/platform/5307/config.c9
-rw-r--r--arch/m68knommu/platform/5307/entry.S11
-rw-r--r--arch/m68knommu/platform/5307/pit.c14
-rw-r--r--arch/m68knommu/platform/5307/timers.c13
-rw-r--r--arch/m68knommu/platform/532x/config.c7
-rw-r--r--arch/m68knommu/platform/5407/config.c9
-rw-r--r--arch/m68knommu/platform/68328/timers.c11
-rw-r--r--arch/m68knommu/platform/68360/config.c14
-rw-r--r--arch/m68knommu/platform/68VZ328/config.c7
-rw-r--r--arch/mips/Kconfig245
-rw-r--r--arch/mips/Makefile67
-rw-r--r--arch/mips/arc/console.c31
-rw-r--r--arch/mips/arc/file.c22
-rw-r--r--arch/mips/au1000/common/Makefile2
-rw-r--r--arch/mips/boot/Makefile4
-rw-r--r--arch/mips/cobalt/Makefile2
-rw-r--r--arch/mips/cobalt/serial.c4
-rw-r--r--arch/mips/configs/atlas_defconfig3
-rw-r--r--arch/mips/configs/bigsur_defconfig3
-rw-r--r--arch/mips/configs/capcella_defconfig3
-rw-r--r--arch/mips/configs/cobalt_defconfig2
-rw-r--r--arch/mips/configs/db1000_defconfig3
-rw-r--r--arch/mips/configs/db1100_defconfig3
-rw-r--r--arch/mips/configs/db1200_defconfig3
-rw-r--r--arch/mips/configs/db1500_defconfig3
-rw-r--r--arch/mips/configs/db1550_defconfig3
-rw-r--r--arch/mips/configs/ddb5477_defconfig990
-rw-r--r--arch/mips/configs/decstation_defconfig3
-rw-r--r--arch/mips/configs/e55_defconfig3
-rw-r--r--arch/mips/configs/emma2rh_defconfig3
-rw-r--r--arch/mips/configs/excite_defconfig3
-rw-r--r--arch/mips/configs/fulong_defconfig2
-rw-r--r--arch/mips/configs/ip22_defconfig3
-rw-r--r--arch/mips/configs/ip27_defconfig3
-rw-r--r--arch/mips/configs/ip32_defconfig3
-rw-r--r--arch/mips/configs/jazz_defconfig3
-rw-r--r--arch/mips/configs/jmr3927_defconfig3
-rw-r--r--arch/mips/configs/malta_defconfig3
-rw-r--r--arch/mips/configs/mipssim_defconfig3
-rw-r--r--arch/mips/configs/mpc30x_defconfig3
-rw-r--r--arch/mips/configs/msp71xx_defconfig3
-rw-r--r--arch/mips/configs/ocelot_defconfig919
-rw-r--r--arch/mips/configs/pb1100_defconfig3
-rw-r--r--arch/mips/configs/pb1500_defconfig3
-rw-r--r--arch/mips/configs/pb1550_defconfig3
-rw-r--r--arch/mips/configs/pnx8550-jbs_defconfig3
-rw-r--r--arch/mips/configs/pnx8550-stb810_defconfig3
-rw-r--r--arch/mips/configs/qemu_defconfig3
-rw-r--r--arch/mips/configs/rbhma4200_defconfig2
-rw-r--r--arch/mips/configs/rbhma4500_defconfig2
-rw-r--r--arch/mips/configs/rm200_defconfig3
-rw-r--r--arch/mips/configs/sb1250-swarm_defconfig3
-rw-r--r--arch/mips/configs/sead_defconfig3
-rw-r--r--arch/mips/configs/tb0219_defconfig3
-rw-r--r--arch/mips/configs/tb0226_defconfig3
-rw-r--r--arch/mips/configs/tb0287_defconfig3
-rw-r--r--arch/mips/configs/workpad_defconfig3
-rw-r--r--arch/mips/configs/wrppmc_defconfig3
-rw-r--r--arch/mips/configs/yosemite_defconfig3
-rw-r--r--arch/mips/ddb5xxx/Kconfig4
-rw-r--r--arch/mips/ddb5xxx/common/Makefile5
-rw-r--r--arch/mips/ddb5xxx/common/nile4.c130
-rw-r--r--arch/mips/ddb5xxx/common/prom.c132
-rw-r--r--arch/mips/ddb5xxx/common/rtc_ds1386.c170
-rw-r--r--arch/mips/ddb5xxx/ddb5477/Makefile9
-rw-r--r--arch/mips/ddb5xxx/ddb5477/ddb5477-platform.c49
-rw-r--r--arch/mips/ddb5xxx/ddb5477/debug.c160
-rw-r--r--arch/mips/ddb5xxx/ddb5477/irq.c209
-rw-r--r--arch/mips/ddb5xxx/ddb5477/irq_5477.c154
-rw-r--r--arch/mips/ddb5xxx/ddb5477/kgdb_io.c136
-rw-r--r--arch/mips/ddb5xxx/ddb5477/lcd44780.c96
-rw-r--r--arch/mips/ddb5xxx/ddb5477/lcd44780.h15
-rw-r--r--arch/mips/ddb5xxx/ddb5477/setup.c399
-rw-r--r--arch/mips/dec/Makefile2
-rw-r--r--arch/mips/defconfig3
-rw-r--r--arch/mips/gt64120/common/Makefile5
-rw-r--r--arch/mips/gt64120/common/time.c101
-rw-r--r--arch/mips/gt64120/momenco_ocelot/Makefile7
-rw-r--r--arch/mips/gt64120/momenco_ocelot/dbg_io.c121
-rw-r--r--arch/mips/gt64120/momenco_ocelot/irq.c95
-rw-r--r--arch/mips/gt64120/momenco_ocelot/ocelot-platform.c46
-rw-r--r--arch/mips/gt64120/momenco_ocelot/ocelot_pld.h30
-rw-r--r--arch/mips/gt64120/momenco_ocelot/prom.c71
-rw-r--r--arch/mips/gt64120/momenco_ocelot/reset.c47
-rw-r--r--arch/mips/gt64120/momenco_ocelot/setup.c365
-rw-r--r--arch/mips/gt64120/wrppmc/Makefile2
-rw-r--r--arch/mips/jazz/Makefile2
-rw-r--r--arch/mips/jazz/io.c135
-rw-r--r--arch/mips/jazz/reset.c13
-rw-r--r--arch/mips/jazz/setup.c4
-rw-r--r--arch/mips/jmr3927/common/Makefile2
-rw-r--r--arch/mips/jmr3927/rbhma3100/Makefile2
-rw-r--r--arch/mips/jmr3927/rbhma3100/setup.c2
-rw-r--r--arch/mips/kernel/Makefile2
-rw-r--r--arch/mips/kernel/asm-offsets.c1
-rw-r--r--arch/mips/kernel/gdb-stub.c4
-rw-r--r--arch/mips/kernel/head.S3
-rw-r--r--arch/mips/kernel/kspd.c19
-rw-r--r--arch/mips/kernel/linux32.c9
-rw-r--r--arch/mips/kernel/machine_kexec.c13
-rw-r--r--arch/mips/kernel/mips-mt-fpaff.c9
-rw-r--r--arch/mips/kernel/mips-mt.c22
-rw-r--r--arch/mips/kernel/process.c2
-rw-r--r--arch/mips/kernel/ptrace.c14
-rw-r--r--arch/mips/kernel/relocate_kernel.S78
-rw-r--r--arch/mips/kernel/rtlx.c26
-rw-r--r--arch/mips/kernel/scall32-o32.S1
-rw-r--r--arch/mips/kernel/scall64-64.S1
-rw-r--r--arch/mips/kernel/scall64-n32.S1
-rw-r--r--arch/mips/kernel/scall64-o32.S1
-rw-r--r--arch/mips/kernel/signal32.c1
-rw-r--r--arch/mips/kernel/smp.c56
-rw-r--r--arch/mips/kernel/smtc.c36
-rw-r--r--arch/mips/kernel/syscall.c23
-rw-r--r--arch/mips/kernel/traps.c2
-rw-r--r--arch/mips/kernel/unaligned.c53
-rw-r--r--arch/mips/kernel/vpe.c360
-rw-r--r--arch/mips/lemote/lm2e/Makefile3
-rw-r--r--arch/mips/lemote/lm2e/irq.c1
-rw-r--r--arch/mips/lemote/lm2e/prom.c10
-rw-r--r--arch/mips/lemote/lm2e/setup.c14
-rw-r--r--arch/mips/math-emu/Makefile2
-rw-r--r--arch/mips/mips-boards/atlas/Makefile2
-rw-r--r--arch/mips/mips-boards/atlas/atlas_int.c1
-rw-r--r--arch/mips/mips-boards/generic/Makefile2
-rw-r--r--arch/mips/mips-boards/generic/init.c1
-rw-r--r--arch/mips/mips-boards/generic/time.c4
-rw-r--r--arch/mips/mips-boards/malta/Makefile2
-rw-r--r--arch/mips/mips-boards/malta/malta_int.c12
-rw-r--r--arch/mips/mips-boards/malta/malta_smtc.c2
-rw-r--r--arch/mips/mips-boards/sead/Makefile2
-rw-r--r--arch/mips/mipssim/Makefile2
-rw-r--r--arch/mips/mipssim/sim_setup.c1
-rw-r--r--arch/mips/mm/Makefile2
-rw-r--r--arch/mips/mm/c-r4k.c4
-rw-r--r--arch/mips/mm/c-sb1.c2
-rw-r--r--arch/mips/mm/init.c2
-rw-r--r--arch/mips/oprofile/op_model_rm9000.c1
-rw-r--r--arch/mips/pci/Makefile2
-rw-r--r--arch/mips/pci/fixup-ddb5477.c78
-rw-r--r--arch/mips/pci/fixup-ocelot.c75
-rw-r--r--arch/mips/pci/fixup-rbtx4927.c2
-rw-r--r--arch/mips/pci/fixup-tx4938.c2
-rw-r--r--arch/mips/pci/ops-ddb5477.c278
-rw-r--r--arch/mips/pci/ops-emma2rh.c2
-rw-r--r--arch/mips/pci/ops-pnx8550.c12
-rw-r--r--arch/mips/pci/pci-ddb5477.c207
-rw-r--r--arch/mips/pci/pci-ocelot.c107
-rw-r--r--arch/mips/philips/pnx8550/common/Makefile2
-rw-r--r--arch/mips/pmc-sierra/yosemite/Makefile4
-rw-r--r--arch/mips/pmc-sierra/yosemite/i2c-yosemite.c188
-rw-r--r--arch/mips/pmc-sierra/yosemite/irq.c4
-rw-r--r--arch/mips/pmc-sierra/yosemite/prom.c4
-rw-r--r--arch/mips/pmc-sierra/yosemite/setup.c4
-rw-r--r--arch/mips/pmc-sierra/yosemite/smp.c19
-rw-r--r--arch/mips/qemu/Makefile2
-rw-r--r--arch/mips/sgi-ip27/Makefile2
-rw-r--r--arch/mips/sgi-ip27/ip27-klnuma.c16
-rw-r--r--arch/mips/sgi-ip27/ip27-smp.c2
-rw-r--r--arch/mips/sgi-ip32/Makefile2
-rw-r--r--arch/mips/sgi-ip32/ip32-reset.c3
-rw-r--r--arch/mips/sibyte/bcm1480/Makefile2
-rw-r--r--arch/mips/sibyte/bcm1480/setup.c1
-rw-r--r--arch/mips/sibyte/common/Makefile1
-rw-r--r--arch/mips/sibyte/sb1250/Makefile2
-rw-r--r--arch/mips/sni/Makefile2
-rw-r--r--arch/mips/sni/sniprom.c5
-rw-r--r--arch/mips/tx4927/common/tx4927_irq.c3
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c4
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c60
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/setup.c4
-rw-r--r--arch/mips/vr41xx/common/Makefile2
-rw-r--r--arch/parisc/hpux/fs.c1
-rw-r--r--arch/parisc/kernel/init_task.c1
-rw-r--r--arch/parisc/kernel/process.c1
-rw-r--r--arch/parisc/kernel/smp.c1
-rw-r--r--arch/powerpc/Kconfig9
-rw-r--r--arch/powerpc/Kconfig.debug4
-rw-r--r--arch/powerpc/boot/dts/kuroboxHD.dts18
-rw-r--r--arch/powerpc/boot/dts/kuroboxHG.dts19
-rw-r--r--arch/powerpc/boot/dts/mpc7448hpc2.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc8313erdb.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc832x_mds.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc832x_rdb.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc8349emitx.dts4
-rw-r--r--arch/powerpc/boot/dts/mpc8349emitxgp.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc834x_mds.dts4
-rw-r--r--arch/powerpc/boot/dts/mpc836x_mds.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc8540ads.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc8541cds.dts4
-rw-r--r--arch/powerpc/boot/dts/mpc8544ds.dts219
-rw-r--r--arch/powerpc/boot/dts/mpc8548cds.dts250
-rw-r--r--arch/powerpc/boot/dts/mpc8555cds.dts4
-rw-r--r--arch/powerpc/boot/dts/mpc8560ads.dts2
-rw-r--r--arch/powerpc/boot/dts/mpc8568mds.dts60
-rw-r--r--arch/powerpc/boot/dts/mpc8641_hpcn.dts8
-rw-r--r--arch/powerpc/boot/dts/prpmc2800.dts6
-rw-r--r--arch/powerpc/configs/lite5200_defconfig2
-rw-r--r--arch/powerpc/configs/mpc8544_ds_defconfig333
-rw-r--r--arch/powerpc/configs/mpc8568mds_defconfig292
-rw-r--r--arch/powerpc/configs/pmac32_defconfig2
-rw-r--r--arch/powerpc/kernel/Makefile6
-rw-r--r--arch/powerpc/kernel/entry_64.S1
-rw-r--r--arch/powerpc/kernel/head_64.S7
-rw-r--r--arch/powerpc/kernel/iomap.c8
-rw-r--r--arch/powerpc/kernel/irq.c8
-rw-r--r--arch/powerpc/kernel/pci-common.c25
-rw-r--r--arch/powerpc/kernel/pci_32.c45
-rw-r--r--arch/powerpc/kernel/process.c4
-rw-r--r--arch/powerpc/kernel/prom_parse.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c4
-rw-r--r--arch/powerpc/kernel/syscalls.c1
-rw-r--r--arch/powerpc/kernel/udbg.c2
-rw-r--r--arch/powerpc/lib/rheap.c1
-rw-r--r--arch/powerpc/mm/lmb.c4
-rw-r--r--arch/powerpc/oprofile/cell/spu_task_sync.c1
-rw-r--r--arch/powerpc/platforms/82xx/mpc82xx_ads.c3
-rw-r--r--arch/powerpc/platforms/83xx/pci.c4
-rw-r--r--arch/powerpc/platforms/85xx/Kconfig6
-rw-r--r--arch/powerpc/platforms/85xx/Makefile2
-rw-r--r--arch/powerpc/platforms/85xx/mpc8544_ds.c241
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx.h1
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ads.c3
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_cds.c125
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_mds.c7
-rw-r--r--arch/powerpc/platforms/85xx/pci.c91
-rw-r--r--arch/powerpc/platforms/86xx/Kconfig3
-rw-r--r--arch/powerpc/platforms/86xx/Makefile1
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx.h5
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_hpcn.c13
-rw-r--r--arch/powerpc/platforms/86xx/pci.c238
-rw-r--r--arch/powerpc/platforms/cell/spufs/context.c3
-rw-r--r--arch/powerpc/platforms/cell/spufs/run.c4
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c4
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h5
-rw-r--r--arch/powerpc/platforms/chrp/pci.c7
-rw-r--r--arch/powerpc/platforms/embedded6xx/linkstation.c2
-rw-r--r--arch/powerpc/platforms/iseries/lpevents.c2
-rw-r--r--arch/powerpc/platforms/maple/pci.c3
-rw-r--r--arch/powerpc/sysdev/Makefile1
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c257
-rw-r--r--arch/powerpc/sysdev/fsl_pci.h88
-rw-r--r--arch/powerpc/sysdev/fsl_pcie.h94
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c61
-rw-r--r--arch/powerpc/sysdev/grackle.c2
-rw-r--r--arch/powerpc/sysdev/indirect_pci.c60
-rw-r--r--arch/powerpc/sysdev/mv64x60_dev.c64
-rw-r--r--arch/powerpc/sysdev/mv64x60_pci.c2
-rw-r--r--arch/ppc/configs/TQM8540_defconfig2
-rw-r--r--arch/ppc/configs/TQM8541_defconfig2
-rw-r--r--arch/ppc/configs/TQM8555_defconfig2
-rw-r--r--arch/ppc/configs/TQM8560_defconfig2
-rw-r--r--arch/ppc/configs/ev64360_defconfig2
-rw-r--r--arch/ppc/configs/ml300_defconfig2
-rw-r--r--arch/ppc/configs/ml403_defconfig2
-rw-r--r--arch/ppc/configs/mpc834x_sys_defconfig2
-rw-r--r--arch/ppc/configs/prep_defconfig2
-rw-r--r--arch/ppc/syslib/mv64x60.c29
-rw-r--r--arch/s390/appldata/appldata_base.c12
-rw-r--r--arch/s390/kernel/compat_wrapper.S10
-rw-r--r--arch/s390/kernel/entry.S6
-rw-r--r--arch/s390/kernel/entry64.S6
-rw-r--r--arch/s390/kernel/head.S1
-rw-r--r--arch/s390/kernel/init_task.c1
-rw-r--r--arch/s390/kernel/process.c1
-rw-r--r--arch/s390/kernel/smp.c31
-rw-r--r--arch/s390/kernel/sys_s390.c21
-rw-r--r--arch/s390/kernel/syscalls.S2
-rw-r--r--arch/s390/kernel/vmlinux.lds.S1
-rw-r--r--arch/s390/kernel/vtime.c2
-rw-r--r--arch/s390/mm/vmem.c6
-rw-r--r--arch/sh/Kconfig33
-rw-r--r--arch/sh/Makefile2
-rw-r--r--arch/sh/boards/se/7300/Makefile5
-rw-r--r--arch/sh/boards/se/7300/io.c268
-rw-r--r--arch/sh/boards/se/7300/irq.c40
-rw-r--r--arch/sh/boards/se/7300/setup.c74
-rw-r--r--arch/sh/boards/se/73180/Makefile5
-rw-r--r--arch/sh/boards/se/73180/io.c268
-rw-r--r--arch/sh/boards/se/73180/irq.c136
-rw-r--r--arch/sh/boards/se/73180/setup.c75
-rw-r--r--arch/sh/boot/Makefile7
-rw-r--r--arch/sh/boot/compressed/Makefile7
-rw-r--r--arch/sh/configs/se7300_defconfig696
-rw-r--r--arch/sh/configs/se73180_defconfig648
-rw-r--r--arch/sh/drivers/dma/dma-api.c7
-rw-r--r--arch/sh/kernel/cpu/irq/Makefile1
-rw-r--r--arch/sh/kernel/cpu/irq/ipr.c2
-rw-r--r--arch/sh/kernel/cpu/irq/pint.c220
-rw-r--r--arch/sh/kernel/cpu/sh3/Makefile4
-rw-r--r--arch/sh/kernel/cpu/sh3/clock-sh7710.c (renamed from arch/sh/kernel/cpu/sh3/clock-sh7300.c)26
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7300.c43
-rw-r--r--arch/sh/kernel/cpu/sh4/probe.c6
-rw-r--r--arch/sh/kernel/cpu/sh4/sq.c18
-rw-r--r--arch/sh/kernel/cpu/sh4a/Makefile2
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh73180.c81
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh73180.c43
-rw-r--r--arch/sh/kernel/init_task.c2
-rw-r--r--arch/sh/kernel/process.c7
-rw-r--r--arch/sh/kernel/setup.c3
-rw-r--r--arch/sh/kernel/sys_sh.c1
-rw-r--r--arch/sh/kernel/timers/timer-tmu.c3
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall.c1
-rw-r--r--arch/sh/mm/Kconfig14
-rw-r--r--arch/sh/mm/cache-sh4.c14
-rw-r--r--arch/sh/mm/pg-sh4.c76
-rw-r--r--arch/sh/tools/mach-types2
-rw-r--r--arch/sh64/Kconfig3
-rw-r--r--arch/sh64/kernel/init_task.c2
-rw-r--r--arch/sh64/kernel/irq_intc.c1
-rw-r--r--arch/sh64/kernel/pci-dma.c4
-rw-r--r--arch/sh64/kernel/process.c1
-rw-r--r--arch/sh64/kernel/sys_sh64.c1
-rw-r--r--arch/sh64/lib/dbg.c1
-rw-r--r--arch/sparc/defconfig188
-rw-r--r--arch/sparc/kernel/init_task.c1
-rw-r--r--arch/sparc/kernel/prom.c5
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c3
-rw-r--r--arch/sparc/kernel/vmlinux.lds.S2
-rw-r--r--arch/sparc/lib/memset.S2
-rw-r--r--arch/sparc/mm/sun4c.c3
-rw-r--r--arch/sparc/prom/printf.c2
-rw-r--r--arch/sparc64/Kconfig.debug2
-rw-r--r--arch/sparc64/defconfig32
-rw-r--r--arch/sparc64/kernel/Makefile4
-rw-r--r--arch/sparc64/kernel/ebus.c2
-rw-r--r--arch/sparc64/kernel/head.S11
-rw-r--r--arch/sparc64/kernel/init_task.c1
-rw-r--r--arch/sparc64/kernel/iommu.c (renamed from arch/sparc64/kernel/pci_iommu.c)304
-rw-r--r--arch/sparc64/kernel/isa.c2
-rw-r--r--arch/sparc64/kernel/pci.c77
-rw-r--r--arch/sparc64/kernel/pci_common.c123
-rw-r--r--arch/sparc64/kernel/pci_fire.c24
-rw-r--r--arch/sparc64/kernel/pci_psycho.c32
-rw-r--r--arch/sparc64/kernel/pci_sabre.c35
-rw-r--r--arch/sparc64/kernel/pci_schizo.c42
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c168
-rw-r--r--arch/sparc64/kernel/process.c1
-rw-r--r--arch/sparc64/kernel/sbus.c568
-rw-r--r--arch/sparc64/kernel/time.c75
-rw-r--r--arch/sparc64/kernel/traps.c18
-rw-r--r--arch/sparc64/kernel/viohs.c2
-rw-r--r--arch/sparc64/kernel/vmlinux.lds.S2
-rw-r--r--arch/sparc64/mm/fault.c5
-rw-r--r--arch/um/drivers/chan_kern.c9
-rw-r--r--arch/um/drivers/mconsole_kern.c4
-rw-r--r--arch/um/drivers/mmapper_kern.c1
-rw-r--r--arch/um/drivers/net_kern.c2
-rw-r--r--arch/um/drivers/ubd_kern.c4
-rw-r--r--arch/um/kernel/exec.c1
-rw-r--r--arch/um/kernel/init_task.c1
-rw-r--r--arch/um/kernel/mem.c2
-rw-r--r--arch/um/kernel/physmem.c15
-rw-r--r--arch/um/kernel/skas/process.c4
-rw-r--r--arch/um/kernel/syscall.c1
-rw-r--r--arch/um/os-Linux/aio.c47
-rw-r--r--arch/um/os-Linux/process.c2
-rw-r--r--arch/um/os-Linux/user_syms.c5
-rw-r--r--arch/um/sys-i386/Makefile2
-rw-r--r--arch/x86_64/Kconfig3
-rw-r--r--arch/x86_64/defconfig2
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c5
-rw-r--r--arch/x86_64/ia32/ptrace32.c1
-rw-r--r--arch/x86_64/ia32/syscall32.c8
-rw-r--r--arch/x86_64/kernel/Makefile4
-rw-r--r--arch/x86_64/kernel/acpi/sleep.c4
-rw-r--r--arch/x86_64/kernel/bugs.c1
-rw-r--r--arch/x86_64/kernel/entry.S6
-rw-r--r--arch/x86_64/kernel/process.c1
-rw-r--r--arch/x86_64/kernel/suspend.c4
-rw-r--r--arch/x86_64/kernel/sys_x86_64.c1
-rw-r--r--arch/x86_64/kernel/tce.c6
-rw-r--r--arch/x86_64/kernel/tsc.c2
-rw-r--r--arch/x86_64/mm/init.c10
-rw-r--r--arch/x86_64/vdso/vma.c1
-rw-r--r--block/Kconfig4
-rw-r--r--block/as-iosched.c26
-rw-r--r--block/blktrace.c30
-rw-r--r--block/bsg.c90
-rw-r--r--block/cfq-iosched.c39
-rw-r--r--block/deadline-iosched.c18
-rw-r--r--block/elevator.c75
-rw-r--r--block/ll_rw_blk.c215
-rw-r--r--block/noop-iosched.c14
-rw-r--r--block/scsi_ioctl.c24
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/acorn/README1
-rw-r--r--drivers/acorn/block/Kconfig36
-rw-r--r--drivers/acorn/block/Makefile9
-rw-r--r--drivers/acorn/block/fd1772.c1604
-rw-r--r--drivers/acorn/block/fd1772dma.S100
-rw-r--r--drivers/acorn/block/mfm.S162
-rw-r--r--drivers/acorn/block/mfmhd.c1385
-rw-r--r--drivers/acpi/Kconfig58
-rw-r--r--drivers/acpi/ac.c9
-rw-r--r--drivers/acpi/acpi_memhotplug.c8
-rw-r--r--drivers/acpi/asus_acpi.c11
-rw-r--r--drivers/acpi/battery.c9
-rw-r--r--drivers/acpi/button.c12
-rw-r--r--drivers/acpi/container.c10
-rw-r--r--drivers/acpi/ec.c8
-rw-r--r--drivers/acpi/events/evrgnini.c2
-rw-r--r--drivers/acpi/fan.c8
-rw-r--r--drivers/acpi/namespace/nsxfeval.c2
-rw-r--r--drivers/acpi/pci_link.c9
-rw-r--r--drivers/acpi/pci_root.c9
-rw-r--r--drivers/acpi/power.c8
-rw-r--r--drivers/acpi/processor_core.c8
-rw-r--r--drivers/acpi/processor_throttling.c59
-rw-r--r--drivers/acpi/sbs.c10
-rw-r--r--drivers/acpi/scan.c156
-rw-r--r--drivers/acpi/sleep/Makefile2
-rw-r--r--drivers/acpi/sleep/main.c244
-rw-r--r--drivers/acpi/sleep/proc.c24
-rw-r--r--drivers/acpi/sleep/sleep.h2
-rw-r--r--drivers/acpi/sleep/wakeup.c2
-rw-r--r--drivers/acpi/thermal.c8
-rw-r--r--drivers/acpi/utilities/uteval.c4
-rw-r--r--drivers/acpi/video.c8
-rw-r--r--drivers/ata/ata_piix.c113
-rw-r--r--drivers/ata/libata-scsi.c2
-rw-r--r--drivers/ata/pata_ali.c2
-rw-r--r--drivers/ata/pata_hpt37x.c14
-rw-r--r--drivers/base/core.c5
-rw-r--r--drivers/base/cpu.c2
-rw-r--r--drivers/base/firmware_class.c1
-rw-r--r--drivers/base/power/Makefile2
-rw-r--r--drivers/base/power/power.h4
-rw-r--r--drivers/base/power/shutdown.c2
-rw-r--r--drivers/block/Makefile2
-rw-r--r--drivers/block/amiflop.c2
-rw-r--r--drivers/block/aoe/aoe.h2
-rw-r--r--drivers/block/aoe/aoeblk.c2
-rw-r--r--drivers/block/ataflop.c2
-rw-r--r--drivers/block/cciss.c15
-rw-r--r--drivers/block/cpqarray.c6
-rw-r--r--drivers/block/floppy.c4
-rw-r--r--drivers/block/lguest_blk.c171
-rw-r--r--drivers/block/loop.c4
-rw-r--r--drivers/block/nbd.c4
-rw-r--r--drivers/block/paride/pcd.c4
-rw-r--r--drivers/block/paride/pd.c2
-rw-r--r--drivers/block/paride/pf.c4
-rw-r--r--drivers/block/pktcdvd.c12
-rw-r--r--drivers/block/ps2esdi.c4
-rw-r--r--drivers/block/ps3disk.c8
-rw-r--r--drivers/block/rd.c2
-rw-r--r--drivers/block/sunvdc.c2
-rw-r--r--drivers/block/swim3.c4
-rw-r--r--drivers/block/sx8.c20
-rw-r--r--drivers/block/ub.c6
-rw-r--r--drivers/block/umem.c6
-rw-r--r--drivers/block/viodasd.c2
-rw-r--r--drivers/block/xd.c2
-rw-r--r--drivers/block/xd.h2
-rw-r--r--drivers/block/xen-blkfront.c4
-rw-r--r--drivers/block/xsysace.c4
-rw-r--r--drivers/block/z2ram.c2
-rw-r--r--drivers/cdrom/cdrom.c2
-rw-r--r--drivers/cdrom/viocd.c2
-rw-r--r--drivers/char/Kconfig25
-rw-r--r--drivers/char/Makefile4
-rw-r--r--drivers/char/agp/Kconfig2
-rw-r--r--drivers/char/agp/ati-agp.c9
-rw-r--r--drivers/char/agp/compat_ioctl.c1
-rw-r--r--drivers/char/agp/frontend.c1
-rw-r--r--drivers/char/agp/generic.c2
-rw-r--r--drivers/char/agp/intel-agp.c19
-rw-r--r--drivers/char/agp/sgi-agp.c1
-rw-r--r--drivers/char/hpet.c10
-rw-r--r--drivers/char/hvc_lguest.c80
-rw-r--r--drivers/char/ip2/ip2main.c3
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c1
-rw-r--r--drivers/char/mmtimer.c1
-rw-r--r--drivers/char/mspec.c1
-rw-r--r--drivers/char/synclink_gt.c75
-rw-r--r--drivers/char/watchdog/Kconfig117
-rw-r--r--drivers/char/watchdog/Makefile43
-rw-r--r--drivers/char/watchdog/bfin_wdt.c490
-rw-r--r--drivers/char/watchdog/booke_wdt.c2
-rw-r--r--drivers/char/watchdog/cpu5wdt.c4
-rw-r--r--drivers/char/watchdog/davinci_wdt.c281
-rw-r--r--drivers/char/watchdog/iTCO_wdt.c38
-rw-r--r--drivers/char/watchdog/machzwd.c1
-rw-r--r--drivers/char/watchdog/mixcomwd.c5
-rw-r--r--drivers/char/watchdog/mpc5200_wdt.c286
-rw-r--r--drivers/char/watchdog/mpc83xx_wdt.c3
-rw-r--r--drivers/char/watchdog/mpc8xx_wdt.c2
-rw-r--r--drivers/char/watchdog/mtx-1_wdt.c1
-rw-r--r--drivers/char/watchdog/mv64x60_wdt.c218
-rw-r--r--drivers/char/watchdog/omap_wdt.c4
-rw-r--r--drivers/char/watchdog/s3c2410_wdt.c6
-rw-r--r--drivers/char/watchdog/sa1100_wdt.c3
-rw-r--r--drivers/char/watchdog/sbc60xxwdt.c4
-rw-r--r--drivers/char/watchdog/sc1200wdt.c4
-rw-r--r--drivers/char/watchdog/sc520_wdt.c4
-rw-r--r--drivers/char/watchdog/w83627hf_wdt.c24
-rw-r--r--drivers/dma/iovlock.c27
-rw-r--r--drivers/edac/Kconfig4
-rw-r--r--drivers/edac/edac_mc.c64
-rw-r--r--drivers/edac/edac_mc_sysfs.c19
-rw-r--r--drivers/edac/edac_module.h8
-rw-r--r--drivers/edac/edac_pci.c162
-rw-r--r--drivers/edac/edac_pci_sysfs.c297
-rw-r--r--drivers/edac/i3000_edac.c2
-rw-r--r--drivers/hwmon/Kconfig10
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/abituguru3.c5
-rw-r--r--drivers/hwmon/ams/ams-core.c1
-rw-r--r--drivers/hwmon/applesmc.c14
-rw-r--r--drivers/hwmon/dme1737.c2
-rw-r--r--drivers/hwmon/fscher.c4
-rw-r--r--drivers/hwmon/it87.c2
-rw-r--r--drivers/hwmon/lm78.c2
-rw-r--r--drivers/hwmon/lm90.c2
-rw-r--r--drivers/hwmon/lm93.c2
-rw-r--r--drivers/hwmon/pc87360.c2
-rw-r--r--drivers/hwmon/sis5595.c2
-rw-r--r--drivers/hwmon/smsc47m1.c2
-rw-r--r--drivers/hwmon/thmc50.c440
-rw-r--r--drivers/hwmon/via686a.c2
-rw-r--r--drivers/hwmon/vt8231.c4
-rw-r--r--drivers/hwmon/w83627hf.c2
-rw-r--r--drivers/i2c/busses/Kconfig4
-rw-r--r--drivers/i2c/chips/ds1682.c3
-rw-r--r--drivers/i2c/chips/tps65010.c2
-rw-r--r--drivers/ide/Kconfig2
-rw-r--r--drivers/ide/arm/ide_arm.c20
-rw-r--r--drivers/ide/ide-cd.c4
-rw-r--r--drivers/ide/ide-disk.c4
-rw-r--r--drivers/ide/ide-io.c2
-rw-r--r--drivers/ide/ide-probe.c2
-rw-r--r--drivers/ide/legacy/hd.c2
-rw-r--r--drivers/ide/pci/scc_pata.c4
-rw-r--r--drivers/ieee1394/raw1394.c2
-rw-r--r--drivers/infiniband/hw/amso1100/c2_qp.c1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_classes.h1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c6
-rw-r--r--drivers/infiniband/hw/ehca/ehca_pd.c1
-rw-r--r--drivers/infiniband/hw/ehca/hcp_if.c1
-rw-r--r--drivers/infiniband/hw/ehca/ipz_pt_fn.h2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_common.h3
-rw-r--r--drivers/infiniband/hw/ipath/ipath_diag.c1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c11
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba6120.c20
-rw-r--r--drivers/infiniband/hw/ipath/ipath_init_chip.c7
-rw-r--r--drivers/infiniband/hw/ipath/ipath_intr.c63
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h13
-rw-r--r--drivers/infiniband/hw/ipath/ipath_stats.c54
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c1
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.c1
-rw-r--r--drivers/input/evdev.c2
-rw-r--r--drivers/input/misc/atlas_btns.c9
-rw-r--r--drivers/input/serio/Kconfig2
-rw-r--r--drivers/isdn/divert/divert_procfs.c4
-rw-r--r--drivers/kvm/kvm_main.c44
-rw-r--r--drivers/kvm/x86_emulate.c2
-rw-r--r--drivers/lguest/Kconfig10
-rw-r--r--drivers/lguest/Makefile12
-rw-r--r--drivers/lguest/README47
-rw-r--r--drivers/lguest/core.c357
-rw-r--r--drivers/lguest/hypercalls.c144
-rw-r--r--drivers/lguest/interrupts_and_traps.c212
-rw-r--r--drivers/lguest/io.c265
-rw-r--r--drivers/lguest/lg.h47
-rw-r--r--drivers/lguest/lguest.c535
-rw-r--r--drivers/lguest/lguest_asm.S71
-rw-r--r--drivers/lguest/lguest_bus.c75
-rw-r--r--drivers/lguest/lguest_user.c166
-rw-r--r--drivers/lguest/page_tables.c329
-rw-r--r--drivers/lguest/segments.c126
-rw-r--r--drivers/lguest/switcher.S284
-rw-r--r--drivers/md/dm-table.c8
-rw-r--r--drivers/md/dm.c10
-rw-r--r--drivers/md/faulty.c2
-rw-r--r--drivers/md/linear.c14
-rw-r--r--drivers/md/md.c2
-rw-r--r--drivers/md/multipath.c12
-rw-r--r--drivers/md/raid0.c14
-rw-r--r--drivers/md/raid1.c12
-rw-r--r--drivers/md/raid10.c24
-rw-r--r--drivers/md/raid5.c18
-rw-r--r--drivers/media/dvb/dvb-usb/af9005-fe.c47
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c2
-rw-r--r--drivers/media/video/Kconfig4
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c238
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h1
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c10
-rw-r--r--drivers/media/video/ivtv/ivtv-firmware.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c11
-rw-r--r--drivers/media/video/ivtv/ivtv-mailbox.c14
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c11
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c5
-rw-r--r--drivers/media/video/zoran.h5
-rw-r--r--drivers/media/video/zoran_device.c50
-rw-r--r--drivers/media/video/zoran_driver.c233
-rw-r--r--drivers/message/fusion/Kconfig14
-rw-r--r--drivers/message/fusion/Makefile37
-rw-r--r--drivers/message/fusion/mptbase.c467
-rw-r--r--drivers/message/fusion/mptbase.h198
-rw-r--r--drivers/message/fusion/mptctl.c266
-rw-r--r--drivers/message/fusion/mptdebug.h288
-rw-r--r--drivers/message/fusion/mptfc.c108
-rw-r--r--drivers/message/fusion/mptlan.c3
-rw-r--r--drivers/message/fusion/mptsas.c276
-rw-r--r--drivers/message/fusion/mptscsih.c446
-rw-r--r--drivers/message/fusion/mptspi.c53
-rw-r--r--drivers/message/i2o/i2o_block.c6
-rw-r--r--drivers/misc/asus-laptop.c41
-rw-r--r--drivers/misc/sony-laptop.c21
-rw-r--r--drivers/misc/thinkpad_acpi.c20
-rw-r--r--drivers/misc/thinkpad_acpi.h2
-rw-r--r--drivers/mmc/card/queue.c10
-rw-r--r--drivers/mmc/core/bus.c23
-rw-r--r--drivers/mmc/core/core.c144
-rw-r--r--drivers/mmc/core/core.h22
-rw-r--r--drivers/mmc/core/host.c7
-rw-r--r--drivers/mmc/core/mmc.c26
-rw-r--r--drivers/mmc/core/mmc_ops.c2
-rw-r--r--drivers/mmc/core/mmc_ops.h2
-rw-r--r--drivers/mmc/core/sd.c36
-rw-r--r--drivers/mmc/core/sd_ops.c62
-rw-r--r--drivers/mmc/core/sd_ops.h3
-rw-r--r--drivers/mmc/host/at91_mci.c2
-rw-r--r--drivers/mmc/host/au1xmmc.c2
-rw-r--r--drivers/mmc/host/imxmmc.c2
-rw-r--r--drivers/mmc/host/mmci.c2
-rw-r--r--drivers/mmc/host/mmci.h2
-rw-r--r--drivers/mmc/host/omap.c2
-rw-r--r--drivers/mmc/host/pxamci.c2
-rw-r--r--drivers/mmc/host/sdhci.c63
-rw-r--r--drivers/mmc/host/sdhci.h2
-rw-r--r--drivers/mmc/host/wbsd.c15
-rw-r--r--drivers/mmc/host/wbsd.h2
-rw-r--r--drivers/mtd/devices/docprobe.c5
-rw-r--r--drivers/mtd/maps/Kconfig2
-rw-r--r--drivers/mtd/nand/diskonchip.c3
-rw-r--r--drivers/net/3c59x.c1
-rw-r--r--drivers/net/8139cp.c1
-rw-r--r--drivers/net/8139too.c1
-rw-r--r--drivers/net/82596.c1
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/Makefile4
-rw-r--r--drivers/net/acenic.c6
-rw-r--r--drivers/net/atl1/atl1_hw.h9
-rw-r--r--drivers/net/atl1/atl1_main.c28
-rw-r--r--drivers/net/ax88796.c3
-rw-r--r--drivers/net/b44.c1
-rw-r--r--drivers/net/bfin_mac.c6
-rw-r--r--drivers/net/bnx2.c1
-rw-r--r--drivers/net/bonding/bond_main.c52
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c1
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c2
-rw-r--r--drivers/net/defxx.c17
-rw-r--r--drivers/net/e100.c1
-rw-r--r--drivers/net/e1000/e1000_ethtool.c1
-rw-r--r--drivers/net/ehea/ehea.h2
-rw-r--r--drivers/net/ehea/ehea_main.c22
-rw-r--r--drivers/net/fec.c49
-rw-r--r--drivers/net/forcedeth.c45
-rw-r--r--drivers/net/gianfar_mii.c2
-rw-r--r--drivers/net/gianfar_mii.h2
-rw-r--r--drivers/net/hamradio/bpqether.c6
-rw-r--r--drivers/net/ixgb/ixgb_ethtool.c1
-rw-r--r--drivers/net/lguest_net.c237
-rw-r--r--drivers/net/lib8390.c55
-rw-r--r--drivers/net/loopback.c7
-rw-r--r--drivers/net/mlx4/mr.c15
-rw-r--r--drivers/net/ne2k-pci.c1
-rw-r--r--drivers/net/netxen/netxen_nic.h3
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c1
-rw-r--r--drivers/net/netxen/netxen_nic_main.c92
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c4
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c23
-rw-r--r--drivers/net/pcnet32.c1
-rw-r--r--drivers/net/phy/vitesse.c2
-rw-r--r--drivers/net/pppoe.c37
-rw-r--r--drivers/net/pppol2tp.c4
-rw-r--r--drivers/net/pppox.c11
-rw-r--r--drivers/net/ps3_gelic_net.c215
-rw-r--r--drivers/net/ps3_gelic_net.h24
-rwxr-xr-xdrivers/net/qla3xxx.c1
-rw-r--r--drivers/net/r8169.c1
-rw-r--r--drivers/net/s2io-regs.h5
-rw-r--r--drivers/net/s2io.c542
-rw-r--r--drivers/net/s2io.h11
-rw-r--r--drivers/net/sc92031.c1
-rw-r--r--drivers/net/skfp/pmf.c2
-rw-r--r--drivers/net/skge.c1
-rw-r--r--drivers/net/sky2.c1
-rw-r--r--drivers/net/sundance.c1
-rw-r--r--drivers/net/sunlance.c48
-rw-r--r--drivers/net/sunvnet.c1
-rw-r--r--drivers/net/tc35815.c1
-rw-r--r--drivers/net/tg3.c1
-rw-r--r--drivers/net/tulip/tulip_core.c8
-rw-r--r--drivers/net/ucc_geth.c334
-rw-r--r--drivers/net/ucc_geth.h6
-rw-r--r--drivers/net/ucc_geth_ethtool.c388
-rw-r--r--drivers/net/ucc_geth_mii.c6
-rw-r--r--drivers/net/usb/pegasus.c4
-rw-r--r--drivers/net/via-rhine.c1
-rw-r--r--drivers/net/via-velocity.c2
-rw-r--r--drivers/parport/parport_pc.c4
-rw-r--r--drivers/pci/pci-acpi.c32
-rw-r--r--drivers/pci/pci.c11
-rw-r--r--drivers/pci/pci.h3
-rw-r--r--drivers/pcmcia/cs.c3
-rw-r--r--drivers/pnp/card.c166
-rw-r--r--drivers/pnp/core.c50
-rw-r--r--drivers/pnp/driver.c75
-rw-r--r--drivers/pnp/interface.c217
-rw-r--r--drivers/pnp/isapnp/compat.c39
-rw-r--r--drivers/pnp/isapnp/core.c332
-rw-r--r--drivers/pnp/isapnp/proc.c21
-rw-r--r--drivers/pnp/manager.c144
-rw-r--r--drivers/pnp/pnpacpi/core.c117
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c441
-rw-r--r--drivers/pnp/pnpbios/bioscalls.c339
-rw-r--r--drivers/pnp/pnpbios/core.c257
-rw-r--r--drivers/pnp/pnpbios/proc.c107
-rw-r--r--drivers/pnp/pnpbios/rsparser.c349
-rw-r--r--drivers/pnp/quirks.c80
-rw-r--r--drivers/pnp/resource.c102
-rw-r--r--drivers/pnp/support.c17
-rw-r--r--drivers/pnp/system.c40
-rw-r--r--drivers/rtc/Kconfig78
-rw-r--r--drivers/rtc/Makefile42
-rw-r--r--drivers/rtc/class.c5
-rw-r--r--drivers/rtc/rtc-bfin.c2
-rw-r--r--drivers/rtc/rtc-dev.c2
-rw-r--r--drivers/rtc/rtc-ds1307.c2
-rw-r--r--drivers/rtc/rtc-m48t59.c2
-rw-r--r--drivers/rtc/rtc-s3c.c2
-rw-r--r--drivers/rtc/rtc-sh.c1
-rw-r--r--drivers/rtc/rtc-stk17ta8.c6
-rw-r--r--drivers/s390/block/dasd.c4
-rw-r--r--drivers/s390/block/dasd_eckd.c4
-rw-r--r--drivers/s390/block/dasd_int.h2
-rw-r--r--drivers/s390/block/dcssblk.c2
-rw-r--r--drivers/s390/block/xpram.c2
-rw-r--r--drivers/s390/char/Kconfig12
-rw-r--r--drivers/s390/char/raw3270.c6
-rw-r--r--drivers/s390/char/sclp_vt220.c62
-rw-r--r--drivers/s390/char/tape.h2
-rw-r--r--drivers/s390/char/tape_block.c4
-rw-r--r--drivers/s390/char/vmur.c2
-rw-r--r--drivers/s390/cio/blacklist.c19
-rw-r--r--drivers/s390/cio/ccwgroup.c3
-rw-r--r--drivers/s390/cio/chp.c19
-rw-r--r--drivers/s390/cio/chsc.c26
-rw-r--r--drivers/s390/cio/chsc.h2
-rw-r--r--drivers/s390/cio/cio.c13
-rw-r--r--drivers/s390/cio/cio_debug.h2
-rw-r--r--drivers/s390/cio/cmf.c16
-rw-r--r--drivers/s390/cio/css.c32
-rw-r--r--drivers/s390/cio/css.h1
-rw-r--r--drivers/s390/cio/device.c60
-rw-r--r--drivers/s390/cio/device_fsm.c20
-rw-r--r--drivers/s390/cio/device_ops.c257
-rw-r--r--drivers/s390/net/ctcmain.c6
-rw-r--r--drivers/s390/net/netiucv.c4
-rw-r--r--drivers/sbus/char/Kconfig1
-rw-r--r--drivers/sbus/char/bbc_envctrl.c10
-rw-r--r--drivers/sbus/char/bbc_i2c.c4
-rw-r--r--drivers/sbus/char/jsflash.c2
-rw-r--r--drivers/sbus/char/vfc_dev.c1
-rw-r--r--drivers/sbus/sbus.c9
-rw-r--r--drivers/scsi/aacraid/aachba.c66
-rw-r--r--drivers/scsi/aacraid/aacraid.h6
-rw-r--r--drivers/scsi/aacraid/linit.c9
-rw-r--r--drivers/scsi/aacraid/nark.c3
-rw-r--r--drivers/scsi/aacraid/rkt.c2
-rw-r--r--drivers/scsi/aacraid/rx.c2
-rw-r--r--drivers/scsi/advansys.c28261
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c23
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c11
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c4
-rw-r--r--drivers/scsi/arm/Kconfig9
-rw-r--r--drivers/scsi/arm/Makefile1
-rw-r--r--drivers/scsi/arm/ecoscsi.c166
-rw-r--r--drivers/scsi/iscsi_tcp.c2
-rw-r--r--drivers/scsi/libiscsi.c47
-rw-r--r--drivers/scsi/libsas/sas_ata.c30
-rw-r--r--drivers/scsi/libsas/sas_discover.c3
-rw-r--r--drivers/scsi/libsas/sas_dump.c2
-rw-r--r--drivers/scsi/libsas/sas_expander.c18
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c39
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c19
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c4
-rw-r--r--drivers/scsi/scsi_devinfo.c3
-rw-r--r--drivers/scsi/scsi_lib.c12
-rw-r--r--drivers/scsi/sd.c4
-rw-r--r--drivers/scsi/sr.c2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c2
-rw-r--r--drivers/serial/68328serial.c71
-rw-r--r--drivers/serial/8250.c5
-rw-r--r--drivers/serial/8250_early.c10
-rw-r--r--drivers/serial/8250_pci.c20
-rw-r--r--drivers/serial/Kconfig16
-rw-r--r--drivers/serial/mpsc.c711
-rw-r--r--drivers/serial/sb1250-duart.c14
-rw-r--r--drivers/serial/serial_core.c9
-rw-r--r--drivers/serial/serial_txx9.c5
-rw-r--r--drivers/serial/sh-sci.c9
-rw-r--r--drivers/serial/sh-sci.h66
-rw-r--r--drivers/serial/vr41xx_siu.c7
-rw-r--r--drivers/spi/spi.c45
-rw-r--r--drivers/spi/spi_mpc83xx.c30
-rw-r--r--drivers/spi/spi_s3c24xx.c2
-rw-r--r--drivers/spi/spidev.c13
-rw-r--r--drivers/usb/Makefile1
-rw-r--r--drivers/usb/core/message.c41
-rw-r--r--drivers/usb/core/quirks.c22
-rw-r--r--drivers/usb/gadget/config.c2
-rw-r--r--drivers/usb/gadget/epautoconf.c2
-rw-r--r--drivers/usb/gadget/ether.c3
-rw-r--r--drivers/usb/gadget/inode.c4
-rw-r--r--drivers/usb/gadget/m66592-udc.c2
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c30
-rw-r--r--drivers/usb/gadget/zero.c6
-rw-r--r--drivers/usb/serial/cp2101.c69
-rw-r--r--drivers/usb/serial/digi_acceleport.c970
-rw-r--r--drivers/usb/serial/io_edgeport.c19
-rw-r--r--drivers/usb/serial/mct_u232.c54
-rw-r--r--drivers/usb/serial/mct_u232.h2
-rw-r--r--drivers/usb/serial/sierra.c7
-rw-r--r--drivers/usb/serial/usb-serial.c32
-rw-r--r--drivers/usb/storage/unusual_devs.h21
-rw-r--r--drivers/video/Kconfig21
-rw-r--r--drivers/video/Makefile1
-rw-r--r--drivers/video/acornfb.c20
-rw-r--r--drivers/video/bw2.c105
-rw-r--r--drivers/video/cg14.c150
-rw-r--r--drivers/video/cg3.c136
-rw-r--r--drivers/video/cg6.c161
-rw-r--r--drivers/video/chipsfb.c3
-rw-r--r--drivers/video/console/fonts.c4
-rw-r--r--drivers/video/fbmem.c42
-rw-r--r--drivers/video/ffb.c170
-rw-r--r--drivers/video/geode/Kconfig15
-rw-r--r--drivers/video/geode/Makefile2
-rw-r--r--drivers/video/geode/lxfb.h199
-rw-r--r--drivers/video/geode/lxfb_core.c621
-rw-r--r--drivers/video/geode/lxfb_ops.c536
-rw-r--r--drivers/video/leo.c147
-rw-r--r--drivers/video/p9100.c138
-rw-r--r--drivers/video/s3c2410fb.c88
-rw-r--r--drivers/video/s3c2410fb.h3
-rw-r--r--drivers/video/sbuslib.c25
-rw-r--r--drivers/video/tcx.c184
-rw-r--r--drivers/video/tgafb.c2
-rw-r--r--drivers/video/tx3912fb.c326
-rw-r--r--drivers/video/xilinxfb.c23
-rw-r--r--drivers/w1/masters/ds1wm.c2
-rw-r--r--drivers/xen/xenbus/xenbus_xs.c2
-rw-r--r--fs/afs/flock.c126
-rw-r--r--fs/bio.c30
-rw-r--r--fs/compat_ioctl.c20
-rw-r--r--fs/dcookies.c1
-rw-r--r--fs/ext2/super.c2
-rw-r--r--fs/ext3/super.c2
-rw-r--r--fs/ext4/extents.c2
-rw-r--r--fs/ext4/super.c2
-rw-r--r--fs/gfs2/ops_file.c2
-rw-r--r--fs/isofs/inode.c9
-rw-r--r--fs/lockd/svclock.c6
-rw-r--r--fs/locks.c8
-rw-r--r--fs/ncpfs/ncplib_kernel.c3
-rw-r--r--fs/nfsd/export.c5
-rw-r--r--fs/nfsd/nfs4idmap.c6
-rw-r--r--fs/nfsd/nfs4proc.c10
-rw-r--r--fs/nfsd/nfs4xdr.c2
-rw-r--r--fs/nfsd/vfs.c5
-rw-r--r--fs/ocfs2/file.c2
-rw-r--r--fs/open.c18
-rw-r--r--fs/partitions/msdos.c5
-rw-r--r--fs/partitions/sun.c62
-rw-r--r--fs/partitions/sun.h1
-rw-r--r--fs/pipe.c2
-rw-r--r--fs/proc/base.c2
-rw-r--r--fs/proc/inode.c24
-rw-r--r--fs/quota.c2
-rw-r--r--fs/ramfs/file-nommu.c7
-rw-r--r--fs/reiserfs/stree.c5
-rw-r--r--fs/signalfd.c2
-rw-r--r--fs/splice.c4
-rw-r--r--fs/timerfd.c6
-rw-r--r--fs/udf/inode.c10
-rw-r--r--fs/udf/super.c2
-rw-r--r--fs/udf/udf_sb.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.c4
-rw-r--r--include/acpi/acpi_bus.h16
-rw-r--r--include/acpi/acpi_drivers.h23
-rw-r--r--include/acpi/actypes.h6
-rw-r--r--include/acpi/acutils.h4
-rw-r--r--include/asm-alpha/bitops.h2
-rw-r--r--include/asm-alpha/thread_info.h24
-rw-r--r--include/asm-arm/arch-mxc/uncompress.h3
-rw-r--r--include/asm-arm/arch-omap/mailbox.h2
-rw-r--r--include/asm-arm/thread_info.h7
-rw-r--r--include/asm-arm/unaligned.h22
-rw-r--r--include/asm-arm26/a.out.h39
-rw-r--r--include/asm-arm26/assembler.h106
-rw-r--r--include/asm-arm26/atomic.h123
-rw-r--r--include/asm-arm26/auxvec.h4
-rw-r--r--include/asm-arm26/bitops.h207
-rw-r--r--include/asm-arm26/bug.h19
-rw-r--r--include/asm-arm26/bugs.h15
-rw-r--r--include/asm-arm26/byteorder.h24
-rw-r--r--include/asm-arm26/cache.h12
-rw-r--r--include/asm-arm26/cacheflush.h53
-rw-r--r--include/asm-arm26/checksum.h151
-rw-r--r--include/asm-arm26/constants.h28
-rw-r--r--include/asm-arm26/cputime.h6
-rw-r--r--include/asm-arm26/current.h15
-rw-r--r--include/asm-arm26/delay.h34
-rw-r--r--include/asm-arm26/device.h7
-rw-r--r--include/asm-arm26/div64.h1
-rw-r--r--include/asm-arm26/dma.h183
-rw-r--r--include/asm-arm26/ecard.h294
-rw-r--r--include/asm-arm26/elf.h77
-rw-r--r--include/asm-arm26/emergency-restart.h6
-rw-r--r--include/asm-arm26/errno.h6
-rw-r--r--include/asm-arm26/fb.h12
-rw-r--r--include/asm-arm26/fcntl.h13
-rw-r--r--include/asm-arm26/fiq.h37
-rw-r--r--include/asm-arm26/floppy.h141
-rw-r--r--include/asm-arm26/fpstate.h29
-rw-r--r--include/asm-arm26/futex.h6
-rw-r--r--include/asm-arm26/hardirq.h32
-rw-r--r--include/asm-arm26/hardware.h109
-rw-r--r--include/asm-arm26/ide.h34
-rw-r--r--include/asm-arm26/io.h434
-rw-r--r--include/asm-arm26/ioc.h72
-rw-r--r--include/asm-arm26/ioctl.h1
-rw-r--r--include/asm-arm26/ioctls.h85
-rw-r--r--include/asm-arm26/ipc.h1
-rw-r--r--include/asm-arm26/ipcbuf.h29
-rw-r--r--include/asm-arm26/irq.h43
-rw-r--r--include/asm-arm26/irqchip.h101
-rw-r--r--include/asm-arm26/kdebug.h1
-rw-r--r--include/asm-arm26/kmap_types.h12
-rw-r--r--include/asm-arm26/leds.h50
-rw-r--r--include/asm-arm26/limits.h11
-rw-r--r--include/asm-arm26/linkage.h7
-rw-r--r--include/asm-arm26/local.h2
-rw-r--r--include/asm-arm26/locks.h161
-rw-r--r--include/asm-arm26/mach-types.h36
-rw-r--r--include/asm-arm26/map.h24
-rw-r--r--include/asm-arm26/mc146818rtc.h28
-rw-r--r--include/asm-arm26/memory.h101
-rw-r--r--include/asm-arm26/mman.h17
-rw-r--r--include/asm-arm26/mmu.h9
-rw-r--r--include/asm-arm26/mmu_context.h53
-rw-r--r--include/asm-arm26/module.h7
-rw-r--r--include/asm-arm26/msgbuf.h31
-rw-r--r--include/asm-arm26/namei.h25
-rw-r--r--include/asm-arm26/oldlatches.h37
-rw-r--r--include/asm-arm26/page.h102
-rw-r--r--include/asm-arm26/param.h33
-rw-r--r--include/asm-arm26/parport.h18
-rw-r--r--include/asm-arm26/pci.h6
-rw-r--r--include/asm-arm26/percpu.h6
-rw-r--r--include/asm-arm26/pgalloc.h70
-rw-r--r--include/asm-arm26/pgtable.h298
-rw-r--r--include/asm-arm26/poll.h8
-rw-r--r--include/asm-arm26/posix_types.h81
-rw-r--r--include/asm-arm26/proc-fns.h49
-rw-r--r--include/asm-arm26/processor.h113
-rw-r--r--include/asm-arm26/procinfo.h56
-rw-r--r--include/asm-arm26/ptrace.h104
-rw-r--r--include/asm-arm26/resource.h6
-rw-r--r--include/asm-arm26/scatterlist.h26
-rw-r--r--include/asm-arm26/sections.h2
-rw-r--r--include/asm-arm26/segment.h11
-rw-r--r--include/asm-arm26/semaphore-helper.h84
-rw-r--r--include/asm-arm26/semaphore.h100
-rw-r--r--include/asm-arm26/sembuf.h25
-rw-r--r--include/asm-arm26/serial.h44
-rw-r--r--include/asm-arm26/setup.h209
-rw-r--r--include/asm-arm26/shmbuf.h42
-rw-r--r--include/asm-arm26/shmparam.h15
-rw-r--r--include/asm-arm26/sigcontext.h33
-rw-r--r--include/asm-arm26/siginfo.h6
-rw-r--r--include/asm-arm26/signal.h176
-rw-r--r--include/asm-arm26/sizes.h52
-rw-r--r--include/asm-arm26/smp.h9
-rw-r--r--include/asm-arm26/socket.h55
-rw-r--r--include/asm-arm26/sockios.h13
-rw-r--r--include/asm-arm26/spinlock.h6
-rw-r--r--include/asm-arm26/stat.h77
-rw-r--r--include/asm-arm26/statfs.h8
-rw-r--r--include/asm-arm26/string.h43
-rw-r--r--include/asm-arm26/suspend.h4
-rw-r--r--include/asm-arm26/sysirq.h60
-rw-r--r--include/asm-arm26/system.h247
-rw-r--r--include/asm-arm26/termbits.h196
-rw-r--r--include/asm-arm26/termios.h92
-rw-r--r--include/asm-arm26/thread_info.h140
-rw-r--r--include/asm-arm26/timex.h29
-rw-r--r--include/asm-arm26/tlb.h63
-rw-r--r--include/asm-arm26/tlbflush.h70
-rw-r--r--include/asm-arm26/topology.h6
-rw-r--r--include/asm-arm26/types.h59
-rw-r--r--include/asm-arm26/uaccess-asm.h153
-rw-r--r--include/asm-arm26/uaccess.h293
-rw-r--r--include/asm-arm26/ucontext.h12
-rw-r--r--include/asm-arm26/unaligned.h118
-rw-r--r--include/asm-arm26/uncompress.h111
-rw-r--r--include/asm-arm26/unistd.h343
-rw-r--r--include/asm-arm26/user.h84
-rw-r--r--include/asm-arm26/xor.h141
-rw-r--r--include/asm-avr32/thread_info.h18
-rw-r--r--include/asm-blackfin/bfin-global.h1
-rw-r--r--include/asm-blackfin/mach-bf548/cdefBF54x_base.h33
-rw-r--r--include/asm-blackfin/mach-bf548/irq.h1
-rw-r--r--include/asm-blackfin/mach-bf561/cdefBF561.h6
-rw-r--r--include/asm-blackfin/mach-bf561/defBF561.h4
-rw-r--r--include/asm-blackfin/thread_info.h26
-rw-r--r--include/asm-cris/thread_info.h6
-rw-r--r--include/asm-frv/thread_info.h12
-rw-r--r--include/asm-generic/bug.h6
-rw-r--r--include/asm-generic/unaligned.h12
-rw-r--r--include/asm-h8300/thread_info.h12
-rw-r--r--include/asm-i386/acpi.h23
-rw-r--r--include/asm-i386/bootparam.h9
-rw-r--r--include/asm-i386/e820.h2
-rw-r--r--include/asm-i386/ist.h10
-rw-r--r--include/asm-i386/serial.h16
-rw-r--r--include/asm-i386/suspend.h2
-rw-r--r--include/asm-i386/thread_info.h18
-rw-r--r--include/asm-ia64/acpi.h5
-rw-r--r--include/asm-ia64/ia32.h9
-rw-r--r--include/asm-ia64/machvec.h1
-rw-r--r--include/asm-ia64/processor.h4
-rw-r--r--include/asm-ia64/smp.h1
-rw-r--r--include/asm-ia64/thread_info.h20
-rw-r--r--include/asm-m32r/thread_info.h10
-rw-r--r--include/asm-m68k/raw_io.h8
-rw-r--r--include/asm-m68k/system.h33
-rw-r--r--include/asm-m68knommu/hardirq.h2
-rw-r--r--include/asm-m68knommu/hw_irq.h4
-rw-r--r--include/asm-m68knommu/machdep.h38
-rw-r--r--include/asm-m68knommu/mcfdma.h2
-rw-r--r--include/asm-m68knommu/system.h4
-rw-r--r--include/asm-m68knommu/thread_info.h10
-rw-r--r--include/asm-m68knommu/timex.h24
-rw-r--r--include/asm-mips/a.out.h3
-rw-r--r--include/asm-mips/bootinfo.h13
-rw-r--r--include/asm-mips/ddb5xxx/ddb5477.h342
-rw-r--r--include/asm-mips/ddb5xxx/ddb5xxx.h263
-rw-r--r--include/asm-mips/edac.h35
-rw-r--r--include/asm-mips/elf.h13
-rw-r--r--include/asm-mips/hazards.h7
-rw-r--r--include/asm-mips/mach-tx49xx/cpu-feature-overrides.h23
-rw-r--r--include/asm-mips/mach-tx49xx/kmalloc.h8
-rw-r--r--include/asm-mips/mips-boards/generic.h1
-rw-r--r--include/asm-mips/mips_mt.h6
-rw-r--r--include/asm-mips/pmon.h2
-rw-r--r--include/asm-mips/processor.h20
-rw-r--r--include/asm-mips/seccomp.h37
-rw-r--r--include/asm-mips/system.h8
-rw-r--r--include/asm-mips/thread_info.h27
-rw-r--r--include/asm-mips/tx3912.h361
-rw-r--r--include/asm-mips/tx4927/toshiba_rbtx4927.h2
-rw-r--r--include/asm-mips/unistd.h15
-rw-r--r--include/asm-mips/war.h6
-rw-r--r--include/asm-parisc/thread_info.h16
-rw-r--r--include/asm-powerpc/bug.h4
-rw-r--r--include/asm-powerpc/page.h1
-rw-r--r--include/asm-powerpc/pci-bridge.h36
-rw-r--r--include/asm-powerpc/ppc_asm.h12
-rw-r--r--include/asm-powerpc/thread_info.h36
-rw-r--r--include/asm-powerpc/vio.h5
-rw-r--r--include/asm-ppc/mv64x60.h8
-rw-r--r--include/asm-s390/ccwdev.h5
-rw-r--r--include/asm-s390/s390_ext.h2
-rw-r--r--include/asm-s390/smp.h11
-rw-r--r--include/asm-s390/unistd.h2
-rw-r--r--include/asm-sh/bugs.h4
-rw-r--r--include/asm-sh/cpu-sh3/freq.h4
-rw-r--r--include/asm-sh/cpu-sh3/mmu_context.h1
-rw-r--r--include/asm-sh/cpu-sh3/timer.h3
-rw-r--r--include/asm-sh/cpu-sh4/freq.h2
-rw-r--r--include/asm-sh/dma-mapping.h8
-rw-r--r--include/asm-sh/dma.h1
-rw-r--r--include/asm-sh/fixmap.h8
-rw-r--r--include/asm-sh/floppy.h4
-rw-r--r--include/asm-sh/io.h4
-rw-r--r--include/asm-sh/pgtable.h6
-rw-r--r--include/asm-sh/processor.h4
-rw-r--r--include/asm-sh/se7300.h64
-rw-r--r--include/asm-sh/se73180.h66
-rw-r--r--include/asm-sh/thread_info.h10
-rw-r--r--include/asm-sh/ubc.h3
-rw-r--r--include/asm-sh64/dma-mapping.h8
-rw-r--r--include/asm-sh64/io.h4
-rw-r--r--include/asm-sparc/device.h4
-rw-r--r--include/asm-sparc/floppy.h80
-rw-r--r--include/asm-sparc64/dma-mapping.h338
-rw-r--r--include/asm-sparc64/fbio.h28
-rw-r--r--include/asm-sparc64/floppy.h6
-rw-r--r--include/asm-sparc64/iommu.h11
-rw-r--r--include/asm-sparc64/parport.h2
-rw-r--r--include/asm-sparc64/pci.h152
-rw-r--r--include/asm-sparc64/sbus.h86
-rw-r--r--include/asm-v850/thread_info.h10
-rw-r--r--include/asm-x86_64/acpi.h22
-rw-r--r--include/asm-x86_64/ist.h1
-rw-r--r--include/asm-x86_64/serial.h16
-rw-r--r--include/asm-x86_64/suspend.h2
-rw-r--r--include/asm-x86_64/tce.h6
-rw-r--r--include/asm-x86_64/thread_info.h2
-rw-r--r--include/asm-x86_64/uaccess.h4
-rw-r--r--include/asm-xtensa/io.h1
-rw-r--r--include/asm-xtensa/thread_info.h14
-rw-r--r--include/linux/Kbuild1
-rw-r--r--include/linux/acpi.h1
-rw-r--r--include/linux/apm_bios.h20
-rw-r--r--include/linux/blkdev.h145
-rw-r--r--include/linux/blktrace_api.h2
-rw-r--r--include/linux/bsg.h10
-rw-r--r--include/linux/compiler.h4
-rw-r--r--include/linux/device.h3
-rw-r--r--include/linux/dvb/video.h1
-rw-r--r--include/linux/elevator.h76
-rw-r--r--include/linux/ethtool.h4
-rw-r--r--include/linux/freezer.h6
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/genhd.h2
-rw-r--r--include/linux/hugetlb.h2
-rw-r--r--include/linux/i2c.h4
-rw-r--r--include/linux/ide.h4
-rw-r--r--include/linux/init.h2
-rw-r--r--include/linux/interrupt.h4
-rw-r--r--include/linux/ipv6.h5
-rw-r--r--include/linux/irq.h1
-rw-r--r--include/linux/kdebug.h2
-rw-r--r--include/linux/kobject.h26
-rw-r--r--include/linux/lguest.h51
-rw-r--r--include/linux/lguest_bus.h5
-rw-r--r--include/linux/lguest_launcher.h60
-rw-r--r--include/linux/libata.h2
-rw-r--r--include/linux/loop.h2
-rw-r--r--include/linux/mm.h38
-rw-r--r--include/linux/mmc/core.h2
-rw-r--r--include/linux/mmzone.h1
-rw-r--r--include/linux/mod_devicetable.h6
-rw-r--r--include/linux/mv643xx.h8
-rw-r--r--include/linux/netfilter/xt_connlimit.h4
-rw-r--r--include/linux/notifier.h13
-rw-r--r--include/linux/pci.h1
-rw-r--r--include/linux/pci_ids.h24
-rw-r--r--include/linux/pm.h16
-rw-r--r--include/linux/pnp.h191
-rw-r--r--include/linux/pnpbios.h60
-rw-r--r--include/linux/preempt.h44
-rw-r--r--include/linux/raid/md_k.h4
-rw-r--r--include/linux/reiserfs_fs.h8
-rw-r--r--include/linux/sched.h23
-rw-r--r--include/linux/serial_8250.h2
-rw-r--r--include/linux/serial_core.h2
-rw-r--r--include/linux/skbuff.h4
-rw-r--r--include/linux/spi/spi.h59
-rw-r--r--include/linux/spi/spidev.h4
-rw-r--r--include/linux/suspend.h19
-rw-r--r--include/linux/sysctl.h2
-rw-r--r--include/linux/time.h8
-rw-r--r--include/linux/usb.h2
-rw-r--r--include/net/af_unix.h29
-rw-r--r--include/net/bluetooth/l2cap.h50
-rw-r--r--include/net/ipv6.h1
-rw-r--r--include/net/netfilter/ipv6/nf_conntrack_ipv6.h3
-rw-r--r--include/net/netfilter/nf_conntrack_tuple.h4
-rw-r--r--include/net/tcp.h2
-rw-r--r--include/scsi/libiscsi.h3
-rw-r--r--include/scsi/libsas.h2
-rw-r--r--include/scsi/sd.h2
-rw-r--r--include/video/tx3912.h62
-rw-r--r--include/xen/page.h1
-rw-r--r--init/Kconfig23
-rw-r--r--init/initramfs.c2
-rw-r--r--ipc/shm.c4
-rw-r--r--kernel/Kconfig.preempt3
-rw-r--r--kernel/acct.c2
-rw-r--r--kernel/auditsc.c6
-rw-r--r--kernel/futex.c4
-rw-r--r--kernel/hrtimer.c6
-rw-r--r--kernel/irq/devres.c1
-rw-r--r--kernel/kmod.c8
-rw-r--r--kernel/kthread.c12
-rw-r--r--kernel/lockdep_proc.c2
-rw-r--r--kernel/params.c7
-rw-r--r--kernel/power/Kconfig45
-rw-r--r--kernel/power/Makefile5
-rw-r--r--kernel/power/disk.c1
-rw-r--r--kernel/power/main.c28
-rw-r--r--kernel/power/power.h12
-rw-r--r--kernel/relay.c3
-rw-r--r--kernel/sched.c206
-rw-r--r--kernel/sched_debug.c4
-rw-r--r--kernel/sys.c5
-rw-r--r--kernel/sysctl.c2
-rw-r--r--kernel/time.c16
-rw-r--r--kernel/time/timekeeping.c38
-rw-r--r--kernel/time/timer_list.c2
-rw-r--r--kernel/time/timer_stats.c2
-rw-r--r--kernel/tsacct.c2
-rw-r--r--lib/Kconfig.debug2
-rw-r--r--lib/Makefile2
-rw-r--r--lib/fault-inject.c4
-rw-r--r--lib/idr.c4
-rw-r--r--lib/kasprintf.c44
-rw-r--r--lib/kobject_uevent.c16
-rw-r--r--lib/lzo/lzo1x_compress.c6
-rw-r--r--lib/vsprintf.c35
-rw-r--r--mm/Kconfig4
-rw-r--r--mm/bounce.c4
-rw-r--r--mm/filemap.c2
-rw-r--r--mm/hugetlb.c1
-rw-r--r--mm/migrate.c24
-rw-r--r--mm/mmap.c34
-rw-r--r--mm/oom_kill.c3
-rw-r--r--mm/page_alloc.c14
-rw-r--r--mm/slab.c2
-rw-r--r--mm/slub.c3
-rw-r--r--mm/swapfile.c6
-rw-r--r--mm/vmstat.c1
-rw-r--r--net/8021q/vlan.c2
-rw-r--r--net/8021q/vlan_dev.c3
-rw-r--r--net/9p/conv.c1
-rw-r--r--net/bluetooth/l2cap.c48
-rw-r--r--net/bluetooth/rfcomm/tty.c5
-rw-r--r--net/bridge/br_if.c41
-rw-r--r--net/bridge/br_input.c6
-rw-r--r--net/bridge/netfilter/ebt_log.c7
-rw-r--r--net/bridge/netfilter/ebt_ulog.c9
-rw-r--r--net/core/dev.c93
-rw-r--r--net/core/ethtool.c64
-rw-r--r--net/core/pktgen.c106
-rw-r--r--net/core/rtnetlink.c2
-rw-r--r--net/decnet/dn_route.c4
-rw-r--r--net/ipv4/devinet.c5
-rw-r--r--net/ipv4/ip_options.c7
-rw-r--r--net/ipv4/ipvs/ip_vs_xmit.c2
-rw-r--r--net/ipv4/netfilter/ipt_LOG.c6
-rw-r--r--net/ipv4/netfilter/nf_nat_core.c3
-rw-r--r--net/ipv4/netfilter/nf_nat_rule.c2
-rw-r--r--net/ipv4/tcp_bic.c2
-rw-r--r--net/ipv4/tcp_cubic.c48
-rw-r--r--net/ipv4/tcp_htcp.c10
-rw-r--r--net/ipv4/tcp_illinois.c8
-rw-r--r--net/ipv4/tcp_input.c47
-rw-r--r--net/ipv4/tcp_lp.c6
-rw-r--r--net/ipv4/tcp_vegas.c6
-rw-r--r--net/ipv4/tcp_vegas.h2
-rw-r--r--net/ipv4/tcp_veno.c6
-rw-r--r--net/ipv4/tcp_westwood.c7
-rw-r--r--net/ipv4/tcp_yeah.c4
-rw-r--r--net/ipv6/addrconf.c8
-rw-r--r--net/ipv6/addrconf_core.c3
-rw-r--r--net/ipv6/ip6_tunnel.c17
-rw-r--r--net/ipv6/netfilter/ip6t_LOG.c6
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c4
-rw-r--r--net/ipv6/route.c5
-rw-r--r--net/ipv6/tcp_ipv6.c1
-rw-r--r--net/iucv/iucv.c15
-rw-r--r--net/key/af_key.c4
-rw-r--r--net/netfilter/nf_conntrack_core.c3
-rw-r--r--net/netfilter/nf_conntrack_expect.c8
-rw-r--r--net/netfilter/nf_conntrack_helper.c2
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c1
-rw-r--r--net/netfilter/nf_conntrack_proto_udp.c1
-rw-r--r--net/netfilter/nf_conntrack_proto_udplite.c1
-rw-r--r--net/netfilter/xt_connlimit.c6
-rw-r--r--net/netfilter/xt_physdev.c1
-rw-r--r--net/netfilter/xt_u32.c11
-rw-r--r--net/netlink/genetlink.c28
-rw-r--r--net/rxrpc/af_rxrpc.c2
-rw-r--r--net/rxrpc/ar-connection.c6
-rw-r--r--net/rxrpc/ar-transport.c4
-rw-r--r--net/rxrpc/rxkad.c2
-rw-r--r--net/sched/sch_api.c17
-rw-r--r--net/sched/sch_ingress.c3
-rw-r--r--net/sched/sch_prio.c13
-rw-r--r--net/sunrpc/auth_gss/svcauth_gss.c9
-rw-r--r--net/sunrpc/svcsock.c4
-rw-r--r--net/tipc/link.c28
-rw-r--r--net/tipc/msg.h6
-rw-r--r--net/unix/af_unix.c30
-rw-r--r--net/xfrm/xfrm_policy.c3
-rw-r--r--net/xfrm/xfrm_state.c4
-rw-r--r--net/xfrm/xfrm_user.c7
-rw-r--r--scripts/Makefile.build2
-rw-r--r--scripts/Makefile.modpost21
-rw-r--r--scripts/kconfig/conf.c31
-rw-r--r--scripts/kconfig/expr.h4
-rw-r--r--scripts/kconfig/gconf.c10
-rw-r--r--scripts/kconfig/kxgettext.c4
-rw-r--r--scripts/kconfig/lkc_proto.h2
-rw-r--r--scripts/kconfig/mconf.c4
-rw-r--r--scripts/kconfig/menu.c12
-rw-r--r--scripts/kconfig/qconf.cc2
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped12
-rw-r--r--scripts/kconfig/zconf.y12
-rw-r--r--scripts/mod/file2alias.c12
-rw-r--r--scripts/mod/modpost.c160
-rwxr-xr-xscripts/ver_linux4
-rw-r--r--security/selinux/ss/services.c6
-rw-r--r--security/selinux/xfrm.c3
-rw-r--r--sound/oss/Kconfig8
-rw-r--r--sound/oss/Makefile1
-rw-r--r--sound/oss/nec_vrc5477.c2060
-rw-r--r--sound/pci/bt87x.c2
-rw-r--r--sound/sh/aica.h2
-rw-r--r--sound/soc/pxa/pxa2xx-ac97.c4
1557 files changed, 37438 insertions, 75216 deletions
diff --git a/.gitignore b/.gitignore
index a232295b99ac..27c3e839b54e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
7# 7#
8.* 8.*
9*.o 9*.o
10*.o.*
10*.a 11*.a
11*.s 12*.s
12*.ko 13*.ko
diff --git a/CREDITS b/CREDITS
index 10c214dc95e7..832436e1dd91 100644
--- a/CREDITS
+++ b/CREDITS
@@ -966,6 +966,7 @@ N: Pekka Enberg
966E: penberg@cs.helsinki.fi 966E: penberg@cs.helsinki.fi
967W: http://www.cs.helsinki.fi/u/penberg/ 967W: http://www.cs.helsinki.fi/u/penberg/
968D: Various kernel hacks, fixes, and cleanups. 968D: Various kernel hacks, fixes, and cleanups.
969D: Slab allocators
969S: Finland 970S: Finland
970 971
971N: David Engebretsen 972N: David Engebretsen
@@ -1939,8 +1940,8 @@ D: for Menuconfig's lxdialog.
1939N: Christoph Lameter 1940N: Christoph Lameter
1940E: christoph@lameter.com 1941E: christoph@lameter.com
1941D: Digiboard PC/Xe and PC/Xi, Digiboard EPCA 1942D: Digiboard PC/Xe and PC/Xi, Digiboard EPCA
1942D: Early protocol filter for bridging code 1943D: NUMA support, Slab allocators, Page migration
1943D: Bug fixes 1944D: Scalability, Time subsystem
1944 1945
1945N: Paul Laufer 1946N: Paul Laufer
1946E: paul@laufernet.com 1947E: paul@laufernet.com
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 805db4b2cba6..cc7a8c39fb6f 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -26,7 +26,7 @@ Part Ia - Using large dma-coherent buffers
26 26
27void * 27void *
28dma_alloc_coherent(struct device *dev, size_t size, 28dma_alloc_coherent(struct device *dev, size_t size,
29 dma_addr_t *dma_handle, int flag) 29 dma_addr_t *dma_handle, gfp_t flag)
30void * 30void *
31pci_alloc_consistent(struct pci_dev *dev, size_t size, 31pci_alloc_consistent(struct pci_dev *dev, size_t size,
32 dma_addr_t *dma_handle) 32 dma_addr_t *dma_handle)
@@ -38,7 +38,7 @@ to make sure to flush the processor's write buffers before telling
38devices to read that memory.) 38devices to read that memory.)
39 39
40This routine allocates a region of <size> bytes of consistent memory. 40This routine allocates a region of <size> bytes of consistent memory.
41it also returns a <dma_handle> which may be cast to an unsigned 41It also returns a <dma_handle> which may be cast to an unsigned
42integer the same width as the bus and used as the physical address 42integer the same width as the bus and used as the physical address
43base of the region. 43base of the region.
44 44
@@ -52,21 +52,21 @@ The simplest way to do that is to use the dma_pool calls (see below).
52 52
53The flag parameter (dma_alloc_coherent only) allows the caller to 53The flag parameter (dma_alloc_coherent only) allows the caller to
54specify the GFP_ flags (see kmalloc) for the allocation (the 54specify the GFP_ flags (see kmalloc) for the allocation (the
55implementation may chose to ignore flags that affect the location of 55implementation may choose to ignore flags that affect the location of
56the returned memory, like GFP_DMA). For pci_alloc_consistent, you 56the returned memory, like GFP_DMA). For pci_alloc_consistent, you
57must assume GFP_ATOMIC behaviour. 57must assume GFP_ATOMIC behaviour.
58 58
59void 59void
60dma_free_coherent(struct device *dev, size_t size, void *cpu_addr 60dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
61 dma_addr_t dma_handle) 61 dma_addr_t dma_handle)
62void 62void
63pci_free_consistent(struct pci_dev *dev, size_t size, void *cpu_addr 63pci_free_consistent(struct pci_dev *dev, size_t size, void *cpu_addr,
64 dma_addr_t dma_handle) 64 dma_addr_t dma_handle)
65 65
66Free the region of consistent memory you previously allocated. dev, 66Free the region of consistent memory you previously allocated. dev,
67size and dma_handle must all be the same as those passed into the 67size and dma_handle must all be the same as those passed into the
68consistent allocate. cpu_addr must be the virtual address returned by 68consistent allocate. cpu_addr must be the virtual address returned by
69the consistent allocate 69the consistent allocate.
70 70
71 71
72Part Ib - Using small dma-coherent buffers 72Part Ib - Using small dma-coherent buffers
@@ -77,9 +77,9 @@ To get this part of the dma_ API, you must #include <linux/dmapool.h>
77Many drivers need lots of small dma-coherent memory regions for DMA 77Many drivers need lots of small dma-coherent memory regions for DMA
78descriptors or I/O buffers. Rather than allocating in units of a page 78descriptors or I/O buffers. Rather than allocating in units of a page
79or more using dma_alloc_coherent(), you can use DMA pools. These work 79or more using dma_alloc_coherent(), you can use DMA pools. These work
80much like a struct kmem_cache, except that they use the dma-coherent allocator 80much like a struct kmem_cache, except that they use the dma-coherent allocator,
81not __get_free_pages(). Also, they understand common hardware constraints 81not __get_free_pages(). Also, they understand common hardware constraints
82for alignment, like queue heads needing to be aligned on N byte boundaries. 82for alignment, like queue heads needing to be aligned on N-byte boundaries.
83 83
84 84
85 struct dma_pool * 85 struct dma_pool *
@@ -102,15 +102,15 @@ crossing restrictions, pass 0 for alloc; passing 4096 says memory allocated
102from this pool must not cross 4KByte boundaries. 102from this pool must not cross 4KByte boundaries.
103 103
104 104
105 void *dma_pool_alloc(struct dma_pool *pool, int gfp_flags, 105 void *dma_pool_alloc(struct dma_pool *pool, gfp_t gfp_flags,
106 dma_addr_t *dma_handle); 106 dma_addr_t *dma_handle);
107 107
108 void *pci_pool_alloc(struct pci_pool *pool, int gfp_flags, 108 void *pci_pool_alloc(struct pci_pool *pool, gfp_t gfp_flags,
109 dma_addr_t *dma_handle); 109 dma_addr_t *dma_handle);
110 110
111This allocates memory from the pool; the returned memory will meet the size 111This allocates memory from the pool; the returned memory will meet the size
112and alignment requirements specified at creation time. Pass GFP_ATOMIC to 112and alignment requirements specified at creation time. Pass GFP_ATOMIC to
113prevent blocking, or if it's permitted (not in_interrupt, not holding SMP locks) 113prevent blocking, or if it's permitted (not in_interrupt, not holding SMP locks),
114pass GFP_KERNEL to allow blocking. Like dma_alloc_coherent(), this returns 114pass GFP_KERNEL to allow blocking. Like dma_alloc_coherent(), this returns
115two values: an address usable by the cpu, and the dma address usable by the 115two values: an address usable by the cpu, and the dma address usable by the
116pool's device. 116pool's device.
@@ -123,7 +123,7 @@ pool's device.
123 dma_addr_t addr); 123 dma_addr_t addr);
124 124
125This puts memory back into the pool. The pool is what was passed to 125This puts memory back into the pool. The pool is what was passed to
126the pool allocation routine; the cpu and dma addresses are what 126the pool allocation routine; the cpu (vaddr) and dma addresses are what
127were returned when that routine allocated the memory being freed. 127were returned when that routine allocated the memory being freed.
128 128
129 129
@@ -209,18 +209,18 @@ Notes: Not all memory regions in a machine can be mapped by this
209API. Further, regions that appear to be physically contiguous in 209API. Further, regions that appear to be physically contiguous in
210kernel virtual space may not be contiguous as physical memory. Since 210kernel virtual space may not be contiguous as physical memory. Since
211this API does not provide any scatter/gather capability, it will fail 211this API does not provide any scatter/gather capability, it will fail
212if the user tries to map a non physically contiguous piece of memory. 212if the user tries to map a non-physically contiguous piece of memory.
213For this reason, it is recommended that memory mapped by this API be 213For this reason, it is recommended that memory mapped by this API be
214obtained only from sources which guarantee to be physically contiguous 214obtained only from sources which guarantee it to be physically contiguous
215(like kmalloc). 215(like kmalloc).
216 216
217Further, the physical address of the memory must be within the 217Further, the physical address of the memory must be within the
218dma_mask of the device (the dma_mask represents a bit mask of the 218dma_mask of the device (the dma_mask represents a bit mask of the
219addressable region for the device. i.e. if the physical address of 219addressable region for the device. I.e., if the physical address of
220the memory anded with the dma_mask is still equal to the physical 220the memory anded with the dma_mask is still equal to the physical
221address, then the device can perform DMA to the memory). In order to 221address, then the device can perform DMA to the memory). In order to
222ensure that the memory allocated by kmalloc is within the dma_mask, 222ensure that the memory allocated by kmalloc is within the dma_mask,
223the driver may specify various platform dependent flags to restrict 223the driver may specify various platform-dependent flags to restrict
224the physical memory range of the allocation (e.g. on x86, GFP_DMA 224the physical memory range of the allocation (e.g. on x86, GFP_DMA
225guarantees to be within the first 16Mb of available physical memory, 225guarantees to be within the first 16Mb of available physical memory,
226as required by ISA devices). 226as required by ISA devices).
@@ -244,14 +244,14 @@ are guaranteed also to be cache line boundaries).
244 244
245DMA_TO_DEVICE synchronisation must be done after the last modification 245DMA_TO_DEVICE synchronisation must be done after the last modification
246of the memory region by the software and before it is handed off to 246of the memory region by the software and before it is handed off to
247the driver. Once this primitive is used. Memory covered by this 247the driver. Once this primitive is used, memory covered by this
248primitive should be treated as read only by the device. If the device 248primitive should be treated as read-only by the device. If the device
249may write to it at any point, it should be DMA_BIDIRECTIONAL (see 249may write to it at any point, it should be DMA_BIDIRECTIONAL (see
250below). 250below).
251 251
252DMA_FROM_DEVICE synchronisation must be done before the driver 252DMA_FROM_DEVICE synchronisation must be done before the driver
253accesses data that may be changed by the device. This memory should 253accesses data that may be changed by the device. This memory should
254be treated as read only by the driver. If the driver needs to write 254be treated as read-only by the driver. If the driver needs to write
255to it at any point, it should be DMA_BIDIRECTIONAL (see below). 255to it at any point, it should be DMA_BIDIRECTIONAL (see below).
256 256
257DMA_BIDIRECTIONAL requires special handling: it means that the driver 257DMA_BIDIRECTIONAL requires special handling: it means that the driver
@@ -261,7 +261,7 @@ you must always sync bidirectional memory twice: once before the
261memory is handed off to the device (to make sure all memory changes 261memory is handed off to the device (to make sure all memory changes
262are flushed from the processor) and once before the data may be 262are flushed from the processor) and once before the data may be
263accessed after being used by the device (to make sure any processor 263accessed after being used by the device (to make sure any processor
264cache lines are updated with data that the device may have changed. 264cache lines are updated with data that the device may have changed).
265 265
266void 266void
267dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 267dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
@@ -302,8 +302,8 @@ pci_dma_mapping_error(dma_addr_t dma_addr)
302 302
303In some circumstances dma_map_single and dma_map_page will fail to create 303In some circumstances dma_map_single and dma_map_page will fail to create
304a mapping. A driver can check for these errors by testing the returned 304a mapping. A driver can check for these errors by testing the returned
305dma address with dma_mapping_error(). A non zero return value means the mapping 305dma address with dma_mapping_error(). A non-zero return value means the mapping
306could not be created and the driver should take appropriate action (eg 306could not be created and the driver should take appropriate action (e.g.
307reduce current DMA mapping usage or delay and try again later). 307reduce current DMA mapping usage or delay and try again later).
308 308
309 int 309 int
@@ -315,7 +315,7 @@ reduce current DMA mapping usage or delay and try again later).
315 315
316Maps a scatter gather list from the block layer. 316Maps a scatter gather list from the block layer.
317 317
318Returns: the number of physical segments mapped (this may be shorted 318Returns: the number of physical segments mapped (this may be shorter
319than <nents> passed in if the block layer determines that some 319than <nents> passed in if the block layer determines that some
320elements of the scatter/gather list are physically adjacent and thus 320elements of the scatter/gather list are physically adjacent and thus
321may be mapped with a single entry). 321may be mapped with a single entry).
@@ -357,7 +357,7 @@ accessed sg->address and sg->length as shown above.
357 pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, 357 pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg,
358 int nents, int direction) 358 int nents, int direction)
359 359
360unmap the previously mapped scatter/gather list. All the parameters 360Unmap the previously mapped scatter/gather list. All the parameters
361must be the same as those and passed in to the scatter/gather mapping 361must be the same as those and passed in to the scatter/gather mapping
362API. 362API.
363 363
@@ -377,7 +377,7 @@ void
377pci_dma_sync_sg(struct pci_dev *hwdev, struct scatterlist *sg, 377pci_dma_sync_sg(struct pci_dev *hwdev, struct scatterlist *sg,
378 int nelems, int direction) 378 int nelems, int direction)
379 379
380synchronise a single contiguous or scatter/gather mapping. All the 380Synchronise a single contiguous or scatter/gather mapping. All the
381parameters must be the same as those passed into the single mapping 381parameters must be the same as those passed into the single mapping
382API. 382API.
383 383
@@ -406,7 +406,7 @@ API at all.
406 406
407void * 407void *
408dma_alloc_noncoherent(struct device *dev, size_t size, 408dma_alloc_noncoherent(struct device *dev, size_t size,
409 dma_addr_t *dma_handle, int flag) 409 dma_addr_t *dma_handle, gfp_t flag)
410 410
411Identical to dma_alloc_coherent() except that the platform will 411Identical to dma_alloc_coherent() except that the platform will
412choose to return either consistent or non-consistent memory as it sees 412choose to return either consistent or non-consistent memory as it sees
@@ -426,34 +426,34 @@ void
426dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr, 426dma_free_noncoherent(struct device *dev, size_t size, void *cpu_addr,
427 dma_addr_t dma_handle) 427 dma_addr_t dma_handle)
428 428
429free memory allocated by the nonconsistent API. All parameters must 429Free memory allocated by the nonconsistent API. All parameters must
430be identical to those passed in (and returned by 430be identical to those passed in (and returned by
431dma_alloc_noncoherent()). 431dma_alloc_noncoherent()).
432 432
433int 433int
434dma_is_consistent(struct device *dev, dma_addr_t dma_handle) 434dma_is_consistent(struct device *dev, dma_addr_t dma_handle)
435 435
436returns true if the device dev is performing consistent DMA on the memory 436Returns true if the device dev is performing consistent DMA on the memory
437area pointed to by the dma_handle. 437area pointed to by the dma_handle.
438 438
439int 439int
440dma_get_cache_alignment(void) 440dma_get_cache_alignment(void)
441 441
442returns the processor cache alignment. This is the absolute minimum 442Returns the processor cache alignment. This is the absolute minimum
443alignment *and* width that you must observe when either mapping 443alignment *and* width that you must observe when either mapping
444memory or doing partial flushes. 444memory or doing partial flushes.
445 445
446Notes: This API may return a number *larger* than the actual cache 446Notes: This API may return a number *larger* than the actual cache
447line, but it will guarantee that one or more cache lines fit exactly 447line, but it will guarantee that one or more cache lines fit exactly
448into the width returned by this call. It will also always be a power 448into the width returned by this call. It will also always be a power
449of two for easy alignment 449of two for easy alignment.
450 450
451void 451void
452dma_sync_single_range(struct device *dev, dma_addr_t dma_handle, 452dma_sync_single_range(struct device *dev, dma_addr_t dma_handle,
453 unsigned long offset, size_t size, 453 unsigned long offset, size_t size,
454 enum dma_data_direction direction) 454 enum dma_data_direction direction)
455 455
456does a partial sync. starting at offset and continuing for size. You 456Does a partial sync, starting at offset and continuing for size. You
457must be careful to observe the cache alignment and width when doing 457must be careful to observe the cache alignment and width when doing
458anything like this. You must also be extra careful about accessing 458anything like this. You must also be extra careful about accessing
459memory you intend to sync partially. 459memory you intend to sync partially.
@@ -472,21 +472,20 @@ dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
472 dma_addr_t device_addr, size_t size, int 472 dma_addr_t device_addr, size_t size, int
473 flags) 473 flags)
474 474
475
476Declare region of memory to be handed out by dma_alloc_coherent when 475Declare region of memory to be handed out by dma_alloc_coherent when
477it's asked for coherent memory for this device. 476it's asked for coherent memory for this device.
478 477
479bus_addr is the physical address to which the memory is currently 478bus_addr is the physical address to which the memory is currently
480assigned in the bus responding region (this will be used by the 479assigned in the bus responding region (this will be used by the
481platform to perform the mapping) 480platform to perform the mapping).
482 481
483device_addr is the physical address the device needs to be programmed 482device_addr is the physical address the device needs to be programmed
484with actually to address this memory (this will be handed out as the 483with actually to address this memory (this will be handed out as the
485dma_addr_t in dma_alloc_coherent()) 484dma_addr_t in dma_alloc_coherent()).
486 485
487size is the size of the area (must be multiples of PAGE_SIZE). 486size is the size of the area (must be multiples of PAGE_SIZE).
488 487
489flags can be or'd together and are 488flags can be or'd together and are:
490 489
491DMA_MEMORY_MAP - request that the memory returned from 490DMA_MEMORY_MAP - request that the memory returned from
492dma_alloc_coherent() be directly writable. 491dma_alloc_coherent() be directly writable.
@@ -494,7 +493,7 @@ dma_alloc_coherent() be directly writable.
494DMA_MEMORY_IO - request that the memory returned from 493DMA_MEMORY_IO - request that the memory returned from
495dma_alloc_coherent() be addressable using read/write/memcpy_toio etc. 494dma_alloc_coherent() be addressable using read/write/memcpy_toio etc.
496 495
497One or both of these flags must be present 496One or both of these flags must be present.
498 497
499DMA_MEMORY_INCLUDES_CHILDREN - make the declared memory be allocated by 498DMA_MEMORY_INCLUDES_CHILDREN - make the declared memory be allocated by
500dma_alloc_coherent of any child devices of this one (for memory residing 499dma_alloc_coherent of any child devices of this one (for memory residing
@@ -528,7 +527,7 @@ dma_release_declared_memory(struct device *dev)
528Remove the memory region previously declared from the system. This 527Remove the memory region previously declared from the system. This
529API performs *no* in-use checking for this region and will return 528API performs *no* in-use checking for this region and will return
530unconditionally having removed all the required structures. It is the 529unconditionally having removed all the required structures. It is the
531drivers job to ensure that no parts of this memory region are 530driver's job to ensure that no parts of this memory region are
532currently in use. 531currently in use.
533 532
534void * 533void *
@@ -538,12 +537,10 @@ dma_mark_declared_memory_occupied(struct device *dev,
538This is used to occupy specific regions of the declared space 537This is used to occupy specific regions of the declared space
539(dma_alloc_coherent() will hand out the first free region it finds). 538(dma_alloc_coherent() will hand out the first free region it finds).
540 539
541device_addr is the *device* address of the region requested 540device_addr is the *device* address of the region requested.
542 541
543size is the size (and should be a page sized multiple). 542size is the size (and should be a page-sized multiple).
544 543
545The return value will be either a pointer to the processor virtual 544The return value will be either a pointer to the processor virtual
546address of the memory, or an error (via PTR_ERR()) if any part of the 545address of the memory, or an error (via PTR_ERR()) if any part of the
547region is occupied. 546region is occupied.
548
549
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index eb42bf9847cb..b886f52a9aac 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -380,7 +380,6 @@ X!Edrivers/base/interface.c
380!Edrivers/base/bus.c 380!Edrivers/base/bus.c
381 </sect1> 381 </sect1>
382 <sect1><title>Device Drivers Power Management</title> 382 <sect1><title>Device Drivers Power Management</title>
383!Edrivers/base/power/main.c
384!Edrivers/base/power/resume.c 383!Edrivers/base/power/resume.c
385!Edrivers/base/power/suspend.c 384!Edrivers/base/power/suspend.c
386 </sect1> 385 </sect1>
@@ -398,12 +397,12 @@ X!Edrivers/acpi/pci_bind.c
398--> 397-->
399 </sect1> 398 </sect1>
400 <sect1><title>Device drivers PnP support</title> 399 <sect1><title>Device drivers PnP support</title>
401!Edrivers/pnp/core.c 400!Idrivers/pnp/core.c
402<!-- No correct structured comments 401<!-- No correct structured comments
403X!Edrivers/pnp/system.c 402X!Edrivers/pnp/system.c
404 --> 403 -->
405!Edrivers/pnp/card.c 404!Edrivers/pnp/card.c
406!Edrivers/pnp/driver.c 405!Idrivers/pnp/driver.c
407!Edrivers/pnp/manager.c 406!Edrivers/pnp/manager.c
408!Edrivers/pnp/support.c 407!Edrivers/pnp/support.c
409 </sect1> 408 </sect1>
@@ -704,14 +703,22 @@ X!Idrivers/video/console/fonts.c
704 703
705 <chapter id="splice"> 704 <chapter id="splice">
706 <title>splice API</title> 705 <title>splice API</title>
707 <para>) 706 <para>
708 splice is a method for moving blocks of data around inside the 707 splice is a method for moving blocks of data around inside the
709 kernel, without continually transferring it between the kernel 708 kernel, without continually transferring them between the kernel
710 and user space. 709 and user space.
711 </para> 710 </para>
712!Iinclude/linux/splice.h
713!Ffs/splice.c 711!Ffs/splice.c
714 </chapter> 712 </chapter>
715 713
714 <chapter id="pipes">
715 <title>pipes API</title>
716 <para>
717 Pipe interfaces are all for in-kernel (builtin image) use.
718 They are not exported for use by modules.
719 </para>
720!Iinclude/linux/pipe_fs_i.h
721!Ffs/pipe.c
722 </chapter>
716 723
717</book> 724</book>
diff --git a/Documentation/block/barrier.txt b/Documentation/block/barrier.txt
index 7d279f2f5bb2..2c2f24f634e4 100644
--- a/Documentation/block/barrier.txt
+++ b/Documentation/block/barrier.txt
@@ -79,9 +79,9 @@ and how to prepare flush requests. Note that the term 'ordered' is
79used to indicate the whole sequence of performing barrier requests 79used to indicate the whole sequence of performing barrier requests
80including draining and flushing. 80including draining and flushing.
81 81
82typedef void (prepare_flush_fn)(request_queue_t *q, struct request *rq); 82typedef void (prepare_flush_fn)(struct request_queue *q, struct request *rq);
83 83
84int blk_queue_ordered(request_queue_t *q, unsigned ordered, 84int blk_queue_ordered(struct request_queue *q, unsigned ordered,
85 prepare_flush_fn *prepare_flush_fn); 85 prepare_flush_fn *prepare_flush_fn);
86 86
87@q : the queue in question 87@q : the queue in question
@@ -92,7 +92,7 @@ int blk_queue_ordered(request_queue_t *q, unsigned ordered,
92For example, SCSI disk driver's prepare_flush_fn looks like the 92For example, SCSI disk driver's prepare_flush_fn looks like the
93following. 93following.
94 94
95static void sd_prepare_flush(request_queue_t *q, struct request *rq) 95static void sd_prepare_flush(struct request_queue *q, struct request *rq)
96{ 96{
97 memset(rq->cmd, 0, sizeof(rq->cmd)); 97 memset(rq->cmd, 0, sizeof(rq->cmd));
98 rq->cmd_type = REQ_TYPE_BLOCK_PC; 98 rq->cmd_type = REQ_TYPE_BLOCK_PC;
diff --git a/Documentation/block/biodoc.txt b/Documentation/block/biodoc.txt
index 3adaace328a6..8af392fc6ef0 100644
--- a/Documentation/block/biodoc.txt
+++ b/Documentation/block/biodoc.txt
@@ -740,12 +740,12 @@ Block now offers some simple generic functionality to help support command
740queueing (typically known as tagged command queueing), ie manage more than 740queueing (typically known as tagged command queueing), ie manage more than
741one outstanding command on a queue at any given time. 741one outstanding command on a queue at any given time.
742 742
743 blk_queue_init_tags(request_queue_t *q, int depth) 743 blk_queue_init_tags(struct request_queue *q, int depth)
744 744
745 Initialize internal command tagging structures for a maximum 745 Initialize internal command tagging structures for a maximum
746 depth of 'depth'. 746 depth of 'depth'.
747 747
748 blk_queue_free_tags((request_queue_t *q) 748 blk_queue_free_tags((struct request_queue *q)
749 749
750 Teardown tag info associated with the queue. This will be done 750 Teardown tag info associated with the queue. This will be done
751 automatically by block if blk_queue_cleanup() is called on a queue 751 automatically by block if blk_queue_cleanup() is called on a queue
@@ -754,7 +754,7 @@ one outstanding command on a queue at any given time.
754The above are initialization and exit management, the main helpers during 754The above are initialization and exit management, the main helpers during
755normal operations are: 755normal operations are:
756 756
757 blk_queue_start_tag(request_queue_t *q, struct request *rq) 757 blk_queue_start_tag(struct request_queue *q, struct request *rq)
758 758
759 Start tagged operation for this request. A free tag number between 759 Start tagged operation for this request. A free tag number between
760 0 and 'depth' is assigned to the request (rq->tag holds this number), 760 0 and 'depth' is assigned to the request (rq->tag holds this number),
@@ -762,7 +762,7 @@ normal operations are:
762 for this queue is already achieved (or if the tag wasn't started for 762 for this queue is already achieved (or if the tag wasn't started for
763 some other reason), 1 is returned. Otherwise 0 is returned. 763 some other reason), 1 is returned. Otherwise 0 is returned.
764 764
765 blk_queue_end_tag(request_queue_t *q, struct request *rq) 765 blk_queue_end_tag(struct request_queue *q, struct request *rq)
766 766
767 End tagged operation on this request. 'rq' is removed from the internal 767 End tagged operation on this request. 'rq' is removed from the internal
768 book keeping structures. 768 book keeping structures.
@@ -781,7 +781,7 @@ queue. For instance, on IDE any tagged request error needs to clear both
781the hardware and software block queue and enable the driver to sanely restart 781the hardware and software block queue and enable the driver to sanely restart
782all the outstanding requests. There's a third helper to do that: 782all the outstanding requests. There's a third helper to do that:
783 783
784 blk_queue_invalidate_tags(request_queue_t *q) 784 blk_queue_invalidate_tags(struct request_queue *q)
785 785
786 Clear the internal block tag queue and re-add all the pending requests 786 Clear the internal block tag queue and re-add all the pending requests
787 to the request queue. The driver will receive them again on the 787 to the request queue. The driver will receive them again on the
diff --git a/Documentation/block/request.txt b/Documentation/block/request.txt
index 75924e2a6975..fff58acb40a3 100644
--- a/Documentation/block/request.txt
+++ b/Documentation/block/request.txt
@@ -83,6 +83,6 @@ struct bio *bio DBI First bio in request
83 83
84struct bio *biotail DBI Last bio in request 84struct bio *biotail DBI Last bio in request
85 85
86request_queue_t *q DB Request queue this request belongs to 86struct request_queue *q DB Request queue this request belongs to
87 87
88struct request_list *rl B Request list this request came from 88struct request_list *rl B Request list this request came from
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index 595a5ea4c690..7b9551fc6fe3 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -18,6 +18,7 @@
18*.moc 18*.moc
19*.mod.c 19*.mod.c
20*.o 20*.o
21*.o.*
21*.orig 22*.orig
22*.out 23*.out
23*.pdf 24*.pdf
@@ -163,6 +164,8 @@ raid6tables.c
163relocs 164relocs
164series 165series
165setup 166setup
167setup.bin
168setup.elf
166sim710_d.h* 169sim710_d.h*
167sImage 170sImage
168sm_tbl* 171sm_tbl*
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index c175eedadb5f..a43d2878a4ef 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -211,22 +211,6 @@ Who: Richard Purdie <rpurdie@rpsys.net>
211 211
212--------------------------- 212---------------------------
213 213
214What: read_dev_chars(), read_conf_data{,_lpm}() (s390 common I/O layer)
215When: December 2007
216Why: These functions are a leftover from 2.4 times. They have several
217 problems:
218 - Duplication of checks that are done in the device driver's
219 interrupt handler
220 - common I/O layer can't do device specific error recovery
221 - device driver can't be notified for conditions happening during
222 execution of the function
223 Device drivers should issue the read device characteristics and read
224 configuration data ccws and do the appropriate error handling
225 themselves.
226Who: Cornelia Huck <cornelia.huck@de.ibm.com>
227
228---------------------------
229
230What: i2c-ixp2000, i2c-ixp4xx and scx200_i2c drivers 214What: i2c-ixp2000, i2c-ixp4xx and scx200_i2c drivers
231When: September 2007 215When: September 2007
232Why: Obsolete. The new i2c-gpio driver replaces all hardware-specific 216Why: Obsolete. The new i2c-gpio driver replaces all hardware-specific
diff --git a/Documentation/filesystems/hfsplus.txt b/Documentation/filesystems/hfsplus.txt
new file mode 100644
index 000000000000..af1628a1061c
--- /dev/null
+++ b/Documentation/filesystems/hfsplus.txt
@@ -0,0 +1,59 @@
1
2Macintosh HFSPlus Filesystem for Linux
3======================================
4
5HFSPlus is a filesystem first introduced in MacOS 8.1.
6HFSPlus has several extensions to HFS, including 32-bit allocation
7blocks, 255-character unicode filenames, and file sizes of 2^63 bytes.
8
9
10Mount options
11=============
12
13When mounting an HFSPlus filesystem, the following options are accepted:
14
15 creator=cccc, type=cccc
16 Specifies the creator/type values as shown by the MacOS finder
17 used for creating new files. Default values: '????'.
18
19 uid=n, gid=n
20 Specifies the user/group that owns all files on the filesystem
21 that have uninitialized permissions structures.
22 Default: user/group id of the mounting process.
23
24 umask=n
25 Specifies the umask (in octal) used for files and directories
26 that have uninitialized permissions structures.
27 Default: umask of the mounting process.
28
29 session=n
30 Select the CDROM session to mount as HFSPlus filesystem. Defaults to
31 leaving that decision to the CDROM driver. This option will fail
32 with anything but a CDROM as underlying devices.
33
34 part=n
35 Select partition number n from the devices. This option only makes
36 sense for CDROMs because they can't be partitioned under Linux.
37 For disk devices the generic partition parsing code does this
38 for us. Defaults to not parsing the partition table at all.
39
40 decompose
41 Decompose file name characters.
42
43 nodecompose
44 Do not decompose file name characters.
45
46 force
47 Used to force write access to volumes that are marked as journalled
48 or locked. Use at your own risk.
49
50 nls=cccc
51 Encoding to use when presenting file names.
52
53
54References
55==========
56
57kernel source: <file:fs/hfsplus>
58
59Apple Technote 1150 http://developer.apple.com/technotes/tn/tn1150.html
diff --git a/Documentation/gpio.txt b/Documentation/gpio.txt
index 218a8650f48d..6bc2ba215df9 100644
--- a/Documentation/gpio.txt
+++ b/Documentation/gpio.txt
@@ -148,7 +148,7 @@ pin ... that won't always match the specified output value, because of
148issues including wire-OR and output latencies. 148issues including wire-OR and output latencies.
149 149
150The get/set calls have no error returns because "invalid GPIO" should have 150The get/set calls have no error returns because "invalid GPIO" should have
151been reported earlier in gpio_set_direction(). However, note that not all 151been reported earlier from gpio_direction_*(). However, note that not all
152platforms can read the value of output pins; those that can't should always 152platforms can read the value of output pins; those that can't should always
153return zero. Also, using these calls for GPIOs that can't safely be accessed 153return zero. Also, using these calls for GPIOs that can't safely be accessed
154without sleeping (see below) is an error. 154without sleeping (see below) is an error.
@@ -239,7 +239,7 @@ map between them using calls like:
239Those return either the corresponding number in the other namespace, or 239Those return either the corresponding number in the other namespace, or
240else a negative errno code if the mapping can't be done. (For example, 240else a negative errno code if the mapping can't be done. (For example,
241some GPIOs can't used as IRQs.) It is an unchecked error to use a GPIO 241some GPIOs can't used as IRQs.) It is an unchecked error to use a GPIO
242number that hasn't been marked as an input using gpio_set_direction(), or 242number that wasn't set up as an input using gpio_direction_input(), or
243to use an IRQ number that didn't originally come from gpio_to_irq(). 243to use an IRQ number that didn't originally come from gpio_to_irq().
244 244
245These two mapping calls are expected to cost on the order of a single 245These two mapping calls are expected to cost on the order of a single
diff --git a/Documentation/hpet.txt b/Documentation/hpet.txt
index b7a3dc38dd52..6ad52d9dad6c 100644
--- a/Documentation/hpet.txt
+++ b/Documentation/hpet.txt
@@ -5,7 +5,7 @@ for the 8254 and Real Time Clock (RTC) periodic timer functionality.
5Each HPET can have up to 32 timers. It is possible to configure the 5Each HPET can have up to 32 timers. It is possible to configure the
6first two timers as legacy replacements for 8254 and RTC periodic timers. 6first two timers as legacy replacements for 8254 and RTC periodic timers.
7A specification done by Intel and Microsoft can be found at 7A specification done by Intel and Microsoft can be found at
8<http://www.intel.com/hardwaredesign/hpetspec.htm>. 8<http://www.intel.com/technology/architecture/hpetspec.htm>.
9 9
10The driver supports detection of HPET driver allocation and initialization 10The driver supports detection of HPET driver allocation and initialization
11of the HPET before the driver module_init routine is called. This enables 11of the HPET before the driver module_init routine is called. This enables
diff --git a/Documentation/hwmon/adm1031 b/Documentation/hwmon/adm1031
index 130a38382b98..be92a77da1d5 100644
--- a/Documentation/hwmon/adm1031
+++ b/Documentation/hwmon/adm1031
@@ -6,13 +6,13 @@ Supported chips:
6 Prefix: 'adm1030' 6 Prefix: 'adm1030'
7 Addresses scanned: I2C 0x2c to 0x2e 7 Addresses scanned: I2C 0x2c to 0x2e
8 Datasheet: Publicly available at the Analog Devices website 8 Datasheet: Publicly available at the Analog Devices website
9 http://products.analog.com/products/info.asp?product=ADM1030 9 http://www.analog.com/en/prod/0%2C2877%2CADM1030%2C00.html
10 10
11 * Analog Devices ADM1031 11 * Analog Devices ADM1031
12 Prefix: 'adm1031' 12 Prefix: 'adm1031'
13 Addresses scanned: I2C 0x2c to 0x2e 13 Addresses scanned: I2C 0x2c to 0x2e
14 Datasheet: Publicly available at the Analog Devices website 14 Datasheet: Publicly available at the Analog Devices website
15 http://products.analog.com/products/info.asp?product=ADM1031 15 http://www.analog.com/en/prod/0%2C2877%2CADM1031%2C00.html
16 16
17Authors: 17Authors:
18 Alexandre d'Alton <alex@alexdalton.org> 18 Alexandre d'Alton <alex@alexdalton.org>
diff --git a/Documentation/hwmon/thmc50 b/Documentation/hwmon/thmc50
new file mode 100644
index 000000000000..9639ca93d559
--- /dev/null
+++ b/Documentation/hwmon/thmc50
@@ -0,0 +1,74 @@
1Kernel driver thmc50
2=====================
3
4Supported chips:
5 * Analog Devices ADM1022
6 Prefix: 'adm1022'
7 Addresses scanned: I2C 0x2c - 0x2e
8 Datasheet: http://www.analog.com/en/prod/0,2877,ADM1022,00.html
9 * Texas Instruments THMC50
10 Prefix: 'thmc50'
11 Addresses scanned: I2C 0x2c - 0x2e
12 Datasheet: http://focus.ti.com/docs/prod/folders/print/thmc50.html
13
14Author: Krzysztof Helt <krzysztof.h1@wp.pl>
15
16This driver was derived from the 2.4 kernel thmc50.c source file.
17
18Credits:
19 thmc50.c (2.4 kernel):
20 Frodo Looijaard <frodol@dds.nl>
21 Philip Edelbrock <phil@netroedge.com>
22
23Module Parameters
24-----------------
25
26* adm1022_temp3: short array
27 List of adapter,address pairs to force chips into ADM1022 mode with
28 second remote temperature. This does not work for original THMC50 chips.
29
30Description
31-----------
32
33The THMC50 implements: an internal temperature sensor, support for an
34external diode-type temperature sensor (compatible w/ the diode sensor inside
35many processors), and a controllable fan/analog_out DAC. For the temperature
36sensors, limits can be set through the appropriate Overtemperature Shutdown
37register and Hysteresis register. Each value can be set and read to half-degree
38accuracy. An alarm is issued (usually to a connected LM78) when the
39temperature gets higher then the Overtemperature Shutdown value; it stays on
40until the temperature falls below the Hysteresis value. All temperatures are in
41degrees Celsius, and are guaranteed within a range of -55 to +125 degrees.
42
43The THMC50 only updates its values each 1.5 seconds; reading it more often
44will do no harm, but will return 'old' values.
45
46The THMC50 is usually used in combination with LM78-like chips, to measure
47the temperature of the processor(s).
48
49The ADM1022 works the same as THMC50 but it is faster (5 Hz instead of
501 Hz for THMC50). It can be also put in a new mode to handle additional
51remote temperature sensor. The driver use the mode set by BIOS by default.
52
53In case the BIOS is broken and the mode is set incorrectly, you can force
54the mode with additional remote temperature with adm1022_temp3 parameter.
55A typical symptom of wrong setting is a fan forced to full speed.
56
57Driver Features
58---------------
59
60The driver provides up to three temperatures:
61
62temp1 -- internal
63temp2 -- remote
64temp3 -- 2nd remote only for ADM1022
65
66pwm1 -- fan speed (0 = stop, 255 = full)
67pwm1_mode -- always 0 (DC mode)
68
69The value of 0 for pwm1 also forces FAN_OFF signal from the chip,
70so it stops fans even if the value 0 into the ANALOG_OUT register does not.
71
72The driver was tested on Compaq AP550 with two ADM1022 chips (one works
73in the temp3 mode), five temperature readings and two fans.
74
diff --git a/Documentation/iostats.txt b/Documentation/iostats.txt
index 09a1bafe2528..b963c3b4afa5 100644
--- a/Documentation/iostats.txt
+++ b/Documentation/iostats.txt
@@ -79,7 +79,7 @@ Field 8 -- # of milliseconds spent writing
79 measured from __make_request() to end_that_request_last()). 79 measured from __make_request() to end_that_request_last()).
80Field 9 -- # of I/Os currently in progress 80Field 9 -- # of I/Os currently in progress
81 The only field that should go to zero. Incremented as requests are 81 The only field that should go to zero. Incremented as requests are
82 given to appropriate request_queue_t and decremented as they finish. 82 given to appropriate struct request_queue and decremented as they finish.
83Field 10 -- # of milliseconds spent doing I/Os 83Field 10 -- # of milliseconds spent doing I/Os
84 This field is increases so long as field 9 is nonzero. 84 This field is increases so long as field 9 is nonzero.
85Field 11 -- weighted # of milliseconds spent doing I/Os 85Field 11 -- weighted # of milliseconds spent doing I/Os
diff --git a/Documentation/ja_JP/HOWTO b/Documentation/ja_JP/HOWTO
index b2446a090870..9f08dab1e75b 100644
--- a/Documentation/ja_JP/HOWTO
+++ b/Documentation/ja_JP/HOWTO
@@ -1,23 +1,24 @@
1NOTE: 1NOTE:
2This is Japanese translated version of "Documentation/HOWTO". 2This is a version of Documentation/HOWTO translated into Japanese.
3This one is maintained by Tsugikazu Shibata <tshibata@ab.jp.nec.com> 3This document is maintained by Tsugikazu Shibata <tshibata@ab.jp.nec.com>
4and JF Project team <www.linux.or.jp/JF>. 4and the JF Project team <www.linux.or.jp/JF>.
5If you find difference with original file or problem in translation, 5If you find any difference between this document and the original file
6please contact maintainer of this file or JF project. 6or a problem with the translation,
7 7please contact the maintainer of this file or JF project.
8Please also note that purpose of this file is easier to read for non 8
9English natives and not to be intended to fork. So, if you have any 9Please also note that the purpose of this file is to be easier to read
10comments or updates of this file, please try to update Original(English) 10for non English (read: Japanese) speakers and is not intended as a
11file at first. 11fork. So if you have any comments or updates for this file, please try
12 12to update the original English file first.
13Last Updated: 2007/06/04 13
14Last Updated: 2007/07/18
14================================== 15==================================
15ã“ã‚Œã¯ã€ 16ã“ã‚Œã¯ã€
16linux-2.6.21/Documentation/HOWTO 17linux-2.6.22/Documentation/HOWTO
17ã®å’Œè¨³ã§ã™ã€‚ 18ã®å’Œè¨³ã§ã™ã€‚
18 19
19翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ > 20翻訳団体: JF プロジェクト < http://www.linux.or.jp/JF/ >
20翻訳日: 2007/06/04 21翻訳日: 2007/07/16
21翻訳者: Tsugikazu Shibata <tshibata at ab dot jp dot nec dot com> 22翻訳者: Tsugikazu Shibata <tshibata at ab dot jp dot nec dot com>
22校正者: æ¾å€‰ã•ã‚“ <nbh--mats at nifty dot com> 23校正者: æ¾å€‰ã•ã‚“ <nbh--mats at nifty dot com>
23 å°æž— é›…å…¸ã•ã‚“ (Masanori Kobayasi) <zap03216 at nifty dot ne dot jp> 24 å°æž— é›…å…¸ã•ã‚“ (Masanori Kobayasi) <zap03216 at nifty dot ne dot jp>
@@ -52,6 +53,7 @@ Linux カーãƒãƒ«é–‹ç™ºã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£ã¨å…±ã«æ´»å‹•ã™ã‚‹ã‚„り方を学ã
52ã¾ãŸã€ã“ã®ã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£ãŒãªãœä»Šã†ã¾ãã¾ã‚ã£ã¦ã„ã‚‹ã®ã‹ã¨ã„ã†ç†ç”±ã®ä¸€éƒ¨ã‚‚ 53ã¾ãŸã€ã“ã®ã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£ãŒãªãœä»Šã†ã¾ãã¾ã‚ã£ã¦ã„ã‚‹ã®ã‹ã¨ã„ã†ç†ç”±ã®ä¸€éƒ¨ã‚‚
53説明ã—よã†ã¨è©¦ã¿ã¦ã„ã¾ã™ã€‚ 54説明ã—よã†ã¨è©¦ã¿ã¦ã„ã¾ã™ã€‚
54 55
56
55カーãƒãƒ«ã¯ å°‘é‡ã®ã‚¢ãƒ¼ã‚­ãƒ†ã‚¯ãƒãƒ£ä¾å­˜éƒ¨åˆ†ãŒã‚¢ã‚»ãƒ³ãƒ–リ言語ã§æ›¸ã‹ã‚Œã¦ã„ã‚‹ 57カーãƒãƒ«ã¯ å°‘é‡ã®ã‚¢ãƒ¼ã‚­ãƒ†ã‚¯ãƒãƒ£ä¾å­˜éƒ¨åˆ†ãŒã‚¢ã‚»ãƒ³ãƒ–リ言語ã§æ›¸ã‹ã‚Œã¦ã„ã‚‹
56以外ã¯å¤§éƒ¨åˆ†ã¯ C 言語ã§æ›¸ã‹ã‚Œã¦ã„ã¾ã™ã€‚C言語をよãç†è§£ã—ã¦ã„ã‚‹ã“ã¨ã¯ã‚«ãƒ¼ 58以外ã¯å¤§éƒ¨åˆ†ã¯ C 言語ã§æ›¸ã‹ã‚Œã¦ã„ã¾ã™ã€‚C言語をよãç†è§£ã—ã¦ã„ã‚‹ã“ã¨ã¯ã‚«ãƒ¼
57ãƒãƒ«é–‹ç™ºè€…ã«ã¯å¿…è¦ã§ã™ã€‚アーキテクãƒãƒ£å‘ã‘ã®ä½Žãƒ¬ãƒ™ãƒ«éƒ¨åˆ†ã®é–‹ç™ºã‚’ã™ã‚‹ã® 59ãƒãƒ«é–‹ç™ºè€…ã«ã¯å¿…è¦ã§ã™ã€‚アーキテクãƒãƒ£å‘ã‘ã®ä½Žãƒ¬ãƒ™ãƒ«éƒ¨åˆ†ã®é–‹ç™ºã‚’ã™ã‚‹ã®
@@ -141,6 +143,7 @@ Linux カーãƒãƒ«ã‚½ãƒ¼ã‚¹ãƒ„リーã¯å¹…広ã„範囲ã®ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆã‚’å
141 ã“れらã®ãƒ«ãƒ¼ãƒ«ã«å¾“ãˆã°ã†ã¾ãã„ãã“ã¨ã‚’ä¿è¨¼ã™ã‚‹ã“ã¨ã§ã¯ã‚ã‚Šã¾ã›ã‚“ 143 ã“れらã®ãƒ«ãƒ¼ãƒ«ã«å¾“ãˆã°ã†ã¾ãã„ãã“ã¨ã‚’ä¿è¨¼ã™ã‚‹ã“ã¨ã§ã¯ã‚ã‚Šã¾ã›ã‚“
142 ㌠(ã™ã¹ã¦ã®ãƒ‘ッãƒã¯å†…容ã¨ã‚¹ã‚¿ã‚¤ãƒ«ã«ã¤ã„ã¦ç²¾æŸ»ã‚’å—ã‘ã‚‹ã®ã§)〠144 ㌠(ã™ã¹ã¦ã®ãƒ‘ッãƒã¯å†…容ã¨ã‚¹ã‚¿ã‚¤ãƒ«ã«ã¤ã„ã¦ç²¾æŸ»ã‚’å—ã‘ã‚‹ã®ã§)ã€
143 ルールã«å¾“ã‚ãªã‘ã‚Œã°é–“é•ã„ãªãã†ã¾ãã„ã‹ãªã„ã§ã—ょã†ã€‚ 145 ルールã«å¾“ã‚ãªã‘ã‚Œã°é–“é•ã„ãªãã†ã¾ãã„ã‹ãªã„ã§ã—ょã†ã€‚
146
144 ã“ã®ä»–ã«ãƒ‘ッãƒã‚’作る方法ã«ã¤ã„ã¦ã®ã‚ˆãã§ããŸè¨˜è¿°ã¯- 147 ã“ã®ä»–ã«ãƒ‘ッãƒã‚’作る方法ã«ã¤ã„ã¦ã®ã‚ˆãã§ããŸè¨˜è¿°ã¯-
145 148
146 "The Perfect Patch" 149 "The Perfect Patch"
@@ -360,44 +363,42 @@ linux-kernel メーリングリストã§åŽé›†ã•ã‚ŒãŸå¤šæ•°ã®ãƒ‘ッãƒã¨åŒæ
360 363
361 git ツリー- 364 git ツリー-
362 - Kbuild ã®é–‹ç™ºãƒ„リーã€Sam Ravnborg <sam@ravnborg.org> 365 - Kbuild ã®é–‹ç™ºãƒ„リーã€Sam Ravnborg <sam@ravnborg.org>
363 kernel.org:/pub/scm/linux/kernel/git/sam/kbuild.git 366 git.kernel.org:/pub/scm/linux/kernel/git/sam/kbuild.git
364 367
365 - ACPI ã®é–‹ç™ºãƒ„リー〠Len Brown <len.brown@intel.com> 368 - ACPI ã®é–‹ç™ºãƒ„リー〠Len Brown <len.brown@intel.com>
366 kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git 369 git.kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git
367 370
368 - Block ã®é–‹ç™ºãƒ„リーã€Jens Axboe <axboe@suse.de> 371 - Block ã®é–‹ç™ºãƒ„リーã€Jens Axboe <axboe@suse.de>
369 kernel.org:/pub/scm/linux/kernel/git/axboe/linux-2.6-block.git 372 git.kernel.org:/pub/scm/linux/kernel/git/axboe/linux-2.6-block.git
370 373
371 - DRM ã®é–‹ç™ºãƒ„リーã€Dave Airlie <airlied@linux.ie> 374 - DRM ã®é–‹ç™ºãƒ„リーã€Dave Airlie <airlied@linux.ie>
372 kernel.org:/pub/scm/linux/kernel/git/airlied/drm-2.6.git 375 git.kernel.org:/pub/scm/linux/kernel/git/airlied/drm-2.6.git
373 376
374 - ia64 ã®é–‹ç™ºãƒ„リーã€Tony Luck <tony.luck@intel.com> 377 - ia64 ã®é–‹ç™ºãƒ„リーã€Tony Luck <tony.luck@intel.com>
375 kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6.git 378 git.kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6.git
376
377 - ieee1394 ã®é–‹ç™ºãƒ„リーã€Jody McIntyre <scjody@modernduck.com>
378 kernel.org:/pub/scm/linux/kernel/git/scjody/ieee1394.git
379 379
380 - infiniband, Roland Dreier <rolandd@cisco.com> 380 - infiniband, Roland Dreier <rolandd@cisco.com>
381 kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git 381 git.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git
382 382
383 - libata, Jeff Garzik <jgarzik@pobox.com> 383 - libata, Jeff Garzik <jgarzik@pobox.com>
384 kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git 384 git.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git
385 385
386 - ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯ãƒ‰ãƒ©ã‚¤ãƒ, Jeff Garzik <jgarzik@pobox.com> 386 - ãƒãƒƒãƒˆãƒ¯ãƒ¼ã‚¯ãƒ‰ãƒ©ã‚¤ãƒ, Jeff Garzik <jgarzik@pobox.com>
387 kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git 387 git.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6.git
388 388
389 - pcmcia, Dominik Brodowski <linux@dominikbrodowski.net> 389 - pcmcia, Dominik Brodowski <linux@dominikbrodowski.net>
390 kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git 390 git.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6.git
391 391
392 - SCSI, James Bottomley <James.Bottomley@SteelEye.com> 392 - SCSI, James Bottomley <James.Bottomley@SteelEye.com>
393 kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git 393 git.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6.git
394
395 ãã®ä»–ã® git カーãƒãƒ«ãƒ„リー㯠http://kernel.org/git ã«ä¸€è¦§è¡¨ãŒã‚ã‚Šã¾
396 ã™ã€‚
397 394
398 quilt ツリー- 395 quilt ツリー-
399 - USB, PCI ドライãƒã‚³ã‚¢ã¨ I2C, Greg Kroah-Hartman <gregkh@suse.de> 396 - USB, PCI ドライãƒã‚³ã‚¢ã¨ I2C, Greg Kroah-Hartman <gregkh@suse.de>
400 kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/ 397 kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
398 - x86-64 㨠i386 ã®ä»²é–“ Andi Kleen <ak@suse.de>
399
400 ãã®ä»–ã®ã‚«ãƒ¼ãƒãƒ«ãƒ„リー㯠http://git.kernel.org/ 㨠MAINTAINERS ファ
401 イルã«ä¸€è¦§è¡¨ãŒã‚ã‚Šã¾ã™ã€‚
401 402
402ãƒã‚°ãƒ¬ãƒãƒ¼ãƒˆ 403ãƒã‚°ãƒ¬ãƒãƒ¼ãƒˆ
403------------- 404-------------
@@ -508,6 +509,7 @@ MAINTAINERS ファイルã«ãƒªã‚¹ãƒˆãŒã‚ã‚Šã¾ã™ã®ã§å‚ç…§ã—ã¦ãã ã•ã
508ã›ã‚“*。å˜ã«è‡ªåˆ†ã®ãƒ‘ッãƒã«å¯¾ã—ã¦æŒ‡æ‘˜ã•ã‚ŒãŸå•é¡Œã‚’å…¨ã¦ä¿®æ­£ã—ã¦å†é€ã™ã‚Œã° 509ã›ã‚“*。å˜ã«è‡ªåˆ†ã®ãƒ‘ッãƒã«å¯¾ã—ã¦æŒ‡æ‘˜ã•ã‚ŒãŸå•é¡Œã‚’å…¨ã¦ä¿®æ­£ã—ã¦å†é€ã™ã‚Œã°
509ã„ã„ã®ã§ã™ã€‚ 510ã„ã„ã®ã§ã™ã€‚
510 511
512
511カーãƒãƒ«ã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£ã¨ä¼æ¥­çµ„ç¹”ã®ã¡ãŒã„ 513カーãƒãƒ«ã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£ã¨ä¼æ¥­çµ„ç¹”ã®ã¡ãŒã„
512----------------------------------------------------------------- 514-----------------------------------------------------------------
513 515
@@ -577,6 +579,7 @@ Linux カーãƒãƒ«ã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£ã¯ã€ä¸€åº¦ã«å¤§é‡ã®ã‚³ãƒ¼ãƒ‰ã®å¡Šã‚’å–
577 ã‹ã—ã€500è¡Œã®ãƒ‘ッãƒã¯ã€æ­£ã—ã„ã“ã¨ã‚’レビューã™ã‚‹ã®ã«æ•°æ™‚é–“ã‹ã‹ã‚‹ã‹ã‚‚ 579 ã‹ã—ã€500è¡Œã®ãƒ‘ッãƒã¯ã€æ­£ã—ã„ã“ã¨ã‚’レビューã™ã‚‹ã®ã«æ•°æ™‚é–“ã‹ã‹ã‚‹ã‹ã‚‚
578 ã—ã‚Œã¾ã›ã‚“(時間ã¯ãƒ‘ッãƒã®ã‚µã‚¤ã‚ºãªã©ã«ã‚ˆã‚ŠæŒ‡æ•°é–¢æ•°ã«æ¯”例ã—ã¦ã‹ã‹ã‚Šã¾ 580 ã—ã‚Œã¾ã›ã‚“(時間ã¯ãƒ‘ッãƒã®ã‚µã‚¤ã‚ºãªã©ã«ã‚ˆã‚ŠæŒ‡æ•°é–¢æ•°ã«æ¯”例ã—ã¦ã‹ã‹ã‚Šã¾
579 ã™) 581 ã™)
582
580 å°ã•ã„パッãƒã¯ä½•ã‹ã‚ã£ãŸã¨ãã«ãƒ‡ãƒãƒƒã‚°ã‚‚ã¨ã¦ã‚‚ç°¡å˜ã«ãªã‚Šã¾ã™ã€‚パッ 583 å°ã•ã„パッãƒã¯ä½•ã‹ã‚ã£ãŸã¨ãã«ãƒ‡ãƒãƒƒã‚°ã‚‚ã¨ã¦ã‚‚ç°¡å˜ã«ãªã‚Šã¾ã™ã€‚パッ
581 ãƒã‚’1個1個å–り除ãã®ã¯ã€ã¨ã¦ã‚‚大ããªãƒ‘ッãƒã‚’当ã¦ãŸå¾Œã«(ã‹ã¤ã€ä½•ã‹ãŠ 584 ãƒã‚’1個1個å–り除ãã®ã¯ã€ã¨ã¦ã‚‚大ããªãƒ‘ッãƒã‚’当ã¦ãŸå¾Œã«(ã‹ã¤ã€ä½•ã‹ãŠ
582 ã‹ã—ããªã£ãŸå¾Œã§)解剖ã™ã‚‹ã®ã«æ¯”ã¹ã‚Œã°ã¨ã¦ã‚‚ç°¡å˜ã§ã™ã€‚ 585 ã‹ã—ããªã£ãŸå¾Œã§)解剖ã™ã‚‹ã®ã«æ¯”ã¹ã‚Œã°ã¨ã¦ã‚‚ç°¡å˜ã§ã™ã€‚
@@ -591,6 +594,7 @@ Linux カーãƒãƒ«ã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£ã¯ã€ä¸€åº¦ã«å¤§é‡ã®ã‚³ãƒ¼ãƒ‰ã®å¡Šã‚’å–
591 ã†ã€‚先生ã¯ç°¡æ½”ãªæœ€é«˜ã®è§£ã‚’ã¿ãŸã„ã®ã§ã™ã€‚良ã„生徒ã¯ã“れを知ã£ã¦ 594 ã†ã€‚先生ã¯ç°¡æ½”ãªæœ€é«˜ã®è§£ã‚’ã¿ãŸã„ã®ã§ã™ã€‚良ã„生徒ã¯ã“れを知ã£ã¦
592 ãŠã‚Šã€ãã—ã¦æœ€çµ‚解ã®å‰ã®ä¸­é–“作業をæ出ã™ã‚‹ã“ã¨ã¯æ±ºã—ã¦ãªã„ã®ã§ 595 ãŠã‚Šã€ãã—ã¦æœ€çµ‚解ã®å‰ã®ä¸­é–“作業をæ出ã™ã‚‹ã“ã¨ã¯æ±ºã—ã¦ãªã„ã®ã§
593 ã™" 596 ã™"
597
594 カーãƒãƒ«é–‹ç™ºã§ã‚‚ã“ã‚Œã¯åŒã˜ã§ã™ã€‚メンテナーé”ã¨ãƒ¬ãƒ“ューアé”ã¯ã€ 598 カーãƒãƒ«é–‹ç™ºã§ã‚‚ã“ã‚Œã¯åŒã˜ã§ã™ã€‚メンテナーé”ã¨ãƒ¬ãƒ“ューアé”ã¯ã€
595 å•é¡Œã‚’解決ã™ã‚‹è§£ã®èƒŒå¾Œã«ãªã‚‹æ€è€ƒãƒ—ロセスをã¿ãŸã„ã¨ã¯æ€ã„ã¾ã›ã‚“。 599 å•é¡Œã‚’解決ã™ã‚‹è§£ã®èƒŒå¾Œã«ãªã‚‹æ€è€ƒãƒ—ロセスをã¿ãŸã„ã¨ã¯æ€ã„ã¾ã›ã‚“。
596 彼らã¯å˜ç´”ã§ã‚ã–ã‚„ã‹ãªè§£æ±ºæ–¹æ³•ã‚’ã¿ãŸã„ã®ã§ã™ã€‚ 600 彼らã¯å˜ç´”ã§ã‚ã–ã‚„ã‹ãªè§£æ±ºæ–¹æ³•ã‚’ã¿ãŸã„ã®ã§ã™ã€‚
diff --git a/Documentation/ja_JP/stable_api_nonsense.txt b/Documentation/ja_JP/stable_api_nonsense.txt
index b3f2b27f0881..7653b5cbfed2 100644
--- a/Documentation/ja_JP/stable_api_nonsense.txt
+++ b/Documentation/ja_JP/stable_api_nonsense.txt
@@ -1,17 +1,17 @@
1NOTE: 1NOTE:
2This is a Japanese translated version of 2This is a version of Documentation/stable_api_nonsense.txt into Japanese.
3"Documentation/stable_api_nonsense.txt". 3This document is maintained by IKEDA, Munehiro <m-ikeda@ds.jp.nec.com>
4This one is maintained by 4and the JF Project team <http://www.linux.or.jp/JF/>.
5IKEDA, Munehiro <m-ikeda@ds.jp.nec.com> 5If you find any difference between this document and the original file
6and JF Project team <http://www.linux.or.jp/JF/>. 6or a problem with the translation,
7If you find difference with original file or problem in translation,
8please contact the maintainer of this file or JF project. 7please contact the maintainer of this file or JF project.
9 8
10Please also note that purpose of this file is easier to read for non 9Please also note that the purpose of this file is to be easier to read
11English natives and not to be intended to fork. So, if you have any 10for non English (read: Japanese) speakers and is not intended as a
12comments or updates of this file, please try to update 11fork. So if you have any comments or updates of this file, please try
13Original(English) file at first. 12to update the original English file first.
14 13
14Last Updated: 2007/07/18
15================================== 15==================================
16ã“ã‚Œã¯ã€ 16ã“ã‚Œã¯ã€
17linux-2.6.22-rc4/Documentation/stable_api_nonsense.txt ã®å’Œè¨³ 17linux-2.6.22-rc4/Documentation/stable_api_nonsense.txt ã®å’Œè¨³
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index fb80e9ffea68..efdb42fd3fb8 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -30,6 +30,7 @@ the beginning of each description states the restrictions within which a
30parameter is applicable: 30parameter is applicable:
31 31
32 ACPI ACPI support is enabled. 32 ACPI ACPI support is enabled.
33 AGP AGP (Accelerated Graphics Port) is enabled.
33 ALSA ALSA sound support is enabled. 34 ALSA ALSA sound support is enabled.
34 APIC APIC support is enabled. 35 APIC APIC support is enabled.
35 APM Advanced Power Management support is enabled. 36 APM Advanced Power Management support is enabled.
@@ -40,7 +41,6 @@ parameter is applicable:
40 EIDE EIDE/ATAPI support is enabled. 41 EIDE EIDE/ATAPI support is enabled.
41 FB The frame buffer device is enabled. 42 FB The frame buffer device is enabled.
42 HW Appropriate hardware is enabled. 43 HW Appropriate hardware is enabled.
43 IA-32 IA-32 aka i386 architecture is enabled.
44 IA-64 IA-64 architecture is enabled. 44 IA-64 IA-64 architecture is enabled.
45 IOSCHED More than one I/O scheduler is enabled. 45 IOSCHED More than one I/O scheduler is enabled.
46 IP_PNP IP DHCP, BOOTP, or RARP is enabled. 46 IP_PNP IP DHCP, BOOTP, or RARP is enabled.
@@ -57,14 +57,14 @@ parameter is applicable:
57 MDA MDA console support is enabled. 57 MDA MDA console support is enabled.
58 MOUSE Appropriate mouse support is enabled. 58 MOUSE Appropriate mouse support is enabled.
59 MSI Message Signaled Interrupts (PCI). 59 MSI Message Signaled Interrupts (PCI).
60 MTD MTD support is enabled. 60 MTD MTD (Memory Technology Device) support is enabled.
61 NET Appropriate network support is enabled. 61 NET Appropriate network support is enabled.
62 NUMA NUMA support is enabled. 62 NUMA NUMA support is enabled.
63 GENERIC_TIME The generic timeofday code is enabled. 63 GENERIC_TIME The generic timeofday code is enabled.
64 NFS Appropriate NFS support is enabled. 64 NFS Appropriate NFS support is enabled.
65 OSS OSS sound support is enabled. 65 OSS OSS sound support is enabled.
66 PV_OPS A paravirtualized kernel 66 PV_OPS A paravirtualized kernel is enabled.
67 PARIDE The ParIDE subsystem is enabled. 67 PARIDE The ParIDE (parallel port IDE) subsystem is enabled.
68 PARISC The PA-RISC architecture is enabled. 68 PARISC The PA-RISC architecture is enabled.
69 PCI PCI bus support is enabled. 69 PCI PCI bus support is enabled.
70 PCMCIA The PCMCIA subsystem is enabled. 70 PCMCIA The PCMCIA subsystem is enabled.
@@ -91,6 +91,7 @@ parameter is applicable:
91 VT Virtual terminal support is enabled. 91 VT Virtual terminal support is enabled.
92 WDT Watchdog support is enabled. 92 WDT Watchdog support is enabled.
93 XT IBM PC/XT MFM hard disk support is enabled. 93 XT IBM PC/XT MFM hard disk support is enabled.
94 X86-32 X86-32, aka i386 architecture is enabled.
94 X86-64 X86-64 architecture is enabled. 95 X86-64 X86-64 architecture is enabled.
95 More X86-64 boot options can be found in 96 More X86-64 boot options can be found in
96 Documentation/x86_64/boot-options.txt . 97 Documentation/x86_64/boot-options.txt .
@@ -122,10 +123,6 @@ and is between 256 and 4096 characters. It is defined in the file
122./include/asm/setup.h as COMMAND_LINE_SIZE. 123./include/asm/setup.h as COMMAND_LINE_SIZE.
123 124
124 125
125 53c7xx= [HW,SCSI] Amiga SCSI controllers
126 See header of drivers/scsi/53c7xx.c.
127 See also Documentation/scsi/ncr53c7xx.txt.
128
129 acpi= [HW,ACPI,X86-64,i386] 126 acpi= [HW,ACPI,X86-64,i386]
130 Advanced Configuration and Power Interface 127 Advanced Configuration and Power Interface
131 Format: { force | off | ht | strict | noirq } 128 Format: { force | off | ht | strict | noirq }
@@ -222,11 +219,17 @@ and is between 256 and 4096 characters. It is defined in the file
222 219
223 acpi_fake_ecdt [HW,ACPI] Workaround failure due to BIOS lacking ECDT 220 acpi_fake_ecdt [HW,ACPI] Workaround failure due to BIOS lacking ECDT
224 221
225 acpi_pm_good [IA-32,X86-64] 222 acpi_pm_good [X86-32,X86-64]
226 Override the pmtimer bug detection: force the kernel 223 Override the pmtimer bug detection: force the kernel
227 to assume that this machine's pmtimer latches its value 224 to assume that this machine's pmtimer latches its value
228 and always returns good values. 225 and always returns good values.
229 226
227 agp= [AGP]
228 { off | try_unsupported }
229 off: disable AGP support
230 try_unsupported: try to drive unsupported chipsets
231 (may crash computer or cause data corruption)
232
230 enable_timer_pin_1 [i386,x86-64] 233 enable_timer_pin_1 [i386,x86-64]
231 Enable PIN 1 of APIC timer 234 Enable PIN 1 of APIC timer
232 Can be useful to work around chipset bugs 235 Can be useful to work around chipset bugs
@@ -279,7 +282,8 @@ and is between 256 and 4096 characters. It is defined in the file
279 not play well with APC CPU idle - disable it if you have 282 not play well with APC CPU idle - disable it if you have
280 APC and your system crashes randomly. 283 APC and your system crashes randomly.
281 284
282 apic= [APIC,i386] Change the output verbosity whilst booting 285 apic= [APIC,i386] Advanced Programmable Interrupt Controller
286 Change the output verbosity whilst booting
283 Format: { quiet (default) | verbose | debug } 287 Format: { quiet (default) | verbose | debug }
284 Change the amount of debugging information output 288 Change the amount of debugging information output
285 when initialising the APIC and IO-APIC components. 289 when initialising the APIC and IO-APIC components.
@@ -353,7 +357,7 @@ and is between 256 and 4096 characters. It is defined in the file
353 357
354 c101= [NET] Moxa C101 synchronous serial card 358 c101= [NET] Moxa C101 synchronous serial card
355 359
356 cachesize= [BUGS=IA-32] Override level 2 CPU cache size detection. 360 cachesize= [BUGS=X86-32] Override level 2 CPU cache size detection.
357 Sometimes CPU hardware bugs make them report the cache 361 Sometimes CPU hardware bugs make them report the cache
358 size incorrectly. The kernel will attempt work arounds 362 size incorrectly. The kernel will attempt work arounds
359 to fix known problems, but for some CPUs it is not 363 to fix known problems, but for some CPUs it is not
@@ -372,7 +376,7 @@ and is between 256 and 4096 characters. It is defined in the file
372 Value can be changed at runtime via 376 Value can be changed at runtime via
373 /selinux/checkreqprot. 377 /selinux/checkreqprot.
374 378
375 clock= [BUGS=IA-32, HW] gettimeofday clocksource override. 379 clock= [BUGS=X86-32, HW] gettimeofday clocksource override.
376 [Deprecated] 380 [Deprecated]
377 Forces specified clocksource (if available) to be used 381 Forces specified clocksource (if available) to be used
378 when calculating gettimeofday(). If specified 382 when calculating gettimeofday(). If specified
@@ -390,7 +394,7 @@ and is between 256 and 4096 characters. It is defined in the file
390 [ARM] imx_timer1,OSTS,netx_timer,mpu_timer2, 394 [ARM] imx_timer1,OSTS,netx_timer,mpu_timer2,
391 pxa_timer,timer3,32k_counter,timer0_1 395 pxa_timer,timer3,32k_counter,timer0_1
392 [AVR32] avr32 396 [AVR32] avr32
393 [IA-32] pit,hpet,tsc,vmi-timer; 397 [X86-32] pit,hpet,tsc,vmi-timer;
394 scx200_hrt on Geode; cyclone on IBM x440 398 scx200_hrt on Geode; cyclone on IBM x440
395 [MIPS] MIPS 399 [MIPS] MIPS
396 [PARISC] cr16 400 [PARISC] cr16
@@ -410,7 +414,7 @@ and is between 256 and 4096 characters. It is defined in the file
410 over the 8254 in addition to over the IO-APIC. The 414 over the 8254 in addition to over the IO-APIC. The
411 kernel tries to set a sensible default. 415 kernel tries to set a sensible default.
412 416
413 hpet= [IA-32,HPET] option to disable HPET and use PIT. 417 hpet= [X86-32,HPET] option to disable HPET and use PIT.
414 Format: disable 418 Format: disable
415 419
416 com20020= [HW,NET] ARCnet - COM20020 chipset 420 com20020= [HW,NET] ARCnet - COM20020 chipset
@@ -547,7 +551,7 @@ and is between 256 and 4096 characters. It is defined in the file
547 551
548 dtc3181e= [HW,SCSI] 552 dtc3181e= [HW,SCSI]
549 553
550 earlyprintk= [IA-32,X86-64,SH] 554 earlyprintk= [X86-32,X86-64,SH]
551 earlyprintk=vga 555 earlyprintk=vga
552 earlyprintk=serial[,ttySn[,baudrate]] 556 earlyprintk=serial[,ttySn[,baudrate]]
553 557
@@ -585,7 +589,7 @@ and is between 256 and 4096 characters. It is defined in the file
585 eisa_irq_edge= [PARISC,HW] 589 eisa_irq_edge= [PARISC,HW]
586 See header of drivers/parisc/eisa.c. 590 See header of drivers/parisc/eisa.c.
587 591
588 elanfreq= [IA-32] 592 elanfreq= [X86-32]
589 See comment before function elanfreq_setup() in 593 See comment before function elanfreq_setup() in
590 arch/i386/kernel/cpu/cpufreq/elanfreq.c. 594 arch/i386/kernel/cpu/cpufreq/elanfreq.c.
591 595
@@ -594,7 +598,7 @@ and is between 256 and 4096 characters. It is defined in the file
594 See Documentation/block/as-iosched.txt and 598 See Documentation/block/as-iosched.txt and
595 Documentation/block/deadline-iosched.txt for details. 599 Documentation/block/deadline-iosched.txt for details.
596 600
597 elfcorehdr= [IA-32, X86_64] 601 elfcorehdr= [X86-32, X86_64]
598 Specifies physical address of start of kernel core 602 Specifies physical address of start of kernel core
599 image elf header. Generally kexec loader will 603 image elf header. Generally kexec loader will
600 pass this option to capture kernel. 604 pass this option to capture kernel.
@@ -676,7 +680,7 @@ and is between 256 and 4096 characters. It is defined in the file
676 hisax= [HW,ISDN] 680 hisax= [HW,ISDN]
677 See Documentation/isdn/README.HiSax. 681 See Documentation/isdn/README.HiSax.
678 682
679 hugepages= [HW,IA-32,IA-64] Maximal number of HugeTLB pages. 683 hugepages= [HW,X86-32,IA-64] Maximal number of HugeTLB pages.
680 684
681 i8042.direct [HW] Put keyboard port into non-translated mode 685 i8042.direct [HW] Put keyboard port into non-translated mode
682 i8042.dumbkbd [HW] Pretend that controller can only read data from 686 i8042.dumbkbd [HW] Pretend that controller can only read data from
@@ -768,7 +772,8 @@ and is between 256 and 4096 characters. It is defined in the file
768 See Documentation/nfsroot.txt. 772 See Documentation/nfsroot.txt.
769 773
770 ip2= [HW] Set IO/IRQ pairs for up to 4 IntelliPort boards 774 ip2= [HW] Set IO/IRQ pairs for up to 4 IntelliPort boards
771 See comment before ip2_setup() in drivers/char/ip2.c. 775 See comment before ip2_setup() in
776 drivers/char/ip2/ip2base.c.
772 777
773 ips= [HW,SCSI] Adaptec / IBM ServeRAID controller 778 ips= [HW,SCSI] Adaptec / IBM ServeRAID controller
774 See header of drivers/scsi/ips.c. 779 See header of drivers/scsi/ips.c.
@@ -817,7 +822,7 @@ and is between 256 and 4096 characters. It is defined in the file
817 js= [HW,JOY] Analog joystick 822 js= [HW,JOY] Analog joystick
818 See Documentation/input/joystick.txt. 823 See Documentation/input/joystick.txt.
819 824
820 kernelcore=nn[KMG] [KNL,IA-32,IA-64,PPC,X86-64] This parameter 825 kernelcore=nn[KMG] [KNL,X86-32,IA-64,PPC,X86-64] This parameter
821 specifies the amount of memory usable by the kernel 826 specifies the amount of memory usable by the kernel
822 for non-movable allocations. The requested amount is 827 for non-movable allocations. The requested amount is
823 spread evenly throughout all nodes in the system. The 828 spread evenly throughout all nodes in the system. The
@@ -833,7 +838,7 @@ and is between 256 and 4096 characters. It is defined in the file
833 use the HighMem zone if it exists, and the Normal 838 use the HighMem zone if it exists, and the Normal
834 zone if it does not. 839 zone if it does not.
835 840
836 movablecore=nn[KMG] [KNL,IA-32,IA-64,PPC,X86-64] This parameter 841 movablecore=nn[KMG] [KNL,X86-32,IA-64,PPC,X86-64] This parameter
837 is similar to kernelcore except it specifies the 842 is similar to kernelcore except it specifies the
838 amount of memory used for migratable allocations. 843 amount of memory used for migratable allocations.
839 If both kernelcore and movablecore is specified, 844 If both kernelcore and movablecore is specified,
@@ -845,28 +850,20 @@ and is between 256 and 4096 characters. It is defined in the file
845 850
846 keepinitrd [HW,ARM] 851 keepinitrd [HW,ARM]
847 852
848 kstack=N [IA-32,X86-64] Print N words from the kernel stack 853 kstack=N [X86-32,X86-64] Print N words from the kernel stack
849 in oops dumps. 854 in oops dumps.
850 855
851 l2cr= [PPC] 856 l2cr= [PPC]
852 857
853 lapic [IA-32,APIC] Enable the local APIC even if BIOS 858 lapic [X86-32,APIC] Enable the local APIC even if BIOS
854 disabled it. 859 disabled it.
855 860
856 lapic_timer_c2_ok [IA-32,x86-64,APIC] trust the local apic timer in 861 lapic_timer_c2_ok [X86-32,x86-64,APIC] trust the local apic timer in
857 C2 power state. 862 C2 power state.
858 863
859 lasi= [HW,SCSI] PARISC LASI driver for the 53c700 chip 864 lasi= [HW,SCSI] PARISC LASI driver for the 53c700 chip
860 Format: addr:<io>,irq:<irq> 865 Format: addr:<io>,irq:<irq>
861 866
862 legacy_serial.force [HW,IA-32,X86-64]
863 Probe for COM ports at legacy addresses even
864 if PNPBIOS or ACPI should describe them. This
865 is for working around firmware defects.
866
867 llsc*= [IA64] See function print_params() in
868 arch/ia64/sn/kernel/llsc4.c.
869
870 load_ramdisk= [RAM] List of ramdisks to load from floppy 867 load_ramdisk= [RAM] List of ramdisks to load from floppy
871 See Documentation/ramdisk.txt. 868 See Documentation/ramdisk.txt.
872 869
@@ -972,11 +969,11 @@ and is between 256 and 4096 characters. It is defined in the file
972 [SCSI] Maximum number of LUNs received. 969 [SCSI] Maximum number of LUNs received.
973 Should be between 1 and 16384. 970 Should be between 1 and 16384.
974 971
975 mca-pentium [BUGS=IA-32] 972 mca-pentium [BUGS=X86-32]
976 973
977 mcatest= [IA-64] 974 mcatest= [IA-64]
978 975
979 mce [IA-32] Machine Check Exception 976 mce [X86-32] Machine Check Exception
980 977
981 md= [HW] RAID subsystems devices and level 978 md= [HW] RAID subsystems devices and level
982 See Documentation/md.txt. 979 See Documentation/md.txt.
@@ -988,14 +985,14 @@ and is between 256 and 4096 characters. It is defined in the file
988 mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory 985 mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory
989 Amount of memory to be used when the kernel is not able 986 Amount of memory to be used when the kernel is not able
990 to see the whole system memory or for test. 987 to see the whole system memory or for test.
991 [IA-32] Use together with memmap= to avoid physical 988 [X86-32] Use together with memmap= to avoid physical
992 address space collisions. Without memmap= PCI devices 989 address space collisions. Without memmap= PCI devices
993 could be placed at addresses belonging to unused RAM. 990 could be placed at addresses belonging to unused RAM.
994 991
995 mem=nopentium [BUGS=IA-32] Disable usage of 4MB pages for kernel 992 mem=nopentium [BUGS=X86-32] Disable usage of 4MB pages for kernel
996 memory. 993 memory.
997 994
998 memmap=exactmap [KNL,IA-32,X86_64] Enable setting of an exact 995 memmap=exactmap [KNL,X86-32,X86_64] Enable setting of an exact
999 E820 memory map, as specified by the user. 996 E820 memory map, as specified by the user.
1000 Such memmap=exactmap lines can be constructed based on 997 Such memmap=exactmap lines can be constructed based on
1001 BIOS output or other requirements. See the memmap=nn@ss 998 BIOS output or other requirements. See the memmap=nn@ss
@@ -1039,7 +1036,7 @@ and is between 256 and 4096 characters. It is defined in the file
1039 <name>,<region-number>[,<base>,<size>,<buswidth>,<altbuswidth>] 1036 <name>,<region-number>[,<base>,<size>,<buswidth>,<altbuswidth>]
1040 1037
1041 mtdparts= [MTD] 1038 mtdparts= [MTD]
1042 See drivers/mtd/cmdline.c. 1039 See drivers/mtd/cmdlinepart.c.
1043 1040
1044 mtouchusb.raw_coordinates= 1041 mtouchusb.raw_coordinates=
1045 [HW] Make the MicroTouch USB driver use raw coordinates 1042 [HW] Make the MicroTouch USB driver use raw coordinates
@@ -1081,9 +1078,9 @@ and is between 256 and 4096 characters. It is defined in the file
1081 [NFS] set the maximum lifetime for idmapper cache 1078 [NFS] set the maximum lifetime for idmapper cache
1082 entries. 1079 entries.
1083 1080
1084 nmi_watchdog= [KNL,BUGS=IA-32] Debugging features for SMP kernels 1081 nmi_watchdog= [KNL,BUGS=X86-32] Debugging features for SMP kernels
1085 1082
1086 no387 [BUGS=IA-32] Tells the kernel to use the 387 maths 1083 no387 [BUGS=X86-32] Tells the kernel to use the 387 maths
1087 emulation library even if a 387 maths coprocessor 1084 emulation library even if a 387 maths coprocessor
1088 is present. 1085 is present.
1089 1086
@@ -1114,17 +1111,17 @@ and is between 256 and 4096 characters. It is defined in the file
1114 1111
1115 noexec [IA-64] 1112 noexec [IA-64]
1116 1113
1117 noexec [IA-32,X86-64] 1114 noexec [X86-32,X86-64]
1118 noexec=on: enable non-executable mappings (default) 1115 noexec=on: enable non-executable mappings (default)
1119 noexec=off: disable nn-executable mappings 1116 noexec=off: disable nn-executable mappings
1120 1117
1121 nofxsr [BUGS=IA-32] Disables x86 floating point extended 1118 nofxsr [BUGS=X86-32] Disables x86 floating point extended
1122 register save and restore. The kernel will only save 1119 register save and restore. The kernel will only save
1123 legacy floating-point registers on task switch. 1120 legacy floating-point registers on task switch.
1124 1121
1125 nohlt [BUGS=ARM] 1122 nohlt [BUGS=ARM]
1126 1123
1127 no-hlt [BUGS=IA-32] Tells the kernel that the hlt 1124 no-hlt [BUGS=X86-32] Tells the kernel that the hlt
1128 instruction doesn't work correctly and not to 1125 instruction doesn't work correctly and not to
1129 use it. 1126 use it.
1130 1127
@@ -1139,12 +1136,12 @@ and is between 256 and 4096 characters. It is defined in the file
1139 Valid arguments: on, off 1136 Valid arguments: on, off
1140 Default: on 1137 Default: on
1141 1138
1142 noirqbalance [IA-32,SMP,KNL] Disable kernel irq balancing 1139 noirqbalance [X86-32,SMP,KNL] Disable kernel irq balancing
1143 1140
1144 noirqdebug [IA-32] Disables the code which attempts to detect and 1141 noirqdebug [X86-32] Disables the code which attempts to detect and
1145 disable unhandled interrupt sources. 1142 disable unhandled interrupt sources.
1146 1143
1147 no_timer_check [IA-32,X86_64,APIC] Disables the code which tests for 1144 no_timer_check [X86-32,X86_64,APIC] Disables the code which tests for
1148 broken timer IRQ sources. 1145 broken timer IRQ sources.
1149 1146
1150 noisapnp [ISAPNP] Disables ISA PnP code. 1147 noisapnp [ISAPNP] Disables ISA PnP code.
@@ -1156,20 +1153,20 @@ and is between 256 and 4096 characters. It is defined in the file
1156 1153
1157 nojitter [IA64] Disables jitter checking for ITC timers. 1154 nojitter [IA64] Disables jitter checking for ITC timers.
1158 1155
1159 nolapic [IA-32,APIC] Do not enable or use the local APIC. 1156 nolapic [X86-32,APIC] Do not enable or use the local APIC.
1160 1157
1161 nolapic_timer [IA-32,APIC] Do not use the local APIC timer. 1158 nolapic_timer [X86-32,APIC] Do not use the local APIC timer.
1162 1159
1163 noltlbs [PPC] Do not use large page/tlb entries for kernel 1160 noltlbs [PPC] Do not use large page/tlb entries for kernel
1164 lowmem mapping on PPC40x. 1161 lowmem mapping on PPC40x.
1165 1162
1166 nomca [IA-64] Disable machine check abort handling 1163 nomca [IA-64] Disable machine check abort handling
1167 1164
1168 nomce [IA-32] Machine Check Exception 1165 nomce [X86-32] Machine Check Exception
1169 1166
1170 noreplace-paravirt [IA-32,PV_OPS] Don't patch paravirt_ops 1167 noreplace-paravirt [X86-32,PV_OPS] Don't patch paravirt_ops
1171 1168
1172 noreplace-smp [IA-32,SMP] Don't replace SMP instructions 1169 noreplace-smp [X86-32,SMP] Don't replace SMP instructions
1173 with UP alternatives 1170 with UP alternatives
1174 1171
1175 noresidual [PPC] Don't use residual data on PReP machines. 1172 noresidual [PPC] Don't use residual data on PReP machines.
@@ -1183,7 +1180,7 @@ and is between 256 and 4096 characters. It is defined in the file
1183 1180
1184 nosbagart [IA-64] 1181 nosbagart [IA-64]
1185 1182
1186 nosep [BUGS=IA-32] Disables x86 SYSENTER/SYSEXIT support. 1183 nosep [BUGS=X86-32] Disables x86 SYSENTER/SYSEXIT support.
1187 1184
1188 nosmp [SMP] Tells an SMP kernel to act as a UP kernel. 1185 nosmp [SMP] Tells an SMP kernel to act as a UP kernel.
1189 1186
@@ -1191,7 +1188,7 @@ and is between 256 and 4096 characters. It is defined in the file
1191 1188
1192 nosync [HW,M68K] Disables sync negotiation for all devices. 1189 nosync [HW,M68K] Disables sync negotiation for all devices.
1193 1190
1194 notsc [BUGS=IA-32] Disable Time Stamp Counter 1191 notsc [BUGS=X86-32] Disable Time Stamp Counter
1195 1192
1196 nousb [USB] Disable the USB subsystem 1193 nousb [USB] Disable the USB subsystem
1197 1194
@@ -1264,28 +1261,28 @@ and is between 256 and 4096 characters. It is defined in the file
1264 See also Documentation/paride.txt. 1261 See also Documentation/paride.txt.
1265 1262
1266 pci=option[,option...] [PCI] various PCI subsystem options: 1263 pci=option[,option...] [PCI] various PCI subsystem options:
1267 off [IA-32] don't probe for the PCI bus 1264 off [X86-32] don't probe for the PCI bus
1268 bios [IA-32] force use of PCI BIOS, don't access 1265 bios [X86-32] force use of PCI BIOS, don't access
1269 the hardware directly. Use this if your machine 1266 the hardware directly. Use this if your machine
1270 has a non-standard PCI host bridge. 1267 has a non-standard PCI host bridge.
1271 nobios [IA-32] disallow use of PCI BIOS, only direct 1268 nobios [X86-32] disallow use of PCI BIOS, only direct
1272 hardware access methods are allowed. Use this 1269 hardware access methods are allowed. Use this
1273 if you experience crashes upon bootup and you 1270 if you experience crashes upon bootup and you
1274 suspect they are caused by the BIOS. 1271 suspect they are caused by the BIOS.
1275 conf1 [IA-32] Force use of PCI Configuration 1272 conf1 [X86-32] Force use of PCI Configuration
1276 Mechanism 1. 1273 Mechanism 1.
1277 conf2 [IA-32] Force use of PCI Configuration 1274 conf2 [X86-32] Force use of PCI Configuration
1278 Mechanism 2. 1275 Mechanism 2.
1279 nommconf [IA-32,X86_64] Disable use of MMCONFIG for PCI 1276 nommconf [X86-32,X86_64] Disable use of MMCONFIG for PCI
1280 Configuration 1277 Configuration
1281 nomsi [MSI] If the PCI_MSI kernel config parameter is 1278 nomsi [MSI] If the PCI_MSI kernel config parameter is
1282 enabled, this kernel boot option can be used to 1279 enabled, this kernel boot option can be used to
1283 disable the use of MSI interrupts system-wide. 1280 disable the use of MSI interrupts system-wide.
1284 nosort [IA-32] Don't sort PCI devices according to 1281 nosort [X86-32] Don't sort PCI devices according to
1285 order given by the PCI BIOS. This sorting is 1282 order given by the PCI BIOS. This sorting is
1286 done to get a device order compatible with 1283 done to get a device order compatible with
1287 older kernels. 1284 older kernels.
1288 biosirq [IA-32] Use PCI BIOS calls to get the interrupt 1285 biosirq [X86-32] Use PCI BIOS calls to get the interrupt
1289 routing table. These calls are known to be buggy 1286 routing table. These calls are known to be buggy
1290 on several machines and they hang the machine 1287 on several machines and they hang the machine
1291 when used, but on other computers it's the only 1288 when used, but on other computers it's the only
@@ -1293,32 +1290,32 @@ and is between 256 and 4096 characters. It is defined in the file
1293 this option if the kernel is unable to allocate 1290 this option if the kernel is unable to allocate
1294 IRQs or discover secondary PCI buses on your 1291 IRQs or discover secondary PCI buses on your
1295 motherboard. 1292 motherboard.
1296 rom [IA-32] Assign address space to expansion ROMs. 1293 rom [X86-32] Assign address space to expansion ROMs.
1297 Use with caution as certain devices share 1294 Use with caution as certain devices share
1298 address decoders between ROMs and other 1295 address decoders between ROMs and other
1299 resources. 1296 resources.
1300 irqmask=0xMMMM [IA-32] Set a bit mask of IRQs allowed to be 1297 irqmask=0xMMMM [X86-32] Set a bit mask of IRQs allowed to be
1301 assigned automatically to PCI devices. You can 1298 assigned automatically to PCI devices. You can
1302 make the kernel exclude IRQs of your ISA cards 1299 make the kernel exclude IRQs of your ISA cards
1303 this way. 1300 this way.
1304 pirqaddr=0xAAAAA [IA-32] Specify the physical address 1301 pirqaddr=0xAAAAA [X86-32] Specify the physical address
1305 of the PIRQ table (normally generated 1302 of the PIRQ table (normally generated
1306 by the BIOS) if it is outside the 1303 by the BIOS) if it is outside the
1307 F0000h-100000h range. 1304 F0000h-100000h range.
1308 lastbus=N [IA-32] Scan all buses thru bus #N. Can be 1305 lastbus=N [X86-32] Scan all buses thru bus #N. Can be
1309 useful if the kernel is unable to find your 1306 useful if the kernel is unable to find your
1310 secondary buses and you want to tell it 1307 secondary buses and you want to tell it
1311 explicitly which ones they are. 1308 explicitly which ones they are.
1312 assign-busses [IA-32] Always assign all PCI bus 1309 assign-busses [X86-32] Always assign all PCI bus
1313 numbers ourselves, overriding 1310 numbers ourselves, overriding
1314 whatever the firmware may have done. 1311 whatever the firmware may have done.
1315 usepirqmask [IA-32] Honor the possible IRQ mask stored 1312 usepirqmask [X86-32] Honor the possible IRQ mask stored
1316 in the BIOS $PIR table. This is needed on 1313 in the BIOS $PIR table. This is needed on
1317 some systems with broken BIOSes, notably 1314 some systems with broken BIOSes, notably
1318 some HP Pavilion N5400 and Omnibook XE3 1315 some HP Pavilion N5400 and Omnibook XE3
1319 notebooks. This will have no effect if ACPI 1316 notebooks. This will have no effect if ACPI
1320 IRQ routing is enabled. 1317 IRQ routing is enabled.
1321 noacpi [IA-32] Do not use ACPI for IRQ routing 1318 noacpi [X86-32] Do not use ACPI for IRQ routing
1322 or for PCI scanning. 1319 or for PCI scanning.
1323 routeirq Do IRQ routing for all PCI devices. 1320 routeirq Do IRQ routing for all PCI devices.
1324 This is normally done in pci_enable_device(), 1321 This is normally done in pci_enable_device(),
@@ -1467,13 +1464,13 @@ and is between 256 and 4096 characters. It is defined in the file
1467 Run specified binary instead of /init from the ramdisk, 1464 Run specified binary instead of /init from the ramdisk,
1468 used for early userspace startup. See initrd. 1465 used for early userspace startup. See initrd.
1469 1466
1470 reboot= [BUGS=IA-32,BUGS=ARM,BUGS=IA-64] Rebooting mode 1467 reboot= [BUGS=X86-32,BUGS=ARM,BUGS=IA-64] Rebooting mode
1471 Format: <reboot_mode>[,<reboot_mode2>[,...]] 1468 Format: <reboot_mode>[,<reboot_mode2>[,...]]
1472 See arch/*/kernel/reboot.c or arch/*/kernel/process.c 1469 See arch/*/kernel/reboot.c or arch/*/kernel/process.c
1473 1470
1474 reserve= [KNL,BUGS] Force the kernel to ignore some iomem area 1471 reserve= [KNL,BUGS] Force the kernel to ignore some iomem area
1475 1472
1476 reservetop= [IA-32] 1473 reservetop= [X86-32]
1477 Format: nn[KMG] 1474 Format: nn[KMG]
1478 Reserves a hole at the top of the kernel virtual 1475 Reserves a hole at the top of the kernel virtual
1479 address space. 1476 address space.
@@ -1564,7 +1561,7 @@ and is between 256 and 4096 characters. It is defined in the file
1564 Value can be changed at runtime via 1561 Value can be changed at runtime via
1565 /selinux/compat_net. 1562 /selinux/compat_net.
1566 1563
1567 serialnumber [BUGS=IA-32] 1564 serialnumber [BUGS=X86-32]
1568 1565
1569 sg_def_reserved_size= [SCSI] 1566 sg_def_reserved_size= [SCSI]
1570 1567
@@ -1617,7 +1614,7 @@ and is between 256 and 4096 characters. It is defined in the file
1617 smart2= [HW] 1614 smart2= [HW]
1618 Format: <io1>[,<io2>[,...,<io8>]] 1615 Format: <io1>[,<io2>[,...,<io8>]]
1619 1616
1620 smp-alt-once [IA-32,SMP] On a hotplug CPU system, only 1617 smp-alt-once [X86-32,SMP] On a hotplug CPU system, only
1621 attempt to substitute SMP alternatives once at boot. 1618 attempt to substitute SMP alternatives once at boot.
1622 1619
1623 smsc-ircc2.nopnp [HW] Don't use PNP to discover SMC devices 1620 smsc-ircc2.nopnp [HW] Don't use PNP to discover SMC devices
@@ -1882,7 +1879,7 @@ and is between 256 and 4096 characters. It is defined in the file
1882 usbhid.mousepoll= 1879 usbhid.mousepoll=
1883 [USBHID] The interval which mice are to be polled at. 1880 [USBHID] The interval which mice are to be polled at.
1884 1881
1885 vdso= [IA-32,SH,x86-64] 1882 vdso= [X86-32,SH,x86-64]
1886 vdso=2: enable compat VDSO (default with COMPAT_VDSO) 1883 vdso=2: enable compat VDSO (default with COMPAT_VDSO)
1887 vdso=1: enable VDSO (default) 1884 vdso=1: enable VDSO (default)
1888 vdso=0: disable VDSO mapping 1885 vdso=0: disable VDSO mapping
@@ -1893,7 +1890,7 @@ and is between 256 and 4096 characters. It is defined in the file
1893 video= [FB] Frame buffer configuration 1890 video= [FB] Frame buffer configuration
1894 See Documentation/fb/modedb.txt. 1891 See Documentation/fb/modedb.txt.
1895 1892
1896 vga= [BOOT,IA-32] Select a particular video mode 1893 vga= [BOOT,X86-32] Select a particular video mode
1897 See Documentation/i386/boot.txt and 1894 See Documentation/i386/boot.txt and
1898 Documentation/svga.txt. 1895 Documentation/svga.txt.
1899 Use vga=ask for menu. 1896 Use vga=ask for menu.
diff --git a/Documentation/keys.txt b/Documentation/keys.txt
index 81d9aa097298..947d57d53453 100644
--- a/Documentation/keys.txt
+++ b/Documentation/keys.txt
@@ -859,9 +859,8 @@ payload contents" for more information.
859 void unregister_key_type(struct key_type *type); 859 void unregister_key_type(struct key_type *type);
860 860
861 861
862Under some circumstances, it may be desirable to desirable to deal with a 862Under some circumstances, it may be desirable to deal with a bundle of keys.
863bundle of keys. The facility provides access to the keyring type for managing 863The facility provides access to the keyring type for managing such a bundle:
864such a bundle:
865 864
866 struct key_type key_type_keyring; 865 struct key_type key_type_keyring;
867 866
diff --git a/Documentation/kobject.txt b/Documentation/kobject.txt
index e44855513b3d..8ee49ee7c963 100644
--- a/Documentation/kobject.txt
+++ b/Documentation/kobject.txt
@@ -27,7 +27,6 @@ in detail, and briefly here:
27- kobjects a simple object. 27- kobjects a simple object.
28- kset a set of objects of a certain type. 28- kset a set of objects of a certain type.
29- ktype a set of helpers for objects of a common type. 29- ktype a set of helpers for objects of a common type.
30- subsystem a controlling object for a number of ksets.
31 30
32 31
33The kobject infrastructure maintains a close relationship with the 32The kobject infrastructure maintains a close relationship with the
@@ -54,13 +53,15 @@ embedded in larger data structures and replace fields they duplicate.
541.2 Definition 531.2 Definition
55 54
56struct kobject { 55struct kobject {
56 const char * k_name;
57 char name[KOBJ_NAME_LEN]; 57 char name[KOBJ_NAME_LEN];
58 atomic_t refcount; 58 struct kref kref;
59 struct list_head entry; 59 struct list_head entry;
60 struct kobject * parent; 60 struct kobject * parent;
61 struct kset * kset; 61 struct kset * kset;
62 struct kobj_type * ktype; 62 struct kobj_type * ktype;
63 struct dentry * dentry; 63 struct sysfs_dirent * sd;
64 wait_queue_head_t poll;
64}; 65};
65 66
66void kobject_init(struct kobject *); 67void kobject_init(struct kobject *);
@@ -137,8 +138,7 @@ If a kobject does not have a parent when it is registered, its parent
137becomes its dominant kset. 138becomes its dominant kset.
138 139
139If a kobject does not have a parent nor a dominant kset, its directory 140If a kobject does not have a parent nor a dominant kset, its directory
140is created at the top-level of the sysfs partition. This should only 141is created at the top-level of the sysfs partition.
141happen for kobjects that are embedded in a struct subsystem.
142 142
143 143
144 144
@@ -150,10 +150,10 @@ A kset is a set of kobjects that are embedded in the same type.
150 150
151 151
152struct kset { 152struct kset {
153 struct subsystem * subsys;
154 struct kobj_type * ktype; 153 struct kobj_type * ktype;
155 struct list_head list; 154 struct list_head list;
156 struct kobject kobj; 155 struct kobject kobj;
156 struct kset_uevent_ops * uevent_ops;
157}; 157};
158 158
159 159
@@ -169,8 +169,7 @@ struct kobject * kset_find_obj(struct kset *, char *);
169 169
170 170
171The type that the kobjects are embedded in is described by the ktype 171The type that the kobjects are embedded in is described by the ktype
172pointer. The subsystem that the kobject belongs to is pointed to by the 172pointer.
173subsys pointer.
174 173
175A kset contains a kobject itself, meaning that it may be registered in 174A kset contains a kobject itself, meaning that it may be registered in
176the kobject hierarchy and exported via sysfs. More importantly, the 175the kobject hierarchy and exported via sysfs. More importantly, the
@@ -209,6 +208,58 @@ the hierarchy.
209kset_find_obj() may be used to locate a kobject with a particular 208kset_find_obj() may be used to locate a kobject with a particular
210name. The kobject, if found, is returned. 209name. The kobject, if found, is returned.
211 210
211There are also some helper functions which names point to the formerly
212existing "struct subsystem", whose functions have been taken over by
213ksets.
214
215
216decl_subsys(name,type,uevent_ops)
217
218Declares a kset named '<name>_subsys' of type <type> with
219uevent_ops <uevent_ops>. For example,
220
221decl_subsys(devices, &ktype_device, &device_uevent_ops);
222
223is equivalent to doing:
224
225struct kset devices_subsys = {
226 .kobj = {
227 .name = "devices",
228 },
229 .ktype = &ktype_devices,
230 .uevent_ops = &device_uevent_ops,
231};
232
233
234The objects that are registered with a subsystem that use the
235subsystem's default list must have their kset ptr set properly. These
236objects may have embedded kobjects or ksets. The
237following helpers make setting the kset easier:
238
239
240kobj_set_kset_s(obj,subsys)
241
242- Assumes that obj->kobj exists, and is a struct kobject.
243- Sets the kset of that kobject to the kset <subsys>.
244
245
246kset_set_kset_s(obj,subsys)
247
248- Assumes that obj->kset exists, and is a struct kset.
249- Sets the kset of the embedded kobject to the kset <subsys>.
250
251subsys_set_kset(obj,subsys)
252
253- Assumes obj->subsys exists, and is a struct subsystem.
254- Sets obj->subsys.kset.kobj.kset to the subsystem's embedded kset.
255
256void subsystem_init(struct kset *s);
257int subsystem_register(struct kset *s);
258void subsystem_unregister(struct kset *s);
259struct kset *subsys_get(struct kset *s);
260void kset_put(struct kset *s);
261
262These are just wrappers around the respective kset_* functions.
212 263
2132.3 sysfs 2642.3 sysfs
214 265
@@ -254,114 +305,3 @@ Instances of struct kobj_type are not registered; only referenced by
254the kset. A kobj_type may be referenced by an arbitrary number of 305the kset. A kobj_type may be referenced by an arbitrary number of
255ksets, as there may be disparate sets of identical objects. 306ksets, as there may be disparate sets of identical objects.
256 307
257
258
2594. subsystems
260
2614.1 Description
262
263A subsystem represents a significant entity of code that maintains an
264arbitrary number of sets of objects of various types. Since the number
265of ksets and the type of objects they contain are variable, a
266generic representation of a subsystem is minimal.
267
268
269struct subsystem {
270 struct kset kset;
271 struct rw_semaphore rwsem;
272};
273
274int subsystem_register(struct subsystem *);
275void subsystem_unregister(struct subsystem *);
276
277struct subsystem * subsys_get(struct subsystem * s);
278void subsys_put(struct subsystem * s);
279
280
281A subsystem contains an embedded kset so:
282
283- It can be represented in the object hierarchy via the kset's
284 embedded kobject.
285
286- It can maintain a default list of objects of one type.
287
288Additional ksets may attach to the subsystem simply by referencing the
289subsystem before they are registered. (This one-way reference means
290that there is no way to determine the ksets that are attached to the
291subsystem.)
292
293All ksets that are attached to a subsystem share the subsystem's R/W
294semaphore.
295
296
2974.2 subsystem Programming Interface.
298
299The subsystem programming interface is simple and does not offer the
300flexibility that the kset and kobject programming interfaces do. They
301may be registered and unregistered, as well as reference counted. Each
302call forwards the calls to their embedded ksets (which forward the
303calls to their embedded kobjects).
304
305
3064.3 Helpers
307
308A number of macros are available to make dealing with subsystems and
309their embedded objects easier.
310
311
312decl_subsys(name,type)
313
314Declares a subsystem named '<name>_subsys', with an embedded kset of
315type <type>. For example,
316
317decl_subsys(devices,&ktype_devices);
318
319is equivalent to doing:
320
321struct subsystem device_subsys = {
322 .kset = {
323 .kobj = {
324 .name = "devices",
325 },
326 .ktype = &ktype_devices,
327 }
328};
329
330
331The objects that are registered with a subsystem that use the
332subsystem's default list must have their kset ptr set properly. These
333objects may have embedded kobjects, ksets, or other subsystems. The
334following helpers make setting the kset easier:
335
336
337kobj_set_kset_s(obj,subsys)
338
339- Assumes that obj->kobj exists, and is a struct kobject.
340- Sets the kset of that kobject to the subsystem's embedded kset.
341
342
343kset_set_kset_s(obj,subsys)
344
345- Assumes that obj->kset exists, and is a struct kset.
346- Sets the kset of the embedded kobject to the subsystem's
347 embedded kset.
348
349subsys_set_kset(obj,subsys)
350
351- Assumes obj->subsys exists, and is a struct subsystem.
352- Sets obj->subsys.kset.kobj.kset to the subsystem's embedded kset.
353
354
3554.4 sysfs
356
357subsystems are represented in sysfs via their embedded kobjects. They
358follow the same rules as previously mentioned with no exceptions. They
359typically receive a top-level directory in sysfs, except when their
360embedded kobject is part of another kset, or the parent of the
361embedded kobject is explicitly set.
362
363Note that the subsystem's embedded kset must be 'attached' to the
364subsystem itself in order to use its rwsem. This is done after
365kset_add() has been called. (Not before, because kset_add() uses its
366subsystem for a default parent if it doesn't already have one).
367
diff --git a/Documentation/lguest/Makefile b/Documentation/lguest/Makefile
index b9b9427376e9..31e794ef5f98 100644
--- a/Documentation/lguest/Makefile
+++ b/Documentation/lguest/Makefile
@@ -11,8 +11,7 @@ endif
11include $(KBUILD_OUTPUT)/.config 11include $(KBUILD_OUTPUT)/.config
12LGUEST_GUEST_TOP := ($(CONFIG_PAGE_OFFSET) - 0x08000000) 12LGUEST_GUEST_TOP := ($(CONFIG_PAGE_OFFSET) - 0x08000000)
13 13
14CFLAGS:=-Wall -Wmissing-declarations -Wmissing-prototypes -O3 \ 14CFLAGS:=-Wall -Wmissing-declarations -Wmissing-prototypes -O3 -Wl,-T,lguest.lds
15 -static -DLGUEST_GUEST_TOP="$(LGUEST_GUEST_TOP)" -Wl,-T,lguest.lds
16LDLIBS:=-lz 15LDLIBS:=-lz
17 16
18all: lguest.lds lguest 17all: lguest.lds lguest
diff --git a/Documentation/lguest/extract b/Documentation/lguest/extract
new file mode 100644
index 000000000000..7730bb6e4b94
--- /dev/null
+++ b/Documentation/lguest/extract
@@ -0,0 +1,58 @@
1#! /bin/sh
2
3set -e
4
5PREFIX=$1
6shift
7
8trap 'rm -r $TMPDIR' 0
9TMPDIR=`mktemp -d`
10
11exec 3>/dev/null
12for f; do
13 while IFS="
14" read -r LINE; do
15 case "$LINE" in
16 *$PREFIX:[0-9]*:\**)
17 NUM=`echo "$LINE" | sed "s/.*$PREFIX:\([0-9]*\).*/\1/"`
18 if [ -f $TMPDIR/$NUM ]; then
19 echo "$TMPDIR/$NUM already exits prior to $f"
20 exit 1
21 fi
22 exec 3>>$TMPDIR/$NUM
23 echo $f | sed 's,\.\./,,g' > $TMPDIR/.$NUM
24 /bin/echo "$LINE" | sed -e "s/$PREFIX:[0-9]*//" -e "s/:\*/*/" >&3
25 ;;
26 *$PREFIX:[0-9]*)
27 NUM=`echo "$LINE" | sed "s/.*$PREFIX:\([0-9]*\).*/\1/"`
28 if [ -f $TMPDIR/$NUM ]; then
29 echo "$TMPDIR/$NUM already exits prior to $f"
30 exit 1
31 fi
32 exec 3>>$TMPDIR/$NUM
33 echo $f | sed 's,\.\./,,g' > $TMPDIR/.$NUM
34 /bin/echo "$LINE" | sed "s/$PREFIX:[0-9]*//" >&3
35 ;;
36 *:\**)
37 /bin/echo "$LINE" | sed -e "s/:\*/*/" -e "s,/\*\*/,," >&3
38 echo >&3
39 exec 3>/dev/null
40 ;;
41 *)
42 /bin/echo "$LINE" >&3
43 ;;
44 esac
45 done < $f
46 echo >&3
47 exec 3>/dev/null
48done
49
50LASTFILE=""
51for f in $TMPDIR/*; do
52 if [ "$LASTFILE" != $(cat $TMPDIR/.$(basename $f) ) ]; then
53 LASTFILE=$(cat $TMPDIR/.$(basename $f) )
54 echo "[ $LASTFILE ]"
55 fi
56 cat $f
57done
58
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
index 1432b502a2d9..f7918401a007 100644
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -1,5 +1,10 @@
1/* Simple program to layout "physical" memory for new lguest guest. 1/*P:100 This is the Launcher code, a simple program which lays out the
2 * Linked high to avoid likely physical memory. */ 2 * "physical" memory for the new Guest by mapping the kernel image and the
3 * virtual devices, then reads repeatedly from /dev/lguest to run the Guest.
4 *
5 * The only trick: the Makefile links it at a high address so it will be clear
6 * of the guest memory region. It means that each Guest cannot have more than
7 * about 2.5G of memory on a normally configured Host. :*/
3#define _LARGEFILE64_SOURCE 8#define _LARGEFILE64_SOURCE
4#define _GNU_SOURCE 9#define _GNU_SOURCE
5#include <stdio.h> 10#include <stdio.h>
@@ -29,12 +34,20 @@
29#include <termios.h> 34#include <termios.h>
30#include <getopt.h> 35#include <getopt.h>
31#include <zlib.h> 36#include <zlib.h>
37/*L:110 We can ignore the 28 include files we need for this program, but I do
38 * want to draw attention to the use of kernel-style types.
39 *
40 * As Linus said, "C is a Spartan language, and so should your naming be." I
41 * like these abbreviations and the header we need uses them, so we define them
42 * here.
43 */
32typedef unsigned long long u64; 44typedef unsigned long long u64;
33typedef uint32_t u32; 45typedef uint32_t u32;
34typedef uint16_t u16; 46typedef uint16_t u16;
35typedef uint8_t u8; 47typedef uint8_t u8;
36#include "../../include/linux/lguest_launcher.h" 48#include "../../include/linux/lguest_launcher.h"
37#include "../../include/asm-i386/e820.h" 49#include "../../include/asm-i386/e820.h"
50/*:*/
38 51
39#define PAGE_PRESENT 0x7 /* Present, RW, Execute */ 52#define PAGE_PRESENT 0x7 /* Present, RW, Execute */
40#define NET_PEERNUM 1 53#define NET_PEERNUM 1
@@ -43,31 +56,52 @@ typedef uint8_t u8;
43#define SIOCBRADDIF 0x89a2 /* add interface to bridge */ 56#define SIOCBRADDIF 0x89a2 /* add interface to bridge */
44#endif 57#endif
45 58
59/*L:120 verbose is both a global flag and a macro. The C preprocessor allows
60 * this, and although I wouldn't recommend it, it works quite nicely here. */
46static bool verbose; 61static bool verbose;
47#define verbose(args...) \ 62#define verbose(args...) \
48 do { if (verbose) printf(args); } while(0) 63 do { if (verbose) printf(args); } while(0)
64/*:*/
65
66/* The pipe to send commands to the waker process */
49static int waker_fd; 67static int waker_fd;
68/* The top of guest physical memory. */
69static u32 top;
50 70
71/* This is our list of devices. */
51struct device_list 72struct device_list
52{ 73{
74 /* Summary information about the devices in our list: ready to pass to
75 * select() to ask which need servicing.*/
53 fd_set infds; 76 fd_set infds;
54 int max_infd; 77 int max_infd;
55 78
79 /* The descriptor page for the devices. */
80 struct lguest_device_desc *descs;
81
82 /* A single linked list of devices. */
56 struct device *dev; 83 struct device *dev;
84 /* ... And an end pointer so we can easily append new devices */
57 struct device **lastdev; 85 struct device **lastdev;
58}; 86};
59 87
88/* The device structure describes a single device. */
60struct device 89struct device
61{ 90{
91 /* The linked-list pointer. */
62 struct device *next; 92 struct device *next;
93 /* The descriptor for this device, as mapped into the Guest. */
63 struct lguest_device_desc *desc; 94 struct lguest_device_desc *desc;
95 /* The memory page(s) of this device, if any. Also mapped in Guest. */
64 void *mem; 96 void *mem;
65 97
66 /* Watch this fd if handle_input non-NULL. */ 98 /* If handle_input is set, it wants to be called when this file
99 * descriptor is ready. */
67 int fd; 100 int fd;
68 bool (*handle_input)(int fd, struct device *me); 101 bool (*handle_input)(int fd, struct device *me);
69 102
70 /* Watch DMA to this key if handle_input non-NULL. */ 103 /* If handle_output is set, it wants to be called when the Guest sends
104 * DMA to this key. */
71 unsigned long watch_key; 105 unsigned long watch_key;
72 u32 (*handle_output)(int fd, const struct iovec *iov, 106 u32 (*handle_output)(int fd, const struct iovec *iov,
73 unsigned int num, struct device *me); 107 unsigned int num, struct device *me);
@@ -76,6 +110,11 @@ struct device
76 void *priv; 110 void *priv;
77}; 111};
78 112
113/*L:130
114 * Loading the Kernel.
115 *
116 * We start with couple of simple helper routines. open_or_die() avoids
117 * error-checking code cluttering the callers: */
79static int open_or_die(const char *name, int flags) 118static int open_or_die(const char *name, int flags)
80{ 119{
81 int fd = open(name, flags); 120 int fd = open(name, flags);
@@ -84,26 +123,38 @@ static int open_or_die(const char *name, int flags)
84 return fd; 123 return fd;
85} 124}
86 125
126/* map_zeroed_pages() takes a (page-aligned) address and a number of pages. */
87static void *map_zeroed_pages(unsigned long addr, unsigned int num) 127static void *map_zeroed_pages(unsigned long addr, unsigned int num)
88{ 128{
129 /* We cache the /dev/zero file-descriptor so we only open it once. */
89 static int fd = -1; 130 static int fd = -1;
90 131
91 if (fd == -1) 132 if (fd == -1)
92 fd = open_or_die("/dev/zero", O_RDONLY); 133 fd = open_or_die("/dev/zero", O_RDONLY);
93 134
135 /* We use a private mapping (ie. if we write to the page, it will be
136 * copied), and obviously we insist that it be mapped where we ask. */
94 if (mmap((void *)addr, getpagesize() * num, 137 if (mmap((void *)addr, getpagesize() * num,
95 PROT_READ|PROT_WRITE|PROT_EXEC, MAP_FIXED|MAP_PRIVATE, fd, 0) 138 PROT_READ|PROT_WRITE|PROT_EXEC, MAP_FIXED|MAP_PRIVATE, fd, 0)
96 != (void *)addr) 139 != (void *)addr)
97 err(1, "Mmaping %u pages of /dev/zero @%p", num, (void *)addr); 140 err(1, "Mmaping %u pages of /dev/zero @%p", num, (void *)addr);
141
142 /* Returning the address is just a courtesy: can simplify callers. */
98 return (void *)addr; 143 return (void *)addr;
99} 144}
100 145
101/* Find magic string marking entry point, return entry point. */ 146/* To find out where to start we look for the magic Guest string, which marks
147 * the code we see in lguest_asm.S. This is a hack which we are currently
148 * plotting to replace with the normal Linux entry point. */
102static unsigned long entry_point(void *start, void *end, 149static unsigned long entry_point(void *start, void *end,
103 unsigned long page_offset) 150 unsigned long page_offset)
104{ 151{
105 void *p; 152 void *p;
106 153
154 /* The scan gives us the physical starting address. We want the
155 * virtual address in this case, and fortunately, we already figured
156 * out the physical-virtual difference and passed it here in
157 * "page_offset". */
107 for (p = start; p < end; p++) 158 for (p = start; p < end; p++)
108 if (memcmp(p, "GenuineLguest", strlen("GenuineLguest")) == 0) 159 if (memcmp(p, "GenuineLguest", strlen("GenuineLguest")) == 0)
109 return (long)p + strlen("GenuineLguest") + page_offset; 160 return (long)p + strlen("GenuineLguest") + page_offset;
@@ -111,7 +162,17 @@ static unsigned long entry_point(void *start, void *end,
111 err(1, "Is this image a genuine lguest?"); 162 err(1, "Is this image a genuine lguest?");
112} 163}
113 164
114/* Returns the entry point */ 165/* This routine takes an open vmlinux image, which is in ELF, and maps it into
166 * the Guest memory. ELF = Embedded Linking Format, which is the format used
167 * by all modern binaries on Linux including the kernel.
168 *
169 * The ELF headers give *two* addresses: a physical address, and a virtual
170 * address. The Guest kernel expects to be placed in memory at the physical
171 * address, and the page tables set up so it will correspond to that virtual
172 * address. We return the difference between the virtual and physical
173 * addresses in the "page_offset" pointer.
174 *
175 * We return the starting address. */
115static unsigned long map_elf(int elf_fd, const Elf32_Ehdr *ehdr, 176static unsigned long map_elf(int elf_fd, const Elf32_Ehdr *ehdr,
116 unsigned long *page_offset) 177 unsigned long *page_offset)
117{ 178{
@@ -120,40 +181,61 @@ static unsigned long map_elf(int elf_fd, const Elf32_Ehdr *ehdr,
120 unsigned int i; 181 unsigned int i;
121 unsigned long start = -1UL, end = 0; 182 unsigned long start = -1UL, end = 0;
122 183
123 /* Sanity checks. */ 184 /* Sanity checks on the main ELF header: an x86 executable with a
185 * reasonable number of correctly-sized program headers. */
124 if (ehdr->e_type != ET_EXEC 186 if (ehdr->e_type != ET_EXEC
125 || ehdr->e_machine != EM_386 187 || ehdr->e_machine != EM_386
126 || ehdr->e_phentsize != sizeof(Elf32_Phdr) 188 || ehdr->e_phentsize != sizeof(Elf32_Phdr)
127 || ehdr->e_phnum < 1 || ehdr->e_phnum > 65536U/sizeof(Elf32_Phdr)) 189 || ehdr->e_phnum < 1 || ehdr->e_phnum > 65536U/sizeof(Elf32_Phdr))
128 errx(1, "Malformed elf header"); 190 errx(1, "Malformed elf header");
129 191
192 /* An ELF executable contains an ELF header and a number of "program"
193 * headers which indicate which parts ("segments") of the program to
194 * load where. */
195
196 /* We read in all the program headers at once: */
130 if (lseek(elf_fd, ehdr->e_phoff, SEEK_SET) < 0) 197 if (lseek(elf_fd, ehdr->e_phoff, SEEK_SET) < 0)
131 err(1, "Seeking to program headers"); 198 err(1, "Seeking to program headers");
132 if (read(elf_fd, phdr, sizeof(phdr)) != sizeof(phdr)) 199 if (read(elf_fd, phdr, sizeof(phdr)) != sizeof(phdr))
133 err(1, "Reading program headers"); 200 err(1, "Reading program headers");
134 201
202 /* We don't know page_offset yet. */
135 *page_offset = 0; 203 *page_offset = 0;
136 /* We map the loadable segments at virtual addresses corresponding 204
137 * to their physical addresses (our virtual == guest physical). */ 205 /* Try all the headers: there are usually only three. A read-only one,
206 * a read-write one, and a "note" section which isn't loadable. */
138 for (i = 0; i < ehdr->e_phnum; i++) { 207 for (i = 0; i < ehdr->e_phnum; i++) {
208 /* If this isn't a loadable segment, we ignore it */
139 if (phdr[i].p_type != PT_LOAD) 209 if (phdr[i].p_type != PT_LOAD)
140 continue; 210 continue;
141 211
142 verbose("Section %i: size %i addr %p\n", 212 verbose("Section %i: size %i addr %p\n",
143 i, phdr[i].p_memsz, (void *)phdr[i].p_paddr); 213 i, phdr[i].p_memsz, (void *)phdr[i].p_paddr);
144 214
145 /* We expect linear address space. */ 215 /* We expect a simple linear address space: every segment must
216 * have the same difference between virtual (p_vaddr) and
217 * physical (p_paddr) address. */
146 if (!*page_offset) 218 if (!*page_offset)
147 *page_offset = phdr[i].p_vaddr - phdr[i].p_paddr; 219 *page_offset = phdr[i].p_vaddr - phdr[i].p_paddr;
148 else if (*page_offset != phdr[i].p_vaddr - phdr[i].p_paddr) 220 else if (*page_offset != phdr[i].p_vaddr - phdr[i].p_paddr)
149 errx(1, "Page offset of section %i different", i); 221 errx(1, "Page offset of section %i different", i);
150 222
223 /* We track the first and last address we mapped, so we can
224 * tell entry_point() where to scan. */
151 if (phdr[i].p_paddr < start) 225 if (phdr[i].p_paddr < start)
152 start = phdr[i].p_paddr; 226 start = phdr[i].p_paddr;
153 if (phdr[i].p_paddr + phdr[i].p_filesz > end) 227 if (phdr[i].p_paddr + phdr[i].p_filesz > end)
154 end = phdr[i].p_paddr + phdr[i].p_filesz; 228 end = phdr[i].p_paddr + phdr[i].p_filesz;
155 229
156 /* We map everything private, writable. */ 230 /* We map this section of the file at its physical address. We
231 * map it read & write even if the header says this segment is
232 * read-only. The kernel really wants to be writable: it
233 * patches its own instructions which would normally be
234 * read-only.
235 *
236 * MAP_PRIVATE means that the page won't be copied until a
237 * write is done to it. This allows us to share much of the
238 * kernel memory between Guests. */
157 addr = mmap((void *)phdr[i].p_paddr, 239 addr = mmap((void *)phdr[i].p_paddr,
158 phdr[i].p_filesz, 240 phdr[i].p_filesz,
159 PROT_READ|PROT_WRITE|PROT_EXEC, 241 PROT_READ|PROT_WRITE|PROT_EXEC,
@@ -167,7 +249,31 @@ static unsigned long map_elf(int elf_fd, const Elf32_Ehdr *ehdr,
167 return entry_point((void *)start, (void *)end, *page_offset); 249 return entry_point((void *)start, (void *)end, *page_offset);
168} 250}
169 251
170/* This is amazingly reliable. */ 252/*L:170 Prepare to be SHOCKED and AMAZED. And possibly a trifle nauseated.
253 *
254 * We know that CONFIG_PAGE_OFFSET sets what virtual address the kernel expects
255 * to be. We don't know what that option was, but we can figure it out
256 * approximately by looking at the addresses in the code. I chose the common
257 * case of reading a memory location into the %eax register:
258 *
259 * movl <some-address>, %eax
260 *
261 * This gets encoded as five bytes: "0xA1 <4-byte-address>". For example,
262 * "0xA1 0x18 0x60 0x47 0xC0" reads the address 0xC0476018 into %eax.
263 *
264 * In this example can guess that the kernel was compiled with
265 * CONFIG_PAGE_OFFSET set to 0xC0000000 (it's always a round number). If the
266 * kernel were larger than 16MB, we might see 0xC1 addresses show up, but our
267 * kernel isn't that bloated yet.
268 *
269 * Unfortunately, x86 has variable-length instructions, so finding this
270 * particular instruction properly involves writing a disassembler. Instead,
271 * we rely on statistics. We look for "0xA1" and tally the different bytes
272 * which occur 4 bytes later (the "0xC0" in our example above). When one of
273 * those bytes appears three times, we can be reasonably confident that it
274 * forms the start of CONFIG_PAGE_OFFSET.
275 *
276 * This is amazingly reliable. */
171static unsigned long intuit_page_offset(unsigned char *img, unsigned long len) 277static unsigned long intuit_page_offset(unsigned char *img, unsigned long len)
172{ 278{
173 unsigned int i, possibilities[256] = { 0 }; 279 unsigned int i, possibilities[256] = { 0 };
@@ -180,30 +286,52 @@ static unsigned long intuit_page_offset(unsigned char *img, unsigned long len)
180 errx(1, "could not determine page offset"); 286 errx(1, "could not determine page offset");
181} 287}
182 288
289/*L:160 Unfortunately the entire ELF image isn't compressed: the segments
290 * which need loading are extracted and compressed raw. This denies us the
291 * information we need to make a fully-general loader. */
183static unsigned long unpack_bzimage(int fd, unsigned long *page_offset) 292static unsigned long unpack_bzimage(int fd, unsigned long *page_offset)
184{ 293{
185 gzFile f; 294 gzFile f;
186 int ret, len = 0; 295 int ret, len = 0;
296 /* A bzImage always gets loaded at physical address 1M. This is
297 * actually configurable as CONFIG_PHYSICAL_START, but as the comment
298 * there says, "Don't change this unless you know what you are doing".
299 * Indeed. */
187 void *img = (void *)0x100000; 300 void *img = (void *)0x100000;
188 301
302 /* gzdopen takes our file descriptor (carefully placed at the start of
303 * the GZIP header we found) and returns a gzFile. */
189 f = gzdopen(fd, "rb"); 304 f = gzdopen(fd, "rb");
305 /* We read it into memory in 64k chunks until we hit the end. */
190 while ((ret = gzread(f, img + len, 65536)) > 0) 306 while ((ret = gzread(f, img + len, 65536)) > 0)
191 len += ret; 307 len += ret;
192 if (ret < 0) 308 if (ret < 0)
193 err(1, "reading image from bzImage"); 309 err(1, "reading image from bzImage");
194 310
195 verbose("Unpacked size %i addr %p\n", len, img); 311 verbose("Unpacked size %i addr %p\n", len, img);
312
313 /* Without the ELF header, we can't tell virtual-physical gap. This is
314 * CONFIG_PAGE_OFFSET, and people do actually change it. Fortunately,
315 * I have a clever way of figuring it out from the code itself. */
196 *page_offset = intuit_page_offset(img, len); 316 *page_offset = intuit_page_offset(img, len);
197 317
198 return entry_point(img, img + len, *page_offset); 318 return entry_point(img, img + len, *page_offset);
199} 319}
200 320
321/*L:150 A bzImage, unlike an ELF file, is not meant to be loaded. You're
322 * supposed to jump into it and it will unpack itself. We can't do that
323 * because the Guest can't run the unpacking code, and adding features to
324 * lguest kills puppies, so we don't want to.
325 *
326 * The bzImage is formed by putting the decompressing code in front of the
327 * compressed kernel code. So we can simple scan through it looking for the
328 * first "gzip" header, and start decompressing from there. */
201static unsigned long load_bzimage(int fd, unsigned long *page_offset) 329static unsigned long load_bzimage(int fd, unsigned long *page_offset)
202{ 330{
203 unsigned char c; 331 unsigned char c;
204 int state = 0; 332 int state = 0;
205 333
206 /* Ugly brute force search for gzip header. */ 334 /* GZIP header is 0x1F 0x8B <method> <flags>... <compressed-by>. */
207 while (read(fd, &c, 1) == 1) { 335 while (read(fd, &c, 1) == 1) {
208 switch (state) { 336 switch (state) {
209 case 0: 337 case 0:
@@ -220,8 +348,10 @@ static unsigned long load_bzimage(int fd, unsigned long *page_offset)
220 state++; 348 state++;
221 break; 349 break;
222 case 9: 350 case 9:
351 /* Seek back to the start of the gzip header. */
223 lseek(fd, -10, SEEK_CUR); 352 lseek(fd, -10, SEEK_CUR);
224 if (c != 0x03) /* Compressed under UNIX. */ 353 /* One final check: "compressed under UNIX". */
354 if (c != 0x03)
225 state = -1; 355 state = -1;
226 else 356 else
227 return unpack_bzimage(fd, page_offset); 357 return unpack_bzimage(fd, page_offset);
@@ -230,25 +360,43 @@ static unsigned long load_bzimage(int fd, unsigned long *page_offset)
230 errx(1, "Could not find kernel in bzImage"); 360 errx(1, "Could not find kernel in bzImage");
231} 361}
232 362
363/*L:140 Loading the kernel is easy when it's a "vmlinux", but most kernels
364 * come wrapped up in the self-decompressing "bzImage" format. With some funky
365 * coding, we can load those, too. */
233static unsigned long load_kernel(int fd, unsigned long *page_offset) 366static unsigned long load_kernel(int fd, unsigned long *page_offset)
234{ 367{
235 Elf32_Ehdr hdr; 368 Elf32_Ehdr hdr;
236 369
370 /* Read in the first few bytes. */
237 if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) 371 if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr))
238 err(1, "Reading kernel"); 372 err(1, "Reading kernel");
239 373
374 /* If it's an ELF file, it starts with "\177ELF" */
240 if (memcmp(hdr.e_ident, ELFMAG, SELFMAG) == 0) 375 if (memcmp(hdr.e_ident, ELFMAG, SELFMAG) == 0)
241 return map_elf(fd, &hdr, page_offset); 376 return map_elf(fd, &hdr, page_offset);
242 377
378 /* Otherwise we assume it's a bzImage, and try to unpack it */
243 return load_bzimage(fd, page_offset); 379 return load_bzimage(fd, page_offset);
244} 380}
245 381
382/* This is a trivial little helper to align pages. Andi Kleen hated it because
383 * it calls getpagesize() twice: "it's dumb code."
384 *
385 * Kernel guys get really het up about optimization, even when it's not
386 * necessary. I leave this code as a reaction against that. */
246static inline unsigned long page_align(unsigned long addr) 387static inline unsigned long page_align(unsigned long addr)
247{ 388{
389 /* Add upwards and truncate downwards. */
248 return ((addr + getpagesize()-1) & ~(getpagesize()-1)); 390 return ((addr + getpagesize()-1) & ~(getpagesize()-1));
249} 391}
250 392
251/* initrd gets loaded at top of memory: return length. */ 393/*L:180 An "initial ram disk" is a disk image loaded into memory along with
394 * the kernel which the kernel can use to boot from without needing any
395 * drivers. Most distributions now use this as standard: the initrd contains
396 * the code to load the appropriate driver modules for the current machine.
397 *
398 * Importantly, James Morris works for RedHat, and Fedora uses initrds for its
399 * kernels. He sent me this (and tells me when I break it). */
252static unsigned long load_initrd(const char *name, unsigned long mem) 400static unsigned long load_initrd(const char *name, unsigned long mem)
253{ 401{
254 int ifd; 402 int ifd;
@@ -257,21 +405,35 @@ static unsigned long load_initrd(const char *name, unsigned long mem)
257 void *iaddr; 405 void *iaddr;
258 406
259 ifd = open_or_die(name, O_RDONLY); 407 ifd = open_or_die(name, O_RDONLY);
408 /* fstat() is needed to get the file size. */
260 if (fstat(ifd, &st) < 0) 409 if (fstat(ifd, &st) < 0)
261 err(1, "fstat() on initrd '%s'", name); 410 err(1, "fstat() on initrd '%s'", name);
262 411
412 /* The length needs to be rounded up to a page size: mmap needs the
413 * address to be page aligned. */
263 len = page_align(st.st_size); 414 len = page_align(st.st_size);
415 /* We map the initrd at the top of memory. */
264 iaddr = mmap((void *)mem - len, st.st_size, 416 iaddr = mmap((void *)mem - len, st.st_size,
265 PROT_READ|PROT_EXEC|PROT_WRITE, 417 PROT_READ|PROT_EXEC|PROT_WRITE,
266 MAP_FIXED|MAP_PRIVATE, ifd, 0); 418 MAP_FIXED|MAP_PRIVATE, ifd, 0);
267 if (iaddr != (void *)mem - len) 419 if (iaddr != (void *)mem - len)
268 err(1, "Mmaping initrd '%s' returned %p not %p", 420 err(1, "Mmaping initrd '%s' returned %p not %p",
269 name, iaddr, (void *)mem - len); 421 name, iaddr, (void *)mem - len);
422 /* Once a file is mapped, you can close the file descriptor. It's a
423 * little odd, but quite useful. */
270 close(ifd); 424 close(ifd);
271 verbose("mapped initrd %s size=%lu @ %p\n", name, st.st_size, iaddr); 425 verbose("mapped initrd %s size=%lu @ %p\n", name, st.st_size, iaddr);
426
427 /* We return the initrd size. */
272 return len; 428 return len;
273} 429}
274 430
431/* Once we know how much memory we have, and the address the Guest kernel
432 * expects, we can construct simple linear page tables which will get the Guest
433 * far enough into the boot to create its own.
434 *
435 * We lay them out of the way, just below the initrd (which is why we need to
436 * know its size). */
275static unsigned long setup_pagetables(unsigned long mem, 437static unsigned long setup_pagetables(unsigned long mem,
276 unsigned long initrd_size, 438 unsigned long initrd_size,
277 unsigned long page_offset) 439 unsigned long page_offset)
@@ -280,23 +442,32 @@ static unsigned long setup_pagetables(unsigned long mem,
280 unsigned int mapped_pages, i, linear_pages; 442 unsigned int mapped_pages, i, linear_pages;
281 unsigned int ptes_per_page = getpagesize()/sizeof(u32); 443 unsigned int ptes_per_page = getpagesize()/sizeof(u32);
282 444
283 /* If we can map all of memory above page_offset, we do so. */ 445 /* Ideally we map all physical memory starting at page_offset.
446 * However, if page_offset is 0xC0000000 we can only map 1G of physical
447 * (0xC0000000 + 1G overflows). */
284 if (mem <= -page_offset) 448 if (mem <= -page_offset)
285 mapped_pages = mem/getpagesize(); 449 mapped_pages = mem/getpagesize();
286 else 450 else
287 mapped_pages = -page_offset/getpagesize(); 451 mapped_pages = -page_offset/getpagesize();
288 452
289 /* Each linear PTE page can map ptes_per_page pages. */ 453 /* Each PTE page can map ptes_per_page pages: how many do we need? */
290 linear_pages = (mapped_pages + ptes_per_page-1)/ptes_per_page; 454 linear_pages = (mapped_pages + ptes_per_page-1)/ptes_per_page;
291 455
292 /* We lay out top-level then linear mapping immediately below initrd */ 456 /* We put the toplevel page directory page at the top of memory. */
293 pgdir = (void *)mem - initrd_size - getpagesize(); 457 pgdir = (void *)mem - initrd_size - getpagesize();
458
459 /* Now we use the next linear_pages pages as pte pages */
294 linear = (void *)pgdir - linear_pages*getpagesize(); 460 linear = (void *)pgdir - linear_pages*getpagesize();
295 461
462 /* Linear mapping is easy: put every page's address into the mapping in
463 * order. PAGE_PRESENT contains the flags Present, Writable and
464 * Executable. */
296 for (i = 0; i < mapped_pages; i++) 465 for (i = 0; i < mapped_pages; i++)
297 linear[i] = ((i * getpagesize()) | PAGE_PRESENT); 466 linear[i] = ((i * getpagesize()) | PAGE_PRESENT);
298 467
299 /* Now set up pgd so that this memory is at page_offset */ 468 /* The top level points to the linear page table pages above. The
469 * entry representing page_offset points to the first one, and they
470 * continue from there. */
300 for (i = 0; i < mapped_pages; i += ptes_per_page) { 471 for (i = 0; i < mapped_pages; i += ptes_per_page) {
301 pgdir[(i + page_offset/getpagesize())/ptes_per_page] 472 pgdir[(i + page_offset/getpagesize())/ptes_per_page]
302 = (((u32)linear + i*sizeof(u32)) | PAGE_PRESENT); 473 = (((u32)linear + i*sizeof(u32)) | PAGE_PRESENT);
@@ -305,9 +476,13 @@ static unsigned long setup_pagetables(unsigned long mem,
305 verbose("Linear mapping of %u pages in %u pte pages at %p\n", 476 verbose("Linear mapping of %u pages in %u pte pages at %p\n",
306 mapped_pages, linear_pages, linear); 477 mapped_pages, linear_pages, linear);
307 478
479 /* We return the top level (guest-physical) address: the kernel needs
480 * to know where it is. */
308 return (unsigned long)pgdir; 481 return (unsigned long)pgdir;
309} 482}
310 483
484/* Simple routine to roll all the commandline arguments together with spaces
485 * between them. */
311static void concat(char *dst, char *args[]) 486static void concat(char *dst, char *args[])
312{ 487{
313 unsigned int i, len = 0; 488 unsigned int i, len = 0;
@@ -321,18 +496,24 @@ static void concat(char *dst, char *args[])
321 dst[len] = '\0'; 496 dst[len] = '\0';
322} 497}
323 498
499/* This is where we actually tell the kernel to initialize the Guest. We saw
500 * the arguments it expects when we looked at initialize() in lguest_user.c:
501 * the top physical page to allow, the top level pagetable, the entry point and
502 * the page_offset constant for the Guest. */
324static int tell_kernel(u32 pgdir, u32 start, u32 page_offset) 503static int tell_kernel(u32 pgdir, u32 start, u32 page_offset)
325{ 504{
326 u32 args[] = { LHREQ_INITIALIZE, 505 u32 args[] = { LHREQ_INITIALIZE,
327 LGUEST_GUEST_TOP/getpagesize(), /* Just below us */ 506 top/getpagesize(), pgdir, start, page_offset };
328 pgdir, start, page_offset };
329 int fd; 507 int fd;
330 508
331 fd = open_or_die("/dev/lguest", O_RDWR); 509 fd = open_or_die("/dev/lguest", O_RDWR);
332 if (write(fd, args, sizeof(args)) < 0) 510 if (write(fd, args, sizeof(args)) < 0)
333 err(1, "Writing to /dev/lguest"); 511 err(1, "Writing to /dev/lguest");
512
513 /* We return the /dev/lguest file descriptor to control this Guest */
334 return fd; 514 return fd;
335} 515}
516/*:*/
336 517
337static void set_fd(int fd, struct device_list *devices) 518static void set_fd(int fd, struct device_list *devices)
338{ 519{
@@ -341,61 +522,108 @@ static void set_fd(int fd, struct device_list *devices)
341 devices->max_infd = fd; 522 devices->max_infd = fd;
342} 523}
343 524
344/* When input arrives, we tell the kernel to kick lguest out with -EAGAIN. */ 525/*L:200
526 * The Waker.
527 *
528 * With a console and network devices, we can have lots of input which we need
529 * to process. We could try to tell the kernel what file descriptors to watch,
530 * but handing a file descriptor mask through to the kernel is fairly icky.
531 *
532 * Instead, we fork off a process which watches the file descriptors and writes
533 * the LHREQ_BREAK command to the /dev/lguest filedescriptor to tell the Host
534 * loop to stop running the Guest. This causes it to return from the
535 * /dev/lguest read with -EAGAIN, where it will write to /dev/lguest to reset
536 * the LHREQ_BREAK and wake us up again.
537 *
538 * This, of course, is merely a different *kind* of icky.
539 */
345static void wake_parent(int pipefd, int lguest_fd, struct device_list *devices) 540static void wake_parent(int pipefd, int lguest_fd, struct device_list *devices)
346{ 541{
542 /* Add the pipe from the Launcher to the fdset in the device_list, so
543 * we watch it, too. */
347 set_fd(pipefd, devices); 544 set_fd(pipefd, devices);
348 545
349 for (;;) { 546 for (;;) {
350 fd_set rfds = devices->infds; 547 fd_set rfds = devices->infds;
351 u32 args[] = { LHREQ_BREAK, 1 }; 548 u32 args[] = { LHREQ_BREAK, 1 };
352 549
550 /* Wait until input is ready from one of the devices. */
353 select(devices->max_infd+1, &rfds, NULL, NULL, NULL); 551 select(devices->max_infd+1, &rfds, NULL, NULL, NULL);
552 /* Is it a message from the Launcher? */
354 if (FD_ISSET(pipefd, &rfds)) { 553 if (FD_ISSET(pipefd, &rfds)) {
355 int ignorefd; 554 int ignorefd;
555 /* If read() returns 0, it means the Launcher has
556 * exited. We silently follow. */
356 if (read(pipefd, &ignorefd, sizeof(ignorefd)) == 0) 557 if (read(pipefd, &ignorefd, sizeof(ignorefd)) == 0)
357 exit(0); 558 exit(0);
559 /* Otherwise it's telling us there's a problem with one
560 * of the devices, and we should ignore that file
561 * descriptor from now on. */
358 FD_CLR(ignorefd, &devices->infds); 562 FD_CLR(ignorefd, &devices->infds);
359 } else 563 } else /* Send LHREQ_BREAK command. */
360 write(lguest_fd, args, sizeof(args)); 564 write(lguest_fd, args, sizeof(args));
361 } 565 }
362} 566}
363 567
568/* This routine just sets up a pipe to the Waker process. */
364static int setup_waker(int lguest_fd, struct device_list *device_list) 569static int setup_waker(int lguest_fd, struct device_list *device_list)
365{ 570{
366 int pipefd[2], child; 571 int pipefd[2], child;
367 572
573 /* We create a pipe to talk to the waker, and also so it knows when the
574 * Launcher dies (and closes pipe). */
368 pipe(pipefd); 575 pipe(pipefd);
369 child = fork(); 576 child = fork();
370 if (child == -1) 577 if (child == -1)
371 err(1, "forking"); 578 err(1, "forking");
372 579
373 if (child == 0) { 580 if (child == 0) {
581 /* Close the "writing" end of our copy of the pipe */
374 close(pipefd[1]); 582 close(pipefd[1]);
375 wake_parent(pipefd[0], lguest_fd, device_list); 583 wake_parent(pipefd[0], lguest_fd, device_list);
376 } 584 }
585 /* Close the reading end of our copy of the pipe. */
377 close(pipefd[0]); 586 close(pipefd[0]);
378 587
588 /* Here is the fd used to talk to the waker. */
379 return pipefd[1]; 589 return pipefd[1];
380} 590}
381 591
592/*L:210
593 * Device Handling.
594 *
595 * When the Guest sends DMA to us, it sends us an array of addresses and sizes.
596 * We need to make sure it's not trying to reach into the Launcher itself, so
597 * we have a convenient routine which check it and exits with an error message
598 * if something funny is going on:
599 */
382static void *_check_pointer(unsigned long addr, unsigned int size, 600static void *_check_pointer(unsigned long addr, unsigned int size,
383 unsigned int line) 601 unsigned int line)
384{ 602{
385 if (addr >= LGUEST_GUEST_TOP || addr + size >= LGUEST_GUEST_TOP) 603 /* We have to separately check addr and addr+size, because size could
604 * be huge and addr + size might wrap around. */
605 if (addr >= top || addr + size >= top)
386 errx(1, "%s:%i: Invalid address %li", __FILE__, line, addr); 606 errx(1, "%s:%i: Invalid address %li", __FILE__, line, addr);
607 /* We return a pointer for the caller's convenience, now we know it's
608 * safe to use. */
387 return (void *)addr; 609 return (void *)addr;
388} 610}
611/* A macro which transparently hands the line number to the real function. */
389#define check_pointer(addr,size) _check_pointer(addr, size, __LINE__) 612#define check_pointer(addr,size) _check_pointer(addr, size, __LINE__)
390 613
391/* Returns pointer to dma->used_len */ 614/* The Guest has given us the address of a "struct lguest_dma". We check it's
615 * OK and convert it to an iovec (which is a simple array of ptr/size
616 * pairs). */
392static u32 *dma2iov(unsigned long dma, struct iovec iov[], unsigned *num) 617static u32 *dma2iov(unsigned long dma, struct iovec iov[], unsigned *num)
393{ 618{
394 unsigned int i; 619 unsigned int i;
395 struct lguest_dma *udma; 620 struct lguest_dma *udma;
396 621
622 /* First we make sure that the array memory itself is valid. */
397 udma = check_pointer(dma, sizeof(*udma)); 623 udma = check_pointer(dma, sizeof(*udma));
624 /* Now we check each element */
398 for (i = 0; i < LGUEST_MAX_DMA_SECTIONS; i++) { 625 for (i = 0; i < LGUEST_MAX_DMA_SECTIONS; i++) {
626 /* A zero length ends the array. */
399 if (!udma->len[i]) 627 if (!udma->len[i])
400 break; 628 break;
401 629
@@ -403,9 +631,15 @@ static u32 *dma2iov(unsigned long dma, struct iovec iov[], unsigned *num)
403 iov[i].iov_len = udma->len[i]; 631 iov[i].iov_len = udma->len[i];
404 } 632 }
405 *num = i; 633 *num = i;
634
635 /* We return the pointer to where the caller should write the amount of
636 * the buffer used. */
406 return &udma->used_len; 637 return &udma->used_len;
407} 638}
408 639
640/* This routine gets a DMA buffer from the Guest for a given key, and converts
641 * it to an iovec array. It returns the interrupt the Guest wants when we're
642 * finished, and a pointer to the "used_len" field to fill in. */
409static u32 *get_dma_buffer(int fd, void *key, 643static u32 *get_dma_buffer(int fd, void *key,
410 struct iovec iov[], unsigned int *num, u32 *irq) 644 struct iovec iov[], unsigned int *num, u32 *irq)
411{ 645{
@@ -413,16 +647,21 @@ static u32 *get_dma_buffer(int fd, void *key,
413 unsigned long udma; 647 unsigned long udma;
414 u32 *res; 648 u32 *res;
415 649
650 /* Ask the kernel for a DMA buffer corresponding to this key. */
416 udma = write(fd, buf, sizeof(buf)); 651 udma = write(fd, buf, sizeof(buf));
652 /* They haven't registered any, or they're all used? */
417 if (udma == (unsigned long)-1) 653 if (udma == (unsigned long)-1)
418 return NULL; 654 return NULL;
419 655
420 /* Kernel stashes irq in ->used_len. */ 656 /* Convert it into our iovec array */
421 res = dma2iov(udma, iov, num); 657 res = dma2iov(udma, iov, num);
658 /* The kernel stashes irq in ->used_len to get it out to us. */
422 *irq = *res; 659 *irq = *res;
660 /* Return a pointer to ((struct lguest_dma *)udma)->used_len. */
423 return res; 661 return res;
424} 662}
425 663
664/* This is a convenient routine to send the Guest an interrupt. */
426static void trigger_irq(int fd, u32 irq) 665static void trigger_irq(int fd, u32 irq)
427{ 666{
428 u32 buf[] = { LHREQ_IRQ, irq }; 667 u32 buf[] = { LHREQ_IRQ, irq };
@@ -430,6 +669,10 @@ static void trigger_irq(int fd, u32 irq)
430 err(1, "Triggering irq %i", irq); 669 err(1, "Triggering irq %i", irq);
431} 670}
432 671
672/* This simply sets up an iovec array where we can put data to be discarded.
673 * This happens when the Guest doesn't want or can't handle the input: we have
674 * to get rid of it somewhere, and if we bury it in the ceiling space it will
675 * start to smell after a week. */
433static void discard_iovec(struct iovec *iov, unsigned int *num) 676static void discard_iovec(struct iovec *iov, unsigned int *num)
434{ 677{
435 static char discard_buf[1024]; 678 static char discard_buf[1024];
@@ -438,19 +681,24 @@ static void discard_iovec(struct iovec *iov, unsigned int *num)
438 iov->iov_len = sizeof(discard_buf); 681 iov->iov_len = sizeof(discard_buf);
439} 682}
440 683
684/* Here is the input terminal setting we save, and the routine to restore them
685 * on exit so the user can see what they type next. */
441static struct termios orig_term; 686static struct termios orig_term;
442static void restore_term(void) 687static void restore_term(void)
443{ 688{
444 tcsetattr(STDIN_FILENO, TCSANOW, &orig_term); 689 tcsetattr(STDIN_FILENO, TCSANOW, &orig_term);
445} 690}
446 691
692/* We associate some data with the console for our exit hack. */
447struct console_abort 693struct console_abort
448{ 694{
695 /* How many times have they hit ^C? */
449 int count; 696 int count;
697 /* When did they start? */
450 struct timeval start; 698 struct timeval start;
451}; 699};
452 700
453/* We DMA input to buffer bound at start of console page. */ 701/* This is the routine which handles console input (ie. stdin). */
454static bool handle_console_input(int fd, struct device *dev) 702static bool handle_console_input(int fd, struct device *dev)
455{ 703{
456 u32 irq = 0, *lenp; 704 u32 irq = 0, *lenp;
@@ -459,24 +707,38 @@ static bool handle_console_input(int fd, struct device *dev)
459 struct iovec iov[LGUEST_MAX_DMA_SECTIONS]; 707 struct iovec iov[LGUEST_MAX_DMA_SECTIONS];
460 struct console_abort *abort = dev->priv; 708 struct console_abort *abort = dev->priv;
461 709
710 /* First we get the console buffer from the Guest. The key is dev->mem
711 * which was set to 0 in setup_console(). */
462 lenp = get_dma_buffer(fd, dev->mem, iov, &num, &irq); 712 lenp = get_dma_buffer(fd, dev->mem, iov, &num, &irq);
463 if (!lenp) { 713 if (!lenp) {
714 /* If it's not ready for input, warn and set up to discard. */
464 warn("console: no dma buffer!"); 715 warn("console: no dma buffer!");
465 discard_iovec(iov, &num); 716 discard_iovec(iov, &num);
466 } 717 }
467 718
719 /* This is why we convert to iovecs: the readv() call uses them, and so
720 * it reads straight into the Guest's buffer. */
468 len = readv(dev->fd, iov, num); 721 len = readv(dev->fd, iov, num);
469 if (len <= 0) { 722 if (len <= 0) {
723 /* This implies that the console is closed, is /dev/null, or
724 * something went terribly wrong. We still go through the rest
725 * of the logic, though, especially the exit handling below. */
470 warnx("Failed to get console input, ignoring console."); 726 warnx("Failed to get console input, ignoring console.");
471 len = 0; 727 len = 0;
472 } 728 }
473 729
730 /* If we read the data into the Guest, fill in the length and send the
731 * interrupt. */
474 if (lenp) { 732 if (lenp) {
475 *lenp = len; 733 *lenp = len;
476 trigger_irq(fd, irq); 734 trigger_irq(fd, irq);
477 } 735 }
478 736
479 /* Three ^C within one second? Exit. */ 737 /* Three ^C within one second? Exit.
738 *
739 * This is such a hack, but works surprisingly well. Each ^C has to be
740 * in a buffer by itself, so they can't be too fast. But we check that
741 * we get three within about a second, so they can't be too slow. */
480 if (len == 1 && ((char *)iov[0].iov_base)[0] == 3) { 742 if (len == 1 && ((char *)iov[0].iov_base)[0] == 3) {
481 if (!abort->count++) 743 if (!abort->count++)
482 gettimeofday(&abort->start, NULL); 744 gettimeofday(&abort->start, NULL);
@@ -484,43 +746,60 @@ static bool handle_console_input(int fd, struct device *dev)
484 struct timeval now; 746 struct timeval now;
485 gettimeofday(&now, NULL); 747 gettimeofday(&now, NULL);
486 if (now.tv_sec <= abort->start.tv_sec+1) { 748 if (now.tv_sec <= abort->start.tv_sec+1) {
487 /* Make sure waker is not blocked in BREAK */
488 u32 args[] = { LHREQ_BREAK, 0 }; 749 u32 args[] = { LHREQ_BREAK, 0 };
750 /* Close the fd so Waker will know it has to
751 * exit. */
489 close(waker_fd); 752 close(waker_fd);
753 /* Just in case waker is blocked in BREAK, send
754 * unbreak now. */
490 write(fd, args, sizeof(args)); 755 write(fd, args, sizeof(args));
491 exit(2); 756 exit(2);
492 } 757 }
493 abort->count = 0; 758 abort->count = 0;
494 } 759 }
495 } else 760 } else
761 /* Any other key resets the abort counter. */
496 abort->count = 0; 762 abort->count = 0;
497 763
764 /* Now, if we didn't read anything, put the input terminal back and
765 * return failure (meaning, don't call us again). */
498 if (!len) { 766 if (!len) {
499 restore_term(); 767 restore_term();
500 return false; 768 return false;
501 } 769 }
770 /* Everything went OK! */
502 return true; 771 return true;
503} 772}
504 773
774/* Handling console output is much simpler than input. */
505static u32 handle_console_output(int fd, const struct iovec *iov, 775static u32 handle_console_output(int fd, const struct iovec *iov,
506 unsigned num, struct device*dev) 776 unsigned num, struct device*dev)
507{ 777{
778 /* Whatever the Guest sends, write it to standard output. Return the
779 * number of bytes written. */
508 return writev(STDOUT_FILENO, iov, num); 780 return writev(STDOUT_FILENO, iov, num);
509} 781}
510 782
783/* Guest->Host network output is also pretty easy. */
511static u32 handle_tun_output(int fd, const struct iovec *iov, 784static u32 handle_tun_output(int fd, const struct iovec *iov,
512 unsigned num, struct device *dev) 785 unsigned num, struct device *dev)
513{ 786{
514 /* Now we've seen output, we should warn if we can't get buffers. */ 787 /* We put a flag in the "priv" pointer of the network device, and set
788 * it as soon as we see output. We'll see why in handle_tun_input() */
515 *(bool *)dev->priv = true; 789 *(bool *)dev->priv = true;
790 /* Whatever packet the Guest sent us, write it out to the tun
791 * device. */
516 return writev(dev->fd, iov, num); 792 return writev(dev->fd, iov, num);
517} 793}
518 794
795/* This matches the peer_key() in lguest_net.c. The key for any given slot
796 * is the address of the network device's page plus 4 * the slot number. */
519static unsigned long peer_offset(unsigned int peernum) 797static unsigned long peer_offset(unsigned int peernum)
520{ 798{
521 return 4 * peernum; 799 return 4 * peernum;
522} 800}
523 801
802/* This is where we handle a packet coming in from the tun device */
524static bool handle_tun_input(int fd, struct device *dev) 803static bool handle_tun_input(int fd, struct device *dev)
525{ 804{
526 u32 irq = 0, *lenp; 805 u32 irq = 0, *lenp;
@@ -528,17 +807,28 @@ static bool handle_tun_input(int fd, struct device *dev)
528 unsigned num; 807 unsigned num;
529 struct iovec iov[LGUEST_MAX_DMA_SECTIONS]; 808 struct iovec iov[LGUEST_MAX_DMA_SECTIONS];
530 809
810 /* First we get a buffer the Guest has bound to its key. */
531 lenp = get_dma_buffer(fd, dev->mem+peer_offset(NET_PEERNUM), iov, &num, 811 lenp = get_dma_buffer(fd, dev->mem+peer_offset(NET_PEERNUM), iov, &num,
532 &irq); 812 &irq);
533 if (!lenp) { 813 if (!lenp) {
814 /* Now, it's expected that if we try to send a packet too
815 * early, the Guest won't be ready yet. This is why we set a
816 * flag when the Guest sends its first packet. If it's sent a
817 * packet we assume it should be ready to receive them.
818 *
819 * Actually, this is what the status bits in the descriptor are
820 * for: we should *use* them. FIXME! */
534 if (*(bool *)dev->priv) 821 if (*(bool *)dev->priv)
535 warn("network: no dma buffer!"); 822 warn("network: no dma buffer!");
536 discard_iovec(iov, &num); 823 discard_iovec(iov, &num);
537 } 824 }
538 825
826 /* Read the packet from the device directly into the Guest's buffer. */
539 len = readv(dev->fd, iov, num); 827 len = readv(dev->fd, iov, num);
540 if (len <= 0) 828 if (len <= 0)
541 err(1, "reading network"); 829 err(1, "reading network");
830
831 /* Write the used_len, and trigger the interrupt for the Guest */
542 if (lenp) { 832 if (lenp) {
543 *lenp = len; 833 *lenp = len;
544 trigger_irq(fd, irq); 834 trigger_irq(fd, irq);
@@ -546,9 +836,13 @@ static bool handle_tun_input(int fd, struct device *dev)
546 verbose("tun input packet len %i [%02x %02x] (%s)\n", len, 836 verbose("tun input packet len %i [%02x %02x] (%s)\n", len,
547 ((u8 *)iov[0].iov_base)[0], ((u8 *)iov[0].iov_base)[1], 837 ((u8 *)iov[0].iov_base)[0], ((u8 *)iov[0].iov_base)[1],
548 lenp ? "sent" : "discarded"); 838 lenp ? "sent" : "discarded");
839 /* All good. */
549 return true; 840 return true;
550} 841}
551 842
843/* The last device handling routine is block output: the Guest has sent a DMA
844 * to the block device. It will have placed the command it wants in the
845 * "struct lguest_block_page". */
552static u32 handle_block_output(int fd, const struct iovec *iov, 846static u32 handle_block_output(int fd, const struct iovec *iov,
553 unsigned num, struct device *dev) 847 unsigned num, struct device *dev)
554{ 848{
@@ -558,36 +852,64 @@ static u32 handle_block_output(int fd, const struct iovec *iov,
558 struct iovec reply[LGUEST_MAX_DMA_SECTIONS]; 852 struct iovec reply[LGUEST_MAX_DMA_SECTIONS];
559 off64_t device_len, off = (off64_t)p->sector * 512; 853 off64_t device_len, off = (off64_t)p->sector * 512;
560 854
855 /* First we extract the device length from the dev->priv pointer. */
561 device_len = *(off64_t *)dev->priv; 856 device_len = *(off64_t *)dev->priv;
562 857
858 /* We first check that the read or write is within the length of the
859 * block file. */
563 if (off >= device_len) 860 if (off >= device_len)
564 err(1, "Bad offset %llu vs %llu", off, device_len); 861 err(1, "Bad offset %llu vs %llu", off, device_len);
862 /* Move to the right location in the block file. This shouldn't fail,
863 * but best to check. */
565 if (lseek64(dev->fd, off, SEEK_SET) != off) 864 if (lseek64(dev->fd, off, SEEK_SET) != off)
566 err(1, "Bad seek to sector %i", p->sector); 865 err(1, "Bad seek to sector %i", p->sector);
567 866
568 verbose("Block: %s at offset %llu\n", p->type ? "WRITE" : "READ", off); 867 verbose("Block: %s at offset %llu\n", p->type ? "WRITE" : "READ", off);
569 868
869 /* They were supposed to bind a reply buffer at key equal to the start
870 * of the block device memory. We need this to tell them when the
871 * request is finished. */
570 lenp = get_dma_buffer(fd, dev->mem, reply, &reply_num, &irq); 872 lenp = get_dma_buffer(fd, dev->mem, reply, &reply_num, &irq);
571 if (!lenp) 873 if (!lenp)
572 err(1, "Block request didn't give us a dma buffer"); 874 err(1, "Block request didn't give us a dma buffer");
573 875
574 if (p->type) { 876 if (p->type) {
877 /* A write request. The DMA they sent contained the data, so
878 * write it out. */
575 len = writev(dev->fd, iov, num); 879 len = writev(dev->fd, iov, num);
880 /* Grr... Now we know how long the "struct lguest_dma" they
881 * sent was, we make sure they didn't try to write over the end
882 * of the block file (possibly extending it). */
576 if (off + len > device_len) { 883 if (off + len > device_len) {
884 /* Trim it back to the correct length */
577 ftruncate(dev->fd, device_len); 885 ftruncate(dev->fd, device_len);
886 /* Die, bad Guest, die. */
578 errx(1, "Write past end %llu+%u", off, len); 887 errx(1, "Write past end %llu+%u", off, len);
579 } 888 }
889 /* The reply length is 0: we just send back an empty DMA to
890 * interrupt them and tell them the write is finished. */
580 *lenp = 0; 891 *lenp = 0;
581 } else { 892 } else {
893 /* A read request. They sent an empty DMA to start the
894 * request, and we put the read contents into the reply
895 * buffer. */
582 len = readv(dev->fd, reply, reply_num); 896 len = readv(dev->fd, reply, reply_num);
583 *lenp = len; 897 *lenp = len;
584 } 898 }
585 899
900 /* The result is 1 (done), 2 if there was an error (short read or
901 * write). */
586 p->result = 1 + (p->bytes != len); 902 p->result = 1 + (p->bytes != len);
903 /* Now tell them we've used their reply buffer. */
587 trigger_irq(fd, irq); 904 trigger_irq(fd, irq);
905
906 /* We're supposed to return the number of bytes of the output buffer we
907 * used. But the block device uses the "result" field instead, so we
908 * don't bother. */
588 return 0; 909 return 0;
589} 910}
590 911
912/* This is the generic routine we call when the Guest sends some DMA out. */
591static void handle_output(int fd, unsigned long dma, unsigned long key, 913static void handle_output(int fd, unsigned long dma, unsigned long key,
592 struct device_list *devices) 914 struct device_list *devices)
593{ 915{
@@ -596,30 +918,53 @@ static void handle_output(int fd, unsigned long dma, unsigned long key,
596 struct iovec iov[LGUEST_MAX_DMA_SECTIONS]; 918 struct iovec iov[LGUEST_MAX_DMA_SECTIONS];
597 unsigned num = 0; 919 unsigned num = 0;
598 920
921 /* Convert the "struct lguest_dma" they're sending to a "struct
922 * iovec". */
599 lenp = dma2iov(dma, iov, &num); 923 lenp = dma2iov(dma, iov, &num);
924
925 /* Check each device: if they expect output to this key, tell them to
926 * handle it. */
600 for (i = devices->dev; i; i = i->next) { 927 for (i = devices->dev; i; i = i->next) {
601 if (i->handle_output && key == i->watch_key) { 928 if (i->handle_output && key == i->watch_key) {
929 /* We write the result straight into the used_len field
930 * for them. */
602 *lenp = i->handle_output(fd, iov, num, i); 931 *lenp = i->handle_output(fd, iov, num, i);
603 return; 932 return;
604 } 933 }
605 } 934 }
935
936 /* This can happen: the kernel sends any SEND_DMA which doesn't match
937 * another Guest to us. It could be that another Guest just left a
938 * network, for example. But it's unusual. */
606 warnx("Pending dma %p, key %p", (void *)dma, (void *)key); 939 warnx("Pending dma %p, key %p", (void *)dma, (void *)key);
607} 940}
608 941
942/* This is called when the waker wakes us up: check for incoming file
943 * descriptors. */
609static void handle_input(int fd, struct device_list *devices) 944static void handle_input(int fd, struct device_list *devices)
610{ 945{
946 /* select() wants a zeroed timeval to mean "don't wait". */
611 struct timeval poll = { .tv_sec = 0, .tv_usec = 0 }; 947 struct timeval poll = { .tv_sec = 0, .tv_usec = 0 };
612 948
613 for (;;) { 949 for (;;) {
614 struct device *i; 950 struct device *i;
615 fd_set fds = devices->infds; 951 fd_set fds = devices->infds;
616 952
953 /* If nothing is ready, we're done. */
617 if (select(devices->max_infd+1, &fds, NULL, NULL, &poll) == 0) 954 if (select(devices->max_infd+1, &fds, NULL, NULL, &poll) == 0)
618 break; 955 break;
619 956
957 /* Otherwise, call the device(s) which have readable
958 * file descriptors and a method of handling them. */
620 for (i = devices->dev; i; i = i->next) { 959 for (i = devices->dev; i; i = i->next) {
621 if (i->handle_input && FD_ISSET(i->fd, &fds)) { 960 if (i->handle_input && FD_ISSET(i->fd, &fds)) {
961 /* If handle_input() returns false, it means we
962 * should no longer service it.
963 * handle_console_input() does this. */
622 if (!i->handle_input(fd, i)) { 964 if (!i->handle_input(fd, i)) {
965 /* Clear it from the set of input file
966 * descriptors kept at the head of the
967 * device list. */
623 FD_CLR(i->fd, &devices->infds); 968 FD_CLR(i->fd, &devices->infds);
624 /* Tell waker to ignore it too... */ 969 /* Tell waker to ignore it too... */
625 write(waker_fd, &i->fd, sizeof(i->fd)); 970 write(waker_fd, &i->fd, sizeof(i->fd));
@@ -629,26 +974,42 @@ static void handle_input(int fd, struct device_list *devices)
629 } 974 }
630} 975}
631 976
632static struct lguest_device_desc *new_dev_desc(u16 type, u16 features, 977/*L:190
633 u16 num_pages) 978 * Device Setup
979 *
980 * All devices need a descriptor so the Guest knows it exists, and a "struct
981 * device" so the Launcher can keep track of it. We have common helper
982 * routines to allocate them.
983 *
984 * This routine allocates a new "struct lguest_device_desc" from descriptor
985 * table in the devices array just above the Guest's normal memory. */
986static struct lguest_device_desc *
987new_dev_desc(struct lguest_device_desc *descs,
988 u16 type, u16 features, u16 num_pages)
634{ 989{
635 static unsigned long top = LGUEST_GUEST_TOP; 990 unsigned int i;
636 struct lguest_device_desc *desc;
637 991
638 desc = malloc(sizeof(*desc)); 992 for (i = 0; i < LGUEST_MAX_DEVICES; i++) {
639 desc->type = type; 993 if (!descs[i].type) {
640 desc->num_pages = num_pages; 994 descs[i].type = type;
641 desc->features = features; 995 descs[i].features = features;
642 desc->status = 0; 996 descs[i].num_pages = num_pages;
643 if (num_pages) { 997 /* If they said the device needs memory, we allocate
644 top -= num_pages*getpagesize(); 998 * that now, bumping up the top of Guest memory. */
645 map_zeroed_pages(top, num_pages); 999 if (num_pages) {
646 desc->pfn = top / getpagesize(); 1000 map_zeroed_pages(top, num_pages);
647 } else 1001 descs[i].pfn = top/getpagesize();
648 desc->pfn = 0; 1002 top += num_pages*getpagesize();
649 return desc; 1003 }
1004 return &descs[i];
1005 }
1006 }
1007 errx(1, "too many devices");
650} 1008}
651 1009
1010/* This monster routine does all the creation and setup of a new device,
1011 * including caling new_dev_desc() to allocate the descriptor and device
1012 * memory. */
652static struct device *new_device(struct device_list *devices, 1013static struct device *new_device(struct device_list *devices,
653 u16 type, u16 num_pages, u16 features, 1014 u16 type, u16 num_pages, u16 features,
654 int fd, 1015 int fd,
@@ -661,15 +1022,21 @@ static struct device *new_device(struct device_list *devices,
661{ 1022{
662 struct device *dev = malloc(sizeof(*dev)); 1023 struct device *dev = malloc(sizeof(*dev));
663 1024
664 /* Append to device list. */ 1025 /* Append to device list. Prepending to a single-linked list is
1026 * easier, but the user expects the devices to be arranged on the bus
1027 * in command-line order. The first network device on the command line
1028 * is eth0, the first block device /dev/lgba, etc. */
665 *devices->lastdev = dev; 1029 *devices->lastdev = dev;
666 dev->next = NULL; 1030 dev->next = NULL;
667 devices->lastdev = &dev->next; 1031 devices->lastdev = &dev->next;
668 1032
1033 /* Now we populate the fields one at a time. */
669 dev->fd = fd; 1034 dev->fd = fd;
1035 /* If we have an input handler for this file descriptor, then we add it
1036 * to the device_list's fdset and maxfd. */
670 if (handle_input) 1037 if (handle_input)
671 set_fd(dev->fd, devices); 1038 set_fd(dev->fd, devices);
672 dev->desc = new_dev_desc(type, features, num_pages); 1039 dev->desc = new_dev_desc(devices->descs, type, features, num_pages);
673 dev->mem = (void *)(dev->desc->pfn * getpagesize()); 1040 dev->mem = (void *)(dev->desc->pfn * getpagesize());
674 dev->handle_input = handle_input; 1041 dev->handle_input = handle_input;
675 dev->watch_key = (unsigned long)dev->mem + watch_off; 1042 dev->watch_key = (unsigned long)dev->mem + watch_off;
@@ -677,27 +1044,37 @@ static struct device *new_device(struct device_list *devices,
677 return dev; 1044 return dev;
678} 1045}
679 1046
1047/* Our first setup routine is the console. It's a fairly simple device, but
1048 * UNIX tty handling makes it uglier than it could be. */
680static void setup_console(struct device_list *devices) 1049static void setup_console(struct device_list *devices)
681{ 1050{
682 struct device *dev; 1051 struct device *dev;
683 1052
1053 /* If we can save the initial standard input settings... */
684 if (tcgetattr(STDIN_FILENO, &orig_term) == 0) { 1054 if (tcgetattr(STDIN_FILENO, &orig_term) == 0) {
685 struct termios term = orig_term; 1055 struct termios term = orig_term;
1056 /* Then we turn off echo, line buffering and ^C etc. We want a
1057 * raw input stream to the Guest. */
686 term.c_lflag &= ~(ISIG|ICANON|ECHO); 1058 term.c_lflag &= ~(ISIG|ICANON|ECHO);
687 tcsetattr(STDIN_FILENO, TCSANOW, &term); 1059 tcsetattr(STDIN_FILENO, TCSANOW, &term);
1060 /* If we exit gracefully, the original settings will be
1061 * restored so the user can see what they're typing. */
688 atexit(restore_term); 1062 atexit(restore_term);
689 } 1063 }
690 1064
691 /* We don't currently require a page for the console. */ 1065 /* We don't currently require any memory for the console, so we ask for
1066 * 0 pages. */
692 dev = new_device(devices, LGUEST_DEVICE_T_CONSOLE, 0, 0, 1067 dev = new_device(devices, LGUEST_DEVICE_T_CONSOLE, 0, 0,
693 STDIN_FILENO, handle_console_input, 1068 STDIN_FILENO, handle_console_input,
694 LGUEST_CONSOLE_DMA_KEY, handle_console_output); 1069 LGUEST_CONSOLE_DMA_KEY, handle_console_output);
1070 /* We store the console state in dev->priv, and initialize it. */
695 dev->priv = malloc(sizeof(struct console_abort)); 1071 dev->priv = malloc(sizeof(struct console_abort));
696 ((struct console_abort *)dev->priv)->count = 0; 1072 ((struct console_abort *)dev->priv)->count = 0;
697 verbose("device %p: console\n", 1073 verbose("device %p: console\n",
698 (void *)(dev->desc->pfn * getpagesize())); 1074 (void *)(dev->desc->pfn * getpagesize()));
699} 1075}
700 1076
1077/* Setting up a block file is also fairly straightforward. */
701static void setup_block_file(const char *filename, struct device_list *devices) 1078static void setup_block_file(const char *filename, struct device_list *devices)
702{ 1079{
703 int fd; 1080 int fd;
@@ -705,20 +1082,47 @@ static void setup_block_file(const char *filename, struct device_list *devices)
705 off64_t *device_len; 1082 off64_t *device_len;
706 struct lguest_block_page *p; 1083 struct lguest_block_page *p;
707 1084
1085 /* We open with O_LARGEFILE because otherwise we get stuck at 2G. We
1086 * open with O_DIRECT because otherwise our benchmarks go much too
1087 * fast. */
708 fd = open_or_die(filename, O_RDWR|O_LARGEFILE|O_DIRECT); 1088 fd = open_or_die(filename, O_RDWR|O_LARGEFILE|O_DIRECT);
1089
1090 /* We want one page, and have no input handler (the block file never
1091 * has anything interesting to say to us). Our timing will be quite
1092 * random, so it should be a reasonable randomness source. */
709 dev = new_device(devices, LGUEST_DEVICE_T_BLOCK, 1, 1093 dev = new_device(devices, LGUEST_DEVICE_T_BLOCK, 1,
710 LGUEST_DEVICE_F_RANDOMNESS, 1094 LGUEST_DEVICE_F_RANDOMNESS,
711 fd, NULL, 0, handle_block_output); 1095 fd, NULL, 0, handle_block_output);
1096
1097 /* We store the device size in the private area */
712 device_len = dev->priv = malloc(sizeof(*device_len)); 1098 device_len = dev->priv = malloc(sizeof(*device_len));
1099 /* This is the safe way of establishing the size of our device: it
1100 * might be a normal file or an actual block device like /dev/hdb. */
713 *device_len = lseek64(fd, 0, SEEK_END); 1101 *device_len = lseek64(fd, 0, SEEK_END);
714 p = dev->mem;
715 1102
1103 /* The device memory is a "struct lguest_block_page". It's zeroed
1104 * already, we just need to put in the device size. Block devices
1105 * think in sectors (ie. 512 byte chunks), so we translate here. */
1106 p = dev->mem;
716 p->num_sectors = *device_len/512; 1107 p->num_sectors = *device_len/512;
717 verbose("device %p: block %i sectors\n", 1108 verbose("device %p: block %i sectors\n",
718 (void *)(dev->desc->pfn * getpagesize()), p->num_sectors); 1109 (void *)(dev->desc->pfn * getpagesize()), p->num_sectors);
719} 1110}
720 1111
721/* We use fnctl locks to reserve network slots (autocleanup!) */ 1112/*
1113 * Network Devices.
1114 *
1115 * Setting up network devices is quite a pain, because we have three types.
1116 * First, we have the inter-Guest network. This is a file which is mapped into
1117 * the address space of the Guests who are on the network. Because it is a
1118 * shared mapping, the same page underlies all the devices, and they can send
1119 * DMA to each other.
1120 *
1121 * Remember from our network driver, the Guest is told what slot in the page it
1122 * is to use. We use exclusive fnctl locks to reserve a slot. If another
1123 * Guest is using a slot, the lock will fail and we try another. Because fnctl
1124 * locks are cleaned up automatically when we die, this cleverly means that our
1125 * reservation on the slot will vanish if we crash. */
722static unsigned int find_slot(int netfd, const char *filename) 1126static unsigned int find_slot(int netfd, const char *filename)
723{ 1127{
724 struct flock fl; 1128 struct flock fl;
@@ -726,26 +1130,33 @@ static unsigned int find_slot(int netfd, const char *filename)
726 fl.l_type = F_WRLCK; 1130 fl.l_type = F_WRLCK;
727 fl.l_whence = SEEK_SET; 1131 fl.l_whence = SEEK_SET;
728 fl.l_len = 1; 1132 fl.l_len = 1;
1133 /* Try a 1 byte lock in each possible position number */
729 for (fl.l_start = 0; 1134 for (fl.l_start = 0;
730 fl.l_start < getpagesize()/sizeof(struct lguest_net); 1135 fl.l_start < getpagesize()/sizeof(struct lguest_net);
731 fl.l_start++) { 1136 fl.l_start++) {
1137 /* If we succeed, return the slot number. */
732 if (fcntl(netfd, F_SETLK, &fl) == 0) 1138 if (fcntl(netfd, F_SETLK, &fl) == 0)
733 return fl.l_start; 1139 return fl.l_start;
734 } 1140 }
735 errx(1, "No free slots in network file %s", filename); 1141 errx(1, "No free slots in network file %s", filename);
736} 1142}
737 1143
1144/* This function sets up the network file */
738static void setup_net_file(const char *filename, 1145static void setup_net_file(const char *filename,
739 struct device_list *devices) 1146 struct device_list *devices)
740{ 1147{
741 int netfd; 1148 int netfd;
742 struct device *dev; 1149 struct device *dev;
743 1150
1151 /* We don't use open_or_die() here: for friendliness we create the file
1152 * if it doesn't already exist. */
744 netfd = open(filename, O_RDWR, 0); 1153 netfd = open(filename, O_RDWR, 0);
745 if (netfd < 0) { 1154 if (netfd < 0) {
746 if (errno == ENOENT) { 1155 if (errno == ENOENT) {
747 netfd = open(filename, O_RDWR|O_CREAT, 0600); 1156 netfd = open(filename, O_RDWR|O_CREAT, 0600);
748 if (netfd >= 0) { 1157 if (netfd >= 0) {
1158 /* If we succeeded, initialize the file with a
1159 * blank page. */
749 char page[getpagesize()]; 1160 char page[getpagesize()];
750 memset(page, 0, sizeof(page)); 1161 memset(page, 0, sizeof(page));
751 write(netfd, page, sizeof(page)); 1162 write(netfd, page, sizeof(page));
@@ -755,11 +1166,15 @@ static void setup_net_file(const char *filename,
755 err(1, "cannot open net file '%s'", filename); 1166 err(1, "cannot open net file '%s'", filename);
756 } 1167 }
757 1168
1169 /* We need 1 page, and the features indicate the slot to use and that
1170 * no checksum is needed. We never touch this device again; it's
1171 * between the Guests on the network, so we don't register input or
1172 * output handlers. */
758 dev = new_device(devices, LGUEST_DEVICE_T_NET, 1, 1173 dev = new_device(devices, LGUEST_DEVICE_T_NET, 1,
759 find_slot(netfd, filename)|LGUEST_NET_F_NOCSUM, 1174 find_slot(netfd, filename)|LGUEST_NET_F_NOCSUM,
760 -1, NULL, 0, NULL); 1175 -1, NULL, 0, NULL);
761 1176
762 /* We overwrite the /dev/zero mapping with the actual file. */ 1177 /* Map the shared file. */
763 if (mmap(dev->mem, getpagesize(), PROT_READ|PROT_WRITE, 1178 if (mmap(dev->mem, getpagesize(), PROT_READ|PROT_WRITE,
764 MAP_FIXED|MAP_SHARED, netfd, 0) != dev->mem) 1179 MAP_FIXED|MAP_SHARED, netfd, 0) != dev->mem)
765 err(1, "could not mmap '%s'", filename); 1180 err(1, "could not mmap '%s'", filename);
@@ -767,6 +1182,7 @@ static void setup_net_file(const char *filename,
767 (void *)(dev->desc->pfn * getpagesize()), filename, 1182 (void *)(dev->desc->pfn * getpagesize()), filename,
768 dev->desc->features & ~LGUEST_NET_F_NOCSUM); 1183 dev->desc->features & ~LGUEST_NET_F_NOCSUM);
769} 1184}
1185/*:*/
770 1186
771static u32 str2ip(const char *ipaddr) 1187static u32 str2ip(const char *ipaddr)
772{ 1188{
@@ -776,7 +1192,11 @@ static u32 str2ip(const char *ipaddr)
776 return (byte[0] << 24) | (byte[1] << 16) | (byte[2] << 8) | byte[3]; 1192 return (byte[0] << 24) | (byte[1] << 16) | (byte[2] << 8) | byte[3];
777} 1193}
778 1194
779/* adapted from libbridge */ 1195/* This code is "adapted" from libbridge: it attaches the Host end of the
1196 * network device to the bridge device specified by the command line.
1197 *
1198 * This is yet another James Morris contribution (I'm an IP-level guy, so I
1199 * dislike bridging), and I just try not to break it. */
780static void add_to_bridge(int fd, const char *if_name, const char *br_name) 1200static void add_to_bridge(int fd, const char *if_name, const char *br_name)
781{ 1201{
782 int ifidx; 1202 int ifidx;
@@ -795,12 +1215,16 @@ static void add_to_bridge(int fd, const char *if_name, const char *br_name)
795 err(1, "can't add %s to bridge %s", if_name, br_name); 1215 err(1, "can't add %s to bridge %s", if_name, br_name);
796} 1216}
797 1217
1218/* This sets up the Host end of the network device with an IP address, brings
1219 * it up so packets will flow, the copies the MAC address into the hwaddr
1220 * pointer (in practice, the Host's slot in the network device's memory). */
798static void configure_device(int fd, const char *devname, u32 ipaddr, 1221static void configure_device(int fd, const char *devname, u32 ipaddr,
799 unsigned char hwaddr[6]) 1222 unsigned char hwaddr[6])
800{ 1223{
801 struct ifreq ifr; 1224 struct ifreq ifr;
802 struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr; 1225 struct sockaddr_in *sin = (struct sockaddr_in *)&ifr.ifr_addr;
803 1226
1227 /* Don't read these incantations. Just cut & paste them like I did! */
804 memset(&ifr, 0, sizeof(ifr)); 1228 memset(&ifr, 0, sizeof(ifr));
805 strcpy(ifr.ifr_name, devname); 1229 strcpy(ifr.ifr_name, devname);
806 sin->sin_family = AF_INET; 1230 sin->sin_family = AF_INET;
@@ -811,12 +1235,19 @@ static void configure_device(int fd, const char *devname, u32 ipaddr,
811 if (ioctl(fd, SIOCSIFFLAGS, &ifr) != 0) 1235 if (ioctl(fd, SIOCSIFFLAGS, &ifr) != 0)
812 err(1, "Bringing interface %s up", devname); 1236 err(1, "Bringing interface %s up", devname);
813 1237
1238 /* SIOC stands for Socket I/O Control. G means Get (vs S for Set
1239 * above). IF means Interface, and HWADDR is hardware address.
1240 * Simple! */
814 if (ioctl(fd, SIOCGIFHWADDR, &ifr) != 0) 1241 if (ioctl(fd, SIOCGIFHWADDR, &ifr) != 0)
815 err(1, "getting hw address for %s", devname); 1242 err(1, "getting hw address for %s", devname);
816
817 memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6); 1243 memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, 6);
818} 1244}
819 1245
1246/*L:195 The other kind of network is a Host<->Guest network. This can either
1247 * use briding or routing, but the principle is the same: it uses the "tun"
1248 * device to inject packets into the Host as if they came in from a normal
1249 * network card. We just shunt packets between the Guest and the tun
1250 * device. */
820static void setup_tun_net(const char *arg, struct device_list *devices) 1251static void setup_tun_net(const char *arg, struct device_list *devices)
821{ 1252{
822 struct device *dev; 1253 struct device *dev;
@@ -825,36 +1256,56 @@ static void setup_tun_net(const char *arg, struct device_list *devices)
825 u32 ip; 1256 u32 ip;
826 const char *br_name = NULL; 1257 const char *br_name = NULL;
827 1258
1259 /* We open the /dev/net/tun device and tell it we want a tap device. A
1260 * tap device is like a tun device, only somehow different. To tell
1261 * the truth, I completely blundered my way through this code, but it
1262 * works now! */
828 netfd = open_or_die("/dev/net/tun", O_RDWR); 1263 netfd = open_or_die("/dev/net/tun", O_RDWR);
829 memset(&ifr, 0, sizeof(ifr)); 1264 memset(&ifr, 0, sizeof(ifr));
830 ifr.ifr_flags = IFF_TAP | IFF_NO_PI; 1265 ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
831 strcpy(ifr.ifr_name, "tap%d"); 1266 strcpy(ifr.ifr_name, "tap%d");
832 if (ioctl(netfd, TUNSETIFF, &ifr) != 0) 1267 if (ioctl(netfd, TUNSETIFF, &ifr) != 0)
833 err(1, "configuring /dev/net/tun"); 1268 err(1, "configuring /dev/net/tun");
1269 /* We don't need checksums calculated for packets coming in this
1270 * device: trust us! */
834 ioctl(netfd, TUNSETNOCSUM, 1); 1271 ioctl(netfd, TUNSETNOCSUM, 1);
835 1272
836 /* You will be peer 1: we should create enough jitter to randomize */ 1273 /* We create the net device with 1 page, using the features field of
1274 * the descriptor to tell the Guest it is in slot 1 (NET_PEERNUM), and
1275 * that the device has fairly random timing. We do *not* specify
1276 * LGUEST_NET_F_NOCSUM: these packets can reach the real world.
1277 *
1278 * We will put our MAC address is slot 0 for the Guest to see, so
1279 * it will send packets to us using the key "peer_offset(0)": */
837 dev = new_device(devices, LGUEST_DEVICE_T_NET, 1, 1280 dev = new_device(devices, LGUEST_DEVICE_T_NET, 1,
838 NET_PEERNUM|LGUEST_DEVICE_F_RANDOMNESS, netfd, 1281 NET_PEERNUM|LGUEST_DEVICE_F_RANDOMNESS, netfd,
839 handle_tun_input, peer_offset(0), handle_tun_output); 1282 handle_tun_input, peer_offset(0), handle_tun_output);
1283
1284 /* We keep a flag which says whether we've seen packets come out from
1285 * this network device. */
840 dev->priv = malloc(sizeof(bool)); 1286 dev->priv = malloc(sizeof(bool));
841 *(bool *)dev->priv = false; 1287 *(bool *)dev->priv = false;
842 1288
1289 /* We need a socket to perform the magic network ioctls to bring up the
1290 * tap interface, connect to the bridge etc. Any socket will do! */
843 ipfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); 1291 ipfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
844 if (ipfd < 0) 1292 if (ipfd < 0)
845 err(1, "opening IP socket"); 1293 err(1, "opening IP socket");
846 1294
1295 /* If the command line was --tunnet=bridge:<name> do bridging. */
847 if (!strncmp(BRIDGE_PFX, arg, strlen(BRIDGE_PFX))) { 1296 if (!strncmp(BRIDGE_PFX, arg, strlen(BRIDGE_PFX))) {
848 ip = INADDR_ANY; 1297 ip = INADDR_ANY;
849 br_name = arg + strlen(BRIDGE_PFX); 1298 br_name = arg + strlen(BRIDGE_PFX);
850 add_to_bridge(ipfd, ifr.ifr_name, br_name); 1299 add_to_bridge(ipfd, ifr.ifr_name, br_name);
851 } else 1300 } else /* It is an IP address to set up the device with */
852 ip = str2ip(arg); 1301 ip = str2ip(arg);
853 1302
854 /* We are peer 0, ie. first slot. */ 1303 /* We are peer 0, ie. first slot, so we hand dev->mem to this routine
1304 * to write the MAC address at the start of the device memory. */
855 configure_device(ipfd, ifr.ifr_name, ip, dev->mem); 1305 configure_device(ipfd, ifr.ifr_name, ip, dev->mem);
856 1306
857 /* Set "promisc" bit: we want every single packet. */ 1307 /* Set "promisc" bit: we want every single packet if we're going to
1308 * bridge to other machines (and otherwise it doesn't matter). */
858 *((u8 *)dev->mem) |= 0x1; 1309 *((u8 *)dev->mem) |= 0x1;
859 1310
860 close(ipfd); 1311 close(ipfd);
@@ -865,31 +1316,10 @@ static void setup_tun_net(const char *arg, struct device_list *devices)
865 if (br_name) 1316 if (br_name)
866 verbose("attached to bridge: %s\n", br_name); 1317 verbose("attached to bridge: %s\n", br_name);
867} 1318}
1319/* That's the end of device setup. */
868 1320
869/* Now we know how much memory we have, we copy in device descriptors */ 1321/*L:220 Finally we reach the core of the Launcher, which runs the Guest, serves
870static void map_device_descriptors(struct device_list *devs, unsigned long mem) 1322 * its input and output, and finally, lays it to rest. */
871{
872 struct device *i;
873 unsigned int num;
874 struct lguest_device_desc *descs;
875
876 /* Device descriptor array sits just above top of normal memory */
877 descs = map_zeroed_pages(mem, 1);
878
879 for (i = devs->dev, num = 0; i; i = i->next, num++) {
880 if (num == LGUEST_MAX_DEVICES)
881 errx(1, "too many devices");
882 verbose("Device %i: %s\n", num,
883 i->desc->type == LGUEST_DEVICE_T_NET ? "net"
884 : i->desc->type == LGUEST_DEVICE_T_CONSOLE ? "console"
885 : i->desc->type == LGUEST_DEVICE_T_BLOCK ? "block"
886 : "unknown");
887 descs[num] = *i->desc;
888 free(i->desc);
889 i->desc = &descs[num];
890 }
891}
892
893static void __attribute__((noreturn)) 1323static void __attribute__((noreturn))
894run_guest(int lguest_fd, struct device_list *device_list) 1324run_guest(int lguest_fd, struct device_list *device_list)
895{ 1325{
@@ -901,20 +1331,37 @@ run_guest(int lguest_fd, struct device_list *device_list)
901 /* We read from the /dev/lguest device to run the Guest. */ 1331 /* We read from the /dev/lguest device to run the Guest. */
902 readval = read(lguest_fd, arr, sizeof(arr)); 1332 readval = read(lguest_fd, arr, sizeof(arr));
903 1333
1334 /* The read can only really return sizeof(arr) (the Guest did a
1335 * SEND_DMA to us), or an error. */
1336
1337 /* For a successful read, arr[0] is the address of the "struct
1338 * lguest_dma", and arr[1] is the key the Guest sent to. */
904 if (readval == sizeof(arr)) { 1339 if (readval == sizeof(arr)) {
905 handle_output(lguest_fd, arr[0], arr[1], device_list); 1340 handle_output(lguest_fd, arr[0], arr[1], device_list);
906 continue; 1341 continue;
1342 /* ENOENT means the Guest died. Reading tells us why. */
907 } else if (errno == ENOENT) { 1343 } else if (errno == ENOENT) {
908 char reason[1024] = { 0 }; 1344 char reason[1024] = { 0 };
909 read(lguest_fd, reason, sizeof(reason)-1); 1345 read(lguest_fd, reason, sizeof(reason)-1);
910 errx(1, "%s", reason); 1346 errx(1, "%s", reason);
1347 /* EAGAIN means the waker wanted us to look at some input.
1348 * Anything else means a bug or incompatible change. */
911 } else if (errno != EAGAIN) 1349 } else if (errno != EAGAIN)
912 err(1, "Running guest failed"); 1350 err(1, "Running guest failed");
1351
1352 /* Service input, then unset the BREAK which releases
1353 * the Waker. */
913 handle_input(lguest_fd, device_list); 1354 handle_input(lguest_fd, device_list);
914 if (write(lguest_fd, args, sizeof(args)) < 0) 1355 if (write(lguest_fd, args, sizeof(args)) < 0)
915 err(1, "Resetting break"); 1356 err(1, "Resetting break");
916 } 1357 }
917} 1358}
1359/*
1360 * This is the end of the Launcher.
1361 *
1362 * But wait! We've seen I/O from the Launcher, and we've seen I/O from the
1363 * Drivers. If we were to see the Host kernel I/O code, our understanding
1364 * would be complete... :*/
918 1365
919static struct option opts[] = { 1366static struct option opts[] = {
920 { "verbose", 0, NULL, 'v' }, 1367 { "verbose", 0, NULL, 'v' },
@@ -932,19 +1379,59 @@ static void usage(void)
932 "<mem-in-mb> vmlinux [args...]"); 1379 "<mem-in-mb> vmlinux [args...]");
933} 1380}
934 1381
1382/*L:100 The Launcher code itself takes us out into userspace, that scary place
1383 * where pointers run wild and free! Unfortunately, like most userspace
1384 * programs, it's quite boring (which is why everyone like to hack on the
1385 * kernel!). Perhaps if you make up an Lguest Drinking Game at this point, it
1386 * will get you through this section. Or, maybe not.
1387 *
1388 * The Launcher binary sits up high, usually starting at address 0xB8000000.
1389 * Everything below this is the "physical" memory for the Guest. For example,
1390 * if the Guest were to write a "1" at physical address 0, we would see a "1"
1391 * in the Launcher at "(int *)0". Guest physical == Launcher virtual.
1392 *
1393 * This can be tough to get your head around, but usually it just means that we
1394 * don't need to do any conversion when the Guest gives us it's "physical"
1395 * addresses.
1396 */
935int main(int argc, char *argv[]) 1397int main(int argc, char *argv[])
936{ 1398{
937 unsigned long mem, pgdir, start, page_offset, initrd_size = 0; 1399 /* Memory, top-level pagetable, code startpoint, PAGE_OFFSET and size
938 int c, lguest_fd; 1400 * of the (optional) initrd. */
1401 unsigned long mem = 0, pgdir, start, page_offset, initrd_size = 0;
1402 /* A temporary and the /dev/lguest file descriptor. */
1403 int i, c, lguest_fd;
1404 /* The list of Guest devices, based on command line arguments. */
939 struct device_list device_list; 1405 struct device_list device_list;
1406 /* The boot information for the Guest: at guest-physical address 0. */
940 void *boot = (void *)0; 1407 void *boot = (void *)0;
1408 /* If they specify an initrd file to load. */
941 const char *initrd_name = NULL; 1409 const char *initrd_name = NULL;
942 1410
1411 /* First we initialize the device list. Since console and network
1412 * device receive input from a file descriptor, we keep an fdset
1413 * (infds) and the maximum fd number (max_infd) with the head of the
1414 * list. We also keep a pointer to the last device, for easy appending
1415 * to the list. */
943 device_list.max_infd = -1; 1416 device_list.max_infd = -1;
944 device_list.dev = NULL; 1417 device_list.dev = NULL;
945 device_list.lastdev = &device_list.dev; 1418 device_list.lastdev = &device_list.dev;
946 FD_ZERO(&device_list.infds); 1419 FD_ZERO(&device_list.infds);
947 1420
1421 /* We need to know how much memory so we can set up the device
1422 * descriptor and memory pages for the devices as we parse the command
1423 * line. So we quickly look through the arguments to find the amount
1424 * of memory now. */
1425 for (i = 1; i < argc; i++) {
1426 if (argv[i][0] != '-') {
1427 mem = top = atoi(argv[i]) * 1024 * 1024;
1428 device_list.descs = map_zeroed_pages(top, 1);
1429 top += getpagesize();
1430 break;
1431 }
1432 }
1433
1434 /* The options are fairly straight-forward */
948 while ((c = getopt_long(argc, argv, "v", opts, NULL)) != EOF) { 1435 while ((c = getopt_long(argc, argv, "v", opts, NULL)) != EOF) {
949 switch (c) { 1436 switch (c) {
950 case 'v': 1437 case 'v':
@@ -967,46 +1454,71 @@ int main(int argc, char *argv[])
967 usage(); 1454 usage();
968 } 1455 }
969 } 1456 }
1457 /* After the other arguments we expect memory and kernel image name,
1458 * followed by command line arguments for the kernel. */
970 if (optind + 2 > argc) 1459 if (optind + 2 > argc)
971 usage(); 1460 usage();
972 1461
973 /* We need a console device */ 1462 /* We always have a console device */
974 setup_console(&device_list); 1463 setup_console(&device_list);
975 1464
976 /* First we map /dev/zero over all of guest-physical memory. */ 1465 /* We start by mapping anonymous pages over all of guest-physical
977 mem = atoi(argv[optind]) * 1024 * 1024; 1466 * memory range. This fills it with 0, and ensures that the Guest
1467 * won't be killed when it tries to access it. */
978 map_zeroed_pages(0, mem / getpagesize()); 1468 map_zeroed_pages(0, mem / getpagesize());
979 1469
980 /* Now we load the kernel */ 1470 /* Now we load the kernel */
981 start = load_kernel(open_or_die(argv[optind+1], O_RDONLY), 1471 start = load_kernel(open_or_die(argv[optind+1], O_RDONLY),
982 &page_offset); 1472 &page_offset);
983 1473
984 /* Write the device descriptors into memory. */ 1474 /* Map the initrd image if requested (at top of physical memory) */
985 map_device_descriptors(&device_list, mem);
986
987 /* Map the initrd image if requested */
988 if (initrd_name) { 1475 if (initrd_name) {
989 initrd_size = load_initrd(initrd_name, mem); 1476 initrd_size = load_initrd(initrd_name, mem);
1477 /* These are the location in the Linux boot header where the
1478 * start and size of the initrd are expected to be found. */
990 *(unsigned long *)(boot+0x218) = mem - initrd_size; 1479 *(unsigned long *)(boot+0x218) = mem - initrd_size;
991 *(unsigned long *)(boot+0x21c) = initrd_size; 1480 *(unsigned long *)(boot+0x21c) = initrd_size;
1481 /* The bootloader type 0xFF means "unknown"; that's OK. */
992 *(unsigned char *)(boot+0x210) = 0xFF; 1482 *(unsigned char *)(boot+0x210) = 0xFF;
993 } 1483 }
994 1484
995 /* Set up the initial linar pagetables. */ 1485 /* Set up the initial linear pagetables, starting below the initrd. */
996 pgdir = setup_pagetables(mem, initrd_size, page_offset); 1486 pgdir = setup_pagetables(mem, initrd_size, page_offset);
997 1487
998 /* E820 memory map: ours is a simple, single region. */ 1488 /* The Linux boot header contains an "E820" memory map: ours is a
1489 * simple, single region. */
999 *(char*)(boot+E820NR) = 1; 1490 *(char*)(boot+E820NR) = 1;
1000 *((struct e820entry *)(boot+E820MAP)) 1491 *((struct e820entry *)(boot+E820MAP))
1001 = ((struct e820entry) { 0, mem, E820_RAM }); 1492 = ((struct e820entry) { 0, mem, E820_RAM });
1002 /* Command line pointer and command line (at 4096) */ 1493 /* The boot header contains a command line pointer: we put the command
1494 * line after the boot header (at address 4096) */
1003 *(void **)(boot + 0x228) = boot + 4096; 1495 *(void **)(boot + 0x228) = boot + 4096;
1004 concat(boot + 4096, argv+optind+2); 1496 concat(boot + 4096, argv+optind+2);
1005 /* Paravirt type: 1 == lguest */ 1497
1498 /* The guest type value of "1" tells the Guest it's under lguest. */
1006 *(int *)(boot + 0x23c) = 1; 1499 *(int *)(boot + 0x23c) = 1;
1007 1500
1501 /* We tell the kernel to initialize the Guest: this returns the open
1502 * /dev/lguest file descriptor. */
1008 lguest_fd = tell_kernel(pgdir, start, page_offset); 1503 lguest_fd = tell_kernel(pgdir, start, page_offset);
1504
1505 /* We fork off a child process, which wakes the Launcher whenever one
1506 * of the input file descriptors needs attention. Otherwise we would
1507 * run the Guest until it tries to output something. */
1009 waker_fd = setup_waker(lguest_fd, &device_list); 1508 waker_fd = setup_waker(lguest_fd, &device_list);
1010 1509
1510 /* Finally, run the Guest. This doesn't return. */
1011 run_guest(lguest_fd, &device_list); 1511 run_guest(lguest_fd, &device_list);
1012} 1512}
1513/*:*/
1514
1515/*M:999
1516 * Mastery is done: you now know everything I do.
1517 *
1518 * But surely you have seen code, features and bugs in your wanderings which
1519 * you now yearn to attack? That is the real game, and I look forward to you
1520 * patching and forking lguest into the Your-Name-Here-visor.
1521 *
1522 * Farewell, and good coding!
1523 * Rusty Russell.
1524 */
diff --git a/Documentation/sched-stats.txt b/Documentation/sched-stats.txt
index 6f72021aae51..442e14d35dea 100644
--- a/Documentation/sched-stats.txt
+++ b/Documentation/sched-stats.txt
@@ -1,10 +1,11 @@
1Version 10 of schedstats includes support for sched_domains, which 1Version 14 of schedstats includes support for sched_domains, which hit the
2hit the mainline kernel in 2.6.7. Some counters make more sense to be 2mainline kernel in 2.6.20 although it is identical to the stats from version
3per-runqueue; other to be per-domain. Note that domains (and their associated 312 which was in the kernel from 2.6.13-2.6.19 (version 13 never saw a kernel
4information) will only be pertinent and available on machines utilizing 4release). Some counters make more sense to be per-runqueue; other to be
5CONFIG_SMP. 5per-domain. Note that domains (and their associated information) will only
6 6be pertinent and available on machines utilizing CONFIG_SMP.
7In version 10 of schedstat, there is at least one level of domain 7
8In version 14 of schedstat, there is at least one level of domain
8statistics for each cpu listed, and there may well be more than one 9statistics for each cpu listed, and there may well be more than one
9domain. Domains have no particular names in this implementation, but 10domain. Domains have no particular names in this implementation, but
10the highest numbered one typically arbitrates balancing across all the 11the highest numbered one typically arbitrates balancing across all the
@@ -27,7 +28,7 @@ to write their own scripts, the fields are described here.
27 28
28CPU statistics 29CPU statistics
29-------------- 30--------------
30cpu<N> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 31cpu<N> 1 2 3 4 5 6 7 8 9 10 11 12
31 32
32NOTE: In the sched_yield() statistics, the active queue is considered empty 33NOTE: In the sched_yield() statistics, the active queue is considered empty
33 if it has only one process in it, since obviously the process calling 34 if it has only one process in it, since obviously the process calling
@@ -39,48 +40,20 @@ First four fields are sched_yield() statistics:
39 3) # of times just the expired queue was empty 40 3) # of times just the expired queue was empty
40 4) # of times sched_yield() was called 41 4) # of times sched_yield() was called
41 42
42Next four are schedule() statistics: 43Next three are schedule() statistics:
43 5) # of times the active queue had at least one other process on it 44 5) # of times we switched to the expired queue and reused it
44 6) # of times we switched to the expired queue and reused it 45 6) # of times schedule() was called
45 7) # of times schedule() was called 46 7) # of times schedule() left the processor idle
46 8) # of times schedule() left the processor idle
47
48Next four are active_load_balance() statistics:
49 9) # of times active_load_balance() was called
50 10) # of times active_load_balance() caused this cpu to gain a task
51 11) # of times active_load_balance() caused this cpu to lose a task
52 12) # of times active_load_balance() tried to move a task and failed
53
54Next three are try_to_wake_up() statistics:
55 13) # of times try_to_wake_up() was called
56 14) # of times try_to_wake_up() successfully moved the awakening task
57 15) # of times try_to_wake_up() attempted to move the awakening task
58
59Next two are wake_up_new_task() statistics:
60 16) # of times wake_up_new_task() was called
61 17) # of times wake_up_new_task() successfully moved the new task
62
63Next one is a sched_migrate_task() statistic:
64 18) # of times sched_migrate_task() was called
65 47
66Next one is a sched_balance_exec() statistic: 48Next two are try_to_wake_up() statistics:
67 19) # of times sched_balance_exec() was called 49 8) # of times try_to_wake_up() was called
50 9) # of times try_to_wake_up() was called to wake up the local cpu
68 51
69Next three are statistics describing scheduling latency: 52Next three are statistics describing scheduling latency:
70 20) sum of all time spent running by tasks on this processor (in ms) 53 10) sum of all time spent running by tasks on this processor (in jiffies)
71 21) sum of all time spent waiting to run by tasks on this processor (in ms) 54 11) sum of all time spent waiting to run by tasks on this processor (in
72 22) # of tasks (not necessarily unique) given to the processor 55 jiffies)
73 56 12) # of timeslices run on this cpu
74The last six are statistics dealing with pull_task():
75 23) # of times pull_task() moved a task to this cpu when newly idle
76 24) # of times pull_task() stole a task from this cpu when another cpu
77 was newly idle
78 25) # of times pull_task() moved a task to this cpu when idle
79 26) # of times pull_task() stole a task from this cpu when another cpu
80 was idle
81 27) # of times pull_task() moved a task to this cpu when busy
82 28) # of times pull_task() stole a task from this cpu when another cpu
83 was busy
84 57
85 58
86Domain statistics 59Domain statistics
@@ -89,65 +62,95 @@ One of these is produced per domain for each cpu described. (Note that if
89CONFIG_SMP is not defined, *no* domains are utilized and these lines 62CONFIG_SMP is not defined, *no* domains are utilized and these lines
90will not appear in the output.) 63will not appear in the output.)
91 64
92domain<N> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 65domain<N> <cpumask> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
93 66
94The first field is a bit mask indicating what cpus this domain operates over. 67The first field is a bit mask indicating what cpus this domain operates over.
95 68
96The next fifteen are a variety of load_balance() statistics: 69The next 24 are a variety of load_balance() statistics in grouped into types
97 70of idleness (idle, busy, and newly idle):
98 1) # of times in this domain load_balance() was called when the cpu 71
99 was idle 72 1) # of times in this domain load_balance() was called when the
100 2) # of times in this domain load_balance() was called when the cpu 73 cpu was idle
101 was busy 74 2) # of times in this domain load_balance() checked but found
102 3) # of times in this domain load_balance() was called when the cpu 75 the load did not require balancing when the cpu was idle
103 was just becoming idle 76 3) # of times in this domain load_balance() tried to move one or
104 4) # of times in this domain load_balance() tried to move one or more 77 more tasks and failed, when the cpu was idle
105 tasks and failed, when the cpu was idle 78 4) sum of imbalances discovered (if any) with each call to
106 5) # of times in this domain load_balance() tried to move one or more 79 load_balance() in this domain when the cpu was idle
107 tasks and failed, when the cpu was busy 80 5) # of times in this domain pull_task() was called when the cpu
108 6) # of times in this domain load_balance() tried to move one or more 81 was idle
109 tasks and failed, when the cpu was just becoming idle 82 6) # of times in this domain pull_task() was called even though
110 7) sum of imbalances discovered (if any) with each call to 83 the target task was cache-hot when idle
111 load_balance() in this domain when the cpu was idle 84 7) # of times in this domain load_balance() was called but did
112 8) sum of imbalances discovered (if any) with each call to 85 not find a busier queue while the cpu was idle
113 load_balance() in this domain when the cpu was busy 86 8) # of times in this domain a busier queue was found while the
114 9) sum of imbalances discovered (if any) with each call to 87 cpu was idle but no busier group was found
115 load_balance() in this domain when the cpu was just becoming idle 88
116 10) # of times in this domain load_balance() was called but did not find 89 9) # of times in this domain load_balance() was called when the
117 a busier queue while the cpu was idle 90 cpu was busy
118 11) # of times in this domain load_balance() was called but did not find 91 10) # of times in this domain load_balance() checked but found the
119 a busier queue while the cpu was busy 92 load did not require balancing when busy
120 12) # of times in this domain load_balance() was called but did not find 93 11) # of times in this domain load_balance() tried to move one or
121 a busier queue while the cpu was just becoming idle 94 more tasks and failed, when the cpu was busy
122 13) # of times in this domain a busier queue was found while the cpu was 95 12) sum of imbalances discovered (if any) with each call to
123 idle but no busier group was found 96 load_balance() in this domain when the cpu was busy
124 14) # of times in this domain a busier queue was found while the cpu was 97 13) # of times in this domain pull_task() was called when busy
125 busy but no busier group was found 98 14) # of times in this domain pull_task() was called even though the
126 15) # of times in this domain a busier queue was found while the cpu was 99 target task was cache-hot when busy
127 just becoming idle but no busier group was found 100 15) # of times in this domain load_balance() was called but did not
128 101 find a busier queue while the cpu was busy
129Next two are sched_balance_exec() statistics: 102 16) # of times in this domain a busier queue was found while the cpu
130 17) # of times in this domain sched_balance_exec() successfully pushed 103 was busy but no busier group was found
131 a task to a new cpu 104
132 18) # of times in this domain sched_balance_exec() tried but failed to 105 17) # of times in this domain load_balance() was called when the
133 push a task to a new cpu 106 cpu was just becoming idle
134 107 18) # of times in this domain load_balance() checked but found the
135Next two are try_to_wake_up() statistics: 108 load did not require balancing when the cpu was just becoming idle
136 19) # of times in this domain try_to_wake_up() tried to move a task based 109 19) # of times in this domain load_balance() tried to move one or more
137 on affinity and cache warmth 110 tasks and failed, when the cpu was just becoming idle
138 20) # of times in this domain try_to_wake_up() tried to move a task based 111 20) sum of imbalances discovered (if any) with each call to
139 on load balancing 112 load_balance() in this domain when the cpu was just becoming idle
140 113 21) # of times in this domain pull_task() was called when newly idle
114 22) # of times in this domain pull_task() was called even though the
115 target task was cache-hot when just becoming idle
116 23) # of times in this domain load_balance() was called but did not
117 find a busier queue while the cpu was just becoming idle
118 24) # of times in this domain a busier queue was found while the cpu
119 was just becoming idle but no busier group was found
120
121 Next three are active_load_balance() statistics:
122 25) # of times active_load_balance() was called
123 26) # of times active_load_balance() tried to move a task and failed
124 27) # of times active_load_balance() successfully moved a task
125
126 Next three are sched_balance_exec() statistics:
127 28) sbe_cnt is not used
128 29) sbe_balanced is not used
129 30) sbe_pushed is not used
130
131 Next three are sched_balance_fork() statistics:
132 31) sbf_cnt is not used
133 32) sbf_balanced is not used
134 33) sbf_pushed is not used
135
136 Next three are try_to_wake_up() statistics:
137 34) # of times in this domain try_to_wake_up() awoke a task that
138 last ran on a different cpu in this domain
139 35) # of times in this domain try_to_wake_up() moved a task to the
140 waking cpu because it was cache-cold on its own cpu anyway
141 36) # of times in this domain try_to_wake_up() started passive balancing
141 142
142/proc/<pid>/schedstat 143/proc/<pid>/schedstat
143---------------- 144----------------
144schedstats also adds a new /proc/<pid/schedstat file to include some of 145schedstats also adds a new /proc/<pid/schedstat file to include some of
145the same information on a per-process level. There are three fields in 146the same information on a per-process level. There are three fields in
146this file correlating to fields 20, 21, and 22 in the CPU fields, but 147this file correlating for that process to:
147they only apply for that process. 148 1) time spent on the cpu
149 2) time spent waiting on a runqueue
150 3) # of timeslices run on this cpu
148 151
149A program could be easily written to make use of these extra fields to 152A program could be easily written to make use of these extra fields to
150report on how well a particular process or set of processes is faring 153report on how well a particular process or set of processes is faring
151under the scheduler's policies. A simple version of such a program is 154under the scheduler's policies. A simple version of such a program is
152available at 155available at
153 http://eaglet.rain.com/rick/linux/schedstat/v10/latency.c 156 http://eaglet.rain.com/rick/linux/schedstat/v12/latency.c
diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c
new file mode 100644
index 000000000000..218e86215297
--- /dev/null
+++ b/Documentation/spi/spidev_test.c
@@ -0,0 +1,202 @@
1/*
2 * SPI testing utility (using spidev driver)
3 *
4 * Copyright (c) 2007 MontaVista Software, Inc.
5 * Copyright (c) 2007 Anton Vorontsov <avorontsov@ru.mvista.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License.
10 *
11 * Cross-compile with cross-gcc -I/path/to/cross-kernel/include
12 */
13
14#include <stdint.h>
15#include <unistd.h>
16#include <stdio.h>
17#include <stdlib.h>
18#include <getopt.h>
19#include <fcntl.h>
20#include <sys/ioctl.h>
21#include <linux/types.h>
22#include <linux/spi/spidev.h>
23
24#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
25
26static void pabort(const char *s)
27{
28 perror(s);
29 abort();
30}
31
32static char *device = "/dev/spidev1.1";
33static uint8_t mode;
34static uint8_t bits = 8;
35static uint32_t speed = 500000;
36static uint16_t delay;
37
38static void transfer(int fd)
39{
40 int ret;
41 uint8_t tx[] = {
42 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
43 0x40, 0x00, 0x00, 0x00, 0x00, 0x95,
44 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
45 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
46 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
47 0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xAD,
48 0xF0, 0x0D,
49 };
50 uint8_t rx[ARRAY_SIZE(tx)] = {0, };
51 struct spi_ioc_transfer tr = {
52 .tx_buf = (unsigned long)tx,
53 .rx_buf = (unsigned long)rx,
54 .len = ARRAY_SIZE(tx),
55 .delay_usecs = delay,
56 .speed_hz = speed,
57 .bits_per_word = bits,
58 };
59
60 ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
61 if (ret == 1)
62 pabort("can't send spi message");
63
64 for (ret = 0; ret < ARRAY_SIZE(tx); ret++) {
65 if (!(ret % 6))
66 puts("");
67 printf("%.2X ", rx[ret]);
68 }
69 puts("");
70}
71
72void print_usage(char *prog)
73{
74 printf("Usage: %s [-DsbdlHOLC3]\n", prog);
75 puts(" -D --device device to use (default /dev/spidev1.1)\n"
76 " -s --speed max speed (Hz)\n"
77 " -d --delay delay (usec)\n"
78 " -b --bpw bits per word \n"
79 " -l --loop loopback\n"
80 " -H --cpha clock phase\n"
81 " -O --cpol clock polarity\n"
82 " -L --lsb least significant bit first\n"
83 " -C --cs-high chip select active high\n"
84 " -3 --3wire SI/SO signals shared\n");
85 exit(1);
86}
87
88void parse_opts(int argc, char *argv[])
89{
90 while (1) {
91 static struct option lopts[] = {
92 { "device", 1, 0, 'D' },
93 { "speed", 1, 0, 's' },
94 { "delay", 1, 0, 'd' },
95 { "bpw", 1, 0, 'b' },
96 { "loop", 0, 0, 'l' },
97 { "cpha", 0, 0, 'H' },
98 { "cpol", 0, 0, 'O' },
99 { "lsb", 0, 0, 'L' },
100 { "cs-high", 0, 0, 'C' },
101 { "3wire", 0, 0, '3' },
102 { NULL, 0, 0, 0 },
103 };
104 int c;
105
106 c = getopt_long(argc, argv, "D:s:d:b:lHOLC3", lopts, NULL);
107
108 if (c == -1)
109 break;
110
111 switch (c) {
112 case 'D':
113 device = optarg;
114 break;
115 case 's':
116 speed = atoi(optarg);
117 break;
118 case 'd':
119 delay = atoi(optarg);
120 break;
121 case 'b':
122 bits = atoi(optarg);
123 break;
124 case 'l':
125 mode |= SPI_LOOP;
126 break;
127 case 'H':
128 mode |= SPI_CPHA;
129 break;
130 case 'O':
131 mode |= SPI_CPOL;
132 break;
133 case 'L':
134 mode |= SPI_LSB_FIRST;
135 break;
136 case 'C':
137 mode |= SPI_CS_HIGH;
138 break;
139 case '3':
140 mode |= SPI_3WIRE;
141 break;
142 default:
143 print_usage(argv[0]);
144 break;
145 }
146 }
147}
148
149int main(int argc, char *argv[])
150{
151 int ret = 0;
152 int fd;
153
154 parse_opts(argc, argv);
155
156 fd = open(device, O_RDWR);
157 if (fd < 0)
158 pabort("can't open device");
159
160 /*
161 * spi mode
162 */
163 ret = ioctl(fd, SPI_IOC_WR_MODE, &mode);
164 if (ret == -1)
165 pabort("can't set spi mode");
166
167 ret = ioctl(fd, SPI_IOC_RD_MODE, &mode);
168 if (ret == -1)
169 pabort("can't get spi mode");
170
171 /*
172 * bits per word
173 */
174 ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits);
175 if (ret == -1)
176 pabort("can't set bits per word");
177
178 ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits);
179 if (ret == -1)
180 pabort("can't get bits per word");
181
182 /*
183 * max speed hz
184 */
185 ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
186 if (ret == -1)
187 pabort("can't set max speed hz");
188
189 ret = ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed);
190 if (ret == -1)
191 pabort("can't get max speed hz");
192
193 printf("spi mode: %d\n", mode);
194 printf("bits per word: %d\n", bits);
195 printf("max speed: %d Hz (%d KHz)\n", speed, speed/1000);
196
197 transfer(fd);
198
199 close(fd);
200
201 return ret;
202}
diff --git a/Documentation/stable_api_nonsense.txt b/Documentation/stable_api_nonsense.txt
index a2afca3b2bab..847b342b7b20 100644
--- a/Documentation/stable_api_nonsense.txt
+++ b/Documentation/stable_api_nonsense.txt
@@ -10,7 +10,7 @@ kernel to userspace interfaces. The kernel to userspace interface is
10the one that application programs use, the syscall interface. That 10the one that application programs use, the syscall interface. That
11interface is _very_ stable over time, and will not break. I have old 11interface is _very_ stable over time, and will not break. I have old
12programs that were built on a pre 0.9something kernel that still work 12programs that were built on a pre 0.9something kernel that still work
13just fine on the latest 2.6 kernel release. This interface is the one 13just fine on the latest 2.6 kernel release. That interface is the one
14that users and application programmers can count on being stable. 14that users and application programmers can count on being stable.
15 15
16 16
diff --git a/Documentation/sysfs-rules.txt b/Documentation/sysfs-rules.txt
index 42861bb0bc9b..80ef562160bb 100644
--- a/Documentation/sysfs-rules.txt
+++ b/Documentation/sysfs-rules.txt
@@ -1,19 +1,18 @@
1Rules on how to access information in the Linux kernel sysfs 1Rules on how to access information in the Linux kernel sysfs
2 2
3The kernel exported sysfs exports internal kernel implementation-details 3The kernel-exported sysfs exports internal kernel implementation details
4and depends on internal kernel structures and layout. It is agreed upon 4and depends on internal kernel structures and layout. It is agreed upon
5by the kernel developers that the Linux kernel does not provide a stable 5by the kernel developers that the Linux kernel does not provide a stable
6internal API. As sysfs is a direct export of kernel internal 6internal API. As sysfs is a direct export of kernel internal
7structures, the sysfs interface can not provide a stable interface eighter, 7structures, the sysfs interface cannot provide a stable interface either;
8it may always change along with internal kernel changes. 8it may always change along with internal kernel changes.
9 9
10To minimize the risk of breaking users of sysfs, which are in most cases 10To minimize the risk of breaking users of sysfs, which are in most cases
11low-level userspace applications, with a new kernel release, the users 11low-level userspace applications, with a new kernel release, the users
12of sysfs must follow some rules to use an as abstract-as-possible way to 12of sysfs must follow some rules to use an as-abstract-as-possible way to
13access this filesystem. The current udev and HAL programs already 13access this filesystem. The current udev and HAL programs already
14implement this and users are encouraged to plug, if possible, into the 14implement this and users are encouraged to plug, if possible, into the
15abstractions these programs provide instead of accessing sysfs 15abstractions these programs provide instead of accessing sysfs directly.
16directly.
17 16
18But if you really do want or need to access sysfs directly, please follow 17But if you really do want or need to access sysfs directly, please follow
19the following rules and then your programs should work with future 18the following rules and then your programs should work with future
@@ -25,22 +24,22 @@ versions of the sysfs interface.
25 implementation details in its own API. Therefore it is not better than 24 implementation details in its own API. Therefore it is not better than
26 reading directories and opening the files yourself. 25 reading directories and opening the files yourself.
27 Also, it is not actively maintained, in the sense of reflecting the 26 Also, it is not actively maintained, in the sense of reflecting the
28 current kernel-development. The goal of providing a stable interface 27 current kernel development. The goal of providing a stable interface
29 to sysfs has failed, it causes more problems, than it solves. It 28 to sysfs has failed; it causes more problems than it solves. It
30 violates many of the rules in this document. 29 violates many of the rules in this document.
31 30
32- sysfs is always at /sys 31- sysfs is always at /sys
33 Parsing /proc/mounts is a waste of time. Other mount points are a 32 Parsing /proc/mounts is a waste of time. Other mount points are a
34 system configuration bug you should not try to solve. For test cases, 33 system configuration bug you should not try to solve. For test cases,
35 possibly support a SYSFS_PATH environment variable to overwrite the 34 possibly support a SYSFS_PATH environment variable to overwrite the
36 applications behavior, but never try to search for sysfs. Never try 35 application's behavior, but never try to search for sysfs. Never try
37 to mount it, if you are not an early boot script. 36 to mount it, if you are not an early boot script.
38 37
39- devices are only "devices" 38- devices are only "devices"
40 There is no such thing like class-, bus-, physical devices, 39 There is no such thing like class-, bus-, physical devices,
41 interfaces, and such that you can rely on in userspace. Everything is 40 interfaces, and such that you can rely on in userspace. Everything is
42 just simply a "device". Class-, bus-, physical, ... types are just 41 just simply a "device". Class-, bus-, physical, ... types are just
43 kernel implementation details, which should not be expected by 42 kernel implementation details which should not be expected by
44 applications that look for devices in sysfs. 43 applications that look for devices in sysfs.
45 44
46 The properties of a device are: 45 The properties of a device are:
@@ -48,11 +47,11 @@ versions of the sysfs interface.
48 - identical to the DEVPATH value in the event sent from the kernel 47 - identical to the DEVPATH value in the event sent from the kernel
49 at device creation and removal 48 at device creation and removal
50 - the unique key to the device at that point in time 49 - the unique key to the device at that point in time
51 - the kernels path to the device-directory without the leading 50 - the kernel's path to the device directory without the leading
52 /sys, and always starting with with a slash 51 /sys, and always starting with with a slash
53 - all elements of a devpath must be real directories. Symlinks 52 - all elements of a devpath must be real directories. Symlinks
54 pointing to /sys/devices must always be resolved to their real 53 pointing to /sys/devices must always be resolved to their real
55 target, and the target path must be used to access the device. 54 target and the target path must be used to access the device.
56 That way the devpath to the device matches the devpath of the 55 That way the devpath to the device matches the devpath of the
57 kernel used at event time. 56 kernel used at event time.
58 - using or exposing symlink values as elements in a devpath string 57 - using or exposing symlink values as elements in a devpath string
@@ -73,17 +72,17 @@ versions of the sysfs interface.
73 link 72 link
74 - it is retrieved by reading the "driver"-link and using only the 73 - it is retrieved by reading the "driver"-link and using only the
75 last element of the target path 74 last element of the target path
76 - devices which do not have "driver"-link, just do not have a 75 - devices which do not have "driver"-link just do not have a
77 driver; copying the driver value in a child device context, is a 76 driver; copying the driver value in a child device context is a
78 bug in the application 77 bug in the application
79 78
80 o attributes 79 o attributes
81 - the files in the device directory or files below a subdirectories 80 - the files in the device directory or files below subdirectories
82 of the same device directory 81 of the same device directory
83 - accessing attributes reached by a symlink pointing to another device, 82 - accessing attributes reached by a symlink pointing to another device,
84 like the "device"-link, is a bug in the application 83 like the "device"-link, is a bug in the application
85 84
86 Everything else is just a kernel driver-core implementation detail, 85 Everything else is just a kernel driver-core implementation detail
87 that should not be assumed to be stable across kernel releases. 86 that should not be assumed to be stable across kernel releases.
88 87
89- Properties of parent devices never belong into a child device. 88- Properties of parent devices never belong into a child device.
@@ -91,25 +90,25 @@ versions of the sysfs interface.
91 context properties. If the device 'eth0' or 'sda' does not have a 90 context properties. If the device 'eth0' or 'sda' does not have a
92 "driver"-link, then this device does not have a driver. Its value is empty. 91 "driver"-link, then this device does not have a driver. Its value is empty.
93 Never copy any property of the parent-device into a child-device. Parent 92 Never copy any property of the parent-device into a child-device. Parent
94 device-properties may change dynamically without any notice to the 93 device properties may change dynamically without any notice to the
95 child device. 94 child device.
96 95
97- Hierarchy in a single device-tree 96- Hierarchy in a single device tree
98 There is only one valid place in sysfs where hierarchy can be examined 97 There is only one valid place in sysfs where hierarchy can be examined
99 and this is below: /sys/devices. 98 and this is below: /sys/devices.
100 It is planned, that all device directories will end up in the tree 99 It is planned that all device directories will end up in the tree
101 below this directory. 100 below this directory.
102 101
103- Classification by subsystem 102- Classification by subsystem
104 There are currently three places for classification of devices: 103 There are currently three places for classification of devices:
105 /sys/block, /sys/class and /sys/bus. It is planned that these will 104 /sys/block, /sys/class and /sys/bus. It is planned that these will
106 not contain any device-directories themselves, but only flat lists of 105 not contain any device directories themselves, but only flat lists of
107 symlinks pointing to the unified /sys/devices tree. 106 symlinks pointing to the unified /sys/devices tree.
108 All three places have completely different rules on how to access 107 All three places have completely different rules on how to access
109 device information. It is planned to merge all three 108 device information. It is planned to merge all three
110 classification-directories into one place at /sys/subsystem, 109 classification directories into one place at /sys/subsystem,
111 following the layout of the bus-directories. All buses and 110 following the layout of the bus directories. All buses and
112 classes, including the converted block-subsystem, will show up 111 classes, including the converted block subsystem, will show up
113 there. 112 there.
114 The devices belonging to a subsystem will create a symlink in the 113 The devices belonging to a subsystem will create a symlink in the
115 "devices" directory at /sys/subsystem/<name>/devices. 114 "devices" directory at /sys/subsystem/<name>/devices.
@@ -121,38 +120,38 @@ versions of the sysfs interface.
121 subsystem name. 120 subsystem name.
122 121
123 Assuming /sys/class/<subsystem> and /sys/bus/<subsystem>, or 122 Assuming /sys/class/<subsystem> and /sys/bus/<subsystem>, or
124 /sys/block and /sys/class/block are not interchangeable, is a bug in 123 /sys/block and /sys/class/block are not interchangeable is a bug in
125 the application. 124 the application.
126 125
127- Block 126- Block
128 The converted block-subsystem at /sys/class/block, or 127 The converted block subsystem at /sys/class/block or
129 /sys/subsystem/block will contain the links for disks and partitions 128 /sys/subsystem/block will contain the links for disks and partitions
130 at the same level, never in a hierarchy. Assuming the block-subsytem to 129 at the same level, never in a hierarchy. Assuming the block subsytem to
131 contain only disks and not partition-devices in the same flat list is 130 contain only disks and not partition devices in the same flat list is
132 a bug in the application. 131 a bug in the application.
133 132
134- "device"-link and <subsystem>:<kernel name>-links 133- "device"-link and <subsystem>:<kernel name>-links
135 Never depend on the "device"-link. The "device"-link is a workaround 134 Never depend on the "device"-link. The "device"-link is a workaround
136 for the old layout, where class-devices are not created in 135 for the old layout, where class devices are not created in
137 /sys/devices/ like the bus-devices. If the link-resolving of a 136 /sys/devices/ like the bus devices. If the link-resolving of a
138 device-directory does not end in /sys/devices/, you can use the 137 device directory does not end in /sys/devices/, you can use the
139 "device"-link to find the parent devices in /sys/devices/. That is the 138 "device"-link to find the parent devices in /sys/devices/. That is the
140 single valid use of the "device"-link, it must never appear in any 139 single valid use of the "device"-link; it must never appear in any
141 path as an element. Assuming the existence of the "device"-link for 140 path as an element. Assuming the existence of the "device"-link for
142 a device in /sys/devices/ is a bug in the application. 141 a device in /sys/devices/ is a bug in the application.
143 Accessing /sys/class/net/eth0/device is a bug in the application. 142 Accessing /sys/class/net/eth0/device is a bug in the application.
144 143
145 Never depend on the class-specific links back to the /sys/class 144 Never depend on the class-specific links back to the /sys/class
146 directory. These links are also a workaround for the design mistake 145 directory. These links are also a workaround for the design mistake
147 that class-devices are not created in /sys/devices. If a device 146 that class devices are not created in /sys/devices. If a device
148 directory does not contain directories for child devices, these links 147 directory does not contain directories for child devices, these links
149 may be used to find the child devices in /sys/class. That is the single 148 may be used to find the child devices in /sys/class. That is the single
150 valid use of these links, they must never appear in any path as an 149 valid use of these links; they must never appear in any path as an
151 element. Assuming the existence of these links for devices which are 150 element. Assuming the existence of these links for devices which are
152 real child device directories in the /sys/devices tree, is a bug in 151 real child device directories in the /sys/devices tree is a bug in
153 the application. 152 the application.
154 153
155 It is planned to remove all these links when when all class-device 154 It is planned to remove all these links when all class device
156 directories live in /sys/devices. 155 directories live in /sys/devices.
157 156
158- Position of devices along device chain can change. 157- Position of devices along device chain can change.
@@ -161,6 +160,5 @@ versions of the sysfs interface.
161 the chain. You must always request the parent device you are looking for 160 the chain. You must always request the parent device you are looking for
162 by its subsystem value. You need to walk up the chain until you find 161 by its subsystem value. You need to walk up the chain until you find
163 the device that matches the expected subsystem. Depending on a specific 162 the device that matches the expected subsystem. Depending on a specific
164 position of a parent device, or exposing relative paths, using "../" to 163 position of a parent device or exposing relative paths using "../" to
165 access the chain of parents, is a bug in the application. 164 access the chain of parents is a bug in the application.
166
diff --git a/MAINTAINERS b/MAINTAINERS
index 01f222e51871..1e15a0edc313 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -387,21 +387,6 @@ P: Jaya Kumar
387M: jayalk@intworks.biz 387M: jayalk@intworks.biz
388S: Maintained 388S: Maintained
389 389
390ARM26 ARCHITECTURE
391P: Ian Molton
392M: spyro@f2s.com
393S: Maintained
394
395ARM26/ARCHIMEDES
396P: Ian Molton
397M: spyro@f2s.com
398S: Maintained
399
400ARM26/A5000
401P: John Appleby
402M: john@dnsworld.co.uk
403S: Maintained
404
405ARM MFM AND FLOPPY DRIVERS 390ARM MFM AND FLOPPY DRIVERS
406P: Ian Molton 391P: Ian Molton
407M: spyro@f2s.com 392M: spyro@f2s.com
@@ -771,6 +756,14 @@ L: uclinux-dist-devel@blackfin.uclinux.org (subscribers-only)
771W: http://blackfin.uclinux.org 756W: http://blackfin.uclinux.org
772S: Supported 757S: Supported
773 758
759BLACKFIN WATCHDOG DRIVER
760P: Mike Frysinger
761M: michael.frysinger@analog.com
762M: vapier.adi@gmail.com
763L: uclinux-dist-devel@blackfin.uclinux.org (subscribers-only)
764W: http://blackfin.uclinux.org
765S: Supported
766
774BAYCOM/HDLCDRV DRIVERS FOR AX.25 767BAYCOM/HDLCDRV DRIVERS FOR AX.25
775P: Thomas Sailer 768P: Thomas Sailer
776M: t.sailer@alumni.ethz.ch 769M: t.sailer@alumni.ethz.ch
@@ -2171,6 +2164,8 @@ W: http://www.kerneljanitors.org/
2171S: Maintained 2164S: Maintained
2172 2165
2173KERNEL NFSD 2166KERNEL NFSD
2167P: J. Bruce Fields
2168M: bfields@fieldses.org
2174P: Neil Brown 2169P: Neil Brown
2175M: neilb@suse.de 2170M: neilb@suse.de
2176L: nfs@lists.sourceforge.net 2171L: nfs@lists.sourceforge.net
@@ -3339,6 +3334,14 @@ M: thomas@winischhofer.net
3339W: http://www.winischhofer.at/linuxsisusbvga.shtml 3334W: http://www.winischhofer.at/linuxsisusbvga.shtml
3340S: Maintained 3335S: Maintained
3341 3336
3337SLAB ALLOCATOR
3338P: Christoph Lameter
3339M: clameter@sgi.com
3340P: Pekka Enberg
3341M: penberg@cs.helsinki.fi
3342L: linux-mm@kvack.org
3343S: Maintained
3344
3342SMC91x ETHERNET DRIVER 3345SMC91x ETHERNET DRIVER
3343P: Nicolas Pitre 3346P: Nicolas Pitre
3344M: nico@cam.org 3347M: nico@cam.org
@@ -3666,11 +3669,9 @@ W: http://www.auk.cx/tms380tr/
3666S: Maintained 3669S: Maintained
3667 3670
3668TULIP NETWORK DRIVER 3671TULIP NETWORK DRIVER
3669P: Valerie Henson
3670M: val@nmt.edu
3671L: tulip-users@lists.sourceforge.net 3672L: tulip-users@lists.sourceforge.net
3672W: http://sourceforge.net/projects/tulip/ 3673W: http://sourceforge.net/projects/tulip/
3673S: Maintained 3674S: Orphan
3674 3675
3675TUN/TAP driver 3676TUN/TAP driver
3676P: Maxim Krasnyansky 3677P: Maxim Krasnyansky
diff --git a/Makefile b/Makefile
index 23f81c9f698e..dfe3d1610a7b 100644
--- a/Makefile
+++ b/Makefile
@@ -299,7 +299,7 @@ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(C
299MODFLAGS = -DMODULE 299MODFLAGS = -DMODULE
300CFLAGS_MODULE = $(MODFLAGS) 300CFLAGS_MODULE = $(MODFLAGS)
301AFLAGS_MODULE = $(MODFLAGS) 301AFLAGS_MODULE = $(MODFLAGS)
302LDFLAGS_MODULE = -r 302LDFLAGS_MODULE =
303CFLAGS_KERNEL = 303CFLAGS_KERNEL =
304AFLAGS_KERNEL = 304AFLAGS_KERNEL =
305 305
diff --git a/arch/alpha/boot/Makefile b/arch/alpha/boot/Makefile
index e1ae14cd2b4e..cd143887380a 100644
--- a/arch/alpha/boot/Makefile
+++ b/arch/alpha/boot/Makefile
@@ -104,7 +104,7 @@ OBJ_bootlx := $(obj)/head.o $(obj)/main.o
104OBJ_bootph := $(obj)/head.o $(obj)/bootp.o 104OBJ_bootph := $(obj)/head.o $(obj)/bootp.o
105OBJ_bootpzh := $(obj)/head.o $(obj)/bootpz.o $(obj)/misc.o 105OBJ_bootpzh := $(obj)/head.o $(obj)/bootpz.o $(obj)/misc.o
106 106
107$(obj)/bootloader: $(obj)/bootloader.lds $(OBJ_bootlx) FORCE 107$(obj)/bootloader: $(obj)/bootloader.lds $(OBJ_bootlx) $(LIBS_Y) FORCE
108 $(call if_changed,ld) 108 $(call if_changed,ld)
109 109
110$(obj)/bootpheader: $(obj)/bootloader.lds $(OBJ_bootph) $(LIBS_Y) FORCE 110$(obj)/bootpheader: $(obj)/bootloader.lds $(OBJ_bootph) $(LIBS_Y) FORCE
diff --git a/arch/alpha/boot/main.c b/arch/alpha/boot/main.c
index 90ed55b662a8..89f3be071ae5 100644
--- a/arch/alpha/boot/main.c
+++ b/arch/alpha/boot/main.c
@@ -132,7 +132,7 @@ static inline long load(long dev, unsigned long addr, unsigned long count)
132 if (result) 132 if (result)
133 srm_printk("Boot file specification (%s) not implemented\n", 133 srm_printk("Boot file specification (%s) not implemented\n",
134 bootfile); 134 bootfile);
135 return callback_read(dev, count, addr, boot_size/512 + 1); 135 return callback_read(dev, count, (void *)addr, boot_size/512 + 1);
136} 136}
137 137
138/* 138/*
diff --git a/arch/alpha/boot/tools/mkbb.c b/arch/alpha/boot/tools/mkbb.c
index 632a7fd6d7dc..1185778e6a1e 100644
--- a/arch/alpha/boot/tools/mkbb.c
+++ b/arch/alpha/boot/tools/mkbb.c
@@ -11,6 +11,7 @@
11 11
12#include <fcntl.h> 12#include <fcntl.h>
13#include <unistd.h> 13#include <unistd.h>
14#include <stdlib.h>
14#include <stdio.h> 15#include <stdio.h>
15 16
16/* Minimal definition of disklabel, so we don't have to include 17/* Minimal definition of disklabel, so we don't have to include
@@ -114,7 +115,7 @@ int main(int argc, char ** argv)
114 nread = read(fd, &bootloader_image, sizeof(bootblock)); 115 nread = read(fd, &bootloader_image, sizeof(bootblock));
115 if(nread != sizeof(bootblock)) { 116 if(nread != sizeof(bootblock)) {
116 perror("lxboot read"); 117 perror("lxboot read");
117 fprintf(stderr, "expected %d, got %d\n", sizeof(bootblock), nread); 118 fprintf(stderr, "expected %zd, got %d\n", sizeof(bootblock), nread);
118 exit(0); 119 exit(0);
119 } 120 }
120 121
@@ -122,7 +123,7 @@ int main(int argc, char ** argv)
122 nread = read(dev, &bootblock_from_disk, sizeof(bootblock)); 123 nread = read(dev, &bootblock_from_disk, sizeof(bootblock));
123 if(nread != sizeof(bootblock)) { 124 if(nread != sizeof(bootblock)) {
124 perror("bootblock read"); 125 perror("bootblock read");
125 fprintf(stderr, "expected %d, got %d\n", sizeof(bootblock), nread); 126 fprintf(stderr, "expected %zd, got %d\n", sizeof(bootblock), nread);
126 exit(0); 127 exit(0);
127 } 128 }
128 129
diff --git a/arch/alpha/boot/tools/objstrip.c b/arch/alpha/boot/tools/objstrip.c
index 96154e768a20..ef1838230291 100644
--- a/arch/alpha/boot/tools/objstrip.c
+++ b/arch/alpha/boot/tools/objstrip.c
@@ -144,7 +144,7 @@ main (int argc, char *argv[])
144#ifdef __ELF__ 144#ifdef __ELF__
145 elf = (struct elfhdr *) buf; 145 elf = (struct elfhdr *) buf;
146 146
147 if (elf->e_ident[0] == 0x7f && strncmp(elf->e_ident + 1, "ELF", 3) == 0) { 147 if (elf->e_ident[0] == 0x7f && strncmp((char *)elf->e_ident + 1, "ELF", 3) == 0) {
148 if (elf->e_type != ET_EXEC) { 148 if (elf->e_type != ET_EXEC) {
149 fprintf(stderr, "%s: %s is not an ELF executable\n", 149 fprintf(stderr, "%s: %s is not an ELF executable\n",
150 prog_name, inname); 150 prog_name, inname);
diff --git a/arch/alpha/kernel/head.S b/arch/alpha/kernel/head.S
index e27d23c74ba8..7ac1f1372c36 100644
--- a/arch/alpha/kernel/head.S
+++ b/arch/alpha/kernel/head.S
@@ -10,6 +10,7 @@
10#include <asm/system.h> 10#include <asm/system.h>
11#include <asm/asm-offsets.h> 11#include <asm/asm-offsets.h>
12 12
13.section .text.head, "ax"
13.globl swapper_pg_dir 14.globl swapper_pg_dir
14.globl _stext 15.globl _stext
15swapper_pg_dir=SWAPPER_PGD 16swapper_pg_dir=SWAPPER_PGD
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index ab642a4f08de..9dc1cee43265 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -195,7 +195,7 @@ pcibios_init(void)
195 195
196subsys_initcall(pcibios_init); 196subsys_initcall(pcibios_init);
197 197
198char * __init 198char * __devinit
199pcibios_setup(char *str) 199pcibios_setup(char *str)
200{ 200{
201 return str; 201 return str;
@@ -204,7 +204,7 @@ pcibios_setup(char *str)
204#ifdef ALPHA_RESTORE_SRM_SETUP 204#ifdef ALPHA_RESTORE_SRM_SETUP
205static struct pdev_srm_saved_conf *srm_saved_configs; 205static struct pdev_srm_saved_conf *srm_saved_configs;
206 206
207void __init 207void __devinit
208pdev_save_srm_config(struct pci_dev *dev) 208pdev_save_srm_config(struct pci_dev *dev)
209{ 209{
210 struct pdev_srm_saved_conf *tmp; 210 struct pdev_srm_saved_conf *tmp;
@@ -247,14 +247,14 @@ pci_restore_srm_config(void)
247} 247}
248#endif 248#endif
249 249
250void __init 250void __devinit
251pcibios_fixup_resource(struct resource *res, struct resource *root) 251pcibios_fixup_resource(struct resource *res, struct resource *root)
252{ 252{
253 res->start += root->start; 253 res->start += root->start;
254 res->end += root->start; 254 res->end += root->start;
255} 255}
256 256
257void __init 257void __devinit
258pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus) 258pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus)
259{ 259{
260 /* Update device resources. */ 260 /* Update device resources. */
@@ -273,7 +273,7 @@ pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus)
273 } 273 }
274} 274}
275 275
276void __init 276void __devinit
277pcibios_fixup_bus(struct pci_bus *bus) 277pcibios_fixup_bus(struct pci_bus *bus)
278{ 278{
279 /* Propagate hose info into the subordinate devices. */ 279 /* Propagate hose info into the subordinate devices. */
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 6b07f89a72c7..e1c470752ebc 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -58,7 +58,7 @@ size_for_memory(unsigned long max)
58 return max; 58 return max;
59} 59}
60 60
61struct pci_iommu_arena * 61struct pci_iommu_arena * __init
62iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base, 62iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,
63 unsigned long window_size, unsigned long align) 63 unsigned long window_size, unsigned long align)
64{ 64{
@@ -117,7 +117,7 @@ iommu_arena_new_node(int nid, struct pci_controller *hose, dma_addr_t base,
117 return arena; 117 return arena;
118} 118}
119 119
120struct pci_iommu_arena * 120struct pci_iommu_arena * __init
121iommu_arena_new(struct pci_controller *hose, dma_addr_t base, 121iommu_arena_new(struct pci_controller *hose, dma_addr_t base,
122 unsigned long window_size, unsigned long align) 122 unsigned long window_size, unsigned long align)
123{ 123{
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index b28731437c31..ad176441be55 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/err.h>
19#include <linux/threads.h> 20#include <linux/threads.h>
20#include <linux/smp.h> 21#include <linux/smp.h>
21#include <linux/interrupt.h> 22#include <linux/interrupt.h>
@@ -358,7 +359,7 @@ secondary_cpu_start(int cpuid, struct task_struct *idle)
358/* 359/*
359 * Bring one cpu online. 360 * Bring one cpu online.
360 */ 361 */
361static int __devinit 362static int __cpuinit
362smp_boot_one_cpu(int cpuid) 363smp_boot_one_cpu(int cpuid)
363{ 364{
364 struct task_struct *idle; 365 struct task_struct *idle;
@@ -487,7 +488,7 @@ smp_prepare_boot_cpu(void)
487{ 488{
488} 489}
489 490
490int __devinit 491int __cpuinit
491__cpu_up(unsigned int cpu) 492__cpu_up(unsigned int cpu)
492{ 493{
493 smp_boot_one_cpu(cpu); 494 smp_boot_one_cpu(cpu);
@@ -541,7 +542,7 @@ smp_percpu_timer_interrupt(struct pt_regs *regs)
541 set_irq_regs(old_regs); 542 set_irq_regs(old_regs);
542} 543}
543 544
544int __init 545int
545setup_profiling_timer(unsigned int multiplier) 546setup_profiling_timer(unsigned int multiplier)
546{ 547{
547 return -EINVAL; 548 return -EINVAL;
diff --git a/arch/alpha/kernel/vmlinux.lds.S b/arch/alpha/kernel/vmlinux.lds.S
index fe13daa5cb2c..7af07d3ad5f0 100644
--- a/arch/alpha/kernel/vmlinux.lds.S
+++ b/arch/alpha/kernel/vmlinux.lds.S
@@ -15,6 +15,7 @@ SECTIONS
15 15
16 _text = .; /* Text and read-only data */ 16 _text = .; /* Text and read-only data */
17 .text : { 17 .text : {
18 *(.text.head)
18 TEXT_TEXT 19 TEXT_TEXT
19 SCHED_TEXT 20 SCHED_TEXT
20 LOCK_TEXT 21 LOCK_TEXT
diff --git a/arch/alpha/mm/init.c b/arch/alpha/mm/init.c
index 550f4907d613..5e6da47779a4 100644
--- a/arch/alpha/mm/init.c
+++ b/arch/alpha/mm/init.c
@@ -267,8 +267,7 @@ callback_init(void * kernel_end)
267/* 267/*
268 * paging_init() sets up the memory map. 268 * paging_init() sets up the memory map.
269 */ 269 */
270void 270void __init paging_init(void)
271paging_init(void)
272{ 271{
273 unsigned long zones_size[MAX_NR_ZONES] = {0, }; 272 unsigned long zones_size[MAX_NR_ZONES] = {0, };
274 unsigned long dma_pfn, high_pfn; 273 unsigned long dma_pfn, high_pfn;
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 85016313bd11..d6145298a325 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -341,6 +341,7 @@ config ARCH_PXA
341 select ARCH_MTD_XIP 341 select ARCH_MTD_XIP
342 select GENERIC_GPIO 342 select GENERIC_GPIO
343 select GENERIC_TIME 343 select GENERIC_TIME
344 select GENERIC_CLOCKEVENTS
344 help 345 help
345 Support for Intel's PXA2XX processor line. 346 Support for Intel's PXA2XX processor line.
346 347
@@ -990,8 +991,6 @@ source "drivers/pnp/Kconfig"
990 991
991source "drivers/block/Kconfig" 992source "drivers/block/Kconfig"
992 993
993source "drivers/acorn/block/Kconfig"
994
995if PCMCIA || ARCH_CLPS7500 || ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX \ 994if PCMCIA || ARCH_CLPS7500 || ARCH_IOP32X || ARCH_IOP33X || ARCH_IXP4XX \
996 || ARCH_L7200 || ARCH_LH7A40X || ARCH_PXA || ARCH_RPC \ 995 || ARCH_L7200 || ARCH_LH7A40X || ARCH_PXA || ARCH_RPC \
997 || ARCH_S3C2410 || ARCH_SA1100 || ARCH_SHARK || FOOTBRIDGE \ 996 || ARCH_S3C2410 || ARCH_SA1100 || ARCH_SHARK || FOOTBRIDGE \
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index c589dc3ecd1a..33e6cc2ffd3b 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -46,7 +46,7 @@ fast_work_pending:
46work_pending: 46work_pending:
47 tst r1, #_TIF_NEED_RESCHED 47 tst r1, #_TIF_NEED_RESCHED
48 bne work_resched 48 bne work_resched
49 tst r1, #_TIF_NOTIFY_RESUME | _TIF_SIGPENDING 49 tst r1, #_TIF_SIGPENDING
50 beq no_work_pending 50 beq no_work_pending
51 mov r0, sp @ 'regs' 51 mov r0, sp @ 'regs'
52 mov r2, why @ 'syscall' 52 mov r2, why @ 'syscall'
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 5be2e987b843..4de432ec903a 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -23,6 +23,7 @@
23#include <linux/cpu.h> 23#include <linux/cpu.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/smp.h> 25#include <linux/smp.h>
26#include <linux/fs.h>
26 27
27#include <asm/cpu.h> 28#include <asm/cpu.h>
28#include <asm/elf.h> 29#include <asm/elf.h>
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 1b76d87fa335..eafbb2b05eb8 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -17,6 +17,7 @@
17#include <linux/profile.h> 17#include <linux/profile.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/err.h>
20#include <linux/cpu.h> 21#include <linux/cpu.h>
21#include <linux/smp.h> 22#include <linux/smp.h>
22#include <linux/seq_file.h> 23#include <linux/seq_file.h>
@@ -630,7 +631,7 @@ void smp_send_stop(void)
630/* 631/*
631 * not supported here 632 * not supported here
632 */ 633 */
633int __init setup_profiling_timer(unsigned int multiplier) 634int setup_profiling_timer(unsigned int multiplier)
634{ 635{
635 return -EINVAL; 636 return -EINVAL;
636} 637}
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index f2114bcf09d5..8ad47619c079 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -352,10 +352,8 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
352 352
353asmlinkage void do_unexp_fiq (struct pt_regs *regs) 353asmlinkage void do_unexp_fiq (struct pt_regs *regs)
354{ 354{
355#ifndef CONFIG_IGNORE_FIQ
356 printk("Hmm. Unexpected FIQ received, but trying to continue\n"); 355 printk("Hmm. Unexpected FIQ received, but trying to continue\n");
357 printk("You may have a hardware problem...\n"); 356 printk("You may have a hardware problem...\n");
358#endif
359} 357}
360 358
361/* 359/*
diff --git a/arch/arm/mach-sa1100/jornada720.c b/arch/arm/mach-sa1100/jornada720.c
index 64067cd58d36..52ac37d1e23a 100644
--- a/arch/arm/mach-sa1100/jornada720.c
+++ b/arch/arm/mach-sa1100/jornada720.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * HP Jornada720 init code 4 * HP Jornada720 init code
5 * 5 *
6 * Copyright (C) 2007 Kristoffer Ericson <Kristoffer.Ericson@gmail.com>
6 * Copyright (C) 2006 Filip Zyzniewski <filip.zyzniewski@tefnet.pl> 7 * Copyright (C) 2006 Filip Zyzniewski <filip.zyzniewski@tefnet.pl>
7 * Copyright (C) 2005 Michael Gernoth <michael@gernoth.net> 8 * Copyright (C) 2005 Michael Gernoth <michael@gernoth.net>
8 * 9 *
@@ -220,14 +221,16 @@ static struct platform_device sa1111_device = {
220 .resource = sa1111_resources, 221 .resource = sa1111_resources,
221}; 222};
222 223
223static struct platform_device jornada720_mcu_device = { 224static struct platform_device jornada_ssp_device = {
224 .name = "jornada720_mcu", 225 .name = "jornada_ssp",
225 .id = -1, 226 .id = -1,
226}; 227};
227 228
228static struct platform_device *devices[] __initdata = { 229static struct platform_device *devices[] __initdata = {
229 &sa1111_device, 230 &sa1111_device,
230 &jornada720_mcu_device, 231#ifdef CONFIG_SA1100_JORNADA720_SSP
232 &jornada_ssp_device,
233#endif
231 &s1d13xxxfb_device, 234 &s1d13xxxfb_device,
232}; 235};
233 236
@@ -236,19 +239,19 @@ static int __init jornada720_init(void)
236 int ret = -ENODEV; 239 int ret = -ENODEV;
237 240
238 if (machine_is_jornada720()) { 241 if (machine_is_jornada720()) {
239 GPDR |= GPIO_GPIO20; 242 /* we want to use gpio20 as input to drive the clock of our uart 3 */
240 /* oscillator setup (line 116 of HP's doc) */ 243 GPDR |= GPIO_GPIO20; /* Clear gpio20 pin as input */
241 TUCR = TUCR_VAL; 244 TUCR = TUCR_VAL;
242 /* resetting SA1111 (line 118 of HP's doc) */ 245 GPSR = GPIO_GPIO20; /* start gpio20 pin */
243 GPSR = GPIO_GPIO20;
244 udelay(1); 246 udelay(1);
245 GPCR = GPIO_GPIO20; 247 GPCR = GPIO_GPIO20; /* stop gpio20 */
246 udelay(1); 248 udelay(1);
247 GPSR = GPIO_GPIO20; 249 GPSR = GPIO_GPIO20; /* restart gpio20 */
248 udelay(20); 250 udelay(20); /* give it some time to restart */
249 251
250 ret = platform_add_devices(devices, ARRAY_SIZE(devices)); 252 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
251 } 253 }
254
252 return ret; 255 return ret;
253} 256}
254 257
@@ -345,7 +348,7 @@ static void __init jornada720_mach_init(void)
345} 348}
346 349
347MACHINE_START(JORNADA720, "HP Jornada 720") 350MACHINE_START(JORNADA720, "HP Jornada 720")
348 /* Maintainer: Michael Gernoth <michael@gernoth.net> */ 351 /* Maintainer: Kristoffer Ericson <Kristoffer.Ericson@gmail.com> */
349 .phys_io = 0x80000000, 352 .phys_io = 0x80000000,
350 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc, 353 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
351 .boot_params = 0xc0000100, 354 .boot_params = 0xc0000100,
diff --git a/arch/arm/mach-sa1100/jornada720_ssp.c b/arch/arm/mach-sa1100/jornada720_ssp.c
index 0a45e1ac8ad6..395c39bed7d8 100644
--- a/arch/arm/mach-sa1100/jornada720_ssp.c
+++ b/arch/arm/mach-sa1100/jornada720_ssp.c
@@ -161,7 +161,7 @@ static int __init jornada_ssp_probe(struct platform_device *dev)
161 ret = jornada_ssp_inout(GETBRIGHTNESS); 161 ret = jornada_ssp_inout(GETBRIGHTNESS);
162 162
163 /* seems like it worked, just feed it with TxDummy to get rid of data */ 163 /* seems like it worked, just feed it with TxDummy to get rid of data */
164 if (ret == TxDummy) 164 if (ret == TXDUMMY)
165 jornada_ssp_inout(TXDUMMY); 165 jornada_ssp_inout(TXDUMMY);
166 166
167 jornada_ssp_end(); 167 jornada_ssp_end();
diff --git a/arch/arm/nwfpe/Makefile b/arch/arm/nwfpe/Makefile
index ed7b26bf73f5..b29178c0414e 100644
--- a/arch/arm/nwfpe/Makefile
+++ b/arch/arm/nwfpe/Makefile
@@ -9,5 +9,4 @@ nwfpe-y += fpa11.o fpa11_cpdo.o fpa11_cpdt.o \
9 softfloat.o single_cpdo.o double_cpdo.o 9 softfloat.o single_cpdo.o double_cpdo.o
10 10
11nwfpe-$(CONFIG_FPE_NWFPE_XP) += extended_cpdo.o 11nwfpe-$(CONFIG_FPE_NWFPE_XP) += extended_cpdo.o
12nwfpe-$(CONFIG_CPU_26) += entry26.o
13nwfpe-$(CONFIG_CPU_32) += entry.o 12nwfpe-$(CONFIG_CPU_32) += entry.o
diff --git a/arch/arm/nwfpe/entry26.S b/arch/arm/nwfpe/entry26.S
deleted file mode 100644
index 3e6fb5d21d64..000000000000
--- a/arch/arm/nwfpe/entry26.S
+++ /dev/null
@@ -1,112 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998
4 (c) Philip Blundell 1998-1999
5
6 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/
22
23#include <asm/asm-offsets.h>
24
25/* This is the kernel's entry point into the floating point emulator.
26It is called from the kernel with code similar to this:
27
28 mov fp, #0
29 teqp pc, #PSR_I_BIT | SVC_MODE
30 ldr r4, .LC2
31 ldr pc, [r4] @ Call FP module USR entry point
32
33The kernel expects the emulator to return via one of two possible
34points of return it passes to the emulator. The emulator, if
35successful in its emulation, jumps to ret_from_exception and the
36kernel takes care of returning control from the trap to the user code.
37If the emulator is unable to emulate the instruction, it returns to
38fpundefinstr and the kernel halts the user program with a core dump.
39
40This routine does four things:
41
421) It saves SP into a variable called userRegisters. The kernel has
43created a struct pt_regs on the stack and saved the user registers
44into it. See /usr/include/asm/proc/ptrace.h for details. The
45emulator code uses userRegisters as the base of an array of words from
46which the contents of the registers can be extracted.
47
482) It locates the FP emulator work area within the TSS structure and
49points `fpa11' to it.
50
513) It calls EmulateAll to emulate a floating point instruction.
52EmulateAll returns 1 if the emulation was successful, or 0 if not.
53
544) If an instruction has been emulated successfully, it looks ahead at
55the next instruction. If it is a floating point instruction, it
56executes the instruction, without returning to user space. In this
57way it repeatedly looks ahead and executes floating point instructions
58until it encounters a non floating point instruction, at which time it
59returns via _fpreturn.
60
61This is done to reduce the effect of the trap overhead on each
62floating point instructions. GCC attempts to group floating point
63instructions to allow the emulator to spread the cost of the trap over
64several floating point instructions. */
65
66 .globl nwfpe_enter
67nwfpe_enter:
68 mov sl, sp
69 ldr r5, [sp, #60] @ get contents of PC
70 bic r5, r5, #0xfc000003
71 ldr r0, [r5, #-4] @ get actual instruction into r0
72 bl EmulateAll @ emulate the instruction
731: cmp r0, #0 @ was emulation successful
74 beq fpundefinstr @ no, return failure
75
76next:
77.Lx1: ldrt r6, [r5], #4 @ get the next instruction and
78 @ increment PC
79
80 and r2, r6, #0x0F000000 @ test for FP insns
81 teq r2, #0x0C000000
82 teqne r2, #0x0D000000
83 teqne r2, #0x0E000000
84 bne ret_from_exception @ return ok if not a fp insn
85
86 ldr r9, [sp, #60] @ get new condition codes
87 and r9, r9, #0xfc000003
88 orr r7, r5, r9
89 str r7, [sp, #60] @ update PC copy in regs
90
91 mov r0, r6 @ save a copy
92 mov r1, r9 @ fetch the condition codes
93 bl checkCondition @ check the condition
94 cmp r0, #0 @ r0 = 0 ==> condition failed
95
96 @ if condition code failed to match, next insn
97 beq next @ get the next instruction;
98
99 mov r0, r6 @ prepare for EmulateAll()
100 adr lr, 1b
101 orr lr, lr, #3
102 b EmulateAll @ if r0 != 0, goto EmulateAll
103
104.Lret: b ret_from_exception @ let the user eat segfaults
105
106 @ We need to be prepared for the instruction at .Lx1 to fault.
107 @ Emit the appropriate exception gunk to fix things up.
108 .section __ex_table,"a"
109 .align 3
110 .long .Lx1
111 ldr lr, [lr, $(.Lret - .Lx1)/4]
112 .previous
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index de7e6ef48bd0..0360b1f14d11 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -161,11 +161,11 @@ static void mbox_rx_work(struct work_struct *work)
161/* 161/*
162 * Mailbox interrupt handler 162 * Mailbox interrupt handler
163 */ 163 */
164static void mbox_txq_fn(request_queue_t * q) 164static void mbox_txq_fn(struct request_queue * q)
165{ 165{
166} 166}
167 167
168static void mbox_rxq_fn(request_queue_t * q) 168static void mbox_rxq_fn(struct request_queue * q)
169{ 169{
170} 170}
171 171
@@ -180,7 +180,7 @@ static void __mbox_rx_interrupt(struct omap_mbox *mbox)
180{ 180{
181 struct request *rq; 181 struct request *rq;
182 mbox_msg_t msg; 182 mbox_msg_t msg;
183 request_queue_t *q = mbox->rxq->queue; 183 struct request_queue *q = mbox->rxq->queue;
184 184
185 disable_mbox_irq(mbox, IRQ_RX); 185 disable_mbox_irq(mbox, IRQ_RX);
186 186
@@ -297,7 +297,7 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox,
297 request_fn_proc * proc, 297 request_fn_proc * proc,
298 void (*work) (struct work_struct *)) 298 void (*work) (struct work_struct *))
299{ 299{
300 request_queue_t *q; 300 struct request_queue *q;
301 struct omap_mbox_queue *mq; 301 struct omap_mbox_queue *mq;
302 302
303 mq = kzalloc(sizeof(struct omap_mbox_queue), GFP_KERNEL); 303 mq = kzalloc(sizeof(struct omap_mbox_queue), GFP_KERNEL);
diff --git a/arch/arm26/ACKNOWLEDGEMENTS b/arch/arm26/ACKNOWLEDGEMENTS
deleted file mode 100644
index 0a17a45110e7..000000000000
--- a/arch/arm26/ACKNOWLEDGEMENTS
+++ /dev/null
@@ -1,29 +0,0 @@
1The work in this architecture (ARM26) is that of a great many people.
2
3This is what has happened:
4
5I [Ian Molton] have been trying to repair the ARM26 architecture support, but it has become an impossible task whilst it is still merged with the ARM32 (arch/arm) code. The ARM26 code is too different to be sensible to keep with the ARM32 code now, and Russell King really doesnt have the time to maintain the ARM26 code. Add to that that most ARM32 developers dont know about or care about ARM26 when writing patches, and you have a reall mess.
6
7As a result, I've split it off into a new architecture of its own. I've named it arm26 since these CPUs have only a 26 bit address space, unlike the other ARMs.
8
9The upheaval in moving around so many source files and chopping out vasty ammounts of cruft was enormous, and the copyright of many files is sometimes unclear. Because of this, I am writing this, in order that no-one is left out / misaccredited / blamed for any of the code.
10
11People I KNOW have made major contributions to the code:
12
13David Alan Gilbert (former maintainer of ARM26 bits)
14Philip Blundell
15Russell King
16Keith Owens
17
18also thanks to Nicholas Pitre for hints, and for the basis or our XIP support.
19
20Currently maintaing the code are
21
22Ian Molton (Maintainer / Archimedes)
23John Appleby (kernel / A5K)
24
25If anyone has a problem with attributions in header files / source files, please do contact me to straighten things out.
26
27Ian Molton (aka spyro) - ARM26 maintainer
28spyro@f2s.com
29
diff --git a/arch/arm26/Kconfig b/arch/arm26/Kconfig
deleted file mode 100644
index 9044f33299f7..000000000000
--- a/arch/arm26/Kconfig
+++ /dev/null
@@ -1,253 +0,0 @@
1#
2# For a description of the syntax of this configuration file,
3# see Documentation/kbuild/kconfig-language.txt.
4#
5
6mainmenu "Linux Kernel Configuration"
7
8config ARM
9 bool
10 default y
11
12config ARM26
13 bool
14 default y
15
16config MMU
17 bool
18 default y
19
20config NO_DMA
21 def_bool y
22
23config ARCH_ACORN
24 bool
25 default y
26
27config CPU_26
28 bool
29 default y
30
31config FIQ
32 bool
33 default y
34
35# 9 = 512 pages 8 = 256 pages 7 = 128 pages
36config FORCE_MAX_ZONEORDER
37 int
38 default 9
39
40config RWSEM_GENERIC_SPINLOCK
41 bool
42 default y
43
44config RWSEM_XCHGADD_ALGORITHM
45 bool
46
47config ARCH_HAS_ILOG2_U32
48 bool
49 default n
50
51config ARCH_HAS_ILOG2_U64
52 bool
53 default n
54
55config GENERIC_HWEIGHT
56 bool
57 default y
58
59config GENERIC_CALIBRATE_DELAY
60 bool
61 default y
62
63config ZONE_DMA
64 bool
65 default y
66
67config GENERIC_ISA_DMA
68 bool
69
70config ARCH_MAY_HAVE_PC_FDC
71 bool
72
73source "init/Kconfig"
74
75
76menu "System Type"
77
78choice
79 prompt "Archimedes/A5000 Implementations"
80
81config ARCH_ARC
82 bool "Archimedes"
83 help
84 Say Y to support the Acorn Archimedes.
85
86 The Acorn Archimedes was an personal computer based on an 8MHz ARM2
87 processor, released in 1987. It supported up to 16MB of RAM in
88 later models and floppy, harddisc, ethernet etc.
89
90config ARCH_A5K
91 bool "A5000"
92 select ARCH_MAY_HAVE_PC_FDC
93 help
94 Say Y here to support the Acorn A5000.
95
96 Linux can support the
97 internal IDE disk and CD-ROM interface, serial and parallel port,
98 and the floppy drive. Note that on some A5000s the floppy is
99 plugged into the wrong socket on the motherboard.
100
101config PAGESIZE_16
102 bool "2MB physical memory (broken)"
103 help
104 Say Y here if your Archimedes or A5000 system has only 2MB of
105 memory, otherwise say N. The resulting kernel will not run on a
106 machine with 4MB of memory.
107endchoice
108endmenu
109
110config ISA_DMA_API
111 bool
112 default y
113
114menu "General setup"
115
116# Compressed boot loader in ROM. Yes, we really want to ask about
117# TEXT and BSS so we preserve their values in the config files.
118config ZBOOT_ROM
119 bool "Compressed boot loader in ROM/flash"
120 help
121 Say Y here if you intend to execute your compressed kernel image (zImage)
122 directly from ROM or flash. If unsure, say N.
123
124config ZBOOT_ROM_TEXT
125 depends on ZBOOT_ROM
126 hex "Compressed ROM boot loader base address"
127 default "0"
128 help
129 The base address for zImage. Unless you have special requirements, you
130 should not change this value.
131
132config ZBOOT_ROM_BSS
133 depends on ZBOOT_ROM
134 hex "Compressed ROM boot loader BSS address"
135 default "0"
136 help
137 The base address of 64KiB of read/write memory, which must be available
138 while the decompressor is running. Unless you have special requirements,
139 you should not change this value.
140
141config XIP_KERNEL
142 bool "Execute In Place (XIP) kernel image"
143 help
144 Select this option to create a kernel that can be programmed into
145 the OS ROMs.
146
147comment "At least one math emulation must be selected"
148
149config FPE_NWFPE
150 tristate "NWFPE math emulation"
151 ---help---
152 Say Y to include the NWFPE floating point emulator in the kernel.
153 This is necessary to run most binaries. Linux does not currently
154 support floating point hardware so you need to say Y here even if
155 your machine has an FPA or floating point co-processor module.
156
157 It is also possible to say M to build the emulator as a module
158 (nwfpe) or indeed to leave it out altogether. However, unless you
159 know what you are doing this can easily render your machine
160 unbootable. Saying Y is the safe option.
161
162 You may say N here if you are going to load the Acorn FPEmulator
163 early in the bootup.
164
165source "fs/Kconfig.binfmt"
166
167config PREEMPT
168 bool "Preemptible Kernel (EXPERIMENTAL)"
169 depends on CPU_32 && EXPERIMENTAL
170 help
171 This option reduces the latency of the kernel when reacting to
172 real-time or interactive events by allowing a low priority process to
173 be preempted even if it is in kernel mode executing a system call.
174 This allows applications to run more reliably even when the system is
175 under load.
176
177 Say Y here if you are building a kernel for a desktop, embedded
178 or real-time system. Say N if you are unsure.
179
180config ARTHUR
181 tristate "RISC OS personality"
182 depends on CPU_32
183 help
184 Say Y here to include the kernel code necessary if you want to run
185 Acorn RISC OS/Arthur binaries under Linux. This code is still very
186 experimental; if this sounds frightening, say N and sleep in peace.
187 You can also say M here to compile this support as a module (which
188 will be called arthur).
189
190config CMDLINE
191 string "Default kernel command string"
192 default ""
193 help
194 On some architectures (EBSA110 and CATS), there is currently no way
195 for the boot loader to pass arguments to the kernel. For these
196 architectures, you should supply some command-line options at build
197 time by entering them here. As a minimum, you should specify the
198 memory size and the root device (e.g., mem=64M root=/dev/nfs).
199
200source "mm/Kconfig"
201
202endmenu
203
204source "net/Kconfig"
205
206source "drivers/base/Kconfig"
207
208source "drivers/parport/Kconfig"
209
210source "drivers/pnp/Kconfig"
211
212source "drivers/block/Kconfig"
213
214source "drivers/md/Kconfig"
215
216source "drivers/net/Kconfig"
217
218source "drivers/ide/Kconfig"
219
220source "drivers/scsi/Kconfig"
221
222source "drivers/isdn/Kconfig"
223
224#
225# input before char - char/joystick depends on it. As does USB.
226#
227source "drivers/input/Kconfig"
228
229source "drivers/char/Kconfig"
230
231source "drivers/media/Kconfig"
232
233source "fs/Kconfig"
234
235source "drivers/video/Kconfig"
236
237if ARCH_ACORN
238
239source "sound/Kconfig"
240
241endif
242
243source "drivers/misc/Kconfig"
244
245source "drivers/usb/Kconfig"
246
247source "arch/arm26/Kconfig.debug"
248
249source "security/Kconfig"
250
251source "crypto/Kconfig"
252
253source "lib/Kconfig"
diff --git a/arch/arm26/Kconfig.debug b/arch/arm26/Kconfig.debug
deleted file mode 100644
index 611fc86503fc..000000000000
--- a/arch/arm26/Kconfig.debug
+++ /dev/null
@@ -1,50 +0,0 @@
1menu "Kernel hacking"
2
3source "lib/Kconfig.debug"
4
5# RMK wants arm kernels compiled with frame pointers so hardwire this to y.
6# If you know what you are doing and are willing to live without stack
7# traces, you can get a slightly smaller kernel by setting this option to
8# n, but then RMK will have to kill you ;).
9config FRAME_POINTER
10 bool
11 default y
12 help
13 If you say N here, the resulting kernel will be slightly smaller and
14 faster. However, when a problem occurs with the kernel, the
15 information that is reported is severely limited. Most people
16 should say Y here.
17
18config DEBUG_USER
19 bool "Verbose user fault messages"
20 help
21 When a user program crashes due to an exception, the kernel can
22 print a brief message explaining what the problem was. This is
23 sometimes helpful for debugging but serves no purpose on a
24 production system. Most people should say N here.
25
26config DEBUG_WAITQ
27 bool "Wait queue debugging"
28 depends on DEBUG_KERNEL
29
30config DEBUG_ERRORS
31 bool "Verbose kernel error messages"
32 depends on DEBUG_KERNEL
33 help
34 This option controls verbose debugging information which can be
35 printed when the kernel detects an internal error. This debugging
36 information is useful to kernel hackers when tracking down problems,
37 but mostly meaningless to other people. It's safe to say Y unless
38 you are concerned with the code size or don't want to see these
39 messages.
40
41# These options are only for real kernel hackers who want to get their hands dirty.
42config DEBUG_LL
43 bool "Kernel low-level debugging functions"
44 depends on DEBUG_KERNEL
45 help
46 Say Y here to include definitions of printascii, printchar, printhex
47 in the kernel. This is helpful if you are debugging code that
48 executes before the console is initialized.
49
50endmenu
diff --git a/arch/arm26/Makefile b/arch/arm26/Makefile
deleted file mode 100644
index fe91eda98a94..000000000000
--- a/arch/arm26/Makefile
+++ /dev/null
@@ -1,107 +0,0 @@
1#
2# arch/arm26/Makefile
3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
7# This file is subject to the terms and conditions of the GNU General Public
8# License. See the file "COPYING" in the main directory of this archive
9# for more details.
10#
11# Copyright (C) 1995-2001 by Russell King
12# Copyright (c) 2004 Ian Molton
13
14LDFLAGS_vmlinux :=-p -X
15CPPFLAGS_vmlinux.lds = -DTEXTADDR=$(TEXTADDR) -DDATAADDR=$(DATAADDR)
16OBJCOPYFLAGS :=-O binary -R .note -R .comment -S
17GZFLAGS :=-9
18
19ifeq ($(CONFIG_FRAME_POINTER),y)
20CFLAGS +=-fno-omit-frame-pointer -mno-sched-prolog
21endif
22
23CFLAGS_BOOT :=-mapcs-26 -mcpu=arm3 -msoft-float -Uarm
24CFLAGS +=-mapcs-26 -mcpu=arm3 -msoft-float -Uarm
25AFLAGS +=-mapcs-26 -mcpu=arm3 -msoft-float
26
27ifeq ($(CONFIG_XIP_KERNEL),y)
28 TEXTADDR := 0x03880000
29 DATAADDR := 0x02080000
30else
31 TEXTADDR := 0x02080000
32 DATAADDR := .
33endif
34
35head-y := arch/arm26/kernel/head.o arch/arm26/kernel/init_task.o
36
37ifeq ($(incdir-y),)
38incdir-y :=
39endif
40INCDIR :=
41
42export MACHINE TEXTADDR GZFLAGS CFLAGS_BOOT
43
44# If we have a machine-specific directory, then include it in the build.
45core-y += arch/arm26/kernel/ arch/arm26/mm/ arch/arm26/machine/
46core-$(CONFIG_FPE_NWFPE) += arch/arm26/nwfpe/
47
48libs-y += arch/arm26/lib/
49
50# Default target when executing plain make
51all: zImage
52
53boot := arch/arm26/boot
54
55PHONY += maketools FORCE
56maketools: FORCE
57
58
59# Convert bzImage to zImage
60bzImage: vmlinux
61 $(Q)$(MAKE) $(build)=$(boot) $(boot)/zImage
62
63zImage Image bootpImage xipImage: vmlinux
64 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
65
66zinstall install: vmlinux
67 $(Q)$(MAKE) $(build)=$(boot) $@
68
69# We use MRPROPER_FILES and CLEAN_FILES now
70archclean:
71 $(Q)$(MAKE) $(clean)=$(boot)
72
73# My testing targets (that short circuit a few dependencies)
74zImg:; $(Q)$(MAKE) $(build)=$(boot) $(boot)/zImage
75Img:; $(Q)$(MAKE) $(build)=$(boot) $(boot)/Image
76bp:; $(Q)$(MAKE) $(build)=$(boot) $(boot)/bootpImage
77i:; $(Q)$(MAKE) $(build)=$(boot) install
78zi:; $(Q)$(MAKE) $(build)=$(boot) zinstall
79
80#
81# Configuration targets. Use these to select a
82# configuration for your architecture
83%_config:
84 @( \
85 CFG=$(@:_config=); \
86 if [ -f arch/arm26/def-configs/$$CFG ]; then \
87 [ -f .config ] && mv -f .config .config.old; \
88 cp arch/arm26/def-configs/$$CFG .config; \
89 echo "*** Default configuration for $$CFG installed"; \
90 echo "*** Next, you may run 'make oldconfig'"; \
91 else \
92 echo "$$CFG does not exist"; \
93 fi; \
94 )
95
96define archhelp
97 echo '* zImage - Compressed kernel image (arch/$(ARCH)/boot/zImage)'
98 echo ' Image - Uncompressed kernel image (arch/$(ARCH)/boot/Image)'
99 echo ' bootpImage - Combined zImage and initial RAM disk'
100 echo ' xipImage - eXecute In Place capable image for ROM use (arch/$(ARCH)/boot/xipImage)'
101 echo ' initrd - Create an initial image'
102 echo ' install - Install uncompressed kernel'
103 echo ' zinstall - Install compressed kernel'
104 echo ' Install using (your) ~/bin/installkernel or'
105 echo ' (distribution) /sbin/installkernel or'
106 echo ' install to $$(INSTALL_PATH) and run lilo'
107endef
diff --git a/arch/arm26/boot/Makefile b/arch/arm26/boot/Makefile
deleted file mode 100644
index 68acb7b0d47f..000000000000
--- a/arch/arm26/boot/Makefile
+++ /dev/null
@@ -1,83 +0,0 @@
1#
2# arch/arm26/boot/Makefile
3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
7# This file is subject to the terms and conditions of the GNU General Public
8# License. See the file "COPYING" in the main directory of this archive
9# for more details.
10#
11# Copyright (C) 1995-2002 Russell King
12#
13
14# Note: the following conditions must always be true:
15# ZRELADDR == virt_to_phys(TEXTADDR)
16# PARAMS_PHYS must be with 4MB of ZRELADDR
17# INITRD_PHYS must be in RAM
18
19 zreladdr-y := 0x02080000
20params_phys-y := 0x0207c000
21initrd_phys-y := 0x02180000
22
23ZRELADDR := 0x02080000
24ZTEXTADDR := 0x0207c000
25PARAMS_PHYS := $(params_phys-y)
26INITRD_PHYS := 0x02180000
27
28# We now have a PIC decompressor implementation. Decompressors running
29# from RAM should not define ZTEXTADDR. Decompressors running directly
30# from ROM or Flash must define ZTEXTADDR (preferably via the config)
31# FIXME: Previous assignment to ztextaddr-y is lost here. See SHARK
32ifeq ($(CONFIG_ZBOOT_ROM),y)
33ZTEXTADDR := $(CONFIG_ZBOOT_ROM_TEXT)
34ZBSSADDR := $(CONFIG_ZBOOT_ROM_BSS)
35else
36ZTEXTADDR := 0
37ZBSSADDR := ALIGN(4)
38endif
39
40export ZTEXTADDR ZBSSADDR ZRELADDR INITRD_PHYS PARAMS_PHYS
41
42targets := Image zImage bootpImage xipImage
43
44$(obj)/Image: vmlinux FORCE
45 $(call if_changed,objcopy)
46 @echo ' Kernel: $@ is ready'
47
48$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
49 $(call if_changed,objcopy)
50 @echo ' Kernel: $@ is ready'
51
52$(obj)/compressed/vmlinux: vmlinux FORCE
53 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
54
55ifeq ($(CONFIG_XIP_KERNEL),y)
56$(obj)/xipImage: vmlinux FORCE
57# $(OBJCOPY) -S -O binary -R .data -R .comment vmlinux vmlinux-text.bin
58# FIXME - where has .pci_fixup crept in from?
59 $(OBJCOPY) -S -O binary -R .data -R .pci_fixup -R .comment vmlinux vmlinux-text.bin
60 $(OBJCOPY) -S -O binary -R .init -R .text -R __ex_table -R .pci_fixup -R __ksymtab -R __ksymtab_gpl -R __kcrctab -R __kcrctab_gpl -R __param -R .comment vmlinux vmlinux-data.bin
61 cat vmlinux-text.bin vmlinux-data.bin > $@
62 $(RM) -f vmlinux-text.bin vmlinux-data.bin
63 @echo ' Kernel: $@ is ready'
64endif
65
66PHONY += initrd
67initrd:
68 @test "$(INITRD_PHYS)" != "" || \
69 (echo This machine does not support INITRD; exit -1)
70 @test "$(INITRD)" != "" || \
71 (echo You must specify INITRD; exit -1)
72
73install: $(obj)/Image
74 $(CONFIG_SHELL) $(obj)/install.sh \
75 $(KERNELRELEASE) \
76 $(obj)/Image System.map "$(INSTALL_PATH)"
77
78zinstall: $(obj)/zImage
79 $(CONFIG_SHELL) $(obj)/install.sh \
80 $(KERNELRELEASE) \
81 $(obj)/zImage System.map "$(INSTALL_PATH)"
82
83subdir- := compressed
diff --git a/arch/arm26/boot/compressed/Makefile b/arch/arm26/boot/compressed/Makefile
deleted file mode 100644
index b1d9ddebbe74..000000000000
--- a/arch/arm26/boot/compressed/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
1#
2# linux/arch/arm26/boot/compressed/Makefile
3#
4# create a compressed vmlinuz image from the original vmlinux
5#
6# Note! ZTEXTADDR, ZBSSADDR and ZRELADDR are now exported
7# from arch/arm26/boot/Makefile
8#
9
10HEAD = head.o
11OBJS = misc.o
12FONTC = drivers/video/console/font_acorn_8x8.c
13
14OBJS += ll_char_wr.o font.o
15CFLAGS_misc.o := -DPARAMS_PHYS=$(PARAMS_PHYS)
16
17targets := vmlinux vmlinux.lds piggy piggy.gz piggy.o font.o head.o $(OBJS)
18
19SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/LOAD_ADDR/$(ZRELADDR)/;s/BSS_START/$(ZBSSADDR)/
20
21EXTRA_CFLAGS := $(CFLAGS_BOOT) -fpic
22EXTRA_AFLAGS := -traditional
23
24LDFLAGS_vmlinux := -p -X \
25 $(shell $(CC) $(CFLAGS)) -T
26
27$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o \
28 $(addprefix $(obj)/, $(OBJS)) FORCE
29 $(call if_changed,ld)
30 @:
31
32
33$(obj)/piggy: vmlinux FORCE
34 $(call if_changed,objcopy)
35
36$(obj)/piggy.gz: $(obj)/piggy FORCE
37 $(call if_changed,gzip)
38
39LDFLAGS_piggy.o := -r -b binary
40$(obj)/piggy.o: $(obj)/piggy.gz FORCE
41 $(call if_changed,ld)
42
43$(obj)/font.o: $(FONTC)
44 $(CC) $(CFLAGS) -Dstatic= -c $(FONTC) -o $(obj)/font.o
45
46$(obj)/vmlinux.lds: $(obj)/vmlinux.lds.in Makefile arch/arm26/boot/Makefile .config
47 @sed "$(SEDFLAGS)" < $< > $@
48
49$(obj)/misc.o: $(obj)/misc.c $(obj)/uncompress.h lib/inflate.c
50
diff --git a/arch/arm26/boot/compressed/head.S b/arch/arm26/boot/compressed/head.S
deleted file mode 100644
index 2a2cda36d83b..000000000000
--- a/arch/arm26/boot/compressed/head.S
+++ /dev/null
@@ -1,516 +0,0 @@
1/*
2 * linux/arch/arm26/boot/compressed/head.S
3 *
4 * Copyright (C) 1996-2002 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11
12/*
13 * Debugging stuff
14 *
15 * Note that these macros must not contain any code which is not
16 * 100% relocatable. Any attempt to do so will result in a crash.
17 * Please select one of the following when turning on debugging.
18 */
19
20 .macro kputc,val
21 mov r0, \val
22 bl putc
23 .endm
24
25 .macro kphex,val,len
26 mov r0, \val
27 mov r1, #\len
28 bl phex
29 .endm
30
31 .macro debug_reloc_start
32 .endm
33
34 .macro debug_reloc_end
35 .endm
36
37 .section ".start", #alloc, #execinstr
38/*
39 * sort out different calling conventions
40 */
41 .align
42start:
43 .type start,#function
44 .rept 8
45 mov r0, r0
46 .endr
47
48 b 1f
49 .word 0x016f2818 @ Magic numbers to help the loader
50 .word start @ absolute load/run zImage address
51 .word _edata @ zImage end address
521: mov r7, r1 @ save architecture ID
53 mov r8, #0 @ save r0
54 teqp pc, #0x0c000003 @ turn off interrupts
55
56 .text
57 adr r0, LC0
58 ldmia r0, {r1, r2, r3, r4, r5, r6, ip, sp}
59 subs r0, r0, r1 @ calculate the delta offset
60
61 teq r0, #0 @ if delta is zero, we're
62 beq not_relocated @ running at the address we
63 @ were linked at.
64
65 add r2, r2, r0 @ different address, so we
66 add r3, r3, r0 @ need to fix up various
67 add r5, r5, r0 @ pointers.
68 add r6, r6, r0
69 add ip, ip, r0
70 add sp, sp, r0
71
721: ldr r1, [r6, #0] @ relocate entries in the GOT
73 add r1, r1, r0 @ table. This fixes up the
74 str r1, [r6], #4 @ C references.
75 cmp r6, ip
76 blo 1b
77
78not_relocated: mov r0, #0
791: str r0, [r2], #4 @ clear bss
80 str r0, [r2], #4
81 str r0, [r2], #4
82 str r0, [r2], #4
83 cmp r2, r3
84 blo 1b
85
86 bl cache_on
87
88 mov r1, sp @ malloc space above stack
89 add r2, sp, #0x10000 @ 64k max
90
91/*
92 * Check to see if we will overwrite ourselves.
93 * r4 = final kernel address
94 * r5 = start of this image
95 * r2 = end of malloc space (and therefore this image)
96 * We basically want:
97 * r4 >= r2 -> OK
98 * r4 + image length <= r5 -> OK
99 */
100 cmp r4, r2
101 bhs wont_overwrite
102 add r0, r4, #4096*1024 @ 4MB largest kernel size
103 cmp r0, r5
104 bls wont_overwrite
105
106 mov r5, r2 @ decompress after malloc space
107 mov r0, r5
108 mov r3, r7
109 bl decompress_kernel
110
111 add r0, r0, #127
112 bic r0, r0, #127 @ align the kernel length
113/*
114 * r0 = decompressed kernel length
115 * r1-r3 = unused
116 * r4 = kernel execution address
117 * r5 = decompressed kernel start
118 * r6 = processor ID
119 * r7 = architecture ID
120 * r8-r14 = unused
121 */
122 add r1, r5, r0 @ end of decompressed kernel
123 adr r2, reloc_start
124 ldr r3, LC1
125 add r3, r2, r3
1261: ldmia r2!, {r8 - r13} @ copy relocation code
127 stmia r1!, {r8 - r13}
128 ldmia r2!, {r8 - r13}
129 stmia r1!, {r8 - r13}
130 cmp r2, r3
131 blo 1b
132
133 bl cache_clean_flush
134 add pc, r5, r0 @ call relocation code
135
136/*
137 * We're not in danger of overwriting ourselves. Do this the simple way.
138 *
139 * r4 = kernel execution address
140 * r7 = architecture ID
141 */
142wont_overwrite: mov r0, r4
143 mov r3, r7
144 bl decompress_kernel
145 b call_kernel
146
147 .type LC0, #object
148LC0: .word LC0 @ r1
149 .word __bss_start @ r2
150 .word _end @ r3
151 .word _load_addr @ r4
152 .word _start @ r5
153 .word _got_start @ r6
154 .word _got_end @ ip
155 .word user_stack+4096 @ sp
156LC1: .word reloc_end - reloc_start
157 .size LC0, . - LC0
158
159/*
160 * Turn on the cache. We need to setup some page tables so that we
161 * can have both the I and D caches on.
162 *
163 * We place the page tables 16k down from the kernel execution address,
164 * and we hope that nothing else is using it. If we're using it, we
165 * will go pop!
166 *
167 * On entry,
168 * r4 = kernel execution address
169 * r6 = processor ID
170 * r7 = architecture number
171 * r8 = run-time address of "start"
172 * On exit,
173 * r1, r2, r3, r8, r9, r12 corrupted
174 * This routine must preserve:
175 * r4, r5, r6, r7
176 */
177 .align 5
178cache_on: mov r3, #8 @ cache_on function
179 b call_cache_fn
180
181__setup_mmu: sub r3, r4, #16384 @ Page directory size
182 bic r3, r3, #0xff @ Align the pointer
183 bic r3, r3, #0x3f00
184/*
185 * Initialise the page tables, turning on the cacheable and bufferable
186 * bits for the RAM area only.
187 */
188 mov r0, r3
189 mov r8, r0, lsr #18
190 mov r8, r8, lsl #18 @ start of RAM
191 add r9, r8, #0x10000000 @ a reasonable RAM size
192 mov r1, #0x12
193 orr r1, r1, #3 << 10
194 add r2, r3, #16384
1951: cmp r1, r8 @ if virt > start of RAM
196 orrhs r1, r1, #0x0c @ set cacheable, bufferable
197 cmp r1, r9 @ if virt > end of RAM
198 bichs r1, r1, #0x0c @ clear cacheable, bufferable
199 str r1, [r0], #4 @ 1:1 mapping
200 add r1, r1, #1048576
201 teq r0, r2
202 bne 1b
203/*
204 * If ever we are running from Flash, then we surely want the cache
205 * to be enabled also for our execution instance... We map 2MB of it
206 * so there is no map overlap problem for up to 1 MB compressed kernel.
207 * If the execution is in RAM then we would only be duplicating the above.
208 */
209 mov r1, #0x1e
210 orr r1, r1, #3 << 10
211 mov r2, pc, lsr #20
212 orr r1, r1, r2, lsl #20
213 add r0, r3, r2, lsl #2
214 str r1, [r0], #4
215 add r1, r1, #1048576
216 str r1, [r0]
217 mov pc, lr
218
219__armv4_cache_on:
220 mov r12, lr
221 bl __setup_mmu
222 mov r0, #0
223 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
224 mcr p15, 0, r0, c8, c7, 0 @ flush I,D TLBs
225 mrc p15, 0, r0, c1, c0, 0 @ read control reg
226 orr r0, r0, #0x1000 @ I-cache enable
227 orr r0, r0, #0x0030
228 b __common_cache_on
229
230__arm6_cache_on:
231 mov r12, lr
232 bl __setup_mmu
233 mov r0, #0
234 mcr p15, 0, r0, c7, c0, 0 @ invalidate whole cache v3
235 mcr p15, 0, r0, c5, c0, 0 @ invalidate whole TLB v3
236 mov r0, #0x30
237__common_cache_on:
238#ifndef DEBUG
239 orr r0, r0, #0x000d @ Write buffer, mmu
240#endif
241 mov r1, #-1
242 mcr p15, 0, r3, c2, c0, 0 @ load page table pointer
243 mcr p15, 0, r1, c3, c0, 0 @ load domain access control
244 mcr p15, 0, r0, c1, c0, 0 @ load control register
245 mov pc, r12
246
247/*
248 * All code following this line is relocatable. It is relocated by
249 * the above code to the end of the decompressed kernel image and
250 * executed there. During this time, we have no stacks.
251 *
252 * r0 = decompressed kernel length
253 * r1-r3 = unused
254 * r4 = kernel execution address
255 * r5 = decompressed kernel start
256 * r6 = processor ID
257 * r7 = architecture ID
258 * r8-r14 = unused
259 */
260 .align 5
261reloc_start: add r8, r5, r0
262 debug_reloc_start
263 mov r1, r4
2641:
265 .rept 4
266 ldmia r5!, {r0, r2, r3, r9 - r13} @ relocate kernel
267 stmia r1!, {r0, r2, r3, r9 - r13}
268 .endr
269
270 cmp r5, r8
271 blo 1b
272 debug_reloc_end
273
274call_kernel: bl cache_clean_flush
275 bl cache_off
276 mov r0, #0
277 mov r1, r7 @ restore architecture number
278 mov pc, r4 @ call kernel
279
280/*
281 * Here follow the relocatable cache support functions for the
282 * various processors. This is a generic hook for locating an
283 * entry and jumping to an instruction at the specified offset
284 * from the start of the block. Please note this is all position
285 * independent code.
286 *
287 * r1 = corrupted
288 * r2 = corrupted
289 * r3 = block offset
290 * r6 = corrupted
291 * r12 = corrupted
292 */
293
294call_cache_fn: adr r12, proc_types
295 mrc p15, 0, r6, c0, c0 @ get processor ID
2961: ldr r1, [r12, #0] @ get value
297 ldr r2, [r12, #4] @ get mask
298 eor r1, r1, r6 @ (real ^ match)
299 tst r1, r2 @ & mask
300 addeq pc, r12, r3 @ call cache function
301 add r12, r12, #4*5
302 b 1b
303
304/*
305 * Table for cache operations. This is basically:
306 * - CPU ID match
307 * - CPU ID mask
308 * - 'cache on' method instruction
309 * - 'cache off' method instruction
310 * - 'cache flush' method instruction
311 *
312 * We match an entry using: ((real_id ^ match) & mask) == 0
313 *
314 * Writethrough caches generally only need 'on' and 'off'
315 * methods. Writeback caches _must_ have the flush method
316 * defined.
317 */
318 .type proc_types,#object
319proc_types:
320 .word 0x41560600 @ ARM6/610
321 .word 0xffffffe0
322 b __arm6_cache_off @ works, but slow
323 b __arm6_cache_off
324 mov pc, lr
325@ b __arm6_cache_on @ untested
326@ b __arm6_cache_off
327@ b __armv3_cache_flush
328
329 .word 0x41007000 @ ARM7/710
330 .word 0xfff8fe00
331 b __arm7_cache_off
332 b __arm7_cache_off
333 mov pc, lr
334
335 .word 0x41807200 @ ARM720T (writethrough)
336 .word 0xffffff00
337 b __armv4_cache_on
338 b __armv4_cache_off
339 mov pc, lr
340
341 .word 0x41129200 @ ARM920T
342 .word 0xff00fff0
343 b __armv4_cache_on
344 b __armv4_cache_off
345 b __armv4_cache_flush
346
347 .word 0x4401a100 @ sa110 / sa1100
348 .word 0xffffffe0
349 b __armv4_cache_on
350 b __armv4_cache_off
351 b __armv4_cache_flush
352
353 .word 0x6901b110 @ sa1110
354 .word 0xfffffff0
355 b __armv4_cache_on
356 b __armv4_cache_off
357 b __armv4_cache_flush
358
359 .word 0x69050000 @ xscale
360 .word 0xffff0000
361 b __armv4_cache_on
362 b __armv4_cache_off
363 b __armv4_cache_flush
364
365 .word 0 @ unrecognised type
366 .word 0
367 mov pc, lr
368 mov pc, lr
369 mov pc, lr
370
371 .size proc_types, . - proc_types
372
373/*
374 * Turn off the Cache and MMU. ARMv3 does not support
375 * reading the control register, but ARMv4 does.
376 *
377 * On entry, r6 = processor ID
378 * On exit, r0, r1, r2, r3, r12 corrupted
379 * This routine must preserve: r4, r6, r7
380 */
381 .align 5
382cache_off: mov r3, #12 @ cache_off function
383 b call_cache_fn
384
385__armv4_cache_off:
386 mrc p15, 0, r0, c1, c0
387 bic r0, r0, #0x000d
388 mcr p15, 0, r0, c1, c0 @ turn MMU and cache off
389 mov r0, #0
390 mcr p15, 0, r0, c7, c7 @ invalidate whole cache v4
391 mcr p15, 0, r0, c8, c7 @ invalidate whole TLB v4
392 mov pc, lr
393
394__arm6_cache_off:
395 mov r0, #0x00000030 @ ARM6 control reg.
396 b __armv3_cache_off
397
398__arm7_cache_off:
399 mov r0, #0x00000070 @ ARM7 control reg.
400 b __armv3_cache_off
401
402__armv3_cache_off:
403 mcr p15, 0, r0, c1, c0, 0 @ turn MMU and cache off
404 mov r0, #0
405 mcr p15, 0, r0, c7, c0, 0 @ invalidate whole cache v3
406 mcr p15, 0, r0, c5, c0, 0 @ invalidate whole TLB v3
407 mov pc, lr
408
409/*
410 * Clean and flush the cache to maintain consistency.
411 *
412 * On entry,
413 * r6 = processor ID
414 * On exit,
415 * r1, r2, r3, r12 corrupted
416 * This routine must preserve:
417 * r0, r4, r5, r6, r7
418 */
419 .align 5
420cache_clean_flush:
421 mov r3, #16
422 b call_cache_fn
423
424__armv4_cache_flush:
425 bic r1, pc, #31
426 add r2, r1, #65536 @ 2x the largest dcache size
4271: ldr r12, [r1], #32 @ s/w flush D cache
428 teq r1, r2
429 bne 1b
430
431 mcr p15, 0, r1, c7, c7, 0 @ flush I cache
432 mcr p15, 0, r1, c7, c10, 4 @ drain WB
433 mov pc, lr
434
435__armv3_cache_flush:
436 mov r1, #0
437 mcr p15, 0, r0, c7, c0, 0 @ invalidate whole cache v3
438 mov pc, lr
439
440/*
441 * Various debugging routines for printing hex characters and
442 * memory, which again must be relocatable.
443 */
444#ifdef DEBUG
445 .type phexbuf,#object
446phexbuf: .space 12
447 .size phexbuf, . - phexbuf
448
449phex: adr r3, phexbuf
450 mov r2, #0
451 strb r2, [r3, r1]
4521: subs r1, r1, #1
453 movmi r0, r3
454 bmi puts
455 and r2, r0, #15
456 mov r0, r0, lsr #4
457 cmp r2, #10
458 addge r2, r2, #7
459 add r2, r2, #'0'
460 strb r2, [r3, r1]
461 b 1b
462
463puts: loadsp r3
4641: ldrb r2, [r0], #1
465 teq r2, #0
466 moveq pc, lr
4672: writeb r2
468 mov r1, #0x00020000
4693: subs r1, r1, #1
470 bne 3b
471 teq r2, #'\n'
472 moveq r2, #'\r'
473 beq 2b
474 teq r0, #0
475 bne 1b
476 mov pc, lr
477putc:
478 mov r2, r0
479 mov r0, #0
480 loadsp r3
481 b 2b
482
483memdump: mov r12, r0
484 mov r10, lr
485 mov r11, #0
4862: mov r0, r11, lsl #2
487 add r0, r0, r12
488 mov r1, #8
489 bl phex
490 mov r0, #':'
491 bl putc
4921: mov r0, #' '
493 bl putc
494 ldr r0, [r12, r11, lsl #2]
495 mov r1, #8
496 bl phex
497 and r0, r11, #7
498 teq r0, #3
499 moveq r0, #' '
500 bleq putc
501 and r0, r11, #7
502 add r11, r11, #1
503 teq r0, #7
504 bne 1b
505 mov r0, #'\n'
506 bl putc
507 cmp r11, #64
508 blt 2b
509 mov pc, r10
510#endif
511
512reloc_end:
513
514 .align
515 .section ".stack", "aw"
516user_stack: .space 4096
diff --git a/arch/arm26/boot/compressed/ll_char_wr.S b/arch/arm26/boot/compressed/ll_char_wr.S
deleted file mode 100644
index f024c3ebdfa5..000000000000
--- a/arch/arm26/boot/compressed/ll_char_wr.S
+++ /dev/null
@@ -1,162 +0,0 @@
1/*
2 * linux/arch/arm26/lib/ll_char_wr.S
3 *
4 * Copyright (C) 1995, 1996 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Speedups & 1bpp code (C) 1996 Philip Blundell & Russell King.
11 *
12 * 10-04-96 RMK Various cleanups & reduced register usage.
13 * 08-04-98 RMK Shifts re-ordered
14 */
15
16@ Regs: [] = corruptible
17@ {} = used
18@ () = do not use
19
20#include <linux/linkage.h>
21#include <asm/assembler.h>
22 .text
23
24#define BOLD 0x01
25#define ITALIC 0x02
26#define UNDERLINE 0x04
27#define FLASH 0x08
28#define INVERSE 0x10
29
30LC0: .word bytes_per_char_h
31 .word video_size_row
32 .word acorndata_8x8
33 .word con_charconvtable
34
35ENTRY(ll_write_char)
36 stmfd sp!, {r4 - r7, lr}
37@
38@ Smashable regs: {r0 - r3}, [r4 - r7], (r8 - fp), [ip], (sp), [lr], (pc)
39@
40 eor ip, r1, #UNDERLINE << 9
41/*
42 * calculate colours
43 */
44 tst r1, #INVERSE << 9
45 moveq r2, r1, lsr #16
46 moveq r3, r1, lsr #24
47 movne r2, r1, lsr #24
48 movne r3, r1, lsr #16
49 and r3, r3, #255
50 and r2, r2, #255
51/*
52 * calculate offset into character table
53 */
54 mov r1, r1, lsl #23
55 mov r1, r1, lsr #20
56/*
57 * calculate offset required for each row [maybe I should make this an argument to this fn.
58 * Have to see what the register usage is like in the calling routines.
59 */
60 adr r4, LC0
61 ldmia r4, {r4, r5, r6, lr}
62 ldr r4, [r4]
63 ldr r5, [r5]
64/*
65 * Go to resolution-dependent routine...
66 */
67 cmp r4, #4
68 blt Lrow1bpp
69 eor r2, r3, r2 @ Create eor mask to change colour from bg
70 orr r3, r3, r3, lsl #8 @ to fg.
71 orr r3, r3, r3, lsl #16
72 add r0, r0, r5, lsl #3 @ Move to bottom of character
73 add r1, r1, #7
74 ldrb r7, [r6, r1]
75 tst ip, #UNDERLINE << 9
76 eoreq r7, r7, #255
77 teq r4, #8
78 beq Lrow8bpplp
79@
80@ Smashable regs: {r0 - r3}, [r4], {r5 - r7}, (r8 - fp), [ip], (sp), {lr}, (pc)
81@
82 orr r3, r3, r3, lsl #4
83Lrow4bpplp: ldr r7, [lr, r7, lsl #2]
84 mul r7, r2, r7
85 tst r1, #7 @ avoid using r7 directly after
86 eor ip, r3, r7
87 str ip, [r0, -r5]!
88 LOADREGS(eqfd, sp!, {r4 - r7, pc})
89 sub r1, r1, #1
90 ldrb r7, [r6, r1]
91 ldr r7, [lr, r7, lsl #2]
92 mul r7, r2, r7
93 tst r1, #7 @ avoid using r7 directly after
94 eor ip, r3, r7
95 str ip, [r0, -r5]!
96 subne r1, r1, #1
97 ldrneb r7, [r6, r1]
98 bne Lrow4bpplp
99 LOADREGS(fd, sp!, {r4 - r7, pc})
100
101@
102@ Smashable regs: {r0 - r3}, [r4], {r5 - r7}, (r8 - fp), [ip], (sp), {lr}, (pc)
103@
104Lrow8bpplp: mov ip, r7, lsr #4
105 ldr ip, [lr, ip, lsl #2]
106 mul r4, r2, ip
107 and ip, r7, #15 @ avoid r4
108 ldr ip, [lr, ip, lsl #2] @ avoid r4
109 mul ip, r2, ip @ avoid r4
110 eor r4, r3, r4 @ avoid ip
111 tst r1, #7 @ avoid ip
112 sub r0, r0, r5 @ avoid ip
113 eor ip, r3, ip
114 stmia r0, {r4, ip}
115 LOADREGS(eqfd, sp!, {r4 - r7, pc})
116 sub r1, r1, #1
117 ldrb r7, [r6, r1]
118 mov ip, r7, lsr #4
119 ldr ip, [lr, ip, lsl #2]
120 mul r4, r2, ip
121 and ip, r7, #15 @ avoid r4
122 ldr ip, [lr, ip, lsl #2] @ avoid r4
123 mul ip, r2, ip @ avoid r4
124 eor r4, r3, r4 @ avoid ip
125 tst r1, #7 @ avoid ip
126 sub r0, r0, r5 @ avoid ip
127 eor ip, r3, ip
128 stmia r0, {r4, ip}
129 subne r1, r1, #1
130 ldrneb r7, [r6, r1]
131 bne Lrow8bpplp
132 LOADREGS(fd, sp!, {r4 - r7, pc})
133
134@
135@ Smashable regs: {r0 - r3}, [r4], {r5, r6}, [r7], (r8 - fp), [ip], (sp), [lr], (pc)
136@
137Lrow1bpp: add r6, r6, r1
138 ldmia r6, {r4, r7}
139 tst ip, #INVERSE << 9
140 mvnne r4, r4
141 mvnne r7, r7
142 strb r4, [r0], r5
143 mov r4, r4, lsr #8
144 strb r4, [r0], r5
145 mov r4, r4, lsr #8
146 strb r4, [r0], r5
147 mov r4, r4, lsr #8
148 strb r4, [r0], r5
149 strb r7, [r0], r5
150 mov r7, r7, lsr #8
151 strb r7, [r0], r5
152 mov r7, r7, lsr #8
153 strb r7, [r0], r5
154 mov r7, r7, lsr #8
155 tst ip, #UNDERLINE << 9
156 mvneq r7, r7
157 strb r7, [r0], r5
158 LOADREGS(fd, sp!, {r4 - r7, pc})
159
160 .bss
161ENTRY(con_charconvtable)
162 .space 1024
diff --git a/arch/arm26/boot/compressed/misc.c b/arch/arm26/boot/compressed/misc.c
deleted file mode 100644
index 0714d19c5776..000000000000
--- a/arch/arm26/boot/compressed/misc.c
+++ /dev/null
@@ -1,316 +0,0 @@
1/*
2 * misc.c
3 *
4 * This is a collection of several routines from gzip-1.0.3
5 * adapted for Linux.
6 *
7 * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
8 *
9 * Modified for ARM Linux by Russell King
10 *
11 * Nicolas Pitre <nico@visuaide.com> 1999/04/14 :
12 * For this code to run directly from Flash, all constant variables must
13 * be marked with 'const' and all other variables initialized at run-time
14 * only. This way all non constant variables will end up in the bss segment,
15 * which should point to addresses in RAM and cleared to 0 on start.
16 * This allows for a much quicker boot time.
17 */
18
19unsigned int __machine_arch_type;
20
21#include <linux/kernel.h>
22
23#include <asm/uaccess.h>
24#include "uncompress.h"
25
26#ifdef STANDALONE_DEBUG
27#define puts printf
28#endif
29
30#define __ptr_t void *
31
32/*
33 * Optimised C version of memzero for the ARM.
34 */
35void __memzero (__ptr_t s, size_t n)
36{
37 union { void *vp; unsigned long *ulp; unsigned char *ucp; } u;
38 int i;
39
40 u.vp = s;
41
42 for (i = n >> 5; i > 0; i--) {
43 *u.ulp++ = 0;
44 *u.ulp++ = 0;
45 *u.ulp++ = 0;
46 *u.ulp++ = 0;
47 *u.ulp++ = 0;
48 *u.ulp++ = 0;
49 *u.ulp++ = 0;
50 *u.ulp++ = 0;
51 }
52
53 if (n & 1 << 4) {
54 *u.ulp++ = 0;
55 *u.ulp++ = 0;
56 *u.ulp++ = 0;
57 *u.ulp++ = 0;
58 }
59
60 if (n & 1 << 3) {
61 *u.ulp++ = 0;
62 *u.ulp++ = 0;
63 }
64
65 if (n & 1 << 2)
66 *u.ulp++ = 0;
67
68 if (n & 1 << 1) {
69 *u.ucp++ = 0;
70 *u.ucp++ = 0;
71 }
72
73 if (n & 1)
74 *u.ucp++ = 0;
75}
76
77static inline __ptr_t memcpy(__ptr_t __dest, __const __ptr_t __src,
78 size_t __n)
79{
80 int i = 0;
81 unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src;
82
83 for (i = __n >> 3; i > 0; i--) {
84 *d++ = *s++;
85 *d++ = *s++;
86 *d++ = *s++;
87 *d++ = *s++;
88 *d++ = *s++;
89 *d++ = *s++;
90 *d++ = *s++;
91 *d++ = *s++;
92 }
93
94 if (__n & 1 << 2) {
95 *d++ = *s++;
96 *d++ = *s++;
97 *d++ = *s++;
98 *d++ = *s++;
99 }
100
101 if (__n & 1 << 1) {
102 *d++ = *s++;
103 *d++ = *s++;
104 }
105
106 if (__n & 1)
107 *d++ = *s++;
108
109 return __dest;
110}
111
112/*
113 * gzip delarations
114 */
115#define OF(args) args
116#define STATIC static
117
118typedef unsigned char uch;
119typedef unsigned short ush;
120typedef unsigned long ulg;
121
122#define WSIZE 0x8000 /* Window size must be at least 32k, */
123 /* and a power of two */
124
125static uch *inbuf; /* input buffer */
126static uch window[WSIZE]; /* Sliding window buffer */
127
128static unsigned insize; /* valid bytes in inbuf */
129static unsigned inptr; /* index of next byte to be processed in inbuf */
130static unsigned outcnt; /* bytes in output buffer */
131
132/* gzip flag byte */
133#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
134#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
135#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
136#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
137#define COMMENT 0x10 /* bit 4 set: file comment present */
138#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
139#define RESERVED 0xC0 /* bit 6,7: reserved */
140
141#define get_byte() (inptr < insize ? inbuf[inptr++] : fill_inbuf())
142
143/* Diagnostic functions */
144#ifdef DEBUG
145# define Assert(cond,msg) {if(!(cond)) error(msg);}
146# define Trace(x) fprintf x
147# define Tracev(x) {if (verbose) fprintf x ;}
148# define Tracevv(x) {if (verbose>1) fprintf x ;}
149# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
150# define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;}
151#else
152# define Assert(cond,msg)
153# define Trace(x)
154# define Tracev(x)
155# define Tracevv(x)
156# define Tracec(c,x)
157# define Tracecv(c,x)
158#endif
159
160static int fill_inbuf(void);
161static void flush_window(void);
162static void error(char *m);
163static void gzip_mark(void **);
164static void gzip_release(void **);
165
166extern char input_data[];
167extern char input_data_end[];
168
169static uch *output_data;
170static ulg output_ptr;
171static ulg bytes_out;
172
173static void *malloc(int size);
174static void free(void *where);
175static void error(char *m);
176static void gzip_mark(void **);
177static void gzip_release(void **);
178
179static void puts(const char *);
180
181extern int end;
182static ulg free_mem_ptr;
183static ulg free_mem_ptr_end;
184
185#define HEAP_SIZE 0x3000
186
187#include "../../../../lib/inflate.c"
188
189#ifndef STANDALONE_DEBUG
190static void *malloc(int size)
191{
192 void *p;
193
194 if (size <0) error("Malloc error");
195 if (free_mem_ptr <= 0) error("Memory error");
196
197 free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
198
199 p = (void *)free_mem_ptr;
200 free_mem_ptr += size;
201
202 if (free_mem_ptr >= free_mem_ptr_end)
203 error("Out of memory");
204 return p;
205}
206
207static void free(void *where)
208{ /* gzip_mark & gzip_release do the free */
209}
210
211static void gzip_mark(void **ptr)
212{
213 arch_decomp_wdog();
214 *ptr = (void *) free_mem_ptr;
215}
216
217static void gzip_release(void **ptr)
218{
219 arch_decomp_wdog();
220 free_mem_ptr = (long) *ptr;
221}
222#else
223static void gzip_mark(void **ptr)
224{
225}
226
227static void gzip_release(void **ptr)
228{
229}
230#endif
231
232/* ===========================================================================
233 * Fill the input buffer. This is called only when the buffer is empty
234 * and at least one byte is really needed.
235 */
236int fill_inbuf(void)
237{
238 if (insize != 0)
239 error("ran out of input data");
240
241 inbuf = input_data;
242 insize = &input_data_end[0] - &input_data[0];
243
244 inptr = 1;
245 return inbuf[0];
246}
247
248/* ===========================================================================
249 * Write the output window window[0..outcnt-1] and update crc and bytes_out.
250 * (Used for the decompressed data only.)
251 */
252void flush_window(void)
253{
254 ulg c = crc;
255 unsigned n;
256 uch *in, *out, ch;
257
258 in = window;
259 out = &output_data[output_ptr];
260 for (n = 0; n < outcnt; n++) {
261 ch = *out++ = *in++;
262 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
263 }
264 crc = c;
265 bytes_out += (ulg)outcnt;
266 output_ptr += (ulg)outcnt;
267 outcnt = 0;
268 puts(".");
269}
270
271static void error(char *x)
272{
273 int ptr;
274
275 puts("\n\n");
276 puts(x);
277 puts("\n\n -- System halted");
278
279 while(1); /* Halt */
280}
281
282#ifndef STANDALONE_DEBUG
283
284ulg
285decompress_kernel(ulg output_start, ulg free_mem_ptr_p, ulg free_mem_ptr_end_p,
286 int arch_id)
287{
288 output_data = (uch *)output_start; /* Points to kernel start */
289 free_mem_ptr = free_mem_ptr_p;
290 free_mem_ptr_end = free_mem_ptr_end_p;
291 __machine_arch_type = arch_id;
292
293 arch_decomp_setup();
294
295 makecrc();
296 puts("Uncompressing Linux...");
297 gunzip();
298 puts(" done, booting the kernel.\n");
299 return output_ptr;
300}
301#else
302
303char output_buffer[1500*1024];
304
305int main()
306{
307 output_data = output_buffer;
308
309 makecrc();
310 puts("Uncompressing Linux...");
311 gunzip();
312 puts("done.\n");
313 return 0;
314}
315#endif
316
diff --git a/arch/arm26/boot/compressed/uncompress.h b/arch/arm26/boot/compressed/uncompress.h
deleted file mode 100644
index 66d9b938a7a4..000000000000
--- a/arch/arm26/boot/compressed/uncompress.h
+++ /dev/null
@@ -1,110 +0,0 @@
1/*
2 *
3 * Copyright (C) 1996 Russell King
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9#define VIDMEM ((char *)0x02000000)
10
11int video_num_columns, video_num_lines, video_size_row;
12int white, bytes_per_char_h;
13extern unsigned long con_charconvtable[256];
14
15struct param_struct {
16 unsigned long page_size;
17 unsigned long nr_pages;
18 unsigned long ramdisk_size;
19 unsigned long mountrootrdonly;
20 unsigned long rootdev;
21 unsigned long video_num_cols;
22 unsigned long video_num_rows;
23 unsigned long video_x;
24 unsigned long video_y;
25 unsigned long memc_control_reg;
26 unsigned char sounddefault;
27 unsigned char adfsdrives;
28 unsigned char bytes_per_char_h;
29 unsigned char bytes_per_char_v;
30 unsigned long unused[256/4-11];
31};
32
33static struct param_struct *params = (struct param_struct *)0x0207c000;
34
35/*
36 * This does not append a newline
37 */
38static void puts(const char *s)
39{
40 extern void ll_write_char(char *, unsigned long);
41 int x,y;
42 unsigned char c;
43 char *ptr;
44
45 x = params->video_x;
46 y = params->video_y;
47
48 while ( ( c = *(unsigned char *)s++ ) != '\0' ) {
49 if ( c == '\n' ) {
50 x = 0;
51 if ( ++y >= video_num_lines ) {
52 y--;
53 }
54 } else {
55 ptr = VIDMEM + ((y*video_num_columns*params->bytes_per_char_v+x)*bytes_per_char_h);
56 ll_write_char(ptr, c|(white<<16));
57 if ( ++x >= video_num_columns ) {
58 x = 0;
59 if ( ++y >= video_num_lines ) {
60 y--;
61 }
62 }
63 }
64 }
65
66 params->video_x = x;
67 params->video_y = y;
68}
69
70static void error(char *x);
71
72/*
73 * Setup for decompression
74 */
75static void arch_decomp_setup(void)
76{
77 int i;
78
79 video_num_lines = params->video_num_rows;
80 video_num_columns = params->video_num_cols;
81 bytes_per_char_h = params->bytes_per_char_h;
82 video_size_row = video_num_columns * bytes_per_char_h;
83 if (bytes_per_char_h == 4)
84 for (i = 0; i < 256; i++)
85 con_charconvtable[i] =
86 (i & 128 ? 1 << 0 : 0) |
87 (i & 64 ? 1 << 4 : 0) |
88 (i & 32 ? 1 << 8 : 0) |
89 (i & 16 ? 1 << 12 : 0) |
90 (i & 8 ? 1 << 16 : 0) |
91 (i & 4 ? 1 << 20 : 0) |
92 (i & 2 ? 1 << 24 : 0) |
93 (i & 1 ? 1 << 28 : 0);
94 else
95 for (i = 0; i < 16; i++)
96 con_charconvtable[i] =
97 (i & 8 ? 1 << 0 : 0) |
98 (i & 4 ? 1 << 8 : 0) |
99 (i & 2 ? 1 << 16 : 0) |
100 (i & 1 ? 1 << 24 : 0);
101
102 white = bytes_per_char_h == 8 ? 0xfc : 7;
103
104 if (params->nr_pages * params->page_size < 4096*1024) error("<4M of mem\n");
105}
106
107/*
108 * nothing to do
109 */
110#define arch_decomp_wdog()
diff --git a/arch/arm26/boot/compressed/vmlinux.lds.in b/arch/arm26/boot/compressed/vmlinux.lds.in
deleted file mode 100644
index 86d821d5ab70..000000000000
--- a/arch/arm26/boot/compressed/vmlinux.lds.in
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * linux/arch/arm26/boot/compressed/vmlinux.lds.in
3 *
4 * Copyright (C) 2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10OUTPUT_ARCH(arm)
11ENTRY(_start)
12SECTIONS
13{
14 . = LOAD_ADDR;
15 _load_addr = .;
16
17 . = TEXT_START;
18 _text = .;
19
20 .text : {
21 _start = .;
22 *(.start)
23 *(.text)
24 *(.fixup)
25 *(.gnu.warning)
26 *(.rodata)
27 *(.rodata.*)
28 *(.glue_7)
29 *(.glue_7t)
30 input_data = .;
31 arch/arm26/boot/compressed/piggy.o
32 input_data_end = .;
33 . = ALIGN(4);
34 }
35
36 _etext = .;
37
38 _got_start = .;
39 .got : { *(.got) }
40 _got_end = .;
41 .got.plt : { *(.got.plt) }
42 .data : { *(.data) }
43 _edata = .;
44
45 . = BSS_START;
46 __bss_start = .;
47 .bss : { *(.bss) }
48 _end = .;
49
50 .stack (NOLOAD) : { *(.stack) }
51
52 .stab 0 : { *(.stab) }
53 .stabstr 0 : { *(.stabstr) }
54 .stab.excl 0 : { *(.stab.excl) }
55 .stab.exclstr 0 : { *(.stab.exclstr) }
56 .stab.index 0 : { *(.stab.index) }
57 .stab.indexstr 0 : { *(.stab.indexstr) }
58 .comment 0 : { *(.comment) }
59}
60
diff --git a/arch/arm26/boot/install.sh b/arch/arm26/boot/install.sh
deleted file mode 100644
index 8a8399b26cf7..000000000000
--- a/arch/arm26/boot/install.sh
+++ /dev/null
@@ -1,62 +0,0 @@
1#!/bin/sh
2#
3# arch/arm26/boot/install.sh
4#
5# This file is subject to the terms and conditions of the GNU General Public
6# License. See the file "COPYING" in the main directory of this archive
7# for more details.
8#
9# Copyright (C) 1995 by Linus Torvalds
10#
11# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
12# Adapted from code in arch/i386/boot/install.sh by Russell King
13# Stolen from arm32 by Ian Molton
14#
15# "make install" script for arm architecture
16#
17# Arguments:
18# $1 - kernel version
19# $2 - kernel image file
20# $3 - kernel map file
21# $4 - default install path (blank if root directory)
22#
23
24# User may have a custom install script
25
26if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then
27 exec /sbin/${CROSS_COMPILE}installkernel "$@"
28fi
29
30if [ "$2" = "zImage" ]; then
31# Compressed install
32 echo "Installing compressed kernel"
33 if [ -f $4/vmlinuz-$1 ]; then
34 mv $4/vmlinuz-$1 $4/vmlinuz.old
35 fi
36
37 if [ -f $4/System.map-$1 ]; then
38 mv $4/System.map-$1 $4/System.old
39 fi
40
41 cat $2 > $4/vmlinuz-$1
42 cp $3 $4/System.map-$1
43else
44# Normal install
45 echo "Installing normal kernel"
46 if [ -f $4/vmlinux-$1 ]; then
47 mv $4/vmlinux-$1 $4/vmlinux.old
48 fi
49
50 if [ -f $4/System.map ]; then
51 mv $4/System.map $4/System.old
52 fi
53
54 cat $2 > $4/vmlinux-$1
55 cp $3 $4/System.map
56fi
57
58if [ -x /sbin/loadmap ]; then
59 /sbin/loadmap --rdev /dev/ima
60else
61 echo "You have to install it yourself"
62fi
diff --git a/arch/arm26/defconfig b/arch/arm26/defconfig
deleted file mode 100644
index 2b7d44bf49bf..000000000000
--- a/arch/arm26/defconfig
+++ /dev/null
@@ -1,361 +0,0 @@
1#
2# Automatically generated by make menuconfig: don't edit
3#
4CONFIG_ARM=y
5# CONFIG_EISA is not set
6# CONFIG_SBUS is not set
7# CONFIG_MCA is not set
8CONFIG_UID16=y
9CONFIG_RWSEM_GENERIC_SPINLOCK=y
10# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
11# CONFIG_GENERIC_BUST_SPINLOCK is not set
12# CONFIG_GENERIC_ISA_DMA is not set
13
14#
15# Code maturity level options
16#
17CONFIG_EXPERIMENTAL=y
18
19#
20# General setup
21#
22# CONFIG_NET is not set
23# CONFIG_SYSVIPC is not set
24# CONFIG_BSD_PROCESS_ACCT is not set
25# CONFIG_SYSCTL is not set
26
27#
28# Loadable module support
29#
30# CONFIG_MODULES is not set
31
32#
33# System Type
34#
35CONFIG_ARCH_ARC=y
36# CONFIG_ARCH_A5K is not set
37CONFIG_ARCH_ACORN=y
38# CONFIG_CPU_32 is not set
39CONFIG_CPU_26=y
40# CONFIG_PAGESIZE_16 is not set
41
42#
43# General setup
44#
45CONFIG_FIQ=y
46# CONFIG_ZBOOT_ROM is not set
47CONFIG_ZBOOT_ROM_TEXT=0
48CONFIG_ZBOOT_ROM_BSS=0
49CONFIG_FPE_NWFPE=y
50CONFIG_KCORE_ELF=y
51# CONFIG_KCORE_AOUT is not set
52# CONFIG_BINFMT_AOUT is not set
53# CONFIG_BINFMT_ELF is not set
54# CONFIG_BINFMT_MISC is not set
55CONFIG_CMDLINE=""
56# CONFIG_ALIGNMENT_TRAP is not set
57
58#
59# Parallel port support
60#
61# CONFIG_PARPORT is not set
62
63#
64# Plug and Play configuration
65#
66# CONFIG_PNP is not set
67# CONFIG_ISAPNP is not set
68# CONFIG_PNPBIOS is not set
69
70#
71# Block devices
72#
73# CONFIG_BLK_DEV_FD is not set
74# CONFIG_BLK_DEV_XD is not set
75# CONFIG_PARIDE is not set
76# CONFIG_BLK_CPQ_DA is not set
77# CONFIG_BLK_CPQ_CISS_DA is not set
78# CONFIG_CISS_SCSI_TAPE is not set
79# CONFIG_BLK_DEV_DAC960 is not set
80# CONFIG_BLK_DEV_UMEM is not set
81# CONFIG_BLK_DEV_LOOP is not set
82# CONFIG_BLK_DEV_NBD is not set
83# CONFIG_BLK_DEV_RAM is not set
84# CONFIG_BLK_DEV_INITRD is not set
85
86#
87# Multi-device support (RAID and LVM)
88#
89# CONFIG_MD is not set
90# CONFIG_BLK_DEV_MD is not set
91# CONFIG_MD_LINEAR is not set
92# CONFIG_MD_RAID0 is not set
93# CONFIG_MD_RAID1 is not set
94# CONFIG_MD_RAID5 is not set
95# CONFIG_MD_MULTIPATH is not set
96# CONFIG_BLK_DEV_LVM is not set
97
98#
99# Acorn-specific block devices
100#
101# CONFIG_BLK_DEV_FD1772 is not set
102# CONFIG_BLK_DEV_MFM is not set
103
104#
105# ATA/ATAPI/MFM/RLL support
106#
107# CONFIG_IDE is not set
108# CONFIG_BLK_DEV_HD is not set
109
110#
111# SCSI support
112#
113# CONFIG_SCSI is not set
114
115#
116# ISDN subsystem
117#
118
119#
120# Input device support
121#
122# CONFIG_INPUT is not set
123# CONFIG_INPUT_KEYBDEV is not set
124# CONFIG_INPUT_MOUSEDEV is not set
125# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
126# CONFIG_INPUT_JOYDEV is not set
127# CONFIG_INPUT_TSDEV is not set
128# CONFIG_INPUT_TSLIBDEV is not set
129# CONFIG_INPUT_EVDEV is not set
130# CONFIG_INPUT_EVBUG is not set
131# CONFIG_INPUT_UINPUT is not set
132# CONFIG_GAMEPORT is not set
133CONFIG_SOUND_GAMEPORT=y
134# CONFIG_GAMEPORT_NS558 is not set
135# CONFIG_GAMEPORT_L4 is not set
136# CONFIG_GAMEPORT_EMU10K1 is not set
137# CONFIG_GAMEPORT_VORTEX is not set
138# CONFIG_GAMEPORT_FM801 is not set
139# CONFIG_GAMEPORT_CS461x is not set
140# CONFIG_SERIO is not set
141# CONFIG_SERIO_I8042 is not set
142# CONFIG_SERIO_SERPORT is not set
143# CONFIG_SERIO_CT82C710 is not set
144# CONFIG_SERIO_PARKBD is not set
145# CONFIG_SERIO_ACORN is not set
146
147#
148# Character devices
149#
150# CONFIG_VT is not set
151# CONFIG_SERIAL_NONSTANDARD is not set
152
153#
154# Serial drivers
155#
156# CONFIG_SERIAL_8250 is not set
157# CONFIG_SERIAL_8250_CONSOLE is not set
158# CONFIG_SERIAL_8250_CS is not set
159# CONFIG_SERIAL_8250_EXTENDED is not set
160# CONFIG_SERIAL_8250_MANY_PORTS is not set
161# CONFIG_SERIAL_8250_SHARE_IRQ is not set
162# CONFIG_SERIAL_8250_DETECT_IRQ is not set
163# CONFIG_SERIAL_8250_MULTIPORT is not set
164# CONFIG_SERIAL_8250_RSA is not set
165# CONFIG_ATOMWIDE_SERIAL is not set
166# CONFIG_DUALSP_SERIAL is not set
167# CONFIG_SERIAL_AMBA is not set
168# CONFIG_SERIAL_AMBA_CONSOLE is not set
169# CONFIG_SERIAL_CLPS711X is not set
170# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
171# CONFIG_SERIAL_CLPS711X_OLD_NAME is not set
172# CONFIG_SERIAL_21285 is not set
173# CONFIG_SERIAL_21285_OLD is not set
174# CONFIG_SERIAL_21285_CONSOLE is not set
175# CONFIG_SERIAL_UART00 is not set
176# CONFIG_SERIAL_UART00_CONSOLE is not set
177# CONFIG_SERIAL_SA1100 is not set
178# CONFIG_SERIAL_SA1100_CONSOLE is not set
179# CONFIG_UNIX98_PTYS is not set
180
181#
182# I2C support
183#
184CONFIG_I2C=y
185CONFIG_I2C_ALGOBIT=y
186CONFIG_I2C_ALGOPCF=y
187# CONFIG_I2C_ELEKTOR is not set
188CONFIG_I2C_CHARDEV=y
189# CONFIG_I2C_PROC is not set
190
191#
192# L3 serial bus support
193#
194# CONFIG_L3 is not set
195# CONFIG_L3_ALGOBIT is not set
196# CONFIG_L3_BIT_SA1100_GPIO is not set
197# CONFIG_L3_SA1111 is not set
198# CONFIG_BIT_SA1100_GPIO is not set
199
200#
201# Mice
202#
203# CONFIG_BUSMOUSE is not set
204# CONFIG_PSMOUSE is not set
205# CONFIG_QIC02_TAPE is not set
206
207#
208# Watchdog Cards
209#
210# CONFIG_WATCHDOG is not set
211# CONFIG_NVRAM is not set
212# CONFIG_RTC is not set
213# CONFIG_DTLK is not set
214# CONFIG_R3964 is not set
215# CONFIG_APPLICOM is not set
216
217#
218# Ftape, the floppy tape device driver
219#
220# CONFIG_FTAPE is not set
221# CONFIG_AGP is not set
222# CONFIG_DRM is not set
223# CONFIG_RAW_DRIVER is not set
224
225#
226# Multimedia devices
227#
228# CONFIG_VIDEO_DEV is not set
229
230#
231# File systems
232#
233# CONFIG_QUOTA is not set
234# CONFIG_QFMT_V1 is not set
235# CONFIG_QFMT_V2 is not set
236# CONFIG_AUTOFS_FS is not set
237# CONFIG_AUTOFS4_FS is not set
238# CONFIG_REISERFS_FS is not set
239# CONFIG_REISERFS_CHECK is not set
240# CONFIG_REISERFS_PROC_INFO is not set
241# CONFIG_ADFS_FS is not set
242# CONFIG_ADFS_FS_RW is not set
243# CONFIG_AFFS_FS is not set
244# CONFIG_HFS_FS is not set
245# CONFIG_BFS_FS is not set
246# CONFIG_EXT3_FS is not set
247# CONFIG_JBD is not set
248# CONFIG_JBD_DEBUG is not set
249# CONFIG_FAT_FS is not set
250# CONFIG_MSDOS_FS is not set
251# CONFIG_VFAT_FS is not set
252# CONFIG_EFS_FS is not set
253# CONFIG_JFFS_FS is not set
254# CONFIG_JFFS2_FS is not set
255# CONFIG_CRAMFS is not set
256# CONFIG_TMPFS is not set
257CONFIG_RAMFS=y
258# CONFIG_ISO9660_FS is not set
259# CONFIG_JOLIET is not set
260# CONFIG_ZISOFS is not set
261# CONFIG_JFS_FS is not set
262# CONFIG_JFS_DEBUG is not set
263# CONFIG_JFS_STATISTICS is not set
264# CONFIG_MINIX_FS is not set
265# CONFIG_VXFS_FS is not set
266# CONFIG_NTFS_FS is not set
267# CONFIG_NTFS_DEBUG is not set
268# CONFIG_HPFS_FS is not set
269CONFIG_PROC_FS=y
270# CONFIG_DEVFS_FS is not set
271# CONFIG_DEVFS_MOUNT is not set
272# CONFIG_DEVFS_DEBUG is not set
273# CONFIG_DEVPTS_FS is not set
274# CONFIG_QNX4FS_FS is not set
275# CONFIG_QNX4FS_RW is not set
276# CONFIG_ROMFS_FS is not set
277CONFIG_EXT2_FS=y
278# CONFIG_SYSV_FS is not set
279# CONFIG_UDF_FS is not set
280# CONFIG_UDF_RW is not set
281# CONFIG_UFS_FS is not set
282# CONFIG_UFS_FS_WRITE is not set
283# CONFIG_NCPFS_NLS is not set
284# CONFIG_SMB_FS is not set
285# CONFIG_ZISOFS_FS is not set
286
287#
288# Partition Types
289#
290CONFIG_PARTITION_ADVANCED=y
291CONFIG_ACORN_PARTITION=y
292# CONFIG_ACORN_PARTITION_EESOX is not set
293# CONFIG_ACORN_PARTITION_ICS is not set
294CONFIG_ACORN_PARTITION_ADFS=y
295# CONFIG_ACORN_PARTITION_POWERTEC is not set
296CONFIG_ACORN_PARTITION_RISCIX=y
297# CONFIG_OSF_PARTITION is not set
298# CONFIG_AMIGA_PARTITION is not set
299# CONFIG_ATARI_PARTITION is not set
300# CONFIG_MAC_PARTITION is not set
301# CONFIG_MSDOS_PARTITION is not set
302# CONFIG_LDM_PARTITION is not set
303# CONFIG_SGI_PARTITION is not set
304# CONFIG_ULTRIX_PARTITION is not set
305# CONFIG_SUN_PARTITION is not set
306# CONFIG_EFI_PARTITION is not set
307# CONFIG_SMB_NLS is not set
308# CONFIG_NLS is not set
309
310#
311# Sound
312#
313# CONFIG_SOUND is not set
314
315#
316# Multimedia Capabilities Port drivers
317#
318# CONFIG_MCP is not set
319# CONFIG_MCP_SA1100 is not set
320# CONFIG_MCP_UCB1200 is not set
321# CONFIG_MCP_UCB1200_AUDIO is not set
322# CONFIG_MCP_UCB1200_TS is not set
323
324#
325# Console Switches
326#
327# CONFIG_SWITCHES is not set
328# CONFIG_SWITCHES_SA1100 is not set
329# CONFIG_SWITCHES_UCB1X00 is not set
330
331#
332# USB support
333#
334# CONFIG_USB is not set
335
336#
337# Kernel hacking
338#
339# CONFIG_NO_FRAME_POINTER is not set
340CONFIG_DEBUG_USER=y
341CONFIG_DEBUG_INFO=y
342CONFIG_DEBUG_KERNEL=y
343CONFIG_DEBUG_SLAB=y
344CONFIG_MAGIC_SYSRQ=y
345CONFIG_DEBUG_SPINLOCK=y
346CONFIG_DEBUG_WAITQ=y
347CONFIG_DEBUG_BUGVERBOSE=y
348CONFIG_DEBUG_ERRORS=y
349CONFIG_DEBUG_LL=y
350
351#
352# Security options
353#
354CONFIG_SECURITY_CAPABILITIES=y
355
356#
357# Library routines
358#
359CONFIG_CRC32=y
360# CONFIG_ZLIB_INFLATE is not set
361# CONFIG_ZLIB_DEFLATE is not set
diff --git a/arch/arm26/kernel/Makefile b/arch/arm26/kernel/Makefile
deleted file mode 100644
index ee9fb49fdb78..000000000000
--- a/arch/arm26/kernel/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
1#
2# Makefile for the linux kernel.
3#
4
5# Object file lists.
6
7AFLAGS_head.o := -DTEXTADDR=$(TEXTADDR)
8
9obj-y := compat.o dma.o entry.o irq.o process.o ptrace.o \
10 semaphore.o setup.o signal.o sys_arm.o time.o traps.o \
11 ecard.o dma.o ecard.o fiq.o time.o
12
13extra-y := head.o init_task.o vmlinux.lds
14
15obj-$(CONFIG_FIQ) += fiq.o
16obj-$(CONFIG_MODULES) += armksyms.o
17
diff --git a/arch/arm26/kernel/armksyms.c b/arch/arm26/kernel/armksyms.c
deleted file mode 100644
index fe1e3ceed7cb..000000000000
--- a/arch/arm26/kernel/armksyms.c
+++ /dev/null
@@ -1,204 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/armksyms.c
3 *
4 * Copyright (C) 2003 Ian Molton
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/module.h>
11#include <linux/module.h>
12#include <linux/user.h>
13#include <linux/string.h>
14#include <linux/fs.h>
15#include <linux/mm.h>
16#include <linux/mman.h>
17#include <linux/delay.h>
18#include <linux/in6.h>
19#include <linux/interrupt.h>
20#include <linux/pm.h>
21#include <linux/tty.h>
22#include <linux/vt_kern.h>
23#include <linux/syscalls.h>
24
25#include <asm/byteorder.h>
26#include <asm/elf.h>
27#include <asm/io.h>
28#include <asm/irq.h>
29#include <asm/processor.h>
30#include <asm/semaphore.h>
31#include <asm/system.h>
32#include <asm/uaccess.h>
33#include <asm/checksum.h>
34#include <asm/mach-types.h>
35
36extern int dump_fpu(struct pt_regs *, struct user_fp_struct *);
37extern void inswb(unsigned int port, void *to, int len);
38extern void outswb(unsigned int port, const void *to, int len);
39
40extern void __bad_xchg(volatile void *ptr, int size);
41
42/*
43 * libgcc functions - functions that are used internally by the
44 * compiler... (prototypes are not correct though, but that
45 * doesn't really matter since they're not versioned).
46 */
47extern void __ashldi3(void);
48extern void __ashrdi3(void);
49extern void __divsi3(void);
50extern void __lshrdi3(void);
51extern void __modsi3(void);
52extern void __muldi3(void);
53extern void __ucmpdi2(void);
54extern void __udivdi3(void);
55extern void __umoddi3(void);
56extern void __udivmoddi4(void);
57extern void __udivsi3(void);
58extern void __umodsi3(void);
59extern void abort(void);
60
61extern void ret_from_exception(void);
62extern void fpundefinstr(void);
63extern void fp_enter(void);
64
65/*
66 * This has a special calling convention; it doesn't
67 * modify any of the usual registers, except for LR.
68 * FIXME - we used to use our own local version - looks to be in kernel/softirq now
69 */
70//extern void __do_softirq(void);
71
72#define EXPORT_SYMBOL_ALIAS(sym,orig) \
73 const char __kstrtab_##sym[] \
74 __attribute__((section(".kstrtab"))) = \
75 __MODULE_STRING(sym); \
76 const struct module_symbol __ksymtab_##sym \
77 __attribute__((section("__ksymtab"))) = \
78 { (unsigned long)&orig, __kstrtab_##sym };
79
80/*
81 * floating point math emulator support.
82 * These symbols will never change their calling convention...
83 */
84EXPORT_SYMBOL_ALIAS(kern_fp_enter,fp_enter);
85EXPORT_SYMBOL_ALIAS(fp_printk,printk);
86EXPORT_SYMBOL_ALIAS(fp_send_sig,send_sig);
87
88EXPORT_SYMBOL(fpundefinstr);
89EXPORT_SYMBOL(ret_from_exception);
90
91#ifdef CONFIG_VT
92EXPORT_SYMBOL(kd_mksound);
93#endif
94
95//EXPORT_SYMBOL(__do_softirq);
96
97 /* platform dependent support */
98EXPORT_SYMBOL(dump_thread);
99EXPORT_SYMBOL(dump_fpu);
100EXPORT_SYMBOL(udelay);
101EXPORT_SYMBOL(kernel_thread);
102EXPORT_SYMBOL(system_rev);
103EXPORT_SYMBOL(system_serial_low);
104EXPORT_SYMBOL(system_serial_high);
105#ifdef CONFIG_DEBUG_BUGVERBOSE
106EXPORT_SYMBOL(__bug);
107#endif
108EXPORT_SYMBOL(__bad_xchg);
109EXPORT_SYMBOL(__readwrite_bug);
110EXPORT_SYMBOL(set_irq_type);
111EXPORT_SYMBOL(pm_idle);
112EXPORT_SYMBOL(pm_power_off);
113
114 /* processor dependencies */
115EXPORT_SYMBOL(__machine_arch_type);
116
117 /* networking */
118EXPORT_SYMBOL(csum_partial_copy_nocheck);
119EXPORT_SYMBOL(__csum_ipv6_magic);
120
121 /* io */
122#ifndef __raw_readsb
123EXPORT_SYMBOL(__raw_readsb);
124#endif
125#ifndef __raw_readsw
126EXPORT_SYMBOL(__raw_readsw);
127#endif
128#ifndef __raw_readsl
129EXPORT_SYMBOL(__raw_readsl);
130#endif
131#ifndef __raw_writesb
132EXPORT_SYMBOL(__raw_writesb);
133#endif
134#ifndef __raw_writesw
135EXPORT_SYMBOL(__raw_writesw);
136#endif
137#ifndef __raw_writesl
138EXPORT_SYMBOL(__raw_writesl);
139#endif
140
141 /* string / mem functions */
142EXPORT_SYMBOL(strcpy);
143EXPORT_SYMBOL(strncpy);
144EXPORT_SYMBOL(strcat);
145EXPORT_SYMBOL(strncat);
146EXPORT_SYMBOL(strcmp);
147EXPORT_SYMBOL(strncmp);
148EXPORT_SYMBOL(strchr);
149EXPORT_SYMBOL(strlen);
150EXPORT_SYMBOL(strnlen);
151EXPORT_SYMBOL(strrchr);
152EXPORT_SYMBOL(strstr);
153EXPORT_SYMBOL(memset);
154EXPORT_SYMBOL(memcpy);
155EXPORT_SYMBOL(memmove);
156EXPORT_SYMBOL(memcmp);
157EXPORT_SYMBOL(memscan);
158EXPORT_SYMBOL(__memzero);
159
160 /* user mem (segment) */
161EXPORT_SYMBOL(uaccess_kernel);
162EXPORT_SYMBOL(uaccess_user);
163
164EXPORT_SYMBOL(__get_user_1);
165EXPORT_SYMBOL(__get_user_2);
166EXPORT_SYMBOL(__get_user_4);
167EXPORT_SYMBOL(__get_user_8);
168
169EXPORT_SYMBOL(__put_user_1);
170EXPORT_SYMBOL(__put_user_2);
171EXPORT_SYMBOL(__put_user_4);
172EXPORT_SYMBOL(__put_user_8);
173
174 /* gcc lib functions */
175EXPORT_SYMBOL(__ashldi3);
176EXPORT_SYMBOL(__ashrdi3);
177EXPORT_SYMBOL(__divsi3);
178EXPORT_SYMBOL(__lshrdi3);
179EXPORT_SYMBOL(__modsi3);
180EXPORT_SYMBOL(__muldi3);
181EXPORT_SYMBOL(__ucmpdi2);
182EXPORT_SYMBOL(__udivdi3);
183EXPORT_SYMBOL(__umoddi3);
184EXPORT_SYMBOL(__udivmoddi4);
185EXPORT_SYMBOL(__udivsi3);
186EXPORT_SYMBOL(__umodsi3);
187
188 /* bitops */
189EXPORT_SYMBOL(_set_bit_le);
190EXPORT_SYMBOL(_test_and_set_bit_le);
191EXPORT_SYMBOL(_clear_bit_le);
192EXPORT_SYMBOL(_test_and_clear_bit_le);
193EXPORT_SYMBOL(_change_bit_le);
194EXPORT_SYMBOL(_test_and_change_bit_le);
195EXPORT_SYMBOL(_find_first_zero_bit_le);
196EXPORT_SYMBOL(_find_next_zero_bit_le);
197
198 /* elf */
199EXPORT_SYMBOL(elf_platform);
200EXPORT_SYMBOL(elf_hwcap);
201
202#ifdef CONFIG_PREEMPT
203EXPORT_SYMBOL(kernel_flag);
204#endif
diff --git a/arch/arm26/kernel/asm-offsets.c b/arch/arm26/kernel/asm-offsets.c
deleted file mode 100644
index 76d9d7d489a8..000000000000
--- a/arch/arm26/kernel/asm-offsets.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/*
2 * Copyright (C) 1995-2001 Russell King
3 * 2001-2002 Keith Owens
4 * 2003 Ian Molton
5 *
6 * Generate definitions needed by assembly language modules.
7 * This code generates raw asm output which is post-processed to extract
8 * and format the required data.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/sched.h>
16#include <linux/mm.h>
17
18#include <asm/pgtable.h>
19#include <asm/uaccess.h>
20
21/*
22 * Make sure that the compiler and target are compatible.
23 */
24#if defined(__APCS_32__) && defined(CONFIG_CPU_26)
25#error Sorry, your compiler targets APCS-32 but this kernel requires APCS-26
26#endif
27
28/* Use marker if you need to separate the values later */
29
30#define DEFINE(sym, val) \
31 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
32
33#define BLANK() asm volatile("\n->" : : )
34
35int main(void)
36{
37 DEFINE(TSK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
38 BLANK();
39 DEFINE(VMA_VM_MM, offsetof(struct vm_area_struct, vm_mm));
40 DEFINE(VMA_VM_FLAGS, offsetof(struct vm_area_struct, vm_flags));
41 BLANK();
42 DEFINE(VM_EXEC, VM_EXEC);
43 BLANK();
44 BLANK();
45 DEFINE(PAGE_PRESENT, _PAGE_PRESENT);
46 DEFINE(PAGE_READONLY, _PAGE_READONLY);
47 DEFINE(PAGE_NOT_USER, _PAGE_NOT_USER);
48 DEFINE(PAGE_OLD, _PAGE_OLD);
49 DEFINE(PAGE_CLEAN, _PAGE_CLEAN);
50 BLANK();
51 DEFINE(PAGE_SZ, PAGE_SIZE);
52 BLANK();
53 DEFINE(SYS_ERROR0, 0x9f0000);
54 return 0;
55}
diff --git a/arch/arm26/kernel/calls.S b/arch/arm26/kernel/calls.S
deleted file mode 100644
index e3d276827c84..000000000000
--- a/arch/arm26/kernel/calls.S
+++ /dev/null
@@ -1,265 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/calls.S
3 *
4 * Copyright (C) 2003 Ian Molton
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * FIXME
11 * This file is included twice in entry.S which may not be necessary
12 */
13
14//FIXME - clearly NR_syscalls is never defined here
15
16#ifndef NR_syscalls
17#define NR_syscalls 256
18#else
19
20__syscall_start:
21/* 0 */ .long sys_ni_syscall
22 .long sys_exit
23 .long sys_fork_wrapper
24 .long sys_read
25 .long sys_write
26/* 5 */ .long sys_open
27 .long sys_close
28 .long sys_ni_syscall /* was sys_waitpid */
29 .long sys_creat
30 .long sys_link
31/* 10 */ .long sys_unlink
32 .long sys_execve_wrapper
33 .long sys_chdir
34 .long sys_time /* used by libc4 */
35 .long sys_mknod
36/* 15 */ .long sys_chmod
37 .long sys_lchown16
38 .long sys_ni_syscall /* was sys_break */
39 .long sys_ni_syscall /* was sys_stat */
40 .long sys_lseek
41/* 20 */ .long sys_getpid
42 .long sys_mount
43 .long sys_oldumount /* used by libc4 */
44 .long sys_setuid16
45 .long sys_getuid16
46/* 25 */ .long sys_stime
47 .long sys_ptrace
48 .long sys_alarm /* used by libc4 */
49 .long sys_ni_syscall /* was sys_fstat */
50 .long sys_pause
51/* 30 */ .long sys_utime /* used by libc4 */
52 .long sys_ni_syscall /* was sys_stty */
53 .long sys_ni_syscall /* was sys_getty */
54 .long sys_access
55 .long sys_nice
56/* 35 */ .long sys_ni_syscall /* was sys_ftime */
57 .long sys_sync
58 .long sys_kill
59 .long sys_rename
60 .long sys_mkdir
61/* 40 */ .long sys_rmdir
62 .long sys_dup
63 .long sys_pipe
64 .long sys_times
65 .long sys_ni_syscall /* was sys_prof */
66/* 45 */ .long sys_brk
67 .long sys_setgid16
68 .long sys_getgid16
69 .long sys_ni_syscall /* was sys_signal */
70 .long sys_geteuid16
71/* 50 */ .long sys_getegid16
72 .long sys_acct
73 .long sys_umount
74 .long sys_ni_syscall /* was sys_lock */
75 .long sys_ioctl
76/* 55 */ .long sys_fcntl
77 .long sys_ni_syscall /* was sys_mpx */
78 .long sys_setpgid
79 .long sys_ni_syscall /* was sys_ulimit */
80 .long sys_ni_syscall /* was sys_olduname */
81/* 60 */ .long sys_umask
82 .long sys_chroot
83 .long sys_ustat
84 .long sys_dup2
85 .long sys_getppid
86/* 65 */ .long sys_getpgrp
87 .long sys_setsid
88 .long sys_sigaction
89 .long sys_ni_syscall /* was sys_sgetmask */
90 .long sys_ni_syscall /* was sys_ssetmask */
91/* 70 */ .long sys_setreuid16
92 .long sys_setregid16
93 .long sys_sigsuspend_wrapper
94 .long sys_sigpending
95 .long sys_sethostname
96/* 75 */ .long sys_setrlimit
97 .long sys_old_getrlimit /* used by libc4 */
98 .long sys_getrusage
99 .long sys_gettimeofday
100 .long sys_settimeofday
101/* 80 */ .long sys_getgroups16
102 .long sys_setgroups16
103 .long old_select /* used by libc4 */
104 .long sys_symlink
105 .long sys_ni_syscall /* was sys_lstat */
106/* 85 */ .long sys_readlink
107 .long sys_uselib
108 .long sys_swapon
109 .long sys_reboot
110 .long old_readdir /* used by libc4 */
111/* 90 */ .long old_mmap /* used by libc4 */
112 .long sys_munmap
113 .long sys_truncate
114 .long sys_ftruncate
115 .long sys_fchmod
116/* 95 */ .long sys_fchown16
117 .long sys_getpriority
118 .long sys_setpriority
119 .long sys_ni_syscall /* was sys_profil */
120 .long sys_statfs
121/* 100 */ .long sys_fstatfs
122 .long sys_ni_syscall
123 .long sys_socketcall
124 .long sys_syslog
125 .long sys_setitimer
126/* 105 */ .long sys_getitimer
127 .long sys_newstat
128 .long sys_newlstat
129 .long sys_newfstat
130 .long sys_ni_syscall /* was sys_uname */
131/* 110 */ .long sys_ni_syscall /* was sys_iopl */
132 .long sys_vhangup
133 .long sys_ni_syscall
134 .long sys_syscall /* call a syscall */
135 .long sys_wait4
136/* 115 */ .long sys_swapoff
137 .long sys_sysinfo
138 .long sys_ipc
139 .long sys_fsync
140 .long sys_sigreturn_wrapper
141/* 120 */ .long sys_clone_wapper
142 .long sys_setdomainname
143 .long sys_newuname
144 .long sys_ni_syscall
145 .long sys_adjtimex
146/* 125 */ .long sys_mprotect
147 .long sys_sigprocmask
148 .long sys_ni_syscall /* WAS: sys_create_module */
149 .long sys_init_module
150 .long sys_delete_module
151/* 130 */ .long sys_ni_syscall /* WAS: sys_get_kernel_syms */
152 .long sys_quotactl
153 .long sys_getpgid
154 .long sys_fchdir
155 .long sys_bdflush
156/* 135 */ .long sys_sysfs
157 .long sys_personality
158 .long sys_ni_syscall /* .long _sys_afs_syscall */
159 .long sys_setfsuid16
160 .long sys_setfsgid16
161/* 140 */ .long sys_llseek
162 .long sys_getdents
163 .long sys_select
164 .long sys_flock
165 .long sys_msync
166/* 145 */ .long sys_readv
167 .long sys_writev
168 .long sys_getsid
169 .long sys_fdatasync
170 .long sys_sysctl
171/* 150 */ .long sys_mlock
172 .long sys_munlock
173 .long sys_mlockall
174 .long sys_munlockall
175 .long sys_sched_setparam
176/* 155 */ .long sys_sched_getparam
177 .long sys_sched_setscheduler
178 .long sys_sched_getscheduler
179 .long sys_sched_yield
180 .long sys_sched_get_priority_max
181/* 160 */ .long sys_sched_get_priority_min
182 .long sys_sched_rr_get_interval
183 .long sys_nanosleep
184 .long sys_arm_mremap
185 .long sys_setresuid16
186/* 165 */ .long sys_getresuid16
187 .long sys_ni_syscall
188 .long sys_ni_syscall /* WAS: sys_query_module */
189 .long sys_poll
190 .long sys_nfsservctl
191/* 170 */ .long sys_setresgid16
192 .long sys_getresgid16
193 .long sys_prctl
194 .long sys_rt_sigreturn_wrapper
195 .long sys_rt_sigaction
196/* 175 */ .long sys_rt_sigprocmask
197 .long sys_rt_sigpending
198 .long sys_rt_sigtimedwait
199 .long sys_rt_sigqueueinfo
200 .long sys_rt_sigsuspend_wrapper
201/* 180 */ .long sys_pread64
202 .long sys_pwrite64
203 .long sys_chown16
204 .long sys_getcwd
205 .long sys_capget
206/* 185 */ .long sys_capset
207 .long sys_sigaltstack_wrapper
208 .long sys_sendfile
209 .long sys_ni_syscall
210 .long sys_ni_syscall
211/* 190 */ .long sys_vfork_wrapper
212 .long sys_getrlimit
213 .long sys_mmap2
214 .long sys_truncate64
215 .long sys_ftruncate64
216/* 195 */ .long sys_stat64
217 .long sys_lstat64
218 .long sys_fstat64
219 .long sys_lchown
220 .long sys_getuid
221/* 200 */ .long sys_getgid
222 .long sys_geteuid
223 .long sys_getegid
224 .long sys_setreuid
225 .long sys_setregid
226/* 205 */ .long sys_getgroups
227 .long sys_setgroups
228 .long sys_fchown
229 .long sys_setresuid
230 .long sys_getresuid
231/* 210 */ .long sys_setresgid
232 .long sys_getresgid
233 .long sys_chown
234 .long sys_setuid
235 .long sys_setgid
236/* 215 */ .long sys_setfsuid
237 .long sys_setfsgid
238 .long sys_getdents64
239 .long sys_pivot_root
240 .long sys_mincore
241/* 220 */ .long sys_madvise
242 .long sys_fcntl64
243 .long sys_ni_syscall /* TUX */
244 .long sys_ni_syscall /* WAS: sys_security */
245 .long sys_gettid
246/* 225 */ .long sys_readahead
247 .long sys_setxattr
248 .long sys_lsetxattr
249 .long sys_fsetxattr
250 .long sys_getxattr
251/* 230 */ .long sys_lgetxattr
252 .long sys_fgetxattr
253 .long sys_listxattr
254 .long sys_llistxattr
255 .long sys_flistxattr
256/* 235 */ .long sys_removexattr
257 .long sys_lremovexattr
258 .long sys_fremovexattr
259 .long sys_tkill
260__syscall_end:
261
262 .rept NR_syscalls - (__syscall_end - __syscall_start) / 4
263 .long sys_ni_syscall
264 .endr
265#endif
diff --git a/arch/arm26/kernel/compat.c b/arch/arm26/kernel/compat.c
deleted file mode 100644
index 21e966ff0aa7..000000000000
--- a/arch/arm26/kernel/compat.c
+++ /dev/null
@@ -1,173 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/compat.c
3 *
4 * Copyright (C) 2001 Russell King
5 * 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * We keep the old params compatibility cruft in one place (here)
12 * so we don't end up with lots of mess around other places.
13 *
14 * NOTE:
15 * The old struct param_struct is deprecated, but it will be kept in
16 * the kernel for 5 years from now (2001). This will allow boot loaders
17 * to convert to the new struct tag way.
18 */
19#include <linux/types.h>
20#include <linux/kernel.h>
21#include <linux/string.h>
22#include <linux/init.h>
23
24#include <asm/setup.h>
25#include <asm/mach-types.h>
26#include <asm/page.h>
27
28//#include <asm/arch.h>
29//#include <asm/mach/irq.h>
30
31/*
32 * Usage:
33 * - do not go blindly adding fields, add them at the end
34 * - when adding fields, don't rely on the address until
35 * a patch from me has been released
36 * - unused fields should be zero (for future expansion)
37 * - this structure is relatively short-lived - only
38 * guaranteed to contain useful data in setup_arch()
39 *
40 * This is the old deprecated way to pass parameters to the kernel
41 */
42struct param_struct {
43 union {
44 struct {
45 unsigned long page_size; /* 0 */
46 unsigned long nr_pages; /* 4 */
47 unsigned long ramdisk_size; /* 8 */
48 unsigned long flags; /* 12 */
49#define FLAG_READONLY 1
50#define FLAG_RDLOAD 4
51#define FLAG_RDPROMPT 8
52 unsigned long rootdev; /* 16 */
53 unsigned long video_num_cols; /* 20 */
54 unsigned long video_num_rows; /* 24 */
55 unsigned long video_x; /* 28 */
56 unsigned long video_y; /* 32 */
57 unsigned long memc_control_reg; /* 36 */
58 unsigned char sounddefault; /* 40 */
59 unsigned char adfsdrives; /* 41 */
60 unsigned char bytes_per_char_h; /* 42 */
61 unsigned char bytes_per_char_v; /* 43 */
62 unsigned long pages_in_bank[4]; /* 44 */
63 unsigned long pages_in_vram; /* 60 */
64 unsigned long initrd_start; /* 64 */
65 unsigned long initrd_size; /* 68 */
66 unsigned long rd_start; /* 72 */
67 unsigned long system_rev; /* 76 */
68 unsigned long system_serial_low; /* 80 */
69 unsigned long system_serial_high; /* 84 */
70 unsigned long mem_fclk_21285; /* 88 */
71 } s;
72 char unused[256];
73 } u1;
74 union {
75 char paths[8][128];
76 struct {
77 unsigned long magic;
78 char n[1024 - sizeof(unsigned long)];
79 } s;
80 } u2;
81 char commandline[COMMAND_LINE_SIZE];
82};
83
84static struct tag * __init memtag(struct tag *tag, unsigned long start, unsigned long size)
85{
86 tag = tag_next(tag);
87 tag->hdr.tag = ATAG_MEM;
88 tag->hdr.size = tag_size(tag_mem32);
89 tag->u.mem.size = size;
90 tag->u.mem.start = start;
91
92 return tag;
93}
94
95static void __init build_tag_list(struct param_struct *params, void *taglist)
96{
97 struct tag *tag = taglist;
98
99 if (params->u1.s.page_size != PAGE_SIZE) {
100 printk(KERN_WARNING "Warning: bad configuration page, "
101 "trying to continue\n");
102 return;
103 }
104
105 printk(KERN_DEBUG "Converting old-style param struct to taglist\n");
106
107 tag->hdr.tag = ATAG_CORE;
108 tag->hdr.size = tag_size(tag_core);
109 tag->u.core.flags = params->u1.s.flags & FLAG_READONLY;
110 tag->u.core.pagesize = params->u1.s.page_size;
111 tag->u.core.rootdev = params->u1.s.rootdev;
112
113 tag = tag_next(tag);
114 tag->hdr.tag = ATAG_RAMDISK;
115 tag->hdr.size = tag_size(tag_ramdisk);
116 tag->u.ramdisk.flags = (params->u1.s.flags & FLAG_RDLOAD ? 1 : 0) |
117 (params->u1.s.flags & FLAG_RDPROMPT ? 2 : 0);
118 tag->u.ramdisk.size = params->u1.s.ramdisk_size;
119 tag->u.ramdisk.start = params->u1.s.rd_start;
120
121 tag = tag_next(tag);
122 tag->hdr.tag = ATAG_INITRD;
123 tag->hdr.size = tag_size(tag_initrd);
124 tag->u.initrd.start = params->u1.s.initrd_start;
125 tag->u.initrd.size = params->u1.s.initrd_size;
126
127 tag = tag_next(tag);
128 tag->hdr.tag = ATAG_SERIAL;
129 tag->hdr.size = tag_size(tag_serialnr);
130 tag->u.serialnr.low = params->u1.s.system_serial_low;
131 tag->u.serialnr.high = params->u1.s.system_serial_high;
132
133 tag = tag_next(tag);
134 tag->hdr.tag = ATAG_REVISION;
135 tag->hdr.size = tag_size(tag_revision);
136 tag->u.revision.rev = params->u1.s.system_rev;
137
138 tag = memtag(tag, PHYS_OFFSET, params->u1.s.nr_pages * PAGE_SIZE);
139
140 tag = tag_next(tag);
141 tag->hdr.tag = ATAG_ACORN;
142 tag->hdr.size = tag_size(tag_acorn);
143 tag->u.acorn.memc_control_reg = params->u1.s.memc_control_reg;
144 tag->u.acorn.vram_pages = params->u1.s.pages_in_vram;
145 tag->u.acorn.sounddefault = params->u1.s.sounddefault;
146 tag->u.acorn.adfsdrives = params->u1.s.adfsdrives;
147
148 tag = tag_next(tag);
149 tag->hdr.tag = ATAG_CMDLINE;
150 tag->hdr.size = (strlen(params->commandline) + 3 +
151 sizeof(struct tag_header)) >> 2;
152 strcpy(tag->u.cmdline.cmdline, params->commandline);
153
154 tag = tag_next(tag);
155 tag->hdr.tag = ATAG_NONE;
156 tag->hdr.size = 0;
157
158 memmove(params, taglist, ((int)tag) - ((int)taglist) +
159 sizeof(struct tag_header));
160}
161
162void __init convert_to_tag_list(struct tag *tags)
163{
164 struct param_struct *params = (struct param_struct *)tags;
165 build_tag_list(params, &params->u2);
166}
167
168void __init squash_mem_tags(struct tag *tag)
169{
170 for (; tag->hdr.size; tag = tag_next(tag))
171 if (tag->hdr.tag == ATAG_MEM)
172 tag->hdr.tag = ATAG_NONE;
173}
diff --git a/arch/arm26/kernel/dma.c b/arch/arm26/kernel/dma.c
deleted file mode 100644
index 80b5a774d905..000000000000
--- a/arch/arm26/kernel/dma.c
+++ /dev/null
@@ -1,273 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/dma.c
3 *
4 * Copyright (C) 1995-2000 Russell King
5 * 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Front-end to the DMA handling. This handles the allocation/freeing
12 * of DMA channels, and provides a unified interface to the machines
13 * DMA facilities.
14 */
15#include <linux/module.h>
16#include <linux/slab.h>
17#include <linux/sched.h>
18#include <linux/mman.h>
19#include <linux/init.h>
20#include <linux/spinlock.h>
21#include <linux/errno.h>
22
23#include <asm/dma.h>
24
25DEFINE_SPINLOCK(dma_spin_lock);
26
27static dma_t dma_chan[MAX_DMA_CHANNELS];
28
29/*
30 * Get dma list for /proc/dma
31 */
32int get_dma_list(char *buf)
33{
34 dma_t *dma;
35 char *p = buf;
36 int i;
37
38 for (i = 0, dma = dma_chan; i < MAX_DMA_CHANNELS; i++, dma++)
39 if (dma->lock)
40 p += sprintf(p, "%2d: %14s %s\n", i,
41 dma->d_ops->type, dma->device_id);
42
43 return p - buf;
44}
45
46/*
47 * Request DMA channel
48 *
49 * On certain platforms, we have to allocate an interrupt as well...
50 */
51int request_dma(dmach_t channel, const char *device_id)
52{
53 dma_t *dma = dma_chan + channel;
54 int ret;
55
56 if (channel >= MAX_DMA_CHANNELS || !dma->d_ops)
57 goto bad_dma;
58
59 if (xchg(&dma->lock, 1) != 0)
60 goto busy;
61
62 dma->device_id = device_id;
63 dma->active = 0;
64 dma->invalid = 1;
65
66 ret = 0;
67 if (dma->d_ops->request)
68 ret = dma->d_ops->request(channel, dma);
69
70 if (ret)
71 xchg(&dma->lock, 0);
72
73 return ret;
74
75bad_dma:
76 printk(KERN_ERR "dma: trying to allocate DMA%d\n", channel);
77 return -EINVAL;
78
79busy:
80 return -EBUSY;
81}
82
83/*
84 * Free DMA channel
85 *
86 * On certain platforms, we have to free interrupt as well...
87 */
88void free_dma(dmach_t channel)
89{
90 dma_t *dma = dma_chan + channel;
91
92 if (channel >= MAX_DMA_CHANNELS || !dma->d_ops)
93 goto bad_dma;
94
95 if (dma->active) {
96 printk(KERN_ERR "dma%d: freeing active DMA\n", channel);
97 dma->d_ops->disable(channel, dma);
98 dma->active = 0;
99 }
100
101 if (xchg(&dma->lock, 0) != 0) {
102 if (dma->d_ops->free)
103 dma->d_ops->free(channel, dma);
104 return;
105 }
106
107 printk(KERN_ERR "dma%d: trying to free free DMA\n", channel);
108 return;
109
110bad_dma:
111 printk(KERN_ERR "dma: trying to free DMA%d\n", channel);
112}
113
114/* Set DMA Scatter-Gather list
115 */
116void set_dma_sg (dmach_t channel, struct scatterlist *sg, int nr_sg)
117{
118 dma_t *dma = dma_chan + channel;
119
120 if (dma->active)
121 printk(KERN_ERR "dma%d: altering DMA SG while "
122 "DMA active\n", channel);
123
124 dma->sg = sg;
125 dma->sgcount = nr_sg;
126 dma->using_sg = 1;
127 dma->invalid = 1;
128}
129
130/* Set DMA address
131 *
132 * Copy address to the structure, and set the invalid bit
133 */
134void set_dma_addr (dmach_t channel, unsigned long physaddr)
135{
136 dma_t *dma = dma_chan + channel;
137
138 if (dma->active)
139 printk(KERN_ERR "dma%d: altering DMA address while "
140 "DMA active\n", channel);
141
142 dma->sg = &dma->buf;
143 dma->sgcount = 1;
144 dma->buf.__address = (char *)physaddr;//FIXME - not pretty
145 dma->using_sg = 0;
146 dma->invalid = 1;
147}
148
149/* Set DMA byte count
150 *
151 * Copy address to the structure, and set the invalid bit
152 */
153void set_dma_count (dmach_t channel, unsigned long count)
154{
155 dma_t *dma = dma_chan + channel;
156
157 if (dma->active)
158 printk(KERN_ERR "dma%d: altering DMA count while "
159 "DMA active\n", channel);
160
161 dma->sg = &dma->buf;
162 dma->sgcount = 1;
163 dma->buf.length = count;
164 dma->using_sg = 0;
165 dma->invalid = 1;
166}
167
168/* Set DMA direction mode
169 */
170void set_dma_mode (dmach_t channel, dmamode_t mode)
171{
172 dma_t *dma = dma_chan + channel;
173
174 if (dma->active)
175 printk(KERN_ERR "dma%d: altering DMA mode while "
176 "DMA active\n", channel);
177
178 dma->dma_mode = mode;
179 dma->invalid = 1;
180}
181
182/* Enable DMA channel
183 */
184void enable_dma (dmach_t channel)
185{
186 dma_t *dma = dma_chan + channel;
187
188 if (!dma->lock)
189 goto free_dma;
190
191 if (dma->active == 0) {
192 dma->active = 1;
193 dma->d_ops->enable(channel, dma);
194 }
195 return;
196
197free_dma:
198 printk(KERN_ERR "dma%d: trying to enable free DMA\n", channel);
199 BUG();
200}
201
202/* Disable DMA channel
203 */
204void disable_dma (dmach_t channel)
205{
206 dma_t *dma = dma_chan + channel;
207
208 if (!dma->lock)
209 goto free_dma;
210
211 if (dma->active == 1) {
212 dma->active = 0;
213 dma->d_ops->disable(channel, dma);
214 }
215 return;
216
217free_dma:
218 printk(KERN_ERR "dma%d: trying to disable free DMA\n", channel);
219 BUG();
220}
221
222/*
223 * Is the specified DMA channel active?
224 */
225int dma_channel_active(dmach_t channel)
226{
227 return dma_chan[channel].active;
228}
229
230void set_dma_page(dmach_t channel, char pagenr)
231{
232 printk(KERN_ERR "dma%d: trying to set_dma_page\n", channel);
233}
234
235void set_dma_speed(dmach_t channel, int cycle_ns)
236{
237 dma_t *dma = dma_chan + channel;
238 int ret = 0;
239
240 if (dma->d_ops->setspeed)
241 ret = dma->d_ops->setspeed(channel, dma, cycle_ns);
242 dma->speed = ret;
243}
244
245int get_dma_residue(dmach_t channel)
246{
247 dma_t *dma = dma_chan + channel;
248 int ret = 0;
249
250 if (dma->d_ops->residue)
251 ret = dma->d_ops->residue(channel, dma);
252
253 return ret;
254}
255
256void __init init_dma(void)
257{
258 arch_dma_init(dma_chan);
259}
260
261EXPORT_SYMBOL(request_dma);
262EXPORT_SYMBOL(free_dma);
263EXPORT_SYMBOL(enable_dma);
264EXPORT_SYMBOL(disable_dma);
265EXPORT_SYMBOL(set_dma_addr);
266EXPORT_SYMBOL(set_dma_count);
267EXPORT_SYMBOL(set_dma_mode);
268EXPORT_SYMBOL(set_dma_page);
269EXPORT_SYMBOL(get_dma_residue);
270EXPORT_SYMBOL(set_dma_sg);
271EXPORT_SYMBOL(set_dma_speed);
272
273EXPORT_SYMBOL(dma_spin_lock);
diff --git a/arch/arm26/kernel/ecard.c b/arch/arm26/kernel/ecard.c
deleted file mode 100644
index e2bcefc91cc3..000000000000
--- a/arch/arm26/kernel/ecard.c
+++ /dev/null
@@ -1,847 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/ecard.c
3 *
4 * Copyright 1995-2001 Russell King
5 * Copyright 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Find all installed expansion cards, and handle interrupts from them.
12 *
13 * Created from information from Acorns RiscOS3 PRMs
14 * 15-Jun-2003 IM Modified from ARM32 (RiscPC capable) version
15 * 10-Jan-1999 RMK Run loaders in a simulated RISC OS environment.
16 * 06-May-1997 RMK Added blacklist for cards whose loader doesn't work.
17 * 12-Sep-1997 RMK Created new handling of interrupt enables/disables
18 * - cards can now register their own routine to control
19 * interrupts (recommended).
20 * 29-Sep-1997 RMK Expansion card interrupt hardware not being re-enabled
21 * on reset from Linux. (Caused cards not to respond
22 * under RiscOS without hard reset).
23 *
24 */
25#define ECARD_C
26
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/types.h>
30#include <linux/sched.h>
31#include <linux/interrupt.h>
32#include <linux/reboot.h>
33#include <linux/mm.h>
34#include <linux/slab.h>
35#include <linux/proc_fs.h>
36#include <linux/device.h>
37#include <linux/init.h>
38
39#include <asm/dma.h>
40#include <asm/ecard.h>
41#include <asm/hardware.h>
42#include <asm/io.h>
43#include <asm/irq.h>
44#include <asm/mmu_context.h>
45#include <asm/irqchip.h>
46#include <asm/tlbflush.h>
47
48enum req {
49 req_readbytes,
50 req_reset
51};
52
53struct ecard_request {
54 enum req req;
55 ecard_t *ec;
56 unsigned int address;
57 unsigned int length;
58 unsigned int use_loader;
59 void *buffer;
60};
61
62struct expcard_blacklist {
63 unsigned short manufacturer;
64 unsigned short product;
65 const char *type;
66};
67
68static ecard_t *cards;
69static ecard_t *slot_to_expcard[MAX_ECARDS];
70static unsigned int ectcr;
71
72/* List of descriptions of cards which don't have an extended
73 * identification, or chunk directories containing a description.
74 */
75static struct expcard_blacklist __initdata blacklist[] = {
76 { MANU_ACORN, PROD_ACORN_ETHER1, "Acorn Ether1" }
77};
78
79asmlinkage extern int
80ecard_loader_reset(volatile unsigned char *pa, loader_t loader);
81asmlinkage extern int
82ecard_loader_read(int off, volatile unsigned char *pa, loader_t loader);
83
84static const struct ecard_id *
85ecard_match_device(const struct ecard_id *ids, struct expansion_card *ec);
86
87static inline unsigned short
88ecard_getu16(unsigned char *v)
89{
90 return v[0] | v[1] << 8;
91}
92
93static inline signed long
94ecard_gets24(unsigned char *v)
95{
96 return v[0] | v[1] << 8 | v[2] << 16 | ((v[2] & 0x80) ? 0xff000000 : 0);
97}
98
99static inline ecard_t *
100slot_to_ecard(unsigned int slot)
101{
102 return slot < MAX_ECARDS ? slot_to_expcard[slot] : NULL;
103}
104
105/* ===================== Expansion card daemon ======================== */
106/*
107 * Since the loader programs on the expansion cards need to be run
108 * in a specific environment, create a separate task with this
109 * environment up, and pass requests to this task as and when we
110 * need to.
111 *
112 * This should allow 99% of loaders to be called from Linux.
113 *
114 * From a security standpoint, we trust the card vendors. This
115 * may be a misplaced trust.
116 */
117#define BUS_ADDR(x) ((((unsigned long)(x)) << 2) + IO_BASE)
118#define POD_INT_ADDR(x) ((volatile unsigned char *)\
119 ((BUS_ADDR((x)) - IO_BASE) + IO_START))
120
121static inline void ecard_task_reset(struct ecard_request *req)
122{
123 struct expansion_card *ec = req->ec;
124 if (ec->loader)
125 ecard_loader_reset(POD_INT_ADDR(ec->podaddr), ec->loader);
126}
127
128static void
129ecard_task_readbytes(struct ecard_request *req)
130{
131 unsigned char *buf = (unsigned char *)req->buffer;
132 volatile unsigned char *base_addr =
133 (volatile unsigned char *)POD_INT_ADDR(req->ec->podaddr);
134 unsigned int len = req->length;
135 unsigned int off = req->address;
136
137 if (!req->use_loader || !req->ec->loader) {
138 off *= 4;
139 while (len--) {
140 *buf++ = base_addr[off];
141 off += 4;
142 }
143 } else {
144 while(len--) {
145 /*
146 * The following is required by some
147 * expansion card loader programs.
148 */
149 *(unsigned long *)0x108 = 0;
150 *buf++ = ecard_loader_read(off++, base_addr,
151 req->ec->loader);
152 }
153 }
154}
155
156static void ecard_do_request(struct ecard_request *req)
157{
158 switch (req->req) {
159 case req_readbytes:
160 ecard_task_readbytes(req);
161 break;
162
163 case req_reset:
164 ecard_task_reset(req);
165 break;
166 }
167}
168
169/*
170 * On 26-bit processors, we don't need the kcardd thread to access the
171 * expansion card loaders. We do it directly.
172 */
173#define ecard_call(req) ecard_do_request(req)
174
175/* ======================= Mid-level card control ===================== */
176
177static void
178ecard_readbytes(void *addr, ecard_t *ec, int off, int len, int useld)
179{
180 struct ecard_request req;
181
182 req.req = req_readbytes;
183 req.ec = ec;
184 req.address = off;
185 req.length = len;
186 req.use_loader = useld;
187 req.buffer = addr;
188
189 ecard_call(&req);
190}
191
192int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num)
193{
194 struct ex_chunk_dir excd;
195 int index = 16;
196 int useld = 0;
197
198 if (!ec->cid.cd)
199 return 0;
200
201 while(1) {
202 ecard_readbytes(&excd, ec, index, 8, useld);
203 index += 8;
204 if (c_id(&excd) == 0) {
205 if (!useld && ec->loader) {
206 useld = 1;
207 index = 0;
208 continue;
209 }
210 return 0;
211 }
212 if (c_id(&excd) == 0xf0) { /* link */
213 index = c_start(&excd);
214 continue;
215 }
216 if (c_id(&excd) == 0x80) { /* loader */
217 if (!ec->loader) {
218 ec->loader = kmalloc(c_len(&excd),
219 GFP_KERNEL);
220 if (ec->loader)
221 ecard_readbytes(ec->loader, ec,
222 (int)c_start(&excd),
223 c_len(&excd), useld);
224 else
225 return 0;
226 }
227 continue;
228 }
229 if (c_id(&excd) == id && num-- == 0)
230 break;
231 }
232
233 if (c_id(&excd) & 0x80) {
234 switch (c_id(&excd) & 0x70) {
235 case 0x70:
236 ecard_readbytes((unsigned char *)excd.d.string, ec,
237 (int)c_start(&excd), c_len(&excd),
238 useld);
239 break;
240 case 0x00:
241 break;
242 }
243 }
244 cd->start_offset = c_start(&excd);
245 memcpy(cd->d.string, excd.d.string, 256);
246 return 1;
247}
248
249/* ======================= Interrupt control ============================ */
250
251static void ecard_def_irq_enable(ecard_t *ec, int irqnr)
252{
253}
254
255static void ecard_def_irq_disable(ecard_t *ec, int irqnr)
256{
257}
258
259static int ecard_def_irq_pending(ecard_t *ec)
260{
261 return !ec->irqmask || ec->irqaddr[0] & ec->irqmask;
262}
263
264static void ecard_def_fiq_enable(ecard_t *ec, int fiqnr)
265{
266 panic("ecard_def_fiq_enable called - impossible");
267}
268
269static void ecard_def_fiq_disable(ecard_t *ec, int fiqnr)
270{
271 panic("ecard_def_fiq_disable called - impossible");
272}
273
274static int ecard_def_fiq_pending(ecard_t *ec)
275{
276 return !ec->fiqmask || ec->fiqaddr[0] & ec->fiqmask;
277}
278
279static expansioncard_ops_t ecard_default_ops = {
280 ecard_def_irq_enable,
281 ecard_def_irq_disable,
282 ecard_def_irq_pending,
283 ecard_def_fiq_enable,
284 ecard_def_fiq_disable,
285 ecard_def_fiq_pending
286};
287
288/*
289 * Enable and disable interrupts from expansion cards.
290 * (interrupts are disabled for these functions).
291 *
292 * They are not meant to be called directly, but via enable/disable_irq.
293 */
294static void ecard_irq_unmask(unsigned int irqnr)
295{
296 ecard_t *ec = slot_to_ecard(irqnr - 32);
297
298 if (ec) {
299 if (!ec->ops)
300 ec->ops = &ecard_default_ops;
301
302 if (ec->claimed && ec->ops->irqenable)
303 ec->ops->irqenable(ec, irqnr);
304 else
305 printk(KERN_ERR "ecard: rejecting request to "
306 "enable IRQs for %d\n", irqnr);
307 }
308}
309
310static void ecard_irq_mask(unsigned int irqnr)
311{
312 ecard_t *ec = slot_to_ecard(irqnr - 32);
313
314 if (ec) {
315 if (!ec->ops)
316 ec->ops = &ecard_default_ops;
317
318 if (ec->ops && ec->ops->irqdisable)
319 ec->ops->irqdisable(ec, irqnr);
320 }
321}
322
323static struct irqchip ecard_chip = {
324 .ack = ecard_irq_mask,
325 .mask = ecard_irq_mask,
326 .unmask = ecard_irq_unmask,
327};
328
329void ecard_enablefiq(unsigned int fiqnr)
330{
331 ecard_t *ec = slot_to_ecard(fiqnr);
332
333 if (ec) {
334 if (!ec->ops)
335 ec->ops = &ecard_default_ops;
336
337 if (ec->claimed && ec->ops->fiqenable)
338 ec->ops->fiqenable(ec, fiqnr);
339 else
340 printk(KERN_ERR "ecard: rejecting request to "
341 "enable FIQs for %d\n", fiqnr);
342 }
343}
344
345void ecard_disablefiq(unsigned int fiqnr)
346{
347 ecard_t *ec = slot_to_ecard(fiqnr);
348
349 if (ec) {
350 if (!ec->ops)
351 ec->ops = &ecard_default_ops;
352
353 if (ec->ops->fiqdisable)
354 ec->ops->fiqdisable(ec, fiqnr);
355 }
356}
357
358static void
359ecard_dump_irq_state(ecard_t *ec)
360{
361 printk(" %d: %sclaimed, ",
362 ec->slot_no,
363 ec->claimed ? "" : "not ");
364
365 if (ec->ops && ec->ops->irqpending &&
366 ec->ops != &ecard_default_ops)
367 printk("irq %spending\n",
368 ec->ops->irqpending(ec) ? "" : "not ");
369 else
370 printk("irqaddr %p, mask = %02X, status = %02X\n",
371 ec->irqaddr, ec->irqmask, *ec->irqaddr);
372}
373
374static void ecard_check_lockup(struct irqdesc *desc)
375{
376 static int last, lockup;
377 ecard_t *ec;
378
379 /*
380 * If the timer interrupt has not run since the last million
381 * unrecognised expansion card interrupts, then there is
382 * something seriously wrong. Disable the expansion card
383 * interrupts so at least we can continue.
384 *
385 * Maybe we ought to start a timer to re-enable them some time
386 * later?
387 */
388 if (last == jiffies) {
389 lockup += 1;
390 if (lockup > 1000000) {
391 printk(KERN_ERR "\nInterrupt lockup detected - "
392 "disabling all expansion card interrupts\n");
393
394 desc->chip->mask(IRQ_EXPANSIONCARD);
395
396 printk("Expansion card IRQ state:\n");
397
398 for (ec = cards; ec; ec = ec->next)
399 ecard_dump_irq_state(ec);
400 }
401 } else
402 lockup = 0;
403
404 /*
405 * If we did not recognise the source of this interrupt,
406 * warn the user, but don't flood the user with these messages.
407 */
408 if (!last || time_after(jiffies, (unsigned long)(last + 5*HZ))) {
409 last = jiffies;
410 printk(KERN_WARNING "Unrecognised interrupt from backplane\n");
411 }
412}
413
414static void
415ecard_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
416{
417 ecard_t *ec;
418 int called = 0;
419
420 desc->chip->mask(irq);
421 for (ec = cards; ec; ec = ec->next) {
422 int pending;
423
424 if (!ec->claimed || ec->irq == NO_IRQ)
425 continue;
426
427 if (ec->ops && ec->ops->irqpending)
428 pending = ec->ops->irqpending(ec);
429 else
430 pending = ecard_default_ops.irqpending(ec);
431
432 if (pending) {
433 struct irqdesc *d = irq_desc + ec->irq;
434 d->handle(ec->irq, d, regs);
435 called ++;
436 }
437 }
438 desc->chip->unmask(irq);
439
440 if (called == 0)
441 ecard_check_lockup(desc);
442}
443
444#define ecard_irqexp_handler NULL
445#define ecard_probeirqhw() (0)
446
447unsigned int ecard_address(ecard_t *ec, card_type_t type, card_speed_t speed)
448{
449 unsigned long address = 0;
450 int slot = ec->slot_no;
451
452 ectcr &= ~(1 << slot);
453
454 switch (type) {
455 case ECARD_MEMC:
456 address = IO_EC_MEMC_BASE + (slot << 12);
457 break;
458
459 case ECARD_IOC:
460 address = IO_EC_IOC_BASE + (slot << 12) + (speed << 17);
461 break;
462
463 default:
464 break;
465 }
466
467 return address;
468}
469
470static int ecard_prints(char *buffer, ecard_t *ec)
471{
472 char *start = buffer;
473
474 buffer += sprintf(buffer, " %d: ", ec->slot_no);
475
476 if (ec->cid.id == 0) {
477 struct in_chunk_dir incd;
478
479 buffer += sprintf(buffer, "[%04X:%04X] ",
480 ec->cid.manufacturer, ec->cid.product);
481
482 if (!ec->card_desc && ec->cid.cd &&
483 ecard_readchunk(&incd, ec, 0xf5, 0)) {
484 ec->card_desc = kmalloc(strlen(incd.d.string)+1, GFP_KERNEL);
485
486 if (ec->card_desc)
487 strcpy((char *)ec->card_desc, incd.d.string);
488 }
489
490 buffer += sprintf(buffer, "%s\n", ec->card_desc ? ec->card_desc : "*unknown*");
491 } else
492 buffer += sprintf(buffer, "Simple card %d\n", ec->cid.id);
493
494 return buffer - start;
495}
496
497static int get_ecard_dev_info(char *buf, char **start, off_t pos, int count)
498{
499 ecard_t *ec = cards;
500 off_t at = 0;
501 int len, cnt;
502
503 cnt = 0;
504 while (ec && count > cnt) {
505 len = ecard_prints(buf, ec);
506 at += len;
507 if (at >= pos) {
508 if (!*start) {
509 *start = buf + (pos - (at - len));
510 cnt = at - pos;
511 } else
512 cnt += len;
513 buf += len;
514 }
515 ec = ec->next;
516 }
517 return (count > cnt) ? cnt : count;
518}
519
520static struct proc_dir_entry *proc_bus_ecard_dir = NULL;
521
522static void ecard_proc_init(void)
523{
524 proc_bus_ecard_dir = proc_mkdir("ecard", proc_bus);
525 create_proc_info_entry("devices", 0, proc_bus_ecard_dir,
526 get_ecard_dev_info);
527}
528
529#define ec_set_resource(ec,nr,st,sz,flg) \
530 do { \
531 (ec)->resource[nr].name = ec->dev.bus_id; \
532 (ec)->resource[nr].start = st; \
533 (ec)->resource[nr].end = (st) + (sz) - 1; \
534 (ec)->resource[nr].flags = flg; \
535 } while (0)
536
537static void __init ecard_init_resources(struct expansion_card *ec)
538{
539 unsigned long base = PODSLOT_IOC0_BASE;
540 unsigned int slot = ec->slot_no;
541 int i;
542
543 ec_set_resource(ec, ECARD_RES_MEMC,
544 PODSLOT_MEMC_BASE + (slot << 14),
545 PODSLOT_MEMC_SIZE, IORESOURCE_MEM);
546
547 for (i = 0; i < ECARD_RES_IOCSYNC - ECARD_RES_IOCSLOW; i++) {
548 ec_set_resource(ec, i + ECARD_RES_IOCSLOW,
549 base + (slot << 14) + (i << 19),
550 PODSLOT_IOC_SIZE, IORESOURCE_MEM);
551 }
552
553 for (i = 0; i < ECARD_NUM_RESOURCES; i++) {
554 if (ec->resource[i].start &&
555 request_resource(&iomem_resource, &ec->resource[i])) {
556 printk(KERN_ERR "%s: resource(s) not available\n",
557 ec->dev.bus_id);
558 ec->resource[i].end -= ec->resource[i].start;
559 ec->resource[i].start = 0;
560 }
561 }
562}
563
564static ssize_t ecard_show_irq(struct device *dev, struct device_attribute *attr, char *buf)
565{
566 struct expansion_card *ec = ECARD_DEV(dev);
567 return sprintf(buf, "%u\n", ec->irq);
568}
569
570static ssize_t ecard_show_vendor(struct device *dev, struct device_attribute *attr, char *buf)
571{
572 struct expansion_card *ec = ECARD_DEV(dev);
573 return sprintf(buf, "%u\n", ec->cid.manufacturer);
574}
575
576static ssize_t ecard_show_device(struct device *dev, struct device_attribute *attr, char *buf)
577{
578 struct expansion_card *ec = ECARD_DEV(dev);
579 return sprintf(buf, "%u\n", ec->cid.product);
580}
581
582static ssize_t ecard_show_dma(struct device *dev, struct device_attribute *attr, char *buf)
583{
584 struct expansion_card *ec = ECARD_DEV(dev);
585 return sprintf(buf, "%u\n", ec->dma);
586}
587
588static ssize_t ecard_show_resources(struct device *dev, struct device_attribute *attr, char *buf)
589{
590 struct expansion_card *ec = ECARD_DEV(dev);
591 char *str = buf;
592 int i;
593
594 for (i = 0; i < ECARD_NUM_RESOURCES; i++)
595 str += sprintf(str, "%08lx %08lx %08lx\n",
596 ec->resource[i].start,
597 ec->resource[i].end,
598 ec->resource[i].flags);
599
600 return str - buf;
601}
602
603static DEVICE_ATTR(irq, S_IRUGO, ecard_show_irq, NULL);
604static DEVICE_ATTR(vendor, S_IRUGO, ecard_show_vendor, NULL);
605static DEVICE_ATTR(device, S_IRUGO, ecard_show_device, NULL);
606static DEVICE_ATTR(dma, S_IRUGO, ecard_show_dma, NULL);
607static DEVICE_ATTR(resource, S_IRUGO, ecard_show_resources, NULL);
608
609/*
610 * Probe for an expansion card.
611 *
612 * If bit 1 of the first byte of the card is set, then the
613 * card does not exist.
614 */
615static int __init
616ecard_probe(int slot, card_type_t type)
617{
618 ecard_t **ecp;
619 ecard_t *ec;
620 struct ex_ecid cid;
621 int i, rc = -ENOMEM;
622
623 ec = kzalloc(sizeof(ecard_t), GFP_KERNEL);
624 if (!ec)
625 goto nomem;
626
627 ec->slot_no = slot;
628 ec->type = type;
629 ec->irq = NO_IRQ;
630 ec->fiq = NO_IRQ;
631 ec->dma = NO_DMA;
632 ec->card_desc = NULL;
633 ec->ops = &ecard_default_ops;
634
635 rc = -ENODEV;
636 if ((ec->podaddr = ecard_address(ec, type, ECARD_SYNC)) == 0)
637 goto nodev;
638
639 cid.r_zero = 1;
640 ecard_readbytes(&cid, ec, 0, 16, 0);
641 if (cid.r_zero)
642 goto nodev;
643
644 ec->cid.id = cid.r_id;
645 ec->cid.cd = cid.r_cd;
646 ec->cid.is = cid.r_is;
647 ec->cid.w = cid.r_w;
648 ec->cid.manufacturer = ecard_getu16(cid.r_manu);
649 ec->cid.product = ecard_getu16(cid.r_prod);
650 ec->cid.country = cid.r_country;
651 ec->cid.irqmask = cid.r_irqmask;
652 ec->cid.irqoff = ecard_gets24(cid.r_irqoff);
653 ec->cid.fiqmask = cid.r_fiqmask;
654 ec->cid.fiqoff = ecard_gets24(cid.r_fiqoff);
655 ec->fiqaddr =
656 ec->irqaddr = (unsigned char *)ioaddr(ec->podaddr);
657
658 if (ec->cid.is) {
659 ec->irqmask = ec->cid.irqmask;
660 ec->irqaddr += ec->cid.irqoff;
661 ec->fiqmask = ec->cid.fiqmask;
662 ec->fiqaddr += ec->cid.fiqoff;
663 } else {
664 ec->irqmask = 1;
665 ec->fiqmask = 4;
666 }
667
668 for (i = 0; i < ARRAY_SIZE(blacklist); i++)
669 if (blacklist[i].manufacturer == ec->cid.manufacturer &&
670 blacklist[i].product == ec->cid.product) {
671 ec->card_desc = blacklist[i].type;
672 break;
673 }
674
675 snprintf(ec->dev.bus_id, sizeof(ec->dev.bus_id), "ecard%d", slot);
676 ec->dev.parent = NULL;
677 ec->dev.bus = &ecard_bus_type;
678 ec->dev.dma_mask = &ec->dma_mask;
679 ec->dma_mask = (u64)0xffffffff;
680
681 ecard_init_resources(ec);
682
683 /*
684 * hook the interrupt handlers
685 */
686 ec->irq = 32 + slot;
687 set_irq_chip(ec->irq, &ecard_chip);
688 set_irq_handler(ec->irq, do_level_IRQ);
689 set_irq_flags(ec->irq, IRQF_VALID);
690
691 for (ecp = &cards; *ecp; ecp = &(*ecp)->next);
692
693 *ecp = ec;
694 slot_to_expcard[slot] = ec;
695
696 device_register(&ec->dev);
697 device_create_file(&ec->dev, &dev_attr_dma);
698 device_create_file(&ec->dev, &dev_attr_irq);
699 device_create_file(&ec->dev, &dev_attr_resource);
700 device_create_file(&ec->dev, &dev_attr_vendor);
701 device_create_file(&ec->dev, &dev_attr_device);
702
703 return 0;
704
705nodev:
706 kfree(ec);
707nomem:
708 return rc;
709}
710
711/*
712 * Initialise the expansion card system.
713 * Locate all hardware - interrupt management and
714 * actual cards.
715 */
716static int __init ecard_init(void)
717{
718 int slot, irqhw;
719
720 printk("Probing expansion cards\n");
721
722 for (slot = 0; slot < MAX_ECARDS; slot ++) {
723 ecard_probe(slot, ECARD_IOC);
724 }
725
726 irqhw = ecard_probeirqhw();
727
728 set_irq_chained_handler(IRQ_EXPANSIONCARD,
729 irqhw ? ecard_irqexp_handler : ecard_irq_handler);
730
731 ecard_proc_init();
732
733 return 0;
734}
735
736subsys_initcall(ecard_init);
737
738/*
739 * ECARD "bus"
740 */
741static const struct ecard_id *
742ecard_match_device(const struct ecard_id *ids, struct expansion_card *ec)
743{
744 int i;
745
746 for (i = 0; ids[i].manufacturer != 65535; i++)
747 if (ec->cid.manufacturer == ids[i].manufacturer &&
748 ec->cid.product == ids[i].product)
749 return ids + i;
750
751 return NULL;
752}
753
754static int ecard_drv_probe(struct device *dev)
755{
756 struct expansion_card *ec = ECARD_DEV(dev);
757 struct ecard_driver *drv = ECARD_DRV(dev->driver);
758 const struct ecard_id *id;
759 int ret;
760
761 id = ecard_match_device(drv->id_table, ec);
762
763 ecard_claim(ec);
764 ret = drv->probe(ec, id);
765 if (ret)
766 ecard_release(ec);
767 return ret;
768}
769
770static int ecard_drv_remove(struct device *dev)
771{
772 struct expansion_card *ec = ECARD_DEV(dev);
773 struct ecard_driver *drv = ECARD_DRV(dev->driver);
774
775 drv->remove(ec);
776 ecard_release(ec);
777
778 return 0;
779}
780
781/*
782 * Before rebooting, we must make sure that the expansion card is in a
783 * sensible state, so it can be re-detected. This means that the first
784 * page of the ROM must be visible. We call the expansion cards reset
785 * handler, if any.
786 */
787static void ecard_drv_shutdown(struct device *dev)
788{
789 struct expansion_card *ec = ECARD_DEV(dev);
790 struct ecard_driver *drv = ECARD_DRV(dev->driver);
791 struct ecard_request req;
792
793 if (drv->shutdown)
794 drv->shutdown(ec);
795 ecard_release(ec);
796 req.req = req_reset;
797 req.ec = ec;
798 ecard_call(&req);
799}
800
801int ecard_register_driver(struct ecard_driver *drv)
802{
803 drv->drv.bus = &ecard_bus_type;
804 drv->drv.probe = ecard_drv_probe;
805 drv->drv.remove = ecard_drv_remove;
806 drv->drv.shutdown = ecard_drv_shutdown;
807
808 return driver_register(&drv->drv);
809}
810
811void ecard_remove_driver(struct ecard_driver *drv)
812{
813 driver_unregister(&drv->drv);
814}
815
816static int ecard_match(struct device *_dev, struct device_driver *_drv)
817{
818 struct expansion_card *ec = ECARD_DEV(_dev);
819 struct ecard_driver *drv = ECARD_DRV(_drv);
820 int ret;
821
822 if (drv->id_table) {
823 ret = ecard_match_device(drv->id_table, ec) != NULL;
824 } else {
825 ret = ec->cid.id == drv->id;
826 }
827
828 return ret;
829}
830
831struct bus_type ecard_bus_type = {
832 .name = "ecard",
833 .match = ecard_match,
834};
835
836static int ecard_bus_init(void)
837{
838 return bus_register(&ecard_bus_type);
839}
840
841postcore_initcall(ecard_bus_init);
842
843EXPORT_SYMBOL(ecard_readchunk);
844EXPORT_SYMBOL(ecard_address);
845EXPORT_SYMBOL(ecard_register_driver);
846EXPORT_SYMBOL(ecard_remove_driver);
847EXPORT_SYMBOL(ecard_bus_type);
diff --git a/arch/arm26/kernel/entry.S b/arch/arm26/kernel/entry.S
deleted file mode 100644
index 91496cc687b1..000000000000
--- a/arch/arm26/kernel/entry.S
+++ /dev/null
@@ -1,951 +0,0 @@
1/* arch/arm26/kernel/entry.S
2 *
3 * Assembled from chunks of code in arch/arm
4 *
5 * Copyright (C) 2003 Ian Molton
6 * Based on the work of RMK.
7 *
8 */
9
10#include <linux/linkage.h>
11
12#include <asm/assembler.h>
13#include <asm/asm-offsets.h>
14#include <asm/errno.h>
15#include <asm/hardware.h>
16#include <asm/sysirq.h>
17#include <asm/thread_info.h>
18#include <asm/page.h>
19#include <asm/ptrace.h>
20
21 .macro zero_fp
22#ifndef CONFIG_NO_FRAME_POINTER
23 mov fp, #0
24#endif
25 .endm
26
27 .text
28
29@ Bad Abort numbers
30@ -----------------
31@
32#define BAD_PREFETCH 0
33#define BAD_DATA 1
34#define BAD_ADDREXCPTN 2
35#define BAD_IRQ 3
36#define BAD_UNDEFINSTR 4
37
38@ OS version number used in SWIs
39@ RISC OS is 0
40@ RISC iX is 8
41@
42#define OS_NUMBER 9
43#define ARMSWI_OFFSET 0x000f0000
44
45@
46@ Stack format (ensured by USER_* and SVC_*)
47@ PSR and PC are comined on arm26
48@
49
50#define S_OFF 8
51
52#define S_OLD_R0 64
53#define S_PC 60
54#define S_LR 56
55#define S_SP 52
56#define S_IP 48
57#define S_FP 44
58#define S_R10 40
59#define S_R9 36
60#define S_R8 32
61#define S_R7 28
62#define S_R6 24
63#define S_R5 20
64#define S_R4 16
65#define S_R3 12
66#define S_R2 8
67#define S_R1 4
68#define S_R0 0
69
70 .macro save_user_regs
71 str r0, [sp, #-4]! @ Store SVC r0
72 str lr, [sp, #-4]! @ Store user mode PC
73 sub sp, sp, #15*4
74 stmia sp, {r0 - lr}^ @ Store the other user-mode regs
75 mov r0, r0
76 .endm
77
78 .macro slow_restore_user_regs
79 ldmia sp, {r0 - lr}^ @ restore the user regs not including PC
80 mov r0, r0
81 ldr lr, [sp, #15*4] @ get user PC
82 add sp, sp, #15*4+8 @ free stack
83 movs pc, lr @ return
84 .endm
85
86 .macro fast_restore_user_regs
87 add sp, sp, #S_OFF
88 ldmib sp, {r1 - lr}^
89 mov r0, r0
90 ldr lr, [sp, #15*4]
91 add sp, sp, #15*4+8
92 movs pc, lr
93 .endm
94
95 .macro save_svc_regs
96 str sp, [sp, #-16]!
97 str lr, [sp, #8]
98 str lr, [sp, #4]
99 stmfd sp!, {r0 - r12}
100 mov r0, #-1
101 str r0, [sp, #S_OLD_R0]
102 zero_fp
103 .endm
104
105 .macro save_svc_regs_irq
106 str sp, [sp, #-16]!
107 str lr, [sp, #4]
108 ldr lr, .LCirq
109 ldr lr, [lr]
110 str lr, [sp, #8]
111 stmfd sp!, {r0 - r12}
112 mov r0, #-1
113 str r0, [sp, #S_OLD_R0]
114 zero_fp
115 .endm
116
117 .macro restore_svc_regs
118 ldmfd sp, {r0 - pc}^
119 .endm
120
121 .macro mask_pc, rd, rm
122 bic \rd, \rm, #PCMASK
123 .endm
124
125 .macro disable_irqs, temp
126 mov \temp, pc
127 orr \temp, \temp, #PSR_I_BIT
128 teqp \temp, #0
129 .endm
130
131 .macro enable_irqs, temp
132 mov \temp, pc
133 and \temp, \temp, #~PSR_I_BIT
134 teqp \temp, #0
135 .endm
136
137 .macro initialise_traps_extra
138 .endm
139
140 .macro get_thread_info, rd
141 mov \rd, sp, lsr #13
142 mov \rd, \rd, lsl #13
143 .endm
144
145/*
146 * These are the registers used in the syscall handler, and allow us to
147 * have in theory up to 7 arguments to a function - r0 to r6.
148 *
149 * Note that tbl == why is intentional.
150 *
151 * We must set at least "tsk" and "why" when calling ret_with_reschedule.
152 */
153scno .req r7 @ syscall number
154tbl .req r8 @ syscall table pointer
155why .req r8 @ Linux syscall (!= 0)
156tsk .req r9 @ current thread_info
157
158/*
159 * Get the system call number.
160 */
161 .macro get_scno
162 mask_pc lr, lr
163 ldr scno, [lr, #-4] @ get SWI instruction
164 .endm
165/*
166 * -----------------------------------------------------------------------
167 */
168
169/*
170 * We rely on the fact that R0 is at the bottom of the stack (due to
171 * slow/fast restore user regs).
172 */
173#if S_R0 != 0
174#error "Please fix"
175#endif
176
177/*
178 * This is the fast syscall return path. We do as little as
179 * possible here, and this includes saving r0 back into the SVC
180 * stack.
181 */
182ret_fast_syscall:
183 disable_irqs r1 @ disable interrupts
184 ldr r1, [tsk, #TI_FLAGS]
185 tst r1, #_TIF_WORK_MASK
186 bne fast_work_pending
187 fast_restore_user_regs
188
189/*
190 * Ok, we need to do extra processing, enter the slow path.
191 */
192fast_work_pending:
193 str r0, [sp, #S_R0+S_OFF]! @ returned r0
194work_pending:
195 tst r1, #_TIF_NEED_RESCHED
196 bne work_resched
197 tst r1, #_TIF_NOTIFY_RESUME | _TIF_SIGPENDING
198 beq no_work_pending
199 mov r0, sp @ 'regs'
200 mov r2, why @ 'syscall'
201 bl do_notify_resume
202 disable_irqs r1 @ disable interrupts
203 b no_work_pending
204
205work_resched:
206 bl schedule
207/*
208 * "slow" syscall return path. "why" tells us if this was a real syscall.
209 */
210ENTRY(ret_to_user)
211ret_slow_syscall:
212 disable_irqs r1 @ disable interrupts
213 ldr r1, [tsk, #TI_FLAGS]
214 tst r1, #_TIF_WORK_MASK
215 bne work_pending
216no_work_pending:
217 slow_restore_user_regs
218
219/*
220 * This is how we return from a fork.
221 */
222ENTRY(ret_from_fork)
223 bl schedule_tail
224 get_thread_info tsk
225 ldr r1, [tsk, #TI_FLAGS] @ check for syscall tracing
226 mov why, #1
227 tst r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
228 beq ret_slow_syscall
229 mov r1, sp
230 mov r0, #1 @ trace exit [IP = 1]
231 bl syscall_trace
232 b ret_slow_syscall
233
234// FIXME - is this strictly necessary?
235#include "calls.S"
236
237/*=============================================================================
238 * SWI handler
239 *-----------------------------------------------------------------------------
240 */
241
242 .align 5
243ENTRY(vector_swi)
244 save_user_regs
245 zero_fp
246 get_scno
247
248 enable_irqs ip
249
250 str r4, [sp, #-S_OFF]! @ push fifth arg
251
252 get_thread_info tsk
253 ldr ip, [tsk, #TI_FLAGS] @ check for syscall tracing
254 bic scno, scno, #0xff000000 @ mask off SWI op-code
255 eor scno, scno, #OS_NUMBER << 20 @ check OS number
256 adr tbl, sys_call_table @ load syscall table pointer
257 tst ip, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
258 bne __sys_trace
259
260 adral lr, ret_fast_syscall @ set return address
261 orral lr, lr, #PSR_I_BIT | MODE_SVC26 @ Force SVC mode on return
262 cmp scno, #NR_syscalls @ check upper syscall limit
263 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
264
265 add r1, sp, #S_OFF
2662: mov why, #0 @ no longer a real syscall
267 cmp scno, #ARMSWI_OFFSET
268 eor r0, scno, #OS_NUMBER << 20 @ put OS number back
269 bcs arm_syscall
270 b sys_ni_syscall @ not private func
271
272 /*
273 * This is the really slow path. We're going to be doing
274 * context switches, and waiting for our parent to respond.
275 */
276__sys_trace:
277 add r1, sp, #S_OFF
278 mov r0, #0 @ trace entry [IP = 0]
279 bl syscall_trace
280
281 adral lr, __sys_trace_return @ set return address
282 orral lr, lr, #PSR_I_BIT | MODE_SVC26 @ Force SVC mode on return
283 add r1, sp, #S_R0 + S_OFF @ pointer to regs
284 cmp scno, #NR_syscalls @ check upper syscall limit
285 ldmccia r1, {r0 - r3} @ have to reload r0 - r3
286 ldrcc pc, [tbl, scno, lsl #2] @ call sys_* routine
287 b 2b
288
289__sys_trace_return:
290 str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
291 mov r1, sp
292 mov r0, #1 @ trace exit [IP = 1]
293 bl syscall_trace
294 b ret_slow_syscall
295
296 .align 5
297
298 .type sys_call_table, #object
299ENTRY(sys_call_table)
300#include "calls.S"
301
302/*============================================================================
303 * Special system call wrappers
304 */
305@ r0 = syscall number
306@ r5 = syscall table
307 .type sys_syscall, #function
308sys_syscall:
309 eor scno, r0, #OS_NUMBER << 20
310 cmp scno, #NR_syscalls @ check range
311 stmleia sp, {r5, r6} @ shuffle args
312 movle r0, r1
313 movle r1, r2
314 movle r2, r3
315 movle r3, r4
316 ldrle pc, [tbl, scno, lsl #2]
317 b sys_ni_syscall
318
319sys_fork_wrapper:
320 add r0, sp, #S_OFF
321 b sys_fork
322
323sys_vfork_wrapper:
324 add r0, sp, #S_OFF
325 b sys_vfork
326
327sys_execve_wrapper:
328 add r3, sp, #S_OFF
329 b sys_execve
330
331sys_clone_wapper:
332 add r2, sp, #S_OFF
333 b sys_clone
334
335sys_sigsuspend_wrapper:
336 add r3, sp, #S_OFF
337 b sys_sigsuspend
338
339sys_rt_sigsuspend_wrapper:
340 add r2, sp, #S_OFF
341 b sys_rt_sigsuspend
342
343sys_sigreturn_wrapper:
344 add r0, sp, #S_OFF
345 b sys_sigreturn
346
347sys_rt_sigreturn_wrapper:
348 add r0, sp, #S_OFF
349 b sys_rt_sigreturn
350
351sys_sigaltstack_wrapper:
352 ldr r2, [sp, #S_OFF + S_SP]
353 b do_sigaltstack
354
355/*
356 * Note: off_4k (r5) is always units of 4K. If we can't do the requested
357 * offset, we return EINVAL. FIXME - this lost some stuff from arm32 to
358 * ifdefs. check it out.
359 */
360sys_mmap2:
361 tst r5, #((1 << (PAGE_SHIFT - 12)) - 1)
362 moveq r5, r5, lsr #PAGE_SHIFT - 12
363 streq r5, [sp, #4]
364 beq do_mmap2
365 mov r0, #-EINVAL
366 RETINSTR(mov,pc, lr)
367
368/*
369 * Design issues:
370 * - We have several modes that each vector can be called from,
371 * each with its own set of registers. On entry to any vector,
372 * we *must* save the registers used in *that* mode.
373 *
374 * - This code must be as fast as possible.
375 *
376 * There are a few restrictions on the vectors:
377 * - the SWI vector cannot be called from *any* non-user mode
378 *
379 * - the FP emulator is *never* called from *any* non-user mode undefined
380 * instruction.
381 *
382 */
383
384 .text
385
386 .macro handle_irq
3871: mov r4, #IOC_BASE
388 ldrb r6, [r4, #0x24] @ get high priority first
389 adr r5, irq_prio_h
390 teq r6, #0
391 ldreqb r6, [r4, #0x14] @ get low priority
392 adreq r5, irq_prio_l
393
394 teq r6, #0 @ If an IRQ happened...
395 ldrneb r0, [r5, r6] @ get IRQ number
396 movne r1, sp @ get struct pt_regs
397 adrne lr, 1b @ Set return address to 1b
398 orrne lr, lr, #PSR_I_BIT | MODE_SVC26 @ (and force SVC mode)
399 bne asm_do_IRQ @ process IRQ (if asserted)
400 .endm
401
402
403/*
404 * Interrupt table (incorporates priority)
405 */
406 .macro irq_prio_table
407irq_prio_l: .byte 0, 0, 1, 0, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
408 .byte 4, 0, 1, 0, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3
409 .byte 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
410 .byte 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
411 .byte 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3
412 .byte 6, 6, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3
413 .byte 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
414 .byte 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
415 .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
416 .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
417 .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
418 .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
419 .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
420 .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
421 .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
422 .byte 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
423irq_prio_h: .byte 0, 8, 9, 8,10,10,10,10,11,11,11,11,10,10,10,10
424 .byte 12, 8, 9, 8,10,10,10,10,11,11,11,11,10,10,10,10
425 .byte 13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
426 .byte 13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
427 .byte 14,14,14,14,10,10,10,10,11,11,11,11,10,10,10,10
428 .byte 14,14,14,14,10,10,10,10,11,11,11,11,10,10,10,10
429 .byte 13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
430 .byte 13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
431 .byte 15,15,15,15,10,10,10,10,11,11,11,11,10,10,10,10
432 .byte 15,15,15,15,10,10,10,10,11,11,11,11,10,10,10,10
433 .byte 13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
434 .byte 13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
435 .byte 15,15,15,15,10,10,10,10,11,11,11,11,10,10,10,10
436 .byte 15,15,15,15,10,10,10,10,11,11,11,11,10,10,10,10
437 .byte 13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
438 .byte 13,13,13,13,10,10,10,10,11,11,11,11,10,10,10,10
439 .endm
440
441#if 1
442/*
443 * Uncomment these if you wish to get more debugging into about data aborts.
444 * FIXME - I bet we can find a way to encode these and keep performance.
445 */
446#define FAULT_CODE_LDRSTRPOST 0x80
447#define FAULT_CODE_LDRSTRPRE 0x40
448#define FAULT_CODE_LDRSTRREG 0x20
449#define FAULT_CODE_LDMSTM 0x10
450#define FAULT_CODE_LDCSTC 0x08
451#endif
452#define FAULT_CODE_PREFETCH 0x04
453#define FAULT_CODE_WRITE 0x02
454#define FAULT_CODE_FORCECOW 0x01
455
456/*=============================================================================
457 * Undefined FIQs
458 *-----------------------------------------------------------------------------
459 */
460_unexp_fiq: ldr sp, .LCfiq
461 mov r12, #IOC_BASE
462 strb r12, [r12, #0x38] @ Disable FIQ register
463 teqp pc, #PSR_I_BIT | PSR_F_BIT | MODE_SVC26
464 mov r0, r0
465 stmfd sp!, {r0 - r3, ip, lr}
466 adr r0, Lfiqmsg
467 bl printk
468 ldmfd sp!, {r0 - r3, ip, lr}
469 teqp pc, #PSR_I_BIT | PSR_F_BIT | MODE_FIQ26
470 mov r0, r0
471 movs pc, lr
472
473Lfiqmsg: .ascii "*** Unexpected FIQ\n\0"
474 .align
475
476.LCfiq: .word __temp_fiq
477.LCirq: .word __temp_irq
478
479/*=============================================================================
480 * Undefined instruction handler
481 *-----------------------------------------------------------------------------
482 * Handles floating point instructions
483 */
484vector_undefinstr:
485 tst lr, #MODE_SVC26 @ did we come from a non-user mode?
486 bne __und_svc @ yes - deal with it.
487/* Otherwise, fall through for the user-space (common) case. */
488 save_user_regs
489 zero_fp @ zero frame pointer
490 teqp pc, #PSR_I_BIT | MODE_SVC26 @ disable IRQs
491.Lbug_undef:
492 ldr r4, .LC2
493 ldr pc, [r4] @ Call FP module entry point
494/* FIXME - should we trap for a null pointer here? */
495
496/* The SVC mode case */
497__und_svc: save_svc_regs @ Non-user mode
498 mask_pc r0, lr
499 and r2, lr, #3
500 sub r0, r0, #4
501 mov r1, sp
502 bl do_undefinstr
503 restore_svc_regs
504
505/* We get here if the FP emulator doesnt handle the undef instr.
506 * If the insn WAS handled, the emulator jumps to ret_from_exception by itself/
507 */
508 .globl fpundefinstr
509fpundefinstr:
510 mov r0, lr
511 mov r1, sp
512 teqp pc, #MODE_SVC26
513 bl do_undefinstr
514 b ret_from_exception @ Normal FP exit
515
516#if defined CONFIG_FPE_NWFPE || defined CONFIG_FPE_FASTFPE
517 /* The FPE is always present */
518 .equ fpe_not_present, 0
519#else
520/* We get here if an undefined instruction happens and the floating
521 * point emulator is not present. If the offending instruction was
522 * a WFS, we just perform a normal return as if we had emulated the
523 * operation. This is a hack to allow some basic userland binaries
524 * to run so that the emulator module proper can be loaded. --philb
525 * FIXME - probably a broken useless hack...
526 */
527fpe_not_present:
528 adr r10, wfs_mask_data
529 ldmia r10, {r4, r5, r6, r7, r8}
530 ldr r10, [sp, #S_PC] @ Load PC
531 sub r10, r10, #4
532 mask_pc r10, r10
533 ldrt r10, [r10] @ get instruction
534 and r5, r10, r5
535 teq r5, r4 @ Is it WFS?
536 beq ret_from_exception
537 and r5, r10, r8
538 teq r5, r6 @ Is it LDF/STF on sp or fp?
539 teqne r5, r7
540 bne fpundefinstr
541 tst r10, #0x00200000 @ Does it have WB
542 beq ret_from_exception
543 and r4, r10, #255 @ get offset
544 and r6, r10, #0x000f0000
545 tst r10, #0x00800000 @ +/-
546 ldr r5, [sp, r6, lsr #14] @ Load reg
547 rsbeq r4, r4, #0
548 add r5, r5, r4, lsl #2
549 str r5, [sp, r6, lsr #14] @ Save reg
550 b ret_from_exception
551
552wfs_mask_data: .word 0x0e200110 @ WFS/RFS
553 .word 0x0fef0fff
554 .word 0x0d0d0100 @ LDF [sp]/STF [sp]
555 .word 0x0d0b0100 @ LDF [fp]/STF [fp]
556 .word 0x0f0f0f00
557#endif
558
559.LC2: .word fp_enter
560
561/*=============================================================================
562 * Prefetch abort handler
563 *-----------------------------------------------------------------------------
564 */
565#define DEBUG_UNDEF
566/* remember: lr = USR pc */
567vector_prefetch:
568 sub lr, lr, #4
569 tst lr, #MODE_SVC26
570 bne __pabt_invalid
571 save_user_regs
572 teqp pc, #MODE_SVC26 @ Enable IRQs...
573 mask_pc r0, lr @ Address of abort
574 mov r1, sp @ Tasks registers
575 bl do_PrefetchAbort
576 teq r0, #0 @ If non-zero, we believe this abort..
577 bne ret_from_exception
578#ifdef DEBUG_UNDEF
579 adr r0, t
580 bl printk
581#endif
582 ldr lr, [sp,#S_PC] @ FIXME program to test this on. I think its
583 b .Lbug_undef @ broken at the moment though!)
584
585__pabt_invalid: save_svc_regs
586 mov r0, sp @ Prefetch aborts are definitely *not*
587 mov r1, #BAD_PREFETCH @ allowed in non-user modes. We cant
588 and r2, lr, #3 @ recover from this problem.
589 b bad_mode
590
591#ifdef DEBUG_UNDEF
592t: .ascii "*** undef ***\r\n\0"
593 .align
594#endif
595
596/*=============================================================================
597 * Address exception handler
598 *-----------------------------------------------------------------------------
599 * These aren't too critical.
600 * (they're not supposed to happen).
601 * In order to debug the reason for address exceptions in non-user modes,
602 * we have to obtain all the registers so that we can see what's going on.
603 */
604
605vector_addrexcptn:
606 sub lr, lr, #8
607 tst lr, #3
608 bne Laddrexcptn_not_user
609 save_user_regs
610 teq pc, #MODE_SVC26
611 mask_pc r0, lr @ Point to instruction
612 mov r1, sp @ Point to registers
613 mov r2, #0x400
614 mov lr, pc
615 bl do_excpt
616 b ret_from_exception
617
618Laddrexcptn_not_user:
619 save_svc_regs
620 and r2, lr, #3
621 teq r2, #3
622 bne Laddrexcptn_illegal_mode
623 teqp pc, #MODE_SVC26
624 mask_pc r0, lr
625 mov r1, sp
626 orr r2, r2, #0x400
627 bl do_excpt
628 ldmia sp, {r0 - lr} @ I cant remember the reason I changed this...
629 add sp, sp, #15*4
630 movs pc, lr
631
632Laddrexcptn_illegal_mode:
633 mov r0, sp
634 str lr, [sp, #-4]!
635 orr r1, r2, #PSR_I_BIT | PSR_F_BIT
636 teqp r1, #0 @ change into mode (wont be user mode)
637 mov r0, r0
638 mov r1, r8 @ Any register from r8 - r14 can be banked
639 mov r2, r9
640 mov r3, r10
641 mov r4, r11
642 mov r5, r12
643 mov r6, r13
644 mov r7, r14
645 teqp pc, #PSR_F_BIT | MODE_SVC26 @ back to svc
646 mov r0, r0
647 stmfd sp!, {r1-r7}
648 ldmia r0, {r0-r7}
649 stmfd sp!, {r0-r7}
650 mov r0, sp
651 mov r1, #BAD_ADDREXCPTN
652 b bad_mode
653
654/*=============================================================================
655 * Interrupt (IRQ) handler
656 *-----------------------------------------------------------------------------
657 * Note: if the IRQ was taken whilst in user mode, then *no* kernel routine
658 * is running, so do not have to save svc lr.
659 *
660 * Entered in IRQ mode.
661 */
662
663vector_IRQ: ldr sp, .LCirq @ Setup some temporary stack
664 sub lr, lr, #4
665 str lr, [sp] @ push return address
666
667 tst lr, #3
668 bne __irq_non_usr
669
670__irq_usr: teqp pc, #PSR_I_BIT | MODE_SVC26 @ Enter SVC mode
671 mov r0, r0
672
673 ldr lr, .LCirq
674 ldr lr, [lr] @ Restore lr for jump back to USR
675
676 save_user_regs
677
678 handle_irq
679
680 mov why, #0
681 get_thread_info tsk
682 b ret_to_user
683
684@ Place the IRQ priority table here so that the handle_irq macros above
685@ and below here can access it.
686
687 irq_prio_table
688
689__irq_non_usr: teqp pc, #PSR_I_BIT | MODE_SVC26 @ Enter SVC mode
690 mov r0, r0
691
692 save_svc_regs_irq
693
694 and r2, lr, #3
695 teq r2, #3
696 bne __irq_invalid @ IRQ not from SVC mode
697
698 handle_irq
699
700 restore_svc_regs
701
702__irq_invalid: mov r0, sp
703 mov r1, #BAD_IRQ
704 b bad_mode
705
706/*=============================================================================
707 * Data abort handler code
708 *-----------------------------------------------------------------------------
709 *
710 * This handles both exceptions from user and SVC modes, computes the address
711 * range of the problem, and does any correction that is required. It then
712 * calls the kernel data abort routine.
713 *
714 * This is where I wish that the ARM would tell you which address aborted.
715 */
716
717vector_data: sub lr, lr, #8 @ Correct lr
718 tst lr, #3
719 bne Ldata_not_user
720 save_user_regs
721 teqp pc, #MODE_SVC26
722 mask_pc r0, lr
723 bl Ldata_do
724 b ret_from_exception
725
726Ldata_not_user:
727 save_svc_regs
728 and r2, lr, #3
729 teq r2, #3
730 bne Ldata_illegal_mode
731 tst lr, #PSR_I_BIT
732 teqeqp pc, #MODE_SVC26
733 mask_pc r0, lr
734 bl Ldata_do
735 restore_svc_regs
736
737Ldata_illegal_mode:
738 mov r0, sp
739 mov r1, #BAD_DATA
740 b bad_mode
741
742Ldata_do: mov r3, sp
743 ldr r4, [r0] @ Get instruction
744 mov r2, #0
745 tst r4, #1 << 20 @ Check to see if it is a write instruction
746 orreq r2, r2, #FAULT_CODE_WRITE @ Indicate write instruction
747 mov r1, r4, lsr #22 @ Now branch to the relevent processing routine
748 and r1, r1, #15 << 2
749 add pc, pc, r1
750 movs pc, lr
751 b Ldata_unknown
752 b Ldata_unknown
753 b Ldata_unknown
754 b Ldata_unknown
755 b Ldata_ldrstr_post @ ldr rd, [rn], #m
756 b Ldata_ldrstr_numindex @ ldr rd, [rn, #m] @ RegVal
757 b Ldata_ldrstr_post @ ldr rd, [rn], rm
758 b Ldata_ldrstr_regindex @ ldr rd, [rn, rm]
759 b Ldata_ldmstm @ ldm*a rn, <rlist>
760 b Ldata_ldmstm @ ldm*b rn, <rlist>
761 b Ldata_unknown
762 b Ldata_unknown
763 b Ldata_ldrstr_post @ ldc rd, [rn], #m @ Same as ldr rd, [rn], #m
764 b Ldata_ldcstc_pre @ ldc rd, [rn, #m]
765 b Ldata_unknown
766Ldata_unknown: @ Part of jumptable
767 mov r0, r1
768 mov r1, r4
769 mov r2, r3
770 b baddataabort
771
772Ldata_ldrstr_post:
773 mov r0, r4, lsr #14 @ Get Rn
774 and r0, r0, #15 << 2 @ Mask out reg.
775 teq r0, #15 << 2
776 ldr r0, [r3, r0] @ Get register
777 biceq r0, r0, #PCMASK
778 mov r1, r0
779#ifdef FAULT_CODE_LDRSTRPOST
780 orr r2, r2, #FAULT_CODE_LDRSTRPOST
781#endif
782 b do_DataAbort
783
784Ldata_ldrstr_numindex:
785 mov r0, r4, lsr #14 @ Get Rn
786 and r0, r0, #15 << 2 @ Mask out reg.
787 teq r0, #15 << 2
788 ldr r0, [r3, r0] @ Get register
789 mov r1, r4, lsl #20
790 biceq r0, r0, #PCMASK
791 tst r4, #1 << 23
792 addne r0, r0, r1, lsr #20
793 subeq r0, r0, r1, lsr #20
794 mov r1, r0
795#ifdef FAULT_CODE_LDRSTRPRE
796 orr r2, r2, #FAULT_CODE_LDRSTRPRE
797#endif
798 b do_DataAbort
799
800Ldata_ldrstr_regindex:
801 mov r0, r4, lsr #14 @ Get Rn
802 and r0, r0, #15 << 2 @ Mask out reg.
803 teq r0, #15 << 2
804 ldr r0, [r3, r0] @ Get register
805 and r7, r4, #15
806 biceq r0, r0, #PCMASK
807 teq r7, #15 @ Check for PC
808 ldr r7, [r3, r7, lsl #2] @ Get Rm
809 and r8, r4, #0x60 @ Get shift types
810 biceq r7, r7, #PCMASK
811 mov r9, r4, lsr #7 @ Get shift amount
812 and r9, r9, #31
813 teq r8, #0
814 moveq r7, r7, lsl r9
815 teq r8, #0x20 @ LSR shift
816 moveq r7, r7, lsr r9
817 teq r8, #0x40 @ ASR shift
818 moveq r7, r7, asr r9
819 teq r8, #0x60 @ ROR shift
820 moveq r7, r7, ror r9
821 tst r4, #1 << 23
822 addne r0, r0, r7
823 subeq r0, r0, r7 @ Apply correction
824 mov r1, r0
825#ifdef FAULT_CODE_LDRSTRREG
826 orr r2, r2, #FAULT_CODE_LDRSTRREG
827#endif
828 b do_DataAbort
829
830Ldata_ldmstm:
831 mov r7, #0x11
832 orr r7, r7, r7, lsl #8
833 and r0, r4, r7
834 and r1, r4, r7, lsl #1
835 add r0, r0, r1, lsr #1
836 and r1, r4, r7, lsl #2
837 add r0, r0, r1, lsr #2
838 and r1, r4, r7, lsl #3
839 add r0, r0, r1, lsr #3
840 add r0, r0, r0, lsr #8
841 add r0, r0, r0, lsr #4
842 and r7, r0, #15 @ r7 = no. of registers to transfer.
843 mov r5, r4, lsr #14 @ Get Rn
844 and r5, r5, #15 << 2
845 ldr r0, [r3, r5] @ Get reg
846 eor r6, r4, r4, lsl #2
847 tst r6, #1 << 23 @ Check inc/dec ^ writeback
848 rsbeq r7, r7, #0
849 add r7, r0, r7, lsl #2 @ Do correction (signed)
850 subne r1, r7, #1
851 subeq r1, r0, #1
852 moveq r0, r7
853 tst r4, #1 << 21 @ Check writeback
854 strne r7, [r3, r5]
855 eor r6, r4, r4, lsl #1
856 tst r6, #1 << 24 @ Check Pre/Post ^ inc/dec
857 addeq r0, r0, #4
858 addeq r1, r1, #4
859 teq r5, #15*4 @ CHECK FOR PC
860 biceq r1, r1, #PCMASK
861 biceq r0, r0, #PCMASK
862#ifdef FAULT_CODE_LDMSTM
863 orr r2, r2, #FAULT_CODE_LDMSTM
864#endif
865 b do_DataAbort
866
867Ldata_ldcstc_pre:
868 mov r0, r4, lsr #14 @ Get Rn
869 and r0, r0, #15 << 2 @ Mask out reg.
870 teq r0, #15 << 2
871 ldr r0, [r3, r0] @ Get register
872 mov r1, r4, lsl #24 @ Get offset
873 biceq r0, r0, #PCMASK
874 tst r4, #1 << 23
875 addne r0, r0, r1, lsr #24
876 subeq r0, r0, r1, lsr #24
877 mov r1, r0
878#ifdef FAULT_CODE_LDCSTC
879 orr r2, r2, #FAULT_CODE_LDCSTC
880#endif
881 b do_DataAbort
882
883
884/*
885 * This is the return code to user mode for abort handlers
886 */
887ENTRY(ret_from_exception)
888 get_thread_info tsk
889 mov why, #0
890 b ret_to_user
891
892 .data
893ENTRY(fp_enter)
894 .word fpe_not_present
895 .text
896/*
897 * Register switch for older 26-bit only ARMs
898 */
899ENTRY(__switch_to)
900 add r0, r0, #TI_CPU_SAVE
901 stmia r0, {r4 - sl, fp, sp, lr}
902 add r1, r1, #TI_CPU_SAVE
903 ldmia r1, {r4 - sl, fp, sp, pc}^
904
905/*
906 *=============================================================================
907 * Low-level interface code
908 *-----------------------------------------------------------------------------
909 * Trap initialisation
910 *-----------------------------------------------------------------------------
911 *
912 * Note - FIQ code has changed. The default is a couple of words in 0x1c, 0x20
913 * that call _unexp_fiq. Nowever, we now copy the FIQ routine to 0x1c (removes
914 * some excess cycles).
915 *
916 * What we need to put into 0-0x1c are branches to branch to the kernel.
917 */
918
919 .section ".init.text",#alloc,#execinstr
920
921.Ljump_addresses:
922 swi SYS_ERROR0
923 .word vector_undefinstr - 12
924 .word vector_swi - 16
925 .word vector_prefetch - 20
926 .word vector_data - 24
927 .word vector_addrexcptn - 28
928 .word vector_IRQ - 32
929 .word _unexp_fiq - 36
930 b . + 8
931/*
932 * initialise the trap system
933 */
934ENTRY(__trap_init)
935 stmfd sp!, {r4 - r7, lr}
936 adr r1, .Ljump_addresses
937 ldmia r1, {r1 - r7, ip, lr}
938 orr r2, lr, r2, lsr #2
939 orr r3, lr, r3, lsr #2
940 orr r4, lr, r4, lsr #2
941 orr r5, lr, r5, lsr #2
942 orr r6, lr, r6, lsr #2
943 orr r7, lr, r7, lsr #2
944 orr ip, lr, ip, lsr #2
945 mov r0, #0
946 stmia r0, {r1 - r7, ip}
947 ldmfd sp!, {r4 - r7, pc}^
948
949 .bss
950__temp_irq: .space 4 @ saved lr_irq
951__temp_fiq: .space 128
diff --git a/arch/arm26/kernel/fiq.c b/arch/arm26/kernel/fiq.c
deleted file mode 100644
index c4776c96be6b..000000000000
--- a/arch/arm26/kernel/fiq.c
+++ /dev/null
@@ -1,201 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/fiq.c
3 *
4 * Copyright (C) 1998 Russell King
5 * Copyright (C) 1998, 1999 Phil Blundell
6 * Copyright (C) 2003 Ian Molton
7 *
8 * FIQ support written by Philip Blundell <philb@gnu.org>, 1998.
9 *
10 * FIQ support re-written by Russell King to be more generic
11 *
12 * We now properly support a method by which the FIQ handlers can
13 * be stacked onto the vector. We still do not support sharing
14 * the FIQ vector itself.
15 *
16 * Operation is as follows:
17 * 1. Owner A claims FIQ:
18 * - default_fiq relinquishes control.
19 * 2. Owner A:
20 * - inserts code.
21 * - sets any registers,
22 * - enables FIQ.
23 * 3. Owner B claims FIQ:
24 * - if owner A has a relinquish function.
25 * - disable FIQs.
26 * - saves any registers.
27 * - returns zero.
28 * 4. Owner B:
29 * - inserts code.
30 * - sets any registers,
31 * - enables FIQ.
32 * 5. Owner B releases FIQ:
33 * - Owner A is asked to reacquire FIQ:
34 * - inserts code.
35 * - restores saved registers.
36 * - enables FIQ.
37 * 6. Goto 3
38 */
39#include <linux/module.h>
40#include <linux/mm.h>
41#include <linux/mman.h>
42#include <linux/init.h>
43#include <linux/seq_file.h>
44
45#include <asm/fiq.h>
46#include <asm/io.h>
47#include <asm/irq.h>
48#include <asm/pgalloc.h>
49#include <asm/system.h>
50#include <asm/uaccess.h>
51
52#define FIQ_VECTOR (vectors_base() + 0x1c)
53
54static unsigned long no_fiq_insn;
55
56#define unprotect_page_0()
57#define protect_page_0()
58
59/* Default reacquire function
60 * - we always relinquish FIQ control
61 * - we always reacquire FIQ control
62 */
63static int fiq_def_op(void *ref, int relinquish)
64{
65 if (!relinquish) {
66 unprotect_page_0();
67 *(unsigned long *)FIQ_VECTOR = no_fiq_insn;
68 protect_page_0();
69 }
70
71 return 0;
72}
73
74static struct fiq_handler default_owner = {
75 .name = "default",
76 .fiq_op = fiq_def_op,
77};
78
79static struct fiq_handler *current_fiq = &default_owner;
80
81int show_fiq_list(struct seq_file *p, void *v)
82{
83 if (current_fiq != &default_owner)
84 seq_printf(p, "FIQ: %s\n", current_fiq->name);
85
86 return 0;
87}
88
89void set_fiq_handler(void *start, unsigned int length)
90{
91 unprotect_page_0();
92
93 memcpy((void *)FIQ_VECTOR, start, length);
94
95 protect_page_0();
96}
97
98/*
99 * Taking an interrupt in FIQ mode is death, so both these functions
100 * disable irqs for the duration.
101 */
102void set_fiq_regs(struct pt_regs *regs)
103{
104 register unsigned long tmp, tmp2;
105 __asm__ volatile (
106 "mov %0, pc \n"
107 "bic %1, %0, #0x3 \n"
108 "orr %1, %1, %3 \n"
109 "teqp %1, #0 @ select FIQ mode \n"
110 "mov r0, r0 \n"
111 "ldmia %2, {r8 - r14} \n"
112 "teqp %0, #0 @ return to SVC mode \n"
113 "mov r0, r0 "
114 : "=&r" (tmp), "=&r" (tmp2)
115 : "r" (&regs->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | MODE_FIQ26)
116 /* These registers aren't modified by the above code in a way
117 visible to the compiler, but we mark them as clobbers anyway
118 so that GCC won't put any of the input or output operands in
119 them. */
120 : "r8", "r9", "r10", "r11", "r12", "r13", "r14");
121}
122
123void get_fiq_regs(struct pt_regs *regs)
124{
125 register unsigned long tmp, tmp2;
126 __asm__ volatile (
127 "mov %0, pc \n"
128 "bic %1, %0, #0x3 \n"
129 "orr %1, %1, %3 \n"
130 "teqp %1, #0 @ select FIQ mode \n"
131 "mov r0, r0 \n"
132 "stmia %2, {r8 - r14} \n"
133 "teqp %0, #0 @ return to SVC mode \n"
134 "mov r0, r0 "
135 : "=&r" (tmp), "=&r" (tmp2)
136 : "r" (&regs->ARM_r8), "I" (PSR_I_BIT | PSR_F_BIT | MODE_FIQ26)
137 /* These registers aren't modified by the above code in a way
138 visible to the compiler, but we mark them as clobbers anyway
139 so that GCC won't put any of the input or output operands in
140 them. */
141 : "r8", "r9", "r10", "r11", "r12", "r13", "r14");
142}
143
144int claim_fiq(struct fiq_handler *f)
145{
146 int ret = 0;
147
148 if (current_fiq) {
149 ret = -EBUSY;
150
151 if (current_fiq->fiq_op != NULL)
152 ret = current_fiq->fiq_op(current_fiq->dev_id, 1);
153 }
154
155 if (!ret) {
156 f->next = current_fiq;
157 current_fiq = f;
158 }
159
160 return ret;
161}
162
163void release_fiq(struct fiq_handler *f)
164{
165 if (current_fiq != f) {
166 printk(KERN_ERR "%s FIQ trying to release %s FIQ\n",
167 f->name, current_fiq->name);
168#ifdef CONFIG_DEBUG_ERRORS
169 __backtrace();
170#endif
171 return;
172 }
173
174 do
175 current_fiq = current_fiq->next;
176 while (current_fiq->fiq_op(current_fiq->dev_id, 0));
177}
178
179void enable_fiq(int fiq)
180{
181 enable_irq(fiq + FIQ_START);
182}
183
184void disable_fiq(int fiq)
185{
186 disable_irq(fiq + FIQ_START);
187}
188
189EXPORT_SYMBOL(set_fiq_handler);
190EXPORT_SYMBOL(set_fiq_regs);
191EXPORT_SYMBOL(get_fiq_regs);
192EXPORT_SYMBOL(claim_fiq);
193EXPORT_SYMBOL(release_fiq);
194EXPORT_SYMBOL(enable_fiq);
195EXPORT_SYMBOL(disable_fiq);
196
197void __init init_FIQ(void)
198{
199 no_fiq_insn = *(unsigned long *)FIQ_VECTOR;
200 set_fs(get_fs());
201}
diff --git a/arch/arm26/kernel/head.S b/arch/arm26/kernel/head.S
deleted file mode 100644
index 93575e0e58fe..000000000000
--- a/arch/arm26/kernel/head.S
+++ /dev/null
@@ -1,112 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/head.S
3 *
4 * Copyright (C) 1994-2000 Russell King
5 * Copyright (C) 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * 26-bit kernel startup code
12 */
13#include <linux/linkage.h>
14#include <asm/mach-types.h>
15
16 .globl swapper_pg_dir
17 .equ swapper_pg_dir, 0x0207d000
18
19/*
20 * Entry point.
21 */
22 .section ".init.text",#alloc,#execinstr
23ENTRY(stext)
24
25__entry:
26 cmp pc, #0x02000000
27 ldrlt pc, LC0 @ if 0x01800000, call at 0x02080000
28 teq r0, #0 @ Check for old calling method
29 blne oldparams @ Move page if old
30
31 adr r0, LC0
32 ldmib r0, {r2-r5, sp} @ Setup stack (and fetch other values)
33
34 mov r0, #0 @ Clear BSS
351: cmp r2, r3
36 strcc r0, [r2], #4
37 bcc 1b
38
39 bl detect_proc_type
40 str r0, [r4]
41 bl detect_arch_type
42 str r0, [r5]
43
44#ifdef CONFIG_XIP_KERNEL
45 ldr r3, ETEXT @ data section copy
46 ldr r4, SDATA
47 ldr r5, EDATA
481:
49 ldr r6, [r3], #4
50 str r6, [r4], #4
51 cmp r4, r5
52 blt 1b
53#endif
54 mov fp, #0
55 b start_kernel
56
57LC0: .word _stext
58 .word __bss_start @ r2
59 .word _end @ r3
60 .word processor_id @ r4
61 .word __machine_arch_type @ r5
62 .word init_thread_union+8192 @ sp
63#ifdef CONFIG_XIP_KERNEL
64ETEXT: .word _endtext
65SDATA: .word _sdata
66EDATA: .word __bss_start
67#endif
68
69arm2_id: .long 0x41560200 @ ARM2 and 250 dont have a CPUID
70arm250_id: .long 0x41560250 @ So we create some after probing for them
71 .align
72
73oldparams: mov r4, #0x02000000
74 add r3, r4, #0x00080000
75 add r4, r4, #0x0007c000
761: ldmia r0!, {r5 - r12}
77 stmia r4!, {r5 - r12}
78 cmp r4, r3
79 blt 1b
80 mov pc, lr
81
82/*
83 * We need some way to automatically detect the difference between
84 * these two machines. Unfortunately, it is not possible to detect
85 * the presence of the SuperIO chip, because that will hang the old
86 * Archimedes machines solid.
87 */
88/* DAG: Outdated, these have been combined !!!!!!! */
89detect_arch_type:
90#if defined(CONFIG_ARCH_ARC)
91 mov r0, #MACH_TYPE_ARCHIMEDES
92#elif defined(CONFIG_ARCH_A5K)
93 mov r0, #MACH_TYPE_A5K
94#endif
95 mov pc, lr
96
97detect_proc_type:
98 mov ip, lr
99 mov r2, #0xea000000 @ Point undef instr to continuation
100 adr r0, continue - 12
101 orr r0, r2, r0, lsr #2
102 mov r1, #0
103 str r0, [r1, #4]
104 ldr r0, arm2_id
105 swp r2, r2, [r1] @ check for swp (ARM2 cant)
106 ldr r0, arm250_id
107 mrc 15, 0, r3, c0, c0 @ check for CP#15 (ARM250 cant)
108 mov r0, r3
109continue: mov r2, #0xeb000000 @ Make undef vector loop
110 sub r2, r2, #2
111 str r2, [r1, #4]
112 mov pc, ip
diff --git a/arch/arm26/kernel/init_task.c b/arch/arm26/kernel/init_task.c
deleted file mode 100644
index 4191565b889b..000000000000
--- a/arch/arm26/kernel/init_task.c
+++ /dev/null
@@ -1,49 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/init_task.c
3 *
4 * Copyright (C) 2003 Ian Molton
5 *
6 */
7#include <linux/mm.h>
8#include <linux/module.h>
9#include <linux/fs.h>
10#include <linux/sched.h>
11#include <linux/init.h>
12#include <linux/init_task.h>
13#include <linux/mqueue.h>
14
15#include <asm/uaccess.h>
16#include <asm/pgtable.h>
17
18static struct fs_struct init_fs = INIT_FS;
19static struct files_struct init_files = INIT_FILES;
20static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
21static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
22struct mm_struct init_mm = INIT_MM(init_mm);
23
24EXPORT_SYMBOL(init_mm);
25
26/*
27 * Initial thread structure.
28 *
29 * We need to make sure that this is 8192-byte aligned due to the
30 * way process stacks are handled. This is done by making sure
31 * the linker maps this in the .text segment right after head.S,
32 * and making the linker scripts ensure the proper alignment.
33 *
34 * FIXME - should this be 32K alignment on arm26?
35 *
36 * The things we do for performance...
37 */
38union thread_union init_thread_union
39 __attribute__((__section__(".init.task"))) =
40 { INIT_THREAD_INFO(init_task) };
41
42/*
43 * Initial task structure.
44 *
45 * All other task structs will be allocated on slabs in fork.c
46 */
47struct task_struct init_task = INIT_TASK(init_task);
48
49EXPORT_SYMBOL(init_task);
diff --git a/arch/arm26/kernel/irq.c b/arch/arm26/kernel/irq.c
deleted file mode 100644
index 2ffe695b062e..000000000000
--- a/arch/arm26/kernel/irq.c
+++ /dev/null
@@ -1,722 +0,0 @@
1/*
2 * linux/arch/arm/kernel/irq.c
3 *
4 * Copyright (C) 1992 Linus Torvalds
5 * Modifications for ARM processor Copyright (C) 1995-2000 Russell King.
6 * 'Borrowed' for ARM26 and (C) 2003 Ian Molton.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This file contains the code used by various IRQ handling routines:
13 * asking for different IRQ's should be done through these routines
14 * instead of just grabbing them. Thus setups with different IRQ numbers
15 * shouldn't result in any weird surprises, and installing new handlers
16 * should be easier.
17 *
18 * IRQ's are in fact implemented a bit like signal handlers for the kernel.
19 * Naturally it's not a 1:1 relation, but there are similarities.
20 */
21#include <linux/module.h>
22#include <linux/ptrace.h>
23#include <linux/kernel_stat.h>
24#include <linux/signal.h>
25#include <linux/sched.h>
26#include <linux/ioport.h>
27#include <linux/interrupt.h>
28#include <linux/slab.h>
29#include <linux/random.h>
30#include <linux/smp.h>
31#include <linux/init.h>
32#include <linux/seq_file.h>
33#include <linux/errno.h>
34
35#include <asm/irq.h>
36#include <asm/system.h>
37#include <asm/irqchip.h>
38
39//FIXME - this ought to be in a header IMO
40void __init arc_init_irq(void);
41
42/*
43 * Maximum IRQ count. Currently, this is arbitary. However, it should
44 * not be set too low to prevent false triggering. Conversely, if it
45 * is set too high, then you could miss a stuck IRQ.
46 *
47 * FIXME Maybe we ought to set a timer and re-enable the IRQ at a later time?
48 */
49#define MAX_IRQ_CNT 100000
50
51static volatile unsigned long irq_err_count;
52static DEFINE_SPINLOCK(irq_controller_lock);
53
54struct irqdesc irq_desc[NR_IRQS];
55
56/*
57 * Dummy mask/unmask handler
58 */
59void dummy_mask_unmask_irq(unsigned int irq)
60{
61}
62
63void do_bad_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
64{
65 irq_err_count += 1;
66 printk(KERN_ERR "IRQ: spurious interrupt %d\n", irq);
67}
68
69static struct irqchip bad_chip = {
70 .ack = dummy_mask_unmask_irq,
71 .mask = dummy_mask_unmask_irq,
72 .unmask = dummy_mask_unmask_irq,
73};
74
75static struct irqdesc bad_irq_desc = {
76 .chip = &bad_chip,
77 .handle = do_bad_IRQ,
78 .depth = 1,
79};
80
81/**
82 * disable_irq - disable an irq and wait for completion
83 * @irq: Interrupt to disable
84 *
85 * Disable the selected interrupt line. We do this lazily.
86 *
87 * This function may be called from IRQ context.
88 */
89void disable_irq(unsigned int irq)
90{
91 struct irqdesc *desc = irq_desc + irq;
92 unsigned long flags;
93 spin_lock_irqsave(&irq_controller_lock, flags);
94 if (!desc->depth++)
95 desc->enabled = 0;
96 spin_unlock_irqrestore(&irq_controller_lock, flags);
97}
98EXPORT_SYMBOL(disable_irq);
99
100void disable_irq_nosync(unsigned int irq) __attribute__((alias("disable_irq")));
101
102EXPORT_SYMBOL(disable_irq_nosync);
103
104/**
105 * enable_irq - enable interrupt handling on an irq
106 * @irq: Interrupt to enable
107 *
108 * Re-enables the processing of interrupts on this IRQ line.
109 * Note that this may call the interrupt handler, so you may
110 * get unexpected results if you hold IRQs disabled.
111 *
112 * This function may be called from IRQ context.
113 */
114void enable_irq(unsigned int irq)
115{
116 struct irqdesc *desc = irq_desc + irq;
117 unsigned long flags;
118 int pending = 0;
119
120 spin_lock_irqsave(&irq_controller_lock, flags);
121 if (unlikely(!desc->depth)) {
122 printk("enable_irq(%u) unbalanced from %p\n", irq,
123 __builtin_return_address(0)); //FIXME bum addresses reported - why?
124 } else if (!--desc->depth) {
125 desc->probing = 0;
126 desc->enabled = 1;
127 desc->chip->unmask(irq);
128 pending = desc->pending;
129 desc->pending = 0;
130 /*
131 * If the interrupt was waiting to be processed,
132 * retrigger it.
133 */
134 if (pending)
135 desc->chip->rerun(irq);
136 }
137 spin_unlock_irqrestore(&irq_controller_lock, flags);
138}
139EXPORT_SYMBOL(enable_irq);
140
141int show_interrupts(struct seq_file *p, void *v)
142{
143 int i = *(loff_t *) v;
144 struct irqaction * action;
145
146 if (i < NR_IRQS) {
147 action = irq_desc[i].action;
148 if (!action)
149 goto out;
150 seq_printf(p, "%3d: %10u ", i, kstat_irqs(i));
151 seq_printf(p, " %s", action->name);
152 for (action = action->next; action; action = action->next) {
153 seq_printf(p, ", %s", action->name);
154 }
155 seq_putc(p, '\n');
156 } else if (i == NR_IRQS) {
157 show_fiq_list(p, v);
158 seq_printf(p, "Err: %10lu\n", irq_err_count);
159 }
160out:
161 return 0;
162}
163
164/*
165 * IRQ lock detection.
166 *
167 * Hopefully, this should get us out of a few locked situations.
168 * However, it may take a while for this to happen, since we need
169 * a large number if IRQs to appear in the same jiffie with the
170 * same instruction pointer (or within 2 instructions).
171 */
172static int check_irq_lock(struct irqdesc *desc, int irq, struct pt_regs *regs)
173{
174 unsigned long instr_ptr = instruction_pointer(regs);
175
176 if (desc->lck_jif == jiffies &&
177 desc->lck_pc >= instr_ptr && desc->lck_pc < instr_ptr + 8) {
178 desc->lck_cnt += 1;
179
180 if (desc->lck_cnt > MAX_IRQ_CNT) {
181 printk(KERN_ERR "IRQ LOCK: IRQ%d is locking the system, disabled\n", irq);
182 return 1;
183 }
184 } else {
185 desc->lck_cnt = 0;
186 desc->lck_pc = instruction_pointer(regs);
187 desc->lck_jif = jiffies;
188 }
189 return 0;
190}
191
192static void
193__do_irq(unsigned int irq, struct irqaction *action, struct pt_regs *regs)
194{
195 unsigned int status;
196 int ret;
197
198 spin_unlock(&irq_controller_lock);
199 if (!(action->flags & IRQF_DISABLED))
200 local_irq_enable();
201
202 status = 0;
203 do {
204 ret = action->handler(irq, action->dev_id, regs);
205 if (ret == IRQ_HANDLED)
206 status |= action->flags;
207 action = action->next;
208 } while (action);
209
210 if (status & IRQF_SAMPLE_RANDOM)
211 add_interrupt_randomness(irq);
212
213 spin_lock_irq(&irq_controller_lock);
214}
215
216/*
217 * This is for software-decoded IRQs. The caller is expected to
218 * handle the ack, clear, mask and unmask issues.
219 */
220void
221do_simple_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
222{
223 struct irqaction *action;
224 const int cpu = smp_processor_id();
225
226 desc->triggered = 1;
227
228 kstat_cpu(cpu).irqs[irq]++;
229
230 action = desc->action;
231 if (action)
232 __do_irq(irq, desc->action, regs);
233}
234
235/*
236 * Most edge-triggered IRQ implementations seem to take a broken
237 * approach to this. Hence the complexity.
238 */
239void
240do_edge_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
241{
242 const int cpu = smp_processor_id();
243
244 desc->triggered = 1;
245
246 /*
247 * If we're currently running this IRQ, or its disabled,
248 * we shouldn't process the IRQ. Instead, turn on the
249 * hardware masks.
250 */
251 if (unlikely(desc->running || !desc->enabled))
252 goto running;
253
254 /*
255 * Acknowledge and clear the IRQ, but don't mask it.
256 */
257 desc->chip->ack(irq);
258
259 /*
260 * Mark the IRQ currently in progress.
261 */
262 desc->running = 1;
263
264 kstat_cpu(cpu).irqs[irq]++;
265
266 do {
267 struct irqaction *action;
268
269 action = desc->action;
270 if (!action)
271 break;
272
273 if (desc->pending && desc->enabled) {
274 desc->pending = 0;
275 desc->chip->unmask(irq);
276 }
277
278 __do_irq(irq, action, regs);
279 } while (desc->pending);
280
281 desc->running = 0;
282
283 /*
284 * If we were disabled or freed, shut down the handler.
285 */
286 if (likely(desc->action && !check_irq_lock(desc, irq, regs)))
287 return;
288
289 running:
290 /*
291 * We got another IRQ while this one was masked or
292 * currently running. Delay it.
293 */
294 desc->pending = 1;
295 desc->chip->mask(irq);
296 desc->chip->ack(irq);
297}
298
299/*
300 * Level-based IRQ handler. Nice and simple.
301 */
302void
303do_level_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
304{
305 struct irqaction *action;
306 const int cpu = smp_processor_id();
307
308 desc->triggered = 1;
309
310 /*
311 * Acknowledge, clear _AND_ disable the interrupt.
312 */
313 desc->chip->ack(irq);
314
315 if (likely(desc->enabled)) {
316 kstat_cpu(cpu).irqs[irq]++;
317
318 /*
319 * Return with this interrupt masked if no action
320 */
321 action = desc->action;
322 if (action) {
323 __do_irq(irq, desc->action, regs);
324
325 if (likely(desc->enabled &&
326 !check_irq_lock(desc, irq, regs)))
327 desc->chip->unmask(irq);
328 }
329 }
330}
331
332/*
333 * do_IRQ handles all hardware IRQ's. Decoded IRQs should not
334 * come via this function. Instead, they should provide their
335 * own 'handler'
336 */
337asmlinkage void asm_do_IRQ(int irq, struct pt_regs *regs)
338{
339 struct irqdesc *desc = irq_desc + irq;
340
341 /*
342 * Some hardware gives randomly wrong interrupts. Rather
343 * than crashing, do something sensible.
344 */
345 if (irq >= NR_IRQS)
346 desc = &bad_irq_desc;
347
348 irq_enter();
349 spin_lock(&irq_controller_lock);
350 desc->handle(irq, desc, regs);
351 spin_unlock(&irq_controller_lock);
352 irq_exit();
353}
354
355void __set_irq_handler(unsigned int irq, irq_handler_t handle, int is_chained)
356{
357 struct irqdesc *desc;
358 unsigned long flags;
359
360 if (irq >= NR_IRQS) {
361 printk(KERN_ERR "Trying to install handler for IRQ%d\n", irq);
362 return;
363 }
364
365 if (handle == NULL)
366 handle = do_bad_IRQ;
367
368 desc = irq_desc + irq;
369
370 if (is_chained && desc->chip == &bad_chip)
371 printk(KERN_WARNING "Trying to install chained handler for IRQ%d\n", irq);
372
373 spin_lock_irqsave(&irq_controller_lock, flags);
374 if (handle == do_bad_IRQ) {
375 desc->chip->mask(irq);
376 desc->chip->ack(irq);
377 desc->depth = 1;
378 desc->enabled = 0;
379 }
380 desc->handle = handle;
381 if (handle != do_bad_IRQ && is_chained) {
382 desc->valid = 0;
383 desc->probe_ok = 0;
384 desc->depth = 0;
385 desc->chip->unmask(irq);
386 }
387 spin_unlock_irqrestore(&irq_controller_lock, flags);
388}
389
390void set_irq_chip(unsigned int irq, struct irqchip *chip)
391{
392 struct irqdesc *desc;
393 unsigned long flags;
394
395 if (irq >= NR_IRQS) {
396 printk(KERN_ERR "Trying to install chip for IRQ%d\n", irq);
397 return;
398 }
399
400 if (chip == NULL)
401 chip = &bad_chip;
402
403 desc = irq_desc + irq;
404 spin_lock_irqsave(&irq_controller_lock, flags);
405 desc->chip = chip;
406 spin_unlock_irqrestore(&irq_controller_lock, flags);
407}
408
409int set_irq_type(unsigned int irq, unsigned int type)
410{
411 struct irqdesc *desc;
412 unsigned long flags;
413 int ret = -ENXIO;
414
415 if (irq >= NR_IRQS) {
416 printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
417 return -ENODEV;
418 }
419
420 desc = irq_desc + irq;
421 if (desc->chip->type) {
422 spin_lock_irqsave(&irq_controller_lock, flags);
423 ret = desc->chip->type(irq, type);
424 spin_unlock_irqrestore(&irq_controller_lock, flags);
425 }
426
427 return ret;
428}
429
430void set_irq_flags(unsigned int irq, unsigned int iflags)
431{
432 struct irqdesc *desc;
433 unsigned long flags;
434
435 if (irq >= NR_IRQS) {
436 printk(KERN_ERR "Trying to set irq flags for IRQ%d\n", irq);
437 return;
438 }
439
440 desc = irq_desc + irq;
441 spin_lock_irqsave(&irq_controller_lock, flags);
442 desc->valid = (iflags & IRQF_VALID) != 0;
443 desc->probe_ok = (iflags & IRQF_PROBE) != 0;
444 desc->noautoenable = (iflags & IRQF_NOAUTOEN) != 0;
445 spin_unlock_irqrestore(&irq_controller_lock, flags);
446}
447
448int setup_irq(unsigned int irq, struct irqaction *new)
449{
450 int shared = 0;
451 struct irqaction *old, **p;
452 unsigned long flags;
453 struct irqdesc *desc;
454
455 /*
456 * Some drivers like serial.c use request_irq() heavily,
457 * so we have to be careful not to interfere with a
458 * running system.
459 */
460 if (new->flags & IRQF_SAMPLE_RANDOM) {
461 /*
462 * This function might sleep, we want to call it first,
463 * outside of the atomic block.
464 * Yes, this might clear the entropy pool if the wrong
465 * driver is attempted to be loaded, without actually
466 * installing a new handler, but is this really a problem,
467 * only the sysadmin is able to do this.
468 */
469 rand_initialize_irq(irq);
470 }
471
472 /*
473 * The following block of code has to be executed atomically
474 */
475 desc = irq_desc + irq;
476 spin_lock_irqsave(&irq_controller_lock, flags);
477 p = &desc->action;
478 if ((old = *p) != NULL) {
479 /* Can't share interrupts unless both agree to */
480 if (!(old->flags & new->flags & IRQF_SHARED)) {
481 spin_unlock_irqrestore(&irq_controller_lock, flags);
482 return -EBUSY;
483 }
484
485 /* add new interrupt at end of irq queue */
486 do {
487 p = &old->next;
488 old = *p;
489 } while (old);
490 shared = 1;
491 }
492
493 *p = new;
494
495 if (!shared) {
496 desc->probing = 0;
497 desc->running = 0;
498 desc->pending = 0;
499 desc->depth = 1;
500 if (!desc->noautoenable) {
501 desc->depth = 0;
502 desc->enabled = 1;
503 desc->chip->unmask(irq);
504 }
505 }
506
507 spin_unlock_irqrestore(&irq_controller_lock, flags);
508 return 0;
509}
510
511/**
512 * request_irq - allocate an interrupt line
513 * @irq: Interrupt line to allocate
514 * @handler: Function to be called when the IRQ occurs
515 * @irqflags: Interrupt type flags
516 * @devname: An ascii name for the claiming device
517 * @dev_id: A cookie passed back to the handler function
518 *
519 * This call allocates interrupt resources and enables the
520 * interrupt line and IRQ handling. From the point this
521 * call is made your handler function may be invoked. Since
522 * your handler function must clear any interrupt the board
523 * raises, you must take care both to initialise your hardware
524 * and to set up the interrupt handler in the right order.
525 *
526 * Dev_id must be globally unique. Normally the address of the
527 * device data structure is used as the cookie. Since the handler
528 * receives this value it makes sense to use it.
529 *
530 * If your interrupt is shared you must pass a non NULL dev_id
531 * as this is required when freeing the interrupt.
532 *
533 * Flags:
534 *
535 * IRQF_SHARED Interrupt is shared
536 *
537 * IRQF_DISABLED Disable local interrupts while processing
538 *
539 * IRQF_SAMPLE_RANDOM The interrupt can be used for entropy
540 *
541 */
542
543//FIXME - handler used to return void - whats the significance of the change?
544int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *),
545 unsigned long irq_flags, const char * devname, void *dev_id)
546{
547 unsigned long retval;
548 struct irqaction *action;
549
550 if (irq >= NR_IRQS || !irq_desc[irq].valid || !handler ||
551 (irq_flags & IRQF_SHARED && !dev_id))
552 return -EINVAL;
553
554 action = kmalloc(sizeof(struct irqaction), GFP_KERNEL);
555 if (!action)
556 return -ENOMEM;
557
558 action->handler = handler;
559 action->flags = irq_flags;
560 cpus_clear(action->mask);
561 action->name = devname;
562 action->next = NULL;
563 action->dev_id = dev_id;
564
565 retval = setup_irq(irq, action);
566
567 if (retval)
568 kfree(action);
569 return retval;
570}
571
572EXPORT_SYMBOL(request_irq);
573
574/**
575 * free_irq - free an interrupt
576 * @irq: Interrupt line to free
577 * @dev_id: Device identity to free
578 *
579 * Remove an interrupt handler. The handler is removed and if the
580 * interrupt line is no longer in use by any driver it is disabled.
581 * On a shared IRQ the caller must ensure the interrupt is disabled
582 * on the card it drives before calling this function.
583 *
584 * This function may be called from interrupt context.
585 */
586void free_irq(unsigned int irq, void *dev_id)
587{
588 struct irqaction * action, **p;
589 unsigned long flags;
590
591 if (irq >= NR_IRQS || !irq_desc[irq].valid) {
592 printk(KERN_ERR "Trying to free IRQ%d\n",irq);
593#ifdef CONFIG_DEBUG_ERRORS
594 __backtrace();
595#endif
596 return;
597 }
598
599 spin_lock_irqsave(&irq_controller_lock, flags);
600 for (p = &irq_desc[irq].action; (action = *p) != NULL; p = &action->next) {
601 if (action->dev_id != dev_id)
602 continue;
603
604 /* Found it - now free it */
605 *p = action->next;
606 kfree(action);
607 goto out;
608 }
609 printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
610#ifdef CONFIG_DEBUG_ERRORS
611 __backtrace();
612#endif
613out:
614 spin_unlock_irqrestore(&irq_controller_lock, flags);
615}
616
617EXPORT_SYMBOL(free_irq);
618
619/* Start the interrupt probing. Unlike other architectures,
620 * we don't return a mask of interrupts from probe_irq_on,
621 * but return the number of interrupts enabled for the probe.
622 * The interrupts which have been enabled for probing is
623 * instead recorded in the irq_desc structure.
624 */
625unsigned long probe_irq_on(void)
626{
627 unsigned int i, irqs = 0;
628 unsigned long delay;
629
630 /*
631 * first snaffle up any unassigned but
632 * probe-able interrupts
633 */
634 spin_lock_irq(&irq_controller_lock);
635 for (i = 0; i < NR_IRQS; i++) {
636 if (!irq_desc[i].probe_ok || irq_desc[i].action)
637 continue;
638
639 irq_desc[i].probing = 1;
640 irq_desc[i].triggered = 0;
641 if (irq_desc[i].chip->type)
642 irq_desc[i].chip->type(i, IRQT_PROBE);
643 irq_desc[i].chip->unmask(i);
644 irqs += 1;
645 }
646 spin_unlock_irq(&irq_controller_lock);
647
648 /*
649 * wait for spurious interrupts to mask themselves out again
650 */
651 for (delay = jiffies + HZ/10; time_before(jiffies, delay); )
652 /* min 100ms delay */;
653
654 /*
655 * now filter out any obviously spurious interrupts
656 */
657 spin_lock_irq(&irq_controller_lock);
658 for (i = 0; i < NR_IRQS; i++) {
659 if (irq_desc[i].probing && irq_desc[i].triggered) {
660 irq_desc[i].probing = 0;
661 irqs -= 1;
662 }
663 }
664 spin_unlock_irq(&irq_controller_lock);
665
666 return irqs;
667}
668
669EXPORT_SYMBOL(probe_irq_on);
670
671/*
672 * Possible return values:
673 * >= 0 - interrupt number
674 * -1 - no interrupt/many interrupts
675 */
676int probe_irq_off(unsigned long irqs)
677{
678 unsigned int i;
679 int irq_found = NO_IRQ;
680
681 /*
682 * look at the interrupts, and find exactly one
683 * that we were probing has been triggered
684 */
685 spin_lock_irq(&irq_controller_lock);
686 for (i = 0; i < NR_IRQS; i++) {
687 if (irq_desc[i].probing &&
688 irq_desc[i].triggered) {
689 if (irq_found != NO_IRQ) {
690 irq_found = NO_IRQ;
691 goto out;
692 }
693 irq_found = i;
694 }
695 }
696
697 if (irq_found == -1)
698 irq_found = NO_IRQ;
699out:
700 spin_unlock_irq(&irq_controller_lock);
701
702 return irq_found;
703}
704
705EXPORT_SYMBOL(probe_irq_off);
706
707void __init init_irq_proc(void)
708{
709}
710
711void __init init_IRQ(void)
712{
713 struct irqdesc *desc;
714 extern void init_dma(void);
715 int irq;
716
717 for (irq = 0, desc = irq_desc; irq < NR_IRQS; irq++, desc++)
718 *desc = bad_irq_desc;
719
720 arc_init_irq();
721 init_dma();
722}
diff --git a/arch/arm26/kernel/process.c b/arch/arm26/kernel/process.c
deleted file mode 100644
index dcd81e62ff4e..000000000000
--- a/arch/arm26/kernel/process.c
+++ /dev/null
@@ -1,392 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/process.c
3 *
4 * Copyright (C) 2003 Ian Molton - adapted for ARM26
5 * Copyright (C) 1996-2000 Russell King - Converted to ARM.
6 * Origional Copyright (C) 1995 Linus Torvalds
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <stdarg.h>
13
14#include <linux/module.h>
15#include <linux/sched.h>
16#include <linux/kernel.h>
17#include <linux/mm.h>
18#include <linux/stddef.h>
19#include <linux/unistd.h>
20#include <linux/ptrace.h>
21#include <linux/slab.h>
22#include <linux/user.h>
23#include <linux/a.out.h>
24#include <linux/delay.h>
25#include <linux/reboot.h>
26#include <linux/interrupt.h>
27#include <linux/init.h>
28
29#include <asm/system.h>
30#include <asm/io.h>
31#include <asm/leds.h>
32#include <asm/processor.h>
33#include <asm/uaccess.h>
34
35extern const char *processor_modes[];
36extern void setup_mm_for_reboot(char mode);
37
38static volatile int hlt_counter;
39
40void disable_hlt(void)
41{
42 hlt_counter++;
43}
44
45EXPORT_SYMBOL(disable_hlt);
46
47void enable_hlt(void)
48{
49 hlt_counter--;
50}
51
52EXPORT_SYMBOL(enable_hlt);
53
54static int __init nohlt_setup(char *__unused)
55{
56 hlt_counter = 1;
57 return 1;
58}
59
60static int __init hlt_setup(char *__unused)
61{
62 hlt_counter = 0;
63 return 1;
64}
65
66__setup("nohlt", nohlt_setup);
67__setup("hlt", hlt_setup);
68
69/*
70 * This is our default idle handler. We need to disable
71 * interrupts here to ensure we don't miss a wakeup call.
72 */
73void cpu_idle(void)
74{
75 /* endless idle loop with no priority at all */
76 while (1) {
77 while (!need_resched())
78 cpu_relax();
79 preempt_enable_no_resched();
80 schedule();
81 preempt_disable();
82 }
83}
84
85static char reboot_mode = 'h';
86
87int __init reboot_setup(char *str)
88{
89 reboot_mode = str[0];
90 return 1;
91}
92
93__setup("reboot=", reboot_setup);
94
95/* ARM26 cant do these but we still need to define them. */
96void machine_halt(void)
97{
98}
99void machine_power_off(void)
100{
101}
102
103void machine_restart(char * __unused)
104{
105 /*
106 * Clean and disable cache, and turn off interrupts
107 */
108 cpu_proc_fin();
109
110 /*
111 * Tell the mm system that we are going to reboot -
112 * we may need it to insert some 1:1 mappings so that
113 * soft boot works.
114 */
115 setup_mm_for_reboot(reboot_mode);
116
117 /*
118 * copy branch instruction to reset location and call it
119 */
120
121 *(unsigned long *)0 = *(unsigned long *)0x03800000;
122 ((void(*)(void))0)();
123
124 /*
125 * Whoops - the architecture was unable to reboot.
126 * Tell the user! Should never happen...
127 */
128 mdelay(1000);
129 printk("Reboot failed -- System halted\n");
130 while (1);
131}
132
133void show_regs(struct pt_regs * regs)
134{
135 unsigned long flags;
136
137 flags = condition_codes(regs);
138
139 printk("pc : [<%08lx>] lr : [<%08lx>] %s\n"
140 "sp : %08lx ip : %08lx fp : %08lx\n",
141 instruction_pointer(regs),
142 regs->ARM_lr, print_tainted(), regs->ARM_sp,
143 regs->ARM_ip, regs->ARM_fp);
144 printk("r10: %08lx r9 : %08lx r8 : %08lx\n",
145 regs->ARM_r10, regs->ARM_r9,
146 regs->ARM_r8);
147 printk("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
148 regs->ARM_r7, regs->ARM_r6,
149 regs->ARM_r5, regs->ARM_r4);
150 printk("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
151 regs->ARM_r3, regs->ARM_r2,
152 regs->ARM_r1, regs->ARM_r0);
153 printk("Flags: %c%c%c%c",
154 flags & PSR_N_BIT ? 'N' : 'n',
155 flags & PSR_Z_BIT ? 'Z' : 'z',
156 flags & PSR_C_BIT ? 'C' : 'c',
157 flags & PSR_V_BIT ? 'V' : 'v');
158 printk(" IRQs o%s FIQs o%s Mode %s Segment %s\n",
159 interrupts_enabled(regs) ? "n" : "ff",
160 fast_interrupts_enabled(regs) ? "n" : "ff",
161 processor_modes[processor_mode(regs)],
162 get_fs() == get_ds() ? "kernel" : "user");
163}
164
165void show_fpregs(struct user_fp *regs)
166{
167 int i;
168
169 for (i = 0; i < 8; i++) {
170 unsigned long *p;
171 char type;
172
173 p = (unsigned long *)(regs->fpregs + i);
174
175 switch (regs->ftype[i]) {
176 case 1: type = 'f'; break;
177 case 2: type = 'd'; break;
178 case 3: type = 'e'; break;
179 default: type = '?'; break;
180 }
181 if (regs->init_flag)
182 type = '?';
183
184 printk(" f%d(%c): %08lx %08lx %08lx%c",
185 i, type, p[0], p[1], p[2], i & 1 ? '\n' : ' ');
186 }
187
188
189 printk("FPSR: %08lx FPCR: %08lx\n",
190 (unsigned long)regs->fpsr,
191 (unsigned long)regs->fpcr);
192}
193
194/*
195 * Task structure and kernel stack allocation.
196 */
197static unsigned long *thread_info_head;
198static unsigned int nr_thread_info;
199
200extern unsigned long get_page_8k(int priority);
201extern void free_page_8k(unsigned long page);
202
203// FIXME - is this valid?
204#define EXTRA_TASK_STRUCT 0
205#define ll_alloc_task_struct() ((struct thread_info *)get_page_8k(GFP_KERNEL))
206#define ll_free_task_struct(p) free_page_8k((unsigned long)(p))
207
208//FIXME - do we use *task param below looks like we dont, which is ok?
209//FIXME - if EXTRA_TASK_STRUCT is zero we can optimise the below away permanently. *IF* its supposed to be zero.
210struct thread_info *alloc_thread_info(struct task_struct *task)
211{
212 struct thread_info *thread = NULL;
213
214 if (EXTRA_TASK_STRUCT) {
215 unsigned long *p = thread_info_head;
216
217 if (p) {
218 thread_info_head = (unsigned long *)p[0];
219 nr_thread_info -= 1;
220 }
221 thread = (struct thread_info *)p;
222 }
223
224 if (!thread)
225 thread = ll_alloc_task_struct();
226
227#ifdef CONFIG_MAGIC_SYSRQ
228 /*
229 * The stack must be cleared if you want SYSRQ-T to
230 * give sensible stack usage information
231 */
232 if (thread) {
233 char *p = (char *)thread;
234 memzero(p+KERNEL_STACK_SIZE, KERNEL_STACK_SIZE);
235 }
236#endif
237 return thread;
238}
239
240void free_thread_info(struct thread_info *thread)
241{
242 if (EXTRA_TASK_STRUCT && nr_thread_info < EXTRA_TASK_STRUCT) {
243 unsigned long *p = (unsigned long *)thread;
244 p[0] = (unsigned long)thread_info_head;
245 thread_info_head = p;
246 nr_thread_info += 1;
247 } else
248 ll_free_task_struct(thread);
249}
250
251/*
252 * Free current thread data structures etc..
253 */
254void exit_thread(void)
255{
256}
257
258void flush_thread(void)
259{
260 struct thread_info *thread = current_thread_info();
261 struct task_struct *tsk = current;
262
263 memset(&tsk->thread.debug, 0, sizeof(struct debug_info));
264 memset(&thread->fpstate, 0, sizeof(union fp_state));
265
266 clear_used_math();
267}
268
269void release_thread(struct task_struct *dead_task)
270{
271}
272
273asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
274
275int
276copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start,
277 unsigned long unused, struct task_struct *p, struct pt_regs *regs)
278{
279 struct thread_info *thread = task_thread_info(p);
280 struct pt_regs *childregs = task_pt_regs(p);
281
282 *childregs = *regs;
283 childregs->ARM_r0 = 0;
284 childregs->ARM_sp = stack_start;
285
286 memset(&thread->cpu_context, 0, sizeof(struct cpu_context_save));
287 thread->cpu_context.sp = (unsigned long)childregs;
288 thread->cpu_context.pc = (unsigned long)ret_from_fork | MODE_SVC26 | PSR_I_BIT;
289
290 return 0;
291}
292
293/*
294 * fill in the fpe structure for a core dump...
295 */
296int dump_fpu (struct pt_regs *regs, struct user_fp *fp)
297{
298 struct thread_info *thread = current_thread_info();
299 int used_math = !!used_math();
300
301 if (used_math)
302 memcpy(fp, &thread->fpstate.soft, sizeof (*fp));
303
304 return used_math;
305}
306
307/*
308 * fill in the user structure for a core dump..
309 */
310void dump_thread(struct pt_regs * regs, struct user * dump)
311{
312 struct task_struct *tsk = current;
313
314 dump->magic = CMAGIC;
315 dump->start_code = tsk->mm->start_code;
316 dump->start_stack = regs->ARM_sp & ~(PAGE_SIZE - 1);
317
318 dump->u_tsize = (tsk->mm->end_code - tsk->mm->start_code) >> PAGE_SHIFT;
319 dump->u_dsize = (tsk->mm->brk - tsk->mm->start_data + PAGE_SIZE - 1) >> PAGE_SHIFT;
320 dump->u_ssize = 0;
321
322 dump->u_debugreg[0] = tsk->thread.debug.bp[0].address;
323 dump->u_debugreg[1] = tsk->thread.debug.bp[1].address;
324 dump->u_debugreg[2] = tsk->thread.debug.bp[0].insn;
325 dump->u_debugreg[3] = tsk->thread.debug.bp[1].insn;
326 dump->u_debugreg[4] = tsk->thread.debug.nsaved;
327
328 if (dump->start_stack < 0x04000000)
329 dump->u_ssize = (0x04000000 - dump->start_stack) >> PAGE_SHIFT;
330
331 dump->regs = *regs;
332 dump->u_fpvalid = dump_fpu (regs, &dump->u_fp);
333}
334
335/*
336 * Shuffle the argument into the correct register before calling the
337 * thread function. r1 is the thread argument, r2 is the pointer to
338 * the thread function, and r3 points to the exit function.
339 * FIXME - make sure this is right - the older code used to zero fp
340 * and cause the parent to call sys_exit (do_exit in this version)
341 */
342extern void kernel_thread_helper(void);
343
344asm( ".section .text\n"
345" .align\n"
346" .type kernel_thread_helper, #function\n"
347"kernel_thread_helper:\n"
348" mov r0, r1\n"
349" mov lr, r3\n"
350" mov pc, r2\n"
351" .size kernel_thread_helper, . - kernel_thread_helper\n"
352" .previous");
353
354/*
355 * Create a kernel thread.
356 */
357pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
358{
359 struct pt_regs regs;
360
361 memset(&regs, 0, sizeof(regs));
362
363 regs.ARM_r1 = (unsigned long)arg;
364 regs.ARM_r2 = (unsigned long)fn;
365 regs.ARM_r3 = (unsigned long)do_exit;
366 regs.ARM_pc = (unsigned long)kernel_thread_helper | MODE_SVC26;
367
368 return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
369}
370EXPORT_SYMBOL(kernel_thread);
371
372
373unsigned long get_wchan(struct task_struct *p)
374{
375 unsigned long fp, lr;
376 unsigned long stack_page;
377 int count = 0;
378 if (!p || p == current || p->state == TASK_RUNNING)
379 return 0;
380
381 stack_page = 4096 + (unsigned long)p;
382 fp = thread_saved_fp(p);
383 do {
384 if (fp < stack_page || fp > 4092+stack_page)
385 return 0;
386 lr = pc_pointer (((unsigned long *)fp)[-1]);
387 if (!in_sched_functions(lr))
388 return lr;
389 fp = *(unsigned long *) (fp - 12);
390 } while (count ++ < 16);
391 return 0;
392}
diff --git a/arch/arm26/kernel/ptrace.c b/arch/arm26/kernel/ptrace.c
deleted file mode 100644
index 0fefb86970c6..000000000000
--- a/arch/arm26/kernel/ptrace.c
+++ /dev/null
@@ -1,670 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/ptrace.c
3 *
4 * By Ross Biro 1/23/92
5 * edited by Linus Torvalds
6 * ARM modifications Copyright (C) 2000 Russell King
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/kernel.h>
13#include <linux/sched.h>
14#include <linux/mm.h>
15#include <linux/smp.h>
16#include <linux/ptrace.h>
17#include <linux/user.h>
18#include <linux/security.h>
19#include <linux/signal.h>
20
21#include <asm/uaccess.h>
22#include <asm/pgtable.h>
23#include <asm/system.h>
24//#include <asm/processor.h>
25
26#include "ptrace.h"
27
28#define REG_PC 15
29#define REG_PSR 15
30/*
31 * does not yet catch signals sent when the child dies.
32 * in exit.c or in signal.c.
33 */
34
35/*
36 * Breakpoint SWI instruction: SWI &9F0001
37 */
38#define BREAKINST_ARM 0xef9f0001
39
40/*
41 * this routine will get a word off of the processes privileged stack.
42 * the offset is how far from the base addr as stored in the THREAD.
43 * this routine assumes that all the privileged stacks are in our
44 * data space.
45 */
46static inline long get_user_reg(struct task_struct *task, int offset)
47{
48 return task_pt_regs(task)->uregs[offset];
49}
50
51/*
52 * this routine will put a word on the processes privileged stack.
53 * the offset is how far from the base addr as stored in the THREAD.
54 * this routine assumes that all the privileged stacks are in our
55 * data space.
56 */
57static inline int
58put_user_reg(struct task_struct *task, int offset, long data)
59{
60 struct pt_regs newregs, *regs = task_pt_regs(task);
61 int ret = -EINVAL;
62
63 newregs = *regs;
64 newregs.uregs[offset] = data;
65
66 if (valid_user_regs(&newregs)) {
67 regs->uregs[offset] = data;
68 ret = 0;
69 }
70
71 return ret;
72}
73
74static inline int
75read_u32(struct task_struct *task, unsigned long addr, u32 *res)
76{
77 int ret;
78
79 ret = access_process_vm(task, addr, res, sizeof(*res), 0);
80
81 return ret == sizeof(*res) ? 0 : -EIO;
82}
83
84static inline int
85read_instr(struct task_struct *task, unsigned long addr, u32 *res)
86{
87 int ret;
88 u32 val;
89 ret = access_process_vm(task, addr & ~3, &val, sizeof(val), 0);
90 ret = ret == sizeof(val) ? 0 : -EIO;
91 *res = val;
92 return ret;
93}
94
95/*
96 * Get value of register `rn' (in the instruction)
97 */
98static unsigned long
99ptrace_getrn(struct task_struct *child, unsigned long insn)
100{
101 unsigned int reg = (insn >> 16) & 15;
102 unsigned long val;
103
104 val = get_user_reg(child, reg);
105 if (reg == 15)
106 val = pc_pointer(val + 8); //FIXME - correct for arm26?
107
108 return val;
109}
110
111/*
112 * Get value of operand 2 (in an ALU instruction)
113 */
114static unsigned long
115ptrace_getaluop2(struct task_struct *child, unsigned long insn)
116{
117 unsigned long val;
118 int shift;
119 int type;
120
121 if (insn & 1 << 25) {
122 val = insn & 255;
123 shift = (insn >> 8) & 15;
124 type = 3;
125 } else {
126 val = get_user_reg (child, insn & 15);
127
128 if (insn & (1 << 4))
129 shift = (int)get_user_reg (child, (insn >> 8) & 15);
130 else
131 shift = (insn >> 7) & 31;
132
133 type = (insn >> 5) & 3;
134 }
135
136 switch (type) {
137 case 0: val <<= shift; break;
138 case 1: val >>= shift; break;
139 case 2:
140 val = (((signed long)val) >> shift);
141 break;
142 case 3:
143 val = (val >> shift) | (val << (32 - shift));
144 break;
145 }
146 return val;
147}
148
149/*
150 * Get value of operand 2 (in a LDR instruction)
151 */
152static unsigned long
153ptrace_getldrop2(struct task_struct *child, unsigned long insn)
154{
155 unsigned long val;
156 int shift;
157 int type;
158
159 val = get_user_reg(child, insn & 15);
160 shift = (insn >> 7) & 31;
161 type = (insn >> 5) & 3;
162
163 switch (type) {
164 case 0: val <<= shift; break;
165 case 1: val >>= shift; break;
166 case 2:
167 val = (((signed long)val) >> shift);
168 break;
169 case 3:
170 val = (val >> shift) | (val << (32 - shift));
171 break;
172 }
173 return val;
174}
175
176#define OP_MASK 0x01e00000
177#define OP_AND 0x00000000
178#define OP_EOR 0x00200000
179#define OP_SUB 0x00400000
180#define OP_RSB 0x00600000
181#define OP_ADD 0x00800000
182#define OP_ADC 0x00a00000
183#define OP_SBC 0x00c00000
184#define OP_RSC 0x00e00000
185#define OP_ORR 0x01800000
186#define OP_MOV 0x01a00000
187#define OP_BIC 0x01c00000
188#define OP_MVN 0x01e00000
189
190static unsigned long
191get_branch_address(struct task_struct *child, unsigned long pc, unsigned long insn)
192{
193 u32 alt = 0;
194
195 switch (insn & 0x0e000000) {
196 case 0x00000000:
197 case 0x02000000: {
198 /*
199 * data processing
200 */
201 long aluop1, aluop2, ccbit;
202
203 if ((insn & 0xf000) != 0xf000)
204 break;
205
206 aluop1 = ptrace_getrn(child, insn);
207 aluop2 = ptrace_getaluop2(child, insn);
208 ccbit = get_user_reg(child, REG_PSR) & PSR_C_BIT ? 1 : 0;
209
210 switch (insn & OP_MASK) {
211 case OP_AND: alt = aluop1 & aluop2; break;
212 case OP_EOR: alt = aluop1 ^ aluop2; break;
213 case OP_SUB: alt = aluop1 - aluop2; break;
214 case OP_RSB: alt = aluop2 - aluop1; break;
215 case OP_ADD: alt = aluop1 + aluop2; break;
216 case OP_ADC: alt = aluop1 + aluop2 + ccbit; break;
217 case OP_SBC: alt = aluop1 - aluop2 + ccbit; break;
218 case OP_RSC: alt = aluop2 - aluop1 + ccbit; break;
219 case OP_ORR: alt = aluop1 | aluop2; break;
220 case OP_MOV: alt = aluop2; break;
221 case OP_BIC: alt = aluop1 & ~aluop2; break;
222 case OP_MVN: alt = ~aluop2; break;
223 }
224 break;
225 }
226
227 case 0x04000000:
228 case 0x06000000:
229 /*
230 * ldr
231 */
232 if ((insn & 0x0010f000) == 0x0010f000) {
233 unsigned long base;
234
235 base = ptrace_getrn(child, insn);
236 if (insn & 1 << 24) {
237 long aluop2;
238
239 if (insn & 0x02000000)
240 aluop2 = ptrace_getldrop2(child, insn);
241 else
242 aluop2 = insn & 0xfff;
243
244 if (insn & 1 << 23)
245 base += aluop2;
246 else
247 base -= aluop2;
248 }
249 if (read_u32(child, base, &alt) == 0)
250 alt = pc_pointer(alt);
251 }
252 break;
253
254 case 0x08000000:
255 /*
256 * ldm
257 */
258 if ((insn & 0x00108000) == 0x00108000) {
259 unsigned long base;
260 unsigned int nr_regs;
261
262 if (insn & (1 << 23)) {
263 nr_regs = hweight16(insn & 65535) << 2;
264
265 if (!(insn & (1 << 24)))
266 nr_regs -= 4;
267 } else {
268 if (insn & (1 << 24))
269 nr_regs = -4;
270 else
271 nr_regs = 0;
272 }
273
274 base = ptrace_getrn(child, insn);
275
276 if (read_u32(child, base + nr_regs, &alt) == 0)
277 alt = pc_pointer(alt);
278 break;
279 }
280 break;
281
282 case 0x0a000000: {
283 /*
284 * bl or b
285 */
286 signed long displ;
287 /* It's a branch/branch link: instead of trying to
288 * figure out whether the branch will be taken or not,
289 * we'll put a breakpoint at both locations. This is
290 * simpler, more reliable, and probably not a whole lot
291 * slower than the alternative approach of emulating the
292 * branch.
293 */
294 displ = (insn & 0x00ffffff) << 8;
295 displ = (displ >> 6) + 8;
296 if (displ != 0 && displ != 4)
297 alt = pc + displ;
298 }
299 break;
300 }
301
302 return alt;
303}
304
305static int
306swap_insn(struct task_struct *task, unsigned long addr,
307 void *old_insn, void *new_insn, int size)
308{
309 int ret;
310
311 ret = access_process_vm(task, addr, old_insn, size, 0);
312 if (ret == size)
313 ret = access_process_vm(task, addr, new_insn, size, 1);
314 return ret;
315}
316
317static void
318add_breakpoint(struct task_struct *task, struct debug_info *dbg, unsigned long addr)
319{
320 int nr = dbg->nsaved;
321
322 if (nr < 2) {
323 u32 new_insn = BREAKINST_ARM;
324 int res;
325
326 res = swap_insn(task, addr, &dbg->bp[nr].insn, &new_insn, 4);
327
328 if (res == 4) {
329 dbg->bp[nr].address = addr;
330 dbg->nsaved += 1;
331 }
332 } else
333 printk(KERN_ERR "ptrace: too many breakpoints\n");
334}
335
336/*
337 * Clear one breakpoint in the user program. We copy what the hardware
338 * does and use bit 0 of the address to indicate whether this is a Thumb
339 * breakpoint or an ARM breakpoint.
340 */
341static void clear_breakpoint(struct task_struct *task, struct debug_entry *bp)
342{
343 unsigned long addr = bp->address;
344 u32 old_insn;
345 int ret;
346
347 ret = swap_insn(task, addr & ~3, &old_insn,
348 &bp->insn, 4);
349
350 if (ret != 4 || old_insn != BREAKINST_ARM)
351 printk(KERN_ERR "%s:%d: corrupted ARM breakpoint at "
352 "0x%08lx (0x%08x)\n", task->comm, task->pid,
353 addr, old_insn);
354}
355
356void ptrace_set_bpt(struct task_struct *child)
357{
358 struct pt_regs *regs;
359 unsigned long pc;
360 u32 insn;
361 int res;
362
363 regs = task_pt_regs(child);
364 pc = instruction_pointer(regs);
365
366 res = read_instr(child, pc, &insn);
367 if (!res) {
368 struct debug_info *dbg = &child->thread.debug;
369 unsigned long alt;
370
371 dbg->nsaved = 0;
372
373 alt = get_branch_address(child, pc, insn);
374 if (alt)
375 add_breakpoint(child, dbg, alt);
376
377 /*
378 * Note that we ignore the result of setting the above
379 * breakpoint since it may fail. When it does, this is
380 * not so much an error, but a forewarning that we may
381 * be receiving a prefetch abort shortly.
382 *
383 * If we don't set this breakpoint here, then we can
384 * lose control of the thread during single stepping.
385 */
386 if (!alt || predicate(insn) != PREDICATE_ALWAYS)
387 add_breakpoint(child, dbg, pc + 4);
388 }
389}
390
391/*
392 * Ensure no single-step breakpoint is pending. Returns non-zero
393 * value if child was being single-stepped.
394 */
395void ptrace_cancel_bpt(struct task_struct *child)
396{
397 int i, nsaved = child->thread.debug.nsaved;
398
399 child->thread.debug.nsaved = 0;
400
401 if (nsaved > 2) {
402 printk("ptrace_cancel_bpt: bogus nsaved: %d!\n", nsaved);
403 nsaved = 2;
404 }
405
406 for (i = 0; i < nsaved; i++)
407 clear_breakpoint(child, &child->thread.debug.bp[i]);
408}
409
410/*
411 * Called by kernel/ptrace.c when detaching..
412 *
413 * Make sure the single step bit is not set.
414 */
415void ptrace_disable(struct task_struct *child)
416{
417 child->ptrace &= ~PT_SINGLESTEP;
418 ptrace_cancel_bpt(child);
419}
420
421/*
422 * Handle hitting a breakpoint.
423 */
424void ptrace_break(struct task_struct *tsk, struct pt_regs *regs)
425{
426 siginfo_t info;
427
428 /*
429 * The PC is always left pointing at the next instruction. Fix this.
430 */
431 regs->ARM_pc -= 4;
432
433 if (tsk->thread.debug.nsaved == 0)
434 printk(KERN_ERR "ptrace: bogus breakpoint trap\n");
435
436 ptrace_cancel_bpt(tsk);
437
438 info.si_signo = SIGTRAP;
439 info.si_errno = 0;
440 info.si_code = TRAP_BRKPT;
441 info.si_addr = (void *)instruction_pointer(regs) - 4;
442
443 force_sig_info(SIGTRAP, &info, tsk);
444}
445
446/*
447 * Read the word at offset "off" into the "struct user". We
448 * actually access the pt_regs stored on the kernel stack.
449 */
450static int ptrace_read_user(struct task_struct *tsk, unsigned long off,
451 unsigned long *ret)
452{
453 unsigned long tmp;
454
455 if (off & 3 || off >= sizeof(struct user))
456 return -EIO;
457
458 tmp = 0;
459 if (off < sizeof(struct pt_regs))
460 tmp = get_user_reg(tsk, off >> 2);
461
462 return put_user(tmp, ret);
463}
464
465/*
466 * Write the word at offset "off" into "struct user". We
467 * actually access the pt_regs stored on the kernel stack.
468 */
469static int ptrace_write_user(struct task_struct *tsk, unsigned long off,
470 unsigned long val)
471{
472 if (off & 3 || off >= sizeof(struct user))
473 return -EIO;
474
475 if (off >= sizeof(struct pt_regs))
476 return 0;
477
478 return put_user_reg(tsk, off >> 2, val);
479}
480
481/*
482 * Get all user integer registers.
483 */
484static int ptrace_getregs(struct task_struct *tsk, void *uregs)
485{
486 struct pt_regs *regs = task_pt_regs(tsk);
487
488 return copy_to_user(uregs, regs, sizeof(struct pt_regs)) ? -EFAULT : 0;
489}
490
491/*
492 * Set all user integer registers.
493 */
494static int ptrace_setregs(struct task_struct *tsk, void *uregs)
495{
496 struct pt_regs newregs;
497 int ret;
498
499 ret = -EFAULT;
500 if (copy_from_user(&newregs, uregs, sizeof(struct pt_regs)) == 0) {
501 struct pt_regs *regs = task_pt_regs(tsk);
502
503 ret = -EINVAL;
504 if (valid_user_regs(&newregs)) {
505 *regs = newregs;
506 ret = 0;
507 }
508 }
509
510 return ret;
511}
512
513/*
514 * Get the child FPU state.
515 */
516static int ptrace_getfpregs(struct task_struct *tsk, void *ufp)
517{
518 return copy_to_user(ufp, &task_thread_info(tsk)->fpstate,
519 sizeof(struct user_fp)) ? -EFAULT : 0;
520}
521
522/*
523 * Set the child FPU state.
524 */
525static int ptrace_setfpregs(struct task_struct *tsk, void *ufp)
526{
527 set_stopped_child_used_math(tsk);
528 return copy_from_user(&task_thread_info(tsk)->fpstate, ufp,
529 sizeof(struct user_fp)) ? -EFAULT : 0;
530}
531
532long arch_ptrace(struct task_struct *child, long request, long addr, long data)
533{
534 int ret;
535
536 switch (request) {
537 /*
538 * read word at location "addr" in the child process.
539 */
540 case PTRACE_PEEKTEXT:
541 case PTRACE_PEEKDATA:
542 ret = generic_ptrace_peekdata(child, addr, data);
543 break;
544
545 case PTRACE_PEEKUSR:
546 ret = ptrace_read_user(child, addr, (unsigned long *)data);
547 break;
548
549 /*
550 * write the word at location addr.
551 */
552 case PTRACE_POKETEXT:
553 case PTRACE_POKEDATA:
554 ret = generic_ptrace_pokedata(child, addr, data);
555 break;
556
557 case PTRACE_POKEUSR:
558 ret = ptrace_write_user(child, addr, data);
559 break;
560
561 /*
562 * continue/restart and stop at next (return from) syscall
563 */
564 case PTRACE_SYSCALL:
565 case PTRACE_CONT:
566 ret = -EIO;
567 if (!valid_signal(data))
568 break;
569 if (request == PTRACE_SYSCALL)
570 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
571 else
572 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
573 child->exit_code = data;
574 /* make sure single-step breakpoint is gone. */
575 child->ptrace &= ~PT_SINGLESTEP;
576 ptrace_cancel_bpt(child);
577 wake_up_process(child);
578 ret = 0;
579 break;
580
581 /*
582 * make the child exit. Best I can do is send it a sigkill.
583 * perhaps it should be put in the status that it wants to
584 * exit.
585 */
586 case PTRACE_KILL:
587 /* make sure single-step breakpoint is gone. */
588 child->ptrace &= ~PT_SINGLESTEP;
589 ptrace_cancel_bpt(child);
590 if (child->exit_state != EXIT_ZOMBIE) {
591 child->exit_code = SIGKILL;
592 wake_up_process(child);
593 }
594 ret = 0;
595 break;
596
597 /*
598 * execute single instruction.
599 */
600 case PTRACE_SINGLESTEP:
601 ret = -EIO;
602 if (!valid_signal(data))
603 break;
604 child->ptrace |= PT_SINGLESTEP;
605 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
606 child->exit_code = data;
607 /* give it a chance to run. */
608 wake_up_process(child);
609 ret = 0;
610 break;
611
612 case PTRACE_DETACH:
613 ret = ptrace_detach(child, data);
614 break;
615
616 case PTRACE_GETREGS:
617 ret = ptrace_getregs(child, (void *)data);
618 break;
619
620 case PTRACE_SETREGS:
621 ret = ptrace_setregs(child, (void *)data);
622 break;
623
624 case PTRACE_GETFPREGS:
625 ret = ptrace_getfpregs(child, (void *)data);
626 break;
627
628 case PTRACE_SETFPREGS:
629 ret = ptrace_setfpregs(child, (void *)data);
630 break;
631
632 default:
633 ret = ptrace_request(child, request, addr, data);
634 break;
635 }
636
637 return ret;
638}
639
640asmlinkage void syscall_trace(int why, struct pt_regs *regs)
641{
642 unsigned long ip;
643
644 if (!test_thread_flag(TIF_SYSCALL_TRACE))
645 return;
646 if (!(current->ptrace & PT_PTRACED))
647 return;
648
649 /*
650 * Save IP. IP is used to denote syscall entry/exit:
651 * IP = 0 -> entry, = 1 -> exit
652 */
653 ip = regs->ARM_ip;
654 regs->ARM_ip = why;
655
656 /* the 0x80 provides a way for the tracing parent to distinguish
657 between a syscall stop and SIGTRAP delivery */
658 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
659 ? 0x80 : 0));
660 /*
661 * this isn't the same as continuing with a signal, but it will do
662 * for normal use. strace only continues with a signal if the
663 * stopping signal is not SIGTRAP. -brl
664 */
665 if (current->exit_code) {
666 send_sig(current->exit_code, current, 1);
667 current->exit_code = 0;
668 }
669 regs->ARM_ip = ip;
670}
diff --git a/arch/arm26/kernel/ptrace.h b/arch/arm26/kernel/ptrace.h
deleted file mode 100644
index 846c9d8d36ed..000000000000
--- a/arch/arm26/kernel/ptrace.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/ptrace.h
3 *
4 * Copyright (C) 2000-2003 Russell King
5 * Copyright (C) 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11extern void ptrace_cancel_bpt(struct task_struct *);
12extern void ptrace_set_bpt(struct task_struct *);
13extern void ptrace_break(struct task_struct *, struct pt_regs *);
diff --git a/arch/arm26/kernel/semaphore.c b/arch/arm26/kernel/semaphore.c
deleted file mode 100644
index 5447a06db3fa..000000000000
--- a/arch/arm26/kernel/semaphore.c
+++ /dev/null
@@ -1,222 +0,0 @@
1/*
2 * ARM semaphore implementation, taken from
3 *
4 * i386 semaphore implementation.
5 *
6 * (C) Copyright 1999 Linus Torvalds
7 * (C) Copyright 2003 Ian Molton (ARM26 mods)
8 *
9 * Modified for ARM by Russell King
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15#include <linux/module.h>
16#include <linux/sched.h>
17#include <linux/errno.h>
18#include <linux/init.h>
19
20#include <asm/semaphore.h>
21
22/*
23 * Semaphores are implemented using a two-way counter:
24 * The "count" variable is decremented for each process
25 * that tries to acquire the semaphore, while the "sleeping"
26 * variable is a count of such acquires.
27 *
28 * Notably, the inline "up()" and "down()" functions can
29 * efficiently test if they need to do any extra work (up
30 * needs to do something only if count was negative before
31 * the increment operation.
32 *
33 * "sleeping" and the contention routine ordering is
34 * protected by the semaphore spinlock.
35 *
36 * Note that these functions are only called when there is
37 * contention on the lock, and as such all this is the
38 * "non-critical" part of the whole semaphore business. The
39 * critical part is the inline stuff in <asm/semaphore.h>
40 * where we want to avoid any extra jumps and calls.
41 */
42
43/*
44 * Logic:
45 * - only on a boundary condition do we need to care. When we go
46 * from a negative count to a non-negative, we wake people up.
47 * - when we go from a non-negative count to a negative do we
48 * (a) synchronize with the "sleeper" count and (b) make sure
49 * that we're on the wakeup list before we synchronize so that
50 * we cannot lose wakeup events.
51 */
52
53void __up(struct semaphore *sem)
54{
55 wake_up(&sem->wait);
56}
57
58static DEFINE_SPINLOCK(semaphore_lock);
59
60void __sched __down(struct semaphore * sem)
61{
62 struct task_struct *tsk = current;
63 DECLARE_WAITQUEUE(wait, tsk);
64 tsk->state = TASK_UNINTERRUPTIBLE;
65 add_wait_queue_exclusive(&sem->wait, &wait);
66
67 spin_lock_irq(&semaphore_lock);
68 sem->sleepers++;
69 for (;;) {
70 int sleepers = sem->sleepers;
71
72 /*
73 * Add "everybody else" into it. They aren't
74 * playing, because we own the spinlock.
75 */
76 if (!atomic_add_negative(sleepers - 1, &sem->count)) {
77 sem->sleepers = 0;
78 break;
79 }
80 sem->sleepers = 1; /* us - see -1 above */
81 spin_unlock_irq(&semaphore_lock);
82
83 schedule();
84 tsk->state = TASK_UNINTERRUPTIBLE;
85 spin_lock_irq(&semaphore_lock);
86 }
87 spin_unlock_irq(&semaphore_lock);
88 remove_wait_queue(&sem->wait, &wait);
89 tsk->state = TASK_RUNNING;
90 wake_up(&sem->wait);
91}
92
93int __sched __down_interruptible(struct semaphore * sem)
94{
95 int retval = 0;
96 struct task_struct *tsk = current;
97 DECLARE_WAITQUEUE(wait, tsk);
98 tsk->state = TASK_INTERRUPTIBLE;
99 add_wait_queue_exclusive(&sem->wait, &wait);
100
101 spin_lock_irq(&semaphore_lock);
102 sem->sleepers ++;
103 for (;;) {
104 int sleepers = sem->sleepers;
105
106 /*
107 * With signals pending, this turns into
108 * the trylock failure case - we won't be
109 * sleeping, and we* can't get the lock as
110 * it has contention. Just correct the count
111 * and exit.
112 */
113 if (signal_pending(current)) {
114 retval = -EINTR;
115 sem->sleepers = 0;
116 atomic_add(sleepers, &sem->count);
117 break;
118 }
119
120 /*
121 * Add "everybody else" into it. They aren't
122 * playing, because we own the spinlock. The
123 * "-1" is because we're still hoping to get
124 * the lock.
125 */
126 if (!atomic_add_negative(sleepers - 1, &sem->count)) {
127 sem->sleepers = 0;
128 break;
129 }
130 sem->sleepers = 1; /* us - see -1 above */
131 spin_unlock_irq(&semaphore_lock);
132
133 schedule();
134 tsk->state = TASK_INTERRUPTIBLE;
135 spin_lock_irq(&semaphore_lock);
136 }
137 spin_unlock_irq(&semaphore_lock);
138 tsk->state = TASK_RUNNING;
139 remove_wait_queue(&sem->wait, &wait);
140 wake_up(&sem->wait);
141 return retval;
142}
143
144/*
145 * Trylock failed - make sure we correct for
146 * having decremented the count.
147 *
148 * We could have done the trylock with a
149 * single "cmpxchg" without failure cases,
150 * but then it wouldn't work on a 386.
151 */
152int __down_trylock(struct semaphore * sem)
153{
154 int sleepers;
155 unsigned long flags;
156
157 spin_lock_irqsave(&semaphore_lock, flags);
158 sleepers = sem->sleepers + 1;
159 sem->sleepers = 0;
160
161 /*
162 * Add "everybody else" and us into it. They aren't
163 * playing, because we own the spinlock.
164 */
165 if (!atomic_add_negative(sleepers, &sem->count))
166 wake_up(&sem->wait);
167
168 spin_unlock_irqrestore(&semaphore_lock, flags);
169 return 1;
170}
171
172/*
173 * The semaphore operations have a special calling sequence that
174 * allow us to do a simpler in-line version of them. These routines
175 * need to convert that sequence back into the C sequence when
176 * there is contention on the semaphore.
177 *
178 * ip contains the semaphore pointer on entry. Save the C-clobbered
179 * registers (r0 to r3 and lr), but not ip, as we use it as a return
180 * value in some cases..
181 */
182asm(" .section .sched.text , #alloc, #execinstr \n\
183 .align 5 \n\
184 .globl __down_failed \n\
185__down_failed: \n\
186 stmfd sp!, {r0 - r3, lr} \n\
187 mov r0, ip \n\
188 bl __down \n\
189 ldmfd sp!, {r0 - r3, pc}^ \n\
190 \n\
191 .align 5 \n\
192 .globl __down_interruptible_failed \n\
193__down_interruptible_failed: \n\
194 stmfd sp!, {r0 - r3, lr} \n\
195 mov r0, ip \n\
196 bl __down_interruptible \n\
197 mov ip, r0 \n\
198 ldmfd sp!, {r0 - r3, pc}^ \n\
199 \n\
200 .align 5 \n\
201 .globl __down_trylock_failed \n\
202__down_trylock_failed: \n\
203 stmfd sp!, {r0 - r3, lr} \n\
204 mov r0, ip \n\
205 bl __down_trylock \n\
206 mov ip, r0 \n\
207 ldmfd sp!, {r0 - r3, pc}^ \n\
208 \n\
209 .align 5 \n\
210 .globl __up_wakeup \n\
211__up_wakeup: \n\
212 stmfd sp!, {r0 - r3, lr} \n\
213 mov r0, ip \n\
214 bl __up \n\
215 ldmfd sp!, {r0 - r3, pc}^ \n\
216 ");
217
218EXPORT_SYMBOL(__down_failed);
219EXPORT_SYMBOL(__down_interruptible_failed);
220EXPORT_SYMBOL(__down_trylock_failed);
221EXPORT_SYMBOL(__up_wakeup);
222
diff --git a/arch/arm26/kernel/setup.c b/arch/arm26/kernel/setup.c
deleted file mode 100644
index 0e006c6cd5a0..000000000000
--- a/arch/arm26/kernel/setup.c
+++ /dev/null
@@ -1,572 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/setup.c
3 *
4 * Copyright (C) 1995-2001 Russell King
5 * Copyright (C) 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/kernel.h>
12#include <linux/stddef.h>
13#include <linux/ioport.h>
14#include <linux/delay.h>
15#include <linux/utsname.h>
16#include <linux/blkdev.h>
17#include <linux/console.h>
18#include <linux/bootmem.h>
19#include <linux/seq_file.h>
20#include <linux/screen_info.h>
21#include <linux/init.h>
22#include <linux/root_dev.h>
23
24#include <asm/elf.h>
25#include <asm/hardware.h>
26#include <asm/io.h>
27#include <asm/procinfo.h>
28#include <asm/setup.h>
29#include <asm/mach-types.h>
30#include <asm/tlbflush.h>
31
32#include <asm/irqchip.h>
33
34#ifndef MEM_SIZE
35#define MEM_SIZE (16*1024*1024)
36#endif
37
38#ifdef CONFIG_PREEMPT
39DEFINE_SPINLOCK(kernel_flag);
40#endif
41
42#if defined(CONFIG_FPE_NWFPE)
43char fpe_type[8];
44
45static int __init fpe_setup(char *line)
46{
47 memcpy(fpe_type, line, 8);
48 return 1;
49}
50
51__setup("fpe=", fpe_setup);
52#endif
53
54extern void paging_init(struct meminfo *);
55extern void convert_to_tag_list(struct tag *tags);
56extern void squash_mem_tags(struct tag *tag);
57extern void bootmem_init(struct meminfo *);
58extern int root_mountflags;
59extern int _stext, _text, _etext, _edata, _end;
60#ifdef CONFIG_XIP_KERNEL
61extern int _endtext, _sdata;
62#endif
63
64
65unsigned int processor_id;
66unsigned int __machine_arch_type;
67unsigned int system_rev;
68unsigned int system_serial_low;
69unsigned int system_serial_high;
70unsigned int elf_hwcap;
71unsigned int memc_ctrl_reg;
72unsigned int number_mfm_drives;
73
74struct processor processor;
75
76char elf_platform[ELF_PLATFORM_SIZE];
77
78unsigned long phys_initrd_start __initdata = 0;
79unsigned long phys_initrd_size __initdata = 0;
80static struct meminfo meminfo __initdata = { 0, };
81static struct proc_info_item proc_info;
82static const char *machine_name;
83static char __initdata command_line[COMMAND_LINE_SIZE];
84
85static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;
86
87/*
88 * Standard memory resources
89 */
90static struct resource mem_res[] = {
91 { "Video RAM", 0, 0, IORESOURCE_MEM },
92 { "Kernel code", 0, 0, IORESOURCE_MEM },
93 { "Kernel data", 0, 0, IORESOURCE_MEM }
94};
95
96#define video_ram mem_res[0]
97#define kernel_code mem_res[1]
98#define kernel_data mem_res[2]
99
100static struct resource io_res[] = {
101 { "reserved", 0x3bc, 0x3be, IORESOURCE_IO | IORESOURCE_BUSY },
102 { "reserved", 0x378, 0x37f, IORESOURCE_IO | IORESOURCE_BUSY },
103 { "reserved", 0x278, 0x27f, IORESOURCE_IO | IORESOURCE_BUSY }
104};
105
106#define lp0 io_res[0]
107#define lp1 io_res[1]
108#define lp2 io_res[2]
109
110#define dump_cpu_info() do { } while (0)
111
112static void __init setup_processor(void)
113{
114 extern struct proc_info_list __proc_info_begin, __proc_info_end;
115 struct proc_info_list *list;
116
117 /*
118 * locate processor in the list of supported processor
119 * types. The linker builds this table for us from the
120 * entries in arch/arm26/mm/proc-*.S
121 */
122 for (list = &__proc_info_begin; list < &__proc_info_end ; list++)
123 if ((processor_id & list->cpu_mask) == list->cpu_val)
124 break;
125
126 /*
127 * If processor type is unrecognised, then we
128 * can do nothing...
129 */
130 if (list >= &__proc_info_end) {
131 printk("CPU configuration botched (ID %08x), unable "
132 "to continue.\n", processor_id);
133 while (1);
134 }
135
136 proc_info = *list->info;
137 processor = *list->proc;
138
139
140 printk("CPU: %s %s revision %d\n",
141 proc_info.manufacturer, proc_info.cpu_name,
142 (int)processor_id & 15);
143
144 dump_cpu_info();
145
146 sprintf(init_utsname()->machine, "%s", list->arch_name);
147 sprintf(elf_platform, "%s", list->elf_name);
148 elf_hwcap = list->elf_hwcap;
149
150 cpu_proc_init();
151}
152
153/*
154 * Initial parsing of the command line. We need to pick out the
155 * memory size. We look for mem=size@start, where start and size
156 * are "size[KkMm]"
157 */
158static void __init
159parse_cmdline(struct meminfo *mi, char **cmdline_p, char *from)
160{
161 char c = ' ', *to = command_line;
162 int usermem = 0, len = 0;
163
164 for (;;) {
165 if (c == ' ' && !memcmp(from, "mem=", 4)) {
166 unsigned long size, start;
167
168 if (to != command_line)
169 to -= 1;
170
171 /*
172 * If the user specifies memory size, we
173 * blow away any automatically generated
174 * size.
175 */
176 if (usermem == 0) {
177 usermem = 1;
178 mi->nr_banks = 0;
179 }
180
181 start = PHYS_OFFSET;
182 size = memparse(from + 4, &from);
183 if (*from == '@')
184 start = memparse(from + 1, &from);
185
186 mi->bank[mi->nr_banks].start = start;
187 mi->bank[mi->nr_banks].size = size;
188 mi->bank[mi->nr_banks].node = PHYS_TO_NID(start);
189 mi->nr_banks += 1;
190 }
191 c = *from++;
192 if (!c)
193 break;
194 if (COMMAND_LINE_SIZE <= ++len)
195 break;
196 *to++ = c;
197 }
198 *to = '\0';
199 *cmdline_p = command_line;
200}
201
202static void __init
203setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
204{
205#ifdef CONFIG_BLK_DEV_RAM
206 extern int rd_size, rd_image_start, rd_prompt, rd_doload;
207
208 rd_image_start = image_start;
209 rd_prompt = prompt;
210 rd_doload = doload;
211
212 if (rd_sz)
213 rd_size = rd_sz;
214#endif
215}
216
217static void __init
218request_standard_resources(struct meminfo *mi)
219{
220 struct resource *res;
221 int i;
222
223 kernel_code.start = init_mm.start_code;
224 kernel_code.end = init_mm.end_code - 1;
225#ifdef CONFIG_XIP_KERNEL
226 kernel_data.start = init_mm.start_data;
227#else
228 kernel_data.start = init_mm.end_code;
229#endif
230 kernel_data.end = init_mm.brk - 1;
231
232 for (i = 0; i < mi->nr_banks; i++) {
233 unsigned long virt_start, virt_end;
234
235 if (mi->bank[i].size == 0)
236 continue;
237
238 virt_start = mi->bank[i].start;
239 virt_end = virt_start + mi->bank[i].size - 1;
240
241 res = alloc_bootmem_low(sizeof(*res));
242 res->name = "System RAM";
243 res->start = virt_start;
244 res->end = virt_end;
245 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
246
247 request_resource(&iomem_resource, res);
248
249 if (kernel_code.start >= res->start &&
250 kernel_code.end <= res->end)
251 request_resource(res, &kernel_code);
252 if (kernel_data.start >= res->start &&
253 kernel_data.end <= res->end)
254 request_resource(res, &kernel_data);
255 }
256
257/* FIXME - needed? if (mdesc->video_start) {
258 video_ram.start = mdesc->video_start;
259 video_ram.end = mdesc->video_end;
260 request_resource(&iomem_resource, &video_ram);
261 }*/
262
263 /*
264 * Some machines don't have the possibility of ever
265 * possessing lp1 or lp2
266 */
267 if (0) /* FIXME - need to do this for A5k at least */
268 request_resource(&ioport_resource, &lp0);
269}
270
271/*
272 * Tag parsing.
273 *
274 * This is the new way of passing data to the kernel at boot time. Rather
275 * than passing a fixed inflexible structure to the kernel, we pass a list
276 * of variable-sized tags to the kernel. The first tag must be a ATAG_CORE
277 * tag for the list to be recognised (to distinguish the tagged list from
278 * a param_struct). The list is terminated with a zero-length tag (this tag
279 * is not parsed in any way).
280 */
281static int __init parse_tag_core(const struct tag *tag)
282{
283 if (tag->hdr.size > 2) {
284 if ((tag->u.core.flags & 1) == 0)
285 root_mountflags &= ~MS_RDONLY;
286 ROOT_DEV = old_decode_dev(tag->u.core.rootdev);
287 }
288 return 0;
289}
290
291__tagtable(ATAG_CORE, parse_tag_core);
292
293static int __init parse_tag_mem32(const struct tag *tag)
294{
295 if (meminfo.nr_banks >= NR_BANKS) {
296 printk(KERN_WARNING
297 "Ignoring memory bank 0x%08x size %dKB\n",
298 tag->u.mem.start, tag->u.mem.size / 1024);
299 return -EINVAL;
300 }
301 meminfo.bank[meminfo.nr_banks].start = tag->u.mem.start;
302 meminfo.bank[meminfo.nr_banks].size = tag->u.mem.size;
303 meminfo.bank[meminfo.nr_banks].node = PHYS_TO_NID(tag->u.mem.start);
304 meminfo.nr_banks += 1;
305
306 return 0;
307}
308
309__tagtable(ATAG_MEM, parse_tag_mem32);
310
311#if defined(CONFIG_DUMMY_CONSOLE)
312struct screen_info screen_info = {
313 .orig_video_lines = 30,
314 .orig_video_cols = 80,
315 .orig_video_mode = 0,
316 .orig_video_ega_bx = 0,
317 .orig_video_isVGA = 1,
318 .orig_video_points = 8
319};
320
321static int __init parse_tag_videotext(const struct tag *tag)
322{
323 screen_info.orig_x = tag->u.videotext.x;
324 screen_info.orig_y = tag->u.videotext.y;
325 screen_info.orig_video_page = tag->u.videotext.video_page;
326 screen_info.orig_video_mode = tag->u.videotext.video_mode;
327 screen_info.orig_video_cols = tag->u.videotext.video_cols;
328 screen_info.orig_video_ega_bx = tag->u.videotext.video_ega_bx;
329 screen_info.orig_video_lines = tag->u.videotext.video_lines;
330 screen_info.orig_video_isVGA = tag->u.videotext.video_isvga;
331 screen_info.orig_video_points = tag->u.videotext.video_points;
332 return 0;
333}
334
335__tagtable(ATAG_VIDEOTEXT, parse_tag_videotext);
336#endif
337
338static int __init parse_tag_acorn(const struct tag *tag)
339{
340 memc_ctrl_reg = tag->u.acorn.memc_control_reg;
341 number_mfm_drives = tag->u.acorn.adfsdrives;
342 return 0;
343}
344
345__tagtable(ATAG_ACORN, parse_tag_acorn);
346
347static int __init parse_tag_ramdisk(const struct tag *tag)
348{
349 setup_ramdisk((tag->u.ramdisk.flags & 1) == 0,
350 (tag->u.ramdisk.flags & 2) == 0,
351 tag->u.ramdisk.start, tag->u.ramdisk.size);
352 return 0;
353}
354
355__tagtable(ATAG_RAMDISK, parse_tag_ramdisk);
356
357static int __init parse_tag_initrd(const struct tag *tag)
358{
359 printk(KERN_WARNING "ATAG_INITRD is deprecated; please update your bootloader. \n");
360 phys_initrd_start = (unsigned long)tag->u.initrd.start;
361 phys_initrd_size = (unsigned long)tag->u.initrd.size;
362 return 0;
363}
364
365__tagtable(ATAG_INITRD, parse_tag_initrd);
366
367static int __init parse_tag_initrd2(const struct tag *tag)
368{
369 printk(KERN_WARNING "ATAG_INITRD is deprecated; please update your bootloader. \n");
370 phys_initrd_start = (unsigned long)tag->u.initrd.start;
371 phys_initrd_size = (unsigned long)tag->u.initrd.size;
372 return 0;
373}
374
375__tagtable(ATAG_INITRD2, parse_tag_initrd2);
376
377static int __init parse_tag_serialnr(const struct tag *tag)
378{
379 system_serial_low = tag->u.serialnr.low;
380 system_serial_high = tag->u.serialnr.high;
381 return 0;
382}
383
384__tagtable(ATAG_SERIAL, parse_tag_serialnr);
385
386static int __init parse_tag_revision(const struct tag *tag)
387{
388 system_rev = tag->u.revision.rev;
389 return 0;
390}
391
392__tagtable(ATAG_REVISION, parse_tag_revision);
393
394static int __init parse_tag_cmdline(const struct tag *tag)
395{
396 strncpy(default_command_line, tag->u.cmdline.cmdline, COMMAND_LINE_SIZE);
397 default_command_line[COMMAND_LINE_SIZE - 1] = '\0';
398 return 0;
399}
400
401__tagtable(ATAG_CMDLINE, parse_tag_cmdline);
402
403/*
404 * Scan the tag table for this tag, and call its parse function.
405 * The tag table is built by the linker from all the __tagtable
406 * declarations.
407 */
408static int __init parse_tag(const struct tag *tag)
409{
410 extern struct tagtable __tagtable_begin, __tagtable_end;
411 struct tagtable *t;
412
413 for (t = &__tagtable_begin; t < &__tagtable_end; t++)
414 if (tag->hdr.tag == t->tag) {
415 t->parse(tag);
416 break;
417 }
418
419 return t < &__tagtable_end;
420}
421
422/*
423 * Parse all tags in the list, checking both the global and architecture
424 * specific tag tables.
425 */
426static void __init parse_tags(const struct tag *t)
427{
428 for (; t->hdr.size; t = tag_next(t))
429 if (!parse_tag(t))
430 printk(KERN_WARNING
431 "Ignoring unrecognised tag 0x%08x\n",
432 t->hdr.tag);
433}
434
435/*
436 * This holds our defaults.
437 */
438static struct init_tags {
439 struct tag_header hdr1;
440 struct tag_core core;
441 struct tag_header hdr2;
442 struct tag_mem32 mem;
443 struct tag_header hdr3;
444} init_tags __initdata = {
445 { tag_size(tag_core), ATAG_CORE },
446 { 1, PAGE_SIZE, 0xff },
447 { tag_size(tag_mem32), ATAG_MEM },
448 { MEM_SIZE, PHYS_OFFSET },
449 { 0, ATAG_NONE }
450};
451
452void __init setup_arch(char **cmdline_p)
453{
454 struct tag *tags = (struct tag *)&init_tags;
455 char *from = default_command_line;
456
457 setup_processor();
458 if(machine_arch_type == MACH_TYPE_A5K)
459 machine_name = "A5000";
460 else if(machine_arch_type == MACH_TYPE_ARCHIMEDES)
461 machine_name = "Archimedes";
462 else
463 machine_name = "UNKNOWN";
464
465 //FIXME - the tag struct is always copied here but this is a block
466 // of RAM that is accidentally reserved along with video RAM. perhaps
467 // it would be a good idea to explicitly reserve this?
468
469 tags = (struct tag *)0x0207c000;
470
471 /*
472 * If we have the old style parameters, convert them to
473 * a tag list.
474 */
475 if (tags->hdr.tag != ATAG_CORE)
476 convert_to_tag_list(tags);
477 if (tags->hdr.tag != ATAG_CORE)
478 tags = (struct tag *)&init_tags;
479 if (tags->hdr.tag == ATAG_CORE) {
480 if (meminfo.nr_banks != 0)
481 squash_mem_tags(tags);
482 parse_tags(tags);
483 }
484
485 init_mm.start_code = (unsigned long) &_text;
486#ifndef CONFIG_XIP_KERNEL
487 init_mm.end_code = (unsigned long) &_etext;
488#else
489 init_mm.end_code = (unsigned long) &_endtext;
490 init_mm.start_data = (unsigned long) &_sdata;
491#endif
492 init_mm.end_data = (unsigned long) &_edata;
493 init_mm.brk = (unsigned long) &_end;
494
495 memcpy(boot_command_line, from, COMMAND_LINE_SIZE);
496 boot_command_line[COMMAND_LINE_SIZE-1] = '\0';
497 parse_cmdline(&meminfo, cmdline_p, from);
498 bootmem_init(&meminfo);
499 paging_init(&meminfo);
500 request_standard_resources(&meminfo);
501
502#ifdef CONFIG_VT
503#if defined(CONFIG_DUMMY_CONSOLE)
504 conswitchp = &dummy_con;
505#endif
506#endif
507}
508
509static const char *hwcap_str[] = {
510 "swp",
511 "half",
512 "thumb",
513 "26bit",
514 "fastmult",
515 "fpa",
516 "vfp",
517 "edsp",
518 NULL
519};
520
521static int c_show(struct seq_file *m, void *v)
522{
523 int i;
524
525 seq_printf(m, "Processor\t: %s %s rev %d (%s)\n",
526 proc_info.manufacturer, proc_info.cpu_name,
527 (int)processor_id & 15, elf_platform);
528
529 seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
530 loops_per_jiffy / (500000/HZ),
531 (loops_per_jiffy / (5000/HZ)) % 100);
532
533 /* dump out the processor features */
534 seq_puts(m, "Features\t: ");
535
536 for (i = 0; hwcap_str[i]; i++)
537 if (elf_hwcap & (1 << i))
538 seq_printf(m, "%s ", hwcap_str[i]);
539
540 seq_puts(m, "\n");
541
542 seq_printf(m, "CPU part\t\t: %07x\n", processor_id >> 4);
543 seq_printf(m, "CPU revision\t: %d\n\n", processor_id & 15);
544 seq_printf(m, "Hardware\t: %s\n", machine_name);
545 seq_printf(m, "Revision\t: %04x\n", system_rev);
546 seq_printf(m, "Serial\t\t: %08x%08x\n",
547 system_serial_high, system_serial_low);
548
549 return 0;
550}
551
552static void *c_start(struct seq_file *m, loff_t *pos)
553{
554 return *pos < 1 ? (void *)1 : NULL;
555}
556
557static void *c_next(struct seq_file *m, void *v, loff_t *pos)
558{
559 ++*pos;
560 return NULL;
561}
562
563static void c_stop(struct seq_file *m, void *v)
564{
565}
566
567struct seq_operations cpuinfo_op = {
568 .start = c_start,
569 .next = c_next,
570 .stop = c_stop,
571 .show = c_show
572};
diff --git a/arch/arm26/kernel/signal.c b/arch/arm26/kernel/signal.c
deleted file mode 100644
index 379b82dc645f..000000000000
--- a/arch/arm26/kernel/signal.c
+++ /dev/null
@@ -1,538 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/signal.c
3 *
4 * Copyright (C) 1995-2002 Russell King
5 * Copyright (C) 2003 Ian Molton (ARM26)
6 *
7 * FIXME!!! This is probably very broken (13/05/2003)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#include <linux/sched.h>
14#include <linux/mm.h>
15#include <linux/smp.h>
16#include <linux/kernel.h>
17#include <linux/errno.h>
18#include <linux/signal.h>
19#include <linux/wait.h>
20#include <linux/ptrace.h>
21#include <linux/personality.h>
22#include <linux/tty.h>
23#include <linux/binfmts.h>
24#include <linux/elf.h>
25
26#include <asm/pgalloc.h>
27#include <asm/ucontext.h>
28#include <asm/uaccess.h>
29#include <asm/unistd.h>
30
31#include "ptrace.h"
32
33#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
34
35/*
36 * For ARM syscalls, we encode the syscall number into the instruction.
37 */
38#define SWI_SYS_SIGRETURN (0xef000000|(__NR_sigreturn))
39#define SWI_SYS_RT_SIGRETURN (0xef000000|(__NR_rt_sigreturn))
40
41static int do_signal(sigset_t *oldset, struct pt_regs * regs, int syscall);
42
43/*
44 * atomically swap in the new signal mask, and wait for a signal.
45 */
46asmlinkage int sys_sigsuspend(int restart, unsigned long oldmask, old_sigset_t mask, struct pt_regs *regs)
47{
48 sigset_t saveset;
49
50 mask &= _BLOCKABLE;
51 spin_lock_irq(&current->sighand->siglock);
52 saveset = current->blocked;
53 siginitset(&current->blocked, mask);
54 recalc_sigpending();
55 spin_unlock_irq(&current->sighand->siglock);
56 regs->ARM_r0 = -EINTR;
57
58 while (1) {
59 current->state = TASK_INTERRUPTIBLE;
60 schedule();
61 if (do_signal(&saveset, regs, 0))
62 return regs->ARM_r0;
63 }
64}
65
66asmlinkage int
67sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize, struct pt_regs *regs)
68{
69 sigset_t saveset, newset;
70
71 /* XXX: Don't preclude handling different sized sigset_t's. */
72 if (sigsetsize != sizeof(sigset_t))
73 return -EINVAL;
74
75 if (copy_from_user(&newset, unewset, sizeof(newset)))
76 return -EFAULT;
77 sigdelsetmask(&newset, ~_BLOCKABLE);
78
79 spin_lock_irq(&current->sighand->siglock);
80 saveset = current->blocked;
81 current->blocked = newset;
82 recalc_sigpending();
83 spin_unlock_irq(&current->sighand->siglock);
84 regs->ARM_r0 = -EINTR;
85
86 while (1) {
87 current->state = TASK_INTERRUPTIBLE;
88 schedule();
89 if (do_signal(&saveset, regs, 0))
90 return regs->ARM_r0;
91 }
92}
93
94asmlinkage int
95sys_sigaction(int sig, const struct old_sigaction *act,
96 struct old_sigaction *oact)
97{
98 struct k_sigaction new_ka, old_ka;
99 int ret;
100
101 if (act) {
102 old_sigset_t mask;
103 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
104 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
105 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
106 return -EFAULT;
107 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
108 __get_user(mask, &act->sa_mask);
109 siginitset(&new_ka.sa.sa_mask, mask);
110 }
111
112 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
113
114 if (!ret && oact) {
115 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
116 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
117 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
118 return -EFAULT;
119 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
120 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
121 }
122
123 return ret;
124}
125
126/*
127 * Do a signal return; undo the signal stack.
128 */
129struct sigframe
130{
131 struct sigcontext sc;
132 unsigned long extramask[_NSIG_WORDS-1];
133 unsigned long retcode;
134};
135
136struct rt_sigframe
137{
138 struct siginfo *pinfo;
139 void *puc;
140 struct siginfo info;
141 struct ucontext uc;
142 unsigned long retcode;
143};
144
145static int
146restore_sigcontext(struct pt_regs *regs, struct sigcontext *sc)
147{
148 int err = 0;
149
150 __get_user_error(regs->ARM_r0, &sc->arm_r0, err);
151 __get_user_error(regs->ARM_r1, &sc->arm_r1, err);
152 __get_user_error(regs->ARM_r2, &sc->arm_r2, err);
153 __get_user_error(regs->ARM_r3, &sc->arm_r3, err);
154 __get_user_error(regs->ARM_r4, &sc->arm_r4, err);
155 __get_user_error(regs->ARM_r5, &sc->arm_r5, err);
156 __get_user_error(regs->ARM_r6, &sc->arm_r6, err);
157 __get_user_error(regs->ARM_r7, &sc->arm_r7, err);
158 __get_user_error(regs->ARM_r8, &sc->arm_r8, err);
159 __get_user_error(regs->ARM_r9, &sc->arm_r9, err);
160 __get_user_error(regs->ARM_r10, &sc->arm_r10, err);
161 __get_user_error(regs->ARM_fp, &sc->arm_fp, err);
162 __get_user_error(regs->ARM_ip, &sc->arm_ip, err);
163 __get_user_error(regs->ARM_sp, &sc->arm_sp, err);
164 __get_user_error(regs->ARM_lr, &sc->arm_lr, err);
165 __get_user_error(regs->ARM_pc, &sc->arm_pc, err);
166
167 err |= !valid_user_regs(regs);
168
169 return err;
170}
171
172asmlinkage int sys_sigreturn(struct pt_regs *regs)
173{
174 struct sigframe *frame;
175 sigset_t set;
176
177 /*
178 * Since we stacked the signal on a 64-bit boundary,
179 * then 'sp' should be word aligned here. If it's
180 * not, then the user is trying to mess with us.
181 */
182 if (regs->ARM_sp & 7)
183 goto badframe;
184
185 frame = (struct sigframe *)regs->ARM_sp;
186
187 if (!access_ok(VERIFY_READ, frame, sizeof (*frame)))
188 goto badframe;
189 if (__get_user(set.sig[0], &frame->sc.oldmask)
190 || (_NSIG_WORDS > 1
191 && __copy_from_user(&set.sig[1], &frame->extramask,
192 sizeof(frame->extramask))))
193 goto badframe;
194
195 sigdelsetmask(&set, ~_BLOCKABLE);
196 spin_lock_irq(&current->sighand->siglock);
197 current->blocked = set;
198 recalc_sigpending();
199 spin_unlock_irq(&current->sighand->siglock);
200
201 if (restore_sigcontext(regs, &frame->sc))
202 goto badframe;
203
204 /* Send SIGTRAP if we're single-stepping */
205 if (current->ptrace & PT_SINGLESTEP) {
206 ptrace_cancel_bpt(current);
207 send_sig(SIGTRAP, current, 1);
208 }
209
210 return regs->ARM_r0;
211
212badframe:
213 force_sig(SIGSEGV, current);
214 return 0;
215}
216
217asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
218{
219 struct rt_sigframe *frame;
220 sigset_t set;
221
222 /*
223 * Since we stacked the signal on a 64-bit boundary,
224 * then 'sp' should be word aligned here. If it's
225 * not, then the user is trying to mess with us.
226 */
227 if (regs->ARM_sp & 7)
228 goto badframe;
229
230 frame = (struct rt_sigframe *)regs->ARM_sp;
231
232 if (!access_ok(VERIFY_READ, frame, sizeof (*frame)))
233 goto badframe;
234 if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
235 goto badframe;
236
237 sigdelsetmask(&set, ~_BLOCKABLE);
238 spin_lock_irq(&current->sighand->siglock);
239 current->blocked = set;
240 recalc_sigpending();
241 spin_unlock_irq(&current->sighand->siglock);
242
243 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
244 goto badframe;
245
246 /* Send SIGTRAP if we're single-stepping */
247 if (current->ptrace & PT_SINGLESTEP) {
248 ptrace_cancel_bpt(current);
249 send_sig(SIGTRAP, current, 1);
250 }
251
252 return regs->ARM_r0;
253
254badframe:
255 force_sig(SIGSEGV, current);
256 return 0;
257}
258
259static int
260setup_sigcontext(struct sigcontext *sc, /*struct _fpstate *fpstate,*/
261 struct pt_regs *regs, unsigned long mask)
262{
263 int err = 0;
264
265 __put_user_error(regs->ARM_r0, &sc->arm_r0, err);
266 __put_user_error(regs->ARM_r1, &sc->arm_r1, err);
267 __put_user_error(regs->ARM_r2, &sc->arm_r2, err);
268 __put_user_error(regs->ARM_r3, &sc->arm_r3, err);
269 __put_user_error(regs->ARM_r4, &sc->arm_r4, err);
270 __put_user_error(regs->ARM_r5, &sc->arm_r5, err);
271 __put_user_error(regs->ARM_r6, &sc->arm_r6, err);
272 __put_user_error(regs->ARM_r7, &sc->arm_r7, err);
273 __put_user_error(regs->ARM_r8, &sc->arm_r8, err);
274 __put_user_error(regs->ARM_r9, &sc->arm_r9, err);
275 __put_user_error(regs->ARM_r10, &sc->arm_r10, err);
276 __put_user_error(regs->ARM_fp, &sc->arm_fp, err);
277 __put_user_error(regs->ARM_ip, &sc->arm_ip, err);
278 __put_user_error(regs->ARM_sp, &sc->arm_sp, err);
279 __put_user_error(regs->ARM_lr, &sc->arm_lr, err);
280 __put_user_error(regs->ARM_pc, &sc->arm_pc, err);
281
282 __put_user_error(current->thread.trap_no, &sc->trap_no, err);
283 __put_user_error(current->thread.error_code, &sc->error_code, err);
284 __put_user_error(current->thread.address, &sc->fault_address, err);
285 __put_user_error(mask, &sc->oldmask, err);
286
287 return err;
288}
289
290static inline void *
291get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, int framesize)
292{
293 unsigned long sp = regs->ARM_sp;
294
295 /*
296 * This is the X/Open sanctioned signal stack switching.
297 */
298 if ((ka->sa.sa_flags & SA_ONSTACK) && !sas_ss_flags(sp))
299 sp = current->sas_ss_sp + current->sas_ss_size;
300
301 /*
302 * ATPCS B01 mandates 8-byte alignment
303 */
304 return (void *)((sp - framesize) & ~7);
305}
306
307static int
308setup_return(struct pt_regs *regs, struct k_sigaction *ka,
309 unsigned long *rc, void *frame, int usig)
310{
311 unsigned long handler = (unsigned long)ka->sa.sa_handler;
312 unsigned long retcode;
313
314 if (ka->sa.sa_flags & SA_RESTORER) {
315 retcode = (unsigned long)ka->sa.sa_restorer;
316 } else {
317
318 if (__put_user((ka->sa.sa_flags & SA_SIGINFO)?SWI_SYS_RT_SIGRETURN:SWI_SYS_SIGRETURN, rc))
319 return 1;
320
321 retcode = ((unsigned long)rc);
322 }
323
324 regs->ARM_r0 = usig;
325 regs->ARM_sp = (unsigned long)frame;
326 regs->ARM_lr = retcode;
327 regs->ARM_pc = handler & ~3;
328
329 return 0;
330}
331
332static int
333setup_frame(int usig, struct k_sigaction *ka, sigset_t *set, struct pt_regs *regs)
334{
335 struct sigframe *frame = get_sigframe(ka, regs, sizeof(*frame));
336 int err = 0;
337
338 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
339 return 1;
340
341 err |= setup_sigcontext(&frame->sc, /*&frame->fpstate,*/ regs, set->sig[0]);
342
343 if (_NSIG_WORDS > 1) {
344 err |= __copy_to_user(frame->extramask, &set->sig[1],
345 sizeof(frame->extramask));
346 }
347
348 if (err == 0)
349 err = setup_return(regs, ka, &frame->retcode, frame, usig);
350
351 return err;
352}
353
354static int
355setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
356 sigset_t *set, struct pt_regs *regs)
357{
358 struct rt_sigframe *frame = get_sigframe(ka, regs, sizeof(*frame));
359 int err = 0;
360
361 if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
362 return 1;
363
364 __put_user_error(&frame->info, &frame->pinfo, err);
365 __put_user_error(&frame->uc, &frame->puc, err);
366 err |= copy_siginfo_to_user(&frame->info, info);
367
368 /* Clear all the bits of the ucontext we don't use. */
369 err |= __clear_user(&frame->uc, offsetof(struct ucontext, uc_mcontext));
370
371 err |= setup_sigcontext(&frame->uc.uc_mcontext, /*&frame->fpstate,*/
372 regs, set->sig[0]);
373 err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
374
375 if (err == 0)
376 err = setup_return(regs, ka, &frame->retcode, frame, usig);
377
378 if (err == 0) {
379 /*
380 * For realtime signals we must also set the second and third
381 * arguments for the signal handler.
382 * -- Peter Maydell <pmaydell@chiark.greenend.org.uk> 2000-12-06
383 */
384 regs->ARM_r1 = (unsigned long)frame->pinfo;
385 regs->ARM_r2 = (unsigned long)frame->puc;
386 }
387
388 return err;
389}
390
391static inline void restart_syscall(struct pt_regs *regs)
392{
393 regs->ARM_r0 = regs->ARM_ORIG_r0;
394 regs->ARM_pc -= 4;
395}
396
397/*
398 * OK, we're invoking a handler
399 */
400static void
401handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset,
402 struct pt_regs * regs, int syscall)
403{
404 struct thread_info *thread = current_thread_info();
405 struct task_struct *tsk = current;
406 struct k_sigaction *ka = &tsk->sighand->action[sig-1];
407 int usig = sig;
408 int ret;
409
410 /*
411 * If we were from a system call, check for system call restarting...
412 */
413 if (syscall) {
414 switch (regs->ARM_r0) {
415 case -ERESTART_RESTARTBLOCK:
416 current_thread_info()->restart_block.fn =
417 do_no_restart_syscall;
418 case -ERESTARTNOHAND:
419 regs->ARM_r0 = -EINTR;
420 break;
421 case -ERESTARTSYS:
422 if (!(ka->sa.sa_flags & SA_RESTART)) {
423 regs->ARM_r0 = -EINTR;
424 break;
425 }
426 /* fallthrough */
427 case -ERESTARTNOINTR:
428 restart_syscall(regs);
429 }
430 }
431
432 /*
433 * translate the signal
434 */
435 if (usig < 32 && thread->exec_domain && thread->exec_domain->signal_invmap)
436 usig = thread->exec_domain->signal_invmap[usig];
437
438 /*
439 * Set up the stack frame
440 */
441 if (ka->sa.sa_flags & SA_SIGINFO)
442 ret = setup_rt_frame(usig, ka, info, oldset, regs);
443 else
444 ret = setup_frame(usig, ka, oldset, regs);
445
446 /*
447 * Check that the resulting registers are actually sane.
448 */
449 ret |= !valid_user_regs(regs);
450
451 if (ret == 0) {
452 if (ka->sa.sa_flags & SA_ONESHOT)
453 ka->sa.sa_handler = SIG_DFL;
454
455 spin_lock_irq(&tsk->sighand->siglock);
456 sigorsets(&tsk->blocked, &tsk->blocked,
457 &ka->sa.sa_mask);
458 if (!(ka->sa.sa_flags & SA_NODEFER))
459 sigaddset(&tsk->blocked, sig);
460 recalc_sigpending();
461 spin_unlock_irq(&tsk->sighand->siglock);
462 return;
463 }
464
465 force_sigsegv(sig, tsk);
466}
467
468/*
469 * Note that 'init' is a special process: it doesn't get signals it doesn't
470 * want to handle. Thus you cannot kill init even with a SIGKILL even by
471 * mistake.
472 *
473 * Note that we go through the signals twice: once to check the signals that
474 * the kernel can handle, and then we build all the user-level signal handling
475 * stack-frames in one go after that.
476 */
477static int do_signal(sigset_t *oldset, struct pt_regs *regs, int syscall)
478{
479 siginfo_t info;
480 int signr;
481 struct k_sigaction ka;
482
483 /*
484 * We want the common case to go fast, which
485 * is why we may in certain cases get here from
486 * kernel mode. Just return without doing anything
487 * if so.
488 */
489 if (!user_mode(regs))
490 return 0;
491
492 if (current->ptrace & PT_SINGLESTEP)
493 ptrace_cancel_bpt(current);
494
495 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
496 if (signr > 0) {
497 handle_signal(signr, &info, oldset, regs, syscall);
498 if (current->ptrace & PT_SINGLESTEP)
499 ptrace_set_bpt(current);
500 return 1;
501 }
502
503 /*
504 * No signal to deliver to the process - restart the syscall.
505 */
506 if (syscall) {
507 if (regs->ARM_r0 == -ERESTART_RESTARTBLOCK) {
508 u32 *usp;
509
510 regs->ARM_sp -= 12;
511 usp = (u32 *)regs->ARM_sp;
512
513 put_user(regs->ARM_pc, &usp[0]);
514 /* swi __NR_restart_syscall */
515 put_user(0xef000000 | __NR_restart_syscall, &usp[1]);
516 /* ldr pc, [sp], #12 */
517// FIXME!!! is #12 correct there?
518 put_user(0xe49df00c, &usp[2]);
519
520 regs->ARM_pc = regs->ARM_sp + 4;
521 }
522 if (regs->ARM_r0 == -ERESTARTNOHAND ||
523 regs->ARM_r0 == -ERESTARTSYS ||
524 regs->ARM_r0 == -ERESTARTNOINTR) {
525 restart_syscall(regs);
526 }
527 }
528 if (current->ptrace & PT_SINGLESTEP)
529 ptrace_set_bpt(current);
530 return 0;
531}
532
533asmlinkage void
534do_notify_resume(struct pt_regs *regs, unsigned int thread_flags, int syscall)
535{
536 if (thread_flags & _TIF_SIGPENDING)
537 do_signal(&current->blocked, regs, syscall);
538}
diff --git a/arch/arm26/kernel/sys_arm.c b/arch/arm26/kernel/sys_arm.c
deleted file mode 100644
index dc05aba58baf..000000000000
--- a/arch/arm26/kernel/sys_arm.c
+++ /dev/null
@@ -1,323 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/sys_arm.c
3 *
4 * Copyright (C) People who wrote linux/arch/i386/kernel/sys_i386.c
5 * Copyright (C) 1995, 1996 Russell King.
6 * Copyright (C) 2003 Ian Molton.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This file contains various random system calls that
13 * have a non-standard calling sequence on the Linux/arm
14 * platform.
15 */
16#include <linux/module.h>
17#include <linux/errno.h>
18#include <linux/sched.h>
19#include <linux/slab.h>
20#include <linux/mm.h>
21#include <linux/sem.h>
22#include <linux/msg.h>
23#include <linux/shm.h>
24#include <linux/stat.h>
25#include <linux/syscalls.h>
26#include <linux/mman.h>
27#include <linux/fs.h>
28#include <linux/file.h>
29#include <linux/utsname.h>
30
31#include <asm/uaccess.h>
32#include <asm/ipc.h>
33
34extern unsigned long do_mremap(unsigned long addr, unsigned long old_len,
35 unsigned long new_len, unsigned long flags,
36 unsigned long new_addr);
37
38/*
39 * sys_pipe() is the normal C calling standard for creating
40 * a pipe. It's not the way unix traditionally does this, though.
41 */
42asmlinkage int sys_pipe(unsigned long * fildes)
43{
44 int fd[2];
45 int error;
46
47 error = do_pipe(fd);
48 if (!error) {
49 if (copy_to_user(fildes, fd, 2*sizeof(int)))
50 error = -EFAULT;
51 }
52 return error;
53}
54
55/* common code for old and new mmaps */
56inline long do_mmap2(
57 unsigned long addr, unsigned long len,
58 unsigned long prot, unsigned long flags,
59 unsigned long fd, unsigned long pgoff)
60{
61 int error = -EINVAL;
62 struct file * file = NULL;
63
64 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
65
66 /*
67 * If we are doing a fixed mapping, and address < FIRST_USER_ADDRESS,
68 * then deny it.
69 */
70 if (flags & MAP_FIXED && addr < FIRST_USER_ADDRESS)
71 goto out;
72
73 error = -EBADF;
74 if (!(flags & MAP_ANONYMOUS)) {
75 file = fget(fd);
76 if (!file)
77 goto out;
78 }
79
80 down_write(&current->mm->mmap_sem);
81 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
82 up_write(&current->mm->mmap_sem);
83
84 if (file)
85 fput(file);
86out:
87 return error;
88}
89
90struct mmap_arg_struct {
91 unsigned long addr;
92 unsigned long len;
93 unsigned long prot;
94 unsigned long flags;
95 unsigned long fd;
96 unsigned long offset;
97};
98
99asmlinkage int old_mmap(struct mmap_arg_struct *arg)
100{
101 int error = -EFAULT;
102 struct mmap_arg_struct a;
103
104 if (copy_from_user(&a, arg, sizeof(a)))
105 goto out;
106
107 error = -EINVAL;
108 if (a.offset & ~PAGE_MASK)
109 goto out;
110
111 error = do_mmap2(a.addr, a.len, a.prot, a.flags, a.fd, a.offset >> PAGE_SHIFT);
112out:
113 return error;
114}
115
116asmlinkage unsigned long
117sys_arm_mremap(unsigned long addr, unsigned long old_len,
118 unsigned long new_len, unsigned long flags,
119 unsigned long new_addr)
120{
121 unsigned long ret = -EINVAL;
122
123 /*
124 * If we are doing a fixed mapping, and address < FIRST_USER_ADDRESS,
125 * then deny it.
126 */
127 if (flags & MREMAP_FIXED && new_addr < FIRST_USER_ADDRESS)
128 goto out;
129
130 down_write(&current->mm->mmap_sem);
131 ret = do_mremap(addr, old_len, new_len, flags, new_addr);
132 up_write(&current->mm->mmap_sem);
133
134out:
135 return ret;
136}
137
138/*
139 * Perform the select(nd, in, out, ex, tv) and mmap() system
140 * calls.
141 */
142
143struct sel_arg_struct {
144 unsigned long n;
145 fd_set *inp, *outp, *exp;
146 struct timeval *tvp;
147};
148
149asmlinkage int old_select(struct sel_arg_struct *arg)
150{
151 struct sel_arg_struct a;
152
153 if (copy_from_user(&a, arg, sizeof(a)))
154 return -EFAULT;
155 /* sys_select() does the appropriate kernel locking */
156 return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
157}
158
159/*
160 * sys_ipc() is the de-multiplexer for the SysV IPC calls..
161 *
162 * This is really horribly ugly.
163 */
164asmlinkage int sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)
165{
166 int version, ret;
167
168 version = call >> 16; /* hack for backward compatibility */
169 call &= 0xffff;
170
171 switch (call) {
172 case SEMOP:
173 return sys_semop (first, (struct sembuf *)ptr, second);
174 case SEMGET:
175 return sys_semget (first, second, third);
176 case SEMCTL: {
177 union semun fourth;
178 if (!ptr)
179 return -EINVAL;
180 if (get_user(fourth.__pad, (void **) ptr))
181 return -EFAULT;
182 return sys_semctl (first, second, third, fourth);
183 }
184
185 case MSGSND:
186 return sys_msgsnd (first, (struct msgbuf *) ptr,
187 second, third);
188 case MSGRCV:
189 switch (version) {
190 case 0: {
191 struct ipc_kludge tmp;
192 if (!ptr)
193 return -EINVAL;
194 if (copy_from_user(&tmp,(struct ipc_kludge *) ptr,
195 sizeof (tmp)))
196 return -EFAULT;
197 return sys_msgrcv (first, tmp.msgp, second,
198 tmp.msgtyp, third);
199 }
200 default:
201 return sys_msgrcv (first,
202 (struct msgbuf *) ptr,
203 second, fifth, third);
204 }
205 case MSGGET:
206 return sys_msgget ((key_t) first, second);
207 case MSGCTL:
208 return sys_msgctl (first, second, (struct msqid_ds *) ptr);
209
210 case SHMAT:
211 switch (version) {
212 default: {
213 ulong raddr;
214 ret = do_shmat (first, (char *) ptr, second, &raddr);
215 if (ret)
216 return ret;
217 return put_user (raddr, (ulong *) third);
218 }
219 case 1: /* iBCS2 emulator entry point */
220 if (!segment_eq(get_fs(), get_ds()))
221 return -EINVAL;
222 return do_shmat (first, (char *) ptr,
223 second, (ulong *) third);
224 }
225 case SHMDT:
226 return sys_shmdt ((char *)ptr);
227 case SHMGET:
228 return sys_shmget (first, second, third);
229 case SHMCTL:
230 return sys_shmctl (first, second,
231 (struct shmid_ds *) ptr);
232 default:
233 return -EINVAL;
234 }
235}
236
237/* Fork a new task - this creates a new program thread.
238 * This is called indirectly via a small wrapper
239 */
240asmlinkage int sys_fork(struct pt_regs *regs)
241{
242 return do_fork(SIGCHLD, regs->ARM_sp, regs, 0, NULL, NULL);
243}
244
245/* Clone a task - this clones the calling program thread.
246 * This is called indirectly via a small wrapper
247 */
248asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, struct pt_regs *regs)
249{
250 /*
251 * We don't support SETTID / CLEARTID (FIXME!!! (nicked from arm32))
252 */
253 if (clone_flags & (CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID))
254 return -EINVAL;
255
256 if (!newsp)
257 newsp = regs->ARM_sp;
258
259 return do_fork(clone_flags, newsp, regs, 0, NULL, NULL);
260}
261
262asmlinkage int sys_vfork(struct pt_regs *regs)
263{
264 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->ARM_sp, regs, 0, NULL, NULL);
265}
266
267/* sys_execve() executes a new program.
268 * This is called indirectly via a small wrapper
269 */
270asmlinkage int sys_execve(char *filenamei, char **argv, char **envp, struct pt_regs *regs)
271{
272 int error;
273 char * filename;
274
275 filename = getname(filenamei);
276 error = PTR_ERR(filename);
277 if (IS_ERR(filename))
278 goto out;
279 error = do_execve(filename, argv, envp, regs);
280 putname(filename);
281out:
282 return error;
283}
284
285/* FIXME - see if this is correct for arm26 */
286int kernel_execve(const char *filename, char *const argv[], char *const envp[])
287{
288 struct pt_regs regs;
289 int ret;
290 memset(&regs, 0, sizeof(struct pt_regs));
291 ret = do_execve((char *)filename, (char __user * __user *)argv, (char __user * __user *)envp, &regs);
292 if (ret < 0)
293 goto out;
294
295 /*
296 * Save argc to the register structure for userspace.
297 */
298 regs.ARM_r0 = ret;
299
300 /*
301 * We were successful. We won't be returning to our caller, but
302 * instead to user space by manipulating the kernel stack.
303 */
304 asm( "add r0, %0, %1\n\t"
305 "mov r1, %2\n\t"
306 "mov r2, %3\n\t"
307 "bl memmove\n\t" /* copy regs to top of stack */
308 "mov r8, #0\n\t" /* not a syscall */
309 "mov r9, %0\n\t" /* thread structure */
310 "mov sp, r0\n\t" /* reposition stack pointer */
311 "b ret_to_user"
312 :
313 : "r" (current_thread_info()),
314 "Ir" (THREAD_SIZE - 8 - sizeof(regs)),
315 "r" (&regs),
316 "Ir" (sizeof(regs))
317 : "r0", "r1", "r2", "r3", "ip", "memory");
318
319 out:
320 return ret;
321}
322
323EXPORT_SYMBOL(kernel_execve);
diff --git a/arch/arm26/kernel/time.c b/arch/arm26/kernel/time.c
deleted file mode 100644
index 0f1d57fbd3d7..000000000000
--- a/arch/arm26/kernel/time.c
+++ /dev/null
@@ -1,210 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/time.c
3 *
4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
5 * Modifications for ARM (C) 1994-2001 Russell King
6 * Mods for ARM26 (C) 2003 Ian Molton
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This file contains the ARM-specific time handling details:
13 * reading the RTC at bootup, etc...
14 *
15 * 1994-07-02 Alan Modra
16 * fixed set_rtc_mmss, fixed time.year for >= 2000, new mktime
17 * 1998-12-20 Updated NTP code according to technical memorandum Jan '96
18 * "A Kernel Model for Precision Timekeeping" by Dave Mills
19 */
20
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/interrupt.h>
24#include <linux/time.h>
25#include <linux/init.h>
26#include <linux/smp.h>
27#include <linux/timex.h>
28#include <linux/errno.h>
29#include <linux/profile.h>
30
31#include <asm/hardware.h>
32#include <asm/io.h>
33#include <asm/irq.h>
34#include <asm/ioc.h>
35
36/* this needs a better home */
37DEFINE_SPINLOCK(rtc_lock);
38
39/* change this if you have some constant time drift */
40#define USECS_PER_JIFFY (1000000/HZ)
41
42static int dummy_set_rtc(void)
43{
44 return 0;
45}
46
47/*
48 * hook for setting the RTC's idea of the current time.
49 */
50int (*set_rtc)(void) = dummy_set_rtc;
51
52/*
53 * Get time offset based on IOCs timer.
54 * FIXME - if this is called with interrutps off, why the shennanigans
55 * below ?
56 */
57static unsigned long gettimeoffset(void)
58{
59 unsigned int count1, count2, status;
60 long offset;
61
62 ioc_writeb (0, IOC_T0LATCH);
63 barrier ();
64 count1 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
65 barrier ();
66 status = ioc_readb(IOC_IRQREQA);
67 barrier ();
68 ioc_writeb (0, IOC_T0LATCH);
69 barrier ();
70 count2 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8);
71
72 offset = count2;
73 if (count2 < count1) {
74 /*
75 * We have not had an interrupt between reading count1
76 * and count2.
77 */
78 if (status & (1 << 5))
79 offset -= LATCH;
80 } else if (count2 > count1) {
81 /*
82 * We have just had another interrupt between reading
83 * count1 and count2.
84 */
85 offset -= LATCH;
86 }
87
88 offset = (LATCH - offset) * (tick_nsec / 1000);
89 return (offset + LATCH/2) / LATCH;
90}
91
92static unsigned long next_rtc_update;
93
94/*
95 * If we have an externally synchronized linux clock, then update
96 * CMOS clock accordingly every ~11 minutes. set_rtc() has to be
97 * called as close as possible to 500 ms before the new second
98 * starts.
99 */
100static inline void do_set_rtc(void)
101{
102 if (!ntp_synced() || set_rtc == NULL)
103 return;
104
105//FIXME - timespec.tv_sec is a time_t not unsigned long
106 if (next_rtc_update &&
107 time_before((unsigned long)xtime.tv_sec, next_rtc_update))
108 return;
109
110 if (xtime.tv_nsec < 500000000 - ((unsigned) tick_nsec >> 1) &&
111 xtime.tv_nsec >= 500000000 + ((unsigned) tick_nsec >> 1))
112 return;
113
114 if (set_rtc())
115 /*
116 * rtc update failed. Try again in 60s
117 */
118 next_rtc_update = xtime.tv_sec + 60;
119 else
120 next_rtc_update = xtime.tv_sec + 660;
121}
122
123#define do_leds()
124
125void do_gettimeofday(struct timeval *tv)
126{
127 unsigned long flags;
128 unsigned long seq;
129 unsigned long usec, sec;
130
131 do {
132 seq = read_seqbegin_irqsave(&xtime_lock, flags);
133 usec = gettimeoffset();
134 sec = xtime.tv_sec;
135 usec += xtime.tv_nsec / 1000;
136 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
137
138 /* usec may have gone up a lot: be safe */
139 while (usec >= 1000000) {
140 usec -= 1000000;
141 sec++;
142 }
143
144 tv->tv_sec = sec;
145 tv->tv_usec = usec;
146}
147
148EXPORT_SYMBOL(do_gettimeofday);
149
150int do_settimeofday(struct timespec *tv)
151{
152 if ((unsigned long)tv->tv_nsec >= NSEC_PER_SEC)
153 return -EINVAL;
154
155 write_seqlock_irq(&xtime_lock);
156 /*
157 * This is revolting. We need to set "xtime" correctly. However, the
158 * value in this location is the value at the most recent update of
159 * wall time. Discover what correction gettimeofday() would have
160 * done, and then undo it!
161 */
162 tv->tv_nsec -= 1000 * gettimeoffset();
163
164 while (tv->tv_nsec < 0) {
165 tv->tv_nsec += NSEC_PER_SEC;
166 tv->tv_sec--;
167 }
168
169 xtime.tv_sec = tv->tv_sec;
170 xtime.tv_nsec = tv->tv_nsec;
171 ntp_clear();
172 write_sequnlock_irq(&xtime_lock);
173 clock_was_set();
174 return 0;
175}
176
177EXPORT_SYMBOL(do_settimeofday);
178
179static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
180{
181 do_timer(1);
182#ifndef CONFIG_SMP
183 update_process_times(user_mode(regs));
184#endif
185 do_set_rtc(); //FIME - EVERY timer IRQ?
186 profile_tick(CPU_PROFILING, regs);
187 return IRQ_HANDLED; //FIXME - is this right?
188}
189
190static struct irqaction timer_irq = {
191 .name = "timer",
192 .flags = IRQF_DISABLED,
193 .handler = timer_interrupt,
194};
195
196extern void ioctime_init(void);
197
198/*
199 * Set up timer interrupt.
200 */
201void __init time_init(void)
202{
203 ioc_writeb(LATCH & 255, IOC_T0LTCHL);
204 ioc_writeb(LATCH >> 8, IOC_T0LTCHH);
205 ioc_writeb(0, IOC_T0GO);
206
207
208 setup_irq(IRQ_TIMER, &timer_irq);
209}
210
diff --git a/arch/arm26/kernel/traps.c b/arch/arm26/kernel/traps.c
deleted file mode 100644
index 2911e2eae80e..000000000000
--- a/arch/arm26/kernel/traps.c
+++ /dev/null
@@ -1,548 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/traps.c
3 *
4 * Copyright (C) 1995-2002 Russell King
5 * Fragments that appear the same as linux/arch/i386/kernel/traps.c (C) Linus Torvalds
6 * Copyright (C) 2003 Ian Molton (ARM26)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * 'traps.c' handles hardware exceptions after we have saved some state in
13 * 'linux/arch/arm26/lib/traps.S'. Mostly a debugging aid, but will probably
14 * kill the offending process.
15 */
16
17#include <linux/module.h>
18#include <linux/types.h>
19#include <linux/kernel.h>
20#include <linux/signal.h>
21#include <linux/sched.h>
22#include <linux/mm.h>
23#include <linux/spinlock.h>
24#include <linux/personality.h>
25#include <linux/ptrace.h>
26#include <linux/elf.h>
27#include <linux/interrupt.h>
28#include <linux/init.h>
29
30#include <asm/atomic.h>
31#include <asm/io.h>
32#include <asm/pgtable.h>
33#include <asm/system.h>
34#include <asm/uaccess.h>
35#include <asm/unistd.h>
36#include <linux/mutex.h>
37
38#include "ptrace.h"
39
40extern void c_backtrace (unsigned long fp, int pmode);
41extern void show_pte(struct mm_struct *mm, unsigned long addr);
42
43const char *processor_modes[] = { "USER_26", "FIQ_26" , "IRQ_26" , "SVC_26" };
44
45static const char *handler[]= { "prefetch abort", "data abort", "address exception", "interrupt" "*bad reason*"};
46
47/*
48 * Stack pointers should always be within the kernels view of
49 * physical memory. If it is not there, then we can't dump
50 * out any information relating to the stack.
51 */
52static int verify_stack(unsigned long sp)
53{
54 if (sp < PAGE_OFFSET || (sp > (unsigned long)high_memory && high_memory != 0))
55 return -EFAULT;
56
57 return 0;
58}
59
60/*
61 * Dump out the contents of some memory nicely...
62 */
63static void dump_mem(const char *str, unsigned long bottom, unsigned long top)
64{
65 unsigned long p = bottom & ~31;
66 mm_segment_t fs;
67 int i;
68
69 /*
70 * We need to switch to kernel mode so that we can use __get_user
71 * to safely read from kernel space. Note that we now dump the
72 * code first, just in case the backtrace kills us.
73 */
74 fs = get_fs();
75 set_fs(KERNEL_DS);
76
77 printk("%s", str);
78 printk("(0x%08lx to 0x%08lx)\n", bottom, top);
79
80 for (p = bottom & ~31; p < top;) {
81 printk("%04lx: ", p & 0xffff);
82
83 for (i = 0; i < 8; i++, p += 4) {
84 unsigned int val;
85
86 if (p < bottom || p >= top)
87 printk(" ");
88 else {
89 __get_user(val, (unsigned long *)p);
90 printk("%08x ", val);
91 }
92 }
93 printk ("\n");
94 }
95
96 set_fs(fs);
97}
98
99static void dump_instr(struct pt_regs *regs)
100{
101 unsigned long addr = instruction_pointer(regs);
102 const int width = 8;
103 mm_segment_t fs;
104 int i;
105
106 /*
107 * We need to switch to kernel mode so that we can use __get_user
108 * to safely read from kernel space. Note that we now dump the
109 * code first, just in case the backtrace kills us.
110 */
111 fs = get_fs();
112 set_fs(KERNEL_DS);
113
114 printk("Code: ");
115 for (i = -4; i < 1; i++) {
116 unsigned int val, bad;
117
118 bad = __get_user(val, &((u32 *)addr)[i]);
119
120 if (!bad)
121 printk(i == 0 ? "(%0*x) " : "%0*x ", width, val);
122 else {
123 printk("bad PC value.");
124 break;
125 }
126 }
127 printk("\n");
128
129 set_fs(fs);
130}
131
132/*static*/ void __dump_stack(struct task_struct *tsk, unsigned long sp)
133{
134 dump_mem("Stack: ", sp, 8192+(unsigned long)task_stack_page(tsk));
135}
136
137void dump_stack(void)
138{
139#ifdef CONFIG_DEBUG_ERRORS
140 __backtrace();
141#endif
142}
143
144EXPORT_SYMBOL(dump_stack);
145
146//FIXME - was a static fn
147void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
148{
149 unsigned int fp;
150 int ok = 1;
151
152 printk("Backtrace: ");
153 fp = regs->ARM_fp;
154 if (!fp) {
155 printk("no frame pointer");
156 ok = 0;
157 } else if (verify_stack(fp)) {
158 printk("invalid frame pointer 0x%08x", fp);
159 ok = 0;
160 } else if (fp < (unsigned long)end_of_stack(tsk))
161 printk("frame pointer underflow");
162 printk("\n");
163
164 if (ok)
165 c_backtrace(fp, processor_mode(regs));
166}
167
168/* FIXME - this is probably wrong.. */
169void show_stack(struct task_struct *task, unsigned long *sp) {
170 dump_mem("Stack: ", (unsigned long)sp, 8192+(unsigned long)task_stack_page(task));
171}
172
173DEFINE_SPINLOCK(die_lock);
174
175/*
176 * This function is protected against re-entrancy.
177 */
178NORET_TYPE void die(const char *str, struct pt_regs *regs, int err)
179{
180 struct task_struct *tsk = current;
181
182 console_verbose();
183 spin_lock_irq(&die_lock);
184
185 printk("Internal error: %s: %x\n", str, err);
186 printk("CPU: %d\n", smp_processor_id());
187 show_regs(regs);
188 add_taint(TAINT_DIE);
189 printk("Process %s (pid: %d, stack limit = 0x%p)\n",
190 current->comm, current->pid, end_of_stack(tsk));
191
192 if (!user_mode(regs) || in_interrupt()) {
193 __dump_stack(tsk, (unsigned long)(regs + 1));
194 dump_backtrace(regs, tsk);
195 dump_instr(regs);
196 }
197while(1);
198 spin_unlock_irq(&die_lock);
199 do_exit(SIGSEGV);
200}
201
202void die_if_kernel(const char *str, struct pt_regs *regs, int err)
203{
204 if (user_mode(regs))
205 return;
206
207 die(str, regs, err);
208}
209
210static DEFINE_MUTEX(undef_mutex);
211static int (*undef_hook)(struct pt_regs *);
212
213int request_undef_hook(int (*fn)(struct pt_regs *))
214{
215 int ret = -EBUSY;
216
217 mutex_lock(&undef_mutex);
218 if (undef_hook == NULL) {
219 undef_hook = fn;
220 ret = 0;
221 }
222 mutex_unlock(&undef_mutex);
223
224 return ret;
225}
226
227int release_undef_hook(int (*fn)(struct pt_regs *))
228{
229 int ret = -EINVAL;
230
231 mutex_lock(&undef_mutex);
232 if (undef_hook == fn) {
233 undef_hook = NULL;
234 ret = 0;
235 }
236 mutex_unlock(&undef_mutex);
237
238 return ret;
239}
240
241static int undefined_extension(struct pt_regs *regs, unsigned int op)
242{
243 switch (op) {
244 case 1: /* 0xde01 / 0x?7f001f0 */
245 ptrace_break(current, regs);
246 return 0;
247 }
248 return 1;
249}
250
251asmlinkage void do_undefinstr(struct pt_regs *regs)
252{
253 siginfo_t info;
254 void *pc;
255
256 regs->ARM_pc -= 4;
257
258 pc = (unsigned long *)instruction_pointer(regs); /* strip PSR */
259
260 if (user_mode(regs)) {
261 u32 instr;
262
263 get_user(instr, (u32 *)pc);
264
265 if ((instr & 0x0fff00ff) == 0x07f000f0 &&
266 undefined_extension(regs, (instr >> 8) & 255) == 0) {
267 regs->ARM_pc += 4;
268 return;
269 }
270 } else {
271 if (undef_hook && undef_hook(regs) == 0) {
272 regs->ARM_pc += 4;
273 return;
274 }
275 }
276
277#ifdef CONFIG_DEBUG_USER
278 printk(KERN_INFO "%s (%d): undefined instruction: pc=%p\n",
279 current->comm, current->pid, pc);
280 dump_instr(regs);
281#endif
282
283 current->thread.error_code = 0;
284 current->thread.trap_no = 6;
285
286 info.si_signo = SIGILL;
287 info.si_errno = 0;
288 info.si_code = ILL_ILLOPC;
289 info.si_addr = pc;
290
291 force_sig_info(SIGILL, &info, current);
292
293 die_if_kernel("Oops - undefined instruction", regs, 0);
294}
295
296asmlinkage void do_excpt(unsigned long address, struct pt_regs *regs, int mode)
297{
298 siginfo_t info;
299
300#ifdef CONFIG_DEBUG_USER
301 printk(KERN_INFO "%s (%d): address exception: pc=%08lx\n",
302 current->comm, current->pid, instruction_pointer(regs));
303 dump_instr(regs);
304#endif
305
306 current->thread.error_code = 0;
307 current->thread.trap_no = 11;
308
309 info.si_signo = SIGBUS;
310 info.si_errno = 0;
311 info.si_code = BUS_ADRERR;
312 info.si_addr = (void *)address;
313
314 force_sig_info(SIGBUS, &info, current);
315
316 die_if_kernel("Oops - address exception", regs, mode);
317}
318
319asmlinkage void do_unexp_fiq (struct pt_regs *regs)
320{
321#ifndef CONFIG_IGNORE_FIQ
322 printk("Hmm. Unexpected FIQ received, but trying to continue\n");
323 printk("You may have a hardware problem...\n");
324#endif
325}
326
327/*
328 * bad_mode handles the impossible case in the vectors. If you see one of
329 * these, then it's extremely serious, and could mean you have buggy hardware.
330 * It never returns, and never tries to sync. We hope that we can at least
331 * dump out some state information...
332 */
333asmlinkage void bad_mode(struct pt_regs *regs, int reason, int proc_mode)
334{
335 unsigned int vectors = vectors_base();
336
337 console_verbose();
338
339 printk(KERN_CRIT "Bad mode in %s handler detected: mode %s\n",
340 handler[reason<5?reason:4], processor_modes[proc_mode]);
341
342 /*
343 * Dump out the vectors and stub routines. Maybe a better solution
344 * would be to dump them out only if we detect that they are corrupted.
345 */
346 dump_mem(KERN_CRIT "Vectors: ", vectors, vectors + 0x40);
347 dump_mem(KERN_CRIT "Stubs: ", vectors + 0x200, vectors + 0x4b8);
348
349 die("Oops", regs, 0);
350 local_irq_disable();
351 panic("bad mode");
352}
353
354static int bad_syscall(int n, struct pt_regs *regs)
355{
356 struct thread_info *thread = current_thread_info();
357 siginfo_t info;
358
359 if (current->personality != PER_LINUX && thread->exec_domain->handler) {
360 thread->exec_domain->handler(n, regs);
361 return regs->ARM_r0;
362 }
363
364#ifdef CONFIG_DEBUG_USER
365 printk(KERN_ERR "[%d] %s: obsolete system call %08x.\n",
366 current->pid, current->comm, n);
367 dump_instr(regs);
368#endif
369
370 info.si_signo = SIGILL;
371 info.si_errno = 0;
372 info.si_code = ILL_ILLTRP;
373 info.si_addr = (void *)instruction_pointer(regs) - 4;
374
375 force_sig_info(SIGILL, &info, current);
376 die_if_kernel("Oops", regs, n);
377 return regs->ARM_r0;
378}
379
380static inline void
381do_cache_op(unsigned long start, unsigned long end, int flags)
382{
383 struct vm_area_struct *vma;
384
385 if (end < start)
386 return;
387
388 vma = find_vma(current->active_mm, start);
389 if (vma && vma->vm_start < end) {
390 if (start < vma->vm_start)
391 start = vma->vm_start;
392 if (end > vma->vm_end)
393 end = vma->vm_end;
394 }
395}
396
397/*
398 * Handle all unrecognised system calls.
399 * 0x9f0000 - 0x9fffff are some more esoteric system calls
400 */
401#define NR(x) ((__ARM_NR_##x) - __ARM_NR_BASE)
402asmlinkage int arm_syscall(int no, struct pt_regs *regs)
403{
404 siginfo_t info;
405
406 if ((no >> 16) != 0x9f)
407 return bad_syscall(no, regs);
408
409 switch (no & 0xffff) {
410 case 0: /* branch through 0 */
411 info.si_signo = SIGSEGV;
412 info.si_errno = 0;
413 info.si_code = SEGV_MAPERR;
414 info.si_addr = NULL;
415
416 force_sig_info(SIGSEGV, &info, current);
417
418 die_if_kernel("branch through zero", regs, 0);
419 return 0;
420
421 case NR(breakpoint): /* SWI BREAK_POINT */
422 ptrace_break(current, regs);
423 return regs->ARM_r0;
424
425 case NR(cacheflush):
426 return 0;
427
428 case NR(usr26):
429 break;
430
431 default:
432 /* Calls 9f00xx..9f07ff are defined to return -ENOSYS
433 if not implemented, rather than raising SIGILL. This
434 way the calling program can gracefully determine whether
435 a feature is supported. */
436 if (no <= 0x7ff)
437 return -ENOSYS;
438 break;
439 }
440#ifdef CONFIG_DEBUG_USER
441 /*
442 * experience shows that these seem to indicate that
443 * something catastrophic has happened
444 */
445 printk("[%d] %s: arm syscall %d\n", current->pid, current->comm, no);
446 dump_instr(regs);
447 if (user_mode(regs)) {
448 show_regs(regs);
449 c_backtrace(regs->ARM_fp, processor_mode(regs));
450 }
451#endif
452 info.si_signo = SIGILL;
453 info.si_errno = 0;
454 info.si_code = ILL_ILLTRP;
455 info.si_addr = (void *)instruction_pointer(regs) - 4;
456
457 force_sig_info(SIGILL, &info, current);
458 die_if_kernel("Oops", regs, no);
459 return 0;
460}
461
462void __bad_xchg(volatile void *ptr, int size)
463{
464 printk("xchg: bad data size: pc 0x%p, ptr 0x%p, size %d\n",
465 __builtin_return_address(0), ptr, size);
466 BUG();
467}
468
469/*
470 * A data abort trap was taken, but we did not handle the instruction.
471 * Try to abort the user program, or panic if it was the kernel.
472 */
473asmlinkage void
474baddataabort(int code, unsigned long instr, struct pt_regs *regs)
475{
476 unsigned long addr = instruction_pointer(regs);
477 siginfo_t info;
478
479#ifdef CONFIG_DEBUG_USER
480 printk(KERN_ERR "[%d] %s: bad data abort: code %d instr 0x%08lx\n",
481 current->pid, current->comm, code, instr);
482 dump_instr(regs);
483 show_pte(current->mm, addr);
484#endif
485
486 info.si_signo = SIGILL;
487 info.si_errno = 0;
488 info.si_code = ILL_ILLOPC;
489 info.si_addr = (void *)addr;
490
491 force_sig_info(SIGILL, &info, current);
492 die_if_kernel("unknown data abort code", regs, instr);
493}
494
495volatile void __bug(const char *file, int line, void *data)
496{
497 printk(KERN_CRIT"kernel BUG at %s:%d!", file, line);
498 if (data)
499 printk(KERN_CRIT" - extra data = %p", data);
500 printk("\n");
501 *(int *)0 = 0;
502}
503
504void __readwrite_bug(const char *fn)
505{
506 printk("%s called, but not implemented", fn);
507 BUG();
508}
509
510void __pte_error(const char *file, int line, unsigned long val)
511{
512 printk("%s:%d: bad pte %08lx.\n", file, line, val);
513}
514
515void __pmd_error(const char *file, int line, unsigned long val)
516{
517 printk("%s:%d: bad pmd %08lx.\n", file, line, val);
518}
519
520void __pgd_error(const char *file, int line, unsigned long val)
521{
522 printk("%s:%d: bad pgd %08lx.\n", file, line, val);
523}
524
525asmlinkage void __div0(void)
526{
527 printk("Division by zero in kernel.\n");
528 dump_stack();
529}
530
531void abort(void)
532{
533 BUG();
534
535 /* if that doesn't kill us, halt */
536 panic("Oops failed to kill thread");
537}
538
539void __init trap_init(void)
540{
541 extern void __trap_init(unsigned long);
542 unsigned long base = vectors_base();
543
544 __trap_init(base);
545 if (base != 0)
546 printk(KERN_DEBUG "Relocating machine vectors to 0x%08lx\n",
547 base);
548}
diff --git a/arch/arm26/kernel/vmlinux-arm26-xip.lds.in b/arch/arm26/kernel/vmlinux-arm26-xip.lds.in
deleted file mode 100644
index 4ec715c25dea..000000000000
--- a/arch/arm26/kernel/vmlinux-arm26-xip.lds.in
+++ /dev/null
@@ -1,136 +0,0 @@
1/* ld script to make ARM Linux kernel
2 * taken from the i386 version by Russell King
3 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
4 * borrowed from Russels ARM port by Ian Molton
5 */
6
7#include <asm-generic/vmlinux.lds.h>
8
9OUTPUT_ARCH(arm)
10ENTRY(stext)
11jiffies = jiffies_64;
12SECTIONS
13{
14 . = TEXTADDR;
15 .init : { /* Init code and data */
16 _stext = .;
17 __init_begin = .;
18 _sinittext = .;
19 *(.init.text)
20 _einittext = .;
21 __proc_info_begin = .;
22 *(.proc.info)
23 __proc_info_end = .;
24 __arch_info_begin = .;
25 *(.arch.info)
26 __arch_info_end = .;
27 __tagtable_begin = .;
28 *(.taglist)
29 __tagtable_end = .;
30 . = ALIGN(16);
31 __setup_start = .;
32 *(.init.setup)
33 __setup_end = .;
34 __early_begin = .;
35 *(__early_param)
36 __early_end = .;
37 __initcall_start = .;
38 *(.initcall1.init)
39 *(.initcall2.init)
40 *(.initcall3.init)
41 *(.initcall4.init)
42 *(.initcall5.init)
43 *(.initcall6.init)
44 *(.initcall7.init)
45 __initcall_end = .;
46 __con_initcall_start = .;
47 *(.con_initcall.init)
48 __con_initcall_end = .;
49#ifdef CONFIG_BLK_DEV_INITRD
50 . = ALIGN(32);
51 __initramfs_start = .;
52 usr/built-in.o(.init.ramfs)
53 __initramfs_end = .;
54#endif
55 . = ALIGN(32768);
56 __init_end = .;
57 }
58
59 /DISCARD/ : { /* Exit code and data */
60 *(.exit.text)
61 *(.exit.data)
62 *(.exitcall.exit)
63 }
64
65 .text : { /* Real text segment */
66 _text = .; /* Text and read-only data */
67 TEXT_TEXT
68 SCHED_TEXT
69 LOCK_TEXT /* FIXME - borrowed from arm32 - check*/
70 *(.fixup)
71 *(.gnu.warning)
72 *(.rodata)
73 *(.rodata.*)
74 *(.glue_7)
75 *(.glue_7t)
76 *(.got) /* Global offset table */
77
78 _etext = .; /* End of text section */
79 }
80
81 . = ALIGN(16);
82 __ex_table : { /* Exception table */
83 __start___ex_table = .;
84 *(__ex_table)
85 __stop___ex_table = .;
86 }
87
88 RODATA
89
90 _endtext = .;
91
92 . = DATAADDR;
93
94 _sdata = .;
95
96 .data : {
97 . = ALIGN(8192);
98 /*
99 * first, the init thread union, aligned
100 * to an 8192 byte boundary. (see arm26/kernel/init_task.c)
101 * FIXME - sould this be 32K aligned on arm26?
102 */
103 *(.init.task)
104
105 /*
106 * The cacheline aligned data
107 */
108 . = ALIGN(32);
109 *(.data.cacheline_aligned)
110
111 /*
112 * and the usual data section
113 */
114 DATA_DATA
115 CONSTRUCTORS
116
117 *(.init.data)
118
119 _edata = .;
120 }
121
122 .bss : {
123 __bss_start = .; /* BSS */
124 *(.bss)
125 *(COMMON)
126 _end = . ;
127 }
128 /* Stabs debugging sections. */
129 .stab 0 : { *(.stab) }
130 .stabstr 0 : { *(.stabstr) }
131 .stab.excl 0 : { *(.stab.excl) }
132 .stab.exclstr 0 : { *(.stab.exclstr) }
133 .stab.index 0 : { *(.stab.index) }
134 .stab.indexstr 0 : { *(.stab.indexstr) }
135 .comment 0 : { *(.comment) }
136}
diff --git a/arch/arm26/kernel/vmlinux-arm26.lds.in b/arch/arm26/kernel/vmlinux-arm26.lds.in
deleted file mode 100644
index 6c44f6a17bf7..000000000000
--- a/arch/arm26/kernel/vmlinux-arm26.lds.in
+++ /dev/null
@@ -1,129 +0,0 @@
1/* ld script to make ARM Linux kernel
2 * taken from the i386 version by Russell King
3 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
4 * borrowed from Russels ARM port by Ian Molton and subsequently modified.
5 */
6
7#include <asm-generic/vmlinux.lds.h>
8
9OUTPUT_ARCH(arm)
10ENTRY(stext)
11jiffies = jiffies_64;
12SECTIONS
13{
14 . = TEXTADDR;
15 .init : { /* Init code and data */
16 _stext = .;
17 __init_begin = .;
18 _sinittext = .;
19 *(.init.text)
20 _einittext = .;
21 __proc_info_begin = .;
22 *(.proc.info)
23 __proc_info_end = .;
24 __arch_info_begin = .;
25 *(.arch.info)
26 __arch_info_end = .;
27 __tagtable_begin = .;
28 *(.taglist)
29 __tagtable_end = .;
30 *(.init.data)
31 . = ALIGN(16);
32 __setup_start = .;
33 *(.init.setup)
34 __setup_end = .;
35 __early_begin = .;
36 *(__early_param)
37 __early_end = .;
38 __initcall_start = .;
39 *(.initcall1.init)
40 *(.initcall2.init)
41 *(.initcall3.init)
42 *(.initcall4.init)
43 *(.initcall5.init)
44 *(.initcall6.init)
45 *(.initcall7.init)
46 __initcall_end = .;
47 __con_initcall_start = .;
48 *(.con_initcall.init)
49 __con_initcall_end = .;
50#ifdef CONFIG_BLK_DEV_INITRD
51 . = ALIGN(32);
52 __initramfs_start = .;
53 usr/built-in.o(.init.ramfs)
54 __initramfs_end = .;
55#endif
56 . = ALIGN(32768);
57 __init_end = .;
58 }
59
60 /DISCARD/ : { /* Exit code and data */
61 *(.exit.text)
62 *(.exit.data)
63 *(.exitcall.exit)
64 }
65
66 .text : { /* Real text segment */
67 _text = .; /* Text and read-only data */
68 TEXT_TEXT
69 SCHED_TEXT
70 LOCK_TEXT
71 *(.fixup)
72 *(.gnu.warning)
73 *(.rodata)
74 *(.rodata.*)
75 *(.glue_7)
76 *(.glue_7t)
77 *(.got) /* Global offset table */
78
79 _etext = .; /* End of text section */
80 }
81
82 . = ALIGN(16);
83 __ex_table : { /* Exception table */
84 __start___ex_table = .;
85 *(__ex_table)
86 __stop___ex_table = .;
87 }
88
89 RODATA
90
91 . = ALIGN(8192);
92
93 .data : {
94 /*
95 * first, the init task union, aligned
96 * to an 8192 byte boundary. (see arm26/kernel/init_task.c)
97 */
98 *(.init.task)
99
100 /*
101 * The cacheline aligned data
102 */
103 . = ALIGN(32);
104 *(.data.cacheline_aligned)
105
106 /*
107 * and the usual data section
108 */
109 DATA_DATA
110 CONSTRUCTORS
111
112 _edata = .;
113 }
114
115 .bss : {
116 __bss_start = .; /* BSS */
117 *(.bss)
118 *(COMMON)
119 _end = . ;
120 }
121 /* Stabs debugging sections. */
122 .stab 0 : { *(.stab) }
123 .stabstr 0 : { *(.stabstr) }
124 .stab.excl 0 : { *(.stab.excl) }
125 .stab.exclstr 0 : { *(.stab.exclstr) }
126 .stab.index 0 : { *(.stab.index) }
127 .stab.indexstr 0 : { *(.stab.indexstr) }
128 .comment 0 : { *(.comment) }
129}
diff --git a/arch/arm26/kernel/vmlinux.lds.S b/arch/arm26/kernel/vmlinux.lds.S
deleted file mode 100644
index 1fa39f02e07c..000000000000
--- a/arch/arm26/kernel/vmlinux.lds.S
+++ /dev/null
@@ -1,11 +0,0 @@
1
2#ifdef CONFIG_XIP_KERNEL
3
4#include "vmlinux-arm26-xip.lds.in"
5
6#else
7
8#include "vmlinux-arm26.lds.in"
9
10#endif
11
diff --git a/arch/arm26/lib/Makefile b/arch/arm26/lib/Makefile
deleted file mode 100644
index 6df2b793d367..000000000000
--- a/arch/arm26/lib/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
1#
2# linux/arch/arm26/lib/Makefile
3#
4# Copyright (C) 1995-2000 Russell King
5#
6
7lib-y := backtrace.o changebit.o csumipv6.o csumpartial.o \
8 csumpartialcopy.o csumpartialcopyuser.o clearbit.o \
9 copy_page.o delay.o findbit.o memchr.o memcpy.o \
10 memset.o memzero.o setbit.o \
11 strchr.o strrchr.o testchangebit.o \
12 testclearbit.o testsetbit.o getuser.o \
13 putuser.o ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
14 ucmpdi2.o udivdi3.o lib1funcs.o ecard.o io-acorn.o \
15 floppydma.o io-readsb.o io-writesb.o io-writesl.o \
16 uaccess-kernel.o uaccess-user.o io-readsw.o \
17 io-writesw.o io-readsl.o ecard.o io-acorn.o \
18 floppydma.o
19
20lib-n :=
21
22lib-$(CONFIG_VT)+= kbd.o
23
24csumpartialcopy.o: csumpartialcopygeneric.S
25csumpartialcopyuser.o: csumpartialcopygeneric.S
26
diff --git a/arch/arm26/lib/ashldi3.c b/arch/arm26/lib/ashldi3.c
deleted file mode 100644
index 130f5a839669..000000000000
--- a/arch/arm26/lib/ashldi3.c
+++ /dev/null
@@ -1,61 +0,0 @@
1/* More subroutines needed by GCC output code on some machines. */
2/* Compile this one with gcc. */
3/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc.
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
22/* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License.
28 */
29/* support functions required by the kernel. based on code from gcc-2.95.3 */
30/* I Molton 29/07/01 */
31
32#include "gcclib.h"
33
34DItype
35__ashldi3 (DItype u, word_type b)
36{
37 DIunion w;
38 word_type bm;
39 DIunion uu;
40
41 if (b == 0)
42 return u;
43
44 uu.ll = u;
45
46 bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
47 if (bm <= 0)
48 {
49 w.s.low = 0;
50 w.s.high = (USItype)uu.s.low << -bm;
51 }
52 else
53 {
54 USItype carries = (USItype)uu.s.low >> bm;
55 w.s.low = (USItype)uu.s.low << b;
56 w.s.high = ((USItype)uu.s.high << b) | carries;
57 }
58
59 return w.ll;
60}
61
diff --git a/arch/arm26/lib/ashrdi3.c b/arch/arm26/lib/ashrdi3.c
deleted file mode 100644
index 71625d218f8d..000000000000
--- a/arch/arm26/lib/ashrdi3.c
+++ /dev/null
@@ -1,61 +0,0 @@
1/* More subroutines needed by GCC output code on some machines. */
2/* Compile this one with gcc. */
3/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc.
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
22/* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License.
28 */
29/* support functions required by the kernel. based on code from gcc-2.95.3 */
30/* I Molton 29/07/01 */
31
32#include "gcclib.h"
33
34DItype
35__ashrdi3 (DItype u, word_type b)
36{
37 DIunion w;
38 word_type bm;
39 DIunion uu;
40
41 if (b == 0)
42 return u;
43
44 uu.ll = u;
45
46 bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
47 if (bm <= 0)
48 {
49 /* w.s.high = 1..1 or 0..0 */
50 w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1);
51 w.s.low = uu.s.high >> -bm;
52 }
53 else
54 {
55 USItype carries = (USItype)uu.s.high << bm;
56 w.s.high = uu.s.high >> b;
57 w.s.low = ((USItype)uu.s.low >> b) | carries;
58 }
59
60 return w.ll;
61}
diff --git a/arch/arm26/lib/backtrace.S b/arch/arm26/lib/backtrace.S
deleted file mode 100644
index e27feb1e891d..000000000000
--- a/arch/arm26/lib/backtrace.S
+++ /dev/null
@@ -1,144 +0,0 @@
1/*
2 * linux/arch/arm26/lib/backtrace.S
3 *
4 * Copyright (C) 1995, 1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12 .text
13
14@ fp is 0 or stack frame
15
16#define frame r4
17#define next r5
18#define save r6
19#define mask r7
20#define offset r8
21
22ENTRY(__backtrace)
23 mov r1, #0x10
24 mov r0, fp
25
26ENTRY(c_backtrace)
27
28#ifdef CONFIG_NO_FRAME_POINTER
29 mov pc, lr
30#else
31
32 stmfd sp!, {r4 - r8, lr} @ Save an extra register so we have a location...
33 mov mask, #0xfc000003
34 tst mask, r0
35 movne r0, #0
36 movs frame, r0
371: moveq r0, #-2
38 LOADREGS(eqfd, sp!, {r4 - r8, pc})
39
402: stmfd sp!, {pc} @ calculate offset of PC in STMIA instruction
41 ldr r0, [sp], #4
42 adr r1, 2b - 4
43 sub offset, r0, r1
44
453: tst frame, mask @ Check for address exceptions...
46 bne 1b
47
481001: ldr next, [frame, #-12] @ get fp
491002: ldr r2, [frame, #-4] @ get lr
501003: ldr r3, [frame, #0] @ get pc
51 sub save, r3, offset @ Correct PC for prefetching
52 bic save, save, mask
531004: ldr r1, [save, #0] @ get instruction at function
54 mov r1, r1, lsr #10
55 ldr r3, .Ldsi+4
56 teq r1, r3
57 subeq save, save, #4
58 adr r0, .Lfe
59 mov r1, save
60 bic r2, r2, mask
61 bl printk @ print pc and link register
62
63 ldr r0, [frame, #-8] @ get sp
64 sub r0, r0, #4
651005: ldr r1, [save, #4] @ get instruction at function+4
66 mov r3, r1, lsr #10
67 ldr r2, .Ldsi+4
68 teq r3, r2 @ Check for stmia sp!, {args}
69 addeq save, save, #4 @ next instruction
70 bleq .Ldumpstm
71
72 sub r0, frame, #16
731006: ldr r1, [save, #4] @ Get 'stmia sp!, {rlist, fp, ip, lr, pc}' instruction
74 mov r3, r1, lsr #10
75 ldr r2, .Ldsi
76 teq r3, r2
77 bleq .Ldumpstm
78
79 teq frame, next
80 movne frame, next
81 teqne frame, #0
82 bne 3b
83 LOADREGS(fd, sp!, {r4 - r8, pc})
84
85/*
86 * Fixup for LDMDB
87 */
88 .section .fixup,"ax"
89 .align 0
901007: ldr r0, =.Lbad
91 mov r1, frame
92 bl printk
93 LOADREGS(fd, sp!, {r4 - r8, pc})
94 .ltorg
95 .previous
96
97 .section __ex_table,"a"
98 .align 3
99 .long 1001b, 1007b
100 .long 1002b, 1007b
101 .long 1003b, 1007b
102 .long 1004b, 1007b
103 .long 1005b, 1007b
104 .long 1006b, 1007b
105 .previous
106
107#define instr r4
108#define reg r5
109#define stack r6
110
111.Ldumpstm: stmfd sp!, {instr, reg, stack, r7, lr}
112 mov stack, r0
113 mov instr, r1
114 mov reg, #9
115 mov r7, #0
1161: mov r3, #1
117 tst instr, r3, lsl reg
118 beq 2f
119 add r7, r7, #1
120 teq r7, #4
121 moveq r7, #0
122 moveq r3, #'\n'
123 movne r3, #' '
124 ldr r2, [stack], #-4
125 mov r1, reg
126 adr r0, .Lfp
127 bl printk
1282: subs reg, reg, #1
129 bpl 1b
130 teq r7, #0
131 adrne r0, .Lcr
132 blne printk
133 mov r0, stack
134 LOADREGS(fd, sp!, {instr, reg, stack, r7, pc})
135
136.Lfe: .asciz "Function entered at [<%p>] from [<%p>]\n"
137.Lfp: .asciz " r%d = %08X%c"
138.Lcr: .asciz "\n"
139.Lbad: .asciz "Backtrace aborted due to bad frame pointer <%p>\n"
140 .align
141.Ldsi: .word 0x00e92dd8 >> 2
142 .word 0x00e92d00 >> 2
143
144#endif
diff --git a/arch/arm26/lib/changebit.S b/arch/arm26/lib/changebit.S
deleted file mode 100644
index 1b6a077be5a6..000000000000
--- a/arch/arm26/lib/changebit.S
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * linux/arch/arm26/lib/changebit.S
3 *
4 * Copyright (C) 1995-1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12 .text
13
14/* Purpose : Function to change a bit
15 * Prototype: int change_bit(int bit, void *addr)
16 */
17ENTRY(_change_bit_be)
18 eor r0, r0, #0x18 @ big endian byte ordering
19ENTRY(_change_bit_le)
20 and r2, r0, #7
21 mov r3, #1
22 mov r3, r3, lsl r2
23 save_and_disable_irqs ip, r2
24 ldrb r2, [r1, r0, lsr #3]
25 eor r2, r2, r3
26 strb r2, [r1, r0, lsr #3]
27 restore_irqs ip
28 RETINSTR(mov,pc,lr)
diff --git a/arch/arm26/lib/clearbit.S b/arch/arm26/lib/clearbit.S
deleted file mode 100644
index 0a895b0c759f..000000000000
--- a/arch/arm26/lib/clearbit.S
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * linux/arch/arm26/lib/clearbit.S
3 *
4 * Copyright (C) 1995-1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12 .text
13
14/*
15 * Purpose : Function to clear a bit
16 * Prototype: int clear_bit(int bit, void *addr)
17 */
18ENTRY(_clear_bit_be)
19 eor r0, r0, #0x18 @ big endian byte ordering
20ENTRY(_clear_bit_le)
21 and r2, r0, #7
22 mov r3, #1
23 mov r3, r3, lsl r2
24 save_and_disable_irqs ip, r2
25 ldrb r2, [r1, r0, lsr #3]
26 bic r2, r2, r3
27 strb r2, [r1, r0, lsr #3]
28 restore_irqs ip
29 RETINSTR(mov,pc,lr)
30
31
diff --git a/arch/arm26/lib/copy_page.S b/arch/arm26/lib/copy_page.S
deleted file mode 100644
index c7511a2739d3..000000000000
--- a/arch/arm26/lib/copy_page.S
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * linux/arch/arm26/lib/copypage.S
3 *
4 * Copyright (C) 1995-1999 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ASM optimised string functions
11 */
12#include <linux/linkage.h>
13#include <asm/assembler.h>
14#include <asm/asm-offsets.h>
15
16 .text
17 .align 5
18/*
19 * ARMv3 optimised copy_user_page
20 *
21 * FIXME: rmk do we need to handle cache stuff...
22 * FIXME: im is this right on ARM26?
23 */
24ENTRY(__copy_user_page)
25 stmfd sp!, {r4, lr} @ 2
26 mov r2, #PAGE_SZ/64 @ 1
27 ldmia r1!, {r3, r4, ip, lr} @ 4+1
281: stmia r0!, {r3, r4, ip, lr} @ 4
29 ldmia r1!, {r3, r4, ip, lr} @ 4+1
30 stmia r0!, {r3, r4, ip, lr} @ 4
31 ldmia r1!, {r3, r4, ip, lr} @ 4+1
32 stmia r0!, {r3, r4, ip, lr} @ 4
33 ldmia r1!, {r3, r4, ip, lr} @ 4
34 subs r2, r2, #1 @ 1
35 stmia r0!, {r3, r4, ip, lr} @ 4
36 ldmneia r1!, {r3, r4, ip, lr} @ 4
37 bne 1b @ 1
38 LOADREGS(fd, sp!, {r4, pc}) @ 3
39
40 .align 5
41/*
42 * ARMv3 optimised clear_user_page
43 *
44 * FIXME: rmk do we need to handle cache stuff...
45 */
46ENTRY(__clear_user_page)
47 str lr, [sp, #-4]!
48 mov r1, #PAGE_SZ/64 @ 1
49 mov r2, #0 @ 1
50 mov r3, #0 @ 1
51 mov ip, #0 @ 1
52 mov lr, #0 @ 1
531: stmia r0!, {r2, r3, ip, lr} @ 4
54 stmia r0!, {r2, r3, ip, lr} @ 4
55 stmia r0!, {r2, r3, ip, lr} @ 4
56 stmia r0!, {r2, r3, ip, lr} @ 4
57 subs r1, r1, #1 @ 1
58 bne 1b @ 1
59 ldr pc, [sp], #4
60
61 .section ".init.text", #alloc, #execinstr
62
diff --git a/arch/arm26/lib/csumipv6.S b/arch/arm26/lib/csumipv6.S
deleted file mode 100644
index 62831155acde..000000000000
--- a/arch/arm26/lib/csumipv6.S
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * linux/arch/arm26/lib/csumipv6.S
3 *
4 * Copyright (C) 1995-1998 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12
13 .text
14
15ENTRY(__csum_ipv6_magic)
16 str lr, [sp, #-4]!
17 adds ip, r2, r3
18 ldmia r1, {r1 - r3, lr}
19 adcs ip, ip, r1
20 adcs ip, ip, r2
21 adcs ip, ip, r3
22 adcs ip, ip, lr
23 ldmia r0, {r0 - r3}
24 adcs r0, ip, r0
25 adcs r0, r0, r1
26 adcs r0, r0, r2
27 ldr r2, [sp, #4]
28 adcs r0, r0, r3
29 adcs r0, r0, r2
30 adcs r0, r0, #0
31 LOADREGS(fd, sp!, {pc})
32
diff --git a/arch/arm26/lib/csumpartial.S b/arch/arm26/lib/csumpartial.S
deleted file mode 100644
index e53e7109e623..000000000000
--- a/arch/arm26/lib/csumpartial.S
+++ /dev/null
@@ -1,130 +0,0 @@
1/*
2 * linux/arch/arm26/lib/csumpartial.S
3 *
4 * Copyright (C) 1995-1998 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12
13 .text
14
15/*
16 * Function: __u32 csum_partial(const char *src, int len, __u32 sum)
17 * Params : r0 = buffer, r1 = len, r2 = checksum
18 * Returns : r0 = new checksum
19 */
20
21buf .req r0
22len .req r1
23sum .req r2
24td0 .req r3
25td1 .req r4 @ save before use
26td2 .req r5 @ save before use
27td3 .req lr
28
29.zero: mov r0, sum
30 add sp, sp, #4
31 ldr pc, [sp], #4
32
33 /*
34 * Handle 0 to 7 bytes, with any alignment of source and
35 * destination pointers. Note that when we get here, C = 0
36 */
37.less8: teq len, #0 @ check for zero count
38 beq .zero
39
40 /* we must have at least one byte. */
41 tst buf, #1 @ odd address?
42 ldrneb td0, [buf], #1
43 subne len, len, #1
44 adcnes sum, sum, td0, lsl #byte(1)
45
46.less4: tst len, #6
47 beq .less8_byte
48
49 /* we are now half-word aligned */
50
51.less8_wordlp:
52#if __LINUX_ARM_ARCH__ >= 4
53 ldrh td0, [buf], #2
54 sub len, len, #2
55#else
56 ldrb td0, [buf], #1
57 ldrb td3, [buf], #1
58 sub len, len, #2
59 orr td0, td0, td3, lsl #8
60#endif
61 adcs sum, sum, td0
62 tst len, #6
63 bne .less8_wordlp
64
65.less8_byte: tst len, #1 @ odd number of bytes
66 ldrneb td0, [buf], #1 @ include last byte
67 adcnes sum, sum, td0, lsl #byte(0) @ update checksum
68
69.done: adc r0, sum, #0 @ collect up the last carry
70 ldr td0, [sp], #4
71 tst td0, #1 @ check buffer alignment
72 movne td0, r0, lsl #8 @ rotate checksum by 8 bits
73 orrne r0, td0, r0, lsr #24
74 ldr pc, [sp], #4 @ return
75
76.not_aligned: tst buf, #1 @ odd address
77 ldrneb td0, [buf], #1 @ make even
78 subne len, len, #1
79 adcnes sum, sum, td0, lsl #byte(1) @ update checksum
80
81 tst buf, #2 @ 32-bit aligned?
82#if __LINUX_ARM_ARCH__ >= 4
83 ldrneh td0, [buf], #2 @ make 32-bit aligned
84 subne len, len, #2
85#else
86 ldrneb td0, [buf], #1
87 ldrneb ip, [buf], #1
88 subne len, len, #2
89 orrne td0, td0, ip, lsl #8
90#endif
91 adcnes sum, sum, td0 @ update checksum
92 mov pc, lr
93
94ENTRY(csum_partial)
95 stmfd sp!, {buf, lr}
96 cmp len, #8 @ Ensure that we have at least
97 blo .less8 @ 8 bytes to copy.
98
99 adds sum, sum, #0 @ C = 0
100 tst buf, #3 @ Test destination alignment
101 blne .not_aligned @ aligh destination, return here
102
1031: bics ip, len, #31
104 beq 3f
105
106 stmfd sp!, {r4 - r5}
1072: ldmia buf!, {td0, td1, td2, td3}
108 adcs sum, sum, td0
109 adcs sum, sum, td1
110 adcs sum, sum, td2
111 adcs sum, sum, td3
112 ldmia buf!, {td0, td1, td2, td3}
113 adcs sum, sum, td0
114 adcs sum, sum, td1
115 adcs sum, sum, td2
116 adcs sum, sum, td3
117 sub ip, ip, #32
118 teq ip, #0
119 bne 2b
120 ldmfd sp!, {r4 - r5}
121
1223: tst len, #0x1c @ should not change C
123 beq .less4
124
1254: ldr td0, [buf], #4
126 sub len, len, #4
127 adcs sum, sum, td0
128 tst len, #0x1c
129 bne 4b
130 b .less4
diff --git a/arch/arm26/lib/csumpartialcopy.S b/arch/arm26/lib/csumpartialcopy.S
deleted file mode 100644
index a1c4b5fdd498..000000000000
--- a/arch/arm26/lib/csumpartialcopy.S
+++ /dev/null
@@ -1,52 +0,0 @@
1/*
2 * linux/arch/arm26/lib/csumpartialcopy.S
3 *
4 * Copyright (C) 1995-1998 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12
13 .text
14
15/* Function: __u32 csum_partial_copy_nocheck(const char *src, char *dst, int len, __u32 sum)
16 * Params : r0 = src, r1 = dst, r2 = len, r3 = checksum
17 * Returns : r0 = new checksum
18 */
19
20 .macro save_regs
21 stmfd sp!, {r1, r4 - r8, fp, ip, lr, pc}
22 .endm
23
24 .macro load_regs,flags
25 LOADREGS(\flags,fp,{r1, r4 - r8, fp, sp, pc})
26 .endm
27
28 .macro load1b, reg1
29 ldrb \reg1, [r0], #1
30 .endm
31
32 .macro load2b, reg1, reg2
33 ldrb \reg1, [r0], #1
34 ldrb \reg2, [r0], #1
35 .endm
36
37 .macro load1l, reg1
38 ldr \reg1, [r0], #4
39 .endm
40
41 .macro load2l, reg1, reg2
42 ldr \reg1, [r0], #4
43 ldr \reg2, [r0], #4
44 .endm
45
46 .macro load4l, reg1, reg2, reg3, reg4
47 ldmia r0!, {\reg1, \reg2, \reg3, \reg4}
48 .endm
49
50#define FN_ENTRY ENTRY(csum_partial_copy_nocheck)
51
52#include "csumpartialcopygeneric.S"
diff --git a/arch/arm26/lib/csumpartialcopygeneric.S b/arch/arm26/lib/csumpartialcopygeneric.S
deleted file mode 100644
index 5249c3ad11db..000000000000
--- a/arch/arm26/lib/csumpartialcopygeneric.S
+++ /dev/null
@@ -1,352 +0,0 @@
1/*
2 * linux/arch/arm26/lib/csumpartialcopygeneric.S
3 *
4 * Copyright (C) 1995-2001 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * JMA 01/06/03 Commented out some shl0s; probobly irrelevant to arm26
11 *
12 */
13
14/*
15 * unsigned int
16 * csum_partial_copy_xxx(const char *src, char *dst, int len, int sum, )
17 * r0 = src, r1 = dst, r2 = len, r3 = sum
18 * Returns : r0 = checksum
19 *
20 * Note that 'tst' and 'teq' preserve the carry flag.
21 */
22
23/* Quick hack */
24 .macro save_regs
25 stmfd sp!, {r1, r4 - r8, fp, ip, lr, pc}
26 .endm
27
28/* end Quick Hack */
29
30src .req r0
31dst .req r1
32len .req r2
33sum .req r3
34
35.zero: mov r0, sum
36 load_regs ea
37
38 /*
39 * Align an unaligned destination pointer. We know that
40 * we have >= 8 bytes here, so we don't need to check
41 * the length. Note that the source pointer hasn't been
42 * aligned yet.
43 */
44.dst_unaligned: tst dst, #1
45 beq .dst_16bit
46
47 load1b ip
48 sub len, len, #1
49 adcs sum, sum, ip, lsl #byte(1) @ update checksum
50 strb ip, [dst], #1
51 tst dst, #2
52 moveq pc, lr @ dst is now 32bit aligned
53
54.dst_16bit: load2b r8, ip
55 sub len, len, #2
56 adcs sum, sum, r8, lsl #byte(0)
57 strb r8, [dst], #1
58 adcs sum, sum, ip, lsl #byte(1)
59 strb ip, [dst], #1
60 mov pc, lr @ dst is now 32bit aligned
61
62 /*
63 * Handle 0 to 7 bytes, with any alignment of source and
64 * destination pointers. Note that when we get here, C = 0
65 */
66.less8: teq len, #0 @ check for zero count
67 beq .zero
68
69 /* we must have at least one byte. */
70 tst dst, #1 @ dst 16-bit aligned
71 beq .less8_aligned
72
73 /* Align dst */
74 load1b ip
75 sub len, len, #1
76 adcs sum, sum, ip, lsl #byte(1) @ update checksum
77 strb ip, [dst], #1
78 tst len, #6
79 beq .less8_byteonly
80
811: load2b r8, ip
82 sub len, len, #2
83 adcs sum, sum, r8, lsl #byte(0)
84 strb r8, [dst], #1
85 adcs sum, sum, ip, lsl #byte(1)
86 strb ip, [dst], #1
87.less8_aligned: tst len, #6
88 bne 1b
89.less8_byteonly:
90 tst len, #1
91 beq .done
92 load1b r8
93 adcs sum, sum, r8, lsl #byte(0) @ update checksum
94 strb r8, [dst], #1
95 b .done
96
97FN_ENTRY
98 mov ip, sp
99 save_regs
100 sub fp, ip, #4
101
102 cmp len, #8 @ Ensure that we have at least
103 blo .less8 @ 8 bytes to copy.
104
105 adds sum, sum, #0 @ C = 0
106 tst dst, #3 @ Test destination alignment
107 blne .dst_unaligned @ align destination, return here
108
109 /*
110 * Ok, the dst pointer is now 32bit aligned, and we know
111 * that we must have more than 4 bytes to copy. Note
112 * that C contains the carry from the dst alignment above.
113 */
114
115 tst src, #3 @ Test source alignment
116 bne .src_not_aligned
117
118 /* Routine for src & dst aligned */
119
120 bics ip, len, #15
121 beq 2f
122
1231: load4l r4, r5, r6, r7
124 stmia dst!, {r4, r5, r6, r7}
125 adcs sum, sum, r4
126 adcs sum, sum, r5
127 adcs sum, sum, r6
128 adcs sum, sum, r7
129 sub ip, ip, #16
130 teq ip, #0
131 bne 1b
132
1332: ands ip, len, #12
134 beq 4f
135 tst ip, #8
136 beq 3f
137 load2l r4, r5
138 stmia dst!, {r4, r5}
139 adcs sum, sum, r4
140 adcs sum, sum, r5
141 tst ip, #4
142 beq 4f
143
1443: load1l r4
145 str r4, [dst], #4
146 adcs sum, sum, r4
147
1484: ands len, len, #3
149 beq .done
150 load1l r4
151 tst len, #2
152/* mov r5, r4, lsr #byte(0)
153FIXME? 0 Shift anyhow!
154*/
155 beq .exit
156 adcs sum, sum, r4, push #16
157 strb r5, [dst], #1
158 mov r5, r4, lsr #byte(1)
159 strb r5, [dst], #1
160 mov r5, r4, lsr #byte(2)
161.exit: tst len, #1
162 strneb r5, [dst], #1
163 andne r5, r5, #255
164 adcnes sum, sum, r5, lsl #byte(0)
165
166 /*
167 * If the dst pointer was not 16-bit aligned, we
168 * need to rotate the checksum here to get around
169 * the inefficient byte manipulations in the
170 * architecture independent code.
171 */
172.done: adc r0, sum, #0
173 ldr sum, [sp, #0] @ dst
174 tst sum, #1
175 movne sum, r0, lsl #8
176 orrne r0, sum, r0, lsr #24
177 load_regs ea
178
179.src_not_aligned:
180 adc sum, sum, #0 @ include C from dst alignment
181 and ip, src, #3
182 bic src, src, #3
183 load1l r5
184 cmp ip, #2
185 beq .src2_aligned
186 bhi .src3_aligned
187 mov r4, r5, pull #8 @ C = 0
188 bics ip, len, #15
189 beq 2f
1901: load4l r5, r6, r7, r8
191 orr r4, r4, r5, push #24
192 mov r5, r5, pull #8
193 orr r5, r5, r6, push #24
194 mov r6, r6, pull #8
195 orr r6, r6, r7, push #24
196 mov r7, r7, pull #8
197 orr r7, r7, r8, push #24
198 stmia dst!, {r4, r5, r6, r7}
199 adcs sum, sum, r4
200 adcs sum, sum, r5
201 adcs sum, sum, r6
202 adcs sum, sum, r7
203 mov r4, r8, pull #8
204 sub ip, ip, #16
205 teq ip, #0
206 bne 1b
2072: ands ip, len, #12
208 beq 4f
209 tst ip, #8
210 beq 3f
211 load2l r5, r6
212 orr r4, r4, r5, push #24
213 mov r5, r5, pull #8
214 orr r5, r5, r6, push #24
215 stmia dst!, {r4, r5}
216 adcs sum, sum, r4
217 adcs sum, sum, r5
218 mov r4, r6, pull #8
219 tst ip, #4
220 beq 4f
2213: load1l r5
222 orr r4, r4, r5, push #24
223 str r4, [dst], #4
224 adcs sum, sum, r4
225 mov r4, r5, pull #8
2264: ands len, len, #3
227 beq .done
228/* mov r5, r4, lsr #byte(0)
229FIXME? 0 Shift anyhow
230*/
231 tst len, #2
232 beq .exit
233 adcs sum, sum, r4, push #16
234 strb r5, [dst], #1
235 mov r5, r4, lsr #byte(1)
236 strb r5, [dst], #1
237 mov r5, r4, lsr #byte(2)
238 b .exit
239
240.src2_aligned: mov r4, r5, pull #16
241 adds sum, sum, #0
242 bics ip, len, #15
243 beq 2f
2441: load4l r5, r6, r7, r8
245 orr r4, r4, r5, push #16
246 mov r5, r5, pull #16
247 orr r5, r5, r6, push #16
248 mov r6, r6, pull #16
249 orr r6, r6, r7, push #16
250 mov r7, r7, pull #16
251 orr r7, r7, r8, push #16
252 stmia dst!, {r4, r5, r6, r7}
253 adcs sum, sum, r4
254 adcs sum, sum, r5
255 adcs sum, sum, r6
256 adcs sum, sum, r7
257 mov r4, r8, pull #16
258 sub ip, ip, #16
259 teq ip, #0
260 bne 1b
2612: ands ip, len, #12
262 beq 4f
263 tst ip, #8
264 beq 3f
265 load2l r5, r6
266 orr r4, r4, r5, push #16
267 mov r5, r5, pull #16
268 orr r5, r5, r6, push #16
269 stmia dst!, {r4, r5}
270 adcs sum, sum, r4
271 adcs sum, sum, r5
272 mov r4, r6, pull #16
273 tst ip, #4
274 beq 4f
2753: load1l r5
276 orr r4, r4, r5, push #16
277 str r4, [dst], #4
278 adcs sum, sum, r4
279 mov r4, r5, pull #16
2804: ands len, len, #3
281 beq .done
282/* mov r5, r4, lsr #byte(0)
283FIXME? 0 Shift anyhow
284*/
285 tst len, #2
286 beq .exit
287 adcs sum, sum, r4
288 strb r5, [dst], #1
289 mov r5, r4, lsr #byte(1)
290 strb r5, [dst], #1
291 tst len, #1
292 beq .done
293 load1b r5
294 b .exit
295
296.src3_aligned: mov r4, r5, pull #24
297 adds sum, sum, #0
298 bics ip, len, #15
299 beq 2f
3001: load4l r5, r6, r7, r8
301 orr r4, r4, r5, push #8
302 mov r5, r5, pull #24
303 orr r5, r5, r6, push #8
304 mov r6, r6, pull #24
305 orr r6, r6, r7, push #8
306 mov r7, r7, pull #24
307 orr r7, r7, r8, push #8
308 stmia dst!, {r4, r5, r6, r7}
309 adcs sum, sum, r4
310 adcs sum, sum, r5
311 adcs sum, sum, r6
312 adcs sum, sum, r7
313 mov r4, r8, pull #24
314 sub ip, ip, #16
315 teq ip, #0
316 bne 1b
3172: ands ip, len, #12
318 beq 4f
319 tst ip, #8
320 beq 3f
321 load2l r5, r6
322 orr r4, r4, r5, push #8
323 mov r5, r5, pull #24
324 orr r5, r5, r6, push #8
325 stmia dst!, {r4, r5}
326 adcs sum, sum, r4
327 adcs sum, sum, r5
328 mov r4, r6, pull #24
329 tst ip, #4
330 beq 4f
3313: load1l r5
332 orr r4, r4, r5, push #8
333 str r4, [dst], #4
334 adcs sum, sum, r4
335 mov r4, r5, pull #24
3364: ands len, len, #3
337 beq .done
338/* mov r5, r4, lsr #byte(0)
339FIXME? 0 Shift anyhow
340*/
341 tst len, #2
342 beq .exit
343 strb r5, [dst], #1
344 adcs sum, sum, r4
345 load1l r4
346/* mov r5, r4, lsr #byte(0)
347FIXME? 0 Shift anyhow
348*/
349 strb r5, [dst], #1
350 adcs sum, sum, r4, push #24
351 mov r5, r4, lsr #byte(1)
352 b .exit
diff --git a/arch/arm26/lib/csumpartialcopyuser.S b/arch/arm26/lib/csumpartialcopyuser.S
deleted file mode 100644
index a98eea74305a..000000000000
--- a/arch/arm26/lib/csumpartialcopyuser.S
+++ /dev/null
@@ -1,114 +0,0 @@
1/*
2 * linux/arch/arm26/lib/csumpartialcopyuser.S
3 *
4 * Copyright (C) 1995-1998 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/errno.h>
13#include <asm/asm-offsets.h>
14
15 .text
16
17 .macro save_regs
18 stmfd sp!, {r1 - r2, r4 - r9, fp, ip, lr, pc}
19 mov r9, sp, lsr #13
20 mov r9, r9, lsl #13
21 ldr r9, [r9, #TSK_ADDR_LIMIT]
22 mov r9, r9, lsr #24
23 .endm
24
25 .macro load_regs,flags
26 ldm\flags fp, {r1, r2, r4-r9, fp, sp, pc}^
27 .endm
28
29 .macro load1b, reg1
30 tst r9, #0x01
319999: ldreqbt \reg1, [r0], #1
32 ldrneb \reg1, [r0], #1
33 .section __ex_table, "a"
34 .align 3
35 .long 9999b, 6001f
36 .previous
37 .endm
38
39 .macro load2b, reg1, reg2
40 tst r9, #0x01
419999: ldreqbt \reg1, [r0], #1
42 ldrneb \reg1, [r0], #1
439998: ldreqbt \reg2, [r0], #1
44 ldrneb \reg2, [r0], #1
45 .section __ex_table, "a"
46 .long 9999b, 6001f
47 .long 9998b, 6001f
48 .previous
49 .endm
50
51 .macro load1l, reg1
52 tst r9, #0x01
539999: ldreqt \reg1, [r0], #4
54 ldrne \reg1, [r0], #4
55 .section __ex_table, "a"
56 .align 3
57 .long 9999b, 6001f
58 .previous
59 .endm
60
61 .macro load2l, reg1, reg2
62 tst r9, #0x01
63 ldmneia r0!, {\reg1, \reg2}
649999: ldreqt \reg1, [r0], #4
659998: ldreqt \reg2, [r0], #4
66 .section __ex_table, "a"
67 .long 9999b, 6001f
68 .long 9998b, 6001f
69 .previous
70 .endm
71
72 .macro load4l, reg1, reg2, reg3, reg4
73 tst r9, #0x01
74 ldmneia r0!, {\reg1, \reg2, \reg3, \reg4}
759999: ldreqt \reg1, [r0], #4
769998: ldreqt \reg2, [r0], #4
779997: ldreqt \reg3, [r0], #4
789996: ldreqt \reg4, [r0], #4
79 .section __ex_table, "a"
80 .long 9999b, 6001f
81 .long 9998b, 6001f
82 .long 9997b, 6001f
83 .long 9996b, 6001f
84 .previous
85 .endm
86
87/*
88 * unsigned int
89 * csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *err_ptr)
90 * r0 = src, r1 = dst, r2 = len, r3 = sum, [sp] = *err_ptr
91 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
92 */
93
94#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
95
96#include "csumpartialcopygeneric.S"
97
98/*
99 * FIXME: minor buglet here
100 * We don't return the checksum for the data present in the buffer. To do
101 * so properly, we would have to add in whatever registers were loaded before
102 * the fault, which, with the current asm above is not predictable.
103 */
104 .align 4
1056001: mov r4, #-EFAULT
106 ldr r5, [fp, #4] @ *err_ptr
107 str r4, [r5]
108 ldmia sp, {r1, r2} @ retrieve dst, len
109 add r2, r2, r1
110 mov r0, #0 @ zero the buffer
1116002: teq r2, r1
112 strneb r0, [r1], #1
113 bne 6002b
114 load_regs ea
diff --git a/arch/arm26/lib/delay.S b/arch/arm26/lib/delay.S
deleted file mode 100644
index 66f2b68e1b13..000000000000
--- a/arch/arm26/lib/delay.S
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * linux/arch/arm26/lib/delay.S
3 *
4 * Copyright (C) 1995, 1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12 .text
13
14LC0: .word loops_per_jiffy
15
16/*
17 * 0 <= r0 <= 2000
18 */
19ENTRY(udelay)
20 mov r2, #0x6800
21 orr r2, r2, #0x00db
22 mul r1, r0, r2
23 ldr r2, LC0
24 ldr r2, [r2]
25 mov r1, r1, lsr #11
26 mov r2, r2, lsr #11
27 mul r0, r1, r2
28 movs r0, r0, lsr #6
29 RETINSTR(moveq,pc,lr)
30
31/*
32 * loops = (r0 * 0x10c6 * 100 * loops_per_jiffy) / 2^32
33 *
34 * Oh, if only we had a cycle counter...
35 */
36
37@ Delay routine
38ENTRY(__delay)
39 subs r0, r0, #1
40#if 0
41 RETINSTR(movls,pc,lr)
42 subs r0, r0, #1
43 RETINSTR(movls,pc,lr)
44 subs r0, r0, #1
45 RETINSTR(movls,pc,lr)
46 subs r0, r0, #1
47 RETINSTR(movls,pc,lr)
48 subs r0, r0, #1
49 RETINSTR(movls,pc,lr)
50 subs r0, r0, #1
51 RETINSTR(movls,pc,lr)
52 subs r0, r0, #1
53 RETINSTR(movls,pc,lr)
54 subs r0, r0, #1
55#endif
56 bhi __delay
57 RETINSTR(mov,pc,lr)
diff --git a/arch/arm26/lib/ecard.S b/arch/arm26/lib/ecard.S
deleted file mode 100644
index 658bc4529c9d..000000000000
--- a/arch/arm26/lib/ecard.S
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * linux/arch/arm26/lib/ecard.S
3 *
4 * Copyright (C) 1995, 1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/hardware.h>
13
14#define CPSR2SPSR(rt)
15
16@ Purpose: call an expansion card loader to read bytes.
17@ Proto : char read_loader(int offset, char *card_base, char *loader);
18@ Returns: byte read
19
20ENTRY(ecard_loader_read)
21 stmfd sp!, {r4 - r12, lr}
22 mov r11, r1
23 mov r1, r0
24 CPSR2SPSR(r0)
25 mov lr, pc
26 mov pc, r2
27 LOADREGS(fd, sp!, {r4 - r12, pc})
28
29@ Purpose: call an expansion card loader to reset the card
30@ Proto : void read_loader(int card_base, char *loader);
31@ Returns: byte read
32
33ENTRY(ecard_loader_reset)
34 stmfd sp!, {r4 - r12, lr}
35 mov r11, r0
36 CPSR2SPSR(r0)
37 mov lr, pc
38 add pc, r1, #8
39 LOADREGS(fd, sp!, {r4 - r12, pc})
40
diff --git a/arch/arm26/lib/findbit.S b/arch/arm26/lib/findbit.S
deleted file mode 100644
index 26f67cccc37c..000000000000
--- a/arch/arm26/lib/findbit.S
+++ /dev/null
@@ -1,67 +0,0 @@
1/*
2 * linux/arch/arm/lib/findbit.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * 16th March 2001 - John Ripley <jripley@sonicblue.com>
11 * Fixed so that "size" is an exclusive not an inclusive quantity.
12 * All users of these functions expect exclusive sizes, and may
13 * also call with zero size.
14 * Reworked by rmk.
15 */
16#include <linux/linkage.h>
17#include <asm/assembler.h>
18 .text
19
20/*
21 * Purpose : Find a 'zero' bit
22 * Prototype: int find_first_zero_bit(void *addr, unsigned int maxbit);
23 */
24ENTRY(_find_first_zero_bit_le)
25 teq r1, #0
26 beq 3f
27 mov r2, #0
281: ldrb r3, [r0, r2, lsr #3]
29 eors r3, r3, #0xff @ invert bits
30 bne .found @ any now set - found zero bit
31 add r2, r2, #8 @ next bit pointer
322: cmp r2, r1 @ any more?
33 blo 1b
343: mov r0, r1 @ no free bits
35 RETINSTR(mov,pc,lr)
36
37/*
38 * Purpose : Find next 'zero' bit
39 * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset)
40 */
41ENTRY(_find_next_zero_bit_le)
42 teq r1, #0
43 beq 2b
44 ands ip, r2, #7
45 beq 1b @ If new byte, goto old routine
46 ldrb r3, [r0, r2, lsr #3]
47 eor r3, r3, #0xff @ now looking for a 1 bit
48 movs r3, r3, lsr ip @ shift off unused bits
49 bne .found
50 orr r2, r2, #7 @ if zero, then no bits here
51 add r2, r2, #1 @ align bit pointer
52 b 2b @ loop for next bit
53
54/*
55 * One or more bits in the LSB of r3 are assumed to be set.
56 */
57.found: tst r3, #0x0f
58 addeq r2, r2, #4
59 movne r3, r3, lsl #4
60 tst r3, #0x30
61 addeq r2, r2, #2
62 movne r3, r3, lsl #2
63 tst r3, #0x40
64 addeq r2, r2, #1
65 mov r0, r2
66 RETINSTR(mov,pc,lr)
67
diff --git a/arch/arm26/lib/floppydma.S b/arch/arm26/lib/floppydma.S
deleted file mode 100644
index e99ebbb20353..000000000000
--- a/arch/arm26/lib/floppydma.S
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * linux/arch/arm26/lib/floppydma.S
3 *
4 * Copyright (C) 1995, 1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12 .text
13
14 .global floppy_fiqin_end
15ENTRY(floppy_fiqin_start)
16 subs r9, r9, #1
17 ldrgtb r12, [r11, #-4]
18 ldrleb r12, [r11], #0
19 strb r12, [r10], #1
20 subs pc, lr, #4
21floppy_fiqin_end:
22
23 .global floppy_fiqout_end
24ENTRY(floppy_fiqout_start)
25 subs r9, r9, #1
26 ldrgeb r12, [r10], #1
27 movlt r12, #0
28 strleb r12, [r11], #0
29 subles pc, lr, #4
30 strb r12, [r11, #-4]
31 subs pc, lr, #4
32floppy_fiqout_end:
diff --git a/arch/arm26/lib/gcclib.h b/arch/arm26/lib/gcclib.h
deleted file mode 100644
index 9895e78904b5..000000000000
--- a/arch/arm26/lib/gcclib.h
+++ /dev/null
@@ -1,21 +0,0 @@
1/* gcclib.h -- definitions for various functions 'borrowed' from gcc-2.95.3 */
2/* I Molton 29/07/01 */
3
4#define BITS_PER_UNIT 8
5#define SI_TYPE_SIZE (sizeof (SItype) * BITS_PER_UNIT)
6
7typedef unsigned int UQItype __attribute__ ((mode (QI)));
8typedef int SItype __attribute__ ((mode (SI)));
9typedef unsigned int USItype __attribute__ ((mode (SI)));
10typedef int DItype __attribute__ ((mode (DI)));
11typedef int word_type __attribute__ ((mode (__word__)));
12typedef unsigned int UDItype __attribute__ ((mode (DI)));
13
14struct DIstruct {SItype low, high;};
15
16typedef union
17{
18 struct DIstruct s;
19 DItype ll;
20} DIunion;
21
diff --git a/arch/arm26/lib/getuser.S b/arch/arm26/lib/getuser.S
deleted file mode 100644
index 2b1de7fbfe1f..000000000000
--- a/arch/arm26/lib/getuser.S
+++ /dev/null
@@ -1,112 +0,0 @@
1/*
2 * linux/arch/arm26/lib/getuser.S
3 *
4 * Copyright (C) 2001 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Idea from x86 version, (C) Copyright 1998 Linus Torvalds
11 *
12 * These functions have a non-standard call interface to make them more
13 * efficient, especially as they return an error value in addition to
14 * the "real" return value.
15 *
16 * __get_user_X
17 *
18 * Inputs: r0 contains the address
19 * Outputs: r0 is the error code
20 * r1, r2 contains the zero-extended value
21 * lr corrupted
22 *
23 * No other registers must be altered. (see include/asm-arm/uaccess.h
24 * for specific ASM register usage).
25 *
26 * Note that ADDR_LIMIT is either 0 or 0xc0000000.
27 * Note also that it is intended that __get_user_bad is not global.
28 */
29#include <asm/asm-offsets.h>
30#include <asm/thread_info.h>
31#include <asm/errno.h>
32
33 .global __get_user_1
34__get_user_1:
35 bic r1, sp, #0x1f00
36 bic r1, r1, #0x00ff
37 str lr, [sp, #-4]!
38 ldr r1, [r1, #TI_ADDR_LIMIT]
39 sub r1, r1, #1
40 cmp r0, r1
41 bge __get_user_bad
42 cmp r0, #0x02000000
431: ldrlsbt r1, [r0]
44 ldrgeb r1, [r0]
45 mov r0, #0
46 ldmfd sp!, {pc}^
47
48 .global __get_user_2
49__get_user_2:
50 bic r2, sp, #0x1f00
51 bic r2, r2, #0x00ff
52 str lr, [sp, #-4]!
53 ldr r2, [r2, #TI_ADDR_LIMIT]
54 sub r2, r2, #2
55 cmp r0, r2
56 bge __get_user_bad
57 cmp r0, #0x02000000
582: ldrlsbt r1, [r0], #1
593: ldrlsbt r2, [r0]
60 ldrgeb r1, [r0], #1
61 ldrgeb r2, [r0]
62 orr r1, r1, r2, lsl #8
63 mov r0, #0
64 ldmfd sp!, {pc}^
65
66 .global __get_user_4
67__get_user_4:
68 bic r1, sp, #0x1f00
69 bic r1, r1, #0x00ff
70 str lr, [sp, #-4]!
71 ldr r1, [r1, #TI_ADDR_LIMIT]
72 sub r1, r1, #4
73 cmp r0, r1
74 bge __get_user_bad
75 cmp r0, #0x02000000
764: ldrlst r1, [r0]
77 ldrge r1, [r0]
78 mov r0, #0
79 ldmfd sp!, {pc}^
80
81 .global __get_user_8
82__get_user_8:
83 bic r2, sp, #0x1f00
84 bic r2, r2, #0x00ff
85 str lr, [sp, #-4]!
86 ldr r2, [r2, #TI_ADDR_LIMIT]
87 sub r2, r2, #8
88 cmp r0, r2
89 bge __get_user_bad_8
90 cmp r0, #0x02000000
915: ldrlst r1, [r0], #4
926: ldrlst r2, [r0]
93 ldrge r1, [r0], #4
94 ldrge r2, [r0]
95 mov r0, #0
96 ldmfd sp!, {pc}^
97
98__get_user_bad_8:
99 mov r2, #0
100__get_user_bad:
101 mov r1, #0
102 mov r0, #-EFAULT
103 ldmfd sp!, {pc}^
104
105.section __ex_table, "a"
106 .long 1b, __get_user_bad
107 .long 2b, __get_user_bad
108 .long 3b, __get_user_bad
109 .long 4b, __get_user_bad
110 .long 5b, __get_user_bad_8
111 .long 6b, __get_user_bad_8
112.previous
diff --git a/arch/arm26/lib/io-acorn.S b/arch/arm26/lib/io-acorn.S
deleted file mode 100644
index 5f62ade5be39..000000000000
--- a/arch/arm26/lib/io-acorn.S
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * linux/arch/arm26/lib/io-acorn.S
3 *
4 * Copyright (C) 1995, 1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/hardware.h>
13
14 .text
15 .align
16
17 .equ diff_pcio_base, PCIO_BASE - IO_BASE
18
19 .macro outw2 rd
20 mov r8, \rd, lsl #16
21 orr r8, r8, r8, lsr #16
22 str r8, [r3, r0, lsl #2]
23 mov r8, \rd, lsr #16
24 orr r8, r8, r8, lsl #16
25 str r8, [r3, r0, lsl #2]
26 .endm
27
28 .macro inw2 rd, mask, temp
29 ldr \rd, [r0]
30 and \rd, \rd, \mask
31 ldr \temp, [r0]
32 orr \rd, \rd, \temp, lsl #16
33 .endm
34
35 .macro addr rd
36 tst \rd, #0x80000000
37 mov \rd, \rd, lsl #2
38 add \rd, \rd, #IO_BASE
39 addeq \rd, \rd, #diff_pcio_base
40 .endm
41
42.iosl_warning:
43 .ascii "<4>insl/outsl not implemented, called from %08lX\0"
44 .align
45
46/*
47 * These make no sense on Acorn machines.
48 * Print a warning message.
49 */
50ENTRY(insl)
51ENTRY(outsl)
52 adr r0, .iosl_warning
53 mov r1, lr
54 b printk
55
56@ Purpose: write a memc register
57@ Proto : void memc_write(int register, int value);
58@ Returns: nothing
59
60ENTRY(memc_write)
61 cmp r0, #7
62 RETINSTR(movgt,pc,lr)
63 mov r0, r0, lsl #17
64 mov r1, r1, lsl #15
65 mov r1, r1, lsr #17
66 orr r0, r0, r1, lsl #2
67 add r0, r0, #0x03600000
68 strb r0, [r0]
69 RETINSTR(mov,pc,lr)
70
diff --git a/arch/arm26/lib/io-readsb.S b/arch/arm26/lib/io-readsb.S
deleted file mode 100644
index 4c4d99c05856..000000000000
--- a/arch/arm26/lib/io-readsb.S
+++ /dev/null
@@ -1,116 +0,0 @@
1/*
2 * linux/arch/arm26/lib/io-readsb.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/hardware.h>
13
14.insb_align: rsb ip, ip, #4
15 cmp ip, r2
16 movgt ip, r2
17 cmp ip, #2
18 ldrb r3, [r0]
19 strb r3, [r1], #1
20 ldrgeb r3, [r0]
21 strgeb r3, [r1], #1
22 ldrgtb r3, [r0]
23 strgtb r3, [r1], #1
24 subs r2, r2, ip
25 bne .insb_aligned
26
27ENTRY(__raw_readsb)
28 teq r2, #0 @ do we have to check for the zero len?
29 moveq pc, lr
30 ands ip, r1, #3
31 bne .insb_align
32
33.insb_aligned: stmfd sp!, {r4 - r6, lr}
34
35 subs r2, r2, #16
36 bmi .insb_no_16
37
38.insb_16_lp: ldrb r3, [r0]
39 ldrb r4, [r0]
40 orr r3, r3, r4, lsl #8
41 ldrb r4, [r0]
42 orr r3, r3, r4, lsl #16
43 ldrb r4, [r0]
44 orr r3, r3, r4, lsl #24
45 ldrb r4, [r0]
46 ldrb r5, [r0]
47 orr r4, r4, r5, lsl #8
48 ldrb r5, [r0]
49 orr r4, r4, r5, lsl #16
50 ldrb r5, [r0]
51 orr r4, r4, r5, lsl #24
52 ldrb r5, [r0]
53 ldrb r6, [r0]
54 orr r5, r5, r6, lsl #8
55 ldrb r6, [r0]
56 orr r5, r5, r6, lsl #16
57 ldrb r6, [r0]
58 orr r5, r5, r6, lsl #24
59 ldrb r6, [r0]
60 ldrb ip, [r0]
61 orr r6, r6, ip, lsl #8
62 ldrb ip, [r0]
63 orr r6, r6, ip, lsl #16
64 ldrb ip, [r0]
65 orr r6, r6, ip, lsl #24
66 stmia r1!, {r3 - r6}
67
68 subs r2, r2, #16
69 bpl .insb_16_lp
70
71 tst r2, #15
72 LOADREGS(eqfd, sp!, {r4 - r6, pc})
73
74.insb_no_16: tst r2, #8
75 beq .insb_no_8
76
77 ldrb r3, [r0]
78 ldrb r4, [r0]
79 orr r3, r3, r4, lsl #8
80 ldrb r4, [r0]
81 orr r3, r3, r4, lsl #16
82 ldrb r4, [r0]
83 orr r3, r3, r4, lsl #24
84 ldrb r4, [r0]
85 ldrb r5, [r0]
86 orr r4, r4, r5, lsl #8
87 ldrb r5, [r0]
88 orr r4, r4, r5, lsl #16
89 ldrb r5, [r0]
90 orr r4, r4, r5, lsl #24
91 stmia r1!, {r3, r4}
92
93.insb_no_8: tst r2, #4
94 beq .insb_no_4
95
96 ldrb r3, [r0]
97 ldrb r4, [r0]
98 orr r3, r3, r4, lsl #8
99 ldrb r4, [r0]
100 orr r3, r3, r4, lsl #16
101 ldrb r4, [r0]
102 orr r3, r3, r4, lsl #24
103 str r3, [r1], #4
104
105.insb_no_4: ands r2, r2, #3
106 LOADREGS(eqfd, sp!, {r4 - r6, pc})
107
108 cmp r2, #2
109 ldrb r3, [r0]
110 strb r3, [r1], #1
111 ldrgeb r3, [r0]
112 strgeb r3, [r1], #1
113 ldrgtb r3, [r0]
114 strgtb r3, [r1]
115
116 LOADREGS(fd, sp!, {r4 - r6, pc})
diff --git a/arch/arm26/lib/io-readsl.S b/arch/arm26/lib/io-readsl.S
deleted file mode 100644
index 7be208bd23c6..000000000000
--- a/arch/arm26/lib/io-readsl.S
+++ /dev/null
@@ -1,78 +0,0 @@
1/*
2 * linux/arch/arm26/lib/io-readsl.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/hardware.h>
13
14/*
15 * Note that some reads can be aligned on half-word boundaries.
16 */
17ENTRY(__raw_readsl)
18 teq r2, #0 @ do we have to check for the zero len?
19 moveq pc, lr
20 ands ip, r1, #3
21 bne 2f
22
231: ldr r3, [r0]
24 str r3, [r1], #4
25 subs r2, r2, #1
26 bne 1b
27 mov pc, lr
28
292: cmp ip, #2
30 ldr ip, [r0]
31 blt 4f
32 bgt 6f
33
34 strb ip, [r1], #1
35 mov ip, ip, lsr #8
36 strb ip, [r1], #1
37 mov ip, ip, lsr #8
383: subs r2, r2, #1
39 ldrne r3, [r0]
40 orrne ip, ip, r3, lsl #16
41 strne ip, [r1], #4
42 movne ip, r3, lsr #16
43 bne 3b
44 strb ip, [r1], #1
45 mov ip, ip, lsr #8
46 strb ip, [r1], #1
47 mov pc, lr
48
494: strb ip, [r1], #1
50 mov ip, ip, lsr #8
51 strb ip, [r1], #1
52 mov ip, ip, lsr #8
53 strb ip, [r1], #1
54 mov ip, ip, lsr #8
555: subs r2, r2, #1
56 ldrne r3, [r0]
57 orrne ip, ip, r3, lsl #8
58 strne ip, [r1], #4
59 movne ip, r3, lsr #24
60 bne 5b
61 strb ip, [r1], #1
62 mov pc, lr
63
646: strb ip, [r1], #1
65 mov ip, ip, lsr #8
667: subs r2, r2, #1
67 ldrne r3, [r0]
68 orrne ip, ip, r3, lsl #24
69 strne ip, [r1], #4
70 movne ip, r3, lsr #8
71 bne 7b
72 strb ip, [r1], #1
73 mov ip, ip, lsr #8
74 strb ip, [r1], #1
75 mov ip, ip, lsr #8
76 strb ip, [r1], #1
77 mov pc, lr
78
diff --git a/arch/arm26/lib/io-readsw.S b/arch/arm26/lib/io-readsw.S
deleted file mode 100644
index c65c1f28fcff..000000000000
--- a/arch/arm26/lib/io-readsw.S
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 * linux/arch/arm26/lib/io-readsw.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/hardware.h>
13
14.insw_bad_alignment:
15 adr r0, .insw_bad_align_msg
16 mov r2, lr
17 b panic
18.insw_bad_align_msg:
19 .asciz "insw: bad buffer alignment (0x%p, lr=0x%08lX)\n"
20 .align
21
22.insw_align: tst r1, #1
23 bne .insw_bad_alignment
24
25 ldr r3, [r0]
26 strb r3, [r1], #1
27 mov r3, r3, lsr #8
28 strb r3, [r1], #1
29
30 subs r2, r2, #1
31 RETINSTR(moveq, pc, lr)
32
33ENTRY(__raw_readsw)
34 teq r2, #0 @ do we have to check for the zero len?
35 moveq pc, lr
36 tst r1, #3
37 bne .insw_align
38
39.insw_aligned: mov ip, #0xff
40 orr ip, ip, ip, lsl #8
41 stmfd sp!, {r4, r5, r6, lr}
42
43 subs r2, r2, #8
44 bmi .no_insw_8
45
46.insw_8_lp: ldr r3, [r0]
47 and r3, r3, ip
48 ldr r4, [r0]
49 orr r3, r3, r4, lsl #16
50
51 ldr r4, [r0]
52 and r4, r4, ip
53 ldr r5, [r0]
54 orr r4, r4, r5, lsl #16
55
56 ldr r5, [r0]
57 and r5, r5, ip
58 ldr r6, [r0]
59 orr r5, r5, r6, lsl #16
60
61 ldr r6, [r0]
62 and r6, r6, ip
63 ldr lr, [r0]
64 orr r6, r6, lr, lsl #16
65
66 stmia r1!, {r3 - r6}
67
68 subs r2, r2, #8
69 bpl .insw_8_lp
70
71 tst r2, #7
72 LOADREGS(eqfd, sp!, {r4, r5, r6, pc})
73
74.no_insw_8: tst r2, #4
75 beq .no_insw_4
76
77 ldr r3, [r0]
78 and r3, r3, ip
79 ldr r4, [r0]
80 orr r3, r3, r4, lsl #16
81
82 ldr r4, [r0]
83 and r4, r4, ip
84 ldr r5, [r0]
85 orr r4, r4, r5, lsl #16
86
87 stmia r1!, {r3, r4}
88
89.no_insw_4: tst r2, #2
90 beq .no_insw_2
91
92 ldr r3, [r0]
93 and r3, r3, ip
94 ldr r4, [r0]
95 orr r3, r3, r4, lsl #16
96
97 str r3, [r1], #4
98
99.no_insw_2: tst r2, #1
100 ldrne r3, [r0]
101 strneb r3, [r1], #1
102 movne r3, r3, lsr #8
103 strneb r3, [r1]
104
105 LOADREGS(fd, sp!, {r4, r5, r6, pc})
106
107
diff --git a/arch/arm26/lib/io-writesb.S b/arch/arm26/lib/io-writesb.S
deleted file mode 100644
index 16251b4d5101..000000000000
--- a/arch/arm26/lib/io-writesb.S
+++ /dev/null
@@ -1,122 +0,0 @@
1/*
2 * linux/arch/arm26/lib/io-writesb.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/hardware.h>
13
14.outsb_align: rsb ip, ip, #4
15 cmp ip, r2
16 movgt ip, r2
17 cmp ip, #2
18 ldrb r3, [r1], #1
19 strb r3, [r0]
20 ldrgeb r3, [r1], #1
21 strgeb r3, [r0]
22 ldrgtb r3, [r1], #1
23 strgtb r3, [r0]
24 subs r2, r2, ip
25 bne .outsb_aligned
26
27ENTRY(__raw_writesb)
28 teq r2, #0 @ do we have to check for the zero len?
29 moveq pc, lr
30 ands ip, r1, #3
31 bne .outsb_align
32
33.outsb_aligned: stmfd sp!, {r4 - r6, lr}
34
35 subs r2, r2, #16
36 bmi .outsb_no_16
37
38.outsb_16_lp: ldmia r1!, {r3 - r6}
39
40 strb r3, [r0]
41 mov r3, r3, lsr #8
42 strb r3, [r0]
43 mov r3, r3, lsr #8
44 strb r3, [r0]
45 mov r3, r3, lsr #8
46 strb r3, [r0]
47
48 strb r4, [r0]
49 mov r4, r4, lsr #8
50 strb r4, [r0]
51 mov r4, r4, lsr #8
52 strb r4, [r0]
53 mov r4, r4, lsr #8
54 strb r4, [r0]
55
56 strb r5, [r0]
57 mov r5, r5, lsr #8
58 strb r5, [r0]
59 mov r5, r5, lsr #8
60 strb r5, [r0]
61 mov r5, r5, lsr #8
62 strb r5, [r0]
63
64 strb r6, [r0]
65 mov r6, r6, lsr #8
66 strb r6, [r0]
67 mov r6, r6, lsr #8
68 strb r6, [r0]
69 mov r6, r6, lsr #8
70 strb r6, [r0]
71
72 subs r2, r2, #16
73 bpl .outsb_16_lp
74
75 tst r2, #15
76 LOADREGS(eqfd, sp!, {r4 - r6, pc})
77
78.outsb_no_16: tst r2, #8
79 beq .outsb_no_8
80
81 ldmia r1!, {r3, r4}
82
83 strb r3, [r0]
84 mov r3, r3, lsr #8
85 strb r3, [r0]
86 mov r3, r3, lsr #8
87 strb r3, [r0]
88 mov r3, r3, lsr #8
89 strb r3, [r0]
90
91 strb r4, [r0]
92 mov r4, r4, lsr #8
93 strb r4, [r0]
94 mov r4, r4, lsr #8
95 strb r4, [r0]
96 mov r4, r4, lsr #8
97 strb r4, [r0]
98
99.outsb_no_8: tst r2, #4
100 beq .outsb_no_4
101
102 ldr r3, [r1], #4
103 strb r3, [r0]
104 mov r3, r3, lsr #8
105 strb r3, [r0]
106 mov r3, r3, lsr #8
107 strb r3, [r0]
108 mov r3, r3, lsr #8
109 strb r3, [r0]
110
111.outsb_no_4: ands r2, r2, #3
112 LOADREGS(eqfd, sp!, {r4 - r6, pc})
113
114 cmp r2, #2
115 ldrb r3, [r1], #1
116 strb r3, [r0]
117 ldrgeb r3, [r1], #1
118 strgeb r3, [r0]
119 ldrgtb r3, [r1]
120 strgtb r3, [r0]
121
122 LOADREGS(fd, sp!, {r4 - r6, pc})
diff --git a/arch/arm26/lib/io-writesl.S b/arch/arm26/lib/io-writesl.S
deleted file mode 100644
index 4d6049b16e71..000000000000
--- a/arch/arm26/lib/io-writesl.S
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * linux/arch/arm26/lib/io-writesl.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/hardware.h>
13
14ENTRY(__raw_writesl)
15 teq r2, #0 @ do we have to check for the zero len?
16 moveq pc, lr
17 ands ip, r1, #3
18 bne 2f
19
201: ldr r3, [r1], #4
21 str r3, [r0]
22 subs r2, r2, #1
23 bne 1b
24 mov pc, lr
25
262: bic r1, r1, #3
27 cmp ip, #2
28 ldr r3, [r1], #4
29 bgt 4f
30 blt 5f
31
323: mov ip, r3, lsr #16
33 ldr r3, [r1], #4
34 orr ip, ip, r3, lsl #16
35 str ip, [r0]
36 subs r2, r2, #1
37 bne 3b
38 mov pc, lr
39
404: mov ip, r3, lsr #24
41 ldr r3, [r1], #4
42 orr ip, ip, r3, lsl #8
43 str ip, [r0]
44 subs r2, r2, #1
45 bne 4b
46 mov pc, lr
47
485: mov ip, r3, lsr #8
49 ldr r3, [r1], #4
50 orr ip, ip, r3, lsl #24
51 str ip, [r0]
52 subs r2, r2, #1
53 bne 5b
54 mov pc, lr
55
56
diff --git a/arch/arm26/lib/io-writesw.S b/arch/arm26/lib/io-writesw.S
deleted file mode 100644
index a24f891f6b1c..000000000000
--- a/arch/arm26/lib/io-writesw.S
+++ /dev/null
@@ -1,127 +0,0 @@
1/*
2 * linux/arch/arm26/lib/io-writesw.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/hardware.h>
13
14.outsw_bad_alignment:
15 adr r0, .outsw_bad_align_msg
16 mov r2, lr
17 b panic
18.outsw_bad_align_msg:
19 .asciz "outsw: bad buffer alignment (0x%p, lr=0x%08lX)\n"
20 .align
21
22.outsw_align: tst r1, #1
23 bne .outsw_bad_alignment
24
25 add r1, r1, #2
26
27 ldr r3, [r1, #-4]
28 mov r3, r3, lsr #16
29 orr r3, r3, r3, lsl #16
30 str r3, [r0]
31 subs r2, r2, #1
32 RETINSTR(moveq, pc, lr)
33
34ENTRY(__raw_writesw)
35 teq r2, #0 @ do we have to check for the zero len?
36 moveq pc, lr
37 tst r1, #3
38 bne .outsw_align
39
40.outsw_aligned: stmfd sp!, {r4, r5, r6, lr}
41
42 subs r2, r2, #8
43 bmi .no_outsw_8
44
45.outsw_8_lp: ldmia r1!, {r3, r4, r5, r6}
46
47 mov ip, r3, lsl #16
48 orr ip, ip, ip, lsr #16
49 str ip, [r0]
50
51 mov ip, r3, lsr #16
52 orr ip, ip, ip, lsl #16
53 str ip, [r0]
54
55 mov ip, r4, lsl #16
56 orr ip, ip, ip, lsr #16
57 str ip, [r0]
58
59 mov ip, r4, lsr #16
60 orr ip, ip, ip, lsl #16
61 str ip, [r0]
62
63 mov ip, r5, lsl #16
64 orr ip, ip, ip, lsr #16
65 str ip, [r0]
66
67 mov ip, r5, lsr #16
68 orr ip, ip, ip, lsl #16
69 str ip, [r0]
70
71 mov ip, r6, lsl #16
72 orr ip, ip, ip, lsr #16
73 str ip, [r0]
74
75 mov ip, r6, lsr #16
76 orr ip, ip, ip, lsl #16
77 str ip, [r0]
78
79 subs r2, r2, #8
80 bpl .outsw_8_lp
81
82 tst r2, #7
83 LOADREGS(eqfd, sp!, {r4, r5, r6, pc})
84
85.no_outsw_8: tst r2, #4
86 beq .no_outsw_4
87
88 ldmia r1!, {r3, r4}
89
90 mov ip, r3, lsl #16
91 orr ip, ip, ip, lsr #16
92 str ip, [r0]
93
94 mov ip, r3, lsr #16
95 orr ip, ip, ip, lsl #16
96 str ip, [r0]
97
98 mov ip, r4, lsl #16
99 orr ip, ip, ip, lsr #16
100 str ip, [r0]
101
102 mov ip, r4, lsr #16
103 orr ip, ip, ip, lsl #16
104 str ip, [r0]
105
106.no_outsw_4: tst r2, #2
107 beq .no_outsw_2
108
109 ldr r3, [r1], #4
110
111 mov ip, r3, lsl #16
112 orr ip, ip, ip, lsr #16
113 str ip, [r0]
114
115 mov ip, r3, lsr #16
116 orr ip, ip, ip, lsl #16
117 str ip, [r0]
118
119.no_outsw_2: tst r2, #1
120
121 ldrne r3, [r1]
122
123 movne ip, r3, lsl #16
124 orrne ip, ip, ip, lsr #16
125 strne ip, [r0]
126
127 LOADREGS(fd, sp!, {r4, r5, r6, pc})
diff --git a/arch/arm26/lib/kbd.c b/arch/arm26/lib/kbd.c
deleted file mode 100644
index cb56e943e006..000000000000
--- a/arch/arm26/lib/kbd.c
+++ /dev/null
@@ -1,278 +0,0 @@
1#include <linux/kd.h>
2//#include <linux/kbd_ll.h>
3#include <linux/kbd_kern.h>
4
5/*
6 * Translation of escaped scancodes to keycodes.
7 * This is now user-settable.
8 * The keycodes 1-88,96-111,119 are fairly standard, and
9 * should probably not be changed - changing might confuse X.
10 * X also interprets scancode 0x5d (KEY_Begin).
11 *
12 * For 1-88 keycode equals scancode.
13 */
14
15#define E0_KPENTER 96
16#define E0_RCTRL 97
17#define E0_KPSLASH 98
18#define E0_PRSCR 99
19#define E0_RALT 100
20#define E0_BREAK 101 /* (control-pause) */
21#define E0_HOME 102
22#define E0_UP 103
23#define E0_PGUP 104
24#define E0_LEFT 105
25#define E0_RIGHT 106
26#define E0_END 107
27#define E0_DOWN 108
28#define E0_PGDN 109
29#define E0_INS 110
30#define E0_DEL 111
31
32/* for USB 106 keyboard */
33#define E0_YEN 124
34#define E0_BACKSLASH 89
35
36
37#define E1_PAUSE 119
38
39/*
40 * The keycodes below are randomly located in 89-95,112-118,120-127.
41 * They could be thrown away (and all occurrences below replaced by 0),
42 * but that would force many users to use the `setkeycodes' utility, where
43 * they needed not before. It does not matter that there are duplicates, as
44 * long as no duplication occurs for any single keyboard.
45 */
46#define SC_LIM 89
47
48#define FOCUS_PF1 85 /* actual code! */
49#define FOCUS_PF2 89
50#define FOCUS_PF3 90
51#define FOCUS_PF4 91
52#define FOCUS_PF5 92
53#define FOCUS_PF6 93
54#define FOCUS_PF7 94
55#define FOCUS_PF8 95
56#define FOCUS_PF9 120
57#define FOCUS_PF10 121
58#define FOCUS_PF11 122
59#define FOCUS_PF12 123
60
61#define JAP_86 124
62/* tfj@olivia.ping.dk:
63 * The four keys are located over the numeric keypad, and are
64 * labelled A1-A4. It's an rc930 keyboard, from
65 * Regnecentralen/RC International, Now ICL.
66 * Scancodes: 59, 5a, 5b, 5c.
67 */
68#define RGN1 124
69#define RGN2 125
70#define RGN3 126
71#define RGN4 127
72
73static unsigned char high_keys[128 - SC_LIM] = {
74 RGN1, RGN2, RGN3, RGN4, 0, 0, 0, /* 0x59-0x5f */
75 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */
76 0, 0, 0, 0, 0, FOCUS_PF11, 0, FOCUS_PF12, /* 0x68-0x6f */
77 0, 0, 0, FOCUS_PF2, FOCUS_PF9, 0, 0, FOCUS_PF3, /* 0x70-0x77 */
78 FOCUS_PF4, FOCUS_PF5, FOCUS_PF6, FOCUS_PF7, /* 0x78-0x7b */
79 FOCUS_PF8, JAP_86, FOCUS_PF10, 0 /* 0x7c-0x7f */
80};
81
82/* BTC */
83#define E0_MACRO 112
84/* LK450 */
85#define E0_F13 113
86#define E0_F14 114
87#define E0_HELP 115
88#define E0_DO 116
89#define E0_F17 117
90#define E0_KPMINPLUS 118
91/*
92 * My OmniKey generates e0 4c for the "OMNI" key and the
93 * right alt key does nada. [kkoller@nyx10.cs.du.edu]
94 */
95#define E0_OK 124
96/*
97 * New microsoft keyboard is rumoured to have
98 * e0 5b (left window button), e0 5c (right window button),
99 * e0 5d (menu button). [or: LBANNER, RBANNER, RMENU]
100 * [or: Windows_L, Windows_R, TaskMan]
101 */
102#define E0_MSLW 125
103#define E0_MSRW 126
104#define E0_MSTM 127
105
106static unsigned char e0_keys[128] = {
107 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00-0x07 */
108 0, 0, 0, 0, 0, 0, 0, 0, /* 0x08-0x0f */
109 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */
110 0, 0, 0, 0, E0_KPENTER, E0_RCTRL, 0, 0, /* 0x18-0x1f */
111 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */
112 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */
113 0, 0, 0, 0, 0, E0_KPSLASH, 0, E0_PRSCR, /* 0x30-0x37 */
114 E0_RALT, 0, 0, 0, 0, E0_F13, E0_F14, E0_HELP, /* 0x38-0x3f */
115 E0_DO, E0_F17, 0, 0, 0, 0, E0_BREAK, E0_HOME, /* 0x40-0x47 */
116 E0_UP, E0_PGUP, 0, E0_LEFT, E0_OK, E0_RIGHT, E0_KPMINPLUS, E0_END, /* 0x48-0x4f */
117 E0_DOWN, E0_PGDN, E0_INS, E0_DEL, 0, 0, 0, 0, /* 0x50-0x57 */
118 0, 0, 0, E0_MSLW, E0_MSRW, E0_MSTM, 0, 0, /* 0x58-0x5f */
119 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */
120 0, 0, 0, 0, 0, 0, 0, E0_MACRO, /* 0x68-0x6f */
121 //0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */
122 0, 0, 0, 0, 0, E0_BACKSLASH, 0, 0, /* 0x70-0x77 */
123 0, 0, 0, E0_YEN, 0, 0, 0, 0 /* 0x78-0x7f */
124};
125
126static int gen_setkeycode(unsigned int scancode, unsigned int keycode)
127{
128 if (scancode < SC_LIM || scancode > 255 || keycode > 127)
129 return -EINVAL;
130 if (scancode < 128)
131 high_keys[scancode - SC_LIM] = keycode;
132 else
133 e0_keys[scancode - 128] = keycode;
134 return 0;
135}
136
137static int gen_getkeycode(unsigned int scancode)
138{
139 return
140 (scancode < SC_LIM || scancode > 255) ? -EINVAL :
141 (scancode <
142 128) ? high_keys[scancode - SC_LIM] : e0_keys[scancode - 128];
143}
144
145static int
146gen_translate(unsigned char scancode, unsigned char *keycode, char raw_mode)
147{
148 static int prev_scancode;
149
150 /* special prefix scancodes.. */
151 if (scancode == 0xe0 || scancode == 0xe1) {
152 prev_scancode = scancode;
153 return 0;
154 }
155
156 /* 0xFF is sent by a few keyboards, ignore it. 0x00 is error */
157 if (scancode == 0x00 || scancode == 0xff) {
158 prev_scancode = 0;
159 return 0;
160 }
161
162 scancode &= 0x7f;
163
164 if (prev_scancode) {
165 /*
166 * usually it will be 0xe0, but a Pause key generates
167 * e1 1d 45 e1 9d c5 when pressed, and nothing when released
168 */
169 if (prev_scancode != 0xe0) {
170 if (prev_scancode == 0xe1 && scancode == 0x1d) {
171 prev_scancode = 0x100;
172 return 0;
173 }
174 else if (prev_scancode == 0x100
175 && scancode == 0x45) {
176 *keycode = E1_PAUSE;
177 prev_scancode = 0;
178 } else {
179#ifdef KBD_REPORT_UNKN
180 if (!raw_mode)
181 printk(KERN_INFO
182 "keyboard: unknown e1 escape sequence\n");
183#endif
184 prev_scancode = 0;
185 return 0;
186 }
187 } else {
188 prev_scancode = 0;
189 /*
190 * The keyboard maintains its own internal caps lock and
191 * num lock statuses. In caps lock mode E0 AA precedes make
192 * code and E0 2A follows break code. In num lock mode,
193 * E0 2A precedes make code and E0 AA follows break code.
194 * We do our own book-keeping, so we will just ignore these.
195 */
196 /*
197 * For my keyboard there is no caps lock mode, but there are
198 * both Shift-L and Shift-R modes. The former mode generates
199 * E0 2A / E0 AA pairs, the latter E0 B6 / E0 36 pairs.
200 * So, we should also ignore the latter. - aeb@cwi.nl
201 */
202 if (scancode == 0x2a || scancode == 0x36)
203 return 0;
204
205 if (e0_keys[scancode])
206 *keycode = e0_keys[scancode];
207 else {
208#ifdef KBD_REPORT_UNKN
209 if (!raw_mode)
210 printk(KERN_INFO
211 "keyboard: unknown scancode e0 %02x\n",
212 scancode);
213#endif
214 return 0;
215 }
216 }
217 } else if (scancode >= SC_LIM) {
218 /* This happens with the FOCUS 9000 keyboard
219 Its keys PF1..PF12 are reported to generate
220 55 73 77 78 79 7a 7b 7c 74 7e 6d 6f
221 Moreover, unless repeated, they do not generate
222 key-down events, so we have to zero up_flag below */
223 /* Also, Japanese 86/106 keyboards are reported to
224 generate 0x73 and 0x7d for \ - and \ | respectively. */
225 /* Also, some Brazilian keyboard is reported to produce
226 0x73 and 0x7e for \ ? and KP-dot, respectively. */
227
228 *keycode = high_keys[scancode - SC_LIM];
229
230 if (!*keycode) {
231 if (!raw_mode) {
232#ifdef KBD_REPORT_UNKN
233 printk(KERN_INFO
234 "keyboard: unrecognized scancode (%02x)"
235 " - ignored\n", scancode);
236#endif
237 }
238 return 0;
239 }
240 } else
241 *keycode = scancode;
242 return 1;
243}
244
245static char gen_unexpected_up(unsigned char keycode)
246{
247 /* unexpected, but this can happen: maybe this was a key release for a
248 FOCUS 9000 PF key; if we want to see it, we have to clear up_flag */
249 if (keycode >= SC_LIM || keycode == 85)
250 return 0;
251 else
252 return 0200;
253}
254
255/*
256 * These are the default mappings
257 */
258int (*k_setkeycode)(unsigned int, unsigned int) = gen_setkeycode;
259int (*k_getkeycode)(unsigned int) = gen_getkeycode;
260int (*k_translate)(unsigned char, unsigned char *, char) = gen_translate;
261char (*k_unexpected_up)(unsigned char) = gen_unexpected_up;
262void (*k_leds)(unsigned char);
263
264/* Simple translation table for the SysRq keys */
265
266#ifdef CONFIG_MAGIC_SYSRQ
267static unsigned char gen_sysrq_xlate[128] =
268 "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
269 "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
270 "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
271 "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
272 "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
273 "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
274 "\r\000/"; /* 0x60 - 0x6f */
275
276unsigned char *k_sysrq_xlate = gen_sysrq_xlate;
277int k_sysrq_key = 0x54;
278#endif
diff --git a/arch/arm26/lib/lib1funcs.S b/arch/arm26/lib/lib1funcs.S
deleted file mode 100644
index 0e29970b0e8a..000000000000
--- a/arch/arm26/lib/lib1funcs.S
+++ /dev/null
@@ -1,313 +0,0 @@
1@ libgcc1 routines for ARM cpu.
2@ Division routines, written by Richard Earnshaw, (rearnsha@armltd.co.uk)
3
4/* Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
5
6This file is free software; you can redistribute it and/or modify it
7under the terms of the GNU General Public License as published by the
8Free Software Foundation; either version 2, or (at your option) any
9later version.
10
11In addition to the permissions in the GNU General Public License, the
12Free Software Foundation gives you unlimited permission to link the
13compiled version of this file with other programs, and to distribute
14those programs without any restriction coming from the use of this
15file. (The General Public License restrictions do apply in other
16respects; for example, they cover modification of the file, and
17distribution when not linked into another program.)
18
19This file is distributed in the hope that it will be useful, but
20WITHOUT ANY WARRANTY; without even the implied warranty of
21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22General Public License for more details.
23
24You should have received a copy of the GNU General Public License
25along with this program; see the file COPYING. If not, write to
26the Free Software Foundation, 59 Temple Place - Suite 330,
27Boston, MA 02111-1307, USA. */
28
29/* As a special exception, if you link this library with other files,
30 some of which are compiled with GCC, to produce an executable,
31 this library does not by itself cause the resulting executable
32 to be covered by the GNU General Public License.
33 This exception does not however invalidate any other reasons why
34 the executable file might be covered by the GNU General Public License.
35 */
36/* This code is derived from gcc 2.95.3 */
37/* I Molton 29/07/01 */
38
39#include <linux/linkage.h>
40#include <asm/assembler.h>
41#include <asm/hardware.h>
42
43#define RET movs
44#define RETc(x) mov##x##s
45#define RETCOND ^
46
47dividend .req r0
48divisor .req r1
49result .req r2
50overdone .req r2
51curbit .req r3
52ip .req r12
53sp .req r13
54lr .req r14
55pc .req r15
56
57ENTRY(__udivsi3)
58 cmp divisor, #0
59 beq Ldiv0
60 mov curbit, #1
61 mov result, #0
62 cmp dividend, divisor
63 bcc Lgot_result_udivsi3
641:
65 @ Unless the divisor is very big, shift it up in multiples of
66 @ four bits, since this is the amount of unwinding in the main
67 @ division loop. Continue shifting until the divisor is
68 @ larger than the dividend.
69 cmp divisor, #0x10000000
70 cmpcc divisor, dividend
71 movcc divisor, divisor, lsl #4
72 movcc curbit, curbit, lsl #4
73 bcc 1b
74
752:
76 @ For very big divisors, we must shift it a bit at a time, or
77 @ we will be in danger of overflowing.
78 cmp divisor, #0x80000000
79 cmpcc divisor, dividend
80 movcc divisor, divisor, lsl #1
81 movcc curbit, curbit, lsl #1
82 bcc 2b
83
843:
85 @ Test for possible subtractions, and note which bits
86 @ are done in the result. On the final pass, this may subtract
87 @ too much from the dividend, but the result will be ok, since the
88 @ "bit" will have been shifted out at the bottom.
89 cmp dividend, divisor
90 subcs dividend, dividend, divisor
91 orrcs result, result, curbit
92 cmp dividend, divisor, lsr #1
93 subcs dividend, dividend, divisor, lsr #1
94 orrcs result, result, curbit, lsr #1
95 cmp dividend, divisor, lsr #2
96 subcs dividend, dividend, divisor, lsr #2
97 orrcs result, result, curbit, lsr #2
98 cmp dividend, divisor, lsr #3
99 subcs dividend, dividend, divisor, lsr #3
100 orrcs result, result, curbit, lsr #3
101 cmp dividend, #0 @ Early termination?
102 movnes curbit, curbit, lsr #4 @ No, any more bits to do?
103 movne divisor, divisor, lsr #4
104 bne 3b
105Lgot_result_udivsi3:
106 mov r0, result
107 RET pc, lr
108
109Ldiv0:
110 str lr, [sp, #-4]!
111 bl __div0
112 mov r0, #0 @ about as wrong as it could be
113 ldmia sp!, {pc}RETCOND
114
115/* __umodsi3 ----------------------- */
116
117ENTRY(__umodsi3)
118 cmp divisor, #0
119 beq Ldiv0
120 mov curbit, #1
121 cmp dividend, divisor
122 RETc(cc) pc, lr
1231:
124 @ Unless the divisor is very big, shift it up in multiples of
125 @ four bits, since this is the amount of unwinding in the main
126 @ division loop. Continue shifting until the divisor is
127 @ larger than the dividend.
128 cmp divisor, #0x10000000
129 cmpcc divisor, dividend
130 movcc divisor, divisor, lsl #4
131 movcc curbit, curbit, lsl #4
132 bcc 1b
133
1342:
135 @ For very big divisors, we must shift it a bit at a time, or
136 @ we will be in danger of overflowing.
137 cmp divisor, #0x80000000
138 cmpcc divisor, dividend
139 movcc divisor, divisor, lsl #1
140 movcc curbit, curbit, lsl #1
141 bcc 2b
142
1433:
144 @ Test for possible subtractions. On the final pass, this may
145 @ subtract too much from the dividend, so keep track of which
146 @ subtractions are done, we can fix them up afterwards...
147 mov overdone, #0
148 cmp dividend, divisor
149 subcs dividend, dividend, divisor
150 cmp dividend, divisor, lsr #1
151 subcs dividend, dividend, divisor, lsr #1
152 orrcs overdone, overdone, curbit, ror #1
153 cmp dividend, divisor, lsr #2
154 subcs dividend, dividend, divisor, lsr #2
155 orrcs overdone, overdone, curbit, ror #2
156 cmp dividend, divisor, lsr #3
157 subcs dividend, dividend, divisor, lsr #3
158 orrcs overdone, overdone, curbit, ror #3
159 mov ip, curbit
160 cmp dividend, #0 @ Early termination?
161 movnes curbit, curbit, lsr #4 @ No, any more bits to do?
162 movne divisor, divisor, lsr #4
163 bne 3b
164
165 @ Any subtractions that we should not have done will be recorded in
166 @ the top three bits of "overdone". Exactly which were not needed
167 @ are governed by the position of the bit, stored in ip.
168 @ If we terminated early, because dividend became zero,
169 @ then none of the below will match, since the bit in ip will not be
170 @ in the bottom nibble.
171 ands overdone, overdone, #0xe0000000
172 RETc(eq) pc, lr @ No fixups needed
173 tst overdone, ip, ror #3
174 addne dividend, dividend, divisor, lsr #3
175 tst overdone, ip, ror #2
176 addne dividend, dividend, divisor, lsr #2
177 tst overdone, ip, ror #1
178 addne dividend, dividend, divisor, lsr #1
179 RET pc, lr
180
181ENTRY(__divsi3)
182 eor ip, dividend, divisor @ Save the sign of the result.
183 mov curbit, #1
184 mov result, #0
185 cmp divisor, #0
186 rsbmi divisor, divisor, #0 @ Loops below use unsigned.
187 beq Ldiv0
188 cmp dividend, #0
189 rsbmi dividend, dividend, #0
190 cmp dividend, divisor
191 bcc Lgot_result_divsi3
192
1931:
194 @ Unless the divisor is very big, shift it up in multiples of
195 @ four bits, since this is the amount of unwinding in the main
196 @ division loop. Continue shifting until the divisor is
197 @ larger than the dividend.
198 cmp divisor, #0x10000000
199 cmpcc divisor, dividend
200 movcc divisor, divisor, lsl #4
201 movcc curbit, curbit, lsl #4
202 bcc 1b
203
2042:
205 @ For very big divisors, we must shift it a bit at a time, or
206 @ we will be in danger of overflowing.
207 cmp divisor, #0x80000000
208 cmpcc divisor, dividend
209 movcc divisor, divisor, lsl #1
210 movcc curbit, curbit, lsl #1
211 bcc 2b
212
2133:
214 @ Test for possible subtractions, and note which bits
215 @ are done in the result. On the final pass, this may subtract
216 @ too much from the dividend, but the result will be ok, since the
217 @ "bit" will have been shifted out at the bottom.
218 cmp dividend, divisor
219 subcs dividend, dividend, divisor
220 orrcs result, result, curbit
221 cmp dividend, divisor, lsr #1
222 subcs dividend, dividend, divisor, lsr #1
223 orrcs result, result, curbit, lsr #1
224 cmp dividend, divisor, lsr #2
225 subcs dividend, dividend, divisor, lsr #2
226 orrcs result, result, curbit, lsr #2
227 cmp dividend, divisor, lsr #3
228 subcs dividend, dividend, divisor, lsr #3
229 orrcs result, result, curbit, lsr #3
230 cmp dividend, #0 @ Early termination?
231 movnes curbit, curbit, lsr #4 @ No, any more bits to do?
232 movne divisor, divisor, lsr #4
233 bne 3b
234Lgot_result_divsi3:
235 mov r0, result
236 cmp ip, #0
237 rsbmi r0, r0, #0
238 RET pc, lr
239
240ENTRY(__modsi3)
241 mov curbit, #1
242 cmp divisor, #0
243 rsbmi divisor, divisor, #0 @ Loops below use unsigned.
244 beq Ldiv0
245 @ Need to save the sign of the dividend, unfortunately, we need
246 @ ip later on; this is faster than pushing lr and using that.
247 str dividend, [sp, #-4]!
248 cmp dividend, #0
249 rsbmi dividend, dividend, #0
250 cmp dividend, divisor
251 bcc Lgot_result_modsi3
252
2531:
254 @ Unless the divisor is very big, shift it up in multiples of
255 @ four bits, since this is the amount of unwinding in the main
256 @ division loop. Continue shifting until the divisor is
257 @ larger than the dividend.
258 cmp divisor, #0x10000000
259 cmpcc divisor, dividend
260 movcc divisor, divisor, lsl #4
261 movcc curbit, curbit, lsl #4
262 bcc 1b
263
2642:
265 @ For very big divisors, we must shift it a bit at a time, or
266 @ we will be in danger of overflowing.
267 cmp divisor, #0x80000000
268 cmpcc divisor, dividend
269 movcc divisor, divisor, lsl #1
270 movcc curbit, curbit, lsl #1
271 bcc 2b
272
2733:
274 @ Test for possible subtractions. On the final pass, this may
275 @ subtract too much from the dividend, so keep track of which
276 @ subtractions are done, we can fix them up afterwards...
277 mov overdone, #0
278 cmp dividend, divisor
279 subcs dividend, dividend, divisor
280 cmp dividend, divisor, lsr #1
281 subcs dividend, dividend, divisor, lsr #1
282 orrcs overdone, overdone, curbit, ror #1
283 cmp dividend, divisor, lsr #2
284 subcs dividend, dividend, divisor, lsr #2
285 orrcs overdone, overdone, curbit, ror #2
286 cmp dividend, divisor, lsr #3
287 subcs dividend, dividend, divisor, lsr #3
288 orrcs overdone, overdone, curbit, ror #3
289 mov ip, curbit
290 cmp dividend, #0 @ Early termination?
291 movnes curbit, curbit, lsr #4 @ No, any more bits to do?
292 movne divisor, divisor, lsr #4
293 bne 3b
294
295 @ Any subtractions that we should not have done will be recorded in
296 @ the top three bits of "overdone". Exactly which were not needed
297 @ are governed by the position of the bit, stored in ip.
298 @ If we terminated early, because dividend became zero,
299 @ then none of the below will match, since the bit in ip will not be
300 @ in the bottom nibble.
301 ands overdone, overdone, #0xe0000000
302 beq Lgot_result_modsi3
303 tst overdone, ip, ror #3
304 addne dividend, dividend, divisor, lsr #3
305 tst overdone, ip, ror #2
306 addne dividend, dividend, divisor, lsr #2
307 tst overdone, ip, ror #1
308 addne dividend, dividend, divisor, lsr #1
309Lgot_result_modsi3:
310 ldr ip, [sp], #4
311 cmp ip, #0
312 rsbmi dividend, dividend, #0
313 RET pc, lr
diff --git a/arch/arm26/lib/longlong.h b/arch/arm26/lib/longlong.h
deleted file mode 100644
index 05ec1abd6a2c..000000000000
--- a/arch/arm26/lib/longlong.h
+++ /dev/null
@@ -1,184 +0,0 @@
1/* longlong.h -- based on code from gcc-2.95.3
2
3 definitions for mixed size 32/64 bit arithmetic.
4 Copyright (C) 1991, 92, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
5
6 This definition file is free software; you can redistribute it
7 and/or modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either
9 version 2, or (at your option) any later version.
10
11 This definition file is distributed in the hope that it will be
12 useful, but WITHOUT ANY WARRANTY; without even the implied
13 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21/* Borrowed from GCC 2.95.3, I Molton 29/07/01 */
22
23#ifndef SI_TYPE_SIZE
24#define SI_TYPE_SIZE 32
25#endif
26
27#define __BITS4 (SI_TYPE_SIZE / 4)
28#define __ll_B (1L << (SI_TYPE_SIZE / 2))
29#define __ll_lowpart(t) ((USItype) (t) % __ll_B)
30#define __ll_highpart(t) ((USItype) (t) / __ll_B)
31
32/* Define auxiliary asm macros.
33
34 1) umul_ppmm(high_prod, low_prod, multipler, multiplicand)
35 multiplies two USItype integers MULTIPLER and MULTIPLICAND,
36 and generates a two-part USItype product in HIGH_PROD and
37 LOW_PROD.
38
39 2) __umulsidi3(a,b) multiplies two USItype integers A and B,
40 and returns a UDItype product. This is just a variant of umul_ppmm.
41
42 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
43 denominator) divides a two-word unsigned integer, composed by the
44 integers HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and
45 places the quotient in QUOTIENT and the remainder in REMAINDER.
46 HIGH_NUMERATOR must be less than DENOMINATOR for correct operation.
47 If, in addition, the most significant bit of DENOMINATOR must be 1,
48 then the pre-processor symbol UDIV_NEEDS_NORMALIZATION is defined to 1.
49
50 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
51 denominator). Like udiv_qrnnd but the numbers are signed. The
52 quotient is rounded towards 0.
53
54 5) count_leading_zeros(count, x) counts the number of zero-bits from
55 the msb to the first non-zero bit. This is the number of steps X
56 needs to be shifted left to set the msb. Undefined for X == 0.
57
58 6) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
59 high_addend_2, low_addend_2) adds two two-word unsigned integers,
60 composed by HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and
61 LOW_ADDEND_2 respectively. The result is placed in HIGH_SUM and
62 LOW_SUM. Overflow (i.e. carry out) is not stored anywhere, and is
63 lost.
64
65 7) sub_ddmmss(high_difference, low_difference, high_minuend,
66 low_minuend, high_subtrahend, low_subtrahend) subtracts two
67 two-word unsigned integers, composed by HIGH_MINUEND_1 and
68 LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and LOW_SUBTRAHEND_2
69 respectively. The result is placed in HIGH_DIFFERENCE and
70 LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
71 and is lost.
72
73 If any of these macros are left undefined for a particular CPU,
74 C macros are used. */
75
76#if defined (__arm__)
77#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
78 __asm__ ("adds %1, %4, %5 \n\
79 adc %0, %2, %3" \
80 : "=r" ((USItype) (sh)), \
81 "=&r" ((USItype) (sl)) \
82 : "%r" ((USItype) (ah)), \
83 "rI" ((USItype) (bh)), \
84 "%r" ((USItype) (al)), \
85 "rI" ((USItype) (bl)))
86#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
87 __asm__ ("subs %1, %4, %5 \n\
88 sbc %0, %2, %3" \
89 : "=r" ((USItype) (sh)), \
90 "=&r" ((USItype) (sl)) \
91 : "r" ((USItype) (ah)), \
92 "rI" ((USItype) (bh)), \
93 "r" ((USItype) (al)), \
94 "rI" ((USItype) (bl)))
95#define umul_ppmm(xh, xl, a, b) \
96{register USItype __t0, __t1, __t2; \
97 __asm__ ("%@ Inlined umul_ppmm \n\
98 mov %2, %5, lsr #16 \n\
99 mov %0, %6, lsr #16 \n\
100 bic %3, %5, %2, lsl #16 \n\
101 bic %4, %6, %0, lsl #16 \n\
102 mul %1, %3, %4 \n\
103 mul %4, %2, %4 \n\
104 mul %3, %0, %3 \n\
105 mul %0, %2, %0 \n\
106 adds %3, %4, %3 \n\
107 addcs %0, %0, #65536 \n\
108 adds %1, %1, %3, lsl #16 \n\
109 adc %0, %0, %3, lsr #16" \
110 : "=&r" ((USItype) (xh)), \
111 "=r" ((USItype) (xl)), \
112 "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
113 : "r" ((USItype) (a)), \
114 "r" ((USItype) (b)));}
115#define UMUL_TIME 20
116#define UDIV_TIME 100
117#endif /* __arm__ */
118
119#define __umulsidi3(u, v) \
120 ({DIunion __w; \
121 umul_ppmm (__w.s.high, __w.s.low, u, v); \
122 __w.ll; })
123
124#define __udiv_qrnnd_c(q, r, n1, n0, d) \
125 do { \
126 USItype __d1, __d0, __q1, __q0; \
127 USItype __r1, __r0, __m; \
128 __d1 = __ll_highpart (d); \
129 __d0 = __ll_lowpart (d); \
130 \
131 __r1 = (n1) % __d1; \
132 __q1 = (n1) / __d1; \
133 __m = (USItype) __q1 * __d0; \
134 __r1 = __r1 * __ll_B | __ll_highpart (n0); \
135 if (__r1 < __m) \
136 { \
137 __q1--, __r1 += (d); \
138 if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
139 if (__r1 < __m) \
140 __q1--, __r1 += (d); \
141 } \
142 __r1 -= __m; \
143 \
144 __r0 = __r1 % __d1; \
145 __q0 = __r1 / __d1; \
146 __m = (USItype) __q0 * __d0; \
147 __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
148 if (__r0 < __m) \
149 { \
150 __q0--, __r0 += (d); \
151 if (__r0 >= (d)) \
152 if (__r0 < __m) \
153 __q0--, __r0 += (d); \
154 } \
155 __r0 -= __m; \
156 \
157 (q) = (USItype) __q1 * __ll_B | __q0; \
158 (r) = __r0; \
159 } while (0)
160
161#define UDIV_NEEDS_NORMALIZATION 1
162#define udiv_qrnnd __udiv_qrnnd_c
163
164extern const UQItype __clz_tab[];
165#define count_leading_zeros(count, x) \
166 do { \
167 USItype __xr = (x); \
168 USItype __a; \
169 \
170 if (SI_TYPE_SIZE <= 32) \
171 { \
172 __a = __xr < ((USItype)1<<2*__BITS4) \
173 ? (__xr < ((USItype)1<<__BITS4) ? 0 : __BITS4) \
174 : (__xr < ((USItype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \
175 } \
176 else \
177 { \
178 for (__a = SI_TYPE_SIZE - 8; __a > 0; __a -= 8) \
179 if (((__xr >> __a) & 0xff) != 0) \
180 break; \
181 } \
182 \
183 (count) = SI_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \
184 } while (0)
diff --git a/arch/arm26/lib/lshrdi3.c b/arch/arm26/lib/lshrdi3.c
deleted file mode 100644
index b666f1bad451..000000000000
--- a/arch/arm26/lib/lshrdi3.c
+++ /dev/null
@@ -1,61 +0,0 @@
1/* More subroutines needed by GCC output code on some machines. */
2/* Compile this one with gcc. */
3/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc.
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
22/* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License.
28 */
29/* support functions required by the kernel. based on code from gcc-2.95.3 */
30/* I Molton 29/07/01 */
31
32#include "gcclib.h"
33
34DItype
35__lshrdi3 (DItype u, word_type b)
36{
37 DIunion w;
38 word_type bm;
39 DIunion uu;
40
41 if (b == 0)
42 return u;
43
44 uu.ll = u;
45
46 bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
47 if (bm <= 0)
48 {
49 w.s.high = 0;
50 w.s.low = (USItype)uu.s.high >> -bm;
51 }
52 else
53 {
54 USItype carries = (USItype)uu.s.high << bm;
55 w.s.high = (USItype)uu.s.high >> b;
56 w.s.low = ((USItype)uu.s.low >> b) | carries;
57 }
58
59 return w.ll;
60}
61
diff --git a/arch/arm26/lib/memchr.S b/arch/arm26/lib/memchr.S
deleted file mode 100644
index 34e7c14c08ad..000000000000
--- a/arch/arm26/lib/memchr.S
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * linux/arch/arm26/lib/memchr.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ASM optimised string functions
11 */
12#include <linux/linkage.h>
13#include <asm/assembler.h>
14
15 .text
16 .align 5
17ENTRY(memchr)
181: subs r2, r2, #1
19 bmi 2f
20 ldrb r3, [r0], #1
21 teq r3, r1
22 bne 1b
23 sub r0, r0, #1
242: movne r0, #0
25 RETINSTR(mov,pc,lr)
diff --git a/arch/arm26/lib/memcpy.S b/arch/arm26/lib/memcpy.S
deleted file mode 100644
index 3f719e412069..000000000000
--- a/arch/arm26/lib/memcpy.S
+++ /dev/null
@@ -1,318 +0,0 @@
1/*
2 * linux/arch/arm26/lib/memcpy.S
3 *
4 * Copyright (C) 1995-1999 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ASM optimised string functions
11 */
12#include <linux/linkage.h>
13#include <asm/assembler.h>
14
15 .text
16
17#define ENTER \
18 mov ip,sp ;\
19 stmfd sp!,{r4-r9,fp,ip,lr,pc} ;\
20 sub fp,ip,#4
21
22#define EXIT \
23 LOADREGS(ea, fp, {r4 - r9, fp, sp, pc})
24
25#define EXITEQ \
26 LOADREGS(eqea, fp, {r4 - r9, fp, sp, pc})
27
28/*
29 * Prototype: void memcpy(void *to,const void *from,unsigned long n);
30 * ARM3: cant use memcopy here!!!
31 */
32ENTRY(memcpy)
33ENTRY(memmove)
34 ENTER
35 cmp r1, r0
36 bcc 19f
37 subs r2, r2, #4
38 blt 6f
39 ands ip, r0, #3
40 bne 7f
41 ands ip, r1, #3
42 bne 8f
43
441: subs r2, r2, #8
45 blt 5f
46 subs r2, r2, #0x14
47 blt 3f
482: ldmia r1!,{r3 - r9, ip}
49 stmia r0!,{r3 - r9, ip}
50 subs r2, r2, #32
51 bge 2b
52 cmn r2, #16
53 ldmgeia r1!, {r3 - r6}
54 stmgeia r0!, {r3 - r6}
55 subge r2, r2, #0x10
563: adds r2, r2, #0x14
574: ldmgeia r1!, {r3 - r5}
58 stmgeia r0!, {r3 - r5}
59 subges r2, r2, #12
60 bge 4b
615: adds r2, r2, #8
62 blt 6f
63 subs r2, r2, #4
64 ldrlt r3, [r1], #4
65 ldmgeia r1!, {r4, r5}
66 strlt r3, [r0], #4
67 stmgeia r0!, {r4, r5}
68 subge r2, r2, #4
69
706: adds r2, r2, #4
71 EXITEQ
72 cmp r2, #2
73 ldrb r3, [r1], #1
74 ldrgeb r4, [r1], #1
75 ldrgtb r5, [r1], #1
76 strb r3, [r0], #1
77 strgeb r4, [r0], #1
78 strgtb r5, [r0], #1
79 EXIT
80
817: rsb ip, ip, #4
82 cmp ip, #2
83 ldrb r3, [r1], #1
84 ldrgeb r4, [r1], #1
85 ldrgtb r5, [r1], #1
86 strb r3, [r0], #1
87 strgeb r4, [r0], #1
88 strgtb r5, [r0], #1
89 subs r2, r2, ip
90 blt 6b
91 ands ip, r1, #3
92 beq 1b
93
948: bic r1, r1, #3
95 ldr r7, [r1], #4
96 cmp ip, #2
97 bgt 15f
98 beq 11f
99 cmp r2, #12
100 blt 10f
101 sub r2, r2, #12
1029: mov r3, r7, pull #8
103 ldmia r1!, {r4 - r7}
104 orr r3, r3, r4, push #24
105 mov r4, r4, pull #8
106 orr r4, r4, r5, push #24
107 mov r5, r5, pull #8
108 orr r5, r5, r6, push #24
109 mov r6, r6, pull #8
110 orr r6, r6, r7, push #24
111 stmia r0!, {r3 - r6}
112 subs r2, r2, #16
113 bge 9b
114 adds r2, r2, #12
115 blt 100f
11610: mov r3, r7, pull #8
117 ldr r7, [r1], #4
118 subs r2, r2, #4
119 orr r3, r3, r7, push #24
120 str r3, [r0], #4
121 bge 10b
122100: sub r1, r1, #3
123 b 6b
124
12511: cmp r2, #12
126 blt 13f /* */
127 sub r2, r2, #12
12812: mov r3, r7, pull #16
129 ldmia r1!, {r4 - r7}
130 orr r3, r3, r4, push #16
131 mov r4, r4, pull #16
132 orr r4, r4, r5, push #16
133 mov r5, r5, pull #16
134 orr r5, r5, r6, push #16
135 mov r6, r6, pull #16
136 orr r6, r6, r7, push #16
137 stmia r0!, {r3 - r6}
138 subs r2, r2, #16
139 bge 12b
140 adds r2, r2, #12
141 blt 14f
14213: mov r3, r7, pull #16
143 ldr r7, [r1], #4
144 subs r2, r2, #4
145 orr r3, r3, r7, push #16
146 str r3, [r0], #4
147 bge 13b
14814: sub r1, r1, #2
149 b 6b
150
15115: cmp r2, #12
152 blt 17f
153 sub r2, r2, #12
15416: mov r3, r7, pull #24
155 ldmia r1!, {r4 - r7}
156 orr r3, r3, r4, push #8
157 mov r4, r4, pull #24
158 orr r4, r4, r5, push #8
159 mov r5, r5, pull #24
160 orr r5, r5, r6, push #8
161 mov r6, r6, pull #24
162 orr r6, r6, r7, push #8
163 stmia r0!, {r3 - r6}
164 subs r2, r2, #16
165 bge 16b
166 adds r2, r2, #12
167 blt 18f
16817: mov r3, r7, pull #24
169 ldr r7, [r1], #4
170 subs r2, r2, #4
171 orr r3, r3, r7, push #8
172 str r3, [r0], #4
173 bge 17b
17418: sub r1, r1, #1
175 b 6b
176
177
17819: add r1, r1, r2
179 add r0, r0, r2
180 subs r2, r2, #4
181 blt 24f
182 ands ip, r0, #3
183 bne 25f
184 ands ip, r1, #3
185 bne 26f
186
18720: subs r2, r2, #8
188 blt 23f
189 subs r2, r2, #0x14
190 blt 22f
19121: ldmdb r1!, {r3 - r9, ip}
192 stmdb r0!, {r3 - r9, ip}
193 subs r2, r2, #32
194 bge 21b
19522: cmn r2, #16
196 ldmgedb r1!, {r3 - r6}
197 stmgedb r0!, {r3 - r6}
198 subge r2, r2, #16
199 adds r2, r2, #20
200 ldmgedb r1!, {r3 - r5}
201 stmgedb r0!, {r3 - r5}
202 subge r2, r2, #12
20323: adds r2, r2, #8
204 blt 24f
205 subs r2, r2, #4
206 ldrlt r3, [r1, #-4]!
207 ldmgedb r1!, {r4, r5}
208 strlt r3, [r0, #-4]!
209 stmgedb r0!, {r4, r5}
210 subge r2, r2, #4
211
21224: adds r2, r2, #4
213 EXITEQ
214 cmp r2, #2
215 ldrb r3, [r1, #-1]!
216 ldrgeb r4, [r1, #-1]!
217 ldrgtb r5, [r1, #-1]!
218 strb r3, [r0, #-1]!
219 strgeb r4, [r0, #-1]!
220 strgtb r5, [r0, #-1]!
221 EXIT
222
22325: cmp ip, #2
224 ldrb r3, [r1, #-1]!
225 ldrgeb r4, [r1, #-1]!
226 ldrgtb r5, [r1, #-1]!
227 strb r3, [r0, #-1]!
228 strgeb r4, [r0, #-1]!
229 strgtb r5, [r0, #-1]!
230 subs r2, r2, ip
231 blt 24b
232 ands ip, r1, #3
233 beq 20b
234
23526: bic r1, r1, #3
236 ldr r3, [r1], #0
237 cmp ip, #2
238 blt 34f
239 beq 30f
240 cmp r2, #12
241 blt 28f
242 sub r2, r2, #12
24327: mov r7, r3, push #8
244 ldmdb r1!, {r3, r4, r5, r6}
245 orr r7, r7, r6, pull #24
246 mov r6, r6, push #8
247 orr r6, r6, r5, pull #24
248 mov r5, r5, push #8
249 orr r5, r5, r4, pull #24
250 mov r4, r4, push #8
251 orr r4, r4, r3, pull #24
252 stmdb r0!, {r4, r5, r6, r7}
253 subs r2, r2, #16
254 bge 27b
255 adds r2, r2, #12
256 blt 29f
25728: mov ip, r3, push #8
258 ldr r3, [r1, #-4]!
259 subs r2, r2, #4
260 orr ip, ip, r3, pull #24
261 str ip, [r0, #-4]!
262 bge 28b
26329: add r1, r1, #3
264 b 24b
265
26630: cmp r2, #12
267 blt 32f
268 sub r2, r2, #12
26931: mov r7, r3, push #16
270 ldmdb r1!, {r3, r4, r5, r6}
271 orr r7, r7, r6, pull #16
272 mov r6, r6, push #16
273 orr r6, r6, r5, pull #16
274 mov r5, r5, push #16
275 orr r5, r5, r4, pull #16
276 mov r4, r4, push #16
277 orr r4, r4, r3, pull #16
278 stmdb r0!, {r4, r5, r6, r7}
279 subs r2, r2, #16
280 bge 31b
281 adds r2, r2, #12
282 blt 33f
28332: mov ip, r3, push #16
284 ldr r3, [r1, #-4]!
285 subs r2, r2, #4
286 orr ip, ip, r3, pull #16
287 str ip, [r0, #-4]!
288 bge 32b
28933: add r1, r1, #2
290 b 24b
291
29234: cmp r2, #12
293 blt 36f
294 sub r2, r2, #12
29535: mov r7, r3, push #24
296 ldmdb r1!, {r3, r4, r5, r6}
297 orr r7, r7, r6, pull #8
298 mov r6, r6, push #24
299 orr r6, r6, r5, pull #8
300 mov r5, r5, push #24
301 orr r5, r5, r4, pull #8
302 mov r4, r4, push #24
303 orr r4, r4, r3, pull #8
304 stmdb r0!, {r4, r5, r6, r7}
305 subs r2, r2, #16
306 bge 35b
307 adds r2, r2, #12
308 blt 37f
30936: mov ip, r3, push #24
310 ldr r3, [r1, #-4]!
311 subs r2, r2, #4
312 orr ip, ip, r3, pull #8
313 str ip, [r0, #-4]!
314 bge 36b
31537: add r1, r1, #1
316 b 24b
317
318 .align
diff --git a/arch/arm26/lib/memset.S b/arch/arm26/lib/memset.S
deleted file mode 100644
index aedec10b58f5..000000000000
--- a/arch/arm26/lib/memset.S
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * linux/arch/arm26/lib/memset.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ASM optimised string functions
11 */
12#include <linux/linkage.h>
13#include <asm/assembler.h>
14
15 .text
16 .align 5
17 .word 0
18
191: subs r2, r2, #4 @ 1 do we have enough
20 blt 5f @ 1 bytes to align with?
21 cmp r3, #2 @ 1
22 strltb r1, [r0], #1 @ 1
23 strleb r1, [r0], #1 @ 1
24 strb r1, [r0], #1 @ 1
25 add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3))
26/*
27 * The pointer is now aligned and the length is adjusted. Try doing the
28 * memzero again.
29 */
30
31ENTRY(memset)
32 ands r3, r0, #3 @ 1 unaligned?
33 bne 1b @ 1
34/*
35 * we know that the pointer in r0 is aligned to a word boundary.
36 */
37 orr r1, r1, r1, lsl #8
38 orr r1, r1, r1, lsl #16
39 mov r3, r1
40 cmp r2, #16
41 blt 4f
42/*
43 * We need an extra register for this loop - save the return address and
44 * use the LR
45 */
46 str lr, [sp, #-4]!
47 mov ip, r1
48 mov lr, r1
49
502: subs r2, r2, #64
51 stmgeia r0!, {r1, r3, ip, lr} @ 64 bytes at a time.
52 stmgeia r0!, {r1, r3, ip, lr}
53 stmgeia r0!, {r1, r3, ip, lr}
54 stmgeia r0!, {r1, r3, ip, lr}
55 bgt 2b
56 LOADREGS(eqfd, sp!, {pc}) @ Now <64 bytes to go.
57/*
58 * No need to correct the count; we're only testing bits from now on
59 */
60 tst r2, #32
61 stmneia r0!, {r1, r3, ip, lr}
62 stmneia r0!, {r1, r3, ip, lr}
63 tst r2, #16
64 stmneia r0!, {r1, r3, ip, lr}
65 ldr lr, [sp], #4
66
674: tst r2, #8
68 stmneia r0!, {r1, r3}
69 tst r2, #4
70 strne r1, [r0], #4
71/*
72 * When we get here, we've got less than 4 bytes to zero. We
73 * may have an unaligned pointer as well.
74 */
755: tst r2, #2
76 strneb r1, [r0], #1
77 strneb r1, [r0], #1
78 tst r2, #1
79 strneb r1, [r0], #1
80 RETINSTR(mov,pc,lr)
diff --git a/arch/arm26/lib/memzero.S b/arch/arm26/lib/memzero.S
deleted file mode 100644
index cc5bf6860061..000000000000
--- a/arch/arm26/lib/memzero.S
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * linux/arch/arm26/lib/memzero.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12
13 .text
14 .align 5
15 .word 0
16/*
17 * Align the pointer in r0. r3 contains the number of bytes that we are
18 * mis-aligned by, and r1 is the number of bytes. If r1 < 4, then we
19 * don't bother; we use byte stores instead.
20 */
211: subs r1, r1, #4 @ 1 do we have enough
22 blt 5f @ 1 bytes to align with?
23 cmp r3, #2 @ 1
24 strltb r2, [r0], #1 @ 1
25 strleb r2, [r0], #1 @ 1
26 strb r2, [r0], #1 @ 1
27 add r1, r1, r3 @ 1 (r1 = r1 - (4 - r3))
28/*
29 * The pointer is now aligned and the length is adjusted. Try doing the
30 * memzero again.
31 */
32
33ENTRY(__memzero)
34 mov r2, #0 @ 1
35 ands r3, r0, #3 @ 1 unaligned?
36 bne 1b @ 1
37/*
38 * r3 = 0, and we know that the pointer in r0 is aligned to a word boundary.
39 */
40 cmp r1, #16 @ 1 we can skip this chunk if we
41 blt 4f @ 1 have < 16 bytes
42/*
43 * We need an extra register for this loop - save the return address and
44 * use the LR
45 */
46 str lr, [sp, #-4]! @ 1
47 mov ip, r2 @ 1
48 mov lr, r2 @ 1
49
503: subs r1, r1, #64 @ 1 write 32 bytes out per loop
51 stmgeia r0!, {r2, r3, ip, lr} @ 4
52 stmgeia r0!, {r2, r3, ip, lr} @ 4
53 stmgeia r0!, {r2, r3, ip, lr} @ 4
54 stmgeia r0!, {r2, r3, ip, lr} @ 4
55 bgt 3b @ 1
56 LOADREGS(eqfd, sp!, {pc}) @ 1/2 quick exit
57/*
58 * No need to correct the count; we're only testing bits from now on
59 */
60 tst r1, #32 @ 1
61 stmneia r0!, {r2, r3, ip, lr} @ 4
62 stmneia r0!, {r2, r3, ip, lr} @ 4
63 tst r1, #16 @ 1 16 bytes or more?
64 stmneia r0!, {r2, r3, ip, lr} @ 4
65 ldr lr, [sp], #4 @ 1
66
674: tst r1, #8 @ 1 8 bytes or more?
68 stmneia r0!, {r2, r3} @ 2
69 tst r1, #4 @ 1 4 bytes or more?
70 strne r2, [r0], #4 @ 1
71/*
72 * When we get here, we've got less than 4 bytes to zero. We
73 * may have an unaligned pointer as well.
74 */
755: tst r1, #2 @ 1 2 bytes or more?
76 strneb r2, [r0], #1 @ 1
77 strneb r2, [r0], #1 @ 1
78 tst r1, #1 @ 1 a byte left over
79 strneb r2, [r0], #1 @ 1
80 RETINSTR(mov,pc,lr) @ 1
diff --git a/arch/arm26/lib/muldi3.c b/arch/arm26/lib/muldi3.c
deleted file mode 100644
index 44d611b1cfdb..000000000000
--- a/arch/arm26/lib/muldi3.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/* More subroutines needed by GCC output code on some machines. */
2/* Compile this one with gcc. */
3/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc.
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
22/* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License.
28 */
29/* support functions required by the kernel. based on code from gcc-2.95.3 */
30/* I Molton 29/07/01 */
31
32#include "gcclib.h"
33
34#define umul_ppmm(xh, xl, a, b) \
35{register USItype __t0, __t1, __t2; \
36 __asm__ ("%@ Inlined umul_ppmm \n\
37 mov %2, %5, lsr #16 \n\
38 mov %0, %6, lsr #16 \n\
39 bic %3, %5, %2, lsl #16 \n\
40 bic %4, %6, %0, lsl #16 \n\
41 mul %1, %3, %4 \n\
42 mul %4, %2, %4 \n\
43 mul %3, %0, %3 \n\
44 mul %0, %2, %0 \n\
45 adds %3, %4, %3 \n\
46 addcs %0, %0, #65536 \n\
47 adds %1, %1, %3, lsl #16 \n\
48 adc %0, %0, %3, lsr #16" \
49 : "=&r" ((USItype) (xh)), \
50 "=r" ((USItype) (xl)), \
51 "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
52 : "r" ((USItype) (a)), \
53 "r" ((USItype) (b)));}
54
55
56#define __umulsidi3(u, v) \
57 ({DIunion __w; \
58 umul_ppmm (__w.s.high, __w.s.low, u, v); \
59 __w.ll; })
60
61
62DItype
63__muldi3 (DItype u, DItype v)
64{
65 DIunion w;
66 DIunion uu, vv;
67
68 uu.ll = u,
69 vv.ll = v;
70
71 w.ll = __umulsidi3 (uu.s.low, vv.s.low);
72 w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high
73 + (USItype) uu.s.high * (USItype) vv.s.low);
74
75 return w.ll;
76}
77
diff --git a/arch/arm26/lib/putuser.S b/arch/arm26/lib/putuser.S
deleted file mode 100644
index 46c7f15f9f2d..000000000000
--- a/arch/arm26/lib/putuser.S
+++ /dev/null
@@ -1,109 +0,0 @@
1/*
2 * linux/arch/arm26/lib/putuser.S
3 *
4 * Copyright (C) 2001 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Idea from x86 version, (C) Copyright 1998 Linus Torvalds
11 *
12 * These functions have a non-standard call interface to make
13 * them more efficient, especially as they return an error
14 * value in addition to the "real" return value.
15 *
16 * __put_user_X
17 *
18 * Inputs: r0 contains the address
19 * r1, r2 contains the value
20 * Outputs: r0 is the error code
21 * lr corrupted
22 *
23 * No other registers must be altered. (see include/asm-arm/uaccess.h
24 * for specific ASM register usage).
25 *
26 * Note that ADDR_LIMIT is either 0 or 0xc0000000
27 * Note also that it is intended that __put_user_bad is not global.
28 */
29#include <asm/asm-offsets.h>
30#include <asm/thread_info.h>
31#include <asm/errno.h>
32
33 .global __put_user_1
34__put_user_1:
35 bic r2, sp, #0x1f00
36 bic r2, r2, #0x00ff
37 str lr, [sp, #-4]!
38 ldr r2, [r2, #TI_ADDR_LIMIT]
39 sub r2, r2, #1
40 cmp r0, r2
41 bge __put_user_bad
421: cmp r0, #0x02000000
43 strlsbt r1, [r0]
44 strgeb r1, [r0]
45 mov r0, #0
46 ldmfd sp!, {pc}^
47
48 .global __put_user_2
49__put_user_2:
50 bic r2, sp, #0x1f00
51 bic r2, r2, #0x00ff
52 str lr, [sp, #-4]!
53 ldr r2, [r2, #TI_ADDR_LIMIT]
54 sub r2, r2, #2
55 cmp r0, r2
56 bge __put_user_bad
572: cmp r0, #0x02000000
58 strlsbt r1, [r0], #1
59 strgeb r1, [r0], #1
60 mov r1, r1, lsr #8
613: strlsbt r1, [r0]
62 strgeb r1, [r0]
63 mov r0, #0
64 ldmfd sp!, {pc}^
65
66 .global __put_user_4
67__put_user_4:
68 bic r2, sp, #0x1f00
69 bic r2, r2, #0x00ff
70 str lr, [sp, #-4]!
71 ldr r2, [r2, #TI_ADDR_LIMIT]
72 sub r2, r2, #4
73 cmp r0, r2
744: bge __put_user_bad
75 cmp r0, #0x02000000
76 strlst r1, [r0]
77 strge r1, [r0]
78 mov r0, #0
79 ldmfd sp!, {pc}^
80
81 .global __put_user_8
82__put_user_8:
83 bic ip, sp, #0x1f00
84 bic ip, ip, #0x00ff
85 str lr, [sp, #-4]!
86 ldr ip, [ip, #TI_ADDR_LIMIT]
87 sub ip, ip, #8
88 cmp r0, ip
89 bge __put_user_bad
90 cmp r0, #0x02000000
915: strlst r1, [r0], #4
926: strlst r2, [r0]
93 strge r1, [r0], #4
94 strge r2, [r0]
95 mov r0, #0
96 ldmfd sp!, {pc}^
97
98__put_user_bad:
99 mov r0, #-EFAULT
100 mov pc, lr
101
102.section __ex_table, "a"
103 .long 1b, __put_user_bad
104 .long 2b, __put_user_bad
105 .long 3b, __put_user_bad
106 .long 4b, __put_user_bad
107 .long 5b, __put_user_bad
108 .long 6b, __put_user_bad
109.previous
diff --git a/arch/arm26/lib/setbit.S b/arch/arm26/lib/setbit.S
deleted file mode 100644
index e180c1a1b2f1..000000000000
--- a/arch/arm26/lib/setbit.S
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * linux/arch/arm26/lib/setbit.S
3 *
4 * Copyright (C) 1995-1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12 .text
13
14/*
15 * Purpose : Function to set a bit
16 * Prototype: int set_bit(int bit, void *addr)
17 */
18ENTRY(_set_bit_be)
19 eor r0, r0, #0x18 @ big endian byte ordering
20ENTRY(_set_bit_le)
21 and r2, r0, #7
22 mov r3, #1
23 mov r3, r3, lsl r2
24 save_and_disable_irqs ip, r2
25 ldrb r2, [r1, r0, lsr #3]
26 orr r2, r2, r3
27 strb r2, [r1, r0, lsr #3]
28 restore_irqs ip
29 RETINSTR(mov,pc,lr)
diff --git a/arch/arm26/lib/strchr.S b/arch/arm26/lib/strchr.S
deleted file mode 100644
index ecfff21aa7c7..000000000000
--- a/arch/arm26/lib/strchr.S
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * linux/arch/arm26/lib/strchr.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ASM optimised string functions
11 */
12#include <linux/linkage.h>
13#include <asm/assembler.h>
14
15 .text
16 .align 5
17ENTRY(strchr)
181: ldrb r2, [r0], #1
19 teq r2, r1
20 teqne r2, #0
21 bne 1b
22 teq r2, #0
23 moveq r0, #0
24 subne r0, r0, #1
25 RETINSTR(mov,pc,lr)
diff --git a/arch/arm26/lib/strrchr.S b/arch/arm26/lib/strrchr.S
deleted file mode 100644
index db43b28e78dc..000000000000
--- a/arch/arm26/lib/strrchr.S
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * linux/arch/arm26/lib/strrchr.S
3 *
4 * Copyright (C) 1995-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ASM optimised string functions
11 */
12#include <linux/linkage.h>
13#include <asm/assembler.h>
14
15 .text
16 .align 5
17ENTRY(strrchr)
18 mov r3, #0
191: ldrb r2, [r0], #1
20 teq r2, r1
21 subeq r3, r0, #1
22 teq r2, #0
23 bne 1b
24 mov r0, r3
25 RETINSTR(mov,pc,lr)
diff --git a/arch/arm26/lib/testchangebit.S b/arch/arm26/lib/testchangebit.S
deleted file mode 100644
index 17049a2d93a4..000000000000
--- a/arch/arm26/lib/testchangebit.S
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * linux/arch/arm26/lib/testchangebit.S
3 *
4 * Copyright (C) 1995-1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12 .text
13
14ENTRY(_test_and_change_bit_be)
15 eor r0, r0, #0x18 @ big endian byte ordering
16ENTRY(_test_and_change_bit_le)
17 add r1, r1, r0, lsr #3
18 and r3, r0, #7
19 mov r0, #1
20 save_and_disable_irqs ip, r2
21 ldrb r2, [r1]
22 tst r2, r0, lsl r3
23 eor r2, r2, r0, lsl r3
24 strb r2, [r1]
25 restore_irqs ip
26 moveq r0, #0
27 RETINSTR(mov,pc,lr)
28
29
diff --git a/arch/arm26/lib/testclearbit.S b/arch/arm26/lib/testclearbit.S
deleted file mode 100644
index 2506bd743ab4..000000000000
--- a/arch/arm26/lib/testclearbit.S
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * linux/arch/arm26/lib/testclearbit.S
3 *
4 * Copyright (C) 1995-1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12 .text
13
14ENTRY(_test_and_clear_bit_be)
15 eor r0, r0, #0x18 @ big endian byte ordering
16ENTRY(_test_and_clear_bit_le)
17 add r1, r1, r0, lsr #3 @ Get byte offset
18 and r3, r0, #7 @ Get bit offset
19 mov r0, #1
20 save_and_disable_irqs ip, r2
21 ldrb r2, [r1]
22 tst r2, r0, lsl r3
23 bic r2, r2, r0, lsl r3
24 strb r2, [r1]
25 restore_irqs ip
26 moveq r0, #0
27 RETINSTR(mov,pc,lr)
28
29
diff --git a/arch/arm26/lib/testsetbit.S b/arch/arm26/lib/testsetbit.S
deleted file mode 100644
index f827de64b22d..000000000000
--- a/arch/arm26/lib/testsetbit.S
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * linux/arch/arm26/lib/testsetbit.S
3 *
4 * Copyright (C) 1995-1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/linkage.h>
11#include <asm/assembler.h>
12 .text
13
14ENTRY(_test_and_set_bit_be)
15 eor r0, r0, #0x18 @ big endian byte ordering
16ENTRY(_test_and_set_bit_le)
17 add r1, r1, r0, lsr #3 @ Get byte offset
18 and r3, r0, #7 @ Get bit offset
19 mov r0, #1
20 save_and_disable_irqs ip, r2
21 ldrb r2, [r1]
22 tst r2, r0, lsl r3
23 orr r2, r2, r0, lsl r3
24 strb r2, [r1]
25 restore_irqs ip
26 moveq r0, #0
27 RETINSTR(mov,pc,lr)
28
29
diff --git a/arch/arm26/lib/uaccess-kernel.S b/arch/arm26/lib/uaccess-kernel.S
deleted file mode 100644
index 3950a1f6bc99..000000000000
--- a/arch/arm26/lib/uaccess-kernel.S
+++ /dev/null
@@ -1,173 +0,0 @@
1/*
2 * linux/arch/arm26/lib/uaccess-kernel.S
3 *
4 * Copyright (C) 1998 Russell King
5 *
6 * Note! Some code fragments found in here have a special calling
7 * convention - they are not APCS compliant!
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#include <linux/linkage.h>
14#include <asm/assembler.h>
15
16 .text
17
18//FIXME - surely this can be done in C not asm, removing the problem of keeping C and asm in sync? (this is a struct uaccess_t)
19
20 .globl uaccess_kernel
21uaccess_kernel:
22 .word uaccess_kernel_put_byte
23 .word uaccess_kernel_get_byte
24 .word uaccess_kernel_put_half
25 .word uaccess_kernel_get_half
26 .word uaccess_kernel_put_word
27 .word uaccess_kernel_get_word
28 .word uaccess_kernel_put_dword
29 .word uaccess_kernel_copy
30 .word uaccess_kernel_copy
31 .word uaccess_kernel_clear
32 .word uaccess_kernel_strncpy
33 .word uaccess_kernel_strnlen
34
35@ In : r0 = x, r1 = addr, r2 = error
36@ Out: r2 = error
37uaccess_kernel_put_byte:
38 stmfd sp!, {lr}
39 strb r0, [r1]
40 ldmfd sp!, {pc}^
41
42@ In : r0 = x, r1 = addr, r2 = error
43@ Out: r2 = error
44uaccess_kernel_put_half:
45 stmfd sp!, {lr}
46 strb r0, [r1]
47 mov r0, r0, lsr #8
48 strb r0, [r1, #1]
49 ldmfd sp!, {pc}^
50
51@ In : r0 = x, r1 = addr, r2 = error
52@ Out: r2 = error
53uaccess_kernel_put_word:
54 stmfd sp!, {lr}
55 str r0, [r1]
56 ldmfd sp!, {pc}^
57
58@ In : r0 = x, r1 = addr, r2 = error
59@ Out: r2 = error
60uaccess_kernel_put_dword:
61 stmfd sp!, {lr}
62 str r0, [r1], #4
63 str r0, [r1], #0
64 ldmfd sp!, {pc}^
65
66@ In : r0 = addr, r1 = error
67@ Out: r0 = x, r1 = error
68uaccess_kernel_get_byte:
69 stmfd sp!, {lr}
70 ldrb r0, [r0]
71 ldmfd sp!, {pc}^
72
73@ In : r0 = addr, r1 = error
74@ Out: r0 = x, r1 = error
75uaccess_kernel_get_half:
76 stmfd sp!, {lr}
77 ldr r0, [r0]
78 mov r0, r0, lsl #16
79 mov r0, r0, lsr #16
80 ldmfd sp!, {pc}^
81
82@ In : r0 = addr, r1 = error
83@ Out: r0 = x, r1 = error
84uaccess_kernel_get_word:
85 stmfd sp!, {lr}
86 ldr r0, [r0]
87 ldmfd sp!, {pc}^
88
89
90/* Prototype: int uaccess_kernel_copy(void *to, const char *from, size_t n)
91 * Purpose : copy a block to kernel memory from kernel memory
92 * Params : to - kernel memory
93 * : from - kernel memory
94 * : n - number of bytes to copy
95 * Returns : Number of bytes NOT copied.
96 */
97uaccess_kernel_copy:
98 stmfd sp!, {lr}
99 bl memcpy
100 mov r0, #0
101 ldmfd sp!, {pc}^
102
103/* Prototype: int uaccess_kernel_clear(void *addr, size_t sz)
104 * Purpose : clear some kernel memory
105 * Params : addr - kernel memory address to clear
106 * : sz - number of bytes to clear
107 * Returns : number of bytes NOT cleared
108 */
109uaccess_kernel_clear:
110 stmfd sp!, {lr}
111 mov r2, #0
112 cmp r1, #4
113 blt 2f
114 ands ip, r0, #3
115 beq 1f
116 cmp ip, #1
117 strb r2, [r0], #1
118 strleb r2, [r0], #1
119 strltb r2, [r0], #1
120 rsb ip, ip, #4
121 sub r1, r1, ip @ 7 6 5 4 3 2 1
1221: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7
123 bmi 2f
124 str r2, [r0], #4
125 str r2, [r0], #4
126 b 1b
1272: adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3
128 strpl r2, [r0], #4
129 tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x
130 strneb r2, [r0], #1
131 strneb r2, [r0], #1
132 tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1
133 strneb r2, [r0], #1
134 mov r0, #0
135 ldmfd sp!, {pc}^
136
137/* Prototype: size_t uaccess_kernel_strncpy(char *dst, char *src, size_t len)
138 * Purpose : copy a string from kernel memory to kernel memory
139 * Params : dst - kernel memory destination
140 * : src - kernel memory source
141 * : len - maximum length of string
142 * Returns : number of characters copied
143 */
144uaccess_kernel_strncpy:
145 stmfd sp!, {lr}
146 mov ip, r2
1471: subs r2, r2, #1
148 bmi 2f
149 ldrb r3, [r1], #1
150 strb r3, [r0], #1
151 teq r3, #0
152 bne 1b
1532: subs r0, ip, r2
154 ldmfd sp!, {pc}^
155
156/* Prototype: int uaccess_kernel_strlen(char *str, long n)
157 * Purpose : get length of a string in kernel memory
158 * Params : str - address of string in kernel memory
159 * Returns : length of string *including terminator*,
160 * or zero on exception, or n + 1 if too long
161 */
162uaccess_kernel_strnlen:
163 stmfd sp!, {lr}
164 mov r2, r0
1651: ldrb r1, [r0], #1
166 teq r1, #0
167 beq 2f
168 subs r1, r1, #1
169 bne 1b
170 add r0, r0, #1
1712: sub r0, r0, r2
172 ldmfd sp!, {pc}^
173
diff --git a/arch/arm26/lib/uaccess-user.S b/arch/arm26/lib/uaccess-user.S
deleted file mode 100644
index 130b8f28610a..000000000000
--- a/arch/arm26/lib/uaccess-user.S
+++ /dev/null
@@ -1,718 +0,0 @@
1/*
2 * linux/arch/arm26/lib/uaccess-user.S
3 *
4 * Copyright (C) 1995, 1996,1997,1998 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Routines to block copy data to/from user memory
11 * These are highly optimised both for the 4k page size
12 * and for various alignments.
13 */
14#include <linux/linkage.h>
15#include <asm/assembler.h>
16#include <asm/errno.h>
17#include <asm/page.h>
18
19 .text
20
21//FIXME - surely this can be done in C not asm, removing the problem of keeping C and asm in sync? (this is a struct uaccess_t)
22 .globl uaccess_user
23uaccess_user:
24 .word uaccess_user_put_byte
25 .word uaccess_user_get_byte
26 .word uaccess_user_put_half
27 .word uaccess_user_get_half
28 .word uaccess_user_put_word
29 .word uaccess_user_get_word
30 .word uaccess_user_put_dword
31 .word uaccess_user_copy_from_user
32 .word uaccess_user_copy_to_user
33 .word uaccess_user_clear_user
34 .word uaccess_user_strncpy_from_user
35 .word uaccess_user_strnlen_user
36
37
38@ In : r0 = x, r1 = addr, r2 = error
39@ Out: r2 = error
40uaccess_user_put_byte:
41 stmfd sp!, {lr}
42USER( strbt r0, [r1])
43 ldmfd sp!, {pc}^
44
45@ In : r0 = x, r1 = addr, r2 = error
46@ Out: r2 = error
47uaccess_user_put_half:
48 stmfd sp!, {lr}
49USER( strbt r0, [r1], #1)
50 mov r0, r0, lsr #8
51USER( strbt r0, [r1])
52 ldmfd sp!, {pc}^
53
54@ In : r0 = x, r1 = addr, r2 = error
55@ Out: r2 = error
56uaccess_user_put_word:
57 stmfd sp!, {lr}
58USER( strt r0, [r1])
59 ldmfd sp!, {pc}^
60
61@ In : r0 = x, r1 = addr, r2 = error
62@ Out: r2 = error
63uaccess_user_put_dword:
64 stmfd sp!, {lr}
65USER( strt r0, [r1], #4)
66USER( strt r0, [r1], #0)
67 ldmfd sp!, {pc}^
68
699001: mov r2, #-EFAULT
70 ldmfd sp!, {pc}^
71
72
73@ In : r0 = addr, r1 = error
74@ Out: r0 = x, r1 = error
75uaccess_user_get_byte:
76 stmfd sp!, {lr}
77USER( ldrbt r0, [r0])
78 ldmfd sp!, {pc}^
79
80@ In : r0 = addr, r1 = error
81@ Out: r0 = x, r1 = error
82uaccess_user_get_half:
83 stmfd sp!, {lr}
84USER( ldrt r0, [r0])
85 mov r0, r0, lsl #16
86 mov r0, r0, lsr #16
87 ldmfd sp!, {pc}^
88
89@ In : r0 = addr, r1 = error
90@ Out: r0 = x, r1 = error
91uaccess_user_get_word:
92 stmfd sp!, {lr}
93USER( ldrt r0, [r0])
94 ldmfd sp!, {pc}^
95
969001: mov r1, #-EFAULT
97 ldmfd sp!, {pc}^
98
99/* Prototype: int uaccess_user_copy_to_user(void *to, const char *from, size_t n)
100 * Purpose : copy a block to user memory from kernel memory
101 * Params : to - user memory
102 * : from - kernel memory
103 * : n - number of bytes to copy
104 * Returns : Number of bytes NOT copied.
105 */
106
107.c2u_dest_not_aligned:
108 rsb ip, ip, #4
109 cmp ip, #2
110 ldrb r3, [r1], #1
111USER( strbt r3, [r0], #1) @ May fault
112 ldrgeb r3, [r1], #1
113USER( strgebt r3, [r0], #1) @ May fault
114 ldrgtb r3, [r1], #1
115USER( strgtbt r3, [r0], #1) @ May fault
116 sub r2, r2, ip
117 b .c2u_dest_aligned
118
119ENTRY(uaccess_user_copy_to_user)
120 stmfd sp!, {r2, r4 - r7, lr}
121 cmp r2, #4
122 blt .c2u_not_enough
123 ands ip, r0, #3
124 bne .c2u_dest_not_aligned
125.c2u_dest_aligned:
126
127 ands ip, r1, #3
128 bne .c2u_src_not_aligned
129/*
130 * Seeing as there has to be at least 8 bytes to copy, we can
131 * copy one word, and force a user-mode page fault...
132 */
133
134.c2u_0fupi: subs r2, r2, #4
135 addmi ip, r2, #4
136 bmi .c2u_0nowords
137 ldr r3, [r1], #4
138USER( strt r3, [r0], #4) @ May fault
139 mov ip, r0, lsl #32 - PAGE_SHIFT @ On each page, use a ld/st??t instruction
140 rsb ip, ip, #0
141 movs ip, ip, lsr #32 - PAGE_SHIFT
142 beq .c2u_0fupi
143/*
144 * ip = max no. of bytes to copy before needing another "strt" insn
145 */
146 cmp r2, ip
147 movlt ip, r2
148 sub r2, r2, ip
149 subs ip, ip, #32
150 blt .c2u_0rem8lp
151
152.c2u_0cpy8lp: ldmia r1!, {r3 - r6}
153 stmia r0!, {r3 - r6} @ Shouldnt fault
154 ldmia r1!, {r3 - r6}
155 stmia r0!, {r3 - r6} @ Shouldnt fault
156 subs ip, ip, #32
157 bpl .c2u_0cpy8lp
158.c2u_0rem8lp: cmn ip, #16
159 ldmgeia r1!, {r3 - r6}
160 stmgeia r0!, {r3 - r6} @ Shouldnt fault
161 tst ip, #8
162 ldmneia r1!, {r3 - r4}
163 stmneia r0!, {r3 - r4} @ Shouldnt fault
164 tst ip, #4
165 ldrne r3, [r1], #4
166 strnet r3, [r0], #4 @ Shouldnt fault
167 ands ip, ip, #3
168 beq .c2u_0fupi
169.c2u_0nowords: teq ip, #0
170 beq .c2u_finished
171.c2u_nowords: cmp ip, #2
172 ldrb r3, [r1], #1
173USER( strbt r3, [r0], #1) @ May fault
174 ldrgeb r3, [r1], #1
175USER( strgebt r3, [r0], #1) @ May fault
176 ldrgtb r3, [r1], #1
177USER( strgtbt r3, [r0], #1) @ May fault
178 b .c2u_finished
179
180.c2u_not_enough:
181 movs ip, r2
182 bne .c2u_nowords
183.c2u_finished: mov r0, #0
184 LOADREGS(fd,sp!,{r2, r4 - r7, pc})
185
186.c2u_src_not_aligned:
187 bic r1, r1, #3
188 ldr r7, [r1], #4
189 cmp ip, #2
190 bgt .c2u_3fupi
191 beq .c2u_2fupi
192.c2u_1fupi: subs r2, r2, #4
193 addmi ip, r2, #4
194 bmi .c2u_1nowords
195 mov r3, r7, pull #8
196 ldr r7, [r1], #4
197 orr r3, r3, r7, push #24
198USER( strt r3, [r0], #4) @ May fault
199 mov ip, r0, lsl #32 - PAGE_SHIFT
200 rsb ip, ip, #0
201 movs ip, ip, lsr #32 - PAGE_SHIFT
202 beq .c2u_1fupi
203 cmp r2, ip
204 movlt ip, r2
205 sub r2, r2, ip
206 subs ip, ip, #16
207 blt .c2u_1rem8lp
208
209.c2u_1cpy8lp: mov r3, r7, pull #8
210 ldmia r1!, {r4 - r7}
211 orr r3, r3, r4, push #24
212 mov r4, r4, pull #8
213 orr r4, r4, r5, push #24
214 mov r5, r5, pull #8
215 orr r5, r5, r6, push #24
216 mov r6, r6, pull #8
217 orr r6, r6, r7, push #24
218 stmia r0!, {r3 - r6} @ Shouldnt fault
219 subs ip, ip, #16
220 bpl .c2u_1cpy8lp
221.c2u_1rem8lp: tst ip, #8
222 movne r3, r7, pull #8
223 ldmneia r1!, {r4, r7}
224 orrne r3, r3, r4, push #24
225 movne r4, r4, pull #8
226 orrne r4, r4, r7, push #24
227 stmneia r0!, {r3 - r4} @ Shouldnt fault
228 tst ip, #4
229 movne r3, r7, pull #8
230 ldrne r7, [r1], #4
231 orrne r3, r3, r7, push #24
232 strnet r3, [r0], #4 @ Shouldnt fault
233 ands ip, ip, #3
234 beq .c2u_1fupi
235.c2u_1nowords: mov r3, r7, lsr #byte(1)
236 teq ip, #0
237 beq .c2u_finished
238 cmp ip, #2
239USER( strbt r3, [r0], #1) @ May fault
240 movge r3, r7, lsr #byte(2)
241USER( strgebt r3, [r0], #1) @ May fault
242 movgt r3, r7, lsr #byte(3)
243USER( strgtbt r3, [r0], #1) @ May fault
244 b .c2u_finished
245
246.c2u_2fupi: subs r2, r2, #4
247 addmi ip, r2, #4
248 bmi .c2u_2nowords
249 mov r3, r7, pull #16
250 ldr r7, [r1], #4
251 orr r3, r3, r7, push #16
252USER( strt r3, [r0], #4) @ May fault
253 mov ip, r0, lsl #32 - PAGE_SHIFT
254 rsb ip, ip, #0
255 movs ip, ip, lsr #32 - PAGE_SHIFT
256 beq .c2u_2fupi
257 cmp r2, ip
258 movlt ip, r2
259 sub r2, r2, ip
260 subs ip, ip, #16
261 blt .c2u_2rem8lp
262
263.c2u_2cpy8lp: mov r3, r7, pull #16
264 ldmia r1!, {r4 - r7}
265 orr r3, r3, r4, push #16
266 mov r4, r4, pull #16
267 orr r4, r4, r5, push #16
268 mov r5, r5, pull #16
269 orr r5, r5, r6, push #16
270 mov r6, r6, pull #16
271 orr r6, r6, r7, push #16
272 stmia r0!, {r3 - r6} @ Shouldnt fault
273 subs ip, ip, #16
274 bpl .c2u_2cpy8lp
275.c2u_2rem8lp: tst ip, #8
276 movne r3, r7, pull #16
277 ldmneia r1!, {r4, r7}
278 orrne r3, r3, r4, push #16
279 movne r4, r4, pull #16
280 orrne r4, r4, r7, push #16
281 stmneia r0!, {r3 - r4} @ Shouldnt fault
282 tst ip, #4
283 movne r3, r7, pull #16
284 ldrne r7, [r1], #4
285 orrne r3, r3, r7, push #16
286 strnet r3, [r0], #4 @ Shouldnt fault
287 ands ip, ip, #3
288 beq .c2u_2fupi
289.c2u_2nowords: mov r3, r7, lsr #byte(2)
290 teq ip, #0
291 beq .c2u_finished
292 cmp ip, #2
293USER( strbt r3, [r0], #1) @ May fault
294 movge r3, r7, lsr #byte(3)
295USER( strgebt r3, [r0], #1) @ May fault
296 ldrgtb r3, [r1], #0
297USER( strgtbt r3, [r0], #1) @ May fault
298 b .c2u_finished
299
300.c2u_3fupi: subs r2, r2, #4
301 addmi ip, r2, #4
302 bmi .c2u_3nowords
303 mov r3, r7, pull #24
304 ldr r7, [r1], #4
305 orr r3, r3, r7, push #8
306USER( strt r3, [r0], #4) @ May fault
307 mov ip, r0, lsl #32 - PAGE_SHIFT
308 rsb ip, ip, #0
309 movs ip, ip, lsr #32 - PAGE_SHIFT
310 beq .c2u_3fupi
311 cmp r2, ip
312 movlt ip, r2
313 sub r2, r2, ip
314 subs ip, ip, #16
315 blt .c2u_3rem8lp
316
317.c2u_3cpy8lp: mov r3, r7, pull #24
318 ldmia r1!, {r4 - r7}
319 orr r3, r3, r4, push #8
320 mov r4, r4, pull #24
321 orr r4, r4, r5, push #8
322 mov r5, r5, pull #24
323 orr r5, r5, r6, push #8
324 mov r6, r6, pull #24
325 orr r6, r6, r7, push #8
326 stmia r0!, {r3 - r6} @ Shouldnt fault
327 subs ip, ip, #16
328 bpl .c2u_3cpy8lp
329.c2u_3rem8lp: tst ip, #8
330 movne r3, r7, pull #24
331 ldmneia r1!, {r4, r7}
332 orrne r3, r3, r4, push #8
333 movne r4, r4, pull #24
334 orrne r4, r4, r7, push #8
335 stmneia r0!, {r3 - r4} @ Shouldnt fault
336 tst ip, #4
337 movne r3, r7, pull #24
338 ldrne r7, [r1], #4
339 orrne r3, r3, r7, push #8
340 strnet r3, [r0], #4 @ Shouldnt fault
341 ands ip, ip, #3
342 beq .c2u_3fupi
343.c2u_3nowords: mov r3, r7, lsr #byte(3)
344 teq ip, #0
345 beq .c2u_finished
346 cmp ip, #2
347USER( strbt r3, [r0], #1) @ May fault
348 ldrgeb r3, [r1], #1
349USER( strgebt r3, [r0], #1) @ May fault
350 ldrgtb r3, [r1], #0
351USER( strgtbt r3, [r0], #1) @ May fault
352 b .c2u_finished
353
354 .section .fixup,"ax"
355 .align 0
3569001: LOADREGS(fd,sp!, {r0, r4 - r7, pc})
357 .previous
358
359/* Prototype: unsigned long uaccess_user_copy_from_user(void *to,const void *from,unsigned long n);
360 * Purpose : copy a block from user memory to kernel memory
361 * Params : to - kernel memory
362 * : from - user memory
363 * : n - number of bytes to copy
364 * Returns : Number of bytes NOT copied.
365 */
366.cfu_dest_not_aligned:
367 rsb ip, ip, #4
368 cmp ip, #2
369USER( ldrbt r3, [r1], #1) @ May fault
370 strb r3, [r0], #1
371USER( ldrgebt r3, [r1], #1) @ May fault
372 strgeb r3, [r0], #1
373USER( ldrgtbt r3, [r1], #1) @ May fault
374 strgtb r3, [r0], #1
375 sub r2, r2, ip
376 b .cfu_dest_aligned
377
378ENTRY(uaccess_user_copy_from_user)
379 stmfd sp!, {r0, r2, r4 - r7, lr}
380 cmp r2, #4
381 blt .cfu_not_enough
382 ands ip, r0, #3
383 bne .cfu_dest_not_aligned
384.cfu_dest_aligned:
385 ands ip, r1, #3
386 bne .cfu_src_not_aligned
387/*
388 * Seeing as there has to be at least 8 bytes to copy, we can
389 * copy one word, and force a user-mode page fault...
390 */
391
392.cfu_0fupi: subs r2, r2, #4
393 addmi ip, r2, #4
394 bmi .cfu_0nowords
395USER( ldrt r3, [r1], #4)
396 str r3, [r0], #4
397 mov ip, r1, lsl #32 - PAGE_SHIFT @ On each page, use a ld/st??t instruction
398 rsb ip, ip, #0
399 movs ip, ip, lsr #32 - PAGE_SHIFT
400 beq .cfu_0fupi
401/*
402 * ip = max no. of bytes to copy before needing another "strt" insn
403 */
404 cmp r2, ip
405 movlt ip, r2
406 sub r2, r2, ip
407 subs ip, ip, #32
408 blt .cfu_0rem8lp
409
410.cfu_0cpy8lp: ldmia r1!, {r3 - r6} @ Shouldnt fault
411 stmia r0!, {r3 - r6}
412 ldmia r1!, {r3 - r6} @ Shouldnt fault
413 stmia r0!, {r3 - r6}
414 subs ip, ip, #32
415 bpl .cfu_0cpy8lp
416.cfu_0rem8lp: cmn ip, #16
417 ldmgeia r1!, {r3 - r6} @ Shouldnt fault
418 stmgeia r0!, {r3 - r6}
419 tst ip, #8
420 ldmneia r1!, {r3 - r4} @ Shouldnt fault
421 stmneia r0!, {r3 - r4}
422 tst ip, #4
423 ldrnet r3, [r1], #4 @ Shouldnt fault
424 strne r3, [r0], #4
425 ands ip, ip, #3
426 beq .cfu_0fupi
427.cfu_0nowords: teq ip, #0
428 beq .cfu_finished
429.cfu_nowords: cmp ip, #2
430USER( ldrbt r3, [r1], #1) @ May fault
431 strb r3, [r0], #1
432USER( ldrgebt r3, [r1], #1) @ May fault
433 strgeb r3, [r0], #1
434USER( ldrgtbt r3, [r1], #1) @ May fault
435 strgtb r3, [r0], #1
436 b .cfu_finished
437
438.cfu_not_enough:
439 movs ip, r2
440 bne .cfu_nowords
441.cfu_finished: mov r0, #0
442 add sp, sp, #8
443 LOADREGS(fd,sp!,{r4 - r7, pc})
444
445.cfu_src_not_aligned:
446 bic r1, r1, #3
447USER( ldrt r7, [r1], #4) @ May fault
448 cmp ip, #2
449 bgt .cfu_3fupi
450 beq .cfu_2fupi
451.cfu_1fupi: subs r2, r2, #4
452 addmi ip, r2, #4
453 bmi .cfu_1nowords
454 mov r3, r7, pull #8
455USER( ldrt r7, [r1], #4) @ May fault
456 orr r3, r3, r7, push #24
457 str r3, [r0], #4
458 mov ip, r1, lsl #32 - PAGE_SHIFT
459 rsb ip, ip, #0
460 movs ip, ip, lsr #32 - PAGE_SHIFT
461 beq .cfu_1fupi
462 cmp r2, ip
463 movlt ip, r2
464 sub r2, r2, ip
465 subs ip, ip, #16
466 blt .cfu_1rem8lp
467
468.cfu_1cpy8lp: mov r3, r7, pull #8
469 ldmia r1!, {r4 - r7} @ Shouldnt fault
470 orr r3, r3, r4, push #24
471 mov r4, r4, pull #8
472 orr r4, r4, r5, push #24
473 mov r5, r5, pull #8
474 orr r5, r5, r6, push #24
475 mov r6, r6, pull #8
476 orr r6, r6, r7, push #24
477 stmia r0!, {r3 - r6}
478 subs ip, ip, #16
479 bpl .cfu_1cpy8lp
480.cfu_1rem8lp: tst ip, #8
481 movne r3, r7, pull #8
482 ldmneia r1!, {r4, r7} @ Shouldnt fault
483 orrne r3, r3, r4, push #24
484 movne r4, r4, pull #8
485 orrne r4, r4, r7, push #24
486 stmneia r0!, {r3 - r4}
487 tst ip, #4
488 movne r3, r7, pull #8
489USER( ldrnet r7, [r1], #4) @ May fault
490 orrne r3, r3, r7, push #24
491 strne r3, [r0], #4
492 ands ip, ip, #3
493 beq .cfu_1fupi
494.cfu_1nowords: mov r3, r7, lsr #byte(1)
495 teq ip, #0
496 beq .cfu_finished
497 cmp ip, #2
498 strb r3, [r0], #1
499 movge r3, r7, lsr #byte(2)
500 strgeb r3, [r0], #1
501 movgt r3, r7, lsr #byte(3)
502 strgtb r3, [r0], #1
503 b .cfu_finished
504
505.cfu_2fupi: subs r2, r2, #4
506 addmi ip, r2, #4
507 bmi .cfu_2nowords
508 mov r3, r7, pull #16
509USER( ldrt r7, [r1], #4) @ May fault
510 orr r3, r3, r7, push #16
511 str r3, [r0], #4
512 mov ip, r1, lsl #32 - PAGE_SHIFT
513 rsb ip, ip, #0
514 movs ip, ip, lsr #32 - PAGE_SHIFT
515 beq .cfu_2fupi
516 cmp r2, ip
517 movlt ip, r2
518 sub r2, r2, ip
519 subs ip, ip, #16
520 blt .cfu_2rem8lp
521
522.cfu_2cpy8lp: mov r3, r7, pull #16
523 ldmia r1!, {r4 - r7} @ Shouldnt fault
524 orr r3, r3, r4, push #16
525 mov r4, r4, pull #16
526 orr r4, r4, r5, push #16
527 mov r5, r5, pull #16
528 orr r5, r5, r6, push #16
529 mov r6, r6, pull #16
530 orr r6, r6, r7, push #16
531 stmia r0!, {r3 - r6}
532 subs ip, ip, #16
533 bpl .cfu_2cpy8lp
534.cfu_2rem8lp: tst ip, #8
535 movne r3, r7, pull #16
536 ldmneia r1!, {r4, r7} @ Shouldnt fault
537 orrne r3, r3, r4, push #16
538 movne r4, r4, pull #16
539 orrne r4, r4, r7, push #16
540 stmneia r0!, {r3 - r4}
541 tst ip, #4
542 movne r3, r7, pull #16
543USER( ldrnet r7, [r1], #4) @ May fault
544 orrne r3, r3, r7, push #16
545 strne r3, [r0], #4
546 ands ip, ip, #3
547 beq .cfu_2fupi
548.cfu_2nowords: mov r3, r7, lsr #byte(2)
549 teq ip, #0
550 beq .cfu_finished
551 cmp ip, #2
552 strb r3, [r0], #1
553 movge r3, r7, lsr #byte(3)
554 strgeb r3, [r0], #1
555USER( ldrgtbt r3, [r1], #0) @ May fault
556 strgtb r3, [r0], #1
557 b .cfu_finished
558
559.cfu_3fupi: subs r2, r2, #4
560 addmi ip, r2, #4
561 bmi .cfu_3nowords
562 mov r3, r7, pull #24
563USER( ldrt r7, [r1], #4) @ May fault
564 orr r3, r3, r7, push #8
565 str r3, [r0], #4
566 mov ip, r1, lsl #32 - PAGE_SHIFT
567 rsb ip, ip, #0
568 movs ip, ip, lsr #32 - PAGE_SHIFT
569 beq .cfu_3fupi
570 cmp r2, ip
571 movlt ip, r2
572 sub r2, r2, ip
573 subs ip, ip, #16
574 blt .cfu_3rem8lp
575
576.cfu_3cpy8lp: mov r3, r7, pull #24
577 ldmia r1!, {r4 - r7} @ Shouldnt fault
578 orr r3, r3, r4, push #8
579 mov r4, r4, pull #24
580 orr r4, r4, r5, push #8
581 mov r5, r5, pull #24
582 orr r5, r5, r6, push #8
583 mov r6, r6, pull #24
584 orr r6, r6, r7, push #8
585 stmia r0!, {r3 - r6}
586 subs ip, ip, #16
587 bpl .cfu_3cpy8lp
588.cfu_3rem8lp: tst ip, #8
589 movne r3, r7, pull #24
590 ldmneia r1!, {r4, r7} @ Shouldnt fault
591 orrne r3, r3, r4, push #8
592 movne r4, r4, pull #24
593 orrne r4, r4, r7, push #8
594 stmneia r0!, {r3 - r4}
595 tst ip, #4
596 movne r3, r7, pull #24
597USER( ldrnet r7, [r1], #4) @ May fault
598 orrne r3, r3, r7, push #8
599 strne r3, [r0], #4
600 ands ip, ip, #3
601 beq .cfu_3fupi
602.cfu_3nowords: mov r3, r7, lsr #byte(3)
603 teq ip, #0
604 beq .cfu_finished
605 cmp ip, #2
606 strb r3, [r0], #1
607USER( ldrgebt r3, [r1], #1) @ May fault
608 strgeb r3, [r0], #1
609USER( ldrgtbt r3, [r1], #1) @ May fault
610 strgtb r3, [r0], #1
611 b .cfu_finished
612
613 .section .fixup,"ax"
614 .align 0
615 /*
616 * We took an exception. r0 contains a pointer to
617 * the byte not copied.
618 */
6199001: ldr r2, [sp], #4 @ void *to
620 sub r2, r0, r2 @ bytes copied
621 ldr r1, [sp], #4 @ unsigned long count
622 subs r4, r1, r2 @ bytes left to copy
623 movne r1, r4
624 blne __memzero
625 mov r0, r4
626 LOADREGS(fd,sp!, {r4 - r7, pc})
627 .previous
628
629/* Prototype: int uaccess_user_clear_user(void *addr, size_t sz)
630 * Purpose : clear some user memory
631 * Params : addr - user memory address to clear
632 * : sz - number of bytes to clear
633 * Returns : number of bytes NOT cleared
634 */
635ENTRY(uaccess_user_clear_user)
636 stmfd sp!, {r1, lr}
637 mov r2, #0
638 cmp r1, #4
639 blt 2f
640 ands ip, r0, #3
641 beq 1f
642 cmp ip, #2
643USER( strbt r2, [r0], #1)
644USER( strlebt r2, [r0], #1)
645USER( strltbt r2, [r0], #1)
646 rsb ip, ip, #4
647 sub r1, r1, ip @ 7 6 5 4 3 2 1
6481: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7
649USER( strplt r2, [r0], #4)
650USER( strplt r2, [r0], #4)
651 bpl 1b
652 adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3
653USER( strplt r2, [r0], #4)
6542: tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x
655USER( strnebt r2, [r0], #1)
656USER( strnebt r2, [r0], #1)
657 tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1
658USER( strnebt r2, [r0], #1)
659 mov r0, #0
660 LOADREGS(fd,sp!, {r1, pc})
661
662 .section .fixup,"ax"
663 .align 0
6649001: LOADREGS(fd,sp!, {r0, pc})
665 .previous
666
667/*
668 * Copy a string from user space to kernel space.
669 * r0 = dst, r1 = src, r2 = byte length
670 * returns the number of characters copied (strlen of copied string),
671 * -EFAULT on exception, or "len" if we fill the whole buffer
672 */
673ENTRY(uaccess_user_strncpy_from_user)
674 save_lr
675 mov ip, r1
6761: subs r2, r2, #1
677USER( ldrplbt r3, [r1], #1)
678 bmi 2f
679 strb r3, [r0], #1
680 teq r3, #0
681 bne 1b
682 sub r1, r1, #1 @ take NUL character out of count
6832: sub r0, r1, ip
684 restore_pc
685
686 .section .fixup,"ax"
687 .align 0
6889001: mov r3, #0
689 strb r3, [r0, #0] @ null terminate
690 mov r0, #-EFAULT
691 restore_pc
692 .previous
693
694/* Prototype: unsigned long uaccess_user_strnlen_user(const char *str, long n)
695 * Purpose : get length of a string in user memory
696 * Params : str - address of string in user memory
697 * Returns : length of string *including terminator*
698 * or zero on exception, or n + 1 if too long
699 */
700ENTRY(uaccess_user_strnlen_user)
701 save_lr
702 mov r2, r0
7031:
704USER( ldrbt r3, [r0], #1)
705 teq r3, #0
706 beq 2f
707 subs r1, r1, #1
708 bne 1b
709 add r0, r0, #1
7102: sub r0, r0, r2
711 restore_pc
712
713 .section .fixup,"ax"
714 .align 0
7159001: mov r0, #0
716 restore_pc
717 .previous
718
diff --git a/arch/arm26/lib/ucmpdi2.c b/arch/arm26/lib/ucmpdi2.c
deleted file mode 100644
index 6c6ae63efa02..000000000000
--- a/arch/arm26/lib/ucmpdi2.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/* More subroutines needed by GCC output code on some machines. */
2/* Compile this one with gcc. */
3/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc.
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
22/* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License.
28 */
29/* support functions required by the kernel. based on code from gcc-2.95.3 */
30/* I Molton 29/07/01 */
31
32#include "gcclib.h"
33
34word_type
35__ucmpdi2 (DItype a, DItype b)
36{
37 DIunion au, bu;
38
39 au.ll = a, bu.ll = b;
40
41 if ((USItype) au.s.high < (USItype) bu.s.high)
42 return 0;
43 else if ((USItype) au.s.high > (USItype) bu.s.high)
44 return 2;
45 if ((USItype) au.s.low < (USItype) bu.s.low)
46 return 0;
47 else if ((USItype) au.s.low > (USItype) bu.s.low)
48 return 2;
49 return 1;
50}
51
diff --git a/arch/arm26/lib/udivdi3.c b/arch/arm26/lib/udivdi3.c
deleted file mode 100644
index d25195f673f4..000000000000
--- a/arch/arm26/lib/udivdi3.c
+++ /dev/null
@@ -1,242 +0,0 @@
1/* More subroutines needed by GCC output code on some machines. */
2/* Compile this one with gcc. */
3/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc.
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
22/* As a special exception, if you link this library with other files,
23 some of which are compiled with GCC, to produce an executable,
24 this library does not by itself cause the resulting executable
25 to be covered by the GNU General Public License.
26 This exception does not however invalidate any other reasons why
27 the executable file might be covered by the GNU General Public License.
28 */
29/* support functions required by the kernel. based on code from gcc-2.95.3 */
30/* I Molton 29/07/01 */
31
32#include "gcclib.h"
33#include "longlong.h"
34
35static const UQItype __clz_tab[] =
36{
37 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
38 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
39 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
40 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
41 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
42 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
43 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
44 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
45};
46
47UDItype
48__udivmoddi4 (UDItype n, UDItype d, UDItype *rp)
49{
50 DIunion ww;
51 DIunion nn, dd;
52 DIunion rr;
53 USItype d0, d1, n0, n1, n2;
54 USItype q0, q1;
55 USItype b, bm;
56
57 nn.ll = n;
58 dd.ll = d;
59
60 d0 = dd.s.low;
61 d1 = dd.s.high;
62 n0 = nn.s.low;
63 n1 = nn.s.high;
64
65 if (d1 == 0)
66 {
67 if (d0 > n1)
68 {
69 /* 0q = nn / 0D */
70
71 count_leading_zeros (bm, d0);
72
73 if (bm != 0)
74 {
75 /* Normalize, i.e. make the most significant bit of the
76 denominator set. */
77
78 d0 = d0 << bm;
79 n1 = (n1 << bm) | (n0 >> (SI_TYPE_SIZE - bm));
80 n0 = n0 << bm;
81 }
82
83 udiv_qrnnd (q0, n0, n1, n0, d0);
84 q1 = 0;
85
86 /* Remainder in n0 >> bm. */
87 }
88 else
89 {
90 /* qq = NN / 0d */
91
92 if (d0 == 0)
93 d0 = 1 / d0; /* Divide intentionally by zero. */
94
95 count_leading_zeros (bm, d0);
96
97 if (bm == 0)
98 {
99 /* From (n1 >= d0) /\ (the most significant bit of d0 is set),
100 conclude (the most significant bit of n1 is set) /\ (the
101 leading quotient digit q1 = 1).
102
103 This special case is necessary, not an optimization.
104 (Shifts counts of SI_TYPE_SIZE are undefined.) */
105
106 n1 -= d0;
107 q1 = 1;
108 }
109 else
110 {
111 /* Normalize. */
112
113 b = SI_TYPE_SIZE - bm;
114
115 d0 = d0 << bm;
116 n2 = n1 >> b;
117 n1 = (n1 << bm) | (n0 >> b);
118 n0 = n0 << bm;
119
120 udiv_qrnnd (q1, n1, n2, n1, d0);
121 }
122
123 /* n1 != d0... */
124
125 udiv_qrnnd (q0, n0, n1, n0, d0);
126
127 /* Remainder in n0 >> bm. */
128 }
129
130 if (rp != 0)
131 {
132 rr.s.low = n0 >> bm;
133 rr.s.high = 0;
134 *rp = rr.ll;
135 }
136 }
137 else
138 {
139 if (d1 > n1)
140 {
141 /* 00 = nn / DD */
142
143 q0 = 0;
144 q1 = 0;
145
146 /* Remainder in n1n0. */
147 if (rp != 0)
148 {
149 rr.s.low = n0;
150 rr.s.high = n1;
151 *rp = rr.ll;
152 }
153 }
154 else
155 {
156 /* 0q = NN / dd */
157
158 count_leading_zeros (bm, d1);
159 if (bm == 0)
160 {
161 /* From (n1 >= d1) /\ (the most significant bit of d1 is set),
162 conclude (the most significant bit of n1 is set) /\ (the
163 quotient digit q0 = 0 or 1).
164
165 This special case is necessary, not an optimization. */
166
167 /* The condition on the next line takes advantage of that
168 n1 >= d1 (true due to program flow). */
169 if (n1 > d1 || n0 >= d0)
170 {
171 q0 = 1;
172 sub_ddmmss (n1, n0, n1, n0, d1, d0);
173 }
174 else
175 q0 = 0;
176
177 q1 = 0;
178
179 if (rp != 0)
180 {
181 rr.s.low = n0;
182 rr.s.high = n1;
183 *rp = rr.ll;
184 }
185 }
186 else
187 {
188 USItype m1, m0;
189 /* Normalize. */
190
191 b = SI_TYPE_SIZE - bm;
192
193 d1 = (d1 << bm) | (d0 >> b);
194 d0 = d0 << bm;
195 n2 = n1 >> b;
196 n1 = (n1 << bm) | (n0 >> b);
197 n0 = n0 << bm;
198
199 udiv_qrnnd (q0, n1, n2, n1, d1);
200 umul_ppmm (m1, m0, q0, d0);
201
202 if (m1 > n1 || (m1 == n1 && m0 > n0))
203 {
204 q0--;
205 sub_ddmmss (m1, m0, m1, m0, d1, d0);
206 }
207
208 q1 = 0;
209
210 /* Remainder in (n1n0 - m1m0) >> bm. */
211 if (rp != 0)
212 {
213 sub_ddmmss (n1, n0, n1, n0, m1, m0);
214 rr.s.low = (n1 << b) | (n0 >> bm);
215 rr.s.high = n1 >> bm;
216 *rp = rr.ll;
217 }
218 }
219 }
220 }
221
222 ww.s.low = q0;
223 ww.s.high = q1;
224 return ww.ll;
225}
226
227UDItype
228__udivdi3 (UDItype n, UDItype d)
229{
230 return __udivmoddi4 (n, d, (UDItype *) 0);
231}
232
233UDItype
234__umoddi3 (UDItype u, UDItype v)
235{
236 UDItype w;
237
238 (void) __udivmoddi4 (u ,v, &w);
239
240 return w;
241}
242
diff --git a/arch/arm26/machine/Makefile b/arch/arm26/machine/Makefile
deleted file mode 100644
index 86ea97cc07fc..000000000000
--- a/arch/arm26/machine/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for the linux kernel.
3#
4
5# Object file lists.
6
7obj-y := dma.o irq.o latches.o
8
diff --git a/arch/arm26/machine/dma.c b/arch/arm26/machine/dma.c
deleted file mode 100644
index 4402a5a1b78f..000000000000
--- a/arch/arm26/machine/dma.c
+++ /dev/null
@@ -1,214 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/dma.c
3 *
4 * Copyright (C) 1998-1999 Dave Gilbert / Russell King
5 * Copyright (C) 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * DMA functions specific to Archimedes and A5000 architecture
12 */
13#include <linux/sched.h>
14#include <linux/init.h>
15
16#include <asm/dma.h>
17#include <asm/fiq.h>
18#include <asm/irq.h>
19#include <asm/io.h>
20#include <asm/hardware.h>
21#include <asm/mach-types.h>
22
23#define DPRINTK(x...) printk(KERN_DEBUG x)
24
25#if defined(CONFIG_BLK_DEV_FD1772) || defined(CONFIG_BLK_DEV_FD1772_MODULE)
26
27extern unsigned char fdc1772_dma_read, fdc1772_dma_read_end;
28extern unsigned char fdc1772_dma_write, fdc1772_dma_write_end;
29extern void fdc1772_setupdma(unsigned int count,unsigned int addr);
30
31static void arc_floppy_data_enable_dma(dmach_t channel, dma_t *dma)
32{
33 DPRINTK("arc_floppy_data_enable_dma\n");
34
35 if (dma->using_sg)
36 BUG();
37
38 switch (dma->dma_mode) {
39 case DMA_MODE_READ: { /* read */
40 unsigned long flags;
41 DPRINTK("enable_dma fdc1772 data read\n");
42 local_save_flags_cli(flags);
43 clf();
44
45 memcpy ((void *)0x1c, (void *)&fdc1772_dma_read,
46 &fdc1772_dma_read_end - &fdc1772_dma_read);
47 fdc1772_setupdma(dma->buf.length, dma->buf.__address); /* Sets data pointer up */
48 enable_fiq(FIQ_FLOPPYDATA);
49 local_irq_restore(flags);
50 }
51 break;
52
53 case DMA_MODE_WRITE: { /* write */
54 unsigned long flags;
55 DPRINTK("enable_dma fdc1772 data write\n");
56 local_save_flags_cli(flags);
57 clf();
58 memcpy ((void *)0x1c, (void *)&fdc1772_dma_write,
59 &fdc1772_dma_write_end - &fdc1772_dma_write);
60 fdc1772_setupdma(dma->buf.length, dma->buf.__address); /* Sets data pointer up */
61 enable_fiq(FIQ_FLOPPYDATA);
62
63 local_irq_restore(flags);
64 }
65 break;
66 default:
67 printk ("enable_dma: dma%d not initialised\n", channel);
68 }
69}
70
71static int arc_floppy_data_get_dma_residue(dmach_t channel, dma_t *dma)
72{
73 extern unsigned int fdc1772_bytestogo;
74
75 /* 10/1/1999 DAG - I presume its the number of bytes left? */
76 return fdc1772_bytestogo;
77}
78
79static void arc_floppy_cmdend_enable_dma(dmach_t channel, dma_t *dma)
80{
81 /* Need to build a branch at the FIQ address */
82 extern void fdc1772_comendhandler(void);
83 unsigned long flags;
84
85 DPRINTK("arc_floppy_cmdend_enable_dma\n");
86 /*printk("enable_dma fdc1772 command end FIQ\n");*/
87 save_flags(flags);
88 clf();
89
90 /* B fdc1772_comendhandler */
91 *((unsigned int *)0x1c)=0xea000000 |
92 (((unsigned int)fdc1772_comendhandler-(0x1c+8))/4);
93
94 local_irq_restore(flags);
95}
96
97static int arc_floppy_cmdend_get_dma_residue(dmach_t channel, dma_t *dma)
98{
99 /* 10/1/1999 DAG - Presume whether there is an outstanding command? */
100 extern unsigned int fdc1772_fdc_int_done;
101
102 /* Explicit! If the int done is 0 then 1 int to go */
103 return (fdc1772_fdc_int_done==0)?1:0;
104}
105
106static void arc_disable_dma(dmach_t channel, dma_t *dma)
107{
108 disable_fiq(dma->dma_irq);
109}
110
111static struct dma_ops arc_floppy_data_dma_ops = {
112 .type = "FIQDMA",
113 .enable = arc_floppy_data_enable_dma,
114 .disable = arc_disable_dma,
115 .residue = arc_floppy_data_get_dma_residue,
116};
117
118static struct dma_ops arc_floppy_cmdend_dma_ops = {
119 .type = "FIQCMD",
120 .enable = arc_floppy_cmdend_enable_dma,
121 .disable = arc_disable_dma,
122 .residue = arc_floppy_cmdend_get_dma_residue,
123};
124#endif
125
126#ifdef CONFIG_ARCH_A5K
127static struct fiq_handler fh = {
128 .name = "floppydata"
129};
130
131static int a5k_floppy_get_dma_residue(dmach_t channel, dma_t *dma)
132{
133 struct pt_regs regs;
134 get_fiq_regs(&regs);
135 return regs.ARM_r9;
136}
137
138static void a5k_floppy_enable_dma(dmach_t channel, dma_t *dma)
139{
140 struct pt_regs regs;
141 void *fiqhandler_start;
142 unsigned int fiqhandler_length;
143 extern void floppy_fiqsetup(unsigned long len, unsigned long addr,
144 unsigned long port);
145
146 if (dma->using_sg)
147 BUG();
148
149 if (dma->dma_mode == DMA_MODE_READ) {
150 extern unsigned char floppy_fiqin_start, floppy_fiqin_end;
151 fiqhandler_start = &floppy_fiqin_start;
152 fiqhandler_length = &floppy_fiqin_end - &floppy_fiqin_start;
153 } else {
154 extern unsigned char floppy_fiqout_start, floppy_fiqout_end;
155 fiqhandler_start = &floppy_fiqout_start;
156 fiqhandler_length = &floppy_fiqout_end - &floppy_fiqout_start;
157 }
158 if (claim_fiq(&fh)) {
159 printk("floppydma: couldn't claim FIQ.\n");
160 return;
161 }
162 memcpy((void *)0x1c, fiqhandler_start, fiqhandler_length);
163 regs.ARM_r9 = dma->buf.length;
164 regs.ARM_r10 = (unsigned long)dma->buf.__address;
165 regs.ARM_fp = FLOPPYDMA_BASE;
166 set_fiq_regs(&regs);
167 enable_fiq(dma->dma_irq);
168}
169
170static void a5k_floppy_disable_dma(dmach_t channel, dma_t *dma)
171{
172 disable_fiq(dma->dma_irq);
173 release_fiq(&fh);
174}
175
176static struct dma_ops a5k_floppy_dma_ops = {
177 .type = "FIQDMA",
178 .enable = a5k_floppy_enable_dma,
179 .disable = a5k_floppy_disable_dma,
180 .residue = a5k_floppy_get_dma_residue,
181};
182#endif
183
184/*
185 * This is virtual DMA - we don't need anything here
186 */
187static void sound_enable_disable_dma(dmach_t channel, dma_t *dma)
188{
189}
190
191static struct dma_ops sound_dma_ops = {
192 .type = "VIRTUAL",
193 .enable = sound_enable_disable_dma,
194 .disable = sound_enable_disable_dma,
195};
196
197void __init arch_dma_init(dma_t *dma)
198{
199#if defined(CONFIG_BLK_DEV_FD1772) || defined(CONFIG_BLK_DEV_FD1772_MODULE)
200 if (machine_is_archimedes()) {
201 dma[DMA_VIRTUAL_FLOPPY0].dma_irq = FIQ_FLOPPYDATA;
202 dma[DMA_VIRTUAL_FLOPPY0].d_ops = &arc_floppy_data_dma_ops;
203 dma[DMA_VIRTUAL_FLOPPY1].dma_irq = 1;
204 dma[DMA_VIRTUAL_FLOPPY1].d_ops = &arc_floppy_cmdend_dma_ops;
205 }
206#endif
207#ifdef CONFIG_ARCH_A5K
208 if (machine_is_a5k()) {
209 dma[DMA_VIRTUAL_FLOPPY0].dma_irq = FIQ_FLOPPYDATA;
210 dma[DMA_VIRTUAL_FLOPPY0].d_ops = &a5k_floppy_dma_ops;
211 }
212#endif
213 dma[DMA_VIRTUAL_SOUND].d_ops = &sound_dma_ops;
214}
diff --git a/arch/arm26/machine/irq.c b/arch/arm26/machine/irq.c
deleted file mode 100644
index a60d543edecc..000000000000
--- a/arch/arm26/machine/irq.c
+++ /dev/null
@@ -1,164 +0,0 @@
1/*
2 * linux/arch/arm26/mach-arc/irq.c
3 *
4 * Copyright (C) 1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Changelog:
11 * 24-09-1996 RMK Created
12 * 10-10-1996 RMK Brought up to date with arch-sa110eval
13 * 22-10-1996 RMK Changed interrupt numbers & uses new inb/outb macros
14 * 11-01-1998 RMK Added mask_and_ack_irq
15 * 22-08-1998 RMK Restructured IRQ routines
16 * 08-09-2002 IM Brought up to date for 2.5
17 * 01-06-2003 JMA Removed arc_fiq_chip
18 */
19#include <linux/init.h>
20
21#include <asm/irq.h>
22#include <asm/irqchip.h>
23#include <asm/ioc.h>
24#include <asm/io.h>
25#include <asm/system.h>
26
27extern void init_FIQ(void);
28
29#define a_clf() clf()
30#define a_stf() stf()
31
32static void arc_ack_irq_a(unsigned int irq)
33{
34 unsigned int val, mask;
35
36 mask = 1 << irq;
37 a_clf();
38 val = ioc_readb(IOC_IRQMASKA);
39 ioc_writeb(val & ~mask, IOC_IRQMASKA);
40 ioc_writeb(mask, IOC_IRQCLRA);
41 a_stf();
42}
43
44static void arc_mask_irq_a(unsigned int irq)
45{
46 unsigned int val, mask;
47
48 mask = 1 << irq;
49 a_clf();
50 val = ioc_readb(IOC_IRQMASKA);
51 ioc_writeb(val & ~mask, IOC_IRQMASKA);
52 a_stf();
53}
54
55static void arc_unmask_irq_a(unsigned int irq)
56{
57 unsigned int val, mask;
58
59 mask = 1 << irq;
60 a_clf();
61 val = ioc_readb(IOC_IRQMASKA);
62 ioc_writeb(val | mask, IOC_IRQMASKA);
63 a_stf();
64}
65
66static struct irqchip arc_a_chip = {
67 .ack = arc_ack_irq_a,
68 .mask = arc_mask_irq_a,
69 .unmask = arc_unmask_irq_a,
70};
71
72static void arc_mask_irq_b(unsigned int irq)
73{
74 unsigned int val, mask;
75 mask = 1 << (irq & 7);
76 val = ioc_readb(IOC_IRQMASKB);
77 ioc_writeb(val & ~mask, IOC_IRQMASKB);
78}
79
80static void arc_unmask_irq_b(unsigned int irq)
81{
82 unsigned int val, mask;
83
84 mask = 1 << (irq & 7);
85 val = ioc_readb(IOC_IRQMASKB);
86 ioc_writeb(val | mask, IOC_IRQMASKB);
87}
88
89static struct irqchip arc_b_chip = {
90 .ack = arc_mask_irq_b,
91 .mask = arc_mask_irq_b,
92 .unmask = arc_unmask_irq_b,
93};
94
95/* FIXME - JMA none of these functions are used in arm26 currently
96static void arc_mask_irq_fiq(unsigned int irq)
97{
98 unsigned int val, mask;
99
100 mask = 1 << (irq & 7);
101 val = ioc_readb(IOC_FIQMASK);
102 ioc_writeb(val & ~mask, IOC_FIQMASK);
103}
104
105static void arc_unmask_irq_fiq(unsigned int irq)
106{
107 unsigned int val, mask;
108
109 mask = 1 << (irq & 7);
110 val = ioc_readb(IOC_FIQMASK);
111 ioc_writeb(val | mask, IOC_FIQMASK);
112}
113
114static struct irqchip arc_fiq_chip = {
115 .ack = arc_mask_irq_fiq,
116 .mask = arc_mask_irq_fiq,
117 .unmask = arc_unmask_irq_fiq,
118};
119*/
120
121void __init arc_init_irq(void)
122{
123 unsigned int irq, flags;
124
125 /* Disable all IOC interrupt sources */
126 ioc_writeb(0, IOC_IRQMASKA);
127 ioc_writeb(0, IOC_IRQMASKB);
128 ioc_writeb(0, IOC_FIQMASK);
129
130 for (irq = 0; irq < NR_IRQS; irq++) {
131 flags = IRQF_VALID;
132
133 if (irq <= 6 || (irq >= 9 && irq <= 15))
134 flags |= IRQF_PROBE;
135
136 if (irq == IRQ_KEYBOARDTX)
137 flags |= IRQF_NOAUTOEN;
138
139 switch (irq) {
140 case 0 ... 7:
141 set_irq_chip(irq, &arc_a_chip);
142 set_irq_handler(irq, do_level_IRQ);
143 set_irq_flags(irq, flags);
144 break;
145
146 case 8 ... 15:
147 set_irq_chip(irq, &arc_b_chip);
148 set_irq_handler(irq, do_level_IRQ);
149 set_irq_flags(irq, flags);
150
151/* case 64 ... 72:
152 set_irq_chip(irq, &arc_fiq_chip);
153 set_irq_flags(irq, flags);
154 break;
155*/
156
157 }
158 }
159
160 irq_desc[IRQ_KEYBOARDTX].noautoenable = 1;
161
162 init_FIQ();
163}
164
diff --git a/arch/arm26/machine/latches.c b/arch/arm26/machine/latches.c
deleted file mode 100644
index 94f05d2a3b2b..000000000000
--- a/arch/arm26/machine/latches.c
+++ /dev/null
@@ -1,72 +0,0 @@
1/*
2 * linux/arch/arm26/kernel/latches.c
3 *
4 * Copyright (C) David Alan Gilbert 1995/1996,2000
5 * Copyright (C) Ian Molton 2003
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Support for the latches on the old Archimedes which control the floppy,
12 * hard disc and printer
13 */
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/sched.h>
18
19#include <asm/io.h>
20#include <asm/hardware.h>
21#include <asm/mach-types.h>
22#include <asm/oldlatches.h>
23
24static unsigned char latch_a_copy;
25static unsigned char latch_b_copy;
26
27/* newval=(oldval & ~mask)|newdata */
28void oldlatch_aupdate(unsigned char mask,unsigned char newdata)
29{
30 unsigned long flags;
31
32 BUG_ON(!machine_is_archimedes());
33
34 local_irq_save(flags); //FIXME: was local_save_flags
35 latch_a_copy = (latch_a_copy & ~mask) | newdata;
36 __raw_writeb(latch_a_copy, LATCHA_BASE);
37 local_irq_restore(flags);
38
39 printk("Latch: A = 0x%02x\n", latch_a_copy);
40}
41
42
43/* newval=(oldval & ~mask)|newdata */
44void oldlatch_bupdate(unsigned char mask,unsigned char newdata)
45{
46 unsigned long flags;
47
48 BUG_ON(!machine_is_archimedes());
49
50
51 local_irq_save(flags);//FIXME: was local_save_flags
52 latch_b_copy = (latch_b_copy & ~mask) | newdata;
53 __raw_writeb(latch_b_copy, LATCHB_BASE);
54 local_irq_restore(flags);
55
56 printk("Latch: B = 0x%02x\n", latch_b_copy);
57}
58
59static int __init oldlatch_init(void)
60{
61 if (machine_is_archimedes()) {
62 oldlatch_aupdate(0xff, 0xff);
63 /* Thats no FDC reset...*/
64 oldlatch_bupdate(0xff, LATCHB_FDCRESET);
65 }
66 return 0;
67}
68
69arch_initcall(oldlatch_init);
70
71EXPORT_SYMBOL(oldlatch_aupdate);
72EXPORT_SYMBOL(oldlatch_bupdate);
diff --git a/arch/arm26/mm/Makefile b/arch/arm26/mm/Makefile
deleted file mode 100644
index a8fb166d5c6d..000000000000
--- a/arch/arm26/mm/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
1#
2# Makefile for the linux arm26-specific parts of the memory manager.
3#
4
5obj-y := init.o extable.o proc-funcs.o memc.o fault.o \
6 small_page.o
diff --git a/arch/arm26/mm/extable.c b/arch/arm26/mm/extable.c
deleted file mode 100644
index 38e1958d9538..000000000000
--- a/arch/arm26/mm/extable.c
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * linux/arch/arm26/mm/extable.c
3 */
4
5#include <linux/module.h>
6#include <asm/uaccess.h>
7
8int fixup_exception(struct pt_regs *regs)
9{
10 const struct exception_table_entry *fixup;
11
12 fixup = search_exception_tables(instruction_pointer(regs));
13
14 /*
15 * The kernel runs in SVC mode - make sure we keep running in SVC mode
16 * by frobbing the PSR appropriately (PSR and PC are in the same reg.
17 * on ARM26)
18 */
19 if (fixup)
20 regs->ARM_pc = fixup->fixup | PSR_I_BIT | MODE_SVC26;
21
22 return fixup != NULL;
23}
24
diff --git a/arch/arm26/mm/fault.c b/arch/arm26/mm/fault.c
deleted file mode 100644
index dec638a0c8d9..000000000000
--- a/arch/arm26/mm/fault.c
+++ /dev/null
@@ -1,312 +0,0 @@
1/*
2 * linux/arch/arm26/mm/fault.c
3 *
4 * Copyright (C) 1995 Linus Torvalds
5 * Modifications for ARM processor (c) 1995-2001 Russell King
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/signal.h>
12#include <linux/sched.h>
13#include <linux/kernel.h>
14#include <linux/errno.h>
15#include <linux/string.h>
16#include <linux/types.h>
17#include <linux/ptrace.h>
18#include <linux/mman.h>
19#include <linux/mm.h>
20#include <linux/interrupt.h>
21#include <linux/proc_fs.h>
22#include <linux/init.h>
23
24#include <asm/system.h>
25#include <asm/pgtable.h>
26#include <asm/uaccess.h> //FIXME this header may be bogusly included
27
28#include "fault.h"
29
30#define FAULT_CODE_LDRSTRPOST 0x80
31#define FAULT_CODE_LDRSTRPRE 0x40
32#define FAULT_CODE_LDRSTRREG 0x20
33#define FAULT_CODE_LDMSTM 0x10
34#define FAULT_CODE_LDCSTC 0x08
35#define FAULT_CODE_PREFETCH 0x04
36#define FAULT_CODE_WRITE 0x02
37#define FAULT_CODE_FORCECOW 0x01
38
39#define DO_COW(m) ((m) & (FAULT_CODE_WRITE|FAULT_CODE_FORCECOW))
40#define READ_FAULT(m) (!((m) & FAULT_CODE_WRITE))
41#define DEBUG
42/*
43 * This is useful to dump out the page tables associated with
44 * 'addr' in mm 'mm'.
45 */
46void show_pte(struct mm_struct *mm, unsigned long addr)
47{
48 pgd_t *pgd;
49
50 if (!mm)
51 mm = &init_mm;
52
53 printk(KERN_ALERT "pgd = %p\n", mm->pgd);
54 pgd = pgd_offset(mm, addr);
55 printk(KERN_ALERT "[%08lx] *pgd=%08lx", addr, pgd_val(*pgd));
56
57 do {
58 pmd_t *pmd;
59 pte_t *pte;
60
61 pmd = pmd_offset(pgd, addr);
62
63 if (pmd_none(*pmd))
64 break;
65
66 if (pmd_bad(*pmd)) {
67 printk("(bad)");
68 break;
69 }
70
71 /* We must not map this if we have highmem enabled */
72 /* FIXME */
73 pte = pte_offset_map(pmd, addr);
74 printk(", *pte=%08lx", pte_val(*pte));
75 pte_unmap(pte);
76 } while(0);
77
78 printk("\n");
79}
80
81/*
82 * Oops. The kernel tried to access some page that wasn't present.
83 */
84static void
85__do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
86 struct pt_regs *regs)
87{
88 /*
89 * Are we prepared to handle this kernel fault?
90 */
91 if (fixup_exception(regs))
92 return;
93
94 /*
95 * No handler, we'll have to terminate things with extreme prejudice.
96 */
97 bust_spinlocks(1);
98 printk(KERN_ALERT
99 "Unable to handle kernel %s at virtual address %08lx\n",
100 (addr < PAGE_SIZE) ? "NULL pointer dereference" :
101 "paging request", addr);
102
103 show_pte(mm, addr);
104 die("Oops", regs, fsr);
105 bust_spinlocks(0);
106 do_exit(SIGKILL);
107}
108
109/*
110 * Something tried to access memory that isn't in our memory map..
111 * User mode accesses just cause a SIGSEGV
112 */
113static void
114__do_user_fault(struct task_struct *tsk, unsigned long addr,
115 unsigned int fsr, int code, struct pt_regs *regs)
116{
117 struct siginfo si;
118
119#ifdef CONFIG_DEBUG_USER
120 printk("%s: unhandled page fault at 0x%08lx, code 0x%03x\n",
121 tsk->comm, addr, fsr);
122 show_pte(tsk->mm, addr);
123 show_regs(regs);
124 //dump_backtrace(regs, tsk); // FIXME ARM32 dropped this - why?
125 while(1); //FIXME - hack to stop debug going nutso
126#endif
127
128 tsk->thread.address = addr;
129 tsk->thread.error_code = fsr;
130 tsk->thread.trap_no = 14;
131 si.si_signo = SIGSEGV;
132 si.si_errno = 0;
133 si.si_code = code;
134 si.si_addr = (void *)addr;
135 force_sig_info(SIGSEGV, &si, tsk);
136}
137
138static int
139__do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
140 struct task_struct *tsk)
141{
142 struct vm_area_struct *vma;
143 int fault, mask;
144
145 vma = find_vma(mm, addr);
146 fault = -2; /* bad map area */
147 if (!vma)
148 goto out;
149 if (vma->vm_start > addr)
150 goto check_stack;
151
152 /*
153 * Ok, we have a good vm_area for this
154 * memory access, so we can handle it.
155 */
156good_area:
157 if (READ_FAULT(fsr)) /* read? */
158 mask = VM_READ|VM_EXEC|VM_WRITE;
159 else
160 mask = VM_WRITE;
161
162 fault = -1; /* bad access type */
163 if (!(vma->vm_flags & mask))
164 goto out;
165
166 /*
167 * If for any reason at all we couldn't handle
168 * the fault, make sure we exit gracefully rather
169 * than endlessly redo the fault.
170 */
171survive:
172 fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, DO_COW(fsr));
173 if (unlikely(fault & VM_FAULT_ERROR)) {
174 if (fault & VM_FAULT_OOM)
175 goto out_of_memory;
176 else if (fault & VM_FAULT_SIGBUS)
177 return fault;
178 BUG();
179 }
180 if (fault & VM_FAULT_MAJOR)
181 tsk->maj_flt++;
182 else
183 tsk->min_flt++;
184 return fault;
185
186out_of_memory:
187 fault = -3; /* out of memory */
188 if (!is_init(tsk))
189 goto out;
190
191 /*
192 * If we are out of memory for pid1,
193 * sleep for a while and retry
194 */
195 yield();
196 goto survive;
197
198check_stack:
199 if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
200 goto good_area;
201out:
202 return fault;
203}
204
205int do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
206{
207 struct task_struct *tsk;
208 struct mm_struct *mm;
209 int fault;
210
211 tsk = current;
212 mm = tsk->mm;
213
214 /*
215 * If we're in an interrupt or have no user
216 * context, we must not take the fault..
217 */
218 if (in_atomic() || !mm)
219 goto no_context;
220
221 down_read(&mm->mmap_sem);
222 fault = __do_page_fault(mm, addr, fsr, tsk);
223 up_read(&mm->mmap_sem);
224
225 /*
226 * Handle the "normal" case first
227 */
228 if (likely(!(fault & VM_FAULT_ERROR)))
229 return 0;
230 if (fault & VM_FAULT_SIGBUS)
231 goto do_sigbus;
232 /* else VM_FAULT_OOM */
233
234 /*
235 * If we are in kernel mode at this point, we
236 * have no context to handle this fault with.
237 * FIXME - is this test right?
238 */
239 if (!user_mode(regs)){
240 goto no_context;
241 }
242
243 if (fault == -3) {
244 /*
245 * We ran out of memory, or some other thing happened to
246 * us that made us unable to handle the page fault gracefully.
247 */
248 printk("VM: killing process %s\n", tsk->comm);
249 do_exit(SIGKILL);
250 }
251 else{
252 __do_user_fault(tsk, addr, fsr, fault == -1 ? SEGV_ACCERR : SEGV_MAPERR, regs);
253 }
254
255 return 0;
256
257
258/*
259 * We ran out of memory, or some other thing happened to us that made
260 * us unable to handle the page fault gracefully.
261 */
262do_sigbus:
263 /*
264 * Send a sigbus, regardless of whether we were in kernel
265 * or user mode.
266 */
267 tsk->thread.address = addr; //FIXME - need other bits setting?
268 tsk->thread.error_code = fsr;
269 tsk->thread.trap_no = 14;
270 force_sig(SIGBUS, tsk);
271#ifdef CONFIG_DEBUG_USER
272 printk(KERN_DEBUG "%s: sigbus at 0x%08lx, pc=0x%08lx\n",
273 current->comm, addr, instruction_pointer(regs));
274#endif
275
276 /* Kernel mode? Handle exceptions or die */
277 if (user_mode(regs))
278 return 0;
279
280no_context:
281 __do_kernel_fault(mm, addr, fsr, regs);
282 return 0;
283}
284
285/*
286 * Handle a data abort. Note that we have to handle a range of addresses
287 * on ARM2/3 for ldm. If both pages are zero-mapped, then we have to force
288 * a copy-on-write. However, on the second page, we always force COW.
289 */
290asmlinkage void
291do_DataAbort(unsigned long min_addr, unsigned long max_addr, int mode, struct pt_regs *regs)
292{
293 do_page_fault(min_addr, mode, regs);
294
295 if ((min_addr ^ max_addr) >> PAGE_SHIFT){
296 do_page_fault(max_addr, mode | FAULT_CODE_FORCECOW, regs);
297 }
298}
299
300asmlinkage int
301do_PrefetchAbort(unsigned long addr, struct pt_regs *regs)
302{
303#if 0
304 if (the memc mapping for this page exists) {
305 printk ("Page in, but got abort (undefined instruction?)\n");
306 return 0;
307 }
308#endif
309 do_page_fault(addr, FAULT_CODE_PREFETCH, regs);
310 return 1;
311}
312
diff --git a/arch/arm26/mm/fault.h b/arch/arm26/mm/fault.h
deleted file mode 100644
index 4442d00d86ac..000000000000
--- a/arch/arm26/mm/fault.h
+++ /dev/null
@@ -1,5 +0,0 @@
1void show_pte(struct mm_struct *mm, unsigned long addr);
2
3int do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4
5unsigned long search_extable(unsigned long addr); //FIXME - is it right?
diff --git a/arch/arm26/mm/init.c b/arch/arm26/mm/init.c
deleted file mode 100644
index 36e7ee3f8321..000000000000
--- a/arch/arm26/mm/init.c
+++ /dev/null
@@ -1,403 +0,0 @@
1/*
2 * linux/arch/arm26/mm/init.c
3 *
4 * Copyright (C) 1995-2002 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/signal.h>
11#include <linux/sched.h>
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/string.h>
15#include <linux/types.h>
16#include <linux/ptrace.h>
17#include <linux/mman.h>
18#include <linux/mm.h>
19#include <linux/swap.h>
20#include <linux/smp.h>
21#include <linux/init.h>
22#include <linux/initrd.h>
23#include <linux/bootmem.h>
24#include <linux/blkdev.h>
25#include <linux/pfn.h>
26
27#include <asm/segment.h>
28#include <asm/mach-types.h>
29#include <asm/dma.h>
30#include <asm/hardware.h>
31#include <asm/setup.h>
32#include <asm/tlb.h>
33
34#include <asm/map.h>
35
36struct mmu_gather mmu_gathers[NR_CPUS];
37
38extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
39extern char _stext, _text, _etext, _end, __init_begin, __init_end;
40#ifdef CONFIG_XIP_KERNEL
41extern char _endtext, _sdata;
42#endif
43extern unsigned long phys_initrd_start;
44extern unsigned long phys_initrd_size;
45
46/*
47 * The sole use of this is to pass memory configuration
48 * data from paging_init to mem_init.
49 */
50static struct meminfo meminfo __initdata = { 0, };
51
52/*
53 * empty_zero_page is a special page that is used for
54 * zero-initialized data and COW.
55 */
56struct page *empty_zero_page;
57
58void show_mem(void)
59{
60 int free = 0, total = 0, reserved = 0;
61 int shared = 0, cached = 0, slab = 0;
62 struct page *page, *end;
63
64 printk("Mem-info:\n");
65 show_free_areas();
66 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
67
68
69 page = NODE_MEM_MAP(0);
70 end = page + NODE_DATA(0)->node_spanned_pages;
71
72 do {
73 total++;
74 if (PageReserved(page))
75 reserved++;
76 else if (PageSwapCache(page))
77 cached++;
78 else if (PageSlab(page))
79 slab++;
80 else if (!page_count(page))
81 free++;
82 else
83 shared += page_count(page) - 1;
84 page++;
85 } while (page < end);
86
87 printk("%d pages of RAM\n", total);
88 printk("%d free pages\n", free);
89 printk("%d reserved pages\n", reserved);
90 printk("%d slab pages\n", slab);
91 printk("%d pages shared\n", shared);
92 printk("%d pages swap cached\n", cached);
93}
94
95struct node_info {
96 unsigned int start;
97 unsigned int end;
98 int bootmap_pages;
99};
100
101/*
102 * FIXME: We really want to avoid allocating the bootmap bitmap
103 * over the top of the initrd. Hopefully, this is located towards
104 * the start of a bank, so if we allocate the bootmap bitmap at
105 * the end, we won't clash.
106 */
107static unsigned int __init
108find_bootmap_pfn(struct meminfo *mi, unsigned int bootmap_pages)
109{
110 unsigned int start_pfn, bootmap_pfn;
111 unsigned int start, end;
112
113 start_pfn = PFN_UP((unsigned long)&_end);
114 bootmap_pfn = 0;
115
116 /* ARM26 machines only have one node */
117 if (mi->bank->node != 0)
118 BUG();
119
120 start = PFN_UP(mi->bank->start);
121 end = PFN_DOWN(mi->bank->size + mi->bank->start);
122
123 if (start < start_pfn)
124 start = start_pfn;
125
126 if (end <= start)
127 BUG();
128
129 if (end - start >= bootmap_pages)
130 bootmap_pfn = start;
131 else
132 BUG();
133
134 return bootmap_pfn;
135}
136
137/*
138 * Scan the memory info structure and pull out:
139 * - the end of memory
140 * - the number of nodes
141 * - the pfn range of each node
142 * - the number of bootmem bitmap pages
143 */
144static void __init
145find_memend_and_nodes(struct meminfo *mi, struct node_info *np)
146{
147 unsigned int memend_pfn = 0;
148
149 nodes_clear(node_online_map);
150 node_set_online(0);
151
152 np->bootmap_pages = 0;
153
154 if (mi->bank->size == 0) {
155 BUG();
156 }
157
158 /*
159 * Get the start and end pfns for this bank
160 */
161 np->start = PFN_UP(mi->bank->start);
162 np->end = PFN_DOWN(mi->bank->start + mi->bank->size);
163
164 if (memend_pfn < np->end)
165 memend_pfn = np->end;
166
167 /*
168 * Calculate the number of pages we require to
169 * store the bootmem bitmaps.
170 */
171 np->bootmap_pages = bootmem_bootmap_pages(np->end - np->start);
172
173 /*
174 * This doesn't seem to be used by the Linux memory
175 * manager any more. If we can get rid of it, we
176 * also get rid of some of the stuff above as well.
177 */
178 max_low_pfn = memend_pfn - PFN_DOWN(PHYS_OFFSET);
179 max_pfn = memend_pfn - PFN_DOWN(PHYS_OFFSET);
180 mi->end = memend_pfn << PAGE_SHIFT;
181
182}
183
184/*
185 * Initialise the bootmem allocator for all nodes. This is called
186 * early during the architecture specific initialisation.
187 */
188void __init bootmem_init(struct meminfo *mi)
189{
190 struct node_info node_info;
191 unsigned int bootmap_pfn;
192 pg_data_t *pgdat = NODE_DATA(0);
193
194 find_memend_and_nodes(mi, &node_info);
195
196 bootmap_pfn = find_bootmap_pfn(mi, node_info.bootmap_pages);
197
198 /*
199 * Note that node 0 must always have some pages.
200 */
201 if (node_info.end == 0)
202 BUG();
203
204 /*
205 * Initialise the bootmem allocator.
206 */
207 init_bootmem_node(pgdat, bootmap_pfn, node_info.start, node_info.end);
208
209 /*
210 * Register all available RAM in this node with the bootmem allocator.
211 */
212 free_bootmem_node(pgdat, mi->bank->start, mi->bank->size);
213
214 /*
215 * Register the kernel text and data with bootmem.
216 * Note: with XIP we dont register .text since
217 * its in ROM.
218 */
219#ifdef CONFIG_XIP_KERNEL
220 reserve_bootmem_node(pgdat, __pa(&_sdata), &_end - &_sdata);
221#else
222 reserve_bootmem_node(pgdat, __pa(&_stext), &_end - &_stext);
223#endif
224
225 /*
226 * And don't forget to reserve the allocator bitmap,
227 * which will be freed later.
228 */
229 reserve_bootmem_node(pgdat, bootmap_pfn << PAGE_SHIFT,
230 node_info.bootmap_pages << PAGE_SHIFT);
231
232 /*
233 * These should likewise go elsewhere. They pre-reserve
234 * the screen memory region at the start of main system
235 * memory. FIXME - screen RAM is not 512K!
236 */
237 reserve_bootmem_node(pgdat, 0x02000000, 0x00080000);
238
239#ifdef CONFIG_BLK_DEV_INITRD
240 initrd_start = phys_initrd_start;
241 initrd_end = initrd_start + phys_initrd_size;
242
243 /* Achimedes machines only have one node, so initrd is in node 0 */
244#ifdef CONFIG_XIP_KERNEL
245 /* Only reserve initrd space if it is in RAM */
246 if(initrd_start && initrd_start < 0x03000000){
247#else
248 if(initrd_start){
249#endif
250 reserve_bootmem_node(pgdat, __pa(initrd_start),
251 initrd_end - initrd_start);
252 }
253#endif /* CONFIG_BLK_DEV_INITRD */
254
255
256}
257
258/*
259 * paging_init() sets up the page tables, initialises the zone memory
260 * maps, and sets up the zero page, bad page and bad page tables.
261 */
262void __init paging_init(struct meminfo *mi)
263{
264 void *zero_page;
265 unsigned long zone_size[MAX_NR_ZONES];
266 unsigned long zhole_size[MAX_NR_ZONES];
267 struct bootmem_data *bdata;
268 pg_data_t *pgdat;
269 int i;
270
271 memcpy(&meminfo, mi, sizeof(meminfo));
272
273 /*
274 * allocate the zero page. Note that we count on this going ok.
275 */
276 zero_page = alloc_bootmem_low_pages(PAGE_SIZE);
277
278 /*
279 * initialise the page tables.
280 */
281 memtable_init(mi);
282 flush_tlb_all();
283
284 /*
285 * initialise the zones in node 0 (archimedes have only 1 node)
286 */
287
288 for (i = 0; i < MAX_NR_ZONES; i++) {
289 zone_size[i] = 0;
290 zhole_size[i] = 0;
291 }
292
293 pgdat = NODE_DATA(0);
294 bdata = pgdat->bdata;
295 zone_size[0] = bdata->node_low_pfn -
296 (bdata->node_boot_start >> PAGE_SHIFT);
297 if (!zone_size[0])
298 BUG();
299 pgdat->node_mem_map = NULL;
300 free_area_init_node(0, pgdat, zone_size,
301 bdata->node_boot_start >> PAGE_SHIFT, zhole_size);
302
303 /*
304 * finish off the bad pages once
305 * the mem_map is initialised
306 */
307 memzero(zero_page, PAGE_SIZE);
308 empty_zero_page = virt_to_page(zero_page);
309}
310
311static inline void free_area(unsigned long addr, unsigned long end, char *s)
312{
313 unsigned int size = (end - addr) >> 10;
314
315 for (; addr < end; addr += PAGE_SIZE) {
316 struct page *page = virt_to_page(addr);
317 ClearPageReserved(page);
318 init_page_count(page);
319 free_page(addr);
320 totalram_pages++;
321 }
322
323 if (size && s)
324 printk(KERN_INFO "Freeing %s memory: %dK\n", s, size);
325}
326
327/*
328 * mem_init() marks the free areas in the mem_map and tells us how much
329 * memory is free. This is done after various parts of the system have
330 * claimed their memory after the kernel image.
331 */
332void __init mem_init(void)
333{
334 unsigned int codepages, datapages, initpages;
335 pg_data_t *pgdat = NODE_DATA(0);
336 extern int sysctl_overcommit_memory;
337
338
339 /* Note: data pages includes BSS */
340#ifdef CONFIG_XIP_KERNEL
341 codepages = &_endtext - &_text;
342 datapages = &_end - &_sdata;
343#else
344 codepages = &_etext - &_text;
345 datapages = &_end - &_etext;
346#endif
347 initpages = &__init_end - &__init_begin;
348
349 high_memory = (void *)__va(meminfo.end);
350 max_mapnr = virt_to_page(high_memory) - mem_map;
351
352 /* this will put all unused low memory onto the freelists */
353 if (pgdat->node_spanned_pages != 0)
354 totalram_pages += free_all_bootmem_node(pgdat);
355
356 num_physpages = meminfo.bank[0].size >> PAGE_SHIFT;
357
358 printk(KERN_INFO "Memory: %luMB total\n", num_physpages >> (20 - PAGE_SHIFT));
359 printk(KERN_NOTICE "Memory: %luKB available (%dK code, "
360 "%dK data, %dK init)\n",
361 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
362 codepages >> 10, datapages >> 10, initpages >> 10);
363
364 /*
365 * Turn on overcommit on tiny machines
366 */
367 if (PAGE_SIZE >= 16384 && num_physpages <= 128) {
368 sysctl_overcommit_memory = OVERCOMMIT_ALWAYS;
369 printk("Turning on overcommit\n");
370 }
371}
372
373void free_initmem(void){
374#ifndef CONFIG_XIP_KERNEL
375 free_area((unsigned long)(&__init_begin),
376 (unsigned long)(&__init_end),
377 "init");
378#endif
379}
380
381#ifdef CONFIG_BLK_DEV_INITRD
382
383static int keep_initrd;
384
385void free_initrd_mem(unsigned long start, unsigned long end)
386{
387#ifdef CONFIG_XIP_KERNEL
388 /* Only bin initrd if it is in RAM... */
389 if(!keep_initrd && start < 0x03000000)
390#else
391 if (!keep_initrd)
392#endif
393 free_area(start, end, "initrd");
394}
395
396static int __init keepinitrd_setup(char *__unused)
397{
398 keep_initrd = 1;
399 return 1;
400}
401
402__setup("keepinitrd", keepinitrd_setup);
403#endif
diff --git a/arch/arm26/mm/memc.c b/arch/arm26/mm/memc.c
deleted file mode 100644
index ffecd8578247..000000000000
--- a/arch/arm26/mm/memc.c
+++ /dev/null
@@ -1,184 +0,0 @@
1/*
2 * linux/arch/arm26/mm/memc.c
3 *
4 * Copyright (C) 1998-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Page table sludge for older ARM processor architectures.
11 */
12#include <linux/sched.h>
13#include <linux/mm.h>
14#include <linux/init.h>
15#include <linux/bootmem.h>
16
17#include <asm/pgtable.h>
18#include <asm/pgalloc.h>
19#include <asm/page.h>
20#include <asm/memory.h>
21#include <asm/hardware.h>
22
23#include <asm/map.h>
24
25#define MEMC_TABLE_SIZE (256*sizeof(unsigned long))
26
27struct kmem_cache *pte_cache, *pgd_cache;
28int page_nr;
29
30/*
31 * Allocate space for a page table and a MEMC table.
32 * Note that we place the MEMC
33 * table before the page directory. This means we can
34 * easily get to both tightly-associated data structures
35 * with a single pointer.
36 */
37static inline pgd_t *alloc_pgd_table(void)
38{
39 void *pg2k = kmem_cache_alloc(pgd_cache, GFP_KERNEL);
40
41 if (pg2k)
42 pg2k += MEMC_TABLE_SIZE;
43
44 return (pgd_t *)pg2k;
45}
46
47/*
48 * Free a page table. this function is the counterpart to get_pgd_slow
49 * below, not alloc_pgd_table above.
50 */
51void free_pgd_slow(pgd_t *pgd)
52{
53 unsigned long tbl = (unsigned long)pgd;
54
55 tbl -= MEMC_TABLE_SIZE;
56
57 kmem_cache_free(pgd_cache, (void *)tbl);
58}
59
60/*
61 * Allocate a new pgd and fill it in ready for use
62 *
63 * A new tasks pgd is completely empty (all pages !present) except for:
64 *
65 * o The machine vectors at virtual address 0x0
66 * o The vmalloc region at the top of address space
67 *
68 */
69#define FIRST_KERNEL_PGD_NR (FIRST_USER_PGD_NR + USER_PTRS_PER_PGD)
70
71pgd_t *get_pgd_slow(struct mm_struct *mm)
72{
73 pgd_t *new_pgd, *init_pgd;
74 pmd_t *new_pmd, *init_pmd;
75 pte_t *new_pte, *init_pte;
76
77 new_pgd = alloc_pgd_table();
78 if (!new_pgd)
79 goto no_pgd;
80
81 /*
82 * On ARM, first page must always be allocated since it contains
83 * the machine vectors.
84 */
85 new_pmd = pmd_alloc(mm, new_pgd, 0);
86 if (!new_pmd)
87 goto no_pmd;
88
89 new_pte = pte_alloc_map(mm, new_pmd, 0);
90 if (!new_pte)
91 goto no_pte;
92
93 init_pgd = pgd_offset(&init_mm, 0);
94 init_pmd = pmd_offset(init_pgd, 0);
95 init_pte = pte_offset(init_pmd, 0);
96
97 set_pte(new_pte, *init_pte);
98 pte_unmap(new_pte);
99
100 /*
101 * the page table entries are zeroed
102 * when the table is created. (see the cache_ctor functions below)
103 * Now we need to plonk the kernel (vmalloc) area at the end of
104 * the address space. We copy this from the init thread, just like
105 * the init_pte we copied above...
106 */
107 memcpy(new_pgd + FIRST_KERNEL_PGD_NR, init_pgd + FIRST_KERNEL_PGD_NR,
108 (PTRS_PER_PGD - FIRST_KERNEL_PGD_NR) * sizeof(pgd_t));
109
110 /* update MEMC tables */
111 cpu_memc_update_all(new_pgd);
112 return new_pgd;
113
114no_pte:
115 pmd_free(new_pmd);
116no_pmd:
117 free_pgd_slow(new_pgd);
118no_pgd:
119 return NULL;
120}
121
122/*
123 * No special code is required here.
124 */
125void setup_mm_for_reboot(char mode)
126{
127}
128
129/*
130 * This contains the code to setup the memory map on an ARM2/ARM250/ARM3
131 * o swapper_pg_dir = 0x0207d000
132 * o kernel proper starts at 0x0208000
133 * o create (allocate) a pte to contain the machine vectors
134 * o populate the pte (points to 0x02078000) (FIXME - is it zeroed?)
135 * o populate the init tasks page directory (pgd) with the new pte
136 * o zero the rest of the init tasks pgdir (FIXME - what about vmalloc?!)
137 */
138void __init memtable_init(struct meminfo *mi)
139{
140 pte_t *pte;
141 int i;
142
143 page_nr = max_low_pfn;
144
145 pte = alloc_bootmem_low_pages(PTRS_PER_PTE * sizeof(pte_t));
146 pte[0] = mk_pte_phys(PAGE_OFFSET + SCREEN_SIZE, PAGE_READONLY);
147 pmd_populate(&init_mm, pmd_offset(swapper_pg_dir, 0), pte);
148
149 for (i = 1; i < PTRS_PER_PGD; i++)
150 pgd_val(swapper_pg_dir[i]) = 0;
151}
152
153void __init iotable_init(struct map_desc *io_desc)
154{
155 /* nothing to do */
156}
157
158/*
159 * We never have holes in the memmap
160 */
161void __init create_memmap_holes(struct meminfo *mi)
162{
163}
164
165static void pte_cache_ctor(void *pte, struct kmem_cache *cache, unsigned long flags)
166{
167 memzero(pte, sizeof(pte_t) * PTRS_PER_PTE);
168}
169
170static void pgd_cache_ctor(void *pgd, struct kmem_cache *cache, unsigned long flags)
171{
172 memzero(pgd + MEMC_TABLE_SIZE, USER_PTRS_PER_PGD * sizeof(pgd_t));
173}
174
175void __init pgtable_cache_init(void)
176{
177 pte_cache = kmem_cache_create("pte-cache",
178 sizeof(pte_t) * PTRS_PER_PTE,
179 0, SLAB_PANIC, pte_cache_ctor);
180
181 pgd_cache = kmem_cache_create("pgd-cache", MEMC_TABLE_SIZE +
182 sizeof(pgd_t) * PTRS_PER_PGD,
183 0, SLAB_PANIC, pgd_cache_ctor);
184}
diff --git a/arch/arm26/mm/proc-funcs.S b/arch/arm26/mm/proc-funcs.S
deleted file mode 100644
index f9fca524c57a..000000000000
--- a/arch/arm26/mm/proc-funcs.S
+++ /dev/null
@@ -1,359 +0,0 @@
1/*
2 * linux/arch/arm26/mm/proc-arm2,3.S
3 *
4 * Copyright (C) 1997-1999 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * MMU functions for ARM2,3
11 *
12 * These are the low level assembler for performing cache
13 * and memory functions on ARM2, ARM250 and ARM3 processors.
14 */
15#include <linux/linkage.h>
16#include <asm/assembler.h>
17#include <asm/asm-offsets.h>
18#include <asm/procinfo.h>
19#include <asm/ptrace.h>
20
21/*
22 * MEMC workhorse code. It's both a horse which things it's a pig.
23 */
24/*
25 * Function: cpu_memc_update_entry(pgd_t *pgd, unsigned long phys_pte, unsigned long addr)
26 * Params : pgd Page tables/MEMC mapping
27 * : phys_pte physical address, or PTE
28 * : addr virtual address
29 */
30ENTRY(cpu_memc_update_entry)
31 tst r1, #PAGE_PRESENT @ is the page present
32 orreq r1, r1, #PAGE_OLD | PAGE_CLEAN
33 moveq r2, #0x01f00000
34 mov r3, r1, lsr #13 @ convert to physical page nr
35 and r3, r3, #0x3fc
36 adr ip, memc_phys_table_32
37 ldr r3, [ip, r3]
38 tst r1, #PAGE_OLD | PAGE_NOT_USER
39 biceq r3, r3, #0x200
40 tsteq r1, #PAGE_READONLY | PAGE_CLEAN
41 biceq r3, r3, #0x300
42 mov r2, r2, lsr #15 @ virtual -> nr
43 orr r3, r3, r2, lsl #15
44 and r2, r2, #0x300
45 orr r3, r3, r2, lsl #2
46 and r2, r3, #255
47 sub r0, r0, #256 * 4
48 str r3, [r0, r2, lsl #2]
49 strb r3, [r3]
50 movs pc, lr
51/*
52 * Params : r0 = preserved
53 * : r1 = memc table base (preserved)
54 * : r2 = page table entry
55 * : r3 = preserved
56 * : r4 = unused
57 * : r5 = memc physical address translation table
58 * : ip = virtual address (preserved)
59 */
60update_pte:
61 mov r4, r2, lsr #13
62 and r4, r4, #0x3fc
63 ldr r4, [r5, r4] @ covert to MEMC page
64
65 tst r2, #PAGE_OLD | PAGE_NOT_USER @ check for MEMC read
66 biceq r4, r4, #0x200
67 tsteq r2, #PAGE_READONLY | PAGE_CLEAN @ check for MEMC write
68 biceq r4, r4, #0x300
69
70 orr r4, r4, ip
71 and r2, ip, #0x01800000
72 orr r4, r4, r2, lsr #13
73
74 and r2, r4, #255
75 str r4, [r1, r2, lsl #2]
76 movs pc, lr
77
78/*
79 * Params : r0 = preserved
80 * : r1 = memc table base (preserved)
81 * : r2 = page table base
82 * : r3 = preserved
83 * : r4 = unused
84 * : r5 = memc physical address translation table
85 * : ip = virtual address (updated)
86 */
87update_pte_table:
88 stmfd sp!, {r0, lr}
89 bic r0, r2, #3
901: ldr r2, [r0], #4 @ get entry
91 tst r2, #PAGE_PRESENT @ page present
92 blne update_pte @ process pte
93 add ip, ip, #32768 @ increment virt addr
94 ldr r2, [r0], #4 @ get entry
95 tst r2, #PAGE_PRESENT @ page present
96 blne update_pte @ process pte
97 add ip, ip, #32768 @ increment virt addr
98 ldr r2, [r0], #4 @ get entry
99 tst r2, #PAGE_PRESENT @ page present
100 blne update_pte @ process pte
101 add ip, ip, #32768 @ increment virt addr
102 ldr r2, [r0], #4 @ get entry
103 tst r2, #PAGE_PRESENT @ page present
104 blne update_pte @ process pte
105 add ip, ip, #32768 @ increment virt addr
106 tst ip, #32768 * 31 @ finished?
107 bne 1b
108 ldmfd sp!, {r0, pc}^
109
110/*
111 * Function: cpu_memc_update_all(pgd_t *pgd)
112 * Params : pgd Page tables/MEMC mapping
113 * Notes : this is optimised for 32k pages
114 */
115ENTRY(cpu_memc_update_all)
116 stmfd sp!, {r4, r5, lr}
117 bl clear_tables
118 sub r1, r0, #256 * 4 @ start of MEMC tables
119 adr r5, memc_phys_table_32 @ Convert to logical page number
120 mov ip, #0 @ virtual address
1211: ldmia r0!, {r2, r3} @ load two pgd entries
122 tst r2, #PAGE_PRESENT @ is pgd entry present?
123 addeq ip, ip, #1048576 @FIXME - PAGE_PRESENT is for PTEs technically...
124 blne update_pte_table
125 mov r2, r3
126 tst r2, #PAGE_PRESENT @ is pgd entry present?
127 addeq ip, ip, #1048576
128 blne update_pte_table
129 teq ip, #32 * 1048576
130 bne 1b
131 ldmfd sp!, {r4, r5, pc}^
132
133/*
134 * Build the table to map from physical page number to memc page number
135 */
136 .type memc_phys_table_32, #object
137memc_phys_table_32:
138 .irp b7, 0x00, 0x80
139 .irp b6, 0x00, 0x02
140 .irp b5, 0x00, 0x04
141 .irp b4, 0x00, 0x01
142
143 .irp b3, 0x00, 0x40
144 .irp b2, 0x00, 0x20
145 .irp b1, 0x00, 0x10
146 .irp b0, 0x00, 0x08
147 .long 0x03800300 + \b7 + \b6 + \b5 + \b4 + \b3 + \b2 + \b1 + \b0
148 .endr
149 .endr
150 .endr
151 .endr
152
153 .endr
154 .endr
155 .endr
156 .endr
157 .size memc_phys_table_32, . - memc_phys_table_32
158
159/*
160 * helper for cpu_memc_update_all, this clears out all
161 * mappings, setting them close to the top of memory,
162 * and inaccessible (0x01f00000).
163 * Params : r0 = page table pointer
164 */
165clear_tables: ldr r1, _arm3_set_pgd - 4
166 ldr r2, [r1]
167 sub r1, r0, #256 * 4 @ start of MEMC tables
168 add r2, r1, r2, lsl #2 @ end of tables
169 mov r3, #0x03f00000 @ Default mapping (null mapping)
170 orr r3, r3, #0x00000f00
171 orr r4, r3, #1
172 orr r5, r3, #2
173 orr ip, r3, #3
1741: stmia r1!, {r3, r4, r5, ip}
175 add r3, r3, #4
176 add r4, r4, #4
177 add r5, r5, #4
178 add ip, ip, #4
179 stmia r1!, {r3, r4, r5, ip}
180 add r3, r3, #4
181 add r4, r4, #4
182 add r5, r5, #4
183 add ip, ip, #4
184 teq r1, r2
185 bne 1b
186 mov pc, lr
187
188/*
189 * Function: *_set_pgd(pgd_t *pgd)
190 * Params : pgd New page tables/MEMC mapping
191 * Purpose : update MEMC hardware with new mapping
192 */
193 .word page_nr @ extern - declared in mm-memc.c
194_arm3_set_pgd: mcr p15, 0, r1, c1, c0, 0 @ flush cache
195_arm2_set_pgd: stmfd sp!, {lr}
196 ldr r1, _arm3_set_pgd - 4
197 ldr r2, [r1]
198 sub r0, r0, #256 * 4 @ start of MEMC tables
199 add r1, r0, r2, lsl #2 @ end of tables
2001: ldmia r0!, {r2, r3, ip, lr}
201 strb r2, [r2]
202 strb r3, [r3]
203 strb ip, [ip]
204 strb lr, [lr]
205 ldmia r0!, {r2, r3, ip, lr}
206 strb r2, [r2]
207 strb r3, [r3]
208 strb ip, [ip]
209 strb lr, [lr]
210 teq r0, r1
211 bne 1b
212 ldmfd sp!, {pc}^
213
214/*
215 * Function: *_proc_init (void)
216 * Purpose : Initialise the cache control registers
217 */
218_arm3_proc_init:
219 mov r0, #0x001f0000
220 orr r0, r0, #0x0000ff00
221 orr r0, r0, #0x000000ff
222 mcr p15, 0, r0, c3, c0 @ ARM3 Cacheable
223 mcr p15, 0, r0, c4, c0 @ ARM3 Updateable
224 mov r0, #0
225 mcr p15, 0, r0, c5, c0 @ ARM3 Disruptive
226 mcr p15, 0, r0, c1, c0 @ ARM3 Flush
227 mov r0, #3
228 mcr p15, 0, r0, c2, c0 @ ARM3 Control
229_arm2_proc_init:
230 movs pc, lr
231
232/*
233 * Function: *_proc_fin (void)
234 * Purpose : Finalise processor (disable caches)
235 */
236_arm3_proc_fin: mov r0, #2
237 mcr p15, 0, r0, c2, c0
238_arm2_proc_fin: orrs pc, lr, #PSR_I_BIT|PSR_F_BIT
239
240/*
241 * Function: *_xchg_1 (int new, volatile void *ptr)
242 * Params : new New value to store at...
243 * : ptr pointer to byte-wide location
244 * Purpose : Performs an exchange operation
245 * Returns : Original byte data at 'ptr'
246 */
247_arm2_xchg_1: mov r2, pc
248 orr r2, r2, #PSR_I_BIT
249 teqp r2, #0
250 ldrb r2, [r1]
251 strb r0, [r1]
252 mov r0, r2
253 movs pc, lr
254
255_arm3_xchg_1: swpb r0, r0, [r1]
256 movs pc, lr
257
258/*
259 * Function: *_xchg_4 (int new, volatile void *ptr)
260 * Params : new New value to store at...
261 * : ptr pointer to word-wide location
262 * Purpose : Performs an exchange operation
263 * Returns : Original word data at 'ptr'
264 */
265_arm2_xchg_4: mov r2, pc
266 orr r2, r2, #PSR_I_BIT
267 teqp r2, #0
268 ldr r2, [r1]
269 str r0, [r1]
270 mov r0, r2
271 movs pc, lr
272
273_arm3_xchg_4: swp r0, r0, [r1]
274 movs pc, lr
275
276_arm2_3_check_bugs:
277 bics pc, lr, #PSR_F_BIT @ Clear FIQ disable bit
278
279armvlsi_name: .asciz "ARM/VLSI"
280_arm2_name: .asciz "ARM 2"
281_arm250_name: .asciz "ARM 250"
282_arm3_name: .asciz "ARM 3"
283
284 .section ".init.text", #alloc, #execinstr
285/*
286 * Purpose : Function pointers used to access above functions - all calls
287 * come through these
288 */
289 .globl arm2_processor_functions
290arm2_processor_functions:
291 .word _arm2_3_check_bugs
292 .word _arm2_proc_init
293 .word _arm2_proc_fin
294 .word _arm2_set_pgd
295 .word _arm2_xchg_1
296 .word _arm2_xchg_4
297
298cpu_arm2_info:
299 .long armvlsi_name
300 .long _arm2_name
301
302 .globl arm250_processor_functions
303arm250_processor_functions:
304 .word _arm2_3_check_bugs
305 .word _arm2_proc_init
306 .word _arm2_proc_fin
307 .word _arm2_set_pgd
308 .word _arm3_xchg_1
309 .word _arm3_xchg_4
310
311cpu_arm250_info:
312 .long armvlsi_name
313 .long _arm250_name
314
315 .globl arm3_processor_functions
316arm3_processor_functions:
317 .word _arm2_3_check_bugs
318 .word _arm3_proc_init
319 .word _arm3_proc_fin
320 .word _arm3_set_pgd
321 .word _arm3_xchg_1
322 .word _arm3_xchg_4
323
324cpu_arm3_info:
325 .long armvlsi_name
326 .long _arm3_name
327
328arm2_arch_name: .asciz "armv1"
329arm3_arch_name: .asciz "armv2"
330arm2_elf_name: .asciz "v1"
331arm3_elf_name: .asciz "v2"
332 .align
333
334 .section ".proc.info", #alloc, #execinstr
335
336 .long 0x41560200
337 .long 0xfffffff0
338 .long arm2_arch_name
339 .long arm2_elf_name
340 .long 0
341 .long cpu_arm2_info
342 .long arm2_processor_functions
343
344 .long 0x41560250
345 .long 0xfffffff0
346 .long arm3_arch_name
347 .long arm3_elf_name
348 .long 0
349 .long cpu_arm250_info
350 .long arm250_processor_functions
351
352 .long 0x41560300
353 .long 0xfffffff0
354 .long arm3_arch_name
355 .long arm3_elf_name
356 .long 0
357 .long cpu_arm3_info
358 .long arm3_processor_functions
359
diff --git a/arch/arm26/mm/small_page.c b/arch/arm26/mm/small_page.c
deleted file mode 100644
index 30447106c25f..000000000000
--- a/arch/arm26/mm/small_page.c
+++ /dev/null
@@ -1,192 +0,0 @@
1/*
2 * linux/arch/arm26/mm/small_page.c
3 *
4 * Copyright (C) 1996 Russell King
5 * Copyright (C) 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Changelog:
12 * 26/01/1996 RMK Cleaned up various areas to make little more generic
13 * 07/02/1999 RMK Support added for 16K and 32K page sizes
14 * containing 8K blocks
15 * 23/05/2004 IM Fixed to use struct page->lru (thanks wli)
16 *
17 */
18#include <linux/signal.h>
19#include <linux/sched.h>
20#include <linux/kernel.h>
21#include <linux/errno.h>
22#include <linux/string.h>
23#include <linux/types.h>
24#include <linux/ptrace.h>
25#include <linux/mman.h>
26#include <linux/mm.h>
27#include <linux/swap.h>
28#include <linux/smp.h>
29#include <linux/bitops.h>
30
31#include <asm/pgtable.h>
32
33#define PEDANTIC
34
35/*
36 * Requirement:
37 * We need to be able to allocate naturally aligned memory of finer
38 * granularity than the page size. This is typically used for the
39 * second level page tables on 32-bit ARMs.
40 *
41 * FIXME - this comment is *out of date*
42 * Theory:
43 * We "misuse" the Linux memory management system. We use alloc_page
44 * to allocate a page and then mark it as reserved. The Linux memory
45 * management system will then ignore the "offset", "next_hash" and
46 * "pprev_hash" entries in the mem_map for this page.
47 *
48 * We then use a bitstring in the "offset" field to mark which segments
49 * of the page are in use, and manipulate this as required during the
50 * allocation and freeing of these small pages.
51 *
52 * We also maintain a queue of pages being used for this purpose using
53 * the "next_hash" and "pprev_hash" entries of mem_map;
54 */
55
56struct order {
57 struct list_head queue;
58 unsigned int mask; /* (1 << shift) - 1 */
59 unsigned int shift; /* (1 << shift) size of page */
60 unsigned int block_mask; /* nr_blocks - 1 */
61 unsigned int all_used; /* (1 << nr_blocks) - 1 */
62};
63
64
65static struct order orders[] = {
66#if PAGE_SIZE == 32768
67 { LIST_HEAD_INIT(orders[0].queue), 2047, 11, 15, 0x0000ffff },
68 { LIST_HEAD_INIT(orders[1].queue), 8191, 13, 3, 0x0000000f }
69#else
70#error unsupported page size (ARGH!)
71#endif
72};
73
74#define USED_MAP(pg) ((pg)->index)
75#define TEST_AND_CLEAR_USED(pg,off) (test_and_clear_bit(off, &USED_MAP(pg)))
76#define SET_USED(pg,off) (set_bit(off, &USED_MAP(pg)))
77
78static DEFINE_SPINLOCK(small_page_lock);
79
80static unsigned long __get_small_page(int priority, struct order *order)
81{
82 unsigned long flags;
83 struct page *page;
84 int offset;
85
86 do {
87 spin_lock_irqsave(&small_page_lock, flags);
88
89 if (list_empty(&order->queue))
90 goto need_new_page;
91
92 page = list_entry(order->queue.next, struct page, lru);
93again:
94#ifdef PEDANTIC
95 BUG_ON(USED_MAP(page) & ~order->all_used);
96#endif
97 offset = ffz(USED_MAP(page));
98 SET_USED(page, offset);
99 if (USED_MAP(page) == order->all_used)
100 list_del_init(&page->lru);
101 spin_unlock_irqrestore(&small_page_lock, flags);
102
103 return (unsigned long) page_address(page) + (offset << order->shift);
104
105need_new_page:
106 spin_unlock_irqrestore(&small_page_lock, flags);
107 page = alloc_page(priority);
108 spin_lock_irqsave(&small_page_lock, flags);
109
110 if (list_empty(&order->queue)) {
111 if (!page)
112 goto no_page;
113 SetPageReserved(page);
114 USED_MAP(page) = 0;
115 list_add(&page->lru, &order->queue);
116 goto again;
117 }
118
119 spin_unlock_irqrestore(&small_page_lock, flags);
120 __free_page(page);
121 } while (1);
122
123no_page:
124 spin_unlock_irqrestore(&small_page_lock, flags);
125 return 0;
126}
127
128static void __free_small_page(unsigned long spage, struct order *order)
129{
130 unsigned long flags;
131 struct page *page;
132
133 if (virt_addr_valid(spage)) {
134 page = virt_to_page(spage);
135
136 /*
137 * The container-page must be marked Reserved
138 */
139 if (!PageReserved(page) || spage & order->mask)
140 goto non_small;
141
142#ifdef PEDANTIC
143 BUG_ON(USED_MAP(page) & ~order->all_used);
144#endif
145
146 spage = spage >> order->shift;
147 spage &= order->block_mask;
148
149 /*
150 * the following must be atomic wrt get_page
151 */
152 spin_lock_irqsave(&small_page_lock, flags);
153
154 if (USED_MAP(page) == order->all_used)
155 list_add(&page->lru, &order->queue);
156
157 if (!TEST_AND_CLEAR_USED(page, spage))
158 goto already_free;
159
160 if (USED_MAP(page) == 0)
161 goto free_page;
162
163 spin_unlock_irqrestore(&small_page_lock, flags);
164 }
165 return;
166
167free_page:
168 /*
169 * unlink the page from the small page queue and free it
170 */
171 list_del_init(&page->lru);
172 spin_unlock_irqrestore(&small_page_lock, flags);
173 ClearPageReserved(page);
174 __free_page(page);
175 return;
176
177non_small:
178 printk("Trying to free non-small page from %p\n", __builtin_return_address(0));
179 return;
180already_free:
181 printk("Trying to free free small page from %p\n", __builtin_return_address(0));
182}
183
184unsigned long get_page_8k(int priority)
185{
186 return __get_small_page(priority, orders+1);
187}
188
189void free_page_8k(unsigned long spage)
190{
191 __free_small_page(spage, orders+1);
192}
diff --git a/arch/arm26/nwfpe/ARM-gcc.h b/arch/arm26/nwfpe/ARM-gcc.h
deleted file mode 100644
index e6598470b076..000000000000
--- a/arch/arm26/nwfpe/ARM-gcc.h
+++ /dev/null
@@ -1,120 +0,0 @@
1/*
2-------------------------------------------------------------------------------
3The macro `BITS64' can be defined to indicate that 64-bit integer types are
4supported by the compiler.
5-------------------------------------------------------------------------------
6*/
7#define BITS64
8
9/*
10-------------------------------------------------------------------------------
11Each of the following `typedef's defines the most convenient type that holds
12integers of at least as many bits as specified. For example, `uint8' should
13be the most convenient type that can hold unsigned integers of as many as
148 bits. The `flag' type must be able to hold either a 0 or 1. For most
15implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
16to the same as `int'.
17-------------------------------------------------------------------------------
18*/
19typedef char flag;
20typedef unsigned char uint8;
21typedef signed char int8;
22typedef int uint16;
23typedef int int16;
24typedef unsigned int uint32;
25typedef signed int int32;
26#ifdef BITS64
27typedef unsigned long long int bits64;
28typedef signed long long int sbits64;
29#endif
30
31/*
32-------------------------------------------------------------------------------
33Each of the following `typedef's defines a type that holds integers
34of _exactly_ the number of bits specified. For instance, for most
35implementation of C, `bits16' and `sbits16' should be `typedef'ed to
36`unsigned short int' and `signed short int' (or `short int'), respectively.
37-------------------------------------------------------------------------------
38*/
39typedef unsigned char bits8;
40typedef signed char sbits8;
41typedef unsigned short int bits16;
42typedef signed short int sbits16;
43typedef unsigned int bits32;
44typedef signed int sbits32;
45#ifdef BITS64
46typedef unsigned long long int uint64;
47typedef signed long long int int64;
48#endif
49
50#ifdef BITS64
51/*
52-------------------------------------------------------------------------------
53The `LIT64' macro takes as its argument a textual integer literal and if
54necessary ``marks'' the literal as having a 64-bit integer type. For
55example, the Gnu C Compiler (`gcc') requires that 64-bit literals be
56appended with the letters `LL' standing for `long long', which is `gcc's
57name for the 64-bit integer type. Some compilers may allow `LIT64' to be
58defined as the identity macro: `#define LIT64( a ) a'.
59-------------------------------------------------------------------------------
60*/
61#define LIT64( a ) a##LL
62#endif
63
64/*
65-------------------------------------------------------------------------------
66The macro `INLINE' can be used before functions that should be inlined. If
67a compiler does not support explicit inlining, this macro should be defined
68to be `static'.
69-------------------------------------------------------------------------------
70*/
71#define INLINE extern __inline__
72
73
74/* For use as a GCC soft-float library we need some special function names. */
75
76#ifdef __LIBFLOAT__
77
78/* Some 32-bit ops can be mapped straight across by just changing the name. */
79#define float32_add __addsf3
80#define float32_sub __subsf3
81#define float32_mul __mulsf3
82#define float32_div __divsf3
83#define int32_to_float32 __floatsisf
84#define float32_to_int32_round_to_zero __fixsfsi
85#define float32_to_uint32_round_to_zero __fixunssfsi
86
87/* These ones go through the glue code. To avoid namespace pollution
88 we rename the internal functions too. */
89#define float32_eq ___float32_eq
90#define float32_le ___float32_le
91#define float32_lt ___float32_lt
92
93/* All the 64-bit ops have to go through the glue, so we pull the same
94 trick. */
95#define float64_add ___float64_add
96#define float64_sub ___float64_sub
97#define float64_mul ___float64_mul
98#define float64_div ___float64_div
99#define int32_to_float64 ___int32_to_float64
100#define float64_to_int32_round_to_zero ___float64_to_int32_round_to_zero
101#define float64_to_uint32_round_to_zero ___float64_to_uint32_round_to_zero
102#define float64_to_float32 ___float64_to_float32
103#define float32_to_float64 ___float32_to_float64
104#define float64_eq ___float64_eq
105#define float64_le ___float64_le
106#define float64_lt ___float64_lt
107
108#if 0
109#define float64_add __adddf3
110#define float64_sub __subdf3
111#define float64_mul __muldf3
112#define float64_div __divdf3
113#define int32_to_float64 __floatsidf
114#define float64_to_int32_round_to_zero __fixdfsi
115#define float64_to_uint32_round_to_zero __fixunsdfsi
116#define float64_to_float32 __truncdfsf2
117#define float32_to_float64 __extendsfdf2
118#endif
119
120#endif
diff --git a/arch/arm26/nwfpe/ChangeLog b/arch/arm26/nwfpe/ChangeLog
deleted file mode 100644
index 0c580f764baf..000000000000
--- a/arch/arm26/nwfpe/ChangeLog
+++ /dev/null
@@ -1,83 +0,0 @@
12002-01-19 Russell King <rmk@arm.linux.org.uk>
2
3 * fpa11.h - Add documentation
4 - remove userRegisters pointer from this structure.
5 - add new method to obtain integer register values.
6 * softfloat.c - Remove float128
7 * softfloat.h - Remove float128
8 * softfloat-specialize - Remove float128
9
10 * The FPA11 structure is not a kernel-specific data structure.
11 It is used by users of ptrace to examine the values of the
12 floating point registers. Therefore, any changes to the
13 FPA11 structure (size or position of elements contained
14 within) have to be well thought out.
15
16 * Since 128-bit float requires the FPA11 structure to change
17 size, it has been removed. 128-bit float is currently unused,
18 and needs various things to be re-worked so that we won't
19 overflow the available space in the task structure.
20
21 * The changes are designed to break any patch that goes on top
22 of this code, so that the authors properly review their changes.
23
241999-08-19 Scott Bambrough <scottb@netwinder.org>
25
26 * fpmodule.c - Changed version number to 0.95
27 * fpa11.h - modified FPA11, FPREG structures
28 * fpa11.c - Changes due to FPA11, FPREG structure alterations.
29 * fpa11_cpdo.c - Changes due to FPA11, FPREG structure alterations.
30 * fpa11_cpdt.c - Changes due to FPA11, FPREG structure alterations.
31 * fpa11_cprt.c - Changes due to FPA11, FPREG structure alterations.
32 * single_cpdo.c - Changes due to FPA11, FPREG structure alterations.
33 * double_cpdo.c - Changes due to FPA11, FPREG structure alterations.
34 * extended_cpdo.c - Changes due to FPA11, FPREG structure alterations.
35
36 * I discovered several bugs. First and worst is that the kernel
37 passes in a pointer to the FPE's state area. This is defined
38 as a struct user_fp (see user.h). This pointer was cast to a
39 FPA11*. Unfortunately FPA11 and user_fp are of different sizes;
40 user_fp is smaller. This meant that the FPE scribbled on things
41 below its area, which is bad, as the area is in the thread_struct
42 embedded in the process task structure. Thus we were scribbling
43 over one of the most important structures in the entire OS.
44
45 * user_fp and FPA11 have now been harmonized. Most of the changes
46 in the above code were dereferencing problems due to moving the
47 register type out of FPREG, and getting rid of the union variable
48 fpvalue.
49
50 * Second I noticed resetFPA11 was not always being called for a
51 task. This should happen on the first floating point exception
52 that occurs. It is controlled by init_flag in FPA11. The
53 comment in the code beside init_flag state the kernel guarantees
54 this to be zero. Not so. I found that the kernel recycles task
55 structures, and that recycled ones may not have init_flag zeroed.
56 I couldn't even find anything that guarantees it is zeroed when
57 when the task structure is initially allocated. In any case
58 I now initialize the entire FPE state in the thread structure to
59 zero when allocated and recycled. See alloc_task_struct() and
60 flush_thread() in arch/arm/process.c. The change to
61 alloc_task_struct() may not be necessary, but I left it in for
62 completeness (better safe than sorry).
63
641998-11-23 Scott Bambrough <scottb@netwinder.org>
65
66 * README.FPE - fix typo in description of lfm/sfm instructions
67 * NOTES - Added file to describe known bugs/problems
68 * fpmodule.c - Changed version number to 0.94
69
701998-11-20 Scott Bambrough <scottb@netwinder.org>
71
72 * README.FPE - fix description of URD, NRM instructions
73 * TODO - remove URD, NRM instructions from TODO list
74 * single_cpdo.c - implement URD, NRM
75 * double_cpdo.c - implement URD, NRM
76 * extended_cpdo.c - implement URD, NRM
77
781998-11-19 Scott Bambrough <scottb@netwinder.org>
79
80 * ChangeLog - Added this file to track changes made.
81 * fpa11.c - added code to initialize register types to typeNone
82 * fpa11_cpdt.c - fixed bug in storeExtended (typeExtended changed to
83 typeDouble in switch statement)
diff --git a/arch/arm26/nwfpe/Makefile b/arch/arm26/nwfpe/Makefile
deleted file mode 100644
index b39d34dff054..000000000000
--- a/arch/arm26/nwfpe/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
1#
2# Copyright (C) 1998, 1999, 2001 Philip Blundell
3#
4
5obj-y :=
6obj-m :=
7obj-n :=
8
9obj-$(CONFIG_FPE_NWFPE) += nwfpe.o
10
11nwfpe-objs := fpa11.o fpa11_cpdo.o fpa11_cpdt.o fpa11_cprt.o \
12 fpmodule.o fpopcode.o softfloat.o \
13 single_cpdo.o double_cpdo.o extended_cpdo.o \
14 entry.o
15
diff --git a/arch/arm26/nwfpe/double_cpdo.c b/arch/arm26/nwfpe/double_cpdo.c
deleted file mode 100644
index 7f4fef0216c7..000000000000
--- a/arch/arm26/nwfpe/double_cpdo.c
+++ /dev/null
@@ -1,288 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include "fpa11.h"
23#include "softfloat.h"
24#include "fpopcode.h"
25
26float64 float64_exp(float64 Fm);
27float64 float64_ln(float64 Fm);
28float64 float64_sin(float64 rFm);
29float64 float64_cos(float64 rFm);
30float64 float64_arcsin(float64 rFm);
31float64 float64_arctan(float64 rFm);
32float64 float64_log(float64 rFm);
33float64 float64_tan(float64 rFm);
34float64 float64_arccos(float64 rFm);
35float64 float64_pow(float64 rFn,float64 rFm);
36float64 float64_pol(float64 rFn,float64 rFm);
37
38unsigned int DoubleCPDO(const unsigned int opcode)
39{
40 FPA11 *fpa11 = GET_FPA11();
41 float64 rFm, rFn = 0; //FIXME - should be zero?
42 unsigned int Fd, Fm, Fn, nRc = 1;
43
44 //printk("DoubleCPDO(0x%08x)\n",opcode);
45
46 Fm = getFm(opcode);
47 if (CONSTANT_FM(opcode))
48 {
49 rFm = getDoubleConstant(Fm);
50 }
51 else
52 {
53 switch (fpa11->fType[Fm])
54 {
55 case typeSingle:
56 rFm = float32_to_float64(fpa11->fpreg[Fm].fSingle);
57 break;
58
59 case typeDouble:
60 rFm = fpa11->fpreg[Fm].fDouble;
61 break;
62
63 case typeExtended:
64 // !! patb
65 //printk("not implemented! why not?\n");
66 //!! ScottB
67 // should never get here, if extended involved
68 // then other operand should be promoted then
69 // ExtendedCPDO called.
70 break;
71
72 default: return 0;
73 }
74 }
75
76 if (!MONADIC_INSTRUCTION(opcode))
77 {
78 Fn = getFn(opcode);
79 switch (fpa11->fType[Fn])
80 {
81 case typeSingle:
82 rFn = float32_to_float64(fpa11->fpreg[Fn].fSingle);
83 break;
84
85 case typeDouble:
86 rFn = fpa11->fpreg[Fn].fDouble;
87 break;
88
89 default: return 0;
90 }
91 }
92
93 Fd = getFd(opcode);
94 /* !! this switch isn't optimized; better (opcode & MASK_ARITHMETIC_OPCODE)>>24, sort of */
95 switch (opcode & MASK_ARITHMETIC_OPCODE)
96 {
97 /* dyadic opcodes */
98 case ADF_CODE:
99 fpa11->fpreg[Fd].fDouble = float64_add(rFn,rFm);
100 break;
101
102 case MUF_CODE:
103 case FML_CODE:
104 fpa11->fpreg[Fd].fDouble = float64_mul(rFn,rFm);
105 break;
106
107 case SUF_CODE:
108 fpa11->fpreg[Fd].fDouble = float64_sub(rFn,rFm);
109 break;
110
111 case RSF_CODE:
112 fpa11->fpreg[Fd].fDouble = float64_sub(rFm,rFn);
113 break;
114
115 case DVF_CODE:
116 case FDV_CODE:
117 fpa11->fpreg[Fd].fDouble = float64_div(rFn,rFm);
118 break;
119
120 case RDF_CODE:
121 case FRD_CODE:
122 fpa11->fpreg[Fd].fDouble = float64_div(rFm,rFn);
123 break;
124
125#if 0
126 case POW_CODE:
127 fpa11->fpreg[Fd].fDouble = float64_pow(rFn,rFm);
128 break;
129
130 case RPW_CODE:
131 fpa11->fpreg[Fd].fDouble = float64_pow(rFm,rFn);
132 break;
133#endif
134
135 case RMF_CODE:
136 fpa11->fpreg[Fd].fDouble = float64_rem(rFn,rFm);
137 break;
138
139#if 0
140 case POL_CODE:
141 fpa11->fpreg[Fd].fDouble = float64_pol(rFn,rFm);
142 break;
143#endif
144
145 /* monadic opcodes */
146 case MVF_CODE:
147 fpa11->fpreg[Fd].fDouble = rFm;
148 break;
149
150 case MNF_CODE:
151 {
152 unsigned int *p = (unsigned int*)&rFm;
153 p[1] ^= 0x80000000;
154 fpa11->fpreg[Fd].fDouble = rFm;
155 }
156 break;
157
158 case ABS_CODE:
159 {
160 unsigned int *p = (unsigned int*)&rFm;
161 p[1] &= 0x7fffffff;
162 fpa11->fpreg[Fd].fDouble = rFm;
163 }
164 break;
165
166 case RND_CODE:
167 case URD_CODE:
168 fpa11->fpreg[Fd].fDouble = float64_round_to_int(rFm);
169 break;
170
171 case SQT_CODE:
172 fpa11->fpreg[Fd].fDouble = float64_sqrt(rFm);
173 break;
174
175#if 0
176 case LOG_CODE:
177 fpa11->fpreg[Fd].fDouble = float64_log(rFm);
178 break;
179
180 case LGN_CODE:
181 fpa11->fpreg[Fd].fDouble = float64_ln(rFm);
182 break;
183
184 case EXP_CODE:
185 fpa11->fpreg[Fd].fDouble = float64_exp(rFm);
186 break;
187
188 case SIN_CODE:
189 fpa11->fpreg[Fd].fDouble = float64_sin(rFm);
190 break;
191
192 case COS_CODE:
193 fpa11->fpreg[Fd].fDouble = float64_cos(rFm);
194 break;
195
196 case TAN_CODE:
197 fpa11->fpreg[Fd].fDouble = float64_tan(rFm);
198 break;
199
200 case ASN_CODE:
201 fpa11->fpreg[Fd].fDouble = float64_arcsin(rFm);
202 break;
203
204 case ACS_CODE:
205 fpa11->fpreg[Fd].fDouble = float64_arccos(rFm);
206 break;
207
208 case ATN_CODE:
209 fpa11->fpreg[Fd].fDouble = float64_arctan(rFm);
210 break;
211#endif
212
213 case NRM_CODE:
214 break;
215
216 default:
217 {
218 nRc = 0;
219 }
220 }
221
222 if (0 != nRc) fpa11->fType[Fd] = typeDouble;
223 return nRc;
224}
225
226#if 0
227float64 float64_exp(float64 rFm)
228{
229 return rFm;
230//series
231}
232
233float64 float64_ln(float64 rFm)
234{
235 return rFm;
236//series
237}
238
239float64 float64_sin(float64 rFm)
240{
241 return rFm;
242//series
243}
244
245float64 float64_cos(float64 rFm)
246{
247 return rFm;
248 //series
249}
250
251#if 0
252float64 float64_arcsin(float64 rFm)
253{
254//series
255}
256
257float64 float64_arctan(float64 rFm)
258{
259 //series
260}
261#endif
262
263float64 float64_log(float64 rFm)
264{
265 return float64_div(float64_ln(rFm),getDoubleConstant(7));
266}
267
268float64 float64_tan(float64 rFm)
269{
270 return float64_div(float64_sin(rFm),float64_cos(rFm));
271}
272
273float64 float64_arccos(float64 rFm)
274{
275return rFm;
276 //return float64_sub(halfPi,float64_arcsin(rFm));
277}
278
279float64 float64_pow(float64 rFn,float64 rFm)
280{
281 return float64_exp(float64_mul(rFm,float64_ln(rFn)));
282}
283
284float64 float64_pol(float64 rFn,float64 rFm)
285{
286 return float64_arctan(float64_div(rFn,rFm));
287}
288#endif
diff --git a/arch/arm26/nwfpe/entry.S b/arch/arm26/nwfpe/entry.S
deleted file mode 100644
index e6312000d9f8..000000000000
--- a/arch/arm26/nwfpe/entry.S
+++ /dev/null
@@ -1,114 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998
4 (c) Philip Blundell 1998-1999
5
6 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/
22
23#include <asm/asm-offsets.h>
24
25/* This is the kernel's entry point into the floating point emulator.
26It is called from the kernel with code similar to this:
27
28 mov fp, #0
29 teqp pc, #PSR_I_BIT | MODE_SVC
30 ldr r4, .LC2
31 ldr pc, [r4] @ Call FP module USR entry point
32
33The kernel expects the emulator to return via one of two possible
34points of return it passes to the emulator. The emulator, if
35successful in its emulation, jumps to ret_from_exception and the
36kernel takes care of returning control from the trap to the user code.
37If the emulator is unable to emulate the instruction, it returns to
38fpundefinstr and the kernel halts the user program with a core dump.
39
40This routine does four things:
41
421) It saves SP into a variable called userRegisters. The kernel has
43created a struct pt_regs on the stack and saved the user registers
44into it. See /usr/include/asm/proc/ptrace.h for details. The
45emulator code uses userRegisters as the base of an array of words from
46which the contents of the registers can be extracted.
47
482) It locates the FP emulator work area within the TSS structure and
49points `fpa11' to it.
50
513) It calls EmulateAll to emulate a floating point instruction.
52EmulateAll returns 1 if the emulation was successful, or 0 if not.
53
544) If an instruction has been emulated successfully, it looks ahead at
55the next instruction. If it is a floating point instruction, it
56executes the instruction, without returning to user space. In this
57way it repeatedly looks ahead and executes floating point instructions
58until it encounters a non floating point instruction, at which time it
59returns via _fpreturn.
60
61This is done to reduce the effect of the trap overhead on each
62floating point instructions. GCC attempts to group floating point
63instructions to allow the emulator to spread the cost of the trap over
64several floating point instructions. */
65
66 .globl nwfpe_enter
67nwfpe_enter:
68 mov sl, sp
69 bl FPA11_CheckInit @ check to see if we are initialised
70
71 ldr r5, [sp, #60] @ get contents of PC
72 bic r5, r5, #0xfc000003
73 ldr r0, [r5, #-4] @ get actual instruction into r0
74 bl EmulateAll @ emulate the instruction
751: cmp r0, #0 @ was emulation successful
76 beq fpundefinstr @ no, return failure
77
78next:
79.Lx1: ldrt r6, [r5], #4 @ get the next instruction and
80 @ increment PC
81
82 and r2, r6, #0x0F000000 @ test for FP insns
83 teq r2, #0x0C000000
84 teqne r2, #0x0D000000
85 teqne r2, #0x0E000000
86 bne ret_from_exception @ return ok if not a fp insn
87
88 ldr r9, [sp, #60] @ get new condition codes
89 and r9, r9, #0xfc000003
90 orr r7, r5, r9
91 str r7, [sp, #60] @ update PC copy in regs
92
93 mov r0, r6 @ save a copy
94 mov r1, r9 @ fetch the condition codes
95 bl checkCondition @ check the condition
96 cmp r0, #0 @ r0 = 0 ==> condition failed
97
98 @ if condition code failed to match, next insn
99 beq next @ get the next instruction;
100
101 mov r0, r6 @ prepare for EmulateAll()
102 adr lr, 1b
103 orr lr, lr, #3
104 b EmulateAll @ if r0 != 0, goto EmulateAll
105
106.Lret: b ret_from_exception @ let the user eat segfaults
107
108 @ We need to be prepared for the instruction at .Lx1 to fault.
109 @ Emit the appropriate exception gunk to fix things up.
110 .section __ex_table,"a"
111 .align 3
112 .long .Lx1
113 ldr lr, [lr, $(.Lret - .Lx1)/4]
114 .previous
diff --git a/arch/arm26/nwfpe/extended_cpdo.c b/arch/arm26/nwfpe/extended_cpdo.c
deleted file mode 100644
index 331407596d91..000000000000
--- a/arch/arm26/nwfpe/extended_cpdo.c
+++ /dev/null
@@ -1,273 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include "fpa11.h"
23#include "softfloat.h"
24#include "fpopcode.h"
25
26floatx80 floatx80_exp(floatx80 Fm);
27floatx80 floatx80_ln(floatx80 Fm);
28floatx80 floatx80_sin(floatx80 rFm);
29floatx80 floatx80_cos(floatx80 rFm);
30floatx80 floatx80_arcsin(floatx80 rFm);
31floatx80 floatx80_arctan(floatx80 rFm);
32floatx80 floatx80_log(floatx80 rFm);
33floatx80 floatx80_tan(floatx80 rFm);
34floatx80 floatx80_arccos(floatx80 rFm);
35floatx80 floatx80_pow(floatx80 rFn,floatx80 rFm);
36floatx80 floatx80_pol(floatx80 rFn,floatx80 rFm);
37
38unsigned int ExtendedCPDO(const unsigned int opcode)
39{
40 FPA11 *fpa11 = GET_FPA11();
41 floatx80 rFm, rFn;
42 unsigned int Fd, Fm, Fn, nRc = 1;
43
44 //printk("ExtendedCPDO(0x%08x)\n",opcode);
45
46 Fm = getFm(opcode);
47 if (CONSTANT_FM(opcode))
48 {
49 rFm = getExtendedConstant(Fm);
50 }
51 else
52 {
53 switch (fpa11->fType[Fm])
54 {
55 case typeSingle:
56 rFm = float32_to_floatx80(fpa11->fpreg[Fm].fSingle);
57 break;
58
59 case typeDouble:
60 rFm = float64_to_floatx80(fpa11->fpreg[Fm].fDouble);
61 break;
62
63 case typeExtended:
64 rFm = fpa11->fpreg[Fm].fExtended;
65 break;
66
67 default: return 0;
68 }
69 }
70
71 if (!MONADIC_INSTRUCTION(opcode))
72 {
73 Fn = getFn(opcode);
74 switch (fpa11->fType[Fn])
75 {
76 case typeSingle:
77 rFn = float32_to_floatx80(fpa11->fpreg[Fn].fSingle);
78 break;
79
80 case typeDouble:
81 rFn = float64_to_floatx80(fpa11->fpreg[Fn].fDouble);
82 break;
83
84 case typeExtended:
85 rFn = fpa11->fpreg[Fn].fExtended;
86 break;
87
88 default: return 0;
89 }
90 }
91
92 Fd = getFd(opcode);
93 switch (opcode & MASK_ARITHMETIC_OPCODE)
94 {
95 /* dyadic opcodes */
96 case ADF_CODE:
97 fpa11->fpreg[Fd].fExtended = floatx80_add(rFn,rFm);
98 break;
99
100 case MUF_CODE:
101 case FML_CODE:
102 fpa11->fpreg[Fd].fExtended = floatx80_mul(rFn,rFm);
103 break;
104
105 case SUF_CODE:
106 fpa11->fpreg[Fd].fExtended = floatx80_sub(rFn,rFm);
107 break;
108
109 case RSF_CODE:
110 fpa11->fpreg[Fd].fExtended = floatx80_sub(rFm,rFn);
111 break;
112
113 case DVF_CODE:
114 case FDV_CODE:
115 fpa11->fpreg[Fd].fExtended = floatx80_div(rFn,rFm);
116 break;
117
118 case RDF_CODE:
119 case FRD_CODE:
120 fpa11->fpreg[Fd].fExtended = floatx80_div(rFm,rFn);
121 break;
122
123#if 0
124 case POW_CODE:
125 fpa11->fpreg[Fd].fExtended = floatx80_pow(rFn,rFm);
126 break;
127
128 case RPW_CODE:
129 fpa11->fpreg[Fd].fExtended = floatx80_pow(rFm,rFn);
130 break;
131#endif
132
133 case RMF_CODE:
134 fpa11->fpreg[Fd].fExtended = floatx80_rem(rFn,rFm);
135 break;
136
137#if 0
138 case POL_CODE:
139 fpa11->fpreg[Fd].fExtended = floatx80_pol(rFn,rFm);
140 break;
141#endif
142
143 /* monadic opcodes */
144 case MVF_CODE:
145 fpa11->fpreg[Fd].fExtended = rFm;
146 break;
147
148 case MNF_CODE:
149 rFm.high ^= 0x8000;
150 fpa11->fpreg[Fd].fExtended = rFm;
151 break;
152
153 case ABS_CODE:
154 rFm.high &= 0x7fff;
155 fpa11->fpreg[Fd].fExtended = rFm;
156 break;
157
158 case RND_CODE:
159 case URD_CODE:
160 fpa11->fpreg[Fd].fExtended = floatx80_round_to_int(rFm);
161 break;
162
163 case SQT_CODE:
164 fpa11->fpreg[Fd].fExtended = floatx80_sqrt(rFm);
165 break;
166
167#if 0
168 case LOG_CODE:
169 fpa11->fpreg[Fd].fExtended = floatx80_log(rFm);
170 break;
171
172 case LGN_CODE:
173 fpa11->fpreg[Fd].fExtended = floatx80_ln(rFm);
174 break;
175
176 case EXP_CODE:
177 fpa11->fpreg[Fd].fExtended = floatx80_exp(rFm);
178 break;
179
180 case SIN_CODE:
181 fpa11->fpreg[Fd].fExtended = floatx80_sin(rFm);
182 break;
183
184 case COS_CODE:
185 fpa11->fpreg[Fd].fExtended = floatx80_cos(rFm);
186 break;
187
188 case TAN_CODE:
189 fpa11->fpreg[Fd].fExtended = floatx80_tan(rFm);
190 break;
191
192 case ASN_CODE:
193 fpa11->fpreg[Fd].fExtended = floatx80_arcsin(rFm);
194 break;
195
196 case ACS_CODE:
197 fpa11->fpreg[Fd].fExtended = floatx80_arccos(rFm);
198 break;
199
200 case ATN_CODE:
201 fpa11->fpreg[Fd].fExtended = floatx80_arctan(rFm);
202 break;
203#endif
204
205 case NRM_CODE:
206 break;
207
208 default:
209 {
210 nRc = 0;
211 }
212 }
213
214 if (0 != nRc) fpa11->fType[Fd] = typeExtended;
215 return nRc;
216}
217
218#if 0
219floatx80 floatx80_exp(floatx80 Fm)
220{
221//series
222}
223
224floatx80 floatx80_ln(floatx80 Fm)
225{
226//series
227}
228
229floatx80 floatx80_sin(floatx80 rFm)
230{
231//series
232}
233
234floatx80 floatx80_cos(floatx80 rFm)
235{
236//series
237}
238
239floatx80 floatx80_arcsin(floatx80 rFm)
240{
241//series
242}
243
244floatx80 floatx80_arctan(floatx80 rFm)
245{
246 //series
247}
248
249floatx80 floatx80_log(floatx80 rFm)
250{
251 return floatx80_div(floatx80_ln(rFm),getExtendedConstant(7));
252}
253
254floatx80 floatx80_tan(floatx80 rFm)
255{
256 return floatx80_div(floatx80_sin(rFm),floatx80_cos(rFm));
257}
258
259floatx80 floatx80_arccos(floatx80 rFm)
260{
261 //return floatx80_sub(halfPi,floatx80_arcsin(rFm));
262}
263
264floatx80 floatx80_pow(floatx80 rFn,floatx80 rFm)
265{
266 return floatx80_exp(floatx80_mul(rFm,floatx80_ln(rFn)));
267}
268
269floatx80 floatx80_pol(floatx80 rFn,floatx80 rFm)
270{
271 return floatx80_arctan(floatx80_div(rFn,rFm));
272}
273#endif
diff --git a/arch/arm26/nwfpe/fpa11.c b/arch/arm26/nwfpe/fpa11.c
deleted file mode 100644
index e954540a9464..000000000000
--- a/arch/arm26/nwfpe/fpa11.c
+++ /dev/null
@@ -1,221 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include "fpa11.h"
23#include "fpopcode.h"
24
25#include "fpmodule.h"
26#include "fpmodule.inl"
27
28#include <linux/compiler.h>
29#include <asm/system.h>
30
31/* forward declarations */
32unsigned int EmulateCPDO(const unsigned int);
33unsigned int EmulateCPDT(const unsigned int);
34unsigned int EmulateCPRT(const unsigned int);
35
36/* Reset the FPA11 chip. Called to initialize and reset the emulator. */
37void resetFPA11(void)
38{
39 int i;
40 FPA11 *fpa11 = GET_FPA11();
41
42 /* initialize the register type array */
43 for (i=0;i<=7;i++)
44 {
45 fpa11->fType[i] = typeNone;
46 }
47
48 /* FPSR: set system id to FP_EMULATOR, set AC, clear all other bits */
49 fpa11->fpsr = FP_EMULATOR | BIT_AC;
50
51 /* FPCR: set SB, AB and DA bits, clear all others */
52#if MAINTAIN_FPCR
53 fpa11->fpcr = MASK_RESET;
54#endif
55}
56
57void SetRoundingMode(const unsigned int opcode)
58{
59#if MAINTAIN_FPCR
60 FPA11 *fpa11 = GET_FPA11();
61 fpa11->fpcr &= ~MASK_ROUNDING_MODE;
62#endif
63 switch (opcode & MASK_ROUNDING_MODE)
64 {
65 default:
66 case ROUND_TO_NEAREST:
67 float_rounding_mode = float_round_nearest_even;
68#if MAINTAIN_FPCR
69 fpa11->fpcr |= ROUND_TO_NEAREST;
70#endif
71 break;
72
73 case ROUND_TO_PLUS_INFINITY:
74 float_rounding_mode = float_round_up;
75#if MAINTAIN_FPCR
76 fpa11->fpcr |= ROUND_TO_PLUS_INFINITY;
77#endif
78 break;
79
80 case ROUND_TO_MINUS_INFINITY:
81 float_rounding_mode = float_round_down;
82#if MAINTAIN_FPCR
83 fpa11->fpcr |= ROUND_TO_MINUS_INFINITY;
84#endif
85 break;
86
87 case ROUND_TO_ZERO:
88 float_rounding_mode = float_round_to_zero;
89#if MAINTAIN_FPCR
90 fpa11->fpcr |= ROUND_TO_ZERO;
91#endif
92 break;
93 }
94}
95
96void SetRoundingPrecision(const unsigned int opcode)
97{
98#if MAINTAIN_FPCR
99 FPA11 *fpa11 = GET_FPA11();
100 fpa11->fpcr &= ~MASK_ROUNDING_PRECISION;
101#endif
102 switch (opcode & MASK_ROUNDING_PRECISION)
103 {
104 case ROUND_SINGLE:
105 floatx80_rounding_precision = 32;
106#if MAINTAIN_FPCR
107 fpa11->fpcr |= ROUND_SINGLE;
108#endif
109 break;
110
111 case ROUND_DOUBLE:
112 floatx80_rounding_precision = 64;
113#if MAINTAIN_FPCR
114 fpa11->fpcr |= ROUND_DOUBLE;
115#endif
116 break;
117
118 case ROUND_EXTENDED:
119 floatx80_rounding_precision = 80;
120#if MAINTAIN_FPCR
121 fpa11->fpcr |= ROUND_EXTENDED;
122#endif
123 break;
124
125 default: floatx80_rounding_precision = 80;
126 }
127}
128
129void FPA11_CheckInit(void)
130{
131 FPA11 *fpa11 = GET_FPA11();
132 if (unlikely(fpa11->initflag == 0))
133 {
134 resetFPA11();
135 SetRoundingMode(ROUND_TO_NEAREST);
136 SetRoundingPrecision(ROUND_EXTENDED);
137 fpa11->initflag = 1;
138 }
139}
140
141/* Emulate the instruction in the opcode. */
142unsigned int EmulateAll(unsigned int opcode)
143{
144 unsigned int nRc = 1, code;
145
146 code = opcode & 0x00000f00;
147 if (code == 0x00000100 || code == 0x00000200)
148 {
149 /* For coprocessor 1 or 2 (FPA11) */
150 code = opcode & 0x0e000000;
151 if (code == 0x0e000000)
152 {
153 if (opcode & 0x00000010)
154 {
155 /* Emulate conversion opcodes. */
156 /* Emulate register transfer opcodes. */
157 /* Emulate comparison opcodes. */
158 nRc = EmulateCPRT(opcode);
159 }
160 else
161 {
162 /* Emulate monadic arithmetic opcodes. */
163 /* Emulate dyadic arithmetic opcodes. */
164 nRc = EmulateCPDO(opcode);
165 }
166 }
167 else if (code == 0x0c000000)
168 {
169 /* Emulate load/store opcodes. */
170 /* Emulate load/store multiple opcodes. */
171 nRc = EmulateCPDT(opcode);
172 }
173 else
174 {
175 /* Invalid instruction detected. Return FALSE. */
176 nRc = 0;
177 }
178 }
179
180 return(nRc);
181}
182
183#if 0
184unsigned int EmulateAll1(unsigned int opcode)
185{
186 switch ((opcode >> 24) & 0xf)
187 {
188 case 0xc:
189 case 0xd:
190 if ((opcode >> 20) & 0x1)
191 {
192 switch ((opcode >> 8) & 0xf)
193 {
194 case 0x1: return PerformLDF(opcode); break;
195 case 0x2: return PerformLFM(opcode); break;
196 default: return 0;
197 }
198 }
199 else
200 {
201 switch ((opcode >> 8) & 0xf)
202 {
203 case 0x1: return PerformSTF(opcode); break;
204 case 0x2: return PerformSFM(opcode); break;
205 default: return 0;
206 }
207 }
208 break;
209
210 case 0xe:
211 if (opcode & 0x10)
212 return EmulateCPDO(opcode);
213 else
214 return EmulateCPRT(opcode);
215 break;
216
217 default: return 0;
218 }
219}
220#endif
221
diff --git a/arch/arm26/nwfpe/fpa11.h b/arch/arm26/nwfpe/fpa11.h
deleted file mode 100644
index be09902a211d..000000000000
--- a/arch/arm26/nwfpe/fpa11.h
+++ /dev/null
@@ -1,87 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.com, 1998-1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#ifndef __FPA11_H__
23#define __FPA11_H__
24
25#define GET_FPA11() ((FPA11 *)(&current_thread_info()->fpstate))
26
27/*
28 * The processes registers are always at the very top of the 8K
29 * stack+task struct. Use the same method as 'current' uses to
30 * reach them.
31 */
32register unsigned int *user_registers asm("sl");
33
34#define GET_USERREG() (user_registers)
35
36#include <linux/thread_info.h>
37
38/* includes */
39#include "fpsr.h" /* FP control and status register definitions */
40#include "softfloat.h"
41
42#define typeNone 0x00
43#define typeSingle 0x01
44#define typeDouble 0x02
45#define typeExtended 0x03
46
47/*
48 * This must be no more and no less than 12 bytes.
49 */
50typedef union tagFPREG {
51 floatx80 fExtended;
52 float64 fDouble;
53 float32 fSingle;
54} FPREG;
55
56/*
57 * FPA11 device model.
58 *
59 * This structure is exported to user space. Do not re-order.
60 * Only add new stuff to the end, and do not change the size of
61 * any element. Elements of this structure are used by user
62 * space, and must match struct user_fp in include/asm-arm/user.h.
63 * We include the byte offsets below for documentation purposes.
64 *
65 * The size of this structure and FPREG are checked by fpmodule.c
66 * on initialisation. If the rules have been broken, NWFPE will
67 * not initialise.
68 */
69typedef struct tagFPA11 {
70/* 0 */ FPREG fpreg[8]; /* 8 floating point registers */
71/* 96 */ FPSR fpsr; /* floating point status register */
72/* 100 */ FPCR fpcr; /* floating point control register */
73/* 104 */ unsigned char fType[8]; /* type of floating point value held in
74 floating point registers. One of none
75 single, double or extended. */
76/* 112 */ int initflag; /* this is special. The kernel guarantees
77 to set it to 0 when a thread is launched,
78 so we can use it to detect whether this
79 instance of the emulator needs to be
80 initialised. */
81} FPA11;
82
83extern void resetFPA11(void);
84extern void SetRoundingMode(const unsigned int);
85extern void SetRoundingPrecision(const unsigned int);
86
87#endif
diff --git a/arch/arm26/nwfpe/fpa11.inl b/arch/arm26/nwfpe/fpa11.inl
deleted file mode 100644
index 1c45cba2de66..000000000000
--- a/arch/arm26/nwfpe/fpa11.inl
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include "fpa11.h"
23
24/* Read and write floating point status register */
25extern __inline__ unsigned int readFPSR(void)
26{
27 FPA11 *fpa11 = GET_FPA11();
28 return(fpa11->fpsr);
29}
30
31extern __inline__ void writeFPSR(FPSR reg)
32{
33 FPA11 *fpa11 = GET_FPA11();
34 /* the sysid byte in the status register is readonly */
35 fpa11->fpsr = (fpa11->fpsr & MASK_SYSID) | (reg & ~MASK_SYSID);
36}
37
38/* Read and write floating point control register */
39extern __inline__ FPCR readFPCR(void)
40{
41 FPA11 *fpa11 = GET_FPA11();
42 /* clear SB, AB and DA bits before returning FPCR */
43 return(fpa11->fpcr & ~MASK_RFC);
44}
45
46extern __inline__ void writeFPCR(FPCR reg)
47{
48 FPA11 *fpa11 = GET_FPA11();
49 fpa11->fpcr &= ~MASK_WFC; /* clear SB, AB and DA bits */
50 fpa11->fpcr |= (reg & MASK_WFC); /* write SB, AB and DA bits */
51}
diff --git a/arch/arm26/nwfpe/fpa11_cpdo.c b/arch/arm26/nwfpe/fpa11_cpdo.c
deleted file mode 100644
index 343a6b9fd520..000000000000
--- a/arch/arm26/nwfpe/fpa11_cpdo.c
+++ /dev/null
@@ -1,117 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include "fpa11.h"
23#include "fpopcode.h"
24
25unsigned int SingleCPDO(const unsigned int opcode);
26unsigned int DoubleCPDO(const unsigned int opcode);
27unsigned int ExtendedCPDO(const unsigned int opcode);
28
29unsigned int EmulateCPDO(const unsigned int opcode)
30{
31 FPA11 *fpa11 = GET_FPA11();
32 unsigned int Fd, nType, nDest, nRc = 1;
33
34 //printk("EmulateCPDO(0x%08x)\n",opcode);
35
36 /* Get the destination size. If not valid let Linux perform
37 an invalid instruction trap. */
38 nDest = getDestinationSize(opcode);
39 if (typeNone == nDest) return 0;
40
41 SetRoundingMode(opcode);
42
43 /* Compare the size of the operands in Fn and Fm.
44 Choose the largest size and perform operations in that size,
45 in order to make use of all the precision of the operands.
46 If Fm is a constant, we just grab a constant of a size
47 matching the size of the operand in Fn. */
48 if (MONADIC_INSTRUCTION(opcode))
49 nType = nDest;
50 else
51 nType = fpa11->fType[getFn(opcode)];
52
53 if (!CONSTANT_FM(opcode))
54 {
55 register unsigned int Fm = getFm(opcode);
56 if (nType < fpa11->fType[Fm])
57 {
58 nType = fpa11->fType[Fm];
59 }
60 }
61
62 switch (nType)
63 {
64 case typeSingle : nRc = SingleCPDO(opcode); break;
65 case typeDouble : nRc = DoubleCPDO(opcode); break;
66 case typeExtended : nRc = ExtendedCPDO(opcode); break;
67 default : nRc = 0;
68 }
69
70 /* If the operation succeeded, check to see if the result in the
71 destination register is the correct size. If not force it
72 to be. */
73 Fd = getFd(opcode);
74 nType = fpa11->fType[Fd];
75 if ((0 != nRc) && (nDest != nType))
76 {
77 switch (nDest)
78 {
79 case typeSingle:
80 {
81 if (typeDouble == nType)
82 fpa11->fpreg[Fd].fSingle =
83 float64_to_float32(fpa11->fpreg[Fd].fDouble);
84 else
85 fpa11->fpreg[Fd].fSingle =
86 floatx80_to_float32(fpa11->fpreg[Fd].fExtended);
87 }
88 break;
89
90 case typeDouble:
91 {
92 if (typeSingle == nType)
93 fpa11->fpreg[Fd].fDouble =
94 float32_to_float64(fpa11->fpreg[Fd].fSingle);
95 else
96 fpa11->fpreg[Fd].fDouble =
97 floatx80_to_float64(fpa11->fpreg[Fd].fExtended);
98 }
99 break;
100
101 case typeExtended:
102 {
103 if (typeSingle == nType)
104 fpa11->fpreg[Fd].fExtended =
105 float32_to_floatx80(fpa11->fpreg[Fd].fSingle);
106 else
107 fpa11->fpreg[Fd].fExtended =
108 float64_to_floatx80(fpa11->fpreg[Fd].fDouble);
109 }
110 break;
111 }
112
113 fpa11->fType[Fd] = nDest;
114 }
115
116 return nRc;
117}
diff --git a/arch/arm26/nwfpe/fpa11_cpdt.c b/arch/arm26/nwfpe/fpa11_cpdt.c
deleted file mode 100644
index e12db7c51a76..000000000000
--- a/arch/arm26/nwfpe/fpa11_cpdt.c
+++ /dev/null
@@ -1,368 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.com, 1998-1999
4 (c) Philip Blundell, 1998
5
6 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/
22
23#include "fpa11.h"
24#include "softfloat.h"
25#include "fpopcode.h"
26#include "fpmodule.h"
27#include "fpmodule.inl"
28
29#include <asm/uaccess.h>
30
31static inline
32void loadSingle(const unsigned int Fn,const unsigned int *pMem)
33{
34 FPA11 *fpa11 = GET_FPA11();
35 fpa11->fType[Fn] = typeSingle;
36 get_user(fpa11->fpreg[Fn].fSingle, pMem);
37}
38
39static inline
40void loadDouble(const unsigned int Fn,const unsigned int *pMem)
41{
42 FPA11 *fpa11 = GET_FPA11();
43 unsigned int *p;
44 p = (unsigned int*)&fpa11->fpreg[Fn].fDouble;
45 fpa11->fType[Fn] = typeDouble;
46 get_user(p[0], &pMem[1]);
47 get_user(p[1], &pMem[0]); /* sign & exponent */
48}
49
50static inline
51void loadExtended(const unsigned int Fn,const unsigned int *pMem)
52{
53 FPA11 *fpa11 = GET_FPA11();
54 unsigned int *p;
55 p = (unsigned int*)&fpa11->fpreg[Fn].fExtended;
56 fpa11->fType[Fn] = typeExtended;
57 get_user(p[0], &pMem[0]); /* sign & exponent */
58 get_user(p[1], &pMem[2]); /* ls bits */
59 get_user(p[2], &pMem[1]); /* ms bits */
60}
61
62static inline
63void loadMultiple(const unsigned int Fn,const unsigned int *pMem)
64{
65 FPA11 *fpa11 = GET_FPA11();
66 register unsigned int *p;
67 unsigned long x;
68
69 p = (unsigned int*)&(fpa11->fpreg[Fn]);
70 get_user(x, &pMem[0]);
71 fpa11->fType[Fn] = (x >> 14) & 0x00000003;
72
73 switch (fpa11->fType[Fn])
74 {
75 case typeSingle:
76 case typeDouble:
77 {
78 get_user(p[0], &pMem[2]); /* Single */
79 get_user(p[1], &pMem[1]); /* double msw */
80 p[2] = 0; /* empty */
81 }
82 break;
83
84 case typeExtended:
85 {
86 get_user(p[1], &pMem[2]);
87 get_user(p[2], &pMem[1]); /* msw */
88 p[0] = (x & 0x80003fff);
89 }
90 break;
91 }
92}
93
94static inline
95void storeSingle(const unsigned int Fn,unsigned int *pMem)
96{
97 FPA11 *fpa11 = GET_FPA11();
98 union
99 {
100 float32 f;
101 unsigned int i[1];
102 } val;
103
104 switch (fpa11->fType[Fn])
105 {
106 case typeDouble:
107 val.f = float64_to_float32(fpa11->fpreg[Fn].fDouble);
108 break;
109
110 case typeExtended:
111 val.f = floatx80_to_float32(fpa11->fpreg[Fn].fExtended);
112 break;
113
114 default: val.f = fpa11->fpreg[Fn].fSingle;
115 }
116
117 put_user(val.i[0], pMem);
118}
119
120static inline
121void storeDouble(const unsigned int Fn,unsigned int *pMem)
122{
123 FPA11 *fpa11 = GET_FPA11();
124 union
125 {
126 float64 f;
127 unsigned int i[2];
128 } val;
129
130 switch (fpa11->fType[Fn])
131 {
132 case typeSingle:
133 val.f = float32_to_float64(fpa11->fpreg[Fn].fSingle);
134 break;
135
136 case typeExtended:
137 val.f = floatx80_to_float64(fpa11->fpreg[Fn].fExtended);
138 break;
139
140 default: val.f = fpa11->fpreg[Fn].fDouble;
141 }
142
143 put_user(val.i[1], &pMem[0]); /* msw */
144 put_user(val.i[0], &pMem[1]); /* lsw */
145}
146
147static inline
148void storeExtended(const unsigned int Fn,unsigned int *pMem)
149{
150 FPA11 *fpa11 = GET_FPA11();
151 union
152 {
153 floatx80 f;
154 unsigned int i[3];
155 } val;
156
157 switch (fpa11->fType[Fn])
158 {
159 case typeSingle:
160 val.f = float32_to_floatx80(fpa11->fpreg[Fn].fSingle);
161 break;
162
163 case typeDouble:
164 val.f = float64_to_floatx80(fpa11->fpreg[Fn].fDouble);
165 break;
166
167 default: val.f = fpa11->fpreg[Fn].fExtended;
168 }
169
170 put_user(val.i[0], &pMem[0]); /* sign & exp */
171 put_user(val.i[1], &pMem[2]);
172 put_user(val.i[2], &pMem[1]); /* msw */
173}
174
175static inline
176void storeMultiple(const unsigned int Fn,unsigned int *pMem)
177{
178 FPA11 *fpa11 = GET_FPA11();
179 register unsigned int nType, *p;
180
181 p = (unsigned int*)&(fpa11->fpreg[Fn]);
182 nType = fpa11->fType[Fn];
183
184 switch (nType)
185 {
186 case typeSingle:
187 case typeDouble:
188 {
189 put_user(p[0], &pMem[2]); /* single */
190 put_user(p[1], &pMem[1]); /* double msw */
191 put_user(nType << 14, &pMem[0]);
192 }
193 break;
194
195 case typeExtended:
196 {
197 put_user(p[2], &pMem[1]); /* msw */
198 put_user(p[1], &pMem[2]);
199 put_user((p[0] & 0x80003fff) | (nType << 14), &pMem[0]);
200 }
201 break;
202 }
203}
204
205unsigned int PerformLDF(const unsigned int opcode)
206{
207 unsigned int *pBase, *pAddress, *pFinal, nRc = 1,
208 write_back = WRITE_BACK(opcode);
209
210 //printk("PerformLDF(0x%08x), Fd = 0x%08x\n",opcode,getFd(opcode));
211
212 pBase = (unsigned int*)readRegister(getRn(opcode));
213 if (REG_PC == getRn(opcode))
214 {
215 pBase += 2;
216 write_back = 0;
217 }
218
219 pFinal = pBase;
220 if (BIT_UP_SET(opcode))
221 pFinal += getOffset(opcode);
222 else
223 pFinal -= getOffset(opcode);
224
225 if (PREINDEXED(opcode)) pAddress = pFinal; else pAddress = pBase;
226
227 switch (opcode & MASK_TRANSFER_LENGTH)
228 {
229 case TRANSFER_SINGLE : loadSingle(getFd(opcode),pAddress); break;
230 case TRANSFER_DOUBLE : loadDouble(getFd(opcode),pAddress); break;
231 case TRANSFER_EXTENDED: loadExtended(getFd(opcode),pAddress); break;
232 default: nRc = 0;
233 }
234
235 if (write_back) writeRegister(getRn(opcode),(unsigned int)pFinal);
236 return nRc;
237}
238
239unsigned int PerformSTF(const unsigned int opcode)
240{
241 unsigned int *pBase, *pAddress, *pFinal, nRc = 1,
242 write_back = WRITE_BACK(opcode);
243
244 //printk("PerformSTF(0x%08x), Fd = 0x%08x\n",opcode,getFd(opcode));
245 SetRoundingMode(ROUND_TO_NEAREST);
246
247 pBase = (unsigned int*)readRegister(getRn(opcode));
248 if (REG_PC == getRn(opcode))
249 {
250 pBase += 2;
251 write_back = 0;
252 }
253
254 pFinal = pBase;
255 if (BIT_UP_SET(opcode))
256 pFinal += getOffset(opcode);
257 else
258 pFinal -= getOffset(opcode);
259
260 if (PREINDEXED(opcode)) pAddress = pFinal; else pAddress = pBase;
261
262 switch (opcode & MASK_TRANSFER_LENGTH)
263 {
264 case TRANSFER_SINGLE : storeSingle(getFd(opcode),pAddress); break;
265 case TRANSFER_DOUBLE : storeDouble(getFd(opcode),pAddress); break;
266 case TRANSFER_EXTENDED: storeExtended(getFd(opcode),pAddress); break;
267 default: nRc = 0;
268 }
269
270 if (write_back) writeRegister(getRn(opcode),(unsigned int)pFinal);
271 return nRc;
272}
273
274unsigned int PerformLFM(const unsigned int opcode)
275{
276 unsigned int i, Fd, *pBase, *pAddress, *pFinal,
277 write_back = WRITE_BACK(opcode);
278
279 pBase = (unsigned int*)readRegister(getRn(opcode));
280 if (REG_PC == getRn(opcode))
281 {
282 pBase += 2;
283 write_back = 0;
284 }
285
286 pFinal = pBase;
287 if (BIT_UP_SET(opcode))
288 pFinal += getOffset(opcode);
289 else
290 pFinal -= getOffset(opcode);
291
292 if (PREINDEXED(opcode)) pAddress = pFinal; else pAddress = pBase;
293
294 Fd = getFd(opcode);
295 for (i=getRegisterCount(opcode);i>0;i--)
296 {
297 loadMultiple(Fd,pAddress);
298 pAddress += 3; Fd++;
299 if (Fd == 8) Fd = 0;
300 }
301
302 if (write_back) writeRegister(getRn(opcode),(unsigned int)pFinal);
303 return 1;
304}
305
306unsigned int PerformSFM(const unsigned int opcode)
307{
308 unsigned int i, Fd, *pBase, *pAddress, *pFinal,
309 write_back = WRITE_BACK(opcode);
310
311 pBase = (unsigned int*)readRegister(getRn(opcode));
312 if (REG_PC == getRn(opcode))
313 {
314 pBase += 2;
315 write_back = 0;
316 }
317
318 pFinal = pBase;
319 if (BIT_UP_SET(opcode))
320 pFinal += getOffset(opcode);
321 else
322 pFinal -= getOffset(opcode);
323
324 if (PREINDEXED(opcode)) pAddress = pFinal; else pAddress = pBase;
325
326 Fd = getFd(opcode);
327 for (i=getRegisterCount(opcode);i>0;i--)
328 {
329 storeMultiple(Fd,pAddress);
330 pAddress += 3; Fd++;
331 if (Fd == 8) Fd = 0;
332 }
333
334 if (write_back) writeRegister(getRn(opcode),(unsigned int)pFinal);
335 return 1;
336}
337
338#if 1
339unsigned int EmulateCPDT(const unsigned int opcode)
340{
341 unsigned int nRc = 0;
342
343 //printk("EmulateCPDT(0x%08x)\n",opcode);
344
345 if (LDF_OP(opcode))
346 {
347 nRc = PerformLDF(opcode);
348 }
349 else if (LFM_OP(opcode))
350 {
351 nRc = PerformLFM(opcode);
352 }
353 else if (STF_OP(opcode))
354 {
355 nRc = PerformSTF(opcode);
356 }
357 else if (SFM_OP(opcode))
358 {
359 nRc = PerformSFM(opcode);
360 }
361 else
362 {
363 nRc = 0;
364 }
365
366 return nRc;
367}
368#endif
diff --git a/arch/arm26/nwfpe/fpa11_cprt.c b/arch/arm26/nwfpe/fpa11_cprt.c
deleted file mode 100644
index a201076c1f14..000000000000
--- a/arch/arm26/nwfpe/fpa11_cprt.c
+++ /dev/null
@@ -1,289 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4 (c) Philip Blundell, 1999
5
6 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/
22
23#include "fpa11.h"
24#include "milieu.h"
25#include "softfloat.h"
26#include "fpopcode.h"
27#include "fpa11.inl"
28#include "fpmodule.h"
29#include "fpmodule.inl"
30
31extern flag floatx80_is_nan(floatx80);
32extern flag float64_is_nan( float64);
33extern flag float32_is_nan( float32);
34
35void SetRoundingMode(const unsigned int opcode);
36
37unsigned int PerformFLT(const unsigned int opcode);
38unsigned int PerformFIX(const unsigned int opcode);
39
40static unsigned int
41PerformComparison(const unsigned int opcode);
42
43unsigned int EmulateCPRT(const unsigned int opcode)
44{
45 unsigned int nRc = 1;
46
47 //printk("EmulateCPRT(0x%08x)\n",opcode);
48
49 if (opcode & 0x800000)
50 {
51 /* This is some variant of a comparison (PerformComparison will
52 sort out which one). Since most of the other CPRT
53 instructions are oddball cases of some sort or other it makes
54 sense to pull this out into a fast path. */
55 return PerformComparison(opcode);
56 }
57
58 /* Hint to GCC that we'd like a jump table rather than a load of CMPs */
59 switch ((opcode & 0x700000) >> 20)
60 {
61 case FLT_CODE >> 20: nRc = PerformFLT(opcode); break;
62 case FIX_CODE >> 20: nRc = PerformFIX(opcode); break;
63
64 case WFS_CODE >> 20: writeFPSR(readRegister(getRd(opcode))); break;
65 case RFS_CODE >> 20: writeRegister(getRd(opcode),readFPSR()); break;
66
67#if 0 /* We currently have no use for the FPCR, so there's no point
68 in emulating it. */
69 case WFC_CODE >> 20: writeFPCR(readRegister(getRd(opcode)));
70 case RFC_CODE >> 20: writeRegister(getRd(opcode),readFPCR()); break;
71#endif
72
73 default: nRc = 0;
74 }
75
76 return nRc;
77}
78
79unsigned int PerformFLT(const unsigned int opcode)
80{
81 FPA11 *fpa11 = GET_FPA11();
82
83 unsigned int nRc = 1;
84 SetRoundingMode(opcode);
85
86 switch (opcode & MASK_ROUNDING_PRECISION)
87 {
88 case ROUND_SINGLE:
89 {
90 fpa11->fType[getFn(opcode)] = typeSingle;
91 fpa11->fpreg[getFn(opcode)].fSingle =
92 int32_to_float32(readRegister(getRd(opcode)));
93 }
94 break;
95
96 case ROUND_DOUBLE:
97 {
98 fpa11->fType[getFn(opcode)] = typeDouble;
99 fpa11->fpreg[getFn(opcode)].fDouble =
100 int32_to_float64(readRegister(getRd(opcode)));
101 }
102 break;
103
104 case ROUND_EXTENDED:
105 {
106 fpa11->fType[getFn(opcode)] = typeExtended;
107 fpa11->fpreg[getFn(opcode)].fExtended =
108 int32_to_floatx80(readRegister(getRd(opcode)));
109 }
110 break;
111
112 default: nRc = 0;
113 }
114
115 return nRc;
116}
117
118unsigned int PerformFIX(const unsigned int opcode)
119{
120 FPA11 *fpa11 = GET_FPA11();
121 unsigned int nRc = 1;
122 unsigned int Fn = getFm(opcode);
123
124 SetRoundingMode(opcode);
125
126 switch (fpa11->fType[Fn])
127 {
128 case typeSingle:
129 {
130 writeRegister(getRd(opcode),
131 float32_to_int32(fpa11->fpreg[Fn].fSingle));
132 }
133 break;
134
135 case typeDouble:
136 {
137 writeRegister(getRd(opcode),
138 float64_to_int32(fpa11->fpreg[Fn].fDouble));
139 }
140 break;
141
142 case typeExtended:
143 {
144 writeRegister(getRd(opcode),
145 floatx80_to_int32(fpa11->fpreg[Fn].fExtended));
146 }
147 break;
148
149 default: nRc = 0;
150 }
151
152 return nRc;
153}
154
155
156static unsigned int __inline__
157PerformComparisonOperation(floatx80 Fn, floatx80 Fm)
158{
159 unsigned int flags = 0;
160
161 /* test for less than condition */
162 if (floatx80_lt(Fn,Fm))
163 {
164 flags |= CC_NEGATIVE;
165 }
166
167 /* test for equal condition */
168 if (floatx80_eq(Fn,Fm))
169 {
170 flags |= CC_ZERO;
171 }
172
173 /* test for greater than or equal condition */
174 if (floatx80_lt(Fm,Fn))
175 {
176 flags |= CC_CARRY;
177 }
178
179 writeConditionCodes(flags);
180 return 1;
181}
182
183/* This instruction sets the flags N, Z, C, V in the FPSR. */
184
185static unsigned int PerformComparison(const unsigned int opcode)
186{
187 FPA11 *fpa11 = GET_FPA11();
188 unsigned int Fn, Fm;
189 floatx80 rFn, rFm;
190 int e_flag = opcode & 0x400000; /* 1 if CxFE */
191 int n_flag = opcode & 0x200000; /* 1 if CNxx */
192 unsigned int flags = 0;
193
194 //printk("PerformComparison(0x%08x)\n",opcode);
195
196 Fn = getFn(opcode);
197 Fm = getFm(opcode);
198
199 /* Check for unordered condition and convert all operands to 80-bit
200 format.
201 ?? Might be some mileage in avoiding this conversion if possible.
202 Eg, if both operands are 32-bit, detect this and do a 32-bit
203 comparison (cheaper than an 80-bit one). */
204 switch (fpa11->fType[Fn])
205 {
206 case typeSingle:
207 //printk("single.\n");
208 if (float32_is_nan(fpa11->fpreg[Fn].fSingle))
209 goto unordered;
210 rFn = float32_to_floatx80(fpa11->fpreg[Fn].fSingle);
211 break;
212
213 case typeDouble:
214 //printk("double.\n");
215 if (float64_is_nan(fpa11->fpreg[Fn].fDouble))
216 goto unordered;
217 rFn = float64_to_floatx80(fpa11->fpreg[Fn].fDouble);
218 break;
219
220 case typeExtended:
221 //printk("extended.\n");
222 if (floatx80_is_nan(fpa11->fpreg[Fn].fExtended))
223 goto unordered;
224 rFn = fpa11->fpreg[Fn].fExtended;
225 break;
226
227 default: return 0;
228 }
229
230 if (CONSTANT_FM(opcode))
231 {
232 //printk("Fm is a constant: #%d.\n",Fm);
233 rFm = getExtendedConstant(Fm);
234 if (floatx80_is_nan(rFm))
235 goto unordered;
236 }
237 else
238 {
239 //printk("Fm = r%d which contains a ",Fm);
240 switch (fpa11->fType[Fm])
241 {
242 case typeSingle:
243 //printk("single.\n");
244 if (float32_is_nan(fpa11->fpreg[Fm].fSingle))
245 goto unordered;
246 rFm = float32_to_floatx80(fpa11->fpreg[Fm].fSingle);
247 break;
248
249 case typeDouble:
250 //printk("double.\n");
251 if (float64_is_nan(fpa11->fpreg[Fm].fDouble))
252 goto unordered;
253 rFm = float64_to_floatx80(fpa11->fpreg[Fm].fDouble);
254 break;
255
256 case typeExtended:
257 //printk("extended.\n");
258 if (floatx80_is_nan(fpa11->fpreg[Fm].fExtended))
259 goto unordered;
260 rFm = fpa11->fpreg[Fm].fExtended;
261 break;
262
263 default: return 0;
264 }
265 }
266
267 if (n_flag)
268 {
269 rFm.high ^= 0x8000;
270 }
271
272 return PerformComparisonOperation(rFn,rFm);
273
274 unordered:
275 /* ?? The FPA data sheet is pretty vague about this, in particular
276 about whether the non-E comparisons can ever raise exceptions.
277 This implementation is based on a combination of what it says in
278 the data sheet, observation of how the Acorn emulator actually
279 behaves (and how programs expect it to) and guesswork. */
280 flags |= CC_OVERFLOW;
281 flags &= ~(CC_ZERO | CC_NEGATIVE);
282
283 if (BIT_AC & readFPSR()) flags |= CC_CARRY;
284
285 if (e_flag) float_raise(float_flag_invalid);
286
287 writeConditionCodes(flags);
288 return 1;
289}
diff --git a/arch/arm26/nwfpe/fpmodule.c b/arch/arm26/nwfpe/fpmodule.c
deleted file mode 100644
index a8fad92eb44f..000000000000
--- a/arch/arm26/nwfpe/fpmodule.c
+++ /dev/null
@@ -1,180 +0,0 @@
1
2/*
3 NetWinder Floating Point Emulator
4 (c) Rebel.com, 1998-1999
5 (c) Philip Blundell, 1998-1999
6
7 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/
23
24#include "fpa11.h"
25
26#include <linux/module.h>
27#include <linux/version.h>
28
29/* XXX */
30#include <linux/errno.h>
31#include <linux/types.h>
32#include <linux/kernel.h>
33#include <linux/signal.h>
34#include <linux/sched.h>
35#include <linux/init.h>
36/* XXX */
37
38#include "softfloat.h"
39#include "fpopcode.h"
40#include "fpmodule.h"
41#include "fpa11.inl"
42
43/* kernel symbols required for signal handling */
44typedef struct task_struct* PTASK;
45
46#ifdef MODULE
47void fp_send_sig(unsigned long sig, PTASK p, int priv);
48
49MODULE_AUTHOR("Scott Bambrough <scottb@rebel.com>");
50MODULE_DESCRIPTION("NWFPE floating point emulator");
51
52#else
53#define fp_send_sig send_sig
54#define kern_fp_enter fp_enter
55
56extern char fpe_type[];
57#endif
58
59/* kernel function prototypes required */
60void fp_setup(void);
61
62/* external declarations for saved kernel symbols */
63extern void (*kern_fp_enter)(void);
64
65/* Original value of fp_enter from kernel before patched by fpe_init. */
66static void (*orig_fp_enter)(void);
67
68/* forward declarations */
69extern void nwfpe_enter(void);
70
71#ifdef MODULE
72/*
73 * Return 0 if we can be unloaded. This can only happen if
74 * kern_fp_enter is still pointing at nwfpe_enter
75 */
76static int fpe_unload(void)
77{
78 return (kern_fp_enter == nwfpe_enter) ? 0 : 1;
79}
80#endif
81
82static int __init fpe_init(void)
83{
84 if (sizeof(FPA11) > sizeof(union fp_state)) {
85 printk(KERN_ERR "nwfpe: bad structure size\n");
86 return -EINVAL;
87 }
88
89 if (sizeof(FPREG) != 12) {
90 printk(KERN_ERR "nwfpe: bad register size\n");
91 return -EINVAL;
92 }
93
94#ifdef MODULE
95 if (!mod_member_present(&__this_module, can_unload))
96 return -EINVAL;
97 __this_module.can_unload = fpe_unload;
98#else
99 if (fpe_type[0] && strcmp(fpe_type, "nwfpe"))
100 return 0;
101#endif
102
103 /* Display title, version and copyright information. */
104 printk(KERN_WARNING "NetWinder Floating Point Emulator V0.95 "
105 "(c) 1998-1999 Rebel.com\n");
106
107 /* Save pointer to the old FP handler and then patch ourselves in */
108 orig_fp_enter = kern_fp_enter;
109 kern_fp_enter = nwfpe_enter;
110
111 return 0;
112}
113
114static void __exit fpe_exit(void)
115{
116 /* Restore the values we saved earlier. */
117 kern_fp_enter = orig_fp_enter;
118}
119
120/*
121ScottB: November 4, 1998
122
123Moved this function out of softfloat-specialize into fpmodule.c.
124This effectively isolates all the changes required for integrating with the
125Linux kernel into fpmodule.c. Porting to NetBSD should only require modifying
126fpmodule.c to integrate with the NetBSD kernel (I hope!).
127
128[1/1/99: Not quite true any more unfortunately. There is Linux-specific
129code to access data in user space in some other source files at the
130moment (grep for get_user / put_user calls). --philb]
131
132float_exception_flags is a global variable in SoftFloat.
133
134This function is called by the SoftFloat routines to raise a floating
135point exception. We check the trap enable byte in the FPSR, and raise
136a SIGFPE exception if necessary. If not the relevant bits in the
137cumulative exceptions flag byte are set and we return.
138*/
139
140void float_raise(signed char flags)
141{
142 register unsigned int fpsr, cumulativeTraps;
143
144#ifdef CONFIG_DEBUG_USER
145 printk(KERN_DEBUG "NWFPE: %s[%d] takes exception %08x at %p from %08x\n",
146 current->comm, current->pid, flags,
147 __builtin_return_address(0), GET_USERREG()[15]);
148#endif
149
150 /* Keep SoftFloat exception flags up to date. */
151 float_exception_flags |= flags;
152
153 /* Read fpsr and initialize the cumulativeTraps. */
154 fpsr = readFPSR();
155 cumulativeTraps = 0;
156
157 /* For each type of exception, the cumulative trap exception bit is only
158 set if the corresponding trap enable bit is not set. */
159 if ((!(fpsr & BIT_IXE)) && (flags & BIT_IXC))
160 cumulativeTraps |= BIT_IXC;
161 if ((!(fpsr & BIT_UFE)) && (flags & BIT_UFC))
162 cumulativeTraps |= BIT_UFC;
163 if ((!(fpsr & BIT_OFE)) && (flags & BIT_OFC))
164 cumulativeTraps |= BIT_OFC;
165 if ((!(fpsr & BIT_DZE)) && (flags & BIT_DZC))
166 cumulativeTraps |= BIT_DZC;
167 if ((!(fpsr & BIT_IOE)) && (flags & BIT_IOC))
168 cumulativeTraps |= BIT_IOC;
169
170 /* Set the cumulative exceptions flags. */
171 if (cumulativeTraps)
172 writeFPSR(fpsr | cumulativeTraps);
173
174 /* Raise an exception if necessary. */
175 if (fpsr & (flags << 16))
176 fp_send_sig(SIGFPE, current, 1);
177}
178
179module_init(fpe_init);
180module_exit(fpe_exit);
diff --git a/arch/arm26/nwfpe/fpmodule.h b/arch/arm26/nwfpe/fpmodule.h
deleted file mode 100644
index f971ddd60cc1..000000000000
--- a/arch/arm26/nwfpe/fpmodule.h
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.com, 1998-1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#ifndef __FPMODULE_H__
23#define __FPMODULE_H__
24
25
26#define REG_ORIG_R0 16
27#define REG_CPSR 15
28#define REG_PC 15
29#define REG_LR 14
30#define REG_SP 13
31#define REG_IP 12
32#define REG_FP 11
33#define REG_R10 10
34#define REG_R9 9
35#define REG_R9 9
36#define REG_R8 8
37#define REG_R7 7
38#define REG_R6 6
39#define REG_R5 5
40#define REG_R4 4
41#define REG_R3 3
42#define REG_R2 2
43#define REG_R1 1
44#define REG_R0 0
45
46#endif
diff --git a/arch/arm26/nwfpe/fpmodule.inl b/arch/arm26/nwfpe/fpmodule.inl
deleted file mode 100644
index ef228378ffaf..000000000000
--- a/arch/arm26/nwfpe/fpmodule.inl
+++ /dev/null
@@ -1,84 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22extern __inline__
23unsigned int readRegister(const unsigned int nReg)
24{
25 /* Note: The CPU thinks it has dealt with the current instruction. As
26 a result the program counter has been advanced to the next
27 instruction, and points 4 bytes beyond the actual instruction
28 that caused the invalid instruction trap to occur. We adjust
29 for this in this routine. LDF/STF instructions with Rn = PC
30 depend on the PC being correct, as they use PC+8 in their
31 address calculations. */
32 unsigned int *userRegisters = GET_USERREG();
33 unsigned int val = userRegisters[nReg];
34 if (REG_PC == nReg) val -= 4;
35 return val;
36}
37
38extern __inline__
39void writeRegister(const unsigned int nReg, const unsigned int val)
40{
41 unsigned int *userRegisters = GET_USERREG();
42 userRegisters[nReg] = val;
43}
44
45extern __inline__
46unsigned int readCPSR(void)
47{
48 return(readRegister(REG_CPSR));
49}
50
51extern __inline__
52void writeCPSR(const unsigned int val)
53{
54 writeRegister(REG_CPSR,val);
55}
56
57extern __inline__
58unsigned int readConditionCodes(void)
59{
60#ifdef __FPEM_TEST__
61 return(0);
62#else
63 return(readCPSR() & CC_MASK);
64#endif
65}
66
67extern __inline__
68void writeConditionCodes(const unsigned int val)
69{
70 unsigned int *userRegisters = GET_USERREG();
71 unsigned int rval;
72 /*
73 * Operate directly on userRegisters since
74 * the CPSR may be the PC register itself.
75 */
76 rval = userRegisters[REG_CPSR] & ~CC_MASK;
77 userRegisters[REG_CPSR] = rval | (val & CC_MASK);
78}
79
80extern __inline__
81unsigned int readMemoryInt(unsigned int *pMem)
82{
83 return *pMem;
84}
diff --git a/arch/arm26/nwfpe/fpopcode.c b/arch/arm26/nwfpe/fpopcode.c
deleted file mode 100644
index d81ddd188322..000000000000
--- a/arch/arm26/nwfpe/fpopcode.c
+++ /dev/null
@@ -1,148 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include "fpa11.h"
23#include "softfloat.h"
24#include "fpopcode.h"
25#include "fpsr.h"
26#include "fpmodule.h"
27#include "fpmodule.inl"
28
29const floatx80 floatx80Constant[] = {
30 { 0x0000, 0x0000000000000000ULL}, /* extended 0.0 */
31 { 0x3fff, 0x8000000000000000ULL}, /* extended 1.0 */
32 { 0x4000, 0x8000000000000000ULL}, /* extended 2.0 */
33 { 0x4000, 0xc000000000000000ULL}, /* extended 3.0 */
34 { 0x4001, 0x8000000000000000ULL}, /* extended 4.0 */
35 { 0x4001, 0xa000000000000000ULL}, /* extended 5.0 */
36 { 0x3ffe, 0x8000000000000000ULL}, /* extended 0.5 */
37 { 0x4002, 0xa000000000000000ULL} /* extended 10.0 */
38};
39
40const float64 float64Constant[] = {
41 0x0000000000000000ULL, /* double 0.0 */
42 0x3ff0000000000000ULL, /* double 1.0 */
43 0x4000000000000000ULL, /* double 2.0 */
44 0x4008000000000000ULL, /* double 3.0 */
45 0x4010000000000000ULL, /* double 4.0 */
46 0x4014000000000000ULL, /* double 5.0 */
47 0x3fe0000000000000ULL, /* double 0.5 */
48 0x4024000000000000ULL /* double 10.0 */
49};
50
51const float32 float32Constant[] = {
52 0x00000000, /* single 0.0 */
53 0x3f800000, /* single 1.0 */
54 0x40000000, /* single 2.0 */
55 0x40400000, /* single 3.0 */
56 0x40800000, /* single 4.0 */
57 0x40a00000, /* single 5.0 */
58 0x3f000000, /* single 0.5 */
59 0x41200000 /* single 10.0 */
60};
61
62unsigned int getTransferLength(const unsigned int opcode)
63{
64 unsigned int nRc;
65
66 switch (opcode & MASK_TRANSFER_LENGTH)
67 {
68 case 0x00000000: nRc = 1; break; /* single precision */
69 case 0x00008000: nRc = 2; break; /* double precision */
70 case 0x00400000: nRc = 3; break; /* extended precision */
71 default: nRc = 0;
72 }
73
74 return(nRc);
75}
76
77unsigned int getRegisterCount(const unsigned int opcode)
78{
79 unsigned int nRc;
80
81 switch (opcode & MASK_REGISTER_COUNT)
82 {
83 case 0x00000000: nRc = 4; break;
84 case 0x00008000: nRc = 1; break;
85 case 0x00400000: nRc = 2; break;
86 case 0x00408000: nRc = 3; break;
87 default: nRc = 0;
88 }
89
90 return(nRc);
91}
92
93unsigned int getRoundingPrecision(const unsigned int opcode)
94{
95 unsigned int nRc;
96
97 switch (opcode & MASK_ROUNDING_PRECISION)
98 {
99 case 0x00000000: nRc = 1; break;
100 case 0x00000080: nRc = 2; break;
101 case 0x00080000: nRc = 3; break;
102 default: nRc = 0;
103 }
104
105 return(nRc);
106}
107
108unsigned int getDestinationSize(const unsigned int opcode)
109{
110 unsigned int nRc;
111
112 switch (opcode & MASK_DESTINATION_SIZE)
113 {
114 case 0x00000000: nRc = typeSingle; break;
115 case 0x00000080: nRc = typeDouble; break;
116 case 0x00080000: nRc = typeExtended; break;
117 default: nRc = typeNone;
118 }
119
120 return(nRc);
121}
122
123/* condition code lookup table
124 index into the table is test code: EQ, NE, ... LT, GT, AL, NV
125 bit position in short is condition code: NZCV */
126static const unsigned short aCC[16] = {
127 0xF0F0, // EQ == Z set
128 0x0F0F, // NE
129 0xCCCC, // CS == C set
130 0x3333, // CC
131 0xFF00, // MI == N set
132 0x00FF, // PL
133 0xAAAA, // VS == V set
134 0x5555, // VC
135 0x0C0C, // HI == C set && Z clear
136 0xF3F3, // LS == C clear || Z set
137 0xAA55, // GE == (N==V)
138 0x55AA, // LT == (N!=V)
139 0x0A05, // GT == (!Z && (N==V))
140 0xF5FA, // LE == (Z || (N!=V))
141 0xFFFF, // AL always
142 0 // NV
143};
144
145unsigned int checkCondition(const unsigned int opcode, const unsigned int ccodes)
146{
147 return (aCC[opcode>>28] >> (ccodes>>28)) & 1;
148}
diff --git a/arch/arm26/nwfpe/fpopcode.h b/arch/arm26/nwfpe/fpopcode.h
deleted file mode 100644
index 13c7419262ab..000000000000
--- a/arch/arm26/nwfpe/fpopcode.h
+++ /dev/null
@@ -1,390 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#ifndef __FPOPCODE_H__
23#define __FPOPCODE_H__
24
25/*
26ARM Floating Point Instruction Classes
27| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
28|c o n d|1 1 0 P|U|u|W|L| Rn |v| Fd |0|0|0|1| o f f s e t | CPDT
29|c o n d|1 1 0 P|U|w|W|L| Rn |x| Fd |0|0|0|1| o f f s e t | CPDT
30| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
31|c o n d|1 1 1 0|a|b|c|d|e| Fn |j| Fd |0|0|0|1|f|g|h|0|i| Fm | CPDO
32|c o n d|1 1 1 0|a|b|c|L|e| Fn | Rd |0|0|0|1|f|g|h|1|i| Fm | CPRT
33|c o n d|1 1 1 0|a|b|c|1|e| Fn |1|1|1|1|0|0|0|1|f|g|h|1|i| Fm | comparisons
34| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
35
36CPDT data transfer instructions
37 LDF, STF, LFM, SFM
38
39CPDO dyadic arithmetic instructions
40 ADF, MUF, SUF, RSF, DVF, RDF,
41 POW, RPW, RMF, FML, FDV, FRD, POL
42
43CPDO monadic arithmetic instructions
44 MVF, MNF, ABS, RND, SQT, LOG, LGN, EXP,
45 SIN, COS, TAN, ASN, ACS, ATN, URD, NRM
46
47CPRT joint arithmetic/data transfer instructions
48 FIX (arithmetic followed by load/store)
49 FLT (load/store followed by arithmetic)
50 CMF, CNF CMFE, CNFE (comparisons)
51 WFS, RFS (write/read floating point status register)
52 WFC, RFC (write/read floating point control register)
53
54cond condition codes
55P pre/post index bit: 0 = postindex, 1 = preindex
56U up/down bit: 0 = stack grows down, 1 = stack grows up
57W write back bit: 1 = update base register (Rn)
58L load/store bit: 0 = store, 1 = load
59Rn base register
60Rd destination/source register
61Fd floating point destination register
62Fn floating point source register
63Fm floating point source register or floating point constant
64
65uv transfer length (TABLE 1)
66wx register count (TABLE 2)
67abcd arithmetic opcode (TABLES 3 & 4)
68ef destination size (rounding precision) (TABLE 5)
69gh rounding mode (TABLE 6)
70j dyadic/monadic bit: 0 = dyadic, 1 = monadic
71i constant bit: 1 = constant (TABLE 6)
72*/
73
74/*
75TABLE 1
76+-------------------------+---+---+---------+---------+
77| Precision | u | v | FPSR.EP | length |
78+-------------------------+---+---+---------+---------+
79| Single | 0 ü 0 | x | 1 words |
80| Double | 1 ü 1 | x | 2 words |
81| Extended | 1 ü 1 | x | 3 words |
82| Packed decimal | 1 ü 1 | 0 | 3 words |
83| Expanded packed decimal | 1 ü 1 | 1 | 4 words |
84+-------------------------+---+---+---------+---------+
85Note: x = don't care
86*/
87
88/*
89TABLE 2
90+---+---+---------------------------------+
91| w | x | Number of registers to transfer |
92+---+---+---------------------------------+
93| 0 ü 1 | 1 |
94| 1 ü 0 | 2 |
95| 1 ü 1 | 3 |
96| 0 ü 0 | 4 |
97+---+---+---------------------------------+
98*/
99
100/*
101TABLE 3: Dyadic Floating Point Opcodes
102+---+---+---+---+----------+-----------------------+-----------------------+
103| a | b | c | d | Mnemonic | Description | Operation |
104+---+---+---+---+----------+-----------------------+-----------------------+
105| 0 | 0 | 0 | 0 | ADF | Add | Fd := Fn + Fm |
106| 0 | 0 | 0 | 1 | MUF | Multiply | Fd := Fn * Fm |
107| 0 | 0 | 1 | 0 | SUF | Subtract | Fd := Fn - Fm |
108| 0 | 0 | 1 | 1 | RSF | Reverse subtract | Fd := Fm - Fn |
109| 0 | 1 | 0 | 0 | DVF | Divide | Fd := Fn / Fm |
110| 0 | 1 | 0 | 1 | RDF | Reverse divide | Fd := Fm / Fn |
111| 0 | 1 | 1 | 0 | POW | Power | Fd := Fn ^ Fm |
112| 0 | 1 | 1 | 1 | RPW | Reverse power | Fd := Fm ^ Fn |
113| 1 | 0 | 0 | 0 | RMF | Remainder | Fd := IEEE rem(Fn/Fm) |
114| 1 | 0 | 0 | 1 | FML | Fast Multiply | Fd := Fn * Fm |
115| 1 | 0 | 1 | 0 | FDV | Fast Divide | Fd := Fn / Fm |
116| 1 | 0 | 1 | 1 | FRD | Fast reverse divide | Fd := Fm / Fn |
117| 1 | 1 | 0 | 0 | POL | Polar angle (ArcTan2) | Fd := arctan2(Fn,Fm) |
118| 1 | 1 | 0 | 1 | | undefined instruction | trap |
119| 1 | 1 | 1 | 0 | | undefined instruction | trap |
120| 1 | 1 | 1 | 1 | | undefined instruction | trap |
121+---+---+---+---+----------+-----------------------+-----------------------+
122Note: POW, RPW, POL are deprecated, and are available for backwards
123 compatibility only.
124*/
125
126/*
127TABLE 4: Monadic Floating Point Opcodes
128+---+---+---+---+----------+-----------------------+-----------------------+
129| a | b | c | d | Mnemonic | Description | Operation |
130+---+---+---+---+----------+-----------------------+-----------------------+
131| 0 | 0 | 0 | 0 | MVF | Move | Fd := Fm |
132| 0 | 0 | 0 | 1 | MNF | Move negated | Fd := - Fm |
133| 0 | 0 | 1 | 0 | ABS | Absolute value | Fd := abs(Fm) |
134| 0 | 0 | 1 | 1 | RND | Round to integer | Fd := int(Fm) |
135| 0 | 1 | 0 | 0 | SQT | Square root | Fd := sqrt(Fm) |
136| 0 | 1 | 0 | 1 | LOG | Log base 10 | Fd := log10(Fm) |
137| 0 | 1 | 1 | 0 | LGN | Log base e | Fd := ln(Fm) |
138| 0 | 1 | 1 | 1 | EXP | Exponent | Fd := e ^ Fm |
139| 1 | 0 | 0 | 0 | SIN | Sine | Fd := sin(Fm) |
140| 1 | 0 | 0 | 1 | COS | Cosine | Fd := cos(Fm) |
141| 1 | 0 | 1 | 0 | TAN | Tangent | Fd := tan(Fm) |
142| 1 | 0 | 1 | 1 | ASN | Arc Sine | Fd := arcsin(Fm) |
143| 1 | 1 | 0 | 0 | ACS | Arc Cosine | Fd := arccos(Fm) |
144| 1 | 1 | 0 | 1 | ATN | Arc Tangent | Fd := arctan(Fm) |
145| 1 | 1 | 1 | 0 | URD | Unnormalized round | Fd := int(Fm) |
146| 1 | 1 | 1 | 1 | NRM | Normalize | Fd := norm(Fm) |
147+---+---+---+---+----------+-----------------------+-----------------------+
148Note: LOG, LGN, EXP, SIN, COS, TAN, ASN, ACS, ATN are deprecated, and are
149 available for backwards compatibility only.
150*/
151
152/*
153TABLE 5
154+-------------------------+---+---+
155| Rounding Precision | e | f |
156+-------------------------+---+---+
157| IEEE Single precision | 0 ü 0 |
158| IEEE Double precision | 0 ü 1 |
159| IEEE Extended precision | 1 ü 0 |
160| undefined (trap) | 1 ü 1 |
161+-------------------------+---+---+
162*/
163
164/*
165TABLE 5
166+---------------------------------+---+---+
167| Rounding Mode | g | h |
168+---------------------------------+---+---+
169| Round to nearest (default) | 0 ü 0 |
170| Round toward plus infinity | 0 ü 1 |
171| Round toward negative infinity | 1 ü 0 |
172| Round toward zero | 1 ü 1 |
173+---------------------------------+---+---+
174*/
175
176/*
177===
178=== Definitions for load and store instructions
179===
180*/
181
182/* bit masks */
183#define BIT_PREINDEX 0x01000000
184#define BIT_UP 0x00800000
185#define BIT_WRITE_BACK 0x00200000
186#define BIT_LOAD 0x00100000
187
188/* masks for load/store */
189#define MASK_CPDT 0x0c000000 /* data processing opcode */
190#define MASK_OFFSET 0x000000ff
191#define MASK_TRANSFER_LENGTH 0x00408000
192#define MASK_REGISTER_COUNT MASK_TRANSFER_LENGTH
193#define MASK_COPROCESSOR 0x00000f00
194
195/* Tests for transfer length */
196#define TRANSFER_SINGLE 0x00000000
197#define TRANSFER_DOUBLE 0x00008000
198#define TRANSFER_EXTENDED 0x00400000
199#define TRANSFER_PACKED MASK_TRANSFER_LENGTH
200
201/* Get the coprocessor number from the opcode. */
202#define getCoprocessorNumber(opcode) ((opcode & MASK_COPROCESSOR) >> 8)
203
204/* Get the offset from the opcode. */
205#define getOffset(opcode) (opcode & MASK_OFFSET)
206
207/* Tests for specific data transfer load/store opcodes. */
208#define TEST_OPCODE(opcode,mask) (((opcode) & (mask)) == (mask))
209
210#define LOAD_OP(opcode) TEST_OPCODE((opcode),MASK_CPDT | BIT_LOAD)
211#define STORE_OP(opcode) ((opcode & (MASK_CPDT | BIT_LOAD)) == MASK_CPDT)
212
213#define LDF_OP(opcode) (LOAD_OP(opcode) && (getCoprocessorNumber(opcode) == 1))
214#define LFM_OP(opcode) (LOAD_OP(opcode) && (getCoprocessorNumber(opcode) == 2))
215#define STF_OP(opcode) (STORE_OP(opcode) && (getCoprocessorNumber(opcode) == 1))
216#define SFM_OP(opcode) (STORE_OP(opcode) && (getCoprocessorNumber(opcode) == 2))
217
218#define PREINDEXED(opcode) ((opcode & BIT_PREINDEX) != 0)
219#define POSTINDEXED(opcode) ((opcode & BIT_PREINDEX) == 0)
220#define BIT_UP_SET(opcode) ((opcode & BIT_UP) != 0)
221#define BIT_UP_CLEAR(opcode) ((opcode & BIT_DOWN) == 0)
222#define WRITE_BACK(opcode) ((opcode & BIT_WRITE_BACK) != 0)
223#define LOAD(opcode) ((opcode & BIT_LOAD) != 0)
224#define STORE(opcode) ((opcode & BIT_LOAD) == 0)
225
226/*
227===
228=== Definitions for arithmetic instructions
229===
230*/
231/* bit masks */
232#define BIT_MONADIC 0x00008000
233#define BIT_CONSTANT 0x00000008
234
235#define CONSTANT_FM(opcode) ((opcode & BIT_CONSTANT) != 0)
236#define MONADIC_INSTRUCTION(opcode) ((opcode & BIT_MONADIC) != 0)
237
238/* instruction identification masks */
239#define MASK_CPDO 0x0e000000 /* arithmetic opcode */
240#define MASK_ARITHMETIC_OPCODE 0x00f08000
241#define MASK_DESTINATION_SIZE 0x00080080
242
243/* dyadic arithmetic opcodes. */
244#define ADF_CODE 0x00000000
245#define MUF_CODE 0x00100000
246#define SUF_CODE 0x00200000
247#define RSF_CODE 0x00300000
248#define DVF_CODE 0x00400000
249#define RDF_CODE 0x00500000
250#define POW_CODE 0x00600000
251#define RPW_CODE 0x00700000
252#define RMF_CODE 0x00800000
253#define FML_CODE 0x00900000
254#define FDV_CODE 0x00a00000
255#define FRD_CODE 0x00b00000
256#define POL_CODE 0x00c00000
257/* 0x00d00000 is an invalid dyadic arithmetic opcode */
258/* 0x00e00000 is an invalid dyadic arithmetic opcode */
259/* 0x00f00000 is an invalid dyadic arithmetic opcode */
260
261/* monadic arithmetic opcodes. */
262#define MVF_CODE 0x00008000
263#define MNF_CODE 0x00108000
264#define ABS_CODE 0x00208000
265#define RND_CODE 0x00308000
266#define SQT_CODE 0x00408000
267#define LOG_CODE 0x00508000
268#define LGN_CODE 0x00608000
269#define EXP_CODE 0x00708000
270#define SIN_CODE 0x00808000
271#define COS_CODE 0x00908000
272#define TAN_CODE 0x00a08000
273#define ASN_CODE 0x00b08000
274#define ACS_CODE 0x00c08000
275#define ATN_CODE 0x00d08000
276#define URD_CODE 0x00e08000
277#define NRM_CODE 0x00f08000
278
279/*
280===
281=== Definitions for register transfer and comparison instructions
282===
283*/
284
285#define MASK_CPRT 0x0e000010 /* register transfer opcode */
286#define MASK_CPRT_CODE 0x00f00000
287#define FLT_CODE 0x00000000
288#define FIX_CODE 0x00100000
289#define WFS_CODE 0x00200000
290#define RFS_CODE 0x00300000
291#define WFC_CODE 0x00400000
292#define RFC_CODE 0x00500000
293#define CMF_CODE 0x00900000
294#define CNF_CODE 0x00b00000
295#define CMFE_CODE 0x00d00000
296#define CNFE_CODE 0x00f00000
297
298/*
299===
300=== Common definitions
301===
302*/
303
304/* register masks */
305#define MASK_Rd 0x0000f000
306#define MASK_Rn 0x000f0000
307#define MASK_Fd 0x00007000
308#define MASK_Fm 0x00000007
309#define MASK_Fn 0x00070000
310
311/* condition code masks */
312#define CC_MASK 0xf0000000
313#define CC_NEGATIVE 0x80000000
314#define CC_ZERO 0x40000000
315#define CC_CARRY 0x20000000
316#define CC_OVERFLOW 0x10000000
317#define CC_EQ 0x00000000
318#define CC_NE 0x10000000
319#define CC_CS 0x20000000
320#define CC_HS CC_CS
321#define CC_CC 0x30000000
322#define CC_LO CC_CC
323#define CC_MI 0x40000000
324#define CC_PL 0x50000000
325#define CC_VS 0x60000000
326#define CC_VC 0x70000000
327#define CC_HI 0x80000000
328#define CC_LS 0x90000000
329#define CC_GE 0xa0000000
330#define CC_LT 0xb0000000
331#define CC_GT 0xc0000000
332#define CC_LE 0xd0000000
333#define CC_AL 0xe0000000
334#define CC_NV 0xf0000000
335
336/* rounding masks/values */
337#define MASK_ROUNDING_MODE 0x00000060
338#define ROUND_TO_NEAREST 0x00000000
339#define ROUND_TO_PLUS_INFINITY 0x00000020
340#define ROUND_TO_MINUS_INFINITY 0x00000040
341#define ROUND_TO_ZERO 0x00000060
342
343#define MASK_ROUNDING_PRECISION 0x00080080
344#define ROUND_SINGLE 0x00000000
345#define ROUND_DOUBLE 0x00000080
346#define ROUND_EXTENDED 0x00080000
347
348/* Get the condition code from the opcode. */
349#define getCondition(opcode) (opcode >> 28)
350
351/* Get the source register from the opcode. */
352#define getRn(opcode) ((opcode & MASK_Rn) >> 16)
353
354/* Get the destination floating point register from the opcode. */
355#define getFd(opcode) ((opcode & MASK_Fd) >> 12)
356
357/* Get the first source floating point register from the opcode. */
358#define getFn(opcode) ((opcode & MASK_Fn) >> 16)
359
360/* Get the second source floating point register from the opcode. */
361#define getFm(opcode) (opcode & MASK_Fm)
362
363/* Get the destination register from the opcode. */
364#define getRd(opcode) ((opcode & MASK_Rd) >> 12)
365
366/* Get the rounding mode from the opcode. */
367#define getRoundingMode(opcode) ((opcode & MASK_ROUNDING_MODE) >> 5)
368
369static inline const floatx80 getExtendedConstant(const unsigned int nIndex)
370{
371 extern const floatx80 floatx80Constant[];
372 return floatx80Constant[nIndex];
373}
374
375static inline const float64 getDoubleConstant(const unsigned int nIndex)
376{
377 extern const float64 float64Constant[];
378 return float64Constant[nIndex];
379}
380
381static inline const float32 getSingleConstant(const unsigned int nIndex)
382{
383 extern const float32 float32Constant[];
384 return float32Constant[nIndex];
385}
386
387extern unsigned int getRegisterCount(const unsigned int opcode);
388extern unsigned int getDestinationSize(const unsigned int opcode);
389
390#endif
diff --git a/arch/arm26/nwfpe/fpsr.h b/arch/arm26/nwfpe/fpsr.h
deleted file mode 100644
index 6dafb0f5243c..000000000000
--- a/arch/arm26/nwfpe/fpsr.h
+++ /dev/null
@@ -1,108 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.com, 1998-1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#ifndef __FPSR_H__
23#define __FPSR_H__
24
25/*
26The FPSR is a 32 bit register consisting of 4 parts, each exactly
27one byte.
28
29 SYSTEM ID
30 EXCEPTION TRAP ENABLE BYTE
31 SYSTEM CONTROL BYTE
32 CUMULATIVE EXCEPTION FLAGS BYTE
33
34The FPCR is a 32 bit register consisting of bit flags.
35*/
36
37/* SYSTEM ID
38------------
39Note: the system id byte is read only */
40
41typedef unsigned int FPSR; /* type for floating point status register */
42typedef unsigned int FPCR; /* type for floating point control register */
43
44#define MASK_SYSID 0xff000000
45#define BIT_HARDWARE 0x80000000
46#define FP_EMULATOR 0x01000000 /* System ID for emulator */
47#define FP_ACCELERATOR 0x81000000 /* System ID for FPA11 */
48
49/* EXCEPTION TRAP ENABLE BYTE
50----------------------------- */
51
52#define MASK_TRAP_ENABLE 0x00ff0000
53#define MASK_TRAP_ENABLE_STRICT 0x001f0000
54#define BIT_IXE 0x00100000 /* inexact exception enable */
55#define BIT_UFE 0x00080000 /* underflow exception enable */
56#define BIT_OFE 0x00040000 /* overflow exception enable */
57#define BIT_DZE 0x00020000 /* divide by zero exception enable */
58#define BIT_IOE 0x00010000 /* invalid operation exception enable */
59
60/* SYSTEM CONTROL BYTE
61---------------------- */
62
63#define MASK_SYSTEM_CONTROL 0x0000ff00
64#define MASK_TRAP_STRICT 0x00001f00
65
66#define BIT_AC 0x00001000 /* use alternative C-flag definition
67 for compares */
68#define BIT_EP 0x00000800 /* use expanded packed decimal format */
69#define BIT_SO 0x00000400 /* select synchronous operation of FPA */
70#define BIT_NE 0x00000200 /* NaN exception bit */
71#define BIT_ND 0x00000100 /* no denormalized numbers bit */
72
73/* CUMULATIVE EXCEPTION FLAGS BYTE
74---------------------------------- */
75
76#define MASK_EXCEPTION_FLAGS 0x000000ff
77#define MASK_EXCEPTION_FLAGS_STRICT 0x0000001f
78
79#define BIT_IXC 0x00000010 /* inexact exception flag */
80#define BIT_UFC 0x00000008 /* underflow exception flag */
81#define BIT_OFC 0x00000004 /* overfloat exception flag */
82#define BIT_DZC 0x00000002 /* divide by zero exception flag */
83#define BIT_IOC 0x00000001 /* invalid operation exception flag */
84
85/* Floating Point Control Register
86----------------------------------*/
87
88#define BIT_RU 0x80000000 /* rounded up bit */
89#define BIT_IE 0x10000000 /* inexact bit */
90#define BIT_MO 0x08000000 /* mantissa overflow bit */
91#define BIT_EO 0x04000000 /* exponent overflow bit */
92#define BIT_SB 0x00000800 /* store bounce */
93#define BIT_AB 0x00000400 /* arithmetic bounce */
94#define BIT_RE 0x00000200 /* rounding exception */
95#define BIT_DA 0x00000100 /* disable FPA */
96
97#define MASK_OP 0x00f08010 /* AU operation code */
98#define MASK_PR 0x00080080 /* AU precision */
99#define MASK_S1 0x00070000 /* AU source register 1 */
100#define MASK_S2 0x00000007 /* AU source register 2 */
101#define MASK_DS 0x00007000 /* AU destination register */
102#define MASK_RM 0x00000060 /* AU rounding mode */
103#define MASK_ALU 0x9cfff2ff /* only ALU can write these bits */
104#define MASK_RESET 0x00000d00 /* bits set on reset, all others cleared */
105#define MASK_WFC MASK_RESET
106#define MASK_RFC ~MASK_RESET
107
108#endif
diff --git a/arch/arm26/nwfpe/milieu.h b/arch/arm26/nwfpe/milieu.h
deleted file mode 100644
index a3892ab2dca4..000000000000
--- a/arch/arm26/nwfpe/milieu.h
+++ /dev/null
@@ -1,48 +0,0 @@
1
2/*
3===============================================================================
4
5This C header file is part of the SoftFloat IEC/IEEE Floating-point
6Arithmetic Package, Release 2.
7
8Written by John R. Hauser. This work was made possible in part by the
9International Computer Science Institute, located at Suite 600, 1947 Center
10Street, Berkeley, California 94704. Funding was partially provided by the
11National Science Foundation under grant MIP-9311980. The original version
12of this code was written as part of a project to build a fixed-point vector
13processor in collaboration with the University of California at Berkeley,
14overseen by Profs. Nelson Morgan and John Wawrzynek. More information
15is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
16arithmetic/softfloat.html'.
17
18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
20TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
21PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
22AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
23
24Derivative works are acceptable, even for commercial purposes, so long as
25(1) they include prominent notice that the work is derivative, and (2) they
26include prominent notice akin to these three paragraphs for those parts of
27this code that are retained.
28
29===============================================================================
30*/
31
32/*
33-------------------------------------------------------------------------------
34Include common integer types and flags.
35-------------------------------------------------------------------------------
36*/
37#include "ARM-gcc.h"
38
39/*
40-------------------------------------------------------------------------------
41Symbolic Boolean literals.
42-------------------------------------------------------------------------------
43*/
44enum {
45 FALSE = 0,
46 TRUE = 1
47};
48
diff --git a/arch/arm26/nwfpe/single_cpdo.c b/arch/arm26/nwfpe/single_cpdo.c
deleted file mode 100644
index 5cdcddbb8999..000000000000
--- a/arch/arm26/nwfpe/single_cpdo.c
+++ /dev/null
@@ -1,255 +0,0 @@
1/*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
4
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#include "fpa11.h"
23#include "softfloat.h"
24#include "fpopcode.h"
25
26float32 float32_exp(float32 Fm);
27float32 float32_ln(float32 Fm);
28float32 float32_sin(float32 rFm);
29float32 float32_cos(float32 rFm);
30float32 float32_arcsin(float32 rFm);
31float32 float32_arctan(float32 rFm);
32float32 float32_log(float32 rFm);
33float32 float32_tan(float32 rFm);
34float32 float32_arccos(float32 rFm);
35float32 float32_pow(float32 rFn,float32 rFm);
36float32 float32_pol(float32 rFn,float32 rFm);
37
38unsigned int SingleCPDO(const unsigned int opcode)
39{
40 FPA11 *fpa11 = GET_FPA11();
41 float32 rFm, rFn = 0; //FIXME - should be zero?
42 unsigned int Fd, Fm, Fn, nRc = 1;
43
44 Fm = getFm(opcode);
45 if (CONSTANT_FM(opcode))
46 {
47 rFm = getSingleConstant(Fm);
48 }
49 else
50 {
51 switch (fpa11->fType[Fm])
52 {
53 case typeSingle:
54 rFm = fpa11->fpreg[Fm].fSingle;
55 break;
56
57 default: return 0;
58 }
59 }
60
61 if (!MONADIC_INSTRUCTION(opcode))
62 {
63 Fn = getFn(opcode);
64 switch (fpa11->fType[Fn])
65 {
66 case typeSingle:
67 rFn = fpa11->fpreg[Fn].fSingle;
68 break;
69
70 default: return 0;
71 }
72 }
73
74 Fd = getFd(opcode);
75 switch (opcode & MASK_ARITHMETIC_OPCODE)
76 {
77 /* dyadic opcodes */
78 case ADF_CODE:
79 fpa11->fpreg[Fd].fSingle = float32_add(rFn,rFm);
80 break;
81
82 case MUF_CODE:
83 case FML_CODE:
84 fpa11->fpreg[Fd].fSingle = float32_mul(rFn,rFm);
85 break;
86
87 case SUF_CODE:
88 fpa11->fpreg[Fd].fSingle = float32_sub(rFn,rFm);
89 break;
90
91 case RSF_CODE:
92 fpa11->fpreg[Fd].fSingle = float32_sub(rFm,rFn);
93 break;
94
95 case DVF_CODE:
96 case FDV_CODE:
97 fpa11->fpreg[Fd].fSingle = float32_div(rFn,rFm);
98 break;
99
100 case RDF_CODE:
101 case FRD_CODE:
102 fpa11->fpreg[Fd].fSingle = float32_div(rFm,rFn);
103 break;
104
105#if 0
106 case POW_CODE:
107 fpa11->fpreg[Fd].fSingle = float32_pow(rFn,rFm);
108 break;
109
110 case RPW_CODE:
111 fpa11->fpreg[Fd].fSingle = float32_pow(rFm,rFn);
112 break;
113#endif
114
115 case RMF_CODE:
116 fpa11->fpreg[Fd].fSingle = float32_rem(rFn,rFm);
117 break;
118
119#if 0
120 case POL_CODE:
121 fpa11->fpreg[Fd].fSingle = float32_pol(rFn,rFm);
122 break;
123#endif
124
125 /* monadic opcodes */
126 case MVF_CODE:
127 fpa11->fpreg[Fd].fSingle = rFm;
128 break;
129
130 case MNF_CODE:
131 rFm ^= 0x80000000;
132 fpa11->fpreg[Fd].fSingle = rFm;
133 break;
134
135 case ABS_CODE:
136 rFm &= 0x7fffffff;
137 fpa11->fpreg[Fd].fSingle = rFm;
138 break;
139
140 case RND_CODE:
141 case URD_CODE:
142 fpa11->fpreg[Fd].fSingle = float32_round_to_int(rFm);
143 break;
144
145 case SQT_CODE:
146 fpa11->fpreg[Fd].fSingle = float32_sqrt(rFm);
147 break;
148
149#if 0
150 case LOG_CODE:
151 fpa11->fpreg[Fd].fSingle = float32_log(rFm);
152 break;
153
154 case LGN_CODE:
155 fpa11->fpreg[Fd].fSingle = float32_ln(rFm);
156 break;
157
158 case EXP_CODE:
159 fpa11->fpreg[Fd].fSingle = float32_exp(rFm);
160 break;
161
162 case SIN_CODE:
163 fpa11->fpreg[Fd].fSingle = float32_sin(rFm);
164 break;
165
166 case COS_CODE:
167 fpa11->fpreg[Fd].fSingle = float32_cos(rFm);
168 break;
169
170 case TAN_CODE:
171 fpa11->fpreg[Fd].fSingle = float32_tan(rFm);
172 break;
173
174 case ASN_CODE:
175 fpa11->fpreg[Fd].fSingle = float32_arcsin(rFm);
176 break;
177
178 case ACS_CODE:
179 fpa11->fpreg[Fd].fSingle = float32_arccos(rFm);
180 break;
181
182 case ATN_CODE:
183 fpa11->fpreg[Fd].fSingle = float32_arctan(rFm);
184 break;
185#endif
186
187 case NRM_CODE:
188 break;
189
190 default:
191 {
192 nRc = 0;
193 }
194 }
195
196 if (0 != nRc) fpa11->fType[Fd] = typeSingle;
197 return nRc;
198}
199
200#if 0
201float32 float32_exp(float32 Fm)
202{
203//series
204}
205
206float32 float32_ln(float32 Fm)
207{
208//series
209}
210
211float32 float32_sin(float32 rFm)
212{
213//series
214}
215
216float32 float32_cos(float32 rFm)
217{
218//series
219}
220
221float32 float32_arcsin(float32 rFm)
222{
223//series
224}
225
226float32 float32_arctan(float32 rFm)
227{
228 //series
229}
230
231float32 float32_arccos(float32 rFm)
232{
233 //return float32_sub(halfPi,float32_arcsin(rFm));
234}
235
236float32 float32_log(float32 rFm)
237{
238 return float32_div(float32_ln(rFm),getSingleConstant(7));
239}
240
241float32 float32_tan(float32 rFm)
242{
243 return float32_div(float32_sin(rFm),float32_cos(rFm));
244}
245
246float32 float32_pow(float32 rFn,float32 rFm)
247{
248 return float32_exp(float32_mul(rFm,float32_ln(rFn)));
249}
250
251float32 float32_pol(float32 rFn,float32 rFm)
252{
253 return float32_arctan(float32_div(rFn,rFm));
254}
255#endif
diff --git a/arch/arm26/nwfpe/softfloat-macros b/arch/arm26/nwfpe/softfloat-macros
deleted file mode 100644
index 5469989f2c5e..000000000000
--- a/arch/arm26/nwfpe/softfloat-macros
+++ /dev/null
@@ -1,740 +0,0 @@
1
2/*
3===============================================================================
4
5This C source fragment is part of the SoftFloat IEC/IEEE Floating-point
6Arithmetic Package, Release 2.
7
8Written by John R. Hauser. This work was made possible in part by the
9International Computer Science Institute, located at Suite 600, 1947 Center
10Street, Berkeley, California 94704. Funding was partially provided by the
11National Science Foundation under grant MIP-9311980. The original version
12of this code was written as part of a project to build a fixed-point vector
13processor in collaboration with the University of California at Berkeley,
14overseen by Profs. Nelson Morgan and John Wawrzynek. More information
15is available through the web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
16arithmetic/softfloat.html'.
17
18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
20TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
21PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
22AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
23
24Derivative works are acceptable, even for commercial purposes, so long as
25(1) they include prominent notice that the work is derivative, and (2) they
26include prominent notice akin to these three paragraphs for those parts of
27this code that are retained.
28
29===============================================================================
30*/
31
32/*
33-------------------------------------------------------------------------------
34Shifts `a' right by the number of bits given in `count'. If any nonzero
35bits are shifted off, they are ``jammed'' into the least significant bit of
36the result by setting the least significant bit to 1. The value of `count'
37can be arbitrarily large; in particular, if `count' is greater than 32, the
38result will be either 0 or 1, depending on whether `a' is zero or nonzero.
39The result is stored in the location pointed to by `zPtr'.
40-------------------------------------------------------------------------------
41*/
42INLINE void shift32RightJamming( bits32 a, int16 count, bits32 *zPtr )
43{
44 bits32 z;
45 if ( count == 0 ) {
46 z = a;
47 }
48 else if ( count < 32 ) {
49 z = ( a>>count ) | ( ( a<<( ( - count ) & 31 ) ) != 0 );
50 }
51 else {
52 z = ( a != 0 );
53 }
54 *zPtr = z;
55}
56
57/*
58-------------------------------------------------------------------------------
59Shifts `a' right by the number of bits given in `count'. If any nonzero
60bits are shifted off, they are ``jammed'' into the least significant bit of
61the result by setting the least significant bit to 1. The value of `count'
62can be arbitrarily large; in particular, if `count' is greater than 64, the
63result will be either 0 or 1, depending on whether `a' is zero or nonzero.
64The result is stored in the location pointed to by `zPtr'.
65-------------------------------------------------------------------------------
66*/
67INLINE void shift64RightJamming( bits64 a, int16 count, bits64 *zPtr )
68{
69 bits64 z;
70
71 __asm__("@shift64RightJamming -- start");
72 if ( count == 0 ) {
73 z = a;
74 }
75 else if ( count < 64 ) {
76 z = ( a>>count ) | ( ( a<<( ( - count ) & 63 ) ) != 0 );
77 }
78 else {
79 z = ( a != 0 );
80 }
81 __asm__("@shift64RightJamming -- end");
82 *zPtr = z;
83}
84
85/*
86-------------------------------------------------------------------------------
87Shifts the 128-bit value formed by concatenating `a0' and `a1' right by 64
88_plus_ the number of bits given in `count'. The shifted result is at most
8964 nonzero bits; this is stored at the location pointed to by `z0Ptr'. The
90bits shifted off form a second 64-bit result as follows: The _last_ bit
91shifted off is the most-significant bit of the extra result, and the other
9263 bits of the extra result are all zero if and only if _all_but_the_last_
93bits shifted off were all zero. This extra result is stored in the location
94pointed to by `z1Ptr'. The value of `count' can be arbitrarily large.
95 (This routine makes more sense if `a0' and `a1' are considered to form a
96fixed-point value with binary point between `a0' and `a1'. This fixed-point
97value is shifted right by the number of bits given in `count', and the
98integer part of the result is returned at the location pointed to by
99`z0Ptr'. The fractional part of the result may be slightly corrupted as
100described above, and is returned at the location pointed to by `z1Ptr'.)
101-------------------------------------------------------------------------------
102*/
103INLINE void
104 shift64ExtraRightJamming(
105 bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
106{
107 bits64 z0, z1;
108 int8 negCount = ( - count ) & 63;
109
110 if ( count == 0 ) {
111 z1 = a1;
112 z0 = a0;
113 }
114 else if ( count < 64 ) {
115 z1 = ( a0<<negCount ) | ( a1 != 0 );
116 z0 = a0>>count;
117 }
118 else {
119 if ( count == 64 ) {
120 z1 = a0 | ( a1 != 0 );
121 }
122 else {
123 z1 = ( ( a0 | a1 ) != 0 );
124 }
125 z0 = 0;
126 }
127 *z1Ptr = z1;
128 *z0Ptr = z0;
129
130}
131
132/*
133-------------------------------------------------------------------------------
134Shifts the 128-bit value formed by concatenating `a0' and `a1' right by the
135number of bits given in `count'. Any bits shifted off are lost. The value
136of `count' can be arbitrarily large; in particular, if `count' is greater
137than 128, the result will be 0. The result is broken into two 64-bit pieces
138which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
139-------------------------------------------------------------------------------
140*/
141INLINE void
142 shift128Right(
143 bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
144{
145 bits64 z0, z1;
146 int8 negCount = ( - count ) & 63;
147
148 if ( count == 0 ) {
149 z1 = a1;
150 z0 = a0;
151 }
152 else if ( count < 64 ) {
153 z1 = ( a0<<negCount ) | ( a1>>count );
154 z0 = a0>>count;
155 }
156 else {
157 z1 = ( count < 64 ) ? ( a0>>( count & 63 ) ) : 0;
158 z0 = 0;
159 }
160 *z1Ptr = z1;
161 *z0Ptr = z0;
162
163}
164
165/*
166-------------------------------------------------------------------------------
167Shifts the 128-bit value formed by concatenating `a0' and `a1' right by the
168number of bits given in `count'. If any nonzero bits are shifted off, they
169are ``jammed'' into the least significant bit of the result by setting the
170least significant bit to 1. The value of `count' can be arbitrarily large;
171in particular, if `count' is greater than 128, the result will be either 0
172or 1, depending on whether the concatenation of `a0' and `a1' is zero or
173nonzero. The result is broken into two 64-bit pieces which are stored at
174the locations pointed to by `z0Ptr' and `z1Ptr'.
175-------------------------------------------------------------------------------
176*/
177INLINE void
178 shift128RightJamming(
179 bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
180{
181 bits64 z0, z1;
182 int8 negCount = ( - count ) & 63;
183
184 if ( count == 0 ) {
185 z1 = a1;
186 z0 = a0;
187 }
188 else if ( count < 64 ) {
189 z1 = ( a0<<negCount ) | ( a1>>count ) | ( ( a1<<negCount ) != 0 );
190 z0 = a0>>count;
191 }
192 else {
193 if ( count == 64 ) {
194 z1 = a0 | ( a1 != 0 );
195 }
196 else if ( count < 128 ) {
197 z1 = ( a0>>( count & 63 ) ) | ( ( ( a0<<negCount ) | a1 ) != 0 );
198 }
199 else {
200 z1 = ( ( a0 | a1 ) != 0 );
201 }
202 z0 = 0;
203 }
204 *z1Ptr = z1;
205 *z0Ptr = z0;
206
207}
208
209/*
210-------------------------------------------------------------------------------
211Shifts the 192-bit value formed by concatenating `a0', `a1', and `a2' right
212by 64 _plus_ the number of bits given in `count'. The shifted result is
213at most 128 nonzero bits; these are broken into two 64-bit pieces which are
214stored at the locations pointed to by `z0Ptr' and `z1Ptr'. The bits shifted
215off form a third 64-bit result as follows: The _last_ bit shifted off is
216the most-significant bit of the extra result, and the other 63 bits of the
217extra result are all zero if and only if _all_but_the_last_ bits shifted off
218were all zero. This extra result is stored in the location pointed to by
219`z2Ptr'. The value of `count' can be arbitrarily large.
220 (This routine makes more sense if `a0', `a1', and `a2' are considered
221to form a fixed-point value with binary point between `a1' and `a2'. This
222fixed-point value is shifted right by the number of bits given in `count',
223and the integer part of the result is returned at the locations pointed to
224by `z0Ptr' and `z1Ptr'. The fractional part of the result may be slightly
225corrupted as described above, and is returned at the location pointed to by
226`z2Ptr'.)
227-------------------------------------------------------------------------------
228*/
229INLINE void
230 shift128ExtraRightJamming(
231 bits64 a0,
232 bits64 a1,
233 bits64 a2,
234 int16 count,
235 bits64 *z0Ptr,
236 bits64 *z1Ptr,
237 bits64 *z2Ptr
238 )
239{
240 bits64 z0, z1, z2;
241 int8 negCount = ( - count ) & 63;
242
243 if ( count == 0 ) {
244 z2 = a2;
245 z1 = a1;
246 z0 = a0;
247 }
248 else {
249 if ( count < 64 ) {
250 z2 = a1<<negCount;
251 z1 = ( a0<<negCount ) | ( a1>>count );
252 z0 = a0>>count;
253 }
254 else {
255 if ( count == 64 ) {
256 z2 = a1;
257 z1 = a0;
258 }
259 else {
260 a2 |= a1;
261 if ( count < 128 ) {
262 z2 = a0<<negCount;
263 z1 = a0>>( count & 63 );
264 }
265 else {
266 z2 = ( count == 128 ) ? a0 : ( a0 != 0 );
267 z1 = 0;
268 }
269 }
270 z0 = 0;
271 }
272 z2 |= ( a2 != 0 );
273 }
274 *z2Ptr = z2;
275 *z1Ptr = z1;
276 *z0Ptr = z0;
277
278}
279
280/*
281-------------------------------------------------------------------------------
282Shifts the 128-bit value formed by concatenating `a0' and `a1' left by the
283number of bits given in `count'. Any bits shifted off are lost. The value
284of `count' must be less than 64. The result is broken into two 64-bit
285pieces which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
286-------------------------------------------------------------------------------
287*/
288INLINE void
289 shortShift128Left(
290 bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
291{
292
293 *z1Ptr = a1<<count;
294 *z0Ptr =
295 ( count == 0 ) ? a0 : ( a0<<count ) | ( a1>>( ( - count ) & 63 ) );
296
297}
298
299/*
300-------------------------------------------------------------------------------
301Shifts the 192-bit value formed by concatenating `a0', `a1', and `a2' left
302by the number of bits given in `count'. Any bits shifted off are lost.
303The value of `count' must be less than 64. The result is broken into three
30464-bit pieces which are stored at the locations pointed to by `z0Ptr',
305`z1Ptr', and `z2Ptr'.
306-------------------------------------------------------------------------------
307*/
308INLINE void
309 shortShift192Left(
310 bits64 a0,
311 bits64 a1,
312 bits64 a2,
313 int16 count,
314 bits64 *z0Ptr,
315 bits64 *z1Ptr,
316 bits64 *z2Ptr
317 )
318{
319 bits64 z0, z1, z2;
320 int8 negCount;
321
322 z2 = a2<<count;
323 z1 = a1<<count;
324 z0 = a0<<count;
325 if ( 0 < count ) {
326 negCount = ( ( - count ) & 63 );
327 z1 |= a2>>negCount;
328 z0 |= a1>>negCount;
329 }
330 *z2Ptr = z2;
331 *z1Ptr = z1;
332 *z0Ptr = z0;
333
334}
335
336/*
337-------------------------------------------------------------------------------
338Adds the 128-bit value formed by concatenating `a0' and `a1' to the 128-bit
339value formed by concatenating `b0' and `b1'. Addition is modulo 2^128, so
340any carry out is lost. The result is broken into two 64-bit pieces which
341are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
342-------------------------------------------------------------------------------
343*/
344INLINE void
345 add128(
346 bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr )
347{
348 bits64 z1;
349
350 z1 = a1 + b1;
351 *z1Ptr = z1;
352 *z0Ptr = a0 + b0 + ( z1 < a1 );
353
354}
355
356/*
357-------------------------------------------------------------------------------
358Adds the 192-bit value formed by concatenating `a0', `a1', and `a2' to the
359192-bit value formed by concatenating `b0', `b1', and `b2'. Addition is
360modulo 2^192, so any carry out is lost. The result is broken into three
36164-bit pieces which are stored at the locations pointed to by `z0Ptr',
362`z1Ptr', and `z2Ptr'.
363-------------------------------------------------------------------------------
364*/
365INLINE void
366 add192(
367 bits64 a0,
368 bits64 a1,
369 bits64 a2,
370 bits64 b0,
371 bits64 b1,
372 bits64 b2,
373 bits64 *z0Ptr,
374 bits64 *z1Ptr,
375 bits64 *z2Ptr
376 )
377{
378 bits64 z0, z1, z2;
379 int8 carry0, carry1;
380
381 z2 = a2 + b2;
382 carry1 = ( z2 < a2 );
383 z1 = a1 + b1;
384 carry0 = ( z1 < a1 );
385 z0 = a0 + b0;
386 z1 += carry1;
387 z0 += ( z1 < carry1 );
388 z0 += carry0;
389 *z2Ptr = z2;
390 *z1Ptr = z1;
391 *z0Ptr = z0;
392
393}
394
395/*
396-------------------------------------------------------------------------------
397Subtracts the 128-bit value formed by concatenating `b0' and `b1' from the
398128-bit value formed by concatenating `a0' and `a1'. Subtraction is modulo
3992^128, so any borrow out (carry out) is lost. The result is broken into two
40064-bit pieces which are stored at the locations pointed to by `z0Ptr' and
401`z1Ptr'.
402-------------------------------------------------------------------------------
403*/
404INLINE void
405 sub128(
406 bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr )
407{
408
409 *z1Ptr = a1 - b1;
410 *z0Ptr = a0 - b0 - ( a1 < b1 );
411
412}
413
414/*
415-------------------------------------------------------------------------------
416Subtracts the 192-bit value formed by concatenating `b0', `b1', and `b2'
417from the 192-bit value formed by concatenating `a0', `a1', and `a2'.
418Subtraction is modulo 2^192, so any borrow out (carry out) is lost. The
419result is broken into three 64-bit pieces which are stored at the locations
420pointed to by `z0Ptr', `z1Ptr', and `z2Ptr'.
421-------------------------------------------------------------------------------
422*/
423INLINE void
424 sub192(
425 bits64 a0,
426 bits64 a1,
427 bits64 a2,
428 bits64 b0,
429 bits64 b1,
430 bits64 b2,
431 bits64 *z0Ptr,
432 bits64 *z1Ptr,
433 bits64 *z2Ptr
434 )
435{
436 bits64 z0, z1, z2;
437 int8 borrow0, borrow1;
438
439 z2 = a2 - b2;
440 borrow1 = ( a2 < b2 );
441 z1 = a1 - b1;
442 borrow0 = ( a1 < b1 );
443 z0 = a0 - b0;
444 z0 -= ( z1 < borrow1 );
445 z1 -= borrow1;
446 z0 -= borrow0;
447 *z2Ptr = z2;
448 *z1Ptr = z1;
449 *z0Ptr = z0;
450
451}
452
453/*
454-------------------------------------------------------------------------------
455Multiplies `a' by `b' to obtain a 128-bit product. The product is broken
456into two 64-bit pieces which are stored at the locations pointed to by
457`z0Ptr' and `z1Ptr'.
458-------------------------------------------------------------------------------
459*/
460INLINE void mul64To128( bits64 a, bits64 b, bits64 *z0Ptr, bits64 *z1Ptr )
461{
462 bits32 aHigh, aLow, bHigh, bLow;
463 bits64 z0, zMiddleA, zMiddleB, z1;
464
465 aLow = a;
466 aHigh = a>>32;
467 bLow = b;
468 bHigh = b>>32;
469 z1 = ( (bits64) aLow ) * bLow;
470 zMiddleA = ( (bits64) aLow ) * bHigh;
471 zMiddleB = ( (bits64) aHigh ) * bLow;
472 z0 = ( (bits64) aHigh ) * bHigh;
473 zMiddleA += zMiddleB;
474 z0 += ( ( (bits64) ( zMiddleA < zMiddleB ) )<<32 ) + ( zMiddleA>>32 );
475 zMiddleA <<= 32;
476 z1 += zMiddleA;
477 z0 += ( z1 < zMiddleA );
478 *z1Ptr = z1;
479 *z0Ptr = z0;
480
481}
482
483/*
484-------------------------------------------------------------------------------
485Multiplies the 128-bit value formed by concatenating `a0' and `a1' by `b' to
486obtain a 192-bit product. The product is broken into three 64-bit pieces
487which are stored at the locations pointed to by `z0Ptr', `z1Ptr', and
488`z2Ptr'.
489-------------------------------------------------------------------------------
490*/
491INLINE void
492 mul128By64To192(
493 bits64 a0,
494 bits64 a1,
495 bits64 b,
496 bits64 *z0Ptr,
497 bits64 *z1Ptr,
498 bits64 *z2Ptr
499 )
500{
501 bits64 z0, z1, z2, more1;
502
503 mul64To128( a1, b, &z1, &z2 );
504 mul64To128( a0, b, &z0, &more1 );
505 add128( z0, more1, 0, z1, &z0, &z1 );
506 *z2Ptr = z2;
507 *z1Ptr = z1;
508 *z0Ptr = z0;
509
510}
511
512/*
513-------------------------------------------------------------------------------
514Multiplies the 128-bit value formed by concatenating `a0' and `a1' to the
515128-bit value formed by concatenating `b0' and `b1' to obtain a 256-bit
516product. The product is broken into four 64-bit pieces which are stored at
517the locations pointed to by `z0Ptr', `z1Ptr', `z2Ptr', and `z3Ptr'.
518-------------------------------------------------------------------------------
519*/
520INLINE void
521 mul128To256(
522 bits64 a0,
523 bits64 a1,
524 bits64 b0,
525 bits64 b1,
526 bits64 *z0Ptr,
527 bits64 *z1Ptr,
528 bits64 *z2Ptr,
529 bits64 *z3Ptr
530 )
531{
532 bits64 z0, z1, z2, z3;
533 bits64 more1, more2;
534
535 mul64To128( a1, b1, &z2, &z3 );
536 mul64To128( a1, b0, &z1, &more2 );
537 add128( z1, more2, 0, z2, &z1, &z2 );
538 mul64To128( a0, b0, &z0, &more1 );
539 add128( z0, more1, 0, z1, &z0, &z1 );
540 mul64To128( a0, b1, &more1, &more2 );
541 add128( more1, more2, 0, z2, &more1, &z2 );
542 add128( z0, z1, 0, more1, &z0, &z1 );
543 *z3Ptr = z3;
544 *z2Ptr = z2;
545 *z1Ptr = z1;
546 *z0Ptr = z0;
547
548}
549
550/*
551-------------------------------------------------------------------------------
552Returns an approximation to the 64-bit integer quotient obtained by dividing
553`b' into the 128-bit value formed by concatenating `a0' and `a1'. The
554divisor `b' must be at least 2^63. If q is the exact quotient truncated
555toward zero, the approximation returned lies between q and q + 2 inclusive.
556If the exact quotient q is larger than 64 bits, the maximum positive 64-bit
557unsigned integer is returned.
558-------------------------------------------------------------------------------
559*/
560static bits64 estimateDiv128To64( bits64 a0, bits64 a1, bits64 b )
561{
562 bits64 b0, b1;
563 bits64 rem0, rem1, term0, term1;
564 bits64 z;
565 if ( b <= a0 ) return LIT64( 0xFFFFFFFFFFFFFFFF );
566 b0 = b>>32;
567 z = ( b0<<32 <= a0 ) ? LIT64( 0xFFFFFFFF00000000 ) : ( a0 / b0 )<<32;
568 mul64To128( b, z, &term0, &term1 );
569 sub128( a0, a1, term0, term1, &rem0, &rem1 );
570 while ( ( (sbits64) rem0 ) < 0 ) {
571 z -= LIT64( 0x100000000 );
572 b1 = b<<32;
573 add128( rem0, rem1, b0, b1, &rem0, &rem1 );
574 }
575 rem0 = ( rem0<<32 ) | ( rem1>>32 );
576 z |= ( b0<<32 <= rem0 ) ? 0xFFFFFFFF : rem0 / b0;
577 return z;
578
579}
580
581/*
582-------------------------------------------------------------------------------
583Returns an approximation to the square root of the 32-bit significand given
584by `a'. Considered as an integer, `a' must be at least 2^31. If bit 0 of
585`aExp' (the least significant bit) is 1, the integer returned approximates
5862^31*sqrt(`a'/2^31), where `a' is considered an integer. If bit 0 of `aExp'
587is 0, the integer returned approximates 2^31*sqrt(`a'/2^30). In either
588case, the approximation returned lies strictly within +/-2 of the exact
589value.
590-------------------------------------------------------------------------------
591*/
592static bits32 estimateSqrt32( int16 aExp, bits32 a )
593{
594 static const bits16 sqrtOddAdjustments[] = {
595 0x0004, 0x0022, 0x005D, 0x00B1, 0x011D, 0x019F, 0x0236, 0x02E0,
596 0x039C, 0x0468, 0x0545, 0x0631, 0x072B, 0x0832, 0x0946, 0x0A67
597 };
598 static const bits16 sqrtEvenAdjustments[] = {
599 0x0A2D, 0x08AF, 0x075A, 0x0629, 0x051A, 0x0429, 0x0356, 0x029E,
600 0x0200, 0x0179, 0x0109, 0x00AF, 0x0068, 0x0034, 0x0012, 0x0002
601 };
602 int8 index;
603 bits32 z;
604
605 index = ( a>>27 ) & 15;
606 if ( aExp & 1 ) {
607 z = 0x4000 + ( a>>17 ) - sqrtOddAdjustments[ index ];
608 z = ( ( a / z )<<14 ) + ( z<<15 );
609 a >>= 1;
610 }
611 else {
612 z = 0x8000 + ( a>>17 ) - sqrtEvenAdjustments[ index ];
613 z = a / z + z;
614 z = ( 0x20000 <= z ) ? 0xFFFF8000 : ( z<<15 );
615 if ( z <= a ) return (bits32) ( ( (sbits32) a )>>1 );
616 }
617 return ( (bits32) ( ( ( (bits64) a )<<31 ) / z ) ) + ( z>>1 );
618
619}
620
621/*
622-------------------------------------------------------------------------------
623Returns the number of leading 0 bits before the most-significant 1 bit
624of `a'. If `a' is zero, 32 is returned.
625-------------------------------------------------------------------------------
626*/
627static int8 countLeadingZeros32( bits32 a )
628{
629 static const int8 countLeadingZerosHigh[] = {
630 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
631 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
632 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
633 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
634 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
635 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
636 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
637 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
638 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
639 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
640 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
641 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
642 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
643 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
644 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
645 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
646 };
647 int8 shiftCount;
648
649 shiftCount = 0;
650 if ( a < 0x10000 ) {
651 shiftCount += 16;
652 a <<= 16;
653 }
654 if ( a < 0x1000000 ) {
655 shiftCount += 8;
656 a <<= 8;
657 }
658 shiftCount += countLeadingZerosHigh[ a>>24 ];
659 return shiftCount;
660
661}
662
663/*
664-------------------------------------------------------------------------------
665Returns the number of leading 0 bits before the most-significant 1 bit
666of `a'. If `a' is zero, 64 is returned.
667-------------------------------------------------------------------------------
668*/
669static int8 countLeadingZeros64( bits64 a )
670{
671 int8 shiftCount;
672
673 shiftCount = 0;
674 if ( a < ( (bits64) 1 )<<32 ) {
675 shiftCount += 32;
676 }
677 else {
678 a >>= 32;
679 }
680 shiftCount += countLeadingZeros32( a );
681 return shiftCount;
682
683}
684
685/*
686-------------------------------------------------------------------------------
687Returns 1 if the 128-bit value formed by concatenating `a0' and `a1'
688is equal to the 128-bit value formed by concatenating `b0' and `b1'.
689Otherwise, returns 0.
690-------------------------------------------------------------------------------
691*/
692INLINE flag eq128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
693{
694
695 return ( a0 == b0 ) && ( a1 == b1 );
696
697}
698
699/*
700-------------------------------------------------------------------------------
701Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less
702than or equal to the 128-bit value formed by concatenating `b0' and `b1'.
703Otherwise, returns 0.
704-------------------------------------------------------------------------------
705*/
706INLINE flag le128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
707{
708
709 return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 <= b1 ) );
710
711}
712
713/*
714-------------------------------------------------------------------------------
715Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less
716than the 128-bit value formed by concatenating `b0' and `b1'. Otherwise,
717returns 0.
718-------------------------------------------------------------------------------
719*/
720INLINE flag lt128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
721{
722
723 return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 < b1 ) );
724
725}
726
727/*
728-------------------------------------------------------------------------------
729Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is
730not equal to the 128-bit value formed by concatenating `b0' and `b1'.
731Otherwise, returns 0.
732-------------------------------------------------------------------------------
733*/
734INLINE flag ne128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
735{
736
737 return ( a0 != b0 ) || ( a1 != b1 );
738
739}
740
diff --git a/arch/arm26/nwfpe/softfloat-specialize b/arch/arm26/nwfpe/softfloat-specialize
deleted file mode 100644
index acf409144763..000000000000
--- a/arch/arm26/nwfpe/softfloat-specialize
+++ /dev/null
@@ -1,366 +0,0 @@
1
2/*
3===============================================================================
4
5This C source fragment is part of the SoftFloat IEC/IEEE Floating-point
6Arithmetic Package, Release 2.
7
8Written by John R. Hauser. This work was made possible in part by the
9International Computer Science Institute, located at Suite 600, 1947 Center
10Street, Berkeley, California 94704. Funding was partially provided by the
11National Science Foundation under grant MIP-9311980. The original version
12of this code was written as part of a project to build a fixed-point vector
13processor in collaboration with the University of California at Berkeley,
14overseen by Profs. Nelson Morgan and John Wawrzynek. More information
15is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
16arithmetic/softfloat.html'.
17
18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
20TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
21PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
22AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
23
24Derivative works are acceptable, even for commercial purposes, so long as
25(1) they include prominent notice that the work is derivative, and (2) they
26include prominent notice akin to these three paragraphs for those parts of
27this code that are retained.
28
29===============================================================================
30*/
31
32/*
33-------------------------------------------------------------------------------
34Underflow tininess-detection mode, statically initialized to default value.
35(The declaration in `softfloat.h' must match the `int8' type here.)
36-------------------------------------------------------------------------------
37*/
38int8 float_detect_tininess = float_tininess_after_rounding;
39
40/*
41-------------------------------------------------------------------------------
42Raises the exceptions specified by `flags'. Floating-point traps can be
43defined here if desired. It is currently not possible for such a trap to
44substitute a result value. If traps are not implemented, this routine
45should be simply `float_exception_flags |= flags;'.
46
47ScottB: November 4, 1998
48Moved this function out of softfloat-specialize into fpmodule.c.
49This effectively isolates all the changes required for integrating with the
50Linux kernel into fpmodule.c. Porting to NetBSD should only require modifying
51fpmodule.c to integrate with the NetBSD kernel (I hope!).
52-------------------------------------------------------------------------------
53void float_raise( int8 flags )
54{
55 float_exception_flags |= flags;
56}
57*/
58
59/*
60-------------------------------------------------------------------------------
61Internal canonical NaN format.
62-------------------------------------------------------------------------------
63*/
64typedef struct {
65 flag sign;
66 bits64 high, low;
67} commonNaNT;
68
69/*
70-------------------------------------------------------------------------------
71The pattern for a default generated single-precision NaN.
72-------------------------------------------------------------------------------
73*/
74#define float32_default_nan 0xFFFFFFFF
75
76/*
77-------------------------------------------------------------------------------
78Returns 1 if the single-precision floating-point value `a' is a NaN;
79otherwise returns 0.
80-------------------------------------------------------------------------------
81*/
82flag float32_is_nan( float32 a )
83{
84
85 return ( 0xFF000000 < (bits32) ( a<<1 ) );
86
87}
88
89/*
90-------------------------------------------------------------------------------
91Returns 1 if the single-precision floating-point value `a' is a signaling
92NaN; otherwise returns 0.
93-------------------------------------------------------------------------------
94*/
95flag float32_is_signaling_nan( float32 a )
96{
97
98 return ( ( ( a>>22 ) & 0x1FF ) == 0x1FE ) && ( a & 0x003FFFFF );
99
100}
101
102/*
103-------------------------------------------------------------------------------
104Returns the result of converting the single-precision floating-point NaN
105`a' to the canonical NaN format. If `a' is a signaling NaN, the invalid
106exception is raised.
107-------------------------------------------------------------------------------
108*/
109static commonNaNT float32ToCommonNaN( float32 a )
110{
111 commonNaNT z;
112
113 if ( float32_is_signaling_nan( a ) ) float_raise( float_flag_invalid );
114 z.sign = a>>31;
115 z.low = 0;
116 z.high = ( (bits64) a )<<41;
117 return z;
118
119}
120
121/*
122-------------------------------------------------------------------------------
123Returns the result of converting the canonical NaN `a' to the single-
124precision floating-point format.
125-------------------------------------------------------------------------------
126*/
127static float32 commonNaNToFloat32( commonNaNT a )
128{
129
130 return ( ( (bits32) a.sign )<<31 ) | 0x7FC00000 | ( a.high>>41 );
131
132}
133
134/*
135-------------------------------------------------------------------------------
136Takes two single-precision floating-point values `a' and `b', one of which
137is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a
138signaling NaN, the invalid exception is raised.
139-------------------------------------------------------------------------------
140*/
141static float32 propagateFloat32NaN( float32 a, float32 b )
142{
143 flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
144
145 aIsNaN = float32_is_nan( a );
146 aIsSignalingNaN = float32_is_signaling_nan( a );
147 bIsNaN = float32_is_nan( b );
148 bIsSignalingNaN = float32_is_signaling_nan( b );
149 a |= 0x00400000;
150 b |= 0x00400000;
151 if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid );
152 if ( aIsNaN ) {
153 return ( aIsSignalingNaN & bIsNaN ) ? b : a;
154 }
155 else {
156 return b;
157 }
158
159}
160
161/*
162-------------------------------------------------------------------------------
163The pattern for a default generated double-precision NaN.
164-------------------------------------------------------------------------------
165*/
166#define float64_default_nan LIT64( 0xFFFFFFFFFFFFFFFF )
167
168/*
169-------------------------------------------------------------------------------
170Returns 1 if the double-precision floating-point value `a' is a NaN;
171otherwise returns 0.
172-------------------------------------------------------------------------------
173*/
174flag float64_is_nan( float64 a )
175{
176
177 return ( LIT64( 0xFFE0000000000000 ) < (bits64) ( a<<1 ) );
178
179}
180
181/*
182-------------------------------------------------------------------------------
183Returns 1 if the double-precision floating-point value `a' is a signaling
184NaN; otherwise returns 0.
185-------------------------------------------------------------------------------
186*/
187flag float64_is_signaling_nan( float64 a )
188{
189
190 return
191 ( ( ( a>>51 ) & 0xFFF ) == 0xFFE )
192 && ( a & LIT64( 0x0007FFFFFFFFFFFF ) );
193
194}
195
196/*
197-------------------------------------------------------------------------------
198Returns the result of converting the double-precision floating-point NaN
199`a' to the canonical NaN format. If `a' is a signaling NaN, the invalid
200exception is raised.
201-------------------------------------------------------------------------------
202*/
203static commonNaNT float64ToCommonNaN( float64 a )
204{
205 commonNaNT z;
206
207 if ( float64_is_signaling_nan( a ) ) float_raise( float_flag_invalid );
208 z.sign = a>>63;
209 z.low = 0;
210 z.high = a<<12;
211 return z;
212
213}
214
215/*
216-------------------------------------------------------------------------------
217Returns the result of converting the canonical NaN `a' to the double-
218precision floating-point format.
219-------------------------------------------------------------------------------
220*/
221static float64 commonNaNToFloat64( commonNaNT a )
222{
223
224 return
225 ( ( (bits64) a.sign )<<63 )
226 | LIT64( 0x7FF8000000000000 )
227 | ( a.high>>12 );
228
229}
230
231/*
232-------------------------------------------------------------------------------
233Takes two double-precision floating-point values `a' and `b', one of which
234is a NaN, and returns the appropriate NaN result. If either `a' or `b' is a
235signaling NaN, the invalid exception is raised.
236-------------------------------------------------------------------------------
237*/
238static float64 propagateFloat64NaN( float64 a, float64 b )
239{
240 flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
241
242 aIsNaN = float64_is_nan( a );
243 aIsSignalingNaN = float64_is_signaling_nan( a );
244 bIsNaN = float64_is_nan( b );
245 bIsSignalingNaN = float64_is_signaling_nan( b );
246 a |= LIT64( 0x0008000000000000 );
247 b |= LIT64( 0x0008000000000000 );
248 if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid );
249 if ( aIsNaN ) {
250 return ( aIsSignalingNaN & bIsNaN ) ? b : a;
251 }
252 else {
253 return b;
254 }
255
256}
257
258#ifdef FLOATX80
259
260/*
261-------------------------------------------------------------------------------
262The pattern for a default generated extended double-precision NaN. The
263`high' and `low' values hold the most- and least-significant bits,
264respectively.
265-------------------------------------------------------------------------------
266*/
267#define floatx80_default_nan_high 0xFFFF
268#define floatx80_default_nan_low LIT64( 0xFFFFFFFFFFFFFFFF )
269
270/*
271-------------------------------------------------------------------------------
272Returns 1 if the extended double-precision floating-point value `a' is a
273NaN; otherwise returns 0.
274-------------------------------------------------------------------------------
275*/
276flag floatx80_is_nan( floatx80 a )
277{
278
279 return ( ( a.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( a.low<<1 );
280
281}
282
283/*
284-------------------------------------------------------------------------------
285Returns 1 if the extended double-precision floating-point value `a' is a
286signaling NaN; otherwise returns 0.
287-------------------------------------------------------------------------------
288*/
289flag floatx80_is_signaling_nan( floatx80 a )
290{
291 //register int lr;
292 bits64 aLow;
293
294 //__asm__("mov %0, lr" : : "g" (lr));
295 //fp_printk("floatx80_is_signalling_nan() called from 0x%08x\n",lr);
296 aLow = a.low & ~ LIT64( 0x4000000000000000 );
297 return
298 ( ( a.high & 0x7FFF ) == 0x7FFF )
299 && (bits64) ( aLow<<1 )
300 && ( a.low == aLow );
301
302}
303
304/*
305-------------------------------------------------------------------------------
306Returns the result of converting the extended double-precision floating-
307point NaN `a' to the canonical NaN format. If `a' is a signaling NaN, the
308invalid exception is raised.
309-------------------------------------------------------------------------------
310*/
311static commonNaNT floatx80ToCommonNaN( floatx80 a )
312{
313 commonNaNT z;
314
315 if ( floatx80_is_signaling_nan( a ) ) float_raise( float_flag_invalid );
316 z.sign = a.high>>15;
317 z.low = 0;
318 z.high = a.low<<1;
319 return z;
320
321}
322
323/*
324-------------------------------------------------------------------------------
325Returns the result of converting the canonical NaN `a' to the extended
326double-precision floating-point format.
327-------------------------------------------------------------------------------
328*/
329static floatx80 commonNaNToFloatx80( commonNaNT a )
330{
331 floatx80 z;
332
333 z.low = LIT64( 0xC000000000000000 ) | ( a.high>>1 );
334 z.high = ( ( (bits16) a.sign )<<15 ) | 0x7FFF;
335 return z;
336
337}
338
339/*
340-------------------------------------------------------------------------------
341Takes two extended double-precision floating-point values `a' and `b', one
342of which is a NaN, and returns the appropriate NaN result. If either `a' or
343`b' is a signaling NaN, the invalid exception is raised.
344-------------------------------------------------------------------------------
345*/
346static floatx80 propagateFloatx80NaN( floatx80 a, floatx80 b )
347{
348 flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
349
350 aIsNaN = floatx80_is_nan( a );
351 aIsSignalingNaN = floatx80_is_signaling_nan( a );
352 bIsNaN = floatx80_is_nan( b );
353 bIsSignalingNaN = floatx80_is_signaling_nan( b );
354 a.low |= LIT64( 0xC000000000000000 );
355 b.low |= LIT64( 0xC000000000000000 );
356 if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid );
357 if ( aIsNaN ) {
358 return ( aIsSignalingNaN & bIsNaN ) ? b : a;
359 }
360 else {
361 return b;
362 }
363
364}
365
366#endif
diff --git a/arch/arm26/nwfpe/softfloat.c b/arch/arm26/nwfpe/softfloat.c
deleted file mode 100644
index 26c1b916e527..000000000000
--- a/arch/arm26/nwfpe/softfloat.c
+++ /dev/null
@@ -1,3439 +0,0 @@
1/*
2===============================================================================
3
4This C source file is part of the SoftFloat IEC/IEEE Floating-point
5Arithmetic Package, Release 2.
6
7Written by John R. Hauser. This work was made possible in part by the
8International Computer Science Institute, located at Suite 600, 1947 Center
9Street, Berkeley, California 94704. Funding was partially provided by the
10National Science Foundation under grant MIP-9311980. The original version
11of this code was written as part of a project to build a fixed-point vector
12processor in collaboration with the University of California at Berkeley,
13overseen by Profs. Nelson Morgan and John Wawrzynek. More information
14is available through the web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
15arithmetic/softfloat.html'.
16
17THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
18has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
19TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
20PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
21AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
22
23Derivative works are acceptable, even for commercial purposes, so long as
24(1) they include prominent notice that the work is derivative, and (2) they
25include prominent notice akin to these three paragraphs for those parts of
26this code that are retained.
27
28===============================================================================
29*/
30
31#include "fpa11.h"
32#include "milieu.h"
33#include "softfloat.h"
34
35/*
36-------------------------------------------------------------------------------
37Floating-point rounding mode, extended double-precision rounding precision,
38and exception flags.
39-------------------------------------------------------------------------------
40*/
41int8 float_rounding_mode = float_round_nearest_even;
42int8 floatx80_rounding_precision = 80;
43int8 float_exception_flags;
44
45/*
46-------------------------------------------------------------------------------
47Primitive arithmetic functions, including multi-word arithmetic, and
48division and square root approximations. (Can be specialized to target if
49desired.)
50-------------------------------------------------------------------------------
51*/
52#include "softfloat-macros"
53
54/*
55-------------------------------------------------------------------------------
56Functions and definitions to determine: (1) whether tininess for underflow
57is detected before or after rounding by default, (2) what (if anything)
58happens when exceptions are raised, (3) how signaling NaNs are distinguished
59from quiet NaNs, (4) the default generated quiet NaNs, and (5) how NaNs
60are propagated from function inputs to output. These details are target-
61specific.
62-------------------------------------------------------------------------------
63*/
64#include "softfloat-specialize"
65
66/*
67-------------------------------------------------------------------------------
68Takes a 64-bit fixed-point value `absZ' with binary point between bits 6
69and 7, and returns the properly rounded 32-bit integer corresponding to the
70input. If `zSign' is nonzero, the input is negated before being converted
71to an integer. Bit 63 of `absZ' must be zero. Ordinarily, the fixed-point
72input is simply rounded to an integer, with the inexact exception raised if
73the input cannot be represented exactly as an integer. If the fixed-point
74input is too large, however, the invalid exception is raised and the largest
75positive or negative integer is returned.
76-------------------------------------------------------------------------------
77*/
78static int32 roundAndPackInt32( flag zSign, bits64 absZ )
79{
80 int8 roundingMode;
81 flag roundNearestEven;
82 int8 roundIncrement, roundBits;
83 int32 z;
84
85 roundingMode = float_rounding_mode;
86 roundNearestEven = ( roundingMode == float_round_nearest_even );
87 roundIncrement = 0x40;
88 if ( ! roundNearestEven ) {
89 if ( roundingMode == float_round_to_zero ) {
90 roundIncrement = 0;
91 }
92 else {
93 roundIncrement = 0x7F;
94 if ( zSign ) {
95 if ( roundingMode == float_round_up ) roundIncrement = 0;
96 }
97 else {
98 if ( roundingMode == float_round_down ) roundIncrement = 0;
99 }
100 }
101 }
102 roundBits = absZ & 0x7F;
103 absZ = ( absZ + roundIncrement )>>7;
104 absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
105 z = absZ;
106 if ( zSign ) z = - z;
107 if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) {
108 float_exception_flags |= float_flag_invalid;
109 return zSign ? 0x80000000 : 0x7FFFFFFF;
110 }
111 if ( roundBits ) float_exception_flags |= float_flag_inexact;
112 return z;
113
114}
115
116/*
117-------------------------------------------------------------------------------
118Returns the fraction bits of the single-precision floating-point value `a'.
119-------------------------------------------------------------------------------
120*/
121INLINE bits32 extractFloat32Frac( float32 a )
122{
123
124 return a & 0x007FFFFF;
125
126}
127
128/*
129-------------------------------------------------------------------------------
130Returns the exponent bits of the single-precision floating-point value `a'.
131-------------------------------------------------------------------------------
132*/
133INLINE int16 extractFloat32Exp( float32 a )
134{
135
136 return ( a>>23 ) & 0xFF;
137
138}
139
140/*
141-------------------------------------------------------------------------------
142Returns the sign bit of the single-precision floating-point value `a'.
143-------------------------------------------------------------------------------
144*/
145INLINE flag extractFloat32Sign( float32 a )
146{
147
148 return a>>31;
149
150}
151
152/*
153-------------------------------------------------------------------------------
154Normalizes the subnormal single-precision floating-point value represented
155by the denormalized significand `aSig'. The normalized exponent and
156significand are stored at the locations pointed to by `zExpPtr' and
157`zSigPtr', respectively.
158-------------------------------------------------------------------------------
159*/
160static void
161 normalizeFloat32Subnormal( bits32 aSig, int16 *zExpPtr, bits32 *zSigPtr )
162{
163 int8 shiftCount;
164
165 shiftCount = countLeadingZeros32( aSig ) - 8;
166 *zSigPtr = aSig<<shiftCount;
167 *zExpPtr = 1 - shiftCount;
168
169}
170
171/*
172-------------------------------------------------------------------------------
173Packs the sign `zSign', exponent `zExp', and significand `zSig' into a
174single-precision floating-point value, returning the result. After being
175shifted into the proper positions, the three fields are simply added
176together to form the result. This means that any integer portion of `zSig'
177will be added into the exponent. Since a properly normalized significand
178will have an integer portion equal to 1, the `zExp' input should be 1 less
179than the desired result exponent whenever `zSig' is a complete, normalized
180significand.
181-------------------------------------------------------------------------------
182*/
183INLINE float32 packFloat32( flag zSign, int16 zExp, bits32 zSig )
184{
185#if 0
186 float32 f;
187 __asm__("@ packFloat32; \n\
188 mov %0, %1, asl #31; \n\
189 orr %0, %2, asl #23; \n\
190 orr %0, %3"
191 : /* no outputs */
192 : "g" (f), "g" (zSign), "g" (zExp), "g" (zSig)
193 : "cc");
194 return f;
195#else
196 return ( ( (bits32) zSign )<<31 ) + ( ( (bits32) zExp )<<23 ) + zSig;
197#endif
198}
199
200/*
201-------------------------------------------------------------------------------
202Takes an abstract floating-point value having sign `zSign', exponent `zExp',
203and significand `zSig', and returns the proper single-precision floating-
204point value corresponding to the abstract input. Ordinarily, the abstract
205value is simply rounded and packed into the single-precision format, with
206the inexact exception raised if the abstract input cannot be represented
207exactly. If the abstract value is too large, however, the overflow and
208inexact exceptions are raised and an infinity or maximal finite value is
209returned. If the abstract value is too small, the input value is rounded to
210a subnormal number, and the underflow and inexact exceptions are raised if
211the abstract input cannot be represented exactly as a subnormal single-
212precision floating-point number.
213 The input significand `zSig' has its binary point between bits 30
214and 29, which is 7 bits to the left of the usual location. This shifted
215significand must be normalized or smaller. If `zSig' is not normalized,
216`zExp' must be 0; in that case, the result returned is a subnormal number,
217and it must not require rounding. In the usual case that `zSig' is
218normalized, `zExp' must be 1 less than the ``true'' floating-point exponent.
219The handling of underflow and overflow follows the IEC/IEEE Standard for
220Binary Floating-point Arithmetic.
221-------------------------------------------------------------------------------
222*/
223static float32 roundAndPackFloat32( flag zSign, int16 zExp, bits32 zSig )
224{
225 int8 roundingMode;
226 flag roundNearestEven;
227 int8 roundIncrement, roundBits;
228 flag isTiny;
229
230 roundingMode = float_rounding_mode;
231 roundNearestEven = ( roundingMode == float_round_nearest_even );
232 roundIncrement = 0x40;
233 if ( ! roundNearestEven ) {
234 if ( roundingMode == float_round_to_zero ) {
235 roundIncrement = 0;
236 }
237 else {
238 roundIncrement = 0x7F;
239 if ( zSign ) {
240 if ( roundingMode == float_round_up ) roundIncrement = 0;
241 }
242 else {
243 if ( roundingMode == float_round_down ) roundIncrement = 0;
244 }
245 }
246 }
247 roundBits = zSig & 0x7F;
248 if ( 0xFD <= (bits16) zExp ) {
249 if ( ( 0xFD < zExp )
250 || ( ( zExp == 0xFD )
251 && ( (sbits32) ( zSig + roundIncrement ) < 0 ) )
252 ) {
253 float_raise( float_flag_overflow | float_flag_inexact );
254 return packFloat32( zSign, 0xFF, 0 ) - ( roundIncrement == 0 );
255 }
256 if ( zExp < 0 ) {
257 isTiny =
258 ( float_detect_tininess == float_tininess_before_rounding )
259 || ( zExp < -1 )
260 || ( zSig + roundIncrement < 0x80000000 );
261 shift32RightJamming( zSig, - zExp, &zSig );
262 zExp = 0;
263 roundBits = zSig & 0x7F;
264 if ( isTiny && roundBits ) float_raise( float_flag_underflow );
265 }
266 }
267 if ( roundBits ) float_exception_flags |= float_flag_inexact;
268 zSig = ( zSig + roundIncrement )>>7;
269 zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
270 if ( zSig == 0 ) zExp = 0;
271 return packFloat32( zSign, zExp, zSig );
272
273}
274
275/*
276-------------------------------------------------------------------------------
277Takes an abstract floating-point value having sign `zSign', exponent `zExp',
278and significand `zSig', and returns the proper single-precision floating-
279point value corresponding to the abstract input. This routine is just like
280`roundAndPackFloat32' except that `zSig' does not have to be normalized in
281any way. In all cases, `zExp' must be 1 less than the ``true'' floating-
282point exponent.
283-------------------------------------------------------------------------------
284*/
285static float32
286 normalizeRoundAndPackFloat32( flag zSign, int16 zExp, bits32 zSig )
287{
288 int8 shiftCount;
289
290 shiftCount = countLeadingZeros32( zSig ) - 1;
291 return roundAndPackFloat32( zSign, zExp - shiftCount, zSig<<shiftCount );
292
293}
294
295/*
296-------------------------------------------------------------------------------
297Returns the fraction bits of the double-precision floating-point value `a'.
298-------------------------------------------------------------------------------
299*/
300INLINE bits64 extractFloat64Frac( float64 a )
301{
302
303 return a & LIT64( 0x000FFFFFFFFFFFFF );
304
305}
306
307/*
308-------------------------------------------------------------------------------
309Returns the exponent bits of the double-precision floating-point value `a'.
310-------------------------------------------------------------------------------
311*/
312INLINE int16 extractFloat64Exp( float64 a )
313{
314
315 return ( a>>52 ) & 0x7FF;
316
317}
318
319/*
320-------------------------------------------------------------------------------
321Returns the sign bit of the double-precision floating-point value `a'.
322-------------------------------------------------------------------------------
323*/
324INLINE flag extractFloat64Sign( float64 a )
325{
326
327 return a>>63;
328
329}
330
331/*
332-------------------------------------------------------------------------------
333Normalizes the subnormal double-precision floating-point value represented
334by the denormalized significand `aSig'. The normalized exponent and
335significand are stored at the locations pointed to by `zExpPtr' and
336`zSigPtr', respectively.
337-------------------------------------------------------------------------------
338*/
339static void
340 normalizeFloat64Subnormal( bits64 aSig, int16 *zExpPtr, bits64 *zSigPtr )
341{
342 int8 shiftCount;
343
344 shiftCount = countLeadingZeros64( aSig ) - 11;
345 *zSigPtr = aSig<<shiftCount;
346 *zExpPtr = 1 - shiftCount;
347
348}
349
350/*
351-------------------------------------------------------------------------------
352Packs the sign `zSign', exponent `zExp', and significand `zSig' into a
353double-precision floating-point value, returning the result. After being
354shifted into the proper positions, the three fields are simply added
355together to form the result. This means that any integer portion of `zSig'
356will be added into the exponent. Since a properly normalized significand
357will have an integer portion equal to 1, the `zExp' input should be 1 less
358than the desired result exponent whenever `zSig' is a complete, normalized
359significand.
360-------------------------------------------------------------------------------
361*/
362INLINE float64 packFloat64( flag zSign, int16 zExp, bits64 zSig )
363{
364
365 return ( ( (bits64) zSign )<<63 ) + ( ( (bits64) zExp )<<52 ) + zSig;
366
367}
368
369/*
370-------------------------------------------------------------------------------
371Takes an abstract floating-point value having sign `zSign', exponent `zExp',
372and significand `zSig', and returns the proper double-precision floating-
373point value corresponding to the abstract input. Ordinarily, the abstract
374value is simply rounded and packed into the double-precision format, with
375the inexact exception raised if the abstract input cannot be represented
376exactly. If the abstract value is too large, however, the overflow and
377inexact exceptions are raised and an infinity or maximal finite value is
378returned. If the abstract value is too small, the input value is rounded to
379a subnormal number, and the underflow and inexact exceptions are raised if
380the abstract input cannot be represented exactly as a subnormal double-
381precision floating-point number.
382 The input significand `zSig' has its binary point between bits 62
383and 61, which is 10 bits to the left of the usual location. This shifted
384significand must be normalized or smaller. If `zSig' is not normalized,
385`zExp' must be 0; in that case, the result returned is a subnormal number,
386and it must not require rounding. In the usual case that `zSig' is
387normalized, `zExp' must be 1 less than the ``true'' floating-point exponent.
388The handling of underflow and overflow follows the IEC/IEEE Standard for
389Binary Floating-point Arithmetic.
390-------------------------------------------------------------------------------
391*/
392static float64 roundAndPackFloat64( flag zSign, int16 zExp, bits64 zSig )
393{
394 int8 roundingMode;
395 flag roundNearestEven;
396 int16 roundIncrement, roundBits;
397 flag isTiny;
398
399 roundingMode = float_rounding_mode;
400 roundNearestEven = ( roundingMode == float_round_nearest_even );
401 roundIncrement = 0x200;
402 if ( ! roundNearestEven ) {
403 if ( roundingMode == float_round_to_zero ) {
404 roundIncrement = 0;
405 }
406 else {
407 roundIncrement = 0x3FF;
408 if ( zSign ) {
409 if ( roundingMode == float_round_up ) roundIncrement = 0;
410 }
411 else {
412 if ( roundingMode == float_round_down ) roundIncrement = 0;
413 }
414 }
415 }
416 roundBits = zSig & 0x3FF;
417 if ( 0x7FD <= (bits16) zExp ) {
418 if ( ( 0x7FD < zExp )
419 || ( ( zExp == 0x7FD )
420 && ( (sbits64) ( zSig + roundIncrement ) < 0 ) )
421 ) {
422 //register int lr = __builtin_return_address(0);
423 //printk("roundAndPackFloat64 called from 0x%08x\n",lr);
424 float_raise( float_flag_overflow | float_flag_inexact );
425 return packFloat64( zSign, 0x7FF, 0 ) - ( roundIncrement == 0 );
426 }
427 if ( zExp < 0 ) {
428 isTiny =
429 ( float_detect_tininess == float_tininess_before_rounding )
430 || ( zExp < -1 )
431 || ( zSig + roundIncrement < LIT64( 0x8000000000000000 ) );
432 shift64RightJamming( zSig, - zExp, &zSig );
433 zExp = 0;
434 roundBits = zSig & 0x3FF;
435 if ( isTiny && roundBits ) float_raise( float_flag_underflow );
436 }
437 }
438 if ( roundBits ) float_exception_flags |= float_flag_inexact;
439 zSig = ( zSig + roundIncrement )>>10;
440 zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
441 if ( zSig == 0 ) zExp = 0;
442 return packFloat64( zSign, zExp, zSig );
443
444}
445
446/*
447-------------------------------------------------------------------------------
448Takes an abstract floating-point value having sign `zSign', exponent `zExp',
449and significand `zSig', and returns the proper double-precision floating-
450point value corresponding to the abstract input. This routine is just like
451`roundAndPackFloat64' except that `zSig' does not have to be normalized in
452any way. In all cases, `zExp' must be 1 less than the ``true'' floating-
453point exponent.
454-------------------------------------------------------------------------------
455*/
456static float64
457 normalizeRoundAndPackFloat64( flag zSign, int16 zExp, bits64 zSig )
458{
459 int8 shiftCount;
460
461 shiftCount = countLeadingZeros64( zSig ) - 1;
462 return roundAndPackFloat64( zSign, zExp - shiftCount, zSig<<shiftCount );
463
464}
465
466#ifdef FLOATX80
467
468/*
469-------------------------------------------------------------------------------
470Returns the fraction bits of the extended double-precision floating-point
471value `a'.
472-------------------------------------------------------------------------------
473*/
474INLINE bits64 extractFloatx80Frac( floatx80 a )
475{
476
477 return a.low;
478
479}
480
481/*
482-------------------------------------------------------------------------------
483Returns the exponent bits of the extended double-precision floating-point
484value `a'.
485-------------------------------------------------------------------------------
486*/
487INLINE int32 extractFloatx80Exp( floatx80 a )
488{
489
490 return a.high & 0x7FFF;
491
492}
493
494/*
495-------------------------------------------------------------------------------
496Returns the sign bit of the extended double-precision floating-point value
497`a'.
498-------------------------------------------------------------------------------
499*/
500INLINE flag extractFloatx80Sign( floatx80 a )
501{
502
503 return a.high>>15;
504
505}
506
507/*
508-------------------------------------------------------------------------------
509Normalizes the subnormal extended double-precision floating-point value
510represented by the denormalized significand `aSig'. The normalized exponent
511and significand are stored at the locations pointed to by `zExpPtr' and
512`zSigPtr', respectively.
513-------------------------------------------------------------------------------
514*/
515static void
516 normalizeFloatx80Subnormal( bits64 aSig, int32 *zExpPtr, bits64 *zSigPtr )
517{
518 int8 shiftCount;
519
520 shiftCount = countLeadingZeros64( aSig );
521 *zSigPtr = aSig<<shiftCount;
522 *zExpPtr = 1 - shiftCount;
523
524}
525
526/*
527-------------------------------------------------------------------------------
528Packs the sign `zSign', exponent `zExp', and significand `zSig' into an
529extended double-precision floating-point value, returning the result.
530-------------------------------------------------------------------------------
531*/
532INLINE floatx80 packFloatx80( flag zSign, int32 zExp, bits64 zSig )
533{
534 floatx80 z;
535
536 z.low = zSig;
537 z.high = ( ( (bits16) zSign )<<15 ) + zExp;
538 return z;
539
540}
541
542/*
543-------------------------------------------------------------------------------
544Takes an abstract floating-point value having sign `zSign', exponent `zExp',
545and extended significand formed by the concatenation of `zSig0' and `zSig1',
546and returns the proper extended double-precision floating-point value
547corresponding to the abstract input. Ordinarily, the abstract value is
548rounded and packed into the extended double-precision format, with the
549inexact exception raised if the abstract input cannot be represented
550exactly. If the abstract value is too large, however, the overflow and
551inexact exceptions are raised and an infinity or maximal finite value is
552returned. If the abstract value is too small, the input value is rounded to
553a subnormal number, and the underflow and inexact exceptions are raised if
554the abstract input cannot be represented exactly as a subnormal extended
555double-precision floating-point number.
556 If `roundingPrecision' is 32 or 64, the result is rounded to the same
557number of bits as single or double precision, respectively. Otherwise, the
558result is rounded to the full precision of the extended double-precision
559format.
560 The input significand must be normalized or smaller. If the input
561significand is not normalized, `zExp' must be 0; in that case, the result
562returned is a subnormal number, and it must not require rounding. The
563handling of underflow and overflow follows the IEC/IEEE Standard for Binary
564Floating-point Arithmetic.
565-------------------------------------------------------------------------------
566*/
567static floatx80
568 roundAndPackFloatx80(
569 int8 roundingPrecision, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1
570 )
571{
572 int8 roundingMode;
573 flag roundNearestEven, increment, isTiny;
574 int64 roundIncrement, roundMask, roundBits;
575
576 roundingMode = float_rounding_mode;
577 roundNearestEven = ( roundingMode == float_round_nearest_even );
578 if ( roundingPrecision == 80 ) goto precision80;
579 if ( roundingPrecision == 64 ) {
580 roundIncrement = LIT64( 0x0000000000000400 );
581 roundMask = LIT64( 0x00000000000007FF );
582 }
583 else if ( roundingPrecision == 32 ) {
584 roundIncrement = LIT64( 0x0000008000000000 );
585 roundMask = LIT64( 0x000000FFFFFFFFFF );
586 }
587 else {
588 goto precision80;
589 }
590 zSig0 |= ( zSig1 != 0 );
591 if ( ! roundNearestEven ) {
592 if ( roundingMode == float_round_to_zero ) {
593 roundIncrement = 0;
594 }
595 else {
596 roundIncrement = roundMask;
597 if ( zSign ) {
598 if ( roundingMode == float_round_up ) roundIncrement = 0;
599 }
600 else {
601 if ( roundingMode == float_round_down ) roundIncrement = 0;
602 }
603 }
604 }
605 roundBits = zSig0 & roundMask;
606 if ( 0x7FFD <= (bits32) ( zExp - 1 ) ) {
607 if ( ( 0x7FFE < zExp )
608 || ( ( zExp == 0x7FFE ) && ( zSig0 + roundIncrement < zSig0 ) )
609 ) {
610 goto overflow;
611 }
612 if ( zExp <= 0 ) {
613 isTiny =
614 ( float_detect_tininess == float_tininess_before_rounding )
615 || ( zExp < 0 )
616 || ( zSig0 <= zSig0 + roundIncrement );
617 shift64RightJamming( zSig0, 1 - zExp, &zSig0 );
618 zExp = 0;
619 roundBits = zSig0 & roundMask;
620 if ( isTiny && roundBits ) float_raise( float_flag_underflow );
621 if ( roundBits ) float_exception_flags |= float_flag_inexact;
622 zSig0 += roundIncrement;
623 if ( (sbits64) zSig0 < 0 ) zExp = 1;
624 roundIncrement = roundMask + 1;
625 if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
626 roundMask |= roundIncrement;
627 }
628 zSig0 &= ~ roundMask;
629 return packFloatx80( zSign, zExp, zSig0 );
630 }
631 }
632 if ( roundBits ) float_exception_flags |= float_flag_inexact;
633 zSig0 += roundIncrement;
634 if ( zSig0 < roundIncrement ) {
635 ++zExp;
636 zSig0 = LIT64( 0x8000000000000000 );
637 }
638 roundIncrement = roundMask + 1;
639 if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
640 roundMask |= roundIncrement;
641 }
642 zSig0 &= ~ roundMask;
643 if ( zSig0 == 0 ) zExp = 0;
644 return packFloatx80( zSign, zExp, zSig0 );
645 precision80:
646 increment = ( (sbits64) zSig1 < 0 );
647 if ( ! roundNearestEven ) {
648 if ( roundingMode == float_round_to_zero ) {
649 increment = 0;
650 }
651 else {
652 if ( zSign ) {
653 increment = ( roundingMode == float_round_down ) && zSig1;
654 }
655 else {
656 increment = ( roundingMode == float_round_up ) && zSig1;
657 }
658 }
659 }
660 if ( 0x7FFD <= (bits32) ( zExp - 1 ) ) {
661 if ( ( 0x7FFE < zExp )
662 || ( ( zExp == 0x7FFE )
663 && ( zSig0 == LIT64( 0xFFFFFFFFFFFFFFFF ) )
664 && increment
665 )
666 ) {
667 roundMask = 0;
668 overflow:
669 float_raise( float_flag_overflow | float_flag_inexact );
670 if ( ( roundingMode == float_round_to_zero )
671 || ( zSign && ( roundingMode == float_round_up ) )
672 || ( ! zSign && ( roundingMode == float_round_down ) )
673 ) {
674 return packFloatx80( zSign, 0x7FFE, ~ roundMask );
675 }
676 return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
677 }
678 if ( zExp <= 0 ) {
679 isTiny =
680 ( float_detect_tininess == float_tininess_before_rounding )
681 || ( zExp < 0 )
682 || ! increment
683 || ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );
684 shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );
685 zExp = 0;
686 if ( isTiny && zSig1 ) float_raise( float_flag_underflow );
687 if ( zSig1 ) float_exception_flags |= float_flag_inexact;
688 if ( roundNearestEven ) {
689 increment = ( (sbits64) zSig1 < 0 );
690 }
691 else {
692 if ( zSign ) {
693 increment = ( roundingMode == float_round_down ) && zSig1;
694 }
695 else {
696 increment = ( roundingMode == float_round_up ) && zSig1;
697 }
698 }
699 if ( increment ) {
700 ++zSig0;
701 zSig0 &= ~ ( ( zSig1 + zSig1 == 0 ) & roundNearestEven );
702 if ( (sbits64) zSig0 < 0 ) zExp = 1;
703 }
704 return packFloatx80( zSign, zExp, zSig0 );
705 }
706 }
707 if ( zSig1 ) float_exception_flags |= float_flag_inexact;
708 if ( increment ) {
709 ++zSig0;
710 if ( zSig0 == 0 ) {
711 ++zExp;
712 zSig0 = LIT64( 0x8000000000000000 );
713 }
714 else {
715 zSig0 &= ~ ( ( zSig1 + zSig1 == 0 ) & roundNearestEven );
716 }
717 }
718 else {
719 if ( zSig0 == 0 ) zExp = 0;
720 }
721
722 return packFloatx80( zSign, zExp, zSig0 );
723}
724
725/*
726-------------------------------------------------------------------------------
727Takes an abstract floating-point value having sign `zSign', exponent
728`zExp', and significand formed by the concatenation of `zSig0' and `zSig1',
729and returns the proper extended double-precision floating-point value
730corresponding to the abstract input. This routine is just like
731`roundAndPackFloatx80' except that the input significand does not have to be
732normalized.
733-------------------------------------------------------------------------------
734*/
735static floatx80
736 normalizeRoundAndPackFloatx80(
737 int8 roundingPrecision, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1
738 )
739{
740 int8 shiftCount;
741
742 if ( zSig0 == 0 ) {
743 zSig0 = zSig1;
744 zSig1 = 0;
745 zExp -= 64;
746 }
747 shiftCount = countLeadingZeros64( zSig0 );
748 shortShift128Left( zSig0, zSig1, shiftCount, &zSig0, &zSig1 );
749 zExp -= shiftCount;
750 return
751 roundAndPackFloatx80( roundingPrecision, zSign, zExp, zSig0, zSig1 );
752
753}
754
755#endif
756
757/*
758-------------------------------------------------------------------------------
759Returns the result of converting the 32-bit two's complement integer `a' to
760the single-precision floating-point format. The conversion is performed
761according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
762-------------------------------------------------------------------------------
763*/
764float32 int32_to_float32( int32 a )
765{
766 flag zSign;
767
768 if ( a == 0 ) return 0;
769 if ( a == 0x80000000 ) return packFloat32( 1, 0x9E, 0 );
770 zSign = ( a < 0 );
771 return normalizeRoundAndPackFloat32( zSign, 0x9C, zSign ? - a : a );
772
773}
774
775/*
776-------------------------------------------------------------------------------
777Returns the result of converting the 32-bit two's complement integer `a' to
778the double-precision floating-point format. The conversion is performed
779according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
780-------------------------------------------------------------------------------
781*/
782float64 int32_to_float64( int32 a )
783{
784 flag aSign;
785 uint32 absA;
786 int8 shiftCount;
787 bits64 zSig;
788
789 if ( a == 0 ) return 0;
790 aSign = ( a < 0 );
791 absA = aSign ? - a : a;
792 shiftCount = countLeadingZeros32( absA ) + 21;
793 zSig = absA;
794 return packFloat64( aSign, 0x432 - shiftCount, zSig<<shiftCount );
795
796}
797
798#ifdef FLOATX80
799
800/*
801-------------------------------------------------------------------------------
802Returns the result of converting the 32-bit two's complement integer `a'
803to the extended double-precision floating-point format. The conversion
804is performed according to the IEC/IEEE Standard for Binary Floating-point
805Arithmetic.
806-------------------------------------------------------------------------------
807*/
808floatx80 int32_to_floatx80( int32 a )
809{
810 flag zSign;
811 uint32 absA;
812 int8 shiftCount;
813 bits64 zSig;
814
815 if ( a == 0 ) return packFloatx80( 0, 0, 0 );
816 zSign = ( a < 0 );
817 absA = zSign ? - a : a;
818 shiftCount = countLeadingZeros32( absA ) + 32;
819 zSig = absA;
820 return packFloatx80( zSign, 0x403E - shiftCount, zSig<<shiftCount );
821
822}
823
824#endif
825
826/*
827-------------------------------------------------------------------------------
828Returns the result of converting the single-precision floating-point value
829`a' to the 32-bit two's complement integer format. The conversion is
830performed according to the IEC/IEEE Standard for Binary Floating-point
831Arithmetic---which means in particular that the conversion is rounded
832according to the current rounding mode. If `a' is a NaN, the largest
833positive integer is returned. Otherwise, if the conversion overflows, the
834largest integer with the same sign as `a' is returned.
835-------------------------------------------------------------------------------
836*/
837int32 float32_to_int32( float32 a )
838{
839 flag aSign;
840 int16 aExp, shiftCount;
841 bits32 aSig;
842 bits64 zSig;
843
844 aSig = extractFloat32Frac( a );
845 aExp = extractFloat32Exp( a );
846 aSign = extractFloat32Sign( a );
847 if ( ( aExp == 0x7FF ) && aSig ) aSign = 0;
848 if ( aExp ) aSig |= 0x00800000;
849 shiftCount = 0xAF - aExp;
850 zSig = aSig;
851 zSig <<= 32;
852 if ( 0 < shiftCount ) shift64RightJamming( zSig, shiftCount, &zSig );
853 return roundAndPackInt32( aSign, zSig );
854
855}
856
857/*
858-------------------------------------------------------------------------------
859Returns the result of converting the single-precision floating-point value
860`a' to the 32-bit two's complement integer format. The conversion is
861performed according to the IEC/IEEE Standard for Binary Floating-point
862Arithmetic, except that the conversion is always rounded toward zero. If
863`a' is a NaN, the largest positive integer is returned. Otherwise, if the
864conversion overflows, the largest integer with the same sign as `a' is
865returned.
866-------------------------------------------------------------------------------
867*/
868int32 float32_to_int32_round_to_zero( float32 a )
869{
870 flag aSign;
871 int16 aExp, shiftCount;
872 bits32 aSig;
873 int32 z;
874
875 aSig = extractFloat32Frac( a );
876 aExp = extractFloat32Exp( a );
877 aSign = extractFloat32Sign( a );
878 shiftCount = aExp - 0x9E;
879 if ( 0 <= shiftCount ) {
880 if ( a == 0xCF000000 ) return 0x80000000;
881 float_raise( float_flag_invalid );
882 if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF;
883 return 0x80000000;
884 }
885 else if ( aExp <= 0x7E ) {
886 if ( aExp | aSig ) float_exception_flags |= float_flag_inexact;
887 return 0;
888 }
889 aSig = ( aSig | 0x00800000 )<<8;
890 z = aSig>>( - shiftCount );
891 if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) {
892 float_exception_flags |= float_flag_inexact;
893 }
894 return aSign ? - z : z;
895
896}
897
898/*
899-------------------------------------------------------------------------------
900Returns the result of converting the single-precision floating-point value
901`a' to the double-precision floating-point format. The conversion is
902performed according to the IEC/IEEE Standard for Binary Floating-point
903Arithmetic.
904-------------------------------------------------------------------------------
905*/
906float64 float32_to_float64( float32 a )
907{
908 flag aSign;
909 int16 aExp;
910 bits32 aSig;
911
912 aSig = extractFloat32Frac( a );
913 aExp = extractFloat32Exp( a );
914 aSign = extractFloat32Sign( a );
915 if ( aExp == 0xFF ) {
916 if ( aSig ) return commonNaNToFloat64( float32ToCommonNaN( a ) );
917 return packFloat64( aSign, 0x7FF, 0 );
918 }
919 if ( aExp == 0 ) {
920 if ( aSig == 0 ) return packFloat64( aSign, 0, 0 );
921 normalizeFloat32Subnormal( aSig, &aExp, &aSig );
922 --aExp;
923 }
924 return packFloat64( aSign, aExp + 0x380, ( (bits64) aSig )<<29 );
925
926}
927
928#ifdef FLOATX80
929
930/*
931-------------------------------------------------------------------------------
932Returns the result of converting the single-precision floating-point value
933`a' to the extended double-precision floating-point format. The conversion
934is performed according to the IEC/IEEE Standard for Binary Floating-point
935Arithmetic.
936-------------------------------------------------------------------------------
937*/
938floatx80 float32_to_floatx80( float32 a )
939{
940 flag aSign;
941 int16 aExp;
942 bits32 aSig;
943
944 aSig = extractFloat32Frac( a );
945 aExp = extractFloat32Exp( a );
946 aSign = extractFloat32Sign( a );
947 if ( aExp == 0xFF ) {
948 if ( aSig ) return commonNaNToFloatx80( float32ToCommonNaN( a ) );
949 return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
950 }
951 if ( aExp == 0 ) {
952 if ( aSig == 0 ) return packFloatx80( aSign, 0, 0 );
953 normalizeFloat32Subnormal( aSig, &aExp, &aSig );
954 }
955 aSig |= 0x00800000;
956 return packFloatx80( aSign, aExp + 0x3F80, ( (bits64) aSig )<<40 );
957
958}
959
960#endif
961
962/*
963-------------------------------------------------------------------------------
964Rounds the single-precision floating-point value `a' to an integer, and
965returns the result as a single-precision floating-point value. The
966operation is performed according to the IEC/IEEE Standard for Binary
967Floating-point Arithmetic.
968-------------------------------------------------------------------------------
969*/
970float32 float32_round_to_int( float32 a )
971{
972 flag aSign;
973 int16 aExp;
974 bits32 lastBitMask, roundBitsMask;
975 int8 roundingMode;
976 float32 z;
977
978 aExp = extractFloat32Exp( a );
979 if ( 0x96 <= aExp ) {
980 if ( ( aExp == 0xFF ) && extractFloat32Frac( a ) ) {
981 return propagateFloat32NaN( a, a );
982 }
983 return a;
984 }
985 if ( aExp <= 0x7E ) {
986 if ( (bits32) ( a<<1 ) == 0 ) return a;
987 float_exception_flags |= float_flag_inexact;
988 aSign = extractFloat32Sign( a );
989 switch ( float_rounding_mode ) {
990 case float_round_nearest_even:
991 if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) {
992 return packFloat32( aSign, 0x7F, 0 );
993 }
994 break;
995 case float_round_down:
996 return aSign ? 0xBF800000 : 0;
997 case float_round_up:
998 return aSign ? 0x80000000 : 0x3F800000;
999 }
1000 return packFloat32( aSign, 0, 0 );
1001 }
1002 lastBitMask = 1;
1003 lastBitMask <<= 0x96 - aExp;
1004 roundBitsMask = lastBitMask - 1;
1005 z = a;
1006 roundingMode = float_rounding_mode;
1007 if ( roundingMode == float_round_nearest_even ) {
1008 z += lastBitMask>>1;
1009 if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;
1010 }
1011 else if ( roundingMode != float_round_to_zero ) {
1012 if ( extractFloat32Sign( z ) ^ ( roundingMode == float_round_up ) ) {
1013 z += roundBitsMask;
1014 }
1015 }
1016 z &= ~ roundBitsMask;
1017 if ( z != a ) float_exception_flags |= float_flag_inexact;
1018 return z;
1019
1020}
1021
1022/*
1023-------------------------------------------------------------------------------
1024Returns the result of adding the absolute values of the single-precision
1025floating-point values `a' and `b'. If `zSign' is true, the sum is negated
1026before being returned. `zSign' is ignored if the result is a NaN. The
1027addition is performed according to the IEC/IEEE Standard for Binary
1028Floating-point Arithmetic.
1029-------------------------------------------------------------------------------
1030*/
1031static float32 addFloat32Sigs( float32 a, float32 b, flag zSign )
1032{
1033 int16 aExp, bExp, zExp;
1034 bits32 aSig, bSig, zSig;
1035 int16 expDiff;
1036
1037 aSig = extractFloat32Frac( a );
1038 aExp = extractFloat32Exp( a );
1039 bSig = extractFloat32Frac( b );
1040 bExp = extractFloat32Exp( b );
1041 expDiff = aExp - bExp;
1042 aSig <<= 6;
1043 bSig <<= 6;
1044 if ( 0 < expDiff ) {
1045 if ( aExp == 0xFF ) {
1046 if ( aSig ) return propagateFloat32NaN( a, b );
1047 return a;
1048 }
1049 if ( bExp == 0 ) {
1050 --expDiff;
1051 }
1052 else {
1053 bSig |= 0x20000000;
1054 }
1055 shift32RightJamming( bSig, expDiff, &bSig );
1056 zExp = aExp;
1057 }
1058 else if ( expDiff < 0 ) {
1059 if ( bExp == 0xFF ) {
1060 if ( bSig ) return propagateFloat32NaN( a, b );
1061 return packFloat32( zSign, 0xFF, 0 );
1062 }
1063 if ( aExp == 0 ) {
1064 ++expDiff;
1065 }
1066 else {
1067 aSig |= 0x20000000;
1068 }
1069 shift32RightJamming( aSig, - expDiff, &aSig );
1070 zExp = bExp;
1071 }
1072 else {
1073 if ( aExp == 0xFF ) {
1074 if ( aSig | bSig ) return propagateFloat32NaN( a, b );
1075 return a;
1076 }
1077 if ( aExp == 0 ) return packFloat32( zSign, 0, ( aSig + bSig )>>6 );
1078 zSig = 0x40000000 + aSig + bSig;
1079 zExp = aExp;
1080 goto roundAndPack;
1081 }
1082 aSig |= 0x20000000;
1083 zSig = ( aSig + bSig )<<1;
1084 --zExp;
1085 if ( (sbits32) zSig < 0 ) {
1086 zSig = aSig + bSig;
1087 ++zExp;
1088 }
1089 roundAndPack:
1090 return roundAndPackFloat32( zSign, zExp, zSig );
1091
1092}
1093
1094/*
1095-------------------------------------------------------------------------------
1096Returns the result of subtracting the absolute values of the single-
1097precision floating-point values `a' and `b'. If `zSign' is true, the
1098difference is negated before being returned. `zSign' is ignored if the
1099result is a NaN. The subtraction is performed according to the IEC/IEEE
1100Standard for Binary Floating-point Arithmetic.
1101-------------------------------------------------------------------------------
1102*/
1103static float32 subFloat32Sigs( float32 a, float32 b, flag zSign )
1104{
1105 int16 aExp, bExp, zExp;
1106 bits32 aSig, bSig, zSig;
1107 int16 expDiff;
1108
1109 aSig = extractFloat32Frac( a );
1110 aExp = extractFloat32Exp( a );
1111 bSig = extractFloat32Frac( b );
1112 bExp = extractFloat32Exp( b );
1113 expDiff = aExp - bExp;
1114 aSig <<= 7;
1115 bSig <<= 7;
1116 if ( 0 < expDiff ) goto aExpBigger;
1117 if ( expDiff < 0 ) goto bExpBigger;
1118 if ( aExp == 0xFF ) {
1119 if ( aSig | bSig ) return propagateFloat32NaN( a, b );
1120 float_raise( float_flag_invalid );
1121 return float32_default_nan;
1122 }
1123 if ( aExp == 0 ) {
1124 aExp = 1;
1125 bExp = 1;
1126 }
1127 if ( bSig < aSig ) goto aBigger;
1128 if ( aSig < bSig ) goto bBigger;
1129 return packFloat32( float_rounding_mode == float_round_down, 0, 0 );
1130 bExpBigger:
1131 if ( bExp == 0xFF ) {
1132 if ( bSig ) return propagateFloat32NaN( a, b );
1133 return packFloat32( zSign ^ 1, 0xFF, 0 );
1134 }
1135 if ( aExp == 0 ) {
1136 ++expDiff;
1137 }
1138 else {
1139 aSig |= 0x40000000;
1140 }
1141 shift32RightJamming( aSig, - expDiff, &aSig );
1142 bSig |= 0x40000000;
1143 bBigger:
1144 zSig = bSig - aSig;
1145 zExp = bExp;
1146 zSign ^= 1;
1147 goto normalizeRoundAndPack;
1148 aExpBigger:
1149 if ( aExp == 0xFF ) {
1150 if ( aSig ) return propagateFloat32NaN( a, b );
1151 return a;
1152 }
1153 if ( bExp == 0 ) {
1154 --expDiff;
1155 }
1156 else {
1157 bSig |= 0x40000000;
1158 }
1159 shift32RightJamming( bSig, expDiff, &bSig );
1160 aSig |= 0x40000000;
1161 aBigger:
1162 zSig = aSig - bSig;
1163 zExp = aExp;
1164 normalizeRoundAndPack:
1165 --zExp;
1166 return normalizeRoundAndPackFloat32( zSign, zExp, zSig );
1167
1168}
1169
1170/*
1171-------------------------------------------------------------------------------
1172Returns the result of adding the single-precision floating-point values `a'
1173and `b'. The operation is performed according to the IEC/IEEE Standard for
1174Binary Floating-point Arithmetic.
1175-------------------------------------------------------------------------------
1176*/
1177float32 float32_add( float32 a, float32 b )
1178{
1179 flag aSign, bSign;
1180
1181 aSign = extractFloat32Sign( a );
1182 bSign = extractFloat32Sign( b );
1183 if ( aSign == bSign ) {
1184 return addFloat32Sigs( a, b, aSign );
1185 }
1186 else {
1187 return subFloat32Sigs( a, b, aSign );
1188 }
1189
1190}
1191
1192/*
1193-------------------------------------------------------------------------------
1194Returns the result of subtracting the single-precision floating-point values
1195`a' and `b'. The operation is performed according to the IEC/IEEE Standard
1196for Binary Floating-point Arithmetic.
1197-------------------------------------------------------------------------------
1198*/
1199float32 float32_sub( float32 a, float32 b )
1200{
1201 flag aSign, bSign;
1202
1203 aSign = extractFloat32Sign( a );
1204 bSign = extractFloat32Sign( b );
1205 if ( aSign == bSign ) {
1206 return subFloat32Sigs( a, b, aSign );
1207 }
1208 else {
1209 return addFloat32Sigs( a, b, aSign );
1210 }
1211
1212}
1213
1214/*
1215-------------------------------------------------------------------------------
1216Returns the result of multiplying the single-precision floating-point values
1217`a' and `b'. The operation is performed according to the IEC/IEEE Standard
1218for Binary Floating-point Arithmetic.
1219-------------------------------------------------------------------------------
1220*/
1221float32 float32_mul( float32 a, float32 b )
1222{
1223 flag aSign, bSign, zSign;
1224 int16 aExp, bExp, zExp;
1225 bits32 aSig, bSig;
1226 bits64 zSig64;
1227 bits32 zSig;
1228
1229 aSig = extractFloat32Frac( a );
1230 aExp = extractFloat32Exp( a );
1231 aSign = extractFloat32Sign( a );
1232 bSig = extractFloat32Frac( b );
1233 bExp = extractFloat32Exp( b );
1234 bSign = extractFloat32Sign( b );
1235 zSign = aSign ^ bSign;
1236 if ( aExp == 0xFF ) {
1237 if ( aSig || ( ( bExp == 0xFF ) && bSig ) ) {
1238 return propagateFloat32NaN( a, b );
1239 }
1240 if ( ( bExp | bSig ) == 0 ) {
1241 float_raise( float_flag_invalid );
1242 return float32_default_nan;
1243 }
1244 return packFloat32( zSign, 0xFF, 0 );
1245 }
1246 if ( bExp == 0xFF ) {
1247 if ( bSig ) return propagateFloat32NaN( a, b );
1248 if ( ( aExp | aSig ) == 0 ) {
1249 float_raise( float_flag_invalid );
1250 return float32_default_nan;
1251 }
1252 return packFloat32( zSign, 0xFF, 0 );
1253 }
1254 if ( aExp == 0 ) {
1255 if ( aSig == 0 ) return packFloat32( zSign, 0, 0 );
1256 normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1257 }
1258 if ( bExp == 0 ) {
1259 if ( bSig == 0 ) return packFloat32( zSign, 0, 0 );
1260 normalizeFloat32Subnormal( bSig, &bExp, &bSig );
1261 }
1262 zExp = aExp + bExp - 0x7F;
1263 aSig = ( aSig | 0x00800000 )<<7;
1264 bSig = ( bSig | 0x00800000 )<<8;
1265 shift64RightJamming( ( (bits64) aSig ) * bSig, 32, &zSig64 );
1266 zSig = zSig64;
1267 if ( 0 <= (sbits32) ( zSig<<1 ) ) {
1268 zSig <<= 1;
1269 --zExp;
1270 }
1271 return roundAndPackFloat32( zSign, zExp, zSig );
1272
1273}
1274
1275/*
1276-------------------------------------------------------------------------------
1277Returns the result of dividing the single-precision floating-point value `a'
1278by the corresponding value `b'. The operation is performed according to the
1279IEC/IEEE Standard for Binary Floating-point Arithmetic.
1280-------------------------------------------------------------------------------
1281*/
1282float32 float32_div( float32 a, float32 b )
1283{
1284 flag aSign, bSign, zSign;
1285 int16 aExp, bExp, zExp;
1286 bits32 aSig, bSig, zSig;
1287
1288 aSig = extractFloat32Frac( a );
1289 aExp = extractFloat32Exp( a );
1290 aSign = extractFloat32Sign( a );
1291 bSig = extractFloat32Frac( b );
1292 bExp = extractFloat32Exp( b );
1293 bSign = extractFloat32Sign( b );
1294 zSign = aSign ^ bSign;
1295 if ( aExp == 0xFF ) {
1296 if ( aSig ) return propagateFloat32NaN( a, b );
1297 if ( bExp == 0xFF ) {
1298 if ( bSig ) return propagateFloat32NaN( a, b );
1299 float_raise( float_flag_invalid );
1300 return float32_default_nan;
1301 }
1302 return packFloat32( zSign, 0xFF, 0 );
1303 }
1304 if ( bExp == 0xFF ) {
1305 if ( bSig ) return propagateFloat32NaN( a, b );
1306 return packFloat32( zSign, 0, 0 );
1307 }
1308 if ( bExp == 0 ) {
1309 if ( bSig == 0 ) {
1310 if ( ( aExp | aSig ) == 0 ) {
1311 float_raise( float_flag_invalid );
1312 return float32_default_nan;
1313 }
1314 float_raise( float_flag_divbyzero );
1315 return packFloat32( zSign, 0xFF, 0 );
1316 }
1317 normalizeFloat32Subnormal( bSig, &bExp, &bSig );
1318 }
1319 if ( aExp == 0 ) {
1320 if ( aSig == 0 ) return packFloat32( zSign, 0, 0 );
1321 normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1322 }
1323 zExp = aExp - bExp + 0x7D;
1324 aSig = ( aSig | 0x00800000 )<<7;
1325 bSig = ( bSig | 0x00800000 )<<8;
1326 if ( bSig <= ( aSig + aSig ) ) {
1327 aSig >>= 1;
1328 ++zExp;
1329 }
1330 zSig = ( ( (bits64) aSig )<<32 ) / bSig;
1331 if ( ( zSig & 0x3F ) == 0 ) {
1332 zSig |= ( ( (bits64) bSig ) * zSig != ( (bits64) aSig )<<32 );
1333 }
1334 return roundAndPackFloat32( zSign, zExp, zSig );
1335
1336}
1337
1338/*
1339-------------------------------------------------------------------------------
1340Returns the remainder of the single-precision floating-point value `a'
1341with respect to the corresponding value `b'. The operation is performed
1342according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
1343-------------------------------------------------------------------------------
1344*/
1345float32 float32_rem( float32 a, float32 b )
1346{
1347 flag aSign, bSign, zSign;
1348 int16 aExp, bExp, expDiff;
1349 bits32 aSig, bSig;
1350 bits32 q;
1351 bits64 aSig64, bSig64, q64;
1352 bits32 alternateASig;
1353 sbits32 sigMean;
1354
1355 aSig = extractFloat32Frac( a );
1356 aExp = extractFloat32Exp( a );
1357 aSign = extractFloat32Sign( a );
1358 bSig = extractFloat32Frac( b );
1359 bExp = extractFloat32Exp( b );
1360 bSign = extractFloat32Sign( b );
1361 if ( aExp == 0xFF ) {
1362 if ( aSig || ( ( bExp == 0xFF ) && bSig ) ) {
1363 return propagateFloat32NaN( a, b );
1364 }
1365 float_raise( float_flag_invalid );
1366 return float32_default_nan;
1367 }
1368 if ( bExp == 0xFF ) {
1369 if ( bSig ) return propagateFloat32NaN( a, b );
1370 return a;
1371 }
1372 if ( bExp == 0 ) {
1373 if ( bSig == 0 ) {
1374 float_raise( float_flag_invalid );
1375 return float32_default_nan;
1376 }
1377 normalizeFloat32Subnormal( bSig, &bExp, &bSig );
1378 }
1379 if ( aExp == 0 ) {
1380 if ( aSig == 0 ) return a;
1381 normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1382 }
1383 expDiff = aExp - bExp;
1384 aSig |= 0x00800000;
1385 bSig |= 0x00800000;
1386 if ( expDiff < 32 ) {
1387 aSig <<= 8;
1388 bSig <<= 8;
1389 if ( expDiff < 0 ) {
1390 if ( expDiff < -1 ) return a;
1391 aSig >>= 1;
1392 }
1393 q = ( bSig <= aSig );
1394 if ( q ) aSig -= bSig;
1395 if ( 0 < expDiff ) {
1396 q = ( ( (bits64) aSig )<<32 ) / bSig;
1397 q >>= 32 - expDiff;
1398 bSig >>= 2;
1399 aSig = ( ( aSig>>1 )<<( expDiff - 1 ) ) - bSig * q;
1400 }
1401 else {
1402 aSig >>= 2;
1403 bSig >>= 2;
1404 }
1405 }
1406 else {
1407 if ( bSig <= aSig ) aSig -= bSig;
1408 aSig64 = ( (bits64) aSig )<<40;
1409 bSig64 = ( (bits64) bSig )<<40;
1410 expDiff -= 64;
1411 while ( 0 < expDiff ) {
1412 q64 = estimateDiv128To64( aSig64, 0, bSig64 );
1413 q64 = ( 2 < q64 ) ? q64 - 2 : 0;
1414 aSig64 = - ( ( bSig * q64 )<<38 );
1415 expDiff -= 62;
1416 }
1417 expDiff += 64;
1418 q64 = estimateDiv128To64( aSig64, 0, bSig64 );
1419 q64 = ( 2 < q64 ) ? q64 - 2 : 0;
1420 q = q64>>( 64 - expDiff );
1421 bSig <<= 6;
1422 aSig = ( ( aSig64>>33 )<<( expDiff - 1 ) ) - bSig * q;
1423 }
1424 do {
1425 alternateASig = aSig;
1426 ++q;
1427 aSig -= bSig;
1428 } while ( 0 <= (sbits32) aSig );
1429 sigMean = aSig + alternateASig;
1430 if ( ( sigMean < 0 ) || ( ( sigMean == 0 ) && ( q & 1 ) ) ) {
1431 aSig = alternateASig;
1432 }
1433 zSign = ( (sbits32) aSig < 0 );
1434 if ( zSign ) aSig = - aSig;
1435 return normalizeRoundAndPackFloat32( aSign ^ zSign, bExp, aSig );
1436
1437}
1438
1439/*
1440-------------------------------------------------------------------------------
1441Returns the square root of the single-precision floating-point value `a'.
1442The operation is performed according to the IEC/IEEE Standard for Binary
1443Floating-point Arithmetic.
1444-------------------------------------------------------------------------------
1445*/
1446float32 float32_sqrt( float32 a )
1447{
1448 flag aSign;
1449 int16 aExp, zExp;
1450 bits32 aSig, zSig;
1451 bits64 rem, term;
1452
1453 aSig = extractFloat32Frac( a );
1454 aExp = extractFloat32Exp( a );
1455 aSign = extractFloat32Sign( a );
1456 if ( aExp == 0xFF ) {
1457 if ( aSig ) return propagateFloat32NaN( a, 0 );
1458 if ( ! aSign ) return a;
1459 float_raise( float_flag_invalid );
1460 return float32_default_nan;
1461 }
1462 if ( aSign ) {
1463 if ( ( aExp | aSig ) == 0 ) return a;
1464 float_raise( float_flag_invalid );
1465 return float32_default_nan;
1466 }
1467 if ( aExp == 0 ) {
1468 if ( aSig == 0 ) return 0;
1469 normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1470 }
1471 zExp = ( ( aExp - 0x7F )>>1 ) + 0x7E;
1472 aSig = ( aSig | 0x00800000 )<<8;
1473 zSig = estimateSqrt32( aExp, aSig ) + 2;
1474 if ( ( zSig & 0x7F ) <= 5 ) {
1475 if ( zSig < 2 ) {
1476 zSig = 0xFFFFFFFF;
1477 }
1478 else {
1479 aSig >>= aExp & 1;
1480 term = ( (bits64) zSig ) * zSig;
1481 rem = ( ( (bits64) aSig )<<32 ) - term;
1482 while ( (sbits64) rem < 0 ) {
1483 --zSig;
1484 rem += ( ( (bits64) zSig )<<1 ) | 1;
1485 }
1486 zSig |= ( rem != 0 );
1487 }
1488 }
1489 shift32RightJamming( zSig, 1, &zSig );
1490 return roundAndPackFloat32( 0, zExp, zSig );
1491
1492}
1493
1494/*
1495-------------------------------------------------------------------------------
1496Returns 1 if the single-precision floating-point value `a' is equal to the
1497corresponding value `b', and 0 otherwise. The comparison is performed
1498according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
1499-------------------------------------------------------------------------------
1500*/
1501flag float32_eq( float32 a, float32 b )
1502{
1503
1504 if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
1505 || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
1506 ) {
1507 if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) {
1508 float_raise( float_flag_invalid );
1509 }
1510 return 0;
1511 }
1512 return ( a == b ) || ( (bits32) ( ( a | b )<<1 ) == 0 );
1513
1514}
1515
1516/*
1517-------------------------------------------------------------------------------
1518Returns 1 if the single-precision floating-point value `a' is less than or
1519equal to the corresponding value `b', and 0 otherwise. The comparison is
1520performed according to the IEC/IEEE Standard for Binary Floating-point
1521Arithmetic.
1522-------------------------------------------------------------------------------
1523*/
1524flag float32_le( float32 a, float32 b )
1525{
1526 flag aSign, bSign;
1527
1528 if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
1529 || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
1530 ) {
1531 float_raise( float_flag_invalid );
1532 return 0;
1533 }
1534 aSign = extractFloat32Sign( a );
1535 bSign = extractFloat32Sign( b );
1536 if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 );
1537 return ( a == b ) || ( aSign ^ ( a < b ) );
1538
1539}
1540
1541/*
1542-------------------------------------------------------------------------------
1543Returns 1 if the single-precision floating-point value `a' is less than
1544the corresponding value `b', and 0 otherwise. The comparison is performed
1545according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
1546-------------------------------------------------------------------------------
1547*/
1548flag float32_lt( float32 a, float32 b )
1549{
1550 flag aSign, bSign;
1551
1552 if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
1553 || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
1554 ) {
1555 float_raise( float_flag_invalid );
1556 return 0;
1557 }
1558 aSign = extractFloat32Sign( a );
1559 bSign = extractFloat32Sign( b );
1560 if ( aSign != bSign ) return aSign && ( (bits32) ( ( a | b )<<1 ) != 0 );
1561 return ( a != b ) && ( aSign ^ ( a < b ) );
1562
1563}
1564
1565/*
1566-------------------------------------------------------------------------------
1567Returns 1 if the single-precision floating-point value `a' is equal to the
1568corresponding value `b', and 0 otherwise. The invalid exception is raised
1569if either operand is a NaN. Otherwise, the comparison is performed
1570according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
1571-------------------------------------------------------------------------------
1572*/
1573flag float32_eq_signaling( float32 a, float32 b )
1574{
1575
1576 if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
1577 || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
1578 ) {
1579 float_raise( float_flag_invalid );
1580 return 0;
1581 }
1582 return ( a == b ) || ( (bits32) ( ( a | b )<<1 ) == 0 );
1583
1584}
1585
1586/*
1587-------------------------------------------------------------------------------
1588Returns 1 if the single-precision floating-point value `a' is less than or
1589equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not
1590cause an exception. Otherwise, the comparison is performed according to the
1591IEC/IEEE Standard for Binary Floating-point Arithmetic.
1592-------------------------------------------------------------------------------
1593*/
1594flag float32_le_quiet( float32 a, float32 b )
1595{
1596 flag aSign, bSign;
1597 //int16 aExp, bExp;
1598
1599 if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
1600 || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
1601 ) {
1602 if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) {
1603 float_raise( float_flag_invalid );
1604 }
1605 return 0;
1606 }
1607 aSign = extractFloat32Sign( a );
1608 bSign = extractFloat32Sign( b );
1609 if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 );
1610 return ( a == b ) || ( aSign ^ ( a < b ) );
1611
1612}
1613
1614/*
1615-------------------------------------------------------------------------------
1616Returns 1 if the single-precision floating-point value `a' is less than
1617the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an
1618exception. Otherwise, the comparison is performed according to the IEC/IEEE
1619Standard for Binary Floating-point Arithmetic.
1620-------------------------------------------------------------------------------
1621*/
1622flag float32_lt_quiet( float32 a, float32 b )
1623{
1624 flag aSign, bSign;
1625
1626 if ( ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
1627 || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
1628 ) {
1629 if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) {
1630 float_raise( float_flag_invalid );
1631 }
1632 return 0;
1633 }
1634 aSign = extractFloat32Sign( a );
1635 bSign = extractFloat32Sign( b );
1636 if ( aSign != bSign ) return aSign && ( (bits32) ( ( a | b )<<1 ) != 0 );
1637 return ( a != b ) && ( aSign ^ ( a < b ) );
1638
1639}
1640
1641/*
1642-------------------------------------------------------------------------------
1643Returns the result of converting the double-precision floating-point value
1644`a' to the 32-bit two's complement integer format. The conversion is
1645performed according to the IEC/IEEE Standard for Binary Floating-point
1646Arithmetic---which means in particular that the conversion is rounded
1647according to the current rounding mode. If `a' is a NaN, the largest
1648positive integer is returned. Otherwise, if the conversion overflows, the
1649largest integer with the same sign as `a' is returned.
1650-------------------------------------------------------------------------------
1651*/
1652int32 float64_to_int32( float64 a )
1653{
1654 flag aSign;
1655 int16 aExp, shiftCount;
1656 bits64 aSig;
1657
1658 aSig = extractFloat64Frac( a );
1659 aExp = extractFloat64Exp( a );
1660 aSign = extractFloat64Sign( a );
1661 if ( ( aExp == 0x7FF ) && aSig ) aSign = 0;
1662 if ( aExp ) aSig |= LIT64( 0x0010000000000000 );
1663 shiftCount = 0x42C - aExp;
1664 if ( 0 < shiftCount ) shift64RightJamming( aSig, shiftCount, &aSig );
1665 return roundAndPackInt32( aSign, aSig );
1666
1667}
1668
1669/*
1670-------------------------------------------------------------------------------
1671Returns the result of converting the double-precision floating-point value
1672`a' to the 32-bit two's complement integer format. The conversion is
1673performed according to the IEC/IEEE Standard for Binary Floating-point
1674Arithmetic, except that the conversion is always rounded toward zero. If
1675`a' is a NaN, the largest positive integer is returned. Otherwise, if the
1676conversion overflows, the largest integer with the same sign as `a' is
1677returned.
1678-------------------------------------------------------------------------------
1679*/
1680int32 float64_to_int32_round_to_zero( float64 a )
1681{
1682 flag aSign;
1683 int16 aExp, shiftCount;
1684 bits64 aSig, savedASig;
1685 int32 z;
1686
1687 aSig = extractFloat64Frac( a );
1688 aExp = extractFloat64Exp( a );
1689 aSign = extractFloat64Sign( a );
1690 shiftCount = 0x433 - aExp;
1691 if ( shiftCount < 21 ) {
1692 if ( ( aExp == 0x7FF ) && aSig ) aSign = 0;
1693 goto invalid;
1694 }
1695 else if ( 52 < shiftCount ) {
1696 if ( aExp || aSig ) float_exception_flags |= float_flag_inexact;
1697 return 0;
1698 }
1699 aSig |= LIT64( 0x0010000000000000 );
1700 savedASig = aSig;
1701 aSig >>= shiftCount;
1702 z = aSig;
1703 if ( aSign ) z = - z;
1704 if ( ( z < 0 ) ^ aSign ) {
1705 invalid:
1706 float_exception_flags |= float_flag_invalid;
1707 return aSign ? 0x80000000 : 0x7FFFFFFF;
1708 }
1709 if ( ( aSig<<shiftCount ) != savedASig ) {
1710 float_exception_flags |= float_flag_inexact;
1711 }
1712 return z;
1713
1714}
1715
1716/*
1717-------------------------------------------------------------------------------
1718Returns the result of converting the double-precision floating-point value
1719`a' to the 32-bit two's complement unsigned integer format. The conversion
1720is performed according to the IEC/IEEE Standard for Binary Floating-point
1721Arithmetic---which means in particular that the conversion is rounded
1722according to the current rounding mode. If `a' is a NaN, the largest
1723positive integer is returned. Otherwise, if the conversion overflows, the
1724largest positive integer is returned.
1725-------------------------------------------------------------------------------
1726*/
1727int32 float64_to_uint32( float64 a )
1728{
1729 flag aSign;
1730 int16 aExp, shiftCount;
1731 bits64 aSig;
1732
1733 aSig = extractFloat64Frac( a );
1734 aExp = extractFloat64Exp( a );
1735 aSign = 0; //extractFloat64Sign( a );
1736 //if ( ( aExp == 0x7FF ) && aSig ) aSign = 0;
1737 if ( aExp ) aSig |= LIT64( 0x0010000000000000 );
1738 shiftCount = 0x42C - aExp;
1739 if ( 0 < shiftCount ) shift64RightJamming( aSig, shiftCount, &aSig );
1740 return roundAndPackInt32( aSign, aSig );
1741}
1742
1743/*
1744-------------------------------------------------------------------------------
1745Returns the result of converting the double-precision floating-point value
1746`a' to the 32-bit two's complement integer format. The conversion is
1747performed according to the IEC/IEEE Standard for Binary Floating-point
1748Arithmetic, except that the conversion is always rounded toward zero. If
1749`a' is a NaN, the largest positive integer is returned. Otherwise, if the
1750conversion overflows, the largest positive integer is returned.
1751-------------------------------------------------------------------------------
1752*/
1753int32 float64_to_uint32_round_to_zero( float64 a )
1754{
1755 flag aSign;
1756 int16 aExp, shiftCount;
1757 bits64 aSig, savedASig;
1758 int32 z;
1759
1760 aSig = extractFloat64Frac( a );
1761 aExp = extractFloat64Exp( a );
1762 aSign = extractFloat64Sign( a );
1763 shiftCount = 0x433 - aExp;
1764 if ( shiftCount < 21 ) {
1765 if ( ( aExp == 0x7FF ) && aSig ) aSign = 0;
1766 goto invalid;
1767 }
1768 else if ( 52 < shiftCount ) {
1769 if ( aExp || aSig ) float_exception_flags |= float_flag_inexact;
1770 return 0;
1771 }
1772 aSig |= LIT64( 0x0010000000000000 );
1773 savedASig = aSig;
1774 aSig >>= shiftCount;
1775 z = aSig;
1776 if ( aSign ) z = - z;
1777 if ( ( z < 0 ) ^ aSign ) {
1778 invalid:
1779 float_exception_flags |= float_flag_invalid;
1780 return aSign ? 0x80000000 : 0x7FFFFFFF;
1781 }
1782 if ( ( aSig<<shiftCount ) != savedASig ) {
1783 float_exception_flags |= float_flag_inexact;
1784 }
1785 return z;
1786}
1787
1788/*
1789-------------------------------------------------------------------------------
1790Returns the result of converting the double-precision floating-point value
1791`a' to the single-precision floating-point format. The conversion is
1792performed according to the IEC/IEEE Standard for Binary Floating-point
1793Arithmetic.
1794-------------------------------------------------------------------------------
1795*/
1796float32 float64_to_float32( float64 a )
1797{
1798 flag aSign;
1799 int16 aExp;
1800 bits64 aSig;
1801 bits32 zSig;
1802
1803 aSig = extractFloat64Frac( a );
1804 aExp = extractFloat64Exp( a );
1805 aSign = extractFloat64Sign( a );
1806 if ( aExp == 0x7FF ) {
1807 if ( aSig ) return commonNaNToFloat32( float64ToCommonNaN( a ) );
1808 return packFloat32( aSign, 0xFF, 0 );
1809 }
1810 shift64RightJamming( aSig, 22, &aSig );
1811 zSig = aSig;
1812 if ( aExp || zSig ) {
1813 zSig |= 0x40000000;
1814 aExp -= 0x381;
1815 }
1816 return roundAndPackFloat32( aSign, aExp, zSig );
1817
1818}
1819
1820#ifdef FLOATX80
1821
1822/*
1823-------------------------------------------------------------------------------
1824Returns the result of converting the double-precision floating-point value
1825`a' to the extended double-precision floating-point format. The conversion
1826is performed according to the IEC/IEEE Standard for Binary Floating-point
1827Arithmetic.
1828-------------------------------------------------------------------------------
1829*/
1830floatx80 float64_to_floatx80( float64 a )
1831{
1832 flag aSign;
1833 int16 aExp;
1834 bits64 aSig;
1835
1836 aSig = extractFloat64Frac( a );
1837 aExp = extractFloat64Exp( a );
1838 aSign = extractFloat64Sign( a );
1839 if ( aExp == 0x7FF ) {
1840 if ( aSig ) return commonNaNToFloatx80( float64ToCommonNaN( a ) );
1841 return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
1842 }
1843 if ( aExp == 0 ) {
1844 if ( aSig == 0 ) return packFloatx80( aSign, 0, 0 );
1845 normalizeFloat64Subnormal( aSig, &aExp, &aSig );
1846 }
1847 return
1848 packFloatx80(
1849 aSign, aExp + 0x3C00, ( aSig | LIT64( 0x0010000000000000 ) )<<11 );
1850
1851}
1852
1853#endif
1854
1855/*
1856-------------------------------------------------------------------------------
1857Rounds the double-precision floating-point value `a' to an integer, and
1858returns the result as a double-precision floating-point value. The
1859operation is performed according to the IEC/IEEE Standard for Binary
1860Floating-point Arithmetic.
1861-------------------------------------------------------------------------------
1862*/
1863float64 float64_round_to_int( float64 a )
1864{
1865 flag aSign;
1866 int16 aExp;
1867 bits64 lastBitMask, roundBitsMask;
1868 int8 roundingMode;
1869 float64 z;
1870
1871 aExp = extractFloat64Exp( a );
1872 if ( 0x433 <= aExp ) {
1873 if ( ( aExp == 0x7FF ) && extractFloat64Frac( a ) ) {
1874 return propagateFloat64NaN( a, a );
1875 }
1876 return a;
1877 }
1878 if ( aExp <= 0x3FE ) {
1879 if ( (bits64) ( a<<1 ) == 0 ) return a;
1880 float_exception_flags |= float_flag_inexact;
1881 aSign = extractFloat64Sign( a );
1882 switch ( float_rounding_mode ) {
1883 case float_round_nearest_even:
1884 if ( ( aExp == 0x3FE ) && extractFloat64Frac( a ) ) {
1885 return packFloat64( aSign, 0x3FF, 0 );
1886 }
1887 break;
1888 case float_round_down:
1889 return aSign ? LIT64( 0xBFF0000000000000 ) : 0;
1890 case float_round_up:
1891 return
1892 aSign ? LIT64( 0x8000000000000000 ) : LIT64( 0x3FF0000000000000 );
1893 }
1894 return packFloat64( aSign, 0, 0 );
1895 }
1896 lastBitMask = 1;
1897 lastBitMask <<= 0x433 - aExp;
1898 roundBitsMask = lastBitMask - 1;
1899 z = a;
1900 roundingMode = float_rounding_mode;
1901 if ( roundingMode == float_round_nearest_even ) {
1902 z += lastBitMask>>1;
1903 if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;
1904 }
1905 else if ( roundingMode != float_round_to_zero ) {
1906 if ( extractFloat64Sign( z ) ^ ( roundingMode == float_round_up ) ) {
1907 z += roundBitsMask;
1908 }
1909 }
1910 z &= ~ roundBitsMask;
1911 if ( z != a ) float_exception_flags |= float_flag_inexact;
1912 return z;
1913
1914}
1915
1916/*
1917-------------------------------------------------------------------------------
1918Returns the result of adding the absolute values of the double-precision
1919floating-point values `a' and `b'. If `zSign' is true, the sum is negated
1920before being returned. `zSign' is ignored if the result is a NaN. The
1921addition is performed according to the IEC/IEEE Standard for Binary
1922Floating-point Arithmetic.
1923-------------------------------------------------------------------------------
1924*/
1925static float64 addFloat64Sigs( float64 a, float64 b, flag zSign )
1926{
1927 int16 aExp, bExp, zExp;
1928 bits64 aSig, bSig, zSig;
1929 int16 expDiff;
1930
1931 aSig = extractFloat64Frac( a );
1932 aExp = extractFloat64Exp( a );
1933 bSig = extractFloat64Frac( b );
1934 bExp = extractFloat64Exp( b );
1935 expDiff = aExp - bExp;
1936 aSig <<= 9;
1937 bSig <<= 9;
1938 if ( 0 < expDiff ) {
1939 if ( aExp == 0x7FF ) {
1940 if ( aSig ) return propagateFloat64NaN( a, b );
1941 return a;
1942 }
1943 if ( bExp == 0 ) {
1944 --expDiff;
1945 }
1946 else {
1947 bSig |= LIT64( 0x2000000000000000 );
1948 }
1949 shift64RightJamming( bSig, expDiff, &bSig );
1950 zExp = aExp;
1951 }
1952 else if ( expDiff < 0 ) {
1953 if ( bExp == 0x7FF ) {
1954 if ( bSig ) return propagateFloat64NaN( a, b );
1955 return packFloat64( zSign, 0x7FF, 0 );
1956 }
1957 if ( aExp == 0 ) {
1958 ++expDiff;
1959 }
1960 else {
1961 aSig |= LIT64( 0x2000000000000000 );
1962 }
1963 shift64RightJamming( aSig, - expDiff, &aSig );
1964 zExp = bExp;
1965 }
1966 else {
1967 if ( aExp == 0x7FF ) {
1968 if ( aSig | bSig ) return propagateFloat64NaN( a, b );
1969 return a;
1970 }
1971 if ( aExp == 0 ) return packFloat64( zSign, 0, ( aSig + bSig )>>9 );
1972 zSig = LIT64( 0x4000000000000000 ) + aSig + bSig;
1973 zExp = aExp;
1974 goto roundAndPack;
1975 }
1976 aSig |= LIT64( 0x2000000000000000 );
1977 zSig = ( aSig + bSig )<<1;
1978 --zExp;
1979 if ( (sbits64) zSig < 0 ) {
1980 zSig = aSig + bSig;
1981 ++zExp;
1982 }
1983 roundAndPack:
1984 return roundAndPackFloat64( zSign, zExp, zSig );
1985
1986}
1987
1988/*
1989-------------------------------------------------------------------------------
1990Returns the result of subtracting the absolute values of the double-
1991precision floating-point values `a' and `b'. If `zSign' is true, the
1992difference is negated before being returned. `zSign' is ignored if the
1993result is a NaN. The subtraction is performed according to the IEC/IEEE
1994Standard for Binary Floating-point Arithmetic.
1995-------------------------------------------------------------------------------
1996*/
1997static float64 subFloat64Sigs( float64 a, float64 b, flag zSign )
1998{
1999 int16 aExp, bExp, zExp;
2000 bits64 aSig, bSig, zSig;
2001 int16 expDiff;
2002
2003 aSig = extractFloat64Frac( a );
2004 aExp = extractFloat64Exp( a );
2005 bSig = extractFloat64Frac( b );
2006 bExp = extractFloat64Exp( b );
2007 expDiff = aExp - bExp;
2008 aSig <<= 10;
2009 bSig <<= 10;
2010 if ( 0 < expDiff ) goto aExpBigger;
2011 if ( expDiff < 0 ) goto bExpBigger;
2012 if ( aExp == 0x7FF ) {
2013 if ( aSig | bSig ) return propagateFloat64NaN( a, b );
2014 float_raise( float_flag_invalid );
2015 return float64_default_nan;
2016 }
2017 if ( aExp == 0 ) {
2018 aExp = 1;
2019 bExp = 1;
2020 }
2021 if ( bSig < aSig ) goto aBigger;
2022 if ( aSig < bSig ) goto bBigger;
2023 return packFloat64( float_rounding_mode == float_round_down, 0, 0 );
2024 bExpBigger:
2025 if ( bExp == 0x7FF ) {
2026 if ( bSig ) return propagateFloat64NaN( a, b );
2027 return packFloat64( zSign ^ 1, 0x7FF, 0 );
2028 }
2029 if ( aExp == 0 ) {
2030 ++expDiff;
2031 }
2032 else {
2033 aSig |= LIT64( 0x4000000000000000 );
2034 }
2035 shift64RightJamming( aSig, - expDiff, &aSig );
2036 bSig |= LIT64( 0x4000000000000000 );
2037 bBigger:
2038 zSig = bSig - aSig;
2039 zExp = bExp;
2040 zSign ^= 1;
2041 goto normalizeRoundAndPack;
2042 aExpBigger:
2043 if ( aExp == 0x7FF ) {
2044 if ( aSig ) return propagateFloat64NaN( a, b );
2045 return a;
2046 }
2047 if ( bExp == 0 ) {
2048 --expDiff;
2049 }
2050 else {
2051 bSig |= LIT64( 0x4000000000000000 );
2052 }
2053 shift64RightJamming( bSig, expDiff, &bSig );
2054 aSig |= LIT64( 0x4000000000000000 );
2055 aBigger:
2056 zSig = aSig - bSig;
2057 zExp = aExp;
2058 normalizeRoundAndPack:
2059 --zExp;
2060 return normalizeRoundAndPackFloat64( zSign, zExp, zSig );
2061
2062}
2063
2064/*
2065-------------------------------------------------------------------------------
2066Returns the result of adding the double-precision floating-point values `a'
2067and `b'. The operation is performed according to the IEC/IEEE Standard for
2068Binary Floating-point Arithmetic.
2069-------------------------------------------------------------------------------
2070*/
2071float64 float64_add( float64 a, float64 b )
2072{
2073 flag aSign, bSign;
2074
2075 aSign = extractFloat64Sign( a );
2076 bSign = extractFloat64Sign( b );
2077 if ( aSign == bSign ) {
2078 return addFloat64Sigs( a, b, aSign );
2079 }
2080 else {
2081 return subFloat64Sigs( a, b, aSign );
2082 }
2083
2084}
2085
2086/*
2087-------------------------------------------------------------------------------
2088Returns the result of subtracting the double-precision floating-point values
2089`a' and `b'. The operation is performed according to the IEC/IEEE Standard
2090for Binary Floating-point Arithmetic.
2091-------------------------------------------------------------------------------
2092*/
2093float64 float64_sub( float64 a, float64 b )
2094{
2095 flag aSign, bSign;
2096
2097 aSign = extractFloat64Sign( a );
2098 bSign = extractFloat64Sign( b );
2099 if ( aSign == bSign ) {
2100 return subFloat64Sigs( a, b, aSign );
2101 }
2102 else {
2103 return addFloat64Sigs( a, b, aSign );
2104 }
2105
2106}
2107
2108/*
2109-------------------------------------------------------------------------------
2110Returns the result of multiplying the double-precision floating-point values
2111`a' and `b'. The operation is performed according to the IEC/IEEE Standard
2112for Binary Floating-point Arithmetic.
2113-------------------------------------------------------------------------------
2114*/
2115float64 float64_mul( float64 a, float64 b )
2116{
2117 flag aSign, bSign, zSign;
2118 int16 aExp, bExp, zExp;
2119 bits64 aSig, bSig, zSig0, zSig1;
2120
2121 aSig = extractFloat64Frac( a );
2122 aExp = extractFloat64Exp( a );
2123 aSign = extractFloat64Sign( a );
2124 bSig = extractFloat64Frac( b );
2125 bExp = extractFloat64Exp( b );
2126 bSign = extractFloat64Sign( b );
2127 zSign = aSign ^ bSign;
2128 if ( aExp == 0x7FF ) {
2129 if ( aSig || ( ( bExp == 0x7FF ) && bSig ) ) {
2130 return propagateFloat64NaN( a, b );
2131 }
2132 if ( ( bExp | bSig ) == 0 ) {
2133 float_raise( float_flag_invalid );
2134 return float64_default_nan;
2135 }
2136 return packFloat64( zSign, 0x7FF, 0 );
2137 }
2138 if ( bExp == 0x7FF ) {
2139 if ( bSig ) return propagateFloat64NaN( a, b );
2140 if ( ( aExp | aSig ) == 0 ) {
2141 float_raise( float_flag_invalid );
2142 return float64_default_nan;
2143 }
2144 return packFloat64( zSign, 0x7FF, 0 );
2145 }
2146 if ( aExp == 0 ) {
2147 if ( aSig == 0 ) return packFloat64( zSign, 0, 0 );
2148 normalizeFloat64Subnormal( aSig, &aExp, &aSig );
2149 }
2150 if ( bExp == 0 ) {
2151 if ( bSig == 0 ) return packFloat64( zSign, 0, 0 );
2152 normalizeFloat64Subnormal( bSig, &bExp, &bSig );
2153 }
2154 zExp = aExp + bExp - 0x3FF;
2155 aSig = ( aSig | LIT64( 0x0010000000000000 ) )<<10;
2156 bSig = ( bSig | LIT64( 0x0010000000000000 ) )<<11;
2157 mul64To128( aSig, bSig, &zSig0, &zSig1 );
2158 zSig0 |= ( zSig1 != 0 );
2159 if ( 0 <= (sbits64) ( zSig0<<1 ) ) {
2160 zSig0 <<= 1;
2161 --zExp;
2162 }
2163 return roundAndPackFloat64( zSign, zExp, zSig0 );
2164
2165}
2166
2167/*
2168-------------------------------------------------------------------------------
2169Returns the result of dividing the double-precision floating-point value `a'
2170by the corresponding value `b'. The operation is performed according to
2171the IEC/IEEE Standard for Binary Floating-point Arithmetic.
2172-------------------------------------------------------------------------------
2173*/
2174float64 float64_div( float64 a, float64 b )
2175{
2176 flag aSign, bSign, zSign;
2177 int16 aExp, bExp, zExp;
2178 bits64 aSig, bSig, zSig;
2179 bits64 rem0, rem1;
2180 bits64 term0, term1;
2181
2182 aSig = extractFloat64Frac( a );
2183 aExp = extractFloat64Exp( a );
2184 aSign = extractFloat64Sign( a );
2185 bSig = extractFloat64Frac( b );
2186 bExp = extractFloat64Exp( b );
2187 bSign = extractFloat64Sign( b );
2188 zSign = aSign ^ bSign;
2189 if ( aExp == 0x7FF ) {
2190 if ( aSig ) return propagateFloat64NaN( a, b );
2191 if ( bExp == 0x7FF ) {
2192 if ( bSig ) return propagateFloat64NaN( a, b );
2193 float_raise( float_flag_invalid );
2194 return float64_default_nan;
2195 }
2196 return packFloat64( zSign, 0x7FF, 0 );
2197 }
2198 if ( bExp == 0x7FF ) {
2199 if ( bSig ) return propagateFloat64NaN( a, b );
2200 return packFloat64( zSign, 0, 0 );
2201 }
2202 if ( bExp == 0 ) {
2203 if ( bSig == 0 ) {
2204 if ( ( aExp | aSig ) == 0 ) {
2205 float_raise( float_flag_invalid );
2206 return float64_default_nan;
2207 }
2208 float_raise( float_flag_divbyzero );
2209 return packFloat64( zSign, 0x7FF, 0 );
2210 }
2211 normalizeFloat64Subnormal( bSig, &bExp, &bSig );
2212 }
2213 if ( aExp == 0 ) {
2214 if ( aSig == 0 ) return packFloat64( zSign, 0, 0 );
2215 normalizeFloat64Subnormal( aSig, &aExp, &aSig );
2216 }
2217 zExp = aExp - bExp + 0x3FD;
2218 aSig = ( aSig | LIT64( 0x0010000000000000 ) )<<10;
2219 bSig = ( bSig | LIT64( 0x0010000000000000 ) )<<11;
2220 if ( bSig <= ( aSig + aSig ) ) {
2221 aSig >>= 1;
2222 ++zExp;
2223 }
2224 zSig = estimateDiv128To64( aSig, 0, bSig );
2225 if ( ( zSig & 0x1FF ) <= 2 ) {
2226 mul64To128( bSig, zSig, &term0, &term1 );
2227 sub128( aSig, 0, term0, term1, &rem0, &rem1 );
2228 while ( (sbits64) rem0 < 0 ) {
2229 --zSig;
2230 add128( rem0, rem1, 0, bSig, &rem0, &rem1 );
2231 }
2232 zSig |= ( rem1 != 0 );
2233 }
2234 return roundAndPackFloat64( zSign, zExp, zSig );
2235
2236}
2237
2238/*
2239-------------------------------------------------------------------------------
2240Returns the remainder of the double-precision floating-point value `a'
2241with respect to the corresponding value `b'. The operation is performed
2242according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
2243-------------------------------------------------------------------------------
2244*/
2245float64 float64_rem( float64 a, float64 b )
2246{
2247 flag aSign, bSign, zSign;
2248 int16 aExp, bExp, expDiff;
2249 bits64 aSig, bSig;
2250 bits64 q, alternateASig;
2251 sbits64 sigMean;
2252
2253 aSig = extractFloat64Frac( a );
2254 aExp = extractFloat64Exp( a );
2255 aSign = extractFloat64Sign( a );
2256 bSig = extractFloat64Frac( b );
2257 bExp = extractFloat64Exp( b );
2258 bSign = extractFloat64Sign( b );
2259 if ( aExp == 0x7FF ) {
2260 if ( aSig || ( ( bExp == 0x7FF ) && bSig ) ) {
2261 return propagateFloat64NaN( a, b );
2262 }
2263 float_raise( float_flag_invalid );
2264 return float64_default_nan;
2265 }
2266 if ( bExp == 0x7FF ) {
2267 if ( bSig ) return propagateFloat64NaN( a, b );
2268 return a;
2269 }
2270 if ( bExp == 0 ) {
2271 if ( bSig == 0 ) {
2272 float_raise( float_flag_invalid );
2273 return float64_default_nan;
2274 }
2275 normalizeFloat64Subnormal( bSig, &bExp, &bSig );
2276 }
2277 if ( aExp == 0 ) {
2278 if ( aSig == 0 ) return a;
2279 normalizeFloat64Subnormal( aSig, &aExp, &aSig );
2280 }
2281 expDiff = aExp - bExp;
2282 aSig = ( aSig | LIT64( 0x0010000000000000 ) )<<11;
2283 bSig = ( bSig | LIT64( 0x0010000000000000 ) )<<11;
2284 if ( expDiff < 0 ) {
2285 if ( expDiff < -1 ) return a;
2286 aSig >>= 1;
2287 }
2288 q = ( bSig <= aSig );
2289 if ( q ) aSig -= bSig;
2290 expDiff -= 64;
2291 while ( 0 < expDiff ) {
2292 q = estimateDiv128To64( aSig, 0, bSig );
2293 q = ( 2 < q ) ? q - 2 : 0;
2294 aSig = - ( ( bSig>>2 ) * q );
2295 expDiff -= 62;
2296 }
2297 expDiff += 64;
2298 if ( 0 < expDiff ) {
2299 q = estimateDiv128To64( aSig, 0, bSig );
2300 q = ( 2 < q ) ? q - 2 : 0;
2301 q >>= 64 - expDiff;
2302 bSig >>= 2;
2303 aSig = ( ( aSig>>1 )<<( expDiff - 1 ) ) - bSig * q;
2304 }
2305 else {
2306 aSig >>= 2;
2307 bSig >>= 2;
2308 }
2309 do {
2310 alternateASig = aSig;
2311 ++q;
2312 aSig -= bSig;
2313 } while ( 0 <= (sbits64) aSig );
2314 sigMean = aSig + alternateASig;
2315 if ( ( sigMean < 0 ) || ( ( sigMean == 0 ) && ( q & 1 ) ) ) {
2316 aSig = alternateASig;
2317 }
2318 zSign = ( (sbits64) aSig < 0 );
2319 if ( zSign ) aSig = - aSig;
2320 return normalizeRoundAndPackFloat64( aSign ^ zSign, bExp, aSig );
2321
2322}
2323
2324/*
2325-------------------------------------------------------------------------------
2326Returns the square root of the double-precision floating-point value `a'.
2327The operation is performed according to the IEC/IEEE Standard for Binary
2328Floating-point Arithmetic.
2329-------------------------------------------------------------------------------
2330*/
2331float64 float64_sqrt( float64 a )
2332{
2333 flag aSign;
2334 int16 aExp, zExp;
2335 bits64 aSig, zSig;
2336 bits64 rem0, rem1, term0, term1; //, shiftedRem;
2337 //float64 z;
2338
2339 aSig = extractFloat64Frac( a );
2340 aExp = extractFloat64Exp( a );
2341 aSign = extractFloat64Sign( a );
2342 if ( aExp == 0x7FF ) {
2343 if ( aSig ) return propagateFloat64NaN( a, a );
2344 if ( ! aSign ) return a;
2345 float_raise( float_flag_invalid );
2346 return float64_default_nan;
2347 }
2348 if ( aSign ) {
2349 if ( ( aExp | aSig ) == 0 ) return a;
2350 float_raise( float_flag_invalid );
2351 return float64_default_nan;
2352 }
2353 if ( aExp == 0 ) {
2354 if ( aSig == 0 ) return 0;
2355 normalizeFloat64Subnormal( aSig, &aExp, &aSig );
2356 }
2357 zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE;
2358 aSig |= LIT64( 0x0010000000000000 );
2359 zSig = estimateSqrt32( aExp, aSig>>21 );
2360 zSig <<= 31;
2361 aSig <<= 9 - ( aExp & 1 );
2362 zSig = estimateDiv128To64( aSig, 0, zSig ) + zSig + 2;
2363 if ( ( zSig & 0x3FF ) <= 5 ) {
2364 if ( zSig < 2 ) {
2365 zSig = LIT64( 0xFFFFFFFFFFFFFFFF );
2366 }
2367 else {
2368 aSig <<= 2;
2369 mul64To128( zSig, zSig, &term0, &term1 );
2370 sub128( aSig, 0, term0, term1, &rem0, &rem1 );
2371 while ( (sbits64) rem0 < 0 ) {
2372 --zSig;
2373 shortShift128Left( 0, zSig, 1, &term0, &term1 );
2374 term1 |= 1;
2375 add128( rem0, rem1, term0, term1, &rem0, &rem1 );
2376 }
2377 zSig |= ( ( rem0 | rem1 ) != 0 );
2378 }
2379 }
2380 shift64RightJamming( zSig, 1, &zSig );
2381 return roundAndPackFloat64( 0, zExp, zSig );
2382
2383}
2384
2385/*
2386-------------------------------------------------------------------------------
2387Returns 1 if the double-precision floating-point value `a' is equal to the
2388corresponding value `b', and 0 otherwise. The comparison is performed
2389according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
2390-------------------------------------------------------------------------------
2391*/
2392flag float64_eq( float64 a, float64 b )
2393{
2394
2395 if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
2396 || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
2397 ) {
2398 if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) {
2399 float_raise( float_flag_invalid );
2400 }
2401 return 0;
2402 }
2403 return ( a == b ) || ( (bits64) ( ( a | b )<<1 ) == 0 );
2404
2405}
2406
2407/*
2408-------------------------------------------------------------------------------
2409Returns 1 if the double-precision floating-point value `a' is less than or
2410equal to the corresponding value `b', and 0 otherwise. The comparison is
2411performed according to the IEC/IEEE Standard for Binary Floating-point
2412Arithmetic.
2413-------------------------------------------------------------------------------
2414*/
2415flag float64_le( float64 a, float64 b )
2416{
2417 flag aSign, bSign;
2418
2419 if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
2420 || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
2421 ) {
2422 float_raise( float_flag_invalid );
2423 return 0;
2424 }
2425 aSign = extractFloat64Sign( a );
2426 bSign = extractFloat64Sign( b );
2427 if ( aSign != bSign ) return aSign || ( (bits64) ( ( a | b )<<1 ) == 0 );
2428 return ( a == b ) || ( aSign ^ ( a < b ) );
2429
2430}
2431
2432/*
2433-------------------------------------------------------------------------------
2434Returns 1 if the double-precision floating-point value `a' is less than
2435the corresponding value `b', and 0 otherwise. The comparison is performed
2436according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
2437-------------------------------------------------------------------------------
2438*/
2439flag float64_lt( float64 a, float64 b )
2440{
2441 flag aSign, bSign;
2442
2443 if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
2444 || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
2445 ) {
2446 float_raise( float_flag_invalid );
2447 return 0;
2448 }
2449 aSign = extractFloat64Sign( a );
2450 bSign = extractFloat64Sign( b );
2451 if ( aSign != bSign ) return aSign && ( (bits64) ( ( a | b )<<1 ) != 0 );
2452 return ( a != b ) && ( aSign ^ ( a < b ) );
2453
2454}
2455
2456/*
2457-------------------------------------------------------------------------------
2458Returns 1 if the double-precision floating-point value `a' is equal to the
2459corresponding value `b', and 0 otherwise. The invalid exception is raised
2460if either operand is a NaN. Otherwise, the comparison is performed
2461according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
2462-------------------------------------------------------------------------------
2463*/
2464flag float64_eq_signaling( float64 a, float64 b )
2465{
2466
2467 if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
2468 || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
2469 ) {
2470 float_raise( float_flag_invalid );
2471 return 0;
2472 }
2473 return ( a == b ) || ( (bits64) ( ( a | b )<<1 ) == 0 );
2474
2475}
2476
2477/*
2478-------------------------------------------------------------------------------
2479Returns 1 if the double-precision floating-point value `a' is less than or
2480equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not
2481cause an exception. Otherwise, the comparison is performed according to the
2482IEC/IEEE Standard for Binary Floating-point Arithmetic.
2483-------------------------------------------------------------------------------
2484*/
2485flag float64_le_quiet( float64 a, float64 b )
2486{
2487 flag aSign, bSign;
2488 //int16 aExp, bExp;
2489
2490 if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
2491 || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
2492 ) {
2493 if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) {
2494 float_raise( float_flag_invalid );
2495 }
2496 return 0;
2497 }
2498 aSign = extractFloat64Sign( a );
2499 bSign = extractFloat64Sign( b );
2500 if ( aSign != bSign ) return aSign || ( (bits64) ( ( a | b )<<1 ) == 0 );
2501 return ( a == b ) || ( aSign ^ ( a < b ) );
2502
2503}
2504
2505/*
2506-------------------------------------------------------------------------------
2507Returns 1 if the double-precision floating-point value `a' is less than
2508the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an
2509exception. Otherwise, the comparison is performed according to the IEC/IEEE
2510Standard for Binary Floating-point Arithmetic.
2511-------------------------------------------------------------------------------
2512*/
2513flag float64_lt_quiet( float64 a, float64 b )
2514{
2515 flag aSign, bSign;
2516
2517 if ( ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
2518 || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
2519 ) {
2520 if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) {
2521 float_raise( float_flag_invalid );
2522 }
2523 return 0;
2524 }
2525 aSign = extractFloat64Sign( a );
2526 bSign = extractFloat64Sign( b );
2527 if ( aSign != bSign ) return aSign && ( (bits64) ( ( a | b )<<1 ) != 0 );
2528 return ( a != b ) && ( aSign ^ ( a < b ) );
2529
2530}
2531
2532#ifdef FLOATX80
2533
2534/*
2535-------------------------------------------------------------------------------
2536Returns the result of converting the extended double-precision floating-
2537point value `a' to the 32-bit two's complement integer format. The
2538conversion is performed according to the IEC/IEEE Standard for Binary
2539Floating-point Arithmetic---which means in particular that the conversion
2540is rounded according to the current rounding mode. If `a' is a NaN, the
2541largest positive integer is returned. Otherwise, if the conversion
2542overflows, the largest integer with the same sign as `a' is returned.
2543-------------------------------------------------------------------------------
2544*/
2545int32 floatx80_to_int32( floatx80 a )
2546{
2547 flag aSign;
2548 int32 aExp, shiftCount;
2549 bits64 aSig;
2550
2551 aSig = extractFloatx80Frac( a );
2552 aExp = extractFloatx80Exp( a );
2553 aSign = extractFloatx80Sign( a );
2554 if ( ( aExp == 0x7FFF ) && (bits64) ( aSig<<1 ) ) aSign = 0;
2555 shiftCount = 0x4037 - aExp;
2556 if ( shiftCount <= 0 ) shiftCount = 1;
2557 shift64RightJamming( aSig, shiftCount, &aSig );
2558 return roundAndPackInt32( aSign, aSig );
2559
2560}
2561
2562/*
2563-------------------------------------------------------------------------------
2564Returns the result of converting the extended double-precision floating-
2565point value `a' to the 32-bit two's complement integer format. The
2566conversion is performed according to the IEC/IEEE Standard for Binary
2567Floating-point Arithmetic, except that the conversion is always rounded
2568toward zero. If `a' is a NaN, the largest positive integer is returned.
2569Otherwise, if the conversion overflows, the largest integer with the same
2570sign as `a' is returned.
2571-------------------------------------------------------------------------------
2572*/
2573int32 floatx80_to_int32_round_to_zero( floatx80 a )
2574{
2575 flag aSign;
2576 int32 aExp, shiftCount;
2577 bits64 aSig, savedASig;
2578 int32 z;
2579
2580 aSig = extractFloatx80Frac( a );
2581 aExp = extractFloatx80Exp( a );
2582 aSign = extractFloatx80Sign( a );
2583 shiftCount = 0x403E - aExp;
2584 if ( shiftCount < 32 ) {
2585 if ( ( aExp == 0x7FFF ) && (bits64) ( aSig<<1 ) ) aSign = 0;
2586 goto invalid;
2587 }
2588 else if ( 63 < shiftCount ) {
2589 if ( aExp || aSig ) float_exception_flags |= float_flag_inexact;
2590 return 0;
2591 }
2592 savedASig = aSig;
2593 aSig >>= shiftCount;
2594 z = aSig;
2595 if ( aSign ) z = - z;
2596 if ( ( z < 0 ) ^ aSign ) {
2597 invalid:
2598 float_exception_flags |= float_flag_invalid;
2599 return aSign ? 0x80000000 : 0x7FFFFFFF;
2600 }
2601 if ( ( aSig<<shiftCount ) != savedASig ) {
2602 float_exception_flags |= float_flag_inexact;
2603 }
2604 return z;
2605
2606}
2607
2608/*
2609-------------------------------------------------------------------------------
2610Returns the result of converting the extended double-precision floating-
2611point value `a' to the single-precision floating-point format. The
2612conversion is performed according to the IEC/IEEE Standard for Binary
2613Floating-point Arithmetic.
2614-------------------------------------------------------------------------------
2615*/
2616float32 floatx80_to_float32( floatx80 a )
2617{
2618 flag aSign;
2619 int32 aExp;
2620 bits64 aSig;
2621
2622 aSig = extractFloatx80Frac( a );
2623 aExp = extractFloatx80Exp( a );
2624 aSign = extractFloatx80Sign( a );
2625 if ( aExp == 0x7FFF ) {
2626 if ( (bits64) ( aSig<<1 ) ) {
2627 return commonNaNToFloat32( floatx80ToCommonNaN( a ) );
2628 }
2629 return packFloat32( aSign, 0xFF, 0 );
2630 }
2631 shift64RightJamming( aSig, 33, &aSig );
2632 if ( aExp || aSig ) aExp -= 0x3F81;
2633 return roundAndPackFloat32( aSign, aExp, aSig );
2634
2635}
2636
2637/*
2638-------------------------------------------------------------------------------
2639Returns the result of converting the extended double-precision floating-
2640point value `a' to the double-precision floating-point format. The
2641conversion is performed according to the IEC/IEEE Standard for Binary
2642Floating-point Arithmetic.
2643-------------------------------------------------------------------------------
2644*/
2645float64 floatx80_to_float64( floatx80 a )
2646{
2647 flag aSign;
2648 int32 aExp;
2649 bits64 aSig, zSig;
2650
2651 aSig = extractFloatx80Frac( a );
2652 aExp = extractFloatx80Exp( a );
2653 aSign = extractFloatx80Sign( a );
2654 if ( aExp == 0x7FFF ) {
2655 if ( (bits64) ( aSig<<1 ) ) {
2656 return commonNaNToFloat64( floatx80ToCommonNaN( a ) );
2657 }
2658 return packFloat64( aSign, 0x7FF, 0 );
2659 }
2660 shift64RightJamming( aSig, 1, &zSig );
2661 if ( aExp || aSig ) aExp -= 0x3C01;
2662 return roundAndPackFloat64( aSign, aExp, zSig );
2663
2664}
2665
2666/*
2667-------------------------------------------------------------------------------
2668Rounds the extended double-precision floating-point value `a' to an integer,
2669and returns the result as an extended quadruple-precision floating-point
2670value. The operation is performed according to the IEC/IEEE Standard for
2671Binary Floating-point Arithmetic.
2672-------------------------------------------------------------------------------
2673*/
2674floatx80 floatx80_round_to_int( floatx80 a )
2675{
2676 flag aSign;
2677 int32 aExp;
2678 bits64 lastBitMask, roundBitsMask;
2679 int8 roundingMode;
2680 floatx80 z;
2681
2682 aExp = extractFloatx80Exp( a );
2683 if ( 0x403E <= aExp ) {
2684 if ( ( aExp == 0x7FFF ) && (bits64) ( extractFloatx80Frac( a )<<1 ) ) {
2685 return propagateFloatx80NaN( a, a );
2686 }
2687 return a;
2688 }
2689 if ( aExp <= 0x3FFE ) {
2690 if ( ( aExp == 0 )
2691 && ( (bits64) ( extractFloatx80Frac( a )<<1 ) == 0 ) ) {
2692 return a;
2693 }
2694 float_exception_flags |= float_flag_inexact;
2695 aSign = extractFloatx80Sign( a );
2696 switch ( float_rounding_mode ) {
2697 case float_round_nearest_even:
2698 if ( ( aExp == 0x3FFE ) && (bits64) ( extractFloatx80Frac( a )<<1 )
2699 ) {
2700 return
2701 packFloatx80( aSign, 0x3FFF, LIT64( 0x8000000000000000 ) );
2702 }
2703 break;
2704 case float_round_down:
2705 return
2706 aSign ?
2707 packFloatx80( 1, 0x3FFF, LIT64( 0x8000000000000000 ) )
2708 : packFloatx80( 0, 0, 0 );
2709 case float_round_up:
2710 return
2711 aSign ? packFloatx80( 1, 0, 0 )
2712 : packFloatx80( 0, 0x3FFF, LIT64( 0x8000000000000000 ) );
2713 }
2714 return packFloatx80( aSign, 0, 0 );
2715 }
2716 lastBitMask = 1;
2717 lastBitMask <<= 0x403E - aExp;
2718 roundBitsMask = lastBitMask - 1;
2719 z = a;
2720 roundingMode = float_rounding_mode;
2721 if ( roundingMode == float_round_nearest_even ) {
2722 z.low += lastBitMask>>1;
2723 if ( ( z.low & roundBitsMask ) == 0 ) z.low &= ~ lastBitMask;
2724 }
2725 else if ( roundingMode != float_round_to_zero ) {
2726 if ( extractFloatx80Sign( z ) ^ ( roundingMode == float_round_up ) ) {
2727 z.low += roundBitsMask;
2728 }
2729 }
2730 z.low &= ~ roundBitsMask;
2731 if ( z.low == 0 ) {
2732 ++z.high;
2733 z.low = LIT64( 0x8000000000000000 );
2734 }
2735 if ( z.low != a.low ) float_exception_flags |= float_flag_inexact;
2736 return z;
2737
2738}
2739
2740/*
2741-------------------------------------------------------------------------------
2742Returns the result of adding the absolute values of the extended double-
2743precision floating-point values `a' and `b'. If `zSign' is true, the sum is
2744negated before being returned. `zSign' is ignored if the result is a NaN.
2745The addition is performed according to the IEC/IEEE Standard for Binary
2746Floating-point Arithmetic.
2747-------------------------------------------------------------------------------
2748*/
2749static floatx80 addFloatx80Sigs( floatx80 a, floatx80 b, flag zSign )
2750{
2751 int32 aExp, bExp, zExp;
2752 bits64 aSig, bSig, zSig0, zSig1;
2753 int32 expDiff;
2754
2755 aSig = extractFloatx80Frac( a );
2756 aExp = extractFloatx80Exp( a );
2757 bSig = extractFloatx80Frac( b );
2758 bExp = extractFloatx80Exp( b );
2759 expDiff = aExp - bExp;
2760 if ( 0 < expDiff ) {
2761 if ( aExp == 0x7FFF ) {
2762 if ( (bits64) ( aSig<<1 ) ) return propagateFloatx80NaN( a, b );
2763 return a;
2764 }
2765 if ( bExp == 0 ) --expDiff;
2766 shift64ExtraRightJamming( bSig, 0, expDiff, &bSig, &zSig1 );
2767 zExp = aExp;
2768 }
2769 else if ( expDiff < 0 ) {
2770 if ( bExp == 0x7FFF ) {
2771 if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
2772 return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
2773 }
2774 if ( aExp == 0 ) ++expDiff;
2775 shift64ExtraRightJamming( aSig, 0, - expDiff, &aSig, &zSig1 );
2776 zExp = bExp;
2777 }
2778 else {
2779 if ( aExp == 0x7FFF ) {
2780 if ( (bits64) ( ( aSig | bSig )<<1 ) ) {
2781 return propagateFloatx80NaN( a, b );
2782 }
2783 return a;
2784 }
2785 zSig1 = 0;
2786 zSig0 = aSig + bSig;
2787 if ( aExp == 0 ) {
2788 normalizeFloatx80Subnormal( zSig0, &zExp, &zSig0 );
2789 goto roundAndPack;
2790 }
2791 zExp = aExp;
2792 goto shiftRight1;
2793 }
2794
2795 zSig0 = aSig + bSig;
2796
2797 if ( (sbits64) zSig0 < 0 ) goto roundAndPack;
2798 shiftRight1:
2799 shift64ExtraRightJamming( zSig0, zSig1, 1, &zSig0, &zSig1 );
2800 zSig0 |= LIT64( 0x8000000000000000 );
2801 ++zExp;
2802 roundAndPack:
2803 return
2804 roundAndPackFloatx80(
2805 floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 );
2806
2807}
2808
2809/*
2810-------------------------------------------------------------------------------
2811Returns the result of subtracting the absolute values of the extended
2812double-precision floating-point values `a' and `b'. If `zSign' is true,
2813the difference is negated before being returned. `zSign' is ignored if the
2814result is a NaN. The subtraction is performed according to the IEC/IEEE
2815Standard for Binary Floating-point Arithmetic.
2816-------------------------------------------------------------------------------
2817*/
2818static floatx80 subFloatx80Sigs( floatx80 a, floatx80 b, flag zSign )
2819{
2820 int32 aExp, bExp, zExp;
2821 bits64 aSig, bSig, zSig0, zSig1;
2822 int32 expDiff;
2823 floatx80 z;
2824
2825 aSig = extractFloatx80Frac( a );
2826 aExp = extractFloatx80Exp( a );
2827 bSig = extractFloatx80Frac( b );
2828 bExp = extractFloatx80Exp( b );
2829 expDiff = aExp - bExp;
2830 if ( 0 < expDiff ) goto aExpBigger;
2831 if ( expDiff < 0 ) goto bExpBigger;
2832 if ( aExp == 0x7FFF ) {
2833 if ( (bits64) ( ( aSig | bSig )<<1 ) ) {
2834 return propagateFloatx80NaN( a, b );
2835 }
2836 float_raise( float_flag_invalid );
2837 z.low = floatx80_default_nan_low;
2838 z.high = floatx80_default_nan_high;
2839 return z;
2840 }
2841 if ( aExp == 0 ) {
2842 aExp = 1;
2843 bExp = 1;
2844 }
2845 zSig1 = 0;
2846 if ( bSig < aSig ) goto aBigger;
2847 if ( aSig < bSig ) goto bBigger;
2848 return packFloatx80( float_rounding_mode == float_round_down, 0, 0 );
2849 bExpBigger:
2850 if ( bExp == 0x7FFF ) {
2851 if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
2852 return packFloatx80( zSign ^ 1, 0x7FFF, LIT64( 0x8000000000000000 ) );
2853 }
2854 if ( aExp == 0 ) ++expDiff;
2855 shift128RightJamming( aSig, 0, - expDiff, &aSig, &zSig1 );
2856 bBigger:
2857 sub128( bSig, 0, aSig, zSig1, &zSig0, &zSig1 );
2858 zExp = bExp;
2859 zSign ^= 1;
2860 goto normalizeRoundAndPack;
2861 aExpBigger:
2862 if ( aExp == 0x7FFF ) {
2863 if ( (bits64) ( aSig<<1 ) ) return propagateFloatx80NaN( a, b );
2864 return a;
2865 }
2866 if ( bExp == 0 ) --expDiff;
2867 shift128RightJamming( bSig, 0, expDiff, &bSig, &zSig1 );
2868 aBigger:
2869 sub128( aSig, 0, bSig, zSig1, &zSig0, &zSig1 );
2870 zExp = aExp;
2871 normalizeRoundAndPack:
2872 return
2873 normalizeRoundAndPackFloatx80(
2874 floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 );
2875
2876}
2877
2878/*
2879-------------------------------------------------------------------------------
2880Returns the result of adding the extended double-precision floating-point
2881values `a' and `b'. The operation is performed according to the IEC/IEEE
2882Standard for Binary Floating-point Arithmetic.
2883-------------------------------------------------------------------------------
2884*/
2885floatx80 floatx80_add( floatx80 a, floatx80 b )
2886{
2887 flag aSign, bSign;
2888
2889 aSign = extractFloatx80Sign( a );
2890 bSign = extractFloatx80Sign( b );
2891 if ( aSign == bSign ) {
2892 return addFloatx80Sigs( a, b, aSign );
2893 }
2894 else {
2895 return subFloatx80Sigs( a, b, aSign );
2896 }
2897
2898}
2899
2900/*
2901-------------------------------------------------------------------------------
2902Returns the result of subtracting the extended double-precision floating-
2903point values `a' and `b'. The operation is performed according to the
2904IEC/IEEE Standard for Binary Floating-point Arithmetic.
2905-------------------------------------------------------------------------------
2906*/
2907floatx80 floatx80_sub( floatx80 a, floatx80 b )
2908{
2909 flag aSign, bSign;
2910
2911 aSign = extractFloatx80Sign( a );
2912 bSign = extractFloatx80Sign( b );
2913 if ( aSign == bSign ) {
2914 return subFloatx80Sigs( a, b, aSign );
2915 }
2916 else {
2917 return addFloatx80Sigs( a, b, aSign );
2918 }
2919
2920}
2921
2922/*
2923-------------------------------------------------------------------------------
2924Returns the result of multiplying the extended double-precision floating-
2925point values `a' and `b'. The operation is performed according to the
2926IEC/IEEE Standard for Binary Floating-point Arithmetic.
2927-------------------------------------------------------------------------------
2928*/
2929floatx80 floatx80_mul( floatx80 a, floatx80 b )
2930{
2931 flag aSign, bSign, zSign;
2932 int32 aExp, bExp, zExp;
2933 bits64 aSig, bSig, zSig0, zSig1;
2934 floatx80 z;
2935
2936 aSig = extractFloatx80Frac( a );
2937 aExp = extractFloatx80Exp( a );
2938 aSign = extractFloatx80Sign( a );
2939 bSig = extractFloatx80Frac( b );
2940 bExp = extractFloatx80Exp( b );
2941 bSign = extractFloatx80Sign( b );
2942 zSign = aSign ^ bSign;
2943 if ( aExp == 0x7FFF ) {
2944 if ( (bits64) ( aSig<<1 )
2945 || ( ( bExp == 0x7FFF ) && (bits64) ( bSig<<1 ) ) ) {
2946 return propagateFloatx80NaN( a, b );
2947 }
2948 if ( ( bExp | bSig ) == 0 ) goto invalid;
2949 return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
2950 }
2951 if ( bExp == 0x7FFF ) {
2952 if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
2953 if ( ( aExp | aSig ) == 0 ) {
2954 invalid:
2955 float_raise( float_flag_invalid );
2956 z.low = floatx80_default_nan_low;
2957 z.high = floatx80_default_nan_high;
2958 return z;
2959 }
2960 return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
2961 }
2962 if ( aExp == 0 ) {
2963 if ( aSig == 0 ) return packFloatx80( zSign, 0, 0 );
2964 normalizeFloatx80Subnormal( aSig, &aExp, &aSig );
2965 }
2966 if ( bExp == 0 ) {
2967 if ( bSig == 0 ) return packFloatx80( zSign, 0, 0 );
2968 normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
2969 }
2970 zExp = aExp + bExp - 0x3FFE;
2971 mul64To128( aSig, bSig, &zSig0, &zSig1 );
2972 if ( 0 < (sbits64) zSig0 ) {
2973 shortShift128Left( zSig0, zSig1, 1, &zSig0, &zSig1 );
2974 --zExp;
2975 }
2976 return
2977 roundAndPackFloatx80(
2978 floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 );
2979
2980}
2981
2982/*
2983-------------------------------------------------------------------------------
2984Returns the result of dividing the extended double-precision floating-point
2985value `a' by the corresponding value `b'. The operation is performed
2986according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
2987-------------------------------------------------------------------------------
2988*/
2989floatx80 floatx80_div( floatx80 a, floatx80 b )
2990{
2991 flag aSign, bSign, zSign;
2992 int32 aExp, bExp, zExp;
2993 bits64 aSig, bSig, zSig0, zSig1;
2994 bits64 rem0, rem1, rem2, term0, term1, term2;
2995 floatx80 z;
2996
2997 aSig = extractFloatx80Frac( a );
2998 aExp = extractFloatx80Exp( a );
2999 aSign = extractFloatx80Sign( a );
3000 bSig = extractFloatx80Frac( b );
3001 bExp = extractFloatx80Exp( b );
3002 bSign = extractFloatx80Sign( b );
3003 zSign = aSign ^ bSign;
3004 if ( aExp == 0x7FFF ) {
3005 if ( (bits64) ( aSig<<1 ) ) return propagateFloatx80NaN( a, b );
3006 if ( bExp == 0x7FFF ) {
3007 if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
3008 goto invalid;
3009 }
3010 return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
3011 }
3012 if ( bExp == 0x7FFF ) {
3013 if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
3014 return packFloatx80( zSign, 0, 0 );
3015 }
3016 if ( bExp == 0 ) {
3017 if ( bSig == 0 ) {
3018 if ( ( aExp | aSig ) == 0 ) {
3019 invalid:
3020 float_raise( float_flag_invalid );
3021 z.low = floatx80_default_nan_low;
3022 z.high = floatx80_default_nan_high;
3023 return z;
3024 }
3025 float_raise( float_flag_divbyzero );
3026 return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
3027 }
3028 normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
3029 }
3030 if ( aExp == 0 ) {
3031 if ( aSig == 0 ) return packFloatx80( zSign, 0, 0 );
3032 normalizeFloatx80Subnormal( aSig, &aExp, &aSig );
3033 }
3034 zExp = aExp - bExp + 0x3FFE;
3035 rem1 = 0;
3036 if ( bSig <= aSig ) {
3037 shift128Right( aSig, 0, 1, &aSig, &rem1 );
3038 ++zExp;
3039 }
3040 zSig0 = estimateDiv128To64( aSig, rem1, bSig );
3041 mul64To128( bSig, zSig0, &term0, &term1 );
3042 sub128( aSig, rem1, term0, term1, &rem0, &rem1 );
3043 while ( (sbits64) rem0 < 0 ) {
3044 --zSig0;
3045 add128( rem0, rem1, 0, bSig, &rem0, &rem1 );
3046 }
3047 zSig1 = estimateDiv128To64( rem1, 0, bSig );
3048 if ( (bits64) ( zSig1<<1 ) <= 8 ) {
3049 mul64To128( bSig, zSig1, &term1, &term2 );
3050 sub128( rem1, 0, term1, term2, &rem1, &rem2 );
3051 while ( (sbits64) rem1 < 0 ) {
3052 --zSig1;
3053 add128( rem1, rem2, 0, bSig, &rem1, &rem2 );
3054 }
3055 zSig1 |= ( ( rem1 | rem2 ) != 0 );
3056 }
3057 return
3058 roundAndPackFloatx80(
3059 floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 );
3060
3061}
3062
3063/*
3064-------------------------------------------------------------------------------
3065Returns the remainder of the extended double-precision floating-point value
3066`a' with respect to the corresponding value `b'. The operation is performed
3067according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
3068-------------------------------------------------------------------------------
3069*/
3070floatx80 floatx80_rem( floatx80 a, floatx80 b )
3071{
3072 flag aSign, bSign, zSign;
3073 int32 aExp, bExp, expDiff;
3074 bits64 aSig0, aSig1, bSig;
3075 bits64 q, term0, term1, alternateASig0, alternateASig1;
3076 floatx80 z;
3077
3078 aSig0 = extractFloatx80Frac( a );
3079 aExp = extractFloatx80Exp( a );
3080 aSign = extractFloatx80Sign( a );
3081 bSig = extractFloatx80Frac( b );
3082 bExp = extractFloatx80Exp( b );
3083 bSign = extractFloatx80Sign( b );
3084 if ( aExp == 0x7FFF ) {
3085 if ( (bits64) ( aSig0<<1 )
3086 || ( ( bExp == 0x7FFF ) && (bits64) ( bSig<<1 ) ) ) {
3087 return propagateFloatx80NaN( a, b );
3088 }
3089 goto invalid;
3090 }
3091 if ( bExp == 0x7FFF ) {
3092 if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
3093 return a;
3094 }
3095 if ( bExp == 0 ) {
3096 if ( bSig == 0 ) {
3097 invalid:
3098 float_raise( float_flag_invalid );
3099 z.low = floatx80_default_nan_low;
3100 z.high = floatx80_default_nan_high;
3101 return z;
3102 }
3103 normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
3104 }
3105 if ( aExp == 0 ) {
3106 if ( (bits64) ( aSig0<<1 ) == 0 ) return a;
3107 normalizeFloatx80Subnormal( aSig0, &aExp, &aSig0 );
3108 }
3109 bSig |= LIT64( 0x8000000000000000 );
3110 zSign = aSign;
3111 expDiff = aExp - bExp;
3112 aSig1 = 0;
3113 if ( expDiff < 0 ) {
3114 if ( expDiff < -1 ) return a;
3115 shift128Right( aSig0, 0, 1, &aSig0, &aSig1 );
3116 expDiff = 0;
3117 }
3118 q = ( bSig <= aSig0 );
3119 if ( q ) aSig0 -= bSig;
3120 expDiff -= 64;
3121 while ( 0 < expDiff ) {
3122 q = estimateDiv128To64( aSig0, aSig1, bSig );
3123 q = ( 2 < q ) ? q - 2 : 0;
3124 mul64To128( bSig, q, &term0, &term1 );
3125 sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 );
3126 shortShift128Left( aSig0, aSig1, 62, &aSig0, &aSig1 );
3127 expDiff -= 62;
3128 }
3129 expDiff += 64;
3130 if ( 0 < expDiff ) {
3131 q = estimateDiv128To64( aSig0, aSig1, bSig );
3132 q = ( 2 < q ) ? q - 2 : 0;
3133 q >>= 64 - expDiff;
3134 mul64To128( bSig, q<<( 64 - expDiff ), &term0, &term1 );
3135 sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 );
3136 shortShift128Left( 0, bSig, 64 - expDiff, &term0, &term1 );
3137 while ( le128( term0, term1, aSig0, aSig1 ) ) {
3138 ++q;
3139 sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 );
3140 }
3141 }
3142 else {
3143 term1 = 0;
3144 term0 = bSig;
3145 }
3146 sub128( term0, term1, aSig0, aSig1, &alternateASig0, &alternateASig1 );
3147 if ( lt128( alternateASig0, alternateASig1, aSig0, aSig1 )
3148 || ( eq128( alternateASig0, alternateASig1, aSig0, aSig1 )
3149 && ( q & 1 ) )
3150 ) {
3151 aSig0 = alternateASig0;
3152 aSig1 = alternateASig1;
3153 zSign = ! zSign;
3154 }
3155 return
3156 normalizeRoundAndPackFloatx80(
3157 80, zSign, bExp + expDiff, aSig0, aSig1 );
3158
3159}
3160
3161/*
3162-------------------------------------------------------------------------------
3163Returns the square root of the extended double-precision floating-point
3164value `a'. The operation is performed according to the IEC/IEEE Standard
3165for Binary Floating-point Arithmetic.
3166-------------------------------------------------------------------------------
3167*/
3168floatx80 floatx80_sqrt( floatx80 a )
3169{
3170 flag aSign;
3171 int32 aExp, zExp;
3172 bits64 aSig0, aSig1, zSig0, zSig1;
3173 bits64 rem0, rem1, rem2, rem3, term0, term1, term2, term3;
3174 bits64 shiftedRem0, shiftedRem1;
3175 floatx80 z;
3176
3177 aSig0 = extractFloatx80Frac( a );
3178 aExp = extractFloatx80Exp( a );
3179 aSign = extractFloatx80Sign( a );
3180 if ( aExp == 0x7FFF ) {
3181 if ( (bits64) ( aSig0<<1 ) ) return propagateFloatx80NaN( a, a );
3182 if ( ! aSign ) return a;
3183 goto invalid;
3184 }
3185 if ( aSign ) {
3186 if ( ( aExp | aSig0 ) == 0 ) return a;
3187 invalid:
3188 float_raise( float_flag_invalid );
3189 z.low = floatx80_default_nan_low;
3190 z.high = floatx80_default_nan_high;
3191 return z;
3192 }
3193 if ( aExp == 0 ) {
3194 if ( aSig0 == 0 ) return packFloatx80( 0, 0, 0 );
3195 normalizeFloatx80Subnormal( aSig0, &aExp, &aSig0 );
3196 }
3197 zExp = ( ( aExp - 0x3FFF )>>1 ) + 0x3FFF;
3198 zSig0 = estimateSqrt32( aExp, aSig0>>32 );
3199 zSig0 <<= 31;
3200 aSig1 = 0;
3201 shift128Right( aSig0, 0, ( aExp & 1 ) + 2, &aSig0, &aSig1 );
3202 zSig0 = estimateDiv128To64( aSig0, aSig1, zSig0 ) + zSig0 + 4;
3203 if ( 0 <= (sbits64) zSig0 ) zSig0 = LIT64( 0xFFFFFFFFFFFFFFFF );
3204 shortShift128Left( aSig0, aSig1, 2, &aSig0, &aSig1 );
3205 mul64To128( zSig0, zSig0, &term0, &term1 );
3206 sub128( aSig0, aSig1, term0, term1, &rem0, &rem1 );
3207 while ( (sbits64) rem0 < 0 ) {
3208 --zSig0;
3209 shortShift128Left( 0, zSig0, 1, &term0, &term1 );
3210 term1 |= 1;
3211 add128( rem0, rem1, term0, term1, &rem0, &rem1 );
3212 }
3213 shortShift128Left( rem0, rem1, 63, &shiftedRem0, &shiftedRem1 );
3214 zSig1 = estimateDiv128To64( shiftedRem0, shiftedRem1, zSig0 );
3215 if ( (bits64) ( zSig1<<1 ) <= 10 ) {
3216 if ( zSig1 == 0 ) zSig1 = 1;
3217 mul64To128( zSig0, zSig1, &term1, &term2 );
3218 shortShift128Left( term1, term2, 1, &term1, &term2 );
3219 sub128( rem1, 0, term1, term2, &rem1, &rem2 );
3220 mul64To128( zSig1, zSig1, &term2, &term3 );
3221 sub192( rem1, rem2, 0, 0, term2, term3, &rem1, &rem2, &rem3 );
3222 while ( (sbits64) rem1 < 0 ) {
3223 --zSig1;
3224 shortShift192Left( 0, zSig0, zSig1, 1, &term1, &term2, &term3 );
3225 term3 |= 1;
3226 add192(
3227 rem1, rem2, rem3, term1, term2, term3, &rem1, &rem2, &rem3 );
3228 }
3229 zSig1 |= ( ( rem1 | rem2 | rem3 ) != 0 );
3230 }
3231 return
3232 roundAndPackFloatx80(
3233 floatx80_rounding_precision, 0, zExp, zSig0, zSig1 );
3234
3235}
3236
3237/*
3238-------------------------------------------------------------------------------
3239Returns 1 if the extended double-precision floating-point value `a' is
3240equal to the corresponding value `b', and 0 otherwise. The comparison is
3241performed according to the IEC/IEEE Standard for Binary Floating-point
3242Arithmetic.
3243-------------------------------------------------------------------------------
3244*/
3245flag floatx80_eq( floatx80 a, floatx80 b )
3246{
3247
3248 if ( ( ( extractFloatx80Exp( a ) == 0x7FFF )
3249 && (bits64) ( extractFloatx80Frac( a )<<1 ) )
3250 || ( ( extractFloatx80Exp( b ) == 0x7FFF )
3251 && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3252 ) {
3253 if ( floatx80_is_signaling_nan( a )
3254 || floatx80_is_signaling_nan( b ) ) {
3255 float_raise( float_flag_invalid );
3256 }
3257 return 0;
3258 }
3259 return
3260 ( a.low == b.low )
3261 && ( ( a.high == b.high )
3262 || ( ( a.low == 0 )
3263 && ( (bits16) ( ( a.high | b.high )<<1 ) == 0 ) )
3264 );
3265
3266}
3267
3268/*
3269-------------------------------------------------------------------------------
3270Returns 1 if the extended double-precision floating-point value `a' is
3271less than or equal to the corresponding value `b', and 0 otherwise. The
3272comparison is performed according to the IEC/IEEE Standard for Binary
3273Floating-point Arithmetic.
3274-------------------------------------------------------------------------------
3275*/
3276flag floatx80_le( floatx80 a, floatx80 b )
3277{
3278 flag aSign, bSign;
3279
3280 if ( ( ( extractFloatx80Exp( a ) == 0x7FFF )
3281 && (bits64) ( extractFloatx80Frac( a )<<1 ) )
3282 || ( ( extractFloatx80Exp( b ) == 0x7FFF )
3283 && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3284 ) {
3285 float_raise( float_flag_invalid );
3286 return 0;
3287 }
3288 aSign = extractFloatx80Sign( a );
3289 bSign = extractFloatx80Sign( b );
3290 if ( aSign != bSign ) {
3291 return
3292 aSign
3293 || ( ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
3294 == 0 );
3295 }
3296 return
3297 aSign ? le128( b.high, b.low, a.high, a.low )
3298 : le128( a.high, a.low, b.high, b.low );
3299
3300}
3301
3302/*
3303-------------------------------------------------------------------------------
3304Returns 1 if the extended double-precision floating-point value `a' is
3305less than the corresponding value `b', and 0 otherwise. The comparison
3306is performed according to the IEC/IEEE Standard for Binary Floating-point
3307Arithmetic.
3308-------------------------------------------------------------------------------
3309*/
3310flag floatx80_lt( floatx80 a, floatx80 b )
3311{
3312 flag aSign, bSign;
3313
3314 if ( ( ( extractFloatx80Exp( a ) == 0x7FFF )
3315 && (bits64) ( extractFloatx80Frac( a )<<1 ) )
3316 || ( ( extractFloatx80Exp( b ) == 0x7FFF )
3317 && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3318 ) {
3319 float_raise( float_flag_invalid );
3320 return 0;
3321 }
3322 aSign = extractFloatx80Sign( a );
3323 bSign = extractFloatx80Sign( b );
3324 if ( aSign != bSign ) {
3325 return
3326 aSign
3327 && ( ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
3328 != 0 );
3329 }
3330 return
3331 aSign ? lt128( b.high, b.low, a.high, a.low )
3332 : lt128( a.high, a.low, b.high, b.low );
3333
3334}
3335
3336/*
3337-------------------------------------------------------------------------------
3338Returns 1 if the extended double-precision floating-point value `a' is equal
3339to the corresponding value `b', and 0 otherwise. The invalid exception is
3340raised if either operand is a NaN. Otherwise, the comparison is performed
3341according to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
3342-------------------------------------------------------------------------------
3343*/
3344flag floatx80_eq_signaling( floatx80 a, floatx80 b )
3345{
3346
3347 if ( ( ( extractFloatx80Exp( a ) == 0x7FFF )
3348 && (bits64) ( extractFloatx80Frac( a )<<1 ) )
3349 || ( ( extractFloatx80Exp( b ) == 0x7FFF )
3350 && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3351 ) {
3352 float_raise( float_flag_invalid );
3353 return 0;
3354 }
3355 return
3356 ( a.low == b.low )
3357 && ( ( a.high == b.high )
3358 || ( ( a.low == 0 )
3359 && ( (bits16) ( ( a.high | b.high )<<1 ) == 0 ) )
3360 );
3361
3362}
3363
3364/*
3365-------------------------------------------------------------------------------
3366Returns 1 if the extended double-precision floating-point value `a' is less
3367than or equal to the corresponding value `b', and 0 otherwise. Quiet NaNs
3368do not cause an exception. Otherwise, the comparison is performed according
3369to the IEC/IEEE Standard for Binary Floating-point Arithmetic.
3370-------------------------------------------------------------------------------
3371*/
3372flag floatx80_le_quiet( floatx80 a, floatx80 b )
3373{
3374 flag aSign, bSign;
3375
3376 if ( ( ( extractFloatx80Exp( a ) == 0x7FFF )
3377 && (bits64) ( extractFloatx80Frac( a )<<1 ) )
3378 || ( ( extractFloatx80Exp( b ) == 0x7FFF )
3379 && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3380 ) {
3381 if ( floatx80_is_signaling_nan( a )
3382 || floatx80_is_signaling_nan( b ) ) {
3383 float_raise( float_flag_invalid );
3384 }
3385 return 0;
3386 }
3387 aSign = extractFloatx80Sign( a );
3388 bSign = extractFloatx80Sign( b );
3389 if ( aSign != bSign ) {
3390 return
3391 aSign
3392 || ( ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
3393 == 0 );
3394 }
3395 return
3396 aSign ? le128( b.high, b.low, a.high, a.low )
3397 : le128( a.high, a.low, b.high, b.low );
3398
3399}
3400
3401/*
3402-------------------------------------------------------------------------------
3403Returns 1 if the extended double-precision floating-point value `a' is less
3404than the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause
3405an exception. Otherwise, the comparison is performed according to the
3406IEC/IEEE Standard for Binary Floating-point Arithmetic.
3407-------------------------------------------------------------------------------
3408*/
3409flag floatx80_lt_quiet( floatx80 a, floatx80 b )
3410{
3411 flag aSign, bSign;
3412
3413 if ( ( ( extractFloatx80Exp( a ) == 0x7FFF )
3414 && (bits64) ( extractFloatx80Frac( a )<<1 ) )
3415 || ( ( extractFloatx80Exp( b ) == 0x7FFF )
3416 && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3417 ) {
3418 if ( floatx80_is_signaling_nan( a )
3419 || floatx80_is_signaling_nan( b ) ) {
3420 float_raise( float_flag_invalid );
3421 }
3422 return 0;
3423 }
3424 aSign = extractFloatx80Sign( a );
3425 bSign = extractFloatx80Sign( b );
3426 if ( aSign != bSign ) {
3427 return
3428 aSign
3429 && ( ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
3430 != 0 );
3431 }
3432 return
3433 aSign ? lt128( b.high, b.low, a.high, a.low )
3434 : lt128( a.high, a.low, b.high, b.low );
3435
3436}
3437
3438#endif
3439
diff --git a/arch/arm26/nwfpe/softfloat.h b/arch/arm26/nwfpe/softfloat.h
deleted file mode 100644
index 22c2193a4997..000000000000
--- a/arch/arm26/nwfpe/softfloat.h
+++ /dev/null
@@ -1,232 +0,0 @@
1
2/*
3===============================================================================
4
5This C header file is part of the SoftFloat IEC/IEEE Floating-point
6Arithmetic Package, Release 2.
7
8Written by John R. Hauser. This work was made possible in part by the
9International Computer Science Institute, located at Suite 600, 1947 Center
10Street, Berkeley, California 94704. Funding was partially provided by the
11National Science Foundation under grant MIP-9311980. The original version
12of this code was written as part of a project to build a fixed-point vector
13processor in collaboration with the University of California at Berkeley,
14overseen by Profs. Nelson Morgan and John Wawrzynek. More information
15is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
16arithmetic/softfloat.html'.
17
18THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
20TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
21PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
22AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
23
24Derivative works are acceptable, even for commercial purposes, so long as
25(1) they include prominent notice that the work is derivative, and (2) they
26include prominent notice akin to these three paragraphs for those parts of
27this code that are retained.
28
29===============================================================================
30*/
31
32#ifndef __SOFTFLOAT_H__
33#define __SOFTFLOAT_H__
34
35/*
36-------------------------------------------------------------------------------
37The macro `FLOATX80' must be defined to enable the extended double-precision
38floating-point format `floatx80'. If this macro is not defined, the
39`floatx80' type will not be defined, and none of the functions that either
40input or output the `floatx80' type will be defined.
41-------------------------------------------------------------------------------
42*/
43#define FLOATX80
44
45/*
46-------------------------------------------------------------------------------
47Software IEC/IEEE floating-point types.
48-------------------------------------------------------------------------------
49*/
50typedef unsigned long int float32;
51typedef unsigned long long float64;
52typedef struct {
53 unsigned short high;
54 unsigned long long low;
55} floatx80;
56
57/*
58-------------------------------------------------------------------------------
59Software IEC/IEEE floating-point underflow tininess-detection mode.
60-------------------------------------------------------------------------------
61*/
62extern signed char float_detect_tininess;
63enum {
64 float_tininess_after_rounding = 0,
65 float_tininess_before_rounding = 1
66};
67
68/*
69-------------------------------------------------------------------------------
70Software IEC/IEEE floating-point rounding mode.
71-------------------------------------------------------------------------------
72*/
73extern signed char float_rounding_mode;
74enum {
75 float_round_nearest_even = 0,
76 float_round_to_zero = 1,
77 float_round_down = 2,
78 float_round_up = 3
79};
80
81/*
82-------------------------------------------------------------------------------
83Software IEC/IEEE floating-point exception flags.
84-------------------------------------------------------------------------------
85extern signed char float_exception_flags;
86enum {
87 float_flag_inexact = 1,
88 float_flag_underflow = 2,
89 float_flag_overflow = 4,
90 float_flag_divbyzero = 8,
91 float_flag_invalid = 16
92};
93
94ScottB: November 4, 1998
95Changed the enumeration to match the bit order in the FPA11.
96*/
97
98extern signed char float_exception_flags;
99enum {
100 float_flag_invalid = 1,
101 float_flag_divbyzero = 2,
102 float_flag_overflow = 4,
103 float_flag_underflow = 8,
104 float_flag_inexact = 16
105};
106
107/*
108-------------------------------------------------------------------------------
109Routine to raise any or all of the software IEC/IEEE floating-point
110exception flags.
111-------------------------------------------------------------------------------
112*/
113void float_raise( signed char );
114
115/*
116-------------------------------------------------------------------------------
117Software IEC/IEEE integer-to-floating-point conversion routines.
118-------------------------------------------------------------------------------
119*/
120float32 int32_to_float32( signed int );
121float64 int32_to_float64( signed int );
122#ifdef FLOATX80
123floatx80 int32_to_floatx80( signed int );
124#endif
125
126/*
127-------------------------------------------------------------------------------
128Software IEC/IEEE single-precision conversion routines.
129-------------------------------------------------------------------------------
130*/
131signed int float32_to_int32( float32 );
132signed int float32_to_int32_round_to_zero( float32 );
133float64 float32_to_float64( float32 );
134#ifdef FLOATX80
135floatx80 float32_to_floatx80( float32 );
136#endif
137
138/*
139-------------------------------------------------------------------------------
140Software IEC/IEEE single-precision operations.
141-------------------------------------------------------------------------------
142*/
143float32 float32_round_to_int( float32 );
144float32 float32_add( float32, float32 );
145float32 float32_sub( float32, float32 );
146float32 float32_mul( float32, float32 );
147float32 float32_div( float32, float32 );
148float32 float32_rem( float32, float32 );
149float32 float32_sqrt( float32 );
150char float32_eq( float32, float32 );
151char float32_le( float32, float32 );
152char float32_lt( float32, float32 );
153char float32_eq_signaling( float32, float32 );
154char float32_le_quiet( float32, float32 );
155char float32_lt_quiet( float32, float32 );
156char float32_is_signaling_nan( float32 );
157
158/*
159-------------------------------------------------------------------------------
160Software IEC/IEEE double-precision conversion routines.
161-------------------------------------------------------------------------------
162*/
163signed int float64_to_int32( float64 );
164signed int float64_to_int32_round_to_zero( float64 );
165float32 float64_to_float32( float64 );
166#ifdef FLOATX80
167floatx80 float64_to_floatx80( float64 );
168#endif
169
170/*
171-------------------------------------------------------------------------------
172Software IEC/IEEE double-precision operations.
173-------------------------------------------------------------------------------
174*/
175float64 float64_round_to_int( float64 );
176float64 float64_add( float64, float64 );
177float64 float64_sub( float64, float64 );
178float64 float64_mul( float64, float64 );
179float64 float64_div( float64, float64 );
180float64 float64_rem( float64, float64 );
181float64 float64_sqrt( float64 );
182char float64_eq( float64, float64 );
183char float64_le( float64, float64 );
184char float64_lt( float64, float64 );
185char float64_eq_signaling( float64, float64 );
186char float64_le_quiet( float64, float64 );
187char float64_lt_quiet( float64, float64 );
188char float64_is_signaling_nan( float64 );
189
190#ifdef FLOATX80
191
192/*
193-------------------------------------------------------------------------------
194Software IEC/IEEE extended double-precision conversion routines.
195-------------------------------------------------------------------------------
196*/
197signed int floatx80_to_int32( floatx80 );
198signed int floatx80_to_int32_round_to_zero( floatx80 );
199float32 floatx80_to_float32( floatx80 );
200float64 floatx80_to_float64( floatx80 );
201
202/*
203-------------------------------------------------------------------------------
204Software IEC/IEEE extended double-precision rounding precision. Valid
205values are 32, 64, and 80.
206-------------------------------------------------------------------------------
207*/
208extern signed char floatx80_rounding_precision;
209
210/*
211-------------------------------------------------------------------------------
212Software IEC/IEEE extended double-precision operations.
213-------------------------------------------------------------------------------
214*/
215floatx80 floatx80_round_to_int( floatx80 );
216floatx80 floatx80_add( floatx80, floatx80 );
217floatx80 floatx80_sub( floatx80, floatx80 );
218floatx80 floatx80_mul( floatx80, floatx80 );
219floatx80 floatx80_div( floatx80, floatx80 );
220floatx80 floatx80_rem( floatx80, floatx80 );
221floatx80 floatx80_sqrt( floatx80 );
222char floatx80_eq( floatx80, floatx80 );
223char floatx80_le( floatx80, floatx80 );
224char floatx80_lt( floatx80, floatx80 );
225char floatx80_eq_signaling( floatx80, floatx80 );
226char floatx80_le_quiet( floatx80, floatx80 );
227char floatx80_lt_quiet( floatx80, floatx80 );
228char floatx80_is_signaling_nan( floatx80 );
229
230#endif
231
232#endif
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
index 1b75672dfc8f..20841663270f 100644
--- a/arch/blackfin/Makefile
+++ b/arch/blackfin/Makefile
@@ -24,6 +24,8 @@ machine-$(CONFIG_BF533) := bf533
24machine-$(CONFIG_BF534) := bf537 24machine-$(CONFIG_BF534) := bf537
25machine-$(CONFIG_BF536) := bf537 25machine-$(CONFIG_BF536) := bf537
26machine-$(CONFIG_BF537) := bf537 26machine-$(CONFIG_BF537) := bf537
27machine-$(CONFIG_BF542) := bf548
28machine-$(CONFIG_BF544) := bf548
27machine-$(CONFIG_BF548) := bf548 29machine-$(CONFIG_BF548) := bf548
28machine-$(CONFIG_BF549) := bf548 30machine-$(CONFIG_BF549) := bf548
29machine-$(CONFIG_BF561) := bf561 31machine-$(CONFIG_BF561) := bf561
@@ -36,6 +38,8 @@ cpu-$(CONFIG_BF533) := bf533
36cpu-$(CONFIG_BF534) := bf534 38cpu-$(CONFIG_BF534) := bf534
37cpu-$(CONFIG_BF536) := bf536 39cpu-$(CONFIG_BF536) := bf536
38cpu-$(CONFIG_BF537) := bf537 40cpu-$(CONFIG_BF537) := bf537
41cpu-$(CONFIG_BF542) := bf542
42cpu-$(CONFIG_BF544) := bf544
39cpu-$(CONFIG_BF548) := bf548 43cpu-$(CONFIG_BF548) := bf548
40cpu-$(CONFIG_BF549) := bf549 44cpu-$(CONFIG_BF549) := bf549
41cpu-$(CONFIG_BF561) := bf561 45cpu-$(CONFIG_BF561) := bf561
diff --git a/arch/blackfin/kernel/dma-mapping.c b/arch/blackfin/kernel/dma-mapping.c
index ea48d5b13f11..94d7b119b71e 100644
--- a/arch/blackfin/kernel/dma-mapping.c
+++ b/arch/blackfin/kernel/dma-mapping.c
@@ -160,7 +160,8 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
160 BUG_ON(direction == DMA_NONE); 160 BUG_ON(direction == DMA_NONE);
161 161
162 for (i = 0; i < nents; i++, sg++) { 162 for (i = 0; i < nents; i++, sg++) {
163 sg->dma_address = page_address(sg->page) + sg->offset; 163 sg->dma_address = (dma_addr_t)(page_address(sg->page) +
164 sg->offset);
164 165
165 invalidate_dcache_range(sg_dma_address(sg), 166 invalidate_dcache_range(sg_dma_address(sg),
166 sg_dma_address(sg) + 167 sg_dma_address(sg) +
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c
index f59dcee7bae3..88f221b89b33 100644
--- a/arch/blackfin/kernel/setup.c
+++ b/arch/blackfin/kernel/setup.c
@@ -402,11 +402,7 @@ void __init setup_arch(char **cmdline_p)
402 if (l1_length > L1_DATA_A_LENGTH) 402 if (l1_length > L1_DATA_A_LENGTH)
403 panic("L1 data memory overflow\n"); 403 panic("L1 data memory overflow\n");
404 404
405#ifdef BF561_FAMILY
406 _bfin_swrst = bfin_read_SICA_SWRST();
407#else
408 _bfin_swrst = bfin_read_SWRST(); 405 _bfin_swrst = bfin_read_SWRST();
409#endif
410 406
411 /* Copy atomic sequences to their fixed location, and sanity check that 407 /* Copy atomic sequences to their fixed location, and sanity check that
412 these locations are the ones that we advertise to userspace. */ 408 these locations are the ones that we advertise to userspace. */
@@ -429,6 +425,7 @@ void __init setup_arch(char **cmdline_p)
429 BUG_ON((char *)&atomic_xor32 - (char *)&fixed_code_start 425 BUG_ON((char *)&atomic_xor32 - (char *)&fixed_code_start
430 != ATOMIC_XOR32 - FIXED_CODE_START); 426 != ATOMIC_XOR32 - FIXED_CODE_START);
431 427
428 init_exception_vectors();
432 bf53x_cache_init(); 429 bf53x_cache_init();
433} 430}
434 431
diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c
index 3909f5b35536..8766bd612b47 100644
--- a/arch/blackfin/kernel/traps.c
+++ b/arch/blackfin/kernel/traps.c
@@ -140,7 +140,7 @@ asmlinkage void trap_c(struct pt_regs *fp)
140#ifdef CONFIG_KGDB 140#ifdef CONFIG_KGDB
141# define CHK_DEBUGGER_TRAP() \ 141# define CHK_DEBUGGER_TRAP() \
142 do { \ 142 do { \
143 CHK_DEBUGGER(trapnr, sig, info.si_code, fp); \ 143 CHK_DEBUGGER(trapnr, sig, info.si_code, fp, ); \
144 } while (0) 144 } while (0)
145# define CHK_DEBUGGER_TRAP_MAYBE() \ 145# define CHK_DEBUGGER_TRAP_MAYBE() \
146 do { \ 146 do { \
diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S
index d06f860f4790..fb53780247bc 100644
--- a/arch/blackfin/kernel/vmlinux.lds.S
+++ b/arch/blackfin/kernel/vmlinux.lds.S
@@ -32,6 +32,7 @@
32#include <asm-generic/vmlinux.lds.h> 32#include <asm-generic/vmlinux.lds.h>
33#include <asm/mem_map.h> 33#include <asm/mem_map.h>
34#include <asm/page.h> 34#include <asm/page.h>
35#include <asm/thread_info.h>
35 36
36OUTPUT_FORMAT("elf32-bfin") 37OUTPUT_FORMAT("elf32-bfin")
37ENTRY(__start) 38ENTRY(__start)
@@ -64,8 +65,12 @@ SECTIONS
64 65
65 .data : 66 .data :
66 { 67 {
67 . = ALIGN(PAGE_SIZE); 68 /* make sure the init_task is aligned to the
69 * kernel thread size so we can locate the kernel
70 * stack properly and quickly.
71 */
68 __sdata = .; 72 __sdata = .;
73 . = ALIGN(THREAD_SIZE);
69 *(.data.init_task) 74 *(.data.init_task)
70 DATA_DATA 75 DATA_DATA
71 CONSTRUCTORS 76 CONSTRUCTORS
@@ -73,14 +78,14 @@ SECTIONS
73 . = ALIGN(32); 78 . = ALIGN(32);
74 *(.data.cacheline_aligned) 79 *(.data.cacheline_aligned)
75 80
76 . = ALIGN(PAGE_SIZE); 81 . = ALIGN(THREAD_SIZE);
77 __edata = .; 82 __edata = .;
78 } 83 }
79 84
80 . = ALIGN(PAGE_SIZE);
81 ___init_begin = .; 85 ___init_begin = .;
82 .init : 86 .init :
83 { 87 {
88 . = ALIGN(PAGE_SIZE);
84 __sinittext = .; 89 __sinittext = .;
85 *(.init.text) 90 *(.init.text)
86 __einittext = .; 91 __einittext = .;
@@ -153,10 +158,9 @@ SECTIONS
153 __ebss_b_l1 = .; 158 __ebss_b_l1 = .;
154 } 159 }
155 160
156 . = LOADADDR(.data_b_l1) + SIZEOF(.data_b_l1); 161 ___init_end = LOADADDR(.data_b_l1) + SIZEOF(.data_b_l1);
157 ___init_end = ALIGN(PAGE_SIZE);
158 162
159 .bss ___init_end : 163 .bss LOADADDR(.data_b_l1) + SIZEOF(.data_b_l1) :
160 { 164 {
161 . = ALIGN(4); 165 . = ALIGN(4);
162 ___bss_start = .; 166 ___bss_start = .;
diff --git a/arch/blackfin/mach-bf561/head.S b/arch/blackfin/mach-bf561/head.S
index 2f08bcb2dded..38650a628980 100644
--- a/arch/blackfin/mach-bf561/head.S
+++ b/arch/blackfin/mach-bf561/head.S
@@ -440,15 +440,15 @@ ENTRY(_bfin_reset)
440 SSYNC; 440 SSYNC;
441 441
442 /* make sure SYSCR is set to use BMODE */ 442 /* make sure SYSCR is set to use BMODE */
443 P0.h = hi(SICA_SYSCR); 443 P0.h = hi(SYSCR);
444 P0.l = lo(SICA_SYSCR); 444 P0.l = lo(SYSCR);
445 R0.l = 0x20; 445 R0.l = 0x20; /* on BF561, disable core b */
446 W[P0] = R0.l; 446 W[P0] = R0.l;
447 SSYNC; 447 SSYNC;
448 448
449 /* issue a system soft reset */ 449 /* issue a system soft reset */
450 P1.h = hi(SICA_SWRST); 450 P1.h = hi(SWRST);
451 P1.l = lo(SICA_SWRST); 451 P1.l = lo(SWRST);
452 R1.l = 0x0007; 452 R1.l = 0x0007;
453 W[P1] = R1; 453 W[P1] = R1;
454 SSYNC; 454 SSYNC;
diff --git a/arch/blackfin/mach-common/cacheinit.S b/arch/blackfin/mach-common/cacheinit.S
index 9d475623b724..5be6b975ae4a 100644
--- a/arch/blackfin/mach-common/cacheinit.S
+++ b/arch/blackfin/mach-common/cacheinit.S
@@ -60,6 +60,9 @@ ENDPROC(_bfin_write_IMEM_CONTROL)
60 60
61#if defined(CONFIG_BLKFIN_DCACHE) 61#if defined(CONFIG_BLKFIN_DCACHE)
62ENTRY(_bfin_write_DMEM_CONTROL) 62ENTRY(_bfin_write_DMEM_CONTROL)
63 P0.l = (DMEM_CONTROL & 0xFFFF);
64 P0.h = (DMEM_CONTROL >> 16);
65
63 CLI R1; 66 CLI R1;
64 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */ 67 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
65 .align 8; 68 .align 8;
diff --git a/arch/blackfin/mach-common/ints-priority-dc.c b/arch/blackfin/mach-common/ints-priority-dc.c
index 6b9fd03ce835..660f881b620a 100644
--- a/arch/blackfin/mach-common/ints-priority-dc.c
+++ b/arch/blackfin/mach-common/ints-priority-dc.c
@@ -358,26 +358,10 @@ static void bf561_demux_gpio_irq(unsigned int inta_irq,
358 358
359#endif /* CONFIG_IRQCHIP_DEMUX_GPIO */ 359#endif /* CONFIG_IRQCHIP_DEMUX_GPIO */
360 360
361/* 361void __init init_exception_vectors(void)
362 * This function should be called during kernel startup to initialize
363 * the BFin IRQ handling routines.
364 */
365int __init init_arch_irq(void)
366{ 362{
367 int irq;
368 unsigned long ilat = 0;
369 /* Disable all the peripheral intrs - page 4-29 HW Ref manual */
370 bfin_write_SICA_IMASK0(SIC_UNMASK_ALL);
371 bfin_write_SICA_IMASK1(SIC_UNMASK_ALL);
372 SSYNC(); 363 SSYNC();
373 364
374 bfin_write_SICA_IWR0(IWR_ENABLE_ALL);
375 bfin_write_SICA_IWR1(IWR_ENABLE_ALL);
376
377 local_irq_disable();
378
379 init_exception_buff();
380
381#ifndef CONFIG_KGDB 365#ifndef CONFIG_KGDB
382 bfin_write_EVT0(evt_emulation); 366 bfin_write_EVT0(evt_emulation);
383#endif 367#endif
@@ -395,6 +379,27 @@ int __init init_arch_irq(void)
395 bfin_write_EVT14(evt14_softirq); 379 bfin_write_EVT14(evt14_softirq);
396 bfin_write_EVT15(evt_system_call); 380 bfin_write_EVT15(evt_system_call);
397 CSYNC(); 381 CSYNC();
382}
383
384/*
385 * This function should be called during kernel startup to initialize
386 * the BFin IRQ handling routines.
387 */
388int __init init_arch_irq(void)
389{
390 int irq;
391 unsigned long ilat = 0;
392 /* Disable all the peripheral intrs - page 4-29 HW Ref manual */
393 bfin_write_SICA_IMASK0(SIC_UNMASK_ALL);
394 bfin_write_SICA_IMASK1(SIC_UNMASK_ALL);
395 SSYNC();
396
397 bfin_write_SICA_IWR0(IWR_ENABLE_ALL);
398 bfin_write_SICA_IWR1(IWR_ENABLE_ALL);
399
400 local_irq_disable();
401
402 init_exception_buff();
398 403
399 for (irq = 0; irq <= SYS_IRQS; irq++) { 404 for (irq = 0; irq <= SYS_IRQS; irq++) {
400 if (irq <= IRQ_CORETMR) 405 if (irq <= IRQ_CORETMR)
diff --git a/arch/blackfin/mach-common/ints-priority-sc.c b/arch/blackfin/mach-common/ints-priority-sc.c
index 28a878c3577a..4708023fe716 100644
--- a/arch/blackfin/mach-common/ints-priority-sc.c
+++ b/arch/blackfin/mach-common/ints-priority-sc.c
@@ -579,8 +579,12 @@ static unsigned int bfin_gpio_irq_startup(unsigned int irq)
579 u16 gpionr = irq - IRQ_PA0; 579 u16 gpionr = irq - IRQ_PA0;
580 u8 pint_val = irq2pint_lut[irq - SYS_IRQS]; 580 u8 pint_val = irq2pint_lut[irq - SYS_IRQS];
581 581
582 if (pint_val == IRQ_NOT_AVAIL) 582 if (pint_val == IRQ_NOT_AVAIL) {
583 printk(KERN_ERR
584 "GPIO IRQ %d :Not in PINT Assign table "
585 "Reconfigure Interrupt to Port Assignemt\n", irq);
583 return -ENODEV; 586 return -ENODEV;
587 }
584 588
585 if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) { 589 if (!(gpio_enabled[gpio_bank(gpionr)] & gpio_bit(gpionr))) {
586 ret = gpio_request(gpionr, NULL); 590 ret = gpio_request(gpionr, NULL);
@@ -713,6 +717,29 @@ static void bfin_demux_gpio_irq(unsigned int intb_irq,
713} 717}
714#endif /* CONFIG_IRQCHIP_DEMUX_GPIO */ 718#endif /* CONFIG_IRQCHIP_DEMUX_GPIO */
715 719
720void __init init_exception_vectors(void)
721{
722 SSYNC();
723
724#ifndef CONFIG_KGDB
725 bfin_write_EVT0(evt_emulation);
726#endif
727 bfin_write_EVT2(evt_evt2);
728 bfin_write_EVT3(trap);
729 bfin_write_EVT5(evt_ivhw);
730 bfin_write_EVT6(evt_timer);
731 bfin_write_EVT7(evt_evt7);
732 bfin_write_EVT8(evt_evt8);
733 bfin_write_EVT9(evt_evt9);
734 bfin_write_EVT10(evt_evt10);
735 bfin_write_EVT11(evt_evt11);
736 bfin_write_EVT12(evt_evt12);
737 bfin_write_EVT13(evt_evt13);
738 bfin_write_EVT14(evt14_softirq);
739 bfin_write_EVT15(evt_system_call);
740 CSYNC();
741}
742
716/* 743/*
717 * This function should be called during kernel startup to initialize 744 * This function should be called during kernel startup to initialize
718 * the BFin IRQ handling routines. 745 * the BFin IRQ handling routines.
@@ -733,29 +760,10 @@ int __init init_arch_irq(void)
733 bfin_write_SIC_IMASK(SIC_UNMASK_ALL); 760 bfin_write_SIC_IMASK(SIC_UNMASK_ALL);
734 bfin_write_SIC_IWR(IWR_ENABLE_ALL); 761 bfin_write_SIC_IWR(IWR_ENABLE_ALL);
735#endif 762#endif
736
737 SSYNC(); 763 SSYNC();
738 764
739 local_irq_disable(); 765 local_irq_disable();
740 766
741#ifndef CONFIG_KGDB
742 bfin_write_EVT0(evt_emulation);
743#endif
744 bfin_write_EVT2(evt_evt2);
745 bfin_write_EVT3(trap);
746 bfin_write_EVT5(evt_ivhw);
747 bfin_write_EVT6(evt_timer);
748 bfin_write_EVT7(evt_evt7);
749 bfin_write_EVT8(evt_evt8);
750 bfin_write_EVT9(evt_evt9);
751 bfin_write_EVT10(evt_evt10);
752 bfin_write_EVT11(evt_evt11);
753 bfin_write_EVT12(evt_evt12);
754 bfin_write_EVT13(evt_evt13);
755 bfin_write_EVT14(evt14_softirq);
756 bfin_write_EVT15(evt_system_call);
757 CSYNC();
758
759#if defined(CONFIG_IRQCHIP_DEMUX_GPIO) && defined(CONFIG_BF54x) 767#if defined(CONFIG_IRQCHIP_DEMUX_GPIO) && defined(CONFIG_BF54x)
760#ifdef CONFIG_PINTx_REASSIGN 768#ifdef CONFIG_PINTx_REASSIGN
761 pint[0]->assign = CONFIG_PINT0_ASSIGN; 769 pint[0]->assign = CONFIG_PINT0_ASSIGN;
diff --git a/arch/frv/kernel/sys_frv.c b/arch/frv/kernel/sys_frv.c
index 26b3df32b9a7..6fbe2665c577 100644
--- a/arch/frv/kernel/sys_frv.c
+++ b/arch/frv/kernel/sys_frv.c
@@ -13,6 +13,7 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/fs.h>
16#include <linux/smp.h> 17#include <linux/smp.h>
17#include <linux/sem.h> 18#include <linux/sem.h>
18#include <linux/msg.h> 19#include <linux/msg.h>
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index abb582bc218f..f9524933258a 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -458,8 +458,7 @@ config MICROCODE
458 tristate "/dev/cpu/microcode - Intel IA32 CPU microcode support" 458 tristate "/dev/cpu/microcode - Intel IA32 CPU microcode support"
459 select FW_LOADER 459 select FW_LOADER
460 ---help--- 460 ---help---
461 If you say Y here and also to "/dev file system support" in the 461 If you say Y here, you will be able to update the microcode on
462 'File systems' section, you will be able to update the microcode on
463 Intel processors in the IA32 family, e.g. Pentium Pro, Pentium II, 462 Intel processors in the IA32 family, e.g. Pentium Pro, Pentium II,
464 Pentium III, Pentium 4, Xeon etc. You will obviously need the 463 Pentium III, Pentium 4, Xeon etc. You will obviously need the
465 actual microcode binary data itself which is not shipped with the 464 actual microcode binary data itself which is not shipped with the
@@ -938,7 +937,7 @@ source "drivers/acpi/Kconfig"
938 937
939menuconfig APM 938menuconfig APM
940 tristate "APM (Advanced Power Management) BIOS support" 939 tristate "APM (Advanced Power Management) BIOS support"
941 depends on PM && !X86_VISWS 940 depends on PM_SLEEP && !X86_VISWS
942 ---help--- 941 ---help---
943 APM is a BIOS specification for saving power using several different 942 APM is a BIOS specification for saving power using several different
944 techniques. This is mostly useful for battery powered laptops with 943 techniques. This is mostly useful for battery powered laptops with
diff --git a/arch/i386/Kconfig.debug b/arch/i386/Kconfig.debug
index b31c0802e1cc..f03531eacdfb 100644
--- a/arch/i386/Kconfig.debug
+++ b/arch/i386/Kconfig.debug
@@ -36,11 +36,11 @@ config DEBUG_STACK_USAGE
36 This option will slow down process creation somewhat. 36 This option will slow down process creation somewhat.
37 37
38comment "Page alloc debug is incompatible with Software Suspend on i386" 38comment "Page alloc debug is incompatible with Software Suspend on i386"
39 depends on DEBUG_KERNEL && SOFTWARE_SUSPEND 39 depends on DEBUG_KERNEL && HIBERNATION
40 40
41config DEBUG_PAGEALLOC 41config DEBUG_PAGEALLOC
42 bool "Debug page memory allocations" 42 bool "Debug page memory allocations"
43 depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND && !HUGETLBFS 43 depends on DEBUG_KERNEL && !HIBERNATION && !HUGETLBFS
44 help 44 help
45 Unmap pages from the kernel linear mapping after free_pages(). 45 Unmap pages from the kernel linear mapping after free_pages().
46 This results in a large slowdown, but helps to find certain types 46 This results in a large slowdown, but helps to find certain types
diff --git a/arch/i386/boot/apm.c b/arch/i386/boot/apm.c
index a34087c370c0..eab50c55a3a5 100644
--- a/arch/i386/boot/apm.c
+++ b/arch/i386/boot/apm.c
@@ -40,14 +40,15 @@ int query_apm_bios(void)
40 if (bx != 0x504d) /* "PM" signature */ 40 if (bx != 0x504d) /* "PM" signature */
41 return -1; 41 return -1;
42 42
43 if (cx & 0x02) /* 32 bits supported? */ 43 if (!(cx & 0x02)) /* 32 bits supported? */
44 return -1; 44 return -1;
45 45
46 /* Disconnect first, just in case */ 46 /* Disconnect first, just in case */
47 ax = 0x5304; 47 ax = 0x5304;
48 bx = 0;
48 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp" 49 asm volatile("pushl %%ebp ; int $0x15 ; popl %%ebp"
49 : "+a" (ax) 50 : "+a" (ax), "+b" (bx)
50 : : "ebx", "ecx", "edx", "esi", "edi"); 51 : : "ecx", "edx", "esi", "edi");
51 52
52 /* Paranoia */ 53 /* Paranoia */
53 ebx = esi = 0; 54 ebx = esi = 0;
diff --git a/arch/i386/boot/code16gcc.h b/arch/i386/boot/code16gcc.h
index 3bd848093b9d..d93e48010b61 100644
--- a/arch/i386/boot/code16gcc.h
+++ b/arch/i386/boot/code16gcc.h
@@ -2,7 +2,7 @@
2 * code16gcc.h 2 * code16gcc.h
3 * 3 *
4 * This file is -include'd when compiling 16-bit C code. 4 * This file is -include'd when compiling 16-bit C code.
5 * Note: this asm() needs to be emitted before gcc omits any code. 5 * Note: this asm() needs to be emitted before gcc emits any code.
6 * Depending on gcc version, this requires -fno-unit-at-a-time or 6 * Depending on gcc version, this requires -fno-unit-at-a-time or
7 * -fno-toplevel-reorder. 7 * -fno-toplevel-reorder.
8 * 8 *
diff --git a/arch/i386/boot/edd.c b/arch/i386/boot/edd.c
index 25a282494f4c..77d92daf7923 100644
--- a/arch/i386/boot/edd.c
+++ b/arch/i386/boot/edd.c
@@ -72,17 +72,18 @@ static u32 read_mbr_sig(u8 devno, struct edd_info *ei)
72 u32 mbrsig; 72 u32 mbrsig;
73 u32 buf_base, mbr_base; 73 u32 buf_base, mbr_base;
74 extern char _end[]; 74 extern char _end[];
75 static char mbr_buf[1024];
76 75
77 sector_size = ei->params.bytes_per_sector; 76 sector_size = ei->params.bytes_per_sector;
78 if (!sector_size) 77 if (!sector_size)
79 sector_size = 512; /* Best available guess */ 78 sector_size = 512; /* Best available guess */
80 79
80 /* Produce a naturally aligned buffer on the heap */
81 buf_base = (ds() << 4) + (u32)&_end; 81 buf_base = (ds() << 4) + (u32)&_end;
82 mbr_base = (buf_base+sector_size-1) & ~(sector_size-1); 82 mbr_base = (buf_base+sector_size-1) & ~(sector_size-1);
83 mbrbuf_ptr = mbr_buf + (mbr_base-buf_base); 83 mbrbuf_ptr = _end + (mbr_base-buf_base);
84 mbrbuf_end = mbrbuf_ptr + sector_size; 84 mbrbuf_end = mbrbuf_ptr + sector_size;
85 85
86 /* Make sure we actually have space on the heap... */
86 if (!(boot_params.hdr.loadflags & CAN_USE_HEAP)) 87 if (!(boot_params.hdr.loadflags & CAN_USE_HEAP))
87 return 0; 88 return 0;
88 if (mbrbuf_end > (char *)(size_t)boot_params.hdr.heap_end_ptr) 89 if (mbrbuf_end > (char *)(size_t)boot_params.hdr.heap_end_ptr)
diff --git a/arch/i386/boot/header.S b/arch/i386/boot/header.S
index 6b9923fb6eae..7f4a2c53bd76 100644
--- a/arch/i386/boot/header.S
+++ b/arch/i386/boot/header.S
@@ -225,7 +225,7 @@ start_of_setup:
225 int $0x13 225 int $0x13
226#endif 226#endif
227 227
228# We will have entired with %cs = %ds+0x20, normalize %cs so 228# We will have entered with %cs = %ds+0x20, normalize %cs so
229# it is on par with the other segments. 229# it is on par with the other segments.
230 pushw %ds 230 pushw %ds
231 pushw $setup2 231 pushw $setup2
@@ -280,4 +280,4 @@ die:
280 .section ".initdata", "a" 280 .section ".initdata", "a"
281setup_corrupt: 281setup_corrupt:
282 .byte 7 282 .byte 7
283 .string "No setup signature found..." 283 .string "No setup signature found...\n"
diff --git a/arch/i386/boot/install.sh b/arch/i386/boot/install.sh
index 5e44c736eea8..88d77761d01b 100644
--- a/arch/i386/boot/install.sh
+++ b/arch/i386/boot/install.sh
@@ -51,4 +51,11 @@ fi
51cat $2 > $4/vmlinuz 51cat $2 > $4/vmlinuz
52cp $3 $4/System.map 52cp $3 $4/System.map
53 53
54if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi 54if [ -x /sbin/lilo ]; then
55 /sbin/lilo
56elif [ -x /etc/lilo/install ]; then
57 /etc/lilo/install
58else
59 sync
60 echo "Cannot find LILO."
61fi
diff --git a/arch/i386/boot/main.c b/arch/i386/boot/main.c
index 7f01f96c4fb8..0eeef3989a17 100644
--- a/arch/i386/boot/main.c
+++ b/arch/i386/boot/main.c
@@ -73,15 +73,15 @@ static void keyboard_set_repeat(void)
73} 73}
74 74
75/* 75/*
76 * Get Intel SpeedStep IST information. 76 * Get Intel SpeedStep (IST) information.
77 */ 77 */
78static void query_speedstep_ist(void) 78static void query_ist(void)
79{ 79{
80 asm("int $0x15" 80 asm("int $0x15"
81 : "=a" (boot_params.speedstep_info[0]), 81 : "=a" (boot_params.ist_info.signature),
82 "=b" (boot_params.speedstep_info[1]), 82 "=b" (boot_params.ist_info.command),
83 "=c" (boot_params.speedstep_info[2]), 83 "=c" (boot_params.ist_info.event),
84 "=d" (boot_params.speedstep_info[3]) 84 "=d" (boot_params.ist_info.perf_level)
85 : "a" (0x0000e980), /* IST Support */ 85 : "a" (0x0000e980), /* IST Support */
86 "d" (0x47534943)); /* Request value */ 86 "d" (0x47534943)); /* Request value */
87} 87}
@@ -144,8 +144,8 @@ void main(void)
144 query_voyager(); 144 query_voyager();
145#endif 145#endif
146 146
147 /* Query SpeedStep IST information */ 147 /* Query Intel SpeedStep (IST) information */
148 query_speedstep_ist(); 148 query_ist();
149 149
150 /* Query APM information */ 150 /* Query APM information */
151#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE) 151#if defined(CONFIG_APM) || defined(CONFIG_APM_MODULE)
diff --git a/arch/i386/boot/pm.c b/arch/i386/boot/pm.c
index 1df025c73261..6be9ca811d17 100644
--- a/arch/i386/boot/pm.c
+++ b/arch/i386/boot/pm.c
@@ -80,7 +80,7 @@ static void move_kernel_around(void)
80 */ 80 */
81static void mask_all_interrupts(void) 81static void mask_all_interrupts(void)
82{ 82{
83 outb(0xff, 0xa1); /* Mask all interrupts on the seconday PIC */ 83 outb(0xff, 0xa1); /* Mask all interrupts on the secondary PIC */
84 io_delay(); 84 io_delay();
85 outb(0xfb, 0x21); /* Mask all but cascade on the primary PIC */ 85 outb(0xfb, 0x21); /* Mask all but cascade on the primary PIC */
86 io_delay(); 86 io_delay();
diff --git a/arch/i386/boot/video-bios.c b/arch/i386/boot/video-bios.c
index afea46c500cc..68e65d95cdfd 100644
--- a/arch/i386/boot/video-bios.c
+++ b/arch/i386/boot/video-bios.c
@@ -44,7 +44,7 @@ static int set_bios_mode(u8 mode)
44 : "+a" (ax) 44 : "+a" (ax)
45 : : "ebx", "ecx", "edx", "esi", "edi"); 45 : : "ebx", "ecx", "edx", "esi", "edi");
46 46
47 do_restore = 1; /* Assume video contents was lost */ 47 do_restore = 1; /* Assume video contents were lost */
48 new_mode = ax & 0x7f; /* Not all BIOSes are clean with the top bit */ 48 new_mode = ax & 0x7f; /* Not all BIOSes are clean with the top bit */
49 49
50 if (new_mode == mode) 50 if (new_mode == mode)
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
index dbe5e87e0d66..9d33b00de659 100644
--- a/arch/i386/kernel/Makefile
+++ b/arch/i386/kernel/Makefile
@@ -35,7 +35,6 @@ obj-y += sysenter.o vsyscall.o
35obj-$(CONFIG_ACPI_SRAT) += srat.o 35obj-$(CONFIG_ACPI_SRAT) += srat.o
36obj-$(CONFIG_EFI) += efi.o efi_stub.o 36obj-$(CONFIG_EFI) += efi.o efi_stub.o
37obj-$(CONFIG_DOUBLEFAULT) += doublefault.o 37obj-$(CONFIG_DOUBLEFAULT) += doublefault.o
38obj-$(CONFIG_SERIAL_8250) += legacy_serial.o
39obj-$(CONFIG_VM86) += vm86.o 38obj-$(CONFIG_VM86) += vm86.o
40obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 39obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
41obj-$(CONFIG_HPET_TIMER) += hpet.o 40obj-$(CONFIG_HPET_TIMER) += hpet.o
diff --git a/arch/i386/kernel/alternative.c b/arch/i386/kernel/alternative.c
index c3750c2c4113..c85598acb8fd 100644
--- a/arch/i386/kernel/alternative.c
+++ b/arch/i386/kernel/alternative.c
@@ -430,22 +430,12 @@ void __init alternative_instructions(void)
430 * And on the local CPU you need to be protected again NMI or MCE handlers 430 * And on the local CPU you need to be protected again NMI or MCE handlers
431 * seeing an inconsistent instruction while you patch. 431 * seeing an inconsistent instruction while you patch.
432 */ 432 */
433void __kprobes text_poke(void *oaddr, unsigned char *opcode, int len) 433void __kprobes text_poke(void *addr, unsigned char *opcode, int len)
434{ 434{
435 u8 *addr = oaddr;
436 if (!pte_write(*lookup_address((unsigned long)addr))) {
437 struct page *p[2] = { virt_to_page(addr), virt_to_page(addr+PAGE_SIZE) };
438 addr = vmap(p, 2, VM_MAP, PAGE_KERNEL);
439 if (!addr)
440 return;
441 addr += ((unsigned long)oaddr) % PAGE_SIZE;
442 }
443 memcpy(addr, opcode, len); 435 memcpy(addr, opcode, len);
444 sync_core(); 436 sync_core();
445 /* Not strictly needed, but can speed CPU recovery up. Ignore cross cacheline 437 /* Not strictly needed, but can speed CPU recovery up. Ignore cross cacheline
446 case. */ 438 case. */
447 if (cpu_has_clflush) 439 if (cpu_has_clflush)
448 asm("clflush (%0) " :: "r" (oaddr) : "memory"); 440 asm("clflush (%0) " :: "r" (addr) : "memory");
449 if (addr != oaddr)
450 vunmap(addr);
451} 441}
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index 47001d50a083..f02a8aca826b 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -2235,7 +2235,7 @@ static int __init apm_init(void)
2235 apm_info.bios.cseg_16_len = 0; /* 64k */ 2235 apm_info.bios.cseg_16_len = 0; /* 64k */
2236 2236
2237 if (debug) { 2237 if (debug) {
2238 printk(KERN_INFO "apm: entry %x:%lx cseg16 %x dseg %x", 2238 printk(KERN_INFO "apm: entry %x:%x cseg16 %x dseg %x",
2239 apm_info.bios.cseg, apm_info.bios.offset, 2239 apm_info.bios.cseg, apm_info.bios.offset,
2240 apm_info.bios.cseg_16, apm_info.bios.dseg); 2240 apm_info.bios.cseg_16, apm_info.bios.dseg);
2241 if (apm_info.bios.version > 0x100) 2241 if (apm_info.bios.version > 0x100)
diff --git a/arch/i386/kernel/cpu/bugs.c b/arch/i386/kernel/cpu/bugs.c
index 54428a2500f3..59266f03d1cd 100644
--- a/arch/i386/kernel/cpu/bugs.c
+++ b/arch/i386/kernel/cpu/bugs.c
@@ -11,6 +11,7 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/utsname.h> 13#include <linux/utsname.h>
14#include <asm/bugs.h>
14#include <asm/processor.h> 15#include <asm/processor.h>
15#include <asm/i387.h> 16#include <asm/i387.h>
16#include <asm/msr.h> 17#include <asm/msr.h>
diff --git a/arch/i386/kernel/cpu/cpufreq/Kconfig b/arch/i386/kernel/cpu/cpufreq/Kconfig
index 094118ba00da..d8c6f132dc7a 100644
--- a/arch/i386/kernel/cpu/cpufreq/Kconfig
+++ b/arch/i386/kernel/cpu/cpufreq/Kconfig
@@ -92,7 +92,7 @@ config X86_POWERNOW_K8
92config X86_POWERNOW_K8_ACPI 92config X86_POWERNOW_K8_ACPI
93 bool "ACPI Support" 93 bool "ACPI Support"
94 select ACPI_PROCESSOR 94 select ACPI_PROCESSOR
95 depends on X86_POWERNOW_K8 95 depends on ACPI && X86_POWERNOW_K8
96 default y 96 default y
97 help 97 help
98 This provides access to the K8s Processor Performance States via ACPI. 98 This provides access to the K8s Processor Performance States via ACPI.
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 6f846bee2103..32d04b083e38 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -511,7 +511,6 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
511static int acpi_cpufreq_early_init(void) 511static int acpi_cpufreq_early_init(void)
512{ 512{
513 struct acpi_processor_performance *data; 513 struct acpi_processor_performance *data;
514 cpumask_t covered;
515 unsigned int i, j; 514 unsigned int i, j;
516 515
517 dprintk("acpi_cpufreq_early_init\n"); 516 dprintk("acpi_cpufreq_early_init\n");
@@ -520,14 +519,13 @@ static int acpi_cpufreq_early_init(void)
520 data = kzalloc(sizeof(struct acpi_processor_performance), 519 data = kzalloc(sizeof(struct acpi_processor_performance),
521 GFP_KERNEL); 520 GFP_KERNEL);
522 if (!data) { 521 if (!data) {
523 for_each_cpu_mask(j, covered) { 522 for_each_possible_cpu(j) {
524 kfree(acpi_perf_data[j]); 523 kfree(acpi_perf_data[j]);
525 acpi_perf_data[j] = NULL; 524 acpi_perf_data[j] = NULL;
526 } 525 }
527 return -ENOMEM; 526 return -ENOMEM;
528 } 527 }
529 acpi_perf_data[i] = data; 528 acpi_perf_data[i] = data;
530 cpu_set(i, covered);
531 } 529 }
532 530
533 /* Do initialization in ACPI core */ 531 /* Do initialization in ACPI core */
diff --git a/arch/i386/kernel/e820.c b/arch/i386/kernel/e820.c
index e60cddbc4cfb..3c86b979a40a 100644
--- a/arch/i386/kernel/e820.c
+++ b/arch/i386/kernel/e820.c
@@ -321,7 +321,7 @@ static int __init request_standard_resources(void)
321 321
322subsys_initcall(request_standard_resources); 322subsys_initcall(request_standard_resources);
323 323
324#if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND) 324#if defined(CONFIG_PM) && defined(CONFIG_HIBERNATION)
325/** 325/**
326 * e820_mark_nosave_regions - Find the ranges of physical addresses that do not 326 * e820_mark_nosave_regions - Find the ranges of physical addresses that do not
327 * correspond to e820 RAM areas and mark the corresponding pages as nosave for 327 * correspond to e820 RAM areas and mark the corresponding pages as nosave for
diff --git a/arch/i386/kernel/legacy_serial.c b/arch/i386/kernel/legacy_serial.c
deleted file mode 100644
index 21510118544e..000000000000
--- a/arch/i386/kernel/legacy_serial.c
+++ /dev/null
@@ -1,67 +0,0 @@
1/*
2 * Legacy COM port devices for x86 platforms without PNPBIOS or ACPI.
3 * Data taken from include/asm-i386/serial.h.
4 *
5 * (c) Copyright 2007 Hewlett-Packard Development Company, L.P.
6 * Bjorn Helgaas <bjorn.helgaas@hp.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/pnp.h>
15#include <linux/serial_8250.h>
16
17/* Standard COM flags (except for COM4, because of the 8514 problem) */
18#ifdef CONFIG_SERIAL_DETECT_IRQ
19#define COM_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ)
20#define COM4_FLAGS (UPF_BOOT_AUTOCONF | UPF_AUTO_IRQ)
21#else
22#define COM_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST)
23#define COM4_FLAGS UPF_BOOT_AUTOCONF
24#endif
25
26#define PORT(_base,_irq,_flags) \
27 { \
28 .iobase = _base, \
29 .irq = _irq, \
30 .uartclk = 1843200, \
31 .iotype = UPIO_PORT, \
32 .flags = _flags, \
33 }
34
35static struct plat_serial8250_port x86_com_data[] = {
36 PORT(0x3F8, 4, COM_FLAGS),
37 PORT(0x2F8, 3, COM_FLAGS),
38 PORT(0x3E8, 4, COM_FLAGS),
39 PORT(0x2E8, 3, COM4_FLAGS),
40 { },
41};
42
43static struct platform_device x86_com_device = {
44 .name = "serial8250",
45 .id = PLAT8250_DEV_PLATFORM,
46 .dev = {
47 .platform_data = x86_com_data,
48 },
49};
50
51static int force_legacy_probe;
52module_param_named(force, force_legacy_probe, bool, 0);
53MODULE_PARM_DESC(force, "Force legacy serial port probe");
54
55static int __init serial8250_x86_com_init(void)
56{
57 if (pnp_platform_devices && !force_legacy_probe)
58 return -ENODEV;
59
60 return platform_device_register(&x86_com_device);
61}
62
63module_init(serial8250_x86_com_init);
64
65MODULE_AUTHOR("Bjorn Helgaas");
66MODULE_LICENSE("GPL");
67MODULE_DESCRIPTION("Generic 8250/16x50 legacy probe module");
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index d865d041bea1..09cf78110358 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -82,6 +82,7 @@
82#include <linux/miscdevice.h> 82#include <linux/miscdevice.h>
83#include <linux/spinlock.h> 83#include <linux/spinlock.h>
84#include <linux/mm.h> 84#include <linux/mm.h>
85#include <linux/fs.h>
85#include <linux/mutex.h> 86#include <linux/mutex.h>
86#include <linux/cpu.h> 87#include <linux/cpu.h>
87#include <linux/firmware.h> 88#include <linux/firmware.h>
diff --git a/arch/i386/kernel/sys_i386.c b/arch/i386/kernel/sys_i386.c
index e5dcb9379018..42147304de88 100644
--- a/arch/i386/kernel/sys_i386.c
+++ b/arch/i386/kernel/sys_i386.c
@@ -9,6 +9,7 @@
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/sched.h> 10#include <linux/sched.h>
11#include <linux/mm.h> 11#include <linux/mm.h>
12#include <linux/fs.h>
12#include <linux/smp.h> 13#include <linux/smp.h>
13#include <linux/sem.h> 14#include <linux/sem.h>
14#include <linux/msg.h> 15#include <linux/msg.h>
diff --git a/arch/i386/kernel/sysenter.c b/arch/i386/kernel/sysenter.c
index 6deb159d08e0..4eb2e408764f 100644
--- a/arch/i386/kernel/sysenter.c
+++ b/arch/i386/kernel/sysenter.c
@@ -16,6 +16,7 @@
16#include <linux/string.h> 16#include <linux/string.h>
17#include <linux/elf.h> 17#include <linux/elf.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/err.h>
19#include <linux/module.h> 20#include <linux/module.h>
20 21
21#include <asm/cpufeature.h> 22#include <asm/cpufeature.h>
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index c3b9905af2d5..730a5b177b1f 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -432,7 +432,7 @@ static void __init pagetable_init (void)
432 paravirt_pagetable_setup_done(pgd_base); 432 paravirt_pagetable_setup_done(pgd_base);
433} 433}
434 434
435#if defined(CONFIG_SOFTWARE_SUSPEND) || defined(CONFIG_ACPI_SLEEP) 435#if defined(CONFIG_HIBERNATION) || defined(CONFIG_ACPI)
436/* 436/*
437 * Swap suspend & friends need this for resume because things like the intel-agp 437 * Swap suspend & friends need this for resume because things like the intel-agp
438 * driver might have split up a kernel 4MB mapping. 438 * driver might have split up a kernel 4MB mapping.
@@ -800,9 +800,17 @@ void mark_rodata_ro(void)
800 unsigned long start = PFN_ALIGN(_text); 800 unsigned long start = PFN_ALIGN(_text);
801 unsigned long size = PFN_ALIGN(_etext) - start; 801 unsigned long size = PFN_ALIGN(_etext) - start;
802 802
803 change_page_attr(virt_to_page(start), 803#ifndef CONFIG_KPROBES
804 size >> PAGE_SHIFT, PAGE_KERNEL_RX); 804#ifdef CONFIG_HOTPLUG_CPU
805 printk("Write protecting the kernel text: %luk\n", size >> 10); 805 /* It must still be possible to apply SMP alternatives. */
806 if (num_possible_cpus() <= 1)
807#endif
808 {
809 change_page_attr(virt_to_page(start),
810 size >> PAGE_SHIFT, PAGE_KERNEL_RX);
811 printk("Write protecting the kernel text: %luk\n", size >> 10);
812 }
813#endif
806 start += size; 814 start += size;
807 size = (unsigned long)__end_rodata - start; 815 size = (unsigned long)__end_rodata - start;
808 change_page_attr(virt_to_page(start), 816 change_page_attr(virt_to_page(start),
diff --git a/arch/i386/power/Makefile b/arch/i386/power/Makefile
index 2de7bbf03cd7..d764ec950065 100644
--- a/arch/i386/power/Makefile
+++ b/arch/i386/power/Makefile
@@ -1,2 +1,2 @@
1obj-$(CONFIG_PM) += cpu.o 1obj-$(CONFIG_PM) += cpu.o
2obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o suspend.o 2obj-$(CONFIG_HIBERNATION) += swsusp.o suspend.o
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 36c7b9682aa6..21aa4fc5f8ef 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -425,6 +425,9 @@ config COMPAT
425 depends on IA32_SUPPORT 425 depends on IA32_SUPPORT
426 default y 426 default y
427 427
428config COMPAT_FOR_U64_ALIGNMENT
429 def_bool COMPAT
430
428config IA64_MCA_RECOVERY 431config IA64_MCA_RECOVERY
429 tristate "MCA recovery from errors other than TLB." 432 tristate "MCA recovery from errors other than TLB."
430 433
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index cd4adf52f174..e980e7aa2306 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2015,9 +2015,14 @@ acpi_sba_ioc_add(struct acpi_device *device)
2015 return 0; 2015 return 0;
2016} 2016}
2017 2017
2018static const struct acpi_device_id hp_ioc_iommu_device_ids[] = {
2019 {"HWP0001", 0},
2020 {"HWP0004", 0},
2021 {"", 0},
2022};
2018static struct acpi_driver acpi_sba_ioc_driver = { 2023static struct acpi_driver acpi_sba_ioc_driver = {
2019 .name = "IOC IOMMU Driver", 2024 .name = "IOC IOMMU Driver",
2020 .ids = "HWP0001,HWP0004", 2025 .ids = hp_ioc_iommu_device_ids,
2021 .ops = { 2026 .ops = {
2022 .add = acpi_sba_ioc_add, 2027 .add = acpi_sba_ioc_add,
2023 }, 2028 },
diff --git a/arch/ia64/hp/sim/simscsi.c b/arch/ia64/hp/sim/simscsi.c
index bb87682bbb1b..e62694f8ef75 100644
--- a/arch/ia64/hp/sim/simscsi.c
+++ b/arch/ia64/hp/sim/simscsi.c
@@ -101,7 +101,7 @@ simscsi_interrupt (unsigned long val)
101{ 101{
102 struct scsi_cmnd *sc; 102 struct scsi_cmnd *sc;
103 103
104 while ((sc = queue[rd].sc) != 0) { 104 while ((sc = queue[rd].sc) != NULL) {
105 atomic_dec(&num_reqs); 105 atomic_dec(&num_reqs);
106 queue[rd].sc = NULL; 106 queue[rd].sc = NULL;
107 if (DBG) 107 if (DBG)
@@ -122,48 +122,22 @@ simscsi_biosparam (struct scsi_device *sdev, struct block_device *n,
122} 122}
123 123
124static void 124static void
125simscsi_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset, unsigned long len)
126{
127 struct disk_stat stat;
128 struct disk_req req;
129
130 req.addr = __pa(sc->request_buffer);
131 req.len = len; /* # of bytes to transfer */
132
133 if (sc->request_bufflen < req.len)
134 return;
135
136 stat.fd = desc[sc->device->id];
137 if (DBG)
138 printk("simscsi_%s @ %lx (off %lx)\n",
139 mode == SSC_READ ? "read":"write", req.addr, offset);
140 ia64_ssc(stat.fd, 1, __pa(&req), offset, mode);
141 ia64_ssc(__pa(&stat), 0, 0, 0, SSC_WAIT_COMPLETION);
142
143 if (stat.count == req.len) {
144 sc->result = GOOD;
145 } else {
146 sc->result = DID_ERROR << 16;
147 }
148}
149
150static void
151simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset) 125simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset)
152{ 126{
153 int list_len = sc->use_sg; 127 int i;
154 struct scatterlist *sl = (struct scatterlist *)sc->request_buffer; 128 struct scatterlist *sl;
155 struct disk_stat stat; 129 struct disk_stat stat;
156 struct disk_req req; 130 struct disk_req req;
157 131
158 stat.fd = desc[sc->device->id]; 132 stat.fd = desc[sc->device->id];
159 133
160 while (list_len) { 134 scsi_for_each_sg(sc, sl, scsi_sg_count(sc), i) {
161 req.addr = __pa(page_address(sl->page) + sl->offset); 135 req.addr = __pa(page_address(sl->page) + sl->offset);
162 req.len = sl->length; 136 req.len = sl->length;
163 if (DBG) 137 if (DBG)
164 printk("simscsi_sg_%s @ %lx (off %lx) use_sg=%d len=%d\n", 138 printk("simscsi_sg_%s @ %lx (off %lx) use_sg=%d len=%d\n",
165 mode == SSC_READ ? "read":"write", req.addr, offset, 139 mode == SSC_READ ? "read":"write", req.addr, offset,
166 list_len, sl->length); 140 scsi_sg_count(sc) - i, sl->length);
167 ia64_ssc(stat.fd, 1, __pa(&req), offset, mode); 141 ia64_ssc(stat.fd, 1, __pa(&req), offset, mode);
168 ia64_ssc(__pa(&stat), 0, 0, 0, SSC_WAIT_COMPLETION); 142 ia64_ssc(__pa(&stat), 0, 0, 0, SSC_WAIT_COMPLETION);
169 143
@@ -173,8 +147,6 @@ simscsi_sg_readwrite (struct scsi_cmnd *sc, int mode, unsigned long offset)
173 return; 147 return;
174 } 148 }
175 offset += sl->length; 149 offset += sl->length;
176 sl++;
177 list_len--;
178 } 150 }
179 sc->result = GOOD; 151 sc->result = GOOD;
180} 152}
@@ -190,10 +162,7 @@ simscsi_readwrite6 (struct scsi_cmnd *sc, int mode)
190 unsigned long offset; 162 unsigned long offset;
191 163
192 offset = (((sc->cmnd[1] & 0x1f) << 16) | (sc->cmnd[2] << 8) | sc->cmnd[3])*512; 164 offset = (((sc->cmnd[1] & 0x1f) << 16) | (sc->cmnd[2] << 8) | sc->cmnd[3])*512;
193 if (sc->use_sg > 0) 165 simscsi_sg_readwrite(sc, mode, offset);
194 simscsi_sg_readwrite(sc, mode, offset);
195 else
196 simscsi_readwrite(sc, mode, offset, sc->cmnd[4]*512);
197} 166}
198 167
199static size_t 168static size_t
@@ -230,26 +199,21 @@ simscsi_readwrite10 (struct scsi_cmnd *sc, int mode)
230 | ((unsigned long)sc->cmnd[3] << 16) 199 | ((unsigned long)sc->cmnd[3] << 16)
231 | ((unsigned long)sc->cmnd[4] << 8) 200 | ((unsigned long)sc->cmnd[4] << 8)
232 | ((unsigned long)sc->cmnd[5] << 0))*512UL; 201 | ((unsigned long)sc->cmnd[5] << 0))*512UL;
233 if (sc->use_sg > 0) 202 simscsi_sg_readwrite(sc, mode, offset);
234 simscsi_sg_readwrite(sc, mode, offset);
235 else
236 simscsi_readwrite(sc, mode, offset, ((sc->cmnd[7] << 8) | sc->cmnd[8])*512);
237} 203}
238 204
239static void simscsi_fillresult(struct scsi_cmnd *sc, char *buf, unsigned len) 205static void simscsi_fillresult(struct scsi_cmnd *sc, char *buf, unsigned len)
240{ 206{
241 207
242 int scatterlen = sc->use_sg; 208 int i;
209 unsigned thislen;
243 struct scatterlist *slp; 210 struct scatterlist *slp;
244 211
245 if (scatterlen == 0) 212 scsi_for_each_sg(sc, slp, scsi_sg_count(sc), i) {
246 memcpy(sc->request_buffer, buf, len); 213 if (!len)
247 else for (slp = (struct scatterlist *)sc->request_buffer; 214 break;
248 scatterlen-- > 0 && len > 0; slp++) { 215 thislen = min(len, slp->length);
249 unsigned thislen = min(len, slp->length);
250
251 memcpy(page_address(slp->page) + slp->offset, buf, thislen); 216 memcpy(page_address(slp->page) + slp->offset, buf, thislen);
252 slp++;
253 len -= thislen; 217 len -= thislen;
254 } 218 }
255} 219}
@@ -275,7 +239,7 @@ simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
275 if (target_id <= 15 && sc->device->lun == 0) { 239 if (target_id <= 15 && sc->device->lun == 0) {
276 switch (sc->cmnd[0]) { 240 switch (sc->cmnd[0]) {
277 case INQUIRY: 241 case INQUIRY:
278 if (sc->request_bufflen < 35) { 242 if (scsi_bufflen(sc) < 35) {
279 break; 243 break;
280 } 244 }
281 sprintf (fname, "%s%c", simscsi_root, 'a' + target_id); 245 sprintf (fname, "%s%c", simscsi_root, 'a' + target_id);
@@ -328,7 +292,7 @@ simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
328 break; 292 break;
329 293
330 case READ_CAPACITY: 294 case READ_CAPACITY:
331 if (desc[target_id] < 0 || sc->request_bufflen < 8) { 295 if (desc[target_id] < 0 || scsi_bufflen(sc) < 8) {
332 break; 296 break;
333 } 297 }
334 buf = localbuf; 298 buf = localbuf;
@@ -350,7 +314,7 @@ simscsi_queuecommand (struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
350 case MODE_SENSE: 314 case MODE_SENSE:
351 case MODE_SENSE_10: 315 case MODE_SENSE_10:
352 /* sd.c uses this to determine whether disk does write-caching. */ 316 /* sd.c uses this to determine whether disk does write-caching. */
353 simscsi_fillresult(sc, (char *)empty_zero_page, sc->request_bufflen); 317 simscsi_fillresult(sc, (char *)empty_zero_page, scsi_bufflen(sc));
354 sc->result = GOOD; 318 sc->result = GOOD;
355 break; 319 break;
356 320
diff --git a/arch/ia64/ia32/ia32_support.c b/arch/ia64/ia32/ia32_support.c
index e13a1a1db4b5..d1d50cd1c38a 100644
--- a/arch/ia64/ia32/ia32_support.c
+++ b/arch/ia64/ia32/ia32_support.c
@@ -249,11 +249,11 @@ ia32_init (void)
249 249
250#if PAGE_SHIFT > IA32_PAGE_SHIFT 250#if PAGE_SHIFT > IA32_PAGE_SHIFT
251 { 251 {
252 extern struct kmem_cache *partial_page_cachep; 252 extern struct kmem_cache *ia64_partial_page_cachep;
253 253
254 partial_page_cachep = kmem_cache_create("partial_page_cache", 254 ia64_partial_page_cachep = kmem_cache_create("ia64_partial_page_cache",
255 sizeof(struct partial_page), 255 sizeof(struct ia64_partial_page),
256 0, SLAB_PANIC, NULL); 256 0, SLAB_PANIC, NULL);
257 } 257 }
258#endif 258#endif
259 return 0; 259 return 0;
diff --git a/arch/ia64/ia32/ia32priv.h b/arch/ia64/ia32/ia32priv.h
index cfa0bc0026b5..466bbcb138b2 100644
--- a/arch/ia64/ia32/ia32priv.h
+++ b/arch/ia64/ia32/ia32priv.h
@@ -25,8 +25,8 @@
25 * partially mapped pages provide precise accounting of which 4k sub pages 25 * partially mapped pages provide precise accounting of which 4k sub pages
26 * are mapped and which ones are not, thereby improving IA-32 compatibility. 26 * are mapped and which ones are not, thereby improving IA-32 compatibility.
27 */ 27 */
28struct partial_page { 28struct ia64_partial_page {
29 struct partial_page *next; /* linked list, sorted by address */ 29 struct ia64_partial_page *next; /* linked list, sorted by address */
30 struct rb_node pp_rb; 30 struct rb_node pp_rb;
31 /* 64K is the largest "normal" page supported by ia64 ABI. So 4K*64 31 /* 64K is the largest "normal" page supported by ia64 ABI. So 4K*64
32 * should suffice.*/ 32 * should suffice.*/
@@ -34,17 +34,17 @@ struct partial_page {
34 unsigned int base; 34 unsigned int base;
35}; 35};
36 36
37struct partial_page_list { 37struct ia64_partial_page_list {
38 struct partial_page *pp_head; /* list head, points to the lowest 38 struct ia64_partial_page *pp_head; /* list head, points to the lowest
39 * addressed partial page */ 39 * addressed partial page */
40 struct rb_root ppl_rb; 40 struct rb_root ppl_rb;
41 struct partial_page *pp_hint; /* pp_hint->next is the last 41 struct ia64_partial_page *pp_hint; /* pp_hint->next is the last
42 * accessed partial page */ 42 * accessed partial page */
43 atomic_t pp_count; /* reference count */ 43 atomic_t pp_count; /* reference count */
44}; 44};
45 45
46#if PAGE_SHIFT > IA32_PAGE_SHIFT 46#if PAGE_SHIFT > IA32_PAGE_SHIFT
47struct partial_page_list* ia32_init_pp_list (void); 47struct ia64_partial_page_list* ia32_init_pp_list (void);
48#else 48#else
49# define ia32_init_pp_list() 0 49# define ia32_init_pp_list() 0
50#endif 50#endif
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 0afb4fe7c35b..af10462d44d4 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -253,17 +253,17 @@ mmap_subpage (struct file *file, unsigned long start, unsigned long end, int pro
253 return ret; 253 return ret;
254} 254}
255 255
256/* SLAB cache for partial_page structures */ 256/* SLAB cache for ia64_partial_page structures */
257struct kmem_cache *partial_page_cachep; 257struct kmem_cache *ia64_partial_page_cachep;
258 258
259/* 259/*
260 * init partial_page_list. 260 * init ia64_partial_page_list.
261 * return 0 means kmalloc fail. 261 * return 0 means kmalloc fail.
262 */ 262 */
263struct partial_page_list* 263struct ia64_partial_page_list*
264ia32_init_pp_list(void) 264ia32_init_pp_list(void)
265{ 265{
266 struct partial_page_list *p; 266 struct ia64_partial_page_list *p;
267 267
268 if ((p = kmalloc(sizeof(*p), GFP_KERNEL)) == NULL) 268 if ((p = kmalloc(sizeof(*p), GFP_KERNEL)) == NULL)
269 return p; 269 return p;
@@ -280,12 +280,12 @@ ia32_init_pp_list(void)
280 * Else, return 0 and provide @pprev, @rb_link, @rb_parent to 280 * Else, return 0 and provide @pprev, @rb_link, @rb_parent to
281 * be used by later __ia32_insert_pp(). 281 * be used by later __ia32_insert_pp().
282 */ 282 */
283static struct partial_page * 283static struct ia64_partial_page *
284__ia32_find_pp(struct partial_page_list *ppl, unsigned int start, 284__ia32_find_pp(struct ia64_partial_page_list *ppl, unsigned int start,
285 struct partial_page **pprev, struct rb_node ***rb_link, 285 struct ia64_partial_page **pprev, struct rb_node ***rb_link,
286 struct rb_node **rb_parent) 286 struct rb_node **rb_parent)
287{ 287{
288 struct partial_page *pp; 288 struct ia64_partial_page *pp;
289 struct rb_node **__rb_link, *__rb_parent, *rb_prev; 289 struct rb_node **__rb_link, *__rb_parent, *rb_prev;
290 290
291 pp = ppl->pp_hint; 291 pp = ppl->pp_hint;
@@ -297,7 +297,7 @@ __ia32_find_pp(struct partial_page_list *ppl, unsigned int start,
297 297
298 while (*__rb_link) { 298 while (*__rb_link) {
299 __rb_parent = *__rb_link; 299 __rb_parent = *__rb_link;
300 pp = rb_entry(__rb_parent, struct partial_page, pp_rb); 300 pp = rb_entry(__rb_parent, struct ia64_partial_page, pp_rb);
301 301
302 if (pp->base == start) { 302 if (pp->base == start) {
303 ppl->pp_hint = pp; 303 ppl->pp_hint = pp;
@@ -314,7 +314,7 @@ __ia32_find_pp(struct partial_page_list *ppl, unsigned int start,
314 *rb_parent = __rb_parent; 314 *rb_parent = __rb_parent;
315 *pprev = NULL; 315 *pprev = NULL;
316 if (rb_prev) 316 if (rb_prev)
317 *pprev = rb_entry(rb_prev, struct partial_page, pp_rb); 317 *pprev = rb_entry(rb_prev, struct ia64_partial_page, pp_rb);
318 return NULL; 318 return NULL;
319} 319}
320 320
@@ -322,9 +322,9 @@ __ia32_find_pp(struct partial_page_list *ppl, unsigned int start,
322 * insert @pp into @ppl. 322 * insert @pp into @ppl.
323 */ 323 */
324static void 324static void
325__ia32_insert_pp(struct partial_page_list *ppl, struct partial_page *pp, 325__ia32_insert_pp(struct ia64_partial_page_list *ppl,
326 struct partial_page *prev, struct rb_node **rb_link, 326 struct ia64_partial_page *pp, struct ia64_partial_page *prev,
327 struct rb_node *rb_parent) 327 struct rb_node **rb_link, struct rb_node *rb_parent)
328{ 328{
329 /* link list */ 329 /* link list */
330 if (prev) { 330 if (prev) {
@@ -334,7 +334,7 @@ __ia32_insert_pp(struct partial_page_list *ppl, struct partial_page *pp,
334 ppl->pp_head = pp; 334 ppl->pp_head = pp;
335 if (rb_parent) 335 if (rb_parent)
336 pp->next = rb_entry(rb_parent, 336 pp->next = rb_entry(rb_parent,
337 struct partial_page, pp_rb); 337 struct ia64_partial_page, pp_rb);
338 else 338 else
339 pp->next = NULL; 339 pp->next = NULL;
340 } 340 }
@@ -350,8 +350,8 @@ __ia32_insert_pp(struct partial_page_list *ppl, struct partial_page *pp,
350 * delete @pp from partial page list @ppl. 350 * delete @pp from partial page list @ppl.
351 */ 351 */
352static void 352static void
353__ia32_delete_pp(struct partial_page_list *ppl, struct partial_page *pp, 353__ia32_delete_pp(struct ia64_partial_page_list *ppl,
354 struct partial_page *prev) 354 struct ia64_partial_page *pp, struct ia64_partial_page *prev)
355{ 355{
356 if (prev) { 356 if (prev) {
357 prev->next = pp->next; 357 prev->next = pp->next;
@@ -363,15 +363,15 @@ __ia32_delete_pp(struct partial_page_list *ppl, struct partial_page *pp,
363 ppl->pp_hint = pp->next; 363 ppl->pp_hint = pp->next;
364 } 364 }
365 rb_erase(&pp->pp_rb, &ppl->ppl_rb); 365 rb_erase(&pp->pp_rb, &ppl->ppl_rb);
366 kmem_cache_free(partial_page_cachep, pp); 366 kmem_cache_free(ia64_partial_page_cachep, pp);
367} 367}
368 368
369static struct partial_page * 369static struct ia64_partial_page *
370__pp_prev(struct partial_page *pp) 370__pp_prev(struct ia64_partial_page *pp)
371{ 371{
372 struct rb_node *prev = rb_prev(&pp->pp_rb); 372 struct rb_node *prev = rb_prev(&pp->pp_rb);
373 if (prev) 373 if (prev)
374 return rb_entry(prev, struct partial_page, pp_rb); 374 return rb_entry(prev, struct ia64_partial_page, pp_rb);
375 else 375 else
376 return NULL; 376 return NULL;
377} 377}
@@ -383,7 +383,7 @@ __pp_prev(struct partial_page *pp)
383static void 383static void
384__ia32_delete_pp_range(unsigned int start, unsigned int end) 384__ia32_delete_pp_range(unsigned int start, unsigned int end)
385{ 385{
386 struct partial_page *pp, *prev; 386 struct ia64_partial_page *pp, *prev;
387 struct rb_node **rb_link, *rb_parent; 387 struct rb_node **rb_link, *rb_parent;
388 388
389 if (start >= end) 389 if (start >= end)
@@ -401,7 +401,7 @@ __ia32_delete_pp_range(unsigned int start, unsigned int end)
401 } 401 }
402 402
403 while (pp && pp->base < end) { 403 while (pp && pp->base < end) {
404 struct partial_page *tmp = pp->next; 404 struct ia64_partial_page *tmp = pp->next;
405 __ia32_delete_pp(current->thread.ppl, pp, prev); 405 __ia32_delete_pp(current->thread.ppl, pp, prev);
406 pp = tmp; 406 pp = tmp;
407 } 407 }
@@ -414,7 +414,7 @@ __ia32_delete_pp_range(unsigned int start, unsigned int end)
414static int 414static int
415__ia32_set_pp(unsigned int start, unsigned int end, int flags) 415__ia32_set_pp(unsigned int start, unsigned int end, int flags)
416{ 416{
417 struct partial_page *pp, *prev; 417 struct ia64_partial_page *pp, *prev;
418 struct rb_node ** rb_link, *rb_parent; 418 struct rb_node ** rb_link, *rb_parent;
419 unsigned int pstart, start_bit, end_bit, i; 419 unsigned int pstart, start_bit, end_bit, i;
420 420
@@ -450,8 +450,8 @@ __ia32_set_pp(unsigned int start, unsigned int end, int flags)
450 return 0; 450 return 0;
451 } 451 }
452 452
453 /* new a partial_page */ 453 /* new a ia64_partial_page */
454 pp = kmem_cache_alloc(partial_page_cachep, GFP_KERNEL); 454 pp = kmem_cache_alloc(ia64_partial_page_cachep, GFP_KERNEL);
455 if (!pp) 455 if (!pp)
456 return -ENOMEM; 456 return -ENOMEM;
457 pp->base = pstart; 457 pp->base = pstart;
@@ -504,7 +504,7 @@ ia32_set_pp(unsigned int start, unsigned int end, int flags)
504static int 504static int
505__ia32_unset_pp(unsigned int start, unsigned int end) 505__ia32_unset_pp(unsigned int start, unsigned int end)
506{ 506{
507 struct partial_page *pp, *prev; 507 struct ia64_partial_page *pp, *prev;
508 struct rb_node ** rb_link, *rb_parent; 508 struct rb_node ** rb_link, *rb_parent;
509 unsigned int pstart, start_bit, end_bit, i; 509 unsigned int pstart, start_bit, end_bit, i;
510 struct vm_area_struct *vma; 510 struct vm_area_struct *vma;
@@ -532,8 +532,8 @@ __ia32_unset_pp(unsigned int start, unsigned int end)
532 return -ENOMEM; 532 return -ENOMEM;
533 } 533 }
534 534
535 /* new a partial_page */ 535 /* new a ia64_partial_page */
536 pp = kmem_cache_alloc(partial_page_cachep, GFP_KERNEL); 536 pp = kmem_cache_alloc(ia64_partial_page_cachep, GFP_KERNEL);
537 if (!pp) 537 if (!pp)
538 return -ENOMEM; 538 return -ENOMEM;
539 pp->base = pstart; 539 pp->base = pstart;
@@ -605,7 +605,7 @@ ia32_unset_pp(unsigned int *startp, unsigned int *endp)
605static int 605static int
606__ia32_compare_pp(unsigned int start, unsigned int end) 606__ia32_compare_pp(unsigned int start, unsigned int end)
607{ 607{
608 struct partial_page *pp, *prev; 608 struct ia64_partial_page *pp, *prev;
609 struct rb_node ** rb_link, *rb_parent; 609 struct rb_node ** rb_link, *rb_parent;
610 unsigned int pstart, start_bit, end_bit, size; 610 unsigned int pstart, start_bit, end_bit, size;
611 unsigned int first_bit, next_zero_bit; /* the first range in bitmap */ 611 unsigned int first_bit, next_zero_bit; /* the first range in bitmap */
@@ -682,13 +682,13 @@ ia32_compare_pp(unsigned int *startp, unsigned int *endp)
682} 682}
683 683
684static void 684static void
685__ia32_drop_pp_list(struct partial_page_list *ppl) 685__ia32_drop_pp_list(struct ia64_partial_page_list *ppl)
686{ 686{
687 struct partial_page *pp = ppl->pp_head; 687 struct ia64_partial_page *pp = ppl->pp_head;
688 688
689 while (pp) { 689 while (pp) {
690 struct partial_page *next = pp->next; 690 struct ia64_partial_page *next = pp->next;
691 kmem_cache_free(partial_page_cachep, pp); 691 kmem_cache_free(ia64_partial_page_cachep, pp);
692 pp = next; 692 pp = next;
693 } 693 }
694 694
@@ -696,9 +696,9 @@ __ia32_drop_pp_list(struct partial_page_list *ppl)
696} 696}
697 697
698void 698void
699ia32_drop_partial_page_list(struct task_struct *task) 699ia32_drop_ia64_partial_page_list(struct task_struct *task)
700{ 700{
701 struct partial_page_list* ppl = task->thread.ppl; 701 struct ia64_partial_page_list* ppl = task->thread.ppl;
702 702
703 if (ppl && atomic_dec_and_test(&ppl->pp_count)) 703 if (ppl && atomic_dec_and_test(&ppl->pp_count))
704 __ia32_drop_pp_list(ppl); 704 __ia32_drop_pp_list(ppl);
@@ -708,9 +708,9 @@ ia32_drop_partial_page_list(struct task_struct *task)
708 * Copy current->thread.ppl to ppl (already initialized). 708 * Copy current->thread.ppl to ppl (already initialized).
709 */ 709 */
710static int 710static int
711__ia32_copy_pp_list(struct partial_page_list *ppl) 711__ia32_copy_pp_list(struct ia64_partial_page_list *ppl)
712{ 712{
713 struct partial_page *pp, *tmp, *prev; 713 struct ia64_partial_page *pp, *tmp, *prev;
714 struct rb_node **rb_link, *rb_parent; 714 struct rb_node **rb_link, *rb_parent;
715 715
716 ppl->pp_head = NULL; 716 ppl->pp_head = NULL;
@@ -721,7 +721,7 @@ __ia32_copy_pp_list(struct partial_page_list *ppl)
721 prev = NULL; 721 prev = NULL;
722 722
723 for (pp = current->thread.ppl->pp_head; pp; pp = pp->next) { 723 for (pp = current->thread.ppl->pp_head; pp; pp = pp->next) {
724 tmp = kmem_cache_alloc(partial_page_cachep, GFP_KERNEL); 724 tmp = kmem_cache_alloc(ia64_partial_page_cachep, GFP_KERNEL);
725 if (!tmp) 725 if (!tmp)
726 return -ENOMEM; 726 return -ENOMEM;
727 *tmp = *pp; 727 *tmp = *pp;
@@ -734,7 +734,8 @@ __ia32_copy_pp_list(struct partial_page_list *ppl)
734} 734}
735 735
736int 736int
737ia32_copy_partial_page_list(struct task_struct *p, unsigned long clone_flags) 737ia32_copy_ia64_partial_page_list(struct task_struct *p,
738 unsigned long clone_flags)
738{ 739{
739 int retval = 0; 740 int retval = 0;
740 741
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 103dd8edda71..3d45d24a9d61 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -67,6 +67,8 @@ EXPORT_SYMBOL(pm_power_off);
67unsigned int acpi_cpei_override; 67unsigned int acpi_cpei_override;
68unsigned int acpi_cpei_phys_cpuid; 68unsigned int acpi_cpei_phys_cpuid;
69 69
70unsigned long acpi_wakeup_address = 0;
71
70const char __init * 72const char __init *
71acpi_get_sysname(void) 73acpi_get_sysname(void)
72{ 74{
@@ -739,16 +741,15 @@ int __init acpi_boot_init(void)
739 741
740int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) 742int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
741{ 743{
742 int vector; 744 int tmp;
743 745
744 if (has_8259 && gsi < 16) 746 if (has_8259 && gsi < 16)
745 *irq = isa_irq_to_vector(gsi); 747 *irq = isa_irq_to_vector(gsi);
746 else { 748 else {
747 vector = gsi_to_vector(gsi); 749 tmp = gsi_to_irq(gsi);
748 if (vector == -1) 750 if (tmp == -1)
749 return -1; 751 return -1;
750 752 *irq = tmp;
751 *irq = vector;
752 } 753 }
753 return 0; 754 return 0;
754} 755}
@@ -986,4 +987,21 @@ int acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
986 987
987EXPORT_SYMBOL(acpi_unregister_ioapic); 988EXPORT_SYMBOL(acpi_unregister_ioapic);
988 989
990/*
991 * acpi_save_state_mem() - save kernel state
992 *
993 * TBD when when IA64 starts to support suspend...
994 */
995int acpi_save_state_mem(void) { return 0; }
996
997/*
998 * acpi_restore_state()
999 */
1000void acpi_restore_state_mem(void) {}
1001
1002/*
1003 * do_suspend_lowlevel()
1004 */
1005void do_suspend_lowlevel(void) {}
1006
989#endif /* CONFIG_ACPI */ 1007#endif /* CONFIG_ACPI */
diff --git a/arch/ia64/kernel/cyclone.c b/arch/ia64/kernel/cyclone.c
index 2fd96d9062a1..790ef0d87e12 100644
--- a/arch/ia64/kernel/cyclone.c
+++ b/arch/ia64/kernel/cyclone.c
@@ -38,11 +38,11 @@ static struct clocksource clocksource_cyclone = {
38 38
39int __init init_cyclone_clock(void) 39int __init init_cyclone_clock(void)
40{ 40{
41 u64* reg; 41 u64 __iomem *reg;
42 u64 base; /* saved cyclone base address */ 42 u64 base; /* saved cyclone base address */
43 u64 offset; /* offset from pageaddr to cyclone_timer register */ 43 u64 offset; /* offset from pageaddr to cyclone_timer register */
44 int i; 44 int i;
45 u32* volatile cyclone_timer; /* Cyclone MPMC0 register */ 45 u32 __iomem *cyclone_timer; /* Cyclone MPMC0 register */
46 46
47 if (!use_cyclone) 47 if (!use_cyclone)
48 return 0; 48 return 0;
@@ -51,7 +51,7 @@ int __init init_cyclone_clock(void)
51 51
52 /* find base address */ 52 /* find base address */
53 offset = (CYCLONE_CBAR_ADDR); 53 offset = (CYCLONE_CBAR_ADDR);
54 reg = (u64*)ioremap_nocache(offset, sizeof(u64)); 54 reg = ioremap_nocache(offset, sizeof(u64));
55 if(!reg){ 55 if(!reg){
56 printk(KERN_ERR "Summit chipset: Could not find valid CBAR" 56 printk(KERN_ERR "Summit chipset: Could not find valid CBAR"
57 " register.\n"); 57 " register.\n");
@@ -69,7 +69,7 @@ int __init init_cyclone_clock(void)
69 69
70 /* setup PMCC */ 70 /* setup PMCC */
71 offset = (base + CYCLONE_PMCC_OFFSET); 71 offset = (base + CYCLONE_PMCC_OFFSET);
72 reg = (u64*)ioremap_nocache(offset, sizeof(u64)); 72 reg = ioremap_nocache(offset, sizeof(u64));
73 if(!reg){ 73 if(!reg){
74 printk(KERN_ERR "Summit chipset: Could not find valid PMCC" 74 printk(KERN_ERR "Summit chipset: Could not find valid PMCC"
75 " register.\n"); 75 " register.\n");
@@ -81,7 +81,7 @@ int __init init_cyclone_clock(void)
81 81
82 /* setup MPCS */ 82 /* setup MPCS */
83 offset = (base + CYCLONE_MPCS_OFFSET); 83 offset = (base + CYCLONE_MPCS_OFFSET);
84 reg = (u64*)ioremap_nocache(offset, sizeof(u64)); 84 reg = ioremap_nocache(offset, sizeof(u64));
85 if(!reg){ 85 if(!reg){
86 printk(KERN_ERR "Summit chipset: Could not find valid MPCS" 86 printk(KERN_ERR "Summit chipset: Could not find valid MPCS"
87 " register.\n"); 87 " register.\n");
@@ -93,7 +93,7 @@ int __init init_cyclone_clock(void)
93 93
94 /* map in cyclone_timer */ 94 /* map in cyclone_timer */
95 offset = (base + CYCLONE_MPMC_OFFSET); 95 offset = (base + CYCLONE_MPMC_OFFSET);
96 cyclone_timer = (u32*)ioremap_nocache(offset, sizeof(u32)); 96 cyclone_timer = ioremap_nocache(offset, sizeof(u32));
97 if(!cyclone_timer){ 97 if(!cyclone_timer){
98 printk(KERN_ERR "Summit chipset: Could not find valid MPMC" 98 printk(KERN_ERR "Summit chipset: Could not find valid MPMC"
99 " register.\n"); 99 " register.\n");
@@ -110,7 +110,7 @@ int __init init_cyclone_clock(void)
110 printk(KERN_ERR "Summit chipset: Counter not counting!" 110 printk(KERN_ERR "Summit chipset: Counter not counting!"
111 " DISABLED\n"); 111 " DISABLED\n");
112 iounmap(cyclone_timer); 112 iounmap(cyclone_timer);
113 cyclone_timer = 0; 113 cyclone_timer = NULL;
114 use_cyclone = 0; 114 use_cyclone = 0;
115 return -ENODEV; 115 return -ENODEV;
116 } 116 }
diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index 44d540efa6d1..4e5e27540e27 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -178,7 +178,7 @@ swapper_pg_dir:
178halt_msg: 178halt_msg:
179 stringz "Halting kernel\n" 179 stringz "Halting kernel\n"
180 180
181 .text 181 .section .text.head,"ax"
182 182
183 .global start_ap 183 .global start_ap
184 184
@@ -392,6 +392,8 @@ self: hint @pause
392 br.sptk.many self // endless loop 392 br.sptk.many self // endless loop
393END(_start) 393END(_start)
394 394
395 .text
396
395GLOBAL_ENTRY(ia64_save_debug_regs) 397GLOBAL_ENTRY(ia64_save_debug_regs)
396 alloc r16=ar.pfs,1,0,0,0 398 alloc r16=ar.pfs,1,0,0,0
397 mov r20=ar.lc // preserve ar.lc 399 mov r20=ar.lc // preserve ar.lc
diff --git a/arch/ia64/kernel/init_task.c b/arch/ia64/kernel/init_task.c
index b69c397ed1bf..bc8efcad28b8 100644
--- a/arch/ia64/kernel/init_task.c
+++ b/arch/ia64/kernel/init_task.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/fs.h>
11#include <linux/module.h> 12#include <linux/module.h>
12#include <linux/sched.h> 13#include <linux/sched.h>
13#include <linux/init_task.h> 14#include <linux/init_task.h>
diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index 91797c111162..9386b955eed1 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -85,8 +85,8 @@ DEFINE_PER_CPU(int[IA64_NUM_VECTORS], vector_irq) = {
85 [0 ... IA64_NUM_VECTORS - 1] = IA64_SPURIOUS_INT_VECTOR 85 [0 ... IA64_NUM_VECTORS - 1] = IA64_SPURIOUS_INT_VECTOR
86}; 86};
87 87
88static cpumask_t vector_table[IA64_MAX_DEVICE_VECTORS] = { 88static cpumask_t vector_table[IA64_NUM_VECTORS] = {
89 [0 ... IA64_MAX_DEVICE_VECTORS - 1] = CPU_MASK_NONE 89 [0 ... IA64_NUM_VECTORS - 1] = CPU_MASK_NONE
90}; 90};
91 91
92static int irq_status[NR_IRQS] = { 92static int irq_status[NR_IRQS] = {
@@ -123,17 +123,18 @@ static inline int find_unassigned_irq(void)
123static inline int find_unassigned_vector(cpumask_t domain) 123static inline int find_unassigned_vector(cpumask_t domain)
124{ 124{
125 cpumask_t mask; 125 cpumask_t mask;
126 int pos; 126 int pos, vector;
127 127
128 cpus_and(mask, domain, cpu_online_map); 128 cpus_and(mask, domain, cpu_online_map);
129 if (cpus_empty(mask)) 129 if (cpus_empty(mask))
130 return -EINVAL; 130 return -EINVAL;
131 131
132 for (pos = 0; pos < IA64_NUM_DEVICE_VECTORS; pos++) { 132 for (pos = 0; pos < IA64_NUM_DEVICE_VECTORS; pos++) {
133 cpus_and(mask, domain, vector_table[pos]); 133 vector = IA64_FIRST_DEVICE_VECTOR + pos;
134 cpus_and(mask, domain, vector_table[vector]);
134 if (!cpus_empty(mask)) 135 if (!cpus_empty(mask))
135 continue; 136 continue;
136 return IA64_FIRST_DEVICE_VECTOR + pos; 137 return vector;
137 } 138 }
138 return -ENOSPC; 139 return -ENOSPC;
139} 140}
@@ -141,9 +142,12 @@ static inline int find_unassigned_vector(cpumask_t domain)
141static int __bind_irq_vector(int irq, int vector, cpumask_t domain) 142static int __bind_irq_vector(int irq, int vector, cpumask_t domain)
142{ 143{
143 cpumask_t mask; 144 cpumask_t mask;
144 int cpu, pos; 145 int cpu;
145 struct irq_cfg *cfg = &irq_cfg[irq]; 146 struct irq_cfg *cfg = &irq_cfg[irq];
146 147
148 BUG_ON((unsigned)irq >= NR_IRQS);
149 BUG_ON((unsigned)vector >= IA64_NUM_VECTORS);
150
147 cpus_and(mask, domain, cpu_online_map); 151 cpus_and(mask, domain, cpu_online_map);
148 if (cpus_empty(mask)) 152 if (cpus_empty(mask))
149 return -EINVAL; 153 return -EINVAL;
@@ -156,8 +160,7 @@ static int __bind_irq_vector(int irq, int vector, cpumask_t domain)
156 cfg->vector = vector; 160 cfg->vector = vector;
157 cfg->domain = domain; 161 cfg->domain = domain;
158 irq_status[irq] = IRQ_USED; 162 irq_status[irq] = IRQ_USED;
159 pos = vector - IA64_FIRST_DEVICE_VECTOR; 163 cpus_or(vector_table[vector], vector_table[vector], domain);
160 cpus_or(vector_table[pos], vector_table[pos], domain);
161 return 0; 164 return 0;
162} 165}
163 166
@@ -174,7 +177,7 @@ int bind_irq_vector(int irq, int vector, cpumask_t domain)
174 177
175static void __clear_irq_vector(int irq) 178static void __clear_irq_vector(int irq)
176{ 179{
177 int vector, cpu, pos; 180 int vector, cpu;
178 cpumask_t mask; 181 cpumask_t mask;
179 cpumask_t domain; 182 cpumask_t domain;
180 struct irq_cfg *cfg = &irq_cfg[irq]; 183 struct irq_cfg *cfg = &irq_cfg[irq];
@@ -189,8 +192,7 @@ static void __clear_irq_vector(int irq)
189 cfg->vector = IRQ_VECTOR_UNASSIGNED; 192 cfg->vector = IRQ_VECTOR_UNASSIGNED;
190 cfg->domain = CPU_MASK_NONE; 193 cfg->domain = CPU_MASK_NONE;
191 irq_status[irq] = IRQ_UNUSED; 194 irq_status[irq] = IRQ_UNUSED;
192 pos = vector - IA64_FIRST_DEVICE_VECTOR; 195 cpus_andnot(vector_table[vector], vector_table[vector], domain);
193 cpus_andnot(vector_table[pos], vector_table[pos], domain);
194} 196}
195 197
196static void clear_irq_vector(int irq) 198static void clear_irq_vector(int irq)
@@ -212,9 +214,6 @@ assign_irq_vector (int irq)
212 vector = -ENOSPC; 214 vector = -ENOSPC;
213 215
214 spin_lock_irqsave(&vector_lock, flags); 216 spin_lock_irqsave(&vector_lock, flags);
215 if (irq < 0) {
216 goto out;
217 }
218 for_each_online_cpu(cpu) { 217 for_each_online_cpu(cpu) {
219 domain = vector_allocation_domain(cpu); 218 domain = vector_allocation_domain(cpu);
220 vector = find_unassigned_vector(domain); 219 vector = find_unassigned_vector(domain);
@@ -223,6 +222,8 @@ assign_irq_vector (int irq)
223 } 222 }
224 if (vector < 0) 223 if (vector < 0)
225 goto out; 224 goto out;
225 if (irq == AUTO_ASSIGN)
226 irq = vector;
226 BUG_ON(__bind_irq_vector(irq, vector, domain)); 227 BUG_ON(__bind_irq_vector(irq, vector, domain));
227 out: 228 out:
228 spin_unlock_irqrestore(&vector_lock, flags); 229 spin_unlock_irqrestore(&vector_lock, flags);
@@ -288,7 +289,7 @@ static int __init parse_vector_domain(char *arg)
288 vector_domain_type = VECTOR_DOMAIN_PERCPU; 289 vector_domain_type = VECTOR_DOMAIN_PERCPU;
289 no_int_routing = 1; 290 no_int_routing = 1;
290 } 291 }
291 return 1; 292 return 0;
292} 293}
293early_param("vector", parse_vector_domain); 294early_param("vector", parse_vector_domain);
294#else 295#else
diff --git a/arch/ia64/kernel/machvec.c b/arch/ia64/kernel/machvec.c
index 13df337508e7..7ccb228ceedc 100644
--- a/arch/ia64/kernel/machvec.c
+++ b/arch/ia64/kernel/machvec.c
@@ -13,14 +13,6 @@
13struct ia64_machine_vector ia64_mv; 13struct ia64_machine_vector ia64_mv;
14EXPORT_SYMBOL(ia64_mv); 14EXPORT_SYMBOL(ia64_mv);
15 15
16static __initdata const char *mvec_name;
17static __init int setup_mvec(char *s)
18{
19 mvec_name = s;
20 return 0;
21}
22early_param("machvec", setup_mvec);
23
24static struct ia64_machine_vector * __init 16static struct ia64_machine_vector * __init
25lookup_machvec (const char *name) 17lookup_machvec (const char *name)
26{ 18{
@@ -41,7 +33,7 @@ machvec_init (const char *name)
41 struct ia64_machine_vector *mv; 33 struct ia64_machine_vector *mv;
42 34
43 if (!name) 35 if (!name)
44 name = mvec_name ? mvec_name : acpi_get_sysname(); 36 name = acpi_get_sysname();
45 mv = lookup_machvec(name); 37 mv = lookup_machvec(name);
46 if (!mv) 38 if (!mv)
47 panic("generic kernel failed to find machine vector for" 39 panic("generic kernel failed to find machine vector for"
@@ -51,6 +43,23 @@ machvec_init (const char *name)
51 printk(KERN_INFO "booting generic kernel on platform %s\n", name); 43 printk(KERN_INFO "booting generic kernel on platform %s\n", name);
52} 44}
53 45
46void __init
47machvec_init_from_cmdline(const char *cmdline)
48{
49 char str[64];
50 const char *start;
51 char *end;
52
53 if (! (start = strstr(cmdline, "machvec=")) )
54 return machvec_init(NULL);
55
56 strlcpy(str, start + strlen("machvec="), sizeof(str));
57 if ( (end = strchr(str, ' ')) )
58 *end = '\0';
59
60 return machvec_init(str);
61}
62
54#endif /* CONFIG_IA64_GENERIC */ 63#endif /* CONFIG_IA64_GENERIC */
55 64
56void 65void
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index b7133cabdbea..14b8e5a6222b 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -591,13 +591,13 @@ pfm_set_task_notify(struct task_struct *task)
591 struct thread_info *info; 591 struct thread_info *info;
592 592
593 info = (struct thread_info *) ((char *) task + IA64_TASK_SIZE); 593 info = (struct thread_info *) ((char *) task + IA64_TASK_SIZE);
594 set_bit(TIF_NOTIFY_RESUME, &info->flags); 594 set_bit(TIF_PERFMON_WORK, &info->flags);
595} 595}
596 596
597static inline void 597static inline void
598pfm_clear_task_notify(void) 598pfm_clear_task_notify(void)
599{ 599{
600 clear_thread_flag(TIF_NOTIFY_RESUME); 600 clear_thread_flag(TIF_PERFMON_WORK);
601} 601}
602 602
603static inline void 603static inline void
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index fa40cba43350..4158906c45aa 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -499,7 +499,8 @@ copy_thread (int nr, unsigned long clone_flags,
499 499
500 /* Copy partially mapped page list */ 500 /* Copy partially mapped page list */
501 if (!retval) 501 if (!retval)
502 retval = ia32_copy_partial_page_list(p, clone_flags); 502 retval = ia32_copy_ia64_partial_page_list(p,
503 clone_flags);
503 } 504 }
504#endif 505#endif
505 506
@@ -728,7 +729,7 @@ flush_thread (void)
728 ia64_drop_fpu(current); 729 ia64_drop_fpu(current);
729#ifdef CONFIG_IA32_SUPPORT 730#ifdef CONFIG_IA32_SUPPORT
730 if (IS_IA32_PROCESS(task_pt_regs(current))) { 731 if (IS_IA32_PROCESS(task_pt_regs(current))) {
731 ia32_drop_partial_page_list(current); 732 ia32_drop_ia64_partial_page_list(current);
732 current->thread.task_size = IA32_PAGE_OFFSET; 733 current->thread.task_size = IA32_PAGE_OFFSET;
733 set_fs(USER_DS); 734 set_fs(USER_DS);
734 } 735 }
@@ -754,7 +755,7 @@ exit_thread (void)
754 pfm_release_debug_registers(current); 755 pfm_release_debug_registers(current);
755#endif 756#endif
756 if (IS_IA32_PROCESS(task_pt_regs(current))) 757 if (IS_IA32_PROCESS(task_pt_regs(current)))
757 ia32_drop_partial_page_list(current); 758 ia32_drop_ia64_partial_page_list(current);
758} 759}
759 760
760unsigned long 761unsigned long
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index cf06fe799041..7cecd2964200 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -491,12 +491,17 @@ setup_arch (char **cmdline_p)
491 efi_init(); 491 efi_init();
492 io_port_init(); 492 io_port_init();
493 493
494 parse_early_param();
495
496#ifdef CONFIG_IA64_GENERIC 494#ifdef CONFIG_IA64_GENERIC
497 machvec_init(NULL); 495 /* machvec needs to be parsed from the command line
496 * before parse_early_param() is called to ensure
497 * that ia64_mv is initialised before any command line
498 * settings may cause console setup to occur
499 */
500 machvec_init_from_cmdline(*cmdline_p);
498#endif 501#endif
499 502
503 parse_early_param();
504
500 if (early_console_setup(*cmdline_p) == 0) 505 if (early_console_setup(*cmdline_p) == 0)
501 mark_bsp_online(); 506 mark_bsp_online();
502 507
diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c
index 9f72838db26e..0982882bfb80 100644
--- a/arch/ia64/kernel/smp.c
+++ b/arch/ia64/kernel/smp.c
@@ -468,7 +468,7 @@ smp_send_stop (void)
468 send_IPI_allbutself(IPI_CPU_STOP); 468 send_IPI_allbutself(IPI_CPU_STOP);
469} 469}
470 470
471int __init 471int
472setup_profiling_timer (unsigned int multiplier) 472setup_profiling_timer (unsigned int multiplier)
473{ 473{
474 return -EINVAL; 474 return -EINVAL;
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index 9f5c90b594b9..62209dcf06d3 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -487,7 +487,7 @@ struct create_idle {
487 int cpu; 487 int cpu;
488}; 488};
489 489
490void 490void __cpuinit
491do_fork_idle(struct work_struct *work) 491do_fork_idle(struct work_struct *work)
492{ 492{
493 struct create_idle *c_idle = 493 struct create_idle *c_idle =
@@ -497,7 +497,7 @@ do_fork_idle(struct work_struct *work)
497 complete(&c_idle->done); 497 complete(&c_idle->done);
498} 498}
499 499
500static int __devinit 500static int __cpuinit
501do_boot_cpu (int sapicid, int cpu) 501do_boot_cpu (int sapicid, int cpu)
502{ 502{
503 int timeout; 503 int timeout;
@@ -808,7 +808,7 @@ set_cpu_sibling_map(int cpu)
808 } 808 }
809} 809}
810 810
811int __devinit 811int __cpuinit
812__cpu_up (unsigned int cpu) 812__cpu_up (unsigned int cpu)
813{ 813{
814 int ret; 814 int ret;
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 627785c48ea9..6c0e9e2e1b82 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -52,7 +52,7 @@ static struct clocksource clocksource_itc = {
52 .name = "itc", 52 .name = "itc",
53 .rating = 350, 53 .rating = 350,
54 .read = itc_get_cycles, 54 .read = itc_get_cycles,
55 .mask = 0xffffffffffffffff, 55 .mask = CLOCKSOURCE_MASK(64),
56 .mult = 0, /*to be caluclated*/ 56 .mult = 0, /*to be caluclated*/
57 .shift = 16, 57 .shift = 16,
58 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 58 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
@@ -255,7 +255,7 @@ ia64_init_itm (void)
255 } 255 }
256} 256}
257 257
258static cycle_t itc_get_cycles() 258static cycle_t itc_get_cycles(void)
259{ 259{
260 u64 lcycle, now, ret; 260 u64 lcycle, now, ret;
261 261
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index 860f251d2fc2..83e80677de70 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -50,6 +50,8 @@ SECTIONS
50 KPROBES_TEXT 50 KPROBES_TEXT
51 *(.gnu.linkonce.t*) 51 *(.gnu.linkonce.t*)
52 } 52 }
53 .text.head : AT(ADDR(.text.head) - LOAD_OFFSET)
54 { *(.text.head) }
53 .text2 : AT(ADDR(.text2) - LOAD_OFFSET) 55 .text2 : AT(ADDR(.text2) - LOAD_OFFSET)
54 { *(.text2) } 56 { *(.text2) }
55#ifdef CONFIG_SMP 57#ifdef CONFIG_SMP
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 07d0e92742c8..488e48a5deea 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -581,7 +581,7 @@ pcibios_align_resource (void *data, struct resource *res,
581/* 581/*
582 * PCI BIOS setup, always defaults to SAL interface 582 * PCI BIOS setup, always defaults to SAL interface
583 */ 583 */
584char * __init 584char * __devinit
585pcibios_setup (char *str) 585pcibios_setup (char *str)
586{ 586{
587 return str; 587 return str;
diff --git a/arch/m32r/kernel/ptrace.c b/arch/m32r/kernel/ptrace.c
index 57a92ef31a90..62a51429306e 100644
--- a/arch/m32r/kernel/ptrace.c
+++ b/arch/m32r/kernel/ptrace.c
@@ -17,6 +17,7 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/err.h>
20#include <linux/smp.h> 21#include <linux/smp.h>
21#include <linux/smp_lock.h> 22#include <linux/smp_lock.h>
22#include <linux/errno.h> 23#include <linux/errno.h>
diff --git a/arch/m32r/kernel/setup_mappi.c b/arch/m32r/kernel/setup_mappi.c
index 6b2d77da0683..fe73c9ec611f 100644
--- a/arch/m32r/kernel/setup_mappi.c
+++ b/arch/m32r/kernel/setup_mappi.c
@@ -45,7 +45,8 @@ static void mask_and_ack_mappi(unsigned int irq)
45 45
46static void end_mappi_irq(unsigned int irq) 46static void end_mappi_irq(unsigned int irq)
47{ 47{
48 enable_mappi_irq(irq); 48 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
49 enable_mappi_irq(irq);
49} 50}
50 51
51static unsigned int startup_mappi_irq(unsigned int irq) 52static unsigned int startup_mappi_irq(unsigned int irq)
@@ -88,7 +89,7 @@ void __init init_IRQ(void)
88 irq_desc[M32R_IRQ_INT0].chip = &mappi_irq_type; 89 irq_desc[M32R_IRQ_INT0].chip = &mappi_irq_type;
89 irq_desc[M32R_IRQ_INT0].action = NULL; 90 irq_desc[M32R_IRQ_INT0].action = NULL;
90 irq_desc[M32R_IRQ_INT0].depth = 1; 91 irq_desc[M32R_IRQ_INT0].depth = 1;
91 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD10; 92 icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN|M32R_ICUCR_ISMOD11;
92 disable_mappi_irq(M32R_IRQ_INT0); 93 disable_mappi_irq(M32R_IRQ_INT0);
93#endif /* CONFIG_M32R_NE2000 */ 94#endif /* CONFIG_M32R_NE2000 */
94 95
diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c
index 3eb305953497..9dae410014d8 100644
--- a/arch/m32r/kernel/smpboot.c
+++ b/arch/m32r/kernel/smpboot.c
@@ -43,6 +43,7 @@
43#include <linux/init.h> 43#include <linux/init.h>
44#include <linux/kernel.h> 44#include <linux/kernel.h>
45#include <linux/mm.h> 45#include <linux/mm.h>
46#include <linux/err.h>
46#include <linux/irq.h> 47#include <linux/irq.h>
47#include <linux/bootmem.h> 48#include <linux/bootmem.h>
48#include <linux/delay.h> 49#include <linux/delay.h>
diff --git a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c
index bda85548de6c..b13dbbeaeafa 100644
--- a/arch/m32r/kernel/sys_m32r.c
+++ b/arch/m32r/kernel/sys_m32r.c
@@ -10,6 +10,7 @@
10#include <linux/errno.h> 10#include <linux/errno.h>
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/fs.h>
13#include <linux/smp.h> 14#include <linux/smp.h>
14#include <linux/sem.h> 15#include <linux/sem.h>
15#include <linux/msg.h> 16#include <linux/msg.h>
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index 99fc1226f7f8..3ee918695215 100644
--- a/arch/m68k/kernel/process.c
+++ b/arch/m68k/kernel/process.c
@@ -15,6 +15,7 @@
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/fs.h>
18#include <linux/smp.h> 19#include <linux/smp.h>
19#include <linux/smp_lock.h> 20#include <linux/smp_lock.h>
20#include <linux/stddef.h> 21#include <linux/stddef.h>
diff --git a/arch/m68k/kernel/sys_m68k.c b/arch/m68k/kernel/sys_m68k.c
index 90238a8c9e14..36d78cf1a7bc 100644
--- a/arch/m68k/kernel/sys_m68k.c
+++ b/arch/m68k/kernel/sys_m68k.c
@@ -10,6 +10,7 @@
10#include <linux/errno.h> 10#include <linux/errno.h>
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/fs.h>
13#include <linux/smp.h> 14#include <linux/smp.h>
14#include <linux/smp_lock.h> 15#include <linux/smp_lock.h>
15#include <linux/sem.h> 16#include <linux/sem.h>
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index 1175ceff8b2a..185906b54cb0 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -216,6 +216,18 @@ config XCOPILOT_BUGS
216 help 216 help
217 Support the bugs of Xcopilot. 217 Support the bugs of Xcopilot.
218 218
219config UC5272
220 bool 'Arcturus Networks uC5272 dimm board support'
221 depends on M5272
222 help
223 Support for the Arcturus Networks uC5272 dimm board.
224
225config UC5282
226 bool "Arcturus Networks uC5282 board support"
227 depends on M528x
228 help
229 Support for the Arcturus Networks uC5282 dimm board.
230
219config UCSIMM 231config UCSIMM
220 bool "uCsimm module support" 232 bool "uCsimm module support"
221 depends on M68EZ328 233 depends on M68EZ328
@@ -342,6 +354,18 @@ config SOM5282EM
342 depends on M528x 354 depends on M528x
343 help 355 help
344 Support for the EMAC.Inc SOM5282EM module. 356 Support for the EMAC.Inc SOM5282EM module.
357
358config WILDFIRE
359 bool "Intec Automation Inc. WildFire board support"
360 depends on M528x
361 help
362 Support for the Intec Automation Inc. WildFire.
363
364config WILDFIREMOD
365 bool "Intec Automation Inc. WildFire module support"
366 depends on M528x
367 help
368 Support for the Intec Automation Inc. WildFire module.
345 369
346config ARN5307 370config ARN5307
347 bool "Arnewsh 5307 board support" 371 bool "Arnewsh 5307 board support"
diff --git a/arch/m68knommu/Makefile b/arch/m68knommu/Makefile
index 8951793fd8d4..1305cc980023 100644
--- a/arch/m68knommu/Makefile
+++ b/arch/m68knommu/Makefile
@@ -26,6 +26,8 @@ platform-$(CONFIG_M5407) := 5407
26PLATFORM := $(platform-y) 26PLATFORM := $(platform-y)
27 27
28board-$(CONFIG_PILOT) := pilot 28board-$(CONFIG_PILOT) := pilot
29board-$(CONFIG_UC5272) := UC5272
30board-$(CONFIG_UC5282) := UC5282
29board-$(CONFIG_UCSIMM) := ucsimm 31board-$(CONFIG_UCSIMM) := ucsimm
30board-$(CONFIG_UCDIMM) := ucdimm 32board-$(CONFIG_UCDIMM) := ucdimm
31board-$(CONFIG_UCQUICC) := uCquicc 33board-$(CONFIG_UCQUICC) := uCquicc
diff --git a/arch/m68knommu/kernel/dma.c b/arch/m68knommu/kernel/dma.c
index 0a25874a2aae..e10eafc52789 100644
--- a/arch/m68knommu/kernel/dma.c
+++ b/arch/m68knommu/kernel/dma.c
@@ -8,6 +8,7 @@
8#include <linux/types.h> 8#include <linux/types.h>
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/device.h>
11#include <asm/io.h> 12#include <asm/io.h>
12 13
13void *dma_alloc_coherent(struct device *dev, size_t size, 14void *dma_alloc_coherent(struct device *dev, size_t size,
diff --git a/arch/m68knommu/kernel/setup.c b/arch/m68knommu/kernel/setup.c
index 2203f694f26b..3f86ade3a22a 100644
--- a/arch/m68knommu/kernel/setup.c
+++ b/arch/m68knommu/kernel/setup.c
@@ -42,8 +42,6 @@ EXPORT_SYMBOL(memory_end);
42 42
43char __initdata command_line[COMMAND_LINE_SIZE]; 43char __initdata command_line[COMMAND_LINE_SIZE];
44 44
45void (*mach_trap_init)(void);
46
47/* machine dependent timer functions */ 45/* machine dependent timer functions */
48void (*mach_sched_init)(irq_handler_t handler); 46void (*mach_sched_init)(irq_handler_t handler);
49void (*mach_tick)(void); 47void (*mach_tick)(void);
@@ -132,6 +130,11 @@ void setup_arch(char **cmdline_p)
132 130
133 config_BSP(&command_line[0], sizeof(command_line)); 131 config_BSP(&command_line[0], sizeof(command_line));
134 132
133#if defined(CONFIG_BOOTPARAM)
134 strncpy(&command_line[0], CONFIG_BOOTPARAM_STRING, sizeof(command_line));
135 command_line[sizeof(command_line) - 1] = 0;
136#endif
137
135 printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU "\n"); 138 printk(KERN_INFO "\x0F\r\n\nuClinux/" CPU "\n");
136 139
137#ifdef CONFIG_UCDIMM 140#ifdef CONFIG_UCDIMM
diff --git a/arch/m68knommu/platform/5206/config.c b/arch/m68knommu/platform/5206/config.c
index 3343830aad10..d0f2dc5cb5a1 100644
--- a/arch/m68knommu/platform/5206/config.c
+++ b/arch/m68knommu/platform/5206/config.c
@@ -28,7 +28,6 @@
28void coldfire_tick(void); 28void coldfire_tick(void);
29void coldfire_timer_init(irq_handler_t handler); 29void coldfire_timer_init(irq_handler_t handler);
30unsigned long coldfire_timer_offset(void); 30unsigned long coldfire_timer_offset(void);
31void coldfire_trap_init(void);
32void coldfire_reset(void); 31void coldfire_reset(void);
33 32
34/***************************************************************************/ 33/***************************************************************************/
@@ -98,18 +97,9 @@ int mcf_timerirqpending(int timer)
98void config_BSP(char *commandp, int size) 97void config_BSP(char *commandp, int size)
99{ 98{
100 mcf_setimr(MCFSIM_IMR_MASKALL); 99 mcf_setimr(MCFSIM_IMR_MASKALL);
101
102#if defined(CONFIG_BOOTPARAM)
103 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
104 commandp[size-1] = 0;
105#else
106 memset(commandp, 0, size);
107#endif
108
109 mach_sched_init = coldfire_timer_init; 100 mach_sched_init = coldfire_timer_init;
110 mach_tick = coldfire_tick; 101 mach_tick = coldfire_tick;
111 mach_gettimeoffset = coldfire_timer_offset; 102 mach_gettimeoffset = coldfire_timer_offset;
112 mach_trap_init = coldfire_trap_init;
113 mach_reset = coldfire_reset; 103 mach_reset = coldfire_reset;
114} 104}
115 105
diff --git a/arch/m68knommu/platform/5206e/config.c b/arch/m68knommu/platform/5206e/config.c
index 0f67320b4031..425703fb6cee 100644
--- a/arch/m68knommu/platform/5206e/config.c
+++ b/arch/m68knommu/platform/5206e/config.c
@@ -20,14 +20,12 @@
20#include <asm/mcftimer.h> 20#include <asm/mcftimer.h>
21#include <asm/mcfsim.h> 21#include <asm/mcfsim.h>
22#include <asm/mcfdma.h> 22#include <asm/mcfdma.h>
23#include <asm/irq.h>
24 23
25/***************************************************************************/ 24/***************************************************************************/
26 25
27void coldfire_tick(void); 26void coldfire_tick(void);
28void coldfire_timer_init(irq_handler_t handler); 27void coldfire_timer_init(irq_handler_t handler);
29unsigned long coldfire_timer_offset(void); 28unsigned long coldfire_timer_offset(void);
30void coldfire_trap_init(void);
31void coldfire_reset(void); 29void coldfire_reset(void);
32 30
33/***************************************************************************/ 31/***************************************************************************/
@@ -98,21 +96,15 @@ void config_BSP(char *commandp, int size)
98{ 96{
99 mcf_setimr(MCFSIM_IMR_MASKALL); 97 mcf_setimr(MCFSIM_IMR_MASKALL);
100 98
101#if defined(CONFIG_BOOTPARAM) 99#if defined(CONFIG_NETtel)
102 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
103 commandp[size-1] = 0;
104#elif defined(CONFIG_NETtel)
105 /* Copy command line from FLASH to local buffer... */ 100 /* Copy command line from FLASH to local buffer... */
106 memcpy(commandp, (char *) 0xf0004000, size); 101 memcpy(commandp, (char *) 0xf0004000, size);
107 commandp[size-1] = 0; 102 commandp[size-1] = 0;
108#else
109 memset(commandp, 0, size);
110#endif /* CONFIG_NETtel */ 103#endif /* CONFIG_NETtel */
111 104
112 mach_sched_init = coldfire_timer_init; 105 mach_sched_init = coldfire_timer_init;
113 mach_tick = coldfire_tick; 106 mach_tick = coldfire_tick;
114 mach_gettimeoffset = coldfire_timer_offset; 107 mach_gettimeoffset = coldfire_timer_offset;
115 mach_trap_init = coldfire_trap_init;
116 mach_reset = coldfire_reset; 108 mach_reset = coldfire_reset;
117} 109}
118 110
diff --git a/arch/m68knommu/platform/520x/config.c b/arch/m68knommu/platform/520x/config.c
index 58b2878deb61..a2c95bebd004 100644
--- a/arch/m68knommu/platform/520x/config.c
+++ b/arch/m68knommu/platform/520x/config.c
@@ -30,7 +30,6 @@ unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
30void coldfire_pit_tick(void); 30void coldfire_pit_tick(void);
31void coldfire_pit_init(irq_handler_t handler); 31void coldfire_pit_init(irq_handler_t handler);
32unsigned long coldfire_pit_offset(void); 32unsigned long coldfire_pit_offset(void);
33void coldfire_trap_init(void);
34void coldfire_reset(void); 33void coldfire_reset(void);
35 34
36/***************************************************************************/ 35/***************************************************************************/
@@ -48,17 +47,9 @@ void mcf_autovector(unsigned int vec)
48 47
49void config_BSP(char *commandp, int size) 48void config_BSP(char *commandp, int size)
50{ 49{
51#ifdef CONFIG_BOOTPARAM
52 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
53 commandp[size-1] = 0;
54#else
55 memset(commandp, 0, size);
56#endif
57
58 mach_sched_init = coldfire_pit_init; 50 mach_sched_init = coldfire_pit_init;
59 mach_tick = coldfire_pit_tick; 51 mach_tick = coldfire_pit_tick;
60 mach_gettimeoffset = coldfire_pit_offset; 52 mach_gettimeoffset = coldfire_pit_offset;
61 mach_trap_init = coldfire_trap_init;
62 mach_reset = coldfire_reset; 53 mach_reset = coldfire_reset;
63} 54}
64 55
diff --git a/arch/m68knommu/platform/523x/config.c b/arch/m68knommu/platform/523x/config.c
index 9b054e6caee2..0a3af05a434b 100644
--- a/arch/m68knommu/platform/523x/config.c
+++ b/arch/m68knommu/platform/523x/config.c
@@ -29,7 +29,6 @@
29void coldfire_pit_tick(void); 29void coldfire_pit_tick(void);
30void coldfire_pit_init(irq_handler_t handler); 30void coldfire_pit_init(irq_handler_t handler);
31unsigned long coldfire_pit_offset(void); 31unsigned long coldfire_pit_offset(void);
32void coldfire_trap_init(void);
33void coldfire_reset(void); 32void coldfire_reset(void);
34 33
35/***************************************************************************/ 34/***************************************************************************/
@@ -63,18 +62,9 @@ void mcf_autovector(unsigned int vec)
63void config_BSP(char *commandp, int size) 62void config_BSP(char *commandp, int size)
64{ 63{
65 mcf_disableall(); 64 mcf_disableall();
66
67#ifdef CONFIG_BOOTPARAM
68 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
69 commandp[size-1] = 0;
70#else
71 memset(commandp, 0, size);
72#endif
73
74 mach_sched_init = coldfire_pit_init; 65 mach_sched_init = coldfire_pit_init;
75 mach_tick = coldfire_pit_tick; 66 mach_tick = coldfire_pit_tick;
76 mach_gettimeoffset = coldfire_pit_offset; 67 mach_gettimeoffset = coldfire_pit_offset;
77 mach_trap_init = coldfire_trap_init;
78 mach_reset = coldfire_reset; 68 mach_reset = coldfire_reset;
79} 69}
80 70
diff --git a/arch/m68knommu/platform/5249/config.c b/arch/m68knommu/platform/5249/config.c
index d6706079d64a..dc2c362590c2 100644
--- a/arch/m68knommu/platform/5249/config.c
+++ b/arch/m68knommu/platform/5249/config.c
@@ -27,7 +27,6 @@
27void coldfire_tick(void); 27void coldfire_tick(void);
28void coldfire_timer_init(irq_handler_t handler); 28void coldfire_timer_init(irq_handler_t handler);
29unsigned long coldfire_timer_offset(void); 29unsigned long coldfire_timer_offset(void);
30void coldfire_trap_init(void);
31void coldfire_reset(void); 30void coldfire_reset(void);
32 31
33/***************************************************************************/ 32/***************************************************************************/
@@ -96,18 +95,9 @@ int mcf_timerirqpending(int timer)
96void config_BSP(char *commandp, int size) 95void config_BSP(char *commandp, int size)
97{ 96{
98 mcf_setimr(MCFSIM_IMR_MASKALL); 97 mcf_setimr(MCFSIM_IMR_MASKALL);
99
100#if defined(CONFIG_BOOTPARAM)
101 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
102 commandp[size-1] = 0;
103#else
104 memset(commandp, 0, size);
105#endif
106
107 mach_sched_init = coldfire_timer_init; 98 mach_sched_init = coldfire_timer_init;
108 mach_tick = coldfire_tick; 99 mach_tick = coldfire_tick;
109 mach_gettimeoffset = coldfire_timer_offset; 100 mach_gettimeoffset = coldfire_timer_offset;
110 mach_trap_init = coldfire_trap_init;
111 mach_reset = coldfire_reset; 101 mach_reset = coldfire_reset;
112} 102}
113 103
diff --git a/arch/m68knommu/platform/5272/config.c b/arch/m68knommu/platform/5272/config.c
index 6b437cc97776..1365a8300d5d 100644
--- a/arch/m68knommu/platform/5272/config.c
+++ b/arch/m68knommu/platform/5272/config.c
@@ -28,7 +28,6 @@
28void coldfire_tick(void); 28void coldfire_tick(void);
29void coldfire_timer_init(irq_handler_t handler); 29void coldfire_timer_init(irq_handler_t handler);
30unsigned long coldfire_timer_offset(void); 30unsigned long coldfire_timer_offset(void);
31void coldfire_trap_init(void);
32void coldfire_reset(void); 31void coldfire_reset(void);
33 32
34extern unsigned int mcf_timervector; 33extern unsigned int mcf_timervector;
@@ -113,10 +112,7 @@ void config_BSP(char *commandp, int size)
113 112
114 mcf_disableall(); 113 mcf_disableall();
115 114
116#if defined(CONFIG_BOOTPARAM) 115#if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
117 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
118 commandp[size-1] = 0;
119#elif defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
120 /* Copy command line from FLASH to local buffer... */ 116 /* Copy command line from FLASH to local buffer... */
121 memcpy(commandp, (char *) 0xf0004000, size); 117 memcpy(commandp, (char *) 0xf0004000, size);
122 commandp[size-1] = 0; 118 commandp[size-1] = 0;
@@ -128,8 +124,6 @@ void config_BSP(char *commandp, int size)
128 /* Copy command line from FLASH to local buffer... */ 124 /* Copy command line from FLASH to local buffer... */
129 memcpy(commandp, (char *) 0xf0010000, size); 125 memcpy(commandp, (char *) 0xf0010000, size);
130 commandp[size-1] = 0; 126 commandp[size-1] = 0;
131#else
132 memset(commandp, 0, size);
133#endif 127#endif
134 128
135 mcf_timervector = 69; 129 mcf_timervector = 69;
@@ -137,7 +131,6 @@ void config_BSP(char *commandp, int size)
137 mach_sched_init = coldfire_timer_init; 131 mach_sched_init = coldfire_timer_init;
138 mach_tick = coldfire_tick; 132 mach_tick = coldfire_tick;
139 mach_gettimeoffset = coldfire_timer_offset; 133 mach_gettimeoffset = coldfire_timer_offset;
140 mach_trap_init = coldfire_trap_init;
141 mach_reset = coldfire_reset; 134 mach_reset = coldfire_reset;
142} 135}
143 136
diff --git a/arch/m68knommu/platform/527x/config.c b/arch/m68knommu/platform/527x/config.c
index 28e7d964eef1..1b820441419a 100644
--- a/arch/m68knommu/platform/527x/config.c
+++ b/arch/m68knommu/platform/527x/config.c
@@ -29,7 +29,6 @@
29void coldfire_pit_tick(void); 29void coldfire_pit_tick(void);
30void coldfire_pit_init(irq_handler_t handler); 30void coldfire_pit_init(irq_handler_t handler);
31unsigned long coldfire_pit_offset(void); 31unsigned long coldfire_pit_offset(void);
32void coldfire_trap_init(void);
33void coldfire_reset(void); 32void coldfire_reset(void);
34 33
35/***************************************************************************/ 34/***************************************************************************/
@@ -63,18 +62,9 @@ void mcf_autovector(unsigned int vec)
63void config_BSP(char *commandp, int size) 62void config_BSP(char *commandp, int size)
64{ 63{
65 mcf_disableall(); 64 mcf_disableall();
66
67#ifdef CONFIG_BOOTPARAM
68 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
69 commandp[size-1] = 0;
70#else
71 memset(commandp, 0, size);
72#endif
73
74 mach_sched_init = coldfire_pit_init; 65 mach_sched_init = coldfire_pit_init;
75 mach_tick = coldfire_pit_tick; 66 mach_tick = coldfire_pit_tick;
76 mach_gettimeoffset = coldfire_pit_offset; 67 mach_gettimeoffset = coldfire_pit_offset;
77 mach_trap_init = coldfire_trap_init;
78 mach_reset = coldfire_reset; 68 mach_reset = coldfire_reset;
79} 69}
80 70
diff --git a/arch/m68knommu/platform/528x/config.c b/arch/m68knommu/platform/528x/config.c
index 805b4f74ff19..a089e9513699 100644
--- a/arch/m68knommu/platform/528x/config.c
+++ b/arch/m68knommu/platform/528x/config.c
@@ -29,7 +29,6 @@
29void coldfire_pit_tick(void); 29void coldfire_pit_tick(void);
30void coldfire_pit_init(irq_handler_t handler); 30void coldfire_pit_init(irq_handler_t handler);
31unsigned long coldfire_pit_offset(void); 31unsigned long coldfire_pit_offset(void);
32void coldfire_trap_init(void);
33void coldfire_reset(void); 32void coldfire_reset(void);
34 33
35/***************************************************************************/ 34/***************************************************************************/
@@ -63,18 +62,9 @@ void mcf_autovector(unsigned int vec)
63void config_BSP(char *commandp, int size) 62void config_BSP(char *commandp, int size)
64{ 63{
65 mcf_disableall(); 64 mcf_disableall();
66
67#ifdef CONFIG_BOOTPARAM
68 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
69 commandp[size-1] = 0;
70#else
71 memset(commandp, 0, size);
72#endif
73
74 mach_sched_init = coldfire_pit_init; 65 mach_sched_init = coldfire_pit_init;
75 mach_tick = coldfire_pit_tick; 66 mach_tick = coldfire_pit_tick;
76 mach_gettimeoffset = coldfire_pit_offset; 67 mach_gettimeoffset = coldfire_pit_offset;
77 mach_trap_init = coldfire_trap_init;
78 mach_reset = coldfire_reset; 68 mach_reset = coldfire_reset;
79} 69}
80 70
diff --git a/arch/m68knommu/platform/5307/config.c b/arch/m68knommu/platform/5307/config.c
index e04b84deb57d..e3461619fd65 100644
--- a/arch/m68knommu/platform/5307/config.c
+++ b/arch/m68knommu/platform/5307/config.c
@@ -29,7 +29,6 @@
29void coldfire_tick(void); 29void coldfire_tick(void);
30void coldfire_timer_init(irq_handler_t handler); 30void coldfire_timer_init(irq_handler_t handler);
31unsigned long coldfire_timer_offset(void); 31unsigned long coldfire_timer_offset(void);
32void coldfire_trap_init(void);
33void coldfire_reset(void); 32void coldfire_reset(void);
34 33
35extern unsigned int mcf_timervector; 34extern unsigned int mcf_timervector;
@@ -111,10 +110,7 @@ void config_BSP(char *commandp, int size)
111{ 110{
112 mcf_setimr(MCFSIM_IMR_MASKALL); 111 mcf_setimr(MCFSIM_IMR_MASKALL);
113 112
114#if defined(CONFIG_BOOTPARAM) 113#if defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \
115 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
116 commandp[size-1] = 0;
117#elif defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \
118 defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || \ 114 defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || \
119 defined(CONFIG_CLEOPATRA) 115 defined(CONFIG_CLEOPATRA)
120 /* Copy command line from FLASH to local buffer... */ 116 /* Copy command line from FLASH to local buffer... */
@@ -124,14 +120,11 @@ void config_BSP(char *commandp, int size)
124 mcf_timervector = 30; 120 mcf_timervector = 30;
125 mcf_profilevector = 31; 121 mcf_profilevector = 31;
126 mcf_timerlevel = 6; 122 mcf_timerlevel = 6;
127#else
128 memset(commandp, 0, size);
129#endif 123#endif
130 124
131 mach_sched_init = coldfire_timer_init; 125 mach_sched_init = coldfire_timer_init;
132 mach_tick = coldfire_tick; 126 mach_tick = coldfire_tick;
133 mach_gettimeoffset = coldfire_timer_offset; 127 mach_gettimeoffset = coldfire_timer_offset;
134 mach_trap_init = coldfire_trap_init;
135 mach_reset = coldfire_reset; 128 mach_reset = coldfire_reset;
136 129
137#ifdef MCF_BDM_DISABLE 130#ifdef MCF_BDM_DISABLE
diff --git a/arch/m68knommu/platform/5307/entry.S b/arch/m68knommu/platform/5307/entry.S
index c358aebe0af3..a8cd867805ca 100644
--- a/arch/m68knommu/platform/5307/entry.S
+++ b/arch/m68knommu/platform/5307/entry.S
@@ -213,16 +213,12 @@ ENTRY(ret_from_interrupt)
213 * Beware - when entering resume, prev (the current task) is 213 * Beware - when entering resume, prev (the current task) is
214 * in a0, next (the new task) is in a1,so don't change these 214 * in a0, next (the new task) is in a1,so don't change these
215 * registers until their contents are no longer needed. 215 * registers until their contents are no longer needed.
216 * This is always called in supervisor mode, so don't bother to save
217 * and restore sr; user's process sr is actually in the stack.
216 */ 218 */
217ENTRY(resume) 219ENTRY(resume)
218 movel %a0, %d1 /* get prev thread in d1 */ 220 movel %a0, %d1 /* get prev thread in d1 */
219 221
220 movew %sr,%d0 /* save thread status reg */
221 movew %d0,%a0@(TASK_THREAD+THREAD_SR)
222
223 oril #0x700,%d0 /* disable interrupts */
224 move %d0,%sr
225
226 movel sw_usp,%d0 /* save usp */ 222 movel sw_usp,%d0 /* save usp */
227 movel %d0,%a0@(TASK_THREAD+THREAD_USP) 223 movel %d0,%a0@(TASK_THREAD+THREAD_USP)
228 224
@@ -233,7 +229,4 @@ ENTRY(resume)
233 229
234 movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore thread user stack */ 230 movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore thread user stack */
235 movel %a0, sw_usp 231 movel %a0, sw_usp
236
237 movew %a1@(TASK_THREAD+THREAD_SR),%d0 /* restore thread status reg */
238 movew %d0, %sr
239 rts 232 rts
diff --git a/arch/m68knommu/platform/5307/pit.c b/arch/m68knommu/platform/5307/pit.c
index aa15beeb36ca..e53c446d10e4 100644
--- a/arch/m68knommu/platform/5307/pit.c
+++ b/arch/m68knommu/platform/5307/pit.c
@@ -5,9 +5,8 @@
5 * hardware timer only exists in the Freescale ColdFire 5 * hardware timer only exists in the Freescale ColdFire
6 * 5270/5271, 5282 and other CPUs. 6 * 5270/5271, 5282 and other CPUs.
7 * 7 *
8 * Copyright (C) 1999-2006, Greg Ungerer (gerg@snapgear.com) 8 * Copyright (C) 1999-2007, Greg Ungerer (gerg@snapgear.com)
9 * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com) 9 * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com)
10 *
11 */ 10 */
12 11
13/***************************************************************************/ 12/***************************************************************************/
@@ -17,8 +16,8 @@
17#include <linux/param.h> 16#include <linux/param.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/irq.h>
20#include <asm/io.h> 20#include <asm/io.h>
21#include <asm/irq.h>
22#include <asm/coldfire.h> 21#include <asm/coldfire.h>
23#include <asm/mcfpit.h> 22#include <asm/mcfpit.h>
24#include <asm/mcfsim.h> 23#include <asm/mcfsim.h>
@@ -43,13 +42,18 @@ void coldfire_pit_tick(void)
43 42
44/***************************************************************************/ 43/***************************************************************************/
45 44
45static struct irqaction coldfire_pit_irq = {
46 .name = "timer",
47 .flags = IRQF_DISABLED | IRQF_TIMER,
48};
49
46void coldfire_pit_init(irq_handler_t handler) 50void coldfire_pit_init(irq_handler_t handler)
47{ 51{
48 volatile unsigned char *icrp; 52 volatile unsigned char *icrp;
49 volatile unsigned long *imrp; 53 volatile unsigned long *imrp;
50 54
51 request_irq(MCFINT_VECBASE + MCFINT_PIT1, handler, IRQF_DISABLED, 55 coldfire_pit_irq.handler = handler;
52 "ColdFire Timer", NULL); 56 setup_irq(MCFINT_VECBASE + MCFINT_PIT1, &coldfire_pit_irq);
53 57
54 icrp = (volatile unsigned char *) (MCF_IPSBAR + MCFICM_INTC0 + 58 icrp = (volatile unsigned char *) (MCF_IPSBAR + MCFICM_INTC0 +
55 MCFINTC_ICR0 + MCFINT_PIT1); 59 MCFINTC_ICR0 + MCFINT_PIT1);
diff --git a/arch/m68knommu/platform/5307/timers.c b/arch/m68knommu/platform/5307/timers.c
index fb66eadd5896..64bd0ff9029e 100644
--- a/arch/m68knommu/platform/5307/timers.c
+++ b/arch/m68knommu/platform/5307/timers.c
@@ -3,7 +3,7 @@
3/* 3/*
4 * timers.c -- generic ColdFire hardware timer support. 4 * timers.c -- generic ColdFire hardware timer support.
5 * 5 *
6 * Copyright (C) 1999-2006, Greg Ungerer (gerg@snapgear.com) 6 * Copyright (C) 1999-2007, Greg Ungerer (gerg@snapgear.com)
7 */ 7 */
8 8
9/***************************************************************************/ 9/***************************************************************************/
@@ -13,8 +13,8 @@
13#include <linux/param.h> 13#include <linux/param.h>
14#include <linux/interrupt.h> 14#include <linux/interrupt.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/irq.h>
16#include <asm/io.h> 17#include <asm/io.h>
17#include <asm/irq.h>
18#include <asm/traps.h> 18#include <asm/traps.h>
19#include <asm/machdep.h> 19#include <asm/machdep.h>
20#include <asm/coldfire.h> 20#include <asm/coldfire.h>
@@ -62,17 +62,24 @@ void coldfire_tick(void)
62 62
63/***************************************************************************/ 63/***************************************************************************/
64 64
65static struct irqaction coldfire_timer_irq = {
66 .name = "timer",
67 .flags = IRQF_DISABLED | IRQF_TIMER,
68};
69
65static int ticks_per_intr; 70static int ticks_per_intr;
66 71
67void coldfire_timer_init(irq_handler_t handler) 72void coldfire_timer_init(irq_handler_t handler)
68{ 73{
74 coldfire_timer_irq.handler = handler;
75 setup_irq(mcf_timervector, &coldfire_timer_irq);
76
69 __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR)); 77 __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR));
70 ticks_per_intr = (MCF_BUSCLK / 16) / HZ; 78 ticks_per_intr = (MCF_BUSCLK / 16) / HZ;
71 __raw_writetrr(ticks_per_intr - 1, TA(MCFTIMER_TRR)); 79 __raw_writetrr(ticks_per_intr - 1, TA(MCFTIMER_TRR));
72 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 | 80 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 |
73 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR)); 81 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR));
74 82
75 request_irq(mcf_timervector, handler, IRQF_DISABLED, "timer", NULL);
76 mcf_settimericr(1, mcf_timerlevel); 83 mcf_settimericr(1, mcf_timerlevel);
77 84
78#ifdef CONFIG_HIGHPROFILE 85#ifdef CONFIG_HIGHPROFILE
diff --git a/arch/m68knommu/platform/532x/config.c b/arch/m68knommu/platform/532x/config.c
index 664c3a12b0c1..b32c6425f821 100644
--- a/arch/m68knommu/platform/532x/config.c
+++ b/arch/m68knommu/platform/532x/config.c
@@ -37,7 +37,6 @@
37void coldfire_tick(void); 37void coldfire_tick(void);
38void coldfire_timer_init(irq_handler_t handler); 38void coldfire_timer_init(irq_handler_t handler);
39unsigned long coldfire_timer_offset(void); 39unsigned long coldfire_timer_offset(void);
40void coldfire_trap_init(void);
41void coldfire_reset(void); 40void coldfire_reset(void);
42 41
43extern unsigned int mcf_timervector; 42extern unsigned int mcf_timervector;
@@ -92,10 +91,7 @@ void config_BSP(char *commandp, int size)
92{ 91{
93 mcf_setimr(MCFSIM_IMR_MASKALL); 92 mcf_setimr(MCFSIM_IMR_MASKALL);
94 93
95#if defined(CONFIG_BOOTPARAM) 94#if !defined(CONFIG_BOOTPARAM)
96 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
97 commandp[size-1] = 0;
98#else
99 /* Copy command line from FLASH to local buffer... */ 95 /* Copy command line from FLASH to local buffer... */
100 memcpy(commandp, (char *) 0x4000, 4); 96 memcpy(commandp, (char *) 0x4000, 4);
101 if(strncmp(commandp, "kcl ", 4) == 0){ 97 if(strncmp(commandp, "kcl ", 4) == 0){
@@ -111,7 +107,6 @@ void config_BSP(char *commandp, int size)
111 mach_sched_init = coldfire_timer_init; 107 mach_sched_init = coldfire_timer_init;
112 mach_tick = coldfire_tick; 108 mach_tick = coldfire_tick;
113 mach_gettimeoffset = coldfire_timer_offset; 109 mach_gettimeoffset = coldfire_timer_offset;
114 mach_trap_init = coldfire_trap_init;
115 mach_reset = coldfire_reset; 110 mach_reset = coldfire_reset;
116 111
117#ifdef MCF_BDM_DISABLE 112#ifdef MCF_BDM_DISABLE
diff --git a/arch/m68knommu/platform/5407/config.c b/arch/m68knommu/platform/5407/config.c
index 036f62876241..e692536817d8 100644
--- a/arch/m68knommu/platform/5407/config.c
+++ b/arch/m68knommu/platform/5407/config.c
@@ -28,7 +28,6 @@
28void coldfire_tick(void); 28void coldfire_tick(void);
29void coldfire_timer_init(irq_handler_t handler); 29void coldfire_timer_init(irq_handler_t handler);
30unsigned long coldfire_timer_offset(void); 30unsigned long coldfire_timer_offset(void);
31void coldfire_trap_init(void);
32void coldfire_reset(void); 31void coldfire_reset(void);
33 32
34extern unsigned int mcf_timervector; 33extern unsigned int mcf_timervector;
@@ -102,13 +101,6 @@ void config_BSP(char *commandp, int size)
102{ 101{
103 mcf_setimr(MCFSIM_IMR_MASKALL); 102 mcf_setimr(MCFSIM_IMR_MASKALL);
104 103
105#if defined(CONFIG_BOOTPARAM)
106 strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
107 commandp[size-1] = 0;
108#else
109 memset(commandp, 0, size);
110#endif
111
112#if defined(CONFIG_CLEOPATRA) 104#if defined(CONFIG_CLEOPATRA)
113 /* Different timer setup - to prevent device clash */ 105 /* Different timer setup - to prevent device clash */
114 mcf_timervector = 30; 106 mcf_timervector = 30;
@@ -119,7 +111,6 @@ void config_BSP(char *commandp, int size)
119 mach_sched_init = coldfire_timer_init; 111 mach_sched_init = coldfire_timer_init;
120 mach_tick = coldfire_tick; 112 mach_tick = coldfire_tick;
121 mach_gettimeoffset = coldfire_timer_offset; 113 mach_gettimeoffset = coldfire_timer_offset;
122 mach_trap_init = coldfire_trap_init;
123 mach_reset = coldfire_reset; 114 mach_reset = coldfire_reset;
124} 115}
125 116
diff --git a/arch/m68knommu/platform/68328/timers.c b/arch/m68knommu/platform/68328/timers.c
index ef067f4c3cd4..0396476f955d 100644
--- a/arch/m68knommu/platform/68328/timers.c
+++ b/arch/m68knommu/platform/68328/timers.c
@@ -18,10 +18,10 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/irq.h>
21#include <asm/setup.h> 22#include <asm/setup.h>
22#include <asm/system.h> 23#include <asm/system.h>
23#include <asm/pgtable.h> 24#include <asm/pgtable.h>
24#include <asm/irq.h>
25#include <asm/machdep.h> 25#include <asm/machdep.h>
26#include <asm/MC68VZ328.h> 26#include <asm/MC68VZ328.h>
27 27
@@ -53,14 +53,19 @@
53 53
54/***************************************************************************/ 54/***************************************************************************/
55 55
56static struct irqaction m68328_timer_irq = {
57 .name = "timer",
58 .flags = IRQF_DISABLED | IRQF_TIMER,
59};
60
56void m68328_timer_init(irq_handler_t timer_routine) 61void m68328_timer_init(irq_handler_t timer_routine)
57{ 62{
58 /* disable timer 1 */ 63 /* disable timer 1 */
59 TCTL = 0; 64 TCTL = 0;
60 65
61 /* set ISR */ 66 /* set ISR */
62 if (request_irq(TMR_IRQ_NUM, timer_routine, IRQ_FLG_LOCK, "timer", NULL)) 67 m68328_timer_irq.handler = timer_routine;
63 panic("Unable to attach timer interrupt\n"); 68 setup_irq(TMR_IRQ_NUM, &m68328_timer_irq);
64 69
65 /* Restart mode, Enable int, Set clock source */ 70 /* Restart mode, Enable int, Set clock source */
66 TCTL = TCTL_OM | TCTL_IRQEN | CLOCK_SOURCE; 71 TCTL = TCTL_OM | TCTL_IRQEN | CLOCK_SOURCE;
diff --git a/arch/m68knommu/platform/68360/config.c b/arch/m68knommu/platform/68360/config.c
index 4ff13bd51ffd..155b72fe2607 100644
--- a/arch/m68knommu/platform/68360/config.c
+++ b/arch/m68knommu/platform/68360/config.c
@@ -17,11 +17,11 @@
17#include <linux/tty.h> 17#include <linux/tty.h>
18#include <linux/console.h> 18#include <linux/console.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/irq.h>
20 21
21#include <asm/setup.h> 22#include <asm/setup.h>
22#include <asm/system.h> 23#include <asm/system.h>
23#include <asm/pgtable.h> 24#include <asm/pgtable.h>
24#include <asm/irq.h>
25#include <asm/machdep.h> 25#include <asm/machdep.h>
26#include <asm/m68360.h> 26#include <asm/m68360.h>
27 27
@@ -51,11 +51,15 @@ extern unsigned long int system_clock; //In kernel setup.c
51 51
52extern void config_M68360_irq(void); 52extern void config_M68360_irq(void);
53 53
54static struct irqaction m68360_timer_irq = {
55 .name = "timer",
56 .flags = IRQF_DISABLED | IRQF_TIMER,
57};
58
54void BSP_sched_init(irq_handler_t timer_routine) 59void BSP_sched_init(irq_handler_t timer_routine)
55{ 60{
56 unsigned char prescaler; 61 unsigned char prescaler;
57 unsigned short tgcr_save; 62 unsigned short tgcr_save;
58 int return_value;
59 63
60#if 0 64#if 0
61 /* Restart mode, Enable int, 32KHz, Enable timer */ 65 /* Restart mode, Enable int, 32KHz, Enable timer */
@@ -86,10 +90,8 @@ void BSP_sched_init(irq_handler_t timer_routine)
86 pquicc->timer_ter1 = 0x0003; /* clear timer events */ 90 pquicc->timer_ter1 = 0x0003; /* clear timer events */
87 91
88 /* enable timer 1 interrupt in CIMR */ 92 /* enable timer 1 interrupt in CIMR */
89// request_irq(IRQ_MACHSPEC | CPMVEC_TIMER1, timer_routine, IRQ_FLG_LOCK, "timer", NULL); 93 m68360_timer_irq.handler = timer_routine;
90 //return_value = request_irq( CPMVEC_TIMER1, timer_routine, IRQ_FLG_LOCK, "timer", NULL); 94 setup_irq(CPMVEC_TIMER1, &m68360_timer_irq);
91 return_value = request_irq(CPMVEC_TIMER1 , timer_routine, IRQ_FLG_LOCK,
92 "Timer", NULL);
93 95
94 /* Start timer 1: */ 96 /* Start timer 1: */
95 tgcr_save = (pquicc->timer_tgcr & 0xfff0) | 0x0001; 97 tgcr_save = (pquicc->timer_tgcr & 0xfff0) | 0x0001;
diff --git a/arch/m68knommu/platform/68VZ328/config.c b/arch/m68knommu/platform/68VZ328/config.c
index 8abe0f6e7235..79dced929c97 100644
--- a/arch/m68knommu/platform/68VZ328/config.c
+++ b/arch/m68knommu/platform/68VZ328/config.c
@@ -191,13 +191,6 @@ void config_BSP(char *command, int size)
191{ 191{
192 printk(KERN_INFO "68VZ328 DragonBallVZ support (c) 2001 Lineo, Inc.\n"); 192 printk(KERN_INFO "68VZ328 DragonBallVZ support (c) 2001 Lineo, Inc.\n");
193 193
194#if defined(CONFIG_BOOTPARAM)
195 strncpy(command, CONFIG_BOOTPARAM_STRING, size);
196 command[size-1] = 0;
197#else
198 memset(command, 0, size);
199#endif
200
201 init_hardware(command, size); 194 init_hardware(command, size);
202 195
203 mach_sched_init = (void *) m68328_timer_init; 196 mach_sched_init = (void *) m68328_timer_init;
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 1e3aeccd7322..3b404b7dfa39 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -15,29 +15,6 @@ choice
15 prompt "System type" 15 prompt "System type"
16 default SGI_IP22 16 default SGI_IP22
17 17
18config LEMOTE_FULONG
19 bool "Lemote Fulong mini-PC"
20 select ARCH_SPARSEMEM_ENABLE
21 select SYS_HAS_CPU_LOONGSON2
22 select DMA_NONCOHERENT
23 select BOOT_ELF32
24 select BOARD_SCACHE
25 select HAVE_STD_PC_SERIAL_PORT
26 select HW_HAS_PCI
27 select I8259
28 select ISA
29 select IRQ_CPU
30 select SYS_SUPPORTS_32BIT_KERNEL
31 select SYS_SUPPORTS_64BIT_KERNEL
32 select SYS_SUPPORTS_LITTLE_ENDIAN
33 select SYS_SUPPORTS_HIGHMEM
34 select SYS_HAS_EARLY_PRINTK
35 select GENERIC_HARDIRQS_NO__DO_IRQ
36 select CPU_HAS_WB
37 help
38 Lemote Fulong mini-PC board based on the Chinese Loongson-2E CPU and
39 an FPGA northbridge
40
41config MACH_ALCHEMY 18config MACH_ALCHEMY
42 bool "Alchemy processor based machines" 19 bool "Alchemy processor based machines"
43 20
@@ -131,6 +108,29 @@ config MACH_JAZZ
131 Members include the Acer PICA, MIPS Magnum 4000, MIPS Millenium and 108 Members include the Acer PICA, MIPS Magnum 4000, MIPS Millenium and
132 Olivetti M700-10 workstations. 109 Olivetti M700-10 workstations.
133 110
111config LEMOTE_FULONG
112 bool "Lemote Fulong mini-PC"
113 select ARCH_SPARSEMEM_ENABLE
114 select SYS_HAS_CPU_LOONGSON2
115 select DMA_NONCOHERENT
116 select BOOT_ELF32
117 select BOARD_SCACHE
118 select HAVE_STD_PC_SERIAL_PORT
119 select HW_HAS_PCI
120 select I8259
121 select ISA
122 select IRQ_CPU
123 select SYS_SUPPORTS_32BIT_KERNEL
124 select SYS_SUPPORTS_64BIT_KERNEL
125 select SYS_SUPPORTS_LITTLE_ENDIAN
126 select SYS_SUPPORTS_HIGHMEM
127 select SYS_HAS_EARLY_PRINTK
128 select GENERIC_HARDIRQS_NO__DO_IRQ
129 select CPU_HAS_WB
130 help
131 Lemote Fulong mini-PC board based on the Chinese Loongson-2E CPU and
132 an FPGA northbridge
133
134config MIPS_ATLAS 134config MIPS_ATLAS
135 bool "MIPS Atlas board" 135 bool "MIPS Atlas board"
136 select BOOT_ELF32 136 select BOOT_ELF32
@@ -210,27 +210,6 @@ config MIPS_SEAD
210 This enables support for the MIPS Technologies SEAD evaluation 210 This enables support for the MIPS Technologies SEAD evaluation
211 board. 211 board.
212 212
213config WR_PPMC
214 bool "Wind River PPMC board"
215 select IRQ_CPU
216 select BOOT_ELF32
217 select DMA_NONCOHERENT
218 select HW_HAS_PCI
219 select PCI_GT64XXX_PCI0
220 select SWAP_IO_SPACE
221 select SYS_HAS_CPU_MIPS32_R1
222 select SYS_HAS_CPU_MIPS32_R2
223 select SYS_HAS_CPU_MIPS64_R1
224 select SYS_HAS_CPU_NEVADA
225 select SYS_HAS_CPU_RM7000
226 select SYS_SUPPORTS_32BIT_KERNEL
227 select SYS_SUPPORTS_64BIT_KERNEL
228 select SYS_SUPPORTS_BIG_ENDIAN
229 select SYS_SUPPORTS_LITTLE_ENDIAN
230 help
231 This enables support for the Wind River MIPS32 4KC PPMC evaluation
232 board, which is based on GT64120 bridge chip.
233
234config MIPS_SIM 213config MIPS_SIM
235 bool 'MIPS simulator (MIPSsim)' 214 bool 'MIPS simulator (MIPSsim)'
236 select DMA_NONCOHERENT 215 select DMA_NONCOHERENT
@@ -248,23 +227,24 @@ config MIPS_SIM
248 This option enables support for MIPS Technologies MIPSsim software 227 This option enables support for MIPS Technologies MIPSsim software
249 emulator. 228 emulator.
250 229
251config MOMENCO_OCELOT 230config MARKEINS
252 bool "Momentum Ocelot board" 231 bool "NEC EMMA2RH Mark-eins"
253 select DMA_NONCOHERENT 232 select DMA_NONCOHERENT
254 select HW_HAS_PCI 233 select HW_HAS_PCI
255 select IRQ_CPU 234 select IRQ_CPU
256 select IRQ_CPU_RM7K
257 select PCI_GT64XXX_PCI0
258 select RM7000_CPU_SCACHE
259 select SWAP_IO_SPACE 235 select SWAP_IO_SPACE
260 select SYS_HAS_CPU_RM7000
261 select SYS_SUPPORTS_32BIT_KERNEL 236 select SYS_SUPPORTS_32BIT_KERNEL
262 select SYS_SUPPORTS_64BIT_KERNEL
263 select SYS_SUPPORTS_BIG_ENDIAN 237 select SYS_SUPPORTS_BIG_ENDIAN
264 select SYS_SUPPORTS_KGDB 238 select SYS_SUPPORTS_LITTLE_ENDIAN
239 select SYS_HAS_CPU_R5000
265 help 240 help
266 The Ocelot is a MIPS-based Single Board Computer (SBC) made by 241 This enables support for the R5432-based NEC Mark-eins
267 Momentum Computer <http://www.momenco.com/>. 242 boards with R5500 CPU.
243
244config MACH_VR41XX
245 bool "NEC VR4100 series based machines"
246 select SYS_HAS_CPU_VR41XX
247 select GENERIC_HARDIRQS_NO__DO_IRQ
268 248
269config PNX8550_JBS 249config PNX8550_JBS
270 bool "Philips PNX8550 based JBS board" 250 bool "Philips PNX8550 based JBS board"
@@ -276,31 +256,6 @@ config PNX8550_STB810
276 select PNX8550 256 select PNX8550
277 select SYS_SUPPORTS_LITTLE_ENDIAN 257 select SYS_SUPPORTS_LITTLE_ENDIAN
278 258
279config DDB5477
280 bool "NEC DDB Vrc-5477"
281 select DDB5XXX_COMMON
282 select DMA_NONCOHERENT
283 select HW_HAS_PCI
284 select I8259
285 select IRQ_CPU
286 select SYS_HAS_CPU_R5432
287 select SYS_SUPPORTS_32BIT_KERNEL
288 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
289 select SYS_SUPPORTS_KGDB
290 select SYS_SUPPORTS_KGDB
291 select SYS_SUPPORTS_LITTLE_ENDIAN
292 help
293 This enables support for the R5432-based NEC DDB Vrc-5477,
294 or Rockhopper/SolutionGear boards with R5432/R5500 CPUs.
295
296 Features : kernel debugging, serial terminal, NFS root fs, on-board
297 ether port USB, AC97, PCI, etc.
298
299config MACH_VR41XX
300 bool "NEC VR4100 series based machines"
301 select SYS_HAS_CPU_VR41XX
302 select GENERIC_HARDIRQS_NO__DO_IRQ
303
304config PMC_MSP 259config PMC_MSP
305 bool "PMC-Sierra MSP chipsets" 260 bool "PMC-Sierra MSP chipsets"
306 depends on EXPERIMENTAL 261 depends on EXPERIMENTAL
@@ -367,20 +322,6 @@ config QEMU
367 simulate actual MIPS hardware platforms. More information on Qemu 322 simulate actual MIPS hardware platforms. More information on Qemu
368 can be found at http://www.linux-mips.org/wiki/Qemu. 323 can be found at http://www.linux-mips.org/wiki/Qemu.
369 324
370config MARKEINS
371 bool "NEC EMMA2RH Mark-eins"
372 select DMA_NONCOHERENT
373 select HW_HAS_PCI
374 select IRQ_CPU
375 select SWAP_IO_SPACE
376 select SYS_SUPPORTS_32BIT_KERNEL
377 select SYS_SUPPORTS_BIG_ENDIAN
378 select SYS_SUPPORTS_LITTLE_ENDIAN
379 select SYS_HAS_CPU_R5000
380 help
381 This enables support for the R5432-based NEC Mark-eins
382 boards with R5500 CPU.
383
384config SGI_IP22 325config SGI_IP22
385 bool "SGI IP22 (Indy/Indigo2)" 326 bool "SGI IP22 (Indy/Indigo2)"
386 select ARC 327 select ARC
@@ -443,41 +384,38 @@ config SGI_IP32
443 help 384 help
444 If you want this kernel to run on SGI O2 workstation, say Y here. 385 If you want this kernel to run on SGI O2 workstation, say Y here.
445 386
446config SIBYTE_BIGSUR 387config SIBYTE_CRHINE
447 bool "Sibyte BCM91480B-BigSur" 388 bool "Sibyte BCM91120C-CRhine"
389 depends on EXPERIMENTAL
448 select BOOT_ELF32 390 select BOOT_ELF32
449 select DMA_COHERENT 391 select DMA_COHERENT
450 select NR_CPUS_DEFAULT_4 392 select SIBYTE_BCM1120
451 select PCI_DOMAINS
452 select SIBYTE_BCM1x80
453 select SWAP_IO_SPACE 393 select SWAP_IO_SPACE
454 select SYS_HAS_CPU_SB1 394 select SYS_HAS_CPU_SB1
455 select SYS_SUPPORTS_BIG_ENDIAN 395 select SYS_SUPPORTS_BIG_ENDIAN
456 select SYS_SUPPORTS_LITTLE_ENDIAN 396 select SYS_SUPPORTS_LITTLE_ENDIAN
457 397
458config SIBYTE_SWARM 398config SIBYTE_CARMEL
459 bool "Sibyte BCM91250A-SWARM" 399 bool "Sibyte BCM91120x-Carmel"
400 depends on EXPERIMENTAL
460 select BOOT_ELF32 401 select BOOT_ELF32
461 select DMA_COHERENT 402 select DMA_COHERENT
462 select NR_CPUS_DEFAULT_2 403 select SIBYTE_BCM1120
463 select SIBYTE_SB1250
464 select SWAP_IO_SPACE 404 select SWAP_IO_SPACE
465 select SYS_HAS_CPU_SB1 405 select SYS_HAS_CPU_SB1
466 select SYS_SUPPORTS_BIG_ENDIAN 406 select SYS_SUPPORTS_BIG_ENDIAN
467 select SYS_SUPPORTS_HIGHMEM
468 select SYS_SUPPORTS_KGDB
469 select SYS_SUPPORTS_LITTLE_ENDIAN 407 select SYS_SUPPORTS_LITTLE_ENDIAN
470 408
471config SIBYTE_SENTOSA 409config SIBYTE_CRHONE
472 bool "Sibyte BCM91250E-Sentosa" 410 bool "Sibyte BCM91125C-CRhone"
473 depends on EXPERIMENTAL 411 depends on EXPERIMENTAL
474 select BOOT_ELF32 412 select BOOT_ELF32
475 select DMA_COHERENT 413 select DMA_COHERENT
476 select NR_CPUS_DEFAULT_2 414 select SIBYTE_BCM1125
477 select SIBYTE_SB1250
478 select SWAP_IO_SPACE 415 select SWAP_IO_SPACE
479 select SYS_HAS_CPU_SB1 416 select SYS_HAS_CPU_SB1
480 select SYS_SUPPORTS_BIG_ENDIAN 417 select SYS_SUPPORTS_BIG_ENDIAN
418 select SYS_SUPPORTS_HIGHMEM
481 select SYS_SUPPORTS_LITTLE_ENDIAN 419 select SYS_SUPPORTS_LITTLE_ENDIAN
482 420
483config SIBYTE_RHONE 421config SIBYTE_RHONE
@@ -491,19 +429,21 @@ config SIBYTE_RHONE
491 select SYS_SUPPORTS_BIG_ENDIAN 429 select SYS_SUPPORTS_BIG_ENDIAN
492 select SYS_SUPPORTS_LITTLE_ENDIAN 430 select SYS_SUPPORTS_LITTLE_ENDIAN
493 431
494config SIBYTE_CARMEL 432config SIBYTE_SWARM
495 bool "Sibyte BCM91120x-Carmel" 433 bool "Sibyte BCM91250A-SWARM"
496 depends on EXPERIMENTAL
497 select BOOT_ELF32 434 select BOOT_ELF32
498 select DMA_COHERENT 435 select DMA_COHERENT
499 select SIBYTE_BCM1120 436 select NR_CPUS_DEFAULT_2
437 select SIBYTE_SB1250
500 select SWAP_IO_SPACE 438 select SWAP_IO_SPACE
501 select SYS_HAS_CPU_SB1 439 select SYS_HAS_CPU_SB1
502 select SYS_SUPPORTS_BIG_ENDIAN 440 select SYS_SUPPORTS_BIG_ENDIAN
441 select SYS_SUPPORTS_HIGHMEM
442 select SYS_SUPPORTS_KGDB
503 select SYS_SUPPORTS_LITTLE_ENDIAN 443 select SYS_SUPPORTS_LITTLE_ENDIAN
504 444
505config SIBYTE_PTSWARM 445config SIBYTE_LITTLESUR
506 bool "Sibyte BCM91250PT-PTSWARM" 446 bool "Sibyte BCM91250C2-LittleSur"
507 depends on EXPERIMENTAL 447 depends on EXPERIMENTAL
508 select BOOT_ELF32 448 select BOOT_ELF32
509 select DMA_COHERENT 449 select DMA_COHERENT
@@ -515,8 +455,8 @@ config SIBYTE_PTSWARM
515 select SYS_SUPPORTS_HIGHMEM 455 select SYS_SUPPORTS_HIGHMEM
516 select SYS_SUPPORTS_LITTLE_ENDIAN 456 select SYS_SUPPORTS_LITTLE_ENDIAN
517 457
518config SIBYTE_LITTLESUR 458config SIBYTE_SENTOSA
519 bool "Sibyte BCM91250C2-LittleSur" 459 bool "Sibyte BCM91250E-Sentosa"
520 depends on EXPERIMENTAL 460 depends on EXPERIMENTAL
521 select BOOT_ELF32 461 select BOOT_ELF32
522 select DMA_COHERENT 462 select DMA_COHERENT
@@ -525,30 +465,31 @@ config SIBYTE_LITTLESUR
525 select SWAP_IO_SPACE 465 select SWAP_IO_SPACE
526 select SYS_HAS_CPU_SB1 466 select SYS_HAS_CPU_SB1
527 select SYS_SUPPORTS_BIG_ENDIAN 467 select SYS_SUPPORTS_BIG_ENDIAN
528 select SYS_SUPPORTS_HIGHMEM
529 select SYS_SUPPORTS_LITTLE_ENDIAN 468 select SYS_SUPPORTS_LITTLE_ENDIAN
530 469
531config SIBYTE_CRHINE 470config SIBYTE_PTSWARM
532 bool "Sibyte BCM91120C-CRhine" 471 bool "Sibyte BCM91250PT-PTSWARM"
533 depends on EXPERIMENTAL 472 depends on EXPERIMENTAL
534 select BOOT_ELF32 473 select BOOT_ELF32
535 select DMA_COHERENT 474 select DMA_COHERENT
536 select SIBYTE_BCM1120 475 select NR_CPUS_DEFAULT_2
476 select SIBYTE_SB1250
537 select SWAP_IO_SPACE 477 select SWAP_IO_SPACE
538 select SYS_HAS_CPU_SB1 478 select SYS_HAS_CPU_SB1
539 select SYS_SUPPORTS_BIG_ENDIAN 479 select SYS_SUPPORTS_BIG_ENDIAN
480 select SYS_SUPPORTS_HIGHMEM
540 select SYS_SUPPORTS_LITTLE_ENDIAN 481 select SYS_SUPPORTS_LITTLE_ENDIAN
541 482
542config SIBYTE_CRHONE 483config SIBYTE_BIGSUR
543 bool "Sibyte BCM91125C-CRhone" 484 bool "Sibyte BCM91480B-BigSur"
544 depends on EXPERIMENTAL
545 select BOOT_ELF32 485 select BOOT_ELF32
546 select DMA_COHERENT 486 select DMA_COHERENT
547 select SIBYTE_BCM1125 487 select NR_CPUS_DEFAULT_4
488 select PCI_DOMAINS
489 select SIBYTE_BCM1x80
548 select SWAP_IO_SPACE 490 select SWAP_IO_SPACE
549 select SYS_HAS_CPU_SB1 491 select SYS_HAS_CPU_SB1
550 select SYS_SUPPORTS_BIG_ENDIAN 492 select SYS_SUPPORTS_BIG_ENDIAN
551 select SYS_SUPPORTS_HIGHMEM
552 select SYS_SUPPORTS_LITTLE_ENDIAN 493 select SYS_SUPPORTS_LITTLE_ENDIAN
553 494
554config SNI_RM 495config SNI_RM
@@ -595,7 +536,7 @@ config TOSHIBA_JMR3927
595 select GENERIC_HARDIRQS_NO__DO_IRQ 536 select GENERIC_HARDIRQS_NO__DO_IRQ
596 537
597config TOSHIBA_RBTX4927 538config TOSHIBA_RBTX4927
598 bool "Toshiba TBTX49[23]7 board" 539 bool "Toshiba RBTX49[23]7 board"
599 select DMA_NONCOHERENT 540 select DMA_NONCOHERENT
600 select HAS_TXX9_SERIAL 541 select HAS_TXX9_SERIAL
601 select HW_HAS_PCI 542 select HW_HAS_PCI
@@ -632,10 +573,30 @@ config TOSHIBA_RBTX4938
632 This Toshiba board is based on the TX4938 processor. Say Y here to 573 This Toshiba board is based on the TX4938 processor. Say Y here to
633 support this machine type 574 support this machine type
634 575
576config WR_PPMC
577 bool "Wind River PPMC board"
578 select IRQ_CPU
579 select BOOT_ELF32
580 select DMA_NONCOHERENT
581 select HW_HAS_PCI
582 select PCI_GT64XXX_PCI0
583 select SWAP_IO_SPACE
584 select SYS_HAS_CPU_MIPS32_R1
585 select SYS_HAS_CPU_MIPS32_R2
586 select SYS_HAS_CPU_MIPS64_R1
587 select SYS_HAS_CPU_NEVADA
588 select SYS_HAS_CPU_RM7000
589 select SYS_SUPPORTS_32BIT_KERNEL
590 select SYS_SUPPORTS_64BIT_KERNEL
591 select SYS_SUPPORTS_BIG_ENDIAN
592 select SYS_SUPPORTS_LITTLE_ENDIAN
593 help
594 This enables support for the Wind River MIPS32 4KC PPMC evaluation
595 board, which is based on GT64120 bridge chip.
596
635endchoice 597endchoice
636 598
637source "arch/mips/au1000/Kconfig" 599source "arch/mips/au1000/Kconfig"
638source "arch/mips/ddb5xxx/Kconfig"
639source "arch/mips/jazz/Kconfig" 600source "arch/mips/jazz/Kconfig"
640source "arch/mips/pmc-sierra/Kconfig" 601source "arch/mips/pmc-sierra/Kconfig"
641source "arch/mips/sgi-ip27/Kconfig" 602source "arch/mips/sgi-ip27/Kconfig"
@@ -807,10 +768,6 @@ config IRQ_MSP_SLP
807config IRQ_MSP_CIC 768config IRQ_MSP_CIC
808 bool 769 bool
809 770
810config DDB5XXX_COMMON
811 bool
812 select SYS_SUPPORTS_KGDB
813
814config MIPS_BOARDS_GEN 771config MIPS_BOARDS_GEN
815 bool 772 bool
816 773
@@ -1377,17 +1334,6 @@ config MIPS_MT_SMTC
1377 This is a kernel model which is known a SMTC or lately has been 1334 This is a kernel model which is known a SMTC or lately has been
1378 marketesed into SMVP. 1335 marketesed into SMVP.
1379 1336
1380config MIPS_VPE_LOADER
1381 bool "VPE loader support."
1382 depends on SYS_SUPPORTS_MULTITHREADING
1383 select CPU_MIPSR2_IRQ_VI
1384 select CPU_MIPSR2_IRQ_EI
1385 select CPU_MIPSR2_SRS
1386 select MIPS_MT
1387 help
1388 Includes a loader for loading an elf relocatable object
1389 onto another VPE and running it.
1390
1391endchoice 1337endchoice
1392 1338
1393config MIPS_MT 1339config MIPS_MT
@@ -1398,8 +1344,19 @@ config SYS_SUPPORTS_MULTITHREADING
1398 1344
1399config MIPS_MT_FPAFF 1345config MIPS_MT_FPAFF
1400 bool "Dynamic FPU affinity for FP-intensive threads" 1346 bool "Dynamic FPU affinity for FP-intensive threads"
1401 depends on MIPS_MT
1402 default y 1347 default y
1348 depends on MIPS_MT_SMP || MIPS_MT_SMTC
1349
1350config MIPS_VPE_LOADER
1351 bool "VPE loader support."
1352 depends on SYS_SUPPORTS_MULTITHREADING
1353 select CPU_MIPSR2_IRQ_VI
1354 select CPU_MIPSR2_IRQ_EI
1355 select CPU_MIPSR2_SRS
1356 select MIPS_MT
1357 help
1358 Includes a loader for loading an elf relocatable object
1359 onto another VPE and running it.
1403 1360
1404config MIPS_MT_SMTC_INSTANT_REPLAY 1361config MIPS_MT_SMTC_INSTANT_REPLAY
1405 bool "Low-latency Dispatch of Deferred SMTC IPIs" 1362 bool "Low-latency Dispatch of Deferred SMTC IPIs"
@@ -1772,7 +1729,7 @@ config KEXEC
1772 1729
1773config SECCOMP 1730config SECCOMP
1774 bool "Enable seccomp to safely compute untrusted bytecode" 1731 bool "Enable seccomp to safely compute untrusted bytecode"
1775 depends on PROC_FS && BROKEN 1732 depends on PROC_FS
1776 default y 1733 default y
1777 help 1734 help
1778 This kernel feature is useful for number crunching applications 1735 This kernel feature is useful for number crunching applications
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 20d19c9b7761..32c1c8fb6f98 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -67,6 +67,8 @@ cflags-y += $(call cc-option,-msym32)
67endif 67endif
68endif 68endif
69 69
70all-$(CONFIG_BOOT_ELF32) := $(vmlinux-32)
71all-$(CONFIG_BOOT_ELF64) := $(vmlinux-64)
70 72
71# 73#
72# GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel 74# GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel
@@ -309,6 +311,7 @@ core-$(CONFIG_MIPS_ATLAS) += arch/mips/mips-boards/atlas/
309cflags-$(CONFIG_MIPS_ATLAS) += -Iinclude/asm-mips/mach-atlas 311cflags-$(CONFIG_MIPS_ATLAS) += -Iinclude/asm-mips/mach-atlas
310cflags-$(CONFIG_MIPS_ATLAS) += -Iinclude/asm-mips/mach-mips 312cflags-$(CONFIG_MIPS_ATLAS) += -Iinclude/asm-mips/mach-mips
311load-$(CONFIG_MIPS_ATLAS) += 0xffffffff80100000 313load-$(CONFIG_MIPS_ATLAS) += 0xffffffff80100000
314all-$(CONFIG_MIPS_ATLAS) := vmlinux.srec
312 315
313# 316#
314# MIPS Malta board 317# MIPS Malta board
@@ -316,6 +319,7 @@ load-$(CONFIG_MIPS_ATLAS) += 0xffffffff80100000
316core-$(CONFIG_MIPS_MALTA) += arch/mips/mips-boards/malta/ 319core-$(CONFIG_MIPS_MALTA) += arch/mips/mips-boards/malta/
317cflags-$(CONFIG_MIPS_MALTA) += -Iinclude/asm-mips/mach-mips 320cflags-$(CONFIG_MIPS_MALTA) += -Iinclude/asm-mips/mach-mips
318load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000 321load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000
322all-$(CONFIG_MIPS_MALTA) := vmlinux.srec
319 323
320# 324#
321# MIPS SEAD board 325# MIPS SEAD board
@@ -323,26 +327,16 @@ load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000
323core-$(CONFIG_MIPS_SEAD) += arch/mips/mips-boards/sead/ 327core-$(CONFIG_MIPS_SEAD) += arch/mips/mips-boards/sead/
324cflags-$(CONFIG_MIPS_SEAD) += -Iinclude/asm-mips/mach-mips 328cflags-$(CONFIG_MIPS_SEAD) += -Iinclude/asm-mips/mach-mips
325load-$(CONFIG_MIPS_SEAD) += 0xffffffff80100000 329load-$(CONFIG_MIPS_SEAD) += 0xffffffff80100000
330all-$(CONFIG_MIPS_SEAD) := vmlinux.srec
326 331
327# 332#
328# MIPS SIM 333# MIPS SIM
329# 334#
330core-$(CONFIG_MIPS_SIM) += arch/mips/mipssim/ 335core-$(CONFIG_MIPS_SIM) += arch/mips/mipssim/
331cflags-$(CONFIG_MIPS_SIM) += -Iinclude/asm-mips/mach-sim 336cflags-$(CONFIG_MIPS_SIM) += -Iinclude/asm-mips/mach-mipssim
332load-$(CONFIG_MIPS_SIM) += 0x80100000 337load-$(CONFIG_MIPS_SIM) += 0x80100000
333 338
334# 339#
335# Momentum Ocelot board
336#
337# The Ocelot setup.o must be linked early - it does the ioremap() for the
338# mips_io_port_base.
339#
340core-$(CONFIG_MOMENCO_OCELOT) += arch/mips/gt64120/common/ \
341 arch/mips/gt64120/momenco_ocelot/
342cflags-$(CONFIG_MOMENCO_OCELOT) += -Iinclude/asm-mips/mach-ocelot
343load-$(CONFIG_MOMENCO_OCELOT) += 0xffffffff80100000
344
345#
346# PMC-Sierra MSP SOCs 340# PMC-Sierra MSP SOCs
347# 341#
348core-$(CONFIG_PMC_MSP) += arch/mips/pmc-sierra/msp71xx/ 342core-$(CONFIG_PMC_MSP) += arch/mips/pmc-sierra/msp71xx/
@@ -363,6 +357,7 @@ load-$(CONFIG_PMC_YOSEMITE) += 0xffffffff80100000
363core-$(CONFIG_QEMU) += arch/mips/qemu/ 357core-$(CONFIG_QEMU) += arch/mips/qemu/
364cflags-$(CONFIG_QEMU) += -Iinclude/asm-mips/mach-qemu 358cflags-$(CONFIG_QEMU) += -Iinclude/asm-mips/mach-qemu
365load-$(CONFIG_QEMU) += 0xffffffff80010000 359load-$(CONFIG_QEMU) += 0xffffffff80010000
360all-$(CONFIG_QEMU) := vmlinux.bin
366 361
367# 362#
368# Basler eXcite 363# Basler eXcite
@@ -372,17 +367,6 @@ cflags-$(CONFIG_BASLER_EXCITE) += -Iinclude/asm-mips/mach-excite
372load-$(CONFIG_BASLER_EXCITE) += 0x80100000 367load-$(CONFIG_BASLER_EXCITE) += 0x80100000
373 368
374# 369#
375# NEC DDB
376#
377core-$(CONFIG_DDB5XXX_COMMON) += arch/mips/ddb5xxx/common/
378
379#
380# NEC DDB Vrc-5477
381#
382core-$(CONFIG_DDB5477) += arch/mips/ddb5xxx/ddb5477/
383load-$(CONFIG_DDB5477) += 0xffffffff80100000
384
385#
386# Common VR41xx 370# Common VR41xx
387# 371#
388core-$(CONFIG_MACH_VR41XX) += arch/mips/vr41xx/common/ 372core-$(CONFIG_MACH_VR41XX) += arch/mips/vr41xx/common/
@@ -554,6 +538,7 @@ load-$(CONFIG_SIBYTE_BIGSUR) := 0xffffffff80100000
554core-$(CONFIG_SNI_RM) += arch/mips/sni/ 538core-$(CONFIG_SNI_RM) += arch/mips/sni/
555cflags-$(CONFIG_SNI_RM) += -Iinclude/asm-mips/mach-rm 539cflags-$(CONFIG_SNI_RM) += -Iinclude/asm-mips/mach-rm
556load-$(CONFIG_SNI_RM) += 0xffffffff80600000 540load-$(CONFIG_SNI_RM) += 0xffffffff80600000
541all-$(CONFIG_SNI_RM) := vmlinux.ecoff
557 542
558# 543#
559# Toshiba JMR-TX3927 board 544# Toshiba JMR-TX3927 board
@@ -647,33 +632,7 @@ vmlinux.64: vmlinux
647 632
648makeboot =$(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) $(1) 633makeboot =$(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) $(1)
649 634
650ifdef CONFIG_BOOT_ELF32 635all: $(all-y)
651all: $(vmlinux-32)
652endif
653
654ifdef CONFIG_BOOT_ELF64
655all: $(vmlinux-64)
656endif
657
658ifdef CONFIG_MIPS_ATLAS
659all: vmlinux.srec
660endif
661
662ifdef CONFIG_MIPS_MALTA
663all: vmlinux.srec
664endif
665
666ifdef CONFIG_MIPS_SEAD
667all: vmlinux.srec
668endif
669
670ifdef CONFIG_QEMU
671all: vmlinux.bin
672endif
673
674ifdef CONFIG_SNI_RM
675all: vmlinux.ecoff
676endif
677 636
678vmlinux.bin: $(vmlinux-32) 637vmlinux.bin: $(vmlinux-32)
679 +@$(call makeboot,$@) 638 +@$(call makeboot,$@)
@@ -700,6 +659,14 @@ endif
700archclean: 659archclean:
701 @$(MAKE) $(clean)=arch/mips/boot 660 @$(MAKE) $(clean)=arch/mips/boot
702 661
662define archhelp
663 echo ' vmlinux.ecoff - ECOFF boot image'
664 echo ' vmlinux.bin - Raw binary boot image'
665 echo ' vmlinux.srec - SREC boot image'
666 echo
667 echo ' These will be default as apropriate for a configured platform.'
668endef
669
703CLEAN_FILES += vmlinux.32 \ 670CLEAN_FILES += vmlinux.32 \
704 vmlinux.64 \ 671 vmlinux.64 \
705 vmlinux.ecoff 672 vmlinux.ecoff
diff --git a/arch/mips/arc/console.c b/arch/mips/arc/console.c
deleted file mode 100644
index 0fe6032999cb..000000000000
--- a/arch/mips/arc/console.c
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1996 David S. Miller (dm@sgi.com)
7 * Compability with board caches, Ulf Carlsson
8 */
9#include <linux/kernel.h>
10#include <asm/sgialib.h>
11#include <asm/bcache.h>
12
13/*
14 * IP22 boardcache is not compatible with board caches. Thus we disable it
15 * during romvec action. Since r4xx0.c is always compiled and linked with your
16 * kernel, this shouldn't cause any harm regardless what MIPS processor you
17 * have.
18 *
19 * The ARC write and read functions seem to interfere with the serial lines
20 * in some way. You should be careful with them.
21 */
22
23void prom_putchar(char c)
24{
25 ULONG cnt;
26 CHAR it = c;
27
28 bc_disable();
29 ArcWrite(1, &it, 1, &cnt);
30 bc_enable();
31}
diff --git a/arch/mips/arc/file.c b/arch/mips/arc/file.c
index a43425b3c838..cb0127cf5bc1 100644
--- a/arch/mips/arc/file.c
+++ b/arch/mips/arc/file.c
@@ -13,63 +13,63 @@
13#include <asm/arc/types.h> 13#include <asm/arc/types.h>
14#include <asm/sgialib.h> 14#include <asm/sgialib.h>
15 15
16LONG __init 16LONG
17ArcGetDirectoryEntry(ULONG FileID, struct linux_vdirent *Buffer, 17ArcGetDirectoryEntry(ULONG FileID, struct linux_vdirent *Buffer,
18 ULONG N, ULONG *Count) 18 ULONG N, ULONG *Count)
19{ 19{
20 return ARC_CALL4(get_vdirent, FileID, Buffer, N, Count); 20 return ARC_CALL4(get_vdirent, FileID, Buffer, N, Count);
21} 21}
22 22
23LONG __init 23LONG
24ArcOpen(CHAR *Path, enum linux_omode OpenMode, ULONG *FileID) 24ArcOpen(CHAR *Path, enum linux_omode OpenMode, ULONG *FileID)
25{ 25{
26 return ARC_CALL3(open, Path, OpenMode, FileID); 26 return ARC_CALL3(open, Path, OpenMode, FileID);
27} 27}
28 28
29LONG __init 29LONG
30ArcClose(ULONG FileID) 30ArcClose(ULONG FileID)
31{ 31{
32 return ARC_CALL1(close, FileID); 32 return ARC_CALL1(close, FileID);
33} 33}
34 34
35LONG __init 35LONG
36ArcRead(ULONG FileID, VOID *Buffer, ULONG N, ULONG *Count) 36ArcRead(ULONG FileID, VOID *Buffer, ULONG N, ULONG *Count)
37{ 37{
38 return ARC_CALL4(read, FileID, Buffer, N, Count); 38 return ARC_CALL4(read, FileID, Buffer, N, Count);
39} 39}
40 40
41LONG __init 41LONG
42ArcGetReadStatus(ULONG FileID) 42ArcGetReadStatus(ULONG FileID)
43{ 43{
44 return ARC_CALL1(get_rstatus, FileID); 44 return ARC_CALL1(get_rstatus, FileID);
45} 45}
46 46
47LONG __init 47LONG
48ArcWrite(ULONG FileID, PVOID Buffer, ULONG N, PULONG Count) 48ArcWrite(ULONG FileID, PVOID Buffer, ULONG N, PULONG Count)
49{ 49{
50 return ARC_CALL4(write, FileID, Buffer, N, Count); 50 return ARC_CALL4(write, FileID, Buffer, N, Count);
51} 51}
52 52
53LONG __init 53LONG
54ArcSeek(ULONG FileID, struct linux_bigint *Position, enum linux_seekmode SeekMode) 54ArcSeek(ULONG FileID, struct linux_bigint *Position, enum linux_seekmode SeekMode)
55{ 55{
56 return ARC_CALL3(seek, FileID, Position, SeekMode); 56 return ARC_CALL3(seek, FileID, Position, SeekMode);
57} 57}
58 58
59LONG __init 59LONG
60ArcMount(char *name, enum linux_mountops op) 60ArcMount(char *name, enum linux_mountops op)
61{ 61{
62 return ARC_CALL2(mount, name, op); 62 return ARC_CALL2(mount, name, op);
63} 63}
64 64
65LONG __init 65LONG
66ArcGetFileInformation(ULONG FileID, struct linux_finfo *Information) 66ArcGetFileInformation(ULONG FileID, struct linux_finfo *Information)
67{ 67{
68 return ARC_CALL2(get_finfo, FileID, Information); 68 return ARC_CALL2(get_finfo, FileID, Information);
69} 69}
70 70
71LONG __init ArcSetFileInformation(ULONG FileID, ULONG AttributeFlags, 71LONG ArcSetFileInformation(ULONG FileID, ULONG AttributeFlags,
72 ULONG AttributeMask) 72 ULONG AttributeMask)
73{ 73{
74 return ARC_CALL3(set_finfo, FileID, AttributeFlags, AttributeMask); 74 return ARC_CALL3(set_finfo, FileID, AttributeFlags, AttributeMask);
75} 75}
diff --git a/arch/mips/au1000/common/Makefile b/arch/mips/au1000/common/Makefile
index 4c35525edb4f..90e2d7a46e8e 100644
--- a/arch/mips/au1000/common/Makefile
+++ b/arch/mips/au1000/common/Makefile
@@ -12,3 +12,5 @@ obj-y += prom.o irq.o puts.o time.o reset.o \
12 12
13obj-$(CONFIG_KGDB) += dbg_io.o 13obj-$(CONFIG_KGDB) += dbg_io.o
14obj-$(CONFIG_PCI) += pci.o 14obj-$(CONFIG_PCI) += pci.o
15
16EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index 0dc84417bf49..2a209d74f0b4 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -42,10 +42,6 @@ vmlinux.srec: $(VMLINUX)
42$(obj)/addinitrd: $(obj)/addinitrd.c 42$(obj)/addinitrd: $(obj)/addinitrd.c
43 $(HOSTCC) -o $@ $^ 43 $(HOSTCC) -o $@ $^
44 44
45archhelp:
46 @echo '* vmlinux.ecoff - ECOFF boot image'
47 @echo '* vmlinux.srec - SREC boot image'
48
49clean-files += addinitrd \ 45clean-files += addinitrd \
50 elf2ecoff \ 46 elf2ecoff \
51 vmlinux.bin \ 47 vmlinux.bin \
diff --git a/arch/mips/cobalt/Makefile b/arch/mips/cobalt/Makefile
index c292f80a8c74..a043f93f7d08 100644
--- a/arch/mips/cobalt/Makefile
+++ b/arch/mips/cobalt/Makefile
@@ -7,3 +7,5 @@ obj-y := buttons.o irq.o reset.o rtc.o serial.o setup.o
7obj-$(CONFIG_PCI) += pci.o 7obj-$(CONFIG_PCI) += pci.o
8obj-$(CONFIG_EARLY_PRINTK) += console.o 8obj-$(CONFIG_EARLY_PRINTK) += console.o
9obj-$(CONFIG_MTD_PHYSMAP) += mtd.o 9obj-$(CONFIG_MTD_PHYSMAP) += mtd.o
10
11EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/cobalt/serial.c b/arch/mips/cobalt/serial.c
index c27116599a5f..08e739704cc9 100644
--- a/arch/mips/cobalt/serial.c
+++ b/arch/mips/cobalt/serial.c
@@ -55,9 +55,9 @@ static __init int cobalt_uart_add(void)
55 int retval; 55 int retval;
56 56
57 /* 57 /*
58 * Cobalt Qube1 and RAQ1 have no UART. 58 * Cobalt Qube1 has no UART.
59 */ 59 */
60 if (cobalt_board_id <= COBALT_BRD_ID_RAQ1) 60 if (cobalt_board_id == COBALT_BRD_ID_QUBE1)
61 return 0; 61 return 0;
62 62
63 pdev = platform_device_alloc("serial8250", -1); 63 pdev = platform_device_alloc("serial8250", -1);
diff --git a/arch/mips/configs/atlas_defconfig b/arch/mips/configs/atlas_defconfig
index 129e2c961fec..62bcc887f2ca 100644
--- a/arch/mips/configs/atlas_defconfig
+++ b/arch/mips/configs/atlas_defconfig
@@ -32,12 +32,9 @@ CONFIG_MIPS_ATLAS=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/bigsur_defconfig b/arch/mips/configs/bigsur_defconfig
index dc3e1bf4e42e..67a80f4c7d87 100644
--- a/arch/mips/configs/bigsur_defconfig
+++ b/arch/mips/configs/bigsur_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/capcella_defconfig b/arch/mips/configs/capcella_defconfig
index 4c7031222e64..4dc3197e2e9f 100644
--- a/arch/mips/configs/capcella_defconfig
+++ b/arch/mips/configs/capcella_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41CONFIG_MACH_VR41XX=y 38CONFIG_MACH_VR41XX=y
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/cobalt_defconfig b/arch/mips/configs/cobalt_defconfig
index c8c05785a86d..6d6a01b9a817 100644
--- a/arch/mips/configs/cobalt_defconfig
+++ b/arch/mips/configs/cobalt_defconfig
@@ -18,10 +18,8 @@ CONFIG_MIPS_COBALT=y
18# CONFIG_MIPS_SEAD is not set 18# CONFIG_MIPS_SEAD is not set
19# CONFIG_WR_PPMC is not set 19# CONFIG_WR_PPMC is not set
20# CONFIG_MIPS_SIM is not set 20# CONFIG_MIPS_SIM is not set
21# CONFIG_MOMENCO_OCELOT is not set
22# CONFIG_PNX8550_JBS is not set 21# CONFIG_PNX8550_JBS is not set
23# CONFIG_PNX8550_STB810 is not set 22# CONFIG_PNX8550_STB810 is not set
24# CONFIG_DDB5477 is not set
25# CONFIG_MACH_VR41XX is not set 23# CONFIG_MACH_VR41XX is not set
26# CONFIG_PMC_YOSEMITE is not set 24# CONFIG_PMC_YOSEMITE is not set
27# CONFIG_QEMU is not set 25# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/db1000_defconfig b/arch/mips/configs/db1000_defconfig
index ec60beb888b2..885b633647e9 100644
--- a/arch/mips/configs/db1000_defconfig
+++ b/arch/mips/configs/db1000_defconfig
@@ -33,12 +33,9 @@ CONFIG_MIPS_DB1000=y
33# CONFIG_WR_PPMC is not set 33# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 34# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 35# CONFIG_MOMENCO_JAGUAR_ATX is not set
36# CONFIG_MOMENCO_OCELOT is not set
37# CONFIG_MOMENCO_OCELOT_G is not set
38# CONFIG_MIPS_XXS1500 is not set 36# CONFIG_MIPS_XXS1500 is not set
39# CONFIG_PNX8550_JBS is not set 37# CONFIG_PNX8550_JBS is not set
40# CONFIG_PNX8550_STB810 is not set 38# CONFIG_PNX8550_STB810 is not set
41# CONFIG_DDB5477 is not set
42# CONFIG_MACH_VR41XX is not set 39# CONFIG_MACH_VR41XX is not set
43# CONFIG_PMC_YOSEMITE is not set 40# CONFIG_PMC_YOSEMITE is not set
44# CONFIG_QEMU is not set 41# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/db1100_defconfig b/arch/mips/configs/db1100_defconfig
index f3c25f08bfad..e3c3a07e8a7c 100644
--- a/arch/mips/configs/db1100_defconfig
+++ b/arch/mips/configs/db1100_defconfig
@@ -33,12 +33,9 @@ CONFIG_MIPS_DB1100=y
33# CONFIG_WR_PPMC is not set 33# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 34# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 35# CONFIG_MOMENCO_JAGUAR_ATX is not set
36# CONFIG_MOMENCO_OCELOT is not set
37# CONFIG_MOMENCO_OCELOT_G is not set
38# CONFIG_MIPS_XXS1500 is not set 36# CONFIG_MIPS_XXS1500 is not set
39# CONFIG_PNX8550_JBS is not set 37# CONFIG_PNX8550_JBS is not set
40# CONFIG_PNX8550_STB810 is not set 38# CONFIG_PNX8550_STB810 is not set
41# CONFIG_DDB5477 is not set
42# CONFIG_MACH_VR41XX is not set 39# CONFIG_MACH_VR41XX is not set
43# CONFIG_PMC_YOSEMITE is not set 40# CONFIG_PMC_YOSEMITE is not set
44# CONFIG_QEMU is not set 41# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/db1200_defconfig b/arch/mips/configs/db1200_defconfig
index 6d400befbacc..9aa7c3ebfa3f 100644
--- a/arch/mips/configs/db1200_defconfig
+++ b/arch/mips/configs/db1200_defconfig
@@ -33,12 +33,9 @@ CONFIG_MIPS_DB1200=y
33# CONFIG_WR_PPMC is not set 33# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 34# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 35# CONFIG_MOMENCO_JAGUAR_ATX is not set
36# CONFIG_MOMENCO_OCELOT is not set
37# CONFIG_MOMENCO_OCELOT_G is not set
38# CONFIG_MIPS_XXS1500 is not set 36# CONFIG_MIPS_XXS1500 is not set
39# CONFIG_PNX8550_JBS is not set 37# CONFIG_PNX8550_JBS is not set
40# CONFIG_PNX8550_STB810 is not set 38# CONFIG_PNX8550_STB810 is not set
41# CONFIG_DDB5477 is not set
42# CONFIG_MACH_VR41XX is not set 39# CONFIG_MACH_VR41XX is not set
43# CONFIG_PMC_YOSEMITE is not set 40# CONFIG_PMC_YOSEMITE is not set
44# CONFIG_QEMU is not set 41# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/db1500_defconfig b/arch/mips/configs/db1500_defconfig
index 82aea6e08823..99240668bca1 100644
--- a/arch/mips/configs/db1500_defconfig
+++ b/arch/mips/configs/db1500_defconfig
@@ -33,12 +33,9 @@ CONFIG_MIPS_DB1500=y
33# CONFIG_WR_PPMC is not set 33# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 34# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 35# CONFIG_MOMENCO_JAGUAR_ATX is not set
36# CONFIG_MOMENCO_OCELOT is not set
37# CONFIG_MOMENCO_OCELOT_G is not set
38# CONFIG_MIPS_XXS1500 is not set 36# CONFIG_MIPS_XXS1500 is not set
39# CONFIG_PNX8550_JBS is not set 37# CONFIG_PNX8550_JBS is not set
40# CONFIG_PNX8550_STB810 is not set 38# CONFIG_PNX8550_STB810 is not set
41# CONFIG_DDB5477 is not set
42# CONFIG_MACH_VR41XX is not set 39# CONFIG_MACH_VR41XX is not set
43# CONFIG_PMC_YOSEMITE is not set 40# CONFIG_PMC_YOSEMITE is not set
44# CONFIG_QEMU is not set 41# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/db1550_defconfig b/arch/mips/configs/db1550_defconfig
index 82697714a9e3..19992f76c60d 100644
--- a/arch/mips/configs/db1550_defconfig
+++ b/arch/mips/configs/db1550_defconfig
@@ -33,12 +33,9 @@ CONFIG_MIPS_DB1550=y
33# CONFIG_WR_PPMC is not set 33# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 34# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 35# CONFIG_MOMENCO_JAGUAR_ATX is not set
36# CONFIG_MOMENCO_OCELOT is not set
37# CONFIG_MOMENCO_OCELOT_G is not set
38# CONFIG_MIPS_XXS1500 is not set 36# CONFIG_MIPS_XXS1500 is not set
39# CONFIG_PNX8550_JBS is not set 37# CONFIG_PNX8550_JBS is not set
40# CONFIG_PNX8550_STB810 is not set 38# CONFIG_PNX8550_STB810 is not set
41# CONFIG_DDB5477 is not set
42# CONFIG_MACH_VR41XX is not set 39# CONFIG_MACH_VR41XX is not set
43# CONFIG_PMC_YOSEMITE is not set 40# CONFIG_PMC_YOSEMITE is not set
44# CONFIG_QEMU is not set 41# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/ddb5477_defconfig b/arch/mips/configs/ddb5477_defconfig
deleted file mode 100644
index a42ab9ae7d4b..000000000000
--- a/arch/mips/configs/ddb5477_defconfig
+++ /dev/null
@@ -1,990 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.20
4# Tue Feb 20 21:47:28 2007
5#
6CONFIG_MIPS=y
7
8#
9# Machine selection
10#
11CONFIG_ZONE_DMA=y
12# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set
15# CONFIG_MIPS_PB1100 is not set
16# CONFIG_MIPS_PB1500 is not set
17# CONFIG_MIPS_PB1550 is not set
18# CONFIG_MIPS_PB1200 is not set
19# CONFIG_MIPS_DB1000 is not set
20# CONFIG_MIPS_DB1100 is not set
21# CONFIG_MIPS_DB1500 is not set
22# CONFIG_MIPS_DB1550 is not set
23# CONFIG_MIPS_DB1200 is not set
24# CONFIG_MIPS_MIRAGE is not set
25# CONFIG_BASLER_EXCITE is not set
26# CONFIG_MIPS_COBALT is not set
27# CONFIG_MACH_DECSTATION is not set
28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set
40CONFIG_DDB5477=y
41# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set
44# CONFIG_MARKEINS is not set
45# CONFIG_SGI_IP22 is not set
46# CONFIG_SGI_IP27 is not set
47# CONFIG_SGI_IP32 is not set
48# CONFIG_SIBYTE_BIGSUR is not set
49# CONFIG_SIBYTE_SWARM is not set
50# CONFIG_SIBYTE_SENTOSA is not set
51# CONFIG_SIBYTE_RHONE is not set
52# CONFIG_SIBYTE_CARMEL is not set
53# CONFIG_SIBYTE_PTSWARM is not set
54# CONFIG_SIBYTE_LITTLESUR is not set
55# CONFIG_SIBYTE_CRHINE is not set
56# CONFIG_SIBYTE_CRHONE is not set
57# CONFIG_SNI_RM is not set
58# CONFIG_TOSHIBA_JMR3927 is not set
59# CONFIG_TOSHIBA_RBTX4927 is not set
60# CONFIG_TOSHIBA_RBTX4938 is not set
61CONFIG_DDB5477_BUS_FREQUENCY=0
62CONFIG_RWSEM_GENERIC_SPINLOCK=y
63# CONFIG_ARCH_HAS_ILOG2_U32 is not set
64# CONFIG_ARCH_HAS_ILOG2_U64 is not set
65CONFIG_GENERIC_FIND_NEXT_BIT=y
66CONFIG_GENERIC_HWEIGHT=y
67CONFIG_GENERIC_CALIBRATE_DELAY=y
68CONFIG_GENERIC_TIME=y
69CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
70# CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ is not set
71CONFIG_DMA_NONCOHERENT=y
72CONFIG_DMA_NEED_PCI_MAP_STATE=y
73CONFIG_I8259=y
74# CONFIG_CPU_BIG_ENDIAN is not set
75CONFIG_CPU_LITTLE_ENDIAN=y
76CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
77CONFIG_IRQ_CPU=y
78CONFIG_DDB5XXX_COMMON=y
79CONFIG_MIPS_L1_CACHE_SHIFT=5
80
81#
82# CPU selection
83#
84# CONFIG_CPU_MIPS32_R1 is not set
85# CONFIG_CPU_MIPS32_R2 is not set
86# CONFIG_CPU_MIPS64_R1 is not set
87# CONFIG_CPU_MIPS64_R2 is not set
88# CONFIG_CPU_R3000 is not set
89# CONFIG_CPU_TX39XX is not set
90# CONFIG_CPU_VR41XX is not set
91# CONFIG_CPU_R4300 is not set
92# CONFIG_CPU_R4X00 is not set
93# CONFIG_CPU_TX49XX is not set
94# CONFIG_CPU_R5000 is not set
95CONFIG_CPU_R5432=y
96# CONFIG_CPU_R6000 is not set
97# CONFIG_CPU_NEVADA is not set
98# CONFIG_CPU_R8000 is not set
99# CONFIG_CPU_R10000 is not set
100# CONFIG_CPU_RM7000 is not set
101# CONFIG_CPU_RM9000 is not set
102# CONFIG_CPU_SB1 is not set
103CONFIG_SYS_HAS_CPU_R5432=y
104CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
105CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
106CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
107CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
108
109#
110# Kernel type
111#
112CONFIG_32BIT=y
113# CONFIG_64BIT is not set
114CONFIG_PAGE_SIZE_4KB=y
115# CONFIG_PAGE_SIZE_8KB is not set
116# CONFIG_PAGE_SIZE_16KB is not set
117# CONFIG_PAGE_SIZE_64KB is not set
118CONFIG_MIPS_MT_DISABLED=y
119# CONFIG_MIPS_MT_SMP is not set
120# CONFIG_MIPS_MT_SMTC is not set
121# CONFIG_MIPS_VPE_LOADER is not set
122CONFIG_CPU_HAS_LLSC=y
123CONFIG_CPU_HAS_SYNC=y
124CONFIG_GENERIC_HARDIRQS=y
125CONFIG_GENERIC_IRQ_PROBE=y
126CONFIG_ARCH_FLATMEM_ENABLE=y
127CONFIG_SELECT_MEMORY_MODEL=y
128CONFIG_FLATMEM_MANUAL=y
129# CONFIG_DISCONTIGMEM_MANUAL is not set
130# CONFIG_SPARSEMEM_MANUAL is not set
131CONFIG_FLATMEM=y
132CONFIG_FLAT_NODE_MEM_MAP=y
133# CONFIG_SPARSEMEM_STATIC is not set
134CONFIG_SPLIT_PTLOCK_CPUS=4
135# CONFIG_RESOURCES_64BIT is not set
136CONFIG_ZONE_DMA_FLAG=1
137# CONFIG_HZ_48 is not set
138# CONFIG_HZ_100 is not set
139# CONFIG_HZ_128 is not set
140# CONFIG_HZ_250 is not set
141# CONFIG_HZ_256 is not set
142CONFIG_HZ_1000=y
143# CONFIG_HZ_1024 is not set
144CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
145CONFIG_HZ=1000
146CONFIG_PREEMPT_NONE=y
147# CONFIG_PREEMPT_VOLUNTARY is not set
148# CONFIG_PREEMPT is not set
149# CONFIG_KEXEC is not set
150CONFIG_LOCKDEP_SUPPORT=y
151CONFIG_STACKTRACE_SUPPORT=y
152CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
153
154#
155# Code maturity level options
156#
157CONFIG_EXPERIMENTAL=y
158CONFIG_BROKEN_ON_SMP=y
159CONFIG_INIT_ENV_ARG_LIMIT=32
160
161#
162# General setup
163#
164CONFIG_LOCALVERSION=""
165CONFIG_LOCALVERSION_AUTO=y
166CONFIG_SWAP=y
167CONFIG_SYSVIPC=y
168# CONFIG_IPC_NS is not set
169CONFIG_SYSVIPC_SYSCTL=y
170# CONFIG_POSIX_MQUEUE is not set
171# CONFIG_BSD_PROCESS_ACCT is not set
172# CONFIG_TASKSTATS is not set
173# CONFIG_UTS_NS is not set
174# CONFIG_AUDIT is not set
175# CONFIG_IKCONFIG is not set
176CONFIG_SYSFS_DEPRECATED=y
177CONFIG_RELAY=y
178# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
179CONFIG_SYSCTL=y
180CONFIG_EMBEDDED=y
181CONFIG_SYSCTL_SYSCALL=y
182CONFIG_KALLSYMS=y
183# CONFIG_KALLSYMS_EXTRA_PASS is not set
184CONFIG_HOTPLUG=y
185CONFIG_PRINTK=y
186CONFIG_BUG=y
187CONFIG_ELF_CORE=y
188CONFIG_BASE_FULL=y
189CONFIG_FUTEX=y
190CONFIG_EPOLL=y
191CONFIG_SHMEM=y
192CONFIG_SLAB=y
193CONFIG_VM_EVENT_COUNTERS=y
194CONFIG_RT_MUTEXES=y
195# CONFIG_TINY_SHMEM is not set
196CONFIG_BASE_SMALL=0
197# CONFIG_SLOB is not set
198
199#
200# Loadable module support
201#
202# CONFIG_MODULES is not set
203
204#
205# Block layer
206#
207CONFIG_BLOCK=y
208# CONFIG_LBD is not set
209# CONFIG_BLK_DEV_IO_TRACE is not set
210# CONFIG_LSF is not set
211
212#
213# IO Schedulers
214#
215CONFIG_IOSCHED_NOOP=y
216CONFIG_IOSCHED_AS=y
217CONFIG_IOSCHED_DEADLINE=y
218CONFIG_IOSCHED_CFQ=y
219CONFIG_DEFAULT_AS=y
220# CONFIG_DEFAULT_DEADLINE is not set
221# CONFIG_DEFAULT_CFQ is not set
222# CONFIG_DEFAULT_NOOP is not set
223CONFIG_DEFAULT_IOSCHED="anticipatory"
224
225#
226# Bus options (PCI, PCMCIA, EISA, ISA, TC)
227#
228CONFIG_HW_HAS_PCI=y
229CONFIG_PCI=y
230CONFIG_MMU=y
231
232#
233# PCCARD (PCMCIA/CardBus) support
234#
235# CONFIG_PCCARD is not set
236
237#
238# PCI Hotplug Support
239#
240# CONFIG_HOTPLUG_PCI is not set
241
242#
243# Executable file formats
244#
245CONFIG_BINFMT_ELF=y
246# CONFIG_BINFMT_MISC is not set
247CONFIG_TRAD_SIGNALS=y
248
249#
250# Power management options
251#
252CONFIG_PM=y
253# CONFIG_PM_LEGACY is not set
254# CONFIG_PM_DEBUG is not set
255# CONFIG_PM_SYSFS_DEPRECATED is not set
256
257#
258# Networking
259#
260CONFIG_NET=y
261
262#
263# Networking options
264#
265# CONFIG_NETDEBUG is not set
266CONFIG_PACKET=y
267# CONFIG_PACKET_MMAP is not set
268CONFIG_UNIX=y
269CONFIG_XFRM=y
270CONFIG_XFRM_USER=y
271# CONFIG_XFRM_SUB_POLICY is not set
272CONFIG_XFRM_MIGRATE=y
273CONFIG_NET_KEY=y
274CONFIG_NET_KEY_MIGRATE=y
275CONFIG_INET=y
276# CONFIG_IP_MULTICAST is not set
277# CONFIG_IP_ADVANCED_ROUTER is not set
278CONFIG_IP_FIB_HASH=y
279CONFIG_IP_PNP=y
280# CONFIG_IP_PNP_DHCP is not set
281CONFIG_IP_PNP_BOOTP=y
282# CONFIG_IP_PNP_RARP is not set
283# CONFIG_NET_IPIP is not set
284# CONFIG_NET_IPGRE is not set
285# CONFIG_ARPD is not set
286# CONFIG_SYN_COOKIES is not set
287# CONFIG_INET_AH is not set
288# CONFIG_INET_ESP is not set
289# CONFIG_INET_IPCOMP is not set
290# CONFIG_INET_XFRM_TUNNEL is not set
291# CONFIG_INET_TUNNEL is not set
292CONFIG_INET_XFRM_MODE_TRANSPORT=y
293CONFIG_INET_XFRM_MODE_TUNNEL=y
294CONFIG_INET_XFRM_MODE_BEET=y
295CONFIG_INET_DIAG=y
296CONFIG_INET_TCP_DIAG=y
297# CONFIG_TCP_CONG_ADVANCED is not set
298CONFIG_TCP_CONG_CUBIC=y
299CONFIG_DEFAULT_TCP_CONG="cubic"
300CONFIG_TCP_MD5SIG=y
301# CONFIG_IPV6 is not set
302# CONFIG_INET6_XFRM_TUNNEL is not set
303# CONFIG_INET6_TUNNEL is not set
304CONFIG_NETWORK_SECMARK=y
305# CONFIG_NETFILTER is not set
306
307#
308# DCCP Configuration (EXPERIMENTAL)
309#
310# CONFIG_IP_DCCP is not set
311
312#
313# SCTP Configuration (EXPERIMENTAL)
314#
315# CONFIG_IP_SCTP is not set
316
317#
318# TIPC Configuration (EXPERIMENTAL)
319#
320# CONFIG_TIPC is not set
321# CONFIG_ATM is not set
322# CONFIG_BRIDGE is not set
323# CONFIG_VLAN_8021Q is not set
324# CONFIG_DECNET is not set
325# CONFIG_LLC2 is not set
326# CONFIG_IPX is not set
327# CONFIG_ATALK is not set
328# CONFIG_X25 is not set
329# CONFIG_LAPB is not set
330# CONFIG_ECONET is not set
331# CONFIG_WAN_ROUTER is not set
332
333#
334# QoS and/or fair queueing
335#
336# CONFIG_NET_SCHED is not set
337
338#
339# Network testing
340#
341# CONFIG_NET_PKTGEN is not set
342# CONFIG_HAMRADIO is not set
343# CONFIG_IRDA is not set
344# CONFIG_BT is not set
345CONFIG_IEEE80211=y
346# CONFIG_IEEE80211_DEBUG is not set
347CONFIG_IEEE80211_CRYPT_WEP=y
348CONFIG_IEEE80211_CRYPT_CCMP=y
349CONFIG_IEEE80211_SOFTMAC=y
350# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set
351CONFIG_WIRELESS_EXT=y
352
353#
354# Device Drivers
355#
356
357#
358# Generic Driver Options
359#
360CONFIG_STANDALONE=y
361CONFIG_PREVENT_FIRMWARE_BUILD=y
362CONFIG_FW_LOADER=y
363# CONFIG_SYS_HYPERVISOR is not set
364
365#
366# Connector - unified userspace <-> kernelspace linker
367#
368CONFIG_CONNECTOR=y
369CONFIG_PROC_EVENTS=y
370
371#
372# Memory Technology Devices (MTD)
373#
374# CONFIG_MTD is not set
375
376#
377# Parallel port support
378#
379# CONFIG_PARPORT is not set
380
381#
382# Plug and Play support
383#
384# CONFIG_PNPACPI is not set
385
386#
387# Block devices
388#
389# CONFIG_BLK_CPQ_DA is not set
390# CONFIG_BLK_CPQ_CISS_DA is not set
391# CONFIG_BLK_DEV_DAC960 is not set
392# CONFIG_BLK_DEV_UMEM is not set
393# CONFIG_BLK_DEV_COW_COMMON is not set
394# CONFIG_BLK_DEV_LOOP is not set
395# CONFIG_BLK_DEV_NBD is not set
396# CONFIG_BLK_DEV_SX8 is not set
397# CONFIG_BLK_DEV_RAM is not set
398# CONFIG_BLK_DEV_INITRD is not set
399CONFIG_CDROM_PKTCDVD=y
400CONFIG_CDROM_PKTCDVD_BUFFERS=8
401# CONFIG_CDROM_PKTCDVD_WCACHE is not set
402CONFIG_ATA_OVER_ETH=y
403
404#
405# Misc devices
406#
407CONFIG_SGI_IOC4=y
408# CONFIG_TIFM_CORE is not set
409
410#
411# ATA/ATAPI/MFM/RLL support
412#
413# CONFIG_IDE is not set
414
415#
416# SCSI device support
417#
418CONFIG_RAID_ATTRS=y
419# CONFIG_SCSI is not set
420# CONFIG_SCSI_NETLINK is not set
421
422#
423# Serial ATA (prod) and Parallel ATA (experimental) drivers
424#
425# CONFIG_ATA is not set
426
427#
428# Multi-device support (RAID and LVM)
429#
430# CONFIG_MD is not set
431
432#
433# Fusion MPT device support
434#
435# CONFIG_FUSION is not set
436
437#
438# IEEE 1394 (FireWire) support
439#
440# CONFIG_IEEE1394 is not set
441
442#
443# I2O device support
444#
445# CONFIG_I2O is not set
446
447#
448# Network device support
449#
450CONFIG_NETDEVICES=y
451# CONFIG_DUMMY is not set
452# CONFIG_BONDING is not set
453# CONFIG_EQUALIZER is not set
454# CONFIG_TUN is not set
455
456#
457# ARCnet devices
458#
459# CONFIG_ARCNET is not set
460
461#
462# PHY device support
463#
464CONFIG_PHYLIB=y
465
466#
467# MII PHY device drivers
468#
469CONFIG_MARVELL_PHY=y
470CONFIG_DAVICOM_PHY=y
471CONFIG_QSEMI_PHY=y
472CONFIG_LXT_PHY=y
473CONFIG_CICADA_PHY=y
474CONFIG_VITESSE_PHY=y
475CONFIG_SMSC_PHY=y
476# CONFIG_BROADCOM_PHY is not set
477# CONFIG_FIXED_PHY is not set
478
479#
480# Ethernet (10 or 100Mbit)
481#
482CONFIG_NET_ETHERNET=y
483CONFIG_MII=y
484# CONFIG_HAPPYMEAL is not set
485# CONFIG_SUNGEM is not set
486# CONFIG_CASSINI is not set
487# CONFIG_NET_VENDOR_3COM is not set
488# CONFIG_DM9000 is not set
489
490#
491# Tulip family network device support
492#
493# CONFIG_NET_TULIP is not set
494# CONFIG_HP100 is not set
495CONFIG_NET_PCI=y
496CONFIG_PCNET32=y
497# CONFIG_PCNET32_NAPI is not set
498# CONFIG_AMD8111_ETH is not set
499# CONFIG_ADAPTEC_STARFIRE is not set
500# CONFIG_B44 is not set
501# CONFIG_FORCEDETH is not set
502# CONFIG_DGRS is not set
503# CONFIG_EEPRO100 is not set
504# CONFIG_E100 is not set
505# CONFIG_FEALNX is not set
506# CONFIG_NATSEMI is not set
507# CONFIG_NE2K_PCI is not set
508# CONFIG_8139CP is not set
509# CONFIG_8139TOO is not set
510# CONFIG_SIS900 is not set
511# CONFIG_EPIC100 is not set
512# CONFIG_SUNDANCE is not set
513# CONFIG_TLAN is not set
514# CONFIG_VIA_RHINE is not set
515# CONFIG_SC92031 is not set
516
517#
518# Ethernet (1000 Mbit)
519#
520# CONFIG_ACENIC is not set
521# CONFIG_DL2K is not set
522# CONFIG_E1000 is not set
523# CONFIG_NS83820 is not set
524# CONFIG_HAMACHI is not set
525# CONFIG_YELLOWFIN is not set
526# CONFIG_R8169 is not set
527# CONFIG_SIS190 is not set
528# CONFIG_SKGE is not set
529# CONFIG_SKY2 is not set
530# CONFIG_SK98LIN is not set
531# CONFIG_VIA_VELOCITY is not set
532# CONFIG_TIGON3 is not set
533# CONFIG_BNX2 is not set
534CONFIG_QLA3XXX=y
535# CONFIG_ATL1 is not set
536
537#
538# Ethernet (10000 Mbit)
539#
540# CONFIG_CHELSIO_T1 is not set
541CONFIG_CHELSIO_T3=y
542# CONFIG_IXGB is not set
543# CONFIG_S2IO is not set
544# CONFIG_MYRI10GE is not set
545CONFIG_NETXEN_NIC=y
546
547#
548# Token Ring devices
549#
550# CONFIG_TR is not set
551
552#
553# Wireless LAN (non-hamradio)
554#
555# CONFIG_NET_RADIO is not set
556
557#
558# Wan interfaces
559#
560# CONFIG_WAN is not set
561# CONFIG_FDDI is not set
562# CONFIG_HIPPI is not set
563# CONFIG_PPP is not set
564# CONFIG_SLIP is not set
565# CONFIG_SHAPER is not set
566# CONFIG_NETCONSOLE is not set
567# CONFIG_NETPOLL is not set
568# CONFIG_NET_POLL_CONTROLLER is not set
569
570#
571# ISDN subsystem
572#
573# CONFIG_ISDN is not set
574
575#
576# Telephony Support
577#
578# CONFIG_PHONE is not set
579
580#
581# Input device support
582#
583CONFIG_INPUT=y
584# CONFIG_INPUT_FF_MEMLESS is not set
585
586#
587# Userland interfaces
588#
589CONFIG_INPUT_MOUSEDEV=y
590CONFIG_INPUT_MOUSEDEV_PSAUX=y
591CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
592CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
593# CONFIG_INPUT_JOYDEV is not set
594# CONFIG_INPUT_TSDEV is not set
595# CONFIG_INPUT_EVDEV is not set
596# CONFIG_INPUT_EVBUG is not set
597
598#
599# Input Device Drivers
600#
601# CONFIG_INPUT_KEYBOARD is not set
602# CONFIG_INPUT_MOUSE is not set
603# CONFIG_INPUT_JOYSTICK is not set
604# CONFIG_INPUT_TOUCHSCREEN is not set
605# CONFIG_INPUT_MISC is not set
606
607#
608# Hardware I/O ports
609#
610CONFIG_SERIO=y
611# CONFIG_SERIO_I8042 is not set
612CONFIG_SERIO_SERPORT=y
613# CONFIG_SERIO_PCIPS2 is not set
614# CONFIG_SERIO_LIBPS2 is not set
615CONFIG_SERIO_RAW=y
616# CONFIG_GAMEPORT is not set
617
618#
619# Character devices
620#
621CONFIG_VT=y
622CONFIG_VT_CONSOLE=y
623CONFIG_HW_CONSOLE=y
624CONFIG_VT_HW_CONSOLE_BINDING=y
625# CONFIG_SERIAL_NONSTANDARD is not set
626
627#
628# Serial drivers
629#
630CONFIG_SERIAL_8250=y
631CONFIG_SERIAL_8250_CONSOLE=y
632CONFIG_SERIAL_8250_PCI=y
633CONFIG_SERIAL_8250_NR_UARTS=4
634CONFIG_SERIAL_8250_RUNTIME_UARTS=4
635# CONFIG_SERIAL_8250_EXTENDED is not set
636
637#
638# Non-8250 serial port support
639#
640CONFIG_SERIAL_CORE=y
641CONFIG_SERIAL_CORE_CONSOLE=y
642# CONFIG_SERIAL_JSM is not set
643CONFIG_UNIX98_PTYS=y
644CONFIG_LEGACY_PTYS=y
645CONFIG_LEGACY_PTY_COUNT=256
646
647#
648# IPMI
649#
650# CONFIG_IPMI_HANDLER is not set
651
652#
653# Watchdog Cards
654#
655# CONFIG_WATCHDOG is not set
656# CONFIG_HW_RANDOM is not set
657# CONFIG_RTC is not set
658# CONFIG_GEN_RTC is not set
659# CONFIG_DTLK is not set
660# CONFIG_R3964 is not set
661# CONFIG_APPLICOM is not set
662# CONFIG_DRM is not set
663# CONFIG_RAW_DRIVER is not set
664
665#
666# TPM devices
667#
668# CONFIG_TCG_TPM is not set
669
670#
671# I2C support
672#
673# CONFIG_I2C is not set
674
675#
676# SPI support
677#
678# CONFIG_SPI is not set
679# CONFIG_SPI_MASTER is not set
680
681#
682# Dallas's 1-wire bus
683#
684# CONFIG_W1 is not set
685
686#
687# Hardware Monitoring support
688#
689# CONFIG_HWMON is not set
690# CONFIG_HWMON_VID is not set
691
692#
693# Multimedia devices
694#
695# CONFIG_VIDEO_DEV is not set
696
697#
698# Digital Video Broadcasting Devices
699#
700# CONFIG_DVB is not set
701
702#
703# Graphics support
704#
705# CONFIG_FIRMWARE_EDID is not set
706# CONFIG_FB is not set
707
708#
709# Console display driver support
710#
711# CONFIG_VGA_CONSOLE is not set
712CONFIG_DUMMY_CONSOLE=y
713# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
714
715#
716# Sound
717#
718# CONFIG_SOUND is not set
719
720#
721# HID Devices
722#
723# CONFIG_HID is not set
724
725#
726# USB support
727#
728CONFIG_USB_ARCH_HAS_HCD=y
729CONFIG_USB_ARCH_HAS_OHCI=y
730CONFIG_USB_ARCH_HAS_EHCI=y
731# CONFIG_USB is not set
732
733#
734# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
735#
736
737#
738# USB Gadget Support
739#
740# CONFIG_USB_GADGET is not set
741
742#
743# MMC/SD Card support
744#
745# CONFIG_MMC is not set
746
747#
748# LED devices
749#
750# CONFIG_NEW_LEDS is not set
751
752#
753# LED drivers
754#
755
756#
757# LED Triggers
758#
759
760#
761# InfiniBand support
762#
763# CONFIG_INFINIBAND is not set
764
765#
766# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
767#
768
769#
770# Real Time Clock
771#
772# CONFIG_RTC_CLASS is not set
773
774#
775# DMA Engine support
776#
777# CONFIG_DMA_ENGINE is not set
778
779#
780# DMA Clients
781#
782
783#
784# DMA Devices
785#
786
787#
788# Auxiliary Display support
789#
790
791#
792# Virtualization
793#
794
795#
796# File systems
797#
798CONFIG_EXT2_FS=y
799# CONFIG_EXT2_FS_XATTR is not set
800# CONFIG_EXT2_FS_XIP is not set
801# CONFIG_EXT3_FS is not set
802# CONFIG_EXT4DEV_FS is not set
803# CONFIG_REISERFS_FS is not set
804# CONFIG_JFS_FS is not set
805# CONFIG_FS_POSIX_ACL is not set
806# CONFIG_XFS_FS is not set
807# CONFIG_GFS2_FS is not set
808# CONFIG_OCFS2_FS is not set
809# CONFIG_MINIX_FS is not set
810# CONFIG_ROMFS_FS is not set
811CONFIG_INOTIFY=y
812CONFIG_INOTIFY_USER=y
813# CONFIG_QUOTA is not set
814CONFIG_DNOTIFY=y
815CONFIG_AUTOFS_FS=y
816CONFIG_AUTOFS4_FS=y
817CONFIG_FUSE_FS=y
818
819#
820# CD-ROM/DVD Filesystems
821#
822# CONFIG_ISO9660_FS is not set
823# CONFIG_UDF_FS is not set
824
825#
826# DOS/FAT/NT Filesystems
827#
828# CONFIG_MSDOS_FS is not set
829# CONFIG_VFAT_FS is not set
830# CONFIG_NTFS_FS is not set
831
832#
833# Pseudo filesystems
834#
835CONFIG_PROC_FS=y
836CONFIG_PROC_KCORE=y
837CONFIG_PROC_SYSCTL=y
838CONFIG_SYSFS=y
839# CONFIG_TMPFS is not set
840# CONFIG_HUGETLB_PAGE is not set
841CONFIG_RAMFS=y
842CONFIG_CONFIGFS_FS=y
843
844#
845# Miscellaneous filesystems
846#
847# CONFIG_ADFS_FS is not set
848# CONFIG_AFFS_FS is not set
849# CONFIG_ECRYPT_FS is not set
850# CONFIG_HFS_FS is not set
851# CONFIG_HFSPLUS_FS is not set
852# CONFIG_BEFS_FS is not set
853# CONFIG_BFS_FS is not set
854# CONFIG_EFS_FS is not set
855# CONFIG_CRAMFS is not set
856# CONFIG_VXFS_FS is not set
857# CONFIG_HPFS_FS is not set
858# CONFIG_QNX4FS_FS is not set
859# CONFIG_SYSV_FS is not set
860# CONFIG_UFS_FS is not set
861
862#
863# Network File Systems
864#
865CONFIG_NFS_FS=y
866# CONFIG_NFS_V3 is not set
867# CONFIG_NFS_V4 is not set
868# CONFIG_NFS_DIRECTIO is not set
869CONFIG_NFSD=y
870# CONFIG_NFSD_V3 is not set
871# CONFIG_NFSD_TCP is not set
872CONFIG_ROOT_NFS=y
873CONFIG_LOCKD=y
874CONFIG_EXPORTFS=y
875CONFIG_NFS_COMMON=y
876CONFIG_SUNRPC=y
877# CONFIG_RPCSEC_GSS_KRB5 is not set
878# CONFIG_RPCSEC_GSS_SPKM3 is not set
879# CONFIG_SMB_FS is not set
880# CONFIG_CIFS is not set
881# CONFIG_NCP_FS is not set
882# CONFIG_CODA_FS is not set
883# CONFIG_AFS_FS is not set
884# CONFIG_9P_FS is not set
885
886#
887# Partition Types
888#
889# CONFIG_PARTITION_ADVANCED is not set
890CONFIG_MSDOS_PARTITION=y
891
892#
893# Native Language Support
894#
895# CONFIG_NLS is not set
896
897#
898# Distributed Lock Manager
899#
900CONFIG_DLM=y
901CONFIG_DLM_TCP=y
902# CONFIG_DLM_SCTP is not set
903# CONFIG_DLM_DEBUG is not set
904
905#
906# Profiling support
907#
908# CONFIG_PROFILING is not set
909
910#
911# Kernel hacking
912#
913CONFIG_TRACE_IRQFLAGS_SUPPORT=y
914# CONFIG_PRINTK_TIME is not set
915CONFIG_ENABLE_MUST_CHECK=y
916# CONFIG_MAGIC_SYSRQ is not set
917# CONFIG_UNUSED_SYMBOLS is not set
918# CONFIG_DEBUG_FS is not set
919# CONFIG_HEADERS_CHECK is not set
920# CONFIG_DEBUG_KERNEL is not set
921CONFIG_LOG_BUF_SHIFT=14
922CONFIG_CROSSCOMPILE=y
923CONFIG_CMDLINE="ip=any"
924CONFIG_SYS_SUPPORTS_KGDB=y
925
926#
927# Security options
928#
929CONFIG_KEYS=y
930CONFIG_KEYS_DEBUG_PROC_KEYS=y
931# CONFIG_SECURITY is not set
932
933#
934# Cryptographic options
935#
936CONFIG_CRYPTO=y
937CONFIG_CRYPTO_ALGAPI=y
938CONFIG_CRYPTO_BLKCIPHER=y
939CONFIG_CRYPTO_HASH=y
940CONFIG_CRYPTO_MANAGER=y
941CONFIG_CRYPTO_HMAC=y
942CONFIG_CRYPTO_XCBC=y
943CONFIG_CRYPTO_NULL=y
944CONFIG_CRYPTO_MD4=y
945CONFIG_CRYPTO_MD5=y
946CONFIG_CRYPTO_SHA1=y
947CONFIG_CRYPTO_SHA256=y
948CONFIG_CRYPTO_SHA512=y
949CONFIG_CRYPTO_WP512=y
950CONFIG_CRYPTO_TGR192=y
951CONFIG_CRYPTO_GF128MUL=y
952CONFIG_CRYPTO_ECB=y
953CONFIG_CRYPTO_CBC=y
954CONFIG_CRYPTO_PCBC=y
955CONFIG_CRYPTO_LRW=y
956CONFIG_CRYPTO_DES=y
957CONFIG_CRYPTO_FCRYPT=y
958CONFIG_CRYPTO_BLOWFISH=y
959CONFIG_CRYPTO_TWOFISH=y
960CONFIG_CRYPTO_TWOFISH_COMMON=y
961CONFIG_CRYPTO_SERPENT=y
962CONFIG_CRYPTO_AES=y
963CONFIG_CRYPTO_CAST5=y
964CONFIG_CRYPTO_CAST6=y
965CONFIG_CRYPTO_TEA=y
966CONFIG_CRYPTO_ARC4=y
967CONFIG_CRYPTO_KHAZAD=y
968CONFIG_CRYPTO_ANUBIS=y
969CONFIG_CRYPTO_DEFLATE=y
970CONFIG_CRYPTO_MICHAEL_MIC=y
971CONFIG_CRYPTO_CRC32C=y
972CONFIG_CRYPTO_CAMELLIA=y
973
974#
975# Hardware crypto devices
976#
977
978#
979# Library routines
980#
981CONFIG_BITREVERSE=y
982# CONFIG_CRC_CCITT is not set
983CONFIG_CRC16=y
984CONFIG_CRC32=y
985CONFIG_LIBCRC32C=y
986CONFIG_ZLIB_INFLATE=y
987CONFIG_ZLIB_DEFLATE=y
988CONFIG_PLIST=y
989CONFIG_HAS_IOMEM=y
990CONFIG_HAS_IOPORT=y
diff --git a/arch/mips/configs/decstation_defconfig b/arch/mips/configs/decstation_defconfig
index d6e3fffbc80d..2fb350432669 100644
--- a/arch/mips/configs/decstation_defconfig
+++ b/arch/mips/configs/decstation_defconfig
@@ -32,12 +32,9 @@ CONFIG_MACH_DECSTATION=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/e55_defconfig b/arch/mips/configs/e55_defconfig
index 78f5004fb721..5467d750b6eb 100644
--- a/arch/mips/configs/e55_defconfig
+++ b/arch/mips/configs/e55_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41CONFIG_MACH_VR41XX=y 38CONFIG_MACH_VR41XX=y
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/emma2rh_defconfig b/arch/mips/configs/emma2rh_defconfig
index b29bff0f56c3..d73d965f7615 100644
--- a/arch/mips/configs/emma2rh_defconfig
+++ b/arch/mips/configs/emma2rh_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/excite_defconfig b/arch/mips/configs/excite_defconfig
index 69810592aa6b..17a866057fd4 100644
--- a/arch/mips/configs/excite_defconfig
+++ b/arch/mips/configs/excite_defconfig
@@ -33,12 +33,9 @@ CONFIG_BASLER_EXCITE=y
33# CONFIG_WR_PPMC is not set 33# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 34# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 35# CONFIG_MOMENCO_JAGUAR_ATX is not set
36# CONFIG_MOMENCO_OCELOT is not set
37# CONFIG_MOMENCO_OCELOT_G is not set
38# CONFIG_MIPS_XXS1500 is not set 36# CONFIG_MIPS_XXS1500 is not set
39# CONFIG_PNX8550_JBS is not set 37# CONFIG_PNX8550_JBS is not set
40# CONFIG_PNX8550_STB810 is not set 38# CONFIG_PNX8550_STB810 is not set
41# CONFIG_DDB5477 is not set
42# CONFIG_MACH_VR41XX is not set 39# CONFIG_MACH_VR41XX is not set
43# CONFIG_PMC_YOSEMITE is not set 40# CONFIG_PMC_YOSEMITE is not set
44# CONFIG_QEMU is not set 41# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/fulong_defconfig b/arch/mips/configs/fulong_defconfig
index 6ab94d8cf08b..4ef39a0527cc 100644
--- a/arch/mips/configs/fulong_defconfig
+++ b/arch/mips/configs/fulong_defconfig
@@ -19,10 +19,8 @@ CONFIG_LEMOTE_FULONG=y
19# CONFIG_MIPS_SEAD is not set 19# CONFIG_MIPS_SEAD is not set
20# CONFIG_WR_PPMC is not set 20# CONFIG_WR_PPMC is not set
21# CONFIG_MIPS_SIM is not set 21# CONFIG_MIPS_SIM is not set
22# CONFIG_MOMENCO_OCELOT is not set
23# CONFIG_PNX8550_JBS is not set 22# CONFIG_PNX8550_JBS is not set
24# CONFIG_PNX8550_STB810 is not set 23# CONFIG_PNX8550_STB810 is not set
25# CONFIG_DDB5477 is not set
26# CONFIG_MACH_VR41XX is not set 24# CONFIG_MACH_VR41XX is not set
27# CONFIG_PMC_YOSEMITE is not set 25# CONFIG_PMC_YOSEMITE is not set
28# CONFIG_QEMU is not set 26# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/ip22_defconfig b/arch/mips/configs/ip22_defconfig
index 405c9f505a77..934d8a008936 100644
--- a/arch/mips/configs/ip22_defconfig
+++ b/arch/mips/configs/ip22_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/ip27_defconfig b/arch/mips/configs/ip27_defconfig
index a9dcbcf563cb..eb35f7518d06 100644
--- a/arch/mips/configs/ip27_defconfig
+++ b/arch/mips/configs/ip27_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/ip32_defconfig b/arch/mips/configs/ip32_defconfig
index a040459bec11..47f49b60c5d6 100644
--- a/arch/mips/configs/ip32_defconfig
+++ b/arch/mips/configs/ip32_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/jazz_defconfig b/arch/mips/configs/jazz_defconfig
index 8a0b4ac5283d..fa655e247ecc 100644
--- a/arch/mips/configs/jazz_defconfig
+++ b/arch/mips/configs/jazz_defconfig
@@ -32,12 +32,9 @@ CONFIG_MACH_JAZZ=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/jmr3927_defconfig b/arch/mips/configs/jmr3927_defconfig
index 9a25e770abd8..95a72d2750ef 100644
--- a/arch/mips/configs/jmr3927_defconfig
+++ b/arch/mips/configs/jmr3927_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/malta_defconfig b/arch/mips/configs/malta_defconfig
index 546cb243fd09..fbfa5685887c 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -32,12 +32,9 @@ CONFIG_MIPS_MALTA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/mipssim_defconfig b/arch/mips/configs/mipssim_defconfig
index 6abad6f88313..86dcb7464353 100644
--- a/arch/mips/configs/mipssim_defconfig
+++ b/arch/mips/configs/mipssim_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33CONFIG_MIPS_SIM=y 33CONFIG_MIPS_SIM=y
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/mpc30x_defconfig b/arch/mips/configs/mpc30x_defconfig
index 4981ce425d82..239810b6c88d 100644
--- a/arch/mips/configs/mpc30x_defconfig
+++ b/arch/mips/configs/mpc30x_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41CONFIG_MACH_VR41XX=y 38CONFIG_MACH_VR41XX=y
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/msp71xx_defconfig b/arch/mips/configs/msp71xx_defconfig
index adca5f7ba533..69278999c9a2 100644
--- a/arch/mips/configs/msp71xx_defconfig
+++ b/arch/mips/configs/msp71xx_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42CONFIG_PMC_MSP=y 39CONFIG_PMC_MSP=y
43# CONFIG_PMC_YOSEMITE is not set 40# CONFIG_PMC_YOSEMITE is not set
diff --git a/arch/mips/configs/ocelot_defconfig b/arch/mips/configs/ocelot_defconfig
deleted file mode 100644
index e1db1fb80cd0..000000000000
--- a/arch/mips/configs/ocelot_defconfig
+++ /dev/null
@@ -1,919 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.20
4# Tue Feb 20 21:47:36 2007
5#
6CONFIG_MIPS=y
7
8#
9# Machine selection
10#
11CONFIG_ZONE_DMA=y
12# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set
15# CONFIG_MIPS_PB1100 is not set
16# CONFIG_MIPS_PB1500 is not set
17# CONFIG_MIPS_PB1550 is not set
18# CONFIG_MIPS_PB1200 is not set
19# CONFIG_MIPS_DB1000 is not set
20# CONFIG_MIPS_DB1100 is not set
21# CONFIG_MIPS_DB1500 is not set
22# CONFIG_MIPS_DB1550 is not set
23# CONFIG_MIPS_DB1200 is not set
24# CONFIG_MIPS_MIRAGE is not set
25# CONFIG_BASLER_EXCITE is not set
26# CONFIG_MIPS_COBALT is not set
27# CONFIG_MACH_DECSTATION is not set
28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35CONFIG_MOMENCO_OCELOT=y
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set
44# CONFIG_MARKEINS is not set
45# CONFIG_SGI_IP22 is not set
46# CONFIG_SGI_IP27 is not set
47# CONFIG_SGI_IP32 is not set
48# CONFIG_SIBYTE_BIGSUR is not set
49# CONFIG_SIBYTE_SWARM is not set
50# CONFIG_SIBYTE_SENTOSA is not set
51# CONFIG_SIBYTE_RHONE is not set
52# CONFIG_SIBYTE_CARMEL is not set
53# CONFIG_SIBYTE_PTSWARM is not set
54# CONFIG_SIBYTE_LITTLESUR is not set
55# CONFIG_SIBYTE_CRHINE is not set
56# CONFIG_SIBYTE_CRHONE is not set
57# CONFIG_SNI_RM is not set
58# CONFIG_TOSHIBA_JMR3927 is not set
59# CONFIG_TOSHIBA_RBTX4927 is not set
60# CONFIG_TOSHIBA_RBTX4938 is not set
61CONFIG_RWSEM_GENERIC_SPINLOCK=y
62# CONFIG_ARCH_HAS_ILOG2_U32 is not set
63# CONFIG_ARCH_HAS_ILOG2_U64 is not set
64CONFIG_GENERIC_FIND_NEXT_BIT=y
65CONFIG_GENERIC_HWEIGHT=y
66CONFIG_GENERIC_CALIBRATE_DELAY=y
67CONFIG_GENERIC_TIME=y
68CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
69# CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ is not set
70CONFIG_DMA_NONCOHERENT=y
71CONFIG_DMA_NEED_PCI_MAP_STATE=y
72CONFIG_CPU_BIG_ENDIAN=y
73# CONFIG_CPU_LITTLE_ENDIAN is not set
74CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
75CONFIG_IRQ_CPU=y
76CONFIG_IRQ_CPU_RM7K=y
77CONFIG_MIPS_GT64120=y
78CONFIG_SWAP_IO_SPACE=y
79# CONFIG_SYSCLK_75 is not set
80# CONFIG_SYSCLK_83 is not set
81CONFIG_SYSCLK_100=y
82CONFIG_MIPS_L1_CACHE_SHIFT=5
83
84#
85# CPU selection
86#
87# CONFIG_CPU_MIPS32_R1 is not set
88# CONFIG_CPU_MIPS32_R2 is not set
89# CONFIG_CPU_MIPS64_R1 is not set
90# CONFIG_CPU_MIPS64_R2 is not set
91# CONFIG_CPU_R3000 is not set
92# CONFIG_CPU_TX39XX is not set
93# CONFIG_CPU_VR41XX is not set
94# CONFIG_CPU_R4300 is not set
95# CONFIG_CPU_R4X00 is not set
96# CONFIG_CPU_TX49XX is not set
97# CONFIG_CPU_R5000 is not set
98# CONFIG_CPU_R5432 is not set
99# CONFIG_CPU_R6000 is not set
100# CONFIG_CPU_NEVADA is not set
101# CONFIG_CPU_R8000 is not set
102# CONFIG_CPU_R10000 is not set
103CONFIG_CPU_RM7000=y
104# CONFIG_CPU_RM9000 is not set
105# CONFIG_CPU_SB1 is not set
106CONFIG_SYS_HAS_CPU_RM7000=y
107CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
108CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
109CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
110CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
111
112#
113# Kernel type
114#
115CONFIG_32BIT=y
116# CONFIG_64BIT is not set
117CONFIG_PAGE_SIZE_4KB=y
118# CONFIG_PAGE_SIZE_8KB is not set
119# CONFIG_PAGE_SIZE_16KB is not set
120# CONFIG_PAGE_SIZE_64KB is not set
121CONFIG_BOARD_SCACHE=y
122CONFIG_RM7000_CPU_SCACHE=y
123CONFIG_CPU_HAS_PREFETCH=y
124CONFIG_MIPS_MT_DISABLED=y
125# CONFIG_MIPS_MT_SMP is not set
126# CONFIG_MIPS_MT_SMTC is not set
127# CONFIG_MIPS_VPE_LOADER is not set
128# CONFIG_64BIT_PHYS_ADDR is not set
129CONFIG_CPU_HAS_LLSC=y
130CONFIG_CPU_HAS_SYNC=y
131CONFIG_GENERIC_HARDIRQS=y
132CONFIG_GENERIC_IRQ_PROBE=y
133CONFIG_CPU_SUPPORTS_HIGHMEM=y
134CONFIG_ARCH_FLATMEM_ENABLE=y
135CONFIG_SELECT_MEMORY_MODEL=y
136CONFIG_FLATMEM_MANUAL=y
137# CONFIG_DISCONTIGMEM_MANUAL is not set
138# CONFIG_SPARSEMEM_MANUAL is not set
139CONFIG_FLATMEM=y
140CONFIG_FLAT_NODE_MEM_MAP=y
141# CONFIG_SPARSEMEM_STATIC is not set
142CONFIG_SPLIT_PTLOCK_CPUS=4
143# CONFIG_RESOURCES_64BIT is not set
144CONFIG_ZONE_DMA_FLAG=1
145# CONFIG_HZ_48 is not set
146# CONFIG_HZ_100 is not set
147# CONFIG_HZ_128 is not set
148# CONFIG_HZ_250 is not set
149# CONFIG_HZ_256 is not set
150CONFIG_HZ_1000=y
151# CONFIG_HZ_1024 is not set
152CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
153CONFIG_HZ=1000
154CONFIG_PREEMPT_NONE=y
155# CONFIG_PREEMPT_VOLUNTARY is not set
156# CONFIG_PREEMPT is not set
157# CONFIG_KEXEC is not set
158CONFIG_LOCKDEP_SUPPORT=y
159CONFIG_STACKTRACE_SUPPORT=y
160CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
161
162#
163# Code maturity level options
164#
165CONFIG_EXPERIMENTAL=y
166CONFIG_BROKEN_ON_SMP=y
167CONFIG_INIT_ENV_ARG_LIMIT=32
168
169#
170# General setup
171#
172CONFIG_LOCALVERSION=""
173CONFIG_LOCALVERSION_AUTO=y
174CONFIG_SWAP=y
175CONFIG_SYSVIPC=y
176# CONFIG_IPC_NS is not set
177CONFIG_SYSVIPC_SYSCTL=y
178# CONFIG_POSIX_MQUEUE is not set
179# CONFIG_BSD_PROCESS_ACCT is not set
180# CONFIG_TASKSTATS is not set
181# CONFIG_UTS_NS is not set
182# CONFIG_AUDIT is not set
183# CONFIG_IKCONFIG is not set
184CONFIG_SYSFS_DEPRECATED=y
185CONFIG_RELAY=y
186# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
187CONFIG_SYSCTL=y
188CONFIG_EMBEDDED=y
189CONFIG_SYSCTL_SYSCALL=y
190CONFIG_KALLSYMS=y
191# CONFIG_KALLSYMS_EXTRA_PASS is not set
192# CONFIG_HOTPLUG is not set
193CONFIG_PRINTK=y
194CONFIG_BUG=y
195CONFIG_ELF_CORE=y
196CONFIG_BASE_FULL=y
197CONFIG_FUTEX=y
198CONFIG_EPOLL=y
199CONFIG_SHMEM=y
200CONFIG_SLAB=y
201CONFIG_VM_EVENT_COUNTERS=y
202CONFIG_RT_MUTEXES=y
203# CONFIG_TINY_SHMEM is not set
204CONFIG_BASE_SMALL=0
205# CONFIG_SLOB is not set
206
207#
208# Loadable module support
209#
210# CONFIG_MODULES is not set
211
212#
213# Block layer
214#
215CONFIG_BLOCK=y
216# CONFIG_LBD is not set
217# CONFIG_BLK_DEV_IO_TRACE is not set
218# CONFIG_LSF is not set
219
220#
221# IO Schedulers
222#
223CONFIG_IOSCHED_NOOP=y
224CONFIG_IOSCHED_AS=y
225CONFIG_IOSCHED_DEADLINE=y
226CONFIG_IOSCHED_CFQ=y
227CONFIG_DEFAULT_AS=y
228# CONFIG_DEFAULT_DEADLINE is not set
229# CONFIG_DEFAULT_CFQ is not set
230# CONFIG_DEFAULT_NOOP is not set
231CONFIG_DEFAULT_IOSCHED="anticipatory"
232
233#
234# Bus options (PCI, PCMCIA, EISA, ISA, TC)
235#
236CONFIG_HW_HAS_PCI=y
237# CONFIG_PCI is not set
238CONFIG_MMU=y
239
240#
241# PCCARD (PCMCIA/CardBus) support
242#
243
244#
245# PCI Hotplug Support
246#
247
248#
249# Executable file formats
250#
251CONFIG_BINFMT_ELF=y
252# CONFIG_BINFMT_MISC is not set
253CONFIG_TRAD_SIGNALS=y
254
255#
256# Power management options
257#
258CONFIG_PM=y
259# CONFIG_PM_LEGACY is not set
260# CONFIG_PM_DEBUG is not set
261# CONFIG_PM_SYSFS_DEPRECATED is not set
262
263#
264# Networking
265#
266CONFIG_NET=y
267
268#
269# Networking options
270#
271# CONFIG_NETDEBUG is not set
272# CONFIG_PACKET is not set
273CONFIG_UNIX=y
274CONFIG_XFRM=y
275CONFIG_XFRM_USER=y
276# CONFIG_XFRM_SUB_POLICY is not set
277CONFIG_XFRM_MIGRATE=y
278CONFIG_NET_KEY=y
279CONFIG_NET_KEY_MIGRATE=y
280CONFIG_INET=y
281# CONFIG_IP_MULTICAST is not set
282# CONFIG_IP_ADVANCED_ROUTER is not set
283CONFIG_IP_FIB_HASH=y
284CONFIG_IP_PNP=y
285# CONFIG_IP_PNP_DHCP is not set
286CONFIG_IP_PNP_BOOTP=y
287# CONFIG_IP_PNP_RARP is not set
288# CONFIG_NET_IPIP is not set
289# CONFIG_NET_IPGRE is not set
290# CONFIG_ARPD is not set
291# CONFIG_SYN_COOKIES is not set
292# CONFIG_INET_AH is not set
293# CONFIG_INET_ESP is not set
294# CONFIG_INET_IPCOMP is not set
295# CONFIG_INET_XFRM_TUNNEL is not set
296# CONFIG_INET_TUNNEL is not set
297CONFIG_INET_XFRM_MODE_TRANSPORT=y
298CONFIG_INET_XFRM_MODE_TUNNEL=y
299CONFIG_INET_XFRM_MODE_BEET=y
300CONFIG_INET_DIAG=y
301CONFIG_INET_TCP_DIAG=y
302# CONFIG_TCP_CONG_ADVANCED is not set
303CONFIG_TCP_CONG_CUBIC=y
304CONFIG_DEFAULT_TCP_CONG="cubic"
305CONFIG_TCP_MD5SIG=y
306# CONFIG_IPV6 is not set
307# CONFIG_INET6_XFRM_TUNNEL is not set
308# CONFIG_INET6_TUNNEL is not set
309CONFIG_NETWORK_SECMARK=y
310# CONFIG_NETFILTER is not set
311
312#
313# DCCP Configuration (EXPERIMENTAL)
314#
315# CONFIG_IP_DCCP is not set
316
317#
318# SCTP Configuration (EXPERIMENTAL)
319#
320# CONFIG_IP_SCTP is not set
321
322#
323# TIPC Configuration (EXPERIMENTAL)
324#
325# CONFIG_TIPC is not set
326# CONFIG_ATM is not set
327# CONFIG_BRIDGE is not set
328# CONFIG_VLAN_8021Q is not set
329# CONFIG_DECNET is not set
330# CONFIG_LLC2 is not set
331# CONFIG_IPX is not set
332# CONFIG_ATALK is not set
333# CONFIG_X25 is not set
334# CONFIG_LAPB is not set
335# CONFIG_ECONET is not set
336# CONFIG_WAN_ROUTER is not set
337
338#
339# QoS and/or fair queueing
340#
341# CONFIG_NET_SCHED is not set
342
343#
344# Network testing
345#
346# CONFIG_NET_PKTGEN is not set
347# CONFIG_HAMRADIO is not set
348# CONFIG_IRDA is not set
349# CONFIG_BT is not set
350CONFIG_IEEE80211=y
351# CONFIG_IEEE80211_DEBUG is not set
352CONFIG_IEEE80211_CRYPT_WEP=y
353CONFIG_IEEE80211_CRYPT_CCMP=y
354CONFIG_IEEE80211_SOFTMAC=y
355# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set
356CONFIG_WIRELESS_EXT=y
357
358#
359# Device Drivers
360#
361
362#
363# Generic Driver Options
364#
365CONFIG_STANDALONE=y
366CONFIG_PREVENT_FIRMWARE_BUILD=y
367# CONFIG_SYS_HYPERVISOR is not set
368
369#
370# Connector - unified userspace <-> kernelspace linker
371#
372CONFIG_CONNECTOR=y
373CONFIG_PROC_EVENTS=y
374
375#
376# Memory Technology Devices (MTD)
377#
378# CONFIG_MTD is not set
379
380#
381# Parallel port support
382#
383# CONFIG_PARPORT is not set
384
385#
386# Plug and Play support
387#
388# CONFIG_PNPACPI is not set
389
390#
391# Block devices
392#
393# CONFIG_BLK_DEV_COW_COMMON is not set
394# CONFIG_BLK_DEV_LOOP is not set
395# CONFIG_BLK_DEV_NBD is not set
396# CONFIG_BLK_DEV_RAM is not set
397# CONFIG_BLK_DEV_INITRD is not set
398CONFIG_CDROM_PKTCDVD=y
399CONFIG_CDROM_PKTCDVD_BUFFERS=8
400# CONFIG_CDROM_PKTCDVD_WCACHE is not set
401CONFIG_ATA_OVER_ETH=y
402
403#
404# Misc devices
405#
406
407#
408# ATA/ATAPI/MFM/RLL support
409#
410# CONFIG_IDE is not set
411
412#
413# SCSI device support
414#
415CONFIG_RAID_ATTRS=y
416# CONFIG_SCSI is not set
417# CONFIG_SCSI_NETLINK is not set
418
419#
420# Serial ATA (prod) and Parallel ATA (experimental) drivers
421#
422# CONFIG_ATA is not set
423
424#
425# Multi-device support (RAID and LVM)
426#
427# CONFIG_MD is not set
428
429#
430# Fusion MPT device support
431#
432# CONFIG_FUSION is not set
433
434#
435# IEEE 1394 (FireWire) support
436#
437
438#
439# I2O device support
440#
441
442#
443# Network device support
444#
445CONFIG_NETDEVICES=y
446# CONFIG_DUMMY is not set
447# CONFIG_BONDING is not set
448# CONFIG_EQUALIZER is not set
449# CONFIG_TUN is not set
450
451#
452# PHY device support
453#
454CONFIG_PHYLIB=y
455
456#
457# MII PHY device drivers
458#
459CONFIG_MARVELL_PHY=y
460CONFIG_DAVICOM_PHY=y
461CONFIG_QSEMI_PHY=y
462CONFIG_LXT_PHY=y
463CONFIG_CICADA_PHY=y
464CONFIG_VITESSE_PHY=y
465CONFIG_SMSC_PHY=y
466# CONFIG_BROADCOM_PHY is not set
467# CONFIG_FIXED_PHY is not set
468
469#
470# Ethernet (10 or 100Mbit)
471#
472CONFIG_NET_ETHERNET=y
473# CONFIG_MII is not set
474# CONFIG_DM9000 is not set
475
476#
477# Ethernet (1000 Mbit)
478#
479
480#
481# Ethernet (10000 Mbit)
482#
483
484#
485# Token Ring devices
486#
487
488#
489# Wireless LAN (non-hamradio)
490#
491# CONFIG_NET_RADIO is not set
492
493#
494# Wan interfaces
495#
496# CONFIG_WAN is not set
497# CONFIG_PPP is not set
498# CONFIG_SLIP is not set
499# CONFIG_SHAPER is not set
500# CONFIG_NETCONSOLE is not set
501# CONFIG_NETPOLL is not set
502# CONFIG_NET_POLL_CONTROLLER is not set
503
504#
505# ISDN subsystem
506#
507# CONFIG_ISDN is not set
508
509#
510# Telephony Support
511#
512# CONFIG_PHONE is not set
513
514#
515# Input device support
516#
517CONFIG_INPUT=y
518# CONFIG_INPUT_FF_MEMLESS is not set
519
520#
521# Userland interfaces
522#
523CONFIG_INPUT_MOUSEDEV=y
524CONFIG_INPUT_MOUSEDEV_PSAUX=y
525CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
526CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
527# CONFIG_INPUT_JOYDEV is not set
528# CONFIG_INPUT_TSDEV is not set
529# CONFIG_INPUT_EVDEV is not set
530# CONFIG_INPUT_EVBUG is not set
531
532#
533# Input Device Drivers
534#
535# CONFIG_INPUT_KEYBOARD is not set
536# CONFIG_INPUT_MOUSE is not set
537# CONFIG_INPUT_JOYSTICK is not set
538# CONFIG_INPUT_TOUCHSCREEN is not set
539# CONFIG_INPUT_MISC is not set
540
541#
542# Hardware I/O ports
543#
544CONFIG_SERIO=y
545# CONFIG_SERIO_I8042 is not set
546CONFIG_SERIO_SERPORT=y
547# CONFIG_SERIO_LIBPS2 is not set
548CONFIG_SERIO_RAW=y
549# CONFIG_GAMEPORT is not set
550
551#
552# Character devices
553#
554CONFIG_VT=y
555CONFIG_VT_CONSOLE=y
556CONFIG_HW_CONSOLE=y
557CONFIG_VT_HW_CONSOLE_BINDING=y
558# CONFIG_SERIAL_NONSTANDARD is not set
559
560#
561# Serial drivers
562#
563CONFIG_SERIAL_8250=y
564CONFIG_SERIAL_8250_CONSOLE=y
565CONFIG_SERIAL_8250_NR_UARTS=4
566CONFIG_SERIAL_8250_RUNTIME_UARTS=4
567# CONFIG_SERIAL_8250_EXTENDED is not set
568
569#
570# Non-8250 serial port support
571#
572CONFIG_SERIAL_CORE=y
573CONFIG_SERIAL_CORE_CONSOLE=y
574CONFIG_UNIX98_PTYS=y
575CONFIG_LEGACY_PTYS=y
576CONFIG_LEGACY_PTY_COUNT=256
577
578#
579# IPMI
580#
581# CONFIG_IPMI_HANDLER is not set
582
583#
584# Watchdog Cards
585#
586# CONFIG_WATCHDOG is not set
587# CONFIG_HW_RANDOM is not set
588# CONFIG_RTC is not set
589# CONFIG_GEN_RTC is not set
590# CONFIG_DTLK is not set
591# CONFIG_R3964 is not set
592# CONFIG_RAW_DRIVER is not set
593
594#
595# TPM devices
596#
597# CONFIG_TCG_TPM is not set
598
599#
600# I2C support
601#
602# CONFIG_I2C is not set
603
604#
605# SPI support
606#
607# CONFIG_SPI is not set
608# CONFIG_SPI_MASTER is not set
609
610#
611# Dallas's 1-wire bus
612#
613# CONFIG_W1 is not set
614
615#
616# Hardware Monitoring support
617#
618# CONFIG_HWMON is not set
619# CONFIG_HWMON_VID is not set
620
621#
622# Multimedia devices
623#
624# CONFIG_VIDEO_DEV is not set
625
626#
627# Digital Video Broadcasting Devices
628#
629# CONFIG_DVB is not set
630
631#
632# Graphics support
633#
634# CONFIG_FIRMWARE_EDID is not set
635# CONFIG_FB is not set
636
637#
638# Console display driver support
639#
640# CONFIG_VGA_CONSOLE is not set
641CONFIG_DUMMY_CONSOLE=y
642# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
643
644#
645# Sound
646#
647# CONFIG_SOUND is not set
648
649#
650# HID Devices
651#
652# CONFIG_HID is not set
653
654#
655# USB support
656#
657# CONFIG_USB_ARCH_HAS_HCD is not set
658# CONFIG_USB_ARCH_HAS_OHCI is not set
659# CONFIG_USB_ARCH_HAS_EHCI is not set
660
661#
662# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
663#
664
665#
666# USB Gadget Support
667#
668# CONFIG_USB_GADGET is not set
669
670#
671# MMC/SD Card support
672#
673# CONFIG_MMC is not set
674
675#
676# LED devices
677#
678# CONFIG_NEW_LEDS is not set
679
680#
681# LED drivers
682#
683
684#
685# LED Triggers
686#
687
688#
689# InfiniBand support
690#
691
692#
693# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
694#
695
696#
697# Real Time Clock
698#
699# CONFIG_RTC_CLASS is not set
700
701#
702# DMA Engine support
703#
704# CONFIG_DMA_ENGINE is not set
705
706#
707# DMA Clients
708#
709
710#
711# DMA Devices
712#
713
714#
715# Auxiliary Display support
716#
717
718#
719# Virtualization
720#
721
722#
723# File systems
724#
725CONFIG_EXT2_FS=y
726# CONFIG_EXT2_FS_XATTR is not set
727# CONFIG_EXT2_FS_XIP is not set
728# CONFIG_EXT3_FS is not set
729# CONFIG_EXT4DEV_FS is not set
730# CONFIG_REISERFS_FS is not set
731# CONFIG_JFS_FS is not set
732CONFIG_FS_POSIX_ACL=y
733# CONFIG_XFS_FS is not set
734# CONFIG_GFS2_FS is not set
735# CONFIG_OCFS2_FS is not set
736# CONFIG_MINIX_FS is not set
737# CONFIG_ROMFS_FS is not set
738CONFIG_INOTIFY=y
739CONFIG_INOTIFY_USER=y
740# CONFIG_QUOTA is not set
741CONFIG_DNOTIFY=y
742# CONFIG_AUTOFS_FS is not set
743# CONFIG_AUTOFS4_FS is not set
744CONFIG_FUSE_FS=y
745CONFIG_GENERIC_ACL=y
746
747#
748# CD-ROM/DVD Filesystems
749#
750# CONFIG_ISO9660_FS is not set
751# CONFIG_UDF_FS is not set
752
753#
754# DOS/FAT/NT Filesystems
755#
756# CONFIG_MSDOS_FS is not set
757# CONFIG_VFAT_FS is not set
758# CONFIG_NTFS_FS is not set
759
760#
761# Pseudo filesystems
762#
763CONFIG_PROC_FS=y
764CONFIG_PROC_KCORE=y
765CONFIG_PROC_SYSCTL=y
766CONFIG_SYSFS=y
767CONFIG_TMPFS=y
768CONFIG_TMPFS_POSIX_ACL=y
769# CONFIG_HUGETLB_PAGE is not set
770CONFIG_RAMFS=y
771CONFIG_CONFIGFS_FS=y
772
773#
774# Miscellaneous filesystems
775#
776# CONFIG_ADFS_FS is not set
777# CONFIG_AFFS_FS is not set
778# CONFIG_ECRYPT_FS is not set
779# CONFIG_HFS_FS is not set
780# CONFIG_HFSPLUS_FS is not set
781# CONFIG_BEFS_FS is not set
782# CONFIG_BFS_FS is not set
783# CONFIG_EFS_FS is not set
784# CONFIG_CRAMFS is not set
785# CONFIG_VXFS_FS is not set
786# CONFIG_HPFS_FS is not set
787# CONFIG_QNX4FS_FS is not set
788# CONFIG_SYSV_FS is not set
789# CONFIG_UFS_FS is not set
790
791#
792# Network File Systems
793#
794CONFIG_NFS_FS=y
795# CONFIG_NFS_V3 is not set
796# CONFIG_NFS_V4 is not set
797# CONFIG_NFS_DIRECTIO is not set
798CONFIG_NFSD=y
799# CONFIG_NFSD_V3 is not set
800# CONFIG_NFSD_TCP is not set
801CONFIG_ROOT_NFS=y
802CONFIG_LOCKD=y
803CONFIG_EXPORTFS=y
804CONFIG_NFS_COMMON=y
805CONFIG_SUNRPC=y
806# CONFIG_RPCSEC_GSS_KRB5 is not set
807# CONFIG_RPCSEC_GSS_SPKM3 is not set
808# CONFIG_SMB_FS is not set
809# CONFIG_CIFS is not set
810# CONFIG_NCP_FS is not set
811# CONFIG_CODA_FS is not set
812# CONFIG_AFS_FS is not set
813# CONFIG_9P_FS is not set
814
815#
816# Partition Types
817#
818# CONFIG_PARTITION_ADVANCED is not set
819CONFIG_MSDOS_PARTITION=y
820
821#
822# Native Language Support
823#
824# CONFIG_NLS is not set
825
826#
827# Distributed Lock Manager
828#
829CONFIG_DLM=y
830CONFIG_DLM_TCP=y
831# CONFIG_DLM_SCTP is not set
832# CONFIG_DLM_DEBUG is not set
833
834#
835# Profiling support
836#
837# CONFIG_PROFILING is not set
838
839#
840# Kernel hacking
841#
842CONFIG_TRACE_IRQFLAGS_SUPPORT=y
843# CONFIG_PRINTK_TIME is not set
844CONFIG_ENABLE_MUST_CHECK=y
845# CONFIG_MAGIC_SYSRQ is not set
846# CONFIG_UNUSED_SYMBOLS is not set
847# CONFIG_DEBUG_FS is not set
848# CONFIG_HEADERS_CHECK is not set
849# CONFIG_DEBUG_KERNEL is not set
850CONFIG_LOG_BUF_SHIFT=14
851CONFIG_CROSSCOMPILE=y
852CONFIG_CMDLINE=""
853CONFIG_SYS_SUPPORTS_KGDB=y
854
855#
856# Security options
857#
858CONFIG_KEYS=y
859CONFIG_KEYS_DEBUG_PROC_KEYS=y
860# CONFIG_SECURITY is not set
861
862#
863# Cryptographic options
864#
865CONFIG_CRYPTO=y
866CONFIG_CRYPTO_ALGAPI=y
867CONFIG_CRYPTO_BLKCIPHER=y
868CONFIG_CRYPTO_HASH=y
869CONFIG_CRYPTO_MANAGER=y
870CONFIG_CRYPTO_HMAC=y
871CONFIG_CRYPTO_XCBC=y
872CONFIG_CRYPTO_NULL=y
873CONFIG_CRYPTO_MD4=y
874CONFIG_CRYPTO_MD5=y
875CONFIG_CRYPTO_SHA1=y
876CONFIG_CRYPTO_SHA256=y
877CONFIG_CRYPTO_SHA512=y
878CONFIG_CRYPTO_WP512=y
879CONFIG_CRYPTO_TGR192=y
880CONFIG_CRYPTO_GF128MUL=y
881CONFIG_CRYPTO_ECB=y
882CONFIG_CRYPTO_CBC=y
883CONFIG_CRYPTO_PCBC=y
884CONFIG_CRYPTO_LRW=y
885CONFIG_CRYPTO_DES=y
886CONFIG_CRYPTO_FCRYPT=y
887CONFIG_CRYPTO_BLOWFISH=y
888CONFIG_CRYPTO_TWOFISH=y
889CONFIG_CRYPTO_TWOFISH_COMMON=y
890CONFIG_CRYPTO_SERPENT=y
891CONFIG_CRYPTO_AES=y
892CONFIG_CRYPTO_CAST5=y
893CONFIG_CRYPTO_CAST6=y
894CONFIG_CRYPTO_TEA=y
895CONFIG_CRYPTO_ARC4=y
896CONFIG_CRYPTO_KHAZAD=y
897CONFIG_CRYPTO_ANUBIS=y
898CONFIG_CRYPTO_DEFLATE=y
899CONFIG_CRYPTO_MICHAEL_MIC=y
900CONFIG_CRYPTO_CRC32C=y
901CONFIG_CRYPTO_CAMELLIA=y
902
903#
904# Hardware crypto devices
905#
906
907#
908# Library routines
909#
910CONFIG_BITREVERSE=y
911# CONFIG_CRC_CCITT is not set
912CONFIG_CRC16=y
913CONFIG_CRC32=y
914CONFIG_LIBCRC32C=y
915CONFIG_ZLIB_INFLATE=y
916CONFIG_ZLIB_DEFLATE=y
917CONFIG_PLIST=y
918CONFIG_HAS_IOMEM=y
919CONFIG_HAS_IOPORT=y
diff --git a/arch/mips/configs/pb1100_defconfig b/arch/mips/configs/pb1100_defconfig
index 0028aef0af9d..d53fa8f8e099 100644
--- a/arch/mips/configs/pb1100_defconfig
+++ b/arch/mips/configs/pb1100_defconfig
@@ -33,12 +33,9 @@ CONFIG_MIPS_PB1100=y
33# CONFIG_WR_PPMC is not set 33# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 34# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 35# CONFIG_MOMENCO_JAGUAR_ATX is not set
36# CONFIG_MOMENCO_OCELOT is not set
37# CONFIG_MOMENCO_OCELOT_G is not set
38# CONFIG_MIPS_XXS1500 is not set 36# CONFIG_MIPS_XXS1500 is not set
39# CONFIG_PNX8550_JBS is not set 37# CONFIG_PNX8550_JBS is not set
40# CONFIG_PNX8550_STB810 is not set 38# CONFIG_PNX8550_STB810 is not set
41# CONFIG_DDB5477 is not set
42# CONFIG_MACH_VR41XX is not set 39# CONFIG_MACH_VR41XX is not set
43# CONFIG_PMC_YOSEMITE is not set 40# CONFIG_PMC_YOSEMITE is not set
44# CONFIG_QEMU is not set 41# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/pb1500_defconfig b/arch/mips/configs/pb1500_defconfig
index 8a1d5888739c..dc4aa0c66847 100644
--- a/arch/mips/configs/pb1500_defconfig
+++ b/arch/mips/configs/pb1500_defconfig
@@ -33,12 +33,9 @@ CONFIG_MIPS_PB1500=y
33# CONFIG_WR_PPMC is not set 33# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 34# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 35# CONFIG_MOMENCO_JAGUAR_ATX is not set
36# CONFIG_MOMENCO_OCELOT is not set
37# CONFIG_MOMENCO_OCELOT_G is not set
38# CONFIG_MIPS_XXS1500 is not set 36# CONFIG_MIPS_XXS1500 is not set
39# CONFIG_PNX8550_JBS is not set 37# CONFIG_PNX8550_JBS is not set
40# CONFIG_PNX8550_STB810 is not set 38# CONFIG_PNX8550_STB810 is not set
41# CONFIG_DDB5477 is not set
42# CONFIG_MACH_VR41XX is not set 39# CONFIG_MACH_VR41XX is not set
43# CONFIG_PMC_YOSEMITE is not set 40# CONFIG_PMC_YOSEMITE is not set
44# CONFIG_QEMU is not set 41# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/pb1550_defconfig b/arch/mips/configs/pb1550_defconfig
index 5581ad2ca411..24428e13002b 100644
--- a/arch/mips/configs/pb1550_defconfig
+++ b/arch/mips/configs/pb1550_defconfig
@@ -33,12 +33,9 @@ CONFIG_MIPS_PB1550=y
33# CONFIG_WR_PPMC is not set 33# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 34# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 35# CONFIG_MOMENCO_JAGUAR_ATX is not set
36# CONFIG_MOMENCO_OCELOT is not set
37# CONFIG_MOMENCO_OCELOT_G is not set
38# CONFIG_MIPS_XXS1500 is not set 36# CONFIG_MIPS_XXS1500 is not set
39# CONFIG_PNX8550_JBS is not set 37# CONFIG_PNX8550_JBS is not set
40# CONFIG_PNX8550_STB810 is not set 38# CONFIG_PNX8550_STB810 is not set
41# CONFIG_DDB5477 is not set
42# CONFIG_MACH_VR41XX is not set 39# CONFIG_MACH_VR41XX is not set
43# CONFIG_PMC_YOSEMITE is not set 40# CONFIG_PMC_YOSEMITE is not set
44# CONFIG_QEMU is not set 41# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/pnx8550-jbs_defconfig b/arch/mips/configs/pnx8550-jbs_defconfig
index 821c1cee5639..f6906b069e04 100644
--- a/arch/mips/configs/pnx8550-jbs_defconfig
+++ b/arch/mips/configs/pnx8550-jbs_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38CONFIG_PNX8550_JBS=y 36CONFIG_PNX8550_JBS=y
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/pnx8550-stb810_defconfig b/arch/mips/configs/pnx8550-stb810_defconfig
index 0e8bd92b38cf..b741f81696fb 100644
--- a/arch/mips/configs/pnx8550-stb810_defconfig
+++ b/arch/mips/configs/pnx8550-stb810_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39CONFIG_PNX8550_STB810=y 37CONFIG_PNX8550_STB810=y
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/qemu_defconfig b/arch/mips/configs/qemu_defconfig
index 703de002e372..b3caf5125c15 100644
--- a/arch/mips/configs/qemu_defconfig
+++ b/arch/mips/configs/qemu_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43CONFIG_QEMU=y 40CONFIG_QEMU=y
diff --git a/arch/mips/configs/rbhma4200_defconfig b/arch/mips/configs/rbhma4200_defconfig
index 20a38526d483..9913980add21 100644
--- a/arch/mips/configs/rbhma4200_defconfig
+++ b/arch/mips/configs/rbhma4200_defconfig
@@ -30,11 +30,9 @@ CONFIG_MIPS=y
30# CONFIG_MIPS_SEAD is not set 30# CONFIG_MIPS_SEAD is not set
31# CONFIG_WR_PPMC is not set 31# CONFIG_WR_PPMC is not set
32# CONFIG_MIPS_SIM is not set 32# CONFIG_MIPS_SIM is not set
33# CONFIG_MOMENCO_OCELOT is not set
34# CONFIG_MIPS_XXS1500 is not set 33# CONFIG_MIPS_XXS1500 is not set
35# CONFIG_PNX8550_JBS is not set 34# CONFIG_PNX8550_JBS is not set
36# CONFIG_PNX8550_STB810 is not set 35# CONFIG_PNX8550_STB810 is not set
37# CONFIG_DDB5477 is not set
38# CONFIG_MACH_VR41XX is not set 36# CONFIG_MACH_VR41XX is not set
39# CONFIG_PMC_YOSEMITE is not set 37# CONFIG_PMC_YOSEMITE is not set
40# CONFIG_QEMU is not set 38# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/rbhma4500_defconfig b/arch/mips/configs/rbhma4500_defconfig
index 5dbb250f71c7..40453cd7c70e 100644
--- a/arch/mips/configs/rbhma4500_defconfig
+++ b/arch/mips/configs/rbhma4500_defconfig
@@ -20,10 +20,8 @@ CONFIG_ZONE_DMA=y
20# CONFIG_MIPS_SEAD is not set 20# CONFIG_MIPS_SEAD is not set
21# CONFIG_WR_PPMC is not set 21# CONFIG_WR_PPMC is not set
22# CONFIG_MIPS_SIM is not set 22# CONFIG_MIPS_SIM is not set
23# CONFIG_MOMENCO_OCELOT is not set
24# CONFIG_PNX8550_JBS is not set 23# CONFIG_PNX8550_JBS is not set
25# CONFIG_PNX8550_STB810 is not set 24# CONFIG_PNX8550_STB810 is not set
26# CONFIG_DDB5477 is not set
27# CONFIG_MACH_VR41XX is not set 25# CONFIG_MACH_VR41XX is not set
28# CONFIG_PMC_MSP is not set 26# CONFIG_PMC_MSP is not set
29# CONFIG_PMC_YOSEMITE is not set 27# CONFIG_PMC_YOSEMITE is not set
diff --git a/arch/mips/configs/rm200_defconfig b/arch/mips/configs/rm200_defconfig
index a5dc5cb97aae..fc388118b114 100644
--- a/arch/mips/configs/rm200_defconfig
+++ b/arch/mips/configs/rm200_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/sb1250-swarm_defconfig b/arch/mips/configs/sb1250-swarm_defconfig
index 98a914092258..e72fdf36b3fe 100644
--- a/arch/mips/configs/sb1250-swarm_defconfig
+++ b/arch/mips/configs/sb1250-swarm_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/sead_defconfig b/arch/mips/configs/sead_defconfig
index 69c08b24c82a..2b6282d132a8 100644
--- a/arch/mips/configs/sead_defconfig
+++ b/arch/mips/configs/sead_defconfig
@@ -32,12 +32,9 @@ CONFIG_MIPS_SEAD=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/tb0219_defconfig b/arch/mips/configs/tb0219_defconfig
index 5d4fc0e4f729..e9f2cef4c716 100644
--- a/arch/mips/configs/tb0219_defconfig
+++ b/arch/mips/configs/tb0219_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41CONFIG_MACH_VR41XX=y 38CONFIG_MACH_VR41XX=y
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/tb0226_defconfig b/arch/mips/configs/tb0226_defconfig
index 1b92b48de051..aea67568842a 100644
--- a/arch/mips/configs/tb0226_defconfig
+++ b/arch/mips/configs/tb0226_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41CONFIG_MACH_VR41XX=y 38CONFIG_MACH_VR41XX=y
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/tb0287_defconfig b/arch/mips/configs/tb0287_defconfig
index 5b77c7a5d83a..66383ecff200 100644
--- a/arch/mips/configs/tb0287_defconfig
+++ b/arch/mips/configs/tb0287_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41CONFIG_MACH_VR41XX=y 38CONFIG_MACH_VR41XX=y
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/workpad_defconfig b/arch/mips/configs/workpad_defconfig
index 94a4f94a8b24..db6fd4f15719 100644
--- a/arch/mips/configs/workpad_defconfig
+++ b/arch/mips/configs/workpad_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41CONFIG_MACH_VR41XX=y 38CONFIG_MACH_VR41XX=y
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/wrppmc_defconfig b/arch/mips/configs/wrppmc_defconfig
index e38bd9b0eadc..7e410e10fed7 100644
--- a/arch/mips/configs/wrppmc_defconfig
+++ b/arch/mips/configs/wrppmc_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32CONFIG_WR_PPMC=y 32CONFIG_WR_PPMC=y
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/configs/yosemite_defconfig b/arch/mips/configs/yosemite_defconfig
index f342d8c887b8..acaf0e21bb00 100644
--- a/arch/mips/configs/yosemite_defconfig
+++ b/arch/mips/configs/yosemite_defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42CONFIG_PMC_YOSEMITE=y 39CONFIG_PMC_YOSEMITE=y
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/ddb5xxx/Kconfig b/arch/mips/ddb5xxx/Kconfig
deleted file mode 100644
index e9b5de49f4c2..000000000000
--- a/arch/mips/ddb5xxx/Kconfig
+++ /dev/null
@@ -1,4 +0,0 @@
1config DDB5477_BUS_FREQUENCY
2 int "bus frequency (in kHZ, 0 for auto-detect)"
3 depends on DDB5477
4 default 0
diff --git a/arch/mips/ddb5xxx/common/Makefile b/arch/mips/ddb5xxx/common/Makefile
deleted file mode 100644
index bc44e3032711..000000000000
--- a/arch/mips/ddb5xxx/common/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for the common code of NEC DDB-Vrc5xxx board
3#
4
5obj-y += nile4.o prom.o rtc_ds1386.o
diff --git a/arch/mips/ddb5xxx/common/nile4.c b/arch/mips/ddb5xxx/common/nile4.c
deleted file mode 100644
index 7ec7d903ba97..000000000000
--- a/arch/mips/ddb5xxx/common/nile4.c
+++ /dev/null
@@ -1,130 +0,0 @@
1/*
2 *
3 * Copyright 2001 MontaVista Software Inc.
4 * Author: jsun@mvista.com or jsun@junsun.net
5 *
6 * arch/mips/ddb5xxx/common/nile4.c
7 * misc low-level routines for vrc-5xxx controllers.
8 *
9 * derived from original code by Geert Uytterhoeven <geert@sonycom.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 */
16#include <linux/types.h>
17#include <linux/kernel.h>
18
19#include <asm/ddb5xxx/ddb5xxx.h>
20
21u32
22ddb_calc_pdar(u32 phys, u32 size, int width,
23 int on_memory_bus, int pci_visible)
24{
25 u32 maskbits;
26 u32 widthbits;
27
28 switch (size) {
29#if 0 /* We don't support 4 GB yet */
30 case 0x100000000: /* 4 GB */
31 maskbits = 4;
32 break;
33#endif
34 case 0x80000000: /* 2 GB */
35 maskbits = 5;
36 break;
37 case 0x40000000: /* 1 GB */
38 maskbits = 6;
39 break;
40 case 0x20000000: /* 512 MB */
41 maskbits = 7;
42 break;
43 case 0x10000000: /* 256 MB */
44 maskbits = 8;
45 break;
46 case 0x08000000: /* 128 MB */
47 maskbits = 9;
48 break;
49 case 0x04000000: /* 64 MB */
50 maskbits = 10;
51 break;
52 case 0x02000000: /* 32 MB */
53 maskbits = 11;
54 break;
55 case 0x01000000: /* 16 MB */
56 maskbits = 12;
57 break;
58 case 0x00800000: /* 8 MB */
59 maskbits = 13;
60 break;
61 case 0x00400000: /* 4 MB */
62 maskbits = 14;
63 break;
64 case 0x00200000: /* 2 MB */
65 maskbits = 15;
66 break;
67 case 0: /* OFF */
68 maskbits = 0;
69 break;
70 default:
71 panic("nile4_set_pdar: unsupported size %p", (void *) size);
72 }
73 switch (width) {
74 case 8:
75 widthbits = 0;
76 break;
77 case 16:
78 widthbits = 1;
79 break;
80 case 32:
81 widthbits = 2;
82 break;
83 case 64:
84 widthbits = 3;
85 break;
86 default:
87 panic("nile4_set_pdar: unsupported width %d", width);
88 }
89
90 return maskbits | (on_memory_bus ? 0x10 : 0) |
91 (pci_visible ? 0x20 : 0) | (widthbits << 6) |
92 (phys & 0xffe00000);
93}
94
95void
96ddb_set_pdar(u32 pdar, u32 phys, u32 size, int width,
97 int on_memory_bus, int pci_visible)
98{
99 u32 temp= ddb_calc_pdar(phys, size, width, on_memory_bus, pci_visible);
100 ddb_out32(pdar, temp);
101 ddb_out32(pdar + 4, 0);
102
103 /*
104 * When programming a PDAR, the register should be read immediately
105 * after writing it. This ensures that address decoders are properly
106 * configured.
107 * [jsun] is this really necessary?
108 */
109 ddb_in32(pdar);
110 ddb_in32(pdar + 4);
111}
112
113/*
114 * routines that mess with PCIINITx registers
115 */
116
117void ddb_set_pmr(u32 pmr, u32 type, u32 addr, u32 options)
118{
119 switch (type) {
120 case DDB_PCICMD_IACK: /* PCI Interrupt Acknowledge */
121 case DDB_PCICMD_IO: /* PCI I/O Space */
122 case DDB_PCICMD_MEM: /* PCI Memory Space */
123 case DDB_PCICMD_CFG: /* PCI Configuration Space */
124 break;
125 default:
126 panic("nile4_set_pmr: invalid type %d", type);
127 }
128 ddb_out32(pmr, (type << 1) | (addr & 0xffe00000) | options );
129 ddb_out32(pmr + 4, 0);
130}
diff --git a/arch/mips/ddb5xxx/common/prom.c b/arch/mips/ddb5xxx/common/prom.c
deleted file mode 100644
index 54a857b5e3ba..000000000000
--- a/arch/mips/ddb5xxx/common/prom.c
+++ /dev/null
@@ -1,132 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: jsun@mvista.com or jsun@junsun.net
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
10#include <linux/init.h>
11#include <linux/mm.h>
12#include <linux/sched.h>
13#include <linux/bootmem.h>
14
15#include <asm/addrspace.h>
16#include <asm/bootinfo.h>
17#include <asm/ddb5xxx/ddb5xxx.h>
18#include <asm/debug.h>
19
20const char *get_system_type(void)
21{
22 switch (mips_machtype) {
23 case MACH_NEC_DDB5477: return "NEC DDB Vrc-5477";
24 case MACH_NEC_ROCKHOPPER: return "NEC Rockhopper";
25 case MACH_NEC_ROCKHOPPERII: return "NEC RockhopperII";
26 default: return "Unknown NEC board";
27 }
28}
29
30#if defined(CONFIG_DDB5477)
31void ddb5477_runtime_detection(void);
32#endif
33
34/* [jsun@junsun.net] PMON passes arguments in C main() style */
35void __init prom_init(void)
36{
37 int argc = fw_arg0;
38 char **arg = (char**) fw_arg1;
39 int i;
40
41 /* if user passes kernel args, ignore the default one */
42 if (argc > 1)
43 arcs_cmdline[0] = '\0';
44
45 /* arg[0] is "g", the rest is boot parameters */
46 for (i = 1; i < argc; i++) {
47 if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
48 >= sizeof(arcs_cmdline))
49 break;
50 strcat(arcs_cmdline, arg[i]);
51 strcat(arcs_cmdline, " ");
52 }
53
54 mips_machgroup = MACH_GROUP_NEC_DDB;
55
56#if defined(CONFIG_DDB5477)
57 ddb5477_runtime_detection();
58 add_memory_region(0, board_ram_size, BOOT_MEM_RAM);
59#endif
60}
61
62void __init prom_free_prom_memory(void)
63{
64}
65
66#if defined(CONFIG_DDB5477)
67
68#define DEFAULT_LCS1_BASE 0x19000000
69#define TESTVAL1 'K'
70#define TESTVAL2 'S'
71
72int board_ram_size;
73void ddb5477_runtime_detection(void)
74{
75 volatile char *test_offset;
76 char saved_test_byte;
77
78 /* Determine if this is a DDB5477 board, or a BSB-VR0300
79 base board. We can tell by checking for the location of
80 the NVRAM. It lives at the beginning of LCS1 on the DDB5477,
81 and the beginning of LCS1 on the BSB-VR0300 is flash memory.
82 The first 2K of the NVRAM are reserved, so don't we'll poke
83 around just after that.
84 */
85
86 /* We can only use the PCI bus to distinquish between
87 the Rockhopper and RockhopperII backplanes and this must
88 wait until ddb5477_board_init() in setup.c after the 5477
89 is initialized. So, until then handle
90 both Rockhopper and RockhopperII backplanes as Rockhopper 1
91 */
92
93 test_offset = (char *)KSEG1ADDR(DEFAULT_LCS1_BASE + 0x800);
94 saved_test_byte = *test_offset;
95
96 *test_offset = TESTVAL1;
97 if (*test_offset != TESTVAL1) {
98 /* We couldn't set our test value, so it must not be NVRAM,
99 so it's a BSB_VR0300 */
100 mips_machtype = MACH_NEC_ROCKHOPPER;
101 } else {
102 /* We may have gotten lucky, and the TESTVAL1 was already
103 stored at the test location, so we must check a second
104 test value */
105 *test_offset = TESTVAL2;
106 if (*test_offset != TESTVAL2) {
107 /* OK, we couldn't set this value either, so it must
108 definately be a BSB_VR0300 */
109 mips_machtype = MACH_NEC_ROCKHOPPER;
110 } else {
111 /* We could change the value twice, so it must be
112 NVRAM, so it's a DDB_VRC5477 */
113 mips_machtype = MACH_NEC_DDB5477;
114 }
115 }
116 /* Restore the original byte */
117 *test_offset = saved_test_byte;
118
119 /* before we know a better way, we will trust PMON for getting
120 * RAM size
121 */
122 board_ram_size = 1 << (36 - (ddb_in32(DDB_SDRAM0) & 0xf));
123
124 db_run(printk("DDB run-time detection : %s, %d MB RAM\n",
125 mips_machtype == MACH_NEC_DDB5477 ?
126 "DDB5477" : "Rockhopper",
127 board_ram_size >> 20));
128
129 /* we can't handle ram size > 128 MB */
130 db_assert(board_ram_size <= (128 << 20));
131}
132#endif
diff --git a/arch/mips/ddb5xxx/common/rtc_ds1386.c b/arch/mips/ddb5xxx/common/rtc_ds1386.c
deleted file mode 100644
index 5dc34daa7150..000000000000
--- a/arch/mips/ddb5xxx/common/rtc_ds1386.c
+++ /dev/null
@@ -1,170 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: jsun@mvista.com or jsun@junsun.net
4 *
5 * arch/mips/ddb5xxx/common/rtc_ds1386.c
6 * low-level RTC hookups for s for Dallas 1396 chip.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14
15/*
16 * This file exports a function, rtc_ds1386_init(), which expects an
17 * uncached base address as the argument. It will set the two function
18 * pointers expected by the MIPS generic timer code.
19 */
20
21#include <linux/types.h>
22#include <linux/time.h>
23#include <linux/bcd.h>
24
25#include <asm/time.h>
26#include <asm/addrspace.h>
27
28#include <asm/mc146818rtc.h>
29#include <asm/debug.h>
30
31#define EPOCH 2000
32
33#define READ_RTC(x) *(volatile unsigned char*)(rtc_base+x)
34#define WRITE_RTC(x, y) *(volatile unsigned char*)(rtc_base+x) = y
35
36static unsigned long rtc_base;
37
38static unsigned long
39rtc_ds1386_get_time(void)
40{
41 u8 byte;
42 u8 temp;
43 unsigned int year, month, day, hour, minute, second;
44 unsigned long flags;
45
46 spin_lock_irqsave(&rtc_lock, flags);
47 /* let us freeze external registers */
48 byte = READ_RTC(0xB);
49 byte &= 0x3f;
50 WRITE_RTC(0xB, byte);
51
52 /* read time data */
53 year = BCD2BIN(READ_RTC(0xA)) + EPOCH;
54 month = BCD2BIN(READ_RTC(0x9) & 0x1f);
55 day = BCD2BIN(READ_RTC(0x8));
56 minute = BCD2BIN(READ_RTC(0x2));
57 second = BCD2BIN(READ_RTC(0x1));
58
59 /* hour is special - deal with it later */
60 temp = READ_RTC(0x4);
61
62 /* enable time transfer */
63 byte |= 0x80;
64 WRITE_RTC(0xB, byte);
65 spin_unlock_irqrestore(&rtc_lock, flags);
66
67 /* calc hour */
68 if (temp & 0x40) {
69 /* 12 hour format */
70 hour = BCD2BIN(temp & 0x1f);
71 if (temp & 0x20) hour += 12; /* PM */
72 } else {
73 /* 24 hour format */
74 hour = BCD2BIN(temp & 0x3f);
75 }
76
77 return mktime(year, month, day, hour, minute, second);
78}
79
80static int
81rtc_ds1386_set_time(unsigned long t)
82{
83 struct rtc_time tm;
84 u8 byte;
85 u8 temp;
86 u8 year, month, day, hour, minute, second;
87 unsigned long flags;
88
89 spin_lock_irqsave(&rtc_lock, flags);
90 /* let us freeze external registers */
91 byte = READ_RTC(0xB);
92 byte &= 0x3f;
93 WRITE_RTC(0xB, byte);
94
95 /* convert */
96 to_tm(t, &tm);
97
98
99 /* check each field one by one */
100 year = BIN2BCD(tm.tm_year - EPOCH);
101 if (year != READ_RTC(0xA)) {
102 WRITE_RTC(0xA, year);
103 }
104
105 temp = READ_RTC(0x9);
106 month = BIN2BCD(tm.tm_mon+1); /* tm_mon starts from 0 to 11 */
107 if (month != (temp & 0x1f)) {
108 WRITE_RTC( 0x9,
109 (month & 0x1f) | (temp & ~0x1f) );
110 }
111
112 day = BIN2BCD(tm.tm_mday);
113 if (day != READ_RTC(0x8)) {
114 WRITE_RTC(0x8, day);
115 }
116
117 temp = READ_RTC(0x4);
118 if (temp & 0x40) {
119 /* 12 hour format */
120 hour = 0x40;
121 if (tm.tm_hour > 12) {
122 hour |= 0x20 | (BIN2BCD(hour-12) & 0x1f);
123 } else {
124 hour |= BIN2BCD(tm.tm_hour);
125 }
126 } else {
127 /* 24 hour format */
128 hour = BIN2BCD(tm.tm_hour) & 0x3f;
129 }
130 if (hour != temp) WRITE_RTC(0x4, hour);
131
132 minute = BIN2BCD(tm.tm_min);
133 if (minute != READ_RTC(0x2)) {
134 WRITE_RTC(0x2, minute);
135 }
136
137 second = BIN2BCD(tm.tm_sec);
138 if (second != READ_RTC(0x1)) {
139 WRITE_RTC(0x1, second);
140 }
141 spin_unlock_irqrestore(&rtc_lock, flags);
142
143 return 0;
144}
145
146void
147rtc_ds1386_init(unsigned long base)
148{
149 unsigned char byte;
150
151 /* remember the base */
152 rtc_base = base;
153 db_assert((rtc_base & 0xe0000000) == KSEG1);
154
155 /* turn on RTC if it is not on */
156 byte = READ_RTC(0x9);
157 if (byte & 0x80) {
158 byte &= 0x7f;
159 WRITE_RTC(0x9, byte);
160 }
161
162 /* enable time transfer */
163 byte = READ_RTC(0xB);
164 byte |= 0x80;
165 WRITE_RTC(0xB, byte);
166
167 /* set the function pointers */
168 rtc_mips_get_time = rtc_ds1386_get_time;
169 rtc_mips_set_time = rtc_ds1386_set_time;
170}
diff --git a/arch/mips/ddb5xxx/ddb5477/Makefile b/arch/mips/ddb5xxx/ddb5477/Makefile
deleted file mode 100644
index 4864b8a659c7..000000000000
--- a/arch/mips/ddb5xxx/ddb5477/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for NEC DDB-Vrc5477 board
3#
4
5obj-y += ddb5477-platform.o irq.o irq_5477.o setup.o \
6 lcd44780.o
7
8obj-$(CONFIG_RUNTIME_DEBUG) += debug.o
9obj-$(CONFIG_KGDB) += kgdb_io.o
diff --git a/arch/mips/ddb5xxx/ddb5477/ddb5477-platform.c b/arch/mips/ddb5xxx/ddb5477/ddb5477-platform.c
deleted file mode 100644
index c16020ad54c2..000000000000
--- a/arch/mips/ddb5xxx/ddb5477/ddb5477-platform.c
+++ /dev/null
@@ -1,49 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
7 */
8#include <linux/init.h>
9#include <linux/module.h>
10#include <linux/serial_8250.h>
11
12#include <asm/ddb5xxx/ddb5477.h>
13
14#define DDB_UART_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP)
15
16#define DDB5477_PORT(base, int) \
17{ \
18 .mapbase = base, \
19 .irq = int, \
20 .uartclk = 1843200, \
21 .iotype = UPIO_MEM, \
22 .flags = DDB_UART_FLAGS, \
23 .regshift = 3, \
24}
25
26static struct plat_serial8250_port uart8250_data[] = {
27 DDB5477_PORT(0xbfa04200, VRC5477_IRQ_UART0),
28 DDB5477_PORT(0xbfa04240, VRC5477_IRQ_UART1),
29 { },
30};
31
32static struct platform_device uart8250_device = {
33 .name = "serial8250",
34 .id = PLAT8250_DEV_PLATFORM,
35 .dev = {
36 .platform_data = uart8250_data,
37 },
38};
39
40static int __init uart8250_init(void)
41{
42 return platform_device_register(&uart8250_device);
43}
44
45module_init(uart8250_init);
46
47MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
48MODULE_LICENSE("GPL");
49MODULE_DESCRIPTION("8250 UART probe driver for the NEC DDB5477");
diff --git a/arch/mips/ddb5xxx/ddb5477/debug.c b/arch/mips/ddb5xxx/ddb5477/debug.c
deleted file mode 100644
index 68919d5f8ffd..000000000000
--- a/arch/mips/ddb5xxx/ddb5477/debug.c
+++ /dev/null
@@ -1,160 +0,0 @@
1/***********************************************************************
2 *
3 * Copyright 2001 MontaVista Software Inc.
4 * Author: jsun@mvista.com or jsun@junsun.net
5 *
6 * arch/mips/ddb5xxx/ddb5477/debug.c
7 * vrc5477 specific debug routines.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 ***********************************************************************
15 */
16
17#include <linux/kernel.h>
18
19#include <asm/mipsregs.h>
20#include <asm/ddb5xxx/ddb5xxx.h>
21
22typedef struct {
23 const char *regname;
24 unsigned regaddr;
25} Register;
26
27void jsun_show_regs(char *name, Register *regs)
28{
29 int i;
30
31 printk("\nshow regs: %s\n", name);
32 for(i=0;regs[i].regname!= NULL; i++) {
33 printk("%-16s= %08x\t\t(@%08x)\n",
34 regs[i].regname,
35 *(unsigned *)(regs[i].regaddr),
36 regs[i].regaddr);
37 }
38}
39
40static Register int_regs[] = {
41 {"DDB_INTCTRL0", DDB_BASE + DDB_INTCTRL0},
42 {"DDB_INTCTRL1", DDB_BASE + DDB_INTCTRL1},
43 {"DDB_INTCTRL2", DDB_BASE + DDB_INTCTRL2},
44 {"DDB_INTCTRL3", DDB_BASE + DDB_INTCTRL3},
45 {"DDB_INT0STAT", DDB_BASE + DDB_INT0STAT},
46 {"DDB_INT1STAT", DDB_BASE + DDB_INT1STAT},
47 {"DDB_INT2STAT", DDB_BASE + DDB_INT2STAT},
48 {"DDB_INT3STAT", DDB_BASE + DDB_INT3STAT},
49 {"DDB_INT4STAT", DDB_BASE + DDB_INT4STAT},
50 {"DDB_NMISTAT", DDB_BASE + DDB_NMISTAT},
51 {"DDB_INTPPES0", DDB_BASE + DDB_INTPPES0},
52 {"DDB_INTPPES1", DDB_BASE + DDB_INTPPES1},
53 {NULL, 0x0}
54};
55
56void vrc5477_show_int_regs()
57{
58 jsun_show_regs("interrupt registers", int_regs);
59 printk("CPU CAUSE = %08x\n", read_c0_cause());
60 printk("CPU STATUS = %08x\n", read_c0_status());
61}
62static Register pdar_regs[] = {
63 {"DDB_SDRAM0", DDB_BASE + DDB_SDRAM0},
64 {"DDB_SDRAM1", DDB_BASE + DDB_SDRAM1},
65 {"DDB_LCS0", DDB_BASE + DDB_LCS0},
66 {"DDB_LCS1", DDB_BASE + DDB_LCS1},
67 {"DDB_LCS2", DDB_BASE + DDB_LCS2},
68 {"DDB_INTCS", DDB_BASE + DDB_INTCS},
69 {"DDB_BOOTCS", DDB_BASE + DDB_BOOTCS},
70 {"DDB_PCIW0", DDB_BASE + DDB_PCIW0},
71 {"DDB_PCIW1", DDB_BASE + DDB_PCIW1},
72 {"DDB_IOPCIW0", DDB_BASE + DDB_IOPCIW0},
73 {"DDB_IOPCIW1", DDB_BASE + DDB_IOPCIW1},
74 {NULL, 0x0}
75};
76void vrc5477_show_pdar_regs(void)
77{
78 jsun_show_regs("PDAR regs", pdar_regs);
79}
80
81static Register bar_regs[] = {
82 {"DDB_BARC0", DDB_BASE + DDB_BARC0},
83 {"DDB_BARM010", DDB_BASE + DDB_BARM010},
84 {"DDB_BARM230", DDB_BASE + DDB_BARM230},
85 {"DDB_BAR00", DDB_BASE + DDB_BAR00},
86 {"DDB_BAR10", DDB_BASE + DDB_BAR10},
87 {"DDB_BAR20", DDB_BASE + DDB_BAR20},
88 {"DDB_BAR30", DDB_BASE + DDB_BAR30},
89 {"DDB_BAR40", DDB_BASE + DDB_BAR40},
90 {"DDB_BAR50", DDB_BASE + DDB_BAR50},
91 {"DDB_BARB0", DDB_BASE + DDB_BARB0},
92 {"DDB_BARC1", DDB_BASE + DDB_BARC1},
93 {"DDB_BARM011", DDB_BASE + DDB_BARM011},
94 {"DDB_BARM231", DDB_BASE + DDB_BARM231},
95 {"DDB_BAR01", DDB_BASE + DDB_BAR01},
96 {"DDB_BAR11", DDB_BASE + DDB_BAR11},
97 {"DDB_BAR21", DDB_BASE + DDB_BAR21},
98 {"DDB_BAR31", DDB_BASE + DDB_BAR31},
99 {"DDB_BAR41", DDB_BASE + DDB_BAR41},
100 {"DDB_BAR51", DDB_BASE + DDB_BAR51},
101 {"DDB_BARB1", DDB_BASE + DDB_BARB1},
102 {NULL, 0x0}
103};
104void vrc5477_show_bar_regs(void)
105{
106 jsun_show_regs("BAR regs", bar_regs);
107}
108
109static Register pci_regs[] = {
110 {"DDB_PCIW0", DDB_BASE + DDB_PCIW0},
111 {"DDB_PCIW1", DDB_BASE + DDB_PCIW1},
112 {"DDB_PCIINIT00", DDB_BASE + DDB_PCIINIT00},
113 {"DDB_PCIINIT10", DDB_BASE + DDB_PCIINIT10},
114 {"DDB_PCICTL0_L", DDB_BASE + DDB_PCICTL0_L},
115 {"DDB_PCICTL0_H", DDB_BASE + DDB_PCICTL0_H},
116 {"DDB_PCIARB0_L", DDB_BASE + DDB_PCIARB0_L},
117 {"DDB_PCIARB0_H", DDB_BASE + DDB_PCIARB0_H},
118 {"DDB_PCISWP0", DDB_BASE + DDB_PCISWP0},
119 {"DDB_PCIERR0", DDB_BASE + DDB_PCIERR0},
120 {"DDB_IOPCIW0", DDB_BASE + DDB_IOPCIW0},
121 {"DDB_IOPCIW1", DDB_BASE + DDB_IOPCIW1},
122 {"DDB_PCIINIT01", DDB_BASE + DDB_PCIINIT01},
123 {"DDB_PCIINIT11", DDB_BASE + DDB_PCIINIT11},
124 {"DDB_PCICTL1_L", DDB_BASE + DDB_PCICTL1_L},
125 {"DDB_PCICTL1_H", DDB_BASE + DDB_PCICTL1_H},
126 {"DDB_PCIARB1_L", DDB_BASE + DDB_PCIARB1_L},
127 {"DDB_PCIARB1_H", DDB_BASE + DDB_PCIARB1_H},
128 {"DDB_PCISWP1", DDB_BASE + DDB_PCISWP1},
129 {"DDB_PCIERR1", DDB_BASE + DDB_PCIERR1},
130 {NULL, 0x0}
131};
132void vrc5477_show_pci_regs(void)
133{
134 jsun_show_regs("PCI regs", pci_regs);
135}
136
137static Register lb_regs[] = {
138 {"DDB_LCNFG", DDB_BASE + DDB_LCNFG},
139 {"DDB_LCST0", DDB_BASE + DDB_LCST0},
140 {"DDB_LCST1", DDB_BASE + DDB_LCST1},
141 {"DDB_LCST2", DDB_BASE + DDB_LCST2},
142 {"DDB_ERRADR", DDB_BASE + DDB_ERRADR},
143 {"DDB_ERRCS", DDB_BASE + DDB_ERRCS},
144 {"DDB_BTM", DDB_BASE + DDB_BTM},
145 {"DDB_BCST", DDB_BASE + DDB_BCST},
146 {NULL, 0x0}
147};
148void vrc5477_show_lb_regs(void)
149{
150 jsun_show_regs("Local Bus regs", lb_regs);
151}
152
153void vrc5477_show_all_regs(void)
154{
155 vrc5477_show_pdar_regs();
156 vrc5477_show_pci_regs();
157 vrc5477_show_bar_regs();
158 vrc5477_show_int_regs();
159 vrc5477_show_lb_regs();
160}
diff --git a/arch/mips/ddb5xxx/ddb5477/irq.c b/arch/mips/ddb5xxx/ddb5477/irq.c
deleted file mode 100644
index faa4a506bf82..000000000000
--- a/arch/mips/ddb5xxx/ddb5477/irq.c
+++ /dev/null
@@ -1,209 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
4 *
5 * arch/mips/ddb5xxx/ddb5477/irq.c
6 * The irq setup and misc routines for DDB5476.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13#include <linux/init.h>
14#include <linux/interrupt.h>
15#include <linux/irq.h>
16#include <linux/types.h>
17#include <linux/ptrace.h>
18
19#include <asm/i8259.h>
20#include <asm/irq_cpu.h>
21#include <asm/system.h>
22#include <asm/mipsregs.h>
23#include <asm/debug.h>
24#include <asm/addrspace.h>
25#include <asm/bootinfo.h>
26
27#include <asm/ddb5xxx/ddb5xxx.h>
28
29
30/*
31 * IRQ mapping
32 *
33 * 0-7: 8 CPU interrupts
34 * 0 - software interrupt 0
35 * 1 - software interrupt 1
36 * 2 - most Vrc5477 interrupts are routed to this pin
37 * 3 - (optional) some other interrupts routed to this pin for debugg
38 * 4 - not used
39 * 5 - not used
40 * 6 - not used
41 * 7 - cpu timer (used by default)
42 *
43 * 8-39: 32 Vrc5477 interrupt sources
44 * (refer to the Vrc5477 manual)
45 */
46
47#define PCI0 DDB_INTPPES0
48#define PCI1 DDB_INTPPES1
49
50#define ACTIVE_LOW 1
51#define ACTIVE_HIGH 0
52
53#define LEVEL_SENSE 2
54#define EDGE_TRIGGER 0
55
56#define INTA 0
57#define INTB 1
58#define INTC 2
59#define INTD 3
60#define INTE 4
61
62static inline void
63set_pci_int_attr(u32 pci, u32 intn, u32 active, u32 trigger)
64{
65 u32 reg_value;
66 u32 reg_bitmask;
67
68 reg_value = ddb_in32(pci);
69 reg_bitmask = 0x3 << (intn * 2);
70
71 reg_value &= ~reg_bitmask;
72 reg_value |= (active | trigger) << (intn * 2);
73 ddb_out32(pci, reg_value);
74}
75
76extern void vrc5477_irq_init(u32 base);
77static struct irqaction irq_cascade = { no_action, 0, CPU_MASK_NONE, "cascade", NULL, NULL };
78
79void __init arch_init_irq(void)
80{
81 /* by default, we disable all interrupts and route all vrc5477
82 * interrupts to pin 0 (irq 2) */
83 ddb_out32(DDB_INTCTRL0, 0);
84 ddb_out32(DDB_INTCTRL1, 0);
85 ddb_out32(DDB_INTCTRL2, 0);
86 ddb_out32(DDB_INTCTRL3, 0);
87
88 clear_c0_status(0xff00);
89 set_c0_status(0x0400);
90
91 /* setup PCI interrupt attributes */
92 set_pci_int_attr(PCI0, INTA, ACTIVE_LOW, LEVEL_SENSE);
93 set_pci_int_attr(PCI0, INTB, ACTIVE_LOW, LEVEL_SENSE);
94 if (mips_machtype == MACH_NEC_ROCKHOPPERII)
95 set_pci_int_attr(PCI0, INTC, ACTIVE_HIGH, LEVEL_SENSE);
96 else
97 set_pci_int_attr(PCI0, INTC, ACTIVE_LOW, LEVEL_SENSE);
98 set_pci_int_attr(PCI0, INTD, ACTIVE_LOW, LEVEL_SENSE);
99 set_pci_int_attr(PCI0, INTE, ACTIVE_LOW, LEVEL_SENSE);
100
101 set_pci_int_attr(PCI1, INTA, ACTIVE_LOW, LEVEL_SENSE);
102 set_pci_int_attr(PCI1, INTB, ACTIVE_LOW, LEVEL_SENSE);
103 set_pci_int_attr(PCI1, INTC, ACTIVE_LOW, LEVEL_SENSE);
104 set_pci_int_attr(PCI1, INTD, ACTIVE_LOW, LEVEL_SENSE);
105 set_pci_int_attr(PCI1, INTE, ACTIVE_LOW, LEVEL_SENSE);
106
107 /*
108 * for debugging purpose, we enable several error interrupts
109 * and route them to pin 1. (IP3)
110 */
111 /* cpu parity check - 0 */
112 ll_vrc5477_irq_route(0, 1); ll_vrc5477_irq_enable(0);
113 /* cpu no-target decode - 1 */
114 ll_vrc5477_irq_route(1, 1); ll_vrc5477_irq_enable(1);
115 /* local bus read time-out - 7 */
116 ll_vrc5477_irq_route(7, 1); ll_vrc5477_irq_enable(7);
117 /* PCI SERR# - 14 */
118 ll_vrc5477_irq_route(14, 1); ll_vrc5477_irq_enable(14);
119 /* PCI internal error - 15 */
120 ll_vrc5477_irq_route(15, 1); ll_vrc5477_irq_enable(15);
121 /* IOPCI SERR# - 30 */
122 ll_vrc5477_irq_route(30, 1); ll_vrc5477_irq_enable(30);
123 /* IOPCI internal error - 31 */
124 ll_vrc5477_irq_route(31, 1); ll_vrc5477_irq_enable(31);
125
126 /* init all controllers */
127 init_i8259_irqs();
128 mips_cpu_irq_init();
129 vrc5477_irq_init(VRC5477_IRQ_BASE);
130
131
132 /* setup cascade interrupts */
133 setup_irq(VRC5477_IRQ_BASE + VRC5477_I8259_CASCADE, &irq_cascade);
134 setup_irq(CPU_IRQ_BASE + CPU_VRC5477_CASCADE, &irq_cascade);
135}
136
137u8 i8259_interrupt_ack(void)
138{
139 u8 irq;
140 u32 reg;
141
142 /* Set window 0 for interrupt acknowledge */
143 reg = ddb_in32(DDB_PCIINIT10);
144
145 ddb_set_pmr(DDB_PCIINIT10, DDB_PCICMD_IACK, 0, DDB_PCI_ACCESS_32);
146 irq = *(volatile u8 *) KSEG1ADDR(DDB_PCI_IACK_BASE);
147 ddb_out32(DDB_PCIINIT10, reg);
148
149 return irq;
150}
151/*
152 * the first level int-handler will jump here if it is a vrc5477 irq
153 */
154#define NUM_5477_IRQS 32
155static void vrc5477_irq_dispatch(void)
156{
157 u32 intStatus;
158 u32 bitmask;
159 u32 i;
160
161 db_assert(ddb_in32(DDB_INT2STAT) == 0);
162 db_assert(ddb_in32(DDB_INT3STAT) == 0);
163 db_assert(ddb_in32(DDB_INT4STAT) == 0);
164 db_assert(ddb_in32(DDB_NMISTAT) == 0);
165
166 if (ddb_in32(DDB_INT1STAT) != 0) {
167#if defined(CONFIG_RUNTIME_DEBUG)
168 vrc5477_show_int_regs();
169#endif
170 panic("error interrupt has happened.");
171 }
172
173 intStatus = ddb_in32(DDB_INT0STAT);
174
175 if (mips_machtype == MACH_NEC_ROCKHOPPERII) {
176 /* check for i8259 interrupts */
177 if (intStatus & (1 << VRC5477_I8259_CASCADE)) {
178 int i8259_irq = i8259_interrupt_ack();
179 do_IRQ(i8259_irq);
180 return;
181 }
182 }
183
184 for (i=0, bitmask=1; i<= NUM_5477_IRQS; bitmask <<=1, i++) {
185 /* do we need to "and" with the int mask? */
186 if (intStatus & bitmask) {
187 do_IRQ(VRC5477_IRQ_BASE + i);
188 return;
189 }
190 }
191}
192
193#define VR5477INTS (STATUSF_IP2|STATUSF_IP3|STATUSF_IP4|STATUSF_IP5|STATUSF_IP6)
194
195asmlinkage void plat_irq_dispatch(void)
196{
197 unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
198
199 if (pending & STATUSF_IP7)
200 do_IRQ(CPU_IRQ_BASE + 7);
201 else if (pending & VR5477INTS)
202 vrc5477_irq_dispatch();
203 else if (pending & STATUSF_IP0)
204 do_IRQ(CPU_IRQ_BASE);
205 else if (pending & STATUSF_IP1)
206 do_IRQ(CPU_IRQ_BASE + 1);
207 else
208 spurious_interrupt();
209}
diff --git a/arch/mips/ddb5xxx/ddb5477/irq_5477.c b/arch/mips/ddb5xxx/ddb5477/irq_5477.c
deleted file mode 100644
index 98c3b15eb369..000000000000
--- a/arch/mips/ddb5xxx/ddb5477/irq_5477.c
+++ /dev/null
@@ -1,154 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
4 *
5 * arch/mips/ddb5xxx/ddb5477/irq_5477.c
6 * This file defines the irq handler for Vrc5477.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15/*
16 * Vrc5477 defines 32 IRQs.
17 *
18 * This file exports one function:
19 * vrc5477_irq_init(u32 irq_base);
20 */
21
22#include <linux/interrupt.h>
23#include <linux/types.h>
24#include <linux/ptrace.h>
25
26#include <asm/debug.h>
27
28#include <asm/ddb5xxx/ddb5xxx.h>
29
30/* number of total irqs supported by Vrc5477 */
31#define NUM_5477_IRQ 32
32
33static int vrc5477_irq_base = -1;
34
35
36static void
37vrc5477_irq_enable(unsigned int irq)
38{
39 db_assert(vrc5477_irq_base != -1);
40 db_assert(irq >= vrc5477_irq_base);
41 db_assert(irq < vrc5477_irq_base+ NUM_5477_IRQ);
42
43 ll_vrc5477_irq_enable(irq - vrc5477_irq_base);
44}
45
46static void
47vrc5477_irq_disable(unsigned int irq)
48{
49 db_assert(vrc5477_irq_base != -1);
50 db_assert(irq >= vrc5477_irq_base);
51 db_assert(irq < vrc5477_irq_base + NUM_5477_IRQ);
52
53 ll_vrc5477_irq_disable(irq - vrc5477_irq_base);
54}
55
56static void
57vrc5477_irq_ack(unsigned int irq)
58{
59 db_assert(vrc5477_irq_base != -1);
60 db_assert(irq >= vrc5477_irq_base);
61 db_assert(irq < vrc5477_irq_base+ NUM_5477_IRQ);
62
63 /* clear the interrupt bit */
64 /* some irqs require the driver to clear the sources */
65 ddb_out32(DDB_INTCLR32, 1 << (irq - vrc5477_irq_base));
66
67 /* disable interrupt - some handler will re-enable the irq
68 * and if the interrupt is leveled, we will have infinite loop
69 */
70 ll_vrc5477_irq_disable(irq - vrc5477_irq_base);
71}
72
73static void
74vrc5477_irq_end(unsigned int irq)
75{
76 db_assert(vrc5477_irq_base != -1);
77 db_assert(irq >= vrc5477_irq_base);
78 db_assert(irq < vrc5477_irq_base + NUM_5477_IRQ);
79
80 if(!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
81 ll_vrc5477_irq_enable( irq - vrc5477_irq_base);
82}
83
84struct irq_chip vrc5477_irq_controller = {
85 .name = "vrc5477_irq",
86 .ack = vrc5477_irq_ack,
87 .mask = vrc5477_irq_disable,
88 .mask_ack = vrc5477_irq_ack,
89 .unmask = vrc5477_irq_enable,
90 .end = vrc5477_irq_end
91};
92
93void __init vrc5477_irq_init(u32 irq_base)
94{
95 u32 i;
96
97 for (i= irq_base; i< irq_base+ NUM_5477_IRQ; i++)
98 set_irq_chip(i, &vrc5477_irq_controller);
99
100 vrc5477_irq_base = irq_base;
101}
102
103void ll_vrc5477_irq_route(int vrc5477_irq, int ip)
104{
105 u32 reg_value;
106 u32 reg_bitmask;
107 u32 reg_index;
108
109 db_assert(vrc5477_irq >= 0);
110 db_assert(vrc5477_irq < NUM_5477_IRQ);
111 db_assert(ip >= 0);
112 db_assert((ip < 5) || (ip == 6));
113
114 reg_index = DDB_INTCTRL0 + vrc5477_irq/8*4;
115 reg_value = ddb_in32(reg_index);
116 reg_bitmask = 7 << (vrc5477_irq % 8 * 4);
117 reg_value &= ~reg_bitmask;
118 reg_value |= ip << (vrc5477_irq % 8 * 4);
119 ddb_out32(reg_index, reg_value);
120}
121
122void ll_vrc5477_irq_enable(int vrc5477_irq)
123{
124 u32 reg_value;
125 u32 reg_bitmask;
126 u32 reg_index;
127
128 db_assert(vrc5477_irq >= 0);
129 db_assert(vrc5477_irq < NUM_5477_IRQ);
130
131 reg_index = DDB_INTCTRL0 + vrc5477_irq/8*4;
132 reg_value = ddb_in32(reg_index);
133 reg_bitmask = 8 << (vrc5477_irq % 8 * 4);
134 db_assert((reg_value & reg_bitmask) == 0);
135 ddb_out32(reg_index, reg_value | reg_bitmask);
136}
137
138void ll_vrc5477_irq_disable(int vrc5477_irq)
139{
140 u32 reg_value;
141 u32 reg_bitmask;
142 u32 reg_index;
143
144 db_assert(vrc5477_irq >= 0);
145 db_assert(vrc5477_irq < NUM_5477_IRQ);
146
147 reg_index = DDB_INTCTRL0 + vrc5477_irq/8*4;
148 reg_value = ddb_in32(reg_index);
149 reg_bitmask = 8 << (vrc5477_irq % 8 * 4);
150
151 /* we assert that the interrupt is enabled (perhaps over-zealous) */
152 db_assert( (reg_value & reg_bitmask) != 0);
153 ddb_out32(reg_index, reg_value & ~reg_bitmask);
154}
diff --git a/arch/mips/ddb5xxx/ddb5477/kgdb_io.c b/arch/mips/ddb5xxx/ddb5477/kgdb_io.c
deleted file mode 100644
index 385bbdb10170..000000000000
--- a/arch/mips/ddb5xxx/ddb5477/kgdb_io.c
+++ /dev/null
@@ -1,136 +0,0 @@
1/*
2 * kgdb io functions for DDB5477. We use the second serial port (upper one).
3 *
4 * Copyright (C) 2001 MontaVista Software Inc.
5 * Author: jsun@mvista.com or jsun@junsun.net
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14/* ======================= CONFIG ======================== */
15
16/* [jsun] we use the second serial port for kdb */
17#define BASE 0xbfa04240
18#define MAX_BAUD 115200
19
20/* distance in bytes between two serial registers */
21#define REG_OFFSET 8
22
23/*
24 * 0 - kgdb does serial init
25 * 1 - kgdb skip serial init
26 */
27static int remoteDebugInitialized = 0;
28
29/*
30 * the default baud rate *if* kgdb does serial init
31 */
32#define BAUD_DEFAULT UART16550_BAUD_38400
33
34/* ======================= END OF CONFIG ======================== */
35
36typedef unsigned char uint8;
37typedef unsigned int uint32;
38
39#define UART16550_BAUD_2400 2400
40#define UART16550_BAUD_4800 4800
41#define UART16550_BAUD_9600 9600
42#define UART16550_BAUD_19200 19200
43#define UART16550_BAUD_38400 38400
44#define UART16550_BAUD_57600 57600
45#define UART16550_BAUD_115200 115200
46
47#define UART16550_PARITY_NONE 0
48#define UART16550_PARITY_ODD 0x08
49#define UART16550_PARITY_EVEN 0x18
50#define UART16550_PARITY_MARK 0x28
51#define UART16550_PARITY_SPACE 0x38
52
53#define UART16550_DATA_5BIT 0x0
54#define UART16550_DATA_6BIT 0x1
55#define UART16550_DATA_7BIT 0x2
56#define UART16550_DATA_8BIT 0x3
57
58#define UART16550_STOP_1BIT 0x0
59#define UART16550_STOP_2BIT 0x4
60
61/* register offset */
62#define OFS_RCV_BUFFER 0
63#define OFS_TRANS_HOLD 0
64#define OFS_SEND_BUFFER 0
65#define OFS_INTR_ENABLE (1*REG_OFFSET)
66#define OFS_INTR_ID (2*REG_OFFSET)
67#define OFS_DATA_FORMAT (3*REG_OFFSET)
68#define OFS_LINE_CONTROL (3*REG_OFFSET)
69#define OFS_MODEM_CONTROL (4*REG_OFFSET)
70#define OFS_RS232_OUTPUT (4*REG_OFFSET)
71#define OFS_LINE_STATUS (5*REG_OFFSET)
72#define OFS_MODEM_STATUS (6*REG_OFFSET)
73#define OFS_RS232_INPUT (6*REG_OFFSET)
74#define OFS_SCRATCH_PAD (7*REG_OFFSET)
75
76#define OFS_DIVISOR_LSB (0*REG_OFFSET)
77#define OFS_DIVISOR_MSB (1*REG_OFFSET)
78
79
80/* memory-mapped read/write of the port */
81#define UART16550_READ(y) (*((volatile uint8*)(BASE + y)))
82#define UART16550_WRITE(y, z) ((*((volatile uint8*)(BASE + y))) = z)
83
84void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
85{
86 /* disable interrupts */
87 UART16550_WRITE(OFS_INTR_ENABLE, 0);
88
89 /* set up baud rate */
90 {
91 uint32 divisor;
92
93 /* set DIAB bit */
94 UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
95
96 /* set divisor */
97 divisor = MAX_BAUD / baud;
98 UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
99 UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8);
100
101 /* clear DIAB bit */
102 UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
103 }
104
105 /* set data format */
106 UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
107}
108
109
110uint8 getDebugChar(void)
111{
112 if (!remoteDebugInitialized) {
113 remoteDebugInitialized = 1;
114 debugInit(BAUD_DEFAULT,
115 UART16550_DATA_8BIT,
116 UART16550_PARITY_NONE, UART16550_STOP_1BIT);
117 }
118
119 while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
120 return UART16550_READ(OFS_RCV_BUFFER);
121}
122
123
124int putDebugChar(uint8 byte)
125{
126 if (!remoteDebugInitialized) {
127 remoteDebugInitialized = 1;
128 debugInit(BAUD_DEFAULT,
129 UART16550_DATA_8BIT,
130 UART16550_PARITY_NONE, UART16550_STOP_1BIT);
131 }
132
133 while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0);
134 UART16550_WRITE(OFS_SEND_BUFFER, byte);
135 return 1;
136}
diff --git a/arch/mips/ddb5xxx/ddb5477/lcd44780.c b/arch/mips/ddb5xxx/ddb5477/lcd44780.c
deleted file mode 100644
index 9510b9ae6453..000000000000
--- a/arch/mips/ddb5xxx/ddb5477/lcd44780.c
+++ /dev/null
@@ -1,96 +0,0 @@
1/*
2 * lcd44780.c
3 * Simple "driver" for a memory-mapped 44780-style LCD display.
4 *
5 * Copyright 2001 Bradley D. LaRonde <brad@ltc.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#define LCD44780_COMMAND ((volatile unsigned char *)0xbe020000)
15#define LCD44780_DATA ((volatile unsigned char *)0xbe020001)
16
17#define LCD44780_4BIT_1LINE 0x20
18#define LCD44780_4BIT_2LINE 0x28
19#define LCD44780_8BIT_1LINE 0x30
20#define LCD44780_8BIT_2LINE 0x38
21#define LCD44780_MODE_DEC 0x04
22#define LCD44780_MODE_DEC_SHIFT 0x05
23#define LCD44780_MODE_INC 0x06
24#define LCD44780_MODE_INC_SHIFT 0x07
25#define LCD44780_SCROLL_LEFT 0x18
26#define LCD44780_SCROLL_RIGHT 0x1e
27#define LCD44780_CURSOR_UNDERLINE 0x0e
28#define LCD44780_CURSOR_BLOCK 0x0f
29#define LCD44780_CURSOR_OFF 0x0c
30#define LCD44780_CLEAR 0x01
31#define LCD44780_BLANK 0x08
32#define LCD44780_RESTORE 0x0c // Same as CURSOR_OFF
33#define LCD44780_HOME 0x02
34#define LCD44780_LEFT 0x10
35#define LCD44780_RIGHT 0x14
36
37void lcd44780_wait(void)
38{
39 int i, j;
40 for(i=0; i < 400; i++)
41 for(j=0; j < 10000; j++);
42}
43
44void lcd44780_command(unsigned char c)
45{
46 *LCD44780_COMMAND = c;
47 lcd44780_wait();
48}
49
50void lcd44780_data(unsigned char c)
51{
52 *LCD44780_DATA = c;
53 lcd44780_wait();
54}
55
56void lcd44780_puts(const char* s)
57{
58 int j;
59 int pos = 0;
60
61 lcd44780_command(LCD44780_CLEAR);
62 while(*s) {
63 lcd44780_data(*s);
64 s++;
65 pos++;
66 if (pos == 8) {
67 /* We must write 32 of spaces to get cursor to 2nd line */
68 for (j=0; j<32; j++) {
69 lcd44780_data(' ');
70 }
71 }
72 if (pos == 16) {
73 /* We have filled all 16 character positions, so stop
74 outputing data */
75 break;
76 }
77 }
78#ifdef LCD44780_PUTS_PAUSE
79 {
80 int i;
81
82 for(i = 1; i < 2000; i++)
83 lcd44780_wait();
84 }
85#endif
86}
87
88void lcd44780_init(void)
89{
90 // The display on the RockHopper is physically a single
91 // 16 char line (two 8 char lines concatenated). bdl
92 lcd44780_command(LCD44780_8BIT_2LINE);
93 lcd44780_command(LCD44780_MODE_INC);
94 lcd44780_command(LCD44780_CURSOR_BLOCK);
95 lcd44780_command(LCD44780_CLEAR);
96}
diff --git a/arch/mips/ddb5xxx/ddb5477/lcd44780.h b/arch/mips/ddb5xxx/ddb5477/lcd44780.h
deleted file mode 100644
index cf2f0f71eee5..000000000000
--- a/arch/mips/ddb5xxx/ddb5477/lcd44780.h
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * lcd44780.h
3 * Simple "driver" for a memory-mapped 44780-style LCD display.
4 *
5 * Copyright 2001 Bradley D. LaRonde <brad@ltc.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14void lcd44780_puts(const char* s);
15void lcd44780_init(void);
diff --git a/arch/mips/ddb5xxx/ddb5477/setup.c b/arch/mips/ddb5xxx/ddb5477/setup.c
deleted file mode 100644
index f0cc0e8a8afa..000000000000
--- a/arch/mips/ddb5xxx/ddb5477/setup.c
+++ /dev/null
@@ -1,399 +0,0 @@
1/*
2 *
3 * Copyright 2001 MontaVista Software Inc.
4 * Author: jsun@mvista.com or jsun@junsun.net
5 *
6 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
7 *
8 * arch/mips/ddb5xxx/ddb5477/setup.c
9 * Setup file for DDB5477.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 */
16#include <linux/init.h>
17#include <linux/kernel.h>
18#include <linux/types.h>
19#include <linux/sched.h>
20#include <linux/pci.h>
21#include <linux/ide.h>
22#include <linux/irq.h>
23#include <linux/fs.h>
24#include <linux/ioport.h>
25#include <linux/param.h> /* for HZ */
26#include <linux/major.h>
27#include <linux/kdev_t.h>
28#include <linux/root_dev.h>
29#include <linux/pm.h>
30
31#include <asm/cpu.h>
32#include <asm/bootinfo.h>
33#include <asm/addrspace.h>
34#include <asm/time.h>
35#include <asm/bcache.h>
36#include <asm/irq.h>
37#include <asm/reboot.h>
38#include <asm/gdb-stub.h>
39#include <asm/traps.h>
40#include <asm/debug.h>
41
42#include <asm/ddb5xxx/ddb5xxx.h>
43
44#include "lcd44780.h"
45
46
47#define USE_CPU_COUNTER_TIMER /* whether we use cpu counter */
48
49#define SP_TIMER_BASE DDB_SPT1CTRL_L
50#define SP_TIMER_IRQ VRC5477_IRQ_SPT1
51
52static int bus_frequency = CONFIG_DDB5477_BUS_FREQUENCY*1000;
53
54static void ddb_machine_restart(char *command)
55{
56 static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000;
57
58 u32 t;
59
60 /* PCI cold reset */
61 ddb_pci_reset_bus();
62
63 /* CPU cold reset */
64 t = ddb_in32(DDB_CPUSTAT);
65 db_assert((t&1));
66 ddb_out32(DDB_CPUSTAT, t);
67
68 /* Call the PROM */
69 back_to_prom();
70}
71
72static void ddb_machine_halt(void)
73{
74 printk("DDB Vrc-5477 halted.\n");
75 while (1);
76}
77
78static void ddb_machine_power_off(void)
79{
80 printk("DDB Vrc-5477 halted. Please turn off the power.\n");
81 while (1);
82}
83
84extern void rtc_ds1386_init(unsigned long base);
85
86static unsigned int __init detect_bus_frequency(unsigned long rtc_base)
87{
88 unsigned int freq;
89 unsigned char c;
90 unsigned int t1, t2;
91 unsigned i;
92
93 ddb_out32(SP_TIMER_BASE, 0xffffffff);
94 ddb_out32(SP_TIMER_BASE+4, 0x1);
95 ddb_out32(SP_TIMER_BASE+8, 0xffffffff);
96
97 /* check if rtc is running */
98 c= *(volatile unsigned char*)rtc_base;
99 for(i=0; (c == *(volatile unsigned char*)rtc_base) && (i<100000000); i++);
100 if (c == *(volatile unsigned char*)rtc_base) {
101 printk("Failed to detect bus frequency. Use default 83.3MHz.\n");
102 return 83333000;
103 }
104
105 c= *(volatile unsigned char*)rtc_base;
106 while (c == *(volatile unsigned char*)rtc_base);
107 /* we are now at the turn of 1/100th second, if no error. */
108 t1 = ddb_in32(SP_TIMER_BASE+8);
109
110 for (i=0; i< 10; i++) {
111 c= *(volatile unsigned char*)rtc_base;
112 while (c == *(volatile unsigned char*)rtc_base);
113 /* we are now at the turn of another 1/100th second */
114 t2 = ddb_in32(SP_TIMER_BASE+8);
115 }
116
117 ddb_out32(SP_TIMER_BASE+4, 0x0); /* disable it again */
118
119 freq = (t1 - t2)*10;
120 printk("DDB bus frequency detection : %u \n", freq);
121 return freq;
122}
123
124static void __init ddb_time_init(void)
125{
126 unsigned long rtc_base;
127 unsigned int i;
128
129 /* we have ds1396 RTC chip */
130 if (mips_machtype == MACH_NEC_ROCKHOPPER
131 || mips_machtype == MACH_NEC_ROCKHOPPERII) {
132 rtc_base = KSEG1ADDR(DDB_LCS2_BASE);
133 } else {
134 rtc_base = KSEG1ADDR(DDB_LCS1_BASE);
135 }
136 rtc_ds1386_init(rtc_base);
137
138 /* do we need to do run-time detection of bus speed? */
139 if (bus_frequency == 0) {
140 bus_frequency = detect_bus_frequency(rtc_base);
141 }
142
143 /* mips_hpt_frequency is 1/2 of the cpu core freq */
144 i = (read_c0_config() >> 28 ) & 7;
145 if ((current_cpu_data.cputype == CPU_R5432) && (i == 3))
146 i = 4;
147 mips_hpt_frequency = bus_frequency*(i+4)/4;
148}
149
150void __init plat_timer_setup(struct irqaction *irq)
151{
152#if defined(USE_CPU_COUNTER_TIMER)
153
154 /* we are using the cpu counter for timer interrupts */
155 setup_irq(CPU_IRQ_BASE + 7, irq);
156
157#else
158
159 /* if we use Special purpose timer 1 */
160 ddb_out32(SP_TIMER_BASE, bus_frequency/HZ);
161 ddb_out32(SP_TIMER_BASE+4, 0x1);
162 setup_irq(SP_TIMER_IRQ, irq);
163
164#endif
165}
166
167static void ddb5477_board_init(void);
168
169extern struct pci_controller ddb5477_ext_controller;
170extern struct pci_controller ddb5477_io_controller;
171
172void __init plat_mem_setup(void)
173{
174 /* initialize board - we don't trust the loader */
175 ddb5477_board_init();
176
177 set_io_port_base(KSEG1ADDR(DDB_PCI_IO_BASE));
178
179 board_time_init = ddb_time_init;
180
181 _machine_restart = ddb_machine_restart;
182 _machine_halt = ddb_machine_halt;
183 pm_power_off = ddb_machine_power_off;
184
185 /* setup resource limits */
186 ioport_resource.end = DDB_PCI0_IO_SIZE + DDB_PCI1_IO_SIZE - 1;
187 iomem_resource.end = 0xffffffff;
188
189 /* Reboot on panic */
190 panic_timeout = 180;
191
192 register_pci_controller (&ddb5477_ext_controller);
193 register_pci_controller (&ddb5477_io_controller);
194}
195
196static void __init ddb5477_board_init(void)
197{
198 /* ----------- setup PDARs ------------ */
199
200 /* SDRAM should have been set */
201 db_assert(ddb_in32(DDB_SDRAM0) ==
202 ddb_calc_pdar(DDB_SDRAM_BASE, board_ram_size, 32, 0, 1));
203
204 /* SDRAM1 should be turned off. What is this for anyway ? */
205 db_assert( (ddb_in32(DDB_SDRAM1) & 0xf) == 0);
206
207 /* Setup local bus. */
208
209 /* Flash U12 PDAR and timing. */
210 ddb_set_pdar(DDB_LCS0, DDB_LCS0_BASE, DDB_LCS0_SIZE, 16, 0, 0);
211 ddb_out32(DDB_LCST0, 0x00090842);
212
213 /* We need to setup LCS1 and LCS2 differently based on the
214 board_version */
215 if (mips_machtype == MACH_NEC_ROCKHOPPER) {
216 /* Flash U13 PDAR and timing. */
217 ddb_set_pdar(DDB_LCS1, DDB_LCS1_BASE, DDB_LCS1_SIZE, 16, 0, 0);
218 ddb_out32(DDB_LCST1, 0x00090842);
219
220 /* EPLD (NVRAM, switch, LCD, and mezzanie). */
221 ddb_set_pdar(DDB_LCS2, DDB_LCS2_BASE, DDB_LCS2_SIZE, 8, 0, 0);
222 } else {
223 /* misc */
224 ddb_set_pdar(DDB_LCS1, DDB_LCS1_BASE, DDB_LCS1_SIZE, 8, 0, 0);
225 /* mezzanie (?) */
226 ddb_set_pdar(DDB_LCS2, DDB_LCS2_BASE, DDB_LCS2_SIZE, 16, 0, 0);
227 }
228
229 /* verify VRC5477 base addr */
230 db_assert(ddb_in32(DDB_VRC5477) ==
231 ddb_calc_pdar(DDB_VRC5477_BASE, DDB_VRC5477_SIZE, 32, 0, 1));
232
233 /* verify BOOT ROM addr */
234 db_assert(ddb_in32(DDB_BOOTCS) ==
235 ddb_calc_pdar(DDB_BOOTCS_BASE, DDB_BOOTCS_SIZE, 8, 0, 0));
236
237 /* setup PCI windows - window0 for MEM/config, window1 for IO */
238 ddb_set_pdar(DDB_PCIW0, DDB_PCI0_MEM_BASE, DDB_PCI0_MEM_SIZE, 32, 0, 1);
239 ddb_set_pdar(DDB_PCIW1, DDB_PCI0_IO_BASE, DDB_PCI0_IO_SIZE, 32, 0, 1);
240 ddb_set_pdar(DDB_IOPCIW0, DDB_PCI1_MEM_BASE, DDB_PCI1_MEM_SIZE, 32, 0, 1);
241 ddb_set_pdar(DDB_IOPCIW1, DDB_PCI1_IO_BASE, DDB_PCI1_IO_SIZE, 32, 0, 1);
242
243 /* ------------ reset PCI bus and BARs ----------------- */
244 ddb_pci_reset_bus();
245
246 ddb_out32(DDB_BARM010, 0x00000008);
247 ddb_out32(DDB_BARM011, 0x00000008);
248
249 ddb_out32(DDB_BARC0, 0xffffffff);
250 ddb_out32(DDB_BARM230, 0xffffffff);
251 ddb_out32(DDB_BAR00, 0xffffffff);
252 ddb_out32(DDB_BAR10, 0xffffffff);
253 ddb_out32(DDB_BAR20, 0xffffffff);
254 ddb_out32(DDB_BAR30, 0xffffffff);
255 ddb_out32(DDB_BAR40, 0xffffffff);
256 ddb_out32(DDB_BAR50, 0xffffffff);
257 ddb_out32(DDB_BARB0, 0xffffffff);
258
259 ddb_out32(DDB_BARC1, 0xffffffff);
260 ddb_out32(DDB_BARM231, 0xffffffff);
261 ddb_out32(DDB_BAR01, 0xffffffff);
262 ddb_out32(DDB_BAR11, 0xffffffff);
263 ddb_out32(DDB_BAR21, 0xffffffff);
264 ddb_out32(DDB_BAR31, 0xffffffff);
265 ddb_out32(DDB_BAR41, 0xffffffff);
266 ddb_out32(DDB_BAR51, 0xffffffff);
267 ddb_out32(DDB_BARB1, 0xffffffff);
268
269 /*
270 * We use pci master register 0 for memory space / config space
271 * And we use register 1 for IO space.
272 * Note that for memory space, we bump up the pci base address
273 * so that we have 1:1 mapping between PCI memory and cpu physical.
274 * For PCI IO space, it starts from 0 in PCI IO space but with
275 * DDB_xx_IO_BASE in CPU physical address space.
276 */
277 ddb_set_pmr(DDB_PCIINIT00, DDB_PCICMD_MEM, DDB_PCI0_MEM_BASE,
278 DDB_PCI_ACCESS_32);
279 ddb_set_pmr(DDB_PCIINIT10, DDB_PCICMD_IO, 0, DDB_PCI_ACCESS_32);
280
281 ddb_set_pmr(DDB_PCIINIT01, DDB_PCICMD_MEM, DDB_PCI1_MEM_BASE,
282 DDB_PCI_ACCESS_32);
283 ddb_set_pmr(DDB_PCIINIT11, DDB_PCICMD_IO, DDB_PCI0_IO_SIZE,
284 DDB_PCI_ACCESS_32);
285
286
287 /* PCI cross window should be set properly */
288 ddb_set_pdar(DDB_BARP00, DDB_PCI1_MEM_BASE, DDB_PCI1_MEM_SIZE, 32, 0, 1);
289 ddb_set_pdar(DDB_BARP10, DDB_PCI1_IO_BASE, DDB_PCI1_IO_SIZE, 32, 0, 1);
290 ddb_set_pdar(DDB_BARP01, DDB_PCI0_MEM_BASE, DDB_PCI0_MEM_SIZE, 32, 0, 1);
291 ddb_set_pdar(DDB_BARP11, DDB_PCI0_IO_BASE, DDB_PCI0_IO_SIZE, 32, 0, 1);
292
293 if (mips_machtype == MACH_NEC_ROCKHOPPER
294 || mips_machtype == MACH_NEC_ROCKHOPPERII) {
295 /* Disable bus diagnostics. */
296 ddb_out32(DDB_PCICTL0_L, 0);
297 ddb_out32(DDB_PCICTL0_H, 0);
298 ddb_out32(DDB_PCICTL1_L, 0);
299 ddb_out32(DDB_PCICTL1_H, 0);
300 }
301
302 if (mips_machtype == MACH_NEC_ROCKHOPPER) {
303 u16 vid;
304 struct pci_bus bus;
305 struct pci_dev dev_m1533;
306 extern struct pci_ops ddb5477_ext_pci_ops;
307
308 bus.parent = NULL; /* we scan the top level only */
309 bus.ops = &ddb5477_ext_pci_ops;
310 dev_m1533.bus = &bus;
311 dev_m1533.sysdata = NULL;
312 dev_m1533.devfn = 7*8; // slot 7: M1533 SouthBridge.
313 pci_read_config_word(&dev_m1533, 0, &vid);
314 if (vid == PCI_VENDOR_ID_AL) {
315 printk("Changing mips_machtype to MACH_NEC_ROCKHOPPERII\n");
316 mips_machtype = MACH_NEC_ROCKHOPPERII;
317 }
318 }
319
320 /* enable USB input buffers */
321 ddb_out32(DDB_PIBMISC, 0x00000007);
322
323 /* For dual-function pins, make them all non-GPIO */
324 ddb_out32(DDB_GIUFUNSEL, 0x0);
325 // ddb_out32(DDB_GIUFUNSEL, 0xfe0fcfff); /* NEC recommanded value */
326
327 if (mips_machtype == MACH_NEC_ROCKHOPPERII) {
328
329 /* enable IDE controller on Ali chip (south bridge) */
330 u8 temp8;
331 struct pci_bus bus;
332 struct pci_dev dev_m1533;
333 struct pci_dev dev_m5229;
334 extern struct pci_ops ddb5477_ext_pci_ops;
335
336 /* Setup M1535 registers */
337 bus.parent = NULL; /* we scan the top level only */
338 bus.ops = &ddb5477_ext_pci_ops;
339 dev_m1533.bus = &bus;
340 dev_m1533.sysdata = NULL;
341 dev_m1533.devfn = 7*8; // slot 7: M1533 SouthBridge.
342
343 /* setup IDE controller
344 * enable IDE controller (bit 6 - 1)
345 * IDE IDSEL to be addr:A15 (bit 4:5 - 11)
346 * disable IDE ATA Secondary Bus Signal Pad Control (bit 3 - 0)
347 * enable IDE ATA Primary Bus Signal Pad Control (bit 2 - 1)
348 */
349 pci_write_config_byte(&dev_m1533, 0x58, 0x74);
350
351 /*
352 * positive decode (bit6 -0)
353 * enable IDE controler interrupt (bit 4 -1)
354 * setup SIRQ to point to IRQ 14 (bit 3:0 - 1101)
355 */
356 pci_write_config_byte(&dev_m1533, 0x44, 0x1d);
357
358 /* Setup M5229 registers */
359 dev_m5229.bus = &bus;
360 dev_m5229.sysdata = NULL;
361 dev_m5229.devfn = 4*8; // slot 4 (AD15): M5229 IDE
362
363 /*
364 * enable IDE in the M5229 config register 0x50 (bit 0 - 1)
365 * M5229 IDSEL is addr:15; see above setting
366 */
367 pci_read_config_byte(&dev_m5229, 0x50, &temp8);
368 pci_write_config_byte(&dev_m5229, 0x50, temp8 | 0x1);
369
370 /*
371 * enable bus master (bit 2) and IO decoding (bit 0)
372 */
373 pci_read_config_byte(&dev_m5229, 0x04, &temp8);
374 pci_write_config_byte(&dev_m5229, 0x04, temp8 | 0x5);
375
376 /*
377 * enable native, copied from arch/ppc/k2boot/head.S
378 * TODO - need volatile, need to be portable
379 */
380 pci_write_config_byte(&dev_m5229, 0x09, 0xef);
381
382 /* Set Primary Channel Command Block Timing */
383 pci_write_config_byte(&dev_m5229, 0x59, 0x31);
384
385 /*
386 * Enable primary channel 40-pin cable
387 * M5229 register 0x4a (bit 0)
388 */
389 pci_read_config_byte(&dev_m5229, 0x4a, &temp8);
390 pci_write_config_byte(&dev_m5229, 0x4a, temp8 | 0x1);
391 }
392
393 if (mips_machtype == MACH_NEC_ROCKHOPPER
394 || mips_machtype == MACH_NEC_ROCKHOPPERII) {
395 printk("lcd44780: initializing\n");
396 lcd44780_init();
397 lcd44780_puts("MontaVista Linux");
398 }
399}
diff --git a/arch/mips/dec/Makefile b/arch/mips/dec/Makefile
index 9eb2f9c036aa..c530208ee154 100644
--- a/arch/mips/dec/Makefile
+++ b/arch/mips/dec/Makefile
@@ -8,3 +8,5 @@ obj-y := ecc-berr.o int-handler.o ioasic-irq.o kn01-berr.o \
8obj-$(CONFIG_PROM_CONSOLE) += promcon.o 8obj-$(CONFIG_PROM_CONSOLE) += promcon.o
9obj-$(CONFIG_TC) += tc.o 9obj-$(CONFIG_TC) += tc.o
10obj-$(CONFIG_CPU_HAS_WB) += wbflush.o 10obj-$(CONFIG_CPU_HAS_WB) += wbflush.o
11
12EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/defconfig b/arch/mips/defconfig
index b3b6e58058f6..d3d81fb2765a 100644
--- a/arch/mips/defconfig
+++ b/arch/mips/defconfig
@@ -32,12 +32,9 @@ CONFIG_ZONE_DMA=y
32# CONFIG_WR_PPMC is not set 32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MOMENCO_OCELOT is not set
36# CONFIG_MOMENCO_OCELOT_G is not set
37# CONFIG_MIPS_XXS1500 is not set 35# CONFIG_MIPS_XXS1500 is not set
38# CONFIG_PNX8550_JBS is not set 36# CONFIG_PNX8550_JBS is not set
39# CONFIG_PNX8550_STB810 is not set 37# CONFIG_PNX8550_STB810 is not set
40# CONFIG_DDB5477 is not set
41# CONFIG_MACH_VR41XX is not set 38# CONFIG_MACH_VR41XX is not set
42# CONFIG_PMC_YOSEMITE is not set 39# CONFIG_PMC_YOSEMITE is not set
43# CONFIG_QEMU is not set 40# CONFIG_QEMU is not set
diff --git a/arch/mips/gt64120/common/Makefile b/arch/mips/gt64120/common/Makefile
deleted file mode 100644
index 1ef676e22ab4..000000000000
--- a/arch/mips/gt64120/common/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for common code of gt64120-based boards.
3#
4
5obj-y += time.o
diff --git a/arch/mips/gt64120/common/time.c b/arch/mips/gt64120/common/time.c
deleted file mode 100644
index c47eeb768192..000000000000
--- a/arch/mips/gt64120/common/time.c
+++ /dev/null
@@ -1,101 +0,0 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * Galileo Technology chip interrupt handler
8 */
9#include <linux/interrupt.h>
10#include <linux/kernel.h>
11#include <linux/sched.h>
12#include <linux/kernel_stat.h>
13#include <asm/irq_regs.h>
14#include <asm/gt64120.h>
15
16/*
17 * These are interrupt handlers for the GT on-chip interrupts. They all come
18 * in to the MIPS on a single interrupt line, and have to be handled and ack'ed
19 * differently than other MIPS interrupts.
20 */
21
22static irqreturn_t gt64120_irq(int irq, void *dev_id)
23{
24 unsigned int irq_src, int_high_src, irq_src_mask, int_high_src_mask;
25 int handled = 0;
26
27 irq_src = GT_READ(GT_INTRCAUSE_OFS);
28 irq_src_mask = GT_READ(GT_INTRMASK_OFS);
29 int_high_src = GT_READ(GT_HINTRCAUSE_OFS);
30 int_high_src_mask = GT_READ(GT_HINTRMASK_OFS);
31 irq_src = irq_src & irq_src_mask;
32 int_high_src = int_high_src & int_high_src_mask;
33
34 if (irq_src & 0x00000800) { /* Check for timer interrupt */
35 handled = 1;
36 irq_src &= ~0x00000800;
37 do_timer(1);
38#ifndef CONFIG_SMP
39 update_process_times(user_mode(get_irq_regs()));
40#endif
41 }
42
43 GT_WRITE(GT_INTRCAUSE_OFS, 0);
44 GT_WRITE(GT_HINTRCAUSE_OFS, 0);
45
46 return IRQ_HANDLED;
47}
48
49/*
50 * Initializes timer using galileo's built in timer.
51 */
52#ifdef CONFIG_SYSCLK_100
53#define Sys_clock (100 * 1000000) // 100 MHz
54#endif
55#ifdef CONFIG_SYSCLK_83
56#define Sys_clock (83.333 * 1000000) // 83.333 MHz
57#endif
58#ifdef CONFIG_SYSCLK_75
59#define Sys_clock (75 * 1000000) // 75 MHz
60#endif
61
62/*
63 * This will ignore the standard MIPS timer interrupt handler that is passed in
64 * as *irq (=irq0 in ../kernel/time.c). We will do our own timer interrupt
65 * handling.
66 */
67void __init plat_timer_setup(struct irqaction *irq)
68{
69 static struct irqaction timer;
70
71 /* Disable timer first */
72 GT_WRITE(GT_TC_CONTROL_OFS, 0);
73 /* Load timer value for 100 Hz */
74 GT_WRITE(GT_TC3_OFS, Sys_clock / HZ);
75
76 /*
77 * Create the IRQ structure entry for the timer. Since we're too early
78 * in the boot process to use the "request_irq()" call, we'll hard-code
79 * the values to the correct interrupt line.
80 */
81 timer.handler = gt64120_irq;
82 timer.flags = IRQF_SHARED | IRQF_DISABLED;
83 timer.name = "timer";
84 timer.dev_id = NULL;
85 timer.next = NULL;
86 timer.mask = CPU_MASK_NONE;
87 irq_desc[GT_TIMER].action = &timer;
88
89 enable_irq(GT_TIMER);
90
91 /* Enable timer ints */
92 GT_WRITE(GT_TC_CONTROL_OFS, 0xc0);
93 /* clear Cause register first */
94 GT_WRITE(GT_INTRCAUSE_OFS, 0x0);
95 /* Unmask timer int */
96 GT_WRITE(GT_INTRMASK_OFS, 0x800);
97 /* Clear High int register */
98 GT_WRITE(GT_HINTRCAUSE_OFS, 0x0);
99 /* Mask All interrupts at High cause interrupt */
100 GT_WRITE(GT_HINTRMASK_OFS, 0x0);
101}
diff --git a/arch/mips/gt64120/momenco_ocelot/Makefile b/arch/mips/gt64120/momenco_ocelot/Makefile
deleted file mode 100644
index 1df5fe23c642..000000000000
--- a/arch/mips/gt64120/momenco_ocelot/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
1#
2# Makefile for Momentum's Ocelot board.
3#
4
5obj-y += irq.o ocelot-platform.o prom.o reset.o setup.o
6
7obj-$(CONFIG_KGDB) += dbg_io.o
diff --git a/arch/mips/gt64120/momenco_ocelot/dbg_io.c b/arch/mips/gt64120/momenco_ocelot/dbg_io.c
deleted file mode 100644
index 32d6fb4ee679..000000000000
--- a/arch/mips/gt64120/momenco_ocelot/dbg_io.c
+++ /dev/null
@@ -1,121 +0,0 @@
1
2#include <asm/serial.h> /* For the serial port location and base baud */
3
4/* --- CONFIG --- */
5
6typedef unsigned char uint8;
7typedef unsigned int uint32;
8
9/* --- END OF CONFIG --- */
10
11#define UART16550_BAUD_2400 2400
12#define UART16550_BAUD_4800 4800
13#define UART16550_BAUD_9600 9600
14#define UART16550_BAUD_19200 19200
15#define UART16550_BAUD_38400 38400
16#define UART16550_BAUD_57600 57600
17#define UART16550_BAUD_115200 115200
18
19#define UART16550_PARITY_NONE 0
20#define UART16550_PARITY_ODD 0x08
21#define UART16550_PARITY_EVEN 0x18
22#define UART16550_PARITY_MARK 0x28
23#define UART16550_PARITY_SPACE 0x38
24
25#define UART16550_DATA_5BIT 0x0
26#define UART16550_DATA_6BIT 0x1
27#define UART16550_DATA_7BIT 0x2
28#define UART16550_DATA_8BIT 0x3
29
30#define UART16550_STOP_1BIT 0x0
31#define UART16550_STOP_2BIT 0x4
32
33/* ----------------------------------------------------- */
34
35/* === CONFIG === */
36
37/* [jsun] we use the second serial port for kdb */
38#define BASE OCELOT_SERIAL1_BASE
39#define MAX_BAUD OCELOT_BASE_BAUD
40
41/* === END OF CONFIG === */
42
43#define REG_OFFSET 4
44
45/* register offset */
46#define OFS_RCV_BUFFER 0
47#define OFS_TRANS_HOLD 0
48#define OFS_SEND_BUFFER 0
49#define OFS_INTR_ENABLE (1*REG_OFFSET)
50#define OFS_INTR_ID (2*REG_OFFSET)
51#define OFS_DATA_FORMAT (3*REG_OFFSET)
52#define OFS_LINE_CONTROL (3*REG_OFFSET)
53#define OFS_MODEM_CONTROL (4*REG_OFFSET)
54#define OFS_RS232_OUTPUT (4*REG_OFFSET)
55#define OFS_LINE_STATUS (5*REG_OFFSET)
56#define OFS_MODEM_STATUS (6*REG_OFFSET)
57#define OFS_RS232_INPUT (6*REG_OFFSET)
58#define OFS_SCRATCH_PAD (7*REG_OFFSET)
59
60#define OFS_DIVISOR_LSB (0*REG_OFFSET)
61#define OFS_DIVISOR_MSB (1*REG_OFFSET)
62
63
64/* memory-mapped read/write of the port */
65#define UART16550_READ(y) (*((volatile uint8*)(BASE + y)))
66#define UART16550_WRITE(y, z) ((*((volatile uint8*)(BASE + y))) = z)
67
68void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
69{
70 /* disable interrupts */
71 UART16550_WRITE(OFS_INTR_ENABLE, 0);
72
73 /* set up baud rate */
74 {
75 uint32 divisor;
76
77 /* set DIAB bit */
78 UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
79
80 /* set divisor */
81 divisor = MAX_BAUD / baud;
82 UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
83 UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8);
84
85 /* clear DIAB bit */
86 UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
87 }
88
89 /* set data format */
90 UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
91}
92
93static int remoteDebugInitialized = 0;
94
95uint8 getDebugChar(void)
96{
97 if (!remoteDebugInitialized) {
98 remoteDebugInitialized = 1;
99 debugInit(UART16550_BAUD_38400,
100 UART16550_DATA_8BIT,
101 UART16550_PARITY_NONE, UART16550_STOP_1BIT);
102 }
103
104 while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0);
105 return UART16550_READ(OFS_RCV_BUFFER);
106}
107
108
109int putDebugChar(uint8 byte)
110{
111 if (!remoteDebugInitialized) {
112 remoteDebugInitialized = 1;
113 debugInit(UART16550_BAUD_38400,
114 UART16550_DATA_8BIT,
115 UART16550_PARITY_NONE, UART16550_STOP_1BIT);
116 }
117
118 while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0);
119 UART16550_WRITE(OFS_SEND_BUFFER, byte);
120 return 1;
121}
diff --git a/arch/mips/gt64120/momenco_ocelot/irq.c b/arch/mips/gt64120/momenco_ocelot/irq.c
deleted file mode 100644
index 2585d9dbda33..000000000000
--- a/arch/mips/gt64120/momenco_ocelot/irq.c
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * Copyright (C) 2000 RidgeRun, Inc.
3 * Author: RidgeRun, Inc.
4 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
5 *
6 * Copyright 2001 MontaVista Software Inc.
7 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
8 * Copyright (C) 2000, 2001, 2003 Ralf Baechle (ralf@gnu.org)
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
21 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 *
30 */
31#include <linux/errno.h>
32#include <linux/init.h>
33#include <linux/kernel_stat.h>
34#include <linux/module.h>
35#include <linux/signal.h>
36#include <linux/sched.h>
37#include <linux/types.h>
38#include <linux/interrupt.h>
39#include <linux/ioport.h>
40#include <linux/timex.h>
41#include <linux/slab.h>
42#include <linux/random.h>
43#include <linux/bitops.h>
44#include <asm/bootinfo.h>
45#include <asm/io.h>
46#include <asm/irq.h>
47#include <asm/irq_cpu.h>
48#include <asm/mipsregs.h>
49#include <asm/system.h>
50
51asmlinkage void plat_irq_dispatch(void)
52{
53 unsigned int pending = read_c0_status() & read_c0_cause();
54
55 if (pending & STATUSF_IP2) /* int0 hardware line */
56 do_IRQ(2);
57 else if (pending & STATUSF_IP3) /* int1 hardware line */
58 do_IRQ(3);
59 else if (pending & STATUSF_IP4) /* int2 hardware line */
60 do_IRQ(4);
61 else if (pending & STATUSF_IP5) /* int3 hardware line */
62 do_IRQ(5);
63 else if (pending & STATUSF_IP6) /* int4 hardware line */
64 do_IRQ(6);
65 else if (pending & STATUSF_IP7) /* cpu timer */
66 do_IRQ(7);
67 else {
68 /*
69 * Now look at the extended interrupts
70 */
71 pending = (read_c0_cause() & (read_c0_intcontrol() << 8)) >> 16;
72
73 if (pending & STATUSF_IP8) /* int6 hardware line */
74 do_IRQ(8);
75 else if (pending & STATUSF_IP9) /* int7 hardware line */
76 do_IRQ(9);
77 else if (pending & STATUSF_IP10) /* int8 hardware line */
78 do_IRQ(10);
79 else if (pending & STATUSF_IP11) /* int9 hardware line */
80 do_IRQ(11);
81 }
82}
83
84void __init arch_init_irq(void)
85{
86 /*
87 * Clear all of the interrupts while we change the able around a bit.
88 * int-handler is not on bootstrap
89 */
90 clear_c0_status(ST0_IM);
91 local_irq_disable();
92
93 mips_cpu_irq_init();
94 rm7k_cpu_irq_init();
95}
diff --git a/arch/mips/gt64120/momenco_ocelot/ocelot-platform.c b/arch/mips/gt64120/momenco_ocelot/ocelot-platform.c
deleted file mode 100644
index 81d9031a5a2a..000000000000
--- a/arch/mips/gt64120/momenco_ocelot/ocelot-platform.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
7 *
8 * A NS16552 DUART with a 20MHz crystal.
9 *
10 */
11#include <linux/module.h>
12#include <linux/init.h>
13#include <linux/serial_8250.h>
14
15#define OCELOT_UART_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP)
16
17static struct plat_serial8250_port uart8250_data[] = {
18 {
19 .mapbase = 0xe0001020,
20 .irq = 4,
21 .uartclk = 20000000,
22 .iotype = UPIO_MEM,
23 .flags = OCELOT_UART_FLAGS,
24 .regshift = 2,
25 },
26 { },
27};
28
29static struct platform_device uart8250_device = {
30 .name = "serial8250",
31 .id = PLAT8250_DEV_PLATFORM,
32 .dev = {
33 .platform_data = uart8250_data,
34 },
35};
36
37static int __init uart8250_init(void)
38{
39 return platform_device_register(&uart8250_device);
40}
41
42module_init(uart8250_init);
43
44MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
45MODULE_LICENSE("GPL");
46MODULE_DESCRIPTION("8250 UART probe driver for the Momenco Ocelot");
diff --git a/arch/mips/gt64120/momenco_ocelot/ocelot_pld.h b/arch/mips/gt64120/momenco_ocelot/ocelot_pld.h
deleted file mode 100644
index 11f02c402b2a..000000000000
--- a/arch/mips/gt64120/momenco_ocelot/ocelot_pld.h
+++ /dev/null
@@ -1,30 +0,0 @@
1/*
2 * Ocelot Board Register Definitions
3 *
4 * (C) 2001 Red Hat, Inc.
5 *
6 * GPL'd
7 */
8#ifndef __MOMENCO_OCELOT_PLD_H__
9#define __MOMENCO_OCELOT_PLD_H__
10
11#define OCELOT_CS0_ADDR (0xe0020000)
12
13#define OCELOT_REG_BOARDREV (0)
14#define OCELOT_REG_PLD1_ID (1)
15#define OCELOT_REG_PLD2_ID (2)
16#define OCELOT_REG_RESET_STATUS (3)
17#define OCELOT_REG_BOARD_STATUS (4)
18#define OCELOT_REG_CPCI_ID (5)
19#define OCELOT_REG_I2C_CTRL (8)
20#define OCELOT_REG_EEPROM_MODE (9)
21#define OCELOT_REG_INTMASK (10)
22#define OCELOT_REG_INTSTATUS (11)
23#define OCELOT_REG_INTSET (12)
24#define OCELOT_REG_INTCLR (13)
25
26#define OCELOT_PLD_WRITE(x, y) writeb(x, OCELOT_CS0_ADDR + OCELOT_REG_##y)
27#define OCELOT_PLD_READ(x) readb(OCELOT_CS0_ADDR + OCELOT_REG_##x)
28
29
30#endif /* __MOMENCO_OCELOT_PLD_H__ */
diff --git a/arch/mips/gt64120/momenco_ocelot/prom.c b/arch/mips/gt64120/momenco_ocelot/prom.c
deleted file mode 100644
index c71c85276c74..000000000000
--- a/arch/mips/gt64120/momenco_ocelot/prom.c
+++ /dev/null
@@ -1,71 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: jsun@mvista.com or jsun@junsun.net
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
10#include <linux/init.h>
11#include <linux/mm.h>
12#include <linux/sched.h>
13#include <linux/bootmem.h>
14
15#include <asm/addrspace.h>
16#include <asm/bootinfo.h>
17#include <asm/pmon.h>
18
19struct callvectors* debug_vectors;
20
21extern unsigned long gt64120_base;
22
23const char *get_system_type(void)
24{
25 return "Momentum Ocelot";
26}
27
28/* [jsun@junsun.net] PMON passes arguments in C main() style */
29void __init prom_init(void)
30{
31 int argc = fw_arg0;
32 char **arg = (char **) fw_arg1;
33 char **env = (char **) fw_arg2;
34 struct callvectors *cv = (struct callvectors *) fw_arg3;
35 int i;
36
37 /* save the PROM vectors for debugging use */
38 debug_vectors = cv;
39
40 /* arg[0] is "g", the rest is boot parameters */
41 arcs_cmdline[0] = '\0';
42 for (i = 1; i < argc; i++) {
43 if (strlen(arcs_cmdline) + strlen(arg[i] + 1)
44 >= sizeof(arcs_cmdline))
45 break;
46 strcat(arcs_cmdline, arg[i]);
47 strcat(arcs_cmdline, " ");
48 }
49
50 mips_machgroup = MACH_GROUP_MOMENCO;
51 mips_machtype = MACH_MOMENCO_OCELOT;
52
53 while (*env) {
54 if (strncmp("gtbase", *env, 6) == 0) {
55 gt64120_base = simple_strtol(*env + strlen("gtbase="),
56 NULL, 16);
57 break;
58 }
59 *env++;
60 }
61
62 debug_vectors->printf("Booting Linux kernel...\n");
63
64 /* All the boards have at least 64MiB. If there's more, we
65 detect and register it later */
66 add_memory_region(0, 64 << 20, BOOT_MEM_RAM);
67}
68
69void __init prom_free_prom_memory(void)
70{
71}
diff --git a/arch/mips/gt64120/momenco_ocelot/reset.c b/arch/mips/gt64120/momenco_ocelot/reset.c
deleted file mode 100644
index 3fd499adf4cf..000000000000
--- a/arch/mips/gt64120/momenco_ocelot/reset.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * Copyright (C) 1997, 2001 Ralf Baechle
8 * Copyright 2001 MontaVista Software Inc.
9 * Author: jsun@mvista.com or jsun@junsun.net
10 */
11#include <linux/sched.h>
12#include <linux/mm.h>
13#include <asm/io.h>
14#include <asm/pgtable.h>
15#include <asm/processor.h>
16#include <asm/reboot.h>
17#include <asm/system.h>
18#include <linux/delay.h>
19
20void momenco_ocelot_restart(char *command)
21{
22 void *nvram = ioremap_nocache(0x2c807000, 0x1000);
23
24 if (!nvram) {
25 printk(KERN_NOTICE "ioremap of reset register failed\n");
26 return;
27 }
28 writeb(0x84, nvram + 0xff7); /* Ask the NVRAM/RTC/watchdog chip to
29 assert reset in 1/16 second */
30 mdelay(10+(1000/16));
31 iounmap(nvram);
32 printk(KERN_NOTICE "Watchdog reset failed\n");
33}
34
35void momenco_ocelot_halt(void)
36{
37 printk(KERN_NOTICE "\n** You can safely turn off the power\n");
38 while (1)
39 __asm__(".set\tmips3\n\t"
40 "wait\n\t"
41 ".set\tmips0");
42}
43
44void momenco_ocelot_power_off(void)
45{
46 momenco_ocelot_halt();
47}
diff --git a/arch/mips/gt64120/momenco_ocelot/setup.c b/arch/mips/gt64120/momenco_ocelot/setup.c
deleted file mode 100644
index 98b6fb38096d..000000000000
--- a/arch/mips/gt64120/momenco_ocelot/setup.c
+++ /dev/null
@@ -1,365 +0,0 @@
1/*
2 * setup.c
3 *
4 * BRIEF MODULE DESCRIPTION
5 * Momentum Computer Ocelot (CP7000) - board dependent boot routines
6 *
7 * Copyright (C) 1996, 1997, 2001, 06 Ralf Baechle (ralf@linux-mips.org)
8 * Copyright (C) 2000 RidgeRun, Inc.
9 * Copyright (C) 2001 Red Hat, Inc.
10 * Copyright (C) 2002 Momentum Computer
11 *
12 * Author: RidgeRun, Inc.
13 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
14 *
15 * Copyright 2001 MontaVista Software Inc.
16 * Author: jsun@mvista.com or jsun@junsun.net
17 *
18 * This program is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License as published by the
20 * Free Software Foundation; either version 2 of the License, or (at your
21 * option) any later version.
22 *
23 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
26 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 * You should have received a copy of the GNU General Public License along
35 * with this program; if not, write to the Free Software Foundation, Inc.,
36 * 675 Mass Ave, Cambridge, MA 02139, USA.
37 *
38 */
39#include <linux/init.h>
40#include <linux/kernel.h>
41#include <linux/types.h>
42#include <linux/mm.h>
43#include <linux/swap.h>
44#include <linux/ioport.h>
45#include <linux/sched.h>
46#include <linux/interrupt.h>
47#include <linux/pci.h>
48#include <linux/timex.h>
49#include <linux/vmalloc.h>
50#include <linux/pm.h>
51
52#include <asm/time.h>
53#include <asm/bootinfo.h>
54#include <asm/page.h>
55#include <asm/io.h>
56#include <asm/irq.h>
57#include <asm/pci.h>
58#include <asm/processor.h>
59#include <asm/reboot.h>
60#include <asm/traps.h>
61#include <linux/bootmem.h>
62#include <linux/initrd.h>
63#include <asm/gt64120.h>
64#include "ocelot_pld.h"
65
66unsigned long gt64120_base = KSEG1ADDR(GT_DEF_BASE);
67
68/* These functions are used for rebooting or halting the machine*/
69extern void momenco_ocelot_restart(char *command);
70extern void momenco_ocelot_halt(void);
71extern void momenco_ocelot_power_off(void);
72
73extern void momenco_ocelot_irq_setup(void);
74
75static char reset_reason;
76
77#define ENTRYLO(x) ((pte_val(pfn_pte((x) >> PAGE_SHIFT, PAGE_KERNEL_UNCACHED)) >> 6)|1)
78
79static void __init setup_l3cache(unsigned long size);
80
81/* setup code for a handoff from a version 1 PMON 2000 PROM */
82static void PMON_v1_setup(void)
83{
84 /* A wired TLB entry for the GT64120A and the serial port. The
85 GT64120A is going to be hit on every IRQ anyway - there's
86 absolutely no point in letting it be a random TLB entry, as
87 it'll just cause needless churning of the TLB. And we use
88 the other half for the serial port, which is just a PITA
89 otherwise :)
90
91 Device Physical Virtual
92 GT64120 Internal Regs 0x24000000 0xe0000000
93 UARTs (CS2) 0x2d000000 0xe0001000
94 */
95 add_wired_entry(ENTRYLO(0x24000000), ENTRYLO(0x2D000000), 0xe0000000, PM_4K);
96
97 /* Also a temporary entry to let us talk to the Ocelot PLD and NVRAM
98 in the CS[012] region. We can't use ioremap() yet. The NVRAM
99 is a ST M48T37Y, which includes NVRAM, RTC, and Watchdog functions.
100
101 Ocelot PLD (CS0) 0x2c000000 0xe0020000
102 NVRAM 0x2c800000 0xe0030000
103 */
104
105 add_temporary_entry(ENTRYLO(0x2C000000), ENTRYLO(0x2d000000), 0xe0020000, PM_64K);
106
107 /* Relocate the CS3/BootCS region */
108 GT_WRITE(GT_CS3BOOTLD_OFS, 0x2f000000 >> 21);
109
110 /* Relocate CS[012] */
111 GT_WRITE(GT_CS20LD_OFS, 0x2c000000 >> 21);
112
113 /* Relocate the GT64120A itself... */
114 GT_WRITE(GT_ISD_OFS, 0x24000000 >> 21);
115 mb();
116 gt64120_base = 0xe0000000;
117
118 /* ...and the PCI0 view of it. */
119 GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000020);
120 GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x24000000);
121 GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000024);
122 GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x24000001);
123}
124
125/* setup code for a handoff from a version 2 PMON 2000 PROM */
126void PMON_v2_setup()
127{
128 /* A wired TLB entry for the GT64120A and the serial port. The
129 GT64120A is going to be hit on every IRQ anyway - there's
130 absolutely no point in letting it be a random TLB entry, as
131 it'll just cause needless churning of the TLB. And we use
132 the other half for the serial port, which is just a PITA
133 otherwise :)
134
135 Device Physical Virtual
136 GT64120 Internal Regs 0xf4000000 0xe0000000
137 UARTs (CS2) 0xfd000000 0xe0001000
138 */
139 add_wired_entry(ENTRYLO(0xf4000000), ENTRYLO(0xfD000000), 0xe0000000, PM_4K);
140
141 /* Also a temporary entry to let us talk to the Ocelot PLD and NVRAM
142 in the CS[012] region. We can't use ioremap() yet. The NVRAM
143 is a ST M48T37Y, which includes NVRAM, RTC, and Watchdog functions.
144
145 Ocelot PLD (CS0) 0xfc000000 0xe0020000
146 NVRAM 0xfc800000 0xe0030000
147 */
148 add_temporary_entry(ENTRYLO(0xfC000000), ENTRYLO(0xfd000000), 0xe0020000, PM_64K);
149
150 gt64120_base = 0xe0000000;
151}
152
153void __init plat_mem_setup(void)
154{
155 void (*l3func)(unsigned long)=KSEG1ADDR(&setup_l3cache);
156 unsigned int tmpword;
157
158 _machine_restart = momenco_ocelot_restart;
159 _machine_halt = momenco_ocelot_halt;
160 pm_power_off = momenco_ocelot_power_off;
161
162 /*
163 * initrd_start = (unsigned long)ocelot_initrd_start;
164 * initrd_end = (unsigned long)ocelot_initrd_start + (ulong)ocelot_initrd_size;
165 * initrd_below_start_ok = 1;
166 */
167
168 /* do handoff reconfiguration */
169 if (gt64120_base == KSEG1ADDR(GT_DEF_BASE))
170 PMON_v1_setup();
171 else
172 PMON_v2_setup();
173
174 /* Turn off the Bit-Error LED */
175 OCELOT_PLD_WRITE(0x80, INTCLR);
176
177 /* Relocate all the PCI1 stuff, not that we use it */
178 GT_WRITE(GT_PCI1IOLD_OFS, 0x30000000 >> 21);
179 GT_WRITE(GT_PCI1M0LD_OFS, 0x32000000 >> 21);
180 GT_WRITE(GT_PCI1M1LD_OFS, 0x34000000 >> 21);
181
182 /* Relocate PCI0 I/O and Mem0 */
183 GT_WRITE(GT_PCI0IOLD_OFS, 0x20000000 >> 21);
184 GT_WRITE(GT_PCI0M0LD_OFS, 0x22000000 >> 21);
185
186 /* Relocate PCI0 Mem1 */
187 GT_WRITE(GT_PCI0M1LD_OFS, 0x36000000 >> 21);
188
189 /* For the initial programming, we assume 512MB configuration */
190 /* Relocate the CPU's view of the RAM... */
191 GT_WRITE(GT_SCS10LD_OFS, 0);
192 GT_WRITE(GT_SCS10HD_OFS, 0x0fe00000 >> 21);
193 GT_WRITE(GT_SCS32LD_OFS, 0x10000000 >> 21);
194 GT_WRITE(GT_SCS32HD_OFS, 0x0fe00000 >> 21);
195
196 GT_WRITE(GT_SCS1LD_OFS, 0xff);
197 GT_WRITE(GT_SCS1HD_OFS, 0x00);
198 GT_WRITE(GT_SCS0LD_OFS, 0);
199 GT_WRITE(GT_SCS0HD_OFS, 0xff);
200 GT_WRITE(GT_SCS3LD_OFS, 0xff);
201 GT_WRITE(GT_SCS3HD_OFS, 0x00);
202 GT_WRITE(GT_SCS2LD_OFS, 0);
203 GT_WRITE(GT_SCS2HD_OFS, 0xff);
204
205 /* ...and the PCI0 view of it. */
206 GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000010);
207 GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x00000000);
208 GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000014);
209 GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x10000000);
210 GT_WRITE(GT_PCI0_BS_SCS10_OFS, 0x0ffff000);
211 GT_WRITE(GT_PCI0_BS_SCS32_OFS, 0x0ffff000);
212
213 tmpword = OCELOT_PLD_READ(BOARDREV);
214 if (tmpword < 26)
215 printk("Momenco Ocelot: Board Assembly Rev. %c\n", 'A'+tmpword);
216 else
217 printk("Momenco Ocelot: Board Assembly Revision #0x%x\n", tmpword);
218
219 tmpword = OCELOT_PLD_READ(PLD1_ID);
220 printk("PLD 1 ID: %d.%d\n", tmpword>>4, tmpword&15);
221 tmpword = OCELOT_PLD_READ(PLD2_ID);
222 printk("PLD 2 ID: %d.%d\n", tmpword>>4, tmpword&15);
223 tmpword = OCELOT_PLD_READ(RESET_STATUS);
224 printk("Reset reason: 0x%x\n", tmpword);
225 reset_reason = tmpword;
226 OCELOT_PLD_WRITE(0xff, RESET_STATUS);
227
228 tmpword = OCELOT_PLD_READ(BOARD_STATUS);
229 printk("Board Status register: 0x%02x\n", tmpword);
230 printk(" - User jumper: %s\n", (tmpword & 0x80)?"installed":"absent");
231 printk(" - Boot flash write jumper: %s\n", (tmpword&0x40)?"installed":"absent");
232 printk(" - Tulip PHY %s connected\n", (tmpword&0x10)?"is":"not");
233 printk(" - L3 Cache size: %d MiB\n", (1<<((tmpword&12) >> 2))&~1);
234 printk(" - SDRAM size: %d MiB\n", 1<<(6+(tmpword&3)));
235
236 if (tmpword&12)
237 l3func((1<<(((tmpword&12) >> 2)+20)));
238
239 switch(tmpword &3) {
240 case 3:
241 /* 512MiB */
242 /* Decoders are allready set -- just add the
243 * appropriate region */
244 add_memory_region( 0x40<<20, 0xC0<<20, BOOT_MEM_RAM);
245 add_memory_region(0x100<<20, 0x100<<20, BOOT_MEM_RAM);
246 break;
247 case 2:
248 /* 256MiB -- two banks of 128MiB */
249 GT_WRITE(GT_SCS10HD_OFS, 0x07e00000 >> 21);
250 GT_WRITE(GT_SCS32LD_OFS, 0x08000000 >> 21);
251 GT_WRITE(GT_SCS32HD_OFS, 0x0fe00000 >> 21);
252
253 GT_WRITE(GT_SCS0HD_OFS, 0x7f);
254 GT_WRITE(GT_SCS2LD_OFS, 0x80);
255 GT_WRITE(GT_SCS2HD_OFS, 0xff);
256
257 /* reconfigure the PCI0 interface view of memory */
258 GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000014);
259 GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x08000000);
260 GT_WRITE(GT_PCI0_BS_SCS10_OFS, 0x0ffff000);
261 GT_WRITE(GT_PCI0_BS_SCS32_OFS, 0x0ffff000);
262
263 add_memory_region(0x40<<20, 0x40<<20, BOOT_MEM_RAM);
264 add_memory_region(0x80<<20, 0x80<<20, BOOT_MEM_RAM);
265 break;
266 case 1:
267 /* 128MiB -- 64MiB per bank */
268 GT_WRITE(GT_SCS10HD_OFS, 0x03e00000 >> 21);
269 GT_WRITE(GT_SCS32LD_OFS, 0x04000000 >> 21);
270 GT_WRITE(GT_SCS32HD_OFS, 0x07e00000 >> 21);
271
272 GT_WRITE(GT_SCS0HD_OFS, 0x3f);
273 GT_WRITE(GT_SCS2LD_OFS, 0x40);
274 GT_WRITE(GT_SCS2HD_OFS, 0x7f);
275
276 /* reconfigure the PCI0 interface view of memory */
277 GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000014);
278 GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x04000000);
279 GT_WRITE(GT_PCI0_BS_SCS10_OFS, 0x03fff000);
280 GT_WRITE(GT_PCI0_BS_SCS32_OFS, 0x03fff000);
281
282 /* add the appropriate region */
283 add_memory_region(0x40<<20, 0x40<<20, BOOT_MEM_RAM);
284 break;
285 case 0:
286 /* 64MiB */
287 GT_WRITE(GT_SCS10HD_OFS, 0x01e00000 >> 21);
288 GT_WRITE(GT_SCS32LD_OFS, 0x02000000 >> 21);
289 GT_WRITE(GT_SCS32HD_OFS, 0x03e00000 >> 21);
290
291 GT_WRITE(GT_SCS0HD_OFS, 0x1f);
292 GT_WRITE(GT_SCS2LD_OFS, 0x20);
293 GT_WRITE(GT_SCS2HD_OFS, 0x3f);
294
295 /* reconfigure the PCI0 interface view of memory */
296 GT_WRITE(GT_PCI0_CFGADDR_OFS, 0x80000014);
297 GT_WRITE(GT_PCI0_CFGDATA_OFS, 0x04000000);
298 GT_WRITE(GT_PCI0_BS_SCS10_OFS, 0x01fff000);
299 GT_WRITE(GT_PCI0_BS_SCS32_OFS, 0x01fff000);
300
301 break;
302 }
303
304 /* Fix up the DiskOnChip mapping */
305 GT_WRITE(GT_DEV_B3_OFS, 0xfef73);
306}
307
308extern int rm7k_tcache_enabled;
309/*
310 * This runs in KSEG1. See the verbiage in rm7k.c::probe_scache()
311 */
312#define Page_Invalidate_T 0x16
313static void __init setup_l3cache(unsigned long size)
314{
315 int register i;
316 unsigned long tmp;
317
318 printk("Enabling L3 cache...");
319
320 /* Enable the L3 cache in the GT64120A's CPU Configuration register */
321 tmp = GT_READ(GT_CPU_OFS);
322 GT_WRITE(GT_CPU_OFS, tmp | (1<<14));
323
324 /* Enable the L3 cache in the CPU */
325 set_c0_config(1<<12 /* CONF_TE */);
326
327 /* Clear the cache */
328 write_c0_taglo(0);
329 write_c0_taghi(0);
330
331 for (i=0; i < size; i+= 4096) {
332 __asm__ __volatile__ (
333 ".set noreorder\n\t"
334 ".set mips3\n\t"
335 "cache %1, (%0)\n\t"
336 ".set mips0\n\t"
337 ".set reorder"
338 :
339 : "r" (KSEG0ADDR(i)),
340 "i" (Page_Invalidate_T));
341 }
342
343 /* Let the RM7000 MM code know that the tertiary cache is enabled */
344 rm7k_tcache_enabled = 1;
345
346 printk("Done\n");
347}
348
349
350/* This needs to be one of the first initcalls, because no I/O port access
351 can work before this */
352
353static int io_base_ioremap(void)
354{
355 void *io_remap_range = ioremap(GT_PCI_IO_BASE, GT_PCI_IO_SIZE);
356
357 if (!io_remap_range) {
358 panic("Could not ioremap I/O port range");
359 }
360 set_io_port_base(io_remap_range - GT_PCI_IO_BASE);
361
362 return 0;
363}
364
365module_init(io_base_ioremap);
diff --git a/arch/mips/gt64120/wrppmc/Makefile b/arch/mips/gt64120/wrppmc/Makefile
index e4250435ad89..bef15c90ae15 100644
--- a/arch/mips/gt64120/wrppmc/Makefile
+++ b/arch/mips/gt64120/wrppmc/Makefile
@@ -10,3 +10,5 @@
10# 10#
11 11
12obj-y += irq.o reset.o setup.o time.o pci.o 12obj-y += irq.o reset.o setup.o time.o pci.o
13
14EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/jazz/Makefile b/arch/mips/jazz/Makefile
index ae4c402b5004..575a9442bc82 100644
--- a/arch/mips/jazz/Makefile
+++ b/arch/mips/jazz/Makefile
@@ -3,3 +3,5 @@
3# 3#
4 4
5obj-y := irq.o jazzdma.o jazz-platform.o reset.o setup.o 5obj-y := irq.o jazzdma.o jazz-platform.o reset.o setup.o
6
7EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/jazz/io.c b/arch/mips/jazz/io.c
deleted file mode 100644
index e86904454c89..000000000000
--- a/arch/mips/jazz/io.c
+++ /dev/null
@@ -1,135 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Low level I/O functions for Jazz family machines.
7 *
8 * Copyright (C) 1997 by Ralf Baechle.
9 */
10#include <linux/string.h>
11#include <linux/spinlock.h>
12#include <asm/addrspace.h>
13#include <asm/system.h>
14#include <asm/jazz.h>
15
16/*
17 * Map an 16mb segment of the EISA address space to 0xe3000000;
18 */
19static inline void map_eisa_address(unsigned long address)
20{
21 /* XXX */
22 /* We've got an wired entry in the TLB. We just need to modify it.
23 fast and clean. But since we want to get rid of wired entries
24 things are a little bit more complicated ... */
25}
26
27static unsigned char jazz_readb(unsigned long addr)
28{
29 unsigned char res;
30
31 map_eisa_address(addr);
32 addr &= 0xffffff;
33 res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr);
34
35 return res;
36}
37
38static unsigned short jazz_readw(unsigned long addr)
39{
40 unsigned short res;
41
42 map_eisa_address(addr);
43 addr &= 0xffffff;
44 res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr);
45
46 return res;
47}
48
49static unsigned int jazz_readl(unsigned long addr)
50{
51 unsigned int res;
52
53 map_eisa_address(addr);
54 addr &= 0xffffff;
55 res = *(volatile unsigned char *) (JAZZ_EISA_BASE + addr);
56
57 return res;
58}
59
60static void jazz_writeb(unsigned char val, unsigned long addr)
61{
62 map_eisa_address(addr);
63 addr &= 0xffffff;
64 *(volatile unsigned char *) (JAZZ_EISA_BASE + addr) = val;
65}
66
67static void jazz_writew(unsigned short val, unsigned long addr)
68{
69 map_eisa_address(addr);
70 addr &= 0xffffff;
71 *(volatile unsigned char *) (JAZZ_EISA_BASE + addr) = val;
72}
73
74static void jazz_writel(unsigned int val, unsigned long addr)
75{
76 map_eisa_address(addr);
77 addr &= 0xffffff;
78 *(volatile unsigned char *) (JAZZ_EISA_BASE + addr) = val;
79}
80
81static void jazz_memset_io(unsigned long addr, int val, unsigned long len)
82{
83 unsigned long waddr;
84
85 waddr = JAZZ_EISA_BASE | (addr & 0xffffff);
86 while(len) {
87 unsigned long fraglen;
88
89 fraglen = (~addr + 1) & 0xffffff;
90 fraglen = (fraglen < len) ? fraglen : len;
91 map_eisa_address(addr);
92 memset((char *)waddr, val, fraglen);
93 addr += fraglen;
94 waddr = waddr + fraglen - 0x1000000;
95 len -= fraglen;
96 }
97}
98
99static void jazz_memcpy_fromio(unsigned long to, unsigned long from, unsigned long len)
100{
101 unsigned long waddr;
102
103 waddr = JAZZ_EISA_BASE | (from & 0xffffff);
104 while(len) {
105 unsigned long fraglen;
106
107 fraglen = (~from + 1) & 0xffffff;
108 fraglen = (fraglen < len) ? fraglen : len;
109 map_eisa_address(from);
110 memcpy((void *)to, (void *)waddr, fraglen);
111 to += fraglen;
112 from += fraglen;
113 waddr = waddr + fraglen - 0x1000000;
114 len -= fraglen;
115 }
116}
117
118static void jazz_memcpy_toio(unsigned long to, unsigned long from, unsigned long len)
119{
120 unsigned long waddr;
121
122 waddr = JAZZ_EISA_BASE | (to & 0xffffff);
123 while(len) {
124 unsigned long fraglen;
125
126 fraglen = (~to + 1) & 0xffffff;
127 fraglen = (fraglen < len) ? fraglen : len;
128 map_eisa_address(to);
129 memcpy((char *)to + JAZZ_EISA_BASE, (void *)from, fraglen);
130 to += fraglen;
131 from += fraglen;
132 waddr = waddr + fraglen - 0x1000000;
133 len -= fraglen;
134 }
135}
diff --git a/arch/mips/jazz/reset.c b/arch/mips/jazz/reset.c
index 2a9754750bc8..d8ade85060b3 100644
--- a/arch/mips/jazz/reset.c
+++ b/arch/mips/jazz/reset.c
@@ -6,10 +6,6 @@
6 */ 6 */
7#include <linux/jiffies.h> 7#include <linux/jiffies.h>
8#include <asm/jazz.h> 8#include <asm/jazz.h>
9#include <asm/io.h>
10#include <asm/system.h>
11#include <asm/reboot.h>
12#include <asm/delay.h>
13 9
14#define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */ 10#define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */
15 11
@@ -58,12 +54,3 @@ void jazz_machine_restart(char *command)
58 jazz_write_output (0x00); 54 jazz_write_output (0x00);
59 } 55 }
60} 56}
61
62void jazz_machine_halt(void)
63{
64}
65
66void jazz_machine_power_off(void)
67{
68 /* Jazz machines don't have a software power switch */
69}
diff --git a/arch/mips/jazz/setup.c b/arch/mips/jazz/setup.c
index 81ec559a1c26..798279e06691 100644
--- a/arch/mips/jazz/setup.c
+++ b/arch/mips/jazz/setup.c
@@ -34,8 +34,6 @@
34extern asmlinkage void jazz_handle_int(void); 34extern asmlinkage void jazz_handle_int(void);
35 35
36extern void jazz_machine_restart(char *command); 36extern void jazz_machine_restart(char *command);
37extern void jazz_machine_halt(void);
38extern void jazz_machine_power_off(void);
39 37
40void __init plat_timer_setup(struct irqaction *irq) 38void __init plat_timer_setup(struct irqaction *irq)
41{ 39{
@@ -95,8 +93,6 @@ void __init plat_mem_setup(void)
95 /* The RTC is outside the port address space */ 93 /* The RTC is outside the port address space */
96 94
97 _machine_restart = jazz_machine_restart; 95 _machine_restart = jazz_machine_restart;
98 _machine_halt = jazz_machine_halt;
99 pm_power_off = jazz_machine_power_off;
100 96
101 screen_info = (struct screen_info) { 97 screen_info = (struct screen_info) {
102 0, 0, /* orig-x, orig-y */ 98 0, 0, /* orig-x, orig-y */
diff --git a/arch/mips/jmr3927/common/Makefile b/arch/mips/jmr3927/common/Makefile
index 01e7db19bcbe..8fd4fcccf10e 100644
--- a/arch/mips/jmr3927/common/Makefile
+++ b/arch/mips/jmr3927/common/Makefile
@@ -3,3 +3,5 @@
3# 3#
4 4
5obj-y += prom.o puts.o 5obj-y += prom.o puts.o
6
7EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/jmr3927/rbhma3100/Makefile b/arch/mips/jmr3927/rbhma3100/Makefile
index 8d00ba460cef..d86e30dca8f3 100644
--- a/arch/mips/jmr3927/rbhma3100/Makefile
+++ b/arch/mips/jmr3927/rbhma3100/Makefile
@@ -4,3 +4,5 @@
4 4
5obj-y += init.o irq.o setup.o 5obj-y += init.o irq.o setup.o
6obj-$(CONFIG_KGDB) += kgdb_io.o 6obj-$(CONFIG_KGDB) += kgdb_io.o
7
8EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/jmr3927/rbhma3100/setup.c
index d1ef2895d564..8303001516d2 100644
--- a/arch/mips/jmr3927/rbhma3100/setup.c
+++ b/arch/mips/jmr3927/rbhma3100/setup.c
@@ -434,7 +434,7 @@ EXPORT_SYMBOL(__swizzle_addr_b);
434 434
435static int __init jmr3927_rtc_init(void) 435static int __init jmr3927_rtc_init(void)
436{ 436{
437 struct resource res = { 437 static struct resource __initdata res = {
438 .start = JMR3927_IOC_NVRAMB_ADDR - IO_BASE, 438 .start = JMR3927_IOC_NVRAMB_ADDR - IO_BASE,
439 .end = JMR3927_IOC_NVRAMB_ADDR - IO_BASE + 0x800 - 1, 439 .end = JMR3927_IOC_NVRAMB_ADDR - IO_BASE + 0x800 - 1,
440 .flags = IORESOURCE_MEM, 440 .flags = IORESOURCE_MEM,
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 5c8085b6d7ab..07344cb37596 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -71,3 +71,5 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
71CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) 71CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
72 72
73obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o 73obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o
74
75EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index 3b27309d54b1..013327286c26 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -132,7 +132,6 @@ void output_thread_defines(void)
132 offset("#define THREAD_ECODE ", struct task_struct, \ 132 offset("#define THREAD_ECODE ", struct task_struct, \
133 thread.error_code); 133 thread.error_code);
134 offset("#define THREAD_TRAPNO ", struct task_struct, thread.trap_no); 134 offset("#define THREAD_TRAPNO ", struct task_struct, thread.trap_no);
135 offset("#define THREAD_MFLAGS ", struct task_struct, thread.mflags);
136 offset("#define THREAD_TRAMP ", struct task_struct, \ 135 offset("#define THREAD_TRAMP ", struct task_struct, \
137 thread.irix_trampoline); 136 thread.irix_trampoline);
138 offset("#define THREAD_OLDCTX ", struct task_struct, \ 137 offset("#define THREAD_OLDCTX ", struct task_struct, \
diff --git a/arch/mips/kernel/gdb-stub.c b/arch/mips/kernel/gdb-stub.c
index 7bc882049269..cb5623aad552 100644
--- a/arch/mips/kernel/gdb-stub.c
+++ b/arch/mips/kernel/gdb-stub.c
@@ -1099,12 +1099,12 @@ void adel(void)
1099 * malloc is needed by gdb client in "call func()", even a private one 1099 * malloc is needed by gdb client in "call func()", even a private one
1100 * will make gdb happy 1100 * will make gdb happy
1101 */ 1101 */
1102static void * __attribute_used__ malloc(size_t size) 1102static void __used *malloc(size_t size)
1103{ 1103{
1104 return kmalloc(size, GFP_ATOMIC); 1104 return kmalloc(size, GFP_ATOMIC);
1105} 1105}
1106 1106
1107static void __attribute_used__ free (void *where) 1107static void __used free(void *where)
1108{ 1108{
1109 kfree(where); 1109 kfree(where);
1110} 1110}
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index f78538eceef7..e46782b0ebc8 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -138,10 +138,9 @@
138 .fill 0x400 138 .fill 0x400
139#endif 139#endif
140 140
141EXPORT(stext) # used for profiling
142EXPORT(_stext) 141EXPORT(_stext)
143 142
144#ifdef CONFIG_BOOT_RAW 143#ifndef CONFIG_BOOT_RAW
145 /* 144 /*
146 * Give us a fighting chance of running if execution beings at the 145 * Give us a fighting chance of running if execution beings at the
147 * kernel load address. This is needed because this platform does 146 * kernel load address. This is needed because this platform does
diff --git a/arch/mips/kernel/kspd.c b/arch/mips/kernel/kspd.c
index c6580018c94b..cb9a14a1ca5b 100644
--- a/arch/mips/kernel/kspd.c
+++ b/arch/mips/kernel/kspd.c
@@ -89,7 +89,7 @@ static int sp_stopping = 0;
89#define MTSP_O_EXCL 0x0800 89#define MTSP_O_EXCL 0x0800
90#define MTSP_O_BINARY 0x8000 90#define MTSP_O_BINARY 0x8000
91 91
92#define SP_VPE 1 92extern int tclimit;
93 93
94struct apsp_table { 94struct apsp_table {
95 int sp; 95 int sp;
@@ -225,8 +225,8 @@ void sp_work_handle_request(void)
225 /* Run the syscall at the priviledge of the user who loaded the 225 /* Run the syscall at the priviledge of the user who loaded the
226 SP program */ 226 SP program */
227 227
228 if (vpe_getuid(SP_VPE)) 228 if (vpe_getuid(tclimit))
229 sp_setfsuidgid( vpe_getuid(SP_VPE), vpe_getgid(SP_VPE)); 229 sp_setfsuidgid(vpe_getuid(tclimit), vpe_getgid(tclimit));
230 230
231 switch (sc.cmd) { 231 switch (sc.cmd) {
232 /* needs the flags argument translating from SDE kit to 232 /* needs the flags argument translating from SDE kit to
@@ -245,7 +245,7 @@ void sp_work_handle_request(void)
245 245
246 case MTSP_SYSCALL_EXIT: 246 case MTSP_SYSCALL_EXIT:
247 list_for_each_entry(n, &kspd_notifylist, list) 247 list_for_each_entry(n, &kspd_notifylist, list)
248 n->kspd_sp_exit(SP_VPE); 248 n->kspd_sp_exit(tclimit);
249 sp_stopping = 1; 249 sp_stopping = 1;
250 250
251 printk(KERN_DEBUG "KSPD got exit syscall from SP exitcode %d\n", 251 printk(KERN_DEBUG "KSPD got exit syscall from SP exitcode %d\n",
@@ -255,7 +255,7 @@ void sp_work_handle_request(void)
255 case MTSP_SYSCALL_OPEN: 255 case MTSP_SYSCALL_OPEN:
256 generic.arg1 = translate_open_flags(generic.arg1); 256 generic.arg1 = translate_open_flags(generic.arg1);
257 257
258 vcwd = vpe_getcwd(SP_VPE); 258 vcwd = vpe_getcwd(tclimit);
259 259
260 /* change to the cwd of the process that loaded the SP program */ 260 /* change to the cwd of the process that loaded the SP program */
261 old_fs = get_fs(); 261 old_fs = get_fs();
@@ -283,7 +283,7 @@ void sp_work_handle_request(void)
283 break; 283 break;
284 } /* switch */ 284 } /* switch */
285 285
286 if (vpe_getuid(SP_VPE)) 286 if (vpe_getuid(tclimit))
287 sp_setfsuidgid( 0, 0); 287 sp_setfsuidgid( 0, 0);
288 288
289 old_fs = get_fs(); 289 old_fs = get_fs();
@@ -364,10 +364,9 @@ static void startwork(int vpe)
364 } 364 }
365 365
366 INIT_WORK(&work, sp_work); 366 INIT_WORK(&work, sp_work);
367 queue_work(workqueue, &work); 367 }
368 } else
369 queue_work(workqueue, &work);
370 368
369 queue_work(workqueue, &work);
371} 370}
372 371
373static void stopwork(int vpe) 372static void stopwork(int vpe)
@@ -389,7 +388,7 @@ static int kspd_module_init(void)
389 388
390 notify.start = startwork; 389 notify.start = startwork;
391 notify.stop = stopwork; 390 notify.stop = stopwork;
392 vpe_notify(SP_VPE, &notify); 391 vpe_notify(tclimit, &notify);
393 392
394 return 0; 393 return 0;
395} 394}
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 06e04da211d5..135d9a5fe337 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -566,8 +566,15 @@ asmlinkage long sys32_fadvise64_64(int fd, int __pad,
566 flags); 566 flags);
567} 567}
568 568
569asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_a2,
570 unsigned offset_a3, unsigned len_a4, unsigned len_a5)
571{
572 return sys_fallocate(fd, mode, merge_64(offset_a2, offset_a3),
573 merge_64(len_a4, len_a5));
574}
575
569save_static_function(sys32_clone); 576save_static_function(sys32_clone);
570__attribute_used__ noinline static int 577static int noinline __used
571_sys32_clone(nabi_no_regargs struct pt_regs regs) 578_sys32_clone(nabi_no_regargs struct pt_regs regs)
572{ 579{
573 unsigned long clone_flags; 580 unsigned long clone_flags;
diff --git a/arch/mips/kernel/machine_kexec.c b/arch/mips/kernel/machine_kexec.c
index 8f42fa85ac9e..22960d67cf07 100644
--- a/arch/mips/kernel/machine_kexec.c
+++ b/arch/mips/kernel/machine_kexec.c
@@ -14,7 +14,7 @@
14#include <asm/page.h> 14#include <asm/page.h>
15 15
16extern const unsigned char relocate_new_kernel[]; 16extern const unsigned char relocate_new_kernel[];
17extern const unsigned int relocate_new_kernel_size; 17extern const size_t relocate_new_kernel_size;
18 18
19extern unsigned long kexec_start_address; 19extern unsigned long kexec_start_address;
20extern unsigned long kexec_indirection_page; 20extern unsigned long kexec_indirection_page;
@@ -40,6 +40,8 @@ machine_crash_shutdown(struct pt_regs *regs)
40{ 40{
41} 41}
42 42
43typedef void (*noretfun_t)(void) __attribute__((noreturn));
44
43void 45void
44machine_kexec(struct kimage *image) 46machine_kexec(struct kimage *image)
45{ 47{
@@ -51,7 +53,8 @@ machine_kexec(struct kimage *image)
51 (unsigned long)page_address(image->control_code_page); 53 (unsigned long)page_address(image->control_code_page);
52 54
53 kexec_start_address = image->start; 55 kexec_start_address = image->start;
54 kexec_indirection_page = phys_to_virt(image->head & PAGE_MASK); 56 kexec_indirection_page =
57 (unsigned long) phys_to_virt(image->head & PAGE_MASK);
55 58
56 memcpy((void*)reboot_code_buffer, relocate_new_kernel, 59 memcpy((void*)reboot_code_buffer, relocate_new_kernel,
57 relocate_new_kernel_size); 60 relocate_new_kernel_size);
@@ -67,7 +70,7 @@ machine_kexec(struct kimage *image)
67 phys_to_virt(entry & PAGE_MASK) : ptr + 1) { 70 phys_to_virt(entry & PAGE_MASK) : ptr + 1) {
68 if (*ptr & IND_SOURCE || *ptr & IND_INDIRECTION || 71 if (*ptr & IND_SOURCE || *ptr & IND_INDIRECTION ||
69 *ptr & IND_DESTINATION) 72 *ptr & IND_DESTINATION)
70 *ptr = phys_to_virt(*ptr); 73 *ptr = (unsigned long) phys_to_virt(*ptr);
71 } 74 }
72 75
73 /* 76 /*
@@ -78,8 +81,8 @@ machine_kexec(struct kimage *image)
78 flush_icache_range(reboot_code_buffer, 81 flush_icache_range(reboot_code_buffer,
79 reboot_code_buffer + KEXEC_CONTROL_CODE_SIZE); 82 reboot_code_buffer + KEXEC_CONTROL_CODE_SIZE);
80 83
81 printk("Will call new kernel at %08x\n", image->start); 84 printk("Will call new kernel at %08lx\n", image->start);
82 printk("Bye ...\n"); 85 printk("Bye ...\n");
83 flush_cache_all(); 86 flush_cache_all();
84 ((void (*)(void))reboot_code_buffer)(); 87 ((noretfun_t) reboot_code_buffer)();
85} 88}
diff --git a/arch/mips/kernel/mips-mt-fpaff.c b/arch/mips/kernel/mips-mt-fpaff.c
index ede5d73d652e..892665bb12b1 100644
--- a/arch/mips/kernel/mips-mt-fpaff.c
+++ b/arch/mips/kernel/mips-mt-fpaff.c
@@ -50,6 +50,7 @@ asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len,
50 cpumask_t effective_mask; 50 cpumask_t effective_mask;
51 int retval; 51 int retval;
52 struct task_struct *p; 52 struct task_struct *p;
53 struct thread_info *ti;
53 54
54 if (len < sizeof(new_mask)) 55 if (len < sizeof(new_mask))
55 return -EINVAL; 56 return -EINVAL;
@@ -93,16 +94,16 @@ asmlinkage long mipsmt_sys_sched_setaffinity(pid_t pid, unsigned int len,
93 read_unlock(&tasklist_lock); 94 read_unlock(&tasklist_lock);
94 95
95 /* Compute new global allowed CPU set if necessary */ 96 /* Compute new global allowed CPU set if necessary */
96 if ((p->thread.mflags & MF_FPUBOUND) 97 ti = task_thread_info(p);
97 && cpus_intersects(new_mask, mt_fpu_cpumask)) { 98 if (test_ti_thread_flag(ti, TIF_FPUBOUND) &&
99 cpus_intersects(new_mask, mt_fpu_cpumask)) {
98 cpus_and(effective_mask, new_mask, mt_fpu_cpumask); 100 cpus_and(effective_mask, new_mask, mt_fpu_cpumask);
99 retval = set_cpus_allowed(p, effective_mask); 101 retval = set_cpus_allowed(p, effective_mask);
100 } else { 102 } else {
101 p->thread.mflags &= ~MF_FPUBOUND; 103 clear_ti_thread_flag(ti, TIF_FPUBOUND);
102 retval = set_cpus_allowed(p, new_mask); 104 retval = set_cpus_allowed(p, new_mask);
103 } 105 }
104 106
105
106out_unlock: 107out_unlock:
107 put_task_struct(p); 108 put_task_struct(p);
108 unlock_cpu_hotplug(); 109 unlock_cpu_hotplug();
diff --git a/arch/mips/kernel/mips-mt.c b/arch/mips/kernel/mips-mt.c
index 1a7d89231299..7169a4db37b8 100644
--- a/arch/mips/kernel/mips-mt.c
+++ b/arch/mips/kernel/mips-mt.c
@@ -21,6 +21,28 @@
21#include <asm/r4kcache.h> 21#include <asm/r4kcache.h>
22#include <asm/cacheflush.h> 22#include <asm/cacheflush.h>
23 23
24int vpelimit;
25
26static int __init maxvpes(char *str)
27{
28 get_option(&str, &vpelimit);
29
30 return 1;
31}
32
33__setup("maxvpes=", maxvpes);
34
35int tclimit;
36
37static int __init maxtcs(char *str)
38{
39 get_option(&str, &tclimit);
40
41 return 1;
42}
43
44__setup("maxtcs=", maxtcs);
45
24/* 46/*
25 * Dump new MIPS MT state for the core. Does not leave TCs halted. 47 * Dump new MIPS MT state for the core. Does not leave TCs halted.
26 * Takes an argument which taken to be a pre-call MVPControl value. 48 * Takes an argument which taken to be a pre-call MVPControl value.
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index bd05f5a927ea..e6ce943099a0 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -77,7 +77,7 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
77 status = regs->cp0_status & ~(ST0_CU0|ST0_CU1|KU_MASK); 77 status = regs->cp0_status & ~(ST0_CU0|ST0_CU1|KU_MASK);
78#ifdef CONFIG_64BIT 78#ifdef CONFIG_64BIT
79 status &= ~ST0_FR; 79 status &= ~ST0_FR;
80 status |= (current->thread.mflags & MF_32BIT_REGS) ? 0 : ST0_FR; 80 status |= test_thread_flag(TIF_32BIT_REGS) ? 0 : ST0_FR;
81#endif 81#endif
82 status |= KU_USER; 82 status |= KU_USER;
83 regs->cp0_status = status; 83 regs->cp0_status = status;
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 893e7bccf226..bbd57b20b43e 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -20,11 +20,11 @@
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22#include <linux/ptrace.h> 22#include <linux/ptrace.h>
23#include <linux/audit.h>
24#include <linux/smp.h> 23#include <linux/smp.h>
25#include <linux/user.h> 24#include <linux/user.h>
26#include <linux/security.h> 25#include <linux/security.h>
27#include <linux/signal.h> 26#include <linux/audit.h>
27#include <linux/seccomp.h>
28 28
29#include <asm/byteorder.h> 29#include <asm/byteorder.h>
30#include <asm/cpu.h> 30#include <asm/cpu.h>
@@ -470,12 +470,17 @@ static inline int audit_arch(void)
470 */ 470 */
471asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit) 471asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
472{ 472{
473 /* do the secure computing check first */
474 if (!entryexit)
475 secure_computing(regs->regs[0]);
476
473 if (unlikely(current->audit_context) && entryexit) 477 if (unlikely(current->audit_context) && entryexit)
474 audit_syscall_exit(AUDITSC_RESULT(regs->regs[2]), 478 audit_syscall_exit(AUDITSC_RESULT(regs->regs[2]),
475 regs->regs[2]); 479 regs->regs[2]);
476 480
477 if (!(current->ptrace & PT_PTRACED)) 481 if (!(current->ptrace & PT_PTRACED))
478 goto out; 482 goto out;
483
479 if (!test_thread_flag(TIF_SYSCALL_TRACE)) 484 if (!test_thread_flag(TIF_SYSCALL_TRACE))
480 goto out; 485 goto out;
481 486
@@ -493,9 +498,10 @@ asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
493 send_sig(current->exit_code, current, 1); 498 send_sig(current->exit_code, current, 1);
494 current->exit_code = 0; 499 current->exit_code = 0;
495 } 500 }
496 out: 501
502out:
497 if (unlikely(current->audit_context) && !entryexit) 503 if (unlikely(current->audit_context) && !entryexit)
498 audit_syscall_entry(audit_arch(), regs->regs[2], 504 audit_syscall_entry(audit_arch(), regs->regs[0],
499 regs->regs[4], regs->regs[5], 505 regs->regs[4], regs->regs[5],
500 regs->regs[6], regs->regs[7]); 506 regs->regs[6], regs->regs[7]);
501} 507}
diff --git a/arch/mips/kernel/relocate_kernel.S b/arch/mips/kernel/relocate_kernel.S
index a3f0d00c1334..87481f916a61 100644
--- a/arch/mips/kernel/relocate_kernel.S
+++ b/arch/mips/kernel/relocate_kernel.S
@@ -14,67 +14,69 @@
14#include <asm/stackframe.h> 14#include <asm/stackframe.h>
15#include <asm/addrspace.h> 15#include <asm/addrspace.h>
16 16
17 .globl relocate_new_kernel 17LEAF(relocate_new_kernel)
18relocate_new_kernel: 18 PTR_L s0, kexec_indirection_page
19 19 PTR_L s1, kexec_start_address
20 PTR_L s0, kexec_indirection_page
21 PTR_L s1, kexec_start_address
22 20
23process_entry: 21process_entry:
24 PTR_L s2, (s0) 22 PTR_L s2, (s0)
25 PTR_ADD s0, s0, SZREG 23 PTR_ADD s0, s0, SZREG
26 24
27 /* destination page */ 25 /* destination page */
28 and s3, s2, 0x1 26 and s3, s2, 0x1
29 beq s3, zero, 1f 27 beq s3, zero, 1f
30 and s4, s2, ~0x1 /* store destination addr in s4 */ 28 and s4, s2, ~0x1 /* store destination addr in s4 */
31 move a0, s4 29 move a0, s4
32 b process_entry 30 b process_entry
33 31
341: 321:
35 /* indirection page, update s0 */ 33 /* indirection page, update s0 */
36 and s3, s2, 0x2 34 and s3, s2, 0x2
37 beq s3, zero, 1f 35 beq s3, zero, 1f
38 and s0, s2, ~0x2 36 and s0, s2, ~0x2
39 b process_entry 37 b process_entry
40 38
411: 391:
42 /* done page */ 40 /* done page */
43 and s3, s2, 0x4 41 and s3, s2, 0x4
44 beq s3, zero, 1f 42 beq s3, zero, 1f
45 b done 43 b done
461: 441:
47 /* source page */ 45 /* source page */
48 and s3, s2, 0x8 46 and s3, s2, 0x8
49 beq s3, zero, process_entry 47 beq s3, zero, process_entry
50 and s2, s2, ~0x8 48 and s2, s2, ~0x8
51 li s6, (1 << PAGE_SHIFT) / SZREG 49 li s6, (1 << PAGE_SHIFT) / SZREG
52 50
53copy_word: 51copy_word:
54 /* copy page word by word */ 52 /* copy page word by word */
55 REG_L s5, (s2) 53 REG_L s5, (s2)
56 REG_S s5, (s4) 54 REG_S s5, (s4)
57 INT_ADD s4, s4, SZREG 55 PTR_ADD s4, s4, SZREG
58 INT_ADD s2, s2, SZREG 56 PTR_ADD s2, s2, SZREG
59 INT_SUB s6, s6, 1 57 LONG_SUB s6, s6, 1
60 beq s6, zero, process_entry 58 beq s6, zero, process_entry
61 b copy_word 59 b copy_word
62 b process_entry 60 b process_entry
63 61
64done: 62done:
65 /* jump to kexec_start_address */ 63 /* jump to kexec_start_address */
66 j s1 64 j s1
65 END(relocate_new_kernel)
67 66
68 .globl kexec_start_address
69kexec_start_address: 67kexec_start_address:
70 .long 0x0 68 EXPORT(kexec_start_address)
69 PTR 0x0
70 .size kexec_start_address, PTRSIZE
71 71
72 .globl kexec_indirection_page
73kexec_indirection_page: 72kexec_indirection_page:
74 .long 0x0 73 EXPORT(kexec_indirection_page)
74 PTR 0
75 .size kexec_indirection_page, PTRSIZE
75 76
76relocate_new_kernel_end: 77relocate_new_kernel_end:
77 78
78 .globl relocate_new_kernel_size
79relocate_new_kernel_size: 79relocate_new_kernel_size:
80 .long relocate_new_kernel_end - relocate_new_kernel 80 EXPORT(relocate_new_kernel_size)
81 PTR relocate_new_kernel_end - relocate_new_kernel
82 .size relocate_new_kernel_size, PTRSIZE
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index bfc8ca168f83..aab89e97abb5 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -40,12 +40,11 @@
40#include <asm/atomic.h> 40#include <asm/atomic.h>
41#include <asm/cpu.h> 41#include <asm/cpu.h>
42#include <asm/processor.h> 42#include <asm/processor.h>
43#include <asm/mips_mt.h>
43#include <asm/system.h> 44#include <asm/system.h>
44#include <asm/vpe.h> 45#include <asm/vpe.h>
45#include <asm/rtlx.h> 46#include <asm/rtlx.h>
46 47
47#define RTLX_TARG_VPE 1
48
49static struct rtlx_info *rtlx; 48static struct rtlx_info *rtlx;
50static int major; 49static int major;
51static char module_name[] = "rtlx"; 50static char module_name[] = "rtlx";
@@ -85,7 +84,7 @@ static irqreturn_t rtlx_interrupt(int irq, void *dev_id)
85 return IRQ_HANDLED; 84 return IRQ_HANDLED;
86} 85}
87 86
88static __attribute_used__ void dump_rtlx(void) 87static void __used dump_rtlx(void)
89{ 88{
90 int i; 89 int i;
91 90
@@ -165,10 +164,10 @@ int rtlx_open(int index, int can_sleep)
165 } 164 }
166 165
167 if (rtlx == NULL) { 166 if (rtlx == NULL) {
168 if( (p = vpe_get_shared(RTLX_TARG_VPE)) == NULL) { 167 if( (p = vpe_get_shared(tclimit)) == NULL) {
169 if (can_sleep) { 168 if (can_sleep) {
170 __wait_event_interruptible(channel_wqs[index].lx_queue, 169 __wait_event_interruptible(channel_wqs[index].lx_queue,
171 (p = vpe_get_shared(RTLX_TARG_VPE)), 170 (p = vpe_get_shared(tclimit)),
172 ret); 171 ret);
173 if (ret) 172 if (ret)
174 goto out_fail; 173 goto out_fail;
@@ -472,11 +471,24 @@ static int rtlx_irq_num = MIPS_CPU_IRQ_BASE + MIPS_CPU_RTLX_IRQ;
472static char register_chrdev_failed[] __initdata = 471static char register_chrdev_failed[] __initdata =
473 KERN_ERR "rtlx_module_init: unable to register device\n"; 472 KERN_ERR "rtlx_module_init: unable to register device\n";
474 473
475static int rtlx_module_init(void) 474static int __init rtlx_module_init(void)
476{ 475{
477 struct device *dev; 476 struct device *dev;
478 int i, err; 477 int i, err;
479 478
479 if (!cpu_has_mipsmt) {
480 printk("VPE loader: not a MIPS MT capable processor\n");
481 return -ENODEV;
482 }
483
484 if (tclimit == 0) {
485 printk(KERN_WARNING "No TCs reserved for AP/SP, not "
486 "initializing RTLX.\nPass maxtcs=<n> argument as kernel "
487 "argument\n");
488
489 return -ENODEV;
490 }
491
480 major = register_chrdev(0, module_name, &rtlx_fops); 492 major = register_chrdev(0, module_name, &rtlx_fops);
481 if (major < 0) { 493 if (major < 0) {
482 printk(register_chrdev_failed); 494 printk(register_chrdev_failed);
@@ -501,7 +513,7 @@ static int rtlx_module_init(void)
501 /* set up notifiers */ 513 /* set up notifiers */
502 notify.start = starting; 514 notify.start = starting;
503 notify.stop = stopping; 515 notify.stop = stopping;
504 vpe_notify(RTLX_TARG_VPE, &notify); 516 vpe_notify(tclimit, &notify);
505 517
506 if (cpu_has_vint) 518 if (cpu_has_vint)
507 set_vi_handler(MIPS_CPU_RTLX_IRQ, rtlx_dispatch); 519 set_vi_handler(MIPS_CPU_RTLX_IRQ, rtlx_dispatch);
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index ae985d1fcca1..82480a1717d8 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -662,6 +662,7 @@ einval: li v0, -EINVAL
662 sys sys_signalfd 3 662 sys sys_signalfd 3
663 sys sys_timerfd 4 663 sys sys_timerfd 4
664 sys sys_eventfd 1 664 sys sys_eventfd 1
665 sys sys_fallocate 6 /* 4320 */
665 .endm 666 .endm
666 667
667 /* We pre-compute the number of _instruction_ bytes needed to 668 /* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index 7bcd5a1a85f5..c2c10876da2e 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -477,4 +477,5 @@ sys_call_table:
477 PTR sys_signalfd 477 PTR sys_signalfd
478 PTR sys_timerfd 478 PTR sys_timerfd
479 PTR sys_eventfd 479 PTR sys_eventfd
480 PTR sys_fallocate
480 .size sys_call_table,.-sys_call_table 481 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 532a2f3b42fc..53d7a977193c 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -403,4 +403,5 @@ EXPORT(sysn32_call_table)
403 PTR compat_sys_signalfd /* 5280 */ 403 PTR compat_sys_signalfd /* 5280 */
404 PTR compat_sys_timerfd 404 PTR compat_sys_timerfd
405 PTR sys_eventfd 405 PTR sys_eventfd
406 PTR sys_fallocate
406 .size sysn32_call_table,.-sysn32_call_table 407 .size sysn32_call_table,.-sysn32_call_table
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 6bbe0f4ed8ba..b3ed731a24c6 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -525,4 +525,5 @@ sys_call_table:
525 PTR compat_sys_signalfd 525 PTR compat_sys_signalfd
526 PTR compat_sys_timerfd 526 PTR compat_sys_timerfd
527 PTR sys_eventfd 527 PTR sys_eventfd
528 PTR sys_fallocate /* 4320 */
528 .size sys_call_table,.-sys_call_table 529 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index 486b8e5f52d0..64b612a0a622 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -18,7 +18,6 @@
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/wait.h> 19#include <linux/wait.h>
20#include <linux/ptrace.h> 20#include <linux/ptrace.h>
21#include <linux/compat.h>
22#include <linux/suspend.h> 21#include <linux/suspend.h>
23#include <linux/compiler.h> 22#include <linux/compiler.h>
24#include <linux/uaccess.h> 23#include <linux/uaccess.h>
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index be7362bc2c9a..73b0dab02668 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -30,6 +30,7 @@
30#include <linux/sched.h> 30#include <linux/sched.h>
31#include <linux/cpumask.h> 31#include <linux/cpumask.h>
32#include <linux/cpu.h> 32#include <linux/cpu.h>
33#include <linux/err.h>
33 34
34#include <asm/atomic.h> 35#include <asm/atomic.h>
35#include <asm/cpu.h> 36#include <asm/cpu.h>
@@ -193,6 +194,61 @@ void smp_call_function_interrupt(void)
193 } 194 }
194} 195}
195 196
197int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
198 int retry, int wait)
199{
200 struct call_data_struct data;
201 int me;
202
203 /*
204 * Can die spectacularly if this CPU isn't yet marked online
205 */
206 if (!cpu_online(cpu))
207 return 0;
208
209 me = get_cpu();
210 BUG_ON(!cpu_online(me));
211
212 if (cpu == me) {
213 local_irq_disable();
214 func(info);
215 local_irq_enable();
216 put_cpu();
217 return 0;
218 }
219
220 /* Can deadlock when called with interrupts disabled */
221 WARN_ON(irqs_disabled());
222
223 data.func = func;
224 data.info = info;
225 atomic_set(&data.started, 0);
226 data.wait = wait;
227 if (wait)
228 atomic_set(&data.finished, 0);
229
230 spin_lock(&smp_call_lock);
231 call_data = &data;
232 smp_mb();
233
234 /* Send a message to the other CPU */
235 core_send_ipi(cpu, SMP_CALL_FUNCTION);
236
237 /* Wait for response */
238 /* FIXME: lock-up detection, backtrace on lock-up */
239 while (atomic_read(&data.started) != 1)
240 barrier();
241
242 if (wait)
243 while (atomic_read(&data.finished) != 1)
244 barrier();
245 call_data = NULL;
246 spin_unlock(&smp_call_lock);
247
248 put_cpu();
249 return 0;
250}
251
196static void stop_this_cpu(void *dummy) 252static void stop_this_cpu(void *dummy)
197{ 253{
198 /* 254 /*
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index 342d873b2ecc..16aa5d37117c 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -86,25 +86,11 @@ unsigned int smtc_status = 0;
86 86
87/* Boot command line configuration overrides */ 87/* Boot command line configuration overrides */
88 88
89static int vpelimit = 0;
90static int tclimit = 0;
91static int ipibuffers = 0; 89static int ipibuffers = 0;
92static int nostlb = 0; 90static int nostlb = 0;
93static int asidmask = 0; 91static int asidmask = 0;
94unsigned long smtc_asid_mask = 0xff; 92unsigned long smtc_asid_mask = 0xff;
95 93
96static int __init maxvpes(char *str)
97{
98 get_option(&str, &vpelimit);
99 return 1;
100}
101
102static int __init maxtcs(char *str)
103{
104 get_option(&str, &tclimit);
105 return 1;
106}
107
108static int __init ipibufs(char *str) 94static int __init ipibufs(char *str)
109{ 95{
110 get_option(&str, &ipibuffers); 96 get_option(&str, &ipibuffers);
@@ -137,8 +123,6 @@ static int __init asidmask_set(char *str)
137 return 1; 123 return 1;
138} 124}
139 125
140__setup("maxvpes=", maxvpes);
141__setup("maxtcs=", maxtcs);
142__setup("ipibufs=", ipibufs); 126__setup("ipibufs=", ipibufs);
143__setup("nostlb", stlb_disable); 127__setup("nostlb", stlb_disable);
144__setup("asidmask=", asidmask_set); 128__setup("asidmask=", asidmask_set);
@@ -168,9 +152,9 @@ static int __init tintq(char *str)
168 152
169__setup("tintq=", tintq); 153__setup("tintq=", tintq);
170 154
171int imstuckcount[2][8]; 155static int imstuckcount[2][8];
172/* vpemask represents IM/IE bits of per-VPE Status registers, low-to-high */ 156/* vpemask represents IM/IE bits of per-VPE Status registers, low-to-high */
173int vpemask[2][8] = { 157static int vpemask[2][8] = {
174 {0, 0, 1, 0, 0, 0, 0, 1}, 158 {0, 0, 1, 0, 0, 0, 0, 1},
175 {0, 0, 0, 0, 0, 0, 0, 1} 159 {0, 0, 0, 0, 0, 0, 0, 1}
176}; 160};
@@ -540,7 +524,7 @@ void mipsmt_prepare_cpus(void)
540 * (unsigned long)idle->thread_info the gp 524 * (unsigned long)idle->thread_info the gp
541 * 525 *
542 */ 526 */
543void smtc_boot_secondary(int cpu, struct task_struct *idle) 527void __cpuinit smtc_boot_secondary(int cpu, struct task_struct *idle)
544{ 528{
545 extern u32 kernelsp[NR_CPUS]; 529 extern u32 kernelsp[NR_CPUS];
546 long flags; 530 long flags;
@@ -876,7 +860,7 @@ void deferred_smtc_ipi(void)
876 * Send clock tick to all TCs except the one executing the funtion 860 * Send clock tick to all TCs except the one executing the funtion
877 */ 861 */
878 862
879void smtc_timer_broadcast(int vpe) 863void smtc_timer_broadcast(void)
880{ 864{
881 int cpu; 865 int cpu;
882 int myTC = cpu_data[smp_processor_id()].tc_id; 866 int myTC = cpu_data[smp_processor_id()].tc_id;
@@ -975,7 +959,12 @@ static void ipi_irq_dispatch(void)
975 do_IRQ(cpu_ipi_irq); 959 do_IRQ(cpu_ipi_irq);
976} 960}
977 961
978static struct irqaction irq_ipi; 962static struct irqaction irq_ipi = {
963 .handler = ipi_interrupt,
964 .flags = IRQF_DISABLED,
965 .name = "SMTC_IPI",
966 .flags = IRQF_PERCPU
967};
979 968
980static void setup_cross_vpe_interrupts(unsigned int nvpe) 969static void setup_cross_vpe_interrupts(unsigned int nvpe)
981{ 970{
@@ -987,13 +976,8 @@ static void setup_cross_vpe_interrupts(unsigned int nvpe)
987 976
988 set_vi_handler(MIPS_CPU_IPI_IRQ, ipi_irq_dispatch); 977 set_vi_handler(MIPS_CPU_IPI_IRQ, ipi_irq_dispatch);
989 978
990 irq_ipi.handler = ipi_interrupt;
991 irq_ipi.flags = IRQF_DISABLED;
992 irq_ipi.name = "SMTC_IPI";
993
994 setup_irq_smtc(cpu_ipi_irq, &irq_ipi, (0x100 << MIPS_CPU_IPI_IRQ)); 979 setup_irq_smtc(cpu_ipi_irq, &irq_ipi, (0x100 << MIPS_CPU_IPI_IRQ));
995 980
996 irq_desc[cpu_ipi_irq].status |= IRQ_PER_CPU;
997 set_irq_handler(cpu_ipi_irq, handle_percpu_irq); 981 set_irq_handler(cpu_ipi_irq, handle_percpu_irq);
998} 982}
999 983
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index b947c61c0cc8..7c800ec3ff55 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -12,6 +12,7 @@
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <linux/mm.h> 14#include <linux/mm.h>
15#include <linux/fs.h>
15#include <linux/smp.h> 16#include <linux/smp.h>
16#include <linux/mman.h> 17#include <linux/mman.h>
17#include <linux/ptrace.h> 18#include <linux/ptrace.h>
@@ -167,14 +168,14 @@ sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
167} 168}
168 169
169save_static_function(sys_fork); 170save_static_function(sys_fork);
170__attribute_used__ noinline static int 171static int __used noinline
171_sys_fork(nabi_no_regargs struct pt_regs regs) 172_sys_fork(nabi_no_regargs struct pt_regs regs)
172{ 173{
173 return do_fork(SIGCHLD, regs.regs[29], &regs, 0, NULL, NULL); 174 return do_fork(SIGCHLD, regs.regs[29], &regs, 0, NULL, NULL);
174} 175}
175 176
176save_static_function(sys_clone); 177save_static_function(sys_clone);
177__attribute_used__ noinline static int 178static int __used noinline
178_sys_clone(nabi_no_regargs struct pt_regs regs) 179_sys_clone(nabi_no_regargs struct pt_regs regs)
179{ 180{
180 unsigned long clone_flags; 181 unsigned long clone_flags;
@@ -280,16 +281,24 @@ asmlinkage int sys_set_thread_area(unsigned long addr)
280 281
281asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3) 282asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3)
282{ 283{
283 int tmp; 284 switch (cmd) {
284
285 switch(cmd) {
286 case MIPS_ATOMIC_SET: 285 case MIPS_ATOMIC_SET:
287 printk(KERN_CRIT "How did I get here?\n"); 286 printk(KERN_CRIT "How did I get here?\n");
288 return -EINVAL; 287 return -EINVAL;
289 288
290 case MIPS_FIXADE: 289 case MIPS_FIXADE:
291 tmp = current->thread.mflags & ~3; 290 if (arg1 & ~3)
292 current->thread.mflags = tmp | (arg1 & 3); 291 return -EINVAL;
292
293 if (arg1 & 1)
294 set_thread_flag(TIF_FIXADE);
295 else
296 clear_thread_flag(TIF_FIXADE);
297 if (arg1 & 2)
298 set_thread_flag(TIF_LOGADE);
299 else
300 clear_thread_flag(TIF_FIXADE);
301
293 return 0; 302 return 0;
294 303
295 case FLUSH_CACHE: 304 case FLUSH_CACHE:
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index ce277cb34dd0..c8e291c83057 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -775,7 +775,7 @@ static void mt_ase_fp_affinity(void)
775 cpus_and(tmask, current->thread.user_cpus_allowed, 775 cpus_and(tmask, current->thread.user_cpus_allowed,
776 mt_fpu_cpumask); 776 mt_fpu_cpumask);
777 set_cpus_allowed(current, tmask); 777 set_cpus_allowed(current, tmask);
778 current->thread.mflags |= MF_FPUBOUND; 778 set_thread_flag(TIF_FPUBOUND);
779 } 779 }
780 } 780 }
781#endif /* CONFIG_MIPS_MT_FPAFF */ 781#endif /* CONFIG_MIPS_MT_FPAFF */
diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c
index 8b9c34ffae18..d34b1fb3665d 100644
--- a/arch/mips/kernel/unaligned.c
+++ b/arch/mips/kernel/unaligned.c
@@ -101,16 +101,14 @@ static u32 unaligned_action;
101#endif 101#endif
102extern void show_registers(struct pt_regs *regs); 102extern void show_registers(struct pt_regs *regs);
103 103
104static inline int emulate_load_store_insn(struct pt_regs *regs, 104static void emulate_load_store_insn(struct pt_regs *regs,
105 void __user *addr, unsigned int __user *pc, 105 void __user *addr, unsigned int __user *pc)
106 unsigned long **regptr, unsigned long *newvalue)
107{ 106{
108 union mips_instruction insn; 107 union mips_instruction insn;
109 unsigned long value; 108 unsigned long value;
110 unsigned int res; 109 unsigned int res;
111 110
112 regs->regs[0] = 0; 111 regs->regs[0] = 0;
113 *regptr=NULL;
114 112
115 /* 113 /*
116 * This load never faults. 114 * This load never faults.
@@ -179,8 +177,8 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
179 : "r" (addr), "i" (-EFAULT)); 177 : "r" (addr), "i" (-EFAULT));
180 if (res) 178 if (res)
181 goto fault; 179 goto fault;
182 *newvalue = value; 180 compute_return_epc(regs);
183 *regptr = &regs->regs[insn.i_format.rt]; 181 regs->regs[insn.i_format.rt] = value;
184 break; 182 break;
185 183
186 case lw_op: 184 case lw_op:
@@ -209,8 +207,8 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
209 : "r" (addr), "i" (-EFAULT)); 207 : "r" (addr), "i" (-EFAULT));
210 if (res) 208 if (res)
211 goto fault; 209 goto fault;
212 *newvalue = value; 210 compute_return_epc(regs);
213 *regptr = &regs->regs[insn.i_format.rt]; 211 regs->regs[insn.i_format.rt] = value;
214 break; 212 break;
215 213
216 case lhu_op: 214 case lhu_op:
@@ -243,8 +241,8 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
243 : "r" (addr), "i" (-EFAULT)); 241 : "r" (addr), "i" (-EFAULT));
244 if (res) 242 if (res)
245 goto fault; 243 goto fault;
246 *newvalue = value; 244 compute_return_epc(regs);
247 *regptr = &regs->regs[insn.i_format.rt]; 245 regs->regs[insn.i_format.rt] = value;
248 break; 246 break;
249 247
250 case lwu_op: 248 case lwu_op:
@@ -283,8 +281,8 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
283 : "r" (addr), "i" (-EFAULT)); 281 : "r" (addr), "i" (-EFAULT));
284 if (res) 282 if (res)
285 goto fault; 283 goto fault;
286 *newvalue = value; 284 compute_return_epc(regs);
287 *regptr = &regs->regs[insn.i_format.rt]; 285 regs->regs[insn.i_format.rt] = value;
288 break; 286 break;
289#endif /* CONFIG_64BIT */ 287#endif /* CONFIG_64BIT */
290 288
@@ -325,8 +323,8 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
325 : "r" (addr), "i" (-EFAULT)); 323 : "r" (addr), "i" (-EFAULT));
326 if (res) 324 if (res)
327 goto fault; 325 goto fault;
328 *newvalue = value; 326 compute_return_epc(regs);
329 *regptr = &regs->regs[insn.i_format.rt]; 327 regs->regs[insn.i_format.rt] = value;
330 break; 328 break;
331#endif /* CONFIG_64BIT */ 329#endif /* CONFIG_64BIT */
332 330
@@ -367,6 +365,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
367 : "r" (value), "r" (addr), "i" (-EFAULT)); 365 : "r" (value), "r" (addr), "i" (-EFAULT));
368 if (res) 366 if (res)
369 goto fault; 367 goto fault;
368 compute_return_epc(regs);
370 break; 369 break;
371 370
372 case sw_op: 371 case sw_op:
@@ -397,6 +396,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
397 : "r" (value), "r" (addr), "i" (-EFAULT)); 396 : "r" (value), "r" (addr), "i" (-EFAULT));
398 if (res) 397 if (res)
399 goto fault; 398 goto fault;
399 compute_return_epc(regs);
400 break; 400 break;
401 401
402 case sd_op: 402 case sd_op:
@@ -435,6 +435,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
435 : "r" (value), "r" (addr), "i" (-EFAULT)); 435 : "r" (value), "r" (addr), "i" (-EFAULT));
436 if (res) 436 if (res)
437 goto fault; 437 goto fault;
438 compute_return_epc(regs);
438 break; 439 break;
439#endif /* CONFIG_64BIT */ 440#endif /* CONFIG_64BIT */
440 441
@@ -473,34 +474,31 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
473 unaligned_instructions++; 474 unaligned_instructions++;
474#endif 475#endif
475 476
476 return 0; 477 return;
477 478
478fault: 479fault:
479 /* Did we have an exception handler installed? */ 480 /* Did we have an exception handler installed? */
480 if (fixup_exception(regs)) 481 if (fixup_exception(regs))
481 return 1; 482 return;
482 483
483 die_if_kernel ("Unhandled kernel unaligned access", regs); 484 die_if_kernel ("Unhandled kernel unaligned access", regs);
484 send_sig(SIGSEGV, current, 1); 485 send_sig(SIGSEGV, current, 1);
485 486
486 return 0; 487 return;
487 488
488sigbus: 489sigbus:
489 die_if_kernel("Unhandled kernel unaligned access", regs); 490 die_if_kernel("Unhandled kernel unaligned access", regs);
490 send_sig(SIGBUS, current, 1); 491 send_sig(SIGBUS, current, 1);
491 492
492 return 0; 493 return;
493 494
494sigill: 495sigill:
495 die_if_kernel("Unhandled kernel unaligned access or invalid instruction", regs); 496 die_if_kernel("Unhandled kernel unaligned access or invalid instruction", regs);
496 send_sig(SIGILL, current, 1); 497 send_sig(SIGILL, current, 1);
497
498 return 0;
499} 498}
500 499
501asmlinkage void do_ade(struct pt_regs *regs) 500asmlinkage void do_ade(struct pt_regs *regs)
502{ 501{
503 unsigned long *regptr, newval;
504 extern int do_dsemulret(struct pt_regs *); 502 extern int do_dsemulret(struct pt_regs *);
505 unsigned int __user *pc; 503 unsigned int __user *pc;
506 mm_segment_t seg; 504 mm_segment_t seg;
@@ -524,7 +522,7 @@ asmlinkage void do_ade(struct pt_regs *regs)
524 goto sigbus; 522 goto sigbus;
525 523
526 pc = (unsigned int __user *) exception_epc(regs); 524 pc = (unsigned int __user *) exception_epc(regs);
527 if (user_mode(regs) && (current->thread.mflags & MF_FIXADE) == 0) 525 if (user_mode(regs) && !test_thread_flag(TIF_FIXADE))
528 goto sigbus; 526 goto sigbus;
529 if (unaligned_action == UNALIGNED_ACTION_SIGNAL) 527 if (unaligned_action == UNALIGNED_ACTION_SIGNAL)
530 goto sigbus; 528 goto sigbus;
@@ -538,16 +536,7 @@ asmlinkage void do_ade(struct pt_regs *regs)
538 seg = get_fs(); 536 seg = get_fs();
539 if (!user_mode(regs)) 537 if (!user_mode(regs))
540 set_fs(KERNEL_DS); 538 set_fs(KERNEL_DS);
541 if (!emulate_load_store_insn(regs, (void __user *)regs->cp0_badvaddr, pc, 539 emulate_load_store_insn(regs, (void __user *)regs->cp0_badvaddr, pc);
542 &regptr, &newval)) {
543 compute_return_epc(regs);
544 /*
545 * Now that branch is evaluated, update the dest
546 * register if necessary
547 */
548 if (regptr)
549 *regptr = newval;
550 }
551 set_fs(seg); 540 set_fs(seg);
552 541
553 return; 542 return;
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 9e66354dee8b..3c09b9785f4c 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -27,7 +27,6 @@
27 * To load and run, simply cat a SP 'program file' to /dev/vpe1. 27 * To load and run, simply cat a SP 'program file' to /dev/vpe1.
28 * i.e cat spapp >/dev/vpe1. 28 * i.e cat spapp >/dev/vpe1.
29 */ 29 */
30
31#include <linux/kernel.h> 30#include <linux/kernel.h>
32#include <linux/device.h> 31#include <linux/device.h>
33#include <linux/module.h> 32#include <linux/module.h>
@@ -54,6 +53,7 @@
54#include <asm/system.h> 53#include <asm/system.h>
55#include <asm/vpe.h> 54#include <asm/vpe.h>
56#include <asm/kspd.h> 55#include <asm/kspd.h>
56#include <asm/mips_mt.h>
57 57
58typedef void *vpe_handle; 58typedef void *vpe_handle;
59 59
@@ -64,6 +64,10 @@ typedef void *vpe_handle;
64/* If this is set, the section belongs in the init part of the module */ 64/* If this is set, the section belongs in the init part of the module */
65#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1)) 65#define INIT_OFFSET_MASK (1UL << (BITS_PER_LONG-1))
66 66
67/*
68 * The number of TCs and VPEs physically available on the core
69 */
70static int hw_tcs, hw_vpes;
67static char module_name[] = "vpe"; 71static char module_name[] = "vpe";
68static int major; 72static int major;
69static const int minor = 1; /* fixed for now */ 73static const int minor = 1; /* fixed for now */
@@ -126,20 +130,17 @@ struct vpe {
126 130
127 /* the list of who wants to know when something major happens */ 131 /* the list of who wants to know when something major happens */
128 struct list_head notify; 132 struct list_head notify;
133
134 unsigned int ntcs;
129}; 135};
130 136
131struct tc { 137struct tc {
132 enum tc_state state; 138 enum tc_state state;
133 int index; 139 int index;
134 140
135 /* parent VPE */ 141 struct vpe *pvpe; /* parent VPE */
136 struct vpe *pvpe; 142 struct list_head tc; /* The list of TC's with this VPE */
137 143 struct list_head list; /* The global list of tc's */
138 /* The list of TC's with this VPE */
139 struct list_head tc;
140
141 /* The global list of tc's */
142 struct list_head list;
143}; 144};
144 145
145struct { 146struct {
@@ -154,7 +155,6 @@ struct {
154}; 155};
155 156
156static void release_progmem(void *ptr); 157static void release_progmem(void *ptr);
157/* static __attribute_used__ void dump_vpe(struct vpe * v); */
158extern void save_gp_address(unsigned int secbase, unsigned int rel); 158extern void save_gp_address(unsigned int secbase, unsigned int rel);
159 159
160/* get the vpe associated with this minor */ 160/* get the vpe associated with this minor */
@@ -218,18 +218,17 @@ struct vpe *alloc_vpe(int minor)
218/* allocate a tc. At startup only tc0 is running, all other can be halted. */ 218/* allocate a tc. At startup only tc0 is running, all other can be halted. */
219struct tc *alloc_tc(int index) 219struct tc *alloc_tc(int index)
220{ 220{
221 struct tc *t; 221 struct tc *tc;
222 222
223 if ((t = kzalloc(sizeof(struct tc), GFP_KERNEL)) == NULL) { 223 if ((tc = kzalloc(sizeof(struct tc), GFP_KERNEL)) == NULL)
224 return NULL; 224 goto out;
225 }
226
227 INIT_LIST_HEAD(&t->tc);
228 list_add_tail(&t->list, &vpecontrol.tc_list);
229 225
230 t->index = index; 226 INIT_LIST_HEAD(&tc->tc);
227 tc->index = index;
228 list_add_tail(&tc->list, &vpecontrol.tc_list);
231 229
232 return t; 230out:
231 return tc;
233} 232}
234 233
235/* clean up and free everything */ 234/* clean up and free everything */
@@ -664,66 +663,48 @@ static void dump_elfsymbols(Elf_Shdr * sechdrs, unsigned int symindex,
664} 663}
665#endif 664#endif
666 665
667static void dump_tc(struct tc *t)
668{
669 unsigned long val;
670
671 settc(t->index);
672 printk(KERN_DEBUG "VPE loader: TC index %d targtc %ld "
673 "TCStatus 0x%lx halt 0x%lx\n",
674 t->index, read_c0_vpecontrol() & VPECONTROL_TARGTC,
675 read_tc_c0_tcstatus(), read_tc_c0_tchalt());
676
677 printk(KERN_DEBUG " tcrestart 0x%lx\n", read_tc_c0_tcrestart());
678 printk(KERN_DEBUG " tcbind 0x%lx\n", read_tc_c0_tcbind());
679
680 val = read_c0_vpeconf0();
681 printk(KERN_DEBUG " VPEConf0 0x%lx MVP %ld\n", val,
682 (val & VPECONF0_MVP) >> VPECONF0_MVP_SHIFT);
683
684 printk(KERN_DEBUG " c0 status 0x%lx\n", read_vpe_c0_status());
685 printk(KERN_DEBUG " c0 cause 0x%lx\n", read_vpe_c0_cause());
686
687 printk(KERN_DEBUG " c0 badvaddr 0x%lx\n", read_vpe_c0_badvaddr());
688 printk(KERN_DEBUG " c0 epc 0x%lx\n", read_vpe_c0_epc());
689}
690
691static void dump_tclist(void)
692{
693 struct tc *t;
694
695 list_for_each_entry(t, &vpecontrol.tc_list, list) {
696 dump_tc(t);
697 }
698}
699
700/* We are prepared so configure and start the VPE... */ 666/* We are prepared so configure and start the VPE... */
701static int vpe_run(struct vpe * v) 667static int vpe_run(struct vpe * v)
702{ 668{
669 unsigned long flags, val, dmt_flag;
703 struct vpe_notifications *n; 670 struct vpe_notifications *n;
704 unsigned long val, dmt_flag; 671 unsigned int vpeflags;
705 struct tc *t; 672 struct tc *t;
706 673
707 /* check we are the Master VPE */ 674 /* check we are the Master VPE */
675 local_irq_save(flags);
708 val = read_c0_vpeconf0(); 676 val = read_c0_vpeconf0();
709 if (!(val & VPECONF0_MVP)) { 677 if (!(val & VPECONF0_MVP)) {
710 printk(KERN_WARNING 678 printk(KERN_WARNING
711 "VPE loader: only Master VPE's are allowed to configure MT\n"); 679 "VPE loader: only Master VPE's are allowed to configure MT\n");
680 local_irq_restore(flags);
681
712 return -1; 682 return -1;
713 } 683 }
714 684
715 /* disable MT (using dvpe) */ 685 dmt_flag = dmt();
716 dvpe(); 686 vpeflags = dvpe();
717 687
718 if (!list_empty(&v->tc)) { 688 if (!list_empty(&v->tc)) {
719 if ((t = list_entry(v->tc.next, struct tc, tc)) == NULL) { 689 if ((t = list_entry(v->tc.next, struct tc, tc)) == NULL) {
720 printk(KERN_WARNING "VPE loader: TC %d is already in use.\n", 690 evpe(vpeflags);
721 t->index); 691 emt(dmt_flag);
692 local_irq_restore(flags);
693
694 printk(KERN_WARNING
695 "VPE loader: TC %d is already in use.\n",
696 t->index);
722 return -ENOEXEC; 697 return -ENOEXEC;
723 } 698 }
724 } else { 699 } else {
725 printk(KERN_WARNING "VPE loader: No TC's associated with VPE %d\n", 700 evpe(vpeflags);
701 emt(dmt_flag);
702 local_irq_restore(flags);
703
704 printk(KERN_WARNING
705 "VPE loader: No TC's associated with VPE %d\n",
726 v->minor); 706 v->minor);
707
727 return -ENOEXEC; 708 return -ENOEXEC;
728 } 709 }
729 710
@@ -734,21 +715,20 @@ static int vpe_run(struct vpe * v)
734 715
735 /* should check it is halted, and not activated */ 716 /* should check it is halted, and not activated */
736 if ((read_tc_c0_tcstatus() & TCSTATUS_A) || !(read_tc_c0_tchalt() & TCHALT_H)) { 717 if ((read_tc_c0_tcstatus() & TCSTATUS_A) || !(read_tc_c0_tchalt() & TCHALT_H)) {
737 printk(KERN_WARNING "VPE loader: TC %d is already doing something!\n", 718 evpe(vpeflags);
719 emt(dmt_flag);
720 local_irq_restore(flags);
721
722 printk(KERN_WARNING "VPE loader: TC %d is already active!\n",
738 t->index); 723 t->index);
739 dump_tclist(); 724
740 return -ENOEXEC; 725 return -ENOEXEC;
741 } 726 }
742 727
743 /*
744 * Disable multi-threaded execution whilst we activate, clear the
745 * halt bit and bound the tc to the other VPE...
746 */
747 dmt_flag = dmt();
748
749 /* Write the address we want it to start running from in the TCPC register. */ 728 /* Write the address we want it to start running from in the TCPC register. */
750 write_tc_c0_tcrestart((unsigned long)v->__start); 729 write_tc_c0_tcrestart((unsigned long)v->__start);
751 write_tc_c0_tccontext((unsigned long)0); 730 write_tc_c0_tccontext((unsigned long)0);
731
752 /* 732 /*
753 * Mark the TC as activated, not interrupt exempt and not dynamically 733 * Mark the TC as activated, not interrupt exempt and not dynamically
754 * allocatable 734 * allocatable
@@ -764,15 +744,15 @@ static int vpe_run(struct vpe * v)
764 * here... Or set $a3 to zero and define DFLT_STACK_SIZE and 744 * here... Or set $a3 to zero and define DFLT_STACK_SIZE and
765 * DFLT_HEAP_SIZE when you compile your program 745 * DFLT_HEAP_SIZE when you compile your program
766 */ 746 */
767 mttgpr(7, physical_memsize); 747 mttgpr(6, v->ntcs);
768 748 mttgpr(7, physical_memsize);
769 749
770 /* set up VPE1 */ 750 /* set up VPE1 */
771 /* 751 /*
772 * bind the TC to VPE 1 as late as possible so we only have the final 752 * bind the TC to VPE 1 as late as possible so we only have the final
773 * VPE registers to set up, and so an EJTAG probe can trigger on it 753 * VPE registers to set up, and so an EJTAG probe can trigger on it
774 */ 754 */
775 write_tc_c0_tcbind((read_tc_c0_tcbind() & ~TCBIND_CURVPE) | v->minor); 755 write_tc_c0_tcbind((read_tc_c0_tcbind() & ~TCBIND_CURVPE) | 1);
776 756
777 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~(VPECONF0_VPA)); 757 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~(VPECONF0_VPA));
778 758
@@ -794,15 +774,16 @@ static int vpe_run(struct vpe * v)
794 /* take system out of configuration state */ 774 /* take system out of configuration state */
795 clear_c0_mvpcontrol(MVPCONTROL_VPC); 775 clear_c0_mvpcontrol(MVPCONTROL_VPC);
796 776
797 /* now safe to re-enable multi-threading */ 777#ifdef CONFIG_SMP
798 emt(dmt_flag);
799
800 /* set it running */
801 evpe(EVPE_ENABLE); 778 evpe(EVPE_ENABLE);
779#else
780 evpe(vpeflags);
781#endif
782 emt(dmt_flag);
783 local_irq_restore(flags);
802 784
803 list_for_each_entry(n, &v->notify, list) { 785 list_for_each_entry(n, &v->notify, list)
804 n->start(v->minor); 786 n->start(minor);
805 }
806 787
807 return 0; 788 return 0;
808} 789}
@@ -1024,23 +1005,15 @@ static int vpe_elfload(struct vpe * v)
1024 return 0; 1005 return 0;
1025} 1006}
1026 1007
1027__attribute_used__ void dump_vpe(struct vpe * v)
1028{
1029 struct tc *t;
1030
1031 settc(v->minor);
1032
1033 printk(KERN_DEBUG "VPEControl 0x%lx\n", read_vpe_c0_vpecontrol());
1034 printk(KERN_DEBUG "VPEConf0 0x%lx\n", read_vpe_c0_vpeconf0());
1035
1036 list_for_each_entry(t, &vpecontrol.tc_list, list)
1037 dump_tc(t);
1038}
1039
1040static void cleanup_tc(struct tc *tc) 1008static void cleanup_tc(struct tc *tc)
1041{ 1009{
1010 unsigned long flags;
1011 unsigned int mtflags, vpflags;
1042 int tmp; 1012 int tmp;
1043 1013
1014 local_irq_save(flags);
1015 mtflags = dmt();
1016 vpflags = dvpe();
1044 /* Put MVPE's into 'configuration state' */ 1017 /* Put MVPE's into 'configuration state' */
1045 set_c0_mvpcontrol(MVPCONTROL_VPC); 1018 set_c0_mvpcontrol(MVPCONTROL_VPC);
1046 1019
@@ -1055,9 +1028,12 @@ static void cleanup_tc(struct tc *tc)
1055 write_tc_c0_tchalt(TCHALT_H); 1028 write_tc_c0_tchalt(TCHALT_H);
1056 1029
1057 /* bind it to anything other than VPE1 */ 1030 /* bind it to anything other than VPE1 */
1058 write_tc_c0_tcbind(read_tc_c0_tcbind() & ~TCBIND_CURVPE); // | TCBIND_CURVPE 1031// write_tc_c0_tcbind(read_tc_c0_tcbind() & ~TCBIND_CURVPE); // | TCBIND_CURVPE
1059 1032
1060 clear_c0_mvpcontrol(MVPCONTROL_VPC); 1033 clear_c0_mvpcontrol(MVPCONTROL_VPC);
1034 evpe(vpflags);
1035 emt(mtflags);
1036 local_irq_restore(flags);
1061} 1037}
1062 1038
1063static int getcwd(char *buff, int size) 1039static int getcwd(char *buff, int size)
@@ -1078,36 +1054,32 @@ static int getcwd(char *buff, int size)
1078/* checks VPE is unused and gets ready to load program */ 1054/* checks VPE is unused and gets ready to load program */
1079static int vpe_open(struct inode *inode, struct file *filp) 1055static int vpe_open(struct inode *inode, struct file *filp)
1080{ 1056{
1081 int minor, ret;
1082 enum vpe_state state; 1057 enum vpe_state state;
1083 struct vpe *v;
1084 struct vpe_notifications *not; 1058 struct vpe_notifications *not;
1059 struct vpe *v;
1060 int ret;
1085 1061
1086 /* assume only 1 device at the mo. */ 1062 if (minor != iminor(inode)) {
1087 if ((minor = iminor(inode)) != 1) { 1063 /* assume only 1 device at the moment. */
1088 printk(KERN_WARNING "VPE loader: only vpe1 is supported\n"); 1064 printk(KERN_WARNING "VPE loader: only vpe1 is supported\n");
1089 return -ENODEV; 1065 return -ENODEV;
1090 } 1066 }
1091 1067
1092 if ((v = get_vpe(minor)) == NULL) { 1068 if ((v = get_vpe(tclimit)) == NULL) {
1093 printk(KERN_WARNING "VPE loader: unable to get vpe\n"); 1069 printk(KERN_WARNING "VPE loader: unable to get vpe\n");
1094 return -ENODEV; 1070 return -ENODEV;
1095 } 1071 }
1096 1072
1097 state = xchg(&v->state, VPE_STATE_INUSE); 1073 state = xchg(&v->state, VPE_STATE_INUSE);
1098 if (state != VPE_STATE_UNUSED) { 1074 if (state != VPE_STATE_UNUSED) {
1099 dvpe();
1100
1101 printk(KERN_DEBUG "VPE loader: tc in use dumping regs\n"); 1075 printk(KERN_DEBUG "VPE loader: tc in use dumping regs\n");
1102 1076
1103 dump_tc(get_tc(minor));
1104
1105 list_for_each_entry(not, &v->notify, list) { 1077 list_for_each_entry(not, &v->notify, list) {
1106 not->stop(minor); 1078 not->stop(tclimit);
1107 } 1079 }
1108 1080
1109 release_progmem(v->load_addr); 1081 release_progmem(v->load_addr);
1110 cleanup_tc(get_tc(minor)); 1082 cleanup_tc(get_tc(tclimit));
1111 } 1083 }
1112 1084
1113 /* this of-course trashes what was there before... */ 1085 /* this of-course trashes what was there before... */
@@ -1134,26 +1106,25 @@ static int vpe_open(struct inode *inode, struct file *filp)
1134 1106
1135 v->shared_ptr = NULL; 1107 v->shared_ptr = NULL;
1136 v->__start = 0; 1108 v->__start = 0;
1109
1137 return 0; 1110 return 0;
1138} 1111}
1139 1112
1140static int vpe_release(struct inode *inode, struct file *filp) 1113static int vpe_release(struct inode *inode, struct file *filp)
1141{ 1114{
1142 int minor, ret = 0;
1143 struct vpe *v; 1115 struct vpe *v;
1144 Elf_Ehdr *hdr; 1116 Elf_Ehdr *hdr;
1117 int ret = 0;
1145 1118
1146 minor = iminor(inode); 1119 v = get_vpe(tclimit);
1147 if ((v = get_vpe(minor)) == NULL) 1120 if (v == NULL)
1148 return -ENODEV; 1121 return -ENODEV;
1149 1122
1150 // simple case of fire and forget, so tell the VPE to run...
1151
1152 hdr = (Elf_Ehdr *) v->pbuffer; 1123 hdr = (Elf_Ehdr *) v->pbuffer;
1153 if (memcmp(hdr->e_ident, ELFMAG, 4) == 0) { 1124 if (memcmp(hdr->e_ident, ELFMAG, 4) == 0) {
1154 if (vpe_elfload(v) >= 0) 1125 if (vpe_elfload(v) >= 0) {
1155 vpe_run(v); 1126 vpe_run(v);
1156 else { 1127 } else {
1157 printk(KERN_WARNING "VPE loader: ELF load failed.\n"); 1128 printk(KERN_WARNING "VPE loader: ELF load failed.\n");
1158 ret = -ENOEXEC; 1129 ret = -ENOEXEC;
1159 } 1130 }
@@ -1180,12 +1151,14 @@ static int vpe_release(struct inode *inode, struct file *filp)
1180static ssize_t vpe_write(struct file *file, const char __user * buffer, 1151static ssize_t vpe_write(struct file *file, const char __user * buffer,
1181 size_t count, loff_t * ppos) 1152 size_t count, loff_t * ppos)
1182{ 1153{
1183 int minor;
1184 size_t ret = count; 1154 size_t ret = count;
1185 struct vpe *v; 1155 struct vpe *v;
1186 1156
1187 minor = iminor(file->f_path.dentry->d_inode); 1157 if (iminor(file->f_path.dentry->d_inode) != minor)
1188 if ((v = get_vpe(minor)) == NULL) 1158 return -ENODEV;
1159
1160 v = get_vpe(tclimit);
1161 if (v == NULL)
1189 return -ENODEV; 1162 return -ENODEV;
1190 1163
1191 if (v->pbuffer == NULL) { 1164 if (v->pbuffer == NULL) {
@@ -1367,62 +1340,173 @@ static void kspd_sp_exit( int sp_id)
1367} 1340}
1368#endif 1341#endif
1369 1342
1370static struct device *vpe_dev; 1343static ssize_t store_kill(struct class_device *dev, const char *buf, size_t len)
1344{
1345 struct vpe *vpe = get_vpe(tclimit);
1346 struct vpe_notifications *not;
1347
1348 list_for_each_entry(not, &vpe->notify, list) {
1349 not->stop(tclimit);
1350 }
1351
1352 release_progmem(vpe->load_addr);
1353 cleanup_tc(get_tc(tclimit));
1354 vpe_stop(vpe);
1355 vpe_free(vpe);
1356
1357 return len;
1358}
1359
1360static ssize_t show_ntcs(struct class_device *cd, char *buf)
1361{
1362 struct vpe *vpe = get_vpe(tclimit);
1363
1364 return sprintf(buf, "%d\n", vpe->ntcs);
1365}
1366
1367static ssize_t store_ntcs(struct class_device *dev, const char *buf, size_t len)
1368{
1369 struct vpe *vpe = get_vpe(tclimit);
1370 unsigned long new;
1371 char *endp;
1372
1373 new = simple_strtoul(buf, &endp, 0);
1374 if (endp == buf)
1375 goto out_einval;
1376
1377 if (new == 0 || new > (hw_tcs - tclimit))
1378 goto out_einval;
1379
1380 vpe->ntcs = new;
1381
1382 return len;
1383
1384out_einval:
1385 return -EINVAL;;
1386}
1387
1388static struct class_device_attribute vpe_class_attributes[] = {
1389 __ATTR(kill, S_IWUSR, NULL, store_kill),
1390 __ATTR(ntcs, S_IRUGO | S_IWUSR, show_ntcs, store_ntcs),
1391 {}
1392};
1393
1394static void vpe_class_device_release(struct class_device *cd)
1395{
1396 kfree(cd);
1397}
1398
1399struct class vpe_class = {
1400 .name = "vpe",
1401 .owner = THIS_MODULE,
1402 .release = vpe_class_device_release,
1403 .class_dev_attrs = vpe_class_attributes,
1404};
1405
1406struct class_device vpe_device;
1371 1407
1372static int __init vpe_module_init(void) 1408static int __init vpe_module_init(void)
1373{ 1409{
1410 unsigned int mtflags, vpflags;
1411 unsigned long flags, val;
1374 struct vpe *v = NULL; 1412 struct vpe *v = NULL;
1375 struct device *dev;
1376 struct tc *t; 1413 struct tc *t;
1377 unsigned long val; 1414 int tc, err;
1378 int i, err;
1379 1415
1380 if (!cpu_has_mipsmt) { 1416 if (!cpu_has_mipsmt) {
1381 printk("VPE loader: not a MIPS MT capable processor\n"); 1417 printk("VPE loader: not a MIPS MT capable processor\n");
1382 return -ENODEV; 1418 return -ENODEV;
1383 } 1419 }
1384 1420
1421 if (vpelimit == 0) {
1422 printk(KERN_WARNING "No VPEs reserved for AP/SP, not "
1423 "initializing VPE loader.\nPass maxvpes=<n> argument as "
1424 "kernel argument\n");
1425
1426 return -ENODEV;
1427 }
1428
1429 if (tclimit == 0) {
1430 printk(KERN_WARNING "No TCs reserved for AP/SP, not "
1431 "initializing VPE loader.\nPass maxtcs=<n> argument as "
1432 "kernel argument\n");
1433
1434 return -ENODEV;
1435 }
1436
1385 major = register_chrdev(0, module_name, &vpe_fops); 1437 major = register_chrdev(0, module_name, &vpe_fops);
1386 if (major < 0) { 1438 if (major < 0) {
1387 printk("VPE loader: unable to register character device\n"); 1439 printk("VPE loader: unable to register character device\n");
1388 return major; 1440 return major;
1389 } 1441 }
1390 1442
1391 dev = device_create(mt_class, NULL, MKDEV(major, minor), 1443 err = class_register(&vpe_class);
1392 "tc%d", minor); 1444 if (err) {
1393 if (IS_ERR(dev)) { 1445 printk(KERN_ERR "vpe_class registration failed\n");
1394 err = PTR_ERR(dev);
1395 goto out_chrdev; 1446 goto out_chrdev;
1396 } 1447 }
1397 vpe_dev = dev;
1398 1448
1399 dmt(); 1449 class_device_initialize(&vpe_device);
1400 dvpe(); 1450 vpe_device.class = &vpe_class,
1451 vpe_device.parent = NULL,
1452 strlcpy(vpe_device.class_id, "vpe1", BUS_ID_SIZE);
1453 vpe_device.devt = MKDEV(major, minor);
1454 err = class_device_add(&vpe_device);
1455 if (err) {
1456 printk(KERN_ERR "Adding vpe_device failed\n");
1457 goto out_class;
1458 }
1459
1460 local_irq_save(flags);
1461 mtflags = dmt();
1462 vpflags = dvpe();
1401 1463
1402 /* Put MVPE's into 'configuration state' */ 1464 /* Put MVPE's into 'configuration state' */
1403 set_c0_mvpcontrol(MVPCONTROL_VPC); 1465 set_c0_mvpcontrol(MVPCONTROL_VPC);
1404 1466
1405 /* dump_mtregs(); */ 1467 /* dump_mtregs(); */
1406 1468
1407
1408 val = read_c0_mvpconf0(); 1469 val = read_c0_mvpconf0();
1409 for (i = 0; i < ((val & MVPCONF0_PTC) + 1); i++) { 1470 hw_tcs = (val & MVPCONF0_PTC) + 1;
1410 t = alloc_tc(i); 1471 hw_vpes = ((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT) + 1;
1472
1473 for (tc = tclimit; tc < hw_tcs; tc++) {
1474 /*
1475 * Must re-enable multithreading temporarily or in case we
1476 * reschedule send IPIs or similar we might hang.
1477 */
1478 clear_c0_mvpcontrol(MVPCONTROL_VPC);
1479 evpe(vpflags);
1480 emt(mtflags);
1481 local_irq_restore(flags);
1482 t = alloc_tc(tc);
1483 if (!t) {
1484 err = -ENOMEM;
1485 goto out;
1486 }
1487
1488 local_irq_save(flags);
1489 mtflags = dmt();
1490 vpflags = dvpe();
1491 set_c0_mvpcontrol(MVPCONTROL_VPC);
1411 1492
1412 /* VPE's */ 1493 /* VPE's */
1413 if (i < ((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT) + 1) { 1494 if (tc < hw_tcs) {
1414 settc(i); 1495 settc(tc);
1415 1496
1416 if ((v = alloc_vpe(i)) == NULL) { 1497 if ((v = alloc_vpe(tc)) == NULL) {
1417 printk(KERN_WARNING "VPE: unable to allocate VPE\n"); 1498 printk(KERN_WARNING "VPE: unable to allocate VPE\n");
1418 return -ENODEV; 1499
1500 goto out_reenable;
1419 } 1501 }
1420 1502
1503 v->ntcs = hw_tcs - tclimit;
1504
1421 /* add the tc to the list of this vpe's tc's. */ 1505 /* add the tc to the list of this vpe's tc's. */
1422 list_add(&t->tc, &v->tc); 1506 list_add(&t->tc, &v->tc);
1423 1507
1424 /* deactivate all but vpe0 */ 1508 /* deactivate all but vpe0 */
1425 if (i != 0) { 1509 if (tc >= tclimit) {
1426 unsigned long tmp = read_vpe_c0_vpeconf0(); 1510 unsigned long tmp = read_vpe_c0_vpeconf0();
1427 1511
1428 tmp &= ~VPECONF0_VPA; 1512 tmp &= ~VPECONF0_VPA;
@@ -1435,7 +1519,7 @@ static int __init vpe_module_init(void)
1435 /* disable multi-threading with TC's */ 1519 /* disable multi-threading with TC's */
1436 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() & ~VPECONTROL_TE); 1520 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() & ~VPECONTROL_TE);
1437 1521
1438 if (i != 0) { 1522 if (tc >= vpelimit) {
1439 /* 1523 /*
1440 * Set config to be the same as vpe0, 1524 * Set config to be the same as vpe0,
1441 * particularly kseg0 coherency alg 1525 * particularly kseg0 coherency alg
@@ -1447,10 +1531,10 @@ static int __init vpe_module_init(void)
1447 /* TC's */ 1531 /* TC's */
1448 t->pvpe = v; /* set the parent vpe */ 1532 t->pvpe = v; /* set the parent vpe */
1449 1533
1450 if (i != 0) { 1534 if (tc >= tclimit) {
1451 unsigned long tmp; 1535 unsigned long tmp;
1452 1536
1453 settc(i); 1537 settc(tc);
1454 1538
1455 /* Any TC that is bound to VPE0 gets left as is - in case 1539 /* Any TC that is bound to VPE0 gets left as is - in case
1456 we are running SMTC on VPE0. A TC that is bound to any 1540 we are running SMTC on VPE0. A TC that is bound to any
@@ -1480,17 +1564,25 @@ static int __init vpe_module_init(void)
1480 } 1564 }
1481 } 1565 }
1482 1566
1567out_reenable:
1483 /* release config state */ 1568 /* release config state */
1484 clear_c0_mvpcontrol(MVPCONTROL_VPC); 1569 clear_c0_mvpcontrol(MVPCONTROL_VPC);
1485 1570
1571 evpe(vpflags);
1572 emt(mtflags);
1573 local_irq_restore(flags);
1574
1486#ifdef CONFIG_MIPS_APSP_KSPD 1575#ifdef CONFIG_MIPS_APSP_KSPD
1487 kspd_events.kspd_sp_exit = kspd_sp_exit; 1576 kspd_events.kspd_sp_exit = kspd_sp_exit;
1488#endif 1577#endif
1489 return 0; 1578 return 0;
1490 1579
1580out_class:
1581 class_unregister(&vpe_class);
1491out_chrdev: 1582out_chrdev:
1492 unregister_chrdev(major, module_name); 1583 unregister_chrdev(major, module_name);
1493 1584
1585out:
1494 return err; 1586 return err;
1495} 1587}
1496 1588
@@ -1504,7 +1596,7 @@ static void __exit vpe_module_exit(void)
1504 } 1596 }
1505 } 1597 }
1506 1598
1507 device_destroy(mt_class, MKDEV(major, minor)); 1599 class_device_del(&vpe_device);
1508 unregister_chrdev(major, module_name); 1600 unregister_chrdev(major, module_name);
1509} 1601}
1510 1602
diff --git a/arch/mips/lemote/lm2e/Makefile b/arch/mips/lemote/lm2e/Makefile
index fb1b48c48cb3..dcaf6f4c3a37 100644
--- a/arch/mips/lemote/lm2e/Makefile
+++ b/arch/mips/lemote/lm2e/Makefile
@@ -3,5 +3,6 @@
3# 3#
4 4
5obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o mem.o 5obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o mem.o
6EXTRA_AFLAGS := $(CFLAGS)
7 6
7EXTRA_AFLAGS := $(CFLAGS)
8EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/lemote/lm2e/irq.c b/arch/mips/lemote/lm2e/irq.c
index 05693bceaeaf..3e0b7beb1009 100644
--- a/arch/mips/lemote/lm2e/irq.c
+++ b/arch/mips/lemote/lm2e/irq.c
@@ -25,7 +25,6 @@
25 */ 25 */
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/irq.h>
29#include <linux/init.h> 28#include <linux/init.h>
30#include <linux/interrupt.h> 29#include <linux/interrupt.h>
31#include <linux/irq.h> 30#include <linux/irq.h>
diff --git a/arch/mips/lemote/lm2e/prom.c b/arch/mips/lemote/lm2e/prom.c
index 67312d7acf2a..3efb1cf111f2 100644
--- a/arch/mips/lemote/lm2e/prom.c
+++ b/arch/mips/lemote/lm2e/prom.c
@@ -15,15 +15,11 @@
15 * option) any later version. 15 * option) any later version.
16 */ 16 */
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/mm.h>
19#include <linux/sched.h>
20#include <linux/bootmem.h> 18#include <linux/bootmem.h>
21
22#include <asm/addrspace.h>
23#include <asm/bootinfo.h> 19#include <asm/bootinfo.h>
24 20
25extern unsigned long bus_clock; 21extern unsigned long bus_clock;
26extern unsigned long cpu_clock; 22extern unsigned long cpu_clock_freq;
27extern unsigned int memsize, highmemsize; 23extern unsigned int memsize, highmemsize;
28extern int putDebugChar(unsigned char byte); 24extern int putDebugChar(unsigned char byte);
29 25
@@ -81,7 +77,7 @@ do { \
81 l = (long)*env; 77 l = (long)*env;
82 while (l != 0) { 78 while (l != 0) {
83 parse_even_earlier(bus_clock, "busclock", l); 79 parse_even_earlier(bus_clock, "busclock", l);
84 parse_even_earlier(cpu_clock, "cpuclock", l); 80 parse_even_earlier(cpu_clock_freq, "cpuclock", l);
85 parse_even_earlier(memsize, "memsize", l); 81 parse_even_earlier(memsize, "memsize", l);
86 parse_even_earlier(highmemsize, "highmemsize", l); 82 parse_even_earlier(highmemsize, "highmemsize", l);
87 env++; 83 env++;
@@ -91,7 +87,7 @@ do { \
91 memsize = 256; 87 memsize = 256;
92 88
93 pr_info("busclock=%ld, cpuclock=%ld,memsize=%d,highmemsize=%d\n", 89 pr_info("busclock=%ld, cpuclock=%ld,memsize=%d,highmemsize=%d\n",
94 bus_clock, cpu_clock, memsize, highmemsize); 90 bus_clock, cpu_clock_freq, memsize, highmemsize);
95} 91}
96 92
97void __init prom_free_prom_memory(void) 93void __init prom_free_prom_memory(void)
diff --git a/arch/mips/lemote/lm2e/setup.c b/arch/mips/lemote/lm2e/setup.c
index 0e4d1fa572b5..f34350a4f271 100644
--- a/arch/mips/lemote/lm2e/setup.c
+++ b/arch/mips/lemote/lm2e/setup.c
@@ -28,17 +28,7 @@
28 */ 28 */
29#include <linux/bootmem.h> 29#include <linux/bootmem.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/io.h>
32#include <linux/ioport.h>
33#include <linux/interrupt.h>
34#include <linux/irq.h> 31#include <linux/irq.h>
35#include <linux/kernel.h>
36#include <linux/mc146818rtc.h>
37#include <linux/mm.h>
38#include <linux/module.h>
39#include <linux/pci.h>
40#include <linux/tty.h>
41#include <linux/types.h>
42 32
43#include <asm/bootinfo.h> 33#include <asm/bootinfo.h>
44#include <asm/mc146818-time.h> 34#include <asm/mc146818-time.h>
@@ -58,7 +48,7 @@ extern void mips_reboot_setup(void);
58#define PTR_PAD(p) (p) 48#define PTR_PAD(p) (p)
59#endif 49#endif
60 50
61unsigned long cpu_clock; 51unsigned long cpu_clock_freq;
62unsigned long bus_clock; 52unsigned long bus_clock;
63unsigned int memsize; 53unsigned int memsize;
64unsigned int highmemsize = 0; 54unsigned int highmemsize = 0;
@@ -71,7 +61,7 @@ void __init plat_timer_setup(struct irqaction *irq)
71static void __init loongson2e_time_init(void) 61static void __init loongson2e_time_init(void)
72{ 62{
73 /* setup mips r4k timer */ 63 /* setup mips r4k timer */
74 mips_hpt_frequency = cpu_clock / 2; 64 mips_hpt_frequency = cpu_clock_freq / 2;
75} 65}
76 66
77static unsigned long __init mips_rtc_get_time(void) 67static unsigned long __init mips_rtc_get_time(void)
diff --git a/arch/mips/math-emu/Makefile b/arch/mips/math-emu/Makefile
index 121a848a3594..d547efdeedc2 100644
--- a/arch/mips/math-emu/Makefile
+++ b/arch/mips/math-emu/Makefile
@@ -9,3 +9,5 @@ obj-y := cp1emu.o ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
9 sp_div.o sp_mul.o sp_sub.o sp_add.o sp_fdp.o sp_cmp.o sp_logb.o \ 9 sp_div.o sp_mul.o sp_sub.o sp_add.o sp_fdp.o sp_cmp.o sp_logb.o \
10 sp_scalb.o sp_simple.o sp_tint.o sp_fint.o sp_tlong.o sp_flong.o \ 10 sp_scalb.o sp_simple.o sp_tint.o sp_fint.o sp_tlong.o sp_flong.o \
11 dp_sqrt.o sp_sqrt.o kernel_linkage.o dsemul.o 11 dp_sqrt.o sp_sqrt.o kernel_linkage.o dsemul.o
12
13EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mips-boards/atlas/Makefile b/arch/mips/mips-boards/atlas/Makefile
index d8dab75906bf..f71c2dd1041a 100644
--- a/arch/mips/mips-boards/atlas/Makefile
+++ b/arch/mips/mips-boards/atlas/Makefile
@@ -18,3 +18,5 @@
18 18
19obj-y := atlas_int.o atlas_setup.o 19obj-y := atlas_int.o atlas_setup.o
20obj-$(CONFIG_KGDB) += atlas_gdb.o 20obj-$(CONFIG_KGDB) += atlas_gdb.o
21
22EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mips-boards/atlas/atlas_int.c b/arch/mips/mips-boards/atlas/atlas_int.c
index 6c8f0255e85d..3c692abc2553 100644
--- a/arch/mips/mips-boards/atlas/atlas_int.c
+++ b/arch/mips/mips-boards/atlas/atlas_int.c
@@ -245,6 +245,7 @@ void __init arch_init_irq(void)
245 case MIPS_REVISION_CORID_CORE_MSC: 245 case MIPS_REVISION_CORID_CORE_MSC:
246 case MIPS_REVISION_CORID_CORE_FPGA2: 246 case MIPS_REVISION_CORID_CORE_FPGA2:
247 case MIPS_REVISION_CORID_CORE_FPGA3: 247 case MIPS_REVISION_CORID_CORE_FPGA3:
248 case MIPS_REVISION_CORID_CORE_FPGA4:
248 case MIPS_REVISION_CORID_CORE_24K: 249 case MIPS_REVISION_CORID_CORE_24K:
249 case MIPS_REVISION_CORID_CORE_EMUL_MSC: 250 case MIPS_REVISION_CORID_CORE_EMUL_MSC:
250 if (cpu_has_veic) 251 if (cpu_has_veic)
diff --git a/arch/mips/mips-boards/generic/Makefile b/arch/mips/mips-boards/generic/Makefile
index aade36d78787..b31d8dfed1be 100644
--- a/arch/mips/mips-boards/generic/Makefile
+++ b/arch/mips/mips-boards/generic/Makefile
@@ -24,3 +24,5 @@ obj-y := reset.o display.o init.o memory.o \
24obj-$(CONFIG_EARLY_PRINTK) += console.o 24obj-$(CONFIG_EARLY_PRINTK) += console.o
25obj-$(CONFIG_PCI) += pci.o 25obj-$(CONFIG_PCI) += pci.o
26obj-$(CONFIG_KGDB) += gdb_hook.o 26obj-$(CONFIG_KGDB) += gdb_hook.o
27
28EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mips-boards/generic/init.c b/arch/mips/mips-boards/generic/init.c
index 4eabc1eadd23..e2c7147fedf7 100644
--- a/arch/mips/mips-boards/generic/init.c
+++ b/arch/mips/mips-boards/generic/init.c
@@ -294,6 +294,7 @@ void __init prom_init(void)
294 case MIPS_REVISION_CORID_CORE_MSC: 294 case MIPS_REVISION_CORID_CORE_MSC:
295 case MIPS_REVISION_CORID_CORE_FPGA2: 295 case MIPS_REVISION_CORID_CORE_FPGA2:
296 case MIPS_REVISION_CORID_CORE_FPGA3: 296 case MIPS_REVISION_CORID_CORE_FPGA3:
297 case MIPS_REVISION_CORID_CORE_FPGA4:
297 case MIPS_REVISION_CORID_CORE_24K: 298 case MIPS_REVISION_CORID_CORE_24K:
298 case MIPS_REVISION_CORID_CORE_EMUL_MSC: 299 case MIPS_REVISION_CORID_CORE_EMUL_MSC:
299 mips_revision_sconid = MIPS_REVISION_SCON_SOCIT; 300 mips_revision_sconid = MIPS_REVISION_SCON_SOCIT;
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index c45d556aa96b..d7bff9ca5356 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -55,7 +55,7 @@ unsigned long cpu_khz;
55 55
56static int mips_cpu_timer_irq; 56static int mips_cpu_timer_irq;
57extern int cp0_perfcount_irq; 57extern int cp0_perfcount_irq;
58extern void smtc_timer_broadcast(int); 58extern void smtc_timer_broadcast(void);
59 59
60static void mips_timer_dispatch(void) 60static void mips_timer_dispatch(void)
61{ 61{
@@ -131,7 +131,7 @@ irqreturn_t mips_timer_interrupt(int irq, void *dev_id)
131 (mips_hpt_frequency/HZ)); 131 (mips_hpt_frequency/HZ));
132 local_timer_interrupt(irq, dev_id); 132 local_timer_interrupt(irq, dev_id);
133 } 133 }
134 smtc_timer_broadcast(cpu_data[cpu].vpe_id); 134 smtc_timer_broadcast();
135 } 135 }
136#else /* CONFIG_MIPS_MT_SMTC */ 136#else /* CONFIG_MIPS_MT_SMTC */
137 int r2 = cpu_has_mips_r2; 137 int r2 = cpu_has_mips_r2;
diff --git a/arch/mips/mips-boards/malta/Makefile b/arch/mips/mips-boards/malta/Makefile
index a242b0fc377d..931ca4600a63 100644
--- a/arch/mips/mips-boards/malta/Makefile
+++ b/arch/mips/mips-boards/malta/Makefile
@@ -23,3 +23,5 @@ obj-y := malta_int.o malta_platform.o malta_setup.o
23 23
24obj-$(CONFIG_MTD) += malta_mtd.o 24obj-$(CONFIG_MTD) += malta_mtd.o
25obj-$(CONFIG_MIPS_MT_SMTC) += malta_smtc.o 25obj-$(CONFIG_MIPS_MT_SMTC) += malta_smtc.o
26
27EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mips-boards/malta/malta_int.c b/arch/mips/mips-boards/malta/malta_int.c
index c78d48349600..97aeb8c4e601 100644
--- a/arch/mips/mips-boards/malta/malta_int.c
+++ b/arch/mips/mips-boards/malta/malta_int.c
@@ -330,6 +330,18 @@ void __init arch_init_irq(void)
330 (0x100 << MIPSCPU_INT_I8259A)); 330 (0x100 << MIPSCPU_INT_I8259A));
331 setup_irq_smtc (MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI, 331 setup_irq_smtc (MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI,
332 &corehi_irqaction, (0x100 << MIPSCPU_INT_COREHI)); 332 &corehi_irqaction, (0x100 << MIPSCPU_INT_COREHI));
333 /*
334 * Temporary hack to ensure that the subsidiary device
335 * interrupts coing in via the i8259A, but associated
336 * with low IRQ numbers, will restore the Status.IM
337 * value associated with the i8259A.
338 */
339 {
340 int i;
341
342 for (i = 0; i < 16; i++)
343 irq_hwmask[i] = (0x100 << MIPSCPU_INT_I8259A);
344 }
333#else /* Not SMTC */ 345#else /* Not SMTC */
334 setup_irq (MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq); 346 setup_irq (MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq);
335 setup_irq (MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI, &corehi_irqaction); 347 setup_irq (MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI, &corehi_irqaction);
diff --git a/arch/mips/mips-boards/malta/malta_smtc.c b/arch/mips/mips-boards/malta/malta_smtc.c
index d1c80f631100..0fb4c269901c 100644
--- a/arch/mips/mips-boards/malta/malta_smtc.c
+++ b/arch/mips/mips-boards/malta/malta_smtc.c
@@ -58,7 +58,7 @@ void prom_init_secondary(void)
58 * but it may be multithreaded. 58 * but it may be multithreaded.
59 */ 59 */
60 60
61void plat_smp_setup(void) 61void __cpuinit plat_smp_setup(void)
62{ 62{
63 if (read_c0_config3() & (1<<2)) 63 if (read_c0_config3() & (1<<2))
64 mipsmt_build_cpu_map(0); 64 mipsmt_build_cpu_map(0);
diff --git a/arch/mips/mips-boards/sead/Makefile b/arch/mips/mips-boards/sead/Makefile
index 224bb848f16b..3682fe217bd5 100644
--- a/arch/mips/mips-boards/sead/Makefile
+++ b/arch/mips/mips-boards/sead/Makefile
@@ -24,3 +24,5 @@
24# 24#
25 25
26obj-y := sead_int.o sead_setup.o 26obj-y := sead_int.o sead_setup.o
27
28EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mipssim/Makefile b/arch/mips/mipssim/Makefile
index dc0bfda11427..75568b584df4 100644
--- a/arch/mips/mipssim/Makefile
+++ b/arch/mips/mipssim/Makefile
@@ -22,3 +22,5 @@ obj-y := sim_platform.o sim_setup.o sim_mem.o sim_time.o sim_int.o \
22 22
23obj-$(CONFIG_EARLY_PRINTK) += sim_console.o 23obj-$(CONFIG_EARLY_PRINTK) += sim_console.o
24obj-$(CONFIG_SMP) += sim_smp.o 24obj-$(CONFIG_SMP) += sim_smp.o
25
26EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mipssim/sim_setup.c b/arch/mips/mipssim/sim_setup.c
index 17819b594105..d012719c4d24 100644
--- a/arch/mips/mipssim/sim_setup.c
+++ b/arch/mips/mipssim/sim_setup.c
@@ -22,7 +22,6 @@
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/serial.h>
26#include <linux/tty.h> 25#include <linux/tty.h>
27#include <linux/serial.h> 26#include <linux/serial.h>
28#include <linux/serial_core.h> 27#include <linux/serial_core.h>
diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile
index 19a0e544c4e9..43e4810dcaa8 100644
--- a/arch/mips/mm/Makefile
+++ b/arch/mips/mm/Makefile
@@ -32,3 +32,5 @@ obj-$(CONFIG_IP22_CPU_SCACHE) += sc-ip22.o
32obj-$(CONFIG_R5000_CPU_SCACHE) += sc-r5k.o 32obj-$(CONFIG_R5000_CPU_SCACHE) += sc-r5k.o
33obj-$(CONFIG_RM7000_CPU_SCACHE) += sc-rm7k.o 33obj-$(CONFIG_RM7000_CPU_SCACHE) += sc-rm7k.o
34obj-$(CONFIG_MIPS_CPU_SCACHE) += sc-mips.o 34obj-$(CONFIG_MIPS_CPU_SCACHE) += sc-mips.o
35
36EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index be96231dccb6..bad571971bf6 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -23,6 +23,7 @@
23#include <asm/page.h> 23#include <asm/page.h>
24#include <asm/pgtable.h> 24#include <asm/pgtable.h>
25#include <asm/r4kcache.h> 25#include <asm/r4kcache.h>
26#include <asm/sections.h>
26#include <asm/system.h> 27#include <asm/system.h>
27#include <asm/mmu_context.h> 28#include <asm/mmu_context.h>
28#include <asm/war.h> 29#include <asm/war.h>
@@ -1010,7 +1011,6 @@ static void __init probe_pcache(void)
1010 */ 1011 */
1011static int __init probe_scache(void) 1012static int __init probe_scache(void)
1012{ 1013{
1013 extern unsigned long stext;
1014 unsigned long flags, addr, begin, end, pow2; 1014 unsigned long flags, addr, begin, end, pow2;
1015 unsigned int config = read_c0_config(); 1015 unsigned int config = read_c0_config();
1016 struct cpuinfo_mips *c = &current_cpu_data; 1016 struct cpuinfo_mips *c = &current_cpu_data;
@@ -1019,7 +1019,7 @@ static int __init probe_scache(void)
1019 if (config & CONF_SC) 1019 if (config & CONF_SC)
1020 return 0; 1020 return 0;
1021 1021
1022 begin = (unsigned long) &stext; 1022 begin = (unsigned long) &_stext;
1023 begin &= ~((4 * 1024 * 1024) - 1); 1023 begin &= ~((4 * 1024 * 1024) - 1);
1024 end = begin + (4 * 1024 * 1024); 1024 end = begin + (4 * 1024 * 1024);
1025 1025
diff --git a/arch/mips/mm/c-sb1.c b/arch/mips/mm/c-sb1.c
index 6f9bd7fbd481..85ce2842d0da 100644
--- a/arch/mips/mm/c-sb1.c
+++ b/arch/mips/mm/c-sb1.c
@@ -272,7 +272,7 @@ void sb1_flush_cache_data_page(unsigned long)
272/* 272/*
273 * Invalidate all caches on this CPU 273 * Invalidate all caches on this CPU
274 */ 274 */
275static void __attribute_used__ local_sb1___flush_cache_all(void) 275static void __used local_sb1___flush_cache_all(void)
276{ 276{
277 __sb1_writeback_inv_dcache_all(); 277 __sb1_writeback_inv_dcache_all();
278 __sb1_flush_icache_all(); 278 __sb1_flush_icache_all();
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 4c80528deadd..b8cb0dde3af0 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -484,7 +484,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
484} 484}
485#endif 485#endif
486 486
487void free_initmem(void) 487void __init_refok free_initmem(void)
488{ 488{
489 prom_free_prom_memory(); 489 prom_free_prom_memory();
490 free_init_pages("unused kernel memory", 490 free_init_pages("unused kernel memory",
diff --git a/arch/mips/oprofile/op_model_rm9000.c b/arch/mips/oprofile/op_model_rm9000.c
index 7dc9bf6f1321..d29040a56aea 100644
--- a/arch/mips/oprofile/op_model_rm9000.c
+++ b/arch/mips/oprofile/op_model_rm9000.c
@@ -83,6 +83,7 @@ static void rm9000_cpu_stop(void *args)
83static irqreturn_t rm9000_perfcount_handler(int irq, void * dev_id) 83static irqreturn_t rm9000_perfcount_handler(int irq, void * dev_id)
84{ 84{
85 unsigned int control = read_c0_perfcontrol(); 85 unsigned int control = read_c0_perfcontrol();
86 struct pt_regs *regs = get_irq_regs();
86 uint32_t counter1, counter2; 87 uint32_t counter1, counter2;
87 uint64_t counters; 88 uint64_t counters;
88 89
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index c58bd3d036f4..4ee6800e67e6 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -19,7 +19,6 @@ obj-$(CONFIG_MARKEINS) += ops-emma2rh.o pci-emma2rh.o fixup-emma2rh.o
19# These are still pretty much in the old state, watch, go blind. 19# These are still pretty much in the old state, watch, go blind.
20# 20#
21obj-$(CONFIG_BASLER_EXCITE) += ops-titan.o pci-excite.o fixup-excite.o 21obj-$(CONFIG_BASLER_EXCITE) += ops-titan.o pci-excite.o fixup-excite.o
22obj-$(CONFIG_DDB5477) += fixup-ddb5477.o pci-ddb5477.o ops-ddb5477.o
23obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o 22obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o
24obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o 23obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o
25obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o 24obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o
@@ -27,7 +26,6 @@ obj-$(CONFIG_SOC_AU1550) += fixup-au1000.o ops-au1000.o
27obj-$(CONFIG_SOC_PNX8550) += fixup-pnx8550.o ops-pnx8550.o 26obj-$(CONFIG_SOC_PNX8550) += fixup-pnx8550.o ops-pnx8550.o
28obj-$(CONFIG_LEMOTE_FULONG) += fixup-lm2e.o ops-bonito64.o 27obj-$(CONFIG_LEMOTE_FULONG) += fixup-lm2e.o ops-bonito64.o
29obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o 28obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o
30obj-$(CONFIG_MOMENCO_OCELOT) += fixup-ocelot.o pci-ocelot.o
31obj-$(CONFIG_PMC_MSP7120_GW) += fixup-pmcmsp.o ops-pmcmsp.o 29obj-$(CONFIG_PMC_MSP7120_GW) += fixup-pmcmsp.o ops-pmcmsp.o
32obj-$(CONFIG_PMC_MSP7120_EVAL) += fixup-pmcmsp.o ops-pmcmsp.o 30obj-$(CONFIG_PMC_MSP7120_EVAL) += fixup-pmcmsp.o ops-pmcmsp.o
33obj-$(CONFIG_PMC_MSP7120_FPGA) += fixup-pmcmsp.o ops-pmcmsp.o 31obj-$(CONFIG_PMC_MSP7120_FPGA) += fixup-pmcmsp.o ops-pmcmsp.o
diff --git a/arch/mips/pci/fixup-ddb5477.c b/arch/mips/pci/fixup-ddb5477.c
deleted file mode 100644
index 2f1444e60654..000000000000
--- a/arch/mips/pci/fixup-ddb5477.c
+++ /dev/null
@@ -1,78 +0,0 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Board specific pci fixups.
5 *
6 * Copyright 2001, 2002, 2003 MontaVista Software Inc.
7 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 */
29
30#include <linux/types.h>
31#include <linux/pci.h>
32#include <linux/kernel.h>
33#include <linux/init.h>
34
35static void ddb5477_fixup(struct pci_dev *dev)
36{
37 u8 old;
38
39 printk(KERN_NOTICE "Enabling ALI M1533/35 PS2 keyboard/mouse.\n");
40 pci_read_config_byte(dev, 0x41, &old);
41 pci_write_config_byte(dev, 0x41, old | 0xd0);
42}
43
44DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533,
45 ddb5477_fixup);
46DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1535,
47 ddb5477_fixup);
48
49/*
50 * Fixup baseboard AMD chip so that tx does not underflow.
51 * bcr_18 |= 0x0800
52 * This sets NOUFLO bit which makes tx not start until whole pkt
53 * is fetched to the chip.
54 */
55#define PCNET32_WIO_RDP 0x10
56#define PCNET32_WIO_RAP 0x12
57#define PCNET32_WIO_RESET 0x14
58#define PCNET32_WIO_BDP 0x16
59
60static void ddb5477_amd_lance_fixup(struct pci_dev *dev)
61{
62 unsigned long ioaddr;
63 u16 temp;
64
65 ioaddr = pci_resource_start(dev, 0);
66
67 inw(ioaddr + PCNET32_WIO_RESET); /* reset chip */
68
69 /* bcr_18 |= 0x0800 */
70 outw(18, ioaddr + PCNET32_WIO_RAP);
71 temp = inw(ioaddr + PCNET32_WIO_BDP);
72 temp |= 0x0800;
73 outw(18, ioaddr + PCNET32_WIO_RAP);
74 outw(temp, ioaddr + PCNET32_WIO_BDP);
75}
76
77DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE,
78 ddb5477_amd_lance_fixup);
diff --git a/arch/mips/pci/fixup-ocelot.c b/arch/mips/pci/fixup-ocelot.c
deleted file mode 100644
index 99629bd047ce..000000000000
--- a/arch/mips/pci/fixup-ocelot.c
+++ /dev/null
@@ -1,75 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
4 *
5 * arch/mips/gt64120/momenco_ocelot/pci.c
6 * Board-specific PCI routines for gt64120 controller.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13#include <linux/types.h>
14#include <linux/pci.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <asm/pci.h>
18
19
20void __devinit pcibios_fixup_bus(struct pci_bus *bus)
21{
22 struct pci_bus *current_bus = bus;
23 struct pci_dev *devices;
24 struct list_head *devices_link;
25 u16 cmd;
26
27 list_for_each(devices_link, &(current_bus->devices)) {
28
29 devices = pci_dev_b(devices_link);
30 if (devices == NULL)
31 continue;
32
33 if (PCI_SLOT(devices->devfn) == 1) {
34 /*
35 * Slot 1 is primary ether port, i82559
36 * we double-check against that assumption
37 */
38 if ((devices->vendor != 0x8086) ||
39 (devices->device != 0x1209)) {
40 panic("pcibios_fixup_bus: found "
41 "unexpected PCI device in slot 1.");
42 }
43 devices->irq = 2; /* irq_nr is 2 for INT0 */
44 } else if (PCI_SLOT(devices->devfn) == 2) {
45 /*
46 * Slot 2 is secondary ether port, i21143
47 * we double-check against that assumption
48 */
49 if ((devices->vendor != 0x1011) ||
50 (devices->device != 0x19)) {
51 panic("galileo_pcibios_fixup_bus: "
52 "found unexpected PCI device in slot 2.");
53 }
54 devices->irq = 3; /* irq_nr is 3 for INT1 */
55 } else if (PCI_SLOT(devices->devfn) == 4) {
56 /* PMC Slot 1 */
57 devices->irq = 8; /* irq_nr is 8 for INT6 */
58 } else if (PCI_SLOT(devices->devfn) == 5) {
59 /* PMC Slot 1 */
60 devices->irq = 9; /* irq_nr is 9 for INT7 */
61 } else {
62 /* We don't have assign interrupts for other devices. */
63 devices->irq = 0xff;
64 }
65
66 /* Assign an interrupt number for the device */
67 bus->ops->write_byte(devices, PCI_INTERRUPT_LINE,
68 devices->irq);
69
70 /* enable master */
71 bus->ops->read_word(devices, PCI_COMMAND, &cmd);
72 cmd |= PCI_COMMAND_MASTER;
73 bus->ops->write_word(devices, PCI_COMMAND, cmd);
74 }
75}
diff --git a/arch/mips/pci/fixup-rbtx4927.c b/arch/mips/pci/fixup-rbtx4927.c
index 3cdbecb8e714..7450c335b387 100644
--- a/arch/mips/pci/fixup-rbtx4927.c
+++ b/arch/mips/pci/fixup-rbtx4927.c
@@ -79,7 +79,7 @@ static unsigned char backplane_pci_irq[4][4] = {
79 TX4927_IRQ_IOC_PCIC} 79 TX4927_IRQ_IOC_PCIC}
80}; 80};
81 81
82int pci_get_irq(struct pci_dev *dev, int pin) 82static int pci_get_irq(const struct pci_dev *dev, int pin)
83{ 83{
84 unsigned char irq = pin; 84 unsigned char irq = pin;
85 85
diff --git a/arch/mips/pci/fixup-tx4938.c b/arch/mips/pci/fixup-tx4938.c
index 2485f47dfe6f..f2ba06ee0c10 100644
--- a/arch/mips/pci/fixup-tx4938.c
+++ b/arch/mips/pci/fixup-tx4938.c
@@ -18,7 +18,7 @@
18 18
19extern struct pci_controller tx4938_pci_controller[]; 19extern struct pci_controller tx4938_pci_controller[];
20 20
21int pci_get_irq(struct pci_dev *dev, int pin) 21static int pci_get_irq(const struct pci_dev *dev, int pin)
22{ 22{
23 int irq = pin; 23 int irq = pin;
24 u8 slot = PCI_SLOT(dev->devfn); 24 u8 slot = PCI_SLOT(dev->devfn);
diff --git a/arch/mips/pci/ops-ddb5477.c b/arch/mips/pci/ops-ddb5477.c
deleted file mode 100644
index 8e57d4c5d90f..000000000000
--- a/arch/mips/pci/ops-ddb5477.c
+++ /dev/null
@@ -1,278 +0,0 @@
1/***********************************************************************
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
4 *
5 * arch/mips/ddb5xxx/ddb5477/pci_ops.c
6 * Define the pci_ops for DB5477.
7 *
8 * Much of the code is derived from the original DDB5074 port by
9 * Geert Uytterhoeven <geert@sonycom.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 ***********************************************************************
16 */
17
18/*
19 * DDB5477 has two PCI channels, external PCI and IOPIC (internal)
20 * Therefore we provide two sets of pci_ops.
21 */
22#include <linux/pci.h>
23#include <linux/kernel.h>
24#include <linux/types.h>
25
26#include <asm/addrspace.h>
27#include <asm/debug.h>
28
29#include <asm/ddb5xxx/ddb5xxx.h>
30
31/*
32 * config_swap structure records what set of pdar/pmr are used
33 * to access pci config space. It also provides a place hold the
34 * original values for future restoring.
35 */
36struct pci_config_swap {
37 u32 pdar;
38 u32 pmr;
39 u32 config_base;
40 u32 config_size;
41 u32 pdar_backup;
42 u32 pmr_backup;
43};
44
45/*
46 * On DDB5477, we have two sets of swap registers, for ext PCI and IOPCI.
47 */
48struct pci_config_swap ext_pci_swap = {
49 DDB_PCIW0,
50 DDB_PCIINIT00,
51 DDB_PCI0_CONFIG_BASE,
52 DDB_PCI0_CONFIG_SIZE
53};
54struct pci_config_swap io_pci_swap = {
55 DDB_IOPCIW0,
56 DDB_PCIINIT01,
57 DDB_PCI1_CONFIG_BASE,
58 DDB_PCI1_CONFIG_SIZE
59};
60
61
62/*
63 * access config space
64 */
65static inline u32 ddb_access_config_base(struct pci_config_swap *swap, u32 bus, /* 0 means top level bus */
66 u32 slot_num)
67{
68 u32 pci_addr = 0;
69 u32 pciinit_offset = 0;
70 u32 virt_addr;
71 u32 option;
72
73 /* minimum pdar (window) size is 2MB */
74 db_assert(swap->config_size >= (2 << 20));
75
76 db_assert(slot_num < (1 << 5));
77 db_assert(bus < (1 << 8));
78
79 /* backup registers */
80 swap->pdar_backup = ddb_in32(swap->pdar);
81 swap->pmr_backup = ddb_in32(swap->pmr);
82
83 /* set the pdar (pci window) register */
84 ddb_set_pdar(swap->pdar, swap->config_base, swap->config_size, 32, /* 32 bit wide */
85 0, /* not on local memory bus */
86 0); /* not visible from PCI bus (N/A) */
87
88 /*
89 * calcuate the absolute pci config addr;
90 * according to the spec, we start scanning from adr:11 (0x800)
91 */
92 if (bus == 0) {
93 /* type 0 config */
94 pci_addr = 0x800 << slot_num;
95 } else {
96 /* type 1 config */
97 pci_addr = (bus << 16) | (slot_num << 11);
98 }
99
100 /*
101 * if pci_addr is less than pci config window size, we set
102 * pciinit_offset to 0 and adjust the virt_address.
103 * Otherwise we will try to adjust pciinit_offset.
104 */
105 if (pci_addr < swap->config_size) {
106 virt_addr = KSEG1ADDR(swap->config_base + pci_addr);
107 pciinit_offset = 0;
108 } else {
109 db_assert((pci_addr & (swap->config_size - 1)) == 0);
110 virt_addr = KSEG1ADDR(swap->config_base);
111 pciinit_offset = pci_addr;
112 }
113
114 /* set the pmr register */
115 option = DDB_PCI_ACCESS_32;
116 if (bus != 0)
117 option |= DDB_PCI_CFGTYPE1;
118 ddb_set_pmr(swap->pmr, DDB_PCICMD_CFG, pciinit_offset, option);
119
120 return virt_addr;
121}
122
123static inline void ddb_close_config_base(struct pci_config_swap *swap)
124{
125 ddb_out32(swap->pdar, swap->pdar_backup);
126 ddb_out32(swap->pmr, swap->pmr_backup);
127}
128
129static int read_config_dword(struct pci_config_swap *swap,
130 struct pci_bus *bus, u32 devfn, u32 where,
131 u32 * val)
132{
133 u32 bus_num, slot_num, func_num;
134 u32 base;
135
136 db_assert((where & 3) == 0);
137 db_assert(where < (1 << 8));
138
139 /* check if the bus is top-level */
140 if (bus->parent != NULL) {
141 bus_num = bus->number;
142 db_assert(bus_num != 0);
143 } else {
144 bus_num = 0;
145 }
146
147 slot_num = PCI_SLOT(devfn);
148 func_num = PCI_FUNC(devfn);
149 base = ddb_access_config_base(swap, bus_num, slot_num);
150 *val = *(volatile u32 *) (base + (func_num << 8) + where);
151 ddb_close_config_base(swap);
152 return PCIBIOS_SUCCESSFUL;
153}
154
155static int read_config_word(struct pci_config_swap *swap,
156 struct pci_bus *bus, u32 devfn, u32 where,
157 u16 * val)
158{
159 int status;
160 u32 result;
161
162 db_assert((where & 1) == 0);
163
164 status = read_config_dword(swap, bus, devfn, where & ~3, &result);
165 if (where & 2)
166 result >>= 16;
167 *val = result & 0xffff;
168 return status;
169}
170
171static int read_config_byte(struct pci_config_swap *swap,
172 struct pci_bus *bus, u32 devfn, u32 where,
173 u8 * val)
174{
175 int status;
176 u32 result;
177
178 status = read_config_dword(swap, bus, devfn, where & ~3, &result);
179 if (where & 1)
180 result >>= 8;
181 if (where & 2)
182 result >>= 16;
183 *val = result & 0xff;
184
185 return status;
186}
187
188static int write_config_dword(struct pci_config_swap *swap,
189 struct pci_bus *bus, u32 devfn, u32 where,
190 u32 val)
191{
192 u32 bus_num, slot_num, func_num;
193 u32 base;
194
195 db_assert((where & 3) == 0);
196 db_assert(where < (1 << 8));
197
198 /* check if the bus is top-level */
199 if (bus->parent != NULL) {
200 bus_num = bus->number;
201 db_assert(bus_num != 0);
202 } else {
203 bus_num = 0;
204 }
205
206 slot_num = PCI_SLOT(devfn);
207 func_num = PCI_FUNC(devfn);
208 base = ddb_access_config_base(swap, bus_num, slot_num);
209 *(volatile u32 *) (base + (func_num << 8) + where) = val;
210 ddb_close_config_base(swap);
211 return PCIBIOS_SUCCESSFUL;
212}
213
214static int write_config_word(struct pci_config_swap *swap,
215 struct pci_bus *bus, u32 devfn, u32 where, u16 val)
216{
217 int status, shift = 0;
218 u32 result;
219
220 db_assert((where & 1) == 0);
221
222 status = read_config_dword(swap, bus, devfn, where & ~3, &result);
223 if (status != PCIBIOS_SUCCESSFUL)
224 return status;
225
226 if (where & 2)
227 shift += 16;
228 result &= ~(0xffff << shift);
229 result |= val << shift;
230 return write_config_dword(swap, bus, devfn, where & ~3, result);
231}
232
233static int write_config_byte(struct pci_config_swap *swap,
234 struct pci_bus *bus, u32 devfn, u32 where, u8 val)
235{
236 int status, shift = 0;
237 u32 result;
238
239 status = read_config_dword(swap, bus, devfn, where & ~3, &result);
240 if (status != PCIBIOS_SUCCESSFUL)
241 return status;
242
243 if (where & 2)
244 shift += 16;
245 if (where & 1)
246 shift += 8;
247 result &= ~(0xff << shift);
248 result |= val << shift;
249 return write_config_dword(swap, bus, devfn, where & ~3, result);
250}
251
252#define MAKE_PCI_OPS(prefix, rw, pciswap, star) \
253static int prefix##_##rw##_config(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 star val) \
254{ \
255 if (size == 1) \
256 return rw##_config_byte(pciswap, bus, devfn, where, (u8 star)val); \
257 else if (size == 2) \
258 return rw##_config_word(pciswap, bus, devfn, where, (u16 star)val); \
259 /* Size must be 4 */ \
260 return rw##_config_dword(pciswap, bus, devfn, where, val); \
261}
262
263MAKE_PCI_OPS(extpci, read, &ext_pci_swap, *)
264MAKE_PCI_OPS(extpci, write, &ext_pci_swap,)
265
266MAKE_PCI_OPS(iopci, read, &io_pci_swap, *)
267MAKE_PCI_OPS(iopci, write, &io_pci_swap,)
268
269struct pci_ops ddb5477_ext_pci_ops = {
270 .read = extpci_read_config,
271 .write = extpci_write_config
272};
273
274
275struct pci_ops ddb5477_io_pci_ops = {
276 .read = iopci_read_config,
277 .write = iopci_write_config
278};
diff --git a/arch/mips/pci/ops-emma2rh.c b/arch/mips/pci/ops-emma2rh.c
index 38f181625e10..d31bfc6d4150 100644
--- a/arch/mips/pci/ops-emma2rh.c
+++ b/arch/mips/pci/ops-emma2rh.c
@@ -45,7 +45,7 @@ static int check_args(struct pci_bus *bus, u32 devfn, u32 * bus_num)
45 /* check if the bus is top-level */ 45 /* check if the bus is top-level */
46 if (bus->parent != NULL) { 46 if (bus->parent != NULL) {
47 *bus_num = bus->number; 47 *bus_num = bus->number;
48 db_assert(bus_num != 0); 48 db_assert(bus_num != NULL);
49 } else 49 } else
50 *bus_num = 0; 50 *bus_num = 0;
51 51
diff --git a/arch/mips/pci/ops-pnx8550.c b/arch/mips/pci/ops-pnx8550.c
index f556b7a8dccd..d61064652498 100644
--- a/arch/mips/pci/ops-pnx8550.c
+++ b/arch/mips/pci/ops-pnx8550.c
@@ -117,7 +117,7 @@ read_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 * val)
117 unsigned int data = 0; 117 unsigned int data = 0;
118 int err; 118 int err;
119 119
120 if (bus == 0) 120 if (bus == NULL)
121 return -1; 121 return -1;
122 122
123 err = config_access(PCI_CMD_CONFIG_READ, bus, devfn, where, ~(1 << (where & 3)), &data); 123 err = config_access(PCI_CMD_CONFIG_READ, bus, devfn, where, ~(1 << (where & 3)), &data);
@@ -145,7 +145,7 @@ read_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 * val)
145 unsigned int data = 0; 145 unsigned int data = 0;
146 int err; 146 int err;
147 147
148 if (bus == 0) 148 if (bus == NULL)
149 return -1; 149 return -1;
150 150
151 if (where & 0x01) 151 if (where & 0x01)
@@ -168,7 +168,7 @@ static int
168read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 * val) 168read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 * val)
169{ 169{
170 int err; 170 int err;
171 if (bus == 0) 171 if (bus == NULL)
172 return -1; 172 return -1;
173 173
174 if (where & 0x03) 174 if (where & 0x03)
@@ -185,7 +185,7 @@ write_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 val)
185 unsigned int data = (unsigned int)val; 185 unsigned int data = (unsigned int)val;
186 int err; 186 int err;
187 187
188 if (bus == 0) 188 if (bus == NULL)
189 return -1; 189 return -1;
190 190
191 switch (where & 0x03) { 191 switch (where & 0x03) {
@@ -213,7 +213,7 @@ write_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 val)
213 unsigned int data = (unsigned int)val; 213 unsigned int data = (unsigned int)val;
214 int err; 214 int err;
215 215
216 if (bus == 0) 216 if (bus == NULL)
217 return -1; 217 return -1;
218 218
219 if (where & 0x01) 219 if (where & 0x01)
@@ -235,7 +235,7 @@ static int
235write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val) 235write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val)
236{ 236{
237 int err; 237 int err;
238 if (bus == 0) 238 if (bus == NULL)
239 return -1; 239 return -1;
240 240
241 if (where & 0x03) 241 if (where & 0x03)
diff --git a/arch/mips/pci/pci-ddb5477.c b/arch/mips/pci/pci-ddb5477.c
deleted file mode 100644
index 7363e1877842..000000000000
--- a/arch/mips/pci/pci-ddb5477.c
+++ /dev/null
@@ -1,207 +0,0 @@
1/*
2 * PCI code for DDB5477.
3 *
4 * Copyright (C) 2001 MontaVista Software Inc.
5 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
6 *
7 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/types.h>
17#include <linux/pci.h>
18
19#include <asm/bootinfo.h>
20#include <asm/debug.h>
21
22#include <asm/ddb5xxx/ddb5xxx.h>
23
24static struct resource extpci_io_resource = {
25 .start = DDB_PCI0_IO_BASE - DDB_PCI_IO_BASE + 0x4000,
26 .end = DDB_PCI0_IO_BASE - DDB_PCI_IO_BASE + DDB_PCI0_IO_SIZE - 1,
27 .name = "ext pci IO space",
28 .flags = IORESOURCE_IO
29};
30
31static struct resource extpci_mem_resource = {
32 .start = DDB_PCI0_MEM_BASE + 0x100000,
33 .end = DDB_PCI0_MEM_BASE + DDB_PCI0_MEM_SIZE - 1,
34 .name = "ext pci memory space",
35 .flags = IORESOURCE_MEM
36};
37
38static struct resource iopci_io_resource = {
39 .start = DDB_PCI1_IO_BASE - DDB_PCI_IO_BASE,
40 .end = DDB_PCI1_IO_BASE - DDB_PCI_IO_BASE + DDB_PCI1_IO_SIZE - 1,
41 .name = "io pci IO space",
42 .flags = IORESOURCE_IO
43};
44
45static struct resource iopci_mem_resource = {
46 .start = DDB_PCI1_MEM_BASE,
47 .end = DDB_PCI1_MEM_BASE + DDB_PCI1_MEM_SIZE - 1,
48 .name = "ext pci memory space",
49 .flags = IORESOURCE_MEM
50};
51
52extern struct pci_ops ddb5477_ext_pci_ops;
53extern struct pci_ops ddb5477_io_pci_ops;
54
55struct pci_controller ddb5477_ext_controller = {
56 .pci_ops = &ddb5477_ext_pci_ops,
57 .io_resource = &extpci_io_resource,
58 .mem_resource = &extpci_mem_resource
59};
60
61struct pci_controller ddb5477_io_controller = {
62 .pci_ops = &ddb5477_io_pci_ops,
63 .io_resource = &iopci_io_resource,
64 .mem_resource = &iopci_mem_resource
65};
66
67
68
69/*
70 * we fix up irqs based on the slot number.
71 * The first entry is at AD:11.
72 * Fortunately this works because, although we have two pci buses,
73 * they all have different slot numbers (except for rockhopper slot 20
74 * which is handled below).
75 *
76 */
77
78/*
79 * irq mapping : device -> pci int # -> vrc4377 irq# ,
80 * ddb5477 board manual page 4 and vrc5477 manual page 46
81 */
82
83/*
84 * based on ddb5477 manual page 11
85 */
86#define MAX_SLOT_NUM 21
87static unsigned char irq_map[MAX_SLOT_NUM] = {
88 /* SLOT: 0, AD:11 */ 0xff,
89 /* SLOT: 1, AD:12 */ 0xff,
90 /* SLOT: 2, AD:13 */ 0xff,
91 /* SLOT: 3, AD:14 */ 0xff,
92 /* SLOT: 4, AD:15 */ VRC5477_IRQ_INTA, /* onboard tulip */
93 /* SLOT: 5, AD:16 */ VRC5477_IRQ_INTB, /* slot 1 */
94 /* SLOT: 6, AD:17 */ VRC5477_IRQ_INTC, /* slot 2 */
95 /* SLOT: 7, AD:18 */ VRC5477_IRQ_INTD, /* slot 3 */
96 /* SLOT: 8, AD:19 */ VRC5477_IRQ_INTE, /* slot 4 */
97 /* SLOT: 9, AD:20 */ 0xff,
98 /* SLOT: 10, AD:21 */ 0xff,
99 /* SLOT: 11, AD:22 */ 0xff,
100 /* SLOT: 12, AD:23 */ 0xff,
101 /* SLOT: 13, AD:24 */ 0xff,
102 /* SLOT: 14, AD:25 */ 0xff,
103 /* SLOT: 15, AD:26 */ 0xff,
104 /* SLOT: 16, AD:27 */ 0xff,
105 /* SLOT: 17, AD:28 */ 0xff,
106 /* SLOT: 18, AD:29 */ VRC5477_IRQ_IOPCI_INTC, /* vrc5477 ac97 */
107 /* SLOT: 19, AD:30 */ VRC5477_IRQ_IOPCI_INTB, /* vrc5477 usb peri */
108 /* SLOT: 20, AD:31 */ VRC5477_IRQ_IOPCI_INTA, /* vrc5477 usb host */
109};
110static unsigned char rockhopperII_irq_map[MAX_SLOT_NUM] = {
111 /* SLOT: 0, AD:11 */ 0xff,
112 /* SLOT: 1, AD:12 */ VRC5477_IRQ_INTB, /* onboard AMD PCNET */
113 /* SLOT: 2, AD:13 */ 0xff,
114 /* SLOT: 3, AD:14 */ 0xff,
115 /* SLOT: 4, AD:15 */ 14, /* M5229 ide ISA irq */
116 /* SLOT: 5, AD:16 */ VRC5477_IRQ_INTD, /* slot 3 */
117 /* SLOT: 6, AD:17 */ VRC5477_IRQ_INTA, /* slot 4 */
118 /* SLOT: 7, AD:18 */ VRC5477_IRQ_INTD, /* slot 5 */
119 /* SLOT: 8, AD:19 */ 0, /* M5457 modem nop */
120 /* SLOT: 9, AD:20 */ VRC5477_IRQ_INTA, /* slot 2 */
121 /* SLOT: 10, AD:21 */ 0xff,
122 /* SLOT: 11, AD:22 */ 0xff,
123 /* SLOT: 12, AD:23 */ 0xff,
124 /* SLOT: 13, AD:24 */ 0xff,
125 /* SLOT: 14, AD:25 */ 0xff,
126 /* SLOT: 15, AD:26 */ 0xff,
127 /* SLOT: 16, AD:27 */ 0xff,
128 /* SLOT: 17, AD:28 */ 0, /* M7101 PMU nop */
129 /* SLOT: 18, AD:29 */ VRC5477_IRQ_IOPCI_INTC, /* vrc5477 ac97 */
130 /* SLOT: 19, AD:30 */ VRC5477_IRQ_IOPCI_INTB, /* vrc5477 usb peri */
131 /* SLOT: 20, AD:31 */ VRC5477_IRQ_IOPCI_INTA, /* vrc5477 usb host */
132};
133
134int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
135{
136 int slot_num;
137 unsigned char *slot_irq_map;
138 unsigned char irq;
139
140 /*
141 * We ignore the swizzled slot and pin values. The original
142 * pci_fixup_irq() codes largely base irq number on the dev slot
143 * numbers because except for one case they are unique even
144 * though there are multiple pci buses.
145 */
146
147 if (mips_machtype == MACH_NEC_ROCKHOPPERII)
148 slot_irq_map = rockhopperII_irq_map;
149 else
150 slot_irq_map = irq_map;
151
152 slot_num = PCI_SLOT(dev->devfn);
153 irq = slot_irq_map[slot_num];
154
155 db_assert(slot_num < MAX_SLOT_NUM);
156
157 db_assert(irq != 0xff);
158
159 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
160
161 if (mips_machtype == MACH_NEC_ROCKHOPPERII) {
162 /* hack to distinquish overlapping slot 20s, one
163 * on bus 0 (ALI USB on the M1535 on the backplane),
164 * and one on bus 2 (NEC USB controller on the CPU board)
165 * Make the M1535 USB - ISA IRQ number 9.
166 */
167 if (slot_num == 20 && dev->bus->number == 0) {
168 pci_write_config_byte(dev,
169 PCI_INTERRUPT_LINE,
170 9);
171 irq = 9;
172 }
173
174 }
175
176 return irq;
177}
178
179/* Do platform specific device initialization at pci_enable_device() time */
180int pcibios_plat_dev_init(struct pci_dev *dev)
181{
182 return 0;
183}
184
185void ddb_pci_reset_bus(void)
186{
187 u32 temp;
188
189 /*
190 * I am not sure about the "official" procedure, the following
191 * steps work as far as I know:
192 * We first set PCI cold reset bit (bit 31) in PCICTRL-H.
193 * Then we clear the PCI warm reset bit (bit 30) to 0 in PCICTRL-H.
194 * The same is true for both PCI channels.
195 */
196 temp = ddb_in32(DDB_PCICTL0_H);
197 temp |= 0x80000000;
198 ddb_out32(DDB_PCICTL0_H, temp);
199 temp &= ~0xc0000000;
200 ddb_out32(DDB_PCICTL0_H, temp);
201
202 temp = ddb_in32(DDB_PCICTL1_H);
203 temp |= 0x80000000;
204 ddb_out32(DDB_PCICTL1_H, temp);
205 temp &= ~0xc0000000;
206 ddb_out32(DDB_PCICTL1_H, temp);
207}
diff --git a/arch/mips/pci/pci-ocelot.c b/arch/mips/pci/pci-ocelot.c
deleted file mode 100644
index 1421d34535ef..000000000000
--- a/arch/mips/pci/pci-ocelot.c
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Galileo Evaluation Boards PCI support.
4 *
5 * The general-purpose functions to read/write and configure the GT64120A's
6 * PCI registers (function names start with pci0 or pci1) are either direct
7 * copies of functions written by Galileo Technology, or are modifications
8 * of their functions to work with Linux 2.4 vs Linux 2.2. These functions
9 * are Copyright - Galileo Technology.
10 *
11 * Other functions are derived from other MIPS PCI implementations, or were
12 * written by RidgeRun, Inc, Copyright (C) 2000 RidgeRun, Inc.
13 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
14 *
15 * Copyright 2001 MontaVista Software Inc.
16 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
17 *
18 * This program is free software; you can redistribute it and/or modify it
19 * under the terms of the GNU General Public License as published by the
20 * Free Software Foundation; either version 2 of the License, or (at your
21 * option) any later version.
22 *
23 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
26 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 * You should have received a copy of the GNU General Public License along
35 * with this program; if not, write to the Free Software Foundation, Inc.,
36 * 675 Mass Ave, Cambridge, MA 02139, USA.
37 */
38#include <linux/init.h>
39#include <linux/types.h>
40#include <linux/pci.h>
41#include <linux/kernel.h>
42#include <linux/slab.h>
43#include <linux/cache.h>
44#include <asm/pci.h>
45#include <asm/io.h>
46#include <asm/gt64120.h>
47
48static inline unsigned int pci0ReadConfigReg(unsigned int offset)
49{
50 unsigned int DataForRegCf8;
51 unsigned int data;
52
53 DataForRegCf8 = ((PCI_SLOT(device->devfn) << 11) |
54 (PCI_FUNC(device->devfn) << 8) |
55 (offset & ~0x3)) | 0x80000000;
56 GT_WRITE(GT_PCI0_CFGADDR_OFS, DataForRegCf8);
57 GT_READ(GT_PCI0_CFGDATA_OFS, &data);
58
59 return data;
60}
61
62static inline void pci0WriteConfigReg(unsigned int offset, unsigned int data)
63{
64 unsigned int DataForRegCf8;
65
66 DataForRegCf8 = ((PCI_SLOT(device->devfn) << 11) |
67 (PCI_FUNC(device->devfn) << 8) |
68 (offset & ~0x3)) | 0x80000000;
69 GT_WRITE(GT_PCI0_CFGADDR_OFS, DataForRegCf8);
70 GT_WRITE(GT_PCI0_CFGDATA_OFS, data);
71}
72
73static struct resource ocelot_mem_resource = {
74 .start = GT_PCI_MEM_BASE,
75 .end = GT_PCI_MEM_BASE + GT_PCI_MEM_BASE - 1,
76};
77
78static struct resource ocelot_io_resource = {
79 .start = GT_PCI_IO_BASE,
80 .end = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1,
81};
82
83static struct pci_controller ocelot_pci_controller = {
84 .pci_ops = gt64xxx_pci0_ops,
85 .mem_resource = &ocelot_mem_resource,
86 .io_resource = &ocelot_io_resource,
87};
88
89static int __init ocelot_pcibios_init(void)
90{
91 u32 tmp;
92
93 GT_READ(GT_PCI0_CMD_OFS, &tmp);
94 GT_READ(GT_PCI0_BARE_OFS, &tmp);
95
96 /*
97 * You have to enable bus mastering to configure any other
98 * card on the bus.
99 */
100 tmp = pci0ReadConfigReg(PCI_COMMAND);
101 tmp |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_SERR;
102 pci0WriteConfigReg(PCI_COMMAND, tmp);
103
104 register_pci_controller(&ocelot_pci_controller);
105}
106
107arch_initcall(ocelot_pcibios_init);
diff --git a/arch/mips/philips/pnx8550/common/Makefile b/arch/mips/philips/pnx8550/common/Makefile
index b7c638166e9f..31cc1a5cec3b 100644
--- a/arch/mips/philips/pnx8550/common/Makefile
+++ b/arch/mips/philips/pnx8550/common/Makefile
@@ -25,3 +25,5 @@
25obj-y := setup.o prom.o int.o reset.o time.o proc.o platform.o 25obj-y := setup.o prom.o int.o reset.o time.o proc.o platform.o
26obj-$(CONFIG_PCI) += pci.o 26obj-$(CONFIG_PCI) += pci.o
27obj-$(CONFIG_KGDB) += gdb_hook.o 27obj-$(CONFIG_KGDB) += gdb_hook.o
28
29EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/pmc-sierra/yosemite/Makefile b/arch/mips/pmc-sierra/yosemite/Makefile
index e931e0d44229..8fd9a04e3534 100644
--- a/arch/mips/pmc-sierra/yosemite/Makefile
+++ b/arch/mips/pmc-sierra/yosemite/Makefile
@@ -2,7 +2,9 @@
2# Makefile for the PMC-Sierra Titan 2# Makefile for the PMC-Sierra Titan
3# 3#
4 4
5obj-y += irq.o i2c-yosemite.o prom.o py-console.o setup.o 5obj-y += irq.o prom.o py-console.o setup.o
6 6
7obj-$(CONFIG_KGDB) += dbg_io.o 7obj-$(CONFIG_KGDB) += dbg_io.o
8obj-$(CONFIG_SMP) += smp.o 8obj-$(CONFIG_SMP) += smp.o
9
10EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c b/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c
deleted file mode 100644
index 85b14c73c226..000000000000
--- a/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c
+++ /dev/null
@@ -1,188 +0,0 @@
1/*
2 * Copyright (C) 2003 PMC-Sierra Inc.
3 * Author: Manish Lachwani (lachwani@pmc-sierra.com)
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
11 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
13 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
14 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
15 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
16 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
17 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
19 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26/*
27 * Detailed Description:
28 *
29 * This block implements the I2C interface to the slave devices like the
30 * Atmel 24C32 EEPROM and the MAX 1619 Sensors device. The I2C Master interface
31 * can be controlled by the SCMB block. And the SCMB block kicks in only when
32 * using the Ethernet Mode of operation and __not__ the SysAD mode
33 *
34 * The SCMB controls the two modes: MDIO and the I2C. The MDIO mode is used to
35 * communicate with the Quad-PHY from Marvel. The I2C is used to communicate
36 * with the I2C slave devices. It seems that the driver does not explicitly
37 * deal with the control of SDA and SCL serial lines. So, the driver will set
38 * the slave address, drive the command and then the data. The SCMB will then
39 * control the two serial lines as required.
40 *
41 * It seems the documents are very unclear abt this. Hence, I took some time
42 * out to write the desciption to have an idea of how the I2C can actually
43 * work. Currently, this Linux driver wont be integrated into the generic Linux
44 * I2C framework. And finally, the I2C interface is also known as the 2BI
45 * interface. 2BI means 2-bit interface referring to SDA and SCL serial lines
46 * respectively.
47 *
48 * - Manish Lachwani (12/09/2003)
49 */
50
51#include "i2c-yosemite.h"
52
53/*
54 * Poll the I2C interface for the BUSY bit.
55 */
56static int titan_i2c_poll(void)
57{
58 int i = 0;
59 unsigned long val = 0;
60
61 for (i = 0; i < TITAN_I2C_MAX_POLL; i++) {
62 val = TITAN_I2C_READ(TITAN_I2C_COMMAND);
63
64 if (!(val & 0x8000))
65 return 0;
66 }
67
68 return TITAN_I2C_ERR_TIMEOUT;
69}
70
71/*
72 * Execute the I2C command
73 */
74int titan_i2c_xfer(unsigned int slave_addr, titan_i2c_command * cmd,
75 int size, unsigned int *addr)
76{
77 int loop, bytes = 0, i;
78 unsigned int *write_data, data, *read_data;
79 unsigned long reg_val, val;
80
81 write_data = cmd->data;
82 read_data = addr;
83
84 TITAN_I2C_WRITE(TITAN_I2C_SLAVE_ADDRESS, slave_addr);
85
86 if (cmd->type == TITAN_I2C_CMD_WRITE)
87 loop = cmd->write_size;
88 else
89 loop = size;
90
91 while (loop > 0) {
92 if ((cmd->type == TITAN_I2C_CMD_WRITE) ||
93 (cmd->type == TITAN_I2C_CMD_READ_WRITE)) {
94
95 reg_val = TITAN_I2C_DATA;
96 for (i = 0; i < TITAN_I2C_MAX_WORDS_PER_RW;
97 ++i, write_data += 2, reg_val += 4) {
98 if (bytes < cmd->write_size) {
99 data = write_data[0];
100 ++data;
101 }
102
103 if (bytes < cmd->write_size) {
104 data = write_data[1];
105 ++data;
106 }
107
108 TITAN_I2C_WRITE(reg_val, data);
109 }
110 }
111
112 TITAN_I2C_WRITE(TITAN_I2C_COMMAND,
113 (unsigned int) (cmd->type << 13));
114 if (titan_i2c_poll() != TITAN_I2C_ERR_OK)
115 return TITAN_I2C_ERR_TIMEOUT;
116
117 if ((cmd->type == TITAN_I2C_CMD_READ) ||
118 (cmd->type == TITAN_I2C_CMD_READ_WRITE)) {
119
120 reg_val = TITAN_I2C_DATA;
121 for (i = 0; i < TITAN_I2C_MAX_WORDS_PER_RW;
122 ++i, read_data += 2, reg_val += 4) {
123 data = TITAN_I2C_READ(reg_val);
124
125 if (bytes < size) {
126 read_data[0] = data & 0xff;
127 ++bytes;
128 }
129
130 if (bytes < size) {
131 read_data[1] =
132 ((data >> 8) & 0xff);
133 ++bytes;
134 }
135 }
136 }
137
138 loop -= (TITAN_I2C_MAX_WORDS_PER_RW * 2);
139 }
140
141 /*
142 * Read the Interrupt status and then return the appropriate error code
143 */
144
145 val = TITAN_I2C_READ(TITAN_I2C_INTERRUPTS);
146 if (val & 0x0020)
147 return TITAN_I2C_ERR_ARB_LOST;
148
149 if (val & 0x0040)
150 return TITAN_I2C_ERR_NO_RESP;
151
152 if (val & 0x0080)
153 return TITAN_I2C_ERR_DATA_COLLISION;
154
155 return TITAN_I2C_ERR_OK;
156}
157
158/*
159 * Init the I2C subsystem of the PMC-Sierra Yosemite board
160 */
161int titan_i2c_init(titan_i2c_config * config)
162{
163 unsigned int val;
164
165 /*
166 * Reset the SCMB and program into the I2C mode
167 */
168 TITAN_I2C_WRITE(TITAN_I2C_SCMB_CONTROL, 0xA000);
169 TITAN_I2C_WRITE(TITAN_I2C_SCMB_CONTROL, 0x2000);
170
171 /*
172 * Configure the filtera and clka values
173 */
174 val = TITAN_I2C_READ(TITAN_I2C_SCMB_CLOCK_A);
175 val |= ((val & ~(0xF000)) | ((config->filtera << 12) & 0xF000));
176 val |= ((val & ~(0x03FF)) | (config->clka & 0x03FF));
177 TITAN_I2C_WRITE(TITAN_I2C_SCMB_CLOCK_A, val);
178
179 /*
180 * Configure the filterb and clkb values
181 */
182 val = TITAN_I2C_READ(TITAN_I2C_SCMB_CLOCK_B);
183 val |= ((val & ~(0xF000)) | ((config->filterb << 12) & 0xF000));
184 val |= ((val & ~(0x03FF)) | (config->clkb & 0x03FF));
185 TITAN_I2C_WRITE(TITAN_I2C_SCMB_CLOCK_B, val);
186
187 return TITAN_I2C_ERR_OK;
188}
diff --git a/arch/mips/pmc-sierra/yosemite/irq.c b/arch/mips/pmc-sierra/yosemite/irq.c
index 428d1f45a287..4decc2807867 100644
--- a/arch/mips/pmc-sierra/yosemite/irq.c
+++ b/arch/mips/pmc-sierra/yosemite/irq.c
@@ -56,6 +56,9 @@
56#define HYPERTRANSPORT_INTC 0x7a /* INTC# */ 56#define HYPERTRANSPORT_INTC 0x7a /* INTC# */
57#define HYPERTRANSPORT_INTD 0x7b /* INTD# */ 57#define HYPERTRANSPORT_INTD 0x7b /* INTD# */
58 58
59extern void titan_mailbox_irq(void);
60
61#ifdef CONFIG_HYPERTRANSPORT
59/* 62/*
60 * Handle hypertransport & SMP interrupts. The interrupt lines are scarce. 63 * Handle hypertransport & SMP interrupts. The interrupt lines are scarce.
61 * For interprocessor interrupts, the best thing to do is to use the INTMSG 64 * For interprocessor interrupts, the best thing to do is to use the INTMSG
@@ -107,6 +110,7 @@ static void ll_ht_smp_irq_handler(int irq)
107 110
108 do_IRQ(irq); 111 do_IRQ(irq);
109} 112}
113#endif
110 114
111asmlinkage void plat_irq_dispatch(void) 115asmlinkage void plat_irq_dispatch(void)
112{ 116{
diff --git a/arch/mips/pmc-sierra/yosemite/prom.c b/arch/mips/pmc-sierra/yosemite/prom.c
index 1e1685e415a4..0cd78f0f5f2d 100644
--- a/arch/mips/pmc-sierra/yosemite/prom.c
+++ b/arch/mips/pmc-sierra/yosemite/prom.c
@@ -34,7 +34,7 @@ extern void prom_grab_secondary(void);
34struct callvectors *debug_vectors; 34struct callvectors *debug_vectors;
35 35
36extern unsigned long yosemite_base; 36extern unsigned long yosemite_base;
37extern unsigned long cpu_clock; 37extern unsigned long cpu_clock_freq;
38 38
39const char *get_system_type(void) 39const char *get_system_type(void)
40{ 40{
@@ -119,7 +119,7 @@ void __init prom_init(void)
119 16); 119 16);
120 120
121 if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0) 121 if (strncmp("cpuclock", *env, strlen("cpuclock")) == 0)
122 cpu_clock = 122 cpu_clock_freq =
123 simple_strtol(*env + strlen("cpuclock="), NULL, 123 simple_strtol(*env + strlen("cpuclock="), NULL,
124 10); 124 10);
125 125
diff --git a/arch/mips/pmc-sierra/yosemite/setup.c b/arch/mips/pmc-sierra/yosemite/setup.c
index f7f93ae24c34..58862c8d1d00 100644
--- a/arch/mips/pmc-sierra/yosemite/setup.c
+++ b/arch/mips/pmc-sierra/yosemite/setup.c
@@ -59,7 +59,7 @@ unsigned char titan_ge_mac_addr_base[6] = {
59 0x00, 0xe0, 0x04, 0x00, 0x00, 0x21 59 0x00, 0xe0, 0x04, 0x00, 0x00, 0x21
60}; 60};
61 61
62unsigned long cpu_clock; 62unsigned long cpu_clock_freq;
63unsigned long yosemite_base; 63unsigned long yosemite_base;
64 64
65static struct m48t37_rtc *m48t37_base; 65static struct m48t37_rtc *m48t37_base;
@@ -140,7 +140,7 @@ void __init plat_timer_setup(struct irqaction *irq)
140 140
141void yosemite_time_init(void) 141void yosemite_time_init(void)
142{ 142{
143 mips_hpt_frequency = cpu_clock / 2; 143 mips_hpt_frequency = cpu_clock_freq / 2;
144mips_hpt_frequency = 33000000 * 3 * 5; 144mips_hpt_frequency = 33000000 * 3 * 5;
145} 145}
146 146
diff --git a/arch/mips/pmc-sierra/yosemite/smp.c b/arch/mips/pmc-sierra/yosemite/smp.c
index d83c4ada14f3..1c852d6a7654 100644
--- a/arch/mips/pmc-sierra/yosemite/smp.c
+++ b/arch/mips/pmc-sierra/yosemite/smp.c
@@ -106,23 +106,28 @@ void prom_smp_finish(void)
106{ 106{
107} 107}
108 108
109asmlinkage void titan_mailbox_irq(void) 109void titan_mailbox_irq(void)
110{ 110{
111 int cpu = smp_processor_id(); 111 int cpu = smp_processor_id();
112 unsigned long status; 112 unsigned long status;
113 113
114 if (cpu == 0) { 114 switch (cpu) {
115 case 0:
115 status = OCD_READ(RM9000x2_OCD_INTP0STATUS3); 116 status = OCD_READ(RM9000x2_OCD_INTP0STATUS3);
116 OCD_WRITE(RM9000x2_OCD_INTP0CLEAR3, status); 117 OCD_WRITE(RM9000x2_OCD_INTP0CLEAR3, status);
117 }
118 118
119 if (cpu == 1) { 119 if (status & 0x2)
120 smp_call_function_interrupt();
121 break;
122
123 case 1:
120 status = OCD_READ(RM9000x2_OCD_INTP1STATUS3); 124 status = OCD_READ(RM9000x2_OCD_INTP1STATUS3);
121 OCD_WRITE(RM9000x2_OCD_INTP1CLEAR3, status); 125 OCD_WRITE(RM9000x2_OCD_INTP1CLEAR3, status);
122 }
123 126
124 if (status & 0x2) 127 if (status & 0x2)
125 smp_call_function_interrupt(); 128 smp_call_function_interrupt();
129 break;
130 }
126} 131}
127 132
128/* 133/*
diff --git a/arch/mips/qemu/Makefile b/arch/mips/qemu/Makefile
index 078cd3029c9f..cec24c117f6e 100644
--- a/arch/mips/qemu/Makefile
+++ b/arch/mips/qemu/Makefile
@@ -5,3 +5,5 @@
5obj-y = q-firmware.o q-irq.o q-mem.o q-setup.o q-reset.o 5obj-y = q-firmware.o q-irq.o q-mem.o q-setup.o q-reset.o
6 6
7obj-$(CONFIG_SMP) += q-smp.o 7obj-$(CONFIG_SMP) += q-smp.o
8
9EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/sgi-ip27/Makefile b/arch/mips/sgi-ip27/Makefile
index 7ce76e20beb9..e0a6871d56e4 100644
--- a/arch/mips/sgi-ip27/Makefile
+++ b/arch/mips/sgi-ip27/Makefile
@@ -9,3 +9,5 @@ obj-y := ip27-berr.o ip27-irq.o ip27-init.o ip27-klconfig.o ip27-klnuma.o \
9obj-$(CONFIG_EARLY_PRINTK) += ip27-console.o 9obj-$(CONFIG_EARLY_PRINTK) += ip27-console.o
10obj-$(CONFIG_KGDB) += ip27-dbgio.o 10obj-$(CONFIG_KGDB) += ip27-dbgio.o
11obj-$(CONFIG_SMP) += ip27-smp.o 11obj-$(CONFIG_SMP) += ip27-smp.o
12
13EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/sgi-ip27/ip27-klnuma.c b/arch/mips/sgi-ip27/ip27-klnuma.c
index f9f404a8ddad..f10d9839006d 100644
--- a/arch/mips/sgi-ip27/ip27-klnuma.c
+++ b/arch/mips/sgi-ip27/ip27-klnuma.c
@@ -28,8 +28,6 @@ static cpumask_t ktext_repmask;
28 */ 28 */
29void __init setup_replication_mask(void) 29void __init setup_replication_mask(void)
30{ 30{
31 cnodeid_t cnode;
32
33 /* Set only the master cnode's bit. The master cnode is always 0. */ 31 /* Set only the master cnode's bit. The master cnode is always 0. */
34 cpus_clear(ktext_repmask); 32 cpus_clear(ktext_repmask);
35 cpu_set(0, ktext_repmask); 33 cpu_set(0, ktext_repmask);
@@ -38,11 +36,15 @@ void __init setup_replication_mask(void)
38#ifndef CONFIG_MAPPED_KERNEL 36#ifndef CONFIG_MAPPED_KERNEL
39#error Kernel replication works with mapped kernel support. No calias support. 37#error Kernel replication works with mapped kernel support. No calias support.
40#endif 38#endif
41 for_each_online_node(cnode) { 39 {
42 if (cnode == 0) 40 cnodeid_t cnode;
43 continue; 41
44 /* Advertise that we have a copy of the kernel */ 42 for_each_online_node(cnode) {
45 cpu_set(cnode, ktext_repmask); 43 if (cnode == 0)
44 continue;
45 /* Advertise that we have a copy of the kernel */
46 cpu_set(cnode, ktext_repmask);
47 }
46 } 48 }
47#endif 49#endif
48 /* Set up a GDA pointer to the replication mask. */ 50 /* Set up a GDA pointer to the replication mask. */
diff --git a/arch/mips/sgi-ip27/ip27-smp.c b/arch/mips/sgi-ip27/ip27-smp.c
index 09fa7f5216f0..08e79141b47c 100644
--- a/arch/mips/sgi-ip27/ip27-smp.c
+++ b/arch/mips/sgi-ip27/ip27-smp.c
@@ -181,7 +181,7 @@ void __init prom_boot_secondary(int cpu, struct task_struct *idle)
181 0, (void *) sp, (void *) gp); 181 0, (void *) sp, (void *) gp);
182} 182}
183 183
184void prom_init_secondary(void) 184void __cpuinit prom_init_secondary(void)
185{ 185{
186 per_cpu_init(); 186 per_cpu_init();
187 local_irq_enable(); 187 local_irq_enable();
diff --git a/arch/mips/sgi-ip32/Makefile b/arch/mips/sgi-ip32/Makefile
index 60f0227425e7..31c9aa1bcb40 100644
--- a/arch/mips/sgi-ip32/Makefile
+++ b/arch/mips/sgi-ip32/Makefile
@@ -5,3 +5,5 @@
5 5
6obj-y += ip32-berr.o ip32-irq.o ip32-platform.o ip32-setup.o ip32-reset.o \ 6obj-y += ip32-berr.o ip32-irq.o ip32-platform.o ip32-setup.o ip32-reset.o \
7 crime.o ip32-memory.o 7 crime.o ip32-memory.o
8
9EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/sgi-ip32/ip32-reset.c b/arch/mips/sgi-ip32/ip32-reset.c
index db8084411538..624bbdbff2a8 100644
--- a/arch/mips/sgi-ip32/ip32-reset.c
+++ b/arch/mips/sgi-ip32/ip32-reset.c
@@ -195,7 +195,8 @@ static __init int ip32_reboot_setup(void)
195 blink_timer.function = blink_timeout; 195 blink_timer.function = blink_timeout;
196 atomic_notifier_chain_register(&panic_notifier_list, &panic_block); 196 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
197 197
198 request_irq(MACEISA_RTC_IRQ, ip32_rtc_int, 0, "rtc", NULL); 198 if (request_irq(MACEISA_RTC_IRQ, ip32_rtc_int, 0, "rtc", NULL))
199 panic("Can't allocate MACEISA RTC IRQ");
199 200
200 return 0; 201 return 0;
201} 202}
diff --git a/arch/mips/sibyte/bcm1480/Makefile b/arch/mips/sibyte/bcm1480/Makefile
index cdc4c56c3e29..f292f7df0cfb 100644
--- a/arch/mips/sibyte/bcm1480/Makefile
+++ b/arch/mips/sibyte/bcm1480/Makefile
@@ -1,3 +1,5 @@
1obj-y := setup.o irq.o time.o 1obj-y := setup.o irq.o time.o
2 2
3obj-$(CONFIG_SMP) += smp.o 3obj-$(CONFIG_SMP) += smp.o
4
5EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/sibyte/bcm1480/setup.c b/arch/mips/sibyte/bcm1480/setup.c
index 89f29233cae1..bb28f28e8042 100644
--- a/arch/mips/sibyte/bcm1480/setup.c
+++ b/arch/mips/sibyte/bcm1480/setup.c
@@ -16,6 +16,7 @@
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */ 17 */
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/module.h>
19#include <linux/reboot.h> 20#include <linux/reboot.h>
20#include <linux/string.h> 21#include <linux/string.h>
21 22
diff --git a/arch/mips/sibyte/common/Makefile b/arch/mips/sibyte/common/Makefile
index 8a06a4fb5212..f8ae30066a05 100644
--- a/arch/mips/sibyte/common/Makefile
+++ b/arch/mips/sibyte/common/Makefile
@@ -3,3 +3,4 @@ obj-y :=
3obj-$(CONFIG_SIBYTE_TBPROF) += sb_tbprof.o 3obj-$(CONFIG_SIBYTE_TBPROF) += sb_tbprof.o
4 4
5EXTRA_AFLAGS := $(CFLAGS) 5EXTRA_AFLAGS := $(CFLAGS)
6EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/sibyte/sb1250/Makefile b/arch/mips/sibyte/sb1250/Makefile
index df662c61473a..697793783a25 100644
--- a/arch/mips/sibyte/sb1250/Makefile
+++ b/arch/mips/sibyte/sb1250/Makefile
@@ -3,3 +3,5 @@ obj-y := setup.o irq.o time.o
3obj-$(CONFIG_SMP) += smp.o 3obj-$(CONFIG_SMP) += smp.o
4obj-$(CONFIG_SIBYTE_STANDALONE) += prom.o 4obj-$(CONFIG_SIBYTE_STANDALONE) += prom.o
5obj-$(CONFIG_SIBYTE_BUS_WATCHER) += bus_watcher.o 5obj-$(CONFIG_SIBYTE_BUS_WATCHER) += bus_watcher.o
6
7EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/sni/Makefile b/arch/mips/sni/Makefile
index 471418e4f446..3a99cd62c0bd 100644
--- a/arch/mips/sni/Makefile
+++ b/arch/mips/sni/Makefile
@@ -4,3 +4,5 @@
4 4
5obj-y += irq.o reset.o setup.o a20r.o rm200.o pcimt.o pcit.o time.o 5obj-y += irq.o reset.o setup.o a20r.o rm200.o pcimt.o pcit.o time.o
6obj-$(CONFIG_CPU_BIG_ENDIAN) += sniprom.o 6obj-$(CONFIG_CPU_BIG_ENDIAN) += sniprom.o
7
8EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/sni/sniprom.c b/arch/mips/sni/sniprom.c
index 00a03a6e8f58..db544a6e23f3 100644
--- a/arch/mips/sni/sniprom.c
+++ b/arch/mips/sni/sniprom.c
@@ -19,6 +19,7 @@
19#include <asm/addrspace.h> 19#include <asm/addrspace.h>
20#include <asm/sni.h> 20#include <asm/sni.h>
21#include <asm/mipsprom.h> 21#include <asm/mipsprom.h>
22#include <asm/mipsregs.h>
22#include <asm/bootinfo.h> 23#include <asm/bootinfo.h>
23 24
24/* special SNI prom calls */ 25/* special SNI prom calls */
@@ -71,7 +72,7 @@ const char *get_system_type(void)
71#define SNI_IDPROM_SIZE 0x1000 72#define SNI_IDPROM_SIZE 0x1000
72 73
73#ifdef DEBUG 74#ifdef DEBUG
74static void sni_idprom_dump(void) 75static void __init sni_idprom_dump(void)
75{ 76{
76 int i; 77 int i;
77 78
@@ -88,7 +89,7 @@ static void sni_idprom_dump(void)
88} 89}
89#endif 90#endif
90 91
91static void sni_mem_init(void ) 92static void __init sni_mem_init(void )
92{ 93{
93 int i, memsize; 94 int i, memsize;
94 struct membank { 95 struct membank {
diff --git a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c
index 3d25d010f3d5..00b0b975f349 100644
--- a/arch/mips/tx4927/common/tx4927_irq.c
+++ b/arch/mips/tx4927/common/tx4927_irq.c
@@ -43,6 +43,9 @@
43#include <asm/mipsregs.h> 43#include <asm/mipsregs.h>
44#include <asm/system.h> 44#include <asm/system.h>
45#include <asm/tx4927/tx4927.h> 45#include <asm/tx4927/tx4927.h>
46#ifdef CONFIG_TOSHIBA_RBTX4927
47#include <asm/tx4927/toshiba_rbtx4927.h>
48#endif
46 49
47/* 50/*
48 * DEBUG 51 * DEBUG
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
index 5cc30c10e746..e265fcd31b60 100644
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
@@ -262,8 +262,6 @@ u32 bit2num(u32 num)
262int toshiba_rbtx4927_irq_nested(int sw_irq) 262int toshiba_rbtx4927_irq_nested(int sw_irq)
263{ 263{
264 u32 level3; 264 u32 level3;
265 u32 level4;
266 u32 level5;
267 265
268 level3 = reg_rd08(TOSHIBA_RBTX4927_IOC_INTR_STAT) & 0x1f; 266 level3 = reg_rd08(TOSHIBA_RBTX4927_IOC_INTR_STAT) & 0x1f;
269 if (level3) { 267 if (level3) {
@@ -275,6 +273,8 @@ int toshiba_rbtx4927_irq_nested(int sw_irq)
275#ifdef CONFIG_TOSHIBA_FPCIB0 273#ifdef CONFIG_TOSHIBA_FPCIB0
276 { 274 {
277 if (tx4927_using_backplane) { 275 if (tx4927_using_backplane) {
276 u32 level4;
277 u32 level5;
278 outb(0x0A, 0x20); 278 outb(0x0A, 0x20);
279 level4 = inb(0x20) & 0xff; 279 level4 = inb(0x20) & 0xff;
280 if (level4) { 280 if (level4) {
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
index 40c7c3eeafaf..ea5a70b252a0 100644
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
@@ -159,58 +159,6 @@ int tx4927_pci66 = 0; /* 0:auto */
159char *toshiba_name = ""; 159char *toshiba_name = "";
160 160
161#ifdef CONFIG_PCI 161#ifdef CONFIG_PCI
162static void tx4927_pcierr_interrupt(int irq, void *dev_id)
163{
164#ifdef CONFIG_BLK_DEV_IDEPCI
165 /* ignore MasterAbort for ide probing... */
166 if (irq == TX4927_IRQ_IRC_PCIERR &&
167 ((tx4927_pcicptr->pcistatus >> 16) & 0xf900) ==
168 PCI_STATUS_REC_MASTER_ABORT) {
169 tx4927_pcicptr->pcistatus =
170 (tx4927_pcicptr->
171 pcistatus & 0x0000ffff) | (PCI_STATUS_REC_MASTER_ABORT
172 << 16);
173
174 return;
175 }
176#endif
177 printk("PCI error interrupt (irq 0x%x).\n", irq);
178
179 printk("pcistat:%04x, g2pstatus:%08lx, pcicstatus:%08lx\n",
180 (unsigned short) (tx4927_pcicptr->pcistatus >> 16),
181 tx4927_pcicptr->g2pstatus, tx4927_pcicptr->pcicstatus);
182 printk("ccfg:%08lx, tear:%02lx_%08lx\n",
183 (unsigned long) tx4927_ccfgptr->ccfg,
184 (unsigned long) (tx4927_ccfgptr->tear >> 32),
185 (unsigned long) tx4927_ccfgptr->tear);
186 show_regs(get_irq_regs());
187}
188
189void __init toshiba_rbtx4927_pci_irq_init(void)
190{
191 return;
192}
193
194void tx4927_reset_pci_pcic(void)
195{
196 /* Reset PCI Bus */
197 *tx4927_pcireset_ptr = 1;
198 /* Reset PCIC */
199 tx4927_ccfgptr->clkctr |= TX4927_CLKCTR_PCIRST;
200 udelay(10000);
201 /* clear PCIC reset */
202 tx4927_ccfgptr->clkctr &= ~TX4927_CLKCTR_PCIRST;
203 *tx4927_pcireset_ptr = 0;
204}
205#endif /* CONFIG_PCI */
206
207#ifdef CONFIG_PCI
208void print_pci_status(void)
209{
210 printk("PCI STATUS %lx\n", tx4927_pcicptr->pcistatus);
211 printk("PCIC STATUS %lx\n", tx4927_pcicptr->pcicstatus);
212}
213
214extern struct pci_controller tx4927_controller; 162extern struct pci_controller tx4927_controller;
215 163
216static struct pci_dev *fake_pci_dev(struct pci_controller *hose, 164static struct pci_dev *fake_pci_dev(struct pci_controller *hose,
@@ -239,10 +187,8 @@ static int early_##rw##_config_##size(struct pci_controller *hose, \
239} 187}
240 188
241EARLY_PCI_OP(read, byte, u8 *) 189EARLY_PCI_OP(read, byte, u8 *)
242EARLY_PCI_OP(read, word, u16 *)
243EARLY_PCI_OP(read, dword, u32 *) 190EARLY_PCI_OP(read, dword, u32 *)
244EARLY_PCI_OP(write, byte, u8) 191EARLY_PCI_OP(write, byte, u8)
245EARLY_PCI_OP(write, word, u16)
246EARLY_PCI_OP(write, dword, u32) 192EARLY_PCI_OP(write, dword, u32)
247 193
248static int __init tx4927_pcibios_init(void) 194static int __init tx4927_pcibios_init(void)
@@ -269,7 +215,9 @@ static int __init tx4927_pcibios_init(void)
269 u8 v08_64; 215 u8 v08_64;
270 u32 v32_b0; 216 u32 v32_b0;
271 u8 v08_e1; 217 u8 v08_e1;
218#ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
272 char *s = " sb/isa --"; 219 char *s = " sb/isa --";
220#endif
273 221
274 TOSHIBA_RBTX4927_SETUP_DPRINTK 222 TOSHIBA_RBTX4927_SETUP_DPRINTK
275 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s beg\n", 223 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s beg\n",
@@ -354,7 +302,9 @@ static int __init tx4927_pcibios_init(void)
354 u8 v08_41; 302 u8 v08_41;
355 u8 v08_43; 303 u8 v08_43;
356 u8 v08_5c; 304 u8 v08_5c;
305#ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
357 char *s = " sb/ide --"; 306 char *s = " sb/ide --";
307#endif
358 308
359 TOSHIBA_RBTX4927_SETUP_DPRINTK 309 TOSHIBA_RBTX4927_SETUP_DPRINTK
360 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s beg\n", 310 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s beg\n",
@@ -1020,7 +970,7 @@ void __init toshiba_rbtx4927_timer_setup(struct irqaction *irq)
1020 970
1021static int __init toshiba_rbtx4927_rtc_init(void) 971static int __init toshiba_rbtx4927_rtc_init(void)
1022{ 972{
1023 struct resource res = { 973 static struct resource __initdata res = {
1024 .start = 0x1c010000, 974 .start = 0x1c010000,
1025 .end = 0x1c010000 + 0x800 - 1, 975 .end = 0x1c010000 + 0x800 - 1,
1026 .flags = IORESOURCE_MEM, 976 .flags = IORESOURCE_MEM,
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/setup.c b/arch/mips/tx4938/toshiba_rbtx4938/setup.c
index 6ed39a5aea72..f9ad482749e4 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/setup.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/setup.c
@@ -657,7 +657,7 @@ void __init tx4938_board_setup(void)
657 657
658 /* clocks */ 658 /* clocks */
659 if (txx9_master_clock) { 659 if (txx9_master_clock) {
660 /* calculate gbus_clock and cpu_clock from master_clock */ 660 /* calculate gbus_clock and cpu_clock_freq from master_clock */
661 divmode = (unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_DIVMODE_MASK; 661 divmode = (unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_DIVMODE_MASK;
662 switch (divmode) { 662 switch (divmode) {
663 case TX4938_CCFG_DIVMODE_8: 663 case TX4938_CCFG_DIVMODE_8:
@@ -691,7 +691,7 @@ void __init tx4938_board_setup(void)
691 if (txx9_cpu_clock == 0) { 691 if (txx9_cpu_clock == 0) {
692 txx9_cpu_clock = 300000000; /* 300MHz */ 692 txx9_cpu_clock = 300000000; /* 300MHz */
693 } 693 }
694 /* calculate gbus_clock and master_clock from cpu_clock */ 694 /* calculate gbus_clock and master_clock from cpu_clock_freq */
695 cpuclk = txx9_cpu_clock; 695 cpuclk = txx9_cpu_clock;
696 divmode = (unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_DIVMODE_MASK; 696 divmode = (unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_DIVMODE_MASK;
697 switch (divmode) { 697 switch (divmode) {
diff --git a/arch/mips/vr41xx/common/Makefile b/arch/mips/vr41xx/common/Makefile
index d0d84ec8d63d..7d5d83b8c582 100644
--- a/arch/mips/vr41xx/common/Makefile
+++ b/arch/mips/vr41xx/common/Makefile
@@ -3,3 +3,5 @@
3# 3#
4 4
5obj-y += bcu.o cmu.o giu.o icu.o init.o irq.o pmu.o rtc.o siu.o type.o 5obj-y += bcu.o cmu.o giu.o icu.o init.o irq.o pmu.o rtc.o siu.o type.o
6
7EXTRA_CFLAGS += -Werror
diff --git a/arch/parisc/hpux/fs.c b/arch/parisc/hpux/fs.c
index f2042e6466a4..1263f00dc35d 100644
--- a/arch/parisc/hpux/fs.c
+++ b/arch/parisc/hpux/fs.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/fs.h>
26#include <linux/sched.h> 27#include <linux/sched.h>
27#include <linux/file.h> 28#include <linux/file.h>
28#include <linux/slab.h> 29#include <linux/slab.h>
diff --git a/arch/parisc/kernel/init_task.c b/arch/parisc/kernel/init_task.c
index 8384bf9cecd2..446f98d3fd7b 100644
--- a/arch/parisc/kernel/init_task.c
+++ b/arch/parisc/kernel/init_task.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/fs.h>
26#include <linux/module.h> 27#include <linux/module.h>
27#include <linux/sched.h> 28#include <linux/sched.h>
28#include <linux/init.h> 29#include <linux/init.h>
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index 355664812b83..b80e02a4d81d 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -38,6 +38,7 @@
38#include <linux/errno.h> 38#include <linux/errno.h>
39#include <linux/kernel.h> 39#include <linux/kernel.h>
40#include <linux/mm.h> 40#include <linux/mm.h>
41#include <linux/fs.h>
41#include <linux/module.h> 42#include <linux/module.h>
42#include <linux/personality.h> 43#include <linux/personality.h>
43#include <linux/ptrace.h> 44#include <linux/ptrace.h>
diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index 04c7e1d36cea..d7bc7bb42c94 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -28,6 +28,7 @@
28#include <linux/smp.h> 28#include <linux/smp.h>
29#include <linux/kernel_stat.h> 29#include <linux/kernel_stat.h>
30#include <linux/mm.h> 30#include <linux/mm.h>
31#include <linux/err.h>
31#include <linux/delay.h> 32#include <linux/delay.h>
32#include <linux/bitops.h> 33#include <linux/bitops.h>
33 34
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 853c282da22e..00099efe0e9f 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -411,11 +411,6 @@ config PPC_INDIRECT_PCI
411 default y if 40x || 44x 411 default y if 40x || 44x
412 default n 412 default n
413 413
414config PPC_INDIRECT_PCI_BE
415 bool
416 depends PPC_INDIRECT_PCI
417 default n
418
419config EISA 414config EISA
420 bool 415 bool
421 416
@@ -425,6 +420,10 @@ config SBUS
425config FSL_SOC 420config FSL_SOC
426 bool 421 bool
427 422
423config FSL_PCI
424 bool
425 select PPC_INDIRECT_PCI
426
428# Yes MCA RS/6000s exist but Linux-PPC does not currently support any 427# Yes MCA RS/6000s exist but Linux-PPC does not currently support any
429config MCA 428config MCA
430 bool 429 bool
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index 346cd3befe1e..22acece95b11 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -20,7 +20,7 @@ config DEBUG_STACK_USAGE
20 20
21config DEBUG_PAGEALLOC 21config DEBUG_PAGEALLOC
22 bool "Debug page memory allocations" 22 bool "Debug page memory allocations"
23 depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND 23 depends on DEBUG_KERNEL && !HIBERNATION
24 help 24 help
25 Unmap pages from the kernel linear mapping after free_pages(). 25 Unmap pages from the kernel linear mapping after free_pages().
26 This results in a large slowdown, but helps to find certain types 26 This results in a large slowdown, but helps to find certain types
@@ -134,7 +134,7 @@ config BDI_SWITCH
134 134
135config BOOTX_TEXT 135config BOOTX_TEXT
136 bool "Support for early boot text console (BootX or OpenFirmware only)" 136 bool "Support for early boot text console (BootX or OpenFirmware only)"
137 depends PPC_OF 137 depends PPC_OF && PPC_MULTIPLATFORM
138 help 138 help
139 Say Y here to see progress messages from the boot firmware in text 139 Say Y here to see progress messages from the boot firmware in text
140 mode. Requires either BootX or Open Firmware. 140 mode. Requires either BootX or Open Firmware.
diff --git a/arch/powerpc/boot/dts/kuroboxHD.dts b/arch/powerpc/boot/dts/kuroboxHD.dts
index a983680c3263..122537419d9f 100644
--- a/arch/powerpc/boot/dts/kuroboxHD.dts
+++ b/arch/powerpc/boot/dts/kuroboxHD.dts
@@ -33,12 +33,10 @@ build with: "dtc -f -I dts -O dtb -o kuroboxHD.dtb -V 16 kuroboxHD.dts"
33 PowerPC,603e { /* Really 8241 */ 33 PowerPC,603e { /* Really 8241 */
34 device_type = "cpu"; 34 device_type = "cpu";
35 reg = <0>; 35 reg = <0>;
36 clock-frequency = <bebc200>; /* Fixed by bootwrapper */ 36 clock-frequency = <bebc200>; /* Fixed by bootloader */
37 timebase-frequency = <1743000>; /* Fixed by bootwrapper */ 37 timebase-frequency = <1743000>; /* Fixed by bootloader */
38 bus-frequency = <0>; /* From bootloader */ 38 bus-frequency = <0>; /* Fixed by bootloader */
39 /* Following required by dtc but not used */ 39 /* Following required by dtc but not used */
40 i-cache-line-size = <0>;
41 d-cache-line-size = <0>;
42 i-cache-size = <4000>; 40 i-cache-size = <4000>;
43 d-cache-size = <4000>; 41 d-cache-size = <4000>;
44 }; 42 };
@@ -64,11 +62,19 @@ build with: "dtc -f -I dts -O dtb -o kuroboxHD.dtb -V 16 kuroboxHD.dts"
64 fef00000 fef00000 00100000>; /* pci iack */ 62 fef00000 fef00000 00100000>; /* pci iack */
65 63
66 i2c@80003000 { 64 i2c@80003000 {
65 #address-cells = <1>;
66 #size-cells = <0>;
67 device_type = "i2c"; 67 device_type = "i2c";
68 compatible = "fsl-i2c"; 68 compatible = "fsl-i2c";
69 reg = <80003000 1000>; 69 reg = <80003000 1000>;
70 interrupts = <5 2>; 70 interrupts = <5 2>;
71 interrupt-parent = <&mpic>; 71 interrupt-parent = <&mpic>;
72
73 rtc@32 {
74 device_type = "rtc";
75 compatible = "ricoh,rs5c372b";
76 reg = <32>;
77 };
72 }; 78 };
73 79
74 serial@80004500 { 80 serial@80004500 {
@@ -91,7 +97,7 @@ build with: "dtc -f -I dts -O dtb -o kuroboxHD.dtb -V 16 kuroboxHD.dts"
91 interrupt-parent = <&mpic>; 97 interrupt-parent = <&mpic>;
92 }; 98 };
93 99
94 mpic: pic@80040000 { 100 mpic: interrupt-controller@80040000 {
95 #interrupt-cells = <2>; 101 #interrupt-cells = <2>;
96 #address-cells = <0>; 102 #address-cells = <0>;
97 device_type = "open-pic"; 103 device_type = "open-pic";
diff --git a/arch/powerpc/boot/dts/kuroboxHG.dts b/arch/powerpc/boot/dts/kuroboxHG.dts
index 5cf42dc022df..579aa8b967d9 100644
--- a/arch/powerpc/boot/dts/kuroboxHG.dts
+++ b/arch/powerpc/boot/dts/kuroboxHG.dts
@@ -33,12 +33,10 @@ build with: "dtc -f -I dts -O dtb -o kuroboxHG.dtb -V 16 kuroboxHG.dts"
33 PowerPC,603e { /* Really 8241 */ 33 PowerPC,603e { /* Really 8241 */
34 device_type = "cpu"; 34 device_type = "cpu";
35 reg = <0>; 35 reg = <0>;
36 clock-frequency = <fdad680>; /* Fixed by bootwrapper */ 36 clock-frequency = <fdad680>; /* Fixed by bootloader */
37 timebase-frequency = <1F04000>; /* Fixed by bootwrapper */ 37 timebase-frequency = <1F04000>; /* Fixed by bootloader */
38 bus-frequency = <0>; /* From bootloader */ 38 bus-frequency = <0>; /* Fixed by bootloader */
39 /* Following required by dtc but not used */ 39 /* Following required by dtc but not used */
40 i-cache-line-size = <0>;
41 d-cache-line-size = <0>;
42 i-cache-size = <4000>; 40 i-cache-size = <4000>;
43 d-cache-size = <4000>; 41 d-cache-size = <4000>;
44 }; 42 };
@@ -64,11 +62,19 @@ build with: "dtc -f -I dts -O dtb -o kuroboxHG.dtb -V 16 kuroboxHG.dts"
64 fef00000 fef00000 00100000>; /* pci iack */ 62 fef00000 fef00000 00100000>; /* pci iack */
65 63
66 i2c@80003000 { 64 i2c@80003000 {
65 #address-cells = <1>;
66 #size-cells = <0>;
67 device_type = "i2c"; 67 device_type = "i2c";
68 compatible = "fsl-i2c"; 68 compatible = "fsl-i2c";
69 reg = <80003000 1000>; 69 reg = <80003000 1000>;
70 interrupts = <5 2>; 70 interrupts = <5 2>;
71 interrupt-parent = <&mpic>; 71 interrupt-parent = <&mpic>;
72
73 rtc@32 {
74 device_type = "rtc";
75 compatible = "ricoh,rs5c372b";
76 reg = <32>;
77 };
72 }; 78 };
73 79
74 serial@80004500 { 80 serial@80004500 {
@@ -91,8 +97,7 @@ build with: "dtc -f -I dts -O dtb -o kuroboxHG.dtb -V 16 kuroboxHG.dts"
91 interrupt-parent = <&mpic>; 97 interrupt-parent = <&mpic>;
92 }; 98 };
93 99
94 mpic: pic@80040000 { 100 mpic: interrupt-controller@80040000 {
95 interrupt-parent = <&mpic>;
96 #interrupt-cells = <2>; 101 #interrupt-cells = <2>;
97 #address-cells = <0>; 102 #address-cells = <0>;
98 device_type = "open-pic"; 103 device_type = "open-pic";
diff --git a/arch/powerpc/boot/dts/mpc7448hpc2.dts b/arch/powerpc/boot/dts/mpc7448hpc2.dts
index 0e3d314a7158..b9158eb2797e 100644
--- a/arch/powerpc/boot/dts/mpc7448hpc2.dts
+++ b/arch/powerpc/boot/dts/mpc7448hpc2.dts
@@ -45,7 +45,7 @@
45 #address-cells = <1>; 45 #address-cells = <1>;
46 #size-cells = <1>; 46 #size-cells = <1>;
47 #interrupt-cells = <2>; 47 #interrupt-cells = <2>;
48 device_type = "tsi108-bridge"; 48 device_type = "tsi-bridge";
49 ranges = <00000000 c0000000 00010000>; 49 ranges = <00000000 c0000000 00010000>;
50 reg = <c0000000 00010000>; 50 reg = <c0000000 00010000>;
51 bus-frequency = <0>; 51 bus-frequency = <0>;
diff --git a/arch/powerpc/boot/dts/mpc8313erdb.dts b/arch/powerpc/boot/dts/mpc8313erdb.dts
index a1533cc07d09..c5adbe40364e 100644
--- a/arch/powerpc/boot/dts/mpc8313erdb.dts
+++ b/arch/powerpc/boot/dts/mpc8313erdb.dts
@@ -178,7 +178,7 @@
178 #size-cells = <2>; 178 #size-cells = <2>;
179 #address-cells = <3>; 179 #address-cells = <3>;
180 reg = <8500 100>; 180 reg = <8500 100>;
181 compatible = "83xx"; 181 compatible = "fsl,mpc8349-pci";
182 device_type = "pci"; 182 device_type = "pci";
183 }; 183 };
184 184
diff --git a/arch/powerpc/boot/dts/mpc832x_mds.dts b/arch/powerpc/boot/dts/mpc832x_mds.dts
index 4fc0c4d34aa8..f158ed781ba8 100644
--- a/arch/powerpc/boot/dts/mpc832x_mds.dts
+++ b/arch/powerpc/boot/dts/mpc832x_mds.dts
@@ -154,7 +154,7 @@
154 #size-cells = <2>; 154 #size-cells = <2>;
155 #address-cells = <3>; 155 #address-cells = <3>;
156 reg = <8500 100>; 156 reg = <8500 100>;
157 compatible = "83xx"; 157 compatible = "fsl,mpc8349-pci";
158 device_type = "pci"; 158 device_type = "pci";
159 }; 159 };
160 160
diff --git a/arch/powerpc/boot/dts/mpc832x_rdb.dts b/arch/powerpc/boot/dts/mpc832x_rdb.dts
index 447c03ffabbc..7c4beff3e200 100644
--- a/arch/powerpc/boot/dts/mpc832x_rdb.dts
+++ b/arch/powerpc/boot/dts/mpc832x_rdb.dts
@@ -123,7 +123,7 @@
123 #size-cells = <2>; 123 #size-cells = <2>;
124 #address-cells = <3>; 124 #address-cells = <3>;
125 reg = <8500 100>; 125 reg = <8500 100>;
126 compatible = "83xx"; 126 compatible = "fsl,mpc8349-pci";
127 device_type = "pci"; 127 device_type = "pci";
128 }; 128 };
129 129
diff --git a/arch/powerpc/boot/dts/mpc8349emitx.dts b/arch/powerpc/boot/dts/mpc8349emitx.dts
index ae9bca575453..502f47c01797 100644
--- a/arch/powerpc/boot/dts/mpc8349emitx.dts
+++ b/arch/powerpc/boot/dts/mpc8349emitx.dts
@@ -197,7 +197,7 @@
197 #size-cells = <2>; 197 #size-cells = <2>;
198 #address-cells = <3>; 198 #address-cells = <3>;
199 reg = <8500 100>; 199 reg = <8500 100>;
200 compatible = "83xx"; 200 compatible = "fsl,mpc8349-pci";
201 device_type = "pci"; 201 device_type = "pci";
202 }; 202 };
203 203
@@ -222,7 +222,7 @@
222 #size-cells = <2>; 222 #size-cells = <2>;
223 #address-cells = <3>; 223 #address-cells = <3>;
224 reg = <8600 100>; 224 reg = <8600 100>;
225 compatible = "83xx"; 225 compatible = "fsl,mpc8349-pci";
226 device_type = "pci"; 226 device_type = "pci";
227 }; 227 };
228 228
diff --git a/arch/powerpc/boot/dts/mpc8349emitxgp.dts b/arch/powerpc/boot/dts/mpc8349emitxgp.dts
index f636528a3c72..0b8387141d88 100644
--- a/arch/powerpc/boot/dts/mpc8349emitxgp.dts
+++ b/arch/powerpc/boot/dts/mpc8349emitxgp.dts
@@ -154,7 +154,7 @@
154 #size-cells = <2>; 154 #size-cells = <2>;
155 #address-cells = <3>; 155 #address-cells = <3>;
156 reg = <8600 100>; 156 reg = <8600 100>;
157 compatible = "83xx"; 157 compatible = "fsl,mpc8349-pci";
158 device_type = "pci"; 158 device_type = "pci";
159 }; 159 };
160 160
diff --git a/arch/powerpc/boot/dts/mpc834x_mds.dts b/arch/powerpc/boot/dts/mpc834x_mds.dts
index 310e877826b4..481099756e44 100644
--- a/arch/powerpc/boot/dts/mpc834x_mds.dts
+++ b/arch/powerpc/boot/dts/mpc834x_mds.dts
@@ -241,7 +241,7 @@
241 #size-cells = <2>; 241 #size-cells = <2>;
242 #address-cells = <3>; 242 #address-cells = <3>;
243 reg = <8500 100>; 243 reg = <8500 100>;
244 compatible = "83xx"; 244 compatible = "fsl,mpc8349-pci";
245 device_type = "pci"; 245 device_type = "pci";
246 }; 246 };
247 247
@@ -301,7 +301,7 @@
301 #size-cells = <2>; 301 #size-cells = <2>;
302 #address-cells = <3>; 302 #address-cells = <3>;
303 reg = <8600 100>; 303 reg = <8600 100>;
304 compatible = "83xx"; 304 compatible = "fsl,mpc8349-pci";
305 device_type = "pci"; 305 device_type = "pci";
306 }; 306 };
307 307
diff --git a/arch/powerpc/boot/dts/mpc836x_mds.dts b/arch/powerpc/boot/dts/mpc836x_mds.dts
index 1e914f31dd92..e3f7c1282068 100644
--- a/arch/powerpc/boot/dts/mpc836x_mds.dts
+++ b/arch/powerpc/boot/dts/mpc836x_mds.dts
@@ -169,7 +169,7 @@
169 #size-cells = <2>; 169 #size-cells = <2>;
170 #address-cells = <3>; 170 #address-cells = <3>;
171 reg = <8500 100>; 171 reg = <8500 100>;
172 compatible = "83xx"; 172 compatible = "fsl,mpc8349-pci";
173 device_type = "pci"; 173 device_type = "pci";
174 }; 174 };
175 175
diff --git a/arch/powerpc/boot/dts/mpc8540ads.dts b/arch/powerpc/boot/dts/mpc8540ads.dts
index 364a969f5c2f..fc8dff9f6201 100644
--- a/arch/powerpc/boot/dts/mpc8540ads.dts
+++ b/arch/powerpc/boot/dts/mpc8540ads.dts
@@ -258,7 +258,7 @@
258 #size-cells = <2>; 258 #size-cells = <2>;
259 #address-cells = <3>; 259 #address-cells = <3>;
260 reg = <8000 1000>; 260 reg = <8000 1000>;
261 compatible = "85xx"; 261 compatible = "fsl,mpc8540-pcix", "fsl,mpc8540-pci";
262 device_type = "pci"; 262 device_type = "pci";
263 }; 263 };
264 264
diff --git a/arch/powerpc/boot/dts/mpc8541cds.dts b/arch/powerpc/boot/dts/mpc8541cds.dts
index 070206fffe88..fb0b647f8c2a 100644
--- a/arch/powerpc/boot/dts/mpc8541cds.dts
+++ b/arch/powerpc/boot/dts/mpc8541cds.dts
@@ -193,7 +193,7 @@
193 #size-cells = <2>; 193 #size-cells = <2>;
194 #address-cells = <3>; 194 #address-cells = <3>;
195 reg = <8000 1000>; 195 reg = <8000 1000>;
196 compatible = "85xx"; 196 compatible = "fsl,mpc8540-pci";
197 device_type = "pci"; 197 device_type = "pci";
198 198
199 i8259@19000 { 199 i8259@19000 {
@@ -230,7 +230,7 @@
230 #size-cells = <2>; 230 #size-cells = <2>;
231 #address-cells = <3>; 231 #address-cells = <3>;
232 reg = <9000 1000>; 232 reg = <9000 1000>;
233 compatible = "85xx"; 233 compatible = "fsl,mpc8540-pci";
234 device_type = "pci"; 234 device_type = "pci";
235 }; 235 };
236 236
diff --git a/arch/powerpc/boot/dts/mpc8544ds.dts b/arch/powerpc/boot/dts/mpc8544ds.dts
index 828592592460..4680e2010887 100644
--- a/arch/powerpc/boot/dts/mpc8544ds.dts
+++ b/arch/powerpc/boot/dts/mpc8544ds.dts
@@ -104,6 +104,7 @@
104 interrupts = <1d 2 1e 2 22 2>; 104 interrupts = <1d 2 1e 2 22 2>;
105 interrupt-parent = <&mpic>; 105 interrupt-parent = <&mpic>;
106 phy-handle = <&phy0>; 106 phy-handle = <&phy0>;
107 phy-connection-type = "rgmii-id";
107 }; 108 };
108 109
109 ethernet@26000 { 110 ethernet@26000 {
@@ -117,6 +118,7 @@
117 interrupts = <1f 2 20 2 21 2>; 118 interrupts = <1f 2 20 2 21 2>;
118 interrupt-parent = <&mpic>; 119 interrupt-parent = <&mpic>;
119 phy-handle = <&phy1>; 120 phy-handle = <&phy1>;
121 phy-connection-type = "rgmii-id";
120 }; 122 };
121 123
122 serial@4500 { 124 serial@4500 {
@@ -137,6 +139,223 @@
137 interrupt-parent = <&mpic>; 139 interrupt-parent = <&mpic>;
138 }; 140 };
139 141
142 pci@8000 {
143 compatible = "fsl,mpc8540-pci";
144 device_type = "pci";
145 interrupt-map-mask = <f800 0 0 7>;
146 interrupt-map = <
147
148 /* IDSEL 0x11 J17 Slot 1 */
149 8800 0 0 1 &mpic 2 1
150 8800 0 0 2 &mpic 3 1
151 8800 0 0 3 &mpic 4 1
152 8800 0 0 4 &mpic 1 1
153
154 /* IDSEL 0x12 J16 Slot 2 */
155
156 9000 0 0 1 &mpic 3 1
157 9000 0 0 2 &mpic 4 1
158 9000 0 0 3 &mpic 2 1
159 9000 0 0 4 &mpic 1 1>;
160
161 interrupt-parent = <&mpic>;
162 interrupts = <18 2>;
163 bus-range = <0 ff>;
164 ranges = <02000000 0 80000000 80000000 0 10000000
165 01000000 0 00000000 e2000000 0 00800000>;
166 clock-frequency = <3f940aa>;
167 #interrupt-cells = <1>;
168 #size-cells = <2>;
169 #address-cells = <3>;
170 reg = <8000 1000>;
171 };
172
173 pcie@9000 {
174 compatible = "fsl,mpc8548-pcie";
175 device_type = "pci";
176 #interrupt-cells = <1>;
177 #size-cells = <2>;
178 #address-cells = <3>;
179 reg = <9000 1000>;
180 bus-range = <0 ff>;
181 ranges = <02000000 0 90000000 90000000 0 10000000
182 01000000 0 00000000 e3000000 0 00800000>;
183 clock-frequency = <1fca055>;
184 interrupt-parent = <&mpic>;
185 interrupts = <1a 2>;
186 interrupt-map-mask = <f800 0 0 7>;
187 interrupt-map = <
188 /* IDSEL 0x0 */
189 0000 0 0 1 &mpic 4 1
190 0000 0 0 2 &mpic 5 1
191 0000 0 0 3 &mpic 6 1
192 0000 0 0 4 &mpic 7 1
193 >;
194 };
195
196 pcie@a000 {
197 compatible = "fsl,mpc8548-pcie";
198 device_type = "pci";
199 #interrupt-cells = <1>;
200 #size-cells = <2>;
201 #address-cells = <3>;
202 reg = <a000 1000>;
203 bus-range = <0 ff>;
204 ranges = <02000000 0 a0000000 a0000000 0 10000000
205 01000000 0 00000000 e2800000 0 00800000>;
206 clock-frequency = <1fca055>;
207 interrupt-parent = <&mpic>;
208 interrupts = <19 2>;
209 interrupt-map-mask = <f800 0 0 7>;
210 interrupt-map = <
211 /* IDSEL 0x0 */
212 0000 0 0 1 &mpic 0 1
213 0000 0 0 2 &mpic 1 1
214 0000 0 0 3 &mpic 2 1
215 0000 0 0 4 &mpic 3 1
216 >;
217 };
218
219 pcie@b000 {
220 compatible = "fsl,mpc8548-pcie";
221 device_type = "pci";
222 #interrupt-cells = <1>;
223 #size-cells = <2>;
224 #address-cells = <3>;
225 reg = <b000 1000>;
226 bus-range = <0 ff>;
227 ranges = <02000000 0 b0000000 b0000000 0 10000000
228 01000000 0 00000000 e3800000 0 00800000>;
229 clock-frequency = <1fca055>;
230 interrupt-parent = <&mpic>;
231 interrupts = <1b 2>;
232 interrupt-map-mask = <f800 0 0 7>;
233 interrupt-map = <
234
235 // IDSEL 0x1a
236 d000 0 0 1 &i8259 6 2
237 d000 0 0 2 &i8259 3 2
238 d000 0 0 3 &i8259 4 2
239 d000 0 0 4 &i8259 5 2
240
241 // IDSEL 0x1b
242 d800 0 0 1 &i8259 5 2
243 d800 0 0 2 &i8259 0 0
244 d800 0 0 3 &i8259 0 0
245 d800 0 0 4 &i8259 0 0
246
247 // IDSEL 0x1c USB
248 e000 0 0 1 &i8259 9 2
249 e000 0 0 2 &i8259 a 2
250 e000 0 0 3 &i8259 c 2
251 e000 0 0 4 &i8259 7 2
252
253 // IDSEL 0x1d Audio
254 e800 0 0 1 &i8259 9 2
255 e800 0 0 2 &i8259 a 2
256 e800 0 0 3 &i8259 b 2
257 e800 0 0 4 &i8259 0 0
258
259 // IDSEL 0x1e Legacy
260 f000 0 0 1 &i8259 c 2
261 f000 0 0 2 &i8259 0 0
262 f000 0 0 3 &i8259 0 0
263 f000 0 0 4 &i8259 0 0
264
265 // IDSEL 0x1f IDE/SATA
266 f800 0 0 1 &i8259 6 2
267 f800 0 0 2 &i8259 0 0
268 f800 0 0 3 &i8259 0 0
269 f800 0 0 4 &i8259 0 0
270 >;
271 uli1575@0 {
272 reg = <0 0 0 0 0>;
273 #size-cells = <2>;
274 #address-cells = <3>;
275 ranges = <02000000 0 b0000000
276 02000000 0 b0000000
277 0 10000000
278 01000000 0 00000000
279 01000000 0 00000000
280 0 00080000>;
281
282 pci_bridge@0 {
283 reg = <0 0 0 0 0>;
284 #size-cells = <2>;
285 #address-cells = <3>;
286 ranges = <02000000 0 b0000000
287 02000000 0 b0000000
288 0 20000000
289 01000000 0 00000000
290 01000000 0 00000000
291 0 00100000>;
292
293 isa@1e {
294 device_type = "isa";
295 #interrupt-cells = <2>;
296 #size-cells = <1>;
297 #address-cells = <2>;
298 reg = <f000 0 0 0 0>;
299 ranges = <1 0 01000000 0 0
300 00001000>;
301 interrupt-parent = <&i8259>;
302
303 i8259: interrupt-controller@20 {
304 reg = <1 20 2
305 1 a0 2
306 1 4d0 2>;
307 clock-frequency = <0>;
308 interrupt-controller;
309 device_type = "interrupt-controller";
310 #address-cells = <0>;
311 #interrupt-cells = <2>;
312 built-in;
313 compatible = "chrp,iic";
314 interrupts = <9 2>;
315 interrupt-parent =
316 <&mpic>;
317 };
318
319 i8042@60 {
320 #size-cells = <0>;
321 #address-cells = <1>;
322 reg = <1 60 1 1 64 1>;
323 interrupts = <1 3 c 3>;
324 interrupt-parent =
325 <&i8259>;
326
327 keyboard@0 {
328 reg = <0>;
329 compatible = "pnpPNP,303";
330 };
331
332 mouse@1 {
333 reg = <1>;
334 compatible = "pnpPNP,f03";
335 };
336 };
337
338 rtc@70 {
339 compatible =
340 "pnpPNP,b00";
341 reg = <1 70 2>;
342 };
343
344 gpio@400 {
345 reg = <1 400 80>;
346 };
347 };
348 };
349 };
350
351 };
352
353 global-utilities@e0000 { //global utilities block
354 compatible = "fsl,mpc8548-guts";
355 reg = <e0000 1000>;
356 fsl,has-rstcr;
357 };
358
140 mpic: pic@40000 { 359 mpic: pic@40000 {
141 clock-frequency = <0>; 360 clock-frequency = <0>;
142 interrupt-controller; 361 interrupt-controller;
diff --git a/arch/powerpc/boot/dts/mpc8548cds.dts b/arch/powerpc/boot/dts/mpc8548cds.dts
index 9d0b84b66cd4..d215d21fff42 100644
--- a/arch/powerpc/boot/dts/mpc8548cds.dts
+++ b/arch/powerpc/boot/dts/mpc8548cds.dts
@@ -1,5 +1,5 @@
1/* 1/*
2 * MPC8555 CDS Device Tree Source 2 * MPC8548 CDS Device Tree Source
3 * 3 *
4 * Copyright 2006 Freescale Semiconductor Inc. 4 * Copyright 2006 Freescale Semiconductor Inc.
5 * 5 *
@@ -44,8 +44,14 @@
44 #size-cells = <1>; 44 #size-cells = <1>;
45 #interrupt-cells = <2>; 45 #interrupt-cells = <2>;
46 device_type = "soc"; 46 device_type = "soc";
47 ranges = <0 e0000000 00100000>; 47 ranges = <00001000 e0001000 000ff000
48 reg = <e0000000 00100000>; // CCSRBAR 1M 48 80000000 80000000 10000000
49 e2000000 e2000000 00800000
50 90000000 90000000 10000000
51 e2800000 e2800000 00800000
52 a0000000 a0000000 20000000
53 e3000000 e3000000 01000000>;
54 reg = <e0000000 00001000>; // CCSRBAR
49 bus-frequency = <0>; 55 bus-frequency = <0>;
50 56
51 memory-controller@2000 { 57 memory-controller@2000 {
@@ -162,8 +168,8 @@
162 serial@4500 { 168 serial@4500 {
163 device_type = "serial"; 169 device_type = "serial";
164 compatible = "ns16550"; 170 compatible = "ns16550";
165 reg = <4500 100>; // reg base, size 171 reg = <4500 100>; // reg base, size
166 clock-frequency = <0>; // should we fill in in uboot? 172 clock-frequency = <0>; // should we fill in in uboot?
167 interrupts = <2a 2>; 173 interrupts = <2a 2>;
168 interrupt-parent = <&mpic>; 174 interrupt-parent = <&mpic>;
169 }; 175 };
@@ -172,7 +178,7 @@
172 device_type = "serial"; 178 device_type = "serial";
173 compatible = "ns16550"; 179 compatible = "ns16550";
174 reg = <4600 100>; // reg base, size 180 reg = <4600 100>; // reg base, size
175 clock-frequency = <0>; // should we fill in in uboot? 181 clock-frequency = <0>; // should we fill in in uboot?
176 interrupts = <2a 2>; 182 interrupts = <2a 2>;
177 interrupt-parent = <&mpic>; 183 interrupt-parent = <&mpic>;
178 }; 184 };
@@ -183,77 +189,154 @@
183 fsl,has-rstcr; 189 fsl,has-rstcr;
184 }; 190 };
185 191
186 pci1: pci@8000 { 192 pci@8000 {
187 interrupt-map-mask = <1f800 0 0 7>; 193 interrupt-map-mask = <f800 0 0 7>;
188 interrupt-map = < 194 interrupt-map = <
195 /* IDSEL 0x4 (PCIX Slot 2) */
196 02000 0 0 1 &mpic 0 1
197 02000 0 0 2 &mpic 1 1
198 02000 0 0 3 &mpic 2 1
199 02000 0 0 4 &mpic 3 1
200
201 /* IDSEL 0x5 (PCIX Slot 3) */
202 02800 0 0 1 &mpic 1 1
203 02800 0 0 2 &mpic 2 1
204 02800 0 0 3 &mpic 3 1
205 02800 0 0 4 &mpic 0 1
206
207 /* IDSEL 0x6 (PCIX Slot 4) */
208 03000 0 0 1 &mpic 2 1
209 03000 0 0 2 &mpic 3 1
210 03000 0 0 3 &mpic 0 1
211 03000 0 0 4 &mpic 1 1
212
213 /* IDSEL 0x8 (PCIX Slot 5) */
214 04000 0 0 1 &mpic 0 1
215 04000 0 0 2 &mpic 1 1
216 04000 0 0 3 &mpic 2 1
217 04000 0 0 4 &mpic 3 1
218
219 /* IDSEL 0xC (Tsi310 bridge) */
220 06000 0 0 1 &mpic 0 1
221 06000 0 0 2 &mpic 1 1
222 06000 0 0 3 &mpic 2 1
223 06000 0 0 4 &mpic 3 1
224
225 /* IDSEL 0x14 (Slot 2) */
226 0a000 0 0 1 &mpic 0 1
227 0a000 0 0 2 &mpic 1 1
228 0a000 0 0 3 &mpic 2 1
229 0a000 0 0 4 &mpic 3 1
230
231 /* IDSEL 0x15 (Slot 3) */
232 0a800 0 0 1 &mpic 1 1
233 0a800 0 0 2 &mpic 2 1
234 0a800 0 0 3 &mpic 3 1
235 0a800 0 0 4 &mpic 0 1
236
237 /* IDSEL 0x16 (Slot 4) */
238 0b000 0 0 1 &mpic 2 1
239 0b000 0 0 2 &mpic 3 1
240 0b000 0 0 3 &mpic 0 1
241 0b000 0 0 4 &mpic 1 1
242
243 /* IDSEL 0x18 (Slot 5) */
244 0c000 0 0 1 &mpic 0 1
245 0c000 0 0 2 &mpic 1 1
246 0c000 0 0 3 &mpic 2 1
247 0c000 0 0 4 &mpic 3 1
248
249 /* IDSEL 0x1C (Tsi310 bridge PCI primary) */
250 0E000 0 0 1 &mpic 0 1
251 0E000 0 0 2 &mpic 1 1
252 0E000 0 0 3 &mpic 2 1
253 0E000 0 0 4 &mpic 3 1>;
189 254
190 /* IDSEL 0x10 */
191 08000 0 0 1 &mpic 0 1
192 08000 0 0 2 &mpic 1 1
193 08000 0 0 3 &mpic 2 1
194 08000 0 0 4 &mpic 3 1
195
196 /* IDSEL 0x11 */
197 08800 0 0 1 &mpic 0 1
198 08800 0 0 2 &mpic 1 1
199 08800 0 0 3 &mpic 2 1
200 08800 0 0 4 &mpic 3 1
201
202 /* IDSEL 0x12 (Slot 1) */
203 09000 0 0 1 &mpic 0 1
204 09000 0 0 2 &mpic 1 1
205 09000 0 0 3 &mpic 2 1
206 09000 0 0 4 &mpic 3 1
207
208 /* IDSEL 0x13 (Slot 2) */
209 09800 0 0 1 &mpic 1 1
210 09800 0 0 2 &mpic 2 1
211 09800 0 0 3 &mpic 3 1
212 09800 0 0 4 &mpic 0 1
213
214 /* IDSEL 0x14 (Slot 3) */
215 0a000 0 0 1 &mpic 2 1
216 0a000 0 0 2 &mpic 3 1
217 0a000 0 0 3 &mpic 0 1
218 0a000 0 0 4 &mpic 1 1
219
220 /* IDSEL 0x15 (Slot 4) */
221 0a800 0 0 1 &mpic 3 1
222 0a800 0 0 2 &mpic 0 1
223 0a800 0 0 3 &mpic 1 1
224 0a800 0 0 4 &mpic 2 1
225
226 /* Bus 1 (Tundra Bridge) */
227 /* IDSEL 0x12 (ISA bridge) */
228 19000 0 0 1 &mpic 0 1
229 19000 0 0 2 &mpic 1 1
230 19000 0 0 3 &mpic 2 1
231 19000 0 0 4 &mpic 3 1>;
232 interrupt-parent = <&mpic>; 255 interrupt-parent = <&mpic>;
233 interrupts = <18 2>; 256 interrupts = <18 2>;
234 bus-range = <0 0>; 257 bus-range = <0 0>;
235 ranges = <02000000 0 80000000 80000000 0 20000000 258 ranges = <02000000 0 80000000 80000000 0 10000000
236 01000000 0 00000000 e2000000 0 00100000>; 259 01000000 0 00000000 e2000000 0 00800000>;
237 clock-frequency = <3f940aa>; 260 clock-frequency = <3f940aa>;
238 #interrupt-cells = <1>; 261 #interrupt-cells = <1>;
239 #size-cells = <2>; 262 #size-cells = <2>;
240 #address-cells = <3>; 263 #address-cells = <3>;
241 reg = <8000 1000>; 264 reg = <8000 1000>;
242 compatible = "85xx"; 265 compatible = "fsl,mpc8540-pcix", "fsl,mpc8540-pci";
243 device_type = "pci"; 266 device_type = "pci";
244 267
245 i8259@19000 { 268 pci_bridge@1c {
246 clock-frequency = <0>; 269 interrupt-map-mask = <f800 0 0 7>;
247 interrupt-controller; 270 interrupt-map = <
248 device_type = "interrupt-controller"; 271
249 reg = <19000 0 0 0 1>; 272 /* IDSEL 0x00 (PrPMC Site) */
250 #address-cells = <0>; 273 0000 0 0 1 &mpic 0 1
251 #interrupt-cells = <2>; 274 0000 0 0 2 &mpic 1 1
252 built-in; 275 0000 0 0 3 &mpic 2 1
253 compatible = "chrp,iic"; 276 0000 0 0 4 &mpic 3 1
254 big-endian; 277
255 interrupts = <1>; 278 /* IDSEL 0x04 (VIA chip) */
256 interrupt-parent = <&pci1>; 279 2000 0 0 1 &mpic 0 1
280 2000 0 0 2 &mpic 1 1
281 2000 0 0 3 &mpic 2 1
282 2000 0 0 4 &mpic 3 1
283
284 /* IDSEL 0x05 (8139) */
285 2800 0 0 1 &mpic 1 1
286
287 /* IDSEL 0x06 (Slot 6) */
288 3000 0 0 1 &mpic 2 1
289 3000 0 0 2 &mpic 3 1
290 3000 0 0 3 &mpic 0 1
291 3000 0 0 4 &mpic 1 1
292
293 /* IDESL 0x07 (Slot 7) */
294 3800 0 0 1 &mpic 3 1
295 3800 0 0 2 &mpic 0 1
296 3800 0 0 3 &mpic 1 1
297 3800 0 0 4 &mpic 2 1>;
298
299 reg = <e000 0 0 0 0>;
300 #interrupt-cells = <1>;
301 #size-cells = <2>;
302 #address-cells = <3>;
303 ranges = <02000000 0 80000000
304 02000000 0 80000000
305 0 20000000
306 01000000 0 00000000
307 01000000 0 00000000
308 0 00080000>;
309 clock-frequency = <1fca055>;
310
311 isa@4 {
312 device_type = "isa";
313 #interrupt-cells = <2>;
314 #size-cells = <1>;
315 #address-cells = <2>;
316 reg = <2000 0 0 0 0>;
317 ranges = <1 0 01000000 0 0 00001000>;
318 interrupt-parent = <&i8259>;
319
320 i8259: interrupt-controller@20 {
321 clock-frequency = <0>;
322 interrupt-controller;
323 device_type = "interrupt-controller";
324 reg = <1 20 2
325 1 a0 2
326 1 4d0 2>;
327 #address-cells = <0>;
328 #interrupt-cells = <2>;
329 built-in;
330 compatible = "chrp,iic";
331 interrupts = <0 1>;
332 interrupt-parent = <&mpic>;
333 };
334
335 rtc@70 {
336 compatible = "pnpPNP,b00";
337 reg = <1 70 2>;
338 };
339 };
257 }; 340 };
258 }; 341 };
259 342
@@ -263,20 +346,45 @@
263 346
264 /* IDSEL 0x15 */ 347 /* IDSEL 0x15 */
265 a800 0 0 1 &mpic b 1 348 a800 0 0 1 &mpic b 1
266 a800 0 0 2 &mpic b 1 349 a800 0 0 2 &mpic 1 1
267 a800 0 0 3 &mpic b 1 350 a800 0 0 3 &mpic 2 1
268 a800 0 0 4 &mpic b 1>; 351 a800 0 0 4 &mpic 3 1>;
352
269 interrupt-parent = <&mpic>; 353 interrupt-parent = <&mpic>;
270 interrupts = <19 2>; 354 interrupts = <19 2>;
271 bus-range = <0 0>; 355 bus-range = <0 0>;
272 ranges = <02000000 0 a0000000 a0000000 0 20000000 356 ranges = <02000000 0 90000000 90000000 0 10000000
273 01000000 0 00000000 e3000000 0 00100000>; 357 01000000 0 00000000 e2800000 0 00800000>;
274 clock-frequency = <3f940aa>; 358 clock-frequency = <3f940aa>;
275 #interrupt-cells = <1>; 359 #interrupt-cells = <1>;
276 #size-cells = <2>; 360 #size-cells = <2>;
277 #address-cells = <3>; 361 #address-cells = <3>;
278 reg = <9000 1000>; 362 reg = <9000 1000>;
279 compatible = "85xx"; 363 compatible = "fsl,mpc8540-pci";
364 device_type = "pci";
365 };
366 /* PCI Express */
367 pcie@a000 {
368 interrupt-map-mask = <f800 0 0 7>;
369 interrupt-map = <
370
371 /* IDSEL 0x0 (PEX) */
372 00000 0 0 1 &mpic 0 1
373 00000 0 0 2 &mpic 1 1
374 00000 0 0 3 &mpic 2 1
375 00000 0 0 4 &mpic 3 1>;
376
377 interrupt-parent = <&mpic>;
378 interrupts = <1a 2>;
379 bus-range = <0 ff>;
380 ranges = <02000000 0 a0000000 a0000000 0 20000000
381 01000000 0 00000000 e3000000 0 08000000>;
382 clock-frequency = <1fca055>;
383 #interrupt-cells = <1>;
384 #size-cells = <2>;
385 #address-cells = <3>;
386 reg = <a000 1000>;
387 compatible = "fsl,mpc8548-pcie";
280 device_type = "pci"; 388 device_type = "pci";
281 }; 389 };
282 390
diff --git a/arch/powerpc/boot/dts/mpc8555cds.dts b/arch/powerpc/boot/dts/mpc8555cds.dts
index 17e45d9a382a..c3c888252121 100644
--- a/arch/powerpc/boot/dts/mpc8555cds.dts
+++ b/arch/powerpc/boot/dts/mpc8555cds.dts
@@ -193,7 +193,7 @@
193 #size-cells = <2>; 193 #size-cells = <2>;
194 #address-cells = <3>; 194 #address-cells = <3>;
195 reg = <8000 1000>; 195 reg = <8000 1000>;
196 compatible = "85xx"; 196 compatible = "fsl,mpc8540-pci";
197 device_type = "pci"; 197 device_type = "pci";
198 198
199 i8259@19000 { 199 i8259@19000 {
@@ -230,7 +230,7 @@
230 #size-cells = <2>; 230 #size-cells = <2>;
231 #address-cells = <3>; 231 #address-cells = <3>;
232 reg = <9000 1000>; 232 reg = <9000 1000>;
233 compatible = "85xx"; 233 compatible = "fsl,mpc8540-pci";
234 device_type = "pci"; 234 device_type = "pci";
235 }; 235 };
236 236
diff --git a/arch/powerpc/boot/dts/mpc8560ads.dts b/arch/powerpc/boot/dts/mpc8560ads.dts
index 21ccaaa27993..16dbe848cecf 100644
--- a/arch/powerpc/boot/dts/mpc8560ads.dts
+++ b/arch/powerpc/boot/dts/mpc8560ads.dts
@@ -136,7 +136,7 @@
136 #interrupt-cells = <1>; 136 #interrupt-cells = <1>;
137 #size-cells = <2>; 137 #size-cells = <2>;
138 #address-cells = <3>; 138 #address-cells = <3>;
139 compatible = "85xx"; 139 compatible = "fsl,mpc8540-pcix", "fsl,mpc8540-pci";
140 device_type = "pci"; 140 device_type = "pci";
141 reg = <8000 1000>; 141 reg = <8000 1000>;
142 clock-frequency = <3f940aa>; 142 clock-frequency = <3f940aa>;
diff --git a/arch/powerpc/boot/dts/mpc8568mds.dts b/arch/powerpc/boot/dts/mpc8568mds.dts
index 6bb18f2807a8..b1dcfbe8c1f8 100644
--- a/arch/powerpc/boot/dts/mpc8568mds.dts
+++ b/arch/powerpc/boot/dts/mpc8568mds.dts
@@ -170,6 +170,66 @@
170 interrupt-parent = <&mpic>; 170 interrupt-parent = <&mpic>;
171 }; 171 };
172 172
173 global-utilities@e0000 { //global utilities block
174 compatible = "fsl,mpc8548-guts";
175 reg = <e0000 1000>;
176 fsl,has-rstcr;
177 };
178
179 pci@8000 {
180 interrupt-map-mask = <f800 0 0 7>;
181 interrupt-map = <
182 /* IDSEL 0x12 AD18 */
183 9000 0 0 1 &mpic 5 1
184 9000 0 0 2 &mpic 6 1
185 9000 0 0 3 &mpic 7 1
186 9000 0 0 4 &mpic 4 1
187
188 /* IDSEL 0x13 AD19 */
189 9800 0 0 1 &mpic 6 1
190 9800 0 0 2 &mpic 7 1
191 9800 0 0 3 &mpic 4 1
192 9800 0 0 4 &mpic 5 1>;
193
194 interrupt-parent = <&mpic>;
195 interrupts = <18 2>;
196 bus-range = <0 ff>;
197 ranges = <02000000 0 80000000 80000000 0 20000000
198 01000000 0 00000000 e2000000 0 00800000>;
199 clock-frequency = <3f940aa>;
200 #interrupt-cells = <1>;
201 #size-cells = <2>;
202 #address-cells = <3>;
203 reg = <8000 1000>;
204 compatible = "fsl,mpc8540-pci";
205 device_type = "pci";
206 };
207
208 /* PCI Express */
209 pcie@a000 {
210 interrupt-map-mask = <f800 0 0 7>;
211 interrupt-map = <
212
213 /* IDSEL 0x0 (PEX) */
214 00000 0 0 1 &mpic 0 1
215 00000 0 0 2 &mpic 1 1
216 00000 0 0 3 &mpic 2 1
217 00000 0 0 4 &mpic 3 1>;
218
219 interrupt-parent = <&mpic>;
220 interrupts = <1a 2>;
221 bus-range = <0 ff>;
222 ranges = <02000000 0 a0000000 a0000000 0 20000000
223 01000000 0 00000000 e3000000 0 08000000>;
224 clock-frequency = <1fca055>;
225 #interrupt-cells = <1>;
226 #size-cells = <2>;
227 #address-cells = <3>;
228 reg = <a000 1000>;
229 compatible = "fsl,mpc8548-pcie";
230 device_type = "pci";
231 };
232
173 serial@4600 { 233 serial@4600 {
174 device_type = "serial"; 234 device_type = "serial";
175 compatible = "ns16550"; 235 compatible = "ns16550";
diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn.dts b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
index 6a78a2b37c08..5d82709cfcbb 100644
--- a/arch/powerpc/boot/dts/mpc8641_hpcn.dts
+++ b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
@@ -211,8 +211,8 @@
211 interrupt-parent = <&mpic>; 211 interrupt-parent = <&mpic>;
212 }; 212 };
213 213
214 pci@8000 { 214 pcie@8000 {
215 compatible = "86xx"; 215 compatible = "fsl,mpc8641-pcie";
216 device_type = "pci"; 216 device_type = "pci";
217 #interrupt-cells = <1>; 217 #interrupt-cells = <1>;
218 #size-cells = <2>; 218 #size-cells = <2>;
@@ -399,8 +399,8 @@
399 399
400 }; 400 };
401 401
402 pci@9000 { 402 pcie@9000 {
403 compatible = "86xx"; 403 compatible = "fsl,mpc8641-pcie";
404 device_type = "pci"; 404 device_type = "pci";
405 #interrupt-cells = <1>; 405 #interrupt-cells = <1>;
406 #size-cells = <2>; 406 #size-cells = <2>;
diff --git a/arch/powerpc/boot/dts/prpmc2800.dts b/arch/powerpc/boot/dts/prpmc2800.dts
index 699d0df574d5..5300b50cdc2f 100644
--- a/arch/powerpc/boot/dts/prpmc2800.dts
+++ b/arch/powerpc/boot/dts/prpmc2800.dts
@@ -207,6 +207,12 @@
207 interrupt-parent = <&/mv64x60/pic>; 207 interrupt-parent = <&/mv64x60/pic>;
208 }; 208 };
209 209
210 wdt@b410 { /* watchdog timer */
211 compatible = "marvell,mv64x60-wdt";
212 reg = <b410 8>;
213 timeout = <a>; /* wdt timeout in seconds */
214 };
215
210 i2c@c000 { 216 i2c@c000 {
211 device_type = "i2c"; 217 device_type = "i2c";
212 compatible = "marvell,mv64x60-i2c"; 218 compatible = "marvell,mv64x60-i2c";
diff --git a/arch/powerpc/configs/lite5200_defconfig b/arch/powerpc/configs/lite5200_defconfig
index d12a981398b8..9c30ca451617 100644
--- a/arch/powerpc/configs/lite5200_defconfig
+++ b/arch/powerpc/configs/lite5200_defconfig
@@ -196,7 +196,7 @@ CONFIG_PM=y
196# CONFIG_PM_LEGACY is not set 196# CONFIG_PM_LEGACY is not set
197# CONFIG_PM_DEBUG is not set 197# CONFIG_PM_DEBUG is not set
198# CONFIG_PM_SYSFS_DEPRECATED is not set 198# CONFIG_PM_SYSFS_DEPRECATED is not set
199# CONFIG_SOFTWARE_SUSPEND is not set 199# CONFIG_HIBERNATION is not set
200CONFIG_SECCOMP=y 200CONFIG_SECCOMP=y
201# CONFIG_WANT_DEVICE_TREE is not set 201# CONFIG_WANT_DEVICE_TREE is not set
202CONFIG_ISA_DMA_API=y 202CONFIG_ISA_DMA_API=y
diff --git a/arch/powerpc/configs/mpc8544_ds_defconfig b/arch/powerpc/configs/mpc8544_ds_defconfig
index c40a25a79cbb..7995231def26 100644
--- a/arch/powerpc/configs/mpc8544_ds_defconfig
+++ b/arch/powerpc/configs/mpc8544_ds_defconfig
@@ -1,9 +1,26 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22-rc7 3# Linux kernel version: 2.6.22
4# Sun Jul 1 23:56:58 2007 4# Fri Jul 20 14:09:13 2007
5# 5#
6# CONFIG_PPC64 is not set 6# CONFIG_PPC64 is not set
7
8#
9# Processor support
10#
11# CONFIG_6xx is not set
12CONFIG_PPC_85xx=y
13# CONFIG_PPC_8xx is not set
14# CONFIG_40x is not set
15# CONFIG_44x is not set
16# CONFIG_E200 is not set
17CONFIG_85xx=y
18CONFIG_E500=y
19CONFIG_BOOKE=y
20CONFIG_FSL_BOOKE=y
21# CONFIG_PHYS_64BIT is not set
22# CONFIG_SPE is not set
23# CONFIG_PPC_MM_SLICES is not set
7CONFIG_PPC32=y 24CONFIG_PPC32=y
8CONFIG_PPC_MERGE=y 25CONFIG_PPC_MERGE=y
9CONFIG_MMU=y 26CONFIG_MMU=y
@@ -14,6 +31,7 @@ CONFIG_ARCH_HAS_ILOG2_U32=y
14CONFIG_GENERIC_HWEIGHT=y 31CONFIG_GENERIC_HWEIGHT=y
15CONFIG_GENERIC_CALIBRATE_DELAY=y 32CONFIG_GENERIC_CALIBRATE_DELAY=y
16CONFIG_GENERIC_FIND_NEXT_BIT=y 33CONFIG_GENERIC_FIND_NEXT_BIT=y
34# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
17CONFIG_PPC=y 35CONFIG_PPC=y
18CONFIG_EARLY_PRINTK=y 36CONFIG_EARLY_PRINTK=y
19CONFIG_GENERIC_NVRAM=y 37CONFIG_GENERIC_NVRAM=y
@@ -25,28 +43,8 @@ CONFIG_PPC_UDBG_16550=y
25CONFIG_AUDIT_ARCH=y 43CONFIG_AUDIT_ARCH=y
26CONFIG_GENERIC_BUG=y 44CONFIG_GENERIC_BUG=y
27CONFIG_DEFAULT_UIMAGE=y 45CONFIG_DEFAULT_UIMAGE=y
28
29#
30# Processor support
31#
32# CONFIG_CLASSIC32 is not set
33# CONFIG_PPC_82xx is not set
34# CONFIG_PPC_83xx is not set
35CONFIG_PPC_85xx=y
36# CONFIG_PPC_86xx is not set
37# CONFIG_PPC_8xx is not set
38# CONFIG_40x is not set
39# CONFIG_44x is not set
40# CONFIG_E200 is not set
41CONFIG_85xx=y
42CONFIG_E500=y
43# CONFIG_PPC_DCR_NATIVE is not set 46# CONFIG_PPC_DCR_NATIVE is not set
44# CONFIG_PPC_DCR_MMIO is not set 47# CONFIG_PPC_DCR_MMIO is not set
45CONFIG_BOOKE=y
46CONFIG_FSL_BOOKE=y
47# CONFIG_PHYS_64BIT is not set
48# CONFIG_SPE is not set
49# CONFIG_PPC_MM_SLICES is not set
50CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 48CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
51 49
52# 50#
@@ -63,13 +61,12 @@ CONFIG_LOCALVERSION=""
63CONFIG_LOCALVERSION_AUTO=y 61CONFIG_LOCALVERSION_AUTO=y
64CONFIG_SWAP=y 62CONFIG_SWAP=y
65CONFIG_SYSVIPC=y 63CONFIG_SYSVIPC=y
66CONFIG_IPC_NS=y
67CONFIG_SYSVIPC_SYSCTL=y 64CONFIG_SYSVIPC_SYSCTL=y
68CONFIG_POSIX_MQUEUE=y 65CONFIG_POSIX_MQUEUE=y
69CONFIG_BSD_PROCESS_ACCT=y 66CONFIG_BSD_PROCESS_ACCT=y
70# CONFIG_BSD_PROCESS_ACCT_V3 is not set 67# CONFIG_BSD_PROCESS_ACCT_V3 is not set
71# CONFIG_TASKSTATS is not set 68# CONFIG_TASKSTATS is not set
72# CONFIG_UTS_NS is not set 69# CONFIG_USER_NS is not set
73CONFIG_AUDIT=y 70CONFIG_AUDIT=y
74# CONFIG_AUDITSYSCALL is not set 71# CONFIG_AUDITSYSCALL is not set
75CONFIG_IKCONFIG=y 72CONFIG_IKCONFIG=y
@@ -86,7 +83,7 @@ CONFIG_SYSCTL_SYSCALL=y
86CONFIG_KALLSYMS=y 83CONFIG_KALLSYMS=y
87CONFIG_KALLSYMS_ALL=y 84CONFIG_KALLSYMS_ALL=y
88# CONFIG_KALLSYMS_EXTRA_PASS is not set 85# CONFIG_KALLSYMS_EXTRA_PASS is not set
89# CONFIG_HOTPLUG is not set 86CONFIG_HOTPLUG=y
90CONFIG_PRINTK=y 87CONFIG_PRINTK=y
91CONFIG_BUG=y 88CONFIG_BUG=y
92CONFIG_ELF_CORE=y 89CONFIG_ELF_CORE=y
@@ -105,24 +102,17 @@ CONFIG_SLAB=y
105CONFIG_RT_MUTEXES=y 102CONFIG_RT_MUTEXES=y
106# CONFIG_TINY_SHMEM is not set 103# CONFIG_TINY_SHMEM is not set
107CONFIG_BASE_SMALL=0 104CONFIG_BASE_SMALL=0
108
109#
110# Loadable module support
111#
112CONFIG_MODULES=y 105CONFIG_MODULES=y
113CONFIG_MODULE_UNLOAD=y 106CONFIG_MODULE_UNLOAD=y
114CONFIG_MODULE_FORCE_UNLOAD=y 107CONFIG_MODULE_FORCE_UNLOAD=y
115CONFIG_MODVERSIONS=y 108CONFIG_MODVERSIONS=y
116# CONFIG_MODULE_SRCVERSION_ALL is not set 109# CONFIG_MODULE_SRCVERSION_ALL is not set
117CONFIG_KMOD=y 110CONFIG_KMOD=y
118
119#
120# Block layer
121#
122CONFIG_BLOCK=y 111CONFIG_BLOCK=y
123CONFIG_LBD=y 112CONFIG_LBD=y
124# CONFIG_BLK_DEV_IO_TRACE is not set 113# CONFIG_BLK_DEV_IO_TRACE is not set
125# CONFIG_LSF is not set 114# CONFIG_LSF is not set
115# CONFIG_BLK_DEV_BSG is not set
126 116
127# 117#
128# IO Schedulers 118# IO Schedulers
@@ -153,7 +143,7 @@ CONFIG_MPC8544_DS=y
153CONFIG_MPC85xx=y 143CONFIG_MPC85xx=y
154CONFIG_MPIC=y 144CONFIG_MPIC=y
155# CONFIG_MPIC_WEIRD is not set 145# CONFIG_MPIC_WEIRD is not set
156# CONFIG_PPC_I8259 is not set 146CONFIG_PPC_I8259=y
157# CONFIG_PPC_RTAS is not set 147# CONFIG_PPC_RTAS is not set
158# CONFIG_MMIO_NVRAM is not set 148# CONFIG_MMIO_NVRAM is not set
159# CONFIG_PPC_MPC106 is not set 149# CONFIG_PPC_MPC106 is not set
@@ -191,6 +181,8 @@ CONFIG_FLAT_NODE_MEM_MAP=y
191CONFIG_SPLIT_PTLOCK_CPUS=4 181CONFIG_SPLIT_PTLOCK_CPUS=4
192# CONFIG_RESOURCES_64BIT is not set 182# CONFIG_RESOURCES_64BIT is not set
193CONFIG_ZONE_DMA_FLAG=1 183CONFIG_ZONE_DMA_FLAG=1
184CONFIG_BOUNCE=y
185CONFIG_VIRT_TO_BUS=y
194CONFIG_PROC_DEVICETREE=y 186CONFIG_PROC_DEVICETREE=y
195CONFIG_CMDLINE_BOOL=y 187CONFIG_CMDLINE_BOOL=y
196CONFIG_CMDLINE="root=/dev/sda3 rw console=ttyS0,115200" 188CONFIG_CMDLINE="root=/dev/sda3 rw console=ttyS0,115200"
@@ -205,15 +197,21 @@ CONFIG_ISA_DMA_API=y
205# 197#
206CONFIG_ZONE_DMA=y 198CONFIG_ZONE_DMA=y
207CONFIG_PPC_INDIRECT_PCI=y 199CONFIG_PPC_INDIRECT_PCI=y
208CONFIG_PPC_INDIRECT_PCI_BE=y
209CONFIG_FSL_SOC=y 200CONFIG_FSL_SOC=y
210# CONFIG_PCI is not set 201CONFIG_FSL_PCI=y
211# CONFIG_PCI_DOMAINS is not set 202CONFIG_PCI=y
212# CONFIG_ARCH_SUPPORTS_MSI is not set 203CONFIG_PCI_DOMAINS=y
204CONFIG_PCI_SYSCALL=y
205# CONFIG_PCIEPORTBUS is not set
206CONFIG_ARCH_SUPPORTS_MSI=y
207# CONFIG_PCI_MSI is not set
208# CONFIG_PCI_DEBUG is not set
213 209
214# 210#
215# PCCARD (PCMCIA/CardBus) support 211# PCCARD (PCMCIA/CardBus) support
216# 212#
213# CONFIG_PCCARD is not set
214# CONFIG_HOTPLUG_PCI is not set
217 215
218# 216#
219# Advanced setup 217# Advanced setup
@@ -254,7 +252,6 @@ CONFIG_ASK_IP_FIB_HASH=y
254CONFIG_IP_FIB_HASH=y 252CONFIG_IP_FIB_HASH=y
255CONFIG_IP_MULTIPLE_TABLES=y 253CONFIG_IP_MULTIPLE_TABLES=y
256CONFIG_IP_ROUTE_MULTIPATH=y 254CONFIG_IP_ROUTE_MULTIPATH=y
257# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
258CONFIG_IP_ROUTE_VERBOSE=y 255CONFIG_IP_ROUTE_VERBOSE=y
259CONFIG_IP_PNP=y 256CONFIG_IP_PNP=y
260CONFIG_IP_PNP_DHCP=y 257CONFIG_IP_PNP_DHCP=y
@@ -330,6 +327,7 @@ CONFIG_FIB_RULES=y
330# CONFIG_MAC80211 is not set 327# CONFIG_MAC80211 is not set
331# CONFIG_IEEE80211 is not set 328# CONFIG_IEEE80211 is not set
332# CONFIG_RFKILL is not set 329# CONFIG_RFKILL is not set
330# CONFIG_NET_9P is not set
333 331
334# 332#
335# Device Drivers 333# Device Drivers
@@ -340,45 +338,35 @@ CONFIG_FIB_RULES=y
340# 338#
341CONFIG_STANDALONE=y 339CONFIG_STANDALONE=y
342CONFIG_PREVENT_FIRMWARE_BUILD=y 340CONFIG_PREVENT_FIRMWARE_BUILD=y
341# CONFIG_FW_LOADER is not set
343# CONFIG_DEBUG_DRIVER is not set 342# CONFIG_DEBUG_DRIVER is not set
344# CONFIG_DEBUG_DEVRES is not set 343# CONFIG_DEBUG_DEVRES is not set
345# CONFIG_SYS_HYPERVISOR is not set 344# CONFIG_SYS_HYPERVISOR is not set
346
347#
348# Connector - unified userspace <-> kernelspace linker
349#
350# CONFIG_CONNECTOR is not set 345# CONFIG_CONNECTOR is not set
351# CONFIG_MTD is not set 346# CONFIG_MTD is not set
352
353#
354# Parallel port support
355#
356# CONFIG_PARPORT is not set 347# CONFIG_PARPORT is not set
357 348CONFIG_BLK_DEV=y
358#
359# Plug and Play support
360#
361# CONFIG_PNPACPI is not set
362
363#
364# Block devices
365#
366# CONFIG_BLK_DEV_FD is not set 349# CONFIG_BLK_DEV_FD is not set
350# CONFIG_BLK_CPQ_DA is not set
351# CONFIG_BLK_CPQ_CISS_DA is not set
352# CONFIG_BLK_DEV_DAC960 is not set
353# CONFIG_BLK_DEV_UMEM is not set
367# CONFIG_BLK_DEV_COW_COMMON is not set 354# CONFIG_BLK_DEV_COW_COMMON is not set
368CONFIG_BLK_DEV_LOOP=y 355CONFIG_BLK_DEV_LOOP=y
369# CONFIG_BLK_DEV_CRYPTOLOOP is not set 356# CONFIG_BLK_DEV_CRYPTOLOOP is not set
370CONFIG_BLK_DEV_NBD=y 357CONFIG_BLK_DEV_NBD=y
358# CONFIG_BLK_DEV_SX8 is not set
371CONFIG_BLK_DEV_RAM=y 359CONFIG_BLK_DEV_RAM=y
372CONFIG_BLK_DEV_RAM_COUNT=2 360CONFIG_BLK_DEV_RAM_COUNT=2
373CONFIG_BLK_DEV_RAM_SIZE=16384 361CONFIG_BLK_DEV_RAM_SIZE=16384
374CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 362CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
375# CONFIG_CDROM_PKTCDVD is not set 363# CONFIG_CDROM_PKTCDVD is not set
376# CONFIG_ATA_OVER_ETH is not set 364# CONFIG_ATA_OVER_ETH is not set
377 365CONFIG_MISC_DEVICES=y
378# 366# CONFIG_PHANTOM is not set
379# Misc devices 367# CONFIG_EEPROM_93CX6 is not set
380# 368# CONFIG_SGI_IOC4 is not set
381# CONFIG_BLINK is not set 369# CONFIG_TIFM_CORE is not set
382# CONFIG_IDE is not set 370# CONFIG_IDE is not set
383 371
384# 372#
@@ -386,6 +374,7 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
386# 374#
387# CONFIG_RAID_ATTRS is not set 375# CONFIG_RAID_ATTRS is not set
388CONFIG_SCSI=y 376CONFIG_SCSI=y
377CONFIG_SCSI_DMA=y
389# CONFIG_SCSI_TGT is not set 378# CONFIG_SCSI_TGT is not set
390# CONFIG_SCSI_NETLINK is not set 379# CONFIG_SCSI_NETLINK is not set
391CONFIG_SCSI_PROC_FS=y 380CONFIG_SCSI_PROC_FS=y
@@ -422,25 +411,120 @@ CONFIG_SCSI_WAIT_SCAN=m
422# SCSI low-level drivers 411# SCSI low-level drivers
423# 412#
424# CONFIG_ISCSI_TCP is not set 413# CONFIG_ISCSI_TCP is not set
414# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
415# CONFIG_SCSI_3W_9XXX is not set
416# CONFIG_SCSI_ACARD is not set
417# CONFIG_SCSI_AACRAID is not set
418# CONFIG_SCSI_AIC7XXX is not set
419# CONFIG_SCSI_AIC7XXX_OLD is not set
420# CONFIG_SCSI_AIC79XX is not set
421# CONFIG_SCSI_AIC94XX is not set
422# CONFIG_SCSI_DPT_I2O is not set
423# CONFIG_SCSI_ARCMSR is not set
424# CONFIG_MEGARAID_NEWGEN is not set
425# CONFIG_MEGARAID_LEGACY is not set
426# CONFIG_MEGARAID_SAS is not set
427# CONFIG_SCSI_HPTIOP is not set
428# CONFIG_SCSI_BUSLOGIC is not set
429# CONFIG_SCSI_DMX3191D is not set
430# CONFIG_SCSI_EATA is not set
431# CONFIG_SCSI_FUTURE_DOMAIN is not set
432# CONFIG_SCSI_GDTH is not set
433# CONFIG_SCSI_IPS is not set
434# CONFIG_SCSI_INITIO is not set
435# CONFIG_SCSI_INIA100 is not set
436# CONFIG_SCSI_STEX is not set
437# CONFIG_SCSI_SYM53C8XX_2 is not set
438# CONFIG_SCSI_IPR is not set
439# CONFIG_SCSI_QLOGIC_1280 is not set
440# CONFIG_SCSI_QLA_FC is not set
441# CONFIG_SCSI_QLA_ISCSI is not set
442# CONFIG_SCSI_LPFC is not set
443# CONFIG_SCSI_DC395x is not set
444# CONFIG_SCSI_DC390T is not set
445# CONFIG_SCSI_NSP32 is not set
425# CONFIG_SCSI_DEBUG is not set 446# CONFIG_SCSI_DEBUG is not set
447# CONFIG_SCSI_SRP is not set
426CONFIG_ATA=y 448CONFIG_ATA=y
427# CONFIG_ATA_NONSTANDARD is not set 449# CONFIG_ATA_NONSTANDARD is not set
450# CONFIG_SATA_AHCI is not set
451# CONFIG_SATA_SVW is not set
452# CONFIG_ATA_PIIX is not set
453# CONFIG_SATA_MV is not set
454# CONFIG_SATA_NV is not set
455# CONFIG_PDC_ADMA is not set
456# CONFIG_SATA_QSTOR is not set
457# CONFIG_SATA_PROMISE is not set
458# CONFIG_SATA_SX4 is not set
459# CONFIG_SATA_SIL is not set
460# CONFIG_SATA_SIL24 is not set
461# CONFIG_SATA_SIS is not set
462# CONFIG_SATA_ULI is not set
463# CONFIG_SATA_VIA is not set
464# CONFIG_SATA_VITESSE is not set
465# CONFIG_SATA_INIC162X is not set
466# CONFIG_PATA_ALI is not set
467# CONFIG_PATA_AMD is not set
468# CONFIG_PATA_ARTOP is not set
469# CONFIG_PATA_ATIIXP is not set
470# CONFIG_PATA_CMD640_PCI is not set
471# CONFIG_PATA_CMD64X is not set
472# CONFIG_PATA_CS5520 is not set
473# CONFIG_PATA_CS5530 is not set
474# CONFIG_PATA_CYPRESS is not set
475# CONFIG_PATA_EFAR is not set
476# CONFIG_ATA_GENERIC is not set
477# CONFIG_PATA_HPT366 is not set
478# CONFIG_PATA_HPT37X is not set
479# CONFIG_PATA_HPT3X2N is not set
480# CONFIG_PATA_HPT3X3 is not set
481# CONFIG_PATA_IT821X is not set
482# CONFIG_PATA_IT8213 is not set
483# CONFIG_PATA_JMICRON is not set
484# CONFIG_PATA_TRIFLEX is not set
485# CONFIG_PATA_MARVELL is not set
486# CONFIG_PATA_MPIIX is not set
487# CONFIG_PATA_OLDPIIX is not set
488# CONFIG_PATA_NETCELL is not set
489# CONFIG_PATA_NS87410 is not set
490# CONFIG_PATA_OPTI is not set
491# CONFIG_PATA_OPTIDMA is not set
492# CONFIG_PATA_PDC_OLD is not set
493# CONFIG_PATA_RADISYS is not set
494# CONFIG_PATA_RZ1000 is not set
495# CONFIG_PATA_SC1200 is not set
496# CONFIG_PATA_SERVERWORKS is not set
497# CONFIG_PATA_PDC2027X is not set
498# CONFIG_PATA_SIL680 is not set
499# CONFIG_PATA_SIS is not set
500# CONFIG_PATA_VIA is not set
501# CONFIG_PATA_WINBOND is not set
428# CONFIG_PATA_PLATFORM is not set 502# CONFIG_PATA_PLATFORM is not set
503# CONFIG_MD is not set
429 504
430# 505#
431# Multi-device support (RAID and LVM) 506# Fusion MPT device support
432# 507#
433# CONFIG_MD is not set 508# CONFIG_FUSION is not set
434# CONFIG_MACINTOSH_DRIVERS is not set 509# CONFIG_FUSION_SPI is not set
510# CONFIG_FUSION_FC is not set
511# CONFIG_FUSION_SAS is not set
435 512
436# 513#
437# Network device support 514# IEEE 1394 (FireWire) support
438# 515#
516# CONFIG_FIREWIRE is not set
517# CONFIG_IEEE1394 is not set
518# CONFIG_I2O is not set
519# CONFIG_MACINTOSH_DRIVERS is not set
439CONFIG_NETDEVICES=y 520CONFIG_NETDEVICES=y
521# CONFIG_NETDEVICES_MULTIQUEUE is not set
440# CONFIG_DUMMY is not set 522# CONFIG_DUMMY is not set
441# CONFIG_BONDING is not set 523# CONFIG_BONDING is not set
524# CONFIG_MACVLAN is not set
442# CONFIG_EQUALIZER is not set 525# CONFIG_EQUALIZER is not set
443# CONFIG_TUN is not set 526# CONFIG_TUN is not set
527# CONFIG_ARCNET is not set
444CONFIG_PHYLIB=y 528CONFIG_PHYLIB=y
445 529
446# 530#
@@ -454,17 +538,44 @@ CONFIG_PHYLIB=y
454CONFIG_VITESSE_PHY=y 538CONFIG_VITESSE_PHY=y
455# CONFIG_SMSC_PHY is not set 539# CONFIG_SMSC_PHY is not set
456# CONFIG_BROADCOM_PHY is not set 540# CONFIG_BROADCOM_PHY is not set
541# CONFIG_ICPLUS_PHY is not set
457# CONFIG_FIXED_PHY is not set 542# CONFIG_FIXED_PHY is not set
458
459#
460# Ethernet (10 or 100Mbit)
461#
462CONFIG_NET_ETHERNET=y 543CONFIG_NET_ETHERNET=y
463CONFIG_MII=y 544CONFIG_MII=y
545# CONFIG_HAPPYMEAL is not set
546# CONFIG_SUNGEM is not set
547# CONFIG_CASSINI is not set
548# CONFIG_NET_VENDOR_3COM is not set
549# CONFIG_NET_TULIP is not set
550# CONFIG_HP100 is not set
551# CONFIG_NET_PCI is not set
464CONFIG_NETDEV_1000=y 552CONFIG_NETDEV_1000=y
553# CONFIG_ACENIC is not set
554# CONFIG_DL2K is not set
555# CONFIG_E1000 is not set
556# CONFIG_NS83820 is not set
557# CONFIG_HAMACHI is not set
558# CONFIG_YELLOWFIN is not set
559# CONFIG_R8169 is not set
560# CONFIG_SIS190 is not set
561# CONFIG_SKGE is not set
562# CONFIG_SKY2 is not set
563# CONFIG_VIA_VELOCITY is not set
564# CONFIG_TIGON3 is not set
565# CONFIG_BNX2 is not set
465CONFIG_GIANFAR=y 566CONFIG_GIANFAR=y
466CONFIG_GFAR_NAPI=y 567CONFIG_GFAR_NAPI=y
568# CONFIG_QLA3XXX is not set
569# CONFIG_ATL1 is not set
467CONFIG_NETDEV_10000=y 570CONFIG_NETDEV_10000=y
571# CONFIG_CHELSIO_T1 is not set
572# CONFIG_CHELSIO_T3 is not set
573# CONFIG_IXGB is not set
574# CONFIG_S2IO is not set
575# CONFIG_MYRI10GE is not set
576# CONFIG_NETXEN_NIC is not set
577# CONFIG_MLX4_CORE is not set
578# CONFIG_TR is not set
468 579
469# 580#
470# Wireless LAN 581# Wireless LAN
@@ -472,21 +583,16 @@ CONFIG_NETDEV_10000=y
472# CONFIG_WLAN_PRE80211 is not set 583# CONFIG_WLAN_PRE80211 is not set
473# CONFIG_WLAN_80211 is not set 584# CONFIG_WLAN_80211 is not set
474# CONFIG_WAN is not set 585# CONFIG_WAN is not set
586# CONFIG_FDDI is not set
587# CONFIG_HIPPI is not set
475# CONFIG_PPP is not set 588# CONFIG_PPP is not set
476# CONFIG_SLIP is not set 589# CONFIG_SLIP is not set
590# CONFIG_NET_FC is not set
477# CONFIG_SHAPER is not set 591# CONFIG_SHAPER is not set
478# CONFIG_NETCONSOLE is not set 592# CONFIG_NETCONSOLE is not set
479# CONFIG_NETPOLL is not set 593# CONFIG_NETPOLL is not set
480# CONFIG_NET_POLL_CONTROLLER is not set 594# CONFIG_NET_POLL_CONTROLLER is not set
481
482#
483# ISDN subsystem
484#
485# CONFIG_ISDN is not set 595# CONFIG_ISDN is not set
486
487#
488# Telephony Support
489#
490# CONFIG_PHONE is not set 596# CONFIG_PHONE is not set
491 597
492# 598#
@@ -521,6 +627,7 @@ CONFIG_INPUT=y
521CONFIG_SERIO=y 627CONFIG_SERIO=y
522CONFIG_SERIO_I8042=y 628CONFIG_SERIO_I8042=y
523CONFIG_SERIO_SERPORT=y 629CONFIG_SERIO_SERPORT=y
630# CONFIG_SERIO_PCIPS2 is not set
524CONFIG_SERIO_LIBPS2=y 631CONFIG_SERIO_LIBPS2=y
525# CONFIG_SERIO_RAW is not set 632# CONFIG_SERIO_RAW is not set
526# CONFIG_GAMEPORT is not set 633# CONFIG_GAMEPORT is not set
@@ -539,6 +646,7 @@ CONFIG_HW_CONSOLE=y
539# 646#
540CONFIG_SERIAL_8250=y 647CONFIG_SERIAL_8250=y
541CONFIG_SERIAL_8250_CONSOLE=y 648CONFIG_SERIAL_8250_CONSOLE=y
649CONFIG_SERIAL_8250_PCI=y
542CONFIG_SERIAL_8250_NR_UARTS=4 650CONFIG_SERIAL_8250_NR_UARTS=4
543CONFIG_SERIAL_8250_RUNTIME_UARTS=4 651CONFIG_SERIAL_8250_RUNTIME_UARTS=4
544# CONFIG_SERIAL_8250_EXTENDED is not set 652# CONFIG_SERIAL_8250_EXTENDED is not set
@@ -550,14 +658,11 @@ CONFIG_SERIAL_8250_SHARE_IRQ=y
550# CONFIG_SERIAL_UARTLITE is not set 658# CONFIG_SERIAL_UARTLITE is not set
551CONFIG_SERIAL_CORE=y 659CONFIG_SERIAL_CORE=y
552CONFIG_SERIAL_CORE_CONSOLE=y 660CONFIG_SERIAL_CORE_CONSOLE=y
661# CONFIG_SERIAL_JSM is not set
553# CONFIG_SERIAL_OF_PLATFORM is not set 662# CONFIG_SERIAL_OF_PLATFORM is not set
554CONFIG_UNIX98_PTYS=y 663CONFIG_UNIX98_PTYS=y
555CONFIG_LEGACY_PTYS=y 664CONFIG_LEGACY_PTYS=y
556CONFIG_LEGACY_PTY_COUNT=256 665CONFIG_LEGACY_PTY_COUNT=256
557
558#
559# IPMI
560#
561# CONFIG_IPMI_HANDLER is not set 666# CONFIG_IPMI_HANDLER is not set
562# CONFIG_WATCHDOG is not set 667# CONFIG_WATCHDOG is not set
563# CONFIG_HW_RANDOM is not set 668# CONFIG_HW_RANDOM is not set
@@ -565,12 +670,12 @@ CONFIG_NVRAM=y
565CONFIG_GEN_RTC=y 670CONFIG_GEN_RTC=y
566CONFIG_GEN_RTC_X=y 671CONFIG_GEN_RTC_X=y
567# CONFIG_R3964 is not set 672# CONFIG_R3964 is not set
673# CONFIG_APPLICOM is not set
674# CONFIG_AGP is not set
675# CONFIG_DRM is not set
568# CONFIG_RAW_DRIVER is not set 676# CONFIG_RAW_DRIVER is not set
569
570#
571# TPM devices
572#
573# CONFIG_TCG_TPM is not set 677# CONFIG_TCG_TPM is not set
678CONFIG_DEVPORT=y
574# CONFIG_I2C is not set 679# CONFIG_I2C is not set
575 680
576# 681#
@@ -578,11 +683,8 @@ CONFIG_GEN_RTC_X=y
578# 683#
579# CONFIG_SPI is not set 684# CONFIG_SPI is not set
580# CONFIG_SPI_MASTER is not set 685# CONFIG_SPI_MASTER is not set
581
582#
583# Dallas's 1-wire bus
584#
585# CONFIG_W1 is not set 686# CONFIG_W1 is not set
687# CONFIG_POWER_SUPPLY is not set
586# CONFIG_HWMON is not set 688# CONFIG_HWMON is not set
587 689
588# 690#
@@ -655,19 +757,14 @@ CONFIG_DUMMY_CONSOLE=y
655# Sound 757# Sound
656# 758#
657# CONFIG_SOUND is not set 759# CONFIG_SOUND is not set
658 760CONFIG_HID_SUPPORT=y
659#
660# HID Devices
661#
662CONFIG_HID=y 761CONFIG_HID=y
663# CONFIG_HID_DEBUG is not set 762# CONFIG_HID_DEBUG is not set
664 763CONFIG_USB_SUPPORT=y
665# 764CONFIG_USB_ARCH_HAS_HCD=y
666# USB support 765CONFIG_USB_ARCH_HAS_OHCI=y
667# 766CONFIG_USB_ARCH_HAS_EHCI=y
668# CONFIG_USB_ARCH_HAS_HCD is not set 767# CONFIG_USB is not set
669# CONFIG_USB_ARCH_HAS_OHCI is not set
670# CONFIG_USB_ARCH_HAS_EHCI is not set
671 768
672# 769#
673# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 770# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
@@ -691,14 +788,7 @@ CONFIG_HID=y
691# 788#
692# LED Triggers 789# LED Triggers
693# 790#
694 791# CONFIG_INFINIBAND is not set
695#
696# InfiniBand support
697#
698
699#
700# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
701#
702 792
703# 793#
704# Real Time Clock 794# Real Time Clock
@@ -719,19 +809,13 @@ CONFIG_RTC_INTF_DEV=y
719# CONFIG_RTC_DRV_TEST is not set 809# CONFIG_RTC_DRV_TEST is not set
720 810
721# 811#
722# I2C RTC drivers
723#
724
725#
726# SPI RTC drivers
727#
728
729#
730# Platform RTC drivers 812# Platform RTC drivers
731# 813#
814# CONFIG_RTC_DRV_CMOS is not set
732# CONFIG_RTC_DRV_DS1553 is not set 815# CONFIG_RTC_DRV_DS1553 is not set
733# CONFIG_RTC_DRV_DS1742 is not set 816# CONFIG_RTC_DRV_DS1742 is not set
734# CONFIG_RTC_DRV_M48T86 is not set 817# CONFIG_RTC_DRV_M48T86 is not set
818# CONFIG_RTC_DRV_M48T59 is not set
735# CONFIG_RTC_DRV_V3020 is not set 819# CONFIG_RTC_DRV_V3020 is not set
736 820
737# 821#
@@ -752,6 +836,11 @@ CONFIG_RTC_INTF_DEV=y
752# 836#
753 837
754# 838#
839# Userspace I/O
840#
841# CONFIG_UIO is not set
842
843#
755# File systems 844# File systems
756# 845#
757CONFIG_EXT2_FS=y 846CONFIG_EXT2_FS=y
@@ -859,7 +948,6 @@ CONFIG_RPCSEC_GSS_KRB5=y
859# CONFIG_NCP_FS is not set 948# CONFIG_NCP_FS is not set
860# CONFIG_CODA_FS is not set 949# CONFIG_CODA_FS is not set
861# CONFIG_AFS_FS is not set 950# CONFIG_AFS_FS is not set
862# CONFIG_9P_FS is not set
863 951
864# 952#
865# Partition Types 953# Partition Types
@@ -941,6 +1029,7 @@ CONFIG_BITREVERSE=y
941# CONFIG_CRC16 is not set 1029# CONFIG_CRC16 is not set
942# CONFIG_CRC_ITU_T is not set 1030# CONFIG_CRC_ITU_T is not set
943CONFIG_CRC32=y 1031CONFIG_CRC32=y
1032# CONFIG_CRC7 is not set
944CONFIG_LIBCRC32C=m 1033CONFIG_LIBCRC32C=m
945CONFIG_ZLIB_INFLATE=y 1034CONFIG_ZLIB_INFLATE=y
946CONFIG_PLIST=y 1035CONFIG_PLIST=y
@@ -965,6 +1054,7 @@ CONFIG_ENABLE_MUST_CHECK=y
965CONFIG_DEBUG_KERNEL=y 1054CONFIG_DEBUG_KERNEL=y
966# CONFIG_DEBUG_SHIRQ is not set 1055# CONFIG_DEBUG_SHIRQ is not set
967CONFIG_DETECT_SOFTLOCKUP=y 1056CONFIG_DETECT_SOFTLOCKUP=y
1057CONFIG_SCHED_DEBUG=y
968# CONFIG_SCHEDSTATS is not set 1058# CONFIG_SCHEDSTATS is not set
969# CONFIG_TIMER_STATS is not set 1059# CONFIG_TIMER_STATS is not set
970# CONFIG_DEBUG_SLAB is not set 1060# CONFIG_DEBUG_SLAB is not set
@@ -996,10 +1086,6 @@ CONFIG_FORCED_INLINING=y
996# 1086#
997# CONFIG_KEYS is not set 1087# CONFIG_KEYS is not set
998# CONFIG_SECURITY is not set 1088# CONFIG_SECURITY is not set
999
1000#
1001# Cryptographic options
1002#
1003CONFIG_CRYPTO=y 1089CONFIG_CRYPTO=y
1004CONFIG_CRYPTO_ALGAPI=y 1090CONFIG_CRYPTO_ALGAPI=y
1005CONFIG_CRYPTO_BLKCIPHER=y 1091CONFIG_CRYPTO_BLKCIPHER=y
@@ -1038,7 +1124,4 @@ CONFIG_CRYPTO_DES=y
1038# CONFIG_CRYPTO_CRC32C is not set 1124# CONFIG_CRYPTO_CRC32C is not set
1039# CONFIG_CRYPTO_CAMELLIA is not set 1125# CONFIG_CRYPTO_CAMELLIA is not set
1040# CONFIG_CRYPTO_TEST is not set 1126# CONFIG_CRYPTO_TEST is not set
1041 1127CONFIG_CRYPTO_HW=y
1042#
1043# Hardware crypto devices
1044#
diff --git a/arch/powerpc/configs/mpc8568mds_defconfig b/arch/powerpc/configs/mpc8568mds_defconfig
index 6451d4dd28a0..417d3e6abcdf 100644
--- a/arch/powerpc/configs/mpc8568mds_defconfig
+++ b/arch/powerpc/configs/mpc8568mds_defconfig
@@ -1,9 +1,26 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22-rc7 3# Linux kernel version: 2.6.22
4# Sun Jul 1 23:56:59 2007 4# Fri Jul 20 13:55:04 2007
5# 5#
6# CONFIG_PPC64 is not set 6# CONFIG_PPC64 is not set
7
8#
9# Processor support
10#
11# CONFIG_6xx is not set
12CONFIG_PPC_85xx=y
13# CONFIG_PPC_8xx is not set
14# CONFIG_40x is not set
15# CONFIG_44x is not set
16# CONFIG_E200 is not set
17CONFIG_85xx=y
18CONFIG_E500=y
19CONFIG_BOOKE=y
20CONFIG_FSL_BOOKE=y
21# CONFIG_PHYS_64BIT is not set
22CONFIG_SPE=y
23# CONFIG_PPC_MM_SLICES is not set
7CONFIG_PPC32=y 24CONFIG_PPC32=y
8CONFIG_PPC_MERGE=y 25CONFIG_PPC_MERGE=y
9CONFIG_MMU=y 26CONFIG_MMU=y
@@ -14,6 +31,7 @@ CONFIG_ARCH_HAS_ILOG2_U32=y
14CONFIG_GENERIC_HWEIGHT=y 31CONFIG_GENERIC_HWEIGHT=y
15CONFIG_GENERIC_CALIBRATE_DELAY=y 32CONFIG_GENERIC_CALIBRATE_DELAY=y
16CONFIG_GENERIC_FIND_NEXT_BIT=y 33CONFIG_GENERIC_FIND_NEXT_BIT=y
34# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
17CONFIG_PPC=y 35CONFIG_PPC=y
18CONFIG_EARLY_PRINTK=y 36CONFIG_EARLY_PRINTK=y
19CONFIG_GENERIC_NVRAM=y 37CONFIG_GENERIC_NVRAM=y
@@ -25,28 +43,8 @@ CONFIG_PPC_UDBG_16550=y
25CONFIG_AUDIT_ARCH=y 43CONFIG_AUDIT_ARCH=y
26CONFIG_GENERIC_BUG=y 44CONFIG_GENERIC_BUG=y
27CONFIG_DEFAULT_UIMAGE=y 45CONFIG_DEFAULT_UIMAGE=y
28
29#
30# Processor support
31#
32# CONFIG_CLASSIC32 is not set
33# CONFIG_PPC_82xx is not set
34# CONFIG_PPC_83xx is not set
35CONFIG_PPC_85xx=y
36# CONFIG_PPC_86xx is not set
37# CONFIG_PPC_8xx is not set
38# CONFIG_40x is not set
39# CONFIG_44x is not set
40# CONFIG_E200 is not set
41CONFIG_85xx=y
42CONFIG_E500=y
43# CONFIG_PPC_DCR_NATIVE is not set 46# CONFIG_PPC_DCR_NATIVE is not set
44# CONFIG_PPC_DCR_MMIO is not set 47# CONFIG_PPC_DCR_MMIO is not set
45CONFIG_BOOKE=y
46CONFIG_FSL_BOOKE=y
47# CONFIG_PHYS_64BIT is not set
48CONFIG_SPE=y
49# CONFIG_PPC_MM_SLICES is not set
50CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 48CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
51 49
52# 50#
@@ -63,12 +61,11 @@ CONFIG_LOCALVERSION=""
63CONFIG_LOCALVERSION_AUTO=y 61CONFIG_LOCALVERSION_AUTO=y
64CONFIG_SWAP=y 62CONFIG_SWAP=y
65CONFIG_SYSVIPC=y 63CONFIG_SYSVIPC=y
66# CONFIG_IPC_NS is not set
67CONFIG_SYSVIPC_SYSCTL=y 64CONFIG_SYSVIPC_SYSCTL=y
68# CONFIG_POSIX_MQUEUE is not set 65# CONFIG_POSIX_MQUEUE is not set
69# CONFIG_BSD_PROCESS_ACCT is not set 66# CONFIG_BSD_PROCESS_ACCT is not set
70# CONFIG_TASKSTATS is not set 67# CONFIG_TASKSTATS is not set
71# CONFIG_UTS_NS is not set 68# CONFIG_USER_NS is not set
72# CONFIG_AUDIT is not set 69# CONFIG_AUDIT is not set
73# CONFIG_IKCONFIG is not set 70# CONFIG_IKCONFIG is not set
74CONFIG_LOG_BUF_SHIFT=14 71CONFIG_LOG_BUF_SHIFT=14
@@ -100,24 +97,17 @@ CONFIG_SLAB=y
100CONFIG_RT_MUTEXES=y 97CONFIG_RT_MUTEXES=y
101# CONFIG_TINY_SHMEM is not set 98# CONFIG_TINY_SHMEM is not set
102CONFIG_BASE_SMALL=0 99CONFIG_BASE_SMALL=0
103
104#
105# Loadable module support
106#
107CONFIG_MODULES=y 100CONFIG_MODULES=y
108CONFIG_MODULE_UNLOAD=y 101CONFIG_MODULE_UNLOAD=y
109# CONFIG_MODULE_FORCE_UNLOAD is not set 102# CONFIG_MODULE_FORCE_UNLOAD is not set
110# CONFIG_MODVERSIONS is not set 103# CONFIG_MODVERSIONS is not set
111# CONFIG_MODULE_SRCVERSION_ALL is not set 104# CONFIG_MODULE_SRCVERSION_ALL is not set
112# CONFIG_KMOD is not set 105# CONFIG_KMOD is not set
113
114#
115# Block layer
116#
117CONFIG_BLOCK=y 106CONFIG_BLOCK=y
118# CONFIG_LBD is not set 107# CONFIG_LBD is not set
119# CONFIG_BLK_DEV_IO_TRACE is not set 108# CONFIG_BLK_DEV_IO_TRACE is not set
120# CONFIG_LSF is not set 109# CONFIG_LSF is not set
110# CONFIG_BLK_DEV_BSG is not set
121 111
122# 112#
123# IO Schedulers 113# IO Schedulers
@@ -186,6 +176,8 @@ CONFIG_FLAT_NODE_MEM_MAP=y
186CONFIG_SPLIT_PTLOCK_CPUS=4 176CONFIG_SPLIT_PTLOCK_CPUS=4
187# CONFIG_RESOURCES_64BIT is not set 177# CONFIG_RESOURCES_64BIT is not set
188CONFIG_ZONE_DMA_FLAG=1 178CONFIG_ZONE_DMA_FLAG=1
179CONFIG_BOUNCE=y
180CONFIG_VIRT_TO_BUS=y
189CONFIG_PROC_DEVICETREE=y 181CONFIG_PROC_DEVICETREE=y
190# CONFIG_CMDLINE_BOOL is not set 182# CONFIG_CMDLINE_BOOL is not set
191# CONFIG_PM is not set 183# CONFIG_PM is not set
@@ -201,14 +193,20 @@ CONFIG_ZONE_DMA=y
201CONFIG_PPC_INDIRECT_PCI=y 193CONFIG_PPC_INDIRECT_PCI=y
202CONFIG_PPC_INDIRECT_PCI_BE=y 194CONFIG_PPC_INDIRECT_PCI_BE=y
203CONFIG_FSL_SOC=y 195CONFIG_FSL_SOC=y
204# CONFIG_PCI is not set 196CONFIG_FSL_PCI=y
205# CONFIG_PCI_DOMAINS is not set 197CONFIG_PCI=y
206# CONFIG_ARCH_SUPPORTS_MSI is not set 198CONFIG_PCI_DOMAINS=y
199CONFIG_PCI_SYSCALL=y
200# CONFIG_PCIEPORTBUS is not set
201CONFIG_ARCH_SUPPORTS_MSI=y
202# CONFIG_PCI_MSI is not set
203# CONFIG_PCI_DEBUG is not set
207 204
208# 205#
209# PCCARD (PCMCIA/CardBus) support 206# PCCARD (PCMCIA/CardBus) support
210# 207#
211# CONFIG_PCCARD is not set 208# CONFIG_PCCARD is not set
209# CONFIG_HOTPLUG_PCI is not set
212 210
213# 211#
214# Advanced setup 212# Advanced setup
@@ -309,6 +307,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
309# CONFIG_MAC80211 is not set 307# CONFIG_MAC80211 is not set
310# CONFIG_IEEE80211 is not set 308# CONFIG_IEEE80211 is not set
311# CONFIG_RFKILL is not set 309# CONFIG_RFKILL is not set
310# CONFIG_NET_9P is not set
312 311
313# 312#
314# Device Drivers 313# Device Drivers
@@ -323,42 +322,31 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
323# CONFIG_DEBUG_DRIVER is not set 322# CONFIG_DEBUG_DRIVER is not set
324# CONFIG_DEBUG_DEVRES is not set 323# CONFIG_DEBUG_DEVRES is not set
325# CONFIG_SYS_HYPERVISOR is not set 324# CONFIG_SYS_HYPERVISOR is not set
326
327#
328# Connector - unified userspace <-> kernelspace linker
329#
330# CONFIG_CONNECTOR is not set 325# CONFIG_CONNECTOR is not set
331# CONFIG_MTD is not set 326# CONFIG_MTD is not set
332
333#
334# Parallel port support
335#
336# CONFIG_PARPORT is not set 327# CONFIG_PARPORT is not set
337 328CONFIG_BLK_DEV=y
338#
339# Plug and Play support
340#
341# CONFIG_PNPACPI is not set
342
343#
344# Block devices
345#
346# CONFIG_BLK_DEV_FD is not set 329# CONFIG_BLK_DEV_FD is not set
330# CONFIG_BLK_CPQ_DA is not set
331# CONFIG_BLK_CPQ_CISS_DA is not set
332# CONFIG_BLK_DEV_DAC960 is not set
333# CONFIG_BLK_DEV_UMEM is not set
347# CONFIG_BLK_DEV_COW_COMMON is not set 334# CONFIG_BLK_DEV_COW_COMMON is not set
348CONFIG_BLK_DEV_LOOP=y 335CONFIG_BLK_DEV_LOOP=y
349# CONFIG_BLK_DEV_CRYPTOLOOP is not set 336# CONFIG_BLK_DEV_CRYPTOLOOP is not set
350# CONFIG_BLK_DEV_NBD is not set 337# CONFIG_BLK_DEV_NBD is not set
338# CONFIG_BLK_DEV_SX8 is not set
351CONFIG_BLK_DEV_RAM=y 339CONFIG_BLK_DEV_RAM=y
352CONFIG_BLK_DEV_RAM_COUNT=16 340CONFIG_BLK_DEV_RAM_COUNT=16
353CONFIG_BLK_DEV_RAM_SIZE=32768 341CONFIG_BLK_DEV_RAM_SIZE=32768
354CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 342CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
355# CONFIG_CDROM_PKTCDVD is not set 343# CONFIG_CDROM_PKTCDVD is not set
356# CONFIG_ATA_OVER_ETH is not set 344# CONFIG_ATA_OVER_ETH is not set
357 345CONFIG_MISC_DEVICES=y
358# 346# CONFIG_PHANTOM is not set
359# Misc devices 347# CONFIG_EEPROM_93CX6 is not set
360# 348# CONFIG_SGI_IOC4 is not set
361# CONFIG_BLINK is not set 349# CONFIG_TIFM_CORE is not set
362# CONFIG_IDE is not set 350# CONFIG_IDE is not set
363 351
364# 352#
@@ -366,6 +354,7 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
366# 354#
367# CONFIG_RAID_ATTRS is not set 355# CONFIG_RAID_ATTRS is not set
368CONFIG_SCSI=y 356CONFIG_SCSI=y
357CONFIG_SCSI_DMA=y
369# CONFIG_SCSI_TGT is not set 358# CONFIG_SCSI_TGT is not set
370# CONFIG_SCSI_NETLINK is not set 359# CONFIG_SCSI_NETLINK is not set
371CONFIG_SCSI_PROC_FS=y 360CONFIG_SCSI_PROC_FS=y
@@ -402,23 +391,65 @@ CONFIG_SCSI_WAIT_SCAN=m
402# SCSI low-level drivers 391# SCSI low-level drivers
403# 392#
404# CONFIG_ISCSI_TCP is not set 393# CONFIG_ISCSI_TCP is not set
394# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
395# CONFIG_SCSI_3W_9XXX is not set
396# CONFIG_SCSI_ACARD is not set
397# CONFIG_SCSI_AACRAID is not set
398# CONFIG_SCSI_AIC7XXX is not set
399# CONFIG_SCSI_AIC7XXX_OLD is not set
400# CONFIG_SCSI_AIC79XX is not set
401# CONFIG_SCSI_AIC94XX is not set
402# CONFIG_SCSI_DPT_I2O is not set
403# CONFIG_SCSI_ARCMSR is not set
404# CONFIG_MEGARAID_NEWGEN is not set
405# CONFIG_MEGARAID_LEGACY is not set
406# CONFIG_MEGARAID_SAS is not set
407# CONFIG_SCSI_HPTIOP is not set
408# CONFIG_SCSI_BUSLOGIC is not set
409# CONFIG_SCSI_DMX3191D is not set
410# CONFIG_SCSI_EATA is not set
411# CONFIG_SCSI_FUTURE_DOMAIN is not set
412# CONFIG_SCSI_GDTH is not set
413# CONFIG_SCSI_IPS is not set
414# CONFIG_SCSI_INITIO is not set
415# CONFIG_SCSI_INIA100 is not set
416# CONFIG_SCSI_STEX is not set
417# CONFIG_SCSI_SYM53C8XX_2 is not set
418# CONFIG_SCSI_QLOGIC_1280 is not set
419# CONFIG_SCSI_QLA_FC is not set
420# CONFIG_SCSI_QLA_ISCSI is not set
421# CONFIG_SCSI_LPFC is not set
422# CONFIG_SCSI_DC395x is not set
423# CONFIG_SCSI_DC390T is not set
424# CONFIG_SCSI_NSP32 is not set
405# CONFIG_SCSI_DEBUG is not set 425# CONFIG_SCSI_DEBUG is not set
426# CONFIG_SCSI_SRP is not set
406# CONFIG_ATA is not set 427# CONFIG_ATA is not set
428# CONFIG_MD is not set
407 429
408# 430#
409# Multi-device support (RAID and LVM) 431# Fusion MPT device support
410# 432#
411# CONFIG_MD is not set 433# CONFIG_FUSION is not set
412# CONFIG_MACINTOSH_DRIVERS is not set 434# CONFIG_FUSION_SPI is not set
435# CONFIG_FUSION_FC is not set
436# CONFIG_FUSION_SAS is not set
413 437
414# 438#
415# Network device support 439# IEEE 1394 (FireWire) support
416# 440#
441# CONFIG_FIREWIRE is not set
442# CONFIG_IEEE1394 is not set
443# CONFIG_I2O is not set
444# CONFIG_MACINTOSH_DRIVERS is not set
417CONFIG_NETDEVICES=y 445CONFIG_NETDEVICES=y
446# CONFIG_NETDEVICES_MULTIQUEUE is not set
418# CONFIG_DUMMY is not set 447# CONFIG_DUMMY is not set
419# CONFIG_BONDING is not set 448# CONFIG_BONDING is not set
449# CONFIG_MACVLAN is not set
420# CONFIG_EQUALIZER is not set 450# CONFIG_EQUALIZER is not set
421# CONFIG_TUN is not set 451# CONFIG_TUN is not set
452# CONFIG_ARCNET is not set
422CONFIG_PHYLIB=y 453CONFIG_PHYLIB=y
423 454
424# 455#
@@ -432,17 +463,44 @@ CONFIG_MARVELL_PHY=y
432# CONFIG_VITESSE_PHY is not set 463# CONFIG_VITESSE_PHY is not set
433# CONFIG_SMSC_PHY is not set 464# CONFIG_SMSC_PHY is not set
434# CONFIG_BROADCOM_PHY is not set 465# CONFIG_BROADCOM_PHY is not set
466# CONFIG_ICPLUS_PHY is not set
435# CONFIG_FIXED_PHY is not set 467# CONFIG_FIXED_PHY is not set
436
437#
438# Ethernet (10 or 100Mbit)
439#
440CONFIG_NET_ETHERNET=y 468CONFIG_NET_ETHERNET=y
441CONFIG_MII=y 469CONFIG_MII=y
470# CONFIG_HAPPYMEAL is not set
471# CONFIG_SUNGEM is not set
472# CONFIG_CASSINI is not set
473# CONFIG_NET_VENDOR_3COM is not set
474# CONFIG_NET_TULIP is not set
475# CONFIG_HP100 is not set
476# CONFIG_NET_PCI is not set
442CONFIG_NETDEV_1000=y 477CONFIG_NETDEV_1000=y
478# CONFIG_ACENIC is not set
479# CONFIG_DL2K is not set
480# CONFIG_E1000 is not set
481# CONFIG_NS83820 is not set
482# CONFIG_HAMACHI is not set
483# CONFIG_YELLOWFIN is not set
484# CONFIG_R8169 is not set
485# CONFIG_SIS190 is not set
486# CONFIG_SKGE is not set
487# CONFIG_SKY2 is not set
488# CONFIG_VIA_VELOCITY is not set
489# CONFIG_TIGON3 is not set
490# CONFIG_BNX2 is not set
443CONFIG_GIANFAR=y 491CONFIG_GIANFAR=y
444CONFIG_GFAR_NAPI=y 492CONFIG_GFAR_NAPI=y
493# CONFIG_QLA3XXX is not set
494# CONFIG_ATL1 is not set
445CONFIG_NETDEV_10000=y 495CONFIG_NETDEV_10000=y
496# CONFIG_CHELSIO_T1 is not set
497# CONFIG_CHELSIO_T3 is not set
498# CONFIG_IXGB is not set
499# CONFIG_S2IO is not set
500# CONFIG_MYRI10GE is not set
501# CONFIG_NETXEN_NIC is not set
502# CONFIG_MLX4_CORE is not set
503# CONFIG_TR is not set
446 504
447# 505#
448# Wireless LAN 506# Wireless LAN
@@ -450,21 +508,16 @@ CONFIG_NETDEV_10000=y
450# CONFIG_WLAN_PRE80211 is not set 508# CONFIG_WLAN_PRE80211 is not set
451# CONFIG_WLAN_80211 is not set 509# CONFIG_WLAN_80211 is not set
452# CONFIG_WAN is not set 510# CONFIG_WAN is not set
511# CONFIG_FDDI is not set
512# CONFIG_HIPPI is not set
453# CONFIG_PPP is not set 513# CONFIG_PPP is not set
454# CONFIG_SLIP is not set 514# CONFIG_SLIP is not set
515# CONFIG_NET_FC is not set
455# CONFIG_SHAPER is not set 516# CONFIG_SHAPER is not set
456# CONFIG_NETCONSOLE is not set 517# CONFIG_NETCONSOLE is not set
457# CONFIG_NETPOLL is not set 518# CONFIG_NETPOLL is not set
458# CONFIG_NET_POLL_CONTROLLER is not set 519# CONFIG_NET_POLL_CONTROLLER is not set
459
460#
461# ISDN subsystem
462#
463# CONFIG_ISDN is not set 520# CONFIG_ISDN is not set
464
465#
466# Telephony Support
467#
468# CONFIG_PHONE is not set 521# CONFIG_PHONE is not set
469 522
470# 523#
@@ -510,6 +563,7 @@ CONFIG_INPUT=y
510# 563#
511CONFIG_SERIAL_8250=y 564CONFIG_SERIAL_8250=y
512CONFIG_SERIAL_8250_CONSOLE=y 565CONFIG_SERIAL_8250_CONSOLE=y
566CONFIG_SERIAL_8250_PCI=y
513CONFIG_SERIAL_8250_NR_UARTS=4 567CONFIG_SERIAL_8250_NR_UARTS=4
514CONFIG_SERIAL_8250_RUNTIME_UARTS=4 568CONFIG_SERIAL_8250_RUNTIME_UARTS=4
515# CONFIG_SERIAL_8250_EXTENDED is not set 569# CONFIG_SERIAL_8250_EXTENDED is not set
@@ -521,14 +575,11 @@ CONFIG_SERIAL_8250_SHARE_IRQ=y
521# CONFIG_SERIAL_UARTLITE is not set 575# CONFIG_SERIAL_UARTLITE is not set
522CONFIG_SERIAL_CORE=y 576CONFIG_SERIAL_CORE=y
523CONFIG_SERIAL_CORE_CONSOLE=y 577CONFIG_SERIAL_CORE_CONSOLE=y
578# CONFIG_SERIAL_JSM is not set
524# CONFIG_SERIAL_OF_PLATFORM is not set 579# CONFIG_SERIAL_OF_PLATFORM is not set
525CONFIG_UNIX98_PTYS=y 580CONFIG_UNIX98_PTYS=y
526CONFIG_LEGACY_PTYS=y 581CONFIG_LEGACY_PTYS=y
527CONFIG_LEGACY_PTY_COUNT=256 582CONFIG_LEGACY_PTY_COUNT=256
528
529#
530# IPMI
531#
532# CONFIG_IPMI_HANDLER is not set 583# CONFIG_IPMI_HANDLER is not set
533CONFIG_WATCHDOG=y 584CONFIG_WATCHDOG=y
534# CONFIG_WATCHDOG_NOWAYOUT is not set 585# CONFIG_WATCHDOG_NOWAYOUT is not set
@@ -538,17 +589,23 @@ CONFIG_WATCHDOG=y
538# 589#
539# CONFIG_SOFT_WATCHDOG is not set 590# CONFIG_SOFT_WATCHDOG is not set
540# CONFIG_BOOKE_WDT is not set 591# CONFIG_BOOKE_WDT is not set
592
593#
594# PCI-based Watchdog Cards
595#
596# CONFIG_PCIPCWATCHDOG is not set
597# CONFIG_WDTPCI is not set
541CONFIG_HW_RANDOM=y 598CONFIG_HW_RANDOM=y
542# CONFIG_NVRAM is not set 599# CONFIG_NVRAM is not set
543CONFIG_GEN_RTC=y 600CONFIG_GEN_RTC=y
544# CONFIG_GEN_RTC_X is not set 601# CONFIG_GEN_RTC_X is not set
545# CONFIG_R3964 is not set 602# CONFIG_R3964 is not set
603# CONFIG_APPLICOM is not set
604# CONFIG_AGP is not set
605# CONFIG_DRM is not set
546# CONFIG_RAW_DRIVER is not set 606# CONFIG_RAW_DRIVER is not set
547
548#
549# TPM devices
550#
551# CONFIG_TCG_TPM is not set 607# CONFIG_TCG_TPM is not set
608CONFIG_DEVPORT=y
552CONFIG_I2C=y 609CONFIG_I2C=y
553CONFIG_I2C_BOARDINFO=y 610CONFIG_I2C_BOARDINFO=y
554CONFIG_I2C_CHARDEV=y 611CONFIG_I2C_CHARDEV=y
@@ -563,23 +620,43 @@ CONFIG_I2C_CHARDEV=y
563# 620#
564# I2C Hardware Bus support 621# I2C Hardware Bus support
565# 622#
623# CONFIG_I2C_ALI1535 is not set
624# CONFIG_I2C_ALI1563 is not set
625# CONFIG_I2C_ALI15X3 is not set
626# CONFIG_I2C_AMD756 is not set
627# CONFIG_I2C_AMD8111 is not set
628# CONFIG_I2C_I801 is not set
629# CONFIG_I2C_I810 is not set
630# CONFIG_I2C_PIIX4 is not set
566CONFIG_I2C_MPC=y 631CONFIG_I2C_MPC=y
632# CONFIG_I2C_NFORCE2 is not set
567# CONFIG_I2C_OCORES is not set 633# CONFIG_I2C_OCORES is not set
568# CONFIG_I2C_PARPORT_LIGHT is not set 634# CONFIG_I2C_PARPORT_LIGHT is not set
635# CONFIG_I2C_PROSAVAGE is not set
636# CONFIG_I2C_SAVAGE4 is not set
569# CONFIG_I2C_SIMTEC is not set 637# CONFIG_I2C_SIMTEC is not set
638# CONFIG_I2C_SIS5595 is not set
639# CONFIG_I2C_SIS630 is not set
640# CONFIG_I2C_SIS96X is not set
641# CONFIG_I2C_TAOS_EVM is not set
570# CONFIG_I2C_STUB is not set 642# CONFIG_I2C_STUB is not set
643# CONFIG_I2C_VIA is not set
644# CONFIG_I2C_VIAPRO is not set
645# CONFIG_I2C_VOODOO3 is not set
571 646
572# 647#
573# Miscellaneous I2C Chip support 648# Miscellaneous I2C Chip support
574# 649#
575# CONFIG_SENSORS_DS1337 is not set 650# CONFIG_SENSORS_DS1337 is not set
576# CONFIG_SENSORS_DS1374 is not set 651# CONFIG_SENSORS_DS1374 is not set
652# CONFIG_DS1682 is not set
577# CONFIG_SENSORS_EEPROM is not set 653# CONFIG_SENSORS_EEPROM is not set
578# CONFIG_SENSORS_PCF8574 is not set 654# CONFIG_SENSORS_PCF8574 is not set
579# CONFIG_SENSORS_PCA9539 is not set 655# CONFIG_SENSORS_PCA9539 is not set
580# CONFIG_SENSORS_PCF8591 is not set 656# CONFIG_SENSORS_PCF8591 is not set
581# CONFIG_SENSORS_M41T00 is not set 657# CONFIG_SENSORS_M41T00 is not set
582# CONFIG_SENSORS_MAX6875 is not set 658# CONFIG_SENSORS_MAX6875 is not set
659# CONFIG_SENSORS_TSL2550 is not set
583# CONFIG_I2C_DEBUG_CORE is not set 660# CONFIG_I2C_DEBUG_CORE is not set
584# CONFIG_I2C_DEBUG_ALGO is not set 661# CONFIG_I2C_DEBUG_ALGO is not set
585# CONFIG_I2C_DEBUG_BUS is not set 662# CONFIG_I2C_DEBUG_BUS is not set
@@ -590,11 +667,8 @@ CONFIG_I2C_MPC=y
590# 667#
591# CONFIG_SPI is not set 668# CONFIG_SPI is not set
592# CONFIG_SPI_MASTER is not set 669# CONFIG_SPI_MASTER is not set
593
594#
595# Dallas's 1-wire bus
596#
597# CONFIG_W1 is not set 670# CONFIG_W1 is not set
671# CONFIG_POWER_SUPPLY is not set
598CONFIG_HWMON=y 672CONFIG_HWMON=y
599# CONFIG_HWMON_VID is not set 673# CONFIG_HWMON_VID is not set
600# CONFIG_SENSORS_ABITUGURU is not set 674# CONFIG_SENSORS_ABITUGURU is not set
@@ -628,10 +702,13 @@ CONFIG_HWMON=y
628# CONFIG_SENSORS_MAX6650 is not set 702# CONFIG_SENSORS_MAX6650 is not set
629# CONFIG_SENSORS_PC87360 is not set 703# CONFIG_SENSORS_PC87360 is not set
630# CONFIG_SENSORS_PC87427 is not set 704# CONFIG_SENSORS_PC87427 is not set
705# CONFIG_SENSORS_SIS5595 is not set
631# CONFIG_SENSORS_SMSC47M1 is not set 706# CONFIG_SENSORS_SMSC47M1 is not set
632# CONFIG_SENSORS_SMSC47M192 is not set 707# CONFIG_SENSORS_SMSC47M192 is not set
633# CONFIG_SENSORS_SMSC47B397 is not set 708# CONFIG_SENSORS_SMSC47B397 is not set
709# CONFIG_SENSORS_VIA686A is not set
634# CONFIG_SENSORS_VT1211 is not set 710# CONFIG_SENSORS_VT1211 is not set
711# CONFIG_SENSORS_VT8231 is not set
635# CONFIG_SENSORS_W83781D is not set 712# CONFIG_SENSORS_W83781D is not set
636# CONFIG_SENSORS_W83791D is not set 713# CONFIG_SENSORS_W83791D is not set
637# CONFIG_SENSORS_W83792D is not set 714# CONFIG_SENSORS_W83792D is not set
@@ -670,19 +747,14 @@ CONFIG_DAB=y
670# Sound 747# Sound
671# 748#
672# CONFIG_SOUND is not set 749# CONFIG_SOUND is not set
673 750CONFIG_HID_SUPPORT=y
674#
675# HID Devices
676#
677CONFIG_HID=y 751CONFIG_HID=y
678# CONFIG_HID_DEBUG is not set 752# CONFIG_HID_DEBUG is not set
679 753CONFIG_USB_SUPPORT=y
680# 754CONFIG_USB_ARCH_HAS_HCD=y
681# USB support 755CONFIG_USB_ARCH_HAS_OHCI=y
682# 756CONFIG_USB_ARCH_HAS_EHCI=y
683# CONFIG_USB_ARCH_HAS_HCD is not set 757# CONFIG_USB is not set
684# CONFIG_USB_ARCH_HAS_OHCI is not set
685# CONFIG_USB_ARCH_HAS_EHCI is not set
686 758
687# 759#
688# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 760# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
@@ -706,14 +778,7 @@ CONFIG_HID=y
706# 778#
707# LED Triggers 779# LED Triggers
708# 780#
709 781# CONFIG_INFINIBAND is not set
710#
711# InfiniBand support
712#
713
714#
715# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
716#
717 782
718# 783#
719# Real Time Clock 784# Real Time Clock
@@ -734,6 +799,11 @@ CONFIG_HID=y
734# 799#
735 800
736# 801#
802# Userspace I/O
803#
804# CONFIG_UIO is not set
805
806#
737# File systems 807# File systems
738# 808#
739CONFIG_EXT2_FS=y 809CONFIG_EXT2_FS=y
@@ -829,7 +899,6 @@ CONFIG_RPCSEC_GSS_KRB5=y
829# CONFIG_NCP_FS is not set 899# CONFIG_NCP_FS is not set
830# CONFIG_CODA_FS is not set 900# CONFIG_CODA_FS is not set
831# CONFIG_AFS_FS is not set 901# CONFIG_AFS_FS is not set
832# CONFIG_9P_FS is not set
833 902
834# 903#
835# Partition Types 904# Partition Types
@@ -868,6 +937,7 @@ CONFIG_BITREVERSE=y
868# CONFIG_CRC16 is not set 937# CONFIG_CRC16 is not set
869# CONFIG_CRC_ITU_T is not set 938# CONFIG_CRC_ITU_T is not set
870CONFIG_CRC32=y 939CONFIG_CRC32=y
940# CONFIG_CRC7 is not set
871# CONFIG_LIBCRC32C is not set 941# CONFIG_LIBCRC32C is not set
872CONFIG_PLIST=y 942CONFIG_PLIST=y
873CONFIG_HAS_IOMEM=y 943CONFIG_HAS_IOMEM=y
@@ -892,6 +962,7 @@ CONFIG_ENABLE_MUST_CHECK=y
892CONFIG_DEBUG_KERNEL=y 962CONFIG_DEBUG_KERNEL=y
893# CONFIG_DEBUG_SHIRQ is not set 963# CONFIG_DEBUG_SHIRQ is not set
894CONFIG_DETECT_SOFTLOCKUP=y 964CONFIG_DETECT_SOFTLOCKUP=y
965CONFIG_SCHED_DEBUG=y
895# CONFIG_SCHEDSTATS is not set 966# CONFIG_SCHEDSTATS is not set
896# CONFIG_TIMER_STATS is not set 967# CONFIG_TIMER_STATS is not set
897# CONFIG_DEBUG_SLAB is not set 968# CONFIG_DEBUG_SLAB is not set
@@ -915,7 +986,7 @@ CONFIG_FORCED_INLINING=y
915CONFIG_DEBUGGER=y 986CONFIG_DEBUGGER=y
916# CONFIG_XMON is not set 987# CONFIG_XMON is not set
917# CONFIG_BDI_SWITCH is not set 988# CONFIG_BDI_SWITCH is not set
918CONFIG_BOOTX_TEXT=y 989# CONFIG_BOOTX_TEXT is not set
919CONFIG_PPC_EARLY_DEBUG=y 990CONFIG_PPC_EARLY_DEBUG=y
920# CONFIG_PPC_EARLY_DEBUG_LPAR is not set 991# CONFIG_PPC_EARLY_DEBUG_LPAR is not set
921# CONFIG_PPC_EARLY_DEBUG_G5 is not set 992# CONFIG_PPC_EARLY_DEBUG_G5 is not set
@@ -932,10 +1003,6 @@ CONFIG_PPC_EARLY_DEBUG=y
932# 1003#
933# CONFIG_KEYS is not set 1004# CONFIG_KEYS is not set
934# CONFIG_SECURITY is not set 1005# CONFIG_SECURITY is not set
935
936#
937# Cryptographic options
938#
939CONFIG_CRYPTO=y 1006CONFIG_CRYPTO=y
940CONFIG_CRYPTO_ALGAPI=y 1007CONFIG_CRYPTO_ALGAPI=y
941CONFIG_CRYPTO_BLKCIPHER=y 1008CONFIG_CRYPTO_BLKCIPHER=y
@@ -973,7 +1040,4 @@ CONFIG_CRYPTO_DES=y
973# CONFIG_CRYPTO_CRC32C is not set 1040# CONFIG_CRYPTO_CRC32C is not set
974# CONFIG_CRYPTO_CAMELLIA is not set 1041# CONFIG_CRYPTO_CAMELLIA is not set
975# CONFIG_CRYPTO_TEST is not set 1042# CONFIG_CRYPTO_TEST is not set
976 1043CONFIG_CRYPTO_HW=y
977#
978# Hardware crypto devices
979#
diff --git a/arch/powerpc/configs/pmac32_defconfig b/arch/powerpc/configs/pmac32_defconfig
index 0d8ba623e29a..08525d6fb1f1 100644
--- a/arch/powerpc/configs/pmac32_defconfig
+++ b/arch/powerpc/configs/pmac32_defconfig
@@ -218,7 +218,7 @@ CONFIG_PM=y
218CONFIG_PM_DEBUG=y 218CONFIG_PM_DEBUG=y
219# CONFIG_DISABLE_CONSOLE_SUSPEND is not set 219# CONFIG_DISABLE_CONSOLE_SUSPEND is not set
220CONFIG_PM_SYSFS_DEPRECATED=y 220CONFIG_PM_SYSFS_DEPRECATED=y
221CONFIG_SOFTWARE_SUSPEND=y 221CONFIG_HIBERNATION=y
222CONFIG_PM_STD_PARTITION="" 222CONFIG_PM_STD_PARTITION=""
223CONFIG_APM_EMULATION=y 223CONFIG_APM_EMULATION=y
224CONFIG_SECCOMP=y 224CONFIG_SECCOMP=y
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 42c42ecad00c..f39a72f30aad 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -37,9 +37,9 @@ obj-$(CONFIG_GENERIC_TBSYNC) += smp-tbsync.o
37obj-$(CONFIG_CRASH_DUMP) += crash_dump.o 37obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
38obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o 38obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o
39obj-$(CONFIG_TAU) += tau_6xx.o 39obj-$(CONFIG_TAU) += tau_6xx.o
40obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o suspend.o 40obj-$(CONFIG_HIBERNATION) += swsusp.o suspend.o
41obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o 41obj32-$(CONFIG_HIBERNATION) += swsusp_32.o
42obj64-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_64.o swsusp_asm64.o 42obj64-$(CONFIG_HIBERNATION) += swsusp_64.o swsusp_asm64.o
43obj32-$(CONFIG_MODULES) += module_32.o 43obj32-$(CONFIG_MODULES) += module_32.o
44 44
45ifeq ($(CONFIG_PPC_MERGE),y) 45ifeq ($(CONFIG_PPC_MERGE),y)
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 2b66d53dcc55..9ef28da2c7fe 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -546,7 +546,6 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
546 rfid 546 rfid
547 b . /* prevent speculative execution */ 547 b . /* prevent speculative execution */
548 548
549/* Note: this must change if we start using the TIF_NOTIFY_RESUME bit */
550do_work: 549do_work:
551#ifdef CONFIG_PREEMPT 550#ifdef CONFIG_PREEMPT
552 andi. r0,r3,MSR_PR /* Returning to user mode? */ 551 andi. r0,r3,MSR_PR /* Returning to user mode? */
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 8cdd48ea4391..1448af92c6a9 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -809,8 +809,9 @@ system_reset_iSeries:
809 mtmsrd r24 /* RI on */ 809 mtmsrd r24 /* RI on */
810 lhz r24,PACAPACAINDEX(r13) /* Get processor # */ 810 lhz r24,PACAPACAINDEX(r13) /* Get processor # */
811 cmpwi 0,r24,0 /* Are we processor 0? */ 811 cmpwi 0,r24,0 /* Are we processor 0? */
812 beq .__start_initialization_iSeries /* Start up the first processor */ 812 bne 1f
813 mfspr r4,SPRN_CTRLF 813 b .__start_initialization_iSeries /* Start up the first processor */
8141: mfspr r4,SPRN_CTRLF
814 li r5,CTRL_RUNLATCH /* Turn off the run light */ 815 li r5,CTRL_RUNLATCH /* Turn off the run light */
815 andc r4,r4,r5 816 andc r4,r4,r5
816 mtspr SPRN_CTRLT,r4 817 mtspr SPRN_CTRLT,r4
@@ -1611,7 +1612,7 @@ _GLOBAL(generic_secondary_smp_init)
1611#endif 1612#endif
1612 1613
1613#ifdef CONFIG_PPC_ISERIES 1614#ifdef CONFIG_PPC_ISERIES
1614_STATIC(__start_initialization_iSeries) 1615_INIT_STATIC(__start_initialization_iSeries)
1615 /* Clear out the BSS */ 1616 /* Clear out the BSS */
1616 LOAD_REG_IMMEDIATE(r11,__bss_stop) 1617 LOAD_REG_IMMEDIATE(r11,__bss_stop)
1617 LOAD_REG_IMMEDIATE(r8,__bss_start) 1618 LOAD_REG_IMMEDIATE(r8,__bss_start)
diff --git a/arch/powerpc/kernel/iomap.c b/arch/powerpc/kernel/iomap.c
index 601ef79a5916..2a5cf8680370 100644
--- a/arch/powerpc/kernel/iomap.c
+++ b/arch/powerpc/kernel/iomap.c
@@ -7,6 +7,7 @@
7#include <linux/pci.h> 7#include <linux/pci.h>
8#include <linux/mm.h> 8#include <linux/mm.h>
9#include <asm/io.h> 9#include <asm/io.h>
10#include <asm/pci-bridge.h>
10 11
11/* 12/*
12 * Here comes the ppc64 implementation of the IOMAP 13 * Here comes the ppc64 implementation of the IOMAP
@@ -136,7 +137,12 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
136 137
137void pci_iounmap(struct pci_dev *dev, void __iomem *addr) 138void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
138{ 139{
139 /* Nothing to do */ 140 if (isa_vaddr_is_ioport(addr))
141 return;
142 if (pcibios_vaddr_is_ioport(addr))
143 return;
144 iounmap(addr);
140} 145}
146
141EXPORT_SYMBOL(pci_iomap); 147EXPORT_SYMBOL(pci_iomap);
142EXPORT_SYMBOL(pci_iounmap); 148EXPORT_SYMBOL(pci_iounmap);
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 2fc87862146c..24bea97c736c 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -418,10 +418,10 @@ irq_hw_number_t virq_to_hw(unsigned int virq)
418} 418}
419EXPORT_SYMBOL_GPL(virq_to_hw); 419EXPORT_SYMBOL_GPL(virq_to_hw);
420 420
421struct irq_host *irq_alloc_host(unsigned int revmap_type, 421__init_refok struct irq_host *irq_alloc_host(unsigned int revmap_type,
422 unsigned int revmap_arg, 422 unsigned int revmap_arg,
423 struct irq_host_ops *ops, 423 struct irq_host_ops *ops,
424 irq_hw_number_t inval_irq) 424 irq_hw_number_t inval_irq)
425{ 425{
426 struct irq_host *host; 426 struct irq_host *host;
427 unsigned int size = sizeof(struct irq_host); 427 unsigned int size = sizeof(struct irq_host);
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index fe7d1255e11e..083cfbdbe0b2 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -65,7 +65,7 @@ static void __devinit pci_setup_pci_controller(struct pci_controller *hose)
65 spin_unlock(&hose_spinlock); 65 spin_unlock(&hose_spinlock);
66} 66}
67 67
68struct pci_controller * pcibios_alloc_controller(struct device_node *dev) 68__init_refok struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
69{ 69{
70 struct pci_controller *phb; 70 struct pci_controller *phb;
71 71
@@ -101,6 +101,29 @@ void pcibios_free_controller(struct pci_controller *phb)
101 kfree(phb); 101 kfree(phb);
102} 102}
103 103
104int pcibios_vaddr_is_ioport(void __iomem *address)
105{
106 int ret = 0;
107 struct pci_controller *hose;
108 unsigned long size;
109
110 spin_lock(&hose_spinlock);
111 list_for_each_entry(hose, &hose_list, list_node) {
112#ifdef CONFIG_PPC64
113 size = hose->pci_io_size;
114#else
115 size = hose->io_resource.end - hose->io_resource.start + 1;
116#endif
117 if (address >= hose->io_base_virt &&
118 address < (hose->io_base_virt + size)) {
119 ret = 1;
120 break;
121 }
122 }
123 spin_unlock(&hose_spinlock);
124 return ret;
125}
126
104/* 127/*
105 * Return the domain number for this bus. 128 * Return the domain number for this bus.
106 */ 129 */
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 0adf077f3f3a..cd35c969bb28 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -60,6 +60,24 @@ LIST_HEAD(hose_list);
60static int pci_bus_count; 60static int pci_bus_count;
61 61
62static void 62static void
63fixup_hide_host_resource_fsl(struct pci_dev* dev)
64{
65 int i, class = dev->class >> 8;
66
67 if ((class == PCI_CLASS_PROCESSOR_POWERPC) &&
68 (dev->hdr_type == PCI_HEADER_TYPE_NORMAL) &&
69 (dev->bus->parent == NULL)) {
70 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
71 dev->resource[i].start = 0;
72 dev->resource[i].end = 0;
73 dev->resource[i].flags = 0;
74 }
75 }
76}
77DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MOTOROLA, PCI_ANY_ID, fixup_hide_host_resource_fsl);
78DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, fixup_hide_host_resource_fsl);
79
80static void
63fixup_broken_pcnet32(struct pci_dev* dev) 81fixup_broken_pcnet32(struct pci_dev* dev)
64{ 82{
65 if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) { 83 if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) {
@@ -415,15 +433,13 @@ probe_resource(struct pci_bus *parent, struct resource *pr,
415 return 0; 433 return 0;
416} 434}
417 435
418static void __init 436void __init
419update_bridge_base(struct pci_bus *bus, int i) 437update_bridge_resource(struct pci_dev *dev, struct resource *res)
420{ 438{
421 struct resource *res = bus->resource[i];
422 u8 io_base_lo, io_limit_lo; 439 u8 io_base_lo, io_limit_lo;
423 u16 mem_base, mem_limit; 440 u16 mem_base, mem_limit;
424 u16 cmd; 441 u16 cmd;
425 unsigned long start, end, off; 442 unsigned long start, end, off;
426 struct pci_dev *dev = bus->self;
427 struct pci_controller *hose = dev->sysdata; 443 struct pci_controller *hose = dev->sysdata;
428 444
429 if (!hose) { 445 if (!hose) {
@@ -467,12 +483,20 @@ update_bridge_base(struct pci_bus *bus, int i)
467 pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, mem_limit); 483 pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, mem_limit);
468 484
469 } else { 485 } else {
470 DBG(KERN_ERR "PCI: ugh, bridge %s res %d has flags=%lx\n", 486 DBG(KERN_ERR "PCI: ugh, bridge %s res has flags=%lx\n",
471 pci_name(dev), i, res->flags); 487 pci_name(dev), res->flags);
472 } 488 }
473 pci_write_config_word(dev, PCI_COMMAND, cmd); 489 pci_write_config_word(dev, PCI_COMMAND, cmd);
474} 490}
475 491
492static void __init
493update_bridge_base(struct pci_bus *bus, int i)
494{
495 struct resource *res = bus->resource[i];
496 struct pci_dev *dev = bus->self;
497 update_bridge_resource(dev, res);
498}
499
476static inline void alloc_resource(struct pci_dev *dev, int idx) 500static inline void alloc_resource(struct pci_dev *dev, int idx)
477{ 501{
478 struct resource *pr, *r = &dev->resource[idx]; 502 struct resource *pr, *r = &dev->resource[idx];
@@ -1223,7 +1247,7 @@ pcibios_init(void)
1223 1247
1224subsys_initcall(pcibios_init); 1248subsys_initcall(pcibios_init);
1225 1249
1226void __init pcibios_fixup_bus(struct pci_bus *bus) 1250void pcibios_fixup_bus(struct pci_bus *bus)
1227{ 1251{
1228 struct pci_controller *hose = (struct pci_controller *) bus->sysdata; 1252 struct pci_controller *hose = (struct pci_controller *) bus->sysdata;
1229 unsigned long io_offset; 1253 unsigned long io_offset;
@@ -1468,3 +1492,10 @@ EARLY_PCI_OP(read, dword, u32 *)
1468EARLY_PCI_OP(write, byte, u8) 1492EARLY_PCI_OP(write, byte, u8)
1469EARLY_PCI_OP(write, word, u16) 1493EARLY_PCI_OP(write, word, u16)
1470EARLY_PCI_OP(write, dword, u32) 1494EARLY_PCI_OP(write, dword, u32)
1495
1496extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap);
1497int early_find_capability(struct pci_controller *hose, int bus, int devfn,
1498 int cap)
1499{
1500 return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap);
1501}
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 84f000a45e36..a83727b308a0 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -423,7 +423,11 @@ void show_regs(struct pt_regs * regs)
423 printk(" CR: %08lx XER: %08lx\n", regs->ccr, regs->xer); 423 printk(" CR: %08lx XER: %08lx\n", regs->ccr, regs->xer);
424 trap = TRAP(regs); 424 trap = TRAP(regs);
425 if (trap == 0x300 || trap == 0x600) 425 if (trap == 0x300 || trap == 0x600)
426#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
427 printk("DEAR: "REG", ESR: "REG"\n", regs->dar, regs->dsisr);
428#else
426 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr); 429 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
430#endif
427 printk("TASK = %p[%d] '%s' THREAD: %p", 431 printk("TASK = %p[%d] '%s' THREAD: %p",
428 current, current->pid, current->comm, task_thread_info(current)); 432 current, current->pid, current->comm, task_thread_info(current));
429 433
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index 3786dcc8a7b6..b5c96af955c6 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -24,7 +24,7 @@
24/* Max address size we deal with */ 24/* Max address size we deal with */
25#define OF_MAX_ADDR_CELLS 4 25#define OF_MAX_ADDR_CELLS 4
26#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \ 26#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
27 (ns) >= 0) 27 (ns) > 0)
28 28
29static struct of_bus *of_match_bus(struct device_node *np); 29static struct of_bus *of_match_bus(struct device_node *np);
30static int __of_address_to_resource(struct device_node *dev, 30static int __of_address_to_resource(struct device_node *dev,
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 4924c48cb1ff..50ef38cffdbf 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -496,6 +496,10 @@ int check_legacy_ioport(unsigned long base_port)
496 break; 496 break;
497 } 497 }
498 np = of_find_node_by_type(NULL, "8042"); 498 np = of_find_node_by_type(NULL, "8042");
499 /* Pegasos has no device_type on its 8042 node, look for the
500 * name instead */
501 if (!np)
502 np = of_find_node_by_name(NULL, "8042");
499 break; 503 break;
500 case FDC_BASE: /* FDC1 */ 504 case FDC_BASE: /* FDC1 */
501 np = of_find_node_by_type(NULL, "fdc"); 505 np = of_find_node_by_type(NULL, "fdc");
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index fc6647d332cb..f85f402ceaef 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -23,6 +23,7 @@
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/syscalls.h> 24#include <linux/syscalls.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/fs.h>
26#include <linux/smp.h> 27#include <linux/smp.h>
27#include <linux/sem.h> 28#include <linux/sem.h>
28#include <linux/msg.h> 29#include <linux/msg.h>
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
index cbca1df8bc60..0f9b4eadfbcb 100644
--- a/arch/powerpc/kernel/udbg.c
+++ b/arch/powerpc/kernel/udbg.c
@@ -155,7 +155,7 @@ static int early_console_initialized;
155 * Called by setup_system after ppc_md->probe and ppc_md->early_init. 155 * Called by setup_system after ppc_md->probe and ppc_md->early_init.
156 * Call it again after setting udbg_putc in ppc_md->setup_arch. 156 * Call it again after setting udbg_putc in ppc_md->setup_arch.
157 */ 157 */
158void register_early_udbg_console(void) 158void __init register_early_udbg_console(void)
159{ 159{
160 if (early_console_initialized) 160 if (early_console_initialized)
161 return; 161 return;
diff --git a/arch/powerpc/lib/rheap.c b/arch/powerpc/lib/rheap.c
index 2f24ea0d723a..ada5b42dd231 100644
--- a/arch/powerpc/lib/rheap.c
+++ b/arch/powerpc/lib/rheap.c
@@ -16,6 +16,7 @@
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/err.h>
19#include <linux/slab.h> 20#include <linux/slab.h>
20 21
21#include <asm/rheap.h> 22#include <asm/rheap.h>
diff --git a/arch/powerpc/mm/lmb.c b/arch/powerpc/mm/lmb.c
index e3a1e8dc536a..8f4d2dc4cafb 100644
--- a/arch/powerpc/mm/lmb.c
+++ b/arch/powerpc/mm/lmb.c
@@ -138,8 +138,8 @@ void __init lmb_analyze(void)
138static long __init lmb_add_region(struct lmb_region *rgn, unsigned long base, 138static long __init lmb_add_region(struct lmb_region *rgn, unsigned long base,
139 unsigned long size) 139 unsigned long size)
140{ 140{
141 unsigned long i, coalesced = 0; 141 unsigned long coalesced = 0;
142 long adjacent; 142 long adjacent, i;
143 143
144 /* First try and coalesce this LMB with another. */ 144 /* First try and coalesce this LMB with another. */
145 for (i=0; i < rgn->cnt; i++) { 145 for (i=0; i < rgn->cnt; i++) {
diff --git a/arch/powerpc/oprofile/cell/spu_task_sync.c b/arch/powerpc/oprofile/cell/spu_task_sync.c
index 133665754a75..4a890cb42b98 100644
--- a/arch/powerpc/oprofile/cell/spu_task_sync.c
+++ b/arch/powerpc/oprofile/cell/spu_task_sync.c
@@ -21,6 +21,7 @@
21#include <linux/dcookies.h> 21#include <linux/dcookies.h>
22#include <linux/kref.h> 22#include <linux/kref.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/fs.h>
24#include <linux/module.h> 25#include <linux/module.h>
25#include <linux/notifier.h> 26#include <linux/notifier.h>
26#include <linux/numa.h> 27#include <linux/numa.h>
diff --git a/arch/powerpc/platforms/82xx/mpc82xx_ads.c b/arch/powerpc/platforms/82xx/mpc82xx_ads.c
index da20832b27f1..2d1b05b9f8ef 100644
--- a/arch/powerpc/platforms/82xx/mpc82xx_ads.c
+++ b/arch/powerpc/platforms/82xx/mpc82xx_ads.c
@@ -553,7 +553,8 @@ static void __init mpc82xx_add_bridge(struct device_node *np)
553 553
554 setup_indirect_pci(hose, 554 setup_indirect_pci(hose,
555 r.start + offsetof(pci_cpm2_t, pci_cfg_addr), 555 r.start + offsetof(pci_cpm2_t, pci_cfg_addr),
556 r.start + offsetof(pci_cpm2_t, pci_cfg_data)); 556 r.start + offsetof(pci_cpm2_t, pci_cfg_data),
557 0);
557 558
558 pci_process_bridge_OF_ranges(hose, np, 1); 559 pci_process_bridge_OF_ranges(hose, np, 1);
559} 560}
diff --git a/arch/powerpc/platforms/83xx/pci.c b/arch/powerpc/platforms/83xx/pci.c
index c0e2b89154e5..92069469de20 100644
--- a/arch/powerpc/platforms/83xx/pci.c
+++ b/arch/powerpc/platforms/83xx/pci.c
@@ -74,11 +74,11 @@ int __init mpc83xx_add_bridge(struct device_node *dev)
74 */ 74 */
75 /* PCI 1 */ 75 /* PCI 1 */
76 if ((rsrc.start & 0xfffff) == 0x8500) { 76 if ((rsrc.start & 0xfffff) == 0x8500) {
77 setup_indirect_pci(hose, immr + 0x8300, immr + 0x8304); 77 setup_indirect_pci(hose, immr + 0x8300, immr + 0x8304, 0);
78 } 78 }
79 /* PCI 2 */ 79 /* PCI 2 */
80 if ((rsrc.start & 0xfffff) == 0x8600) { 80 if ((rsrc.start & 0xfffff) == 0x8600) {
81 setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384); 81 setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384, 0);
82 primary = 0; 82 primary = 0;
83 } 83 }
84 84
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index 629926e01e90..f58184086c8c 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -18,6 +18,7 @@ config MPC8560_ADS
18config MPC85xx_CDS 18config MPC85xx_CDS
19 bool "Freescale MPC85xx CDS" 19 bool "Freescale MPC85xx CDS"
20 select DEFAULT_UIMAGE 20 select DEFAULT_UIMAGE
21 select PPC_I8259
21 help 22 help
22 This option enables support for the MPC85xx CDS board 23 This option enables support for the MPC85xx CDS board
23 24
@@ -30,6 +31,7 @@ config MPC85xx_MDS
30 31
31config MPC8544_DS 32config MPC8544_DS
32 bool "Freescale MPC8544 DS" 33 bool "Freescale MPC8544 DS"
34 select PPC_I8259
33 select DEFAULT_UIMAGE 35 select DEFAULT_UIMAGE
34 help 36 help
35 This option enables support for the MPC8544 DS board 37 This option enables support for the MPC8544 DS board
@@ -50,9 +52,9 @@ config MPC8560
50config MPC85xx 52config MPC85xx
51 bool 53 bool
52 select PPC_UDBG_16550 54 select PPC_UDBG_16550
53 select PPC_INDIRECT_PCI 55 select PPC_INDIRECT_PCI if PCI
54 select PPC_INDIRECT_PCI_BE
55 select MPIC 56 select MPIC
57 select FSL_PCI if PCI
56 select SERIAL_8250_SHARE_IRQ if SERIAL_8250 58 select SERIAL_8250_SHARE_IRQ if SERIAL_8250
57 default y if MPC8540_ADS || MPC85xx_CDS || MPC8560_ADS \ 59 default y if MPC8540_ADS || MPC85xx_CDS || MPC8560_ADS \
58 || MPC85xx_MDS || MPC8544_DS 60 || MPC85xx_MDS || MPC8544_DS
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 4e02cbb14cf7..d70f2d0f9d36 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -1,7 +1,7 @@
1# 1#
2# Makefile for the PowerPC 85xx linux kernel. 2# Makefile for the PowerPC 85xx linux kernel.
3# 3#
4obj-$(CONFIG_PPC_85xx) += misc.o pci.o 4obj-$(CONFIG_PPC_85xx) += misc.o
5obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o 5obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
6obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o 6obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
7obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o 7obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
diff --git a/arch/powerpc/platforms/85xx/mpc8544_ds.c b/arch/powerpc/platforms/85xx/mpc8544_ds.c
index 6fb90aab879f..4905f6f8903b 100644
--- a/arch/powerpc/platforms/85xx/mpc8544_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8544_ds.c
@@ -2,6 +2,8 @@
2 * MPC8544 DS Board Setup 2 * MPC8544 DS Board Setup
3 * 3 *
4 * Author Xianghua Xiao (x.xiao@freescale.com) 4 * Author Xianghua Xiao (x.xiao@freescale.com)
5 * Roy Zang <tie-fei.zang@freescale.com>
6 * - Add PCI/PCI Exprees support
5 * Copyright 2007 Freescale Semiconductor Inc. 7 * Copyright 2007 Freescale Semiconductor Inc.
6 * 8 *
7 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
@@ -12,13 +14,16 @@
12 14
13#include <linux/stddef.h> 15#include <linux/stddef.h>
14#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/pci.h>
15#include <linux/kdev_t.h> 18#include <linux/kdev_t.h>
16#include <linux/delay.h> 19#include <linux/delay.h>
17#include <linux/seq_file.h> 20#include <linux/seq_file.h>
21#include <linux/interrupt.h>
18 22
19#include <asm/system.h> 23#include <asm/system.h>
20#include <asm/time.h> 24#include <asm/time.h>
21#include <asm/machdep.h> 25#include <asm/machdep.h>
26#include <asm/pci-bridge.h>
22#include <asm/mpc85xx.h> 27#include <asm/mpc85xx.h>
23#include <mm/mmu_decl.h> 28#include <mm/mmu_decl.h>
24#include <asm/prom.h> 29#include <asm/prom.h>
@@ -27,6 +32,7 @@
27#include <asm/i8259.h> 32#include <asm/i8259.h>
28 33
29#include <sysdev/fsl_soc.h> 34#include <sysdev/fsl_soc.h>
35#include <sysdev/fsl_pci.h>
30#include "mpc85xx.h" 36#include "mpc85xx.h"
31 37
32#undef DEBUG 38#undef DEBUG
@@ -37,6 +43,17 @@
37#define DBG(fmt, args...) 43#define DBG(fmt, args...)
38#endif 44#endif
39 45
46#ifdef CONFIG_PPC_I8259
47static void mpc8544_8259_cascade(unsigned int irq, struct irq_desc *desc)
48{
49 unsigned int cascade_irq = i8259_irq();
50
51 if (cascade_irq != NO_IRQ) {
52 generic_handle_irq(cascade_irq);
53 }
54 desc->chip->eoi(irq);
55}
56#endif /* CONFIG_PPC_I8259 */
40 57
41void __init mpc8544_ds_pic_init(void) 58void __init mpc8544_ds_pic_init(void)
42{ 59{
@@ -96,19 +113,240 @@ void __init mpc8544_ds_pic_init(void)
96#endif /* CONFIG_PPC_I8259 */ 113#endif /* CONFIG_PPC_I8259 */
97} 114}
98 115
116#ifdef CONFIG_PCI
117enum pirq { PIRQA = 8, PIRQB, PIRQC, PIRQD, PIRQE, PIRQF, PIRQG, PIRQH };
118
119/*
120 * Value in table -- IRQ number
121 */
122const unsigned char uli1575_irq_route_table[16] = {
123 0, /* 0: Reserved */
124 0x8,
125 0, /* 2: Reserved */
126 0x2,
127 0x4,
128 0x5,
129 0x7,
130 0x6,
131 0, /* 8: Reserved */
132 0x1,
133 0x3,
134 0x9,
135 0xb,
136 0, /* 13: Reserved */
137 0xd,
138 0xf,
139};
140
141static int __devinit
142get_pci_irq_from_of(struct pci_controller *hose, int slot, int pin)
143{
144 struct of_irq oirq;
145 u32 laddr[3];
146 struct device_node *hosenode = hose ? hose->arch_data : NULL;
147
148 if (!hosenode)
149 return -EINVAL;
150
151 laddr[0] = (hose->first_busno << 16) | (PCI_DEVFN(slot, 0) << 8);
152 laddr[1] = laddr[2] = 0;
153 of_irq_map_raw(hosenode, &pin, 1, laddr, &oirq);
154 DBG("mpc8544_ds: pci irq addr %x, slot %d, pin %d, irq %d\n",
155 laddr[0], slot, pin, oirq.specifier[0]);
156 return oirq.specifier[0];
157}
158
159/*8259*/
160static void __devinit quirk_uli1575(struct pci_dev *dev)
161{
162 unsigned short temp;
163 struct pci_controller *hose = pci_bus_to_host(dev->bus);
164 unsigned char irq2pin[16];
165 unsigned long pirq_map_word = 0;
166 u32 irq;
167 int i;
168
169 /*
170 * ULI1575 interrupts route setup
171 */
172 memset(irq2pin, 0, 16); /* Initialize default value 0 */
173
174 irq2pin[6]=PIRQA+3; /* enabled mapping for IRQ6 to PIRQD, used by SATA */
175
176 /*
177 * PIRQE -> PIRQF mapping set manually
178 *
179 * IRQ pin IRQ#
180 * PIRQE ---- 9
181 * PIRQF ---- 10
182 * PIRQG ---- 11
183 * PIRQH ---- 12
184 */
185 for (i = 0; i < 4; i++)
186 irq2pin[i + 9] = PIRQE + i;
187
188 /* Set IRQ-PIRQ Mapping to ULI1575 */
189 for (i = 0; i < 16; i++)
190 if (irq2pin[i])
191 pirq_map_word |= (uli1575_irq_route_table[i] & 0xf)
192 << ((irq2pin[i] - PIRQA) * 4);
193
194 pirq_map_word |= 1<<26; /* disable INTx in EP mode*/
195
196 /* ULI1575 IRQ mapping conf register default value is 0xb9317542 */
197 DBG("Setup ULI1575 IRQ mapping configuration register value = 0x%x\n",
198 (int)pirq_map_word);
199 pci_write_config_dword(dev, 0x48, pirq_map_word);
200
201#define ULI1575_SET_DEV_IRQ(slot, pin, reg) \
202 do { \
203 int irq; \
204 irq = get_pci_irq_from_of(hose, slot, pin); \
205 if (irq > 0 && irq < 16) \
206 pci_write_config_byte(dev, reg, irq2pin[irq]); \
207 else \
208 printk(KERN_WARNING "ULI1575 device" \
209 "(slot %d, pin %d) irq %d is invalid.\n", \
210 slot, pin, irq); \
211 } while(0)
212
213 /* USB 1.1 OHCI controller 1, slot 28, pin 1 */
214 ULI1575_SET_DEV_IRQ(28, 1, 0x86);
215
216 /* USB 1.1 OHCI controller 2, slot 28, pin 2 */
217 ULI1575_SET_DEV_IRQ(28, 2, 0x87);
218
219 /* USB 1.1 OHCI controller 3, slot 28, pin 3 */
220 ULI1575_SET_DEV_IRQ(28, 3, 0x88);
221
222 /* USB 2.0 controller, slot 28, pin 4 */
223 irq = get_pci_irq_from_of(hose, 28, 4);
224 if (irq >= 0 && irq <= 15)
225 pci_write_config_dword(dev, 0x74, uli1575_irq_route_table[irq]);
226
227 /* Audio controller, slot 29, pin 1 */
228 ULI1575_SET_DEV_IRQ(29, 1, 0x8a);
229
230 /* Modem controller, slot 29, pin 2 */
231 ULI1575_SET_DEV_IRQ(29, 2, 0x8b);
232
233 /* HD audio controller, slot 29, pin 3 */
234 ULI1575_SET_DEV_IRQ(29, 3, 0x8c);
235
236 /* SMB interrupt: slot 30, pin 1 */
237 ULI1575_SET_DEV_IRQ(30, 1, 0x8e);
238
239 /* PMU ACPI SCI interrupt: slot 30, pin 2 */
240 ULI1575_SET_DEV_IRQ(30, 2, 0x8f);
241
242 /* Serial ATA interrupt: slot 31, pin 1 */
243 ULI1575_SET_DEV_IRQ(31, 1, 0x8d);
244
245 /* Primary PATA IDE IRQ: 14
246 * Secondary PATA IDE IRQ: 15
247 */
248 pci_write_config_byte(dev, 0x44, 0x30 | uli1575_irq_route_table[14]);
249 pci_write_config_byte(dev, 0x75, uli1575_irq_route_table[15]);
250
251 /* Set IRQ14 and IRQ15 to legacy IRQs */
252 pci_read_config_word(dev, 0x46, &temp);
253 temp |= 0xc000;
254 pci_write_config_word(dev, 0x46, temp);
255
256 /* Set i8259 interrupt trigger
257 * IRQ 3: Level
258 * IRQ 4: Level
259 * IRQ 5: Level
260 * IRQ 6: Level
261 * IRQ 7: Level
262 * IRQ 9: Level
263 * IRQ 10: Level
264 * IRQ 11: Level
265 * IRQ 12: Level
266 * IRQ 14: Edge
267 * IRQ 15: Edge
268 */
269 outb(0xfa, 0x4d0);
270 outb(0x1e, 0x4d1);
271
272#undef ULI1575_SET_DEV_IRQ
273}
274
275/* SATA */
276static void __devinit quirk_uli5288(struct pci_dev *dev)
277{
278 unsigned char c;
279
280 pci_read_config_byte(dev, 0x83, &c);
281 c |= 0x80; /* read/write lock */
282 pci_write_config_byte(dev, 0x83, c);
283
284 pci_write_config_byte(dev, 0x09, 0x01); /* Base class code: storage */
285 pci_write_config_byte(dev, 0x0a, 0x06); /* IDE disk */
286
287 pci_read_config_byte(dev, 0x83, &c);
288 c &= 0x7f;
289 pci_write_config_byte(dev, 0x83, c);
290
291 pci_read_config_byte(dev, 0x84, &c);
292 c |= 0x01; /* emulated PATA mode enabled */
293 pci_write_config_byte(dev, 0x84, c);
294}
295
296/* PATA */
297static void __devinit quirk_uli5229(struct pci_dev *dev)
298{
299 unsigned short temp;
300 pci_write_config_word(dev, 0x04, 0x0405); /* MEM IO MSI */
301 pci_read_config_word(dev, 0x4a, &temp);
302 temp |= 0x1000; /* Enable Native IRQ 14/15 */
303 pci_write_config_word(dev, 0x4a, temp);
304}
305
306/*Bridge*/
307static void __devinit early_uli5249(struct pci_dev *dev)
308{
309 unsigned char temp;
310 pci_write_config_word(dev, 0x04, 0x0007); /* mem access */
311 pci_read_config_byte(dev, 0x7c, &temp);
312 pci_write_config_byte(dev, 0x7c, 0x80); /* R/W lock control */
313 pci_write_config_byte(dev, 0x09, 0x01); /* set as pci-pci bridge */
314 pci_write_config_byte(dev, 0x7c, temp); /* restore pci bus debug control */
315 dev->class |= 0x1;
316}
317
318DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x1575, quirk_uli1575);
319DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5288, quirk_uli5288);
320DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, 0x5229, quirk_uli5229);
321DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AL, 0x5249, early_uli5249);
322#endif /* CONFIG_PCI */
99 323
100/* 324/*
101 * Setup the architecture 325 * Setup the architecture
102 */ 326 */
103static void __init mpc8544_ds_setup_arch(void) 327static void __init mpc8544_ds_setup_arch(void)
104{ 328{
329#ifdef CONFIG_PCI
330 struct device_node *np;
331#endif
332
105 if (ppc_md.progress) 333 if (ppc_md.progress)
106 ppc_md.progress("mpc8544_ds_setup_arch()", 0); 334 ppc_md.progress("mpc8544_ds_setup_arch()", 0);
107 335
336#ifdef CONFIG_PCI
337 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
338 struct resource rsrc;
339 of_address_to_resource(np, 0, &rsrc);
340 if ((rsrc.start & 0xfffff) == 0xb000)
341 fsl_add_bridge(np, 1);
342 else
343 fsl_add_bridge(np, 0);
344 }
345#endif
346
108 printk("MPC8544 DS board from Freescale Semiconductor\n"); 347 printk("MPC8544 DS board from Freescale Semiconductor\n");
109} 348}
110 349
111
112/* 350/*
113 * Called very early, device-tree isn't unflattened 351 * Called very early, device-tree isn't unflattened
114 */ 352 */
@@ -124,6 +362,7 @@ define_machine(mpc8544_ds) {
124 .probe = mpc8544_ds_probe, 362 .probe = mpc8544_ds_probe,
125 .setup_arch = mpc8544_ds_setup_arch, 363 .setup_arch = mpc8544_ds_setup_arch,
126 .init_IRQ = mpc8544_ds_pic_init, 364 .init_IRQ = mpc8544_ds_pic_init,
365 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
127 .get_irq = mpic_get_irq, 366 .get_irq = mpic_get_irq,
128 .restart = mpc85xx_restart, 367 .restart = mpc85xx_restart,
129 .calibrate_decr = generic_calibrate_decr, 368 .calibrate_decr = generic_calibrate_decr,
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index 7286ffac2c1d..5b34deef12b5 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -15,4 +15,3 @@
15 */ 15 */
16 16
17extern void mpc85xx_restart(char *); 17extern void mpc85xx_restart(char *);
18extern int mpc85xx_add_bridge(struct device_node *dev);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 7235f702394c..40a828675c7b 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -29,6 +29,7 @@
29#include <asm/udbg.h> 29#include <asm/udbg.h>
30 30
31#include <sysdev/fsl_soc.h> 31#include <sysdev/fsl_soc.h>
32#include <sysdev/fsl_pci.h>
32#include "mpc85xx.h" 33#include "mpc85xx.h"
33 34
34#ifdef CONFIG_CPM2 35#ifdef CONFIG_CPM2
@@ -217,7 +218,7 @@ static void __init mpc85xx_ads_setup_arch(void)
217 218
218#ifdef CONFIG_PCI 219#ifdef CONFIG_PCI
219 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) 220 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
220 mpc85xx_add_bridge(np); 221 fsl_add_bridge(np, 1);
221 ppc_md.pci_exclude_device = mpc85xx_exclude_device; 222 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
222#endif 223#endif
223} 224}
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 50c8d6458362..6a171e9abf7d 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -24,6 +24,7 @@
24#include <linux/seq_file.h> 24#include <linux/seq_file.h>
25#include <linux/initrd.h> 25#include <linux/initrd.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/interrupt.h>
27#include <linux/fsl_devices.h> 28#include <linux/fsl_devices.h>
28 29
29#include <asm/system.h> 30#include <asm/system.h>
@@ -45,6 +46,7 @@
45#include <asm/i8259.h> 46#include <asm/i8259.h>
46 47
47#include <sysdev/fsl_soc.h> 48#include <sysdev/fsl_soc.h>
49#include <sysdev/fsl_pci.h>
48#include "mpc85xx.h" 50#include "mpc85xx.h"
49 51
50static int cds_pci_slot = 2; 52static int cds_pci_slot = 2;
@@ -58,8 +60,6 @@ static volatile u8 *cadmus;
58static int mpc85xx_exclude_device(struct pci_controller *hose, 60static int mpc85xx_exclude_device(struct pci_controller *hose,
59 u_char bus, u_char devfn) 61 u_char bus, u_char devfn)
60{ 62{
61 if ((bus == hose->first_busno) && PCI_SLOT(devfn) == 0)
62 return PCIBIOS_DEVICE_NOT_FOUND;
63 /* We explicitly do not go past the Tundra 320 Bridge */ 63 /* We explicitly do not go past the Tundra 320 Bridge */
64 if ((bus == 1) && (PCI_SLOT(devfn) == ARCADIA_2ND_BRIDGE_IDSEL)) 64 if ((bus == 1) && (PCI_SLOT(devfn) == ARCADIA_2ND_BRIDGE_IDSEL))
65 return PCIBIOS_DEVICE_NOT_FOUND; 65 return PCIBIOS_DEVICE_NOT_FOUND;
@@ -69,6 +69,37 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
69 return PCIBIOS_SUCCESSFUL; 69 return PCIBIOS_SUCCESSFUL;
70} 70}
71 71
72static void mpc85xx_cds_restart(char *cmd)
73{
74 struct pci_dev *dev;
75 u_char tmp;
76
77 if ((dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686,
78 NULL))) {
79
80 /* Use the VIA Super Southbridge to force a PCI reset */
81 pci_read_config_byte(dev, 0x47, &tmp);
82 pci_write_config_byte(dev, 0x47, tmp | 1);
83
84 /* Flush the outbound PCI write queues */
85 pci_read_config_byte(dev, 0x47, &tmp);
86
87 /*
88 * At this point, the harware reset should have triggered.
89 * However, if it doesn't work for some mysterious reason,
90 * just fall through to the default reset below.
91 */
92
93 pci_dev_put(dev);
94 }
95
96 /*
97 * If we can't find the VIA chip (maybe the P2P bridge is disabled)
98 * or the VIA chip reset didn't work, just use the default reset.
99 */
100 mpc85xx_restart(NULL);
101}
102
72static void __init mpc85xx_cds_pci_irq_fixup(struct pci_dev *dev) 103static void __init mpc85xx_cds_pci_irq_fixup(struct pci_dev *dev)
73{ 104{
74 u_char c; 105 u_char c;
@@ -98,7 +129,7 @@ static void __init mpc85xx_cds_pci_irq_fixup(struct pci_dev *dev)
98 /* There are two USB controllers. 129 /* There are two USB controllers.
99 * Identify them by functon number 130 * Identify them by functon number
100 */ 131 */
101 if (PCI_FUNC(dev->devfn)) 132 if (PCI_FUNC(dev->devfn) == 3)
102 dev->irq = 11; 133 dev->irq = 11;
103 else 134 else
104 dev->irq = 10; 135 dev->irq = 10;
@@ -109,17 +140,41 @@ static void __init mpc85xx_cds_pci_irq_fixup(struct pci_dev *dev)
109 } 140 }
110} 141}
111 142
143static void __devinit skip_fake_bridge(struct pci_dev *dev)
144{
145 /* Make it an error to skip the fake bridge
146 * in pci_setup_device() in probe.c */
147 dev->hdr_type = 0x7f;
148}
149DECLARE_PCI_FIXUP_EARLY(0x1957, 0x3fff, skip_fake_bridge);
150DECLARE_PCI_FIXUP_EARLY(0x3fff, 0x1957, skip_fake_bridge);
151DECLARE_PCI_FIXUP_EARLY(0xff3f, 0x5719, skip_fake_bridge);
152
112#ifdef CONFIG_PPC_I8259 153#ifdef CONFIG_PPC_I8259
113#warning The i8259 PIC support is currently broken 154static void mpc85xx_8259_cascade_handler(unsigned int irq,
114static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc) 155 struct irq_desc *desc)
115{ 156{
116 unsigned int cascade_irq = i8259_irq(); 157 unsigned int cascade_irq = i8259_irq();
117 158
118 if (cascade_irq != NO_IRQ) 159 if (cascade_irq != NO_IRQ)
160 /* handle an interrupt from the 8259 */
119 generic_handle_irq(cascade_irq); 161 generic_handle_irq(cascade_irq);
120 162
121 desc->chip->eoi(irq); 163 /* check for any interrupts from the shared IRQ line */
164 handle_fasteoi_irq(irq, desc);
165}
166
167static irqreturn_t mpc85xx_8259_cascade_action(int irq, void *dev_id)
168{
169 return IRQ_HANDLED;
122} 170}
171
172static struct irqaction mpc85xxcds_8259_irqaction = {
173 .handler = mpc85xx_8259_cascade_action,
174 .flags = IRQF_SHARED,
175 .mask = CPU_MASK_NONE,
176 .name = "8259 cascade",
177};
123#endif /* PPC_I8259 */ 178#endif /* PPC_I8259 */
124#endif /* CONFIG_PCI */ 179#endif /* CONFIG_PCI */
125 180
@@ -128,10 +183,6 @@ static void __init mpc85xx_cds_pic_init(void)
128 struct mpic *mpic; 183 struct mpic *mpic;
129 struct resource r; 184 struct resource r;
130 struct device_node *np = NULL; 185 struct device_node *np = NULL;
131#ifdef CONFIG_PPC_I8259
132 struct device_node *cascade_node = NULL;
133 int cascade_irq;
134#endif
135 186
136 np = of_find_node_by_type(np, "open-pic"); 187 np = of_find_node_by_type(np, "open-pic");
137 188
@@ -155,8 +206,19 @@ static void __init mpc85xx_cds_pic_init(void)
155 of_node_put(np); 206 of_node_put(np);
156 207
157 mpic_init(mpic); 208 mpic_init(mpic);
209}
210
211#if defined(CONFIG_PPC_I8259) && defined(CONFIG_PCI)
212static int mpc85xx_cds_8259_attach(void)
213{
214 int ret;
215 struct device_node *np = NULL;
216 struct device_node *cascade_node = NULL;
217 int cascade_irq;
218
219 if (!machine_is(mpc85xx_cds))
220 return 0;
158 221
159#ifdef CONFIG_PPC_I8259
160 /* Initialize the i8259 controller */ 222 /* Initialize the i8259 controller */
161 for_each_node_by_type(np, "interrupt-controller") 223 for_each_node_by_type(np, "interrupt-controller")
162 if (of_device_is_compatible(np, "chrp,iic")) { 224 if (of_device_is_compatible(np, "chrp,iic")) {
@@ -166,22 +228,39 @@ static void __init mpc85xx_cds_pic_init(void)
166 228
167 if (cascade_node == NULL) { 229 if (cascade_node == NULL) {
168 printk(KERN_DEBUG "Could not find i8259 PIC\n"); 230 printk(KERN_DEBUG "Could not find i8259 PIC\n");
169 return; 231 return -ENODEV;
170 } 232 }
171 233
172 cascade_irq = irq_of_parse_and_map(cascade_node, 0); 234 cascade_irq = irq_of_parse_and_map(cascade_node, 0);
173 if (cascade_irq == NO_IRQ) { 235 if (cascade_irq == NO_IRQ) {
174 printk(KERN_ERR "Failed to map cascade interrupt\n"); 236 printk(KERN_ERR "Failed to map cascade interrupt\n");
175 return; 237 return -ENXIO;
176 } 238 }
177 239
178 i8259_init(cascade_node, 0); 240 i8259_init(cascade_node, 0);
179 of_node_put(cascade_node); 241 of_node_put(cascade_node);
180 242
181 set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade); 243 /*
182#endif /* CONFIG_PPC_I8259 */ 244 * Hook the interrupt to make sure desc->action is never NULL.
245 * This is required to ensure that the interrupt does not get
246 * disabled when the last user of the shared IRQ line frees their
247 * interrupt.
248 */
249 if ((ret = setup_irq(cascade_irq, &mpc85xxcds_8259_irqaction))) {
250 printk(KERN_ERR "Failed to setup cascade interrupt\n");
251 return ret;
252 }
253
254 /* Success. Connect our low-level cascade handler. */
255 set_irq_handler(cascade_irq, mpc85xx_8259_cascade_handler);
256
257 return 0;
183} 258}
184 259
260device_initcall(mpc85xx_cds_8259_attach);
261
262#endif /* CONFIG_PPC_I8259 */
263
185/* 264/*
186 * Setup the architecture 265 * Setup the architecture
187 */ 266 */
@@ -218,9 +297,14 @@ static void __init mpc85xx_cds_setup_arch(void)
218 } 297 }
219 298
220#ifdef CONFIG_PCI 299#ifdef CONFIG_PCI
221 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) 300 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
222 mpc85xx_add_bridge(np); 301 struct resource rsrc;
223 302 of_address_to_resource(np, 0, &rsrc);
303 if ((rsrc.start & 0xfffff) == 0x8000)
304 fsl_add_bridge(np, 1);
305 else
306 fsl_add_bridge(np, 0);
307 }
224 ppc_md.pci_irq_fixup = mpc85xx_cds_pci_irq_fixup; 308 ppc_md.pci_irq_fixup = mpc85xx_cds_pci_irq_fixup;
225 ppc_md.pci_exclude_device = mpc85xx_exclude_device; 309 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
226#endif 310#endif
@@ -265,7 +349,12 @@ define_machine(mpc85xx_cds) {
265 .init_IRQ = mpc85xx_cds_pic_init, 349 .init_IRQ = mpc85xx_cds_pic_init,
266 .show_cpuinfo = mpc85xx_cds_show_cpuinfo, 350 .show_cpuinfo = mpc85xx_cds_show_cpuinfo,
267 .get_irq = mpic_get_irq, 351 .get_irq = mpic_get_irq,
352#ifdef CONFIG_PCI
353 .restart = mpc85xx_cds_restart,
354#else
268 .restart = mpc85xx_restart, 355 .restart = mpc85xx_restart,
356#endif
269 .calibrate_decr = generic_calibrate_decr, 357 .calibrate_decr = generic_calibrate_decr,
270 .progress = udbg_progress, 358 .progress = udbg_progress,
359 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
271}; 360};
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 004b80bd0b84..e8003bf00c9a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -46,6 +46,7 @@
46#include <asm/prom.h> 46#include <asm/prom.h>
47#include <asm/udbg.h> 47#include <asm/udbg.h>
48#include <sysdev/fsl_soc.h> 48#include <sysdev/fsl_soc.h>
49#include <sysdev/fsl_pci.h>
49#include <asm/qe.h> 50#include <asm/qe.h>
50#include <asm/qe_ic.h> 51#include <asm/qe_ic.h>
51#include <asm/mpic.h> 52#include <asm/mpic.h>
@@ -94,9 +95,8 @@ static void __init mpc85xx_mds_setup_arch(void)
94 } 95 }
95 96
96#ifdef CONFIG_PCI 97#ifdef CONFIG_PCI
97 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) { 98 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
98 mpc85xx_add_bridge(np); 99 fsl_add_bridge(np, 1);
99 }
100 of_node_put(np); 100 of_node_put(np);
101#endif 101#endif
102 102
@@ -208,4 +208,5 @@ define_machine(mpc85xx_mds) {
208 .restart = mpc85xx_restart, 208 .restart = mpc85xx_restart,
209 .calibrate_decr = generic_calibrate_decr, 209 .calibrate_decr = generic_calibrate_decr,
210 .progress = udbg_progress, 210 .progress = udbg_progress,
211 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
211}; 212};
diff --git a/arch/powerpc/platforms/85xx/pci.c b/arch/powerpc/platforms/85xx/pci.c
deleted file mode 100644
index 8118417b7364..000000000000
--- a/arch/powerpc/platforms/85xx/pci.c
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 * FSL SoC setup code
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/errno.h>
16#include <linux/pci.h>
17#include <linux/delay.h>
18#include <linux/irq.h>
19#include <linux/module.h>
20
21#include <asm/system.h>
22#include <asm/atomic.h>
23#include <asm/io.h>
24#include <asm/pci-bridge.h>
25#include <asm/prom.h>
26#include <sysdev/fsl_soc.h>
27
28#undef DEBUG
29
30#ifdef DEBUG
31#define DBG(x...) printk(x)
32#else
33#define DBG(x...)
34#endif
35
36#ifdef CONFIG_PCI
37int __init mpc85xx_add_bridge(struct device_node *dev)
38{
39 int len;
40 struct pci_controller *hose;
41 struct resource rsrc;
42 const int *bus_range;
43 int primary = 1, has_address = 0;
44 phys_addr_t immr = get_immrbase();
45
46 DBG("Adding PCI host bridge %s\n", dev->full_name);
47
48 /* Fetch host bridge registers address */
49 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
50
51 /* Get bus range if any */
52 bus_range = of_get_property(dev, "bus-range", &len);
53 if (bus_range == NULL || len < 2 * sizeof(int)) {
54 printk(KERN_WARNING "Can't get bus-range for %s, assume"
55 " bus 0\n", dev->full_name);
56 }
57
58 pci_assign_all_buses = 1;
59 hose = pcibios_alloc_controller(dev);
60 if (!hose)
61 return -ENOMEM;
62
63 hose->first_busno = bus_range ? bus_range[0] : 0;
64 hose->last_busno = bus_range ? bus_range[1] : 0xff;
65
66 /* PCI 1 */
67 if ((rsrc.start & 0xfffff) == 0x8000) {
68 setup_indirect_pci(hose, immr + 0x8000, immr + 0x8004);
69 }
70 /* PCI 2 */
71 if ((rsrc.start & 0xfffff) == 0x9000) {
72 setup_indirect_pci(hose, immr + 0x9000, immr + 0x9004);
73 primary = 0;
74 }
75
76 printk(KERN_INFO "Found MPC85xx PCI host bridge at 0x%016llx. "
77 "Firmware bus number: %d->%d\n",
78 (unsigned long long)rsrc.start, hose->first_busno,
79 hose->last_busno);
80
81 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
82 hose, hose->cfg_addr, hose->cfg_data);
83
84 /* Interpret the "ranges" property */
85 /* This also maps the I/O region and sets isa_io/mem_base */
86 pci_process_bridge_OF_ranges(hose, dev, primary);
87
88 return 0;
89}
90
91#endif
diff --git a/arch/powerpc/platforms/86xx/Kconfig b/arch/powerpc/platforms/86xx/Kconfig
index 0faebfdc1596..343b76d0d793 100644
--- a/arch/powerpc/platforms/86xx/Kconfig
+++ b/arch/powerpc/platforms/86xx/Kconfig
@@ -14,8 +14,7 @@ endchoice
14 14
15config MPC8641 15config MPC8641
16 bool 16 bool
17 select PPC_INDIRECT_PCI 17 select FSL_PCI if PCI
18 select PPC_INDIRECT_PCI_BE
19 select PPC_UDBG_16550 18 select PPC_UDBG_16550
20 select MPIC 19 select MPIC
21 default y if MPC8641_HPCN 20 default y if MPC8641_HPCN
diff --git a/arch/powerpc/platforms/86xx/Makefile b/arch/powerpc/platforms/86xx/Makefile
index 418fd8f4d268..3376c7767f2d 100644
--- a/arch/powerpc/platforms/86xx/Makefile
+++ b/arch/powerpc/platforms/86xx/Makefile
@@ -4,4 +4,3 @@
4 4
5obj-$(CONFIG_SMP) += mpc86xx_smp.o 5obj-$(CONFIG_SMP) += mpc86xx_smp.o
6obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o 6obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o
7obj-$(CONFIG_PCI) += pci.o
diff --git a/arch/powerpc/platforms/86xx/mpc86xx.h b/arch/powerpc/platforms/86xx/mpc86xx.h
index 23f7ed2a7f88..525ffa1904f9 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx.h
+++ b/arch/powerpc/platforms/86xx/mpc86xx.h
@@ -15,11 +15,6 @@
15 * mpc86xx_* files. Mostly for use by mpc86xx_setup(). 15 * mpc86xx_* files. Mostly for use by mpc86xx_setup().
16 */ 16 */
17 17
18extern int mpc86xx_add_bridge(struct device_node *dev);
19
20extern int mpc86xx_exclude_device(struct pci_controller *hose,
21 u_char bus, u_char devfn);
22
23extern void __init mpc86xx_smp_init(void); 18extern void __init mpc86xx_smp_init(void);
24 19
25#endif /* __MPC86XX_H__ */ 20#endif /* __MPC86XX_H__ */
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 5b01ec7c13dc..e9eaa0749ae6 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -31,6 +31,7 @@
31 31
32#include <asm/mpic.h> 32#include <asm/mpic.h>
33 33
34#include <sysdev/fsl_pci.h>
34#include <sysdev/fsl_soc.h> 35#include <sysdev/fsl_soc.h>
35 36
36#include "mpc86xx.h" 37#include "mpc86xx.h"
@@ -344,8 +345,14 @@ mpc86xx_hpcn_setup_arch(void)
344 } 345 }
345 346
346#ifdef CONFIG_PCI 347#ifdef CONFIG_PCI
347 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) 348 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
348 mpc86xx_add_bridge(np); 349 struct resource rsrc;
350 of_address_to_resource(np, 0, &rsrc);
351 if ((rsrc.start & 0xfffff) == 0x8000)
352 fsl_add_bridge(np, 1);
353 else
354 fsl_add_bridge(np, 0);
355 }
349#endif 356#endif
350 357
351 printk("MPC86xx HPCN board from Freescale Semiconductor\n"); 358 printk("MPC86xx HPCN board from Freescale Semiconductor\n");
@@ -424,7 +431,6 @@ mpc86xx_time_init(void)
424 return 0; 431 return 0;
425} 432}
426 433
427
428define_machine(mpc86xx_hpcn) { 434define_machine(mpc86xx_hpcn) {
429 .name = "MPC86xx HPCN", 435 .name = "MPC86xx HPCN",
430 .probe = mpc86xx_hpcn_probe, 436 .probe = mpc86xx_hpcn_probe,
@@ -436,4 +442,5 @@ define_machine(mpc86xx_hpcn) {
436 .time_init = mpc86xx_time_init, 442 .time_init = mpc86xx_time_init,
437 .calibrate_decr = generic_calibrate_decr, 443 .calibrate_decr = generic_calibrate_decr,
438 .progress = udbg_progress, 444 .progress = udbg_progress,
445 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
439}; 446};
diff --git a/arch/powerpc/platforms/86xx/pci.c b/arch/powerpc/platforms/86xx/pci.c
deleted file mode 100644
index 73cd5b05a84e..000000000000
--- a/arch/powerpc/platforms/86xx/pci.c
+++ /dev/null
@@ -1,238 +0,0 @@
1/*
2 * MPC86XX pci setup code
3 *
4 * Recode: ZHANG WEI <wei.zhang@freescale.com>
5 * Initial author: Xianghua Xiao <x.xiao@freescale.com>
6 *
7 * Copyright 2006 Freescale Semiconductor Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14
15#include <linux/types.h>
16#include <linux/module.h>
17#include <linux/init.h>
18#include <linux/pci.h>
19#include <linux/serial.h>
20
21#include <asm/system.h>
22#include <asm/atomic.h>
23#include <asm/io.h>
24#include <asm/prom.h>
25#include <asm/pci-bridge.h>
26#include <sysdev/fsl_soc.h>
27#include <sysdev/fsl_pcie.h>
28
29#include "mpc86xx.h"
30
31#undef DEBUG
32
33#ifdef DEBUG
34#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
35#else
36#define DBG(fmt, args...)
37#endif
38
39struct pcie_outbound_window_regs {
40 uint pexotar; /* 0x.0 - PCI Express outbound translation address register */
41 uint pexotear; /* 0x.4 - PCI Express outbound translation extended address register */
42 uint pexowbar; /* 0x.8 - PCI Express outbound window base address register */
43 char res1[4];
44 uint pexowar; /* 0x.10 - PCI Express outbound window attributes register */
45 char res2[12];
46};
47
48struct pcie_inbound_window_regs {
49 uint pexitar; /* 0x.0 - PCI Express inbound translation address register */
50 char res1[4];
51 uint pexiwbar; /* 0x.8 - PCI Express inbound window base address register */
52 uint pexiwbear; /* 0x.c - PCI Express inbound window base extended address register */
53 uint pexiwar; /* 0x.10 - PCI Express inbound window attributes register */
54 char res2[12];
55};
56
57static void __init setup_pcie_atmu(struct pci_controller *hose, struct resource *rsrc)
58{
59 volatile struct ccsr_pex *pcie;
60 volatile struct pcie_outbound_window_regs *pcieow;
61 volatile struct pcie_inbound_window_regs *pcieiw;
62 int i = 0;
63
64 DBG("PCIE memory map start 0x%x, size 0x%x\n", rsrc->start,
65 rsrc->end - rsrc->start + 1);
66 pcie = ioremap(rsrc->start, rsrc->end - rsrc->start + 1);
67
68 /* Disable all windows (except pexowar0 since its ignored) */
69 pcie->pexowar1 = 0;
70 pcie->pexowar2 = 0;
71 pcie->pexowar3 = 0;
72 pcie->pexowar4 = 0;
73 pcie->pexiwar1 = 0;
74 pcie->pexiwar2 = 0;
75 pcie->pexiwar3 = 0;
76
77 pcieow = (struct pcie_outbound_window_regs *)&pcie->pexotar1;
78 pcieiw = (struct pcie_inbound_window_regs *)&pcie->pexitar1;
79
80 /* Setup outbound MEM window */
81 for(i = 0; i < 3; i++)
82 if (hose->mem_resources[i].flags & IORESOURCE_MEM){
83 DBG("PCIE MEM resource start 0x%08x, size 0x%08x.\n",
84 hose->mem_resources[i].start,
85 hose->mem_resources[i].end
86 - hose->mem_resources[i].start + 1);
87 pcieow->pexotar = (hose->mem_resources[i].start) >> 12
88 & 0x000fffff;
89 pcieow->pexotear = 0;
90 pcieow->pexowbar = (hose->mem_resources[i].start) >> 12
91 & 0x000fffff;
92 /* Enable, Mem R/W */
93 pcieow->pexowar = 0x80044000 |
94 (__ilog2(hose->mem_resources[i].end
95 - hose->mem_resources[i].start + 1)
96 - 1);
97 pcieow++;
98 }
99
100 /* Setup outbound IO window */
101 if (hose->io_resource.flags & IORESOURCE_IO){
102 DBG("PCIE IO resource start 0x%08x, size 0x%08x, phy base 0x%08x.\n",
103 hose->io_resource.start,
104 hose->io_resource.end - hose->io_resource.start + 1,
105 hose->io_base_phys);
106 pcieow->pexotar = (hose->io_resource.start) >> 12 & 0x000fffff;
107 pcieow->pexotear = 0;
108 pcieow->pexowbar = (hose->io_base_phys) >> 12 & 0x000fffff;
109 /* Enable, IO R/W */
110 pcieow->pexowar = 0x80088000 | (__ilog2(hose->io_resource.end
111 - hose->io_resource.start + 1) - 1);
112 }
113
114 /* Setup 2G inbound Memory Window @ 0 */
115 pcieiw->pexitar = 0x00000000;
116 pcieiw->pexiwbar = 0x00000000;
117 /* Enable, Prefetch, Local Mem, Snoop R/W, 2G */
118 pcieiw->pexiwar = 0xa0f5501e;
119}
120
121static void __init
122mpc86xx_setup_pcie(struct pci_controller *hose, u32 pcie_offset, u32 pcie_size)
123{
124 u16 cmd;
125
126 DBG("PCIE host controller register offset 0x%08x, size 0x%08x.\n",
127 pcie_offset, pcie_size);
128
129 early_read_config_word(hose, 0, 0, PCI_COMMAND, &cmd);
130 cmd |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY
131 | PCI_COMMAND_IO;
132 early_write_config_word(hose, 0, 0, PCI_COMMAND, cmd);
133
134 early_write_config_byte(hose, 0, 0, PCI_LATENCY_TIMER, 0x80);
135}
136
137static void __devinit quirk_fsl_pcie_transparent(struct pci_dev *dev)
138{
139 struct resource *res;
140 int i, res_idx = PCI_BRIDGE_RESOURCES;
141 struct pci_controller *hose;
142
143 /*
144 * Make the bridge be transparent.
145 */
146 dev->transparent = 1;
147
148 hose = pci_bus_to_host(dev->bus);
149 if (!hose) {
150 printk(KERN_ERR "Can't find hose for bus %d\n",
151 dev->bus->number);
152 return;
153 }
154
155 if (hose->io_resource.flags) {
156 res = &dev->resource[res_idx++];
157 res->start = hose->io_resource.start;
158 res->end = hose->io_resource.end;
159 res->flags = hose->io_resource.flags;
160 }
161
162 for (i = 0; i < 3; i++) {
163 res = &dev->resource[res_idx + i];
164 res->start = hose->mem_resources[i].start;
165 res->end = hose->mem_resources[i].end;
166 res->flags = hose->mem_resources[i].flags;
167 }
168}
169
170
171DECLARE_PCI_FIXUP_EARLY(0x1957, 0x7010, quirk_fsl_pcie_transparent);
172DECLARE_PCI_FIXUP_EARLY(0x1957, 0x7011, quirk_fsl_pcie_transparent);
173
174#define PCIE_LTSSM 0x404 /* PCIe Link Training and Status */
175#define PCIE_LTSSM_L0 0x16 /* L0 state */
176
177int __init mpc86xx_add_bridge(struct device_node *dev)
178{
179 int len;
180 struct pci_controller *hose;
181 struct resource rsrc;
182 const int *bus_range;
183 int has_address = 0;
184 int primary = 0;
185 u16 val;
186
187 DBG("Adding PCIE host bridge %s\n", dev->full_name);
188
189 /* Fetch host bridge registers address */
190 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
191
192 /* Get bus range if any */
193 bus_range = of_get_property(dev, "bus-range", &len);
194 if (bus_range == NULL || len < 2 * sizeof(int))
195 printk(KERN_WARNING "Can't get bus-range for %s, assume"
196 " bus 0\n", dev->full_name);
197
198 pci_assign_all_buses = 1;
199 hose = pcibios_alloc_controller(dev);
200 if (!hose)
201 return -ENOMEM;
202
203 hose->indirect_type = PPC_INDIRECT_TYPE_EXT_REG |
204 PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS;
205
206 hose->first_busno = bus_range ? bus_range[0] : 0x0;
207 hose->last_busno = bus_range ? bus_range[1] : 0xff;
208
209 setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4);
210
211 /* Probe the hose link training status */
212 early_read_config_word(hose, 0, 0, PCIE_LTSSM, &val);
213 if (val < PCIE_LTSSM_L0)
214 return -ENXIO;
215
216 /* Setup the PCIE host controller. */
217 mpc86xx_setup_pcie(hose, rsrc.start, rsrc.end - rsrc.start + 1);
218
219 if ((rsrc.start & 0xfffff) == 0x8000)
220 primary = 1;
221
222 printk(KERN_INFO "Found MPC86xx PCIE host bridge at 0x%08lx. "
223 "Firmware bus number: %d->%d\n",
224 (unsigned long) rsrc.start,
225 hose->first_busno, hose->last_busno);
226
227 DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
228 hose, hose->cfg_addr, hose->cfg_data);
229
230 /* Interpret the "ranges" property */
231 /* This also maps the I/O region and sets isa_io/mem_base */
232 pci_process_bridge_OF_ranges(hose, dev, primary);
233
234 /* Setup PEX window registers */
235 setup_pcie_atmu(hose, &rsrc);
236
237 return 0;
238}
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 6694f86d7000..9cb081c26e71 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -59,7 +59,8 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang)
59 INIT_LIST_HEAD(&ctx->aff_list); 59 INIT_LIST_HEAD(&ctx->aff_list);
60 if (gang) 60 if (gang)
61 spu_gang_add_ctx(gang, ctx); 61 spu_gang_add_ctx(gang, ctx);
62 ctx->cpus_allowed = current->cpus_allowed; 62
63 __spu_update_sched_info(ctx);
63 spu_set_timeslice(ctx); 64 spu_set_timeslice(ctx);
64 ctx->stats.util_state = SPU_UTIL_IDLE_LOADED; 65 ctx->stats.util_state = SPU_UTIL_IDLE_LOADED;
65 66
diff --git a/arch/powerpc/platforms/cell/spufs/run.c b/arch/powerpc/platforms/cell/spufs/run.c
index 0b50fa5cb39d..6abdd8fe2098 100644
--- a/arch/powerpc/platforms/cell/spufs/run.c
+++ b/arch/powerpc/platforms/cell/spufs/run.c
@@ -312,6 +312,7 @@ long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *event)
312 spu_acquire(ctx); 312 spu_acquire(ctx);
313 if (ctx->state == SPU_STATE_SAVED) { 313 if (ctx->state == SPU_STATE_SAVED) {
314 __spu_update_sched_info(ctx); 314 __spu_update_sched_info(ctx);
315 spu_set_timeslice(ctx);
315 316
316 ret = spu_activate(ctx, 0); 317 ret = spu_activate(ctx, 0);
317 if (ret) { 318 if (ret) {
@@ -322,6 +323,9 @@ long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *event)
322 /* 323 /*
323 * We have to update the scheduling priority under active_mutex 324 * We have to update the scheduling priority under active_mutex
324 * to protect against find_victim(). 325 * to protect against find_victim().
326 *
327 * No need to update the timeslice ASAP, it will get updated
328 * once the current one has expired.
325 */ 329 */
326 spu_update_sched_info(ctx); 330 spu_update_sched_info(ctx);
327 } 331 }
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 227968b4779d..758a80ac080a 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -927,10 +927,6 @@ int __init spu_sched_init(void)
927 INIT_LIST_HEAD(&spu_prio->runq[i]); 927 INIT_LIST_HEAD(&spu_prio->runq[i]);
928 __clear_bit(i, spu_prio->bitmap); 928 __clear_bit(i, spu_prio->bitmap);
929 } 929 }
930 for (i = 0; i < MAX_NUMNODES; i++) {
931 mutex_init(&cbe_spu_info[i].list_mutex);
932 INIT_LIST_HEAD(&cbe_spu_info[i].spus);
933 }
934 spin_lock_init(&spu_prio->runq_lock); 930 spin_lock_init(&spu_prio->runq_lock);
935 931
936 setup_timer(&spusched_timer, spusched_wake, 0); 932 setup_timer(&spusched_timer, spusched_wake, 0);
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index 8b20c0c1556f..2bfdeb8ea8bd 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -40,13 +40,10 @@ enum {
40struct spu_context_ops; 40struct spu_context_ops;
41struct spu_gang; 41struct spu_gang;
42 42
43enum {
44 SPU_SCHED_WAS_ACTIVE, /* was active upon spu_acquire_saved() */
45};
46
47/* ctx->sched_flags */ 43/* ctx->sched_flags */
48enum { 44enum {
49 SPU_SCHED_NOTIFY_ACTIVE, 45 SPU_SCHED_NOTIFY_ACTIVE,
46 SPU_SCHED_WAS_ACTIVE, /* was active upon spu_acquire_saved() */
50}; 47};
51 48
52struct spu_context { 49struct spu_context {
diff --git a/arch/powerpc/platforms/chrp/pci.c b/arch/powerpc/platforms/chrp/pci.c
index 3690624e49d4..28d1647b204e 100644
--- a/arch/powerpc/platforms/chrp/pci.c
+++ b/arch/powerpc/platforms/chrp/pci.c
@@ -181,7 +181,7 @@ setup_python(struct pci_controller *hose, struct device_node *dev)
181 } 181 }
182 iounmap(reg); 182 iounmap(reg);
183 183
184 setup_indirect_pci(hose, r.start + 0xf8000, r.start + 0xf8010); 184 setup_indirect_pci(hose, r.start + 0xf8000, r.start + 0xf8010, 0);
185} 185}
186 186
187/* Marvell Discovery II based Pegasos 2 */ 187/* Marvell Discovery II based Pegasos 2 */
@@ -277,13 +277,14 @@ chrp_find_bridges(void)
277 hose->cfg_data = p; 277 hose->cfg_data = p;
278 gg2_pci_config_base = p; 278 gg2_pci_config_base = p;
279 } else if (is_pegasos == 1) { 279 } else if (is_pegasos == 1) {
280 setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc); 280 setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc, 0);
281 } else if (is_pegasos == 2) { 281 } else if (is_pegasos == 2) {
282 setup_peg2(hose, dev); 282 setup_peg2(hose, dev);
283 } else if (!strncmp(model, "IBM,CPC710", 10)) { 283 } else if (!strncmp(model, "IBM,CPC710", 10)) {
284 setup_indirect_pci(hose, 284 setup_indirect_pci(hose,
285 r.start + 0x000f8000, 285 r.start + 0x000f8000,
286 r.start + 0x000f8010); 286 r.start + 0x000f8010,
287 0);
287 if (index == 0) { 288 if (index == 0) {
288 dma = of_get_property(dev, "system-dma-base", 289 dma = of_get_property(dev, "system-dma-base",
289 &len); 290 &len);
diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c b/arch/powerpc/platforms/embedded6xx/linkstation.c
index f4d0a7a603f5..bd5ca58345a1 100644
--- a/arch/powerpc/platforms/embedded6xx/linkstation.c
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -73,7 +73,7 @@ static int __init linkstation_add_bridge(struct device_node *dev)
73 return -ENOMEM; 73 return -ENOMEM;
74 hose->first_busno = bus_range ? bus_range[0] : 0; 74 hose->first_busno = bus_range ? bus_range[0] : 0;
75 hose->last_busno = bus_range ? bus_range[1] : 0xff; 75 hose->last_busno = bus_range ? bus_range[1] : 0xff;
76 setup_indirect_pci(hose, 0xfec00000, 0xfee00000); 76 setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
77 77
78 /* Interpret the "ranges" property */ 78 /* Interpret the "ranges" property */
79 /* This also maps the I/O region and sets isa_io/mem_base */ 79 /* This also maps the I/O region and sets isa_io/mem_base */
diff --git a/arch/powerpc/platforms/iseries/lpevents.c b/arch/powerpc/platforms/iseries/lpevents.c
index 91df52a1899a..34bdbbe3ce59 100644
--- a/arch/powerpc/platforms/iseries/lpevents.c
+++ b/arch/powerpc/platforms/iseries/lpevents.c
@@ -182,7 +182,7 @@ static int set_spread_lpevents(char *str)
182} 182}
183__setup("spread_lpevents=", set_spread_lpevents); 183__setup("spread_lpevents=", set_spread_lpevents);
184 184
185void setup_hvlpevent_queue(void) 185void __init setup_hvlpevent_queue(void)
186{ 186{
187 void *eventStack; 187 void *eventStack;
188 188
diff --git a/arch/powerpc/platforms/maple/pci.c b/arch/powerpc/platforms/maple/pci.c
index fceaae40fe70..2542403288f9 100644
--- a/arch/powerpc/platforms/maple/pci.c
+++ b/arch/powerpc/platforms/maple/pci.c
@@ -490,6 +490,9 @@ static int __init maple_add_bridge(struct device_node *dev)
490 /* Fixup "bus-range" OF property */ 490 /* Fixup "bus-range" OF property */
491 fixup_bus_range(dev); 491 fixup_bus_range(dev);
492 492
493 /* Check for legacy IOs */
494 isa_bridge_find_early(hose);
495
493 return 0; 496 return 0;
494} 497}
495 498
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 484eb4e0e9db..08ce31e612c2 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_PPC_PMI) += pmi.o
12obj-$(CONFIG_U3_DART) += dart_iommu.o 12obj-$(CONFIG_U3_DART) += dart_iommu.o
13obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o 13obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
14obj-$(CONFIG_FSL_SOC) += fsl_soc.o 14obj-$(CONFIG_FSL_SOC) += fsl_soc.o
15obj-$(CONFIG_FSL_PCI) += fsl_pci.o
15obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o 16obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o
16obj-$(CONFIG_QUICC_ENGINE) += qe_lib/ 17obj-$(CONFIG_QUICC_ENGINE) += qe_lib/
17mv64x60-$(CONFIG_PCI) += mv64x60_pci.o 18mv64x60-$(CONFIG_PCI) += mv64x60_pci.o
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
new file mode 100644
index 000000000000..9fb0ce5c7176
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -0,0 +1,257 @@
1/*
2 * MPC85xx/86xx PCI/PCIE support routing.
3 *
4 * Copyright 2007 Freescale Semiconductor, Inc
5 *
6 * Initial author: Xianghua Xiao <x.xiao@freescale.com>
7 * Recode: ZHANG WEI <wei.zhang@freescale.com>
8 * Rewrite the routing for Frescale PCI and PCI Express
9 * Roy Zang <tie-fei.zang@freescale.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 */
16#include <linux/kernel.h>
17#include <linux/pci.h>
18#include <linux/delay.h>
19#include <linux/string.h>
20#include <linux/init.h>
21#include <linux/bootmem.h>
22
23#include <asm/io.h>
24#include <asm/prom.h>
25#include <asm/pci-bridge.h>
26#include <asm/machdep.h>
27#include <sysdev/fsl_soc.h>
28#include <sysdev/fsl_pci.h>
29
30/* atmu setup for fsl pci/pcie controller */
31void __init setup_pci_atmu(struct pci_controller *hose, struct resource *rsrc)
32{
33 struct ccsr_pci __iomem *pci;
34 int i;
35
36 pr_debug("PCI memory map start 0x%x, size 0x%x\n", rsrc->start,
37 rsrc->end - rsrc->start + 1);
38 pci = ioremap(rsrc->start, rsrc->end - rsrc->start + 1);
39
40 /* Disable all windows (except powar0 since its ignored) */
41 for(i = 1; i < 5; i++)
42 out_be32(&pci->pow[i].powar, 0);
43 for(i = 0; i < 3; i++)
44 out_be32(&pci->piw[i].piwar, 0);
45
46 /* Setup outbound MEM window */
47 for(i = 0; i < 3; i++)
48 if (hose->mem_resources[i].flags & IORESOURCE_MEM){
49 pr_debug("PCI MEM resource start 0x%08x, size 0x%08x.\n",
50 hose->mem_resources[i].start,
51 hose->mem_resources[i].end
52 - hose->mem_resources[i].start + 1);
53 out_be32(&pci->pow[i+1].potar,
54 (hose->mem_resources[i].start >> 12)
55 & 0x000fffff);
56 out_be32(&pci->pow[i+1].potear, 0);
57 out_be32(&pci->pow[i+1].powbar,
58 (hose->mem_resources[i].start >> 12)
59 & 0x000fffff);
60 /* Enable, Mem R/W */
61 out_be32(&pci->pow[i+1].powar, 0x80044000
62 | (__ilog2(hose->mem_resources[i].end
63 - hose->mem_resources[i].start + 1) - 1));
64 }
65
66 /* Setup outbound IO window */
67 if (hose->io_resource.flags & IORESOURCE_IO){
68 pr_debug("PCI IO resource start 0x%08x, size 0x%08x, phy base 0x%08x.\n",
69 hose->io_resource.start,
70 hose->io_resource.end - hose->io_resource.start + 1,
71 hose->io_base_phys);
72 out_be32(&pci->pow[i+1].potar, (hose->io_resource.start >> 12)
73 & 0x000fffff);
74 out_be32(&pci->pow[i+1].potear, 0);
75 out_be32(&pci->pow[i+1].powbar, (hose->io_base_phys >> 12)
76 & 0x000fffff);
77 /* Enable, IO R/W */
78 out_be32(&pci->pow[i+1].powar, 0x80088000
79 | (__ilog2(hose->io_resource.end
80 - hose->io_resource.start + 1) - 1));
81 }
82
83 /* Setup 2G inbound Memory Window @ 1 */
84 out_be32(&pci->piw[2].pitar, 0x00000000);
85 out_be32(&pci->piw[2].piwbar,0x00000000);
86 out_be32(&pci->piw[2].piwar, PIWAR_2G);
87}
88
89void __init setup_pci_cmd(struct pci_controller *hose)
90{
91 u16 cmd;
92 int cap_x;
93
94 early_read_config_word(hose, 0, 0, PCI_COMMAND, &cmd);
95 cmd |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY
96 | PCI_COMMAND_IO;
97 early_write_config_word(hose, 0, 0, PCI_COMMAND, cmd);
98
99 cap_x = early_find_capability(hose, 0, 0, PCI_CAP_ID_PCIX);
100 if (cap_x) {
101 int pci_x_cmd = cap_x + PCI_X_CMD;
102 cmd = PCI_X_CMD_MAX_SPLIT | PCI_X_CMD_MAX_READ
103 | PCI_X_CMD_ERO | PCI_X_CMD_DPERR_E;
104 early_write_config_word(hose, 0, 0, pci_x_cmd, cmd);
105 } else {
106 early_write_config_byte(hose, 0, 0, PCI_LATENCY_TIMER, 0x80);
107 }
108}
109
110static void __init quirk_fsl_pcie_transparent(struct pci_dev *dev)
111{
112 struct resource *res;
113 int i, res_idx = PCI_BRIDGE_RESOURCES;
114 struct pci_controller *hose;
115
116 /* if we aren't a PCIe don't bother */
117 if (!pci_find_capability(dev, PCI_CAP_ID_EXP))
118 return ;
119
120 /*
121 * Make the bridge be transparent.
122 */
123 dev->transparent = 1;
124
125 hose = pci_bus_to_host(dev->bus);
126 if (!hose) {
127 printk(KERN_ERR "Can't find hose for bus %d\n",
128 dev->bus->number);
129 return;
130 }
131
132 /* Clear out any of the virtual P2P bridge registers */
133 pci_write_config_word(dev, PCI_IO_BASE_UPPER16, 0);
134 pci_write_config_word(dev, PCI_IO_LIMIT_UPPER16, 0);
135 pci_write_config_byte(dev, PCI_IO_BASE, 0x10);
136 pci_write_config_byte(dev, PCI_IO_LIMIT, 0);
137 pci_write_config_word(dev, PCI_MEMORY_BASE, 0x10);
138 pci_write_config_word(dev, PCI_MEMORY_LIMIT, 0);
139 pci_write_config_word(dev, PCI_PREF_BASE_UPPER32, 0x0);
140 pci_write_config_word(dev, PCI_PREF_LIMIT_UPPER32, 0x0);
141 pci_write_config_word(dev, PCI_PREF_MEMORY_BASE, 0x10);
142 pci_write_config_word(dev, PCI_PREF_MEMORY_LIMIT, 0);
143
144 if (hose->io_resource.flags) {
145 res = &dev->resource[res_idx++];
146 res->start = hose->io_resource.start;
147 res->end = hose->io_resource.end;
148 res->flags = hose->io_resource.flags;
149 update_bridge_resource(dev, res);
150 }
151
152 for (i = 0; i < 3; i++) {
153 res = &dev->resource[res_idx + i];
154 res->start = hose->mem_resources[i].start;
155 res->end = hose->mem_resources[i].end;
156 res->flags = hose->mem_resources[i].flags;
157 update_bridge_resource(dev, res);
158 }
159}
160
161int __init fsl_pcie_check_link(struct pci_controller *hose)
162{
163 u16 val;
164 early_read_config_word(hose, 0, 0, PCIE_LTSSM, &val);
165 if (val < PCIE_LTSSM_L0)
166 return 1;
167 return 0;
168}
169
170void fsl_pcibios_fixup_bus(struct pci_bus *bus)
171{
172 struct pci_controller *hose = (struct pci_controller *) bus->sysdata;
173 int i;
174
175 /* deal with bogus pci_bus when we don't have anything connected on PCIe */
176 if (hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK) {
177 if (bus->parent) {
178 for (i = 0; i < 4; ++i)
179 bus->resource[i] = bus->parent->resource[i];
180 }
181 }
182}
183
184int __init fsl_add_bridge(struct device_node *dev, int is_primary)
185{
186 int len;
187 struct pci_controller *hose;
188 struct resource rsrc;
189 const int *bus_range;
190
191 pr_debug("Adding PCI host bridge %s\n", dev->full_name);
192
193 /* Fetch host bridge registers address */
194 if (of_address_to_resource(dev, 0, &rsrc)) {
195 printk(KERN_WARNING "Can't get pci register base!");
196 return -ENOMEM;
197 }
198
199 /* Get bus range if any */
200 bus_range = of_get_property(dev, "bus-range", &len);
201 if (bus_range == NULL || len < 2 * sizeof(int))
202 printk(KERN_WARNING "Can't get bus-range for %s, assume"
203 " bus 0\n", dev->full_name);
204
205 pci_assign_all_buses = 1;
206 hose = pcibios_alloc_controller(dev);
207 if (!hose)
208 return -ENOMEM;
209
210 hose->first_busno = bus_range ? bus_range[0] : 0x0;
211 hose->last_busno = bus_range ? bus_range[1] : 0xff;
212
213 setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
214 PPC_INDIRECT_TYPE_BIG_ENDIAN);
215 setup_pci_cmd(hose);
216
217 /* check PCI express link status */
218 if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
219 hose->indirect_type |= PPC_INDIRECT_TYPE_EXT_REG |
220 PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS;
221 if (fsl_pcie_check_link(hose))
222 hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
223 }
224
225 printk(KERN_INFO "Found FSL PCI host bridge at 0x%016llx."
226 "Firmware bus number: %d->%d\n",
227 (unsigned long long)rsrc.start, hose->first_busno,
228 hose->last_busno);
229
230 pr_debug(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
231 hose, hose->cfg_addr, hose->cfg_data);
232
233 /* Interpret the "ranges" property */
234 /* This also maps the I/O region and sets isa_io/mem_base */
235 pci_process_bridge_OF_ranges(hose, dev, is_primary);
236
237 /* Setup PEX window registers */
238 setup_pci_atmu(hose, &rsrc);
239
240 return 0;
241}
242
243DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8548E, quirk_fsl_pcie_transparent);
244DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8548, quirk_fsl_pcie_transparent);
245DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8543E, quirk_fsl_pcie_transparent);
246DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8543, quirk_fsl_pcie_transparent);
247DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8547E, quirk_fsl_pcie_transparent);
248DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8545E, quirk_fsl_pcie_transparent);
249DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8545, quirk_fsl_pcie_transparent);
250DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8568E, quirk_fsl_pcie_transparent);
251DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8568, quirk_fsl_pcie_transparent);
252DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8567E, quirk_fsl_pcie_transparent);
253DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8567, quirk_fsl_pcie_transparent);
254DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8544E, quirk_fsl_pcie_transparent);
255DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8544, quirk_fsl_pcie_transparent);
256DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8641, quirk_fsl_pcie_transparent);
257DECLARE_PCI_FIXUP_EARLY(0x1957, PCI_DEVICE_ID_MPC8641D, quirk_fsl_pcie_transparent);
diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h
new file mode 100644
index 000000000000..37b04ad26571
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_pci.h
@@ -0,0 +1,88 @@
1/*
2 * MPC85xx/86xx PCI Express structure define
3 *
4 * Copyright 2007 Freescale Semiconductor, Inc
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifdef __KERNEL__
14#ifndef __POWERPC_FSL_PCI_H
15#define __POWERPC_FSL_PCI_H
16
17#define PCIE_LTSSM 0x0404 /* PCIE Link Training and Status */
18#define PCIE_LTSSM_L0 0x16 /* L0 state */
19#define PIWAR_2G 0xa0f5501e /* Enable, Prefetch, Local Mem, Snoop R/W, 2G */
20
21/* PCI/PCI Express outbound window reg */
22struct pci_outbound_window_regs {
23 __be32 potar; /* 0x.0 - Outbound translation address register */
24 __be32 potear; /* 0x.4 - Outbound translation extended address register */
25 __be32 powbar; /* 0x.8 - Outbound window base address register */
26 u8 res1[4];
27 __be32 powar; /* 0x.10 - Outbound window attributes register */
28 u8 res2[12];
29};
30
31/* PCI/PCI Express inbound window reg */
32struct pci_inbound_window_regs {
33 __be32 pitar; /* 0x.0 - Inbound translation address register */
34 u8 res1[4];
35 __be32 piwbar; /* 0x.8 - Inbound window base address register */
36 __be32 piwbear; /* 0x.c - Inbound window base extended address register */
37 __be32 piwar; /* 0x.10 - Inbound window attributes register */
38 u8 res2[12];
39};
40
41/* PCI/PCI Express IO block registers for 85xx/86xx */
42struct ccsr_pci {
43 __be32 config_addr; /* 0x.000 - PCI/PCIE Configuration Address Register */
44 __be32 config_data; /* 0x.004 - PCI/PCIE Configuration Data Register */
45 __be32 int_ack; /* 0x.008 - PCI Interrupt Acknowledge Register */
46 __be32 pex_otb_cpl_tor; /* 0x.00c - PCIE Outbound completion timeout register */
47 __be32 pex_conf_tor; /* 0x.010 - PCIE configuration timeout register */
48 u8 res2[12];
49 __be32 pex_pme_mes_dr; /* 0x.020 - PCIE PME and message detect register */
50 __be32 pex_pme_mes_disr; /* 0x.024 - PCIE PME and message disable register */
51 __be32 pex_pme_mes_ier; /* 0x.028 - PCIE PME and message interrupt enable register */
52 __be32 pex_pmcr; /* 0x.02c - PCIE power management command register */
53 u8 res3[3024];
54
55/* PCI/PCI Express outbound window 0-4
56 * Window 0 is the default window and is the only window enabled upon reset.
57 * The default outbound register set is used when a transaction misses
58 * in all of the other outbound windows.
59 */
60 struct pci_outbound_window_regs pow[5];
61
62 u8 res14[256];
63
64/* PCI/PCI Express inbound window 3-1
65 * inbound window 1 supports only a 32-bit base address and does not
66 * define an inbound window base extended address register.
67 */
68 struct pci_inbound_window_regs piw[3];
69
70 __be32 pex_err_dr; /* 0x.e00 - PCI/PCIE error detect register */
71 u8 res21[4];
72 __be32 pex_err_en; /* 0x.e08 - PCI/PCIE error interrupt enable register */
73 u8 res22[4];
74 __be32 pex_err_disr; /* 0x.e10 - PCI/PCIE error disable register */
75 u8 res23[12];
76 __be32 pex_err_cap_stat; /* 0x.e20 - PCI/PCIE error capture status register */
77 u8 res24[4];
78 __be32 pex_err_cap_r0; /* 0x.e28 - PCIE error capture register 0 */
79 __be32 pex_err_cap_r1; /* 0x.e2c - PCIE error capture register 0 */
80 __be32 pex_err_cap_r2; /* 0x.e30 - PCIE error capture register 0 */
81 __be32 pex_err_cap_r3; /* 0x.e34 - PCIE error capture register 0 */
82};
83
84extern int fsl_add_bridge(struct device_node *dev, int is_primary);
85extern void fsl_pcibios_fixup_bus(struct pci_bus *bus);
86
87#endif /* __POWERPC_FSL_PCI_H */
88#endif /* __KERNEL__ */
diff --git a/arch/powerpc/sysdev/fsl_pcie.h b/arch/powerpc/sysdev/fsl_pcie.h
deleted file mode 100644
index 8d9779c84bea..000000000000
--- a/arch/powerpc/sysdev/fsl_pcie.h
+++ /dev/null
@@ -1,94 +0,0 @@
1/*
2 * MPC85xx/86xx PCI Express structure define
3 *
4 * Copyright 2007 Freescale Semiconductor, Inc
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifdef __KERNEL__
14#ifndef __POWERPC_FSL_PCIE_H
15#define __POWERPC_FSL_PCIE_H
16
17/* PCIE Express IO block registers in 85xx/86xx */
18
19struct ccsr_pex {
20 __be32 __iomem pex_config_addr; /* 0x.000 - PCI Express Configuration Address Register */
21 __be32 __iomem pex_config_data; /* 0x.004 - PCI Express Configuration Data Register */
22 u8 __iomem res1[4];
23 __be32 __iomem pex_otb_cpl_tor; /* 0x.00c - PCI Express Outbound completion timeout register */
24 __be32 __iomem pex_conf_tor; /* 0x.010 - PCI Express configuration timeout register */
25 u8 __iomem res2[12];
26 __be32 __iomem pex_pme_mes_dr; /* 0x.020 - PCI Express PME and message detect register */
27 __be32 __iomem pex_pme_mes_disr; /* 0x.024 - PCI Express PME and message disable register */
28 __be32 __iomem pex_pme_mes_ier; /* 0x.028 - PCI Express PME and message interrupt enable register */
29 __be32 __iomem pex_pmcr; /* 0x.02c - PCI Express power management command register */
30 u8 __iomem res3[3024];
31 __be32 __iomem pexotar0; /* 0x.c00 - PCI Express outbound translation address register 0 */
32 __be32 __iomem pexotear0; /* 0x.c04 - PCI Express outbound translation extended address register 0*/
33 u8 __iomem res4[8];
34 __be32 __iomem pexowar0; /* 0x.c10 - PCI Express outbound window attributes register 0*/
35 u8 __iomem res5[12];
36 __be32 __iomem pexotar1; /* 0x.c20 - PCI Express outbound translation address register 1 */
37 __be32 __iomem pexotear1; /* 0x.c24 - PCI Express outbound translation extended address register 1*/
38 __be32 __iomem pexowbar1; /* 0x.c28 - PCI Express outbound window base address register 1*/
39 u8 __iomem res6[4];
40 __be32 __iomem pexowar1; /* 0x.c30 - PCI Express outbound window attributes register 1*/
41 u8 __iomem res7[12];
42 __be32 __iomem pexotar2; /* 0x.c40 - PCI Express outbound translation address register 2 */
43 __be32 __iomem pexotear2; /* 0x.c44 - PCI Express outbound translation extended address register 2*/
44 __be32 __iomem pexowbar2; /* 0x.c48 - PCI Express outbound window base address register 2*/
45 u8 __iomem res8[4];
46 __be32 __iomem pexowar2; /* 0x.c50 - PCI Express outbound window attributes register 2*/
47 u8 __iomem res9[12];
48 __be32 __iomem pexotar3; /* 0x.c60 - PCI Express outbound translation address register 3 */
49 __be32 __iomem pexotear3; /* 0x.c64 - PCI Express outbound translation extended address register 3*/
50 __be32 __iomem pexowbar3; /* 0x.c68 - PCI Express outbound window base address register 3*/
51 u8 __iomem res10[4];
52 __be32 __iomem pexowar3; /* 0x.c70 - PCI Express outbound window attributes register 3*/
53 u8 __iomem res11[12];
54 __be32 __iomem pexotar4; /* 0x.c80 - PCI Express outbound translation address register 4 */
55 __be32 __iomem pexotear4; /* 0x.c84 - PCI Express outbound translation extended address register 4*/
56 __be32 __iomem pexowbar4; /* 0x.c88 - PCI Express outbound window base address register 4*/
57 u8 __iomem res12[4];
58 __be32 __iomem pexowar4; /* 0x.c90 - PCI Express outbound window attributes register 4*/
59 u8 __iomem res13[12];
60 u8 __iomem res14[256];
61 __be32 __iomem pexitar3; /* 0x.da0 - PCI Express inbound translation address register 3 */
62 u8 __iomem res15[4];
63 __be32 __iomem pexiwbar3; /* 0x.da8 - PCI Express inbound window base address register 3 */
64 __be32 __iomem pexiwbear3; /* 0x.dac - PCI Express inbound window base extended address register 3 */
65 __be32 __iomem pexiwar3; /* 0x.db0 - PCI Express inbound window attributes register 3 */
66 u8 __iomem res16[12];
67 __be32 __iomem pexitar2; /* 0x.dc0 - PCI Express inbound translation address register 2 */
68 u8 __iomem res17[4];
69 __be32 __iomem pexiwbar2; /* 0x.dc8 - PCI Express inbound window base address register 2 */
70 __be32 __iomem pexiwbear2; /* 0x.dcc - PCI Express inbound window base extended address register 2 */
71 __be32 __iomem pexiwar2; /* 0x.dd0 - PCI Express inbound window attributes register 2 */
72 u8 __iomem res18[12];
73 __be32 __iomem pexitar1; /* 0x.de0 - PCI Express inbound translation address register 2 */
74 u8 __iomem res19[4];
75 __be32 __iomem pexiwbar1; /* 0x.de8 - PCI Express inbound window base address register 2 */
76 __be32 __iomem pexiwbear1; /* 0x.dec - PCI Express inbound window base extended address register 2 */
77 __be32 __iomem pexiwar1; /* 0x.df0 - PCI Express inbound window attributes register 2 */
78 u8 __iomem res20[12];
79 __be32 __iomem pex_err_dr; /* 0x.e00 - PCI Express error detect register */
80 u8 __iomem res21[4];
81 __be32 __iomem pex_err_en; /* 0x.e08 - PCI Express error interrupt enable register */
82 u8 __iomem res22[4];
83 __be32 __iomem pex_err_disr; /* 0x.e10 - PCI Express error disable register */
84 u8 __iomem res23[12];
85 __be32 __iomem pex_err_cap_stat; /* 0x.e20 - PCI Express error capture status register */
86 u8 __iomem res24[4];
87 __be32 __iomem pex_err_cap_r0; /* 0x.e28 - PCI Express error capture register 0 */
88 __be32 __iomem pex_err_cap_r1; /* 0x.e2c - PCI Express error capture register 0 */
89 __be32 __iomem pex_err_cap_r2; /* 0x.e30 - PCI Express error capture register 0 */
90 __be32 __iomem pex_err_cap_r3; /* 0x.e34 - PCI Express error capture register 0 */
91};
92
93#endif /* __POWERPC_FSL_PCIE_H */
94#endif /* __KERNEL__ */
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 3289fab01e92..727453d3e8b9 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -305,6 +305,64 @@ err:
305 305
306arch_initcall(gfar_of_init); 306arch_initcall(gfar_of_init);
307 307
308#ifdef CONFIG_I2C_BOARDINFO
309#include <linux/i2c.h>
310struct i2c_driver_device {
311 char *of_device;
312 char *i2c_driver;
313 char *i2c_type;
314};
315
316static struct i2c_driver_device i2c_devices[] __initdata = {
317 {"ricoh,rs5c372a", "rtc-rs5c372", "rs5c372a",},
318 {"ricoh,rs5c372b", "rtc-rs5c372", "rs5c372b",},
319 {"ricoh,rv5c386", "rtc-rs5c372", "rv5c386",},
320 {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",},
321};
322
323static int __init of_find_i2c_driver(struct device_node *node, struct i2c_board_info *info)
324{
325 int i;
326
327 for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
328 if (!of_device_is_compatible(node, i2c_devices[i].of_device))
329 continue;
330 strncpy(info->driver_name, i2c_devices[i].i2c_driver, KOBJ_NAME_LEN);
331 strncpy(info->type, i2c_devices[i].i2c_type, I2C_NAME_SIZE);
332 return 0;
333 }
334 return -ENODEV;
335}
336
337static void __init of_register_i2c_devices(struct device_node *adap_node, int bus_num)
338{
339 struct device_node *node = NULL;
340
341 while ((node = of_get_next_child(adap_node, node))) {
342 struct i2c_board_info info;
343 const u32 *addr;
344 int len;
345
346 addr = of_get_property(node, "reg", &len);
347 if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
348 printk(KERN_WARNING "fsl_ioc.c: invalid i2c device entry\n");
349 continue;
350 }
351
352 info.irq = irq_of_parse_and_map(node, 0);
353 if (info.irq == NO_IRQ)
354 info.irq = -1;
355
356 if (of_find_i2c_driver(node, &info) < 0)
357 continue;
358
359 info.platform_data = NULL;
360 info.addr = *addr;
361
362 i2c_register_board_info(bus_num, &info, 1);
363 }
364}
365
308static int __init fsl_i2c_of_init(void) 366static int __init fsl_i2c_of_init(void)
309{ 367{
310 struct device_node *np; 368 struct device_node *np;
@@ -349,6 +407,8 @@ static int __init fsl_i2c_of_init(void)
349 fsl_i2c_platform_data)); 407 fsl_i2c_platform_data));
350 if (ret) 408 if (ret)
351 goto unreg; 409 goto unreg;
410
411 of_register_i2c_devices(np, i);
352 } 412 }
353 413
354 return 0; 414 return 0;
@@ -360,6 +420,7 @@ err:
360} 420}
361 421
362arch_initcall(fsl_i2c_of_init); 422arch_initcall(fsl_i2c_of_init);
423#endif
363 424
364#ifdef CONFIG_PPC_83xx 425#ifdef CONFIG_PPC_83xx
365static int __init mpc83xx_wdt_init(void) 426static int __init mpc83xx_wdt_init(void)
diff --git a/arch/powerpc/sysdev/grackle.c b/arch/powerpc/sysdev/grackle.c
index 42053625f498..11ad5622eb76 100644
--- a/arch/powerpc/sysdev/grackle.c
+++ b/arch/powerpc/sysdev/grackle.c
@@ -55,7 +55,7 @@ static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable)
55 55
56void __init setup_grackle(struct pci_controller *hose) 56void __init setup_grackle(struct pci_controller *hose)
57{ 57{
58 setup_indirect_pci(hose, 0xfec00000, 0xfee00000); 58 setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
59 if (machine_is_compatible("PowerMac1,1")) 59 if (machine_is_compatible("PowerMac1,1"))
60 pci_assign_all_buses = 1; 60 pci_assign_all_buses = 1;
61 if (machine_is_compatible("AAPL,PowerBook1998")) 61 if (machine_is_compatible("AAPL,PowerBook1998"))
diff --git a/arch/powerpc/sysdev/indirect_pci.c b/arch/powerpc/sysdev/indirect_pci.c
index c7e6e859b393..5294560c7b00 100644
--- a/arch/powerpc/sysdev/indirect_pci.c
+++ b/arch/powerpc/sysdev/indirect_pci.c
@@ -20,12 +20,6 @@
20#include <asm/pci-bridge.h> 20#include <asm/pci-bridge.h>
21#include <asm/machdep.h> 21#include <asm/machdep.h>
22 22
23#ifdef CONFIG_PPC_INDIRECT_PCI_BE
24#define PCI_CFG_OUT out_be32
25#else
26#define PCI_CFG_OUT out_le32
27#endif
28
29static int 23static int
30indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset, 24indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
31 int len, u32 *val) 25 int len, u32 *val)
@@ -35,10 +29,17 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
35 u8 cfg_type = 0; 29 u8 cfg_type = 0;
36 u32 bus_no, reg; 30 u32 bus_no, reg;
37 31
32 if (hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK) {
33 if (bus->number != hose->first_busno)
34 return PCIBIOS_DEVICE_NOT_FOUND;
35 if (devfn != 0)
36 return PCIBIOS_DEVICE_NOT_FOUND;
37 }
38
38 if (ppc_md.pci_exclude_device) 39 if (ppc_md.pci_exclude_device)
39 if (ppc_md.pci_exclude_device(hose, bus->number, devfn)) 40 if (ppc_md.pci_exclude_device(hose, bus->number, devfn))
40 return PCIBIOS_DEVICE_NOT_FOUND; 41 return PCIBIOS_DEVICE_NOT_FOUND;
41 42
42 if (hose->indirect_type & PPC_INDIRECT_TYPE_SET_CFG_TYPE) 43 if (hose->indirect_type & PPC_INDIRECT_TYPE_SET_CFG_TYPE)
43 if (bus->number != hose->first_busno) 44 if (bus->number != hose->first_busno)
44 cfg_type = 1; 45 cfg_type = 1;
@@ -51,9 +52,12 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
51 else 52 else
52 reg = offset & 0xfc; 53 reg = offset & 0xfc;
53 54
54 PCI_CFG_OUT(hose->cfg_addr, 55 if (hose->indirect_type & PPC_INDIRECT_TYPE_BIG_ENDIAN)
55 (0x80000000 | (bus_no << 16) 56 out_be32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
56 | (devfn << 8) | reg | cfg_type)); 57 (devfn << 8) | reg | cfg_type));
58 else
59 out_le32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
60 (devfn << 8) | reg | cfg_type));
57 61
58 /* 62 /*
59 * Note: the caller has already checked that offset is 63 * Note: the caller has already checked that offset is
@@ -83,6 +87,13 @@ indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
83 u8 cfg_type = 0; 87 u8 cfg_type = 0;
84 u32 bus_no, reg; 88 u32 bus_no, reg;
85 89
90 if (hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK) {
91 if (bus->number != hose->first_busno)
92 return PCIBIOS_DEVICE_NOT_FOUND;
93 if (devfn != 0)
94 return PCIBIOS_DEVICE_NOT_FOUND;
95 }
96
86 if (ppc_md.pci_exclude_device) 97 if (ppc_md.pci_exclude_device)
87 if (ppc_md.pci_exclude_device(hose, bus->number, devfn)) 98 if (ppc_md.pci_exclude_device(hose, bus->number, devfn))
88 return PCIBIOS_DEVICE_NOT_FOUND; 99 return PCIBIOS_DEVICE_NOT_FOUND;
@@ -99,9 +110,12 @@ indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
99 else 110 else
100 reg = offset & 0xfc; 111 reg = offset & 0xfc;
101 112
102 PCI_CFG_OUT(hose->cfg_addr, 113 if (hose->indirect_type & PPC_INDIRECT_TYPE_BIG_ENDIAN)
103 (0x80000000 | (bus_no << 16) 114 out_be32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
104 | (devfn << 8) | reg | cfg_type)); 115 (devfn << 8) | reg | cfg_type));
116 else
117 out_le32(hose->cfg_addr, (0x80000000 | (bus_no << 16) |
118 (devfn << 8) | reg | cfg_type));
105 119
106 /* surpress setting of PCI_PRIMARY_BUS */ 120 /* surpress setting of PCI_PRIMARY_BUS */
107 if (hose->indirect_type & PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS) 121 if (hose->indirect_type & PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS)
@@ -135,24 +149,16 @@ static struct pci_ops indirect_pci_ops =
135}; 149};
136 150
137void __init 151void __init
138setup_indirect_pci_nomap(struct pci_controller* hose, void __iomem * cfg_addr, 152setup_indirect_pci(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data, u32 flags)
139 void __iomem * cfg_data)
140{
141 hose->cfg_addr = cfg_addr;
142 hose->cfg_data = cfg_data;
143 hose->ops = &indirect_pci_ops;
144}
145
146void __init
147setup_indirect_pci(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data)
148{ 153{
149 unsigned long base = cfg_addr & PAGE_MASK; 154 unsigned long base = cfg_addr & PAGE_MASK;
150 void __iomem *mbase, *addr, *data; 155 void __iomem *mbase;
151 156
152 mbase = ioremap(base, PAGE_SIZE); 157 mbase = ioremap(base, PAGE_SIZE);
153 addr = mbase + (cfg_addr & ~PAGE_MASK); 158 hose->cfg_addr = mbase + (cfg_addr & ~PAGE_MASK);
154 if ((cfg_data & PAGE_MASK) != base) 159 if ((cfg_data & PAGE_MASK) != base)
155 mbase = ioremap(cfg_data & PAGE_MASK, PAGE_SIZE); 160 mbase = ioremap(cfg_data & PAGE_MASK, PAGE_SIZE);
156 data = mbase + (cfg_data & ~PAGE_MASK); 161 hose->cfg_data = mbase + (cfg_data & ~PAGE_MASK);
157 setup_indirect_pci_nomap(hose, addr, data); 162 hose->ops = &indirect_pci_ops;
163 hose->indirect_type = flags;
158} 164}
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c
index b618fa60aef3..548a32082e4a 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -390,6 +390,61 @@ error:
390 return err; 390 return err;
391} 391}
392 392
393/*
394 * Create mv64x60_wdt platform devices
395 */
396static int __init mv64x60_wdt_device_setup(struct device_node *np, int id)
397{
398 struct resource r;
399 struct platform_device *pdev;
400 struct mv64x60_wdt_pdata pdata;
401 const unsigned int *prop;
402 int err;
403
404 err = of_address_to_resource(np, 0, &r);
405 if (err)
406 return err;
407
408 memset(&pdata, 0, sizeof(pdata));
409
410 prop = of_get_property(np, "timeout", NULL);
411 if (!prop)
412 return -ENODEV;
413 pdata.timeout = *prop;
414
415 np = of_get_parent(np);
416 if (!np)
417 return -ENODEV;
418
419 prop = of_get_property(np, "clock-frequency", NULL);
420 of_node_put(np);
421 if (!prop)
422 return -ENODEV;
423 pdata.bus_clk = *prop / 1000000; /* wdt driver wants freq in MHz */
424
425 pdev = platform_device_alloc(MV64x60_WDT_NAME, id);
426 if (!pdev)
427 return -ENOMEM;
428
429 err = platform_device_add_resources(pdev, &r, 1);
430 if (err)
431 goto error;
432
433 err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
434 if (err)
435 goto error;
436
437 err = platform_device_add(pdev);
438 if (err)
439 goto error;
440
441 return 0;
442
443error:
444 platform_device_put(pdev);
445 return err;
446}
447
393static int __init mv64x60_device_setup(void) 448static int __init mv64x60_device_setup(void)
394{ 449{
395 struct device_node *np = NULL; 450 struct device_node *np = NULL;
@@ -414,6 +469,15 @@ static int __init mv64x60_device_setup(void)
414 if ((err = mv64x60_i2c_device_setup(np, id))) 469 if ((err = mv64x60_i2c_device_setup(np, id)))
415 goto error; 470 goto error;
416 471
472 /* support up to one watchdog timer */
473 np = of_find_compatible_node(np, NULL, "marvell,mv64x60-wdt");
474 if (np) {
475 if ((err = mv64x60_wdt_device_setup(np, id)))
476 goto error;
477 of_node_put(np);
478 }
479
480
417 return 0; 481 return 0;
418 482
419error: 483error:
diff --git a/arch/powerpc/sysdev/mv64x60_pci.c b/arch/powerpc/sysdev/mv64x60_pci.c
index 45db86c2363c..9b3baa7317d7 100644
--- a/arch/powerpc/sysdev/mv64x60_pci.c
+++ b/arch/powerpc/sysdev/mv64x60_pci.c
@@ -144,7 +144,7 @@ static int __init mv64x60_add_bridge(struct device_node *dev)
144 hose->first_busno = bus_range ? bus_range[0] : 0; 144 hose->first_busno = bus_range ? bus_range[0] : 0;
145 hose->last_busno = bus_range ? bus_range[1] : 0xff; 145 hose->last_busno = bus_range ? bus_range[1] : 0xff;
146 146
147 setup_indirect_pci(hose, rsrc.start, rsrc.start + 4); 147 setup_indirect_pci(hose, rsrc.start, rsrc.start + 4, 0);
148 hose->self_busno = hose->first_busno; 148 hose->self_busno = hose->first_busno;
149 149
150 printk(KERN_INFO "Found MV64x60 PCI host bridge at 0x%016llx. " 150 printk(KERN_INFO "Found MV64x60 PCI host bridge at 0x%016llx. "
diff --git a/arch/ppc/configs/TQM8540_defconfig b/arch/ppc/configs/TQM8540_defconfig
index 99bf3b7a2762..f33f0e772dcb 100644
--- a/arch/ppc/configs/TQM8540_defconfig
+++ b/arch/ppc/configs/TQM8540_defconfig
@@ -136,7 +136,7 @@ CONFIG_BINFMT_ELF=y
136# CONFIG_BINFMT_MISC is not set 136# CONFIG_BINFMT_MISC is not set
137# CONFIG_CMDLINE_BOOL is not set 137# CONFIG_CMDLINE_BOOL is not set
138# CONFIG_PM is not set 138# CONFIG_PM is not set
139# CONFIG_SOFTWARE_SUSPEND is not set 139# CONFIG_HIBERNATION is not set
140CONFIG_SECCOMP=y 140CONFIG_SECCOMP=y
141CONFIG_ISA_DMA_API=y 141CONFIG_ISA_DMA_API=y
142 142
diff --git a/arch/ppc/configs/TQM8541_defconfig b/arch/ppc/configs/TQM8541_defconfig
index 0ff56695d349..e00cd62daa3f 100644
--- a/arch/ppc/configs/TQM8541_defconfig
+++ b/arch/ppc/configs/TQM8541_defconfig
@@ -138,7 +138,7 @@ CONFIG_BINFMT_ELF=y
138# CONFIG_BINFMT_MISC is not set 138# CONFIG_BINFMT_MISC is not set
139# CONFIG_CMDLINE_BOOL is not set 139# CONFIG_CMDLINE_BOOL is not set
140# CONFIG_PM is not set 140# CONFIG_PM is not set
141# CONFIG_SOFTWARE_SUSPEND is not set 141# CONFIG_HIBERNATION is not set
142CONFIG_SECCOMP=y 142CONFIG_SECCOMP=y
143CONFIG_ISA_DMA_API=y 143CONFIG_ISA_DMA_API=y
144 144
diff --git a/arch/ppc/configs/TQM8555_defconfig b/arch/ppc/configs/TQM8555_defconfig
index 730b3db2e47a..43a0d9df1e23 100644
--- a/arch/ppc/configs/TQM8555_defconfig
+++ b/arch/ppc/configs/TQM8555_defconfig
@@ -138,7 +138,7 @@ CONFIG_BINFMT_ELF=y
138# CONFIG_BINFMT_MISC is not set 138# CONFIG_BINFMT_MISC is not set
139# CONFIG_CMDLINE_BOOL is not set 139# CONFIG_CMDLINE_BOOL is not set
140# CONFIG_PM is not set 140# CONFIG_PM is not set
141# CONFIG_SOFTWARE_SUSPEND is not set 141# CONFIG_HIBERNATION is not set
142CONFIG_SECCOMP=y 142CONFIG_SECCOMP=y
143CONFIG_ISA_DMA_API=y 143CONFIG_ISA_DMA_API=y
144 144
diff --git a/arch/ppc/configs/TQM8560_defconfig b/arch/ppc/configs/TQM8560_defconfig
index 1d902072825e..a814d17a2be9 100644
--- a/arch/ppc/configs/TQM8560_defconfig
+++ b/arch/ppc/configs/TQM8560_defconfig
@@ -137,7 +137,7 @@ CONFIG_BINFMT_ELF=y
137# CONFIG_BINFMT_MISC is not set 137# CONFIG_BINFMT_MISC is not set
138# CONFIG_CMDLINE_BOOL is not set 138# CONFIG_CMDLINE_BOOL is not set
139# CONFIG_PM is not set 139# CONFIG_PM is not set
140# CONFIG_SOFTWARE_SUSPEND is not set 140# CONFIG_HIBERNATION is not set
141CONFIG_SECCOMP=y 141CONFIG_SECCOMP=y
142CONFIG_ISA_DMA_API=y 142CONFIG_ISA_DMA_API=y
143 143
diff --git a/arch/ppc/configs/ev64360_defconfig b/arch/ppc/configs/ev64360_defconfig
index d471e578dcb5..f297c4bb632b 100644
--- a/arch/ppc/configs/ev64360_defconfig
+++ b/arch/ppc/configs/ev64360_defconfig
@@ -142,7 +142,7 @@ CONFIG_BINFMT_MISC=y
142CONFIG_CMDLINE_BOOL=y 142CONFIG_CMDLINE_BOOL=y
143CONFIG_CMDLINE="console=ttyMM0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2" 143CONFIG_CMDLINE="console=ttyMM0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2"
144# CONFIG_PM is not set 144# CONFIG_PM is not set
145# CONFIG_SOFTWARE_SUSPEND is not set 145# CONFIG_HIBERNATION is not set
146CONFIG_SECCOMP=y 146CONFIG_SECCOMP=y
147CONFIG_ISA_DMA_API=y 147CONFIG_ISA_DMA_API=y
148 148
diff --git a/arch/ppc/configs/ml300_defconfig b/arch/ppc/configs/ml300_defconfig
index 4a33aca948cc..69bad91a6b65 100644
--- a/arch/ppc/configs/ml300_defconfig
+++ b/arch/ppc/configs/ml300_defconfig
@@ -148,7 +148,7 @@ CONFIG_BINFMT_ELF=y
148CONFIG_CMDLINE_BOOL=y 148CONFIG_CMDLINE_BOOL=y
149CONFIG_CMDLINE="console=ttyS0,9600" 149CONFIG_CMDLINE="console=ttyS0,9600"
150# CONFIG_PM is not set 150# CONFIG_PM is not set
151# CONFIG_SOFTWARE_SUSPEND is not set 151# CONFIG_HIBERNATION is not set
152CONFIG_SECCOMP=y 152CONFIG_SECCOMP=y
153CONFIG_ISA_DMA_API=y 153CONFIG_ISA_DMA_API=y
154 154
diff --git a/arch/ppc/configs/ml403_defconfig b/arch/ppc/configs/ml403_defconfig
index fafd2516fa51..a78896ea4560 100644
--- a/arch/ppc/configs/ml403_defconfig
+++ b/arch/ppc/configs/ml403_defconfig
@@ -149,7 +149,7 @@ CONFIG_BINFMT_ELF=y
149CONFIG_CMDLINE_BOOL=y 149CONFIG_CMDLINE_BOOL=y
150CONFIG_CMDLINE="console=ttyS0,9600" 150CONFIG_CMDLINE="console=ttyS0,9600"
151# CONFIG_PM is not set 151# CONFIG_PM is not set
152# CONFIG_SOFTWARE_SUSPEND is not set 152# CONFIG_HIBERNATION is not set
153CONFIG_SECCOMP=y 153CONFIG_SECCOMP=y
154CONFIG_ISA_DMA_API=y 154CONFIG_ISA_DMA_API=y
155 155
diff --git a/arch/ppc/configs/mpc834x_sys_defconfig b/arch/ppc/configs/mpc834x_sys_defconfig
index b96a6d6dad0e..d90c8a7e060c 100644
--- a/arch/ppc/configs/mpc834x_sys_defconfig
+++ b/arch/ppc/configs/mpc834x_sys_defconfig
@@ -130,7 +130,7 @@ CONFIG_BINFMT_ELF=y
130# CONFIG_BINFMT_MISC is not set 130# CONFIG_BINFMT_MISC is not set
131# CONFIG_CMDLINE_BOOL is not set 131# CONFIG_CMDLINE_BOOL is not set
132# CONFIG_PM is not set 132# CONFIG_PM is not set
133# CONFIG_SOFTWARE_SUSPEND is not set 133# CONFIG_HIBERNATION is not set
134CONFIG_SECCOMP=y 134CONFIG_SECCOMP=y
135CONFIG_ISA_DMA_API=y 135CONFIG_ISA_DMA_API=y
136 136
diff --git a/arch/ppc/configs/prep_defconfig b/arch/ppc/configs/prep_defconfig
index 0aa333178b2a..b7cee2d71405 100644
--- a/arch/ppc/configs/prep_defconfig
+++ b/arch/ppc/configs/prep_defconfig
@@ -166,7 +166,7 @@ CONFIG_PROC_PREPRESIDUAL=y
166CONFIG_PM=y 166CONFIG_PM=y
167# CONFIG_PM_LEGACY is not set 167# CONFIG_PM_LEGACY is not set
168# CONFIG_PM_DEBUG is not set 168# CONFIG_PM_DEBUG is not set
169CONFIG_SOFTWARE_SUSPEND=y 169CONFIG_HIBERNATION=y
170CONFIG_PM_STD_PARTITION="" 170CONFIG_PM_STD_PARTITION=""
171# CONFIG_SECCOMP is not set 171# CONFIG_SECCOMP is not set
172CONFIG_ISA_DMA_API=y 172CONFIG_ISA_DMA_API=y
diff --git a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c
index d212b1c418a9..2744b8a6f66a 100644
--- a/arch/ppc/syslib/mv64x60.c
+++ b/arch/ppc/syslib/mv64x60.c
@@ -441,6 +441,32 @@ static struct platform_device i2c_device = {
441}; 441};
442#endif 442#endif
443 443
444#ifdef CONFIG_WATCHDOG
445static struct mv64x60_wdt_pdata mv64x60_wdt_pdata = {
446 .timeout = 10, /* default watchdog expiry in seconds */
447 .bus_clk = 133, /* default bus clock in MHz */
448};
449
450static struct resource mv64x60_wdt_resources[] = {
451 [0] = {
452 .name = "mv64x60 wdt base",
453 .start = MV64x60_WDT_WDC,
454 .end = MV64x60_WDT_WDC + 8 - 1, /* two 32-bit registers */
455 .flags = IORESOURCE_MEM,
456 },
457};
458
459static struct platform_device wdt_device = {
460 .name = MV64x60_WDT_NAME,
461 .id = 0,
462 .num_resources = ARRAY_SIZE(mv64x60_wdt_resources),
463 .resource = mv64x60_wdt_resources,
464 .dev = {
465 .platform_data = &mv64x60_wdt_pdata,
466 },
467};
468#endif
469
444#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260) 470#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
445static struct mv64xxx_pdata mv64xxx_pdata = { 471static struct mv64xxx_pdata mv64xxx_pdata = {
446 .hs_reg_valid = 0, 472 .hs_reg_valid = 0,
@@ -476,6 +502,9 @@ static struct platform_device *mv64x60_pd_devs[] __initdata = {
476#ifdef CONFIG_I2C_MV64XXX 502#ifdef CONFIG_I2C_MV64XXX
477 &i2c_device, 503 &i2c_device,
478#endif 504#endif
505#ifdef CONFIG_MV64X60_WDT
506 &wdt_device,
507#endif
479#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260) 508#if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
480 &mv64xxx_device, 509 &mv64xxx_device,
481#endif 510#endif
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index 6ffbab77ae4d..62391fb1f61f 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -173,7 +173,7 @@ int appldata_diag(char record_nr, u16 function, unsigned long buffer,
173/* 173/*
174 * appldata_mod_vtimer_wrap() 174 * appldata_mod_vtimer_wrap()
175 * 175 *
176 * wrapper function for mod_virt_timer(), because smp_call_function_on() 176 * wrapper function for mod_virt_timer(), because smp_call_function_single()
177 * accepts only one parameter. 177 * accepts only one parameter.
178 */ 178 */
179static void __appldata_mod_vtimer_wrap(void *p) { 179static void __appldata_mod_vtimer_wrap(void *p) {
@@ -208,9 +208,9 @@ __appldata_vtimer_setup(int cmd)
208 num_online_cpus()) * TOD_MICRO; 208 num_online_cpus()) * TOD_MICRO;
209 for_each_online_cpu(i) { 209 for_each_online_cpu(i) {
210 per_cpu(appldata_timer, i).expires = per_cpu_interval; 210 per_cpu(appldata_timer, i).expires = per_cpu_interval;
211 smp_call_function_on(add_virt_timer_periodic, 211 smp_call_function_single(i, add_virt_timer_periodic,
212 &per_cpu(appldata_timer, i), 212 &per_cpu(appldata_timer, i),
213 0, 1, i); 213 0, 1);
214 } 214 }
215 appldata_timer_active = 1; 215 appldata_timer_active = 1;
216 P_INFO("Monitoring timer started.\n"); 216 P_INFO("Monitoring timer started.\n");
@@ -236,8 +236,8 @@ __appldata_vtimer_setup(int cmd)
236 } args; 236 } args;
237 args.timer = &per_cpu(appldata_timer, i); 237 args.timer = &per_cpu(appldata_timer, i);
238 args.expires = per_cpu_interval; 238 args.expires = per_cpu_interval;
239 smp_call_function_on(__appldata_mod_vtimer_wrap, 239 smp_call_function_single(i, __appldata_mod_vtimer_wrap,
240 &args, 0, 1, i); 240 &args, 0, 1);
241 } 241 }
242 } 242 }
243} 243}
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index acc415457b45..6ee1bedbd1bf 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -1710,3 +1710,13 @@ compat_sys_timerfd_wrapper:
1710sys_eventfd_wrapper: 1710sys_eventfd_wrapper:
1711 llgfr %r2,%r2 # unsigned int 1711 llgfr %r2,%r2 # unsigned int
1712 jg sys_eventfd 1712 jg sys_eventfd
1713
1714 .globl sys_fallocate_wrapper
1715sys_fallocate_wrapper:
1716 lgfr %r2,%r2 # int
1717 lgfr %r3,%r3 # int
1718 sllg %r4,%r4,32 # get high word of 64bit loff_t
1719 lr %r4,%r5 # get low word of 64bit loff_t
1720 sllg %r5,%r6,32 # get high word of 64bit loff_t
1721 l %r5,164(%r15) # get low word of 64bit loff_t
1722 jg sys_fallocate
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index bc7ff3658c3d..f3bceb165321 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -624,9 +624,11 @@ io_work_loop:
624# _TIF_MCCK_PENDING is set, call handler 624# _TIF_MCCK_PENDING is set, call handler
625# 625#
626io_mcck_pending: 626io_mcck_pending:
627 TRACE_IRQS_OFF
627 l %r1,BASED(.Ls390_handle_mcck) 628 l %r1,BASED(.Ls390_handle_mcck)
628 la %r14,BASED(io_work_loop) 629 basr %r14,%r1 # TIF bit will be cleared by handler
629 br %r1 # TIF bit will be cleared by handler 630 TRACE_IRQS_ON
631 b BASED(io_work_loop)
630 632
631# 633#
632# _TIF_NEED_RESCHED is set, call schedule 634# _TIF_NEED_RESCHED is set, call schedule
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index 2a7b1304418b..9c0d5cc8269d 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -611,8 +611,10 @@ io_work_loop:
611# _TIF_MCCK_PENDING is set, call handler 611# _TIF_MCCK_PENDING is set, call handler
612# 612#
613io_mcck_pending: 613io_mcck_pending:
614 larl %r14,io_work_loop 614 TRACE_IRQS_OFF
615 jg s390_handle_mcck # TIF bit will be cleared by handler 615 brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler
616 TRACE_IRQS_ON
617 j io_work_loop
616 618
617# 619#
618# _TIF_NEED_RESCHED is set, call schedule 620# _TIF_NEED_RESCHED is set, call schedule
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S
index 8f8c802f1bcf..83477c7dc743 100644
--- a/arch/s390/kernel/head.S
+++ b/arch/s390/kernel/head.S
@@ -35,6 +35,7 @@
35#define ARCH_OFFSET 0 35#define ARCH_OFFSET 0
36#endif 36#endif
37 37
38.section ".text.head","ax"
38#ifndef CONFIG_IPL 39#ifndef CONFIG_IPL
39 .org 0 40 .org 0
40 .long 0x00080000,0x80000000+startup # Just a restart PSW 41 .long 0x00080000,0x80000000+startup # Just a restart PSW
diff --git a/arch/s390/kernel/init_task.c b/arch/s390/kernel/init_task.c
index d73a74013e73..d494161b05b4 100644
--- a/arch/s390/kernel/init_task.c
+++ b/arch/s390/kernel/init_task.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/fs.h>
10#include <linux/module.h> 11#include <linux/module.h>
11#include <linux/sched.h> 12#include <linux/sched.h>
12#include <linux/init_task.h> 13#include <linux/init_task.h>
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 441975b796fb..abb447a3e472 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -21,6 +21,7 @@
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/fs.h>
24#include <linux/smp.h> 25#include <linux/smp.h>
25#include <linux/stddef.h> 26#include <linux/stddef.h>
26#include <linux/unistd.h> 27#include <linux/unistd.h>
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 182c085ae4dd..35edbef1d222 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -23,6 +23,7 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/err.h>
26#include <linux/spinlock.h> 27#include <linux/spinlock.h>
27#include <linux/kernel_stat.h> 28#include <linux/kernel_stat.h>
28#include <linux/delay.h> 29#include <linux/delay.h>
@@ -120,7 +121,7 @@ static void __smp_call_function_map(void (*func) (void *info), void *info,
120 if (wait) 121 if (wait)
121 data.finished = CPU_MASK_NONE; 122 data.finished = CPU_MASK_NONE;
122 123
123 spin_lock_bh(&call_lock); 124 spin_lock(&call_lock);
124 call_data = &data; 125 call_data = &data;
125 126
126 for_each_cpu_mask(cpu, map) 127 for_each_cpu_mask(cpu, map)
@@ -129,18 +130,16 @@ static void __smp_call_function_map(void (*func) (void *info), void *info,
129 /* Wait for response */ 130 /* Wait for response */
130 while (!cpus_equal(map, data.started)) 131 while (!cpus_equal(map, data.started))
131 cpu_relax(); 132 cpu_relax();
132
133 if (wait) 133 if (wait)
134 while (!cpus_equal(map, data.finished)) 134 while (!cpus_equal(map, data.finished))
135 cpu_relax(); 135 cpu_relax();
136 136 spin_unlock(&call_lock);
137 spin_unlock_bh(&call_lock);
138
139out: 137out:
140 local_irq_disable(); 138 if (local) {
141 if (local) 139 local_irq_disable();
142 func(info); 140 func(info);
143 local_irq_enable(); 141 local_irq_enable();
142 }
144} 143}
145 144
146/* 145/*
@@ -170,30 +169,28 @@ int smp_call_function(void (*func) (void *info), void *info, int nonatomic,
170EXPORT_SYMBOL(smp_call_function); 169EXPORT_SYMBOL(smp_call_function);
171 170
172/* 171/*
173 * smp_call_function_on: 172 * smp_call_function_single:
173 * @cpu: the CPU where func should run
174 * @func: the function to run; this must be fast and non-blocking 174 * @func: the function to run; this must be fast and non-blocking
175 * @info: an arbitrary pointer to pass to the function 175 * @info: an arbitrary pointer to pass to the function
176 * @nonatomic: unused 176 * @nonatomic: unused
177 * @wait: if true, wait (atomically) until function has completed on other CPUs 177 * @wait: if true, wait (atomically) until function has completed on other CPUs
178 * @cpu: the CPU where func should run
179 * 178 *
180 * Run a function on one processor. 179 * Run a function on one processor.
181 * 180 *
182 * You must not call this function with disabled interrupts, from a 181 * You must not call this function with disabled interrupts, from a
183 * hardware interrupt handler or from a bottom half. 182 * hardware interrupt handler or from a bottom half.
184 */ 183 */
185int smp_call_function_on(void (*func) (void *info), void *info, int nonatomic, 184int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
186 int wait, int cpu) 185 int nonatomic, int wait)
187{ 186{
188 cpumask_t map = CPU_MASK_NONE;
189
190 preempt_disable(); 187 preempt_disable();
191 cpu_set(cpu, map); 188 __smp_call_function_map(func, info, nonatomic, wait,
192 __smp_call_function_map(func, info, nonatomic, wait, map); 189 cpumask_of_cpu(cpu));
193 preempt_enable(); 190 preempt_enable();
194 return 0; 191 return 0;
195} 192}
196EXPORT_SYMBOL(smp_call_function_on); 193EXPORT_SYMBOL(smp_call_function_single);
197 194
198static void do_send_stop(void) 195static void do_send_stop(void)
199{ 196{
diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c
index 1c90c7e99978..1eaff84a1eb6 100644
--- a/arch/s390/kernel/sys_s390.c
+++ b/arch/s390/kernel/sys_s390.c
@@ -16,6 +16,7 @@
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/sched.h> 17#include <linux/sched.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/fs.h>
19#include <linux/smp.h> 20#include <linux/smp.h>
20#include <linux/sem.h> 21#include <linux/sem.h>
21#include <linux/msg.h> 22#include <linux/msg.h>
@@ -265,3 +266,23 @@ s390_fadvise64_64(struct fadvise64_64_args __user *args)
265 return -EFAULT; 266 return -EFAULT;
266 return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice); 267 return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
267} 268}
269
270#ifndef CONFIG_64BIT
271/*
272 * This is a wrapper to call sys_fallocate(). For 31 bit s390 the last
273 * 64 bit argument "len" is split into the upper and lower 32 bits. The
274 * system call wrapper in the user space loads the value to %r6/%r7.
275 * The code in entry.S keeps the values in %r2 - %r6 where they are and
276 * stores %r7 to 96(%r15). But the standard C linkage requires that
277 * the whole 64 bit value for len is stored on the stack and doesn't
278 * use %r6 at all. So s390_fallocate has to convert the arguments from
279 * %r2: fd, %r3: mode, %r4/%r5: offset, %r6/96(%r15)-99(%r15): len
280 * to
281 * %r2: fd, %r3: mode, %r4/%r5: offset, 96(%r15)-103(%r15): len
282 */
283asmlinkage long s390_fallocate(int fd, int mode, loff_t offset,
284 u32 len_high, u32 len_low)
285{
286 return sys_fallocate(fd, mode, offset, ((u64)len_high << 32) | len_low);
287}
288#endif
diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S
index 738feb4a0aad..9e26ed9fe4e7 100644
--- a/arch/s390/kernel/syscalls.S
+++ b/arch/s390/kernel/syscalls.S
@@ -322,7 +322,7 @@ NI_SYSCALL /* 310 sys_move_pages */
322SYSCALL(sys_getcpu,sys_getcpu,sys_getcpu_wrapper) 322SYSCALL(sys_getcpu,sys_getcpu,sys_getcpu_wrapper)
323SYSCALL(sys_epoll_pwait,sys_epoll_pwait,compat_sys_epoll_pwait_wrapper) 323SYSCALL(sys_epoll_pwait,sys_epoll_pwait,compat_sys_epoll_pwait_wrapper)
324SYSCALL(sys_utimes,sys_utimes,compat_sys_utimes_wrapper) 324SYSCALL(sys_utimes,sys_utimes,compat_sys_utimes_wrapper)
325NI_SYSCALL /* 314 sys_fallocate */ 325SYSCALL(s390_fallocate,sys_fallocate,sys_fallocate_wrapper)
326SYSCALL(sys_utimensat,sys_utimensat,compat_sys_utimensat_wrapper) /* 315 */ 326SYSCALL(sys_utimensat,sys_utimensat,compat_sys_utimensat_wrapper) /* 315 */
327SYSCALL(sys_signalfd,sys_signalfd,compat_sys_signalfd_wrapper) 327SYSCALL(sys_signalfd,sys_signalfd,compat_sys_signalfd_wrapper)
328SYSCALL(sys_timerfd,sys_timerfd,compat_sys_timerfd_wrapper) 328SYSCALL(sys_timerfd,sys_timerfd,compat_sys_timerfd_wrapper)
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
index 6ab7d4ee13a4..b4622a3889b0 100644
--- a/arch/s390/kernel/vmlinux.lds.S
+++ b/arch/s390/kernel/vmlinux.lds.S
@@ -21,6 +21,7 @@ SECTIONS
21 . = 0x00000000; 21 . = 0x00000000;
22 _text = .; /* Text and read-only data */ 22 _text = .; /* Text and read-only data */
23 .text : { 23 .text : {
24 *(.text.head)
24 TEXT_TEXT 25 TEXT_TEXT
25 SCHED_TEXT 26 SCHED_TEXT
26 LOCK_TEXT 27 LOCK_TEXT
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index b6ed143e8597..84ff78de6bac 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -415,7 +415,7 @@ EXPORT_SYMBOL(add_virt_timer_periodic);
415 415
416/* 416/*
417 * If we change a pending timer the function must be called on the CPU 417 * If we change a pending timer the function must be called on the CPU
418 * where the timer is running on, e.g. by smp_call_function_on() 418 * where the timer is running on, e.g. by smp_call_function_single()
419 * 419 *
420 * The original mod_timer adds the timer if it is not pending. For compatibility 420 * The original mod_timer adds the timer if it is not pending. For compatibility
421 * we do the same. The timer will be added on the current CPU as a oneshot timer. 421 * we do the same. The timer will be added on the current CPU as a oneshot timer.
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index 92a565190028..fd594d5fe142 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -29,8 +29,8 @@ struct memory_segment {
29 29
30static LIST_HEAD(mem_segs); 30static LIST_HEAD(mem_segs);
31 31
32void memmap_init(unsigned long size, int nid, unsigned long zone, 32void __meminit memmap_init(unsigned long size, int nid, unsigned long zone,
33 unsigned long start_pfn) 33 unsigned long start_pfn)
34{ 34{
35 struct page *start, *end; 35 struct page *start, *end;
36 struct page *map_start, *map_end; 36 struct page *map_start, *map_end;
@@ -66,7 +66,7 @@ void memmap_init(unsigned long size, int nid, unsigned long zone,
66 } 66 }
67} 67}
68 68
69static inline void *vmem_alloc_pages(unsigned int order) 69static void __init_refok *vmem_alloc_pages(unsigned int order)
70{ 70{
71 if (slab_is_available()) 71 if (slab_is_available())
72 return (void *)__get_free_pages(GFP_KERNEL, order); 72 return (void *)__get_free_pages(GFP_KERNEL, order);
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index f87f429e0b24..54878f07cf0c 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -90,6 +90,9 @@ config ARCH_HAS_ILOG2_U64
90 bool 90 bool
91 default n 91 default n
92 92
93config ARCH_NO_VIRT_TO_BUS
94 def_bool y
95
93source "init/Kconfig" 96source "init/Kconfig"
94 97
95menu "System type" 98menu "System type"
@@ -134,8 +137,8 @@ config SH_FPU_EMU
134 137
135config SH_DSP 138config SH_DSP
136 bool "DSP support" 139 bool "DSP support"
137 default y if SH4AL_DSP || !CPU_SH4 140 depends on CPU_HAS_DSP
138 default n 141 default y
139 help 142 help
140 Selecting this option will enable support for SH processors that 143 Selecting this option will enable support for SH processors that
141 have DSP units (ie, SH2-DSP, SH3-DSP, and SH4AL-DSP). 144 have DSP units (ie, SH2-DSP, SH3-DSP, and SH4AL-DSP).
@@ -172,9 +175,6 @@ config SPECULATIVE_EXECUTION
172config CPU_HAS_INTEVT 175config CPU_HAS_INTEVT
173 bool 176 bool
174 177
175config CPU_HAS_PINT_IRQ
176 bool
177
178config CPU_HAS_MASKREG_IRQ 178config CPU_HAS_MASKREG_IRQ
179 bool 179 bool
180 180
@@ -202,6 +202,9 @@ config CPU_HAS_SR_RB
202config CPU_HAS_PTEA 202config CPU_HAS_PTEA
203 bool 203 bool
204 204
205config CPU_HAS_DSP
206 bool
207
205endmenu 208endmenu
206 209
207menu "Board support" 210menu "Board support"
@@ -261,14 +264,6 @@ config SH_7780_SOLUTION_ENGINE
261 Select 7780 SolutionEngine if configuring for a Renesas SH7780 264 Select 7780 SolutionEngine if configuring for a Renesas SH7780
262 evaluation board. 265 evaluation board.
263 266
264config SH_7300_SOLUTION_ENGINE
265 bool "SolutionEngine7300"
266 select SOLUTION_ENGINE
267 depends on CPU_SUBTYPE_SH7300
268 help
269 Select 7300 SolutionEngine if configuring for a Hitachi
270 SH7300(SH-Mobile V) evaluation board.
271
272config SH_7343_SOLUTION_ENGINE 267config SH_7343_SOLUTION_ENGINE
273 bool "SolutionEngine7343" 268 bool "SolutionEngine7343"
274 select SOLUTION_ENGINE 269 select SOLUTION_ENGINE
@@ -277,14 +272,6 @@ config SH_7343_SOLUTION_ENGINE
277 Select 7343 SolutionEngine if configuring for a Hitachi 272 Select 7343 SolutionEngine if configuring for a Hitachi
278 SH7343 (SH-Mobile 3AS) evaluation board. 273 SH7343 (SH-Mobile 3AS) evaluation board.
279 274
280config SH_73180_SOLUTION_ENGINE
281 bool "SolutionEngine73180"
282 select SOLUTION_ENGINE
283 depends on CPU_SUBTYPE_SH73180
284 help
285 Select 73180 SolutionEngine if configuring for a Hitachi
286 SH73180(SH-Mobile 3) evaluation board.
287
288config SH_7751_SYSTEMH 275config SH_7751_SYSTEMH
289 bool "SystemH7751R" 276 bool "SystemH7751R"
290 depends on CPU_SUBTYPE_SH7751R 277 depends on CPU_SUBTYPE_SH7751R
@@ -448,10 +435,10 @@ config SH_TIMER_IRQ
448 435
449config SH_PCLK_FREQ 436config SH_PCLK_FREQ
450 int "Peripheral clock frequency (in Hz)" 437 int "Peripheral clock frequency (in Hz)"
451 default "27000000" if CPU_SUBTYPE_SH73180 || CPU_SUBTYPE_SH7343 438 default "27000000" if CPU_SUBTYPE_SH7343
452 default "31250000" if CPU_SUBTYPE_SH7619 439 default "31250000" if CPU_SUBTYPE_SH7619
453 default "32000000" if CPU_SUBTYPE_SH7722 440 default "32000000" if CPU_SUBTYPE_SH7722
454 default "33333333" if CPU_SUBTYPE_SH7300 || CPU_SUBTYPE_SH7770 || \ 441 default "33333333" if CPU_SUBTYPE_SH7770 || \
455 CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7705 || \ 442 CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7705 || \
456 CPU_SUBTYPE_SH7206 443 CPU_SUBTYPE_SH7206
457 default "60000000" if CPU_SUBTYPE_SH7751 || CPU_SUBTYPE_SH7751R 444 default "60000000" if CPU_SUBTYPE_SH7751 || CPU_SUBTYPE_SH7751R
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 0016609d1eba..3d211aa33cd8 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -91,9 +91,7 @@ machdir-$(CONFIG_SH_SOLUTION_ENGINE) += se/770x
91machdir-$(CONFIG_SH_7722_SOLUTION_ENGINE) += se/7722 91machdir-$(CONFIG_SH_7722_SOLUTION_ENGINE) += se/7722
92machdir-$(CONFIG_SH_7751_SOLUTION_ENGINE) += se/7751 92machdir-$(CONFIG_SH_7751_SOLUTION_ENGINE) += se/7751
93machdir-$(CONFIG_SH_7780_SOLUTION_ENGINE) += se/7780 93machdir-$(CONFIG_SH_7780_SOLUTION_ENGINE) += se/7780
94machdir-$(CONFIG_SH_7300_SOLUTION_ENGINE) += se/7300
95machdir-$(CONFIG_SH_7343_SOLUTION_ENGINE) += se/7343 94machdir-$(CONFIG_SH_7343_SOLUTION_ENGINE) += se/7343
96machdir-$(CONFIG_SH_73180_SOLUTION_ENGINE) += se/73180
97machdir-$(CONFIG_SH_HP6XX) += hp6xx 95machdir-$(CONFIG_SH_HP6XX) += hp6xx
98machdir-$(CONFIG_SH_DREAMCAST) += dreamcast 96machdir-$(CONFIG_SH_DREAMCAST) += dreamcast
99machdir-$(CONFIG_SH_MPC1211) += mpc1211 97machdir-$(CONFIG_SH_MPC1211) += mpc1211
diff --git a/arch/sh/boards/se/7300/Makefile b/arch/sh/boards/se/7300/Makefile
deleted file mode 100644
index 46247368f14b..000000000000
--- a/arch/sh/boards/se/7300/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for the 7300 SolutionEngine specific parts of the kernel
3#
4
5obj-y := setup.o io.o irq.o
diff --git a/arch/sh/boards/se/7300/io.c b/arch/sh/boards/se/7300/io.c
deleted file mode 100644
index 8a03d7a52a7c..000000000000
--- a/arch/sh/boards/se/7300/io.c
+++ /dev/null
@@ -1,268 +0,0 @@
1/*
2 * arch/sh/boards/se/7300/io.c
3 *
4 * Copyright (C) 2003 YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
5 * Based on arch/sh/kernel/io_shmse.c
6 *
7 * I/O routine for SH-Mobile3 73180 SolutionEngine.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <asm/io.h>
13#include <asm/se7300.h>
14
15#define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
16
17struct iop {
18 unsigned long start, end;
19 unsigned long base;
20 struct iop *(*check) (struct iop * p, unsigned long port);
21 unsigned char (*inb) (struct iop * p, unsigned long port);
22 unsigned short (*inw) (struct iop * p, unsigned long port);
23 void (*outb) (struct iop * p, unsigned char value, unsigned long port);
24 void (*outw) (struct iop * p, unsigned short value, unsigned long port);
25};
26
27struct iop *
28simple_check(struct iop *p, unsigned long port)
29{
30 if ((p->start <= port) && (port <= p->end))
31 return p;
32 else
33 badio(check, port);
34}
35
36struct iop *
37ide_check(struct iop *p, unsigned long port)
38{
39 if (((0x1f0 <= port) && (port <= 0x1f7)) || (port == 0x3f7))
40 return p;
41 return NULL;
42}
43
44unsigned char
45simple_inb(struct iop *p, unsigned long port)
46{
47 return *(unsigned char *) (p->base + port);
48}
49
50unsigned short
51simple_inw(struct iop *p, unsigned long port)
52{
53 return *(unsigned short *) (p->base + port);
54}
55
56void
57simple_outb(struct iop *p, unsigned char value, unsigned long port)
58{
59 *(unsigned char *) (p->base + port) = value;
60}
61
62void
63simple_outw(struct iop *p, unsigned short value, unsigned long port)
64{
65 *(unsigned short *) (p->base + port) = value;
66}
67
68unsigned char
69pcc_inb(struct iop *p, unsigned long port)
70{
71 unsigned long addr = p->base + port + 0x40000;
72 unsigned long v;
73
74 if (port & 1)
75 addr += 0x00400000;
76 v = *(volatile unsigned char *) addr;
77 return v;
78}
79
80void
81pcc_outb(struct iop *p, unsigned char value, unsigned long port)
82{
83 unsigned long addr = p->base + port + 0x40000;
84
85 if (port & 1)
86 addr += 0x00400000;
87 *(volatile unsigned char *) addr = value;
88}
89
90unsigned char
91bad_inb(struct iop *p, unsigned long port)
92{
93 badio(inb, port);
94}
95
96void
97bad_outb(struct iop *p, unsigned char value, unsigned long port)
98{
99 badio(inw, port);
100}
101
102#ifdef CONFIG_SMC91X
103/* MSTLANEX01 LAN at 0xb400:0000 */
104static struct iop laniop = {
105 .start = 0x300,
106 .end = 0x30f,
107 .base = 0xb4000000,
108 .check = simple_check,
109 .inb = simple_inb,
110 .inw = simple_inw,
111 .outb = simple_outb,
112 .outw = simple_outw,
113};
114#endif
115
116/* NE2000 pc card NIC */
117static struct iop neiop = {
118 .start = 0x280,
119 .end = 0x29f,
120 .base = 0xb0600000 + 0x80, /* soft 0x280 -> hard 0x300 */
121 .check = simple_check,
122 .inb = pcc_inb,
123 .inw = simple_inw,
124 .outb = pcc_outb,
125 .outw = simple_outw,
126};
127
128#ifdef CONFIG_IDE
129/* CF in CF slot */
130static struct iop cfiop = {
131 .base = 0xb0600000,
132 .check = ide_check,
133 .inb = pcc_inb,
134 .inw = simple_inw,
135 .outb = pcc_outb,
136 .outw = simple_outw,
137};
138#endif
139
140static __inline__ struct iop *
141port2iop(unsigned long port)
142{
143 if (0) ;
144#if defined(CONFIG_SMC91X)
145 else if (laniop.check(&laniop, port))
146 return &laniop;
147#endif
148#if defined(CONFIG_NE2000)
149 else if (neiop.check(&neiop, port))
150 return &neiop;
151#endif
152#if defined(CONFIG_IDE)
153 else if (cfiop.check(&cfiop, port))
154 return &cfiop;
155#endif
156 else
157 return &neiop; /* fallback */
158}
159
160static inline void
161delay(void)
162{
163 ctrl_inw(0xac000000);
164 ctrl_inw(0xac000000);
165}
166
167unsigned char
168sh7300se_inb(unsigned long port)
169{
170 struct iop *p = port2iop(port);
171 return (p->inb) (p, port);
172}
173
174unsigned char
175sh7300se_inb_p(unsigned long port)
176{
177 unsigned char v = sh7300se_inb(port);
178 delay();
179 return v;
180}
181
182unsigned short
183sh7300se_inw(unsigned long port)
184{
185 struct iop *p = port2iop(port);
186 return (p->inw) (p, port);
187}
188
189unsigned int
190sh7300se_inl(unsigned long port)
191{
192 badio(inl, port);
193}
194
195void
196sh7300se_outb(unsigned char value, unsigned long port)
197{
198 struct iop *p = port2iop(port);
199 (p->outb) (p, value, port);
200}
201
202void
203sh7300se_outb_p(unsigned char value, unsigned long port)
204{
205 sh7300se_outb(value, port);
206 delay();
207}
208
209void
210sh7300se_outw(unsigned short value, unsigned long port)
211{
212 struct iop *p = port2iop(port);
213 (p->outw) (p, value, port);
214}
215
216void
217sh7300se_outl(unsigned int value, unsigned long port)
218{
219 badio(outl, port);
220}
221
222void
223sh7300se_insb(unsigned long port, void *addr, unsigned long count)
224{
225 unsigned char *a = addr;
226 struct iop *p = port2iop(port);
227 while (count--)
228 *a++ = (p->inb) (p, port);
229}
230
231void
232sh7300se_insw(unsigned long port, void *addr, unsigned long count)
233{
234 unsigned short *a = addr;
235 struct iop *p = port2iop(port);
236 while (count--)
237 *a++ = (p->inw) (p, port);
238}
239
240void
241sh7300se_insl(unsigned long port, void *addr, unsigned long count)
242{
243 badio(insl, port);
244}
245
246void
247sh7300se_outsb(unsigned long port, const void *addr, unsigned long count)
248{
249 unsigned char *a = (unsigned char *) addr;
250 struct iop *p = port2iop(port);
251 while (count--)
252 (p->outb) (p, *a++, port);
253}
254
255void
256sh7300se_outsw(unsigned long port, const void *addr, unsigned long count)
257{
258 unsigned short *a = (unsigned short *) addr;
259 struct iop *p = port2iop(port);
260 while (count--)
261 (p->outw) (p, *a++, port);
262}
263
264void
265sh7300se_outsl(unsigned long port, const void *addr, unsigned long count)
266{
267 badio(outsw, port);
268}
diff --git a/arch/sh/boards/se/7300/irq.c b/arch/sh/boards/se/7300/irq.c
deleted file mode 100644
index 1279d776d60f..000000000000
--- a/arch/sh/boards/se/7300/irq.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * linux/arch/sh/boards/se/7300/irq.c
3 *
4 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
5 *
6 * SH-Mobile SolutionEngine 7300 Support.
7 *
8 */
9
10#include <linux/init.h>
11#include <linux/irq.h>
12#include <asm/irq.h>
13#include <asm/io.h>
14#include <asm/se7300.h>
15
16static struct ipr_data se7300_ipr_map[] = {
17 /* PC_IRQ[0-3] -> IRQ0 (32) */
18 { IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, 0x0f - IRQ0_IRQ },
19 /* A_IRQ[0-3] -> IRQ1 (33) */
20 { IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, 0x0f - IRQ1_IRQ },
21 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
22 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
23 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
24 { VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
25};
26
27/*
28 * Initialize IRQ setting
29 */
30void __init
31init_7300se_IRQ(void)
32{
33 ctrl_outw(0x0028, PA_EPLD_MODESET); /* mode set IRQ0,1 active low. */
34 ctrl_outw(0xa000, INTC_ICR1); /* IRQ mode; IRQ0,1 enable. */
35 ctrl_outw(0x0000, PORT_PFCR); /* use F for IRQ[3:0] and SIU. */
36
37 make_ipr_irq(se7300_ipr_map, ARRAY_SIZE(se7300_ipr_map));
38
39 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */
40}
diff --git a/arch/sh/boards/se/7300/setup.c b/arch/sh/boards/se/7300/setup.c
deleted file mode 100644
index eb469f5b6e97..000000000000
--- a/arch/sh/boards/se/7300/setup.c
+++ /dev/null
@@ -1,74 +0,0 @@
1/*
2 * linux/arch/sh/boards/se/7300/setup.c
3 *
4 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
5 *
6 * SH-Mobile SolutionEngine 7300 Support.
7 *
8 */
9#include <linux/init.h>
10#include <linux/platform_device.h>
11#include <asm/machvec.h>
12#include <asm/se7300.h>
13
14void init_7300se_IRQ(void);
15
16static unsigned char heartbeat_bit_pos[] = { 8, 9, 10, 11, 12, 13, 14, 15 };
17
18static struct resource heartbeat_resources[] = {
19 [0] = {
20 .start = PA_LED,
21 .end = PA_LED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
22 .flags = IORESOURCE_MEM,
23 },
24};
25
26static struct platform_device heartbeat_device = {
27 .name = "heartbeat",
28 .id = -1,
29 .dev = {
30 .platform_data = heartbeat_bit_pos,
31 },
32 .num_resources = ARRAY_SIZE(heartbeat_resources),
33 .resource = heartbeat_resources,
34};
35
36static struct platform_device *se7300_devices[] __initdata = {
37 &heartbeat_device,
38};
39
40static int __init se7300_devices_setup(void)
41{
42 return platform_add_devices(se7300_devices, ARRAY_SIZE(se7300_devices));
43}
44__initcall(se7300_devices_setup);
45
46/*
47 * The Machine Vector
48 */
49static struct sh_machine_vector mv_7300se __initmv = {
50 .mv_name = "SolutionEngine 7300",
51 .mv_nr_irqs = 109,
52 .mv_inb = sh7300se_inb,
53 .mv_inw = sh7300se_inw,
54 .mv_inl = sh7300se_inl,
55 .mv_outb = sh7300se_outb,
56 .mv_outw = sh7300se_outw,
57 .mv_outl = sh7300se_outl,
58
59 .mv_inb_p = sh7300se_inb_p,
60 .mv_inw_p = sh7300se_inw,
61 .mv_inl_p = sh7300se_inl,
62 .mv_outb_p = sh7300se_outb_p,
63 .mv_outw_p = sh7300se_outw,
64 .mv_outl_p = sh7300se_outl,
65
66 .mv_insb = sh7300se_insb,
67 .mv_insw = sh7300se_insw,
68 .mv_insl = sh7300se_insl,
69 .mv_outsb = sh7300se_outsb,
70 .mv_outsw = sh7300se_outsw,
71 .mv_outsl = sh7300se_outsl,
72
73 .mv_init_irq = init_7300se_IRQ,
74};
diff --git a/arch/sh/boards/se/73180/Makefile b/arch/sh/boards/se/73180/Makefile
deleted file mode 100644
index e7c09967c529..000000000000
--- a/arch/sh/boards/se/73180/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for the 73180 SolutionEngine specific parts of the kernel
3#
4
5obj-y := setup.o io.o irq.o
diff --git a/arch/sh/boards/se/73180/io.c b/arch/sh/boards/se/73180/io.c
deleted file mode 100644
index 72715575458b..000000000000
--- a/arch/sh/boards/se/73180/io.c
+++ /dev/null
@@ -1,268 +0,0 @@
1/*
2 * arch/sh/boards/se/73180/io.c
3 *
4 * Copyright (C) 2003 YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
5 * Based on arch/sh/boards/se/7300/io.c
6 *
7 * I/O routine for SH-Mobile3 73180 SolutionEngine.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <asm/mach/se73180.h>
13#include <asm/io.h>
14
15#define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
16
17struct iop {
18 unsigned long start, end;
19 unsigned long base;
20 struct iop *(*check) (struct iop * p, unsigned long port);
21 unsigned char (*inb) (struct iop * p, unsigned long port);
22 unsigned short (*inw) (struct iop * p, unsigned long port);
23 void (*outb) (struct iop * p, unsigned char value, unsigned long port);
24 void (*outw) (struct iop * p, unsigned short value, unsigned long port);
25};
26
27struct iop *
28simple_check(struct iop *p, unsigned long port)
29{
30 if ((p->start <= port) && (port <= p->end))
31 return p;
32 else
33 badio(check, port);
34}
35
36struct iop *
37ide_check(struct iop *p, unsigned long port)
38{
39 if (((0x1f0 <= port) && (port <= 0x1f7)) || (port == 0x3f7))
40 return p;
41 return NULL;
42}
43
44unsigned char
45simple_inb(struct iop *p, unsigned long port)
46{
47 return *(unsigned char *) (p->base + port);
48}
49
50unsigned short
51simple_inw(struct iop *p, unsigned long port)
52{
53 return *(unsigned short *) (p->base + port);
54}
55
56void
57simple_outb(struct iop *p, unsigned char value, unsigned long port)
58{
59 *(unsigned char *) (p->base + port) = value;
60}
61
62void
63simple_outw(struct iop *p, unsigned short value, unsigned long port)
64{
65 *(unsigned short *) (p->base + port) = value;
66}
67
68unsigned char
69pcc_inb(struct iop *p, unsigned long port)
70{
71 unsigned long addr = p->base + port + 0x40000;
72 unsigned long v;
73
74 if (port & 1)
75 addr += 0x00400000;
76 v = *(volatile unsigned char *) addr;
77 return v;
78}
79
80void
81pcc_outb(struct iop *p, unsigned char value, unsigned long port)
82{
83 unsigned long addr = p->base + port + 0x40000;
84
85 if (port & 1)
86 addr += 0x00400000;
87 *(volatile unsigned char *) addr = value;
88}
89
90unsigned char
91bad_inb(struct iop *p, unsigned long port)
92{
93 badio(inb, port);
94}
95
96void
97bad_outb(struct iop *p, unsigned char value, unsigned long port)
98{
99 badio(inw, port);
100}
101
102#ifdef CONFIG_SMC91X
103/* MSTLANEX01 LAN at 0xb400:0000 */
104static struct iop laniop = {
105 .start = 0x300,
106 .end = 0x30f,
107 .base = 0xb4000000,
108 .check = simple_check,
109 .inb = simple_inb,
110 .inw = simple_inw,
111 .outb = simple_outb,
112 .outw = simple_outw,
113};
114#endif
115
116/* NE2000 pc card NIC */
117static struct iop neiop = {
118 .start = 0x280,
119 .end = 0x29f,
120 .base = 0xb0600000 + 0x80, /* soft 0x280 -> hard 0x300 */
121 .check = simple_check,
122 .inb = pcc_inb,
123 .inw = simple_inw,
124 .outb = pcc_outb,
125 .outw = simple_outw,
126};
127
128#ifdef CONFIG_IDE
129/* CF in CF slot */
130static struct iop cfiop = {
131 .base = 0xb0600000,
132 .check = ide_check,
133 .inb = pcc_inb,
134 .inw = simple_inw,
135 .outb = pcc_outb,
136 .outw = simple_outw,
137};
138#endif
139
140static __inline__ struct iop *
141port2iop(unsigned long port)
142{
143 if (0) ;
144#if defined(CONFIG_SMC91X)
145 else if (laniop.check(&laniop, port))
146 return &laniop;
147#endif
148#if defined(CONFIG_NE2000)
149 else if (neiop.check(&neiop, port))
150 return &neiop;
151#endif
152#if defined(CONFIG_IDE)
153 else if (cfiop.check(&cfiop, port))
154 return &cfiop;
155#endif
156 else
157 return &neiop; /* fallback */
158}
159
160static inline void
161delay(void)
162{
163 ctrl_inw(0xac000000);
164 ctrl_inw(0xac000000);
165}
166
167unsigned char
168sh73180se_inb(unsigned long port)
169{
170 struct iop *p = port2iop(port);
171 return (p->inb) (p, port);
172}
173
174unsigned char
175sh73180se_inb_p(unsigned long port)
176{
177 unsigned char v = sh73180se_inb(port);
178 delay();
179 return v;
180}
181
182unsigned short
183sh73180se_inw(unsigned long port)
184{
185 struct iop *p = port2iop(port);
186 return (p->inw) (p, port);
187}
188
189unsigned int
190sh73180se_inl(unsigned long port)
191{
192 badio(inl, port);
193}
194
195void
196sh73180se_outb(unsigned char value, unsigned long port)
197{
198 struct iop *p = port2iop(port);
199 (p->outb) (p, value, port);
200}
201
202void
203sh73180se_outb_p(unsigned char value, unsigned long port)
204{
205 sh73180se_outb(value, port);
206 delay();
207}
208
209void
210sh73180se_outw(unsigned short value, unsigned long port)
211{
212 struct iop *p = port2iop(port);
213 (p->outw) (p, value, port);
214}
215
216void
217sh73180se_outl(unsigned int value, unsigned long port)
218{
219 badio(outl, port);
220}
221
222void
223sh73180se_insb(unsigned long port, void *addr, unsigned long count)
224{
225 unsigned char *a = addr;
226 struct iop *p = port2iop(port);
227 while (count--)
228 *a++ = (p->inb) (p, port);
229}
230
231void
232sh73180se_insw(unsigned long port, void *addr, unsigned long count)
233{
234 unsigned short *a = addr;
235 struct iop *p = port2iop(port);
236 while (count--)
237 *a++ = (p->inw) (p, port);
238}
239
240void
241sh73180se_insl(unsigned long port, void *addr, unsigned long count)
242{
243 badio(insl, port);
244}
245
246void
247sh73180se_outsb(unsigned long port, const void *addr, unsigned long count)
248{
249 unsigned char *a = (unsigned char *) addr;
250 struct iop *p = port2iop(port);
251 while (count--)
252 (p->outb) (p, *a++, port);
253}
254
255void
256sh73180se_outsw(unsigned long port, const void *addr, unsigned long count)
257{
258 unsigned short *a = (unsigned short *) addr;
259 struct iop *p = port2iop(port);
260 while (count--)
261 (p->outw) (p, *a++, port);
262}
263
264void
265sh73180se_outsl(unsigned long port, const void *addr, unsigned long count)
266{
267 badio(outsw, port);
268}
diff --git a/arch/sh/boards/se/73180/irq.c b/arch/sh/boards/se/73180/irq.c
deleted file mode 100644
index e7200c56bb45..000000000000
--- a/arch/sh/boards/se/73180/irq.c
+++ /dev/null
@@ -1,136 +0,0 @@
1/*
2 * arch/sh/boards/se/73180/irq.c
3 *
4 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
5 * Based on arch/sh/boards/se/7300/irq.c
6 *
7 * Modified for SH-Mobile SolutionEngine 73180 Support
8 * by YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
9 *
10 */
11
12#include <linux/init.h>
13#include <linux/irq.h>
14#include <asm/irq.h>
15#include <asm/io.h>
16#include <asm/mach/se73180.h>
17
18static int
19irq2intreq(int irq)
20{
21 if (irq == 10)
22 return 5;
23 return 7 - (irq - 32);
24}
25
26static void
27disable_intreq_irq(unsigned int irq)
28{
29 ctrl_outb(1 << (7 - irq2intreq(irq)), INTMSK0);
30}
31
32static void
33enable_intreq_irq(unsigned int irq)
34{
35 ctrl_outb(1 << (7 - irq2intreq(irq)), INTMSKCLR0);
36}
37
38static void
39mask_and_ack_intreq_irq(unsigned int irq)
40{
41 disable_intreq_irq(irq);
42}
43
44static unsigned int
45startup_intreq_irq(unsigned int irq)
46{
47 enable_intreq_irq(irq);
48 return 0;
49}
50
51static void
52shutdown_intreq_irq(unsigned int irq)
53{
54 disable_intreq_irq(irq);
55}
56
57static void
58end_intreq_irq(unsigned int irq)
59{
60 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
61 enable_intreq_irq(irq);
62}
63
64static struct hw_interrupt_type intreq_irq_type = {
65 .typename = "intreq",
66 .startup = startup_intreq_irq,
67 .shutdown = shutdown_intreq_irq,
68 .enable = enable_intreq_irq,
69 .disable = disable_intreq_irq,
70 .ack = mask_and_ack_intreq_irq,
71 .end = end_intreq_irq
72};
73
74void
75make_intreq_irq(unsigned int irq)
76{
77 disable_irq_nosync(irq);
78 irq_desc[irq].chip = &intreq_irq_type;
79 disable_intreq_irq(irq);
80}
81
82int
83shmse_irq_demux(int irq)
84{
85 if (irq == IRQ5_IRQ)
86 return 10;
87 return irq;
88}
89
90static struct ipr_data se73180_siof0_ipr_map[] = {
91 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
92};
93static struct ipr_data se73180_vpu_ipr_map[] = {
94 { VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8 },
95};
96static struct ipr_data se73180_other_ipr_map[] = {
97 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
98 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
99 { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
100 { IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
101 { IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
102 { IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
103 { IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
104 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
105 { SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY },
106
107 /* VIO interrupt */
108 { CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
109 { BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
110 { VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
111
112 { LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY },
113};
114
115/*
116 * Initialize IRQ setting
117 */
118void __init
119init_73180se_IRQ(void)
120{
121 make_ipr_irq(se73180_siof0_ipr_map, ARRAY_SIZE(se73180_siof0_ipr_map));
122
123 ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */
124 ctrl_outw(0x2000, 0xb07fffec); /* mrshpc irq enable */
125 ctrl_outl(3 << ((7 - 5) * 4), INTC_INTPRI0); /* irq5 pri=3 */
126 ctrl_outw(2 << ((7 - 5) * 2), INTC_ICR1); /* low-level irq */
127 make_intreq_irq(10);
128
129 make_ipr_irq(se73180_vpu_ipr_map, ARRAY_SIZE(se73180_vpu_ipr_map));
130
131 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */
132
133 make_ipr_irq(se73180_other_ipr_map, ARRAY_SIZE(se73180_other_ipr_map));
134
135 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */
136}
diff --git a/arch/sh/boards/se/73180/setup.c b/arch/sh/boards/se/73180/setup.c
deleted file mode 100644
index 1deee8556642..000000000000
--- a/arch/sh/boards/se/73180/setup.c
+++ /dev/null
@@ -1,75 +0,0 @@
1/*
2 * arch/sh/boards/se/73180/setup.c
3 *
4 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
5 * Based on arch/sh/setup_shmse.c
6 *
7 * Modified for 73180 SolutionEngine
8 * by YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
9 *
10 */
11
12#include <linux/init.h>
13#include <linux/platform_device.h>
14#include <asm/machvec.h>
15#include <asm/se73180.h>
16#include <asm/irq.h>
17
18void init_73180se_IRQ(void);
19
20static struct resource heartbeat_resources[] = {
21 [0] = {
22 .start = PA_LED,
23 .end = PA_LED + 8 - 1,
24 .flags = IORESOURCE_MEM,
25 },
26};
27
28static struct platform_device heartbeat_device = {
29 .name = "heartbeat",
30 .id = -1,
31 .num_resources = ARRAY_SIZE(heartbeat_resources),
32 .resource = heartbeat_resources,
33};
34
35static struct platform_device *se73180_devices[] __initdata = {
36 &heartbeat_device,
37};
38
39static int __init se73180_devices_setup(void)
40{
41 return platform_add_devices(se73180_devices,
42 ARRAY_SIZE(se73180_devices));
43}
44__initcall(se73180_devices_setup);
45
46/*
47 * The Machine Vector
48 */
49static struct sh_machine_vector mv_73180se __initmv = {
50 .mv_name = "SolutionEngine 73180",
51 .mv_nr_irqs = 108,
52 .mv_inb = sh73180se_inb,
53 .mv_inw = sh73180se_inw,
54 .mv_inl = sh73180se_inl,
55 .mv_outb = sh73180se_outb,
56 .mv_outw = sh73180se_outw,
57 .mv_outl = sh73180se_outl,
58
59 .mv_inb_p = sh73180se_inb_p,
60 .mv_inw_p = sh73180se_inw,
61 .mv_inl_p = sh73180se_inl,
62 .mv_outb_p = sh73180se_outb_p,
63 .mv_outw_p = sh73180se_outw,
64 .mv_outl_p = sh73180se_outl,
65
66 .mv_insb = sh73180se_insb,
67 .mv_insw = sh73180se_insw,
68 .mv_insl = sh73180se_insl,
69 .mv_outsb = sh73180se_outsb,
70 .mv_outsw = sh73180se_outsw,
71 .mv_outsl = sh73180se_outsl,
72
73 .mv_init_irq = init_73180se_IRQ,
74 .mv_irq_demux = shmse_irq_demux,
75};
diff --git a/arch/sh/boot/Makefile b/arch/sh/boot/Makefile
index 11dc272c618e..4c5ffdcd55b6 100644
--- a/arch/sh/boot/Makefile
+++ b/arch/sh/boot/Makefile
@@ -32,9 +32,10 @@ $(obj)/zImage: $(obj)/compressed/vmlinux FORCE
32$(obj)/compressed/vmlinux: FORCE 32$(obj)/compressed/vmlinux: FORCE
33 $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 33 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
34 34
35KERNEL_LOAD := $(shell printf "0x%8x" $$[$(CONFIG_PAGE_OFFSET) + \ 35KERNEL_LOAD := $(shell /bin/bash -c 'printf "0x%8x" \
36 $(CONFIG_MEMORY_START) + \ 36 $$[$(CONFIG_PAGE_OFFSET) + \
37 $(CONFIG_ZERO_PAGE_OFFSET)+0x1000]) 37 $(CONFIG_MEMORY_START) + \
38 $(CONFIG_ZERO_PAGE_OFFSET)+0x1000]')
38 39
39quiet_cmd_uimage = UIMAGE $@ 40quiet_cmd_uimage = UIMAGE $@
40 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sh -O linux -T kernel \ 41 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sh -O linux -T kernel \
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
index d9512416f885..013504ae1122 100644
--- a/arch/sh/boot/compressed/Makefile
+++ b/arch/sh/boot/compressed/Makefile
@@ -16,9 +16,10 @@ endif
16# 16#
17# IMAGE_OFFSET is the load offset of the compression loader 17# IMAGE_OFFSET is the load offset of the compression loader
18# 18#
19IMAGE_OFFSET := $(shell printf "0x%08x" $$[$(CONFIG_PAGE_OFFSET) + \ 19IMAGE_OFFSET := $(shell /bin/bash -c 'printf "0x%08x" \
20 $(CONFIG_MEMORY_START) + \ 20 $$[$(CONFIG_PAGE_OFFSET) + \
21 $(CONFIG_BOOT_LINK_OFFSET)]) 21 $(CONFIG_MEMORY_START) + \
22 $(CONFIG_BOOT_LINK_OFFSET)]')
22 23
23LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) 24LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
24 25
diff --git a/arch/sh/configs/se7300_defconfig b/arch/sh/configs/se7300_defconfig
deleted file mode 100644
index 8a217908b81f..000000000000
--- a/arch/sh/configs/se7300_defconfig
+++ /dev/null
@@ -1,696 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18
4# Tue Oct 3 11:43:22 2006
5#
6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y
8CONFIG_GENERIC_FIND_NEXT_BIT=y
9CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y
13CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
14
15#
16# Code maturity level options
17#
18CONFIG_EXPERIMENTAL=y
19CONFIG_BROKEN_ON_SMP=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
21
22#
23# General setup
24#
25CONFIG_LOCALVERSION=""
26CONFIG_LOCALVERSION_AUTO=y
27# CONFIG_SWAP is not set
28# CONFIG_SYSVIPC is not set
29# CONFIG_BSD_PROCESS_ACCT is not set
30# CONFIG_UTS_NS is not set
31# CONFIG_IKCONFIG is not set
32# CONFIG_RELAY is not set
33CONFIG_INITRAMFS_SOURCE=""
34# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
35CONFIG_SYSCTL=y
36CONFIG_EMBEDDED=y
37CONFIG_UID16=y
38# CONFIG_SYSCTL_SYSCALL is not set
39# CONFIG_KALLSYMS is not set
40# CONFIG_HOTPLUG is not set
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_ELF_CORE=y
44CONFIG_BASE_FULL=y
45# CONFIG_FUTEX is not set
46# CONFIG_EPOLL is not set
47CONFIG_SHMEM=y
48CONFIG_SLAB=y
49CONFIG_VM_EVENT_COUNTERS=y
50# CONFIG_TINY_SHMEM is not set
51CONFIG_BASE_SMALL=0
52# CONFIG_SLOB is not set
53
54#
55# Loadable module support
56#
57# CONFIG_MODULES is not set
58
59#
60# Block layer
61#
62CONFIG_BLOCK=y
63# CONFIG_LBD is not set
64# CONFIG_BLK_DEV_IO_TRACE is not set
65# CONFIG_LSF is not set
66
67#
68# IO Schedulers
69#
70CONFIG_IOSCHED_NOOP=y
71# CONFIG_IOSCHED_AS is not set
72# CONFIG_IOSCHED_DEADLINE is not set
73# CONFIG_IOSCHED_CFQ is not set
74# CONFIG_DEFAULT_AS is not set
75# CONFIG_DEFAULT_DEADLINE is not set
76# CONFIG_DEFAULT_CFQ is not set
77CONFIG_DEFAULT_NOOP=y
78CONFIG_DEFAULT_IOSCHED="noop"
79
80#
81# System type
82#
83CONFIG_SOLUTION_ENGINE=y
84# CONFIG_SH_SOLUTION_ENGINE is not set
85# CONFIG_SH_7751_SOLUTION_ENGINE is not set
86CONFIG_SH_7300_SOLUTION_ENGINE=y
87# CONFIG_SH_7343_SOLUTION_ENGINE is not set
88# CONFIG_SH_73180_SOLUTION_ENGINE is not set
89# CONFIG_SH_7751_SYSTEMH is not set
90# CONFIG_SH_HP6XX is not set
91# CONFIG_SH_EC3104 is not set
92# CONFIG_SH_SATURN is not set
93# CONFIG_SH_DREAMCAST is not set
94# CONFIG_SH_BIGSUR is not set
95# CONFIG_SH_MPC1211 is not set
96# CONFIG_SH_SH03 is not set
97# CONFIG_SH_SECUREEDGE5410 is not set
98# CONFIG_SH_HS7751RVOIP is not set
99# CONFIG_SH_7710VOIPGW is not set
100# CONFIG_SH_RTS7751R2D is not set
101# CONFIG_SH_R7780RP is not set
102# CONFIG_SH_EDOSK7705 is not set
103# CONFIG_SH_SH4202_MICRODEV is not set
104# CONFIG_SH_LANDISK is not set
105# CONFIG_SH_TITAN is not set
106# CONFIG_SH_SHMIN is not set
107# CONFIG_SH_UNKNOWN is not set
108
109#
110# Processor selection
111#
112CONFIG_CPU_SH3=y
113
114#
115# SH-2 Processor Support
116#
117# CONFIG_CPU_SUBTYPE_SH7604 is not set
118
119#
120# SH-3 Processor Support
121#
122CONFIG_CPU_SUBTYPE_SH7300=y
123# CONFIG_CPU_SUBTYPE_SH7705 is not set
124# CONFIG_CPU_SUBTYPE_SH7706 is not set
125# CONFIG_CPU_SUBTYPE_SH7707 is not set
126# CONFIG_CPU_SUBTYPE_SH7708 is not set
127# CONFIG_CPU_SUBTYPE_SH7709 is not set
128# CONFIG_CPU_SUBTYPE_SH7710 is not set
129
130#
131# SH-4 Processor Support
132#
133# CONFIG_CPU_SUBTYPE_SH7750 is not set
134# CONFIG_CPU_SUBTYPE_SH7091 is not set
135# CONFIG_CPU_SUBTYPE_SH7750R is not set
136# CONFIG_CPU_SUBTYPE_SH7750S is not set
137# CONFIG_CPU_SUBTYPE_SH7751 is not set
138# CONFIG_CPU_SUBTYPE_SH7751R is not set
139# CONFIG_CPU_SUBTYPE_SH7760 is not set
140# CONFIG_CPU_SUBTYPE_SH4_202 is not set
141
142#
143# ST40 Processor Support
144#
145# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
146# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
147
148#
149# SH-4A Processor Support
150#
151# CONFIG_CPU_SUBTYPE_SH7770 is not set
152# CONFIG_CPU_SUBTYPE_SH7780 is not set
153
154#
155# SH4AL-DSP Processor Support
156#
157# CONFIG_CPU_SUBTYPE_SH73180 is not set
158# CONFIG_CPU_SUBTYPE_SH7343 is not set
159
160#
161# Memory management options
162#
163CONFIG_MMU=y
164CONFIG_PAGE_OFFSET=0x80000000
165CONFIG_MEMORY_START=0x0c000000
166CONFIG_MEMORY_SIZE=0x04000000
167CONFIG_VSYSCALL=y
168CONFIG_SELECT_MEMORY_MODEL=y
169CONFIG_FLATMEM_MANUAL=y
170# CONFIG_DISCONTIGMEM_MANUAL is not set
171# CONFIG_SPARSEMEM_MANUAL is not set
172CONFIG_FLATMEM=y
173CONFIG_FLAT_NODE_MEM_MAP=y
174# CONFIG_SPARSEMEM_STATIC is not set
175CONFIG_SPLIT_PTLOCK_CPUS=4
176# CONFIG_RESOURCES_64BIT is not set
177
178#
179# Cache configuration
180#
181# CONFIG_SH_DIRECT_MAPPED is not set
182# CONFIG_SH_WRITETHROUGH is not set
183# CONFIG_SH_OCRAM is not set
184
185#
186# Processor features
187#
188CONFIG_CPU_LITTLE_ENDIAN=y
189# CONFIG_SH_FPU_EMU is not set
190CONFIG_SH_DSP=y
191# CONFIG_SH_ADC is not set
192CONFIG_CPU_HAS_INTEVT=y
193CONFIG_CPU_HAS_SR_RB=y
194
195#
196# Timer support
197#
198CONFIG_SH_TMU=y
199CONFIG_SH_PCLK_FREQ=33333333
200
201#
202# CPU Frequency scaling
203#
204# CONFIG_CPU_FREQ is not set
205
206#
207# DMA support
208#
209# CONFIG_SH_DMA is not set
210
211#
212# Companion Chips
213#
214# CONFIG_HD6446X_SERIES is not set
215CONFIG_HEARTBEAT=y
216
217#
218# Kernel features
219#
220# CONFIG_HZ_100 is not set
221CONFIG_HZ_250=y
222# CONFIG_HZ_1000 is not set
223CONFIG_HZ=250
224# CONFIG_KEXEC is not set
225# CONFIG_SMP is not set
226CONFIG_PREEMPT_NONE=y
227# CONFIG_PREEMPT_VOLUNTARY is not set
228# CONFIG_PREEMPT is not set
229
230#
231# Boot options
232#
233CONFIG_ZERO_PAGE_OFFSET=0x00001000
234CONFIG_BOOT_LINK_OFFSET=0x00210000
235# CONFIG_UBC_WAKEUP is not set
236CONFIG_CMDLINE_BOOL=y
237CONFIG_CMDLINE="console=ttySC0,38400 root=/dev/ram0"
238
239#
240# Bus options
241#
242# CONFIG_PCI is not set
243
244#
245# PCCARD (PCMCIA/CardBus) support
246#
247
248#
249# PCI Hotplug Support
250#
251
252#
253# Executable file formats
254#
255CONFIG_BINFMT_ELF=y
256# CONFIG_BINFMT_FLAT is not set
257# CONFIG_BINFMT_MISC is not set
258
259#
260# Power management options (EXPERIMENTAL)
261#
262# CONFIG_PM is not set
263
264#
265# Networking
266#
267# CONFIG_NET is not set
268
269#
270# Device Drivers
271#
272
273#
274# Generic Driver Options
275#
276CONFIG_STANDALONE=y
277CONFIG_PREVENT_FIRMWARE_BUILD=y
278# CONFIG_SYS_HYPERVISOR is not set
279
280#
281# Connector - unified userspace <-> kernelspace linker
282#
283
284#
285# Memory Technology Devices (MTD)
286#
287# CONFIG_MTD is not set
288
289#
290# Parallel port support
291#
292# CONFIG_PARPORT is not set
293
294#
295# Plug and Play support
296#
297
298#
299# Block devices
300#
301# CONFIG_BLK_DEV_COW_COMMON is not set
302# CONFIG_BLK_DEV_LOOP is not set
303CONFIG_BLK_DEV_RAM=y
304CONFIG_BLK_DEV_RAM_COUNT=16
305CONFIG_BLK_DEV_RAM_SIZE=4096
306CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
307CONFIG_BLK_DEV_INITRD=y
308# CONFIG_CDROM_PKTCDVD is not set
309
310#
311# ATA/ATAPI/MFM/RLL support
312#
313# CONFIG_IDE is not set
314
315#
316# SCSI device support
317#
318# CONFIG_RAID_ATTRS is not set
319# CONFIG_SCSI is not set
320# CONFIG_SCSI_NETLINK is not set
321
322#
323# Serial ATA (prod) and Parallel ATA (experimental) drivers
324#
325# CONFIG_ATA is not set
326
327#
328# Multi-device support (RAID and LVM)
329#
330# CONFIG_MD is not set
331
332#
333# Fusion MPT device support
334#
335# CONFIG_FUSION is not set
336
337#
338# IEEE 1394 (FireWire) support
339#
340
341#
342# I2O device support
343#
344
345#
346# ISDN subsystem
347#
348
349#
350# Telephony Support
351#
352# CONFIG_PHONE is not set
353
354#
355# Input device support
356#
357CONFIG_INPUT=y
358# CONFIG_INPUT_FF_MEMLESS is not set
359
360#
361# Userland interfaces
362#
363CONFIG_INPUT_MOUSEDEV=y
364CONFIG_INPUT_MOUSEDEV_PSAUX=y
365CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
366CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
367# CONFIG_INPUT_JOYDEV is not set
368# CONFIG_INPUT_TSDEV is not set
369# CONFIG_INPUT_EVDEV is not set
370# CONFIG_INPUT_EVBUG is not set
371
372#
373# Input Device Drivers
374#
375# CONFIG_INPUT_KEYBOARD is not set
376# CONFIG_INPUT_MOUSE is not set
377# CONFIG_INPUT_JOYSTICK is not set
378# CONFIG_INPUT_TOUCHSCREEN is not set
379# CONFIG_INPUT_MISC is not set
380
381#
382# Hardware I/O ports
383#
384CONFIG_SERIO=y
385# CONFIG_SERIO_I8042 is not set
386# CONFIG_SERIO_SERPORT is not set
387# CONFIG_SERIO_LIBPS2 is not set
388# CONFIG_SERIO_RAW is not set
389# CONFIG_GAMEPORT is not set
390
391#
392# Character devices
393#
394# CONFIG_VT is not set
395# CONFIG_SERIAL_NONSTANDARD is not set
396
397#
398# Serial drivers
399#
400# CONFIG_SERIAL_8250 is not set
401
402#
403# Non-8250 serial port support
404#
405CONFIG_SERIAL_SH_SCI=y
406CONFIG_SERIAL_SH_SCI_NR_UARTS=2
407CONFIG_SERIAL_SH_SCI_CONSOLE=y
408CONFIG_SERIAL_CORE=y
409CONFIG_SERIAL_CORE_CONSOLE=y
410# CONFIG_UNIX98_PTYS is not set
411# CONFIG_LEGACY_PTYS is not set
412
413#
414# IPMI
415#
416CONFIG_IPMI_HANDLER=y
417# CONFIG_IPMI_PANIC_EVENT is not set
418CONFIG_IPMI_DEVICE_INTERFACE=y
419# CONFIG_IPMI_SI is not set
420CONFIG_IPMI_WATCHDOG=y
421# CONFIG_IPMI_POWEROFF is not set
422
423#
424# Watchdog Cards
425#
426CONFIG_WATCHDOG=y
427# CONFIG_WATCHDOG_NOWAYOUT is not set
428
429#
430# Watchdog Device Drivers
431#
432CONFIG_SOFT_WATCHDOG=y
433# CONFIG_SH_WDT is not set
434CONFIG_HW_RANDOM=y
435# CONFIG_GEN_RTC is not set
436# CONFIG_DTLK is not set
437# CONFIG_R3964 is not set
438
439#
440# Ftape, the floppy tape device driver
441#
442# CONFIG_RAW_DRIVER is not set
443
444#
445# TPM devices
446#
447# CONFIG_TCG_TPM is not set
448# CONFIG_TELCLOCK is not set
449
450#
451# I2C support
452#
453# CONFIG_I2C is not set
454
455#
456# SPI support
457#
458# CONFIG_SPI is not set
459# CONFIG_SPI_MASTER is not set
460
461#
462# Dallas's 1-wire bus
463#
464
465#
466# Hardware Monitoring support
467#
468CONFIG_HWMON=y
469# CONFIG_HWMON_VID is not set
470# CONFIG_SENSORS_ABITUGURU is not set
471# CONFIG_SENSORS_F71805F is not set
472# CONFIG_SENSORS_VT1211 is not set
473# CONFIG_HWMON_DEBUG_CHIP is not set
474
475#
476# Misc devices
477#
478
479#
480# Multimedia devices
481#
482# CONFIG_VIDEO_DEV is not set
483CONFIG_VIDEO_V4L2=y
484
485#
486# Digital Video Broadcasting Devices
487#
488
489#
490# Graphics support
491#
492CONFIG_FIRMWARE_EDID=y
493# CONFIG_FB is not set
494# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
495
496#
497# Sound
498#
499# CONFIG_SOUND is not set
500
501#
502# USB support
503#
504# CONFIG_USB_ARCH_HAS_HCD is not set
505# CONFIG_USB_ARCH_HAS_OHCI is not set
506# CONFIG_USB_ARCH_HAS_EHCI is not set
507
508#
509# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
510#
511
512#
513# USB Gadget Support
514#
515# CONFIG_USB_GADGET is not set
516
517#
518# MMC/SD Card support
519#
520# CONFIG_MMC is not set
521
522#
523# LED devices
524#
525# CONFIG_NEW_LEDS is not set
526
527#
528# LED drivers
529#
530
531#
532# LED Triggers
533#
534
535#
536# InfiniBand support
537#
538
539#
540# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
541#
542
543#
544# Real Time Clock
545#
546# CONFIG_RTC_CLASS is not set
547
548#
549# DMA Engine support
550#
551# CONFIG_DMA_ENGINE is not set
552
553#
554# DMA Clients
555#
556
557#
558# DMA Devices
559#
560
561#
562# File systems
563#
564CONFIG_EXT2_FS=y
565# CONFIG_EXT2_FS_XATTR is not set
566# CONFIG_EXT2_FS_XIP is not set
567# CONFIG_EXT3_FS is not set
568# CONFIG_REISERFS_FS is not set
569# CONFIG_JFS_FS is not set
570# CONFIG_FS_POSIX_ACL is not set
571# CONFIG_XFS_FS is not set
572# CONFIG_MINIX_FS is not set
573# CONFIG_ROMFS_FS is not set
574CONFIG_INOTIFY=y
575CONFIG_INOTIFY_USER=y
576# CONFIG_QUOTA is not set
577CONFIG_DNOTIFY=y
578# CONFIG_AUTOFS_FS is not set
579# CONFIG_AUTOFS4_FS is not set
580# CONFIG_FUSE_FS is not set
581
582#
583# CD-ROM/DVD Filesystems
584#
585# CONFIG_ISO9660_FS is not set
586# CONFIG_UDF_FS is not set
587
588#
589# DOS/FAT/NT Filesystems
590#
591# CONFIG_MSDOS_FS is not set
592# CONFIG_VFAT_FS is not set
593# CONFIG_NTFS_FS is not set
594
595#
596# Pseudo filesystems
597#
598CONFIG_PROC_FS=y
599CONFIG_PROC_KCORE=y
600CONFIG_PROC_SYSCTL=y
601CONFIG_SYSFS=y
602# CONFIG_TMPFS is not set
603# CONFIG_HUGETLBFS is not set
604# CONFIG_HUGETLB_PAGE is not set
605CONFIG_RAMFS=y
606# CONFIG_CONFIGFS_FS is not set
607
608#
609# Miscellaneous filesystems
610#
611# CONFIG_ADFS_FS is not set
612# CONFIG_AFFS_FS is not set
613# CONFIG_HFS_FS is not set
614# CONFIG_HFSPLUS_FS is not set
615# CONFIG_BEFS_FS is not set
616# CONFIG_BFS_FS is not set
617# CONFIG_EFS_FS is not set
618# CONFIG_CRAMFS is not set
619# CONFIG_VXFS_FS is not set
620# CONFIG_HPFS_FS is not set
621# CONFIG_QNX4FS_FS is not set
622# CONFIG_SYSV_FS is not set
623# CONFIG_UFS_FS is not set
624
625#
626# Partition Types
627#
628# CONFIG_PARTITION_ADVANCED is not set
629CONFIG_MSDOS_PARTITION=y
630
631#
632# Native Language Support
633#
634# CONFIG_NLS is not set
635
636#
637# Profiling support
638#
639# CONFIG_PROFILING is not set
640
641#
642# Kernel hacking
643#
644# CONFIG_PRINTK_TIME is not set
645CONFIG_ENABLE_MUST_CHECK=y
646# CONFIG_MAGIC_SYSRQ is not set
647# CONFIG_UNUSED_SYMBOLS is not set
648# CONFIG_DEBUG_KERNEL is not set
649CONFIG_LOG_BUF_SHIFT=14
650# CONFIG_DEBUG_BUGVERBOSE is not set
651# CONFIG_DEBUG_FS is not set
652CONFIG_FRAME_POINTER=y
653# CONFIG_UNWIND_INFO is not set
654CONFIG_SH_STANDARD_BIOS=y
655CONFIG_EARLY_PRINTK=y
656CONFIG_KGDB=y
657
658#
659# KGDB configuration options
660#
661# CONFIG_MORE_COMPILE_OPTIONS is not set
662# CONFIG_KGDB_NMI is not set
663# CONFIG_KGDB_THREAD is not set
664# CONFIG_SH_KGDB_CONSOLE is not set
665# CONFIG_KGDB_SYSRQ is not set
666# CONFIG_KGDB_KERNEL_ASSERTS is not set
667
668#
669# Serial port setup
670#
671CONFIG_KGDB_DEFPORT=1
672CONFIG_KGDB_DEFBAUD=115200
673CONFIG_KGDB_DEFPARITY_N=y
674# CONFIG_KGDB_DEFPARITY_E is not set
675# CONFIG_KGDB_DEFPARITY_O is not set
676CONFIG_KGDB_DEFBITS_8=y
677# CONFIG_KGDB_DEFBITS_7 is not set
678
679#
680# Security options
681#
682# CONFIG_KEYS is not set
683# CONFIG_SECURITY is not set
684
685#
686# Cryptographic options
687#
688# CONFIG_CRYPTO is not set
689
690#
691# Library routines
692#
693# CONFIG_CRC_CCITT is not set
694# CONFIG_CRC16 is not set
695CONFIG_CRC32=y
696# CONFIG_LIBCRC32C is not set
diff --git a/arch/sh/configs/se73180_defconfig b/arch/sh/configs/se73180_defconfig
deleted file mode 100644
index 1a766153cbb0..000000000000
--- a/arch/sh/configs/se73180_defconfig
+++ /dev/null
@@ -1,648 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18
4# Tue Oct 3 11:44:45 2006
5#
6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y
8CONFIG_GENERIC_FIND_NEXT_BIT=y
9CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y
13CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
14
15#
16# Code maturity level options
17#
18CONFIG_EXPERIMENTAL=y
19CONFIG_BROKEN_ON_SMP=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
21
22#
23# General setup
24#
25CONFIG_LOCALVERSION=""
26CONFIG_LOCALVERSION_AUTO=y
27CONFIG_SWAP=y
28# CONFIG_SYSVIPC is not set
29# CONFIG_BSD_PROCESS_ACCT is not set
30# CONFIG_UTS_NS is not set
31# CONFIG_IKCONFIG is not set
32# CONFIG_RELAY is not set
33CONFIG_INITRAMFS_SOURCE=""
34# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
35CONFIG_SYSCTL=y
36CONFIG_EMBEDDED=y
37CONFIG_UID16=y
38# CONFIG_SYSCTL_SYSCALL is not set
39# CONFIG_KALLSYMS is not set
40# CONFIG_HOTPLUG is not set
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_ELF_CORE=y
44CONFIG_BASE_FULL=y
45# CONFIG_FUTEX is not set
46# CONFIG_EPOLL is not set
47CONFIG_SHMEM=y
48CONFIG_SLAB=y
49CONFIG_VM_EVENT_COUNTERS=y
50# CONFIG_TINY_SHMEM is not set
51CONFIG_BASE_SMALL=0
52# CONFIG_SLOB is not set
53
54#
55# Loadable module support
56#
57CONFIG_MODULES=y
58# CONFIG_MODULE_UNLOAD is not set
59# CONFIG_MODVERSIONS is not set
60# CONFIG_MODULE_SRCVERSION_ALL is not set
61# CONFIG_KMOD is not set
62
63#
64# Block layer
65#
66CONFIG_BLOCK=y
67# CONFIG_LBD is not set
68# CONFIG_LSF is not set
69
70#
71# IO Schedulers
72#
73CONFIG_IOSCHED_NOOP=y
74# CONFIG_IOSCHED_AS is not set
75# CONFIG_IOSCHED_DEADLINE is not set
76# CONFIG_IOSCHED_CFQ is not set
77# CONFIG_DEFAULT_AS is not set
78# CONFIG_DEFAULT_DEADLINE is not set
79# CONFIG_DEFAULT_CFQ is not set
80CONFIG_DEFAULT_NOOP=y
81CONFIG_DEFAULT_IOSCHED="noop"
82
83#
84# System type
85#
86CONFIG_SOLUTION_ENGINE=y
87# CONFIG_SH_SOLUTION_ENGINE is not set
88# CONFIG_SH_7751_SOLUTION_ENGINE is not set
89# CONFIG_SH_7300_SOLUTION_ENGINE is not set
90# CONFIG_SH_7343_SOLUTION_ENGINE is not set
91CONFIG_SH_73180_SOLUTION_ENGINE=y
92# CONFIG_SH_7751_SYSTEMH is not set
93# CONFIG_SH_HP6XX is not set
94# CONFIG_SH_EC3104 is not set
95# CONFIG_SH_SATURN is not set
96# CONFIG_SH_DREAMCAST is not set
97# CONFIG_SH_BIGSUR is not set
98# CONFIG_SH_MPC1211 is not set
99# CONFIG_SH_SH03 is not set
100# CONFIG_SH_SECUREEDGE5410 is not set
101# CONFIG_SH_HS7751RVOIP is not set
102# CONFIG_SH_7710VOIPGW is not set
103# CONFIG_SH_RTS7751R2D is not set
104# CONFIG_SH_R7780RP is not set
105# CONFIG_SH_EDOSK7705 is not set
106# CONFIG_SH_SH4202_MICRODEV is not set
107# CONFIG_SH_LANDISK is not set
108# CONFIG_SH_TITAN is not set
109# CONFIG_SH_SHMIN is not set
110# CONFIG_SH_UNKNOWN is not set
111
112#
113# Processor selection
114#
115CONFIG_CPU_SH4=y
116CONFIG_CPU_SH4A=y
117CONFIG_CPU_SH4AL_DSP=y
118
119#
120# SH-2 Processor Support
121#
122# CONFIG_CPU_SUBTYPE_SH7604 is not set
123
124#
125# SH-3 Processor Support
126#
127# CONFIG_CPU_SUBTYPE_SH7300 is not set
128# CONFIG_CPU_SUBTYPE_SH7705 is not set
129# CONFIG_CPU_SUBTYPE_SH7706 is not set
130# CONFIG_CPU_SUBTYPE_SH7707 is not set
131# CONFIG_CPU_SUBTYPE_SH7708 is not set
132# CONFIG_CPU_SUBTYPE_SH7709 is not set
133# CONFIG_CPU_SUBTYPE_SH7710 is not set
134
135#
136# SH-4 Processor Support
137#
138# CONFIG_CPU_SUBTYPE_SH7750 is not set
139# CONFIG_CPU_SUBTYPE_SH7091 is not set
140# CONFIG_CPU_SUBTYPE_SH7750R is not set
141# CONFIG_CPU_SUBTYPE_SH7750S is not set
142# CONFIG_CPU_SUBTYPE_SH7751 is not set
143# CONFIG_CPU_SUBTYPE_SH7751R is not set
144# CONFIG_CPU_SUBTYPE_SH7760 is not set
145# CONFIG_CPU_SUBTYPE_SH4_202 is not set
146
147#
148# ST40 Processor Support
149#
150# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
151# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
152
153#
154# SH-4A Processor Support
155#
156# CONFIG_CPU_SUBTYPE_SH7770 is not set
157# CONFIG_CPU_SUBTYPE_SH7780 is not set
158
159#
160# SH4AL-DSP Processor Support
161#
162CONFIG_CPU_SUBTYPE_SH73180=y
163# CONFIG_CPU_SUBTYPE_SH7343 is not set
164
165#
166# Memory management options
167#
168CONFIG_MMU=y
169CONFIG_PAGE_OFFSET=0x80000000
170CONFIG_MEMORY_START=0x0c000000
171CONFIG_MEMORY_SIZE=0x02000000
172CONFIG_32BIT=y
173CONFIG_VSYSCALL=y
174CONFIG_SELECT_MEMORY_MODEL=y
175CONFIG_FLATMEM_MANUAL=y
176# CONFIG_DISCONTIGMEM_MANUAL is not set
177# CONFIG_SPARSEMEM_MANUAL is not set
178CONFIG_FLATMEM=y
179CONFIG_FLAT_NODE_MEM_MAP=y
180# CONFIG_SPARSEMEM_STATIC is not set
181CONFIG_SPLIT_PTLOCK_CPUS=4
182# CONFIG_RESOURCES_64BIT is not set
183
184#
185# Cache configuration
186#
187# CONFIG_SH_DIRECT_MAPPED is not set
188# CONFIG_SH_WRITETHROUGH is not set
189# CONFIG_SH_OCRAM is not set
190
191#
192# Processor features
193#
194CONFIG_CPU_LITTLE_ENDIAN=y
195# CONFIG_SH_FPU is not set
196# CONFIG_SH_FPU_EMU is not set
197CONFIG_SH_DSP=y
198# CONFIG_SH_STORE_QUEUES is not set
199CONFIG_CPU_HAS_INTEVT=y
200CONFIG_CPU_HAS_SR_RB=y
201
202#
203# Timer support
204#
205CONFIG_SH_TMU=y
206CONFIG_SH_PCLK_FREQ=27000000
207
208#
209# CPU Frequency scaling
210#
211# CONFIG_CPU_FREQ is not set
212
213#
214# DMA support
215#
216# CONFIG_SH_DMA is not set
217
218#
219# Companion Chips
220#
221# CONFIG_HD6446X_SERIES is not set
222CONFIG_HEARTBEAT=y
223
224#
225# Kernel features
226#
227# CONFIG_HZ_100 is not set
228CONFIG_HZ_250=y
229# CONFIG_HZ_1000 is not set
230CONFIG_HZ=250
231# CONFIG_KEXEC is not set
232# CONFIG_SMP is not set
233CONFIG_PREEMPT_NONE=y
234# CONFIG_PREEMPT_VOLUNTARY is not set
235# CONFIG_PREEMPT is not set
236
237#
238# Boot options
239#
240CONFIG_ZERO_PAGE_OFFSET=0x00010000
241CONFIG_BOOT_LINK_OFFSET=0x00800000
242# CONFIG_UBC_WAKEUP is not set
243CONFIG_CMDLINE_BOOL=y
244CONFIG_CMDLINE="console=ttySC0,38400 root=/dev/ram"
245
246#
247# Bus options
248#
249# CONFIG_PCI is not set
250
251#
252# PCCARD (PCMCIA/CardBus) support
253#
254
255#
256# PCI Hotplug Support
257#
258
259#
260# Executable file formats
261#
262CONFIG_BINFMT_ELF=y
263# CONFIG_BINFMT_FLAT is not set
264# CONFIG_BINFMT_MISC is not set
265
266#
267# Power management options (EXPERIMENTAL)
268#
269# CONFIG_PM is not set
270
271#
272# Networking
273#
274# CONFIG_NET is not set
275
276#
277# Device Drivers
278#
279
280#
281# Generic Driver Options
282#
283CONFIG_STANDALONE=y
284CONFIG_PREVENT_FIRMWARE_BUILD=y
285# CONFIG_SYS_HYPERVISOR is not set
286
287#
288# Connector - unified userspace <-> kernelspace linker
289#
290
291#
292# Memory Technology Devices (MTD)
293#
294# CONFIG_MTD is not set
295
296#
297# Parallel port support
298#
299# CONFIG_PARPORT is not set
300
301#
302# Plug and Play support
303#
304
305#
306# Block devices
307#
308# CONFIG_BLK_DEV_COW_COMMON is not set
309CONFIG_BLK_DEV_LOOP=y
310# CONFIG_BLK_DEV_CRYPTOLOOP is not set
311CONFIG_BLK_DEV_RAM=y
312CONFIG_BLK_DEV_RAM_COUNT=16
313CONFIG_BLK_DEV_RAM_SIZE=4096
314CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
315CONFIG_BLK_DEV_INITRD=y
316# CONFIG_CDROM_PKTCDVD is not set
317
318#
319# ATA/ATAPI/MFM/RLL support
320#
321# CONFIG_IDE is not set
322
323#
324# SCSI device support
325#
326# CONFIG_RAID_ATTRS is not set
327# CONFIG_SCSI is not set
328# CONFIG_SCSI_NETLINK is not set
329
330#
331# Serial ATA (prod) and Parallel ATA (experimental) drivers
332#
333# CONFIG_ATA is not set
334
335#
336# Multi-device support (RAID and LVM)
337#
338# CONFIG_MD is not set
339
340#
341# Fusion MPT device support
342#
343# CONFIG_FUSION is not set
344
345#
346# IEEE 1394 (FireWire) support
347#
348
349#
350# I2O device support
351#
352
353#
354# ISDN subsystem
355#
356
357#
358# Telephony Support
359#
360# CONFIG_PHONE is not set
361
362#
363# Input device support
364#
365# CONFIG_INPUT is not set
366
367#
368# Hardware I/O ports
369#
370# CONFIG_SERIO is not set
371# CONFIG_GAMEPORT is not set
372
373#
374# Character devices
375#
376# CONFIG_VT is not set
377# CONFIG_SERIAL_NONSTANDARD is not set
378
379#
380# Serial drivers
381#
382# CONFIG_SERIAL_8250 is not set
383
384#
385# Non-8250 serial port support
386#
387CONFIG_SERIAL_SH_SCI=y
388CONFIG_SERIAL_SH_SCI_NR_UARTS=2
389CONFIG_SERIAL_SH_SCI_CONSOLE=y
390CONFIG_SERIAL_CORE=y
391CONFIG_SERIAL_CORE_CONSOLE=y
392# CONFIG_UNIX98_PTYS is not set
393# CONFIG_LEGACY_PTYS is not set
394
395#
396# IPMI
397#
398# CONFIG_IPMI_HANDLER is not set
399
400#
401# Watchdog Cards
402#
403CONFIG_WATCHDOG=y
404# CONFIG_WATCHDOG_NOWAYOUT is not set
405
406#
407# Watchdog Device Drivers
408#
409# CONFIG_SOFT_WATCHDOG is not set
410# CONFIG_SH_WDT is not set
411CONFIG_HW_RANDOM=y
412# CONFIG_GEN_RTC is not set
413# CONFIG_DTLK is not set
414# CONFIG_R3964 is not set
415
416#
417# Ftape, the floppy tape device driver
418#
419# CONFIG_RAW_DRIVER is not set
420
421#
422# TPM devices
423#
424# CONFIG_TCG_TPM is not set
425# CONFIG_TELCLOCK is not set
426
427#
428# I2C support
429#
430# CONFIG_I2C is not set
431
432#
433# SPI support
434#
435# CONFIG_SPI is not set
436# CONFIG_SPI_MASTER is not set
437
438#
439# Dallas's 1-wire bus
440#
441
442#
443# Hardware Monitoring support
444#
445CONFIG_HWMON=y
446# CONFIG_HWMON_VID is not set
447# CONFIG_SENSORS_ABITUGURU is not set
448# CONFIG_SENSORS_F71805F is not set
449# CONFIG_SENSORS_VT1211 is not set
450# CONFIG_HWMON_DEBUG_CHIP is not set
451
452#
453# Misc devices
454#
455
456#
457# Multimedia devices
458#
459# CONFIG_VIDEO_DEV is not set
460CONFIG_VIDEO_V4L2=y
461
462#
463# Digital Video Broadcasting Devices
464#
465
466#
467# Graphics support
468#
469CONFIG_FIRMWARE_EDID=y
470# CONFIG_FB is not set
471
472#
473# Sound
474#
475# CONFIG_SOUND is not set
476
477#
478# USB support
479#
480# CONFIG_USB_ARCH_HAS_HCD is not set
481# CONFIG_USB_ARCH_HAS_OHCI is not set
482# CONFIG_USB_ARCH_HAS_EHCI is not set
483
484#
485# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
486#
487
488#
489# USB Gadget Support
490#
491# CONFIG_USB_GADGET is not set
492
493#
494# MMC/SD Card support
495#
496# CONFIG_MMC is not set
497
498#
499# LED devices
500#
501# CONFIG_NEW_LEDS is not set
502
503#
504# LED drivers
505#
506
507#
508# LED Triggers
509#
510
511#
512# InfiniBand support
513#
514
515#
516# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
517#
518
519#
520# Real Time Clock
521#
522# CONFIG_RTC_CLASS is not set
523
524#
525# DMA Engine support
526#
527# CONFIG_DMA_ENGINE is not set
528
529#
530# DMA Clients
531#
532
533#
534# DMA Devices
535#
536
537#
538# File systems
539#
540CONFIG_EXT2_FS=y
541# CONFIG_EXT2_FS_XATTR is not set
542# CONFIG_EXT2_FS_XIP is not set
543# CONFIG_EXT3_FS is not set
544# CONFIG_REISERFS_FS is not set
545# CONFIG_JFS_FS is not set
546# CONFIG_FS_POSIX_ACL is not set
547# CONFIG_XFS_FS is not set
548# CONFIG_MINIX_FS is not set
549# CONFIG_ROMFS_FS is not set
550CONFIG_INOTIFY=y
551CONFIG_INOTIFY_USER=y
552# CONFIG_QUOTA is not set
553CONFIG_DNOTIFY=y
554# CONFIG_AUTOFS_FS is not set
555# CONFIG_AUTOFS4_FS is not set
556# CONFIG_FUSE_FS is not set
557
558#
559# CD-ROM/DVD Filesystems
560#
561# CONFIG_ISO9660_FS is not set
562# CONFIG_UDF_FS is not set
563
564#
565# DOS/FAT/NT Filesystems
566#
567# CONFIG_MSDOS_FS is not set
568# CONFIG_VFAT_FS is not set
569# CONFIG_NTFS_FS is not set
570
571#
572# Pseudo filesystems
573#
574CONFIG_PROC_FS=y
575CONFIG_PROC_KCORE=y
576CONFIG_PROC_SYSCTL=y
577# CONFIG_SYSFS is not set
578CONFIG_TMPFS=y
579# CONFIG_TMPFS_POSIX_ACL is not set
580# CONFIG_HUGETLBFS is not set
581# CONFIG_HUGETLB_PAGE is not set
582CONFIG_RAMFS=y
583
584#
585# Miscellaneous filesystems
586#
587# CONFIG_ADFS_FS is not set
588# CONFIG_AFFS_FS is not set
589# CONFIG_HFS_FS is not set
590# CONFIG_HFSPLUS_FS is not set
591# CONFIG_BEFS_FS is not set
592# CONFIG_BFS_FS is not set
593# CONFIG_EFS_FS is not set
594# CONFIG_CRAMFS is not set
595# CONFIG_VXFS_FS is not set
596# CONFIG_HPFS_FS is not set
597# CONFIG_QNX4FS_FS is not set
598# CONFIG_SYSV_FS is not set
599# CONFIG_UFS_FS is not set
600
601#
602# Partition Types
603#
604# CONFIG_PARTITION_ADVANCED is not set
605CONFIG_MSDOS_PARTITION=y
606
607#
608# Native Language Support
609#
610# CONFIG_NLS is not set
611
612#
613# Profiling support
614#
615# CONFIG_PROFILING is not set
616
617#
618# Kernel hacking
619#
620# CONFIG_PRINTK_TIME is not set
621CONFIG_ENABLE_MUST_CHECK=y
622# CONFIG_MAGIC_SYSRQ is not set
623# CONFIG_UNUSED_SYMBOLS is not set
624# CONFIG_DEBUG_KERNEL is not set
625CONFIG_LOG_BUF_SHIFT=14
626# CONFIG_DEBUG_BUGVERBOSE is not set
627CONFIG_SH_STANDARD_BIOS=y
628# CONFIG_EARLY_SCIF_CONSOLE is not set
629# CONFIG_EARLY_PRINTK is not set
630# CONFIG_KGDB is not set
631
632#
633# Security options
634#
635# CONFIG_KEYS is not set
636
637#
638# Cryptographic options
639#
640# CONFIG_CRYPTO is not set
641
642#
643# Library routines
644#
645# CONFIG_CRC_CCITT is not set
646# CONFIG_CRC16 is not set
647CONFIG_CRC32=y
648# CONFIG_LIBCRC32C is not set
diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index cf8e11994330..76ed816d9a24 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -31,8 +31,8 @@ struct dma_info *get_dma_info(unsigned int chan)
31 * the channel is. 31 * the channel is.
32 */ 32 */
33 list_for_each_entry(info, &registered_dmac_list, list) { 33 list_for_each_entry(info, &registered_dmac_list, list) {
34 if ((chan < info->first_channel_nr) || 34 if ((chan < info->first_vchannel_nr) ||
35 (chan >= info->first_channel_nr + info->nr_channels)) 35 (chan >= info->first_vchannel_nr + info->nr_channels))
36 continue; 36 continue;
37 37
38 return info; 38 return info;
@@ -82,7 +82,7 @@ struct dma_channel *get_dma_channel(unsigned int chan)
82 82
83 for (i = 0; i < info->nr_channels; i++) { 83 for (i = 0; i < info->nr_channels; i++) {
84 channel = &info->channels[i]; 84 channel = &info->channels[i];
85 if (channel->chan == chan) 85 if (channel->vchan == chan)
86 return channel; 86 return channel;
87 } 87 }
88 88
@@ -369,6 +369,7 @@ int register_dmac(struct dma_info *info)
369 } 369 }
370 370
371 total_channels = get_nr_channels(); 371 total_channels = get_nr_channels();
372 info->first_vchannel_nr = total_channels;
372 for (i = 0; i < info->nr_channels; i++) { 373 for (i = 0; i < info->nr_channels; i++) {
373 struct dma_channel *chan = &info->channels[i]; 374 struct dma_channel *chan = &info->channels[i];
374 375
diff --git a/arch/sh/kernel/cpu/irq/Makefile b/arch/sh/kernel/cpu/irq/Makefile
index 9ddb446ac930..60bfc05cf354 100644
--- a/arch/sh/kernel/cpu/irq/Makefile
+++ b/arch/sh/kernel/cpu/irq/Makefile
@@ -4,7 +4,6 @@
4obj-y += imask.o 4obj-y += imask.o
5 5
6obj-$(CONFIG_CPU_HAS_IPR_IRQ) += ipr.o 6obj-$(CONFIG_CPU_HAS_IPR_IRQ) += ipr.o
7obj-$(CONFIG_CPU_HAS_PINT_IRQ) += pint.o
8obj-$(CONFIG_CPU_HAS_MASKREG_IRQ) += maskreg.o 7obj-$(CONFIG_CPU_HAS_MASKREG_IRQ) += maskreg.o
9obj-$(CONFIG_CPU_HAS_INTC_IRQ) += intc.o 8obj-$(CONFIG_CPU_HAS_INTC_IRQ) += intc.o
10obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o 9obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o
diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c
index 98e84f40c713..5da325414880 100644
--- a/arch/sh/kernel/cpu/irq/ipr.c
+++ b/arch/sh/kernel/cpu/irq/ipr.c
@@ -8,7 +8,7 @@
8 * 8 *
9 * Supported system: 9 * Supported system:
10 * On-chip supporting modules (TMU, RTC, etc.). 10 * On-chip supporting modules (TMU, RTC, etc.).
11 * On-chip supporting modules for SH7709/SH7709A/SH7729/SH7300. 11 * On-chip supporting modules for SH7709/SH7709A/SH7729.
12 * Hitachi SolutionEngine external I/O: 12 * Hitachi SolutionEngine external I/O:
13 * MS7709SE01, MS7709ASE01, and MS7750SE01 13 * MS7709SE01, MS7709ASE01, and MS7750SE01
14 * 14 *
diff --git a/arch/sh/kernel/cpu/irq/pint.c b/arch/sh/kernel/cpu/irq/pint.c
deleted file mode 100644
index 67602685df1a..000000000000
--- a/arch/sh/kernel/cpu/irq/pint.c
+++ /dev/null
@@ -1,220 +0,0 @@
1/*
2 * arch/sh/kernel/cpu/irq/pint.c - Interrupt handling for PINT-based IRQs.
3 *
4 * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi
5 * Copyright (C) 2000 Kazumoto Kojima
6 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/init.h>
14#include <linux/irq.h>
15#include <linux/module.h>
16
17#include <asm/system.h>
18#include <asm/io.h>
19#include <asm/machvec.h>
20
21#if defined(CONFIG_CPU_SUBTYPE_SH7705)
22#define INTC_INTER 0xA4000014UL
23#define INTC_IPRD 0xA4000018UL
24#define INTC_ICR2 0xA4000012UL
25
26/* PFC */
27#define PORT_PACR 0xA4000100UL
28#define PORT_PBCR 0xA4000102UL
29#define PORT_PCCR 0xA4000104UL
30#define PORT_PDCR 0xA4000106UL
31#define PORT_PECR 0xA4000108UL
32#define PORT_PFCR 0xA400010AUL
33#define PORT_PGCR 0xA400010CUL
34#define PORT_PHCR 0xA400010EUL
35#define PORT_PJCR 0xA4000110UL
36#define PORT_PKCR 0xA4000112UL
37#define PORT_PLCR 0xA4000114UL
38#define PORT_PMCR 0xA4000118UL
39#define PORT_PNCR 0xA400011AUL
40#define PORT_PECR2 0xA4050148UL
41#define PORT_PFCR2 0xA405014AUL
42#define PORT_PNCR2 0xA405015AUL
43
44/* I/O port */
45#define PORT_PADR 0xA4000120UL
46#define PORT_PBDR 0xA4000122UL
47#define PORT_PCDR 0xA4000124UL
48#define PORT_PDDR 0xA4000126UL
49#define PORT_PEDR 0xA4000128UL
50#define PORT_PFDR 0xA400012AUL
51#define PORT_PGDR 0xA400012CUL
52#define PORT_PHDR 0xA400012EUL
53#define PORT_PJDR 0xA4000130UL
54#define PORT_PKDR 0xA4000132UL
55#define PORT_PLDR 0xA4000134UL
56#define PORT_PMDR 0xA4000138UL
57#define PORT_PNDR 0xA400013AUL
58
59#define PINT0_IRQ 40
60#define PINT8_IRQ 41
61#define PINT_IRQ_BASE 86
62
63#define PINT0_IPR_ADDR INTC_IPRD
64#define PINT0_IPR_POS 3
65#define PINT0_PRIORITY 2
66
67#define PINT8_IPR_ADDR INTC_IPRD
68#define PINT8_IPR_POS 2
69#define PINT8_PRIORITY 2
70
71#endif /* CONFIG_CPU_SUBTYPE_SH7705 */
72
73static unsigned char pint_map[256];
74static unsigned long portcr_mask;
75
76static void enable_pint_irq(unsigned int irq);
77static void disable_pint_irq(unsigned int irq);
78
79/* shutdown is same as "disable" */
80#define shutdown_pint_irq disable_pint_irq
81
82static void mask_and_ack_pint(unsigned int);
83static void end_pint_irq(unsigned int irq);
84
85static unsigned int startup_pint_irq(unsigned int irq)
86{
87 enable_pint_irq(irq);
88 return 0; /* never anything pending */
89}
90
91static struct hw_interrupt_type pint_irq_type = {
92 .typename = "PINT-IRQ",
93 .startup = startup_pint_irq,
94 .shutdown = shutdown_pint_irq,
95 .enable = enable_pint_irq,
96 .disable = disable_pint_irq,
97 .ack = mask_and_ack_pint,
98 .end = end_pint_irq
99};
100
101static void disable_pint_irq(unsigned int irq)
102{
103 unsigned long val;
104
105 val = ctrl_inw(INTC_INTER);
106 val &= ~(1 << (irq - PINT_IRQ_BASE));
107 ctrl_outw(val, INTC_INTER); /* disable PINTn */
108 portcr_mask &= ~(3 << (irq - PINT_IRQ_BASE)*2);
109}
110
111static void enable_pint_irq(unsigned int irq)
112{
113 unsigned long val;
114
115 val = ctrl_inw(INTC_INTER);
116 val |= 1 << (irq - PINT_IRQ_BASE);
117 ctrl_outw(val, INTC_INTER); /* enable PINTn */
118 portcr_mask |= 3 << (irq - PINT_IRQ_BASE)*2;
119}
120
121static void mask_and_ack_pint(unsigned int irq)
122{
123 disable_pint_irq(irq);
124}
125
126static void end_pint_irq(unsigned int irq)
127{
128 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
129 enable_pint_irq(irq);
130}
131
132void make_pint_irq(unsigned int irq)
133{
134 disable_irq_nosync(irq);
135 irq_desc[irq].chip = &pint_irq_type;
136 disable_pint_irq(irq);
137}
138
139static struct ipr_data pint_ipr_map[] = {
140 { PINT0_IRQ, PINT0_IPR_ADDR, PINT0_IPR_POS, PINT0_PRIORITY },
141 { PINT8_IRQ, PINT8_IPR_ADDR, PINT8_IPR_POS, PINT8_PRIORITY },
142};
143
144void __init init_IRQ_pint(void)
145{
146 int i;
147
148 make_ipr_irq(pint_ipr_map, ARRAY_SIZE(pint_ipr_map));
149
150 enable_irq(PINT0_IRQ);
151 enable_irq(PINT8_IRQ);
152
153 for(i = 0; i < 16; i++)
154 make_pint_irq(PINT_IRQ_BASE + i);
155
156 for(i = 0; i < 256; i++) {
157 if (i & 1)
158 pint_map[i] = 0;
159 else if (i & 2)
160 pint_map[i] = 1;
161 else if (i & 4)
162 pint_map[i] = 2;
163 else if (i & 8)
164 pint_map[i] = 3;
165 else if (i & 0x10)
166 pint_map[i] = 4;
167 else if (i & 0x20)
168 pint_map[i] = 5;
169 else if (i & 0x40)
170 pint_map[i] = 6;
171 else if (i & 0x80)
172 pint_map[i] = 7;
173 }
174}
175
176int ipr_irq_demux(int irq)
177{
178 unsigned long creg, dreg, d, sav;
179
180 if (irq == PINT0_IRQ) {
181#if defined(CONFIG_CPU_SUBTYPE_SH7705) || defined(CONFIG_CPU_SUBTYPE_SH7707)
182 creg = PORT_PACR;
183 dreg = PORT_PADR;
184#else
185 creg = PORT_PCCR;
186 dreg = PORT_PCDR;
187#endif
188 sav = ctrl_inw(creg);
189 ctrl_outw(sav | portcr_mask, creg);
190 d = (~ctrl_inb(dreg) ^ ctrl_inw(INTC_ICR2)) &
191 ctrl_inw(INTC_INTER) & 0xff;
192 ctrl_outw(sav, creg);
193
194 if (d == 0)
195 return irq;
196
197 return PINT_IRQ_BASE + pint_map[d];
198 } else if (irq == PINT8_IRQ) {
199#if defined(CONFIG_CPU_SUBTYPE_SH7705) || defined(CONFIG_CPU_SUBTYPE_SH7707)
200 creg = PORT_PBCR;
201 dreg = PORT_PBDR;
202#else
203 creg = PORT_PFCR;
204 dreg = PORT_PFDR;
205#endif
206 sav = ctrl_inw(creg);
207 ctrl_outw(sav | (portcr_mask >> 16), creg);
208 d = (~ctrl_inb(dreg) ^ (ctrl_inw(INTC_ICR2) >> 8)) &
209 (ctrl_inw(INTC_INTER) >> 8) & 0xff;
210 ctrl_outw(sav, creg);
211
212 if (d == 0)
213 return irq;
214
215 return PINT_IRQ_BASE + 8 + pint_map[d];
216 }
217
218 return irq;
219}
220
diff --git a/arch/sh/kernel/cpu/sh3/Makefile b/arch/sh/kernel/cpu/sh3/Makefile
index 09faa056cd43..55b750763f66 100644
--- a/arch/sh/kernel/cpu/sh3/Makefile
+++ b/arch/sh/kernel/cpu/sh3/Makefile
@@ -10,16 +10,14 @@ obj-$(CONFIG_CPU_SUBTYPE_SH7706) += setup-sh7709.o
10obj-$(CONFIG_CPU_SUBTYPE_SH7707) += setup-sh7709.o 10obj-$(CONFIG_CPU_SUBTYPE_SH7707) += setup-sh7709.o
11obj-$(CONFIG_CPU_SUBTYPE_SH7708) += setup-sh7708.o 11obj-$(CONFIG_CPU_SUBTYPE_SH7708) += setup-sh7708.o
12obj-$(CONFIG_CPU_SUBTYPE_SH7709) += setup-sh7709.o 12obj-$(CONFIG_CPU_SUBTYPE_SH7709) += setup-sh7709.o
13obj-$(CONFIG_CPU_SUBTYPE_SH7300) += setup-sh7300.o
14obj-$(CONFIG_CPU_SUBTYPE_SH7710) += setup-sh7710.o 13obj-$(CONFIG_CPU_SUBTYPE_SH7710) += setup-sh7710.o
15obj-$(CONFIG_CPU_SUBTYPE_SH7712) += setup-sh7710.o 14obj-$(CONFIG_CPU_SUBTYPE_SH7712) += setup-sh7710.o
16 15
17# Primary on-chip clocks (common) 16# Primary on-chip clocks (common)
18clock-$(CONFIG_CPU_SH3) := clock-sh3.o 17clock-$(CONFIG_CPU_SH3) := clock-sh3.o
19clock-$(CONFIG_CPU_SUBTYPE_SH7300) := clock-sh7300.o
20clock-$(CONFIG_CPU_SUBTYPE_SH7705) := clock-sh7705.o 18clock-$(CONFIG_CPU_SUBTYPE_SH7705) := clock-sh7705.o
21clock-$(CONFIG_CPU_SUBTYPE_SH7706) := clock-sh7706.o 19clock-$(CONFIG_CPU_SUBTYPE_SH7706) := clock-sh7706.o
22clock-$(CONFIG_CPU_SUBTYPE_SH7709) := clock-sh7709.o 20clock-$(CONFIG_CPU_SUBTYPE_SH7709) := clock-sh7709.o
23clock-$(CONFIG_CPU_SUBTYPE_SH7710) := clock-sh7300.o 21clock-$(CONFIG_CPU_SUBTYPE_SH7710) := clock-sh7710.o
24 22
25obj-y += $(clock-y) 23obj-y += $(clock-y)
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7300.c b/arch/sh/kernel/cpu/sh3/clock-sh7710.c
index e804174b9625..4744c50ec449 100644
--- a/arch/sh/kernel/cpu/sh3/clock-sh7300.c
+++ b/arch/sh/kernel/cpu/sh3/clock-sh7710.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/sh/kernel/cpu/sh3/clock-sh7300.c 2 * arch/sh/kernel/cpu/sh3/clock-sh7710.c
3 * 3 *
4 * SH7300 support for the clock framework 4 * SH7710 support for the clock framework
5 * 5 *
6 * Copyright (C) 2005 Paul Mundt 6 * Copyright (C) 2005 Paul Mundt
7 * 7 *
@@ -29,7 +29,7 @@ static void master_clk_init(struct clk *clk)
29 clk->rate *= md_table[ctrl_inw(FRQCR) & 0x0007]; 29 clk->rate *= md_table[ctrl_inw(FRQCR) & 0x0007];
30} 30}
31 31
32static struct clk_ops sh7300_master_clk_ops = { 32static struct clk_ops sh7710_master_clk_ops = {
33 .init = master_clk_init, 33 .init = master_clk_init,
34}; 34};
35 35
@@ -39,7 +39,7 @@ static void module_clk_recalc(struct clk *clk)
39 clk->rate = clk->parent->rate / md_table[idx]; 39 clk->rate = clk->parent->rate / md_table[idx];
40} 40}
41 41
42static struct clk_ops sh7300_module_clk_ops = { 42static struct clk_ops sh7710_module_clk_ops = {
43 .recalc = module_clk_recalc, 43 .recalc = module_clk_recalc,
44}; 44};
45 45
@@ -49,7 +49,7 @@ static void bus_clk_recalc(struct clk *clk)
49 clk->rate = clk->parent->rate / md_table[idx]; 49 clk->rate = clk->parent->rate / md_table[idx];
50} 50}
51 51
52static struct clk_ops sh7300_bus_clk_ops = { 52static struct clk_ops sh7710_bus_clk_ops = {
53 .recalc = bus_clk_recalc, 53 .recalc = bus_clk_recalc,
54}; 54};
55 55
@@ -59,20 +59,20 @@ static void cpu_clk_recalc(struct clk *clk)
59 clk->rate = clk->parent->rate / md_table[idx]; 59 clk->rate = clk->parent->rate / md_table[idx];
60} 60}
61 61
62static struct clk_ops sh7300_cpu_clk_ops = { 62static struct clk_ops sh7710_cpu_clk_ops = {
63 .recalc = cpu_clk_recalc, 63 .recalc = cpu_clk_recalc,
64}; 64};
65 65
66static struct clk_ops *sh7300_clk_ops[] = { 66static struct clk_ops *sh7710_clk_ops[] = {
67 &sh7300_master_clk_ops, 67 &sh7710_master_clk_ops,
68 &sh7300_module_clk_ops, 68 &sh7710_module_clk_ops,
69 &sh7300_bus_clk_ops, 69 &sh7710_bus_clk_ops,
70 &sh7300_cpu_clk_ops, 70 &sh7710_cpu_clk_ops,
71}; 71};
72 72
73void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 73void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
74{ 74{
75 if (idx < ARRAY_SIZE(sh7300_clk_ops)) 75 if (idx < ARRAY_SIZE(sh7710_clk_ops))
76 *ops = sh7300_clk_ops[idx]; 76 *ops = sh7710_clk_ops[idx];
77} 77}
78 78
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7300.c b/arch/sh/kernel/cpu/sh3/setup-sh7300.c
deleted file mode 100644
index ab4d204bfba5..000000000000
--- a/arch/sh/kernel/cpu/sh3/setup-sh7300.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * SH7300 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xa4430000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCI,
20 .irqs = { 80, 80, 80, 80 },
21 }, {
22 .flags = 0,
23 }
24};
25
26static struct platform_device sci_device = {
27 .name = "sh-sci",
28 .id = -1,
29 .dev = {
30 .platform_data = sci_platform_data,
31 },
32};
33
34static struct platform_device *sh7300_devices[] __initdata = {
35 &sci_device,
36};
37
38static int __init sh7300_devices_setup(void)
39{
40 return platform_add_devices(sh7300_devices,
41 ARRAY_SIZE(sh7300_devices));
42}
43__initcall(sh7300_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
index 66c3f75647b2..98d28fb1ce16 100644
--- a/arch/sh/kernel/cpu/sh4/probe.c
+++ b/arch/sh/kernel/cpu/sh4/probe.c
@@ -90,12 +90,6 @@ int __init detect_cpu_and_cache_system(void)
90 current_cpu_data.type = CPU_SH7751; 90 current_cpu_data.type = CPU_SH7751;
91 current_cpu_data.flags |= CPU_HAS_FPU; 91 current_cpu_data.flags |= CPU_HAS_FPU;
92 break; 92 break;
93 case 0x2000:
94 current_cpu_data.type = CPU_SH73180;
95 current_cpu_data.icache.ways = 4;
96 current_cpu_data.dcache.ways = 4;
97 current_cpu_data.flags |= CPU_HAS_LLSC;
98 break;
99 case 0x2001: 93 case 0x2001:
100 case 0x2004: 94 case 0x2004:
101 current_cpu_data.type = CPU_SH7770; 95 current_cpu_data.type = CPU_SH7770;
diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
index b98d6c3e6f36..c21512c6044e 100644
--- a/arch/sh/kernel/cpu/sh4/sq.c
+++ b/arch/sh/kernel/cpu/sh4/sq.c
@@ -208,7 +208,6 @@ EXPORT_SYMBOL(sq_remap);
208void sq_unmap(unsigned long vaddr) 208void sq_unmap(unsigned long vaddr)
209{ 209{
210 struct sq_mapping **p, *map; 210 struct sq_mapping **p, *map;
211 struct vm_struct *vma;
212 int page; 211 int page;
213 212
214 for (p = &sq_mapping_list; (map = *p); p = &map->next) 213 for (p = &sq_mapping_list; (map = *p); p = &map->next)
@@ -225,11 +224,18 @@ void sq_unmap(unsigned long vaddr)
225 bitmap_release_region(sq_bitmap, page, get_order(map->size)); 224 bitmap_release_region(sq_bitmap, page, get_order(map->size));
226 225
227#ifdef CONFIG_MMU 226#ifdef CONFIG_MMU
228 vma = remove_vm_area((void *)(map->sq_addr & PAGE_MASK)); 227 {
229 if (!vma) { 228 /*
230 printk(KERN_ERR "%s: bad address 0x%08lx\n", 229 * Tear down the VMA in the MMU case.
231 __FUNCTION__, map->sq_addr); 230 */
232 return; 231 struct vm_struct *vma;
232
233 vma = remove_vm_area((void *)(map->sq_addr & PAGE_MASK));
234 if (!vma) {
235 printk(KERN_ERR "%s: bad address 0x%08lx\n",
236 __FUNCTION__, map->sq_addr);
237 return;
238 }
233 } 239 }
234#endif 240#endif
235 241
diff --git a/arch/sh/kernel/cpu/sh4a/Makefile b/arch/sh/kernel/cpu/sh4a/Makefile
index 400623286487..e6a1fb5f8484 100644
--- a/arch/sh/kernel/cpu/sh4a/Makefile
+++ b/arch/sh/kernel/cpu/sh4a/Makefile
@@ -6,13 +6,11 @@
6obj-$(CONFIG_CPU_SUBTYPE_SH7770) += setup-sh7770.o 6obj-$(CONFIG_CPU_SUBTYPE_SH7770) += setup-sh7770.o
7obj-$(CONFIG_CPU_SUBTYPE_SH7780) += setup-sh7780.o 7obj-$(CONFIG_CPU_SUBTYPE_SH7780) += setup-sh7780.o
8obj-$(CONFIG_CPU_SUBTYPE_SH7785) += setup-sh7785.o 8obj-$(CONFIG_CPU_SUBTYPE_SH7785) += setup-sh7785.o
9obj-$(CONFIG_CPU_SUBTYPE_SH73180) += setup-sh73180.o
10obj-$(CONFIG_CPU_SUBTYPE_SH7343) += setup-sh7343.o 9obj-$(CONFIG_CPU_SUBTYPE_SH7343) += setup-sh7343.o
11obj-$(CONFIG_CPU_SUBTYPE_SH7722) += setup-sh7722.o 10obj-$(CONFIG_CPU_SUBTYPE_SH7722) += setup-sh7722.o
12obj-$(CONFIG_CPU_SUBTYPE_SHX3) += setup-shx3.o 11obj-$(CONFIG_CPU_SUBTYPE_SHX3) += setup-shx3.o
13 12
14# Primary on-chip clocks (common) 13# Primary on-chip clocks (common)
15clock-$(CONFIG_CPU_SUBTYPE_SH73180) := clock-sh73180.o
16clock-$(CONFIG_CPU_SUBTYPE_SH7770) := clock-sh7770.o 14clock-$(CONFIG_CPU_SUBTYPE_SH7770) := clock-sh7770.o
17clock-$(CONFIG_CPU_SUBTYPE_SH7780) := clock-sh7780.o 15clock-$(CONFIG_CPU_SUBTYPE_SH7780) := clock-sh7780.o
18clock-$(CONFIG_CPU_SUBTYPE_SH7785) := clock-sh7785.o 16clock-$(CONFIG_CPU_SUBTYPE_SH7785) := clock-sh7785.o
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh73180.c b/arch/sh/kernel/cpu/sh4a/clock-sh73180.c
deleted file mode 100644
index 6d5ba373a75e..000000000000
--- a/arch/sh/kernel/cpu/sh4a/clock-sh73180.c
+++ /dev/null
@@ -1,81 +0,0 @@
1/*
2 * arch/sh/kernel/cpu/sh4a/clock-sh73180.c
3 *
4 * SH73180 support for the clock framework
5 *
6 * Copyright (C) 2005 Paul Mundt
7 *
8 * FRQCR parsing hacked out of arch/sh/kernel/time.c
9 *
10 * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka
11 * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
12 * Copyright (C) 2002, 2003, 2004 Paul Mundt
13 * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org>
14 *
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive
17 * for more details.
18 */
19#include <linux/init.h>
20#include <linux/kernel.h>
21#include <asm/clock.h>
22#include <asm/freq.h>
23#include <asm/io.h>
24
25/*
26 * SH73180 uses a common set of divisors, so this is quite simple..
27 */
28static int divisors[] = { 1, 2, 3, 4, 6, 8, 12, 16 };
29
30static void master_clk_init(struct clk *clk)
31{
32 clk->rate *= divisors[ctrl_inl(FRQCR) & 0x0007];
33}
34
35static struct clk_ops sh73180_master_clk_ops = {
36 .init = master_clk_init,
37};
38
39static void module_clk_recalc(struct clk *clk)
40{
41 int idx = (ctrl_inl(FRQCR) & 0x0007);
42 clk->rate = clk->parent->rate / divisors[idx];
43}
44
45static struct clk_ops sh73180_module_clk_ops = {
46 .recalc = module_clk_recalc,
47};
48
49static void bus_clk_recalc(struct clk *clk)
50{
51 int idx = (ctrl_inl(FRQCR) >> 12) & 0x0007;
52 clk->rate = clk->parent->rate / divisors[idx];
53}
54
55static struct clk_ops sh73180_bus_clk_ops = {
56 .recalc = bus_clk_recalc,
57};
58
59static void cpu_clk_recalc(struct clk *clk)
60{
61 int idx = (ctrl_inl(FRQCR) >> 20) & 0x0007;
62 clk->rate = clk->parent->rate / divisors[idx];
63}
64
65static struct clk_ops sh73180_cpu_clk_ops = {
66 .recalc = cpu_clk_recalc,
67};
68
69static struct clk_ops *sh73180_clk_ops[] = {
70 &sh73180_master_clk_ops,
71 &sh73180_module_clk_ops,
72 &sh73180_bus_clk_ops,
73 &sh73180_cpu_clk_ops,
74};
75
76void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
77{
78 if (idx < ARRAY_SIZE(sh73180_clk_ops))
79 *ops = sh73180_clk_ops[idx];
80}
81
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh73180.c b/arch/sh/kernel/cpu/sh4a/setup-sh73180.c
deleted file mode 100644
index cc9ea1e2e5df..000000000000
--- a/arch/sh/kernel/cpu/sh4a/setup-sh73180.c
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * SH73180 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xffe80000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 80, 81, 83, 82 },
21 }, {
22 .flags = 0,
23 }
24};
25
26static struct platform_device sci_device = {
27 .name = "sh-sci",
28 .id = -1,
29 .dev = {
30 .platform_data = sci_platform_data,
31 },
32};
33
34static struct platform_device *sh73180_devices[] __initdata = {
35 &sci_device,
36};
37
38static int __init sh73180_devices_setup(void)
39{
40 return platform_add_devices(sh73180_devices,
41 ARRAY_SIZE(sh73180_devices));
42}
43__initcall(sh73180_devices_setup);
diff --git a/arch/sh/kernel/init_task.c b/arch/sh/kernel/init_task.c
index 44053ea92936..4b449c4a6bad 100644
--- a/arch/sh/kernel/init_task.c
+++ b/arch/sh/kernel/init_task.c
@@ -3,7 +3,7 @@
3#include <linux/sched.h> 3#include <linux/sched.h>
4#include <linux/init_task.h> 4#include <linux/init_task.h>
5#include <linux/mqueue.h> 5#include <linux/mqueue.h>
6 6#include <linux/fs.h>
7#include <asm/uaccess.h> 7#include <asm/uaccess.h>
8#include <asm/pgtable.h> 8#include <asm/pgtable.h>
9 9
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 6334a4c54c7c..15ae322dbd74 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -18,6 +18,7 @@
18#include <linux/kdebug.h> 18#include <linux/kdebug.h>
19#include <linux/tick.h> 19#include <linux/tick.h>
20#include <linux/reboot.h> 20#include <linux/reboot.h>
21#include <linux/fs.h>
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
22#include <asm/mmu_context.h> 23#include <asm/mmu_context.h>
23#include <asm/pgalloc.h> 24#include <asm/pgalloc.h>
@@ -474,7 +475,6 @@ out:
474 475
475unsigned long get_wchan(struct task_struct *p) 476unsigned long get_wchan(struct task_struct *p)
476{ 477{
477 unsigned long schedule_frame;
478 unsigned long pc; 478 unsigned long pc;
479 479
480 if (!p || p == current || p->state == TASK_RUNNING) 480 if (!p || p == current || p->state == TASK_RUNNING)
@@ -484,10 +484,13 @@ unsigned long get_wchan(struct task_struct *p)
484 * The same comment as on the Alpha applies here, too ... 484 * The same comment as on the Alpha applies here, too ...
485 */ 485 */
486 pc = thread_saved_pc(p); 486 pc = thread_saved_pc(p);
487
488#ifdef CONFIG_FRAME_POINTER
487 if (in_sched_functions(pc)) { 489 if (in_sched_functions(pc)) {
488 schedule_frame = (unsigned long)p->thread.sp; 490 unsigned long schedule_frame = (unsigned long)p->thread.sp;
489 return ((unsigned long *)schedule_frame)[21]; 491 return ((unsigned long *)schedule_frame)[21];
490 } 492 }
493#endif
491 494
492 return pc; 495 return pc;
493} 496}
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index c14a3e95d0b1..2cf7dec0d690 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -276,7 +276,6 @@ void __init setup_arch(char **cmdline_p)
276 276
277static const char *cpu_name[] = { 277static const char *cpu_name[] = {
278 [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619", 278 [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619",
279 [CPU_SH7300] = "SH7300",
280 [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706", 279 [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706",
281 [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708", 280 [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708",
282 [CPU_SH7709] = "SH7709", [CPU_SH7710] = "SH7710", 281 [CPU_SH7709] = "SH7709", [CPU_SH7710] = "SH7710",
@@ -284,7 +283,7 @@ static const char *cpu_name[] = {
284 [CPU_SH7729] = "SH7729", [CPU_SH7750] = "SH7750", 283 [CPU_SH7729] = "SH7729", [CPU_SH7750] = "SH7750",
285 [CPU_SH7750S] = "SH7750S", [CPU_SH7750R] = "SH7750R", 284 [CPU_SH7750S] = "SH7750S", [CPU_SH7750R] = "SH7750R",
286 [CPU_SH7751] = "SH7751", [CPU_SH7751R] = "SH7751R", 285 [CPU_SH7751] = "SH7751", [CPU_SH7751R] = "SH7751R",
287 [CPU_SH7760] = "SH7760", [CPU_SH73180] = "SH73180", 286 [CPU_SH7760] = "SH7760",
288 [CPU_ST40RA] = "ST40RA", [CPU_ST40GX1] = "ST40GX1", 287 [CPU_ST40RA] = "ST40RA", [CPU_ST40GX1] = "ST40GX1",
289 [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501", 288 [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501",
290 [CPU_SH7770] = "SH7770", [CPU_SH7780] = "SH7780", 289 [CPU_SH7770] = "SH7770", [CPU_SH7780] = "SH7780",
diff --git a/arch/sh/kernel/sys_sh.c b/arch/sh/kernel/sys_sh.c
index 76b1bc7f7029..024ce5dedd8c 100644
--- a/arch/sh/kernel/sys_sh.c
+++ b/arch/sh/kernel/sys_sh.c
@@ -21,6 +21,7 @@
21#include <linux/file.h> 21#include <linux/file.h>
22#include <linux/utsname.h> 22#include <linux/utsname.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/fs.h>
24#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26#include <asm/ipc.h> 27#include <asm/ipc.h>
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c
index 7aca37d79766..8a545d54e2d3 100644
--- a/arch/sh/kernel/timers/timer-tmu.c
+++ b/arch/sh/kernel/timers/timer-tmu.c
@@ -173,8 +173,7 @@ static int tmu_timer_init(void)
173 173
174 tmu_timer_stop(); 174 tmu_timer_stop();
175 175
176#if !defined(CONFIG_CPU_SUBTYPE_SH7300) && \ 176#if !defined(CONFIG_CPU_SUBTYPE_SH7760) && \
177 !defined(CONFIG_CPU_SUBTYPE_SH7760) && \
178 !defined(CONFIG_CPU_SUBTYPE_SH7785) && \ 177 !defined(CONFIG_CPU_SUBTYPE_SH7785) && \
179 !defined(CONFIG_CPU_SUBTYPE_SHX3) 178 !defined(CONFIG_CPU_SUBTYPE_SHX3)
180 ctrl_outb(TMU_TOCR_INIT, TMU_TOCR); 179 ctrl_outb(TMU_TOCR_INIT, TMU_TOCR);
diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c
index 2aa9438361bc..95f4de0800ec 100644
--- a/arch/sh/kernel/vsyscall/vsyscall.c
+++ b/arch/sh/kernel/vsyscall/vsyscall.c
@@ -18,6 +18,7 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/elf.h> 19#include <linux/elf.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/err.h>
21 22
22/* 23/*
23 * Should the kernel map a VDSO page into processes and pass its 24 * Should the kernel map a VDSO page into processes and pass its
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig
index 70da1c8d407e..43f3972a5fb9 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -27,6 +27,7 @@ config CPU_SH4A
27config CPU_SH4AL_DSP 27config CPU_SH4AL_DSP
28 bool 28 bool
29 select CPU_SH4A 29 select CPU_SH4A
30 select CPU_HAS_DSP
30 31
31config CPU_SUBTYPE_ST40 32config CPU_SUBTYPE_ST40
32 bool 33 bool
@@ -62,15 +63,10 @@ config CPU_SUBTYPE_SH7206
62 63
63# SH-3 Processor Support 64# SH-3 Processor Support
64 65
65config CPU_SUBTYPE_SH7300
66 bool "Support SH7300 processor"
67 select CPU_SH3
68
69config CPU_SUBTYPE_SH7705 66config CPU_SUBTYPE_SH7705
70 bool "Support SH7705 processor" 67 bool "Support SH7705 processor"
71 select CPU_SH3 68 select CPU_SH3
72 select CPU_HAS_IPR_IRQ 69 select CPU_HAS_IPR_IRQ
73 select CPU_HAS_PINT_IRQ
74 70
75config CPU_SUBTYPE_SH7706 71config CPU_SUBTYPE_SH7706
76 bool "Support SH7706 processor" 72 bool "Support SH7706 processor"
@@ -82,7 +78,6 @@ config CPU_SUBTYPE_SH7706
82config CPU_SUBTYPE_SH7707 78config CPU_SUBTYPE_SH7707
83 bool "Support SH7707 processor" 79 bool "Support SH7707 processor"
84 select CPU_SH3 80 select CPU_SH3
85 select CPU_HAS_PINT_IRQ
86 help 81 help
87 Select SH7707 if you have a 60 Mhz SH-3 HD6417707 CPU. 82 Select SH7707 if you have a 60 Mhz SH-3 HD6417707 CPU.
88 83
@@ -97,7 +92,6 @@ config CPU_SUBTYPE_SH7709
97 bool "Support SH7709 processor" 92 bool "Support SH7709 processor"
98 select CPU_SH3 93 select CPU_SH3
99 select CPU_HAS_IPR_IRQ 94 select CPU_HAS_IPR_IRQ
100 select CPU_HAS_PINT_IRQ
101 help 95 help
102 Select SH7709 if you have a 80 Mhz SH-3 HD6417709 CPU. 96 Select SH7709 if you have a 80 Mhz SH-3 HD6417709 CPU.
103 97
@@ -105,6 +99,7 @@ config CPU_SUBTYPE_SH7710
105 bool "Support SH7710 processor" 99 bool "Support SH7710 processor"
106 select CPU_SH3 100 select CPU_SH3
107 select CPU_HAS_IPR_IRQ 101 select CPU_HAS_IPR_IRQ
102 select CPU_HAS_DSP
108 help 103 help
109 Select SH7710 if you have a SH3-DSP SH7710 CPU. 104 Select SH7710 if you have a SH3-DSP SH7710 CPU.
110 105
@@ -112,6 +107,7 @@ config CPU_SUBTYPE_SH7712
112 bool "Support SH7712 processor" 107 bool "Support SH7712 processor"
113 select CPU_SH3 108 select CPU_SH3
114 select CPU_HAS_IPR_IRQ 109 select CPU_HAS_IPR_IRQ
110 select CPU_HAS_DSP
115 help 111 help
116 Select SH7712 if you have a SH3-DSP SH7712 CPU. 112 Select SH7712 if you have a SH3-DSP SH7712 CPU.
117 113
@@ -205,10 +201,6 @@ config CPU_SUBTYPE_SHX3
205 201
206# SH4AL-DSP Processor Support 202# SH4AL-DSP Processor Support
207 203
208config CPU_SUBTYPE_SH73180
209 bool "Support SH73180 processor"
210 select CPU_SH4AL_DSP
211
212config CPU_SUBTYPE_SH7343 204config CPU_SUBTYPE_SH7343
213 bool "Support SH7343 processor" 205 bool "Support SH7343 processor"
214 select CPU_SH4AL_DSP 206 select CPU_SH4AL_DSP
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index 981b04089055..86486326ef1d 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -77,16 +77,8 @@ static void __init emit_cache_params(void)
77/* 77/*
78 * SH-4 has virtually indexed and physically tagged cache. 78 * SH-4 has virtually indexed and physically tagged cache.
79 */ 79 */
80
81/* Worst case assumed to be 64k cache, direct-mapped i.e. 4 synonym bits. */
82#define MAX_P3_MUTEXES 16
83
84struct mutex p3map_mutex[MAX_P3_MUTEXES];
85
86void __init p3_cache_init(void) 80void __init p3_cache_init(void)
87{ 81{
88 int i;
89
90 compute_alias(&current_cpu_data.icache); 82 compute_alias(&current_cpu_data.icache);
91 compute_alias(&current_cpu_data.dcache); 83 compute_alias(&current_cpu_data.dcache);
92 84
@@ -106,12 +98,6 @@ void __init p3_cache_init(void)
106 } 98 }
107 99
108 emit_cache_params(); 100 emit_cache_params();
109
110 if (ioremap_page_range(P3SEG, P3SEG + (PAGE_SIZE * 4), 0, PAGE_KERNEL))
111 panic("%s failed.", __FUNCTION__);
112
113 for (i = 0; i < current_cpu_data.dcache.n_aliases; i++)
114 mutex_init(&p3map_mutex[i]);
115} 101}
116 102
117/* 103/*
diff --git a/arch/sh/mm/pg-sh4.c b/arch/sh/mm/pg-sh4.c
index df69da9ca69c..25f5c6f6821d 100644
--- a/arch/sh/mm/pg-sh4.c
+++ b/arch/sh/mm/pg-sh4.c
@@ -2,19 +2,45 @@
2 * arch/sh/mm/pg-sh4.c 2 * arch/sh/mm/pg-sh4.c
3 * 3 *
4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka 4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
5 * Copyright (C) 2002 - 2005 Paul Mundt 5 * Copyright (C) 2002 - 2007 Paul Mundt
6 * 6 *
7 * Released under the terms of the GNU GPL v2.0. 7 * Released under the terms of the GNU GPL v2.0.
8 */ 8 */
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/mutex.h> 10#include <linux/mutex.h>
11#include <linux/fs.h>
11#include <asm/mmu_context.h> 12#include <asm/mmu_context.h>
12#include <asm/cacheflush.h> 13#include <asm/cacheflush.h>
13 14
14extern struct mutex p3map_mutex[];
15
16#define CACHE_ALIAS (current_cpu_data.dcache.alias_mask) 15#define CACHE_ALIAS (current_cpu_data.dcache.alias_mask)
17 16
17static inline void *kmap_coherent(struct page *page, unsigned long addr)
18{
19 enum fixed_addresses idx;
20 unsigned long vaddr, flags;
21 pte_t pte;
22
23 inc_preempt_count();
24
25 idx = (addr & current_cpu_data.dcache.alias_mask) >> PAGE_SHIFT;
26 vaddr = __fix_to_virt(FIX_CMAP_END - idx);
27 pte = mk_pte(page, PAGE_KERNEL);
28
29 local_irq_save(flags);
30 flush_tlb_one(get_asid(), vaddr);
31 local_irq_restore(flags);
32
33 update_mmu_cache(NULL, vaddr, pte);
34
35 return (void *)vaddr;
36}
37
38static inline void kunmap_coherent(struct page *page)
39{
40 dec_preempt_count();
41 preempt_check_resched();
42}
43
18/* 44/*
19 * clear_user_page 45 * clear_user_page
20 * @to: P1 address 46 * @to: P1 address
@@ -27,25 +53,9 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
27 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) 53 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
28 clear_page(to); 54 clear_page(to);
29 else { 55 else {
30 unsigned long phys_addr = PHYSADDR(to); 56 void *vto = kmap_coherent(page, address);
31 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); 57 __clear_user_page(vto, to);
32 pgd_t *pgd = pgd_offset_k(p3_addr); 58 kunmap_coherent(vto);
33 pud_t *pud = pud_offset(pgd, p3_addr);
34 pmd_t *pmd = pmd_offset(pud, p3_addr);
35 pte_t *pte = pte_offset_kernel(pmd, p3_addr);
36 pte_t entry;
37 unsigned long flags;
38
39 entry = pfn_pte(phys_addr >> PAGE_SHIFT, PAGE_KERNEL);
40 mutex_lock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
41 set_pte(pte, entry);
42 local_irq_save(flags);
43 flush_tlb_one(get_asid(), p3_addr);
44 local_irq_restore(flags);
45 update_mmu_cache(NULL, p3_addr, entry);
46 __clear_user_page((void *)p3_addr, to);
47 pte_clear(&init_mm, p3_addr, pte);
48 mutex_unlock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
49 } 59 }
50} 60}
51 61
@@ -63,25 +73,9 @@ void copy_user_page(void *to, void *from, unsigned long address,
63 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) 73 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
64 copy_page(to, from); 74 copy_page(to, from);
65 else { 75 else {
66 unsigned long phys_addr = PHYSADDR(to); 76 void *vfrom = kmap_coherent(page, address);
67 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); 77 __copy_user_page(vfrom, from, to);
68 pgd_t *pgd = pgd_offset_k(p3_addr); 78 kunmap_coherent(vfrom);
69 pud_t *pud = pud_offset(pgd, p3_addr);
70 pmd_t *pmd = pmd_offset(pud, p3_addr);
71 pte_t *pte = pte_offset_kernel(pmd, p3_addr);
72 pte_t entry;
73 unsigned long flags;
74
75 entry = pfn_pte(phys_addr >> PAGE_SHIFT, PAGE_KERNEL);
76 mutex_lock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
77 set_pte(pte, entry);
78 local_irq_save(flags);
79 flush_tlb_one(get_asid(), p3_addr);
80 local_irq_restore(flags);
81 update_mmu_cache(NULL, p3_addr, entry);
82 __copy_user_page((void *)p3_addr, from, to);
83 pte_clear(&init_mm, p3_addr, pte);
84 mutex_unlock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
85 } 79 }
86} 80}
87 81
diff --git a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
index 4b5e9305092e..439bfe3d29af 100644
--- a/arch/sh/tools/mach-types
+++ b/arch/sh/tools/mach-types
@@ -8,12 +8,10 @@
8SE SH_SOLUTION_ENGINE 8SE SH_SOLUTION_ENGINE
97751SE SH_7751_SOLUTION_ENGINE 97751SE SH_7751_SOLUTION_ENGINE
107722SE SH_7722_SOLUTION_ENGINE 107722SE SH_7722_SOLUTION_ENGINE
117300SE SH_7300_SOLUTION_ENGINE
127343SE SH_7343_SOLUTION_ENGINE 117343SE SH_7343_SOLUTION_ENGINE
137206SE SH_7206_SOLUTION_ENGINE 127206SE SH_7206_SOLUTION_ENGINE
147619SE SH_7619_SOLUTION_ENGINE 137619SE SH_7619_SOLUTION_ENGINE
157780SE SH_7780_SOLUTION_ENGINE 147780SE SH_7780_SOLUTION_ENGINE
1673180SE SH_73180_SOLUTION_ENGINE
177751SYSTEMH SH_7751_SYSTEMH 157751SYSTEMH SH_7751_SYSTEMH
18HP6XX SH_HP6XX 16HP6XX SH_HP6XX
19HD64461 HD64461 17HD64461 HD64461
diff --git a/arch/sh64/Kconfig b/arch/sh64/Kconfig
index ff654204b7d4..5664631d8ae5 100644
--- a/arch/sh64/Kconfig
+++ b/arch/sh64/Kconfig
@@ -47,6 +47,9 @@ config ARCH_HAS_ILOG2_U64
47 bool 47 bool
48 default n 48 default n
49 49
50config ARCH_NO_VIRT_TO_BUS
51 def_bool y
52
50source init/Kconfig 53source init/Kconfig
51 54
52menu "System type" 55menu "System type"
diff --git a/arch/sh64/kernel/init_task.c b/arch/sh64/kernel/init_task.c
index de2d07db1f88..deee8bfd3270 100644
--- a/arch/sh64/kernel/init_task.c
+++ b/arch/sh64/kernel/init_task.c
@@ -14,7 +14,7 @@
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/init_task.h> 15#include <linux/init_task.h>
16#include <linux/mqueue.h> 16#include <linux/mqueue.h>
17 17#include <linux/fs.h>
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include <asm/pgtable.h> 19#include <asm/pgtable.h>
20 20
diff --git a/arch/sh64/kernel/irq_intc.c b/arch/sh64/kernel/irq_intc.c
index 42c07d2e71d9..3b63a93198f2 100644
--- a/arch/sh64/kernel/irq_intc.c
+++ b/arch/sh64/kernel/irq_intc.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/interrupt.h>
19#include <linux/irq.h> 20#include <linux/irq.h>
20#include <linux/kernel.h> 21#include <linux/kernel.h>
21#include <linux/stddef.h> 22#include <linux/stddef.h>
diff --git a/arch/sh64/kernel/pci-dma.c b/arch/sh64/kernel/pci-dma.c
index a36c3d71a3fe..a9328f894755 100644
--- a/arch/sh64/kernel/pci-dma.c
+++ b/arch/sh64/kernel/pci-dma.c
@@ -30,7 +30,7 @@ void *consistent_alloc(struct pci_dev *hwdev, size_t size,
30 30
31 if (vp != NULL) { 31 if (vp != NULL) {
32 memset(vp, 0, size); 32 memset(vp, 0, size);
33 *dma_handle = virt_to_bus(ret); 33 *dma_handle = virt_to_phys(ret);
34 dma_cache_wback_inv((unsigned long)ret, size); 34 dma_cache_wback_inv((unsigned long)ret, size);
35 } 35 }
36 36
@@ -42,7 +42,7 @@ void consistent_free(struct pci_dev *hwdev, size_t size,
42{ 42{
43 void *alloc; 43 void *alloc;
44 44
45 alloc = bus_to_virt((unsigned long)dma_handle); 45 alloc = phys_to_virt((unsigned long)dma_handle);
46 free_pages((unsigned long)alloc, get_order(size)); 46 free_pages((unsigned long)alloc, get_order(size));
47 47
48 iounmap(vaddr); 48 iounmap(vaddr);
diff --git a/arch/sh64/kernel/process.c b/arch/sh64/kernel/process.c
index 1b89c9dfb93d..ceb9458abda4 100644
--- a/arch/sh64/kernel/process.c
+++ b/arch/sh64/kernel/process.c
@@ -21,6 +21,7 @@
21 * This file handles the architecture-dependent parts of process handling.. 21 * This file handles the architecture-dependent parts of process handling..
22 */ 22 */
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/fs.h>
24#include <linux/ptrace.h> 25#include <linux/ptrace.h>
25#include <linux/reboot.h> 26#include <linux/reboot.h>
26#include <linux/init.h> 27#include <linux/init.h>
diff --git a/arch/sh64/kernel/sys_sh64.c b/arch/sh64/kernel/sys_sh64.c
index 19126daf9f4c..b7f18e298a20 100644
--- a/arch/sh64/kernel/sys_sh64.c
+++ b/arch/sh64/kernel/sys_sh64.c
@@ -19,6 +19,7 @@
19#include <linux/rwsem.h> 19#include <linux/rwsem.h>
20#include <linux/sched.h> 20#include <linux/sched.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/fs.h>
22#include <linux/smp.h> 23#include <linux/smp.h>
23#include <linux/sem.h> 24#include <linux/sem.h>
24#include <linux/msg.h> 25#include <linux/msg.h>
diff --git a/arch/sh64/lib/dbg.c b/arch/sh64/lib/dbg.c
index 4310fc87444e..97816e0baf19 100644
--- a/arch/sh64/lib/dbg.c
+++ b/arch/sh64/lib/dbg.c
@@ -12,6 +12,7 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/mm.h> 14#include <linux/mm.h>
15#include <linux/fs.h>
15#include <asm/mmu_context.h> 16#include <asm/mmu_context.h>
16 17
17typedef u64 regType_t; 18typedef u64 regType_t;
diff --git a/arch/sparc/defconfig b/arch/sparc/defconfig
index 38bd79fe6e75..f7a509149199 100644
--- a/arch/sparc/defconfig
+++ b/arch/sparc/defconfig
@@ -1,12 +1,14 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22-rc1 3# Linux kernel version: 2.6.23-rc1
4# Mon May 14 03:25:14 2007 4# Wed Jul 25 15:30:21 2007
5# 5#
6CONFIG_MMU=y 6CONFIG_MMU=y
7CONFIG_HIGHMEM=y 7CONFIG_HIGHMEM=y
8CONFIG_ZONE_DMA=y 8CONFIG_ZONE_DMA=y
9CONFIG_GENERIC_ISA_DMA=y 9CONFIG_GENERIC_ISA_DMA=y
10CONFIG_ARCH_NO_VIRT_TO_BUS=y
11CONFIG_OF=y
10CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 12CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
11 13
12# 14#
@@ -23,12 +25,11 @@ CONFIG_LOCALVERSION=""
23CONFIG_LOCALVERSION_AUTO=y 25CONFIG_LOCALVERSION_AUTO=y
24CONFIG_SWAP=y 26CONFIG_SWAP=y
25CONFIG_SYSVIPC=y 27CONFIG_SYSVIPC=y
26# CONFIG_IPC_NS is not set
27CONFIG_SYSVIPC_SYSCTL=y 28CONFIG_SYSVIPC_SYSCTL=y
28CONFIG_POSIX_MQUEUE=y 29CONFIG_POSIX_MQUEUE=y
29# CONFIG_BSD_PROCESS_ACCT is not set 30# CONFIG_BSD_PROCESS_ACCT is not set
30# CONFIG_TASKSTATS is not set 31# CONFIG_TASKSTATS is not set
31# CONFIG_UTS_NS is not set 32# CONFIG_USER_NS is not set
32# CONFIG_AUDIT is not set 33# CONFIG_AUDIT is not set
33# CONFIG_IKCONFIG is not set 34# CONFIG_IKCONFIG is not set
34CONFIG_LOG_BUF_SHIFT=14 35CONFIG_LOG_BUF_SHIFT=14
@@ -63,24 +64,17 @@ CONFIG_SLAB=y
63CONFIG_RT_MUTEXES=y 64CONFIG_RT_MUTEXES=y
64# CONFIG_TINY_SHMEM is not set 65# CONFIG_TINY_SHMEM is not set
65CONFIG_BASE_SMALL=0 66CONFIG_BASE_SMALL=0
66
67#
68# Loadable module support
69#
70CONFIG_MODULES=y 67CONFIG_MODULES=y
71CONFIG_MODULE_UNLOAD=y 68CONFIG_MODULE_UNLOAD=y
72# CONFIG_MODULE_FORCE_UNLOAD is not set 69# CONFIG_MODULE_FORCE_UNLOAD is not set
73# CONFIG_MODVERSIONS is not set 70# CONFIG_MODVERSIONS is not set
74# CONFIG_MODULE_SRCVERSION_ALL is not set 71# CONFIG_MODULE_SRCVERSION_ALL is not set
75CONFIG_KMOD=y 72CONFIG_KMOD=y
76
77#
78# Block layer
79#
80CONFIG_BLOCK=y 73CONFIG_BLOCK=y
81# CONFIG_LBD is not set 74# CONFIG_LBD is not set
82# CONFIG_BLK_DEV_IO_TRACE is not set 75# CONFIG_BLK_DEV_IO_TRACE is not set
83# CONFIG_LSF is not set 76# CONFIG_LSF is not set
77# CONFIG_BLK_DEV_BSG is not set
84 78
85# 79#
86# IO Schedulers 80# IO Schedulers
@@ -113,11 +107,14 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
113CONFIG_ARCH_MAY_HAVE_PC_FDC=y 107CONFIG_ARCH_MAY_HAVE_PC_FDC=y
114# CONFIG_ARCH_HAS_ILOG2_U32 is not set 108# CONFIG_ARCH_HAS_ILOG2_U32 is not set
115# CONFIG_ARCH_HAS_ILOG2_U64 is not set 109# CONFIG_ARCH_HAS_ILOG2_U64 is not set
110CONFIG_EMULATED_CMPXCHG=y
116CONFIG_SUN_PM=y 111CONFIG_SUN_PM=y
117# CONFIG_SUN4 is not set 112# CONFIG_SUN4 is not set
118CONFIG_PCI=y 113CONFIG_PCI=y
114CONFIG_PCI_SYSCALL=y
119# CONFIG_ARCH_SUPPORTS_MSI is not set 115# CONFIG_ARCH_SUPPORTS_MSI is not set
120# CONFIG_PCI_DEBUG is not set 116# CONFIG_PCI_DEBUG is not set
117# CONFIG_NO_DMA is not set
121CONFIG_SUN_OPENPROMFS=m 118CONFIG_SUN_OPENPROMFS=m
122# CONFIG_SPARC_LED is not set 119# CONFIG_SPARC_LED is not set
123CONFIG_BINFMT_ELF=y 120CONFIG_BINFMT_ELF=y
@@ -134,6 +131,7 @@ CONFIG_FLAT_NODE_MEM_MAP=y
134CONFIG_SPLIT_PTLOCK_CPUS=4 131CONFIG_SPLIT_PTLOCK_CPUS=4
135# CONFIG_RESOURCES_64BIT is not set 132# CONFIG_RESOURCES_64BIT is not set
136CONFIG_ZONE_DMA_FLAG=1 133CONFIG_ZONE_DMA_FLAG=1
134CONFIG_BOUNCE=y
137 135
138# 136#
139# Networking 137# Networking
@@ -197,25 +195,13 @@ CONFIG_IPV6_TUNNEL=m
197# CONFIG_IPV6_MULTIPLE_TABLES is not set 195# CONFIG_IPV6_MULTIPLE_TABLES is not set
198# CONFIG_NETWORK_SECMARK is not set 196# CONFIG_NETWORK_SECMARK is not set
199# CONFIG_NETFILTER is not set 197# CONFIG_NETFILTER is not set
200
201#
202# DCCP Configuration (EXPERIMENTAL)
203#
204# CONFIG_IP_DCCP is not set 198# CONFIG_IP_DCCP is not set
205
206#
207# SCTP Configuration (EXPERIMENTAL)
208#
209CONFIG_IP_SCTP=m 199CONFIG_IP_SCTP=m
210# CONFIG_SCTP_DBG_MSG is not set 200# CONFIG_SCTP_DBG_MSG is not set
211CONFIG_SCTP_DBG_OBJCNT=y 201CONFIG_SCTP_DBG_OBJCNT=y
212# CONFIG_SCTP_HMAC_NONE is not set 202# CONFIG_SCTP_HMAC_NONE is not set
213# CONFIG_SCTP_HMAC_SHA1 is not set 203# CONFIG_SCTP_HMAC_SHA1 is not set
214CONFIG_SCTP_HMAC_MD5=y 204CONFIG_SCTP_HMAC_MD5=y
215
216#
217# TIPC Configuration (EXPERIMENTAL)
218#
219# CONFIG_TIPC is not set 205# CONFIG_TIPC is not set
220# CONFIG_ATM is not set 206# CONFIG_ATM is not set
221# CONFIG_BRIDGE is not set 207# CONFIG_BRIDGE is not set
@@ -253,6 +239,7 @@ CONFIG_AF_RXRPC=m
253# CONFIG_MAC80211 is not set 239# CONFIG_MAC80211 is not set
254# CONFIG_IEEE80211 is not set 240# CONFIG_IEEE80211 is not set
255# CONFIG_RFKILL is not set 241# CONFIG_RFKILL is not set
242# CONFIG_NET_9P is not set
256 243
257# 244#
258# Device Drivers 245# Device Drivers
@@ -267,28 +254,12 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
267# CONFIG_DEBUG_DRIVER is not set 254# CONFIG_DEBUG_DRIVER is not set
268# CONFIG_DEBUG_DEVRES is not set 255# CONFIG_DEBUG_DEVRES is not set
269# CONFIG_SYS_HYPERVISOR is not set 256# CONFIG_SYS_HYPERVISOR is not set
270
271#
272# Connector - unified userspace <-> kernelspace linker
273#
274# CONFIG_CONNECTOR is not set 257# CONFIG_CONNECTOR is not set
275# CONFIG_MTD is not set 258# CONFIG_MTD is not set
276 259CONFIG_OF_DEVICE=y
277#
278# Parallel port support
279#
280# CONFIG_PARPORT is not set 260# CONFIG_PARPORT is not set
281 261CONFIG_BLK_DEV=y
282#
283# Plug and Play support
284#
285# CONFIG_PNPACPI is not set
286
287#
288# Block devices
289#
290# CONFIG_BLK_DEV_FD is not set 262# CONFIG_BLK_DEV_FD is not set
291# CONFIG_BLK_CPQ_DA is not set
292# CONFIG_BLK_CPQ_CISS_DA is not set 263# CONFIG_BLK_CPQ_CISS_DA is not set
293# CONFIG_BLK_DEV_DAC960 is not set 264# CONFIG_BLK_DEV_DAC960 is not set
294# CONFIG_BLK_DEV_UMEM is not set 265# CONFIG_BLK_DEV_UMEM is not set
@@ -303,18 +274,11 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
303CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 274CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
304# CONFIG_CDROM_PKTCDVD is not set 275# CONFIG_CDROM_PKTCDVD is not set
305# CONFIG_ATA_OVER_ETH is not set 276# CONFIG_ATA_OVER_ETH is not set
306 277CONFIG_MISC_DEVICES=y
307#
308# Misc devices
309#
310# CONFIG_PHANTOM is not set 278# CONFIG_PHANTOM is not set
279# CONFIG_EEPROM_93CX6 is not set
311# CONFIG_SGI_IOC4 is not set 280# CONFIG_SGI_IOC4 is not set
312# CONFIG_TIFM_CORE is not set 281# CONFIG_TIFM_CORE is not set
313# CONFIG_BLINK is not set
314
315#
316# ATA/ATAPI/MFM/RLL support
317#
318# CONFIG_IDE is not set 282# CONFIG_IDE is not set
319 283
320# 284#
@@ -322,6 +286,7 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
322# 286#
323# CONFIG_RAID_ATTRS is not set 287# CONFIG_RAID_ATTRS is not set
324CONFIG_SCSI=y 288CONFIG_SCSI=y
289CONFIG_SCSI_DMA=y
325# CONFIG_SCSI_TGT is not set 290# CONFIG_SCSI_TGT is not set
326# CONFIG_SCSI_NETLINK is not set 291# CONFIG_SCSI_NETLINK is not set
327CONFIG_SCSI_PROC_FS=y 292CONFIG_SCSI_PROC_FS=y
@@ -352,12 +317,8 @@ CONFIG_SCSI_WAIT_SCAN=m
352CONFIG_SCSI_SPI_ATTRS=y 317CONFIG_SCSI_SPI_ATTRS=y
353# CONFIG_SCSI_FC_ATTRS is not set 318# CONFIG_SCSI_FC_ATTRS is not set
354# CONFIG_SCSI_ISCSI_ATTRS is not set 319# CONFIG_SCSI_ISCSI_ATTRS is not set
355# CONFIG_SCSI_SAS_ATTRS is not set
356# CONFIG_SCSI_SAS_LIBSAS is not set 320# CONFIG_SCSI_SAS_LIBSAS is not set
357 321CONFIG_SCSI_LOWLEVEL=y
358#
359# SCSI low-level drivers
360#
361# CONFIG_ISCSI_TCP is not set 322# CONFIG_ISCSI_TCP is not set
362# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 323# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
363# CONFIG_SCSI_3W_9XXX is not set 324# CONFIG_SCSI_3W_9XXX is not set
@@ -367,7 +328,6 @@ CONFIG_SCSI_SPI_ATTRS=y
367# CONFIG_SCSI_AIC7XXX_OLD is not set 328# CONFIG_SCSI_AIC7XXX_OLD is not set
368# CONFIG_SCSI_AIC79XX is not set 329# CONFIG_SCSI_AIC79XX is not set
369# CONFIG_SCSI_AIC94XX is not set 330# CONFIG_SCSI_AIC94XX is not set
370# CONFIG_SCSI_DPT_I2O is not set
371# CONFIG_SCSI_ARCMSR is not set 331# CONFIG_SCSI_ARCMSR is not set
372# CONFIG_MEGARAID_NEWGEN is not set 332# CONFIG_MEGARAID_NEWGEN is not set
373# CONFIG_MEGARAID_LEGACY is not set 333# CONFIG_MEGARAID_LEGACY is not set
@@ -389,14 +349,9 @@ CONFIG_SCSI_QLOGICPTI=m
389# CONFIG_SCSI_DC390T is not set 349# CONFIG_SCSI_DC390T is not set
390# CONFIG_SCSI_NSP32 is not set 350# CONFIG_SCSI_NSP32 is not set
391# CONFIG_SCSI_DEBUG is not set 351# CONFIG_SCSI_DEBUG is not set
392CONFIG_SCSI_ESP_CORE=y
393CONFIG_SCSI_SUNESP=y 352CONFIG_SCSI_SUNESP=y
394# CONFIG_SCSI_SRP is not set 353# CONFIG_SCSI_SRP is not set
395# CONFIG_ATA is not set 354# CONFIG_ATA is not set
396
397#
398# Multi-device support (RAID and LVM)
399#
400# CONFIG_MD is not set 355# CONFIG_MD is not set
401 356
402# 357#
@@ -412,30 +367,16 @@ CONFIG_SCSI_SUNESP=y
412# 367#
413# CONFIG_FIREWIRE is not set 368# CONFIG_FIREWIRE is not set
414# CONFIG_IEEE1394 is not set 369# CONFIG_IEEE1394 is not set
415
416#
417# I2O device support
418#
419# CONFIG_I2O is not set 370# CONFIG_I2O is not set
420
421#
422# Network device support
423#
424CONFIG_NETDEVICES=y 371CONFIG_NETDEVICES=y
372# CONFIG_NETDEVICES_MULTIQUEUE is not set
425CONFIG_DUMMY=m 373CONFIG_DUMMY=m
426# CONFIG_BONDING is not set 374# CONFIG_BONDING is not set
375# CONFIG_MACVLAN is not set
427# CONFIG_EQUALIZER is not set 376# CONFIG_EQUALIZER is not set
428CONFIG_TUN=m 377CONFIG_TUN=m
429
430#
431# ARCnet devices
432#
433# CONFIG_ARCNET is not set 378# CONFIG_ARCNET is not set
434# CONFIG_PHYLIB is not set 379# CONFIG_PHYLIB is not set
435
436#
437# Ethernet (10 or 100Mbit)
438#
439CONFIG_NET_ETHERNET=y 380CONFIG_NET_ETHERNET=y
440CONFIG_MII=m 381CONFIG_MII=m
441CONFIG_SUNLANCE=y 382CONFIG_SUNLANCE=y
@@ -445,10 +386,6 @@ CONFIG_SUNQE=m
445# CONFIG_SUNGEM is not set 386# CONFIG_SUNGEM is not set
446# CONFIG_CASSINI is not set 387# CONFIG_CASSINI is not set
447# CONFIG_NET_VENDOR_3COM is not set 388# CONFIG_NET_VENDOR_3COM is not set
448
449#
450# Tulip family network device support
451#
452# CONFIG_NET_TULIP is not set 389# CONFIG_NET_TULIP is not set
453# CONFIG_HP100 is not set 390# CONFIG_HP100 is not set
454# CONFIG_NET_PCI is not set 391# CONFIG_NET_PCI is not set
@@ -464,7 +401,7 @@ CONFIG_NETDEV_1000=y
464# CONFIG_SIS190 is not set 401# CONFIG_SIS190 is not set
465# CONFIG_SKGE is not set 402# CONFIG_SKGE is not set
466# CONFIG_SKY2 is not set 403# CONFIG_SKY2 is not set
467# CONFIG_SK98LIN is not set 404# CONFIG_VIA_VELOCITY is not set
468# CONFIG_TIGON3 is not set 405# CONFIG_TIGON3 is not set
469# CONFIG_BNX2 is not set 406# CONFIG_BNX2 is not set
470# CONFIG_QLA3XXX is not set 407# CONFIG_QLA3XXX is not set
@@ -477,11 +414,6 @@ CONFIG_NETDEV_10000=y
477# CONFIG_MYRI10GE is not set 414# CONFIG_MYRI10GE is not set
478# CONFIG_NETXEN_NIC is not set 415# CONFIG_NETXEN_NIC is not set
479# CONFIG_MLX4_CORE is not set 416# CONFIG_MLX4_CORE is not set
480CONFIG_MLX4_DEBUG=y
481
482#
483# Token Ring devices
484#
485# CONFIG_TR is not set 417# CONFIG_TR is not set
486 418
487# 419#
@@ -499,15 +431,7 @@ CONFIG_MLX4_DEBUG=y
499# CONFIG_NETCONSOLE is not set 431# CONFIG_NETCONSOLE is not set
500# CONFIG_NETPOLL is not set 432# CONFIG_NETPOLL is not set
501# CONFIG_NET_POLL_CONTROLLER is not set 433# CONFIG_NET_POLL_CONTROLLER is not set
502
503#
504# ISDN subsystem
505#
506# CONFIG_ISDN is not set 434# CONFIG_ISDN is not set
507
508#
509# Telephony Support
510#
511# CONFIG_PHONE is not set 435# CONFIG_PHONE is not set
512 436
513# 437#
@@ -515,6 +439,7 @@ CONFIG_MLX4_DEBUG=y
515# 439#
516CONFIG_INPUT=y 440CONFIG_INPUT=y
517# CONFIG_INPUT_FF_MEMLESS is not set 441# CONFIG_INPUT_FF_MEMLESS is not set
442# CONFIG_INPUT_POLLDEV is not set
518 443
519# 444#
520# Userland interfaces 445# Userland interfaces
@@ -593,22 +518,13 @@ CONFIG_SERIAL_CORE_CONSOLE=y
593CONFIG_UNIX98_PTYS=y 518CONFIG_UNIX98_PTYS=y
594CONFIG_LEGACY_PTYS=y 519CONFIG_LEGACY_PTYS=y
595CONFIG_LEGACY_PTY_COUNT=256 520CONFIG_LEGACY_PTY_COUNT=256
596
597#
598# IPMI
599#
600# CONFIG_IPMI_HANDLER is not set 521# CONFIG_IPMI_HANDLER is not set
601# CONFIG_WATCHDOG is not set 522# CONFIG_WATCHDOG is not set
602CONFIG_HW_RANDOM=m 523CONFIG_HW_RANDOM=m
603CONFIG_RTC=m 524CONFIG_JS_RTC=m
604# CONFIG_R3964 is not set 525# CONFIG_R3964 is not set
605# CONFIG_APPLICOM is not set 526# CONFIG_APPLICOM is not set
606# CONFIG_DRM is not set
607# CONFIG_RAW_DRIVER is not set 527# CONFIG_RAW_DRIVER is not set
608
609#
610# TPM devices
611#
612# CONFIG_TCG_TPM is not set 528# CONFIG_TCG_TPM is not set
613CONFIG_DEVPORT=y 529CONFIG_DEVPORT=y
614# CONFIG_I2C is not set 530# CONFIG_I2C is not set
@@ -618,20 +534,24 @@ CONFIG_DEVPORT=y
618# 534#
619# CONFIG_SPI is not set 535# CONFIG_SPI is not set
620# CONFIG_SPI_MASTER is not set 536# CONFIG_SPI_MASTER is not set
621
622#
623# Dallas's 1-wire bus
624#
625# CONFIG_W1 is not set 537# CONFIG_W1 is not set
538# CONFIG_POWER_SUPPLY is not set
626CONFIG_HWMON=y 539CONFIG_HWMON=y
627# CONFIG_HWMON_VID is not set 540# CONFIG_HWMON_VID is not set
628# CONFIG_SENSORS_ABITUGURU is not set 541# CONFIG_SENSORS_ABITUGURU is not set
542# CONFIG_SENSORS_ABITUGURU3 is not set
629# CONFIG_SENSORS_F71805F is not set 543# CONFIG_SENSORS_F71805F is not set
544# CONFIG_SENSORS_IT87 is not set
545# CONFIG_SENSORS_PC87360 is not set
630# CONFIG_SENSORS_PC87427 is not set 546# CONFIG_SENSORS_PC87427 is not set
547# CONFIG_SENSORS_SIS5595 is not set
631# CONFIG_SENSORS_SMSC47M1 is not set 548# CONFIG_SENSORS_SMSC47M1 is not set
632# CONFIG_SENSORS_SMSC47B397 is not set 549# CONFIG_SENSORS_SMSC47B397 is not set
550# CONFIG_SENSORS_VIA686A is not set
633# CONFIG_SENSORS_VT1211 is not set 551# CONFIG_SENSORS_VT1211 is not set
552# CONFIG_SENSORS_VT8231 is not set
634# CONFIG_SENSORS_W83627HF is not set 553# CONFIG_SENSORS_W83627HF is not set
554# CONFIG_SENSORS_W83627EHF is not set
635# CONFIG_HWMON_DEBUG_CHIP is not set 555# CONFIG_HWMON_DEBUG_CHIP is not set
636 556
637# 557#
@@ -656,6 +576,7 @@ CONFIG_HWMON=y
656# 576#
657# CONFIG_DISPLAY_SUPPORT is not set 577# CONFIG_DISPLAY_SUPPORT is not set
658# CONFIG_VGASTATE is not set 578# CONFIG_VGASTATE is not set
579# CONFIG_VIDEO_OUTPUT_CONTROL is not set
659# CONFIG_FB is not set 580# CONFIG_FB is not set
660 581
661# 582#
@@ -668,16 +589,10 @@ CONFIG_DUMMY_CONSOLE=y
668# Sound 589# Sound
669# 590#
670# CONFIG_SOUND is not set 591# CONFIG_SOUND is not set
671 592CONFIG_HID_SUPPORT=y
672#
673# HID Devices
674#
675CONFIG_HID=y 593CONFIG_HID=y
676# CONFIG_HID_DEBUG is not set 594# CONFIG_HID_DEBUG is not set
677 595CONFIG_USB_SUPPORT=y
678#
679# USB support
680#
681CONFIG_USB_ARCH_HAS_HCD=y 596CONFIG_USB_ARCH_HAS_HCD=y
682CONFIG_USB_ARCH_HAS_OHCI=y 597CONFIG_USB_ARCH_HAS_OHCI=y
683CONFIG_USB_ARCH_HAS_EHCI=y 598CONFIG_USB_ARCH_HAS_EHCI=y
@@ -692,30 +607,10 @@ CONFIG_USB_ARCH_HAS_EHCI=y
692# 607#
693# CONFIG_USB_GADGET is not set 608# CONFIG_USB_GADGET is not set
694# CONFIG_MMC is not set 609# CONFIG_MMC is not set
695
696#
697# LED devices
698#
699# CONFIG_NEW_LEDS is not set 610# CONFIG_NEW_LEDS is not set
700
701#
702# LED drivers
703#
704
705#
706# LED Triggers
707#
708
709#
710# InfiniBand support
711#
712# CONFIG_INFINIBAND is not set 611# CONFIG_INFINIBAND is not set
713 612
714# 613#
715# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
716#
717
718#
719# Real Time Clock 614# Real Time Clock
720# 615#
721# CONFIG_RTC_CLASS is not set 616# CONFIG_RTC_CLASS is not set
@@ -734,6 +629,11 @@ CONFIG_USB_ARCH_HAS_EHCI=y
734# 629#
735 630
736# 631#
632# Userspace I/O
633#
634# CONFIG_UIO is not set
635
636#
737# Misc Linux/SPARC drivers 637# Misc Linux/SPARC drivers
738# 638#
739CONFIG_SUN_OPENPROMIO=m 639CONFIG_SUN_OPENPROMIO=m
@@ -853,7 +753,6 @@ CONFIG_CIFS=m
853# CONFIG_CODA_FS is not set 753# CONFIG_CODA_FS is not set
854CONFIG_AFS_FS=m 754CONFIG_AFS_FS=m
855# CONFIG_AFS_DEBUG is not set 755# CONFIG_AFS_DEBUG is not set
856# CONFIG_9P_FS is not set
857 756
858# 757#
859# Partition Types 758# Partition Types
@@ -927,6 +826,7 @@ CONFIG_MAGIC_SYSRQ=y
927# CONFIG_HEADERS_CHECK is not set 826# CONFIG_HEADERS_CHECK is not set
928CONFIG_DEBUG_KERNEL=y 827CONFIG_DEBUG_KERNEL=y
929CONFIG_DETECT_SOFTLOCKUP=y 828CONFIG_DETECT_SOFTLOCKUP=y
829# CONFIG_SCHED_DEBUG is not set
930# CONFIG_SCHEDSTATS is not set 830# CONFIG_SCHEDSTATS is not set
931# CONFIG_TIMER_STATS is not set 831# CONFIG_TIMER_STATS is not set
932# CONFIG_DEBUG_SLAB is not set 832# CONFIG_DEBUG_SLAB is not set
@@ -953,10 +853,6 @@ CONFIG_FORCED_INLINING=y
953CONFIG_KEYS=y 853CONFIG_KEYS=y
954# CONFIG_KEYS_DEBUG_PROC_KEYS is not set 854# CONFIG_KEYS_DEBUG_PROC_KEYS is not set
955# CONFIG_SECURITY is not set 855# CONFIG_SECURITY is not set
956
957#
958# Cryptographic options
959#
960CONFIG_CRYPTO=y 856CONFIG_CRYPTO=y
961CONFIG_CRYPTO_ALGAPI=y 857CONFIG_CRYPTO_ALGAPI=y
962CONFIG_CRYPTO_BLKCIPHER=y 858CONFIG_CRYPTO_BLKCIPHER=y
@@ -996,10 +892,7 @@ CONFIG_CRYPTO_MICHAEL_MIC=m
996CONFIG_CRYPTO_CRC32C=m 892CONFIG_CRYPTO_CRC32C=m
997# CONFIG_CRYPTO_CAMELLIA is not set 893# CONFIG_CRYPTO_CAMELLIA is not set
998# CONFIG_CRYPTO_TEST is not set 894# CONFIG_CRYPTO_TEST is not set
999 895# CONFIG_CRYPTO_HW is not set
1000#
1001# Hardware crypto devices
1002#
1003 896
1004# 897#
1005# Library routines 898# Library routines
@@ -1009,6 +902,7 @@ CONFIG_BITREVERSE=y
1009# CONFIG_CRC16 is not set 902# CONFIG_CRC16 is not set
1010# CONFIG_CRC_ITU_T is not set 903# CONFIG_CRC_ITU_T is not set
1011CONFIG_CRC32=y 904CONFIG_CRC32=y
905# CONFIG_CRC7 is not set
1012CONFIG_LIBCRC32C=m 906CONFIG_LIBCRC32C=m
1013CONFIG_ZLIB_INFLATE=y 907CONFIG_ZLIB_INFLATE=y
1014CONFIG_ZLIB_DEFLATE=y 908CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/sparc/kernel/init_task.c b/arch/sparc/kernel/init_task.c
index fc31de66b1c2..d9d4f96360c7 100644
--- a/arch/sparc/kernel/init_task.c
+++ b/arch/sparc/kernel/init_task.c
@@ -1,4 +1,5 @@
1#include <linux/mm.h> 1#include <linux/mm.h>
2#include <linux/fs.h>
2#include <linux/module.h> 3#include <linux/module.h>
3#include <linux/sched.h> 4#include <linux/sched.h>
4#include <linux/init_task.h> 5#include <linux/init_task.h>
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
index e3a537650db1..39fbd3c8ab0b 100644
--- a/arch/sparc/kernel/prom.c
+++ b/arch/sparc/kernel/prom.c
@@ -415,7 +415,7 @@ static void __init of_console_init(void)
415 unsigned long flags; 415 unsigned long flags;
416 const char *type; 416 const char *type;
417 phandle node; 417 phandle node;
418 int skip, fd; 418 int skip, tmp, fd;
419 419
420 of_console_path = prom_early_alloc(256); 420 of_console_path = prom_early_alloc(256);
421 421
@@ -442,8 +442,9 @@ static void __init of_console_init(void)
442 prom_halt(); 442 prom_halt();
443 } 443 }
444 444
445 tmp = skip;
445 for_each_node_by_type(dp, type) { 446 for_each_node_by_type(dp, type) {
446 if (!skip--) 447 if (!tmp--)
447 break; 448 break;
448 } 449 }
449 if (!dp) { 450 if (!dp) {
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index 55bac516dfe2..7b4abde43028 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -161,6 +161,8 @@ EXPORT_SYMBOL(BTFIXUP_CALL(mmu_get_scsi_one));
161EXPORT_SYMBOL(BTFIXUP_CALL(mmu_release_scsi_sgl)); 161EXPORT_SYMBOL(BTFIXUP_CALL(mmu_release_scsi_sgl));
162EXPORT_SYMBOL(BTFIXUP_CALL(mmu_release_scsi_one)); 162EXPORT_SYMBOL(BTFIXUP_CALL(mmu_release_scsi_one));
163 163
164EXPORT_SYMBOL(BTFIXUP_CALL(pgprot_noncached));
165
164#ifdef CONFIG_SBUS 166#ifdef CONFIG_SBUS
165EXPORT_SYMBOL(sbus_root); 167EXPORT_SYMBOL(sbus_root);
166EXPORT_SYMBOL(dma_chain); 168EXPORT_SYMBOL(dma_chain);
@@ -260,6 +262,7 @@ EXPORT_SYMBOL(__memmove);
260/* Moving data to/from userspace. */ 262/* Moving data to/from userspace. */
261EXPORT_SYMBOL(__copy_user); 263EXPORT_SYMBOL(__copy_user);
262EXPORT_SYMBOL(__strncpy_from_user); 264EXPORT_SYMBOL(__strncpy_from_user);
265EXPORT_SYMBOL(__strnlen_user);
263 266
264/* Networking helper routines. */ 267/* Networking helper routines. */
265EXPORT_SYMBOL(__csum_partial_copy_sparc_generic); 268EXPORT_SYMBOL(__csum_partial_copy_sparc_generic);
diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
index 47583887abc6..15109c156e83 100644
--- a/arch/sparc/kernel/vmlinux.lds.S
+++ b/arch/sparc/kernel/vmlinux.lds.S
@@ -35,6 +35,8 @@ SECTIONS
35 __ex_table : { *(__ex_table) } 35 __ex_table : { *(__ex_table) }
36 __stop___ex_table = .; 36 __stop___ex_table = .;
37 37
38 NOTES
39
38 . = ALIGN(4096); 40 . = ALIGN(4096);
39 __init_begin = .; 41 __init_begin = .;
40 _sinittext = .; 42 _sinittext = .;
diff --git a/arch/sparc/lib/memset.S b/arch/sparc/lib/memset.S
index a65eba41097c..1c37ea892deb 100644
--- a/arch/sparc/lib/memset.S
+++ b/arch/sparc/lib/memset.S
@@ -162,7 +162,7 @@ __bzero:
1628: 1628:
163 add %o0, 1, %o0 163 add %o0, 1, %o0
164 subcc %o1, 1, %o1 164 subcc %o1, 1, %o1
165 bne,a 8b 165 bne 8b
166 EX(stb %g3, [%o0 - 1], add %o1, 1) 166 EX(stb %g3, [%o0 - 1], add %o1, 1)
1670: 1670:
168 retl 168 retl
diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c
index a57a366e339a..79d60d86f6f8 100644
--- a/arch/sparc/mm/sun4c.c
+++ b/arch/sparc/mm/sun4c.c
@@ -1999,6 +1999,9 @@ void sun4c_update_mmu_cache(struct vm_area_struct *vma, unsigned long address, p
1999 unsigned long flags; 1999 unsigned long flags;
2000 int pseg; 2000 int pseg;
2001 2001
2002 if (vma->vm_mm->context == NO_CONTEXT)
2003 return;
2004
2002 local_irq_save(flags); 2005 local_irq_save(flags);
2003 address &= PAGE_MASK; 2006 address &= PAGE_MASK;
2004 if ((pseg = sun4c_get_segmap(address)) == invalid_segment) { 2007 if ((pseg = sun4c_get_segmap(address)) == invalid_segment) {
diff --git a/arch/sparc/prom/printf.c b/arch/sparc/prom/printf.c
index 27fdac99f790..a36ab9c5ee08 100644
--- a/arch/sparc/prom/printf.c
+++ b/arch/sparc/prom/printf.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/module.h>
16 17
17#include <asm/openprom.h> 18#include <asm/openprom.h>
18#include <asm/oplib.h> 19#include <asm/oplib.h>
@@ -44,3 +45,4 @@ prom_printf(char *fmt, ...)
44 45
45 prom_write(ppbuf, i); 46 prom_write(ppbuf, i);
46} 47}
48EXPORT_SYMBOL(prom_printf);
diff --git a/arch/sparc64/Kconfig.debug b/arch/sparc64/Kconfig.debug
index 1f130f3b6c24..a5faa3683bd6 100644
--- a/arch/sparc64/Kconfig.debug
+++ b/arch/sparc64/Kconfig.debug
@@ -29,7 +29,7 @@ config DEBUG_BOOTMEM
29 29
30config DEBUG_PAGEALLOC 30config DEBUG_PAGEALLOC
31 bool "Debug page memory allocations" 31 bool "Debug page memory allocations"
32 depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND 32 depends on DEBUG_KERNEL && !HIBERNATION
33 help 33 help
34 Unmap pages from the kernel linear mapping after free_pages(). 34 Unmap pages from the kernel linear mapping after free_pages().
35 This results in a large slowdown, but helps to find certain types 35 This results in a large slowdown, but helps to find certain types
diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig
index 10e301970a44..68338a601f70 100644
--- a/arch/sparc64/defconfig
+++ b/arch/sparc64/defconfig
@@ -1,11 +1,12 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22 3# Linux kernel version: 2.6.23-rc1
4# Thu Jul 19 21:30:37 2007 4# Sun Jul 22 19:24:37 2007
5# 5#
6CONFIG_SPARC=y 6CONFIG_SPARC=y
7CONFIG_SPARC64=y 7CONFIG_SPARC64=y
8CONFIG_GENERIC_TIME=y 8CONFIG_GENERIC_TIME=y
9CONFIG_GENERIC_CMOS_UPDATE=y
9CONFIG_GENERIC_CLOCKEVENTS=y 10CONFIG_GENERIC_CLOCKEVENTS=y
10CONFIG_64BIT=y 11CONFIG_64BIT=y
11CONFIG_MMU=y 12CONFIG_MMU=y
@@ -17,6 +18,7 @@ CONFIG_ARCH_MAY_HAVE_PC_FDC=y
17# CONFIG_ARCH_HAS_ILOG2_U64 is not set 18# CONFIG_ARCH_HAS_ILOG2_U64 is not set
18CONFIG_AUDIT_ARCH=y 19CONFIG_AUDIT_ARCH=y
19CONFIG_ARCH_NO_VIRT_TO_BUS=y 20CONFIG_ARCH_NO_VIRT_TO_BUS=y
21CONFIG_OF=y
20CONFIG_SPARC64_PAGE_SIZE_8KB=y 22CONFIG_SPARC64_PAGE_SIZE_8KB=y
21# CONFIG_SPARC64_PAGE_SIZE_64KB is not set 23# CONFIG_SPARC64_PAGE_SIZE_64KB is not set
22# CONFIG_SPARC64_PAGE_SIZE_512KB is not set 24# CONFIG_SPARC64_PAGE_SIZE_512KB is not set
@@ -314,6 +316,7 @@ CONFIG_FW_LOADER=y
314# CONFIG_SYS_HYPERVISOR is not set 316# CONFIG_SYS_HYPERVISOR is not set
315CONFIG_CONNECTOR=m 317CONFIG_CONNECTOR=m
316# CONFIG_MTD is not set 318# CONFIG_MTD is not set
319CONFIG_OF_DEVICE=y
317# CONFIG_PARPORT is not set 320# CONFIG_PARPORT is not set
318CONFIG_BLK_DEV=y 321CONFIG_BLK_DEV=y
319# CONFIG_BLK_DEV_FD is not set 322# CONFIG_BLK_DEV_FD is not set
@@ -433,10 +436,7 @@ CONFIG_SCSI_FC_ATTRS=y
433CONFIG_SCSI_ISCSI_ATTRS=m 436CONFIG_SCSI_ISCSI_ATTRS=m
434# CONFIG_SCSI_SAS_ATTRS is not set 437# CONFIG_SCSI_SAS_ATTRS is not set
435# CONFIG_SCSI_SAS_LIBSAS is not set 438# CONFIG_SCSI_SAS_LIBSAS is not set
436 439CONFIG_SCSI_LOWLEVEL=y
437#
438# SCSI low-level drivers
439#
440CONFIG_ISCSI_TCP=m 440CONFIG_ISCSI_TCP=m
441# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 441# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
442# CONFIG_SCSI_3W_9XXX is not set 442# CONFIG_SCSI_3W_9XXX is not set
@@ -701,7 +701,6 @@ CONFIG_UNIX98_PTYS=y
701# CONFIG_IPMI_HANDLER is not set 701# CONFIG_IPMI_HANDLER is not set
702# CONFIG_WATCHDOG is not set 702# CONFIG_WATCHDOG is not set
703# CONFIG_HW_RANDOM is not set 703# CONFIG_HW_RANDOM is not set
704CONFIG_RTC=y
705# CONFIG_R3964 is not set 704# CONFIG_R3964 is not set
706# CONFIG_APPLICOM is not set 705# CONFIG_APPLICOM is not set
707# CONFIG_DRM is not set 706# CONFIG_DRM is not set
@@ -844,6 +843,7 @@ CONFIG_HWMON=y
844# 843#
845# CONFIG_DISPLAY_SUPPORT is not set 844# CONFIG_DISPLAY_SUPPORT is not set
846# CONFIG_VGASTATE is not set 845# CONFIG_VGASTATE is not set
846# CONFIG_VIDEO_OUTPUT_CONTROL is not set
847CONFIG_FB=y 847CONFIG_FB=y
848# CONFIG_FIRMWARE_EDID is not set 848# CONFIG_FIRMWARE_EDID is not set
849CONFIG_FB_DDC=y 849CONFIG_FB_DDC=y
@@ -937,7 +937,6 @@ CONFIG_SND_MIXER_OSS=m
937CONFIG_SND_PCM_OSS=m 937CONFIG_SND_PCM_OSS=m
938CONFIG_SND_PCM_OSS_PLUGINS=y 938CONFIG_SND_PCM_OSS_PLUGINS=y
939CONFIG_SND_SEQUENCER_OSS=y 939CONFIG_SND_SEQUENCER_OSS=y
940# CONFIG_SND_RTCTIMER is not set
941# CONFIG_SND_DYNAMIC_MINORS is not set 940# CONFIG_SND_DYNAMIC_MINORS is not set
942CONFIG_SND_SUPPORT_OLD_API=y 941CONFIG_SND_SUPPORT_OLD_API=y
943CONFIG_SND_VERBOSE_PROCFS=y 942CONFIG_SND_VERBOSE_PROCFS=y
@@ -1034,6 +1033,10 @@ CONFIG_SND_SUN_CS4231=m
1034# CONFIG_SND_SOC is not set 1033# CONFIG_SND_SOC is not set
1035 1034
1036# 1035#
1036# SoC Audio support for SuperH
1037#
1038
1039#
1037# Open Sound System 1040# Open Sound System
1038# 1041#
1039# CONFIG_SOUND_PRIME is not set 1042# CONFIG_SOUND_PRIME is not set
@@ -1157,19 +1160,7 @@ CONFIG_USB_STORAGE=m
1157# 1160#
1158# CONFIG_USB_GADGET is not set 1161# CONFIG_USB_GADGET is not set
1159# CONFIG_MMC is not set 1162# CONFIG_MMC is not set
1160
1161#
1162# LED devices
1163#
1164# CONFIG_NEW_LEDS is not set 1163# CONFIG_NEW_LEDS is not set
1165
1166#
1167# LED drivers
1168#
1169
1170#
1171# LED Triggers
1172#
1173# CONFIG_INFINIBAND is not set 1164# CONFIG_INFINIBAND is not set
1174 1165
1175# 1166#
@@ -1199,7 +1190,6 @@ CONFIG_USB_STORAGE=m
1199# Misc Linux/SPARC drivers 1190# Misc Linux/SPARC drivers
1200# 1191#
1201CONFIG_SUN_OPENPROMIO=m 1192CONFIG_SUN_OPENPROMIO=m
1202CONFIG_SUN_MOSTEK_RTC=y
1203# CONFIG_OBP_FLASH is not set 1193# CONFIG_OBP_FLASH is not set
1204# CONFIG_SUN_BPP is not set 1194# CONFIG_SUN_BPP is not set
1205# CONFIG_BBC_I2C is not set 1195# CONFIG_BBC_I2C is not set
diff --git a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile
index b66876bf410c..40d2f3aae91e 100644
--- a/arch/sparc64/kernel/Makefile
+++ b/arch/sparc64/kernel/Makefile
@@ -8,14 +8,14 @@ EXTRA_CFLAGS := -Werror
8extra-y := head.o init_task.o vmlinux.lds 8extra-y := head.o init_task.o vmlinux.lds
9 9
10obj-y := process.o setup.o cpu.o idprom.o \ 10obj-y := process.o setup.o cpu.o idprom.o \
11 traps.o auxio.o una_asm.o sysfs.o \ 11 traps.o auxio.o una_asm.o sysfs.o iommu.o \
12 irq.o ptrace.o time.o sys_sparc.o signal.o \ 12 irq.o ptrace.o time.o sys_sparc.o signal.o \
13 unaligned.o central.o pci.o starfire.o semaphore.o \ 13 unaligned.o central.o pci.o starfire.o semaphore.o \
14 power.o sbus.o iommu_common.o sparc64_ksyms.o chmc.o \ 14 power.o sbus.o iommu_common.o sparc64_ksyms.o chmc.o \
15 visemul.o prom.o of_device.o hvapi.o sstate.o mdesc.o 15 visemul.o prom.o of_device.o hvapi.o sstate.o mdesc.o
16 16
17obj-$(CONFIG_STACKTRACE) += stacktrace.o 17obj-$(CONFIG_STACKTRACE) += stacktrace.o
18obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o pci_iommu.o \ 18obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o \
19 pci_psycho.o pci_sabre.o pci_schizo.o \ 19 pci_psycho.o pci_sabre.o pci_schizo.o \
20 pci_sun4v.o pci_sun4v_asm.o pci_fire.o 20 pci_sun4v.o pci_sun4v_asm.o pci_fire.o
21obj-$(CONFIG_SMP) += smp.o trampoline.o hvtramp.o 21obj-$(CONFIG_SMP) += smp.o trampoline.o hvtramp.o
diff --git a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c
index 6d2956179cde..bc9ae36f7a43 100644
--- a/arch/sparc64/kernel/ebus.c
+++ b/arch/sparc64/kernel/ebus.c
@@ -391,6 +391,8 @@ static void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_de
391 sd = &dev->ofdev.dev.archdata; 391 sd = &dev->ofdev.dev.archdata;
392 sd->prom_node = dp; 392 sd->prom_node = dp;
393 sd->op = &dev->ofdev; 393 sd->op = &dev->ofdev;
394 sd->iommu = dev->bus->ofdev.dev.parent->archdata.iommu;
395 sd->stc = dev->bus->ofdev.dev.parent->archdata.stc;
394 396
395 dev->ofdev.node = dp; 397 dev->ofdev.node = dp;
396 dev->ofdev.dev.parent = &dev->bus->ofdev.dev; 398 dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
diff --git a/arch/sparc64/kernel/head.S b/arch/sparc64/kernel/head.S
index 35feacb6b8ec..9dbd833d79d6 100644
--- a/arch/sparc64/kernel/head.S
+++ b/arch/sparc64/kernel/head.S
@@ -1,15 +1,15 @@
1/* $Id: head.S,v 1.87 2002/02/09 19:49:31 davem Exp $ 1/* head.S: Initial boot code for the Sparc64 port of Linux.
2 * head.S: Initial boot code for the Sparc64 port of Linux.
3 * 2 *
4 * Copyright (C) 1996,1997 David S. Miller (davem@caip.rutgers.edu) 3 * Copyright (C) 1996, 1997, 2007 David S. Miller (davem@davemloft.net)
5 * Copyright (C) 1996 David Sitsky (David.Sitsky@anu.edu.au) 4 * Copyright (C) 1996 David Sitsky (David.Sitsky@anu.edu.au)
6 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 5 * Copyright (C) 1997, 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 * Copyright (C) 1997 Miguel de Icaza (miguel@nuclecu.unam.mx) 6 * Copyright (C) 1997 Miguel de Icaza (miguel@nuclecu.unam.mx)
8 */ 7 */
9 8
10#include <linux/version.h> 9#include <linux/version.h>
11#include <linux/errno.h> 10#include <linux/errno.h>
12#include <linux/threads.h> 11#include <linux/threads.h>
12#include <linux/init.h>
13#include <asm/thread_info.h> 13#include <asm/thread_info.h>
14#include <asm/asi.h> 14#include <asm/asi.h>
15#include <asm/pstate.h> 15#include <asm/pstate.h>
@@ -374,6 +374,7 @@ jump_to_sun4u_init:
374 jmpl %g2 + %g0, %g0 374 jmpl %g2 + %g0, %g0
375 nop 375 nop
376 376
377 .section .text.init.refok
377sun4u_init: 378sun4u_init:
378 BRANCH_IF_SUN4V(g1, sun4v_init) 379 BRANCH_IF_SUN4V(g1, sun4v_init)
379 380
@@ -529,6 +530,8 @@ tlb_fixup_done:
529 nop 530 nop
530 /* Not reached... */ 531 /* Not reached... */
531 532
533 .previous
534
532 /* This is meant to allow the sharing of this code between 535 /* This is meant to allow the sharing of this code between
533 * boot processor invocation (via setup_tba() below) and 536 * boot processor invocation (via setup_tba() below) and
534 * secondary processor startup (via trampoline.S). The 537 * secondary processor startup (via trampoline.S). The
diff --git a/arch/sparc64/kernel/init_task.c b/arch/sparc64/kernel/init_task.c
index 329b38fa5c89..90007cf88bac 100644
--- a/arch/sparc64/kernel/init_task.c
+++ b/arch/sparc64/kernel/init_task.c
@@ -1,4 +1,5 @@
1#include <linux/mm.h> 1#include <linux/mm.h>
2#include <linux/fs.h>
2#include <linux/module.h> 3#include <linux/module.h>
3#include <linux/sched.h> 4#include <linux/sched.h>
4#include <linux/init_task.h> 5#include <linux/init_task.h>
diff --git a/arch/sparc64/kernel/pci_iommu.c b/arch/sparc64/kernel/iommu.c
index 70d2364fdfe0..b35a62167e9c 100644
--- a/arch/sparc64/kernel/pci_iommu.c
+++ b/arch/sparc64/kernel/iommu.c
@@ -1,28 +1,32 @@
1/* pci_iommu.c: UltraSparc PCI controller IOM/STC support. 1/* iommu.c: Generic sparc64 IOMMU support.
2 * 2 *
3 * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net)
4 * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com) 4 * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com)
5 */ 5 */
6 6
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/sched.h> 8#include <linux/module.h>
9#include <linux/mm.h>
10#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/device.h>
11#include <linux/dma-mapping.h>
12#include <linux/errno.h>
13
14#ifdef CONFIG_PCI
11#include <linux/pci.h> 15#include <linux/pci.h>
16#endif
12 17
13#include <asm/oplib.h> 18#include <asm/iommu.h>
14 19
15#include "iommu_common.h" 20#include "iommu_common.h"
16#include "pci_impl.h"
17 21
18#define PCI_STC_CTXMATCH_ADDR(STC, CTX) \ 22#define STC_CTXMATCH_ADDR(STC, CTX) \
19 ((STC)->strbuf_ctxmatch_base + ((CTX) << 3)) 23 ((STC)->strbuf_ctxmatch_base + ((CTX) << 3))
24#define STC_FLUSHFLAG_INIT(STC) \
25 (*((STC)->strbuf_flushflag) = 0UL)
26#define STC_FLUSHFLAG_SET(STC) \
27 (*((STC)->strbuf_flushflag) != 0UL)
20 28
21/* Accessing IOMMU and Streaming Buffer registers. 29#define iommu_read(__reg) \
22 * REG parameter is a physical address. All registers
23 * are 64-bits in size.
24 */
25#define pci_iommu_read(__reg) \
26({ u64 __ret; \ 30({ u64 __ret; \
27 __asm__ __volatile__("ldxa [%1] %2, %0" \ 31 __asm__ __volatile__("ldxa [%1] %2, %0" \
28 : "=r" (__ret) \ 32 : "=r" (__ret) \
@@ -30,7 +34,7 @@
30 : "memory"); \ 34 : "memory"); \
31 __ret; \ 35 __ret; \
32}) 36})
33#define pci_iommu_write(__reg, __val) \ 37#define iommu_write(__reg, __val) \
34 __asm__ __volatile__("stxa %0, [%1] %2" \ 38 __asm__ __volatile__("stxa %0, [%1] %2" \
35 : /* no outputs */ \ 39 : /* no outputs */ \
36 : "r" (__val), "r" (__reg), \ 40 : "r" (__val), "r" (__reg), \
@@ -40,19 +44,19 @@
40static void __iommu_flushall(struct iommu *iommu) 44static void __iommu_flushall(struct iommu *iommu)
41{ 45{
42 if (iommu->iommu_flushinv) { 46 if (iommu->iommu_flushinv) {
43 pci_iommu_write(iommu->iommu_flushinv, ~(u64)0); 47 iommu_write(iommu->iommu_flushinv, ~(u64)0);
44 } else { 48 } else {
45 unsigned long tag; 49 unsigned long tag;
46 int entry; 50 int entry;
47 51
48 tag = iommu->iommu_flush + (0xa580UL - 0x0210UL); 52 tag = iommu->iommu_tags;
49 for (entry = 0; entry < 16; entry++) { 53 for (entry = 0; entry < 16; entry++) {
50 pci_iommu_write(tag, 0); 54 iommu_write(tag, 0);
51 tag += 8; 55 tag += 8;
52 } 56 }
53 57
54 /* Ensure completion of previous PIO writes. */ 58 /* Ensure completion of previous PIO writes. */
55 (void) pci_iommu_read(iommu->write_complete_reg); 59 (void) iommu_read(iommu->write_complete_reg);
56 } 60 }
57} 61}
58 62
@@ -80,7 +84,7 @@ static inline void iopte_make_dummy(struct iommu *iommu, iopte_t *iopte)
80} 84}
81 85
82/* Based largely upon the ppc64 iommu allocator. */ 86/* Based largely upon the ppc64 iommu allocator. */
83static long pci_arena_alloc(struct iommu *iommu, unsigned long npages) 87static long arena_alloc(struct iommu *iommu, unsigned long npages)
84{ 88{
85 struct iommu_arena *arena = &iommu->arena; 89 struct iommu_arena *arena = &iommu->arena;
86 unsigned long n, i, start, end, limit; 90 unsigned long n, i, start, end, limit;
@@ -121,7 +125,7 @@ again:
121 return n; 125 return n;
122} 126}
123 127
124static void pci_arena_free(struct iommu_arena *arena, unsigned long base, unsigned long npages) 128static void arena_free(struct iommu_arena *arena, unsigned long base, unsigned long npages)
125{ 129{
126 unsigned long i; 130 unsigned long i;
127 131
@@ -129,7 +133,8 @@ static void pci_arena_free(struct iommu_arena *arena, unsigned long base, unsign
129 __clear_bit(i, arena->map); 133 __clear_bit(i, arena->map);
130} 134}
131 135
132void pci_iommu_table_init(struct iommu *iommu, int tsbsize, u32 dma_offset, u32 dma_addr_mask) 136int iommu_table_init(struct iommu *iommu, int tsbsize,
137 u32 dma_offset, u32 dma_addr_mask)
133{ 138{
134 unsigned long i, tsbbase, order, sz, num_tsb_entries; 139 unsigned long i, tsbbase, order, sz, num_tsb_entries;
135 140
@@ -146,8 +151,8 @@ void pci_iommu_table_init(struct iommu *iommu, int tsbsize, u32 dma_offset, u32
146 sz = (sz + 7UL) & ~7UL; 151 sz = (sz + 7UL) & ~7UL;
147 iommu->arena.map = kzalloc(sz, GFP_KERNEL); 152 iommu->arena.map = kzalloc(sz, GFP_KERNEL);
148 if (!iommu->arena.map) { 153 if (!iommu->arena.map) {
149 prom_printf("PCI_IOMMU: Error, kmalloc(arena.map) failed.\n"); 154 printk(KERN_ERR "IOMMU: Error, kmalloc(arena.map) failed.\n");
150 prom_halt(); 155 return -ENOMEM;
151 } 156 }
152 iommu->arena.limit = num_tsb_entries; 157 iommu->arena.limit = num_tsb_entries;
153 158
@@ -156,8 +161,8 @@ void pci_iommu_table_init(struct iommu *iommu, int tsbsize, u32 dma_offset, u32
156 */ 161 */
157 iommu->dummy_page = __get_free_pages(GFP_KERNEL, 0); 162 iommu->dummy_page = __get_free_pages(GFP_KERNEL, 0);
158 if (!iommu->dummy_page) { 163 if (!iommu->dummy_page) {
159 prom_printf("PCI_IOMMU: Error, gfp(dummy_page) failed.\n"); 164 printk(KERN_ERR "IOMMU: Error, gfp(dummy_page) failed.\n");
160 prom_halt(); 165 goto out_free_map;
161 } 166 }
162 memset((void *)iommu->dummy_page, 0, PAGE_SIZE); 167 memset((void *)iommu->dummy_page, 0, PAGE_SIZE);
163 iommu->dummy_page_pa = (unsigned long) __pa(iommu->dummy_page); 168 iommu->dummy_page_pa = (unsigned long) __pa(iommu->dummy_page);
@@ -166,20 +171,32 @@ void pci_iommu_table_init(struct iommu *iommu, int tsbsize, u32 dma_offset, u32
166 order = get_order(tsbsize); 171 order = get_order(tsbsize);
167 tsbbase = __get_free_pages(GFP_KERNEL, order); 172 tsbbase = __get_free_pages(GFP_KERNEL, order);
168 if (!tsbbase) { 173 if (!tsbbase) {
169 prom_printf("PCI_IOMMU: Error, gfp(tsb) failed.\n"); 174 printk(KERN_ERR "IOMMU: Error, gfp(tsb) failed.\n");
170 prom_halt(); 175 goto out_free_dummy_page;
171 } 176 }
172 iommu->page_table = (iopte_t *)tsbbase; 177 iommu->page_table = (iopte_t *)tsbbase;
173 178
174 for (i = 0; i < num_tsb_entries; i++) 179 for (i = 0; i < num_tsb_entries; i++)
175 iopte_make_dummy(iommu, &iommu->page_table[i]); 180 iopte_make_dummy(iommu, &iommu->page_table[i]);
181
182 return 0;
183
184out_free_dummy_page:
185 free_page(iommu->dummy_page);
186 iommu->dummy_page = 0UL;
187
188out_free_map:
189 kfree(iommu->arena.map);
190 iommu->arena.map = NULL;
191
192 return -ENOMEM;
176} 193}
177 194
178static inline iopte_t *alloc_npages(struct iommu *iommu, unsigned long npages) 195static inline iopte_t *alloc_npages(struct iommu *iommu, unsigned long npages)
179{ 196{
180 long entry; 197 long entry;
181 198
182 entry = pci_arena_alloc(iommu, npages); 199 entry = arena_alloc(iommu, npages);
183 if (unlikely(entry < 0)) 200 if (unlikely(entry < 0))
184 return NULL; 201 return NULL;
185 202
@@ -188,7 +205,7 @@ static inline iopte_t *alloc_npages(struct iommu *iommu, unsigned long npages)
188 205
189static inline void free_npages(struct iommu *iommu, dma_addr_t base, unsigned long npages) 206static inline void free_npages(struct iommu *iommu, dma_addr_t base, unsigned long npages)
190{ 207{
191 pci_arena_free(&iommu->arena, base >> IO_PAGE_SHIFT, npages); 208 arena_free(&iommu->arena, base >> IO_PAGE_SHIFT, npages);
192} 209}
193 210
194static int iommu_alloc_ctx(struct iommu *iommu) 211static int iommu_alloc_ctx(struct iommu *iommu)
@@ -219,11 +236,8 @@ static inline void iommu_free_ctx(struct iommu *iommu, int ctx)
219 } 236 }
220} 237}
221 238
222/* Allocate and map kernel buffer of size SIZE using consistent mode 239static void *dma_4u_alloc_coherent(struct device *dev, size_t size,
223 * DMA for PCI device PDEV. Return non-NULL cpu-side address if 240 dma_addr_t *dma_addrp, gfp_t gfp)
224 * successful and set *DMA_ADDRP to the PCI side dma address.
225 */
226static void *pci_4u_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp, gfp_t gfp)
227{ 241{
228 struct iommu *iommu; 242 struct iommu *iommu;
229 iopte_t *iopte; 243 iopte_t *iopte;
@@ -241,7 +255,7 @@ static void *pci_4u_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr
241 return NULL; 255 return NULL;
242 memset((char *)first_page, 0, PAGE_SIZE << order); 256 memset((char *)first_page, 0, PAGE_SIZE << order);
243 257
244 iommu = pdev->dev.archdata.iommu; 258 iommu = dev->archdata.iommu;
245 259
246 spin_lock_irqsave(&iommu->lock, flags); 260 spin_lock_irqsave(&iommu->lock, flags);
247 iopte = alloc_npages(iommu, size >> IO_PAGE_SHIFT); 261 iopte = alloc_npages(iommu, size >> IO_PAGE_SHIFT);
@@ -268,15 +282,15 @@ static void *pci_4u_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr
268 return ret; 282 return ret;
269} 283}
270 284
271/* Free and unmap a consistent DMA translation. */ 285static void dma_4u_free_coherent(struct device *dev, size_t size,
272static void pci_4u_free_consistent(struct pci_dev *pdev, size_t size, void *cpu, dma_addr_t dvma) 286 void *cpu, dma_addr_t dvma)
273{ 287{
274 struct iommu *iommu; 288 struct iommu *iommu;
275 iopte_t *iopte; 289 iopte_t *iopte;
276 unsigned long flags, order, npages; 290 unsigned long flags, order, npages;
277 291
278 npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT; 292 npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT;
279 iommu = pdev->dev.archdata.iommu; 293 iommu = dev->archdata.iommu;
280 iopte = iommu->page_table + 294 iopte = iommu->page_table +
281 ((dvma - iommu->page_table_map_base) >> IO_PAGE_SHIFT); 295 ((dvma - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
282 296
@@ -291,10 +305,8 @@ static void pci_4u_free_consistent(struct pci_dev *pdev, size_t size, void *cpu,
291 free_pages((unsigned long)cpu, order); 305 free_pages((unsigned long)cpu, order);
292} 306}
293 307
294/* Map a single buffer at PTR of SZ bytes for PCI DMA 308static dma_addr_t dma_4u_map_single(struct device *dev, void *ptr, size_t sz,
295 * in streaming mode. 309 enum dma_data_direction direction)
296 */
297static dma_addr_t pci_4u_map_single(struct pci_dev *pdev, void *ptr, size_t sz, int direction)
298{ 310{
299 struct iommu *iommu; 311 struct iommu *iommu;
300 struct strbuf *strbuf; 312 struct strbuf *strbuf;
@@ -304,10 +316,10 @@ static dma_addr_t pci_4u_map_single(struct pci_dev *pdev, void *ptr, size_t sz,
304 u32 bus_addr, ret; 316 u32 bus_addr, ret;
305 unsigned long iopte_protection; 317 unsigned long iopte_protection;
306 318
307 iommu = pdev->dev.archdata.iommu; 319 iommu = dev->archdata.iommu;
308 strbuf = pdev->dev.archdata.stc; 320 strbuf = dev->archdata.stc;
309 321
310 if (unlikely(direction == PCI_DMA_NONE)) 322 if (unlikely(direction == DMA_NONE))
311 goto bad_no_ctx; 323 goto bad_no_ctx;
312 324
313 oaddr = (unsigned long)ptr; 325 oaddr = (unsigned long)ptr;
@@ -332,7 +344,7 @@ static dma_addr_t pci_4u_map_single(struct pci_dev *pdev, void *ptr, size_t sz,
332 iopte_protection = IOPTE_STREAMING(ctx); 344 iopte_protection = IOPTE_STREAMING(ctx);
333 else 345 else
334 iopte_protection = IOPTE_CONSISTENT(ctx); 346 iopte_protection = IOPTE_CONSISTENT(ctx);
335 if (direction != PCI_DMA_TODEVICE) 347 if (direction != DMA_TO_DEVICE)
336 iopte_protection |= IOPTE_WRITE; 348 iopte_protection |= IOPTE_WRITE;
337 349
338 for (i = 0; i < npages; i++, base++, base_paddr += IO_PAGE_SIZE) 350 for (i = 0; i < npages; i++, base++, base_paddr += IO_PAGE_SIZE)
@@ -345,10 +357,12 @@ bad:
345bad_no_ctx: 357bad_no_ctx:
346 if (printk_ratelimit()) 358 if (printk_ratelimit())
347 WARN_ON(1); 359 WARN_ON(1);
348 return PCI_DMA_ERROR_CODE; 360 return DMA_ERROR_CODE;
349} 361}
350 362
351static void pci_strbuf_flush(struct strbuf *strbuf, struct iommu *iommu, u32 vaddr, unsigned long ctx, unsigned long npages, int direction) 363static void strbuf_flush(struct strbuf *strbuf, struct iommu *iommu,
364 u32 vaddr, unsigned long ctx, unsigned long npages,
365 enum dma_data_direction direction)
352{ 366{
353 int limit; 367 int limit;
354 368
@@ -358,22 +372,22 @@ static void pci_strbuf_flush(struct strbuf *strbuf, struct iommu *iommu, u32 vad
358 u64 val; 372 u64 val;
359 373
360 flushreg = strbuf->strbuf_ctxflush; 374 flushreg = strbuf->strbuf_ctxflush;
361 matchreg = PCI_STC_CTXMATCH_ADDR(strbuf, ctx); 375 matchreg = STC_CTXMATCH_ADDR(strbuf, ctx);
362 376
363 pci_iommu_write(flushreg, ctx); 377 iommu_write(flushreg, ctx);
364 val = pci_iommu_read(matchreg); 378 val = iommu_read(matchreg);
365 val &= 0xffff; 379 val &= 0xffff;
366 if (!val) 380 if (!val)
367 goto do_flush_sync; 381 goto do_flush_sync;
368 382
369 while (val) { 383 while (val) {
370 if (val & 0x1) 384 if (val & 0x1)
371 pci_iommu_write(flushreg, ctx); 385 iommu_write(flushreg, ctx);
372 val >>= 1; 386 val >>= 1;
373 } 387 }
374 val = pci_iommu_read(matchreg); 388 val = iommu_read(matchreg);
375 if (unlikely(val)) { 389 if (unlikely(val)) {
376 printk(KERN_WARNING "pci_strbuf_flush: ctx flush " 390 printk(KERN_WARNING "strbuf_flush: ctx flush "
377 "timeout matchreg[%lx] ctx[%lx]\n", 391 "timeout matchreg[%lx] ctx[%lx]\n",
378 val, ctx); 392 val, ctx);
379 goto do_page_flush; 393 goto do_page_flush;
@@ -383,7 +397,7 @@ static void pci_strbuf_flush(struct strbuf *strbuf, struct iommu *iommu, u32 vad
383 397
384 do_page_flush: 398 do_page_flush:
385 for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE) 399 for (i = 0; i < npages; i++, vaddr += IO_PAGE_SIZE)
386 pci_iommu_write(strbuf->strbuf_pflush, vaddr); 400 iommu_write(strbuf->strbuf_pflush, vaddr);
387 } 401 }
388 402
389do_flush_sync: 403do_flush_sync:
@@ -391,15 +405,15 @@ do_flush_sync:
391 * the streaming cache, no flush-flag synchronization needs 405 * the streaming cache, no flush-flag synchronization needs
392 * to be performed. 406 * to be performed.
393 */ 407 */
394 if (direction == PCI_DMA_TODEVICE) 408 if (direction == DMA_TO_DEVICE)
395 return; 409 return;
396 410
397 PCI_STC_FLUSHFLAG_INIT(strbuf); 411 STC_FLUSHFLAG_INIT(strbuf);
398 pci_iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa); 412 iommu_write(strbuf->strbuf_fsync, strbuf->strbuf_flushflag_pa);
399 (void) pci_iommu_read(iommu->write_complete_reg); 413 (void) iommu_read(iommu->write_complete_reg);
400 414
401 limit = 100000; 415 limit = 100000;
402 while (!PCI_STC_FLUSHFLAG_SET(strbuf)) { 416 while (!STC_FLUSHFLAG_SET(strbuf)) {
403 limit--; 417 limit--;
404 if (!limit) 418 if (!limit)
405 break; 419 break;
@@ -407,37 +421,32 @@ do_flush_sync:
407 rmb(); 421 rmb();
408 } 422 }
409 if (!limit) 423 if (!limit)
410 printk(KERN_WARNING "pci_strbuf_flush: flushflag timeout " 424 printk(KERN_WARNING "strbuf_flush: flushflag timeout "
411 "vaddr[%08x] ctx[%lx] npages[%ld]\n", 425 "vaddr[%08x] ctx[%lx] npages[%ld]\n",
412 vaddr, ctx, npages); 426 vaddr, ctx, npages);
413} 427}
414 428
415/* Unmap a single streaming mode DMA translation. */ 429static void dma_4u_unmap_single(struct device *dev, dma_addr_t bus_addr,
416static void pci_4u_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction) 430 size_t sz, enum dma_data_direction direction)
417{ 431{
418 struct iommu *iommu; 432 struct iommu *iommu;
419 struct strbuf *strbuf; 433 struct strbuf *strbuf;
420 iopte_t *base; 434 iopte_t *base;
421 unsigned long flags, npages, ctx, i; 435 unsigned long flags, npages, ctx, i;
422 436
423 if (unlikely(direction == PCI_DMA_NONE)) { 437 if (unlikely(direction == DMA_NONE)) {
424 if (printk_ratelimit()) 438 if (printk_ratelimit())
425 WARN_ON(1); 439 WARN_ON(1);
426 return; 440 return;
427 } 441 }
428 442
429 iommu = pdev->dev.archdata.iommu; 443 iommu = dev->archdata.iommu;
430 strbuf = pdev->dev.archdata.stc; 444 strbuf = dev->archdata.stc;
431 445
432 npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK); 446 npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK);
433 npages >>= IO_PAGE_SHIFT; 447 npages >>= IO_PAGE_SHIFT;
434 base = iommu->page_table + 448 base = iommu->page_table +
435 ((bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT); 449 ((bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
436#ifdef DEBUG_PCI_IOMMU
437 if (IOPTE_IS_DUMMY(iommu, base))
438 printk("pci_unmap_single called on non-mapped region %08x,%08x from %016lx\n",
439 bus_addr, sz, __builtin_return_address(0));
440#endif
441 bus_addr &= IO_PAGE_MASK; 450 bus_addr &= IO_PAGE_MASK;
442 451
443 spin_lock_irqsave(&iommu->lock, flags); 452 spin_lock_irqsave(&iommu->lock, flags);
@@ -449,8 +458,8 @@ static void pci_4u_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_
449 458
450 /* Step 1: Kick data out of streaming buffers if necessary. */ 459 /* Step 1: Kick data out of streaming buffers if necessary. */
451 if (strbuf->strbuf_enabled) 460 if (strbuf->strbuf_enabled)
452 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, 461 strbuf_flush(strbuf, iommu, bus_addr, ctx,
453 npages, direction); 462 npages, direction);
454 463
455 /* Step 2: Clear out TSB entries. */ 464 /* Step 2: Clear out TSB entries. */
456 for (i = 0; i < npages; i++) 465 for (i = 0; i < npages; i++)
@@ -467,7 +476,8 @@ static void pci_4u_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_
467 (__pa(page_address((SG)->page)) + (SG)->offset) 476 (__pa(page_address((SG)->page)) + (SG)->offset)
468 477
469static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg, 478static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg,
470 int nused, int nelems, unsigned long iopte_protection) 479 int nused, int nelems,
480 unsigned long iopte_protection)
471{ 481{
472 struct scatterlist *dma_sg = sg; 482 struct scatterlist *dma_sg = sg;
473 struct scatterlist *sg_end = sg + nelems; 483 struct scatterlist *sg_end = sg + nelems;
@@ -539,12 +549,8 @@ static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg,
539 } 549 }
540} 550}
541 551
542/* Map a set of buffers described by SGLIST with NELEMS array 552static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
543 * elements in streaming mode for PCI DMA. 553 int nelems, enum dma_data_direction direction)
544 * When making changes here, inspect the assembly output. I was having
545 * hard time to keep this routine out of using stack slots for holding variables.
546 */
547static int pci_4u_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction)
548{ 554{
549 struct iommu *iommu; 555 struct iommu *iommu;
550 struct strbuf *strbuf; 556 struct strbuf *strbuf;
@@ -557,19 +563,20 @@ static int pci_4u_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int n
557 /* Fast path single entry scatterlists. */ 563 /* Fast path single entry scatterlists. */
558 if (nelems == 1) { 564 if (nelems == 1) {
559 sglist->dma_address = 565 sglist->dma_address =
560 pci_4u_map_single(pdev, 566 dma_4u_map_single(dev,
561 (page_address(sglist->page) + sglist->offset), 567 (page_address(sglist->page) +
568 sglist->offset),
562 sglist->length, direction); 569 sglist->length, direction);
563 if (unlikely(sglist->dma_address == PCI_DMA_ERROR_CODE)) 570 if (unlikely(sglist->dma_address == DMA_ERROR_CODE))
564 return 0; 571 return 0;
565 sglist->dma_length = sglist->length; 572 sglist->dma_length = sglist->length;
566 return 1; 573 return 1;
567 } 574 }
568 575
569 iommu = pdev->dev.archdata.iommu; 576 iommu = dev->archdata.iommu;
570 strbuf = pdev->dev.archdata.stc; 577 strbuf = dev->archdata.stc;
571 578
572 if (unlikely(direction == PCI_DMA_NONE)) 579 if (unlikely(direction == DMA_NONE))
573 goto bad_no_ctx; 580 goto bad_no_ctx;
574 581
575 /* Step 1: Prepare scatter list. */ 582 /* Step 1: Prepare scatter list. */
@@ -609,7 +616,7 @@ static int pci_4u_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int n
609 iopte_protection = IOPTE_STREAMING(ctx); 616 iopte_protection = IOPTE_STREAMING(ctx);
610 else 617 else
611 iopte_protection = IOPTE_CONSISTENT(ctx); 618 iopte_protection = IOPTE_CONSISTENT(ctx);
612 if (direction != PCI_DMA_TODEVICE) 619 if (direction != DMA_TO_DEVICE)
613 iopte_protection |= IOPTE_WRITE; 620 iopte_protection |= IOPTE_WRITE;
614 621
615 fill_sg(base, sglist, used, nelems, iopte_protection); 622 fill_sg(base, sglist, used, nelems, iopte_protection);
@@ -628,8 +635,8 @@ bad_no_ctx:
628 return 0; 635 return 0;
629} 636}
630 637
631/* Unmap a set of streaming mode DMA translations. */ 638static void dma_4u_unmap_sg(struct device *dev, struct scatterlist *sglist,
632static void pci_4u_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) 639 int nelems, enum dma_data_direction direction)
633{ 640{
634 struct iommu *iommu; 641 struct iommu *iommu;
635 struct strbuf *strbuf; 642 struct strbuf *strbuf;
@@ -637,14 +644,14 @@ static void pci_4u_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, in
637 unsigned long flags, ctx, i, npages; 644 unsigned long flags, ctx, i, npages;
638 u32 bus_addr; 645 u32 bus_addr;
639 646
640 if (unlikely(direction == PCI_DMA_NONE)) { 647 if (unlikely(direction == DMA_NONE)) {
641 if (printk_ratelimit()) 648 if (printk_ratelimit())
642 WARN_ON(1); 649 WARN_ON(1);
643 } 650 }
644 651
645 iommu = pdev->dev.archdata.iommu; 652 iommu = dev->archdata.iommu;
646 strbuf = pdev->dev.archdata.stc; 653 strbuf = dev->archdata.stc;
647 654
648 bus_addr = sglist->dma_address & IO_PAGE_MASK; 655 bus_addr = sglist->dma_address & IO_PAGE_MASK;
649 656
650 for (i = 1; i < nelems; i++) 657 for (i = 1; i < nelems; i++)
@@ -657,11 +664,6 @@ static void pci_4u_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, in
657 base = iommu->page_table + 664 base = iommu->page_table +
658 ((bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT); 665 ((bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
659 666
660#ifdef DEBUG_PCI_IOMMU
661 if (IOPTE_IS_DUMMY(iommu, base))
662 printk("pci_unmap_sg called on non-mapped region %016lx,%d from %016lx\n", sglist->dma_address, nelems, __builtin_return_address(0));
663#endif
664
665 spin_lock_irqsave(&iommu->lock, flags); 667 spin_lock_irqsave(&iommu->lock, flags);
666 668
667 /* Record the context, if any. */ 669 /* Record the context, if any. */
@@ -671,7 +673,7 @@ static void pci_4u_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, in
671 673
672 /* Step 1: Kick data out of streaming buffers if necessary. */ 674 /* Step 1: Kick data out of streaming buffers if necessary. */
673 if (strbuf->strbuf_enabled) 675 if (strbuf->strbuf_enabled)
674 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction); 676 strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction);
675 677
676 /* Step 2: Clear out the TSB entries. */ 678 /* Step 2: Clear out the TSB entries. */
677 for (i = 0; i < npages; i++) 679 for (i = 0; i < npages; i++)
@@ -684,17 +686,16 @@ static void pci_4u_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, in
684 spin_unlock_irqrestore(&iommu->lock, flags); 686 spin_unlock_irqrestore(&iommu->lock, flags);
685} 687}
686 688
687/* Make physical memory consistent for a single 689static void dma_4u_sync_single_for_cpu(struct device *dev,
688 * streaming mode DMA translation after a transfer. 690 dma_addr_t bus_addr, size_t sz,
689 */ 691 enum dma_data_direction direction)
690static void pci_4u_dma_sync_single_for_cpu(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction)
691{ 692{
692 struct iommu *iommu; 693 struct iommu *iommu;
693 struct strbuf *strbuf; 694 struct strbuf *strbuf;
694 unsigned long flags, ctx, npages; 695 unsigned long flags, ctx, npages;
695 696
696 iommu = pdev->dev.archdata.iommu; 697 iommu = dev->archdata.iommu;
697 strbuf = pdev->dev.archdata.stc; 698 strbuf = dev->archdata.stc;
698 699
699 if (!strbuf->strbuf_enabled) 700 if (!strbuf->strbuf_enabled)
700 return; 701 return;
@@ -717,23 +718,22 @@ static void pci_4u_dma_sync_single_for_cpu(struct pci_dev *pdev, dma_addr_t bus_
717 } 718 }
718 719
719 /* Step 2: Kick data out of streaming buffers. */ 720 /* Step 2: Kick data out of streaming buffers. */
720 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction); 721 strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction);
721 722
722 spin_unlock_irqrestore(&iommu->lock, flags); 723 spin_unlock_irqrestore(&iommu->lock, flags);
723} 724}
724 725
725/* Make physical memory consistent for a set of streaming 726static void dma_4u_sync_sg_for_cpu(struct device *dev,
726 * mode DMA translations after a transfer. 727 struct scatterlist *sglist, int nelems,
727 */ 728 enum dma_data_direction direction)
728static void pci_4u_dma_sync_sg_for_cpu(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction)
729{ 729{
730 struct iommu *iommu; 730 struct iommu *iommu;
731 struct strbuf *strbuf; 731 struct strbuf *strbuf;
732 unsigned long flags, ctx, npages, i; 732 unsigned long flags, ctx, npages, i;
733 u32 bus_addr; 733 u32 bus_addr;
734 734
735 iommu = pdev->dev.archdata.iommu; 735 iommu = dev->archdata.iommu;
736 strbuf = pdev->dev.archdata.stc; 736 strbuf = dev->archdata.stc;
737 737
738 if (!strbuf->strbuf_enabled) 738 if (!strbuf->strbuf_enabled)
739 return; 739 return;
@@ -759,65 +759,51 @@ static void pci_4u_dma_sync_sg_for_cpu(struct pci_dev *pdev, struct scatterlist
759 i--; 759 i--;
760 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) 760 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length)
761 - bus_addr) >> IO_PAGE_SHIFT; 761 - bus_addr) >> IO_PAGE_SHIFT;
762 pci_strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction); 762 strbuf_flush(strbuf, iommu, bus_addr, ctx, npages, direction);
763 763
764 spin_unlock_irqrestore(&iommu->lock, flags); 764 spin_unlock_irqrestore(&iommu->lock, flags);
765} 765}
766 766
767const struct pci_iommu_ops pci_sun4u_iommu_ops = { 767const struct dma_ops sun4u_dma_ops = {
768 .alloc_consistent = pci_4u_alloc_consistent, 768 .alloc_coherent = dma_4u_alloc_coherent,
769 .free_consistent = pci_4u_free_consistent, 769 .free_coherent = dma_4u_free_coherent,
770 .map_single = pci_4u_map_single, 770 .map_single = dma_4u_map_single,
771 .unmap_single = pci_4u_unmap_single, 771 .unmap_single = dma_4u_unmap_single,
772 .map_sg = pci_4u_map_sg, 772 .map_sg = dma_4u_map_sg,
773 .unmap_sg = pci_4u_unmap_sg, 773 .unmap_sg = dma_4u_unmap_sg,
774 .dma_sync_single_for_cpu = pci_4u_dma_sync_single_for_cpu, 774 .sync_single_for_cpu = dma_4u_sync_single_for_cpu,
775 .dma_sync_sg_for_cpu = pci_4u_dma_sync_sg_for_cpu, 775 .sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
776}; 776};
777 777
778static void ali_sound_dma_hack(struct pci_dev *pdev, int set_bit) 778const struct dma_ops *dma_ops = &sun4u_dma_ops;
779{ 779EXPORT_SYMBOL(dma_ops);
780 struct pci_dev *ali_isa_bridge;
781 u8 val;
782 780
783 /* ALI sound chips generate 31-bits of DMA, a special register 781int dma_supported(struct device *dev, u64 device_mask)
784 * determines what bit 31 is emitted as.
785 */
786 ali_isa_bridge = pci_get_device(PCI_VENDOR_ID_AL,
787 PCI_DEVICE_ID_AL_M1533,
788 NULL);
789
790 pci_read_config_byte(ali_isa_bridge, 0x7e, &val);
791 if (set_bit)
792 val |= 0x01;
793 else
794 val &= ~0x01;
795 pci_write_config_byte(ali_isa_bridge, 0x7e, val);
796 pci_dev_put(ali_isa_bridge);
797}
798
799int pci_dma_supported(struct pci_dev *pdev, u64 device_mask)
800{ 782{
801 u64 dma_addr_mask; 783 struct iommu *iommu = dev->archdata.iommu;
784 u64 dma_addr_mask = iommu->dma_addr_mask;
802 785
803 if (pdev == NULL) { 786 if (device_mask >= (1UL << 32UL))
804 dma_addr_mask = 0xffffffff; 787 return 0;
805 } else {
806 struct iommu *iommu = pdev->dev.archdata.iommu;
807 788
808 dma_addr_mask = iommu->dma_addr_mask; 789 if ((device_mask & dma_addr_mask) == dma_addr_mask)
790 return 1;
809 791
810 if (pdev->vendor == PCI_VENDOR_ID_AL && 792#ifdef CONFIG_PCI
811 pdev->device == PCI_DEVICE_ID_AL_M5451 && 793 if (dev->bus == &pci_bus_type)
812 device_mask == 0x7fffffff) { 794 return pci_dma_supported(to_pci_dev(dev), device_mask);
813 ali_sound_dma_hack(pdev, 795#endif
814 (dma_addr_mask & 0x80000000) != 0);
815 return 1;
816 }
817 }
818 796
819 if (device_mask >= (1UL << 32UL)) 797 return 0;
820 return 0; 798}
799EXPORT_SYMBOL(dma_supported);
821 800
822 return (device_mask & dma_addr_mask) == dma_addr_mask; 801int dma_set_mask(struct device *dev, u64 dma_mask)
802{
803#ifdef CONFIG_PCI
804 if (dev->bus == &pci_bus_type)
805 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
806#endif
807 return -EINVAL;
823} 808}
809EXPORT_SYMBOL(dma_set_mask);
diff --git a/arch/sparc64/kernel/isa.c b/arch/sparc64/kernel/isa.c
index 1a1043fcf97d..0f19dce1c905 100644
--- a/arch/sparc64/kernel/isa.c
+++ b/arch/sparc64/kernel/isa.c
@@ -90,6 +90,8 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
90 sd = &isa_dev->ofdev.dev.archdata; 90 sd = &isa_dev->ofdev.dev.archdata;
91 sd->prom_node = dp; 91 sd->prom_node = dp;
92 sd->op = &isa_dev->ofdev; 92 sd->op = &isa_dev->ofdev;
93 sd->iommu = isa_br->ofdev.dev.parent->archdata.iommu;
94 sd->stc = isa_br->ofdev.dev.parent->archdata.stc;
93 95
94 isa_dev->ofdev.node = dp; 96 isa_dev->ofdev.node = dp;
95 isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev; 97 isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev;
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index 55ad1b899bb8..3d93e9203ba2 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -283,12 +283,6 @@ int __init pcic_present(void)
283 return pci_controller_scan(pci_is_controller); 283 return pci_controller_scan(pci_is_controller);
284} 284}
285 285
286const struct pci_iommu_ops *pci_iommu_ops;
287EXPORT_SYMBOL(pci_iommu_ops);
288
289extern const struct pci_iommu_ops pci_sun4u_iommu_ops,
290 pci_sun4v_iommu_ops;
291
292/* Find each controller in the system, attach and initialize 286/* Find each controller in the system, attach and initialize
293 * software state structure for each and link into the 287 * software state structure for each and link into the
294 * pci_pbm_root. Setup the controller enough such 288 * pci_pbm_root. Setup the controller enough such
@@ -296,11 +290,6 @@ extern const struct pci_iommu_ops pci_sun4u_iommu_ops,
296 */ 290 */
297static void __init pci_controller_probe(void) 291static void __init pci_controller_probe(void)
298{ 292{
299 if (tlb_type == hypervisor)
300 pci_iommu_ops = &pci_sun4v_iommu_ops;
301 else
302 pci_iommu_ops = &pci_sun4u_iommu_ops;
303
304 printk("PCI: Probing for controllers.\n"); 293 printk("PCI: Probing for controllers.\n");
305 294
306 pci_controller_scan(pci_controller_init); 295 pci_controller_scan(pci_controller_init);
@@ -406,6 +395,10 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
406 sd->op = of_find_device_by_node(node); 395 sd->op = of_find_device_by_node(node);
407 sd->msi_num = 0xffffffff; 396 sd->msi_num = 0xffffffff;
408 397
398 sd = &sd->op->dev.archdata;
399 sd->iommu = pbm->iommu;
400 sd->stc = &pbm->stc;
401
409 type = of_get_property(node, "device_type", NULL); 402 type = of_get_property(node, "device_type", NULL);
410 if (type == NULL) 403 if (type == NULL)
411 type = ""; 404 type = "";
@@ -422,10 +415,15 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
422 dev->multifunction = 0; /* maybe a lie? */ 415 dev->multifunction = 0; /* maybe a lie? */
423 416
424 if (host_controller) { 417 if (host_controller) {
425 dev->vendor = 0x108e; 418 if (tlb_type != hypervisor) {
426 dev->device = 0x8000; 419 pci_read_config_word(dev, PCI_VENDOR_ID,
427 dev->subsystem_vendor = 0x0000; 420 &dev->vendor);
428 dev->subsystem_device = 0x0000; 421 pci_read_config_word(dev, PCI_DEVICE_ID,
422 &dev->device);
423 } else {
424 dev->vendor = PCI_VENDOR_ID_SUN;
425 dev->device = 0x80f0;
426 }
429 dev->cfg_size = 256; 427 dev->cfg_size = 256;
430 dev->class = PCI_CLASS_BRIDGE_HOST << 8; 428 dev->class = PCI_CLASS_BRIDGE_HOST << 8;
431 sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus), 429 sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus),
@@ -818,7 +816,7 @@ int pci_host_bridge_read_pci_cfg(struct pci_bus *bus_dev,
818{ 816{
819 static u8 fake_pci_config[] = { 817 static u8 fake_pci_config[] = {
820 0x8e, 0x10, /* Vendor: 0x108e (Sun) */ 818 0x8e, 0x10, /* Vendor: 0x108e (Sun) */
821 0x00, 0x80, /* Device: 0x8000 (PBM) */ 819 0xf0, 0x80, /* Device: 0x80f0 (Fire) */
822 0x46, 0x01, /* Command: 0x0146 (SERR, PARITY, MASTER, MEM) */ 820 0x46, 0x01, /* Command: 0x0146 (SERR, PARITY, MASTER, MEM) */
823 0xa0, 0x22, /* Status: 0x02a0 (DEVSEL_MED, FB2B, 66MHZ) */ 821 0xa0, 0x22, /* Status: 0x02a0 (DEVSEL_MED, FB2B, 66MHZ) */
824 0x00, 0x00, 0x00, 0x06, /* Class: 0x06000000 host bridge */ 822 0x00, 0x00, 0x00, 0x06, /* Class: 0x06000000 host bridge */
@@ -1221,4 +1219,51 @@ struct device_node *pci_device_to_OF_node(struct pci_dev *pdev)
1221} 1219}
1222EXPORT_SYMBOL(pci_device_to_OF_node); 1220EXPORT_SYMBOL(pci_device_to_OF_node);
1223 1221
1222static void ali_sound_dma_hack(struct pci_dev *pdev, int set_bit)
1223{
1224 struct pci_dev *ali_isa_bridge;
1225 u8 val;
1226
1227 /* ALI sound chips generate 31-bits of DMA, a special register
1228 * determines what bit 31 is emitted as.
1229 */
1230 ali_isa_bridge = pci_get_device(PCI_VENDOR_ID_AL,
1231 PCI_DEVICE_ID_AL_M1533,
1232 NULL);
1233
1234 pci_read_config_byte(ali_isa_bridge, 0x7e, &val);
1235 if (set_bit)
1236 val |= 0x01;
1237 else
1238 val &= ~0x01;
1239 pci_write_config_byte(ali_isa_bridge, 0x7e, val);
1240 pci_dev_put(ali_isa_bridge);
1241}
1242
1243int pci_dma_supported(struct pci_dev *pdev, u64 device_mask)
1244{
1245 u64 dma_addr_mask;
1246
1247 if (pdev == NULL) {
1248 dma_addr_mask = 0xffffffff;
1249 } else {
1250 struct iommu *iommu = pdev->dev.archdata.iommu;
1251
1252 dma_addr_mask = iommu->dma_addr_mask;
1253
1254 if (pdev->vendor == PCI_VENDOR_ID_AL &&
1255 pdev->device == PCI_DEVICE_ID_AL_M5451 &&
1256 device_mask == 0x7fffffff) {
1257 ali_sound_dma_hack(pdev,
1258 (dma_addr_mask & 0x80000000) != 0);
1259 return 1;
1260 }
1261 }
1262
1263 if (device_mask >= (1UL << 32UL))
1264 return 0;
1265
1266 return (device_mask & dma_addr_mask) == dma_addr_mask;
1267}
1268
1224#endif /* !(CONFIG_PCI) */ 1269#endif /* !(CONFIG_PCI) */
diff --git a/arch/sparc64/kernel/pci_common.c b/arch/sparc64/kernel/pci_common.c
index 4249214608af..2f61c4b12596 100644
--- a/arch/sparc64/kernel/pci_common.c
+++ b/arch/sparc64/kernel/pci_common.c
@@ -44,6 +44,67 @@ static void *sun4u_config_mkaddr(struct pci_pbm_info *pbm,
44 return (void *) (pbm->config_space | bus | devfn | reg); 44 return (void *) (pbm->config_space | bus | devfn | reg);
45} 45}
46 46
47/* At least on Sabre, it is necessary to access all PCI host controller
48 * registers at their natural size, otherwise zeros are returned.
49 * Strange but true, and I see no language in the UltraSPARC-IIi
50 * programmer's manual that mentions this even indirectly.
51 */
52static int sun4u_read_pci_cfg_host(struct pci_pbm_info *pbm,
53 unsigned char bus, unsigned int devfn,
54 int where, int size, u32 *value)
55{
56 u32 tmp32, *addr;
57 u16 tmp16;
58 u8 tmp8;
59
60 addr = sun4u_config_mkaddr(pbm, bus, devfn, where);
61 if (!addr)
62 return PCIBIOS_SUCCESSFUL;
63
64 switch (size) {
65 case 1:
66 if (where < 8) {
67 unsigned long align = (unsigned long) addr;
68
69 align &= ~1;
70 pci_config_read16((u16 *)align, &tmp16);
71 if (where & 1)
72 *value = tmp16 >> 8;
73 else
74 *value = tmp16 & 0xff;
75 } else {
76 pci_config_read8((u8 *)addr, &tmp8);
77 *value = (u32) tmp8;
78 }
79 break;
80
81 case 2:
82 if (where < 8) {
83 pci_config_read16((u16 *)addr, &tmp16);
84 *value = (u32) tmp16;
85 } else {
86 pci_config_read8((u8 *)addr, &tmp8);
87 *value = (u32) tmp8;
88 pci_config_read8(((u8 *)addr) + 1, &tmp8);
89 *value |= ((u32) tmp8) << 8;
90 }
91 break;
92
93 case 4:
94 tmp32 = 0xffffffff;
95 sun4u_read_pci_cfg_host(pbm, bus, devfn,
96 where, 2, &tmp32);
97 *value = tmp32;
98
99 tmp32 = 0xffffffff;
100 sun4u_read_pci_cfg_host(pbm, bus, devfn,
101 where + 2, 2, &tmp32);
102 *value |= tmp32 << 16;
103 break;
104 }
105 return PCIBIOS_SUCCESSFUL;
106}
107
47static int sun4u_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn, 108static int sun4u_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
48 int where, int size, u32 *value) 109 int where, int size, u32 *value)
49{ 110{
@@ -53,10 +114,6 @@ static int sun4u_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
53 u16 tmp16; 114 u16 tmp16;
54 u8 tmp8; 115 u8 tmp8;
55 116
56 if (bus_dev == pbm->pci_bus && devfn == 0x00)
57 return pci_host_bridge_read_pci_cfg(bus_dev, devfn, where,
58 size, value);
59
60 switch (size) { 117 switch (size) {
61 case 1: 118 case 1:
62 *value = 0xff; 119 *value = 0xff;
@@ -69,6 +126,10 @@ static int sun4u_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
69 break; 126 break;
70 } 127 }
71 128
129 if (!bus_dev->number && !PCI_SLOT(devfn))
130 return sun4u_read_pci_cfg_host(pbm, bus, devfn, where,
131 size, value);
132
72 addr = sun4u_config_mkaddr(pbm, bus, devfn, where); 133 addr = sun4u_config_mkaddr(pbm, bus, devfn, where);
73 if (!addr) 134 if (!addr)
74 return PCIBIOS_SUCCESSFUL; 135 return PCIBIOS_SUCCESSFUL;
@@ -101,6 +162,53 @@ static int sun4u_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
101 return PCIBIOS_SUCCESSFUL; 162 return PCIBIOS_SUCCESSFUL;
102} 163}
103 164
165static int sun4u_write_pci_cfg_host(struct pci_pbm_info *pbm,
166 unsigned char bus, unsigned int devfn,
167 int where, int size, u32 value)
168{
169 u32 *addr;
170
171 addr = sun4u_config_mkaddr(pbm, bus, devfn, where);
172 if (!addr)
173 return PCIBIOS_SUCCESSFUL;
174
175 switch (size) {
176 case 1:
177 if (where < 8) {
178 unsigned long align = (unsigned long) addr;
179 u16 tmp16;
180
181 align &= ~1;
182 pci_config_read16((u16 *)align, &tmp16);
183 if (where & 1) {
184 tmp16 &= 0x00ff;
185 tmp16 |= value << 8;
186 } else {
187 tmp16 &= 0xff00;
188 tmp16 |= value;
189 }
190 pci_config_write16((u16 *)align, tmp16);
191 } else
192 pci_config_write8((u8 *)addr, value);
193 break;
194 case 2:
195 if (where < 8) {
196 pci_config_write16((u16 *)addr, value);
197 } else {
198 pci_config_write8((u8 *)addr, value & 0xff);
199 pci_config_write8(((u8 *)addr) + 1, value >> 8);
200 }
201 break;
202 case 4:
203 sun4u_write_pci_cfg_host(pbm, bus, devfn,
204 where, 2, value & 0xffff);
205 sun4u_write_pci_cfg_host(pbm, bus, devfn,
206 where + 2, 2, value >> 16);
207 break;
208 }
209 return PCIBIOS_SUCCESSFUL;
210}
211
104static int sun4u_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn, 212static int sun4u_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
105 int where, int size, u32 value) 213 int where, int size, u32 value)
106{ 214{
@@ -108,9 +216,10 @@ static int sun4u_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
108 unsigned char bus = bus_dev->number; 216 unsigned char bus = bus_dev->number;
109 u32 *addr; 217 u32 *addr;
110 218
111 if (bus_dev == pbm->pci_bus && devfn == 0x00) 219 if (!bus_dev->number && !PCI_SLOT(devfn))
112 return pci_host_bridge_write_pci_cfg(bus_dev, devfn, where, 220 return sun4u_write_pci_cfg_host(pbm, bus, devfn, where,
113 size, value); 221 size, value);
222
114 addr = sun4u_config_mkaddr(pbm, bus, devfn, where); 223 addr = sun4u_config_mkaddr(pbm, bus, devfn, where);
115 if (!addr) 224 if (!addr)
116 return PCIBIOS_SUCCESSFUL; 225 return PCIBIOS_SUCCESSFUL;
diff --git a/arch/sparc64/kernel/pci_fire.c b/arch/sparc64/kernel/pci_fire.c
index 7f5d473901c4..14d67fe21ab2 100644
--- a/arch/sparc64/kernel/pci_fire.c
+++ b/arch/sparc64/kernel/pci_fire.c
@@ -39,12 +39,12 @@ static void pci_fire_scan_bus(struct pci_pbm_info *pbm)
39#define FIRE_IOMMU_FLUSH 0x40100UL 39#define FIRE_IOMMU_FLUSH 0x40100UL
40#define FIRE_IOMMU_FLUSHINV 0x40108UL 40#define FIRE_IOMMU_FLUSHINV 0x40108UL
41 41
42static void pci_fire_pbm_iommu_init(struct pci_pbm_info *pbm) 42static int pci_fire_pbm_iommu_init(struct pci_pbm_info *pbm)
43{ 43{
44 struct iommu *iommu = pbm->iommu; 44 struct iommu *iommu = pbm->iommu;
45 u32 vdma[2], dma_mask; 45 u32 vdma[2], dma_mask;
46 u64 control; 46 u64 control;
47 int tsbsize; 47 int tsbsize, err;
48 48
49 /* No virtual-dma property on these guys, use largest size. */ 49 /* No virtual-dma property on these guys, use largest size. */
50 vdma[0] = 0xc0000000; /* base */ 50 vdma[0] = 0xc0000000; /* base */
@@ -68,7 +68,9 @@ static void pci_fire_pbm_iommu_init(struct pci_pbm_info *pbm)
68 */ 68 */
69 fire_write(iommu->iommu_flushinv, ~(u64)0); 69 fire_write(iommu->iommu_flushinv, ~(u64)0);
70 70
71 pci_iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask); 71 err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask);
72 if (err)
73 return err;
72 74
73 fire_write(iommu->iommu_tsbbase, __pa(iommu->page_table) | 0x7UL); 75 fire_write(iommu->iommu_tsbbase, __pa(iommu->page_table) | 0x7UL);
74 76
@@ -78,6 +80,8 @@ static void pci_fire_pbm_iommu_init(struct pci_pbm_info *pbm)
78 0x00000002 /* Bypass enable */ | 80 0x00000002 /* Bypass enable */ |
79 0x00000001 /* Translation enable */); 81 0x00000001 /* Translation enable */);
80 fire_write(iommu->iommu_control, control); 82 fire_write(iommu->iommu_control, control);
83
84 return 0;
81} 85}
82 86
83/* Based at pbm->controller_regs */ 87/* Based at pbm->controller_regs */
@@ -167,8 +171,8 @@ static void pci_fire_hw_init(struct pci_pbm_info *pbm)
167 fire_write(pbm->pbm_regs + FIRE_PEC_IENAB, ~(u64)0); 171 fire_write(pbm->pbm_regs + FIRE_PEC_IENAB, ~(u64)0);
168} 172}
169 173
170static void pci_fire_pbm_init(struct pci_controller_info *p, 174static int pci_fire_pbm_init(struct pci_controller_info *p,
171 struct device_node *dp, u32 portid) 175 struct device_node *dp, u32 portid)
172{ 176{
173 const struct linux_prom64_registers *regs; 177 const struct linux_prom64_registers *regs;
174 struct pci_pbm_info *pbm; 178 struct pci_pbm_info *pbm;
@@ -203,7 +207,8 @@ static void pci_fire_pbm_init(struct pci_controller_info *p,
203 pci_get_pbm_props(pbm); 207 pci_get_pbm_props(pbm);
204 208
205 pci_fire_hw_init(pbm); 209 pci_fire_hw_init(pbm);
206 pci_fire_pbm_iommu_init(pbm); 210
211 return pci_fire_pbm_iommu_init(pbm);
207} 212}
208 213
209static inline int portid_compare(u32 x, u32 y) 214static inline int portid_compare(u32 x, u32 y)
@@ -222,7 +227,8 @@ void fire_pci_init(struct device_node *dp, const char *model_name)
222 227
223 for (pbm = pci_pbm_root; pbm; pbm = pbm->next) { 228 for (pbm = pci_pbm_root; pbm; pbm = pbm->next) {
224 if (portid_compare(pbm->portid, portid)) { 229 if (portid_compare(pbm->portid, portid)) {
225 pci_fire_pbm_init(pbm->parent, dp, portid); 230 if (pci_fire_pbm_init(pbm->parent, dp, portid))
231 goto fatal_memory_error;
226 return; 232 return;
227 } 233 }
228 } 234 }
@@ -250,7 +256,9 @@ void fire_pci_init(struct device_node *dp, const char *model_name)
250 */ 256 */
251 pci_memspace_mask = 0x7fffffffUL; 257 pci_memspace_mask = 0x7fffffffUL;
252 258
253 pci_fire_pbm_init(p, dp, portid); 259 if (pci_fire_pbm_init(p, dp, portid))
260 goto fatal_memory_error;
261
254 return; 262 return;
255 263
256fatal_memory_error: 264fatal_memory_error:
diff --git a/arch/sparc64/kernel/pci_psycho.c b/arch/sparc64/kernel/pci_psycho.c
index 598393a2df16..b6b4cfea5b5f 100644
--- a/arch/sparc64/kernel/pci_psycho.c
+++ b/arch/sparc64/kernel/pci_psycho.c
@@ -813,16 +813,19 @@ static void psycho_scan_bus(struct pci_pbm_info *pbm)
813 psycho_register_error_handlers(pbm); 813 psycho_register_error_handlers(pbm);
814} 814}
815 815
816static void psycho_iommu_init(struct pci_pbm_info *pbm) 816static int psycho_iommu_init(struct pci_pbm_info *pbm)
817{ 817{
818 struct iommu *iommu = pbm->iommu; 818 struct iommu *iommu = pbm->iommu;
819 unsigned long i; 819 unsigned long i;
820 u64 control; 820 u64 control;
821 int err;
821 822
822 /* Register addresses. */ 823 /* Register addresses. */
823 iommu->iommu_control = pbm->controller_regs + PSYCHO_IOMMU_CONTROL; 824 iommu->iommu_control = pbm->controller_regs + PSYCHO_IOMMU_CONTROL;
824 iommu->iommu_tsbbase = pbm->controller_regs + PSYCHO_IOMMU_TSBBASE; 825 iommu->iommu_tsbbase = pbm->controller_regs + PSYCHO_IOMMU_TSBBASE;
825 iommu->iommu_flush = pbm->controller_regs + PSYCHO_IOMMU_FLUSH; 826 iommu->iommu_flush = pbm->controller_regs + PSYCHO_IOMMU_FLUSH;
827 iommu->iommu_tags = iommu->iommu_flush + (0xa580UL - 0x0210UL);
828
826 /* PSYCHO's IOMMU lacks ctx flushing. */ 829 /* PSYCHO's IOMMU lacks ctx flushing. */
827 iommu->iommu_ctxflush = 0; 830 iommu->iommu_ctxflush = 0;
828 831
@@ -845,7 +848,9 @@ static void psycho_iommu_init(struct pci_pbm_info *pbm)
845 /* Leave diag mode enabled for full-flushing done 848 /* Leave diag mode enabled for full-flushing done
846 * in pci_iommu.c 849 * in pci_iommu.c
847 */ 850 */
848 pci_iommu_table_init(iommu, IO_TSB_SIZE, 0xc0000000, 0xffffffff); 851 err = iommu_table_init(iommu, IO_TSB_SIZE, 0xc0000000, 0xffffffff);
852 if (err)
853 return err;
849 854
850 psycho_write(pbm->controller_regs + PSYCHO_IOMMU_TSBBASE, 855 psycho_write(pbm->controller_regs + PSYCHO_IOMMU_TSBBASE,
851 __pa(iommu->page_table)); 856 __pa(iommu->page_table));
@@ -858,6 +863,8 @@ static void psycho_iommu_init(struct pci_pbm_info *pbm)
858 /* If necessary, hook us up for starfire IRQ translations. */ 863 /* If necessary, hook us up for starfire IRQ translations. */
859 if (this_is_starfire) 864 if (this_is_starfire)
860 starfire_hookup(pbm->portid); 865 starfire_hookup(pbm->portid);
866
867 return 0;
861} 868}
862 869
863#define PSYCHO_IRQ_RETRY 0x1a00UL 870#define PSYCHO_IRQ_RETRY 0x1a00UL
@@ -1031,15 +1038,12 @@ void psycho_init(struct device_node *dp, char *model_name)
1031 } 1038 }
1032 1039
1033 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); 1040 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
1034 if (!p) { 1041 if (!p)
1035 prom_printf("PSYCHO: Fatal memory allocation error.\n"); 1042 goto fatal_memory_error;
1036 prom_halt();
1037 }
1038 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); 1043 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
1039 if (!iommu) { 1044 if (!iommu)
1040 prom_printf("PSYCHO: Fatal memory allocation error.\n"); 1045 goto fatal_memory_error;
1041 prom_halt(); 1046
1042 }
1043 p->pbm_A.iommu = p->pbm_B.iommu = iommu; 1047 p->pbm_A.iommu = p->pbm_B.iommu = iommu;
1044 1048
1045 p->pbm_A.portid = upa_portid; 1049 p->pbm_A.portid = upa_portid;
@@ -1062,8 +1066,14 @@ void psycho_init(struct device_node *dp, char *model_name)
1062 1066
1063 psycho_controller_hwinit(&p->pbm_A); 1067 psycho_controller_hwinit(&p->pbm_A);
1064 1068
1065 psycho_iommu_init(&p->pbm_A); 1069 if (psycho_iommu_init(&p->pbm_A))
1070 goto fatal_memory_error;
1066 1071
1067 is_pbm_a = ((pr_regs[0].phys_addr & 0x6000) == 0x2000); 1072 is_pbm_a = ((pr_regs[0].phys_addr & 0x6000) == 0x2000);
1068 psycho_pbm_init(p, dp, is_pbm_a); 1073 psycho_pbm_init(p, dp, is_pbm_a);
1074 return;
1075
1076fatal_memory_error:
1077 prom_printf("PSYCHO: Fatal memory allocation error.\n");
1078 prom_halt();
1069} 1079}
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
index 22e1be5c7489..fba67c3d8809 100644
--- a/arch/sparc64/kernel/pci_sabre.c
+++ b/arch/sparc64/kernel/pci_sabre.c
@@ -672,18 +672,20 @@ static void sabre_scan_bus(struct pci_pbm_info *pbm)
672 sabre_register_error_handlers(pbm); 672 sabre_register_error_handlers(pbm);
673} 673}
674 674
675static void sabre_iommu_init(struct pci_pbm_info *pbm, 675static int sabre_iommu_init(struct pci_pbm_info *pbm,
676 int tsbsize, unsigned long dvma_offset, 676 int tsbsize, unsigned long dvma_offset,
677 u32 dma_mask) 677 u32 dma_mask)
678{ 678{
679 struct iommu *iommu = pbm->iommu; 679 struct iommu *iommu = pbm->iommu;
680 unsigned long i; 680 unsigned long i;
681 u64 control; 681 u64 control;
682 int err;
682 683
683 /* Register addresses. */ 684 /* Register addresses. */
684 iommu->iommu_control = pbm->controller_regs + SABRE_IOMMU_CONTROL; 685 iommu->iommu_control = pbm->controller_regs + SABRE_IOMMU_CONTROL;
685 iommu->iommu_tsbbase = pbm->controller_regs + SABRE_IOMMU_TSBBASE; 686 iommu->iommu_tsbbase = pbm->controller_regs + SABRE_IOMMU_TSBBASE;
686 iommu->iommu_flush = pbm->controller_regs + SABRE_IOMMU_FLUSH; 687 iommu->iommu_flush = pbm->controller_regs + SABRE_IOMMU_FLUSH;
688 iommu->iommu_tags = iommu->iommu_flush + (0xa580UL - 0x0210UL);
687 iommu->write_complete_reg = pbm->controller_regs + SABRE_WRSYNC; 689 iommu->write_complete_reg = pbm->controller_regs + SABRE_WRSYNC;
688 /* Sabre's IOMMU lacks ctx flushing. */ 690 /* Sabre's IOMMU lacks ctx flushing. */
689 iommu->iommu_ctxflush = 0; 691 iommu->iommu_ctxflush = 0;
@@ -701,7 +703,10 @@ static void sabre_iommu_init(struct pci_pbm_info *pbm,
701 /* Leave diag mode enabled for full-flushing done 703 /* Leave diag mode enabled for full-flushing done
702 * in pci_iommu.c 704 * in pci_iommu.c
703 */ 705 */
704 pci_iommu_table_init(iommu, tsbsize * 1024 * 8, dvma_offset, dma_mask); 706 err = iommu_table_init(iommu, tsbsize * 1024 * 8,
707 dvma_offset, dma_mask);
708 if (err)
709 return err;
705 710
706 sabre_write(pbm->controller_regs + SABRE_IOMMU_TSBBASE, 711 sabre_write(pbm->controller_regs + SABRE_IOMMU_TSBBASE,
707 __pa(iommu->page_table)); 712 __pa(iommu->page_table));
@@ -722,6 +727,8 @@ static void sabre_iommu_init(struct pci_pbm_info *pbm,
722 break; 727 break;
723 } 728 }
724 sabre_write(pbm->controller_regs + SABRE_IOMMU_CONTROL, control); 729 sabre_write(pbm->controller_regs + SABRE_IOMMU_CONTROL, control);
730
731 return 0;
725} 732}
726 733
727static void sabre_pbm_init(struct pci_controller_info *p, struct pci_pbm_info *pbm, struct device_node *dp) 734static void sabre_pbm_init(struct pci_controller_info *p, struct pci_pbm_info *pbm, struct device_node *dp)
@@ -775,16 +782,12 @@ void sabre_init(struct device_node *dp, char *model_name)
775 } 782 }
776 783
777 p = kzalloc(sizeof(*p), GFP_ATOMIC); 784 p = kzalloc(sizeof(*p), GFP_ATOMIC);
778 if (!p) { 785 if (!p)
779 prom_printf("SABRE: Error, kmalloc(pci_controller_info) failed.\n"); 786 goto fatal_memory_error;
780 prom_halt();
781 }
782 787
783 iommu = kzalloc(sizeof(*iommu), GFP_ATOMIC); 788 iommu = kzalloc(sizeof(*iommu), GFP_ATOMIC);
784 if (!iommu) { 789 if (!iommu)
785 prom_printf("SABRE: Error, kmalloc(pci_iommu) failed.\n"); 790 goto fatal_memory_error;
786 prom_halt();
787 }
788 pbm = &p->pbm_A; 791 pbm = &p->pbm_A;
789 pbm->iommu = iommu; 792 pbm->iommu = iommu;
790 793
@@ -847,10 +850,16 @@ void sabre_init(struct device_node *dp, char *model_name)
847 prom_halt(); 850 prom_halt();
848 } 851 }
849 852
850 sabre_iommu_init(pbm, tsbsize, vdma[0], dma_mask); 853 if (sabre_iommu_init(pbm, tsbsize, vdma[0], dma_mask))
854 goto fatal_memory_error;
851 855
852 /* 856 /*
853 * Look for APB underneath. 857 * Look for APB underneath.
854 */ 858 */
855 sabre_pbm_init(p, pbm, dp); 859 sabre_pbm_init(p, pbm, dp);
860 return;
861
862fatal_memory_error:
863 prom_printf("SABRE: Fatal memory allocation error.\n");
864 prom_halt();
856} 865}
diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c
index ae76898bbe2b..3c30bfa1f3a3 100644
--- a/arch/sparc64/kernel/pci_schizo.c
+++ b/arch/sparc64/kernel/pci_schizo.c
@@ -1148,14 +1148,14 @@ static void schizo_pbm_strbuf_init(struct pci_pbm_info *pbm)
1148#define SCHIZO_IOMMU_FLUSH (0x00210UL) 1148#define SCHIZO_IOMMU_FLUSH (0x00210UL)
1149#define SCHIZO_IOMMU_CTXFLUSH (0x00218UL) 1149#define SCHIZO_IOMMU_CTXFLUSH (0x00218UL)
1150 1150
1151static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm) 1151static int schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1152{ 1152{
1153 struct iommu *iommu = pbm->iommu; 1153 struct iommu *iommu = pbm->iommu;
1154 unsigned long i, tagbase, database; 1154 unsigned long i, tagbase, database;
1155 struct property *prop; 1155 struct property *prop;
1156 u32 vdma[2], dma_mask; 1156 u32 vdma[2], dma_mask;
1157 int tsbsize, err;
1157 u64 control; 1158 u64 control;
1158 int tsbsize;
1159 1159
1160 prop = of_find_property(pbm->prom_node, "virtual-dma", NULL); 1160 prop = of_find_property(pbm->prom_node, "virtual-dma", NULL);
1161 if (prop) { 1161 if (prop) {
@@ -1195,6 +1195,7 @@ static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1195 iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL; 1195 iommu->iommu_control = pbm->pbm_regs + SCHIZO_IOMMU_CONTROL;
1196 iommu->iommu_tsbbase = pbm->pbm_regs + SCHIZO_IOMMU_TSBBASE; 1196 iommu->iommu_tsbbase = pbm->pbm_regs + SCHIZO_IOMMU_TSBBASE;
1197 iommu->iommu_flush = pbm->pbm_regs + SCHIZO_IOMMU_FLUSH; 1197 iommu->iommu_flush = pbm->pbm_regs + SCHIZO_IOMMU_FLUSH;
1198 iommu->iommu_tags = iommu->iommu_flush + (0xa580UL - 0x0210UL);
1198 iommu->iommu_ctxflush = pbm->pbm_regs + SCHIZO_IOMMU_CTXFLUSH; 1199 iommu->iommu_ctxflush = pbm->pbm_regs + SCHIZO_IOMMU_CTXFLUSH;
1199 1200
1200 /* We use the main control/status register of SCHIZO as the write 1201 /* We use the main control/status register of SCHIZO as the write
@@ -1219,7 +1220,9 @@ static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1219 /* Leave diag mode enabled for full-flushing done 1220 /* Leave diag mode enabled for full-flushing done
1220 * in pci_iommu.c 1221 * in pci_iommu.c
1221 */ 1222 */
1222 pci_iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask); 1223 err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask);
1224 if (err)
1225 return err;
1223 1226
1224 schizo_write(iommu->iommu_tsbbase, __pa(iommu->page_table)); 1227 schizo_write(iommu->iommu_tsbbase, __pa(iommu->page_table));
1225 1228
@@ -1236,6 +1239,8 @@ static void schizo_pbm_iommu_init(struct pci_pbm_info *pbm)
1236 1239
1237 control |= SCHIZO_IOMMU_CTRL_ENAB; 1240 control |= SCHIZO_IOMMU_CTRL_ENAB;
1238 schizo_write(iommu->iommu_control, control); 1241 schizo_write(iommu->iommu_control, control);
1242
1243 return 0;
1239} 1244}
1240 1245
1241#define SCHIZO_PCI_IRQ_RETRY (0x1a00UL) 1246#define SCHIZO_PCI_IRQ_RETRY (0x1a00UL)
@@ -1328,14 +1333,14 @@ static void schizo_pbm_hw_init(struct pci_pbm_info *pbm)
1328 } 1333 }
1329} 1334}
1330 1335
1331static void schizo_pbm_init(struct pci_controller_info *p, 1336static int schizo_pbm_init(struct pci_controller_info *p,
1332 struct device_node *dp, u32 portid, 1337 struct device_node *dp, u32 portid,
1333 int chip_type) 1338 int chip_type)
1334{ 1339{
1335 const struct linux_prom64_registers *regs; 1340 const struct linux_prom64_registers *regs;
1336 struct pci_pbm_info *pbm; 1341 struct pci_pbm_info *pbm;
1337 const char *chipset_name; 1342 const char *chipset_name;
1338 int is_pbm_a; 1343 int is_pbm_a, err;
1339 1344
1340 switch (chip_type) { 1345 switch (chip_type) {
1341 case PBM_CHIP_TYPE_TOMATILLO: 1346 case PBM_CHIP_TYPE_TOMATILLO:
@@ -1406,8 +1411,13 @@ static void schizo_pbm_init(struct pci_controller_info *p,
1406 1411
1407 pci_get_pbm_props(pbm); 1412 pci_get_pbm_props(pbm);
1408 1413
1409 schizo_pbm_iommu_init(pbm); 1414 err = schizo_pbm_iommu_init(pbm);
1415 if (err)
1416 return err;
1417
1410 schizo_pbm_strbuf_init(pbm); 1418 schizo_pbm_strbuf_init(pbm);
1419
1420 return 0;
1411} 1421}
1412 1422
1413static inline int portid_compare(u32 x, u32 y, int chip_type) 1423static inline int portid_compare(u32 x, u32 y, int chip_type)
@@ -1431,34 +1441,38 @@ static void __schizo_init(struct device_node *dp, char *model_name, int chip_typ
1431 1441
1432 for (pbm = pci_pbm_root; pbm; pbm = pbm->next) { 1442 for (pbm = pci_pbm_root; pbm; pbm = pbm->next) {
1433 if (portid_compare(pbm->portid, portid, chip_type)) { 1443 if (portid_compare(pbm->portid, portid, chip_type)) {
1434 schizo_pbm_init(pbm->parent, dp, portid, chip_type); 1444 if (schizo_pbm_init(pbm->parent, dp,
1445 portid, chip_type))
1446 goto fatal_memory_error;
1435 return; 1447 return;
1436 } 1448 }
1437 } 1449 }
1438 1450
1439 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); 1451 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
1440 if (!p) 1452 if (!p)
1441 goto memfail; 1453 goto fatal_memory_error;
1442 1454
1443 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); 1455 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
1444 if (!iommu) 1456 if (!iommu)
1445 goto memfail; 1457 goto fatal_memory_error;
1446 1458
1447 p->pbm_A.iommu = iommu; 1459 p->pbm_A.iommu = iommu;
1448 1460
1449 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC); 1461 iommu = kzalloc(sizeof(struct iommu), GFP_ATOMIC);
1450 if (!iommu) 1462 if (!iommu)
1451 goto memfail; 1463 goto fatal_memory_error;
1452 1464
1453 p->pbm_B.iommu = iommu; 1465 p->pbm_B.iommu = iommu;
1454 1466
1455 /* Like PSYCHO we have a 2GB aligned area for memory space. */ 1467 /* Like PSYCHO we have a 2GB aligned area for memory space. */
1456 pci_memspace_mask = 0x7fffffffUL; 1468 pci_memspace_mask = 0x7fffffffUL;
1457 1469
1458 schizo_pbm_init(p, dp, portid, chip_type); 1470 if (schizo_pbm_init(p, dp, portid, chip_type))
1471 goto fatal_memory_error;
1472
1459 return; 1473 return;
1460 1474
1461memfail: 1475fatal_memory_error:
1462 prom_printf("SCHIZO: Fatal memory allocation error.\n"); 1476 prom_printf("SCHIZO: Fatal memory allocation error.\n");
1463 prom_halt(); 1477 prom_halt();
1464} 1478}
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 639cf06ca372..466f4aa8fc82 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -33,30 +33,30 @@ static unsigned long vpci_minor = 1;
33#define PGLIST_NENTS (PAGE_SIZE / sizeof(u64)) 33#define PGLIST_NENTS (PAGE_SIZE / sizeof(u64))
34 34
35struct iommu_batch { 35struct iommu_batch {
36 struct pci_dev *pdev; /* Device mapping is for. */ 36 struct device *dev; /* Device mapping is for. */
37 unsigned long prot; /* IOMMU page protections */ 37 unsigned long prot; /* IOMMU page protections */
38 unsigned long entry; /* Index into IOTSB. */ 38 unsigned long entry; /* Index into IOTSB. */
39 u64 *pglist; /* List of physical pages */ 39 u64 *pglist; /* List of physical pages */
40 unsigned long npages; /* Number of pages in list. */ 40 unsigned long npages; /* Number of pages in list. */
41}; 41};
42 42
43static DEFINE_PER_CPU(struct iommu_batch, pci_iommu_batch); 43static DEFINE_PER_CPU(struct iommu_batch, iommu_batch);
44 44
45/* Interrupts must be disabled. */ 45/* Interrupts must be disabled. */
46static inline void pci_iommu_batch_start(struct pci_dev *pdev, unsigned long prot, unsigned long entry) 46static inline void iommu_batch_start(struct device *dev, unsigned long prot, unsigned long entry)
47{ 47{
48 struct iommu_batch *p = &__get_cpu_var(pci_iommu_batch); 48 struct iommu_batch *p = &__get_cpu_var(iommu_batch);
49 49
50 p->pdev = pdev; 50 p->dev = dev;
51 p->prot = prot; 51 p->prot = prot;
52 p->entry = entry; 52 p->entry = entry;
53 p->npages = 0; 53 p->npages = 0;
54} 54}
55 55
56/* Interrupts must be disabled. */ 56/* Interrupts must be disabled. */
57static long pci_iommu_batch_flush(struct iommu_batch *p) 57static long iommu_batch_flush(struct iommu_batch *p)
58{ 58{
59 struct pci_pbm_info *pbm = p->pdev->dev.archdata.host_controller; 59 struct pci_pbm_info *pbm = p->dev->archdata.host_controller;
60 unsigned long devhandle = pbm->devhandle; 60 unsigned long devhandle = pbm->devhandle;
61 unsigned long prot = p->prot; 61 unsigned long prot = p->prot;
62 unsigned long entry = p->entry; 62 unsigned long entry = p->entry;
@@ -70,7 +70,7 @@ static long pci_iommu_batch_flush(struct iommu_batch *p)
70 npages, prot, __pa(pglist)); 70 npages, prot, __pa(pglist));
71 if (unlikely(num < 0)) { 71 if (unlikely(num < 0)) {
72 if (printk_ratelimit()) 72 if (printk_ratelimit())
73 printk("pci_iommu_batch_flush: IOMMU map of " 73 printk("iommu_batch_flush: IOMMU map of "
74 "[%08lx:%08lx:%lx:%lx:%lx] failed with " 74 "[%08lx:%08lx:%lx:%lx:%lx] failed with "
75 "status %ld\n", 75 "status %ld\n",
76 devhandle, HV_PCI_TSBID(0, entry), 76 devhandle, HV_PCI_TSBID(0, entry),
@@ -90,30 +90,30 @@ static long pci_iommu_batch_flush(struct iommu_batch *p)
90} 90}
91 91
92/* Interrupts must be disabled. */ 92/* Interrupts must be disabled. */
93static inline long pci_iommu_batch_add(u64 phys_page) 93static inline long iommu_batch_add(u64 phys_page)
94{ 94{
95 struct iommu_batch *p = &__get_cpu_var(pci_iommu_batch); 95 struct iommu_batch *p = &__get_cpu_var(iommu_batch);
96 96
97 BUG_ON(p->npages >= PGLIST_NENTS); 97 BUG_ON(p->npages >= PGLIST_NENTS);
98 98
99 p->pglist[p->npages++] = phys_page; 99 p->pglist[p->npages++] = phys_page;
100 if (p->npages == PGLIST_NENTS) 100 if (p->npages == PGLIST_NENTS)
101 return pci_iommu_batch_flush(p); 101 return iommu_batch_flush(p);
102 102
103 return 0; 103 return 0;
104} 104}
105 105
106/* Interrupts must be disabled. */ 106/* Interrupts must be disabled. */
107static inline long pci_iommu_batch_end(void) 107static inline long iommu_batch_end(void)
108{ 108{
109 struct iommu_batch *p = &__get_cpu_var(pci_iommu_batch); 109 struct iommu_batch *p = &__get_cpu_var(iommu_batch);
110 110
111 BUG_ON(p->npages >= PGLIST_NENTS); 111 BUG_ON(p->npages >= PGLIST_NENTS);
112 112
113 return pci_iommu_batch_flush(p); 113 return iommu_batch_flush(p);
114} 114}
115 115
116static long pci_arena_alloc(struct iommu_arena *arena, unsigned long npages) 116static long arena_alloc(struct iommu_arena *arena, unsigned long npages)
117{ 117{
118 unsigned long n, i, start, end, limit; 118 unsigned long n, i, start, end, limit;
119 int pass; 119 int pass;
@@ -152,7 +152,8 @@ again:
152 return n; 152 return n;
153} 153}
154 154
155static void pci_arena_free(struct iommu_arena *arena, unsigned long base, unsigned long npages) 155static void arena_free(struct iommu_arena *arena, unsigned long base,
156 unsigned long npages)
156{ 157{
157 unsigned long i; 158 unsigned long i;
158 159
@@ -160,7 +161,8 @@ static void pci_arena_free(struct iommu_arena *arena, unsigned long base, unsign
160 __clear_bit(i, arena->map); 161 __clear_bit(i, arena->map);
161} 162}
162 163
163static void *pci_4v_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp, gfp_t gfp) 164static void *dma_4v_alloc_coherent(struct device *dev, size_t size,
165 dma_addr_t *dma_addrp, gfp_t gfp)
164{ 166{
165 struct iommu *iommu; 167 struct iommu *iommu;
166 unsigned long flags, order, first_page, npages, n; 168 unsigned long flags, order, first_page, npages, n;
@@ -180,10 +182,10 @@ static void *pci_4v_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr
180 182
181 memset((char *)first_page, 0, PAGE_SIZE << order); 183 memset((char *)first_page, 0, PAGE_SIZE << order);
182 184
183 iommu = pdev->dev.archdata.iommu; 185 iommu = dev->archdata.iommu;
184 186
185 spin_lock_irqsave(&iommu->lock, flags); 187 spin_lock_irqsave(&iommu->lock, flags);
186 entry = pci_arena_alloc(&iommu->arena, npages); 188 entry = arena_alloc(&iommu->arena, npages);
187 spin_unlock_irqrestore(&iommu->lock, flags); 189 spin_unlock_irqrestore(&iommu->lock, flags);
188 190
189 if (unlikely(entry < 0L)) 191 if (unlikely(entry < 0L))
@@ -196,18 +198,18 @@ static void *pci_4v_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr
196 198
197 local_irq_save(flags); 199 local_irq_save(flags);
198 200
199 pci_iommu_batch_start(pdev, 201 iommu_batch_start(dev,
200 (HV_PCI_MAP_ATTR_READ | 202 (HV_PCI_MAP_ATTR_READ |
201 HV_PCI_MAP_ATTR_WRITE), 203 HV_PCI_MAP_ATTR_WRITE),
202 entry); 204 entry);
203 205
204 for (n = 0; n < npages; n++) { 206 for (n = 0; n < npages; n++) {
205 long err = pci_iommu_batch_add(first_page + (n * PAGE_SIZE)); 207 long err = iommu_batch_add(first_page + (n * PAGE_SIZE));
206 if (unlikely(err < 0L)) 208 if (unlikely(err < 0L))
207 goto iommu_map_fail; 209 goto iommu_map_fail;
208 } 210 }
209 211
210 if (unlikely(pci_iommu_batch_end() < 0L)) 212 if (unlikely(iommu_batch_end() < 0L))
211 goto iommu_map_fail; 213 goto iommu_map_fail;
212 214
213 local_irq_restore(flags); 215 local_irq_restore(flags);
@@ -217,7 +219,7 @@ static void *pci_4v_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr
217iommu_map_fail: 219iommu_map_fail:
218 /* Interrupts are disabled. */ 220 /* Interrupts are disabled. */
219 spin_lock(&iommu->lock); 221 spin_lock(&iommu->lock);
220 pci_arena_free(&iommu->arena, entry, npages); 222 arena_free(&iommu->arena, entry, npages);
221 spin_unlock_irqrestore(&iommu->lock, flags); 223 spin_unlock_irqrestore(&iommu->lock, flags);
222 224
223arena_alloc_fail: 225arena_alloc_fail:
@@ -225,7 +227,8 @@ arena_alloc_fail:
225 return NULL; 227 return NULL;
226} 228}
227 229
228static void pci_4v_free_consistent(struct pci_dev *pdev, size_t size, void *cpu, dma_addr_t dvma) 230static void dma_4v_free_coherent(struct device *dev, size_t size, void *cpu,
231 dma_addr_t dvma)
229{ 232{
230 struct pci_pbm_info *pbm; 233 struct pci_pbm_info *pbm;
231 struct iommu *iommu; 234 struct iommu *iommu;
@@ -233,14 +236,14 @@ static void pci_4v_free_consistent(struct pci_dev *pdev, size_t size, void *cpu,
233 u32 devhandle; 236 u32 devhandle;
234 237
235 npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT; 238 npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT;
236 iommu = pdev->dev.archdata.iommu; 239 iommu = dev->archdata.iommu;
237 pbm = pdev->dev.archdata.host_controller; 240 pbm = dev->archdata.host_controller;
238 devhandle = pbm->devhandle; 241 devhandle = pbm->devhandle;
239 entry = ((dvma - iommu->page_table_map_base) >> IO_PAGE_SHIFT); 242 entry = ((dvma - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
240 243
241 spin_lock_irqsave(&iommu->lock, flags); 244 spin_lock_irqsave(&iommu->lock, flags);
242 245
243 pci_arena_free(&iommu->arena, entry, npages); 246 arena_free(&iommu->arena, entry, npages);
244 247
245 do { 248 do {
246 unsigned long num; 249 unsigned long num;
@@ -258,7 +261,8 @@ static void pci_4v_free_consistent(struct pci_dev *pdev, size_t size, void *cpu,
258 free_pages((unsigned long)cpu, order); 261 free_pages((unsigned long)cpu, order);
259} 262}
260 263
261static dma_addr_t pci_4v_map_single(struct pci_dev *pdev, void *ptr, size_t sz, int direction) 264static dma_addr_t dma_4v_map_single(struct device *dev, void *ptr, size_t sz,
265 enum dma_data_direction direction)
262{ 266{
263 struct iommu *iommu; 267 struct iommu *iommu;
264 unsigned long flags, npages, oaddr; 268 unsigned long flags, npages, oaddr;
@@ -267,9 +271,9 @@ static dma_addr_t pci_4v_map_single(struct pci_dev *pdev, void *ptr, size_t sz,
267 unsigned long prot; 271 unsigned long prot;
268 long entry; 272 long entry;
269 273
270 iommu = pdev->dev.archdata.iommu; 274 iommu = dev->archdata.iommu;
271 275
272 if (unlikely(direction == PCI_DMA_NONE)) 276 if (unlikely(direction == DMA_NONE))
273 goto bad; 277 goto bad;
274 278
275 oaddr = (unsigned long)ptr; 279 oaddr = (unsigned long)ptr;
@@ -277,7 +281,7 @@ static dma_addr_t pci_4v_map_single(struct pci_dev *pdev, void *ptr, size_t sz,
277 npages >>= IO_PAGE_SHIFT; 281 npages >>= IO_PAGE_SHIFT;
278 282
279 spin_lock_irqsave(&iommu->lock, flags); 283 spin_lock_irqsave(&iommu->lock, flags);
280 entry = pci_arena_alloc(&iommu->arena, npages); 284 entry = arena_alloc(&iommu->arena, npages);
281 spin_unlock_irqrestore(&iommu->lock, flags); 285 spin_unlock_irqrestore(&iommu->lock, flags);
282 286
283 if (unlikely(entry < 0L)) 287 if (unlikely(entry < 0L))
@@ -288,19 +292,19 @@ static dma_addr_t pci_4v_map_single(struct pci_dev *pdev, void *ptr, size_t sz,
288 ret = bus_addr | (oaddr & ~IO_PAGE_MASK); 292 ret = bus_addr | (oaddr & ~IO_PAGE_MASK);
289 base_paddr = __pa(oaddr & IO_PAGE_MASK); 293 base_paddr = __pa(oaddr & IO_PAGE_MASK);
290 prot = HV_PCI_MAP_ATTR_READ; 294 prot = HV_PCI_MAP_ATTR_READ;
291 if (direction != PCI_DMA_TODEVICE) 295 if (direction != DMA_TO_DEVICE)
292 prot |= HV_PCI_MAP_ATTR_WRITE; 296 prot |= HV_PCI_MAP_ATTR_WRITE;
293 297
294 local_irq_save(flags); 298 local_irq_save(flags);
295 299
296 pci_iommu_batch_start(pdev, prot, entry); 300 iommu_batch_start(dev, prot, entry);
297 301
298 for (i = 0; i < npages; i++, base_paddr += IO_PAGE_SIZE) { 302 for (i = 0; i < npages; i++, base_paddr += IO_PAGE_SIZE) {
299 long err = pci_iommu_batch_add(base_paddr); 303 long err = iommu_batch_add(base_paddr);
300 if (unlikely(err < 0L)) 304 if (unlikely(err < 0L))
301 goto iommu_map_fail; 305 goto iommu_map_fail;
302 } 306 }
303 if (unlikely(pci_iommu_batch_end() < 0L)) 307 if (unlikely(iommu_batch_end() < 0L))
304 goto iommu_map_fail; 308 goto iommu_map_fail;
305 309
306 local_irq_restore(flags); 310 local_irq_restore(flags);
@@ -310,18 +314,19 @@ static dma_addr_t pci_4v_map_single(struct pci_dev *pdev, void *ptr, size_t sz,
310bad: 314bad:
311 if (printk_ratelimit()) 315 if (printk_ratelimit())
312 WARN_ON(1); 316 WARN_ON(1);
313 return PCI_DMA_ERROR_CODE; 317 return DMA_ERROR_CODE;
314 318
315iommu_map_fail: 319iommu_map_fail:
316 /* Interrupts are disabled. */ 320 /* Interrupts are disabled. */
317 spin_lock(&iommu->lock); 321 spin_lock(&iommu->lock);
318 pci_arena_free(&iommu->arena, entry, npages); 322 arena_free(&iommu->arena, entry, npages);
319 spin_unlock_irqrestore(&iommu->lock, flags); 323 spin_unlock_irqrestore(&iommu->lock, flags);
320 324
321 return PCI_DMA_ERROR_CODE; 325 return DMA_ERROR_CODE;
322} 326}
323 327
324static void pci_4v_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction) 328static void dma_4v_unmap_single(struct device *dev, dma_addr_t bus_addr,
329 size_t sz, enum dma_data_direction direction)
325{ 330{
326 struct pci_pbm_info *pbm; 331 struct pci_pbm_info *pbm;
327 struct iommu *iommu; 332 struct iommu *iommu;
@@ -329,14 +334,14 @@ static void pci_4v_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_
329 long entry; 334 long entry;
330 u32 devhandle; 335 u32 devhandle;
331 336
332 if (unlikely(direction == PCI_DMA_NONE)) { 337 if (unlikely(direction == DMA_NONE)) {
333 if (printk_ratelimit()) 338 if (printk_ratelimit())
334 WARN_ON(1); 339 WARN_ON(1);
335 return; 340 return;
336 } 341 }
337 342
338 iommu = pdev->dev.archdata.iommu; 343 iommu = dev->archdata.iommu;
339 pbm = pdev->dev.archdata.host_controller; 344 pbm = dev->archdata.host_controller;
340 devhandle = pbm->devhandle; 345 devhandle = pbm->devhandle;
341 346
342 npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK); 347 npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK);
@@ -346,7 +351,7 @@ static void pci_4v_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_
346 spin_lock_irqsave(&iommu->lock, flags); 351 spin_lock_irqsave(&iommu->lock, flags);
347 352
348 entry = (bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT; 353 entry = (bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT;
349 pci_arena_free(&iommu->arena, entry, npages); 354 arena_free(&iommu->arena, entry, npages);
350 355
351 do { 356 do {
352 unsigned long num; 357 unsigned long num;
@@ -363,7 +368,7 @@ static void pci_4v_unmap_single(struct pci_dev *pdev, dma_addr_t bus_addr, size_
363#define SG_ENT_PHYS_ADDRESS(SG) \ 368#define SG_ENT_PHYS_ADDRESS(SG) \
364 (__pa(page_address((SG)->page)) + (SG)->offset) 369 (__pa(page_address((SG)->page)) + (SG)->offset)
365 370
366static inline long fill_sg(long entry, struct pci_dev *pdev, 371static inline long fill_sg(long entry, struct device *dev,
367 struct scatterlist *sg, 372 struct scatterlist *sg,
368 int nused, int nelems, unsigned long prot) 373 int nused, int nelems, unsigned long prot)
369{ 374{
@@ -374,7 +379,7 @@ static inline long fill_sg(long entry, struct pci_dev *pdev,
374 379
375 local_irq_save(flags); 380 local_irq_save(flags);
376 381
377 pci_iommu_batch_start(pdev, prot, entry); 382 iommu_batch_start(dev, prot, entry);
378 383
379 for (i = 0; i < nused; i++) { 384 for (i = 0; i < nused; i++) {
380 unsigned long pteval = ~0UL; 385 unsigned long pteval = ~0UL;
@@ -415,7 +420,7 @@ static inline long fill_sg(long entry, struct pci_dev *pdev,
415 while (len > 0) { 420 while (len > 0) {
416 long err; 421 long err;
417 422
418 err = pci_iommu_batch_add(pteval); 423 err = iommu_batch_add(pteval);
419 if (unlikely(err < 0L)) 424 if (unlikely(err < 0L))
420 goto iommu_map_failed; 425 goto iommu_map_failed;
421 426
@@ -446,7 +451,7 @@ static inline long fill_sg(long entry, struct pci_dev *pdev,
446 dma_sg++; 451 dma_sg++;
447 } 452 }
448 453
449 if (unlikely(pci_iommu_batch_end() < 0L)) 454 if (unlikely(iommu_batch_end() < 0L))
450 goto iommu_map_failed; 455 goto iommu_map_failed;
451 456
452 local_irq_restore(flags); 457 local_irq_restore(flags);
@@ -457,7 +462,8 @@ iommu_map_failed:
457 return -1L; 462 return -1L;
458} 463}
459 464
460static int pci_4v_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) 465static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
466 int nelems, enum dma_data_direction direction)
461{ 467{
462 struct iommu *iommu; 468 struct iommu *iommu;
463 unsigned long flags, npages, prot; 469 unsigned long flags, npages, prot;
@@ -469,18 +475,19 @@ static int pci_4v_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int n
469 /* Fast path single entry scatterlists. */ 475 /* Fast path single entry scatterlists. */
470 if (nelems == 1) { 476 if (nelems == 1) {
471 sglist->dma_address = 477 sglist->dma_address =
472 pci_4v_map_single(pdev, 478 dma_4v_map_single(dev,
473 (page_address(sglist->page) + sglist->offset), 479 (page_address(sglist->page) +
480 sglist->offset),
474 sglist->length, direction); 481 sglist->length, direction);
475 if (unlikely(sglist->dma_address == PCI_DMA_ERROR_CODE)) 482 if (unlikely(sglist->dma_address == DMA_ERROR_CODE))
476 return 0; 483 return 0;
477 sglist->dma_length = sglist->length; 484 sglist->dma_length = sglist->length;
478 return 1; 485 return 1;
479 } 486 }
480 487
481 iommu = pdev->dev.archdata.iommu; 488 iommu = dev->archdata.iommu;
482 489
483 if (unlikely(direction == PCI_DMA_NONE)) 490 if (unlikely(direction == DMA_NONE))
484 goto bad; 491 goto bad;
485 492
486 /* Step 1: Prepare scatter list. */ 493 /* Step 1: Prepare scatter list. */
@@ -488,7 +495,7 @@ static int pci_4v_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int n
488 495
489 /* Step 2: Allocate a cluster and context, if necessary. */ 496 /* Step 2: Allocate a cluster and context, if necessary. */
490 spin_lock_irqsave(&iommu->lock, flags); 497 spin_lock_irqsave(&iommu->lock, flags);
491 entry = pci_arena_alloc(&iommu->arena, npages); 498 entry = arena_alloc(&iommu->arena, npages);
492 spin_unlock_irqrestore(&iommu->lock, flags); 499 spin_unlock_irqrestore(&iommu->lock, flags);
493 500
494 if (unlikely(entry < 0L)) 501 if (unlikely(entry < 0L))
@@ -510,10 +517,10 @@ static int pci_4v_map_sg(struct pci_dev *pdev, struct scatterlist *sglist, int n
510 517
511 /* Step 4: Create the mappings. */ 518 /* Step 4: Create the mappings. */
512 prot = HV_PCI_MAP_ATTR_READ; 519 prot = HV_PCI_MAP_ATTR_READ;
513 if (direction != PCI_DMA_TODEVICE) 520 if (direction != DMA_TO_DEVICE)
514 prot |= HV_PCI_MAP_ATTR_WRITE; 521 prot |= HV_PCI_MAP_ATTR_WRITE;
515 522
516 err = fill_sg(entry, pdev, sglist, used, nelems, prot); 523 err = fill_sg(entry, dev, sglist, used, nelems, prot);
517 if (unlikely(err < 0L)) 524 if (unlikely(err < 0L))
518 goto iommu_map_failed; 525 goto iommu_map_failed;
519 526
@@ -526,13 +533,14 @@ bad:
526 533
527iommu_map_failed: 534iommu_map_failed:
528 spin_lock_irqsave(&iommu->lock, flags); 535 spin_lock_irqsave(&iommu->lock, flags);
529 pci_arena_free(&iommu->arena, entry, npages); 536 arena_free(&iommu->arena, entry, npages);
530 spin_unlock_irqrestore(&iommu->lock, flags); 537 spin_unlock_irqrestore(&iommu->lock, flags);
531 538
532 return 0; 539 return 0;
533} 540}
534 541
535static void pci_4v_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) 542static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist,
543 int nelems, enum dma_data_direction direction)
536{ 544{
537 struct pci_pbm_info *pbm; 545 struct pci_pbm_info *pbm;
538 struct iommu *iommu; 546 struct iommu *iommu;
@@ -540,13 +548,13 @@ static void pci_4v_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, in
540 long entry; 548 long entry;
541 u32 devhandle, bus_addr; 549 u32 devhandle, bus_addr;
542 550
543 if (unlikely(direction == PCI_DMA_NONE)) { 551 if (unlikely(direction == DMA_NONE)) {
544 if (printk_ratelimit()) 552 if (printk_ratelimit())
545 WARN_ON(1); 553 WARN_ON(1);
546 } 554 }
547 555
548 iommu = pdev->dev.archdata.iommu; 556 iommu = dev->archdata.iommu;
549 pbm = pdev->dev.archdata.host_controller; 557 pbm = dev->archdata.host_controller;
550 devhandle = pbm->devhandle; 558 devhandle = pbm->devhandle;
551 559
552 bus_addr = sglist->dma_address & IO_PAGE_MASK; 560 bus_addr = sglist->dma_address & IO_PAGE_MASK;
@@ -562,7 +570,7 @@ static void pci_4v_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, in
562 570
563 spin_lock_irqsave(&iommu->lock, flags); 571 spin_lock_irqsave(&iommu->lock, flags);
564 572
565 pci_arena_free(&iommu->arena, entry, npages); 573 arena_free(&iommu->arena, entry, npages);
566 574
567 do { 575 do {
568 unsigned long num; 576 unsigned long num;
@@ -576,25 +584,29 @@ static void pci_4v_unmap_sg(struct pci_dev *pdev, struct scatterlist *sglist, in
576 spin_unlock_irqrestore(&iommu->lock, flags); 584 spin_unlock_irqrestore(&iommu->lock, flags);
577} 585}
578 586
579static void pci_4v_dma_sync_single_for_cpu(struct pci_dev *pdev, dma_addr_t bus_addr, size_t sz, int direction) 587static void dma_4v_sync_single_for_cpu(struct device *dev,
588 dma_addr_t bus_addr, size_t sz,
589 enum dma_data_direction direction)
580{ 590{
581 /* Nothing to do... */ 591 /* Nothing to do... */
582} 592}
583 593
584static void pci_4v_dma_sync_sg_for_cpu(struct pci_dev *pdev, struct scatterlist *sglist, int nelems, int direction) 594static void dma_4v_sync_sg_for_cpu(struct device *dev,
595 struct scatterlist *sglist, int nelems,
596 enum dma_data_direction direction)
585{ 597{
586 /* Nothing to do... */ 598 /* Nothing to do... */
587} 599}
588 600
589const struct pci_iommu_ops pci_sun4v_iommu_ops = { 601const struct dma_ops sun4v_dma_ops = {
590 .alloc_consistent = pci_4v_alloc_consistent, 602 .alloc_coherent = dma_4v_alloc_coherent,
591 .free_consistent = pci_4v_free_consistent, 603 .free_coherent = dma_4v_free_coherent,
592 .map_single = pci_4v_map_single, 604 .map_single = dma_4v_map_single,
593 .unmap_single = pci_4v_unmap_single, 605 .unmap_single = dma_4v_unmap_single,
594 .map_sg = pci_4v_map_sg, 606 .map_sg = dma_4v_map_sg,
595 .unmap_sg = pci_4v_unmap_sg, 607 .unmap_sg = dma_4v_unmap_sg,
596 .dma_sync_single_for_cpu = pci_4v_dma_sync_single_for_cpu, 608 .sync_single_for_cpu = dma_4v_sync_single_for_cpu,
597 .dma_sync_sg_for_cpu = pci_4v_dma_sync_sg_for_cpu, 609 .sync_sg_for_cpu = dma_4v_sync_sg_for_cpu,
598}; 610};
599 611
600static void pci_sun4v_scan_bus(struct pci_pbm_info *pbm) 612static void pci_sun4v_scan_bus(struct pci_pbm_info *pbm)
@@ -1186,6 +1198,8 @@ void __init sun4v_pci_init(struct device_node *dp, char *model_name)
1186 } 1198 }
1187 printk("SUN4V_PCI: Registered hvapi major[%lu] minor[%lu]\n", 1199 printk("SUN4V_PCI: Registered hvapi major[%lu] minor[%lu]\n",
1188 vpci_major, vpci_minor); 1200 vpci_major, vpci_minor);
1201
1202 dma_ops = &sun4v_dma_ops;
1189 } 1203 }
1190 1204
1191 prop = of_find_property(dp, "reg", NULL); 1205 prop = of_find_property(dp, "reg", NULL);
@@ -1206,7 +1220,7 @@ void __init sun4v_pci_init(struct device_node *dp, char *model_name)
1206 if (!page) 1220 if (!page)
1207 goto fatal_memory_error; 1221 goto fatal_memory_error;
1208 1222
1209 per_cpu(pci_iommu_batch, i).pglist = (u64 *) page; 1223 per_cpu(iommu_batch, i).pglist = (u64 *) page;
1210 } 1224 }
1211 1225
1212 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); 1226 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
index fd7899ba1d70..ca7cdfd55f72 100644
--- a/arch/sparc64/kernel/process.c
+++ b/arch/sparc64/kernel/process.c
@@ -18,6 +18,7 @@
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/kallsyms.h> 19#include <linux/kallsyms.h>
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/fs.h>
21#include <linux/smp.h> 22#include <linux/smp.h>
22#include <linux/stddef.h> 23#include <linux/stddef.h>
23#include <linux/ptrace.h> 24#include <linux/ptrace.h>
diff --git a/arch/sparc64/kernel/sbus.c b/arch/sparc64/kernel/sbus.c
index a1fd9bcc0b87..d1fb13ba02b5 100644
--- a/arch/sparc64/kernel/sbus.c
+++ b/arch/sparc64/kernel/sbus.c
@@ -26,11 +26,6 @@
26 26
27#define MAP_BASE ((u32)0xc0000000) 27#define MAP_BASE ((u32)0xc0000000)
28 28
29struct sbus_info {
30 struct iommu iommu;
31 struct strbuf strbuf;
32};
33
34/* Offsets from iommu_regs */ 29/* Offsets from iommu_regs */
35#define SYSIO_IOMMUREG_BASE 0x2400UL 30#define SYSIO_IOMMUREG_BASE 0x2400UL
36#define IOMMU_CONTROL (0x2400UL - 0x2400UL) /* IOMMU control register */ 31#define IOMMU_CONTROL (0x2400UL - 0x2400UL) /* IOMMU control register */
@@ -44,19 +39,6 @@ struct sbus_info {
44 39
45#define IOMMU_DRAM_VALID (1UL << 30UL) 40#define IOMMU_DRAM_VALID (1UL << 30UL)
46 41
47static void __iommu_flushall(struct iommu *iommu)
48{
49 unsigned long tag;
50 int entry;
51
52 tag = iommu->iommu_control + (IOMMU_TAGDIAG - IOMMU_CONTROL);
53 for (entry = 0; entry < 16; entry++) {
54 upa_writeq(0, tag);
55 tag += 8UL;
56 }
57 upa_readq(iommu->write_complete_reg);
58}
59
60/* Offsets from strbuf_regs */ 42/* Offsets from strbuf_regs */
61#define SYSIO_STRBUFREG_BASE 0x2800UL 43#define SYSIO_STRBUFREG_BASE 0x2800UL
62#define STRBUF_CONTROL (0x2800UL - 0x2800UL) /* Control */ 44#define STRBUF_CONTROL (0x2800UL - 0x2800UL) /* Control */
@@ -69,511 +51,10 @@ static void __iommu_flushall(struct iommu *iommu)
69 51
70#define STRBUF_TAG_VALID 0x02UL 52#define STRBUF_TAG_VALID 0x02UL
71 53
72static void sbus_strbuf_flush(struct iommu *iommu, struct strbuf *strbuf, u32 base, unsigned long npages, int direction)
73{
74 unsigned long n;
75 int limit;
76
77 n = npages;
78 while (n--)
79 upa_writeq(base + (n << IO_PAGE_SHIFT), strbuf->strbuf_pflush);
80
81 /* If the device could not have possibly put dirty data into
82 * the streaming cache, no flush-flag synchronization needs
83 * to be performed.
84 */
85 if (direction == SBUS_DMA_TODEVICE)
86 return;
87
88 *(strbuf->strbuf_flushflag) = 0UL;
89
90 /* Whoopee cushion! */
91 upa_writeq(strbuf->strbuf_flushflag_pa, strbuf->strbuf_fsync);
92 upa_readq(iommu->write_complete_reg);
93
94 limit = 100000;
95 while (*(strbuf->strbuf_flushflag) == 0UL) {
96 limit--;
97 if (!limit)
98 break;
99 udelay(1);
100 rmb();
101 }
102 if (!limit)
103 printk(KERN_WARNING "sbus_strbuf_flush: flushflag timeout "
104 "vaddr[%08x] npages[%ld]\n",
105 base, npages);
106}
107
108/* Based largely upon the ppc64 iommu allocator. */
109static long sbus_arena_alloc(struct iommu *iommu, unsigned long npages)
110{
111 struct iommu_arena *arena = &iommu->arena;
112 unsigned long n, i, start, end, limit;
113 int pass;
114
115 limit = arena->limit;
116 start = arena->hint;
117 pass = 0;
118
119again:
120 n = find_next_zero_bit(arena->map, limit, start);
121 end = n + npages;
122 if (unlikely(end >= limit)) {
123 if (likely(pass < 1)) {
124 limit = start;
125 start = 0;
126 __iommu_flushall(iommu);
127 pass++;
128 goto again;
129 } else {
130 /* Scanned the whole thing, give up. */
131 return -1;
132 }
133 }
134
135 for (i = n; i < end; i++) {
136 if (test_bit(i, arena->map)) {
137 start = i + 1;
138 goto again;
139 }
140 }
141
142 for (i = n; i < end; i++)
143 __set_bit(i, arena->map);
144
145 arena->hint = end;
146
147 return n;
148}
149
150static void sbus_arena_free(struct iommu_arena *arena, unsigned long base, unsigned long npages)
151{
152 unsigned long i;
153
154 for (i = base; i < (base + npages); i++)
155 __clear_bit(i, arena->map);
156}
157
158static void sbus_iommu_table_init(struct iommu *iommu, unsigned int tsbsize)
159{
160 unsigned long tsbbase, order, sz, num_tsb_entries;
161
162 num_tsb_entries = tsbsize / sizeof(iopte_t);
163
164 /* Setup initial software IOMMU state. */
165 spin_lock_init(&iommu->lock);
166 iommu->page_table_map_base = MAP_BASE;
167
168 /* Allocate and initialize the free area map. */
169 sz = num_tsb_entries / 8;
170 sz = (sz + 7UL) & ~7UL;
171 iommu->arena.map = kzalloc(sz, GFP_KERNEL);
172 if (!iommu->arena.map) {
173 prom_printf("SBUS_IOMMU: Error, kmalloc(arena.map) failed.\n");
174 prom_halt();
175 }
176 iommu->arena.limit = num_tsb_entries;
177
178 /* Now allocate and setup the IOMMU page table itself. */
179 order = get_order(tsbsize);
180 tsbbase = __get_free_pages(GFP_KERNEL, order);
181 if (!tsbbase) {
182 prom_printf("IOMMU: Error, gfp(tsb) failed.\n");
183 prom_halt();
184 }
185 iommu->page_table = (iopte_t *)tsbbase;
186 memset(iommu->page_table, 0, tsbsize);
187}
188
189static inline iopte_t *alloc_npages(struct iommu *iommu, unsigned long npages)
190{
191 long entry;
192
193 entry = sbus_arena_alloc(iommu, npages);
194 if (unlikely(entry < 0))
195 return NULL;
196
197 return iommu->page_table + entry;
198}
199
200static inline void free_npages(struct iommu *iommu, dma_addr_t base, unsigned long npages)
201{
202 sbus_arena_free(&iommu->arena, base >> IO_PAGE_SHIFT, npages);
203}
204
205void *sbus_alloc_consistent(struct sbus_dev *sdev, size_t size, dma_addr_t *dvma_addr)
206{
207 struct sbus_info *info;
208 struct iommu *iommu;
209 iopte_t *iopte;
210 unsigned long flags, order, first_page;
211 void *ret;
212 int npages;
213
214 size = IO_PAGE_ALIGN(size);
215 order = get_order(size);
216 if (order >= 10)
217 return NULL;
218
219 first_page = __get_free_pages(GFP_KERNEL|__GFP_COMP, order);
220 if (first_page == 0UL)
221 return NULL;
222 memset((char *)first_page, 0, PAGE_SIZE << order);
223
224 info = sdev->bus->iommu;
225 iommu = &info->iommu;
226
227 spin_lock_irqsave(&iommu->lock, flags);
228 iopte = alloc_npages(iommu, size >> IO_PAGE_SHIFT);
229 spin_unlock_irqrestore(&iommu->lock, flags);
230
231 if (unlikely(iopte == NULL)) {
232 free_pages(first_page, order);
233 return NULL;
234 }
235
236 *dvma_addr = (iommu->page_table_map_base +
237 ((iopte - iommu->page_table) << IO_PAGE_SHIFT));
238 ret = (void *) first_page;
239 npages = size >> IO_PAGE_SHIFT;
240 first_page = __pa(first_page);
241 while (npages--) {
242 iopte_val(*iopte) = (IOPTE_VALID | IOPTE_CACHE |
243 IOPTE_WRITE |
244 (first_page & IOPTE_PAGE));
245 iopte++;
246 first_page += IO_PAGE_SIZE;
247 }
248
249 return ret;
250}
251
252void sbus_free_consistent(struct sbus_dev *sdev, size_t size, void *cpu, dma_addr_t dvma)
253{
254 struct sbus_info *info;
255 struct iommu *iommu;
256 iopte_t *iopte;
257 unsigned long flags, order, npages;
258
259 npages = IO_PAGE_ALIGN(size) >> IO_PAGE_SHIFT;
260 info = sdev->bus->iommu;
261 iommu = &info->iommu;
262 iopte = iommu->page_table +
263 ((dvma - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
264
265 spin_lock_irqsave(&iommu->lock, flags);
266
267 free_npages(iommu, dvma - iommu->page_table_map_base, npages);
268
269 spin_unlock_irqrestore(&iommu->lock, flags);
270
271 order = get_order(size);
272 if (order < 10)
273 free_pages((unsigned long)cpu, order);
274}
275
276dma_addr_t sbus_map_single(struct sbus_dev *sdev, void *ptr, size_t sz, int direction)
277{
278 struct sbus_info *info;
279 struct iommu *iommu;
280 iopte_t *base;
281 unsigned long flags, npages, oaddr;
282 unsigned long i, base_paddr;
283 u32 bus_addr, ret;
284 unsigned long iopte_protection;
285
286 info = sdev->bus->iommu;
287 iommu = &info->iommu;
288
289 if (unlikely(direction == SBUS_DMA_NONE))
290 BUG();
291
292 oaddr = (unsigned long)ptr;
293 npages = IO_PAGE_ALIGN(oaddr + sz) - (oaddr & IO_PAGE_MASK);
294 npages >>= IO_PAGE_SHIFT;
295
296 spin_lock_irqsave(&iommu->lock, flags);
297 base = alloc_npages(iommu, npages);
298 spin_unlock_irqrestore(&iommu->lock, flags);
299
300 if (unlikely(!base))
301 BUG();
302
303 bus_addr = (iommu->page_table_map_base +
304 ((base - iommu->page_table) << IO_PAGE_SHIFT));
305 ret = bus_addr | (oaddr & ~IO_PAGE_MASK);
306 base_paddr = __pa(oaddr & IO_PAGE_MASK);
307
308 iopte_protection = IOPTE_VALID | IOPTE_STBUF | IOPTE_CACHE;
309 if (direction != SBUS_DMA_TODEVICE)
310 iopte_protection |= IOPTE_WRITE;
311
312 for (i = 0; i < npages; i++, base++, base_paddr += IO_PAGE_SIZE)
313 iopte_val(*base) = iopte_protection | base_paddr;
314
315 return ret;
316}
317
318void sbus_unmap_single(struct sbus_dev *sdev, dma_addr_t bus_addr, size_t sz, int direction)
319{
320 struct sbus_info *info = sdev->bus->iommu;
321 struct iommu *iommu = &info->iommu;
322 struct strbuf *strbuf = &info->strbuf;
323 iopte_t *base;
324 unsigned long flags, npages, i;
325
326 if (unlikely(direction == SBUS_DMA_NONE))
327 BUG();
328
329 npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK);
330 npages >>= IO_PAGE_SHIFT;
331 base = iommu->page_table +
332 ((bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
333
334 bus_addr &= IO_PAGE_MASK;
335
336 spin_lock_irqsave(&iommu->lock, flags);
337 sbus_strbuf_flush(iommu, strbuf, bus_addr, npages, direction);
338 for (i = 0; i < npages; i++)
339 iopte_val(base[i]) = 0UL;
340 free_npages(iommu, bus_addr - iommu->page_table_map_base, npages);
341 spin_unlock_irqrestore(&iommu->lock, flags);
342}
343
344#define SG_ENT_PHYS_ADDRESS(SG) \
345 (__pa(page_address((SG)->page)) + (SG)->offset)
346
347static inline void fill_sg(iopte_t *iopte, struct scatterlist *sg,
348 int nused, int nelems, unsigned long iopte_protection)
349{
350 struct scatterlist *dma_sg = sg;
351 struct scatterlist *sg_end = sg + nelems;
352 int i;
353
354 for (i = 0; i < nused; i++) {
355 unsigned long pteval = ~0UL;
356 u32 dma_npages;
357
358 dma_npages = ((dma_sg->dma_address & (IO_PAGE_SIZE - 1UL)) +
359 dma_sg->dma_length +
360 ((IO_PAGE_SIZE - 1UL))) >> IO_PAGE_SHIFT;
361 do {
362 unsigned long offset;
363 signed int len;
364
365 /* If we are here, we know we have at least one
366 * more page to map. So walk forward until we
367 * hit a page crossing, and begin creating new
368 * mappings from that spot.
369 */
370 for (;;) {
371 unsigned long tmp;
372
373 tmp = SG_ENT_PHYS_ADDRESS(sg);
374 len = sg->length;
375 if (((tmp ^ pteval) >> IO_PAGE_SHIFT) != 0UL) {
376 pteval = tmp & IO_PAGE_MASK;
377 offset = tmp & (IO_PAGE_SIZE - 1UL);
378 break;
379 }
380 if (((tmp ^ (tmp + len - 1UL)) >> IO_PAGE_SHIFT) != 0UL) {
381 pteval = (tmp + IO_PAGE_SIZE) & IO_PAGE_MASK;
382 offset = 0UL;
383 len -= (IO_PAGE_SIZE - (tmp & (IO_PAGE_SIZE - 1UL)));
384 break;
385 }
386 sg++;
387 }
388
389 pteval = iopte_protection | (pteval & IOPTE_PAGE);
390 while (len > 0) {
391 *iopte++ = __iopte(pteval);
392 pteval += IO_PAGE_SIZE;
393 len -= (IO_PAGE_SIZE - offset);
394 offset = 0;
395 dma_npages--;
396 }
397
398 pteval = (pteval & IOPTE_PAGE) + len;
399 sg++;
400
401 /* Skip over any tail mappings we've fully mapped,
402 * adjusting pteval along the way. Stop when we
403 * detect a page crossing event.
404 */
405 while (sg < sg_end &&
406 (pteval << (64 - IO_PAGE_SHIFT)) != 0UL &&
407 (pteval == SG_ENT_PHYS_ADDRESS(sg)) &&
408 ((pteval ^
409 (SG_ENT_PHYS_ADDRESS(sg) + sg->length - 1UL)) >> IO_PAGE_SHIFT) == 0UL) {
410 pteval += sg->length;
411 sg++;
412 }
413 if ((pteval << (64 - IO_PAGE_SHIFT)) == 0UL)
414 pteval = ~0UL;
415 } while (dma_npages != 0);
416 dma_sg++;
417 }
418}
419
420int sbus_map_sg(struct sbus_dev *sdev, struct scatterlist *sglist, int nelems, int direction)
421{
422 struct sbus_info *info;
423 struct iommu *iommu;
424 unsigned long flags, npages, iopte_protection;
425 iopte_t *base;
426 u32 dma_base;
427 struct scatterlist *sgtmp;
428 int used;
429
430 /* Fast path single entry scatterlists. */
431 if (nelems == 1) {
432 sglist->dma_address =
433 sbus_map_single(sdev,
434 (page_address(sglist->page) + sglist->offset),
435 sglist->length, direction);
436 sglist->dma_length = sglist->length;
437 return 1;
438 }
439
440 info = sdev->bus->iommu;
441 iommu = &info->iommu;
442
443 if (unlikely(direction == SBUS_DMA_NONE))
444 BUG();
445
446 npages = prepare_sg(sglist, nelems);
447
448 spin_lock_irqsave(&iommu->lock, flags);
449 base = alloc_npages(iommu, npages);
450 spin_unlock_irqrestore(&iommu->lock, flags);
451
452 if (unlikely(base == NULL))
453 BUG();
454
455 dma_base = iommu->page_table_map_base +
456 ((base - iommu->page_table) << IO_PAGE_SHIFT);
457
458 /* Normalize DVMA addresses. */
459 used = nelems;
460
461 sgtmp = sglist;
462 while (used && sgtmp->dma_length) {
463 sgtmp->dma_address += dma_base;
464 sgtmp++;
465 used--;
466 }
467 used = nelems - used;
468
469 iopte_protection = IOPTE_VALID | IOPTE_STBUF | IOPTE_CACHE;
470 if (direction != SBUS_DMA_TODEVICE)
471 iopte_protection |= IOPTE_WRITE;
472
473 fill_sg(base, sglist, used, nelems, iopte_protection);
474
475#ifdef VERIFY_SG
476 verify_sglist(sglist, nelems, base, npages);
477#endif
478
479 return used;
480}
481
482void sbus_unmap_sg(struct sbus_dev *sdev, struct scatterlist *sglist, int nelems, int direction)
483{
484 struct sbus_info *info;
485 struct iommu *iommu;
486 struct strbuf *strbuf;
487 iopte_t *base;
488 unsigned long flags, i, npages;
489 u32 bus_addr;
490
491 if (unlikely(direction == SBUS_DMA_NONE))
492 BUG();
493
494 info = sdev->bus->iommu;
495 iommu = &info->iommu;
496 strbuf = &info->strbuf;
497
498 bus_addr = sglist->dma_address & IO_PAGE_MASK;
499
500 for (i = 1; i < nelems; i++)
501 if (sglist[i].dma_length == 0)
502 break;
503 i--;
504 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length) -
505 bus_addr) >> IO_PAGE_SHIFT;
506
507 base = iommu->page_table +
508 ((bus_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT);
509
510 spin_lock_irqsave(&iommu->lock, flags);
511 sbus_strbuf_flush(iommu, strbuf, bus_addr, npages, direction);
512 for (i = 0; i < npages; i++)
513 iopte_val(base[i]) = 0UL;
514 free_npages(iommu, bus_addr - iommu->page_table_map_base, npages);
515 spin_unlock_irqrestore(&iommu->lock, flags);
516}
517
518void sbus_dma_sync_single_for_cpu(struct sbus_dev *sdev, dma_addr_t bus_addr, size_t sz, int direction)
519{
520 struct sbus_info *info;
521 struct iommu *iommu;
522 struct strbuf *strbuf;
523 unsigned long flags, npages;
524
525 info = sdev->bus->iommu;
526 iommu = &info->iommu;
527 strbuf = &info->strbuf;
528
529 npages = IO_PAGE_ALIGN(bus_addr + sz) - (bus_addr & IO_PAGE_MASK);
530 npages >>= IO_PAGE_SHIFT;
531 bus_addr &= IO_PAGE_MASK;
532
533 spin_lock_irqsave(&iommu->lock, flags);
534 sbus_strbuf_flush(iommu, strbuf, bus_addr, npages, direction);
535 spin_unlock_irqrestore(&iommu->lock, flags);
536}
537
538void sbus_dma_sync_single_for_device(struct sbus_dev *sdev, dma_addr_t base, size_t size, int direction)
539{
540}
541
542void sbus_dma_sync_sg_for_cpu(struct sbus_dev *sdev, struct scatterlist *sglist, int nelems, int direction)
543{
544 struct sbus_info *info;
545 struct iommu *iommu;
546 struct strbuf *strbuf;
547 unsigned long flags, npages, i;
548 u32 bus_addr;
549
550 info = sdev->bus->iommu;
551 iommu = &info->iommu;
552 strbuf = &info->strbuf;
553
554 bus_addr = sglist[0].dma_address & IO_PAGE_MASK;
555 for (i = 0; i < nelems; i++) {
556 if (!sglist[i].dma_length)
557 break;
558 }
559 i--;
560 npages = (IO_PAGE_ALIGN(sglist[i].dma_address + sglist[i].dma_length)
561 - bus_addr) >> IO_PAGE_SHIFT;
562
563 spin_lock_irqsave(&iommu->lock, flags);
564 sbus_strbuf_flush(iommu, strbuf, bus_addr, npages, direction);
565 spin_unlock_irqrestore(&iommu->lock, flags);
566}
567
568void sbus_dma_sync_sg_for_device(struct sbus_dev *sdev, struct scatterlist *sg, int nents, int direction)
569{
570}
571
572/* Enable 64-bit DVMA mode for the given device. */ 54/* Enable 64-bit DVMA mode for the given device. */
573void sbus_set_sbus64(struct sbus_dev *sdev, int bursts) 55void sbus_set_sbus64(struct sbus_dev *sdev, int bursts)
574{ 56{
575 struct sbus_info *info = sdev->bus->iommu; 57 struct iommu *iommu = sdev->ofdev.dev.archdata.iommu;
576 struct iommu *iommu = &info->iommu;
577 int slot = sdev->slot; 58 int slot = sdev->slot;
578 unsigned long cfg_reg; 59 unsigned long cfg_reg;
579 u64 val; 60 u64 val;
@@ -713,8 +194,7 @@ static unsigned long sysio_imap_to_iclr(unsigned long imap)
713unsigned int sbus_build_irq(void *buscookie, unsigned int ino) 194unsigned int sbus_build_irq(void *buscookie, unsigned int ino)
714{ 195{
715 struct sbus_bus *sbus = (struct sbus_bus *)buscookie; 196 struct sbus_bus *sbus = (struct sbus_bus *)buscookie;
716 struct sbus_info *info = sbus->iommu; 197 struct iommu *iommu = sbus->ofdev.dev.archdata.iommu;
717 struct iommu *iommu = &info->iommu;
718 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 198 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
719 unsigned long imap, iclr; 199 unsigned long imap, iclr;
720 int sbus_level = 0; 200 int sbus_level = 0;
@@ -776,8 +256,7 @@ unsigned int sbus_build_irq(void *buscookie, unsigned int ino)
776static irqreturn_t sysio_ue_handler(int irq, void *dev_id) 256static irqreturn_t sysio_ue_handler(int irq, void *dev_id)
777{ 257{
778 struct sbus_bus *sbus = dev_id; 258 struct sbus_bus *sbus = dev_id;
779 struct sbus_info *info = sbus->iommu; 259 struct iommu *iommu = sbus->ofdev.dev.archdata.iommu;
780 struct iommu *iommu = &info->iommu;
781 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 260 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
782 unsigned long afsr_reg, afar_reg; 261 unsigned long afsr_reg, afar_reg;
783 unsigned long afsr, afar, error_bits; 262 unsigned long afsr, afar, error_bits;
@@ -849,8 +328,7 @@ static irqreturn_t sysio_ue_handler(int irq, void *dev_id)
849static irqreturn_t sysio_ce_handler(int irq, void *dev_id) 328static irqreturn_t sysio_ce_handler(int irq, void *dev_id)
850{ 329{
851 struct sbus_bus *sbus = dev_id; 330 struct sbus_bus *sbus = dev_id;
852 struct sbus_info *info = sbus->iommu; 331 struct iommu *iommu = sbus->ofdev.dev.archdata.iommu;
853 struct iommu *iommu = &info->iommu;
854 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 332 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
855 unsigned long afsr_reg, afar_reg; 333 unsigned long afsr_reg, afar_reg;
856 unsigned long afsr, afar, error_bits; 334 unsigned long afsr, afar, error_bits;
@@ -927,8 +405,7 @@ static irqreturn_t sysio_ce_handler(int irq, void *dev_id)
927static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id) 405static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id)
928{ 406{
929 struct sbus_bus *sbus = dev_id; 407 struct sbus_bus *sbus = dev_id;
930 struct sbus_info *info = sbus->iommu; 408 struct iommu *iommu = sbus->ofdev.dev.archdata.iommu;
931 struct iommu *iommu = &info->iommu;
932 unsigned long afsr_reg, afar_reg, reg_base; 409 unsigned long afsr_reg, afar_reg, reg_base;
933 unsigned long afsr, afar, error_bits; 410 unsigned long afsr, afar, error_bits;
934 int reported; 411 int reported;
@@ -995,8 +472,7 @@ static irqreturn_t sysio_sbus_error_handler(int irq, void *dev_id)
995 472
996static void __init sysio_register_error_handlers(struct sbus_bus *sbus) 473static void __init sysio_register_error_handlers(struct sbus_bus *sbus)
997{ 474{
998 struct sbus_info *info = sbus->iommu; 475 struct iommu *iommu = sbus->ofdev.dev.archdata.iommu;
999 struct iommu *iommu = &info->iommu;
1000 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL; 476 unsigned long reg_base = iommu->write_complete_reg - 0x2000UL;
1001 unsigned int irq; 477 unsigned int irq;
1002 u64 control; 478 u64 control;
@@ -1041,7 +517,6 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
1041{ 517{
1042 const struct linux_prom64_registers *pr; 518 const struct linux_prom64_registers *pr;
1043 struct device_node *dp; 519 struct device_node *dp;
1044 struct sbus_info *info;
1045 struct iommu *iommu; 520 struct iommu *iommu;
1046 struct strbuf *strbuf; 521 struct strbuf *strbuf;
1047 unsigned long regs, reg_base; 522 unsigned long regs, reg_base;
@@ -1054,25 +529,28 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
1054 529
1055 pr = of_get_property(dp, "reg", NULL); 530 pr = of_get_property(dp, "reg", NULL);
1056 if (!pr) { 531 if (!pr) {
1057 prom_printf("sbus_iommu_init: Cannot map SYSIO control registers.\n"); 532 prom_printf("sbus_iommu_init: Cannot map SYSIO "
533 "control registers.\n");
1058 prom_halt(); 534 prom_halt();
1059 } 535 }
1060 regs = pr->phys_addr; 536 regs = pr->phys_addr;
1061 537
1062 info = kzalloc(sizeof(*info), GFP_ATOMIC); 538 iommu = kzalloc(sizeof(*iommu), GFP_ATOMIC);
1063 if (info == NULL) { 539 if (!iommu)
1064 prom_printf("sbus_iommu_init: Fatal error, " 540 goto fatal_memory_error;
1065 "kmalloc(info) failed\n"); 541 strbuf = kzalloc(sizeof(*strbuf), GFP_ATOMIC);
1066 prom_halt(); 542 if (!strbuf)
1067 } 543 goto fatal_memory_error;
1068 544
1069 iommu = &info->iommu; 545 sbus->ofdev.dev.archdata.iommu = iommu;
1070 strbuf = &info->strbuf; 546 sbus->ofdev.dev.archdata.stc = strbuf;
1071 547
1072 reg_base = regs + SYSIO_IOMMUREG_BASE; 548 reg_base = regs + SYSIO_IOMMUREG_BASE;
1073 iommu->iommu_control = reg_base + IOMMU_CONTROL; 549 iommu->iommu_control = reg_base + IOMMU_CONTROL;
1074 iommu->iommu_tsbbase = reg_base + IOMMU_TSBBASE; 550 iommu->iommu_tsbbase = reg_base + IOMMU_TSBBASE;
1075 iommu->iommu_flush = reg_base + IOMMU_FLUSH; 551 iommu->iommu_flush = reg_base + IOMMU_FLUSH;
552 iommu->iommu_tags = iommu->iommu_control +
553 (IOMMU_TAGDIAG - IOMMU_CONTROL);
1076 554
1077 reg_base = regs + SYSIO_STRBUFREG_BASE; 555 reg_base = regs + SYSIO_STRBUFREG_BASE;
1078 strbuf->strbuf_control = reg_base + STRBUF_CONTROL; 556 strbuf->strbuf_control = reg_base + STRBUF_CONTROL;
@@ -1093,14 +571,12 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
1093 */ 571 */
1094 iommu->write_complete_reg = regs + 0x2000UL; 572 iommu->write_complete_reg = regs + 0x2000UL;
1095 573
1096 /* Link into SYSIO software state. */
1097 sbus->iommu = info;
1098
1099 printk("SYSIO: UPA portID %x, at %016lx\n", 574 printk("SYSIO: UPA portID %x, at %016lx\n",
1100 sbus->portid, regs); 575 sbus->portid, regs);
1101 576
1102 /* Setup for TSB_SIZE=7, TBW_SIZE=0, MMU_DE=1, MMU_EN=1 */ 577 /* Setup for TSB_SIZE=7, TBW_SIZE=0, MMU_DE=1, MMU_EN=1 */
1103 sbus_iommu_table_init(iommu, IO_TSB_SIZE); 578 if (iommu_table_init(iommu, IO_TSB_SIZE, MAP_BASE, 0xffffffff))
579 goto fatal_memory_error;
1104 580
1105 control = upa_readq(iommu->iommu_control); 581 control = upa_readq(iommu->iommu_control);
1106 control = ((7UL << 16UL) | 582 control = ((7UL << 16UL) |
@@ -1157,6 +633,10 @@ static void __init sbus_iommu_init(int __node, struct sbus_bus *sbus)
1157 starfire_hookup(sbus->portid); 633 starfire_hookup(sbus->portid);
1158 634
1159 sysio_register_error_handlers(sbus); 635 sysio_register_error_handlers(sbus);
636 return;
637
638fatal_memory_error:
639 prom_printf("sbus_iommu_init: Fatal memory allocation error.\n");
1160} 640}
1161 641
1162void sbus_fill_device_irq(struct sbus_dev *sdev) 642void sbus_fill_device_irq(struct sbus_dev *sdev)
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index 49063ca2efcd..69cad1b653c1 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -1460,6 +1460,74 @@ static int cmos_set_rtc_time(struct rtc_time *rtc_tm)
1460} 1460}
1461#endif /* CONFIG_PCI */ 1461#endif /* CONFIG_PCI */
1462 1462
1463static void mostek_get_rtc_time(struct rtc_time *rtc_tm)
1464{
1465 void __iomem *regs = mstk48t02_regs;
1466 u8 tmp;
1467
1468 spin_lock_irq(&mostek_lock);
1469
1470 tmp = mostek_read(regs + MOSTEK_CREG);
1471 tmp |= MSTK_CREG_READ;
1472 mostek_write(regs + MOSTEK_CREG, tmp);
1473
1474 rtc_tm->tm_sec = MSTK_REG_SEC(regs);
1475 rtc_tm->tm_min = MSTK_REG_MIN(regs);
1476 rtc_tm->tm_hour = MSTK_REG_HOUR(regs);
1477 rtc_tm->tm_mday = MSTK_REG_DOM(regs);
1478 rtc_tm->tm_mon = MSTK_REG_MONTH(regs);
1479 rtc_tm->tm_year = MSTK_CVT_YEAR( MSTK_REG_YEAR(regs) );
1480 rtc_tm->tm_wday = MSTK_REG_DOW(regs);
1481
1482 tmp = mostek_read(regs + MOSTEK_CREG);
1483 tmp &= ~MSTK_CREG_READ;
1484 mostek_write(regs + MOSTEK_CREG, tmp);
1485
1486 spin_unlock_irq(&mostek_lock);
1487
1488 rtc_tm->tm_mon--;
1489 rtc_tm->tm_wday--;
1490 rtc_tm->tm_year -= 1900;
1491}
1492
1493static int mostek_set_rtc_time(struct rtc_time *rtc_tm)
1494{
1495 unsigned char mon, day, hrs, min, sec, wday;
1496 void __iomem *regs = mstk48t02_regs;
1497 unsigned int yrs;
1498 u8 tmp;
1499
1500 yrs = rtc_tm->tm_year + 1900;
1501 mon = rtc_tm->tm_mon + 1;
1502 day = rtc_tm->tm_mday;
1503 wday = rtc_tm->tm_wday + 1;
1504 hrs = rtc_tm->tm_hour;
1505 min = rtc_tm->tm_min;
1506 sec = rtc_tm->tm_sec;
1507
1508 spin_lock_irq(&mostek_lock);
1509
1510 tmp = mostek_read(regs + MOSTEK_CREG);
1511 tmp |= MSTK_CREG_WRITE;
1512 mostek_write(regs + MOSTEK_CREG, tmp);
1513
1514 MSTK_SET_REG_SEC(regs, sec);
1515 MSTK_SET_REG_MIN(regs, min);
1516 MSTK_SET_REG_HOUR(regs, hrs);
1517 MSTK_SET_REG_DOW(regs, wday);
1518 MSTK_SET_REG_DOM(regs, day);
1519 MSTK_SET_REG_MONTH(regs, mon);
1520 MSTK_SET_REG_YEAR(regs, yrs - MSTK_YEAR_ZERO);
1521
1522 tmp = mostek_read(regs + MOSTEK_CREG);
1523 tmp &= ~MSTK_CREG_WRITE;
1524 mostek_write(regs + MOSTEK_CREG, tmp);
1525
1526 spin_unlock_irq(&mostek_lock);
1527
1528 return 0;
1529}
1530
1463struct mini_rtc_ops { 1531struct mini_rtc_ops {
1464 void (*get_rtc_time)(struct rtc_time *); 1532 void (*get_rtc_time)(struct rtc_time *);
1465 int (*set_rtc_time)(struct rtc_time *); 1533 int (*set_rtc_time)(struct rtc_time *);
@@ -1487,6 +1555,11 @@ static struct mini_rtc_ops cmos_rtc_ops = {
1487}; 1555};
1488#endif /* CONFIG_PCI */ 1556#endif /* CONFIG_PCI */
1489 1557
1558static struct mini_rtc_ops mostek_rtc_ops = {
1559 .get_rtc_time = mostek_get_rtc_time,
1560 .set_rtc_time = mostek_set_rtc_time,
1561};
1562
1490static struct mini_rtc_ops *mini_rtc_ops; 1563static struct mini_rtc_ops *mini_rtc_ops;
1491 1564
1492static inline void mini_get_rtc_time(struct rtc_time *time) 1565static inline void mini_get_rtc_time(struct rtc_time *time)
@@ -1615,6 +1688,8 @@ static int __init rtc_mini_init(void)
1615 else if (ds1287_regs) 1688 else if (ds1287_regs)
1616 mini_rtc_ops = &cmos_rtc_ops; 1689 mini_rtc_ops = &cmos_rtc_ops;
1617#endif /* CONFIG_PCI */ 1690#endif /* CONFIG_PCI */
1691 else if (mstk48t02_regs)
1692 mini_rtc_ops = &mostek_rtc_ops;
1618 else 1693 else
1619 return -ENODEV; 1694 return -ENODEV;
1620 1695
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index 6ef2d299fb10..6ef42b8e53d8 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -2134,12 +2134,20 @@ static void user_instruction_dump (unsigned int __user *pc)
2134void show_stack(struct task_struct *tsk, unsigned long *_ksp) 2134void show_stack(struct task_struct *tsk, unsigned long *_ksp)
2135{ 2135{
2136 unsigned long pc, fp, thread_base, ksp; 2136 unsigned long pc, fp, thread_base, ksp;
2137 void *tp = task_stack_page(tsk); 2137 struct thread_info *tp;
2138 struct reg_window *rw; 2138 struct reg_window *rw;
2139 int count = 0; 2139 int count = 0;
2140 2140
2141 ksp = (unsigned long) _ksp; 2141 ksp = (unsigned long) _ksp;
2142 2142 if (!tsk)
2143 tsk = current;
2144 tp = task_thread_info(tsk);
2145 if (ksp == 0UL) {
2146 if (tsk == current)
2147 asm("mov %%fp, %0" : "=r" (ksp));
2148 else
2149 ksp = tp->ksp;
2150 }
2143 if (tp == current_thread_info()) 2151 if (tp == current_thread_info())
2144 flushw_all(); 2152 flushw_all();
2145 2153
@@ -2168,11 +2176,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
2168 2176
2169void dump_stack(void) 2177void dump_stack(void)
2170{ 2178{
2171 unsigned long *ksp; 2179 show_stack(current, NULL);
2172
2173 __asm__ __volatile__("mov %%fp, %0"
2174 : "=r" (ksp));
2175 show_stack(current, ksp);
2176} 2180}
2177 2181
2178EXPORT_SYMBOL(dump_stack); 2182EXPORT_SYMBOL(dump_stack);
diff --git a/arch/sparc64/kernel/viohs.c b/arch/sparc64/kernel/viohs.c
index 09126fc338ba..708fa1705fbe 100644
--- a/arch/sparc64/kernel/viohs.c
+++ b/arch/sparc64/kernel/viohs.c
@@ -702,7 +702,7 @@ u32 vio_send_sid(struct vio_driver_state *vio)
702} 702}
703EXPORT_SYMBOL(vio_send_sid); 703EXPORT_SYMBOL(vio_send_sid);
704 704
705extern int vio_ldc_alloc(struct vio_driver_state *vio, 705int vio_ldc_alloc(struct vio_driver_state *vio,
706 struct ldc_channel_config *base_cfg, 706 struct ldc_channel_config *base_cfg,
707 void *event_arg) 707 void *event_arg)
708{ 708{
diff --git a/arch/sparc64/kernel/vmlinux.lds.S b/arch/sparc64/kernel/vmlinux.lds.S
index 481861764deb..b982fa3dd748 100644
--- a/arch/sparc64/kernel/vmlinux.lds.S
+++ b/arch/sparc64/kernel/vmlinux.lds.S
@@ -45,6 +45,8 @@ SECTIONS
45 __ex_table : { *(__ex_table) } 45 __ex_table : { *(__ex_table) }
46 __stop___ex_table = .; 46 __stop___ex_table = .;
47 47
48 NOTES
49
48 . = ALIGN(PAGE_SIZE); 50 . = ALIGN(PAGE_SIZE);
49 __init_begin = .; 51 __init_begin = .;
50 .init.text : { 52 .init.text : {
diff --git a/arch/sparc64/mm/fault.c b/arch/sparc64/mm/fault.c
index 17123e9ecf78..9f7740eee8d2 100644
--- a/arch/sparc64/mm/fault.c
+++ b/arch/sparc64/mm/fault.c
@@ -112,15 +112,12 @@ static void __kprobes unhandled_fault(unsigned long address,
112 112
113static void bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr) 113static void bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
114{ 114{
115 unsigned long *ksp;
116
117 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n", 115 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
118 regs->tpc); 116 regs->tpc);
119 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]); 117 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
120 print_symbol("RPC: <%s>\n", regs->u_regs[15]); 118 print_symbol("RPC: <%s>\n", regs->u_regs[15]);
121 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr); 119 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
122 __asm__("mov %%sp, %0" : "=r" (ksp)); 120 dump_stack();
123 show_stack(current, ksp);
124 unhandled_fault(regs->tpc, current, regs); 121 unhandled_fault(regs->tpc, current, regs);
125} 122}
126 123
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 368d3e97dfd9..629b00e3b0b0 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -157,7 +157,7 @@ static void tty_receive_char(struct tty_struct *tty, char ch)
157 157
158static int open_one_chan(struct chan *chan) 158static int open_one_chan(struct chan *chan)
159{ 159{
160 int fd; 160 int fd, err;
161 161
162 if(chan->opened) 162 if(chan->opened)
163 return 0; 163 return 0;
@@ -168,6 +168,13 @@ static int open_one_chan(struct chan *chan)
168 chan->data, &chan->dev); 168 chan->data, &chan->dev);
169 if(fd < 0) 169 if(fd < 0)
170 return fd; 170 return fd;
171
172 err = os_set_fd_block(fd, 0);
173 if (err) {
174 (*chan->ops->close)(fd, chan->data);
175 return err;
176 }
177
171 chan->fd = fd; 178 chan->fd = fd;
172 179
173 chan->opened = 1; 180 chan->opened = 1;
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 542c9ef858f8..d87090507401 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -499,7 +499,7 @@ static struct mc_device mem_mc = {
499 .remove = mem_remove, 499 .remove = mem_remove,
500}; 500};
501 501
502static int mem_mc_init(void) 502static int __init mem_mc_init(void)
503{ 503{
504 if(can_drop_memory()) 504 if(can_drop_memory())
505 mconsole_register_dev(&mem_mc); 505 mconsole_register_dev(&mem_mc);
@@ -798,7 +798,7 @@ void mconsole_stack(struct mc_request *req)
798 */ 798 */
799static char *notify_socket = NULL; 799static char *notify_socket = NULL;
800 800
801static int mconsole_init(void) 801static int __init mconsole_init(void)
802{ 802{
803 /* long to avoid size mismatch warnings from gcc */ 803 /* long to avoid size mismatch warnings from gcc */
804 long sock; 804 long sock;
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index e41a08f04694..867666a02339 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/mm.h> 14#include <linux/mm.h>
15#include <linux/fs.h>
15#include <linux/miscdevice.h> 16#include <linux/miscdevice.h>
16#include <asm/uaccess.h> 17#include <asm/uaccess.h>
17#include "mem_user.h" 18#include "mem_user.h"
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 72773dd54425..d35d0c1ee7f4 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -623,7 +623,7 @@ static int eth_setup_common(char *str, int index)
623 return found; 623 return found;
624} 624}
625 625
626static int eth_setup(char *str) 626static int __init eth_setup(char *str)
627{ 627{
628 struct eth_init *new; 628 struct eth_init *new;
629 char *error; 629 char *error;
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index fc27f6c72b41..aff661fe2ee1 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -469,7 +469,7 @@ __uml_help(fakehd,
469" Change the ubd device name to \"hd\".\n\n" 469" Change the ubd device name to \"hd\".\n\n"
470); 470);
471 471
472static void do_ubd_request(request_queue_t * q); 472static void do_ubd_request(struct request_queue * q);
473 473
474/* Only changed by ubd_init, which is an initcall. */ 474/* Only changed by ubd_init, which is an initcall. */
475int thread_fd = -1; 475int thread_fd = -1;
@@ -1081,7 +1081,7 @@ static void prepare_request(struct request *req, struct io_thread_req *io_req,
1081} 1081}
1082 1082
1083/* Called with dev->lock held */ 1083/* Called with dev->lock held */
1084static void do_ubd_request(request_queue_t *q) 1084static void do_ubd_request(struct request_queue *q)
1085{ 1085{
1086 struct io_thread_req *io_req; 1086 struct io_thread_req *io_req;
1087 struct request *req; 1087 struct request *req;
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index 356e50f5aaed..ce6828fd396f 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -6,6 +6,7 @@
6#include "linux/slab.h" 6#include "linux/slab.h"
7#include "linux/smp_lock.h" 7#include "linux/smp_lock.h"
8#include "linux/ptrace.h" 8#include "linux/ptrace.h"
9#include "linux/fs.h"
9#include "asm/ptrace.h" 10#include "asm/ptrace.h"
10#include "asm/pgtable.h" 11#include "asm/pgtable.h"
11#include "asm/tlbflush.h" 12#include "asm/tlbflush.h"
diff --git a/arch/um/kernel/init_task.c b/arch/um/kernel/init_task.c
index d4f1d1ab252b..cba516e6c99a 100644
--- a/arch/um/kernel/init_task.c
+++ b/arch/um/kernel/init_task.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include "linux/mm.h" 6#include "linux/mm.h"
7#include "linux/fs.h"
7#include "linux/module.h" 8#include "linux/module.h"
8#include "linux/sched.h" 9#include "linux/sched.h"
9#include "linux/init_task.h" 10#include "linux/init_task.h"
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 72ff85693a39..d2b11f242698 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -62,7 +62,7 @@ static void setup_highmem(unsigned long highmem_start,
62} 62}
63#endif 63#endif
64 64
65void mem_init(void) 65void __init mem_init(void)
66{ 66{
67 /* clear the zero-page */ 67 /* clear the zero-page */
68 memset((void *) empty_zero_page, 0, PAGE_SIZE); 68 memset((void *) empty_zero_page, 0, PAGE_SIZE);
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
index 3ba6e4c841da..5ee7e851bbc1 100644
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -28,7 +28,8 @@ unsigned long high_physmem;
28 28
29extern unsigned long long physmem_size; 29extern unsigned long long physmem_size;
30 30
31int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem) 31int __init init_maps(unsigned long physmem, unsigned long iomem,
32 unsigned long highmem)
32{ 33{
33 struct page *p, *map; 34 struct page *p, *map;
34 unsigned long phys_len, phys_pages, highmem_len, highmem_pages; 35 unsigned long phys_len, phys_pages, highmem_len, highmem_pages;
@@ -47,13 +48,7 @@ int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem)
47 total_pages = phys_pages + iomem_pages + highmem_pages; 48 total_pages = phys_pages + iomem_pages + highmem_pages;
48 total_len = phys_len + iomem_len + highmem_len; 49 total_len = phys_len + iomem_len + highmem_len;
49 50
50 if(kmalloc_ok){ 51 map = alloc_bootmem_low_pages(total_len);
51 map = kmalloc(total_len, GFP_KERNEL);
52 if(map == NULL)
53 map = vmalloc(total_len);
54 }
55 else map = alloc_bootmem_low_pages(total_len);
56
57 if(map == NULL) 52 if(map == NULL)
58 return -ENOMEM; 53 return -ENOMEM;
59 54
@@ -98,8 +93,8 @@ void map_memory(unsigned long virt, unsigned long phys, unsigned long len,
98 93
99extern int __syscall_stub_start; 94extern int __syscall_stub_start;
100 95
101void setup_physmem(unsigned long start, unsigned long reserve_end, 96void __init setup_physmem(unsigned long start, unsigned long reserve_end,
102 unsigned long len, unsigned long long highmem) 97 unsigned long len, unsigned long long highmem)
103{ 98{
104 unsigned long reserve = reserve_end - start; 99 unsigned long reserve = reserve_end - start;
105 int pfn = PFN_UP(__pa(reserve_end)); 100 int pfn = PFN_UP(__pa(reserve_end));
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
index 2a69a7ce5792..48051a98525f 100644
--- a/arch/um/kernel/skas/process.c
+++ b/arch/um/kernel/skas/process.c
@@ -145,7 +145,7 @@ void init_idle_skas(void)
145 145
146extern void start_kernel(void); 146extern void start_kernel(void);
147 147
148static int start_kernel_proc(void *unused) 148static int __init start_kernel_proc(void *unused)
149{ 149{
150 int pid; 150 int pid;
151 151
@@ -165,7 +165,7 @@ extern int userspace_pid[];
165 165
166extern char cpu0_irqstack[]; 166extern char cpu0_irqstack[];
167 167
168int start_uml_skas(void) 168int __init start_uml_skas(void)
169{ 169{
170 stack_protections((unsigned long) &cpu0_irqstack); 170 stack_protections((unsigned long) &cpu0_irqstack);
171 set_sigstack(cpu0_irqstack, THREAD_SIZE); 171 set_sigstack(cpu0_irqstack, THREAD_SIZE);
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
index 237c4eab7cfd..7b3b67333ff3 100644
--- a/arch/um/kernel/syscall.c
+++ b/arch/um/kernel/syscall.c
@@ -7,6 +7,7 @@
7#include "linux/file.h" 7#include "linux/file.h"
8#include "linux/smp_lock.h" 8#include "linux/smp_lock.h"
9#include "linux/mm.h" 9#include "linux/mm.h"
10#include "linux/fs.h"
10#include "linux/utsname.h" 11#include "linux/utsname.h"
11#include "linux/msg.h" 12#include "linux/msg.h"
12#include "linux/shm.h" 13#include "linux/shm.h"
diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c
index b126df4ea168..59348359f9ab 100644
--- a/arch/um/os-Linux/aio.c
+++ b/arch/um/os-Linux/aio.c
@@ -14,6 +14,7 @@
14#include "init.h" 14#include "init.h"
15#include "user.h" 15#include "user.h"
16#include "mode.h" 16#include "mode.h"
17#include "kern_constants.h"
17 18
18struct aio_thread_req { 19struct aio_thread_req {
19 enum aio_type type; 20 enum aio_type type;
@@ -65,47 +66,33 @@ static long io_getevents(aio_context_t ctx_id, long min_nr, long nr,
65static int do_aio(aio_context_t ctx, enum aio_type type, int fd, char *buf, 66static int do_aio(aio_context_t ctx, enum aio_type type, int fd, char *buf,
66 int len, unsigned long long offset, struct aio_context *aio) 67 int len, unsigned long long offset, struct aio_context *aio)
67{ 68{
68 struct iocb iocb, *iocbp = &iocb; 69 struct iocb *iocbp = & ((struct iocb) {
70 .aio_data = (unsigned long) aio,
71 .aio_fildes = fd,
72 .aio_buf = (unsigned long) buf,
73 .aio_nbytes = len,
74 .aio_offset = offset
75 });
69 char c; 76 char c;
70 int err;
71 77
72 iocb = ((struct iocb) { .aio_data = (unsigned long) aio, 78 switch (type) {
73 .aio_reqprio = 0,
74 .aio_fildes = fd,
75 .aio_buf = (unsigned long) buf,
76 .aio_nbytes = len,
77 .aio_offset = offset,
78 .aio_reserved1 = 0,
79 .aio_reserved2 = 0,
80 .aio_reserved3 = 0 });
81
82 switch(type){
83 case AIO_READ: 79 case AIO_READ:
84 iocb.aio_lio_opcode = IOCB_CMD_PREAD; 80 iocbp->aio_lio_opcode = IOCB_CMD_PREAD;
85 err = io_submit(ctx, 1, &iocbp);
86 break; 81 break;
87 case AIO_WRITE: 82 case AIO_WRITE:
88 iocb.aio_lio_opcode = IOCB_CMD_PWRITE; 83 iocbp->aio_lio_opcode = IOCB_CMD_PWRITE;
89 err = io_submit(ctx, 1, &iocbp);
90 break; 84 break;
91 case AIO_MMAP: 85 case AIO_MMAP:
92 iocb.aio_lio_opcode = IOCB_CMD_PREAD; 86 iocbp->aio_lio_opcode = IOCB_CMD_PREAD;
93 iocb.aio_buf = (unsigned long) &c; 87 iocbp->aio_buf = (unsigned long) &c;
94 iocb.aio_nbytes = sizeof(c); 88 iocbp->aio_nbytes = sizeof(c);
95 err = io_submit(ctx, 1, &iocbp);
96 break; 89 break;
97 default: 90 default:
98 printk("Bogus op in do_aio - %d\n", type); 91 printk(UM_KERN_ERR "Bogus op in do_aio - %d\n", type);
99 err = -EINVAL; 92 return -EINVAL;
100 break;
101 } 93 }
102 94
103 if(err > 0) 95 return (io_submit(ctx, 1, &iocbp) > 0) ? 0 : -errno;
104 err = 0;
105 else
106 err = -errno;
107
108 return err;
109} 96}
110 97
111/* Initialized in an initcall and unchanged thereafter */ 98/* Initialized in an initcall and unchanged thereafter */
diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c
index 2d9d2ca39299..e9c143297512 100644
--- a/arch/um/os-Linux/process.c
+++ b/arch/um/os-Linux/process.c
@@ -194,7 +194,7 @@ int os_unmap_memory(void *addr, int len)
194#define MADV_REMOVE KERNEL_MADV_REMOVE 194#define MADV_REMOVE KERNEL_MADV_REMOVE
195#endif 195#endif
196 196
197int __init os_drop_memory(void *addr, int length) 197int os_drop_memory(void *addr, int length)
198{ 198{
199 int err; 199 int err;
200 200
diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c
index 419b2d5ff6de..4c37b1b1d0b5 100644
--- a/arch/um/os-Linux/user_syms.c
+++ b/arch/um/os-Linux/user_syms.c
@@ -19,10 +19,7 @@ extern void *memmove(void *, const void *, size_t);
19extern void *memset(void *, int, size_t); 19extern void *memset(void *, int, size_t);
20extern int printf(const char *, ...); 20extern int printf(const char *, ...);
21 21
22/* If they're not defined, the export is included in lib/string.c.*/ 22/* If it's not defined, the export is included in lib/string.c.*/
23#ifdef __HAVE_ARCH_STRLEN
24EXPORT_SYMBOL(strlen);
25#endif
26#ifdef __HAVE_ARCH_STRSTR 23#ifdef __HAVE_ARCH_STRSTR
27EXPORT_SYMBOL(strstr); 24EXPORT_SYMBOL(strstr);
28#endif 25#endif
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile
index 098720be019a..d6b3ecd4b77e 100644
--- a/arch/um/sys-i386/Makefile
+++ b/arch/um/sys-i386/Makefile
@@ -4,7 +4,7 @@ obj-y = bug.o bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \
4 4
5obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o 5obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o
6 6
7subarch-obj-y = lib/bitops.o lib/semaphore.o 7subarch-obj-y = lib/bitops.o lib/semaphore.o lib/string.o
8subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem.o 8subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem.o
9subarch-obj-$(CONFIG_MODULES) += kernel/module.o 9subarch-obj-$(CONFIG_MODULES) += kernel/module.o
10 10
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 45f82ae6d389..ffa036406289 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -765,6 +765,9 @@ config COMPAT
765 depends on IA32_EMULATION 765 depends on IA32_EMULATION
766 default y 766 default y
767 767
768config COMPAT_FOR_U64_ALIGNMENT
769 def_bool COMPAT
770
768config SYSVIPC_COMPAT 771config SYSVIPC_COMPAT
769 bool 772 bool
770 depends on COMPAT && SYSVIPC 773 depends on COMPAT && SYSVIPC
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index b7c4cd04bfc3..e64f65c9d901 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -199,7 +199,7 @@ CONFIG_GENERIC_PENDING_IRQ=y
199CONFIG_PM=y 199CONFIG_PM=y
200# CONFIG_PM_LEGACY is not set 200# CONFIG_PM_LEGACY is not set
201# CONFIG_PM_DEBUG is not set 201# CONFIG_PM_DEBUG is not set
202CONFIG_SOFTWARE_SUSPEND=y 202CONFIG_HIBERNATION=y
203CONFIG_PM_STD_PARTITION="" 203CONFIG_PM_STD_PARTITION=""
204CONFIG_SUSPEND_SMP=y 204CONFIG_SUSPEND_SMP=y
205 205
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index b70f3e7cf06c..dffd2ac72747 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -41,8 +41,9 @@ int sysctl_vsyscall32 = 1;
41#undef ARCH_DLINFO 41#undef ARCH_DLINFO
42#define ARCH_DLINFO do { \ 42#define ARCH_DLINFO do { \
43 if (sysctl_vsyscall32) { \ 43 if (sysctl_vsyscall32) { \
44 NEW_AUX_ENT(AT_SYSINFO, (u32)(u64)VSYSCALL32_VSYSCALL); \ 44 current->mm->context.vdso = (void *)VSYSCALL32_BASE; \
45 NEW_AUX_ENT(AT_SYSINFO_EHDR, VSYSCALL32_BASE); \ 45 NEW_AUX_ENT(AT_SYSINFO, (u32)(u64)VSYSCALL32_VSYSCALL); \
46 NEW_AUX_ENT(AT_SYSINFO_EHDR, VSYSCALL32_BASE); \
46 } \ 47 } \
47} while(0) 48} while(0)
48 49
diff --git a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
index 4de3a54318f4..4a233ad6269c 100644
--- a/arch/x86_64/ia32/ptrace32.c
+++ b/arch/x86_64/ia32/ptrace32.c
@@ -15,6 +15,7 @@
15#include <linux/syscalls.h> 15#include <linux/syscalls.h>
16#include <linux/unistd.h> 16#include <linux/unistd.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/err.h>
18#include <linux/ptrace.h> 19#include <linux/ptrace.h>
19#include <asm/ptrace.h> 20#include <asm/ptrace.h>
20#include <asm/compat.h> 21#include <asm/compat.h>
diff --git a/arch/x86_64/ia32/syscall32.c b/arch/x86_64/ia32/syscall32.c
index fc4419ff0355..15013bac181c 100644
--- a/arch/x86_64/ia32/syscall32.c
+++ b/arch/x86_64/ia32/syscall32.c
@@ -49,14 +49,6 @@ int syscall32_setup_pages(struct linux_binprm *bprm, int exstack)
49 return ret; 49 return ret;
50} 50}
51 51
52const char *arch_vma_name(struct vm_area_struct *vma)
53{
54 if (vma->vm_start == VSYSCALL32_BASE &&
55 vma->vm_mm && vma->vm_mm->task_size == IA32_PAGE_OFFSET)
56 return "[vdso]";
57 return NULL;
58}
59
60static int __init init_syscall32(void) 52static int __init init_syscall32(void)
61{ 53{
62 char *syscall32_page = (void *)get_zeroed_page(GFP_KERNEL); 54 char *syscall32_page = (void *)get_zeroed_page(GFP_KERNEL);
diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile
index 47f1dc30bf56..ff5d8c9b96d9 100644
--- a/arch/x86_64/kernel/Makefile
+++ b/arch/x86_64/kernel/Makefile
@@ -26,13 +26,12 @@ obj-y += io_apic.o mpparse.o genapic.o genapic_flat.o
26obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o 26obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o
27obj-$(CONFIG_CRASH_DUMP) += crash_dump.o 27obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
28obj-$(CONFIG_PM) += suspend.o 28obj-$(CONFIG_PM) += suspend.o
29obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend_asm.o 29obj-$(CONFIG_HIBERNATION) += suspend_asm.o
30obj-$(CONFIG_CPU_FREQ) += cpufreq/ 30obj-$(CONFIG_CPU_FREQ) += cpufreq/
31obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 31obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
32obj-$(CONFIG_IOMMU) += pci-gart.o aperture.o 32obj-$(CONFIG_IOMMU) += pci-gart.o aperture.o
33obj-$(CONFIG_CALGARY_IOMMU) += pci-calgary.o tce.o 33obj-$(CONFIG_CALGARY_IOMMU) += pci-calgary.o tce.o
34obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o 34obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
35obj-$(CONFIG_SERIAL_8250) += legacy_serial.o
36obj-$(CONFIG_KPROBES) += kprobes.o 35obj-$(CONFIG_KPROBES) += kprobes.o
37obj-$(CONFIG_X86_PM_TIMER) += pmtimer.o 36obj-$(CONFIG_X86_PM_TIMER) += pmtimer.o
38obj-$(CONFIG_X86_VSMP) += vsmp.o 37obj-$(CONFIG_X86_VSMP) += vsmp.o
@@ -51,7 +50,6 @@ CFLAGS_vsyscall.o := $(PROFILING) -g0
51 50
52therm_throt-y += ../../i386/kernel/cpu/mcheck/therm_throt.o 51therm_throt-y += ../../i386/kernel/cpu/mcheck/therm_throt.o
53bootflag-y += ../../i386/kernel/bootflag.o 52bootflag-y += ../../i386/kernel/bootflag.o
54legacy_serial-y += ../../i386/kernel/legacy_serial.o
55cpuid-$(subst m,y,$(CONFIG_X86_CPUID)) += ../../i386/kernel/cpuid.o 53cpuid-$(subst m,y,$(CONFIG_X86_CPUID)) += ../../i386/kernel/cpuid.o
56topology-y += ../../i386/kernel/topology.o 54topology-y += ../../i386/kernel/topology.o
57microcode-$(subst m,y,$(CONFIG_MICROCODE)) += ../../i386/kernel/microcode.o 55microcode-$(subst m,y,$(CONFIG_MICROCODE)) += ../../i386/kernel/microcode.o
diff --git a/arch/x86_64/kernel/acpi/sleep.c b/arch/x86_64/kernel/acpi/sleep.c
index 4277f2b27e6d..79475d237071 100644
--- a/arch/x86_64/kernel/acpi/sleep.c
+++ b/arch/x86_64/kernel/acpi/sleep.c
@@ -51,8 +51,6 @@
51 Low-Level Sleep Support 51 Low-Level Sleep Support
52 -------------------------------------------------------------------------- */ 52 -------------------------------------------------------------------------- */
53 53
54#ifdef CONFIG_ACPI_SLEEP
55
56/* address in low memory of the wakeup routine. */ 54/* address in low memory of the wakeup routine. */
57unsigned long acpi_wakeup_address = 0; 55unsigned long acpi_wakeup_address = 0;
58unsigned long acpi_realmode_flags; 56unsigned long acpi_realmode_flags;
@@ -117,8 +115,6 @@ static int __init acpi_sleep_setup(char *str)
117 115
118__setup("acpi_sleep=", acpi_sleep_setup); 116__setup("acpi_sleep=", acpi_sleep_setup);
119 117
120#endif /*CONFIG_ACPI_SLEEP */
121
122void acpi_pci_link_exit(void) 118void acpi_pci_link_exit(void)
123{ 119{
124} 120}
diff --git a/arch/x86_64/kernel/bugs.c b/arch/x86_64/kernel/bugs.c
index c3c6b91566ed..4e5e9d364d63 100644
--- a/arch/x86_64/kernel/bugs.c
+++ b/arch/x86_64/kernel/bugs.c
@@ -8,6 +8,7 @@
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/init.h> 9#include <linux/init.h>
10#include <asm/alternative.h> 10#include <asm/alternative.h>
11#include <asm/bugs.h>
11#include <asm/processor.h> 12#include <asm/processor.h>
12#include <asm/mtrr.h> 13#include <asm/mtrr.h>
13 14
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 830cfc6ee8cb..1d232e5f5658 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -282,7 +282,7 @@ sysret_careful:
282sysret_signal: 282sysret_signal:
283 TRACE_IRQS_ON 283 TRACE_IRQS_ON
284 sti 284 sti
285 testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx 285 testl $(_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
286 jz 1f 286 jz 1f
287 287
288 /* Really a signal */ 288 /* Really a signal */
@@ -375,7 +375,7 @@ int_very_careful:
375 jmp int_restore_rest 375 jmp int_restore_rest
376 376
377int_signal: 377int_signal:
378 testl $(_TIF_NOTIFY_RESUME|_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx 378 testl $(_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
379 jz 1f 379 jz 1f
380 movq %rsp,%rdi # &ptregs -> arg1 380 movq %rsp,%rdi # &ptregs -> arg1
381 xorl %esi,%esi # oldset -> arg2 381 xorl %esi,%esi # oldset -> arg2
@@ -599,7 +599,7 @@ retint_careful:
599 jmp retint_check 599 jmp retint_check
600 600
601retint_signal: 601retint_signal:
602 testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx 602 testl $(_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
603 jz retint_swapgs 603 jz retint_swapgs
604 TRACE_IRQS_ON 604 TRACE_IRQS_ON
605 sti 605 sti
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index e7ac629d4c46..2842f50cbe3f 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -23,6 +23,7 @@
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/fs.h>
26#include <linux/elfcore.h> 27#include <linux/elfcore.h>
27#include <linux/smp.h> 28#include <linux/smp.h>
28#include <linux/slab.h> 29#include <linux/slab.h>
diff --git a/arch/x86_64/kernel/suspend.c b/arch/x86_64/kernel/suspend.c
index ea83a9f91965..573c0a6e0ac6 100644
--- a/arch/x86_64/kernel/suspend.c
+++ b/arch/x86_64/kernel/suspend.c
@@ -146,7 +146,7 @@ void fix_processor_context(void)
146 146
147} 147}
148 148
149#ifdef CONFIG_SOFTWARE_SUSPEND 149#ifdef CONFIG_HIBERNATION
150/* Defined in arch/x86_64/kernel/suspend_asm.S */ 150/* Defined in arch/x86_64/kernel/suspend_asm.S */
151extern int restore_image(void); 151extern int restore_image(void);
152 152
@@ -236,4 +236,4 @@ int pfn_is_nosave(unsigned long pfn)
236 unsigned long nosave_end_pfn = PAGE_ALIGN(__pa_symbol(&__nosave_end)) >> PAGE_SHIFT; 236 unsigned long nosave_end_pfn = PAGE_ALIGN(__pa_symbol(&__nosave_end)) >> PAGE_SHIFT;
237 return (pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn); 237 return (pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn);
238} 238}
239#endif /* CONFIG_SOFTWARE_SUSPEND */ 239#endif /* CONFIG_HIBERNATION */
diff --git a/arch/x86_64/kernel/sys_x86_64.c b/arch/x86_64/kernel/sys_x86_64.c
index d067d9a2ad27..4770b7a2052c 100644
--- a/arch/x86_64/kernel/sys_x86_64.c
+++ b/arch/x86_64/kernel/sys_x86_64.c
@@ -6,6 +6,7 @@
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/syscalls.h> 7#include <linux/syscalls.h>
8#include <linux/mm.h> 8#include <linux/mm.h>
9#include <linux/fs.h>
9#include <linux/smp.h> 10#include <linux/smp.h>
10#include <linux/sem.h> 11#include <linux/sem.h>
11#include <linux/msg.h> 12#include <linux/msg.h>
diff --git a/arch/x86_64/kernel/tce.c b/arch/x86_64/kernel/tce.c
index 3aeae2fa2e24..e3f2569b2c44 100644
--- a/arch/x86_64/kernel/tce.c
+++ b/arch/x86_64/kernel/tce.c
@@ -131,7 +131,7 @@ done:
131 return ret; 131 return ret;
132} 132}
133 133
134int build_tce_table(struct pci_dev *dev, void __iomem *bbar) 134int __init build_tce_table(struct pci_dev *dev, void __iomem *bbar)
135{ 135{
136 struct iommu_table *tbl; 136 struct iommu_table *tbl;
137 int ret; 137 int ret;
@@ -165,7 +165,7 @@ done:
165 return ret; 165 return ret;
166} 166}
167 167
168void* alloc_tce_table(void) 168void * __init alloc_tce_table(void)
169{ 169{
170 unsigned int size; 170 unsigned int size;
171 171
@@ -175,7 +175,7 @@ void* alloc_tce_table(void)
175 return __alloc_bootmem_low(size, size, 0); 175 return __alloc_bootmem_low(size, size, 0);
176} 176}
177 177
178void free_tce_table(void *tbl) 178void __init free_tce_table(void *tbl)
179{ 179{
180 unsigned int size; 180 unsigned int size;
181 181
diff --git a/arch/x86_64/kernel/tsc.c b/arch/x86_64/kernel/tsc.c
index 9b76b03d0600..2a59bde663f2 100644
--- a/arch/x86_64/kernel/tsc.c
+++ b/arch/x86_64/kernel/tsc.c
@@ -118,8 +118,6 @@ core_initcall(cpufreq_tsc);
118 118
119#endif 119#endif
120 120
121static int tsc_unstable = 0;
122
123/* 121/*
124 * Make an educated guess if the TSC is trustworthy and synchronized 122 * Make an educated guess if the TSC is trustworthy and synchronized
125 * over all CPUs. 123 * over all CPUs.
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 38f5d6368006..458893b376f8 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -600,6 +600,16 @@ void mark_rodata_ro(void)
600{ 600{
601 unsigned long start = (unsigned long)_stext, end; 601 unsigned long start = (unsigned long)_stext, end;
602 602
603#ifdef CONFIG_HOTPLUG_CPU
604 /* It must still be possible to apply SMP alternatives. */
605 if (num_possible_cpus() > 1)
606 start = (unsigned long)_etext;
607#endif
608
609#ifdef CONFIG_KPROBES
610 start = (unsigned long)__start_rodata;
611#endif
612
603 end = (unsigned long)__end_rodata; 613 end = (unsigned long)__end_rodata;
604 start = (start + PAGE_SIZE - 1) & PAGE_MASK; 614 start = (start + PAGE_SIZE - 1) & PAGE_MASK;
605 end &= PAGE_MASK; 615 end &= PAGE_MASK;
diff --git a/arch/x86_64/vdso/vma.c b/arch/x86_64/vdso/vma.c
index d4cb83a6c066..ff9333e5fb08 100644
--- a/arch/x86_64/vdso/vma.c
+++ b/arch/x86_64/vdso/vma.c
@@ -4,6 +4,7 @@
4 * Subject to the GPL, v.2 4 * Subject to the GPL, v.2
5 */ 5 */
6#include <linux/mm.h> 6#include <linux/mm.h>
7#include <linux/err.h>
7#include <linux/sched.h> 8#include <linux/sched.h>
8#include <linux/init.h> 9#include <linux/init.h>
9#include <linux/random.h> 10#include <linux/random.h>
diff --git a/block/Kconfig b/block/Kconfig
index ca2ef4e08497..2484e0e9d89c 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -49,8 +49,6 @@ config LSF
49 49
50 If unsure, say Y. 50 If unsure, say Y.
51 51
52endif # BLOCK
53
54config BLK_DEV_BSG 52config BLK_DEV_BSG
55 bool "Block layer SG support v4 (EXPERIMENTAL)" 53 bool "Block layer SG support v4 (EXPERIMENTAL)"
56 depends on EXPERIMENTAL 54 depends on EXPERIMENTAL
@@ -64,4 +62,6 @@ config BLK_DEV_BSG
64 protocols (e.g. Task Management Functions and SMP in Serial 62 protocols (e.g. Task Management Functions and SMP in Serial
65 Attached SCSI). 63 Attached SCSI).
66 64
65endif # BLOCK
66
67source block/Kconfig.iosched 67source block/Kconfig.iosched
diff --git a/block/as-iosched.c b/block/as-iosched.c
index 3e316dd72529..dc715a562e14 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -796,7 +796,7 @@ static void update_write_batch(struct as_data *ad)
796 * as_completed_request is to be called when a request has completed and 796 * as_completed_request is to be called when a request has completed and
797 * returned something to the requesting process, be it an error or data. 797 * returned something to the requesting process, be it an error or data.
798 */ 798 */
799static void as_completed_request(request_queue_t *q, struct request *rq) 799static void as_completed_request(struct request_queue *q, struct request *rq)
800{ 800{
801 struct as_data *ad = q->elevator->elevator_data; 801 struct as_data *ad = q->elevator->elevator_data;
802 802
@@ -853,7 +853,8 @@ out:
853 * reference unless it replaces the request at somepart of the elevator 853 * reference unless it replaces the request at somepart of the elevator
854 * (ie. the dispatch queue) 854 * (ie. the dispatch queue)
855 */ 855 */
856static void as_remove_queued_request(request_queue_t *q, struct request *rq) 856static void as_remove_queued_request(struct request_queue *q,
857 struct request *rq)
857{ 858{
858 const int data_dir = rq_is_sync(rq); 859 const int data_dir = rq_is_sync(rq);
859 struct as_data *ad = q->elevator->elevator_data; 860 struct as_data *ad = q->elevator->elevator_data;
@@ -978,7 +979,7 @@ static void as_move_to_dispatch(struct as_data *ad, struct request *rq)
978 * read/write expire, batch expire, etc, and moves it to the dispatch 979 * read/write expire, batch expire, etc, and moves it to the dispatch
979 * queue. Returns 1 if a request was found, 0 otherwise. 980 * queue. Returns 1 if a request was found, 0 otherwise.
980 */ 981 */
981static int as_dispatch_request(request_queue_t *q, int force) 982static int as_dispatch_request(struct request_queue *q, int force)
982{ 983{
983 struct as_data *ad = q->elevator->elevator_data; 984 struct as_data *ad = q->elevator->elevator_data;
984 const int reads = !list_empty(&ad->fifo_list[REQ_SYNC]); 985 const int reads = !list_empty(&ad->fifo_list[REQ_SYNC]);
@@ -1139,7 +1140,7 @@ fifo_expired:
1139/* 1140/*
1140 * add rq to rbtree and fifo 1141 * add rq to rbtree and fifo
1141 */ 1142 */
1142static void as_add_request(request_queue_t *q, struct request *rq) 1143static void as_add_request(struct request_queue *q, struct request *rq)
1143{ 1144{
1144 struct as_data *ad = q->elevator->elevator_data; 1145 struct as_data *ad = q->elevator->elevator_data;
1145 int data_dir; 1146 int data_dir;
@@ -1167,7 +1168,7 @@ static void as_add_request(request_queue_t *q, struct request *rq)
1167 RQ_SET_STATE(rq, AS_RQ_QUEUED); 1168 RQ_SET_STATE(rq, AS_RQ_QUEUED);
1168} 1169}
1169 1170
1170static void as_activate_request(request_queue_t *q, struct request *rq) 1171static void as_activate_request(struct request_queue *q, struct request *rq)
1171{ 1172{
1172 WARN_ON(RQ_STATE(rq) != AS_RQ_DISPATCHED); 1173 WARN_ON(RQ_STATE(rq) != AS_RQ_DISPATCHED);
1173 RQ_SET_STATE(rq, AS_RQ_REMOVED); 1174 RQ_SET_STATE(rq, AS_RQ_REMOVED);
@@ -1175,7 +1176,7 @@ static void as_activate_request(request_queue_t *q, struct request *rq)
1175 atomic_dec(&RQ_IOC(rq)->aic->nr_dispatched); 1176 atomic_dec(&RQ_IOC(rq)->aic->nr_dispatched);
1176} 1177}
1177 1178
1178static void as_deactivate_request(request_queue_t *q, struct request *rq) 1179static void as_deactivate_request(struct request_queue *q, struct request *rq)
1179{ 1180{
1180 WARN_ON(RQ_STATE(rq) != AS_RQ_REMOVED); 1181 WARN_ON(RQ_STATE(rq) != AS_RQ_REMOVED);
1181 RQ_SET_STATE(rq, AS_RQ_DISPATCHED); 1182 RQ_SET_STATE(rq, AS_RQ_DISPATCHED);
@@ -1189,7 +1190,7 @@ static void as_deactivate_request(request_queue_t *q, struct request *rq)
1189 * is not empty - it is used in the block layer to check for plugging and 1190 * is not empty - it is used in the block layer to check for plugging and
1190 * merging opportunities 1191 * merging opportunities
1191 */ 1192 */
1192static int as_queue_empty(request_queue_t *q) 1193static int as_queue_empty(struct request_queue *q)
1193{ 1194{
1194 struct as_data *ad = q->elevator->elevator_data; 1195 struct as_data *ad = q->elevator->elevator_data;
1195 1196
@@ -1198,7 +1199,7 @@ static int as_queue_empty(request_queue_t *q)
1198} 1199}
1199 1200
1200static int 1201static int
1201as_merge(request_queue_t *q, struct request **req, struct bio *bio) 1202as_merge(struct request_queue *q, struct request **req, struct bio *bio)
1202{ 1203{
1203 struct as_data *ad = q->elevator->elevator_data; 1204 struct as_data *ad = q->elevator->elevator_data;
1204 sector_t rb_key = bio->bi_sector + bio_sectors(bio); 1205 sector_t rb_key = bio->bi_sector + bio_sectors(bio);
@@ -1216,7 +1217,8 @@ as_merge(request_queue_t *q, struct request **req, struct bio *bio)
1216 return ELEVATOR_NO_MERGE; 1217 return ELEVATOR_NO_MERGE;
1217} 1218}
1218 1219
1219static void as_merged_request(request_queue_t *q, struct request *req, int type) 1220static void as_merged_request(struct request_queue *q, struct request *req,
1221 int type)
1220{ 1222{
1221 struct as_data *ad = q->elevator->elevator_data; 1223 struct as_data *ad = q->elevator->elevator_data;
1222 1224
@@ -1234,7 +1236,7 @@ static void as_merged_request(request_queue_t *q, struct request *req, int type)
1234 } 1236 }
1235} 1237}
1236 1238
1237static void as_merged_requests(request_queue_t *q, struct request *req, 1239static void as_merged_requests(struct request_queue *q, struct request *req,
1238 struct request *next) 1240 struct request *next)
1239{ 1241{
1240 /* 1242 /*
@@ -1285,7 +1287,7 @@ static void as_work_handler(struct work_struct *work)
1285 spin_unlock_irqrestore(q->queue_lock, flags); 1287 spin_unlock_irqrestore(q->queue_lock, flags);
1286} 1288}
1287 1289
1288static int as_may_queue(request_queue_t *q, int rw) 1290static int as_may_queue(struct request_queue *q, int rw)
1289{ 1291{
1290 int ret = ELV_MQUEUE_MAY; 1292 int ret = ELV_MQUEUE_MAY;
1291 struct as_data *ad = q->elevator->elevator_data; 1293 struct as_data *ad = q->elevator->elevator_data;
@@ -1318,7 +1320,7 @@ static void as_exit_queue(elevator_t *e)
1318/* 1320/*
1319 * initialize elevator private data (as_data). 1321 * initialize elevator private data (as_data).
1320 */ 1322 */
1321static void *as_init_queue(request_queue_t *q) 1323static void *as_init_queue(struct request_queue *q)
1322{ 1324{
1323 struct as_data *ad; 1325 struct as_data *ad;
1324 1326
diff --git a/block/blktrace.c b/block/blktrace.c
index 3f0e7c37c059..20fa034ea4a2 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -41,7 +41,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action,
41 const int cpu = smp_processor_id(); 41 const int cpu = smp_processor_id();
42 42
43 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION; 43 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
44 t->time = sched_clock() - per_cpu(blk_trace_cpu_offset, cpu); 44 t->time = cpu_clock(cpu) - per_cpu(blk_trace_cpu_offset, cpu);
45 t->device = bt->dev; 45 t->device = bt->dev;
46 t->action = action; 46 t->action = action;
47 t->pid = pid; 47 t->pid = pid;
@@ -159,7 +159,7 @@ void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
159 159
160 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION; 160 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
161 t->sequence = ++(*sequence); 161 t->sequence = ++(*sequence);
162 t->time = sched_clock() - per_cpu(blk_trace_cpu_offset, cpu); 162 t->time = cpu_clock(cpu) - per_cpu(blk_trace_cpu_offset, cpu);
163 t->sector = sector; 163 t->sector = sector;
164 t->bytes = bytes; 164 t->bytes = bytes;
165 t->action = what; 165 t->action = what;
@@ -231,7 +231,7 @@ static void blk_trace_cleanup(struct blk_trace *bt)
231 kfree(bt); 231 kfree(bt);
232} 232}
233 233
234static int blk_trace_remove(request_queue_t *q) 234static int blk_trace_remove(struct request_queue *q)
235{ 235{
236 struct blk_trace *bt; 236 struct blk_trace *bt;
237 237
@@ -312,7 +312,7 @@ static struct rchan_callbacks blk_relay_callbacks = {
312/* 312/*
313 * Setup everything required to start tracing 313 * Setup everything required to start tracing
314 */ 314 */
315static int blk_trace_setup(request_queue_t *q, struct block_device *bdev, 315static int blk_trace_setup(struct request_queue *q, struct block_device *bdev,
316 char __user *arg) 316 char __user *arg)
317{ 317{
318 struct blk_user_trace_setup buts; 318 struct blk_user_trace_setup buts;
@@ -401,7 +401,7 @@ err:
401 return ret; 401 return ret;
402} 402}
403 403
404static int blk_trace_startstop(request_queue_t *q, int start) 404static int blk_trace_startstop(struct request_queue *q, int start)
405{ 405{
406 struct blk_trace *bt; 406 struct blk_trace *bt;
407 int ret; 407 int ret;
@@ -444,7 +444,7 @@ static int blk_trace_startstop(request_queue_t *q, int start)
444 **/ 444 **/
445int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg) 445int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
446{ 446{
447 request_queue_t *q; 447 struct request_queue *q;
448 int ret, start = 0; 448 int ret, start = 0;
449 449
450 q = bdev_get_queue(bdev); 450 q = bdev_get_queue(bdev);
@@ -479,7 +479,7 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
479 * @q: the request queue associated with the device 479 * @q: the request queue associated with the device
480 * 480 *
481 **/ 481 **/
482void blk_trace_shutdown(request_queue_t *q) 482void blk_trace_shutdown(struct request_queue *q)
483{ 483{
484 if (q->blk_trace) { 484 if (q->blk_trace) {
485 blk_trace_startstop(q, 0); 485 blk_trace_startstop(q, 0);
@@ -488,17 +488,17 @@ void blk_trace_shutdown(request_queue_t *q)
488} 488}
489 489
490/* 490/*
491 * Average offset over two calls to sched_clock() with a gettimeofday() 491 * Average offset over two calls to cpu_clock() with a gettimeofday()
492 * in the middle 492 * in the middle
493 */ 493 */
494static void blk_check_time(unsigned long long *t) 494static void blk_check_time(unsigned long long *t, int this_cpu)
495{ 495{
496 unsigned long long a, b; 496 unsigned long long a, b;
497 struct timeval tv; 497 struct timeval tv;
498 498
499 a = sched_clock(); 499 a = cpu_clock(this_cpu);
500 do_gettimeofday(&tv); 500 do_gettimeofday(&tv);
501 b = sched_clock(); 501 b = cpu_clock(this_cpu);
502 502
503 *t = tv.tv_sec * 1000000000 + tv.tv_usec * 1000; 503 *t = tv.tv_sec * 1000000000 + tv.tv_usec * 1000;
504 *t -= (a + b) / 2; 504 *t -= (a + b) / 2;
@@ -510,16 +510,16 @@ static void blk_check_time(unsigned long long *t)
510static void blk_trace_check_cpu_time(void *data) 510static void blk_trace_check_cpu_time(void *data)
511{ 511{
512 unsigned long long *t; 512 unsigned long long *t;
513 int cpu = get_cpu(); 513 int this_cpu = get_cpu();
514 514
515 t = &per_cpu(blk_trace_cpu_offset, cpu); 515 t = &per_cpu(blk_trace_cpu_offset, this_cpu);
516 516
517 /* 517 /*
518 * Just call it twice, hopefully the second call will be cache hot 518 * Just call it twice, hopefully the second call will be cache hot
519 * and a little more precise 519 * and a little more precise
520 */ 520 */
521 blk_check_time(t); 521 blk_check_time(t, this_cpu);
522 blk_check_time(t); 522 blk_check_time(t, this_cpu);
523 523
524 put_cpu(); 524 put_cpu();
525} 525}
diff --git a/block/bsg.c b/block/bsg.c
index b571869928a8..d60eee549405 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -9,13 +9,6 @@
9 * archive for more details. 9 * archive for more details.
10 * 10 *
11 */ 11 */
12/*
13 * TODO
14 * - Should this get merged, block/scsi_ioctl.c will be migrated into
15 * this file. To keep maintenance down, it's easier to have them
16 * seperated right now.
17 *
18 */
19#include <linux/module.h> 12#include <linux/module.h>
20#include <linux/init.h> 13#include <linux/init.h>
21#include <linux/file.h> 14#include <linux/file.h>
@@ -24,6 +17,7 @@
24#include <linux/cdev.h> 17#include <linux/cdev.h>
25#include <linux/percpu.h> 18#include <linux/percpu.h>
26#include <linux/uio.h> 19#include <linux/uio.h>
20#include <linux/idr.h>
27#include <linux/bsg.h> 21#include <linux/bsg.h>
28 22
29#include <scsi/scsi.h> 23#include <scsi/scsi.h>
@@ -37,7 +31,7 @@
37#define BSG_VERSION "0.4" 31#define BSG_VERSION "0.4"
38 32
39struct bsg_device { 33struct bsg_device {
40 request_queue_t *queue; 34 struct request_queue *queue;
41 spinlock_t lock; 35 spinlock_t lock;
42 struct list_head busy_list; 36 struct list_head busy_list;
43 struct list_head done_list; 37 struct list_head done_list;
@@ -70,13 +64,12 @@ enum {
70#endif 64#endif
71 65
72static DEFINE_MUTEX(bsg_mutex); 66static DEFINE_MUTEX(bsg_mutex);
73static int bsg_device_nr, bsg_minor_idx; 67static DEFINE_IDR(bsg_minor_idr);
74 68
75#define BSG_LIST_ARRAY_SIZE 8 69#define BSG_LIST_ARRAY_SIZE 8
76static struct hlist_head bsg_device_list[BSG_LIST_ARRAY_SIZE]; 70static struct hlist_head bsg_device_list[BSG_LIST_ARRAY_SIZE];
77 71
78static struct class *bsg_class; 72static struct class *bsg_class;
79static LIST_HEAD(bsg_class_list);
80static int bsg_major; 73static int bsg_major;
81 74
82static struct kmem_cache *bsg_cmd_cachep; 75static struct kmem_cache *bsg_cmd_cachep;
@@ -92,7 +85,6 @@ struct bsg_command {
92 struct bio *bidi_bio; 85 struct bio *bidi_bio;
93 int err; 86 int err;
94 struct sg_io_v4 hdr; 87 struct sg_io_v4 hdr;
95 struct sg_io_v4 __user *uhdr;
96 char sense[SCSI_SENSE_BUFFERSIZE]; 88 char sense[SCSI_SENSE_BUFFERSIZE];
97}; 89};
98 90
@@ -180,7 +172,7 @@ unlock:
180 return ret; 172 return ret;
181} 173}
182 174
183static int blk_fill_sgv4_hdr_rq(request_queue_t *q, struct request *rq, 175static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
184 struct sg_io_v4 *hdr, int has_write_perm) 176 struct sg_io_v4 *hdr, int has_write_perm)
185{ 177{
186 memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ 178 memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
@@ -214,7 +206,7 @@ static int blk_fill_sgv4_hdr_rq(request_queue_t *q, struct request *rq,
214 * Check if sg_io_v4 from user is allowed and valid 206 * Check if sg_io_v4 from user is allowed and valid
215 */ 207 */
216static int 208static int
217bsg_validate_sgv4_hdr(request_queue_t *q, struct sg_io_v4 *hdr, int *rw) 209bsg_validate_sgv4_hdr(struct request_queue *q, struct sg_io_v4 *hdr, int *rw)
218{ 210{
219 int ret = 0; 211 int ret = 0;
220 212
@@ -250,7 +242,7 @@ bsg_validate_sgv4_hdr(request_queue_t *q, struct sg_io_v4 *hdr, int *rw)
250static struct request * 242static struct request *
251bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr) 243bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr)
252{ 244{
253 request_queue_t *q = bd->queue; 245 struct request_queue *q = bd->queue;
254 struct request *rq, *next_rq = NULL; 246 struct request *rq, *next_rq = NULL;
255 int ret, rw; 247 int ret, rw;
256 unsigned int dxfer_len; 248 unsigned int dxfer_len;
@@ -345,7 +337,7 @@ static void bsg_rq_end_io(struct request *rq, int uptodate)
345 * do final setup of a 'bc' and submit the matching 'rq' to the block 337 * do final setup of a 'bc' and submit the matching 'rq' to the block
346 * layer for io 338 * layer for io
347 */ 339 */
348static void bsg_add_command(struct bsg_device *bd, request_queue_t *q, 340static void bsg_add_command(struct bsg_device *bd, struct request_queue *q,
349 struct bsg_command *bc, struct request *rq) 341 struct bsg_command *bc, struct request *rq)
350{ 342{
351 rq->sense = bc->sense; 343 rq->sense = bc->sense;
@@ -611,7 +603,7 @@ static int __bsg_write(struct bsg_device *bd, const char __user *buf,
611 bc = NULL; 603 bc = NULL;
612 ret = 0; 604 ret = 0;
613 while (nr_commands) { 605 while (nr_commands) {
614 request_queue_t *q = bd->queue; 606 struct request_queue *q = bd->queue;
615 607
616 bc = bsg_alloc_command(bd); 608 bc = bsg_alloc_command(bd);
617 if (IS_ERR(bc)) { 609 if (IS_ERR(bc)) {
@@ -620,7 +612,6 @@ static int __bsg_write(struct bsg_device *bd, const char __user *buf,
620 break; 612 break;
621 } 613 }
622 614
623 bc->uhdr = (struct sg_io_v4 __user *) buf;
624 if (copy_from_user(&bc->hdr, buf, sizeof(bc->hdr))) { 615 if (copy_from_user(&bc->hdr, buf, sizeof(bc->hdr))) {
625 ret = -EFAULT; 616 ret = -EFAULT;
626 break; 617 break;
@@ -781,23 +772,18 @@ static struct bsg_device *__bsg_get_device(int minor)
781 772
782static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file) 773static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file)
783{ 774{
784 struct bsg_device *bd = __bsg_get_device(iminor(inode)); 775 struct bsg_device *bd;
785 struct bsg_class_device *bcd, *__bcd; 776 struct bsg_class_device *bcd;
786 777
778 bd = __bsg_get_device(iminor(inode));
787 if (bd) 779 if (bd)
788 return bd; 780 return bd;
789 781
790 /* 782 /*
791 * find the class device 783 * find the class device
792 */ 784 */
793 bcd = NULL;
794 mutex_lock(&bsg_mutex); 785 mutex_lock(&bsg_mutex);
795 list_for_each_entry(__bcd, &bsg_class_list, list) { 786 bcd = idr_find(&bsg_minor_idr, iminor(inode));
796 if (__bcd->minor == iminor(inode)) {
797 bcd = __bcd;
798 break;
799 }
800 }
801 mutex_unlock(&bsg_mutex); 787 mutex_unlock(&bsg_mutex);
802 788
803 if (!bcd) 789 if (!bcd)
@@ -936,13 +922,12 @@ void bsg_unregister_queue(struct request_queue *q)
936 return; 922 return;
937 923
938 mutex_lock(&bsg_mutex); 924 mutex_lock(&bsg_mutex);
925 idr_remove(&bsg_minor_idr, bcd->minor);
939 sysfs_remove_link(&q->kobj, "bsg"); 926 sysfs_remove_link(&q->kobj, "bsg");
940 class_device_unregister(bcd->class_dev); 927 class_device_unregister(bcd->class_dev);
941 put_device(bcd->dev); 928 put_device(bcd->dev);
942 bcd->class_dev = NULL; 929 bcd->class_dev = NULL;
943 bcd->dev = NULL; 930 bcd->dev = NULL;
944 list_del_init(&bcd->list);
945 bsg_device_nr--;
946 mutex_unlock(&bsg_mutex); 931 mutex_unlock(&bsg_mutex);
947} 932}
948EXPORT_SYMBOL_GPL(bsg_unregister_queue); 933EXPORT_SYMBOL_GPL(bsg_unregister_queue);
@@ -950,9 +935,9 @@ EXPORT_SYMBOL_GPL(bsg_unregister_queue);
950int bsg_register_queue(struct request_queue *q, struct device *gdev, 935int bsg_register_queue(struct request_queue *q, struct device *gdev,
951 const char *name) 936 const char *name)
952{ 937{
953 struct bsg_class_device *bcd, *__bcd; 938 struct bsg_class_device *bcd;
954 dev_t dev; 939 dev_t dev;
955 int ret = -EMFILE; 940 int ret, minor;
956 struct class_device *class_dev = NULL; 941 struct class_device *class_dev = NULL;
957 const char *devname; 942 const char *devname;
958 943
@@ -969,28 +954,26 @@ int bsg_register_queue(struct request_queue *q, struct device *gdev,
969 954
970 bcd = &q->bsg_dev; 955 bcd = &q->bsg_dev;
971 memset(bcd, 0, sizeof(*bcd)); 956 memset(bcd, 0, sizeof(*bcd));
972 INIT_LIST_HEAD(&bcd->list);
973 957
974 mutex_lock(&bsg_mutex); 958 mutex_lock(&bsg_mutex);
975 if (bsg_device_nr == BSG_MAX_DEVS) {
976 printk(KERN_ERR "bsg: too many bsg devices\n");
977 goto err;
978 }
979 959
980retry: 960 ret = idr_pre_get(&bsg_minor_idr, GFP_KERNEL);
981 list_for_each_entry(__bcd, &bsg_class_list, list) { 961 if (!ret) {
982 if (__bcd->minor == bsg_minor_idx) { 962 ret = -ENOMEM;
983 bsg_minor_idx++; 963 goto unlock;
984 if (bsg_minor_idx == BSG_MAX_DEVS)
985 bsg_minor_idx = 0;
986 goto retry;
987 }
988 } 964 }
989 965
990 bcd->minor = bsg_minor_idx++; 966 ret = idr_get_new(&bsg_minor_idr, bcd, &minor);
991 if (bsg_minor_idx == BSG_MAX_DEVS) 967 if (ret < 0)
992 bsg_minor_idx = 0; 968 goto unlock;
993 969
970 if (minor >= BSG_MAX_DEVS) {
971 printk(KERN_ERR "bsg: too many bsg devices\n");
972 ret = -EINVAL;
973 goto remove_idr;
974 }
975
976 bcd->minor = minor;
994 bcd->queue = q; 977 bcd->queue = q;
995 bcd->dev = get_device(gdev); 978 bcd->dev = get_device(gdev);
996 dev = MKDEV(bsg_major, bcd->minor); 979 dev = MKDEV(bsg_major, bcd->minor);
@@ -998,27 +981,26 @@ retry:
998 devname); 981 devname);
999 if (IS_ERR(class_dev)) { 982 if (IS_ERR(class_dev)) {
1000 ret = PTR_ERR(class_dev); 983 ret = PTR_ERR(class_dev);
1001 goto err_put; 984 goto put_dev;
1002 } 985 }
1003 bcd->class_dev = class_dev; 986 bcd->class_dev = class_dev;
1004 987
1005 if (q->kobj.sd) { 988 if (q->kobj.sd) {
1006 ret = sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg"); 989 ret = sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg");
1007 if (ret) 990 if (ret)
1008 goto err_unregister; 991 goto unregister_class_dev;
1009 } 992 }
1010 993
1011 list_add_tail(&bcd->list, &bsg_class_list);
1012 bsg_device_nr++;
1013
1014 mutex_unlock(&bsg_mutex); 994 mutex_unlock(&bsg_mutex);
1015 return 0; 995 return 0;
1016 996
1017err_unregister: 997unregister_class_dev:
1018 class_device_unregister(class_dev); 998 class_device_unregister(class_dev);
1019err_put: 999put_dev:
1020 put_device(gdev); 1000 put_device(gdev);
1021err: 1001remove_idr:
1002 idr_remove(&bsg_minor_idr, minor);
1003unlock:
1022 mutex_unlock(&bsg_mutex); 1004 mutex_unlock(&bsg_mutex);
1023 return ret; 1005 return ret;
1024} 1006}
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index d148ccbc36d1..54dc05439009 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -71,7 +71,7 @@ struct cfq_rb_root {
71 * Per block device queue structure 71 * Per block device queue structure
72 */ 72 */
73struct cfq_data { 73struct cfq_data {
74 request_queue_t *queue; 74 struct request_queue *queue;
75 75
76 /* 76 /*
77 * rr list of queues with requests and the count of them 77 * rr list of queues with requests and the count of them
@@ -197,7 +197,7 @@ CFQ_CFQQ_FNS(slice_new);
197CFQ_CFQQ_FNS(sync); 197CFQ_CFQQ_FNS(sync);
198#undef CFQ_CFQQ_FNS 198#undef CFQ_CFQQ_FNS
199 199
200static void cfq_dispatch_insert(request_queue_t *, struct request *); 200static void cfq_dispatch_insert(struct request_queue *, struct request *);
201static struct cfq_queue *cfq_get_queue(struct cfq_data *, int, 201static struct cfq_queue *cfq_get_queue(struct cfq_data *, int,
202 struct task_struct *, gfp_t); 202 struct task_struct *, gfp_t);
203static struct cfq_io_context *cfq_cic_rb_lookup(struct cfq_data *, 203static struct cfq_io_context *cfq_cic_rb_lookup(struct cfq_data *,
@@ -237,7 +237,7 @@ static inline void cfq_schedule_dispatch(struct cfq_data *cfqd)
237 kblockd_schedule_work(&cfqd->unplug_work); 237 kblockd_schedule_work(&cfqd->unplug_work);
238} 238}
239 239
240static int cfq_queue_empty(request_queue_t *q) 240static int cfq_queue_empty(struct request_queue *q)
241{ 241{
242 struct cfq_data *cfqd = q->elevator->elevator_data; 242 struct cfq_data *cfqd = q->elevator->elevator_data;
243 243
@@ -623,7 +623,7 @@ cfq_find_rq_fmerge(struct cfq_data *cfqd, struct bio *bio)
623 return NULL; 623 return NULL;
624} 624}
625 625
626static void cfq_activate_request(request_queue_t *q, struct request *rq) 626static void cfq_activate_request(struct request_queue *q, struct request *rq)
627{ 627{
628 struct cfq_data *cfqd = q->elevator->elevator_data; 628 struct cfq_data *cfqd = q->elevator->elevator_data;
629 629
@@ -641,7 +641,7 @@ static void cfq_activate_request(request_queue_t *q, struct request *rq)
641 cfqd->last_position = rq->hard_sector + rq->hard_nr_sectors; 641 cfqd->last_position = rq->hard_sector + rq->hard_nr_sectors;
642} 642}
643 643
644static void cfq_deactivate_request(request_queue_t *q, struct request *rq) 644static void cfq_deactivate_request(struct request_queue *q, struct request *rq)
645{ 645{
646 struct cfq_data *cfqd = q->elevator->elevator_data; 646 struct cfq_data *cfqd = q->elevator->elevator_data;
647 647
@@ -665,7 +665,8 @@ static void cfq_remove_request(struct request *rq)
665 } 665 }
666} 666}
667 667
668static int cfq_merge(request_queue_t *q, struct request **req, struct bio *bio) 668static int cfq_merge(struct request_queue *q, struct request **req,
669 struct bio *bio)
669{ 670{
670 struct cfq_data *cfqd = q->elevator->elevator_data; 671 struct cfq_data *cfqd = q->elevator->elevator_data;
671 struct request *__rq; 672 struct request *__rq;
@@ -679,7 +680,7 @@ static int cfq_merge(request_queue_t *q, struct request **req, struct bio *bio)
679 return ELEVATOR_NO_MERGE; 680 return ELEVATOR_NO_MERGE;
680} 681}
681 682
682static void cfq_merged_request(request_queue_t *q, struct request *req, 683static void cfq_merged_request(struct request_queue *q, struct request *req,
683 int type) 684 int type)
684{ 685{
685 if (type == ELEVATOR_FRONT_MERGE) { 686 if (type == ELEVATOR_FRONT_MERGE) {
@@ -690,7 +691,7 @@ static void cfq_merged_request(request_queue_t *q, struct request *req,
690} 691}
691 692
692static void 693static void
693cfq_merged_requests(request_queue_t *q, struct request *rq, 694cfq_merged_requests(struct request_queue *q, struct request *rq,
694 struct request *next) 695 struct request *next)
695{ 696{
696 /* 697 /*
@@ -703,7 +704,7 @@ cfq_merged_requests(request_queue_t *q, struct request *rq,
703 cfq_remove_request(next); 704 cfq_remove_request(next);
704} 705}
705 706
706static int cfq_allow_merge(request_queue_t *q, struct request *rq, 707static int cfq_allow_merge(struct request_queue *q, struct request *rq,
707 struct bio *bio) 708 struct bio *bio)
708{ 709{
709 struct cfq_data *cfqd = q->elevator->elevator_data; 710 struct cfq_data *cfqd = q->elevator->elevator_data;
@@ -913,7 +914,7 @@ static void cfq_arm_slice_timer(struct cfq_data *cfqd)
913/* 914/*
914 * Move request from internal lists to the request queue dispatch list. 915 * Move request from internal lists to the request queue dispatch list.
915 */ 916 */
916static void cfq_dispatch_insert(request_queue_t *q, struct request *rq) 917static void cfq_dispatch_insert(struct request_queue *q, struct request *rq)
917{ 918{
918 struct cfq_data *cfqd = q->elevator->elevator_data; 919 struct cfq_data *cfqd = q->elevator->elevator_data;
919 struct cfq_queue *cfqq = RQ_CFQQ(rq); 920 struct cfq_queue *cfqq = RQ_CFQQ(rq);
@@ -1093,7 +1094,7 @@ static int cfq_forced_dispatch(struct cfq_data *cfqd)
1093 return dispatched; 1094 return dispatched;
1094} 1095}
1095 1096
1096static int cfq_dispatch_requests(request_queue_t *q, int force) 1097static int cfq_dispatch_requests(struct request_queue *q, int force)
1097{ 1098{
1098 struct cfq_data *cfqd = q->elevator->elevator_data; 1099 struct cfq_data *cfqd = q->elevator->elevator_data;
1099 struct cfq_queue *cfqq; 1100 struct cfq_queue *cfqq;
@@ -1214,7 +1215,7 @@ static void cfq_exit_single_io_context(struct cfq_io_context *cic)
1214 struct cfq_data *cfqd = cic->key; 1215 struct cfq_data *cfqd = cic->key;
1215 1216
1216 if (cfqd) { 1217 if (cfqd) {
1217 request_queue_t *q = cfqd->queue; 1218 struct request_queue *q = cfqd->queue;
1218 1219
1219 spin_lock_irq(q->queue_lock); 1220 spin_lock_irq(q->queue_lock);
1220 __cfq_exit_single_io_context(cfqd, cic); 1221 __cfq_exit_single_io_context(cfqd, cic);
@@ -1775,7 +1776,7 @@ cfq_rq_enqueued(struct cfq_data *cfqd, struct cfq_queue *cfqq,
1775 } 1776 }
1776} 1777}
1777 1778
1778static void cfq_insert_request(request_queue_t *q, struct request *rq) 1779static void cfq_insert_request(struct request_queue *q, struct request *rq)
1779{ 1780{
1780 struct cfq_data *cfqd = q->elevator->elevator_data; 1781 struct cfq_data *cfqd = q->elevator->elevator_data;
1781 struct cfq_queue *cfqq = RQ_CFQQ(rq); 1782 struct cfq_queue *cfqq = RQ_CFQQ(rq);
@@ -1789,7 +1790,7 @@ static void cfq_insert_request(request_queue_t *q, struct request *rq)
1789 cfq_rq_enqueued(cfqd, cfqq, rq); 1790 cfq_rq_enqueued(cfqd, cfqq, rq);
1790} 1791}
1791 1792
1792static void cfq_completed_request(request_queue_t *q, struct request *rq) 1793static void cfq_completed_request(struct request_queue *q, struct request *rq)
1793{ 1794{
1794 struct cfq_queue *cfqq = RQ_CFQQ(rq); 1795 struct cfq_queue *cfqq = RQ_CFQQ(rq);
1795 struct cfq_data *cfqd = cfqq->cfqd; 1796 struct cfq_data *cfqd = cfqq->cfqd;
@@ -1868,7 +1869,7 @@ static inline int __cfq_may_queue(struct cfq_queue *cfqq)
1868 return ELV_MQUEUE_MAY; 1869 return ELV_MQUEUE_MAY;
1869} 1870}
1870 1871
1871static int cfq_may_queue(request_queue_t *q, int rw) 1872static int cfq_may_queue(struct request_queue *q, int rw)
1872{ 1873{
1873 struct cfq_data *cfqd = q->elevator->elevator_data; 1874 struct cfq_data *cfqd = q->elevator->elevator_data;
1874 struct task_struct *tsk = current; 1875 struct task_struct *tsk = current;
@@ -1922,7 +1923,7 @@ static void cfq_put_request(struct request *rq)
1922 * Allocate cfq data structures associated with this request. 1923 * Allocate cfq data structures associated with this request.
1923 */ 1924 */
1924static int 1925static int
1925cfq_set_request(request_queue_t *q, struct request *rq, gfp_t gfp_mask) 1926cfq_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)
1926{ 1927{
1927 struct cfq_data *cfqd = q->elevator->elevator_data; 1928 struct cfq_data *cfqd = q->elevator->elevator_data;
1928 struct task_struct *tsk = current; 1929 struct task_struct *tsk = current;
@@ -1974,7 +1975,7 @@ static void cfq_kick_queue(struct work_struct *work)
1974{ 1975{
1975 struct cfq_data *cfqd = 1976 struct cfq_data *cfqd =
1976 container_of(work, struct cfq_data, unplug_work); 1977 container_of(work, struct cfq_data, unplug_work);
1977 request_queue_t *q = cfqd->queue; 1978 struct request_queue *q = cfqd->queue;
1978 unsigned long flags; 1979 unsigned long flags;
1979 1980
1980 spin_lock_irqsave(q->queue_lock, flags); 1981 spin_lock_irqsave(q->queue_lock, flags);
@@ -2072,7 +2073,7 @@ static void cfq_put_async_queues(struct cfq_data *cfqd)
2072static void cfq_exit_queue(elevator_t *e) 2073static void cfq_exit_queue(elevator_t *e)
2073{ 2074{
2074 struct cfq_data *cfqd = e->elevator_data; 2075 struct cfq_data *cfqd = e->elevator_data;
2075 request_queue_t *q = cfqd->queue; 2076 struct request_queue *q = cfqd->queue;
2076 2077
2077 cfq_shutdown_timer_wq(cfqd); 2078 cfq_shutdown_timer_wq(cfqd);
2078 2079
@@ -2098,7 +2099,7 @@ static void cfq_exit_queue(elevator_t *e)
2098 kfree(cfqd); 2099 kfree(cfqd);
2099} 2100}
2100 2101
2101static void *cfq_init_queue(request_queue_t *q) 2102static void *cfq_init_queue(struct request_queue *q)
2102{ 2103{
2103 struct cfq_data *cfqd; 2104 struct cfq_data *cfqd;
2104 2105
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index 87ca02ac84cb..1a511ffaf8a4 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -106,7 +106,7 @@ deadline_add_request(struct request_queue *q, struct request *rq)
106/* 106/*
107 * remove rq from rbtree and fifo. 107 * remove rq from rbtree and fifo.
108 */ 108 */
109static void deadline_remove_request(request_queue_t *q, struct request *rq) 109static void deadline_remove_request(struct request_queue *q, struct request *rq)
110{ 110{
111 struct deadline_data *dd = q->elevator->elevator_data; 111 struct deadline_data *dd = q->elevator->elevator_data;
112 112
@@ -115,7 +115,7 @@ static void deadline_remove_request(request_queue_t *q, struct request *rq)
115} 115}
116 116
117static int 117static int
118deadline_merge(request_queue_t *q, struct request **req, struct bio *bio) 118deadline_merge(struct request_queue *q, struct request **req, struct bio *bio)
119{ 119{
120 struct deadline_data *dd = q->elevator->elevator_data; 120 struct deadline_data *dd = q->elevator->elevator_data;
121 struct request *__rq; 121 struct request *__rq;
@@ -144,8 +144,8 @@ out:
144 return ret; 144 return ret;
145} 145}
146 146
147static void deadline_merged_request(request_queue_t *q, struct request *req, 147static void deadline_merged_request(struct request_queue *q,
148 int type) 148 struct request *req, int type)
149{ 149{
150 struct deadline_data *dd = q->elevator->elevator_data; 150 struct deadline_data *dd = q->elevator->elevator_data;
151 151
@@ -159,7 +159,7 @@ static void deadline_merged_request(request_queue_t *q, struct request *req,
159} 159}
160 160
161static void 161static void
162deadline_merged_requests(request_queue_t *q, struct request *req, 162deadline_merged_requests(struct request_queue *q, struct request *req,
163 struct request *next) 163 struct request *next)
164{ 164{
165 /* 165 /*
@@ -185,7 +185,7 @@ deadline_merged_requests(request_queue_t *q, struct request *req,
185static inline void 185static inline void
186deadline_move_to_dispatch(struct deadline_data *dd, struct request *rq) 186deadline_move_to_dispatch(struct deadline_data *dd, struct request *rq)
187{ 187{
188 request_queue_t *q = rq->q; 188 struct request_queue *q = rq->q;
189 189
190 deadline_remove_request(q, rq); 190 deadline_remove_request(q, rq);
191 elv_dispatch_add_tail(q, rq); 191 elv_dispatch_add_tail(q, rq);
@@ -236,7 +236,7 @@ static inline int deadline_check_fifo(struct deadline_data *dd, int ddir)
236 * deadline_dispatch_requests selects the best request according to 236 * deadline_dispatch_requests selects the best request according to
237 * read/write expire, fifo_batch, etc 237 * read/write expire, fifo_batch, etc
238 */ 238 */
239static int deadline_dispatch_requests(request_queue_t *q, int force) 239static int deadline_dispatch_requests(struct request_queue *q, int force)
240{ 240{
241 struct deadline_data *dd = q->elevator->elevator_data; 241 struct deadline_data *dd = q->elevator->elevator_data;
242 const int reads = !list_empty(&dd->fifo_list[READ]); 242 const int reads = !list_empty(&dd->fifo_list[READ]);
@@ -335,7 +335,7 @@ dispatch_request:
335 return 1; 335 return 1;
336} 336}
337 337
338static int deadline_queue_empty(request_queue_t *q) 338static int deadline_queue_empty(struct request_queue *q)
339{ 339{
340 struct deadline_data *dd = q->elevator->elevator_data; 340 struct deadline_data *dd = q->elevator->elevator_data;
341 341
@@ -356,7 +356,7 @@ static void deadline_exit_queue(elevator_t *e)
356/* 356/*
357 * initialize elevator private data (deadline_data). 357 * initialize elevator private data (deadline_data).
358 */ 358 */
359static void *deadline_init_queue(request_queue_t *q) 359static void *deadline_init_queue(struct request_queue *q)
360{ 360{
361 struct deadline_data *dd; 361 struct deadline_data *dd;
362 362
diff --git a/block/elevator.c b/block/elevator.c
index d265963d1ed3..c6d153de9fd6 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -56,7 +56,7 @@ static const int elv_hash_shift = 6;
56 */ 56 */
57static int elv_iosched_allow_merge(struct request *rq, struct bio *bio) 57static int elv_iosched_allow_merge(struct request *rq, struct bio *bio)
58{ 58{
59 request_queue_t *q = rq->q; 59 struct request_queue *q = rq->q;
60 elevator_t *e = q->elevator; 60 elevator_t *e = q->elevator;
61 61
62 if (e->ops->elevator_allow_merge_fn) 62 if (e->ops->elevator_allow_merge_fn)
@@ -141,12 +141,13 @@ static struct elevator_type *elevator_get(const char *name)
141 return e; 141 return e;
142} 142}
143 143
144static void *elevator_init_queue(request_queue_t *q, struct elevator_queue *eq) 144static void *elevator_init_queue(struct request_queue *q,
145 struct elevator_queue *eq)
145{ 146{
146 return eq->ops->elevator_init_fn(q); 147 return eq->ops->elevator_init_fn(q);
147} 148}
148 149
149static void elevator_attach(request_queue_t *q, struct elevator_queue *eq, 150static void elevator_attach(struct request_queue *q, struct elevator_queue *eq,
150 void *data) 151 void *data)
151{ 152{
152 q->elevator = eq; 153 q->elevator = eq;
@@ -172,7 +173,8 @@ __setup("elevator=", elevator_setup);
172 173
173static struct kobj_type elv_ktype; 174static struct kobj_type elv_ktype;
174 175
175static elevator_t *elevator_alloc(request_queue_t *q, struct elevator_type *e) 176static elevator_t *elevator_alloc(struct request_queue *q,
177 struct elevator_type *e)
176{ 178{
177 elevator_t *eq; 179 elevator_t *eq;
178 int i; 180 int i;
@@ -212,7 +214,7 @@ static void elevator_release(struct kobject *kobj)
212 kfree(e); 214 kfree(e);
213} 215}
214 216
215int elevator_init(request_queue_t *q, char *name) 217int elevator_init(struct request_queue *q, char *name)
216{ 218{
217 struct elevator_type *e = NULL; 219 struct elevator_type *e = NULL;
218 struct elevator_queue *eq; 220 struct elevator_queue *eq;
@@ -264,7 +266,7 @@ void elevator_exit(elevator_t *e)
264 266
265EXPORT_SYMBOL(elevator_exit); 267EXPORT_SYMBOL(elevator_exit);
266 268
267static void elv_activate_rq(request_queue_t *q, struct request *rq) 269static void elv_activate_rq(struct request_queue *q, struct request *rq)
268{ 270{
269 elevator_t *e = q->elevator; 271 elevator_t *e = q->elevator;
270 272
@@ -272,7 +274,7 @@ static void elv_activate_rq(request_queue_t *q, struct request *rq)
272 e->ops->elevator_activate_req_fn(q, rq); 274 e->ops->elevator_activate_req_fn(q, rq);
273} 275}
274 276
275static void elv_deactivate_rq(request_queue_t *q, struct request *rq) 277static void elv_deactivate_rq(struct request_queue *q, struct request *rq)
276{ 278{
277 elevator_t *e = q->elevator; 279 elevator_t *e = q->elevator;
278 280
@@ -285,13 +287,13 @@ static inline void __elv_rqhash_del(struct request *rq)
285 hlist_del_init(&rq->hash); 287 hlist_del_init(&rq->hash);
286} 288}
287 289
288static void elv_rqhash_del(request_queue_t *q, struct request *rq) 290static void elv_rqhash_del(struct request_queue *q, struct request *rq)
289{ 291{
290 if (ELV_ON_HASH(rq)) 292 if (ELV_ON_HASH(rq))
291 __elv_rqhash_del(rq); 293 __elv_rqhash_del(rq);
292} 294}
293 295
294static void elv_rqhash_add(request_queue_t *q, struct request *rq) 296static void elv_rqhash_add(struct request_queue *q, struct request *rq)
295{ 297{
296 elevator_t *e = q->elevator; 298 elevator_t *e = q->elevator;
297 299
@@ -299,13 +301,13 @@ static void elv_rqhash_add(request_queue_t *q, struct request *rq)
299 hlist_add_head(&rq->hash, &e->hash[ELV_HASH_FN(rq_hash_key(rq))]); 301 hlist_add_head(&rq->hash, &e->hash[ELV_HASH_FN(rq_hash_key(rq))]);
300} 302}
301 303
302static void elv_rqhash_reposition(request_queue_t *q, struct request *rq) 304static void elv_rqhash_reposition(struct request_queue *q, struct request *rq)
303{ 305{
304 __elv_rqhash_del(rq); 306 __elv_rqhash_del(rq);
305 elv_rqhash_add(q, rq); 307 elv_rqhash_add(q, rq);
306} 308}
307 309
308static struct request *elv_rqhash_find(request_queue_t *q, sector_t offset) 310static struct request *elv_rqhash_find(struct request_queue *q, sector_t offset)
309{ 311{
310 elevator_t *e = q->elevator; 312 elevator_t *e = q->elevator;
311 struct hlist_head *hash_list = &e->hash[ELV_HASH_FN(offset)]; 313 struct hlist_head *hash_list = &e->hash[ELV_HASH_FN(offset)];
@@ -391,7 +393,7 @@ EXPORT_SYMBOL(elv_rb_find);
391 * entry. rq is sort insted into the dispatch queue. To be used by 393 * entry. rq is sort insted into the dispatch queue. To be used by
392 * specific elevators. 394 * specific elevators.
393 */ 395 */
394void elv_dispatch_sort(request_queue_t *q, struct request *rq) 396void elv_dispatch_sort(struct request_queue *q, struct request *rq)
395{ 397{
396 sector_t boundary; 398 sector_t boundary;
397 struct list_head *entry; 399 struct list_head *entry;
@@ -449,7 +451,7 @@ void elv_dispatch_add_tail(struct request_queue *q, struct request *rq)
449 451
450EXPORT_SYMBOL(elv_dispatch_add_tail); 452EXPORT_SYMBOL(elv_dispatch_add_tail);
451 453
452int elv_merge(request_queue_t *q, struct request **req, struct bio *bio) 454int elv_merge(struct request_queue *q, struct request **req, struct bio *bio)
453{ 455{
454 elevator_t *e = q->elevator; 456 elevator_t *e = q->elevator;
455 struct request *__rq; 457 struct request *__rq;
@@ -481,7 +483,7 @@ int elv_merge(request_queue_t *q, struct request **req, struct bio *bio)
481 return ELEVATOR_NO_MERGE; 483 return ELEVATOR_NO_MERGE;
482} 484}
483 485
484void elv_merged_request(request_queue_t *q, struct request *rq, int type) 486void elv_merged_request(struct request_queue *q, struct request *rq, int type)
485{ 487{
486 elevator_t *e = q->elevator; 488 elevator_t *e = q->elevator;
487 489
@@ -494,7 +496,7 @@ void elv_merged_request(request_queue_t *q, struct request *rq, int type)
494 q->last_merge = rq; 496 q->last_merge = rq;
495} 497}
496 498
497void elv_merge_requests(request_queue_t *q, struct request *rq, 499void elv_merge_requests(struct request_queue *q, struct request *rq,
498 struct request *next) 500 struct request *next)
499{ 501{
500 elevator_t *e = q->elevator; 502 elevator_t *e = q->elevator;
@@ -509,7 +511,7 @@ void elv_merge_requests(request_queue_t *q, struct request *rq,
509 q->last_merge = rq; 511 q->last_merge = rq;
510} 512}
511 513
512void elv_requeue_request(request_queue_t *q, struct request *rq) 514void elv_requeue_request(struct request_queue *q, struct request *rq)
513{ 515{
514 /* 516 /*
515 * it already went through dequeue, we need to decrement the 517 * it already went through dequeue, we need to decrement the
@@ -526,7 +528,7 @@ void elv_requeue_request(request_queue_t *q, struct request *rq)
526 elv_insert(q, rq, ELEVATOR_INSERT_REQUEUE); 528 elv_insert(q, rq, ELEVATOR_INSERT_REQUEUE);
527} 529}
528 530
529static void elv_drain_elevator(request_queue_t *q) 531static void elv_drain_elevator(struct request_queue *q)
530{ 532{
531 static int printed; 533 static int printed;
532 while (q->elevator->ops->elevator_dispatch_fn(q, 1)) 534 while (q->elevator->ops->elevator_dispatch_fn(q, 1))
@@ -540,7 +542,7 @@ static void elv_drain_elevator(request_queue_t *q)
540 } 542 }
541} 543}
542 544
543void elv_insert(request_queue_t *q, struct request *rq, int where) 545void elv_insert(struct request_queue *q, struct request *rq, int where)
544{ 546{
545 struct list_head *pos; 547 struct list_head *pos;
546 unsigned ordseq; 548 unsigned ordseq;
@@ -638,7 +640,7 @@ void elv_insert(request_queue_t *q, struct request *rq, int where)
638 } 640 }
639} 641}
640 642
641void __elv_add_request(request_queue_t *q, struct request *rq, int where, 643void __elv_add_request(struct request_queue *q, struct request *rq, int where,
642 int plug) 644 int plug)
643{ 645{
644 if (q->ordcolor) 646 if (q->ordcolor)
@@ -676,7 +678,7 @@ void __elv_add_request(request_queue_t *q, struct request *rq, int where,
676 678
677EXPORT_SYMBOL(__elv_add_request); 679EXPORT_SYMBOL(__elv_add_request);
678 680
679void elv_add_request(request_queue_t *q, struct request *rq, int where, 681void elv_add_request(struct request_queue *q, struct request *rq, int where,
680 int plug) 682 int plug)
681{ 683{
682 unsigned long flags; 684 unsigned long flags;
@@ -688,7 +690,7 @@ void elv_add_request(request_queue_t *q, struct request *rq, int where,
688 690
689EXPORT_SYMBOL(elv_add_request); 691EXPORT_SYMBOL(elv_add_request);
690 692
691static inline struct request *__elv_next_request(request_queue_t *q) 693static inline struct request *__elv_next_request(struct request_queue *q)
692{ 694{
693 struct request *rq; 695 struct request *rq;
694 696
@@ -704,7 +706,7 @@ static inline struct request *__elv_next_request(request_queue_t *q)
704 } 706 }
705} 707}
706 708
707struct request *elv_next_request(request_queue_t *q) 709struct request *elv_next_request(struct request_queue *q)
708{ 710{
709 struct request *rq; 711 struct request *rq;
710 int ret; 712 int ret;
@@ -770,7 +772,7 @@ struct request *elv_next_request(request_queue_t *q)
770 772
771EXPORT_SYMBOL(elv_next_request); 773EXPORT_SYMBOL(elv_next_request);
772 774
773void elv_dequeue_request(request_queue_t *q, struct request *rq) 775void elv_dequeue_request(struct request_queue *q, struct request *rq)
774{ 776{
775 BUG_ON(list_empty(&rq->queuelist)); 777 BUG_ON(list_empty(&rq->queuelist));
776 BUG_ON(ELV_ON_HASH(rq)); 778 BUG_ON(ELV_ON_HASH(rq));
@@ -788,7 +790,7 @@ void elv_dequeue_request(request_queue_t *q, struct request *rq)
788 790
789EXPORT_SYMBOL(elv_dequeue_request); 791EXPORT_SYMBOL(elv_dequeue_request);
790 792
791int elv_queue_empty(request_queue_t *q) 793int elv_queue_empty(struct request_queue *q)
792{ 794{
793 elevator_t *e = q->elevator; 795 elevator_t *e = q->elevator;
794 796
@@ -803,7 +805,7 @@ int elv_queue_empty(request_queue_t *q)
803 805
804EXPORT_SYMBOL(elv_queue_empty); 806EXPORT_SYMBOL(elv_queue_empty);
805 807
806struct request *elv_latter_request(request_queue_t *q, struct request *rq) 808struct request *elv_latter_request(struct request_queue *q, struct request *rq)
807{ 809{
808 elevator_t *e = q->elevator; 810 elevator_t *e = q->elevator;
809 811
@@ -812,7 +814,7 @@ struct request *elv_latter_request(request_queue_t *q, struct request *rq)
812 return NULL; 814 return NULL;
813} 815}
814 816
815struct request *elv_former_request(request_queue_t *q, struct request *rq) 817struct request *elv_former_request(struct request_queue *q, struct request *rq)
816{ 818{
817 elevator_t *e = q->elevator; 819 elevator_t *e = q->elevator;
818 820
@@ -821,7 +823,7 @@ struct request *elv_former_request(request_queue_t *q, struct request *rq)
821 return NULL; 823 return NULL;
822} 824}
823 825
824int elv_set_request(request_queue_t *q, struct request *rq, gfp_t gfp_mask) 826int elv_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)
825{ 827{
826 elevator_t *e = q->elevator; 828 elevator_t *e = q->elevator;
827 829
@@ -832,7 +834,7 @@ int elv_set_request(request_queue_t *q, struct request *rq, gfp_t gfp_mask)
832 return 0; 834 return 0;
833} 835}
834 836
835void elv_put_request(request_queue_t *q, struct request *rq) 837void elv_put_request(struct request_queue *q, struct request *rq)
836{ 838{
837 elevator_t *e = q->elevator; 839 elevator_t *e = q->elevator;
838 840
@@ -840,7 +842,7 @@ void elv_put_request(request_queue_t *q, struct request *rq)
840 e->ops->elevator_put_req_fn(rq); 842 e->ops->elevator_put_req_fn(rq);
841} 843}
842 844
843int elv_may_queue(request_queue_t *q, int rw) 845int elv_may_queue(struct request_queue *q, int rw)
844{ 846{
845 elevator_t *e = q->elevator; 847 elevator_t *e = q->elevator;
846 848
@@ -850,7 +852,7 @@ int elv_may_queue(request_queue_t *q, int rw)
850 return ELV_MQUEUE_MAY; 852 return ELV_MQUEUE_MAY;
851} 853}
852 854
853void elv_completed_request(request_queue_t *q, struct request *rq) 855void elv_completed_request(struct request_queue *q, struct request *rq)
854{ 856{
855 elevator_t *e = q->elevator; 857 elevator_t *e = q->elevator;
856 858
@@ -1006,7 +1008,7 @@ EXPORT_SYMBOL_GPL(elv_unregister);
1006 * need for the new one. this way we have a chance of going back to the old 1008 * need for the new one. this way we have a chance of going back to the old
1007 * one, if the new one fails init for some reason. 1009 * one, if the new one fails init for some reason.
1008 */ 1010 */
1009static int elevator_switch(request_queue_t *q, struct elevator_type *new_e) 1011static int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
1010{ 1012{
1011 elevator_t *old_elevator, *e; 1013 elevator_t *old_elevator, *e;
1012 void *data; 1014 void *data;
@@ -1078,7 +1080,8 @@ fail_register:
1078 return 0; 1080 return 0;
1079} 1081}
1080 1082
1081ssize_t elv_iosched_store(request_queue_t *q, const char *name, size_t count) 1083ssize_t elv_iosched_store(struct request_queue *q, const char *name,
1084 size_t count)
1082{ 1085{
1083 char elevator_name[ELV_NAME_MAX]; 1086 char elevator_name[ELV_NAME_MAX];
1084 size_t len; 1087 size_t len;
@@ -1107,7 +1110,7 @@ ssize_t elv_iosched_store(request_queue_t *q, const char *name, size_t count)
1107 return count; 1110 return count;
1108} 1111}
1109 1112
1110ssize_t elv_iosched_show(request_queue_t *q, char *name) 1113ssize_t elv_iosched_show(struct request_queue *q, char *name)
1111{ 1114{
1112 elevator_t *e = q->elevator; 1115 elevator_t *e = q->elevator;
1113 struct elevator_type *elv = e->elevator_type; 1116 struct elevator_type *elv = e->elevator_type;
@@ -1127,7 +1130,8 @@ ssize_t elv_iosched_show(request_queue_t *q, char *name)
1127 return len; 1130 return len;
1128} 1131}
1129 1132
1130struct request *elv_rb_former_request(request_queue_t *q, struct request *rq) 1133struct request *elv_rb_former_request(struct request_queue *q,
1134 struct request *rq)
1131{ 1135{
1132 struct rb_node *rbprev = rb_prev(&rq->rb_node); 1136 struct rb_node *rbprev = rb_prev(&rq->rb_node);
1133 1137
@@ -1139,7 +1143,8 @@ struct request *elv_rb_former_request(request_queue_t *q, struct request *rq)
1139 1143
1140EXPORT_SYMBOL(elv_rb_former_request); 1144EXPORT_SYMBOL(elv_rb_former_request);
1141 1145
1142struct request *elv_rb_latter_request(request_queue_t *q, struct request *rq) 1146struct request *elv_rb_latter_request(struct request_queue *q,
1147 struct request *rq)
1143{ 1148{
1144 struct rb_node *rbnext = rb_next(&rq->rb_node); 1149 struct rb_node *rbnext = rb_next(&rq->rb_node);
1145 1150
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 66056ca5e631..8c2caff87cc3 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -40,7 +40,7 @@ static void blk_unplug_work(struct work_struct *work);
40static void blk_unplug_timeout(unsigned long data); 40static void blk_unplug_timeout(unsigned long data);
41static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io); 41static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io);
42static void init_request_from_bio(struct request *req, struct bio *bio); 42static void init_request_from_bio(struct request *req, struct bio *bio);
43static int __make_request(request_queue_t *q, struct bio *bio); 43static int __make_request(struct request_queue *q, struct bio *bio);
44static struct io_context *current_io_context(gfp_t gfp_flags, int node); 44static struct io_context *current_io_context(gfp_t gfp_flags, int node);
45 45
46/* 46/*
@@ -121,7 +121,7 @@ static void blk_queue_congestion_threshold(struct request_queue *q)
121struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev) 121struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev)
122{ 122{
123 struct backing_dev_info *ret = NULL; 123 struct backing_dev_info *ret = NULL;
124 request_queue_t *q = bdev_get_queue(bdev); 124 struct request_queue *q = bdev_get_queue(bdev);
125 125
126 if (q) 126 if (q)
127 ret = &q->backing_dev_info; 127 ret = &q->backing_dev_info;
@@ -140,7 +140,7 @@ EXPORT_SYMBOL(blk_get_backing_dev_info);
140 * cdb from the request data for instance. 140 * cdb from the request data for instance.
141 * 141 *
142 */ 142 */
143void blk_queue_prep_rq(request_queue_t *q, prep_rq_fn *pfn) 143void blk_queue_prep_rq(struct request_queue *q, prep_rq_fn *pfn)
144{ 144{
145 q->prep_rq_fn = pfn; 145 q->prep_rq_fn = pfn;
146} 146}
@@ -163,14 +163,14 @@ EXPORT_SYMBOL(blk_queue_prep_rq);
163 * no merge_bvec_fn is defined for a queue, and only the fixed limits are 163 * no merge_bvec_fn is defined for a queue, and only the fixed limits are
164 * honored. 164 * honored.
165 */ 165 */
166void blk_queue_merge_bvec(request_queue_t *q, merge_bvec_fn *mbfn) 166void blk_queue_merge_bvec(struct request_queue *q, merge_bvec_fn *mbfn)
167{ 167{
168 q->merge_bvec_fn = mbfn; 168 q->merge_bvec_fn = mbfn;
169} 169}
170 170
171EXPORT_SYMBOL(blk_queue_merge_bvec); 171EXPORT_SYMBOL(blk_queue_merge_bvec);
172 172
173void blk_queue_softirq_done(request_queue_t *q, softirq_done_fn *fn) 173void blk_queue_softirq_done(struct request_queue *q, softirq_done_fn *fn)
174{ 174{
175 q->softirq_done_fn = fn; 175 q->softirq_done_fn = fn;
176} 176}
@@ -199,7 +199,7 @@ EXPORT_SYMBOL(blk_queue_softirq_done);
199 * __bio_kmap_atomic() to get a temporary kernel mapping, or by calling 199 * __bio_kmap_atomic() to get a temporary kernel mapping, or by calling
200 * blk_queue_bounce() to create a buffer in normal memory. 200 * blk_queue_bounce() to create a buffer in normal memory.
201 **/ 201 **/
202void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn) 202void blk_queue_make_request(struct request_queue * q, make_request_fn * mfn)
203{ 203{
204 /* 204 /*
205 * set defaults 205 * set defaults
@@ -235,7 +235,7 @@ void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn)
235 235
236EXPORT_SYMBOL(blk_queue_make_request); 236EXPORT_SYMBOL(blk_queue_make_request);
237 237
238static void rq_init(request_queue_t *q, struct request *rq) 238static void rq_init(struct request_queue *q, struct request *rq)
239{ 239{
240 INIT_LIST_HEAD(&rq->queuelist); 240 INIT_LIST_HEAD(&rq->queuelist);
241 INIT_LIST_HEAD(&rq->donelist); 241 INIT_LIST_HEAD(&rq->donelist);
@@ -272,7 +272,7 @@ static void rq_init(request_queue_t *q, struct request *rq)
272 * feature should call this function and indicate so. 272 * feature should call this function and indicate so.
273 * 273 *
274 **/ 274 **/
275int blk_queue_ordered(request_queue_t *q, unsigned ordered, 275int blk_queue_ordered(struct request_queue *q, unsigned ordered,
276 prepare_flush_fn *prepare_flush_fn) 276 prepare_flush_fn *prepare_flush_fn)
277{ 277{
278 if (ordered & (QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH) && 278 if (ordered & (QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH) &&
@@ -311,7 +311,7 @@ EXPORT_SYMBOL(blk_queue_ordered);
311 * to the block layer by defining it through this call. 311 * to the block layer by defining it through this call.
312 * 312 *
313 **/ 313 **/
314void blk_queue_issue_flush_fn(request_queue_t *q, issue_flush_fn *iff) 314void blk_queue_issue_flush_fn(struct request_queue *q, issue_flush_fn *iff)
315{ 315{
316 q->issue_flush_fn = iff; 316 q->issue_flush_fn = iff;
317} 317}
@@ -321,7 +321,7 @@ EXPORT_SYMBOL(blk_queue_issue_flush_fn);
321/* 321/*
322 * Cache flushing for ordered writes handling 322 * Cache flushing for ordered writes handling
323 */ 323 */
324inline unsigned blk_ordered_cur_seq(request_queue_t *q) 324inline unsigned blk_ordered_cur_seq(struct request_queue *q)
325{ 325{
326 if (!q->ordseq) 326 if (!q->ordseq)
327 return 0; 327 return 0;
@@ -330,7 +330,7 @@ inline unsigned blk_ordered_cur_seq(request_queue_t *q)
330 330
331unsigned blk_ordered_req_seq(struct request *rq) 331unsigned blk_ordered_req_seq(struct request *rq)
332{ 332{
333 request_queue_t *q = rq->q; 333 struct request_queue *q = rq->q;
334 334
335 BUG_ON(q->ordseq == 0); 335 BUG_ON(q->ordseq == 0);
336 336
@@ -357,7 +357,7 @@ unsigned blk_ordered_req_seq(struct request *rq)
357 return QUEUE_ORDSEQ_DONE; 357 return QUEUE_ORDSEQ_DONE;
358} 358}
359 359
360void blk_ordered_complete_seq(request_queue_t *q, unsigned seq, int error) 360void blk_ordered_complete_seq(struct request_queue *q, unsigned seq, int error)
361{ 361{
362 struct request *rq; 362 struct request *rq;
363 int uptodate; 363 int uptodate;
@@ -401,7 +401,7 @@ static void post_flush_end_io(struct request *rq, int error)
401 blk_ordered_complete_seq(rq->q, QUEUE_ORDSEQ_POSTFLUSH, error); 401 blk_ordered_complete_seq(rq->q, QUEUE_ORDSEQ_POSTFLUSH, error);
402} 402}
403 403
404static void queue_flush(request_queue_t *q, unsigned which) 404static void queue_flush(struct request_queue *q, unsigned which)
405{ 405{
406 struct request *rq; 406 struct request *rq;
407 rq_end_io_fn *end_io; 407 rq_end_io_fn *end_io;
@@ -425,7 +425,7 @@ static void queue_flush(request_queue_t *q, unsigned which)
425 elv_insert(q, rq, ELEVATOR_INSERT_FRONT); 425 elv_insert(q, rq, ELEVATOR_INSERT_FRONT);
426} 426}
427 427
428static inline struct request *start_ordered(request_queue_t *q, 428static inline struct request *start_ordered(struct request_queue *q,
429 struct request *rq) 429 struct request *rq)
430{ 430{
431 q->bi_size = 0; 431 q->bi_size = 0;
@@ -476,7 +476,7 @@ static inline struct request *start_ordered(request_queue_t *q,
476 return rq; 476 return rq;
477} 477}
478 478
479int blk_do_ordered(request_queue_t *q, struct request **rqp) 479int blk_do_ordered(struct request_queue *q, struct request **rqp)
480{ 480{
481 struct request *rq = *rqp; 481 struct request *rq = *rqp;
482 int is_barrier = blk_fs_request(rq) && blk_barrier_rq(rq); 482 int is_barrier = blk_fs_request(rq) && blk_barrier_rq(rq);
@@ -527,7 +527,7 @@ int blk_do_ordered(request_queue_t *q, struct request **rqp)
527 527
528static int flush_dry_bio_endio(struct bio *bio, unsigned int bytes, int error) 528static int flush_dry_bio_endio(struct bio *bio, unsigned int bytes, int error)
529{ 529{
530 request_queue_t *q = bio->bi_private; 530 struct request_queue *q = bio->bi_private;
531 531
532 /* 532 /*
533 * This is dry run, restore bio_sector and size. We'll finish 533 * This is dry run, restore bio_sector and size. We'll finish
@@ -551,7 +551,7 @@ static int flush_dry_bio_endio(struct bio *bio, unsigned int bytes, int error)
551static int ordered_bio_endio(struct request *rq, struct bio *bio, 551static int ordered_bio_endio(struct request *rq, struct bio *bio,
552 unsigned int nbytes, int error) 552 unsigned int nbytes, int error)
553{ 553{
554 request_queue_t *q = rq->q; 554 struct request_queue *q = rq->q;
555 bio_end_io_t *endio; 555 bio_end_io_t *endio;
556 void *private; 556 void *private;
557 557
@@ -588,7 +588,7 @@ static int ordered_bio_endio(struct request *rq, struct bio *bio,
588 * blk_queue_bounce_limit to have lower memory pages allocated as bounce 588 * blk_queue_bounce_limit to have lower memory pages allocated as bounce
589 * buffers for doing I/O to pages residing above @page. 589 * buffers for doing I/O to pages residing above @page.
590 **/ 590 **/
591void blk_queue_bounce_limit(request_queue_t *q, u64 dma_addr) 591void blk_queue_bounce_limit(struct request_queue *q, u64 dma_addr)
592{ 592{
593 unsigned long bounce_pfn = dma_addr >> PAGE_SHIFT; 593 unsigned long bounce_pfn = dma_addr >> PAGE_SHIFT;
594 int dma = 0; 594 int dma = 0;
@@ -624,7 +624,7 @@ EXPORT_SYMBOL(blk_queue_bounce_limit);
624 * Enables a low level driver to set an upper limit on the size of 624 * Enables a low level driver to set an upper limit on the size of
625 * received requests. 625 * received requests.
626 **/ 626 **/
627void blk_queue_max_sectors(request_queue_t *q, unsigned int max_sectors) 627void blk_queue_max_sectors(struct request_queue *q, unsigned int max_sectors)
628{ 628{
629 if ((max_sectors << 9) < PAGE_CACHE_SIZE) { 629 if ((max_sectors << 9) < PAGE_CACHE_SIZE) {
630 max_sectors = 1 << (PAGE_CACHE_SHIFT - 9); 630 max_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
@@ -651,7 +651,8 @@ EXPORT_SYMBOL(blk_queue_max_sectors);
651 * physical data segments in a request. This would be the largest sized 651 * physical data segments in a request. This would be the largest sized
652 * scatter list the driver could handle. 652 * scatter list the driver could handle.
653 **/ 653 **/
654void blk_queue_max_phys_segments(request_queue_t *q, unsigned short max_segments) 654void blk_queue_max_phys_segments(struct request_queue *q,
655 unsigned short max_segments)
655{ 656{
656 if (!max_segments) { 657 if (!max_segments) {
657 max_segments = 1; 658 max_segments = 1;
@@ -674,7 +675,8 @@ EXPORT_SYMBOL(blk_queue_max_phys_segments);
674 * address/length pairs the host adapter can actually give as once 675 * address/length pairs the host adapter can actually give as once
675 * to the device. 676 * to the device.
676 **/ 677 **/
677void blk_queue_max_hw_segments(request_queue_t *q, unsigned short max_segments) 678void blk_queue_max_hw_segments(struct request_queue *q,
679 unsigned short max_segments)
678{ 680{
679 if (!max_segments) { 681 if (!max_segments) {
680 max_segments = 1; 682 max_segments = 1;
@@ -695,7 +697,7 @@ EXPORT_SYMBOL(blk_queue_max_hw_segments);
695 * Enables a low level driver to set an upper limit on the size of a 697 * Enables a low level driver to set an upper limit on the size of a
696 * coalesced segment 698 * coalesced segment
697 **/ 699 **/
698void blk_queue_max_segment_size(request_queue_t *q, unsigned int max_size) 700void blk_queue_max_segment_size(struct request_queue *q, unsigned int max_size)
699{ 701{
700 if (max_size < PAGE_CACHE_SIZE) { 702 if (max_size < PAGE_CACHE_SIZE) {
701 max_size = PAGE_CACHE_SIZE; 703 max_size = PAGE_CACHE_SIZE;
@@ -718,7 +720,7 @@ EXPORT_SYMBOL(blk_queue_max_segment_size);
718 * even internal read-modify-write operations). Usually the default 720 * even internal read-modify-write operations). Usually the default
719 * of 512 covers most hardware. 721 * of 512 covers most hardware.
720 **/ 722 **/
721void blk_queue_hardsect_size(request_queue_t *q, unsigned short size) 723void blk_queue_hardsect_size(struct request_queue *q, unsigned short size)
722{ 724{
723 q->hardsect_size = size; 725 q->hardsect_size = size;
724} 726}
@@ -735,7 +737,7 @@ EXPORT_SYMBOL(blk_queue_hardsect_size);
735 * @t: the stacking driver (top) 737 * @t: the stacking driver (top)
736 * @b: the underlying device (bottom) 738 * @b: the underlying device (bottom)
737 **/ 739 **/
738void blk_queue_stack_limits(request_queue_t *t, request_queue_t *b) 740void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)
739{ 741{
740 /* zero is "infinity" */ 742 /* zero is "infinity" */
741 t->max_sectors = min_not_zero(t->max_sectors,b->max_sectors); 743 t->max_sectors = min_not_zero(t->max_sectors,b->max_sectors);
@@ -756,7 +758,7 @@ EXPORT_SYMBOL(blk_queue_stack_limits);
756 * @q: the request queue for the device 758 * @q: the request queue for the device
757 * @mask: the memory boundary mask 759 * @mask: the memory boundary mask
758 **/ 760 **/
759void blk_queue_segment_boundary(request_queue_t *q, unsigned long mask) 761void blk_queue_segment_boundary(struct request_queue *q, unsigned long mask)
760{ 762{
761 if (mask < PAGE_CACHE_SIZE - 1) { 763 if (mask < PAGE_CACHE_SIZE - 1) {
762 mask = PAGE_CACHE_SIZE - 1; 764 mask = PAGE_CACHE_SIZE - 1;
@@ -778,7 +780,7 @@ EXPORT_SYMBOL(blk_queue_segment_boundary);
778 * this is used when buiding direct io requests for the queue. 780 * this is used when buiding direct io requests for the queue.
779 * 781 *
780 **/ 782 **/
781void blk_queue_dma_alignment(request_queue_t *q, int mask) 783void blk_queue_dma_alignment(struct request_queue *q, int mask)
782{ 784{
783 q->dma_alignment = mask; 785 q->dma_alignment = mask;
784} 786}
@@ -796,7 +798,7 @@ EXPORT_SYMBOL(blk_queue_dma_alignment);
796 * 798 *
797 * no locks need be held. 799 * no locks need be held.
798 **/ 800 **/
799struct request *blk_queue_find_tag(request_queue_t *q, int tag) 801struct request *blk_queue_find_tag(struct request_queue *q, int tag)
800{ 802{
801 return blk_map_queue_find_tag(q->queue_tags, tag); 803 return blk_map_queue_find_tag(q->queue_tags, tag);
802} 804}
@@ -840,7 +842,7 @@ static int __blk_free_tags(struct blk_queue_tag *bqt)
840 * blk_cleanup_queue() will take care of calling this function, if tagging 842 * blk_cleanup_queue() will take care of calling this function, if tagging
841 * has been used. So there's no need to call this directly. 843 * has been used. So there's no need to call this directly.
842 **/ 844 **/
843static void __blk_queue_free_tags(request_queue_t *q) 845static void __blk_queue_free_tags(struct request_queue *q)
844{ 846{
845 struct blk_queue_tag *bqt = q->queue_tags; 847 struct blk_queue_tag *bqt = q->queue_tags;
846 848
@@ -877,7 +879,7 @@ EXPORT_SYMBOL(blk_free_tags);
877 * This is used to disabled tagged queuing to a device, yet leave 879 * This is used to disabled tagged queuing to a device, yet leave
878 * queue in function. 880 * queue in function.
879 **/ 881 **/
880void blk_queue_free_tags(request_queue_t *q) 882void blk_queue_free_tags(struct request_queue *q)
881{ 883{
882 clear_bit(QUEUE_FLAG_QUEUED, &q->queue_flags); 884 clear_bit(QUEUE_FLAG_QUEUED, &q->queue_flags);
883} 885}
@@ -885,7 +887,7 @@ void blk_queue_free_tags(request_queue_t *q)
885EXPORT_SYMBOL(blk_queue_free_tags); 887EXPORT_SYMBOL(blk_queue_free_tags);
886 888
887static int 889static int
888init_tag_map(request_queue_t *q, struct blk_queue_tag *tags, int depth) 890init_tag_map(struct request_queue *q, struct blk_queue_tag *tags, int depth)
889{ 891{
890 struct request **tag_index; 892 struct request **tag_index;
891 unsigned long *tag_map; 893 unsigned long *tag_map;
@@ -955,7 +957,7 @@ EXPORT_SYMBOL(blk_init_tags);
955 * @depth: the maximum queue depth supported 957 * @depth: the maximum queue depth supported
956 * @tags: the tag to use 958 * @tags: the tag to use
957 **/ 959 **/
958int blk_queue_init_tags(request_queue_t *q, int depth, 960int blk_queue_init_tags(struct request_queue *q, int depth,
959 struct blk_queue_tag *tags) 961 struct blk_queue_tag *tags)
960{ 962{
961 int rc; 963 int rc;
@@ -996,7 +998,7 @@ EXPORT_SYMBOL(blk_queue_init_tags);
996 * Notes: 998 * Notes:
997 * Must be called with the queue lock held. 999 * Must be called with the queue lock held.
998 **/ 1000 **/
999int blk_queue_resize_tags(request_queue_t *q, int new_depth) 1001int blk_queue_resize_tags(struct request_queue *q, int new_depth)
1000{ 1002{
1001 struct blk_queue_tag *bqt = q->queue_tags; 1003 struct blk_queue_tag *bqt = q->queue_tags;
1002 struct request **tag_index; 1004 struct request **tag_index;
@@ -1059,7 +1061,7 @@ EXPORT_SYMBOL(blk_queue_resize_tags);
1059 * Notes: 1061 * Notes:
1060 * queue lock must be held. 1062 * queue lock must be held.
1061 **/ 1063 **/
1062void blk_queue_end_tag(request_queue_t *q, struct request *rq) 1064void blk_queue_end_tag(struct request_queue *q, struct request *rq)
1063{ 1065{
1064 struct blk_queue_tag *bqt = q->queue_tags; 1066 struct blk_queue_tag *bqt = q->queue_tags;
1065 int tag = rq->tag; 1067 int tag = rq->tag;
@@ -1111,7 +1113,7 @@ EXPORT_SYMBOL(blk_queue_end_tag);
1111 * Notes: 1113 * Notes:
1112 * queue lock must be held. 1114 * queue lock must be held.
1113 **/ 1115 **/
1114int blk_queue_start_tag(request_queue_t *q, struct request *rq) 1116int blk_queue_start_tag(struct request_queue *q, struct request *rq)
1115{ 1117{
1116 struct blk_queue_tag *bqt = q->queue_tags; 1118 struct blk_queue_tag *bqt = q->queue_tags;
1117 int tag; 1119 int tag;
@@ -1158,7 +1160,7 @@ EXPORT_SYMBOL(blk_queue_start_tag);
1158 * Notes: 1160 * Notes:
1159 * queue lock must be held. 1161 * queue lock must be held.
1160 **/ 1162 **/
1161void blk_queue_invalidate_tags(request_queue_t *q) 1163void blk_queue_invalidate_tags(struct request_queue *q)
1162{ 1164{
1163 struct blk_queue_tag *bqt = q->queue_tags; 1165 struct blk_queue_tag *bqt = q->queue_tags;
1164 struct list_head *tmp, *n; 1166 struct list_head *tmp, *n;
@@ -1205,7 +1207,7 @@ void blk_dump_rq_flags(struct request *rq, char *msg)
1205 1207
1206EXPORT_SYMBOL(blk_dump_rq_flags); 1208EXPORT_SYMBOL(blk_dump_rq_flags);
1207 1209
1208void blk_recount_segments(request_queue_t *q, struct bio *bio) 1210void blk_recount_segments(struct request_queue *q, struct bio *bio)
1209{ 1211{
1210 struct bio_vec *bv, *bvprv = NULL; 1212 struct bio_vec *bv, *bvprv = NULL;
1211 int i, nr_phys_segs, nr_hw_segs, seg_size, hw_seg_size, cluster; 1213 int i, nr_phys_segs, nr_hw_segs, seg_size, hw_seg_size, cluster;
@@ -1267,7 +1269,7 @@ new_hw_segment:
1267} 1269}
1268EXPORT_SYMBOL(blk_recount_segments); 1270EXPORT_SYMBOL(blk_recount_segments);
1269 1271
1270static int blk_phys_contig_segment(request_queue_t *q, struct bio *bio, 1272static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
1271 struct bio *nxt) 1273 struct bio *nxt)
1272{ 1274{
1273 if (!(q->queue_flags & (1 << QUEUE_FLAG_CLUSTER))) 1275 if (!(q->queue_flags & (1 << QUEUE_FLAG_CLUSTER)))
@@ -1288,7 +1290,7 @@ static int blk_phys_contig_segment(request_queue_t *q, struct bio *bio,
1288 return 0; 1290 return 0;
1289} 1291}
1290 1292
1291static int blk_hw_contig_segment(request_queue_t *q, struct bio *bio, 1293static int blk_hw_contig_segment(struct request_queue *q, struct bio *bio,
1292 struct bio *nxt) 1294 struct bio *nxt)
1293{ 1295{
1294 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID))) 1296 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID)))
@@ -1308,7 +1310,8 @@ static int blk_hw_contig_segment(request_queue_t *q, struct bio *bio,
1308 * map a request to scatterlist, return number of sg entries setup. Caller 1310 * map a request to scatterlist, return number of sg entries setup. Caller
1309 * must make sure sg can hold rq->nr_phys_segments entries 1311 * must make sure sg can hold rq->nr_phys_segments entries
1310 */ 1312 */
1311int blk_rq_map_sg(request_queue_t *q, struct request *rq, struct scatterlist *sg) 1313int blk_rq_map_sg(struct request_queue *q, struct request *rq,
1314 struct scatterlist *sg)
1312{ 1315{
1313 struct bio_vec *bvec, *bvprv; 1316 struct bio_vec *bvec, *bvprv;
1314 struct bio *bio; 1317 struct bio *bio;
@@ -1361,7 +1364,7 @@ EXPORT_SYMBOL(blk_rq_map_sg);
1361 * specific ones if so desired 1364 * specific ones if so desired
1362 */ 1365 */
1363 1366
1364static inline int ll_new_mergeable(request_queue_t *q, 1367static inline int ll_new_mergeable(struct request_queue *q,
1365 struct request *req, 1368 struct request *req,
1366 struct bio *bio) 1369 struct bio *bio)
1367{ 1370{
@@ -1382,7 +1385,7 @@ static inline int ll_new_mergeable(request_queue_t *q,
1382 return 1; 1385 return 1;
1383} 1386}
1384 1387
1385static inline int ll_new_hw_segment(request_queue_t *q, 1388static inline int ll_new_hw_segment(struct request_queue *q,
1386 struct request *req, 1389 struct request *req,
1387 struct bio *bio) 1390 struct bio *bio)
1388{ 1391{
@@ -1406,7 +1409,7 @@ static inline int ll_new_hw_segment(request_queue_t *q,
1406 return 1; 1409 return 1;
1407} 1410}
1408 1411
1409int ll_back_merge_fn(request_queue_t *q, struct request *req, struct bio *bio) 1412int ll_back_merge_fn(struct request_queue *q, struct request *req, struct bio *bio)
1410{ 1413{
1411 unsigned short max_sectors; 1414 unsigned short max_sectors;
1412 int len; 1415 int len;
@@ -1444,7 +1447,7 @@ int ll_back_merge_fn(request_queue_t *q, struct request *req, struct bio *bio)
1444} 1447}
1445EXPORT_SYMBOL(ll_back_merge_fn); 1448EXPORT_SYMBOL(ll_back_merge_fn);
1446 1449
1447static int ll_front_merge_fn(request_queue_t *q, struct request *req, 1450static int ll_front_merge_fn(struct request_queue *q, struct request *req,
1448 struct bio *bio) 1451 struct bio *bio)
1449{ 1452{
1450 unsigned short max_sectors; 1453 unsigned short max_sectors;
@@ -1483,7 +1486,7 @@ static int ll_front_merge_fn(request_queue_t *q, struct request *req,
1483 return ll_new_hw_segment(q, req, bio); 1486 return ll_new_hw_segment(q, req, bio);
1484} 1487}
1485 1488
1486static int ll_merge_requests_fn(request_queue_t *q, struct request *req, 1489static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
1487 struct request *next) 1490 struct request *next)
1488{ 1491{
1489 int total_phys_segments; 1492 int total_phys_segments;
@@ -1539,7 +1542,7 @@ static int ll_merge_requests_fn(request_queue_t *q, struct request *req,
1539 * This is called with interrupts off and no requests on the queue and 1542 * This is called with interrupts off and no requests on the queue and
1540 * with the queue lock held. 1543 * with the queue lock held.
1541 */ 1544 */
1542void blk_plug_device(request_queue_t *q) 1545void blk_plug_device(struct request_queue *q)
1543{ 1546{
1544 WARN_ON(!irqs_disabled()); 1547 WARN_ON(!irqs_disabled());
1545 1548
@@ -1562,7 +1565,7 @@ EXPORT_SYMBOL(blk_plug_device);
1562 * remove the queue from the plugged list, if present. called with 1565 * remove the queue from the plugged list, if present. called with
1563 * queue lock held and interrupts disabled. 1566 * queue lock held and interrupts disabled.
1564 */ 1567 */
1565int blk_remove_plug(request_queue_t *q) 1568int blk_remove_plug(struct request_queue *q)
1566{ 1569{
1567 WARN_ON(!irqs_disabled()); 1570 WARN_ON(!irqs_disabled());
1568 1571
@@ -1578,7 +1581,7 @@ EXPORT_SYMBOL(blk_remove_plug);
1578/* 1581/*
1579 * remove the plug and let it rip.. 1582 * remove the plug and let it rip..
1580 */ 1583 */
1581void __generic_unplug_device(request_queue_t *q) 1584void __generic_unplug_device(struct request_queue *q)
1582{ 1585{
1583 if (unlikely(blk_queue_stopped(q))) 1586 if (unlikely(blk_queue_stopped(q)))
1584 return; 1587 return;
@@ -1592,7 +1595,7 @@ EXPORT_SYMBOL(__generic_unplug_device);
1592 1595
1593/** 1596/**
1594 * generic_unplug_device - fire a request queue 1597 * generic_unplug_device - fire a request queue
1595 * @q: The &request_queue_t in question 1598 * @q: The &struct request_queue in question
1596 * 1599 *
1597 * Description: 1600 * Description:
1598 * Linux uses plugging to build bigger requests queues before letting 1601 * Linux uses plugging to build bigger requests queues before letting
@@ -1601,7 +1604,7 @@ EXPORT_SYMBOL(__generic_unplug_device);
1601 * gets unplugged, the request_fn defined for the queue is invoked and 1604 * gets unplugged, the request_fn defined for the queue is invoked and
1602 * transfers started. 1605 * transfers started.
1603 **/ 1606 **/
1604void generic_unplug_device(request_queue_t *q) 1607void generic_unplug_device(struct request_queue *q)
1605{ 1608{
1606 spin_lock_irq(q->queue_lock); 1609 spin_lock_irq(q->queue_lock);
1607 __generic_unplug_device(q); 1610 __generic_unplug_device(q);
@@ -1612,7 +1615,7 @@ EXPORT_SYMBOL(generic_unplug_device);
1612static void blk_backing_dev_unplug(struct backing_dev_info *bdi, 1615static void blk_backing_dev_unplug(struct backing_dev_info *bdi,
1613 struct page *page) 1616 struct page *page)
1614{ 1617{
1615 request_queue_t *q = bdi->unplug_io_data; 1618 struct request_queue *q = bdi->unplug_io_data;
1616 1619
1617 /* 1620 /*
1618 * devices don't necessarily have an ->unplug_fn defined 1621 * devices don't necessarily have an ->unplug_fn defined
@@ -1627,7 +1630,8 @@ static void blk_backing_dev_unplug(struct backing_dev_info *bdi,
1627 1630
1628static void blk_unplug_work(struct work_struct *work) 1631static void blk_unplug_work(struct work_struct *work)
1629{ 1632{
1630 request_queue_t *q = container_of(work, request_queue_t, unplug_work); 1633 struct request_queue *q =
1634 container_of(work, struct request_queue, unplug_work);
1631 1635
1632 blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_IO, NULL, 1636 blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_IO, NULL,
1633 q->rq.count[READ] + q->rq.count[WRITE]); 1637 q->rq.count[READ] + q->rq.count[WRITE]);
@@ -1637,7 +1641,7 @@ static void blk_unplug_work(struct work_struct *work)
1637 1641
1638static void blk_unplug_timeout(unsigned long data) 1642static void blk_unplug_timeout(unsigned long data)
1639{ 1643{
1640 request_queue_t *q = (request_queue_t *)data; 1644 struct request_queue *q = (struct request_queue *)data;
1641 1645
1642 blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_TIMER, NULL, 1646 blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_TIMER, NULL,
1643 q->rq.count[READ] + q->rq.count[WRITE]); 1647 q->rq.count[READ] + q->rq.count[WRITE]);
@@ -1647,14 +1651,14 @@ static void blk_unplug_timeout(unsigned long data)
1647 1651
1648/** 1652/**
1649 * blk_start_queue - restart a previously stopped queue 1653 * blk_start_queue - restart a previously stopped queue
1650 * @q: The &request_queue_t in question 1654 * @q: The &struct request_queue in question
1651 * 1655 *
1652 * Description: 1656 * Description:
1653 * blk_start_queue() will clear the stop flag on the queue, and call 1657 * blk_start_queue() will clear the stop flag on the queue, and call
1654 * the request_fn for the queue if it was in a stopped state when 1658 * the request_fn for the queue if it was in a stopped state when
1655 * entered. Also see blk_stop_queue(). Queue lock must be held. 1659 * entered. Also see blk_stop_queue(). Queue lock must be held.
1656 **/ 1660 **/
1657void blk_start_queue(request_queue_t *q) 1661void blk_start_queue(struct request_queue *q)
1658{ 1662{
1659 WARN_ON(!irqs_disabled()); 1663 WARN_ON(!irqs_disabled());
1660 1664
@@ -1677,7 +1681,7 @@ EXPORT_SYMBOL(blk_start_queue);
1677 1681
1678/** 1682/**
1679 * blk_stop_queue - stop a queue 1683 * blk_stop_queue - stop a queue
1680 * @q: The &request_queue_t in question 1684 * @q: The &struct request_queue in question
1681 * 1685 *
1682 * Description: 1686 * Description:
1683 * The Linux block layer assumes that a block driver will consume all 1687 * The Linux block layer assumes that a block driver will consume all
@@ -1689,7 +1693,7 @@ EXPORT_SYMBOL(blk_start_queue);
1689 * the driver has signalled it's ready to go again. This happens by calling 1693 * the driver has signalled it's ready to go again. This happens by calling
1690 * blk_start_queue() to restart queue operations. Queue lock must be held. 1694 * blk_start_queue() to restart queue operations. Queue lock must be held.
1691 **/ 1695 **/
1692void blk_stop_queue(request_queue_t *q) 1696void blk_stop_queue(struct request_queue *q)
1693{ 1697{
1694 blk_remove_plug(q); 1698 blk_remove_plug(q);
1695 set_bit(QUEUE_FLAG_STOPPED, &q->queue_flags); 1699 set_bit(QUEUE_FLAG_STOPPED, &q->queue_flags);
@@ -1746,7 +1750,7 @@ void blk_run_queue(struct request_queue *q)
1746EXPORT_SYMBOL(blk_run_queue); 1750EXPORT_SYMBOL(blk_run_queue);
1747 1751
1748/** 1752/**
1749 * blk_cleanup_queue: - release a &request_queue_t when it is no longer needed 1753 * blk_cleanup_queue: - release a &struct request_queue when it is no longer needed
1750 * @kobj: the kobj belonging of the request queue to be released 1754 * @kobj: the kobj belonging of the request queue to be released
1751 * 1755 *
1752 * Description: 1756 * Description:
@@ -1762,7 +1766,8 @@ EXPORT_SYMBOL(blk_run_queue);
1762 **/ 1766 **/
1763static void blk_release_queue(struct kobject *kobj) 1767static void blk_release_queue(struct kobject *kobj)
1764{ 1768{
1765 request_queue_t *q = container_of(kobj, struct request_queue, kobj); 1769 struct request_queue *q =
1770 container_of(kobj, struct request_queue, kobj);
1766 struct request_list *rl = &q->rq; 1771 struct request_list *rl = &q->rq;
1767 1772
1768 blk_sync_queue(q); 1773 blk_sync_queue(q);
@@ -1778,13 +1783,13 @@ static void blk_release_queue(struct kobject *kobj)
1778 kmem_cache_free(requestq_cachep, q); 1783 kmem_cache_free(requestq_cachep, q);
1779} 1784}
1780 1785
1781void blk_put_queue(request_queue_t *q) 1786void blk_put_queue(struct request_queue *q)
1782{ 1787{
1783 kobject_put(&q->kobj); 1788 kobject_put(&q->kobj);
1784} 1789}
1785EXPORT_SYMBOL(blk_put_queue); 1790EXPORT_SYMBOL(blk_put_queue);
1786 1791
1787void blk_cleanup_queue(request_queue_t * q) 1792void blk_cleanup_queue(struct request_queue * q)
1788{ 1793{
1789 mutex_lock(&q->sysfs_lock); 1794 mutex_lock(&q->sysfs_lock);
1790 set_bit(QUEUE_FLAG_DEAD, &q->queue_flags); 1795 set_bit(QUEUE_FLAG_DEAD, &q->queue_flags);
@@ -1798,7 +1803,7 @@ void blk_cleanup_queue(request_queue_t * q)
1798 1803
1799EXPORT_SYMBOL(blk_cleanup_queue); 1804EXPORT_SYMBOL(blk_cleanup_queue);
1800 1805
1801static int blk_init_free_list(request_queue_t *q) 1806static int blk_init_free_list(struct request_queue *q)
1802{ 1807{
1803 struct request_list *rl = &q->rq; 1808 struct request_list *rl = &q->rq;
1804 1809
@@ -1817,7 +1822,7 @@ static int blk_init_free_list(request_queue_t *q)
1817 return 0; 1822 return 0;
1818} 1823}
1819 1824
1820request_queue_t *blk_alloc_queue(gfp_t gfp_mask) 1825struct request_queue *blk_alloc_queue(gfp_t gfp_mask)
1821{ 1826{
1822 return blk_alloc_queue_node(gfp_mask, -1); 1827 return blk_alloc_queue_node(gfp_mask, -1);
1823} 1828}
@@ -1825,9 +1830,9 @@ EXPORT_SYMBOL(blk_alloc_queue);
1825 1830
1826static struct kobj_type queue_ktype; 1831static struct kobj_type queue_ktype;
1827 1832
1828request_queue_t *blk_alloc_queue_node(gfp_t gfp_mask, int node_id) 1833struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
1829{ 1834{
1830 request_queue_t *q; 1835 struct request_queue *q;
1831 1836
1832 q = kmem_cache_alloc_node(requestq_cachep, 1837 q = kmem_cache_alloc_node(requestq_cachep,
1833 gfp_mask | __GFP_ZERO, node_id); 1838 gfp_mask | __GFP_ZERO, node_id);
@@ -1882,16 +1887,16 @@ EXPORT_SYMBOL(blk_alloc_queue_node);
1882 * when the block device is deactivated (such as at module unload). 1887 * when the block device is deactivated (such as at module unload).
1883 **/ 1888 **/
1884 1889
1885request_queue_t *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock) 1890struct request_queue *blk_init_queue(request_fn_proc *rfn, spinlock_t *lock)
1886{ 1891{
1887 return blk_init_queue_node(rfn, lock, -1); 1892 return blk_init_queue_node(rfn, lock, -1);
1888} 1893}
1889EXPORT_SYMBOL(blk_init_queue); 1894EXPORT_SYMBOL(blk_init_queue);
1890 1895
1891request_queue_t * 1896struct request_queue *
1892blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id) 1897blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
1893{ 1898{
1894 request_queue_t *q = blk_alloc_queue_node(GFP_KERNEL, node_id); 1899 struct request_queue *q = blk_alloc_queue_node(GFP_KERNEL, node_id);
1895 1900
1896 if (!q) 1901 if (!q)
1897 return NULL; 1902 return NULL;
@@ -1940,7 +1945,7 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
1940} 1945}
1941EXPORT_SYMBOL(blk_init_queue_node); 1946EXPORT_SYMBOL(blk_init_queue_node);
1942 1947
1943int blk_get_queue(request_queue_t *q) 1948int blk_get_queue(struct request_queue *q)
1944{ 1949{
1945 if (likely(!test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) { 1950 if (likely(!test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
1946 kobject_get(&q->kobj); 1951 kobject_get(&q->kobj);
@@ -1952,7 +1957,7 @@ int blk_get_queue(request_queue_t *q)
1952 1957
1953EXPORT_SYMBOL(blk_get_queue); 1958EXPORT_SYMBOL(blk_get_queue);
1954 1959
1955static inline void blk_free_request(request_queue_t *q, struct request *rq) 1960static inline void blk_free_request(struct request_queue *q, struct request *rq)
1956{ 1961{
1957 if (rq->cmd_flags & REQ_ELVPRIV) 1962 if (rq->cmd_flags & REQ_ELVPRIV)
1958 elv_put_request(q, rq); 1963 elv_put_request(q, rq);
@@ -1960,7 +1965,7 @@ static inline void blk_free_request(request_queue_t *q, struct request *rq)
1960} 1965}
1961 1966
1962static struct request * 1967static struct request *
1963blk_alloc_request(request_queue_t *q, int rw, int priv, gfp_t gfp_mask) 1968blk_alloc_request(struct request_queue *q, int rw, int priv, gfp_t gfp_mask)
1964{ 1969{
1965 struct request *rq = mempool_alloc(q->rq.rq_pool, gfp_mask); 1970 struct request *rq = mempool_alloc(q->rq.rq_pool, gfp_mask);
1966 1971
@@ -1988,7 +1993,7 @@ blk_alloc_request(request_queue_t *q, int rw, int priv, gfp_t gfp_mask)
1988 * ioc_batching returns true if the ioc is a valid batching request and 1993 * ioc_batching returns true if the ioc is a valid batching request and
1989 * should be given priority access to a request. 1994 * should be given priority access to a request.
1990 */ 1995 */
1991static inline int ioc_batching(request_queue_t *q, struct io_context *ioc) 1996static inline int ioc_batching(struct request_queue *q, struct io_context *ioc)
1992{ 1997{
1993 if (!ioc) 1998 if (!ioc)
1994 return 0; 1999 return 0;
@@ -2009,7 +2014,7 @@ static inline int ioc_batching(request_queue_t *q, struct io_context *ioc)
2009 * is the behaviour we want though - once it gets a wakeup it should be given 2014 * is the behaviour we want though - once it gets a wakeup it should be given
2010 * a nice run. 2015 * a nice run.
2011 */ 2016 */
2012static void ioc_set_batching(request_queue_t *q, struct io_context *ioc) 2017static void ioc_set_batching(struct request_queue *q, struct io_context *ioc)
2013{ 2018{
2014 if (!ioc || ioc_batching(q, ioc)) 2019 if (!ioc || ioc_batching(q, ioc))
2015 return; 2020 return;
@@ -2018,7 +2023,7 @@ static void ioc_set_batching(request_queue_t *q, struct io_context *ioc)
2018 ioc->last_waited = jiffies; 2023 ioc->last_waited = jiffies;
2019} 2024}
2020 2025
2021static void __freed_request(request_queue_t *q, int rw) 2026static void __freed_request(struct request_queue *q, int rw)
2022{ 2027{
2023 struct request_list *rl = &q->rq; 2028 struct request_list *rl = &q->rq;
2024 2029
@@ -2037,7 +2042,7 @@ static void __freed_request(request_queue_t *q, int rw)
2037 * A request has just been released. Account for it, update the full and 2042 * A request has just been released. Account for it, update the full and
2038 * congestion status, wake up any waiters. Called under q->queue_lock. 2043 * congestion status, wake up any waiters. Called under q->queue_lock.
2039 */ 2044 */
2040static void freed_request(request_queue_t *q, int rw, int priv) 2045static void freed_request(struct request_queue *q, int rw, int priv)
2041{ 2046{
2042 struct request_list *rl = &q->rq; 2047 struct request_list *rl = &q->rq;
2043 2048
@@ -2057,7 +2062,7 @@ static void freed_request(request_queue_t *q, int rw, int priv)
2057 * Returns NULL on failure, with queue_lock held. 2062 * Returns NULL on failure, with queue_lock held.
2058 * Returns !NULL on success, with queue_lock *not held*. 2063 * Returns !NULL on success, with queue_lock *not held*.
2059 */ 2064 */
2060static struct request *get_request(request_queue_t *q, int rw_flags, 2065static struct request *get_request(struct request_queue *q, int rw_flags,
2061 struct bio *bio, gfp_t gfp_mask) 2066 struct bio *bio, gfp_t gfp_mask)
2062{ 2067{
2063 struct request *rq = NULL; 2068 struct request *rq = NULL;
@@ -2162,7 +2167,7 @@ out:
2162 * 2167 *
2163 * Called with q->queue_lock held, and returns with it unlocked. 2168 * Called with q->queue_lock held, and returns with it unlocked.
2164 */ 2169 */
2165static struct request *get_request_wait(request_queue_t *q, int rw_flags, 2170static struct request *get_request_wait(struct request_queue *q, int rw_flags,
2166 struct bio *bio) 2171 struct bio *bio)
2167{ 2172{
2168 const int rw = rw_flags & 0x01; 2173 const int rw = rw_flags & 0x01;
@@ -2204,7 +2209,7 @@ static struct request *get_request_wait(request_queue_t *q, int rw_flags,
2204 return rq; 2209 return rq;
2205} 2210}
2206 2211
2207struct request *blk_get_request(request_queue_t *q, int rw, gfp_t gfp_mask) 2212struct request *blk_get_request(struct request_queue *q, int rw, gfp_t gfp_mask)
2208{ 2213{
2209 struct request *rq; 2214 struct request *rq;
2210 2215
@@ -2234,7 +2239,7 @@ EXPORT_SYMBOL(blk_get_request);
2234 * 2239 *
2235 * The queue lock must be held with interrupts disabled. 2240 * The queue lock must be held with interrupts disabled.
2236 */ 2241 */
2237void blk_start_queueing(request_queue_t *q) 2242void blk_start_queueing(struct request_queue *q)
2238{ 2243{
2239 if (!blk_queue_plugged(q)) 2244 if (!blk_queue_plugged(q))
2240 q->request_fn(q); 2245 q->request_fn(q);
@@ -2253,7 +2258,7 @@ EXPORT_SYMBOL(blk_start_queueing);
2253 * more, when that condition happens we need to put the request back 2258 * more, when that condition happens we need to put the request back
2254 * on the queue. Must be called with queue lock held. 2259 * on the queue. Must be called with queue lock held.
2255 */ 2260 */
2256void blk_requeue_request(request_queue_t *q, struct request *rq) 2261void blk_requeue_request(struct request_queue *q, struct request *rq)
2257{ 2262{
2258 blk_add_trace_rq(q, rq, BLK_TA_REQUEUE); 2263 blk_add_trace_rq(q, rq, BLK_TA_REQUEUE);
2259 2264
@@ -2284,7 +2289,7 @@ EXPORT_SYMBOL(blk_requeue_request);
2284 * of the queue for things like a QUEUE_FULL message from a device, or a 2289 * of the queue for things like a QUEUE_FULL message from a device, or a
2285 * host that is unable to accept a particular command. 2290 * host that is unable to accept a particular command.
2286 */ 2291 */
2287void blk_insert_request(request_queue_t *q, struct request *rq, 2292void blk_insert_request(struct request_queue *q, struct request *rq,
2288 int at_head, void *data) 2293 int at_head, void *data)
2289{ 2294{
2290 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK; 2295 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
@@ -2330,7 +2335,7 @@ static int __blk_rq_unmap_user(struct bio *bio)
2330 return ret; 2335 return ret;
2331} 2336}
2332 2337
2333static int __blk_rq_map_user(request_queue_t *q, struct request *rq, 2338static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
2334 void __user *ubuf, unsigned int len) 2339 void __user *ubuf, unsigned int len)
2335{ 2340{
2336 unsigned long uaddr; 2341 unsigned long uaddr;
@@ -2403,8 +2408,8 @@ unmap_bio:
2403 * original bio must be passed back in to blk_rq_unmap_user() for proper 2408 * original bio must be passed back in to blk_rq_unmap_user() for proper
2404 * unmapping. 2409 * unmapping.
2405 */ 2410 */
2406int blk_rq_map_user(request_queue_t *q, struct request *rq, void __user *ubuf, 2411int blk_rq_map_user(struct request_queue *q, struct request *rq,
2407 unsigned long len) 2412 void __user *ubuf, unsigned long len)
2408{ 2413{
2409 unsigned long bytes_read = 0; 2414 unsigned long bytes_read = 0;
2410 struct bio *bio = NULL; 2415 struct bio *bio = NULL;
@@ -2470,7 +2475,7 @@ EXPORT_SYMBOL(blk_rq_map_user);
2470 * original bio must be passed back in to blk_rq_unmap_user() for proper 2475 * original bio must be passed back in to blk_rq_unmap_user() for proper
2471 * unmapping. 2476 * unmapping.
2472 */ 2477 */
2473int blk_rq_map_user_iov(request_queue_t *q, struct request *rq, 2478int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
2474 struct sg_iovec *iov, int iov_count, unsigned int len) 2479 struct sg_iovec *iov, int iov_count, unsigned int len)
2475{ 2480{
2476 struct bio *bio; 2481 struct bio *bio;
@@ -2540,7 +2545,7 @@ EXPORT_SYMBOL(blk_rq_unmap_user);
2540 * @len: length of user data 2545 * @len: length of user data
2541 * @gfp_mask: memory allocation flags 2546 * @gfp_mask: memory allocation flags
2542 */ 2547 */
2543int blk_rq_map_kern(request_queue_t *q, struct request *rq, void *kbuf, 2548int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
2544 unsigned int len, gfp_t gfp_mask) 2549 unsigned int len, gfp_t gfp_mask)
2545{ 2550{
2546 struct bio *bio; 2551 struct bio *bio;
@@ -2577,7 +2582,7 @@ EXPORT_SYMBOL(blk_rq_map_kern);
2577 * Insert a fully prepared request at the back of the io scheduler queue 2582 * Insert a fully prepared request at the back of the io scheduler queue
2578 * for execution. Don't wait for completion. 2583 * for execution. Don't wait for completion.
2579 */ 2584 */
2580void blk_execute_rq_nowait(request_queue_t *q, struct gendisk *bd_disk, 2585void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
2581 struct request *rq, int at_head, 2586 struct request *rq, int at_head,
2582 rq_end_io_fn *done) 2587 rq_end_io_fn *done)
2583{ 2588{
@@ -2605,7 +2610,7 @@ EXPORT_SYMBOL_GPL(blk_execute_rq_nowait);
2605 * Insert a fully prepared request at the back of the io scheduler queue 2610 * Insert a fully prepared request at the back of the io scheduler queue
2606 * for execution and wait for completion. 2611 * for execution and wait for completion.
2607 */ 2612 */
2608int blk_execute_rq(request_queue_t *q, struct gendisk *bd_disk, 2613int blk_execute_rq(struct request_queue *q, struct gendisk *bd_disk,
2609 struct request *rq, int at_head) 2614 struct request *rq, int at_head)
2610{ 2615{
2611 DECLARE_COMPLETION_ONSTACK(wait); 2616 DECLARE_COMPLETION_ONSTACK(wait);
@@ -2648,7 +2653,7 @@ EXPORT_SYMBOL(blk_execute_rq);
2648 */ 2653 */
2649int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector) 2654int blkdev_issue_flush(struct block_device *bdev, sector_t *error_sector)
2650{ 2655{
2651 request_queue_t *q; 2656 struct request_queue *q;
2652 2657
2653 if (bdev->bd_disk == NULL) 2658 if (bdev->bd_disk == NULL)
2654 return -ENXIO; 2659 return -ENXIO;
@@ -2684,7 +2689,7 @@ static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io)
2684 * queue lock is held and interrupts disabled, as we muck with the 2689 * queue lock is held and interrupts disabled, as we muck with the
2685 * request queue list. 2690 * request queue list.
2686 */ 2691 */
2687static inline void add_request(request_queue_t * q, struct request * req) 2692static inline void add_request(struct request_queue * q, struct request * req)
2688{ 2693{
2689 drive_stat_acct(req, req->nr_sectors, 1); 2694 drive_stat_acct(req, req->nr_sectors, 1);
2690 2695
@@ -2730,7 +2735,7 @@ EXPORT_SYMBOL_GPL(disk_round_stats);
2730/* 2735/*
2731 * queue lock must be held 2736 * queue lock must be held
2732 */ 2737 */
2733void __blk_put_request(request_queue_t *q, struct request *req) 2738void __blk_put_request(struct request_queue *q, struct request *req)
2734{ 2739{
2735 if (unlikely(!q)) 2740 if (unlikely(!q))
2736 return; 2741 return;
@@ -2760,7 +2765,7 @@ EXPORT_SYMBOL_GPL(__blk_put_request);
2760void blk_put_request(struct request *req) 2765void blk_put_request(struct request *req)
2761{ 2766{
2762 unsigned long flags; 2767 unsigned long flags;
2763 request_queue_t *q = req->q; 2768 struct request_queue *q = req->q;
2764 2769
2765 /* 2770 /*
2766 * Gee, IDE calls in w/ NULL q. Fix IDE and remove the 2771 * Gee, IDE calls in w/ NULL q. Fix IDE and remove the
@@ -2798,7 +2803,7 @@ EXPORT_SYMBOL(blk_end_sync_rq);
2798/* 2803/*
2799 * Has to be called with the request spinlock acquired 2804 * Has to be called with the request spinlock acquired
2800 */ 2805 */
2801static int attempt_merge(request_queue_t *q, struct request *req, 2806static int attempt_merge(struct request_queue *q, struct request *req,
2802 struct request *next) 2807 struct request *next)
2803{ 2808{
2804 if (!rq_mergeable(req) || !rq_mergeable(next)) 2809 if (!rq_mergeable(req) || !rq_mergeable(next))
@@ -2851,7 +2856,8 @@ static int attempt_merge(request_queue_t *q, struct request *req,
2851 return 1; 2856 return 1;
2852} 2857}
2853 2858
2854static inline int attempt_back_merge(request_queue_t *q, struct request *rq) 2859static inline int attempt_back_merge(struct request_queue *q,
2860 struct request *rq)
2855{ 2861{
2856 struct request *next = elv_latter_request(q, rq); 2862 struct request *next = elv_latter_request(q, rq);
2857 2863
@@ -2861,7 +2867,8 @@ static inline int attempt_back_merge(request_queue_t *q, struct request *rq)
2861 return 0; 2867 return 0;
2862} 2868}
2863 2869
2864static inline int attempt_front_merge(request_queue_t *q, struct request *rq) 2870static inline int attempt_front_merge(struct request_queue *q,
2871 struct request *rq)
2865{ 2872{
2866 struct request *prev = elv_former_request(q, rq); 2873 struct request *prev = elv_former_request(q, rq);
2867 2874
@@ -2905,7 +2912,7 @@ static void init_request_from_bio(struct request *req, struct bio *bio)
2905 req->start_time = jiffies; 2912 req->start_time = jiffies;
2906} 2913}
2907 2914
2908static int __make_request(request_queue_t *q, struct bio *bio) 2915static int __make_request(struct request_queue *q, struct bio *bio)
2909{ 2916{
2910 struct request *req; 2917 struct request *req;
2911 int el_ret, nr_sectors, barrier, err; 2918 int el_ret, nr_sectors, barrier, err;
@@ -3119,7 +3126,7 @@ static inline int should_fail_request(struct bio *bio)
3119 */ 3126 */
3120static inline void __generic_make_request(struct bio *bio) 3127static inline void __generic_make_request(struct bio *bio)
3121{ 3128{
3122 request_queue_t *q; 3129 struct request_queue *q;
3123 sector_t maxsector; 3130 sector_t maxsector;
3124 sector_t old_sector; 3131 sector_t old_sector;
3125 int ret, nr_sectors = bio_sectors(bio); 3132 int ret, nr_sectors = bio_sectors(bio);
@@ -3312,7 +3319,7 @@ static void blk_recalc_rq_segments(struct request *rq)
3312 struct bio *bio, *prevbio = NULL; 3319 struct bio *bio, *prevbio = NULL;
3313 int nr_phys_segs, nr_hw_segs; 3320 int nr_phys_segs, nr_hw_segs;
3314 unsigned int phys_size, hw_size; 3321 unsigned int phys_size, hw_size;
3315 request_queue_t *q = rq->q; 3322 struct request_queue *q = rq->q;
3316 3323
3317 if (!rq->bio) 3324 if (!rq->bio)
3318 return; 3325 return;
@@ -3658,7 +3665,8 @@ void end_request(struct request *req, int uptodate)
3658 3665
3659EXPORT_SYMBOL(end_request); 3666EXPORT_SYMBOL(end_request);
3660 3667
3661void blk_rq_bio_prep(request_queue_t *q, struct request *rq, struct bio *bio) 3668void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
3669 struct bio *bio)
3662{ 3670{
3663 /* first two bits are identical in rq->cmd_flags and bio->bi_rw */ 3671 /* first two bits are identical in rq->cmd_flags and bio->bi_rw */
3664 rq->cmd_flags |= (bio->bi_rw & 3); 3672 rq->cmd_flags |= (bio->bi_rw & 3);
@@ -3701,7 +3709,7 @@ int __init blk_dev_init(void)
3701 sizeof(struct request), 0, SLAB_PANIC, NULL); 3709 sizeof(struct request), 0, SLAB_PANIC, NULL);
3702 3710
3703 requestq_cachep = kmem_cache_create("blkdev_queue", 3711 requestq_cachep = kmem_cache_create("blkdev_queue",
3704 sizeof(request_queue_t), 0, SLAB_PANIC, NULL); 3712 sizeof(struct request_queue), 0, SLAB_PANIC, NULL);
3705 3713
3706 iocontext_cachep = kmem_cache_create("blkdev_ioc", 3714 iocontext_cachep = kmem_cache_create("blkdev_ioc",
3707 sizeof(struct io_context), 0, SLAB_PANIC, NULL); 3715 sizeof(struct io_context), 0, SLAB_PANIC, NULL);
@@ -4021,7 +4029,8 @@ static ssize_t
4021queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page) 4029queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
4022{ 4030{
4023 struct queue_sysfs_entry *entry = to_queue(attr); 4031 struct queue_sysfs_entry *entry = to_queue(attr);
4024 request_queue_t *q = container_of(kobj, struct request_queue, kobj); 4032 struct request_queue *q =
4033 container_of(kobj, struct request_queue, kobj);
4025 ssize_t res; 4034 ssize_t res;
4026 4035
4027 if (!entry->show) 4036 if (!entry->show)
@@ -4041,7 +4050,7 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr,
4041 const char *page, size_t length) 4050 const char *page, size_t length)
4042{ 4051{
4043 struct queue_sysfs_entry *entry = to_queue(attr); 4052 struct queue_sysfs_entry *entry = to_queue(attr);
4044 request_queue_t *q = container_of(kobj, struct request_queue, kobj); 4053 struct request_queue *q = container_of(kobj, struct request_queue, kobj);
4045 4054
4046 ssize_t res; 4055 ssize_t res;
4047 4056
@@ -4072,7 +4081,7 @@ int blk_register_queue(struct gendisk *disk)
4072{ 4081{
4073 int ret; 4082 int ret;
4074 4083
4075 request_queue_t *q = disk->queue; 4084 struct request_queue *q = disk->queue;
4076 4085
4077 if (!q || !q->request_fn) 4086 if (!q || !q->request_fn)
4078 return -ENXIO; 4087 return -ENXIO;
@@ -4097,7 +4106,7 @@ int blk_register_queue(struct gendisk *disk)
4097 4106
4098void blk_unregister_queue(struct gendisk *disk) 4107void blk_unregister_queue(struct gendisk *disk)
4099{ 4108{
4100 request_queue_t *q = disk->queue; 4109 struct request_queue *q = disk->queue;
4101 4110
4102 if (q && q->request_fn) { 4111 if (q && q->request_fn) {
4103 elv_unregister_queue(q); 4112 elv_unregister_queue(q);
diff --git a/block/noop-iosched.c b/block/noop-iosched.c
index 1c3de2b9a6b5..7563d8aa3944 100644
--- a/block/noop-iosched.c
+++ b/block/noop-iosched.c
@@ -11,13 +11,13 @@ struct noop_data {
11 struct list_head queue; 11 struct list_head queue;
12}; 12};
13 13
14static void noop_merged_requests(request_queue_t *q, struct request *rq, 14static void noop_merged_requests(struct request_queue *q, struct request *rq,
15 struct request *next) 15 struct request *next)
16{ 16{
17 list_del_init(&next->queuelist); 17 list_del_init(&next->queuelist);
18} 18}
19 19
20static int noop_dispatch(request_queue_t *q, int force) 20static int noop_dispatch(struct request_queue *q, int force)
21{ 21{
22 struct noop_data *nd = q->elevator->elevator_data; 22 struct noop_data *nd = q->elevator->elevator_data;
23 23
@@ -31,14 +31,14 @@ static int noop_dispatch(request_queue_t *q, int force)
31 return 0; 31 return 0;
32} 32}
33 33
34static void noop_add_request(request_queue_t *q, struct request *rq) 34static void noop_add_request(struct request_queue *q, struct request *rq)
35{ 35{
36 struct noop_data *nd = q->elevator->elevator_data; 36 struct noop_data *nd = q->elevator->elevator_data;
37 37
38 list_add_tail(&rq->queuelist, &nd->queue); 38 list_add_tail(&rq->queuelist, &nd->queue);
39} 39}
40 40
41static int noop_queue_empty(request_queue_t *q) 41static int noop_queue_empty(struct request_queue *q)
42{ 42{
43 struct noop_data *nd = q->elevator->elevator_data; 43 struct noop_data *nd = q->elevator->elevator_data;
44 44
@@ -46,7 +46,7 @@ static int noop_queue_empty(request_queue_t *q)
46} 46}
47 47
48static struct request * 48static struct request *
49noop_former_request(request_queue_t *q, struct request *rq) 49noop_former_request(struct request_queue *q, struct request *rq)
50{ 50{
51 struct noop_data *nd = q->elevator->elevator_data; 51 struct noop_data *nd = q->elevator->elevator_data;
52 52
@@ -56,7 +56,7 @@ noop_former_request(request_queue_t *q, struct request *rq)
56} 56}
57 57
58static struct request * 58static struct request *
59noop_latter_request(request_queue_t *q, struct request *rq) 59noop_latter_request(struct request_queue *q, struct request *rq)
60{ 60{
61 struct noop_data *nd = q->elevator->elevator_data; 61 struct noop_data *nd = q->elevator->elevator_data;
62 62
@@ -65,7 +65,7 @@ noop_latter_request(request_queue_t *q, struct request *rq)
65 return list_entry(rq->queuelist.next, struct request, queuelist); 65 return list_entry(rq->queuelist.next, struct request, queuelist);
66} 66}
67 67
68static void *noop_init_queue(request_queue_t *q) 68static void *noop_init_queue(struct request_queue *q)
69{ 69{
70 struct noop_data *nd; 70 struct noop_data *nd;
71 71
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index d359a715bbc8..91c73224f4c6 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -49,22 +49,22 @@ static int sg_get_version(int __user *p)
49 return put_user(sg_version_num, p); 49 return put_user(sg_version_num, p);
50} 50}
51 51
52static int scsi_get_idlun(request_queue_t *q, int __user *p) 52static int scsi_get_idlun(struct request_queue *q, int __user *p)
53{ 53{
54 return put_user(0, p); 54 return put_user(0, p);
55} 55}
56 56
57static int scsi_get_bus(request_queue_t *q, int __user *p) 57static int scsi_get_bus(struct request_queue *q, int __user *p)
58{ 58{
59 return put_user(0, p); 59 return put_user(0, p);
60} 60}
61 61
62static int sg_get_timeout(request_queue_t *q) 62static int sg_get_timeout(struct request_queue *q)
63{ 63{
64 return q->sg_timeout / (HZ / USER_HZ); 64 return q->sg_timeout / (HZ / USER_HZ);
65} 65}
66 66
67static int sg_set_timeout(request_queue_t *q, int __user *p) 67static int sg_set_timeout(struct request_queue *q, int __user *p)
68{ 68{
69 int timeout, err = get_user(timeout, p); 69 int timeout, err = get_user(timeout, p);
70 70
@@ -74,14 +74,14 @@ static int sg_set_timeout(request_queue_t *q, int __user *p)
74 return err; 74 return err;
75} 75}
76 76
77static int sg_get_reserved_size(request_queue_t *q, int __user *p) 77static int sg_get_reserved_size(struct request_queue *q, int __user *p)
78{ 78{
79 unsigned val = min(q->sg_reserved_size, q->max_sectors << 9); 79 unsigned val = min(q->sg_reserved_size, q->max_sectors << 9);
80 80
81 return put_user(val, p); 81 return put_user(val, p);
82} 82}
83 83
84static int sg_set_reserved_size(request_queue_t *q, int __user *p) 84static int sg_set_reserved_size(struct request_queue *q, int __user *p)
85{ 85{
86 int size, err = get_user(size, p); 86 int size, err = get_user(size, p);
87 87
@@ -101,7 +101,7 @@ static int sg_set_reserved_size(request_queue_t *q, int __user *p)
101 * will always return that we are ATAPI even for a real SCSI drive, I'm not 101 * will always return that we are ATAPI even for a real SCSI drive, I'm not
102 * so sure this is worth doing anything about (why would you care??) 102 * so sure this is worth doing anything about (why would you care??)
103 */ 103 */
104static int sg_emulated_host(request_queue_t *q, int __user *p) 104static int sg_emulated_host(struct request_queue *q, int __user *p)
105{ 105{
106 return put_user(1, p); 106 return put_user(1, p);
107} 107}
@@ -214,7 +214,7 @@ int blk_verify_command(unsigned char *cmd, int has_write_perm)
214} 214}
215EXPORT_SYMBOL_GPL(blk_verify_command); 215EXPORT_SYMBOL_GPL(blk_verify_command);
216 216
217static int blk_fill_sghdr_rq(request_queue_t *q, struct request *rq, 217static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
218 struct sg_io_hdr *hdr, int has_write_perm) 218 struct sg_io_hdr *hdr, int has_write_perm)
219{ 219{
220 memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ 220 memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
@@ -286,7 +286,7 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
286 return r; 286 return r;
287} 287}
288 288
289static int sg_io(struct file *file, request_queue_t *q, 289static int sg_io(struct file *file, struct request_queue *q,
290 struct gendisk *bd_disk, struct sg_io_hdr *hdr) 290 struct gendisk *bd_disk, struct sg_io_hdr *hdr)
291{ 291{
292 unsigned long start_time; 292 unsigned long start_time;
@@ -519,7 +519,8 @@ error:
519EXPORT_SYMBOL_GPL(sg_scsi_ioctl); 519EXPORT_SYMBOL_GPL(sg_scsi_ioctl);
520 520
521/* Send basic block requests */ 521/* Send basic block requests */
522static int __blk_send_generic(request_queue_t *q, struct gendisk *bd_disk, int cmd, int data) 522static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,
523 int cmd, int data)
523{ 524{
524 struct request *rq; 525 struct request *rq;
525 int err; 526 int err;
@@ -539,7 +540,8 @@ static int __blk_send_generic(request_queue_t *q, struct gendisk *bd_disk, int c
539 return err; 540 return err;
540} 541}
541 542
542static inline int blk_send_start_stop(request_queue_t *q, struct gendisk *bd_disk, int data) 543static inline int blk_send_start_stop(struct request_queue *q,
544 struct gendisk *bd_disk, int data)
543{ 545{
544 return __blk_send_generic(q, bd_disk, GPCMD_START_STOP_UNIT, data); 546 return __blk_send_generic(q, bd_disk, GPCMD_START_STOP_UNIT, data);
545} 547}
diff --git a/drivers/Makefile b/drivers/Makefile
index a9e4c5f922a0..f0878b2ec55e 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -66,6 +66,7 @@ obj-y += i2c/
66obj-$(CONFIG_W1) += w1/ 66obj-$(CONFIG_W1) += w1/
67obj-$(CONFIG_POWER_SUPPLY) += power/ 67obj-$(CONFIG_POWER_SUPPLY) += power/
68obj-$(CONFIG_HWMON) += hwmon/ 68obj-$(CONFIG_HWMON) += hwmon/
69obj-$(CONFIG_WATCHDOG) += char/watchdog/
69obj-$(CONFIG_PHONE) += telephony/ 70obj-$(CONFIG_PHONE) += telephony/
70obj-$(CONFIG_MD) += md/ 71obj-$(CONFIG_MD) += md/
71obj-$(CONFIG_BT) += bluetooth/ 72obj-$(CONFIG_BT) += bluetooth/
diff --git a/drivers/acorn/README b/drivers/acorn/README
deleted file mode 100644
index d399c09ca61c..000000000000
--- a/drivers/acorn/README
+++ /dev/null
@@ -1 +0,0 @@
1Drivers for the ACORN "podule" ARM specific bus.
diff --git a/drivers/acorn/block/Kconfig b/drivers/acorn/block/Kconfig
deleted file mode 100644
index a0ff25ea439f..000000000000
--- a/drivers/acorn/block/Kconfig
+++ /dev/null
@@ -1,36 +0,0 @@
1#
2# Block device driver configuration
3#
4
5menu "Acorn-specific block devices"
6 depends on ARCH_ARC || ARCH_A5K
7
8config BLK_DEV_FD1772
9 tristate "Old Archimedes floppy (1772) support"
10 depends on ARCH_ARC || ARCH_A5K
11 help
12 Support the floppy drive on the Acorn Archimedes (A300, A4x0, A540,
13 R140 and R260) series of computers; it supports only 720K floppies
14 at the moment. If you don't have one of these machines just answer
15 N.
16
17config BLK_DEV_MFM
18 tristate "MFM harddisk support"
19 depends on ARCH_ARC || ARCH_A5K
20 help
21 Support the MFM hard drives on the Acorn Archimedes both
22 on-board the A4x0 motherboards and via the Acorn MFM podules.
23 Drives up to 64MB are supported. If you haven't got one of these
24 machines or drives just say N.
25
26config BLK_DEV_MFM_AUTODETECT
27 bool "Autodetect hard drive geometry"
28 depends on BLK_DEV_MFM
29 help
30 If you answer Y, the MFM code will attempt to automatically detect
31 the cylinders/heads/sectors count on your hard drive. WARNING: This
32 sometimes doesn't work and it also does some dodgy stuff which
33 potentially might damage your drive.
34
35endmenu
36
diff --git a/drivers/acorn/block/Makefile b/drivers/acorn/block/Makefile
deleted file mode 100644
index 38a9afe8e03f..000000000000
--- a/drivers/acorn/block/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Makefile for the Acorn block device drivers.
3#
4
5fd1772_mod-objs := fd1772.o fd1772dma.o
6mfmhd_mod-objs := mfmhd.o mfm.o
7
8obj-$(CONFIG_BLK_DEV_FD1772) += fd1772_mod.o
9obj-$(CONFIG_BLK_DEV_MFM) += mfmhd_mod.o
diff --git a/drivers/acorn/block/fd1772.c b/drivers/acorn/block/fd1772.c
deleted file mode 100644
index 423ed08fb6f7..000000000000
--- a/drivers/acorn/block/fd1772.c
+++ /dev/null
@@ -1,1604 +0,0 @@
1/*
2 * linux/kernel/arch/arm/drivers/block/fd1772.c
3 * Based on ataflop.c in the m68k Linux
4 * Copyright (C) 1993 Greg Harp
5 * Atari Support by Bjoern Brauel, Roman Hodek
6 * Archimedes Support by Dave Gilbert (linux@treblig.org)
7 *
8 * Big cleanup Sep 11..14 1994 Roman Hodek:
9 * - Driver now works interrupt driven
10 * - Support for two drives; should work, but I cannot test that :-(
11 * - Reading is done in whole tracks and buffered to speed up things
12 * - Disk change detection and drive deselecting after motor-off
13 * similar to TOS
14 * - Autodetection of disk format (DD/HD); untested yet, because I
15 * don't have an HD drive :-(
16 *
17 * Fixes Nov 13 1994 Martin Schaller:
18 * - Autodetection works now
19 * - Support for 5 1/4" disks
20 * - Removed drive type (unknown on atari)
21 * - Do seeks with 8 Mhz
22 *
23 * Changes by Andreas Schwab:
24 * - After errors in multiple read mode try again reading single sectors
25 * (Feb 1995):
26 * - Clean up error handling
27 * - Set blk_size for proper size checking
28 * - Initialize track register when testing presence of floppy
29 * - Implement some ioctl's
30 *
31 * Changes by Torsten Lang:
32 * - When probing the floppies we should add the FDC1772CMDADD_H flag since
33 * the FDC1772 will otherwise wait forever when no disk is inserted...
34 *
35 * Things left to do:
36 * - Formatting
37 * - Maybe a better strategy for disk change detection (does anyone
38 * know one?)
39 * - There are some strange problems left: The strangest one is
40 * that, at least on my TT (4+4MB), the first 2 Bytes of the last
41 * page of the TT-Ram (!) change their contents (some bits get
42 * set) while a floppy DMA is going on. But there are no accesses
43 * to these memory locations from the kernel... (I tested that by
44 * making the page read-only). I cannot explain what's going on...
45 * - Sometimes the drive-change-detection stops to work. The
46 * function is still called, but the WP bit always reads as 0...
47 * Maybe a problem with the status reg mode or a timing problem.
48 * Note 10/12/94: The change detection now seems to work reliably.
49 * There is no proof, but I've seen no hang for a long time...
50 *
51 * ARCHIMEDES changes: (gilbertd@cs.man.ac.uk)
52 * 26/12/95 - Changed all names starting with FDC to FDC1772
53 * Removed all references to clock speed of FDC - we're stuck with 8MHz
54 * Modified disk_type structure to remove HD formats
55 *
56 * 7/ 1/96 - Wrote FIQ code, removed most remaining atariisms
57 *
58 * 13/ 1/96 - Well I think its read a single sector; but there is a problem
59 * fd_rwsec_done which is called in FIQ mode starts another transfer
60 * off (in fd_rwsec) while still in FIQ mode. Because its still in
61 * FIQ mode it can't service the DMA and loses data. So need to
62 * heavily restructure.
63 * 14/ 1/96 - Found that the definitions of the register numbers of the
64 * FDC were multiplied by 2 in the header for the 16bit words
65 * of the atari so half the writes were going in the wrong place.
66 * Also realised that the FIQ entry didn't make any attempt to
67 * preserve registers or return correctly; now in assembler.
68 *
69 * 11/ 2/96 - Hmm - doesn't work on real machine. Auto detect doesn't
70 * and hacking that past seems to wait forever - check motor
71 * being turned on.
72 *
73 * 17/ 2/96 - still having problems - forcing track to -1 when selecting
74 * new drives seems to allow it to read first few sectors
75 * but then we get solid hangs at apparently random places
76 * which change depending what is happening.
77 *
78 * 9/ 3/96 - Fiddled a lot of stuff around to move to kernel 1.3.35
79 * A lot of fiddling in DMA stuff. Having problems with it
80 * constnatly thinking its timeing out. Ah - its timeout
81 * was set to (6*HZ) rather than jiffies+(6*HZ). Now giving
82 * duff data!
83 *
84 * 5/ 4/96 - Made it use the new IOC_ macros rather than *ioc
85 * Hmm - giving unexpected FIQ and then timeouts
86 * 18/ 8/96 - Ran through indent -kr -i8
87 * Some changes to disc change detect; don't know how well it
88 * works.
89 * 24/ 8/96 - Put all the track buffering code back in from the atari
90 * code - I wonder if it will still work... No :-)
91 * Still works if I turn off track buffering.
92 * 25/ 8/96 - Changed the timer expires that I'd added back to be
93 * jiffies + ....; and it all sprang to life! Got 2.8K/sec
94 * off a cp -r of a 679K disc (showed 94% cpu usage!)
95 * (PC gets 14.3K/sec - 0% CPU!) Hmm - hard drive corrupt!
96 * Also perhaps that compile was with cache off.
97 * changed cli in fd_readtrack_check to cliIF
98 * changed vmallocs to kmalloc (whats the difference!!)
99 * Removed the busy wait loop in do_fd_request and replaced
100 * by a routine on tq_immediate; only 11% cpu on a dd off the
101 * raw disc - but the speed is the same.
102 * 1/ 9/96 - Idea (failed!) - set the 'disable spin-up sequence'
103 * when we read the track if we know the motor is on; didn't
104 * help - perhaps we have to do it in stepping as well.
105 * Nope. Still doesn't help.
106 * Hmm - what seems to be happening is that fd_readtrack_check
107 * is never getting called. Its job is to terminate the read
108 * just after we think we should have got the data; otherwise
109 * the fdc takes 1 second to timeout; which is what's happening
110 * Now I can see 'readtrack_timer' being set (which should do the
111 * call); but it never seems to be called - hmm!
112 * OK - I've moved the check to my tq_immediate code -
113 * and it WORKS! 13.95K/second at 19% CPU.
114 * I wish I knew why that timer didn't work.....
115 *
116 * 16/11/96 - Fiddled and frigged for 2.0.18
117 *
118 * DAG 30/01/99 - Started frobbing for 2.2.1
119 * DAG 20/06/99 - A little more frobbing:
120 * Included include/asm/uaccess.h for get_user/put_user
121 *
122 * DAG 1/09/00 - Dusted off for 2.4.0-test7
123 * MAX_SECTORS was name clashing so it is now FD1772_...
124 * Minor parameter, name layouts for 2.4.x differences
125 */
126
127#include <linux/sched.h>
128#include <linux/fs.h>
129#include <linux/fcntl.h>
130#include <linux/slab.h>
131#include <linux/kernel.h>
132#include <linux/interrupt.h>
133#include <linux/timer.h>
134#include <linux/workqueue.h>
135#include <linux/fd.h>
136#include <linux/fd1772.h>
137#include <linux/errno.h>
138#include <linux/types.h>
139#include <linux/delay.h>
140#include <linux/mm.h>
141#include <linux/bitops.h>
142
143#include <asm/arch/oldlatches.h>
144#include <asm/dma.h>
145#include <asm/hardware.h>
146#include <asm/hardware/ioc.h>
147#include <asm/io.h>
148#include <asm/irq.h>
149#include <asm/mach-types.h>
150#include <asm/pgtable.h>
151#include <asm/system.h>
152#include <asm/uaccess.h>
153
154
155/* Note: FD_MAX_UNITS could be redefined to 2 for the Atari (with
156 * little additional rework in this file). But I'm not yet sure if
157 * some other code depends on the number of floppies... (It is defined
158 * in a public header!)
159 */
160#if 0
161#undef FD_MAX_UNITS
162#define FD_MAX_UNITS 2
163#endif
164
165/* Ditto worries for Arc - DAG */
166#define FD_MAX_UNITS 4
167#define TRACKBUFFER 0
168/*#define DEBUG*/
169
170#ifdef DEBUG
171#define DPRINT(a) printk a
172#else
173#define DPRINT(a)
174#endif
175
176static struct request_queue *floppy_queue;
177
178#define MAJOR_NR FLOPPY_MAJOR
179#define FLOPPY_DMA 0
180#define DEVICE_NAME "floppy"
181#define QUEUE (floppy_queue)
182#define CURRENT elv_next_request(floppy_queue)
183
184/* Disk types: DD */
185static struct archy_disk_type {
186 const char *name;
187 unsigned spt; /* sectors per track */
188 unsigned blocks; /* total number of blocks */
189 unsigned stretch; /* track doubling ? */
190} disk_type[] = {
191
192 { "d360", 9, 720, 0 }, /* 360kB diskette */
193 { "D360", 9, 720, 1 }, /* 360kb in 720kb drive */
194 { "D720", 9, 1440, 0 }, /* 720kb diskette (DD) */
195 /*{ "D820", 10,1640, 0}, *//* DD disk with 82 tracks/10 sectors
196 - DAG - can't see how type detect can distinguish this
197 from 720K until it reads block 4 by which time its too late! */
198};
199
200#define NUM_DISK_TYPES (sizeof(disk_type)/sizeof(*disk_type))
201
202/*
203 * Maximum disk size (in kilobytes). This default is used whenever the
204 * current disk size is unknown.
205 */
206#define MAX_DISK_SIZE 720
207
208static struct gendisk *disks[FD_MAX_UNIT];
209
210/* current info on each unit */
211static struct archy_floppy_struct {
212 int connected; /* !=0 : drive is connected */
213 int autoprobe; /* !=0 : do autoprobe */
214
215 struct archy_disk_type *disktype; /* current type of disk */
216
217 int track; /* current head position or -1
218 * if unknown */
219 unsigned int steprate; /* steprate setting */
220 unsigned int wpstat; /* current state of WP signal
221 * (for disk change detection) */
222} unit[FD_MAX_UNITS];
223
224/* DAG: On Arc we spin on a flag being cleared by fdc1772_comendhandler which
225 is an assembler routine */
226extern void fdc1772_comendhandler(void); /* Actually doens't have these parameters - see fd1772.S */
227extern volatile int fdc1772_comendstatus;
228extern volatile int fdc1772_fdc_int_done;
229
230#define FDC1772BASE ((0x210000>>2)|0x80000000)
231
232#define FDC1772_READ(reg) inb(FDC1772BASE+(reg/2))
233
234/* DAG: You wouldn't be silly to ask why FDC1772_WRITE is a function rather
235 than the #def below - well simple - the #def won't compile - and I
236 don't understand why (__outwc not defined) */
237/* NOTE: Reg is 0,2,4,6 as opposed to 0,1,2,3 or 0,4,8,12 to keep compatibility
238 with the ST version of fd1772.h */
239/*#define FDC1772_WRITE(reg,val) outw(val,(reg+FDC1772BASE)); */
240void FDC1772_WRITE(int reg, unsigned char val)
241{
242 if (reg == FDC1772REG_CMD) {
243 DPRINT(("FDC1772_WRITE new command 0x%x @ %d\n", val,jiffies));
244 if (fdc1772_fdc_int_done) {
245 DPRINT(("FDC1772_WRITE: Hmm fdc1772_fdc_int_done true - resetting\n"));
246 fdc1772_fdc_int_done = 0;
247 };
248 };
249 outb(val, (reg / 2) + FDC1772BASE);
250};
251
252#define FD1772_MAX_SECTORS 22
253
254unsigned char *DMABuffer; /* buffer for writes */
255/*static unsigned long PhysDMABuffer; *//* physical address */
256/* DAG: On Arc we just go straight for the DMA buffer */
257#define PhysDMABuffer DMABuffer
258
259#ifdef TRACKBUFFER
260unsigned char *TrackBuffer; /* buffer for reads */
261#define PhysTrackBuffer TrackBuffer /* physical address */
262static int BufferDrive, BufferSide, BufferTrack;
263static int read_track; /* non-zero if we are reading whole tracks */
264
265#define SECTOR_BUFFER(sec) (TrackBuffer + ((sec)-1)*512)
266#define IS_BUFFERED(drive,side,track) \
267 (BufferDrive == (drive) && BufferSide == (side) && BufferTrack == (track))
268#endif
269
270/*
271 * These are global variables, as that's the easiest way to give
272 * information to interrupts. They are the data used for the current
273 * request.
274 */
275static int SelectedDrive = 0;
276static int ReqCmd, ReqBlock;
277static int ReqSide, ReqTrack, ReqSector, ReqCnt;
278static int HeadSettleFlag = 0;
279static unsigned char *ReqData, *ReqBuffer;
280static int MotorOn = 0, MotorOffTrys;
281
282/* Synchronization of FDC1772 access. */
283static volatile int fdc_busy = 0;
284static DECLARE_WAIT_QUEUE_HEAD(fdc_wait);
285
286
287/* long req'd for set_bit --RR */
288static unsigned long changed_floppies = 0xff, fake_change = 0;
289#define CHECK_CHANGE_DELAY HZ/2
290
291/* DAG - increased to 30*HZ - not sure if this is the correct thing to do */
292#define FD_MOTOR_OFF_DELAY (10*HZ)
293#define FD_MOTOR_OFF_MAXTRY (10*20)
294
295#define FLOPPY_TIMEOUT (6*HZ)
296#define RECALIBRATE_ERRORS 4 /* After this many errors the drive
297 * will be recalibrated. */
298#define MAX_ERRORS 8 /* After this many errors the driver
299 * will give up. */
300
301#define START_MOTOR_OFF_TIMER(delay) \
302 do { \
303 motor_off_timer.expires = jiffies + (delay); \
304 add_timer( &motor_off_timer ); \
305 MotorOffTrys = 0; \
306 } while(0)
307
308#define START_CHECK_CHANGE_TIMER(delay) \
309 do { \
310 mod_timer(&fd_timer, jiffies + (delay)); \
311 } while(0)
312
313#define START_TIMEOUT() \
314 do { \
315 mod_timer(&timeout_timer, jiffies+FLOPPY_TIMEOUT); \
316 } while(0)
317
318#define STOP_TIMEOUT() \
319 do { \
320 del_timer( &timeout_timer ); \
321 } while(0)
322
323#define ENABLE_IRQ() enable_irq(FIQ_FD1772+64);
324
325#define DISABLE_IRQ() disable_irq(FIQ_FD1772+64);
326
327static void fd1772_checkint(void);
328
329DECLARE_WORK(fd1772_tq, (void *)fd1772_checkint, NULL);
330/*
331 * The driver is trying to determine the correct media format
332 * while Probing is set. fd_rwsec_done() clears it after a
333 * successful access.
334 */
335static int Probing = 0;
336
337/* This flag is set when a dummy seek is necessary to make the WP
338 * status bit accessible.
339 */
340static int NeedSeek = 0;
341
342
343/***************************** Prototypes *****************************/
344
345static void fd_select_side(int side);
346static void fd_select_drive(int drive);
347static void fd_deselect(void);
348static void fd_motor_off_timer(unsigned long dummy);
349static void check_change(unsigned long dummy);
350static void floppy_irqconsequencehandler(void);
351static void fd_error(void);
352static void do_fd_action(int drive);
353static void fd_calibrate(void);
354static void fd_calibrate_done(int status);
355static void fd_seek(void);
356static void fd_seek_done(int status);
357static void fd_rwsec(void);
358#ifdef TRACKBUFFER
359static void fd_readtrack_check( unsigned long dummy );
360#endif
361static void fd_rwsec_done(int status);
362static void fd_times_out(unsigned long dummy);
363static void finish_fdc(void);
364static void finish_fdc_done(int dummy);
365static void floppy_off(unsigned int nr);
366static void setup_req_params(int drive);
367static void redo_fd_request(void);
368static int fd_ioctl(struct inode *inode, struct file *filp, unsigned int
369 cmd, unsigned long param);
370static void fd_probe(int drive);
371static int fd_test_drive_present(int drive);
372static void config_types(void);
373static int floppy_open(struct inode *inode, struct file *filp);
374static int floppy_release(struct inode *inode, struct file *filp);
375static void do_fd_request(request_queue_t *);
376
377/************************* End of Prototypes **************************/
378
379static DEFINE_TIMER(motor_off_timer, fd_motor_off_timer, 0, 0);
380
381#ifdef TRACKBUFFER
382static DEFINE_TIMER(readtrack_timer, fd_readtrack_check, 0, 0);
383#endif
384
385static DEFINE_TIMER(timeout_timer, fd_times_out, 0, 0);
386
387static DEFINE_TIMER(fd_timer, check_change, 0, 0);
388
389/* DAG: Haven't got a clue what this is? */
390int stdma_islocked(void)
391{
392 return 0;
393};
394
395/* Select the side to use. */
396
397static void fd_select_side(int side)
398{
399 oldlatch_aupdate(LATCHA_SIDESEL, side ? 0 : LATCHA_SIDESEL);
400}
401
402
403/* Select a drive, update the FDC1772's track register
404 */
405
406static void fd_select_drive(int drive)
407{
408#ifdef DEBUG
409 printk("fd_select_drive:%d\n", drive);
410#endif
411 /* Hmm - nowhere do we seem to turn the motor on - I'm going to do it here! */
412 oldlatch_aupdate(LATCHA_MOTOR | LATCHA_INUSE, 0);
413
414 if (drive == SelectedDrive)
415 return;
416
417 oldlatch_aupdate(LATCHA_FDSELALL, 0xf - (1 << drive));
418
419 /* restore track register to saved value */
420 FDC1772_WRITE(FDC1772REG_TRACK, unit[drive].track);
421 udelay(25);
422
423 SelectedDrive = drive;
424}
425
426
427/* Deselect both drives. */
428
429static void fd_deselect(void)
430{
431 unsigned long flags;
432
433 DPRINT(("fd_deselect\n"));
434
435 oldlatch_aupdate(LATCHA_FDSELALL | LATCHA_MOTOR | LATCHA_INUSE, 0xf | LATCHA_MOTOR | LATCHA_INUSE);
436
437 SelectedDrive = -1;
438}
439
440
441/* This timer function deselects the drives when the FDC1772 switched the
442 * motor off. The deselection cannot happen earlier because the FDC1772
443 * counts the index signals, which arrive only if one drive is selected.
444 */
445
446static void fd_motor_off_timer(unsigned long dummy)
447{
448 unsigned long flags;
449 unsigned char status;
450 int delay;
451
452 del_timer(&motor_off_timer);
453
454 if (SelectedDrive < 0)
455 /* no drive selected, needn't deselect anyone */
456 return;
457
458 save_flags(flags);
459 cli();
460
461 if (fdc_busy) /* was stdma_islocked */
462 goto retry;
463
464 status = FDC1772_READ(FDC1772REG_STATUS);
465
466 if (!(status & 0x80)) {
467 /*
468 * motor already turned off by FDC1772 -> deselect drives
469 * In actual fact its this deselection which turns the motor
470 * off on the Arc, since the motor control is actually on
471 * Latch A
472 */
473 DPRINT(("fdc1772: deselecting in fd_motor_off_timer\n"));
474 fd_deselect();
475 MotorOn = 0;
476 restore_flags(flags);
477 return;
478 }
479 /* not yet off, try again */
480
481retry:
482 restore_flags(flags);
483 /* Test again later; if tested too often, it seems there is no disk
484 * in the drive and the FDC1772 will leave the motor on forever (or,
485 * at least until a disk is inserted). So we'll test only twice
486 * per second from then on...
487 */
488 delay = (MotorOffTrys < FD_MOTOR_OFF_MAXTRY) ?
489 (++MotorOffTrys, HZ / 20) : HZ / 2;
490 START_MOTOR_OFF_TIMER(delay);
491}
492
493
494/* This function is repeatedly called to detect disk changes (as good
495 * as possible) and keep track of the current state of the write protection.
496 */
497
498static void check_change(unsigned long dummy)
499{
500 static int drive = 0;
501
502 unsigned long flags;
503 int stat;
504
505 if (fdc_busy)
506 return; /* Don't start poking about if the fdc is busy */
507
508 return; /* let's just forget it for the mo DAG */
509
510 if (++drive > 1 || !unit[drive].connected)
511 drive = 0;
512
513 save_flags(flags);
514 cli();
515
516 if (!stdma_islocked()) {
517 stat = !!(FDC1772_READ(FDC1772REG_STATUS) & FDC1772STAT_WPROT);
518
519 /* The idea here is that if the write protect line has changed then
520 the disc must have changed */
521 if (stat != unit[drive].wpstat) {
522 DPRINT(("wpstat[%d] = %d\n", drive, stat));
523 unit[drive].wpstat = stat;
524 set_bit(drive, &changed_floppies);
525 }
526 }
527 restore_flags(flags);
528
529 START_CHECK_CHANGE_TIMER(CHECK_CHANGE_DELAY);
530}
531
532
533/* Handling of the Head Settling Flag: This flag should be set after each
534 * seek operation, because we don't use seeks with verify.
535 */
536
537static inline void set_head_settle_flag(void)
538{
539 HeadSettleFlag = FDC1772CMDADD_E;
540}
541
542static inline int get_head_settle_flag(void)
543{
544 int tmp = HeadSettleFlag;
545 HeadSettleFlag = 0;
546 return (tmp);
547}
548
549
550
551
552/* General Interrupt Handling */
553
554static inline void copy_buffer(void *from, void *to)
555{
556 ulong *p1 = (ulong *) from, *p2 = (ulong *) to;
557 int cnt;
558
559 for (cnt = 512 / 4; cnt; cnt--)
560 *p2++ = *p1++;
561}
562
563static void (*FloppyIRQHandler) (int status) = NULL;
564
565static void floppy_irqconsequencehandler(void)
566{
567 unsigned char status;
568 void (*handler) (int);
569
570 fdc1772_fdc_int_done = 0;
571
572 handler = FloppyIRQHandler;
573 FloppyIRQHandler = NULL;
574
575 if (handler) {
576 nop();
577 status = (unsigned char) fdc1772_comendstatus;
578 DPRINT(("FDC1772 irq, status = %02x handler = %08lx\n", (unsigned int) status, (unsigned long) handler));
579 handler(status);
580 } else {
581 DPRINT(("FDC1772 irq, no handler status=%02x\n", fdc1772_comendstatus));
582 }
583 DPRINT(("FDC1772 irq: end of floppy_irq\n"));
584}
585
586
587/* Error handling: If some error happened, retry some times, then
588 * recalibrate, then try again, and fail after MAX_ERRORS.
589 */
590
591static void fd_error(void)
592{
593 printk("FDC1772: fd_error\n");
594 /*panic("fd1772: fd_error"); *//* DAG tmp */
595 if (!CURRENT)
596 return;
597 CURRENT->errors++;
598 if (CURRENT->errors >= MAX_ERRORS) {
599 printk("fd%d: too many errors.\n", SelectedDrive);
600 end_request(CURRENT, 0);
601 } else if (CURRENT->errors == RECALIBRATE_ERRORS) {
602 printk("fd%d: recalibrating\n", SelectedDrive);
603 if (SelectedDrive != -1)
604 unit[SelectedDrive].track = -1;
605 }
606 redo_fd_request();
607}
608
609
610
611#define SET_IRQ_HANDLER(proc) do { FloppyIRQHandler = (proc); } while(0)
612
613
614/* do_fd_action() is the general procedure for a fd request: All
615 * required parameter settings (drive select, side select, track
616 * position) are checked and set if needed. For each of these
617 * parameters and the actual reading or writing exist two functions:
618 * one that starts the setting (or skips it if possible) and one
619 * callback for the "done" interrupt. Each done func calls the next
620 * set function to propagate the request down to fd_rwsec_done().
621 */
622
623static void do_fd_action(int drive)
624{
625 struct request *req;
626 DPRINT(("do_fd_action unit[drive].track=%d\n", unit[drive].track));
627
628#ifdef TRACKBUFFER
629repeat:
630
631 if (IS_BUFFERED( drive, ReqSide, ReqTrack )) {
632 req = CURRENT;
633 if (ReqCmd == READ) {
634 copy_buffer( SECTOR_BUFFER(ReqSector), ReqData );
635 if (++ReqCnt < req->current_nr_sectors) {
636 /* read next sector */
637 setup_req_params( drive );
638 goto repeat;
639 } else {
640 /* all sectors finished */
641 req->nr_sectors -= req->current_nr_sectors;
642 req->sector += req->current_nr_sectors;
643 end_request(req, 1);
644 redo_fd_request();
645 return;
646 }
647 } else {
648 /* cmd == WRITE, pay attention to track buffer
649 * consistency! */
650 copy_buffer( ReqData, SECTOR_BUFFER(ReqSector) );
651 }
652 }
653#endif
654
655 if (SelectedDrive != drive) {
656 /*unit[drive].track = -1; DAG */
657 fd_select_drive(drive);
658 };
659
660
661 if (unit[drive].track == -1)
662 fd_calibrate();
663 else if (unit[drive].track != ReqTrack << unit[drive].disktype->stretch)
664 fd_seek();
665 else
666 fd_rwsec();
667}
668
669
670/* Seek to track 0 if the current track is unknown */
671
672static void fd_calibrate(void)
673{
674 DPRINT(("fd_calibrate\n"));
675 if (unit[SelectedDrive].track >= 0) {
676 fd_calibrate_done(0);
677 return;
678 }
679 DPRINT(("fd_calibrate (after track compare)\n"));
680 SET_IRQ_HANDLER(fd_calibrate_done);
681 /* we can't verify, since the speed may be incorrect */
682 FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_RESTORE | unit[SelectedDrive].steprate);
683
684 NeedSeek = 1;
685 MotorOn = 1;
686 START_TIMEOUT();
687 /* wait for IRQ */
688}
689
690
691static void fd_calibrate_done(int status)
692{
693 DPRINT(("fd_calibrate_done()\n"));
694 STOP_TIMEOUT();
695
696 /* set the correct speed now */
697 if (status & FDC1772STAT_RECNF) {
698 printk("fd%d: restore failed\n", SelectedDrive);
699 fd_error();
700 } else {
701 unit[SelectedDrive].track = 0;
702 fd_seek();
703 }
704}
705
706
707/* Seek the drive to the requested track. The drive must have been
708 * calibrated at some point before this.
709 */
710
711static void fd_seek(void)
712{
713 unsigned long flags;
714 DPRINT(("fd_seek() to track %d (unit[SelectedDrive].track=%d)\n", ReqTrack,
715 unit[SelectedDrive].track));
716 if (unit[SelectedDrive].track == ReqTrack <<
717 unit[SelectedDrive].disktype->stretch) {
718 fd_seek_done(0);
719 return;
720 }
721 FDC1772_WRITE(FDC1772REG_DATA, ReqTrack <<
722 unit[SelectedDrive].disktype->stretch);
723 udelay(25);
724 save_flags(flags);
725 clf();
726 SET_IRQ_HANDLER(fd_seek_done);
727 FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_SEEK | unit[SelectedDrive].steprate |
728 /* DAG */
729 (MotorOn?FDC1772CMDADD_H:0));
730
731 restore_flags(flags);
732 MotorOn = 1;
733 set_head_settle_flag();
734 START_TIMEOUT();
735 /* wait for IRQ */
736}
737
738
739static void fd_seek_done(int status)
740{
741 DPRINT(("fd_seek_done()\n"));
742 STOP_TIMEOUT();
743
744 /* set the correct speed */
745 if (status & FDC1772STAT_RECNF) {
746 printk("fd%d: seek error (to track %d)\n",
747 SelectedDrive, ReqTrack);
748 /* we don't know exactly which track we are on now! */
749 unit[SelectedDrive].track = -1;
750 fd_error();
751 } else {
752 unit[SelectedDrive].track = ReqTrack <<
753 unit[SelectedDrive].disktype->stretch;
754 NeedSeek = 0;
755 fd_rwsec();
756 }
757}
758
759
760/* This does the actual reading/writing after positioning the head
761 * over the correct track.
762 */
763
764#ifdef TRACKBUFFER
765static int MultReadInProgress = 0;
766#endif
767
768
769static void fd_rwsec(void)
770{
771 unsigned long paddr, flags;
772 unsigned int rwflag, old_motoron;
773 unsigned int track;
774
775 DPRINT(("fd_rwsec(), Sec=%d, Access=%c\n", ReqSector, ReqCmd == WRITE ? 'w' : 'r'));
776 if (ReqCmd == WRITE) {
777 /*cache_push( (unsigned long)ReqData, 512 ); */
778 paddr = (unsigned long) ReqData;
779 rwflag = 0x100;
780 } else {
781 paddr = (unsigned long) PhysDMABuffer;
782#ifdef TRACKBUFFER
783 if (read_track)
784 paddr = (unsigned long)PhysTrackBuffer;
785#endif
786 rwflag = 0;
787 }
788
789 DPRINT(("fd_rwsec() before sidesel rwflag=%d sec=%d trk=%d\n", rwflag,
790 ReqSector, FDC1772_READ(FDC1772REG_TRACK)));
791 fd_select_side(ReqSide);
792
793 /*DPRINT(("fd_rwsec() before start sector \n")); */
794 /* Start sector of this operation */
795#ifdef TRACKBUFFER
796 FDC1772_WRITE( FDC1772REG_SECTOR, !read_track ? ReqSector : 1 );
797#else
798 FDC1772_WRITE( FDC1772REG_SECTOR, ReqSector );
799#endif
800
801 /* Cheat for track if stretch != 0 */
802 if (unit[SelectedDrive].disktype->stretch) {
803 track = FDC1772_READ(FDC1772REG_TRACK);
804 FDC1772_WRITE(FDC1772REG_TRACK, track >>
805 unit[SelectedDrive].disktype->stretch);
806 }
807 udelay(25);
808
809 DPRINT(("fd_rwsec() before setup DMA \n"));
810 /* Setup DMA - Heavily modified by DAG */
811 save_flags(flags);
812 clf();
813 disable_dma(FLOPPY_DMA);
814 set_dma_mode(FLOPPY_DMA, rwflag ? DMA_MODE_WRITE : DMA_MODE_READ);
815 set_dma_addr(FLOPPY_DMA, (long) paddr); /* DAG - changed from Atari specific */
816#ifdef TRACKBUFFER
817 set_dma_count(FLOPPY_DMA,(!read_track ? 1 : unit[SelectedDrive].disktype->spt)*512);
818#else
819 set_dma_count(FLOPPY_DMA, 512); /* Block/sector size - going to have to change */
820#endif
821 SET_IRQ_HANDLER(fd_rwsec_done);
822 /* Turn on dma int */
823 enable_dma(FLOPPY_DMA);
824 /* Now give it something to do */
825 FDC1772_WRITE(FDC1772REG_CMD, (rwflag ? (FDC1772CMD_WRSEC | FDC1772CMDADD_P) :
826#ifdef TRACKBUFFER
827 (FDC1772CMD_RDSEC | (read_track ? FDC1772CMDADD_M : 0) |
828 /* Hmm - the idea here is to stop the FDC spinning the disc
829 up when we know that we already still have it spinning */
830 (MotorOn?FDC1772CMDADD_H:0))
831#else
832 FDC1772CMD_RDSEC
833#endif
834 ));
835
836 restore_flags(flags);
837 DPRINT(("fd_rwsec() after DMA setup flags=0x%08x\n", flags));
838 /*sti(); *//* DAG - Hmm */
839 /* Hmm - should do something DAG */
840 old_motoron = MotorOn;
841 MotorOn = 1;
842 NeedSeek = 1;
843
844 /* wait for interrupt */
845
846#ifdef TRACKBUFFER
847 if (read_track) {
848 /*
849 * If reading a whole track, wait about one disk rotation and
850 * then check if all sectors are read. The FDC will even
851 * search for the first non-existant sector and need 1 sec to
852 * recognise that it isn't present :-(
853 */
854 /* 1 rot. + 5 rot.s if motor was off */
855 mod_timer(&readtrack_timer, jiffies + HZ/5 + (old_motoron ? 0 : HZ));
856 DPRINT(("Setting readtrack_timer to %d @ %d\n",
857 readtrack_timer.expires,jiffies));
858 MultReadInProgress = 1;
859 }
860#endif
861
862 /*DPRINT(("fd_rwsec() before START_TIMEOUT \n")); */
863 START_TIMEOUT();
864 /*DPRINT(("fd_rwsec() after START_TIMEOUT \n")); */
865}
866
867
868#ifdef TRACKBUFFER
869
870static void fd_readtrack_check(unsigned long dummy)
871{
872 unsigned long flags, addr;
873 extern unsigned char *fdc1772_dataaddr;
874
875 DPRINT(("fd_readtrack_check @ %d\n",jiffies));
876
877 save_flags(flags);
878 clf();
879
880 del_timer( &readtrack_timer );
881
882 if (!MultReadInProgress) {
883 /* This prevents a race condition that could arise if the
884 * interrupt is triggered while the calling of this timer
885 * callback function takes place. The IRQ function then has
886 * already cleared 'MultReadInProgress' when control flow
887 * gets here.
888 */
889 restore_flags(flags);
890 return;
891 }
892
893 /* get the current DMA address */
894 addr=(unsigned long)fdc1772_dataaddr; /* DAG - ? */
895 DPRINT(("fd_readtrack_check: addr=%x PhysTrackBuffer=%x\n",addr,PhysTrackBuffer));
896
897 if (addr >= (unsigned int)PhysTrackBuffer + unit[SelectedDrive].disktype->spt*512) {
898 /* already read enough data, force an FDC interrupt to stop
899 * the read operation
900 */
901 SET_IRQ_HANDLER( NULL );
902 restore_flags(flags);
903 DPRINT(("fd_readtrack_check(): done\n"));
904 FDC1772_WRITE( FDC1772REG_CMD, FDC1772CMD_FORCI );
905 udelay(25);
906
907 /* No error until now -- the FDC would have interrupted
908 * otherwise!
909 */
910 fd_rwsec_done( 0 );
911 } else {
912 /* not yet finished, wait another tenth rotation */
913 restore_flags(flags);
914 DPRINT(("fd_readtrack_check(): not yet finished\n"));
915 readtrack_timer.expires = jiffies + HZ/5/10;
916 add_timer( &readtrack_timer );
917 }
918}
919
920#endif
921
922static void fd_rwsec_done(int status)
923{
924 unsigned int track;
925
926 DPRINT(("fd_rwsec_done() status=%d @ %d\n", status,jiffies));
927
928#ifdef TRACKBUFFER
929 if (read_track && !MultReadInProgress)
930 return;
931
932 MultReadInProgress = 0;
933
934 STOP_TIMEOUT();
935
936 if (read_track)
937 del_timer( &readtrack_timer );
938#endif
939
940
941 /* Correct the track if stretch != 0 */
942 if (unit[SelectedDrive].disktype->stretch) {
943 track = FDC1772_READ(FDC1772REG_TRACK);
944 FDC1772_WRITE(FDC1772REG_TRACK, track <<
945 unit[SelectedDrive].disktype->stretch);
946 }
947 if (ReqCmd == WRITE && (status & FDC1772STAT_WPROT)) {
948 printk("fd%d: is write protected\n", SelectedDrive);
949 goto err_end;
950 }
951 if ((status & FDC1772STAT_RECNF)
952#ifdef TRACKBUFFER
953 /* RECNF is no error after a multiple read when the FDC
954 * searched for a non-existant sector!
955 */
956 && !(read_track &&
957 FDC1772_READ(FDC1772REG_SECTOR) > unit[SelectedDrive].disktype->spt)
958#endif
959 ) {
960 if (Probing) {
961 if (unit[SelectedDrive].disktype > disk_type) {
962 /* try another disk type */
963 unit[SelectedDrive].disktype--;
964 set_capacity(disks[SelectedDrive],
965 unit[SelectedDrive].disktype->blocks);
966 } else
967 Probing = 0;
968 } else {
969 /* record not found, but not probing. Maybe stretch wrong ? Restart probing */
970 if (unit[SelectedDrive].autoprobe) {
971 unit[SelectedDrive].disktype = disk_type + NUM_DISK_TYPES - 1;
972 set_capacity(disks[SelectedDrive],
973 unit[SelectedDrive].disktype->blocks);
974 Probing = 1;
975 }
976 }
977 if (Probing) {
978 setup_req_params(SelectedDrive);
979#ifdef TRACKBUFFER
980 BufferDrive = -1;
981#endif
982 do_fd_action(SelectedDrive);
983 return;
984 }
985 printk("fd%d: sector %d not found (side %d, track %d)\n",
986 SelectedDrive, FDC1772_READ(FDC1772REG_SECTOR), ReqSide, ReqTrack);
987 goto err_end;
988 }
989 if (status & FDC1772STAT_CRC) {
990 printk("fd%d: CRC error (side %d, track %d, sector %d)\n",
991 SelectedDrive, ReqSide, ReqTrack, FDC1772_READ(FDC1772REG_SECTOR));
992 goto err_end;
993 }
994 if (status & FDC1772STAT_LOST) {
995 printk("fd%d: lost data (side %d, track %d, sector %d)\n",
996 SelectedDrive, ReqSide, ReqTrack, FDC1772_READ(FDC1772REG_SECTOR));
997 goto err_end;
998 }
999 Probing = 0;
1000
1001 if (ReqCmd == READ) {
1002#ifdef TRACKBUFFER
1003 if (!read_track) {
1004 /*cache_clear (PhysDMABuffer, 512);*/
1005 copy_buffer (DMABuffer, ReqData);
1006 } else {
1007 /*cache_clear (PhysTrackBuffer, FD1772_MAX_SECTORS * 512);*/
1008 BufferDrive = SelectedDrive;
1009 BufferSide = ReqSide;
1010 BufferTrack = ReqTrack;
1011 copy_buffer (SECTOR_BUFFER (ReqSector), ReqData);
1012 }
1013#else
1014 /*cache_clear( PhysDMABuffer, 512 ); */
1015 copy_buffer(DMABuffer, ReqData);
1016#endif
1017 }
1018 if (++ReqCnt < CURRENT->current_nr_sectors) {
1019 /* read next sector */
1020 setup_req_params(SelectedDrive);
1021 do_fd_action(SelectedDrive);
1022 } else {
1023 /* all sectors finished */
1024 CURRENT->nr_sectors -= CURRENT->current_nr_sectors;
1025 CURRENT->sector += CURRENT->current_nr_sectors;
1026 end_request(CURRENT, 1);
1027 redo_fd_request();
1028 }
1029 return;
1030
1031err_end:
1032#ifdef TRACKBUFFER
1033 BufferDrive = -1;
1034#endif
1035
1036 fd_error();
1037}
1038
1039
1040static void fd_times_out(unsigned long dummy)
1041{
1042 SET_IRQ_HANDLER(NULL);
1043 /* If the timeout occurred while the readtrack_check timer was
1044 * active, we need to cancel it, else bad things will happen */
1045 del_timer( &readtrack_timer );
1046 FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_FORCI);
1047 udelay(25);
1048
1049 printk("floppy timeout\n");
1050 STOP_TIMEOUT(); /* hmm - should we do this ? */
1051 fd_error();
1052}
1053
1054
1055/* The (noop) seek operation here is needed to make the WP bit in the
1056 * FDC1772 status register accessible for check_change. If the last disk
1057 * operation would have been a RDSEC, this bit would always read as 0
1058 * no matter what :-( To save time, the seek goes to the track we're
1059 * already on.
1060 */
1061
1062static void finish_fdc(void)
1063{
1064 /* DAG - just try without this dummy seek! */
1065 finish_fdc_done(0);
1066 return;
1067
1068 if (!NeedSeek) {
1069 finish_fdc_done(0);
1070 } else {
1071 DPRINT(("finish_fdc: dummy seek started\n"));
1072 FDC1772_WRITE(FDC1772REG_DATA, unit[SelectedDrive].track);
1073 SET_IRQ_HANDLER(finish_fdc_done);
1074 FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_SEEK);
1075 MotorOn = 1;
1076 START_TIMEOUT();
1077 /* we must wait for the IRQ here, because the ST-DMA is
1078 * released immediately afterwards and the interrupt may be
1079 * delivered to the wrong driver.
1080 */
1081 }
1082}
1083
1084
1085static void finish_fdc_done(int dummy)
1086{
1087 unsigned long flags;
1088
1089 DPRINT(("finish_fdc_done entered\n"));
1090 STOP_TIMEOUT();
1091 NeedSeek = 0;
1092
1093 if (timer_pending(&fd_timer) &&
1094 time_after(jiffies + 5, fd_timer.expires))
1095 /* If the check for a disk change is done too early after this
1096 * last seek command, the WP bit still reads wrong :-((
1097 */
1098 mod_timer(&fd_timer, jiffies + 5);
1099 else {
1100 /* START_CHECK_CHANGE_TIMER( CHECK_CHANGE_DELAY ); */
1101 };
1102 del_timer(&motor_off_timer);
1103 START_MOTOR_OFF_TIMER(FD_MOTOR_OFF_DELAY);
1104
1105 save_flags(flags);
1106 cli();
1107 /* stdma_release(); - not sure if I should do something DAG */
1108 fdc_busy = 0;
1109 wake_up(&fdc_wait);
1110 restore_flags(flags);
1111
1112 DPRINT(("finish_fdc() finished\n"));
1113}
1114
1115
1116/* Prevent "aliased" accesses. */
1117static int fd_ref[4];
1118static int fd_device[4];
1119
1120/* dummy for blk.h */
1121static void floppy_off(unsigned int nr)
1122{
1123}
1124
1125
1126/* On the old arcs write protect depends on the particular model
1127 of machine. On the A310, R140, and A440 there is a disc changed
1128 detect, however on the A4x0/1 range there is not. There
1129 is nothing to tell you which machine your on.
1130 At the moment I'm just marking changed always. I've
1131 left the Atari's 'change on write protect change' code in this
1132 part (but nothing sets it).
1133 RiscOS apparently checks the disc serial number etc. to detect changes
1134 - but if it sees a disc change line go high (?) it flips to using
1135 it. Well maybe I'll add that in the future (!?)
1136*/
1137static int check_floppy_change(struct gendisk *disk)
1138{
1139 struct archy_floppy_struct *p = disk->private_data;
1140 unsigned int drive = p - unit;
1141
1142 if (test_bit(drive, &fake_change)) {
1143 /* simulated change (e.g. after formatting) */
1144 return 1;
1145 }
1146 if (test_bit(drive, &changed_floppies)) {
1147 /* surely changed (the WP signal changed at least once) */
1148 return 1;
1149 }
1150 if (p->wpstat) {
1151 /* WP is on -> could be changed: to be sure, buffers should be
1152 * invalidated...
1153 */
1154 return 1;
1155 }
1156 return 1; /* DAG - was 0 */
1157}
1158
1159static int floppy_revalidate(struct gendisk *disk)
1160{
1161 struct archy_floppy_struct *p = disk->private_data;
1162 unsigned int drive = p - unit;
1163
1164 if (test_bit(drive, &changed_floppies) || test_bit(drive, &fake_change)
1165 || unit[drive].disktype == 0) {
1166#ifdef TRACKBUFFER
1167 BufferDrive = -1;
1168#endif
1169 clear_bit(drive, &fake_change);
1170 clear_bit(drive, &changed_floppies);
1171 p->disktype = 0;
1172 }
1173 return 0;
1174}
1175
1176/* This sets up the global variables describing the current request. */
1177
1178static void setup_req_params(int drive)
1179{
1180 int block = ReqBlock + ReqCnt;
1181
1182 ReqTrack = block / unit[drive].disktype->spt;
1183 ReqSector = block - ReqTrack * unit[drive].disktype->spt + 1;
1184 ReqSide = ReqTrack & 1;
1185 ReqTrack >>= 1;
1186 ReqData = ReqBuffer + 512 * ReqCnt;
1187
1188#ifdef TRACKBUFFER
1189 read_track = (ReqCmd == READ && CURRENT->errors == 0);
1190#endif
1191
1192 DPRINT(("Request params: Si=%d Tr=%d Se=%d Data=%08lx\n", ReqSide,
1193 ReqTrack, ReqSector, (unsigned long) ReqData));
1194}
1195
1196
1197static void redo_fd_request(void)
1198{
1199 int drive, type;
1200 struct archy_floppy_struct *floppy;
1201
1202 DPRINT(("redo_fd_request: CURRENT=%p dev=%s CURRENT->sector=%ld\n",
1203 CURRENT, CURRENT ? CURRENT->rq_disk->disk_name : "",
1204 CURRENT ? CURRENT->sector : 0));
1205
1206repeat:
1207
1208 if (!CURRENT)
1209 goto the_end;
1210
1211 floppy = CURRENT->rq_disk->private_data;
1212 drive = floppy - unit;
1213 type = fd_device[drive];
1214
1215 if (!floppy->connected) {
1216 /* drive not connected */
1217 printk("Unknown Device: fd%d\n", drive);
1218 end_request(CURRENT, 0);
1219 goto repeat;
1220 }
1221 if (type == 0) {
1222 if (!floppy->disktype) {
1223 Probing = 1;
1224 floppy->disktype = disk_type + NUM_DISK_TYPES - 1;
1225 set_capacity(disks[drive], floppy->disktype->blocks);
1226 floppy->autoprobe = 1;
1227 }
1228 } else {
1229 /* user supplied disk type */
1230 --type;
1231 if (type >= NUM_DISK_TYPES) {
1232 printk("fd%d: invalid disk format", drive);
1233 end_request(CURRENT, 0);
1234 goto repeat;
1235 }
1236 floppy->disktype = &disk_type[type];
1237 set_capacity(disks[drive], floppy->disktype->blocks);
1238 floppy->autoprobe = 0;
1239 }
1240
1241 if (CURRENT->sector + 1 > floppy->disktype->blocks) {
1242 end_request(CURRENT, 0);
1243 goto repeat;
1244 }
1245 /* stop deselect timer */
1246 del_timer(&motor_off_timer);
1247
1248 ReqCnt = 0;
1249 ReqCmd = rq_data_dir(CURRENT);
1250 ReqBlock = CURRENT->sector;
1251 ReqBuffer = CURRENT->buffer;
1252 setup_req_params(drive);
1253 do_fd_action(drive);
1254
1255 return;
1256
1257the_end:
1258 finish_fdc();
1259}
1260
1261static void fd1772_checkint(void)
1262{
1263 extern int fdc1772_bytestogo;
1264
1265 /*printk("fd1772_checkint %d\n",fdc1772_fdc_int_done);*/
1266 if (fdc1772_fdc_int_done)
1267 floppy_irqconsequencehandler();
1268 if ((MultReadInProgress) && (fdc1772_bytestogo==0)) fd_readtrack_check(0);
1269 if (fdc_busy) {
1270 schedule_work(&fd1772_tq);
1271 }
1272}
1273
1274static void do_fd_request(request_queue_t* q)
1275{
1276 unsigned long flags;
1277
1278 DPRINT(("do_fd_request for pid %d\n", current->pid));
1279 if (fdc_busy) return;
1280 save_flags(flags);
1281 cli();
1282 wait_event(fdc_wait, !fdc_busy);
1283 fdc_busy = 1;
1284 ENABLE_IRQ();
1285 restore_flags(flags);
1286
1287 fdc1772_fdc_int_done = 0;
1288
1289 redo_fd_request();
1290
1291 schedule_work(&fd1772_tq);
1292}
1293
1294
1295static int invalidate_drive(struct block_device *bdev)
1296{
1297 struct archy_floppy_struct *p = bdev->bd_disk->private_data;
1298 /* invalidate the buffer track to force a reread */
1299#ifdef TRACKBUFFER
1300 BufferDrive = -1;
1301#endif
1302
1303 set_bit(p - unit, &fake_change);
1304 return 0;
1305}
1306
1307static int fd_ioctl(struct inode *inode, struct file *filp,
1308 unsigned int cmd, unsigned long param)
1309{
1310 struct block_device *bdev = inode->i_bdev;
1311
1312 switch (cmd) {
1313 case FDFMTEND:
1314 case FDFLUSH:
1315 invalidate_drive(bdev);
1316 check_disk_change(bdev);
1317 case FDFMTBEG:
1318 return 0;
1319 default:
1320 return -EINVAL;
1321 }
1322}
1323
1324
1325/* Initialize the 'unit' variable for drive 'drive' */
1326
1327static void fd_probe(int drive)
1328{
1329 unit[drive].connected = 0;
1330 unit[drive].disktype = NULL;
1331
1332 if (!fd_test_drive_present(drive))
1333 return;
1334
1335 unit[drive].connected = 1;
1336 unit[drive].track = -1; /* If we put the auto detect back in this can go to 0 */
1337 unit[drive].steprate = FDC1772STEP_6;
1338 MotorOn = 1; /* from probe restore operation! */
1339}
1340
1341
1342/* This function tests the physical presence of a floppy drive (not
1343 * whether a disk is inserted). This is done by issuing a restore
1344 * command, waiting max. 2 seconds (that should be enough to move the
1345 * head across the whole disk) and looking at the state of the "TR00"
1346 * signal. This should now be raised if there is a drive connected
1347 * (and there is no hardware failure :-) Otherwise, the drive is
1348 * declared absent.
1349 */
1350
1351static int fd_test_drive_present(int drive)
1352{
1353 unsigned long timeout;
1354 unsigned char status;
1355 int ok;
1356
1357 printk("fd_test_drive_present %d\n", drive);
1358 if (drive > 1)
1359 return (0);
1360 return (1); /* Simple hack for the moment - the autodetect doesn't seem to work on arc */
1361 fd_select_drive(drive);
1362
1363 /* disable interrupt temporarily */
1364 DISABLE_IRQ();
1365 FDC1772_WRITE(FDC1772REG_TRACK, 0x00); /* was ff00 why? */
1366 FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_RESTORE | FDC1772CMDADD_H | FDC1772STEP_6);
1367
1368 /*printk("fd_test_drive_present: Going into timeout loop\n"); */
1369 for (ok = 0, timeout = jiffies + 2 * HZ + HZ / 2; time_before(jiffies, timeout);) {
1370 /* What does this piece of atariism do? - query for an interrupt? */
1371 /* if (!(mfp.par_dt_reg & 0x20))
1372 break; */
1373 /* Well this is my nearest guess - quit when we get an FDC interrupt */
1374 if (ioc_readb(IOC_FIQSTAT) & 2)
1375 break;
1376 }
1377
1378 /*printk("fd_test_drive_present: Coming out of timeout loop\n"); */
1379 status = FDC1772_READ(FDC1772REG_STATUS);
1380 ok = (status & FDC1772STAT_TR00) != 0;
1381
1382 /*printk("fd_test_drive_present: ok=%d\n",ok); */
1383 /* force interrupt to abort restore operation (FDC1772 would try
1384 * about 50 seconds!) */
1385 FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_FORCI);
1386 udelay(500);
1387 status = FDC1772_READ(FDC1772REG_STATUS);
1388 udelay(20);
1389 /*printk("fd_test_drive_present: just before OK code %d\n",ok); */
1390
1391 if (ok) {
1392 /* dummy seek command to make WP bit accessible */
1393 FDC1772_WRITE(FDC1772REG_DATA, 0);
1394 FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_SEEK);
1395 printk("fd_test_drive_present: just before wait for int\n");
1396 /* DAG: Guess means wait for interrupt */
1397 while (!(ioc_readb(IOC_FIQSTAT) & 2));
1398 printk("fd_test_drive_present: just after wait for int\n");
1399 status = FDC1772_READ(FDC1772REG_STATUS);
1400 }
1401 printk("fd_test_drive_present: just before ENABLE_IRQ\n");
1402 ENABLE_IRQ();
1403 printk("fd_test_drive_present: about to return\n");
1404 return (ok);
1405}
1406
1407
1408/* Look how many and which kind of drives are connected. If there are
1409 * floppies, additionally start the disk-change and motor-off timers.
1410 */
1411
1412static void config_types(void)
1413{
1414 int drive, cnt = 0;
1415
1416 printk("Probing floppy drive(s):\n");
1417 for (drive = 0; drive < FD_MAX_UNITS; drive++) {
1418 fd_probe(drive);
1419 if (unit[drive].connected) {
1420 printk("fd%d\n", drive);
1421 ++cnt;
1422 }
1423 }
1424
1425 if (FDC1772_READ(FDC1772REG_STATUS) & FDC1772STAT_BUSY) {
1426 /* If FDC1772 is still busy from probing, give it another FORCI
1427 * command to abort the operation. If this isn't done, the FDC1772
1428 * will interrupt later and its IRQ line stays low, because
1429 * the status register isn't read. And this will block any
1430 * interrupts on this IRQ line :-(
1431 */
1432 FDC1772_WRITE(FDC1772REG_CMD, FDC1772CMD_FORCI);
1433 udelay(500);
1434 FDC1772_READ(FDC1772REG_STATUS);
1435 udelay(20);
1436 }
1437 if (cnt > 0) {
1438 START_MOTOR_OFF_TIMER(FD_MOTOR_OFF_DELAY);
1439 if (cnt == 1)
1440 fd_select_drive(0);
1441 /*START_CHECK_CHANGE_TIMER( CHECK_CHANGE_DELAY ); */
1442 }
1443}
1444
1445/*
1446 * floppy_open check for aliasing (/dev/fd0 can be the same as
1447 * /dev/PS0 etc), and disallows simultaneous access to the same
1448 * drive with different device numbers.
1449 */
1450
1451static int floppy_open(struct inode *inode, struct file *filp)
1452{
1453 int drive = iminor(inode) & 3;
1454 int type = iminor(inode) >> 2;
1455 int old_dev = fd_device[drive];
1456
1457 if (fd_ref[drive] && old_dev != type)
1458 return -EBUSY;
1459
1460 if (fd_ref[drive] == -1 || (fd_ref[drive] && filp->f_flags & O_EXCL))
1461 return -EBUSY;
1462
1463 if (filp->f_flags & O_EXCL)
1464 fd_ref[drive] = -1;
1465 else
1466 fd_ref[drive]++;
1467
1468 fd_device[drive] = type;
1469
1470 if (filp->f_flags & O_NDELAY)
1471 return 0;
1472
1473 if (filp->f_mode & 3) {
1474 check_disk_change(inode->i_bdev);
1475 if (filp->f_mode & 2) {
1476 if (unit[drive].wpstat) {
1477 floppy_release(inode, filp);
1478 return -EROFS;
1479 }
1480 }
1481 }
1482 return 0;
1483}
1484
1485
1486static int floppy_release(struct inode *inode, struct file *filp)
1487{
1488 int drive = iminor(inode) & 3;
1489
1490 if (fd_ref[drive] < 0)
1491 fd_ref[drive] = 0;
1492 else if (!fd_ref[drive]--) {
1493 printk("floppy_release with fd_ref == 0");
1494 fd_ref[drive] = 0;
1495 }
1496
1497 return 0;
1498}
1499
1500static struct block_device_operations floppy_fops =
1501{
1502 .open = floppy_open,
1503 .release = floppy_release,
1504 .ioctl = fd_ioctl,
1505 .media_changed = check_floppy_change,
1506 .revalidate_disk= floppy_revalidate,
1507};
1508
1509static struct kobject *floppy_find(dev_t dev, int *part, void *data)
1510{
1511 int drive = *part & 3;
1512 if ((*part >> 2) > NUM_DISK_TYPES || drive >= FD_MAX_UNITS)
1513 return NULL;
1514 *part = 0;
1515 return get_disk(disks[drive]);
1516}
1517
1518int fd1772_init(void)
1519{
1520 static DEFINE_SPINLOCK(lock);
1521 int i, err = -ENOMEM;
1522
1523 if (!machine_is_archimedes())
1524 return 0;
1525
1526 for (i = 0; i < FD_MAX_UNITS; i++) {
1527 disks[i] = alloc_disk(1);
1528 if (!disks[i])
1529 goto err_disk;
1530 }
1531
1532 err = register_blkdev(MAJOR_NR, "fd");
1533 if (err)
1534 goto err_disk;
1535
1536 err = -EBUSY;
1537 if (request_dma(FLOPPY_DMA, "fd1772")) {
1538 printk("Unable to grab DMA%d for the floppy (1772) driver\n", FLOPPY_DMA);
1539 goto err_blkdev;
1540 };
1541
1542 if (request_dma(FIQ_FD1772, "fd1772 end")) {
1543 printk("Unable to grab DMA%d for the floppy (1772) driver\n", FIQ_FD1772);
1544 goto err_dma1;
1545 };
1546
1547 /* initialize variables */
1548 SelectedDrive = -1;
1549#ifdef TRACKBUFFER
1550 BufferDrive = BufferSide = BufferTrack = -1;
1551 /* Atari uses 512 - I want to eventually cope with 1K sectors */
1552 DMABuffer = kmalloc((FD1772_MAX_SECTORS+1)*512,GFP_KERNEL);
1553 TrackBuffer = DMABuffer + 512;
1554#else
1555 /* Allocate memory for the DMAbuffer - on the Atari this takes it
1556 out of some special memory... */
1557 DMABuffer = kmalloc(2048); /* Copes with pretty large sectors */
1558#endif
1559 err = -ENOMEM;
1560 if (!DMAbuffer)
1561 goto err_dma2;
1562
1563 enable_dma(FIQ_FD1772); /* This inserts a call to our command end routine */
1564
1565 floppy_queue = blk_init_queue(do_fd_request, &lock);
1566 if (!floppy_queue)
1567 goto err_queue;
1568
1569 for (i = 0; i < FD_MAX_UNITS; i++) {
1570 unit[i].track = -1;
1571 disks[i]->major = MAJOR_NR;
1572 disks[i]->first_minor = 0;
1573 disks[i]->fops = &floppy_fops;
1574 sprintf(disks[i]->disk_name, "fd%d", i);
1575 disks[i]->private_data = &unit[i];
1576 disks[i]->queue = floppy_queue;
1577 set_capacity(disks[i], MAX_DISK_SIZE * 2);
1578 }
1579 blk_register_region(MKDEV(MAJOR_NR, 0), 256, THIS_MODULE,
1580 floppy_find, NULL, NULL);
1581
1582 for (i = 0; i < FD_MAX_UNITS; i++)
1583 add_disk(disks[i]);
1584
1585 config_types();
1586
1587 return 0;
1588
1589 err_queue:
1590 kfree(DMAbuffer);
1591 err_dma2:
1592 free_dma(FIQ_FD1772);
1593
1594 err_dma1:
1595 free_dma(FLOPPY_DMA);
1596
1597 err_blkdev:
1598 unregister_blkdev(MAJOR_NR, "fd");
1599
1600 err_disk:
1601 while (i--)
1602 put_disk(disks[i]);
1603 return err;
1604}
diff --git a/drivers/acorn/block/fd1772dma.S b/drivers/acorn/block/fd1772dma.S
deleted file mode 100644
index 7964435443ec..000000000000
--- a/drivers/acorn/block/fd1772dma.S
+++ /dev/null
@@ -1,100 +0,0 @@
1#include <asm/hardware.h>
2
3@ Code for DMA with the 1772 fdc
4.text
5
6
7 .global fdc1772_dataaddr
8fdc1772_fiqdata:
9@ Number of bytes left to DMA
10 .global fdc1772_bytestogo
11fdc1772_bytestogo:
12 .word 0
13@ Place to put/get data from in DMA
14 .global fdc1772_dataaddr
15fdc1772_dataaddr:
16 .word 0
17
18 .global fdc1772_fdc_int_done
19fdc1772_fdc_int_done:
20 .word 0
21 .global fdc1772_comendstatus
22fdc1772_comendstatus:
23 .word 0
24
25@ We hang this off DMA channel 1
26 .global fdc1772_comendhandler
27fdc1772_comendhandler:
28 mov r8,#IOC_BASE
29 ldrb r9,[r8,#0x34] @ IOC FIQ status
30 tst r9,#2
31 subeqs pc,r14,#4 @ should I leave a space here
32 orr r9,r8,#0x10000 @ FDC base
33 adr r8,fdc1772_fdc_int_done
34 ldrb r10,[r9,#0] @ FDC status
35 mov r9,#1 @ Got a FIQ flag
36 stmia r8,{r9,r10}
37 subs pc,r14,#4
38
39
40 .global fdc1772_dma_read
41fdc1772_dma_read:
42 mov r8,#IOC_BASE
43 ldrb r9,[r8,#0x34] @ IOC FIQ status
44 tst r9,#1
45 beq fdc1772_dma_read_notours
46 orr r8,r8,#0x10000 @ FDC base
47 ldrb r10,[r8,#0xc] @ Read from FDC data reg (also clears interrupt)
48 ldmia r11,{r8,r9}
49 subs r8,r8,#1 @ One less byte to go
50 @ If there was somewhere for this data to go then store it and update pointers
51 strplb r10,[r9],#1 @ Store the data and increment the pointer
52 stmplia r11,{r8,r9} @ Update count/pointers
53 @ Handle any other interrupts if there are any
54fdc1772_dma_read_notours:
55 @ Cant branch because this code has been copied down to the FIQ vector
56 ldr pc,[pc,#-4]
57 .word fdc1772_comendhandler
58 .global fdc1772_dma_read_end
59fdc1772_dma_read_end:
60
61 .global fdc1772_dma_write
62fdc1772_dma_write:
63 mov r8,#IOC_BASE
64 ldrb r9,[r8,#0x34] @ IOC FIQ status
65 tst r9,#1
66 beq fdc1772_dma_write_notours
67 orr r8,r8,#0x10000 @ FDC base
68 ldmia r11,{r9,r10}
69 subs r9,r9,#1 @ One less byte to go
70 @ If there really is some data then get it, store it and update count
71 ldrplb r12,[r10],#1
72 strplb r12,[r8,#0xc] @ write it to FDC data reg
73 stmplia r11,{r9,r10} @ Update count and pointer - should clear interrupt
74 @ Handle any other interrupts
75fdc1772_dma_write_notours:
76 @ Cant branch because this code has been copied down to the FIQ vector
77 ldr pc,[pc,#-4]
78 .word fdc1772_comendhandler
79
80 .global fdc1772_dma_write_end
81fdc1772_dma_write_end:
82
83
84@ Setup the FIQ R11 to point to the data and store the count, address
85@ for this dma
86@ R0=count
87@ R1=address
88 .global fdc1772_setupdma
89fdc1772_setupdma:
90 @ The big job is flipping in and out of FIQ mode
91 adr r2,fdc1772_fiqdata @ This is what we really came here for
92 stmia r2,{r0,r1}
93 mov r3, pc
94 teqp pc,#0x0c000001 @ Disable FIQs, IRQs and switch to FIQ mode
95 mov r0,r0 @ NOP
96 mov r11,r2
97 teqp r3,#0 @ Normal mode
98 mov r0,r0 @ NOP
99 mov pc,r14
100
diff --git a/drivers/acorn/block/mfm.S b/drivers/acorn/block/mfm.S
deleted file mode 100644
index c90cbd41ce21..000000000000
--- a/drivers/acorn/block/mfm.S
+++ /dev/null
@@ -1,162 +0,0 @@
1@ Read/Write DMA code for the ST506/MFM hard drive controllers on the A400 Acorn Archimedes
2@ motherboard and on ST506 expansion podules.
3@ (c) David Alan Gilbert (linux@treblig.org) 1996-1999
4
5#include <asm/assembler.h>
6
7hdc63463_irqdata:
8@ Controller base address
9 .global hdc63463_baseaddress
10hdc63463_baseaddress:
11 .word 0
12
13 .global hdc63463_irqpolladdress
14hdc63463_irqpolladdress:
15 .word 0
16
17 .global hdc63463_irqpollmask
18hdc63463_irqpollmask:
19 .word 0
20
21@ where to read/write data from the kernel data space
22 .global hdc63463_dataptr
23hdc63463_dataptr:
24 .word 0
25
26@ Number of bytes left to transfer
27 .global hdc63463_dataleft
28hdc63463_dataleft:
29 .word 0
30
31@ -------------------------------------------------------------------------
32@ hdc63463_writedma: DMA from host to controller
33@ internal reg usage: r0=hdc base address, r1=irq poll address, r2=poll mask
34@ r3=data ptr, r4=data left, r5,r6=temporary
35 .global hdc63463_writedma
36hdc63463_writedma:
37 stmfd sp!,{r4-r7}
38 adr r5,hdc63463_irqdata
39 ldmia r5,{r0,r1,r2,r3,r4}
40
41writedma_again:
42
43 @ test number of remaining bytes to transfer
44 cmp r4,#0
45 beq writedma_end
46 bmi writedma_end
47
48 @ Check the hdc is interrupting
49 ldrb r5,[r1,#0]
50 tst r5,r2
51 beq writedma_end
52
53 @ Transfer a block of upto 256 bytes
54 cmp r4,#256
55 movlt r7,r4
56 movge r7,#256
57
58 @ Check the hdc is still busy and command has not ended and no errors
59 ldr r5,[r0,#32] @ Status reg - 16 bit - its the top few bits which are status
60 @ think we should continue DMA until it drops busy - perhaps this was
61 @ the main problem with corrected errors causing a hang
62 @tst r5,#0x3c00 @ Test for things which should be off
63 @bne writedma_end
64 and r5,r5,#0x8000 @ This is test for things which should be on: Busy
65 cmp r5,#0x8000
66 bne writedma_end
67
68 @ Bytes remaining at end
69 sub r4,r4,r7
70
71 @ HDC Write register location
72 add r0,r0,#32+8
73
74writedma_loop:
75 @ OK - pretty sure we should be doing this
76
77 ldr r5,[r3],#4 @ Get a word to be written
78 @ get bottom half to be sent first
79 mov r6,r5,lsl#16 @ Separate the first 2 bytes
80 orr r2,r6,r6,lsr #16 @ Duplicate them in the bottom half of the word
81 @ now the top half
82 mov r6,r5,lsr#16 @ Get 2nd 2 bytes
83 orr r6,r6,r6,lsl#16 @ Duplicate
84 @str r6,[r0] @ to hdc
85 stmia r0,{r2,r6}
86 subs r7,r7,#4 @ Dec. number of bytes left
87 bne writedma_loop
88
89 @ If we were too slow we had better go through again - DAG - took out with new interrupt routine
90 @ sub r0,r0,#32+8
91 @ adr r2,hdc63463_irqdata
92 @ ldr r2,[r2,#8]
93 @ b writedma_again
94
95writedma_end:
96 adr r5,hdc63463_irqdata+12
97 stmia r5,{r3,r4}
98 ldmfd sp!,{r4-r7}
99 RETINSTR(mov,pc,lr)
100
101@ -------------------------------------------------------------------------
102@ hdc63463_readdma: DMA from controller to host
103@ internal reg usage: r0=hdc base address, r1=irq poll address, r2=poll mask
104@ r3=data ptr, r4=data left, r5,r6=temporary
105 .global hdc63463_readdma
106hdc63463_readdma:
107 stmfd sp!,{r4-r7}
108 adr r5,hdc63463_irqdata
109 ldmia r5,{r0,r1,r2,r3,r4}
110
111readdma_again:
112 @ test number of remaining bytes to transfer
113 cmp r4,#0
114 beq readdma_end
115 bmi readdma_end
116
117 @ Check the hdc is interrupting
118 ldrb r5,[r1,#0]
119 tst r5,r2
120 beq readdma_end
121
122 @ Check the hdc is still busy and command has not ended and no errors
123 ldr r5,[r0,#32] @ Status reg - 16 bit - its the top few bits which are status
124 @ think we should continue DMA until it drops busy - perhaps this was
125 @ the main problem with corrected errors causing a hang
126 @tst r5,#0x3c00 @ Test for things which should be off
127 @bne readdma_end
128 and r5,r5,#0x8000 @ This is test for things which should be on: Busy
129 cmp r5,#0x8000
130 bne readdma_end
131
132 @ Transfer a block of upto 256 bytes
133 cmp r4,#256
134 movlt r7,r4
135 movge r7,#256
136
137 @ Bytes remaining at end
138 sub r4,r4,r7
139
140 @ Set a pointer to the data register in the HDC
141 add r0,r0,#8
142readdma_loop:
143 @ OK - pretty sure we should be doing this
144 ldmia r0,{r5,r6}
145 mov r5,r5,lsl#16
146 mov r6,r6,lsl#16
147 orr r6,r6,r5,lsr #16
148 str r6,[r3],#4
149 subs r7,r7,#4 @ Decrement bytes to go
150 bne readdma_loop
151
152 @ Try reading multiple blocks - if this was fast enough then I do not think
153 @ this should help - NO taken out DAG - new interrupt handler has
154 @ non-consecutive memory blocks
155 @ sub r0,r0,#8
156 @ b readdma_again
157
158readdma_end:
159 adr r5,hdc63463_irqdata+12
160 stmia r5,{r3,r4}
161 ldmfd sp!,{r4-r7}
162 RETINSTR(mov,pc,lr)
diff --git a/drivers/acorn/block/mfmhd.c b/drivers/acorn/block/mfmhd.c
deleted file mode 100644
index d85520f78e68..000000000000
--- a/drivers/acorn/block/mfmhd.c
+++ /dev/null
@@ -1,1385 +0,0 @@
1/*
2 * linux/drivers/acorn/block/mfmhd.c
3 *
4 * Copyright (C) 1995, 1996 Russell King, Dave Alan Gilbert (gilbertd@cs.man.ac.uk)
5 *
6 * MFM hard drive code [experimental]
7 */
8
9/*
10 * Change list:
11 *
12 * 3/2/96:DAG: Started a change list :-)
13 * Set the hardsect_size pointers up since we are running 256 byte
14 * sectors
15 * Added DMA code, put it into the rw_intr
16 * Moved RCAL out of generic interrupt code - don't want to do it
17 * while DMA'ing - its now in individual handlers.
18 * Took interrupt handlers off task queue lists and called
19 * directly - not sure of implications.
20 *
21 * 18/2/96:DAG: Well its reading OK I think, well enough for image file code
22 * to find the image file; but now I've discovered that I actually
23 * have to put some code in for image files.
24 *
25 * Added stuff for image files; seems to work, but I've not
26 * got a multisegment image file (I don't think!).
27 * Put in a hack (yep a real hack) for multiple cylinder reads.
28 * Not convinced its working.
29 *
30 * 5/4/96:DAG: Added asm/hardware.h and use IOC_ macros
31 * Rewrote dma code in mfm.S (again!) - now takes a word at a time
32 * from main RAM for speed; still doesn't feel speedy!
33 *
34 * 20/4/96:DAG: After rewriting mfm.S a heck of a lot of times and speeding
35 * things up, I've finally figured out why its so damn slow.
36 * Linux is only reading a block at a time, and so you never
37 * get more than 1K per disc revoloution ~=60K/second.
38 *
39 * 27/4/96:DAG: On Russell's advice I change ll_rw_blk.c to ask it to
40 * join adjacent blocks together. Everything falls flat on its
41 * face.
42 * Four hours of debugging later; I hadn't realised that
43 * ll_rw_blk would be so generous as to join blocks whose
44 * results aren't going into consecutive buffers.
45 *
46 * OK; severe rehacking of mfm_rw_interrupt; now end_request's
47 * as soon as its DMA'd each request. Odd thing is that
48 * we are sometimes getting interrupts where we are not transferring
49 * any data; why? Is that what happens when you miss? I doubt
50 * it; are we too fast? No - its just at command ends. Got 240K/s
51 * better than before, but RiscOS hits 480K/s
52 *
53 * 25/6/96:RMK: Fixed init code to allow the MFM podule to work. Increased the
54 * number of errors for my Miniscribe drive (8425).
55 *
56 * 30/6/96:DAG: Russell suggested that a check drive 0 might turn the LEDs off
57 * - so in request_done just before it clears Busy it sends a
58 * check drive 0 - and the LEDs go off!!!!
59 *
60 * Added test for mainboard controller. - Removes need for separate
61 * define.
62 *
63 * 13/7/96:DAG: Changed hardware sectore size to 512 in attempt to make
64 * IM drivers work.
65 * 21/7/96:DAG: Took out old image file stuff (accessing it now produces an IO
66 * error.)
67 *
68 * 17/8/96:DAG: Ran through indent -kr -i8; evil - all my nice 2 character indents
69 * gone :-( Hand modified afterwards.
70 * Took out last remains of the older image map system.
71 *
72 * 22/9/96:DAG: Changed mfm.S so it will carry on DMA'ing til; BSY is dropped
73 * Changed mfm_rw_intr so that it doesn't follow the error
74 * code until BSY is dropped. Nope - still broke. Problem
75 * may revolve around when it reads the results for the error
76 * number?
77 *
78 *16/11/96:DAG: Modified for 2.0.18; request_irq changed
79 *
80 *17/12/96:RMK: Various cleanups, reorganisation, and the changes for new IO system.
81 * Improved probe for onboard MFM chip - it was hanging on my A5k.
82 * Added autodetect CHS code such that we don't rely on the presence
83 * of an ADFS boot block. Added ioport resource manager calls so
84 * that we don't clash with already-running hardware (eg. RiscPC Ether
85 * card slots if someone tries this)!
86 *
87 * 17/1/97:RMK: Upgraded to 2.1 kernels.
88 *
89 * 4/3/98:RMK: Changed major number to 21.
90 *
91 * 27/6/98:RMK: Changed asm/delay.h to linux/delay.h for mdelay().
92 */
93
94/*
95 * Possible enhancements:
96 * Multi-thread the code so that it is possible that while one drive
97 * is seeking, the other one can be reading data/seeking as well.
98 * This would be a performance boost with dual drive systems.
99 */
100
101#include <linux/module.h>
102#include <linux/fs.h>
103#include <linux/interrupt.h>
104#include <linux/kernel.h>
105#include <linux/timer.h>
106#include <linux/mm.h>
107#include <linux/errno.h>
108#include <linux/genhd.h>
109#include <linux/major.h>
110#include <linux/ioport.h>
111#include <linux/delay.h>
112#include <linux/blkpg.h>
113
114#include <asm/system.h>
115#include <asm/io.h>
116#include <asm/irq.h>
117#include <asm/uaccess.h>
118#include <asm/dma.h>
119#include <asm/hardware.h>
120#include <asm/ecard.h>
121#include <asm/hardware/ioc.h>
122
123static void (*do_mfm)(void) = NULL;
124static struct request_queue *mfm_queue;
125static DEFINE_SPINLOCK(mfm_lock);
126
127#define MAJOR_NR MFM_ACORN_MAJOR
128#define QUEUE (mfm_queue)
129#define CURRENT elv_next_request(mfm_queue)
130
131/*
132 * Configuration section
133 *
134 * This is the maximum number of drives that we accept
135 */
136#define MFM_MAXDRIVES 2
137/*
138 * Linux I/O address of onboard MFM controller or 0 to disable this
139 */
140#define ONBOARD_MFM_ADDRESS ((0x002d0000 >> 2) | 0x80000000)
141/*
142 * Uncomment this to enable debugging in the MFM driver...
143 */
144#ifndef DEBUG
145/*#define DEBUG */
146#endif
147/*
148 * End of configuration
149 */
150
151
152/*
153 * This structure contains all information to do with a particular physical
154 * device.
155 */
156struct mfm_info {
157 unsigned char sectors;
158 unsigned char heads;
159 unsigned short cylinders;
160 unsigned short lowcurrent;
161 unsigned short precomp;
162#define NO_TRACK -1
163#define NEED_1_RECAL -2
164#define NEED_2_RECAL -3
165 int cylinder;
166 struct {
167 char recal;
168 char report;
169 char abort;
170 } errors;
171} mfm_info[MFM_MAXDRIVES];
172
173#define MFM_DRV_INFO mfm_info[raw_cmd.dev]
174
175/* Stuff from the assembly routines */
176extern unsigned int hdc63463_baseaddress; /* Controller base address */
177extern unsigned int hdc63463_irqpolladdress; /* Address to read to test for int */
178extern unsigned int hdc63463_irqpollmask; /* Mask for irq register */
179extern unsigned int hdc63463_dataptr; /* Pointer to kernel data space to DMA */
180extern int hdc63463_dataleft; /* Number of bytes left to transfer */
181
182
183
184
185static int lastspecifieddrive;
186static unsigned Busy;
187
188static unsigned int PartFragRead; /* The number of sectors which have been read
189 during a partial read split over two
190 cylinders. If 0 it means a partial
191 read did not occur. */
192
193static unsigned int PartFragRead_RestartBlock; /* Where to restart on a split access */
194static unsigned int PartFragRead_SectorsLeft; /* Where to restart on a split access */
195
196static int Sectors256LeftInCurrent; /* i.e. 256 byte sectors left in current */
197static int SectorsLeftInRequest; /* i.e. blocks left in the thing mfm_request was called for */
198static int Copy_Sector; /* The 256 byte sector we are currently at - fragments need to know
199 where to take over */
200static char *Copy_buffer;
201
202
203static void mfm_seek(void);
204static void mfm_rerequest(void);
205static void mfm_request(void);
206static void mfm_specify (void);
207static void issue_request(unsigned int block, unsigned int nsect,
208 struct request *req);
209
210static unsigned int mfm_addr; /* Controller address */
211static unsigned int mfm_IRQPollLoc; /* Address to read for IRQ information */
212static unsigned int mfm_irqenable; /* Podule IRQ enable location */
213static unsigned char mfm_irq; /* Interrupt number */
214static int mfm_drives = 0; /* drives available */
215static int mfm_status = 0; /* interrupt status */
216static int *errors;
217
218static struct rawcmd {
219 unsigned int dev;
220 unsigned int cylinder;
221 unsigned int head;
222 unsigned int sector;
223 unsigned int cmdtype;
224 unsigned int cmdcode;
225 unsigned char cmddata[16];
226 unsigned int cmdlen;
227} raw_cmd;
228
229static unsigned char result[16];
230
231static struct cont {
232 void (*interrupt) (void); /* interrupt handler */
233 void (*error) (void); /* error handler */
234 void (*redo) (void); /* redo handler */
235 void (*done) (int st); /* done handler */
236} *cont = NULL;
237
238#if 0
239static struct tq_struct mfm_tq = {0, 0, (void (*)(void *)) NULL, 0};
240#endif
241
242int number_mfm_drives = 1;
243
244/* ------------------------------------------------------------------------------------------ */
245/*
246 * From the HD63463 data sheet from Hitachi Ltd.
247 */
248
249#define MFM_COMMAND (mfm_addr + 0)
250#define MFM_DATAOUT (mfm_addr + 1)
251#define MFM_STATUS (mfm_addr + 8)
252#define MFM_DATAIN (mfm_addr + 9)
253
254#define CMD_ABT 0xF0 /* Abort */
255#define CMD_SPC 0xE8 /* Specify */
256#define CMD_TST 0xE0 /* Test */
257#define CMD_RCLB 0xC8 /* Recalibrate */
258#define CMD_SEK 0xC0 /* Seek */
259#define CMD_WFS 0xAB /* Write Format Skew */
260#define CMD_WFM 0xA3 /* Write Format */
261#define CMD_MTB 0x90 /* Memory to buffer */
262#define CMD_CMPD 0x88 /* Compare data */
263#define CMD_WD 0x87 /* Write data */
264#define CMD_RED 0x70 /* Read erroneous data */
265#define CMD_RIS 0x68 /* Read ID skew */
266#define CMD_FID 0x61 /* Find ID */
267#define CMD_RID 0x60 /* Read ID */
268#define CMD_BTM 0x50 /* Buffer to memory */
269#define CMD_CKD 0x48 /* Check data */
270#define CMD_RD 0x40 /* Read data */
271#define CMD_OPBW 0x38 /* Open buffer write */
272#define CMD_OPBR 0x30 /* Open buffer read */
273#define CMD_CKV 0x28 /* Check drive */
274#define CMD_CKE 0x20 /* Check ECC */
275#define CMD_POD 0x18 /* Polling disable */
276#define CMD_POL 0x10 /* Polling enable */
277#define CMD_RCAL 0x08 /* Recall */
278
279#define STAT_BSY 0x8000 /* Busy */
280#define STAT_CPR 0x4000 /* Command Parameter Rejection */
281#define STAT_CED 0x2000 /* Command end */
282#define STAT_SED 0x1000 /* Seek end */
283#define STAT_DER 0x0800 /* Drive error */
284#define STAT_ABN 0x0400 /* Abnormal end */
285#define STAT_POL 0x0200 /* Polling */
286
287/* ------------------------------------------------------------------------------------------ */
288#ifdef DEBUG
289static void console_printf(const char *fmt,...)
290{
291 static char buffer[2048]; /* Arbitary! */
292 extern void console_print(const char *);
293 unsigned long flags;
294 va_list ap;
295
296 local_irq_save(flags);
297
298 va_start(ap, fmt);
299 vsprintf(buffer, fmt, ap);
300 console_print(buffer);
301 va_end(fmt);
302
303 local_irq_restore(flags);
304}; /* console_printf */
305
306#define DBG(x...) console_printf(x)
307#else
308#define DBG(x...)
309#endif
310
311static void print_status(void)
312{
313 char *error;
314 static char *errors[] = {
315 "no error",
316 "command aborted",
317 "invalid command",
318 "parameter error",
319 "not initialised",
320 "rejected TEST",
321 "no useld",
322 "write fault",
323 "not ready",
324 "no scp",
325 "in seek",
326 "invalid NCA",
327 "invalid step rate",
328 "seek error",
329 "over run",
330 "invalid PHA",
331 "data field EEC error",
332 "data field CRC error",
333 "error corrected",
334 "data field fatal error",
335 "no data am",
336 "not hit",
337 "ID field CRC error",
338 "time over",
339 "no ID am",
340 "not writable"
341 };
342 if (result[1] < 0x65)
343 error = errors[result[1] >> 2];
344 else
345 error = "unknown";
346 printk("(");
347 if (mfm_status & STAT_BSY) printk("BSY ");
348 if (mfm_status & STAT_CPR) printk("CPR ");
349 if (mfm_status & STAT_CED) printk("CED ");
350 if (mfm_status & STAT_SED) printk("SED ");
351 if (mfm_status & STAT_DER) printk("DER ");
352 if (mfm_status & STAT_ABN) printk("ABN ");
353 if (mfm_status & STAT_POL) printk("POL ");
354 printk(") SSB = %X (%s)\n", result[1], error);
355
356}
357
358/* ------------------------------------------------------------------------------------- */
359
360static void issue_command(int command, unsigned char *cmdb, int len)
361{
362 int status;
363#ifdef DEBUG
364 int i;
365 console_printf("issue_command: %02X: ", command);
366 for (i = 0; i < len; i++)
367 console_printf("%02X ", cmdb[i]);
368 console_printf("\n");
369#endif
370
371 do {
372 status = inw(MFM_STATUS);
373 } while (status & (STAT_BSY | STAT_POL));
374 DBG("issue_command: status after pol/bsy loop: %02X:\n ", status >> 8);
375
376 if (status & (STAT_CPR | STAT_CED | STAT_SED | STAT_DER | STAT_ABN)) {
377 outw(CMD_RCAL, MFM_COMMAND);
378 while (inw(MFM_STATUS) & STAT_BSY);
379 }
380 status = inw(MFM_STATUS);
381 DBG("issue_command: status before parameter issue: %02X:\n ", status >> 8);
382
383 while (len > 0) {
384 outw(cmdb[1] | (cmdb[0] << 8), MFM_DATAOUT);
385 len -= 2;
386 cmdb += 2;
387 }
388 status = inw(MFM_STATUS);
389 DBG("issue_command: status before command issue: %02X:\n ", status >> 8);
390
391 outw(command, MFM_COMMAND);
392 status = inw(MFM_STATUS);
393 DBG("issue_command: status immediately after command issue: %02X:\n ", status >> 8);
394}
395
396static void wait_for_completion(void)
397{
398 while ((mfm_status = inw(MFM_STATUS)) & STAT_BSY);
399}
400
401static void wait_for_command_end(void)
402{
403 int i;
404
405 while (!((mfm_status = inw(MFM_STATUS)) & STAT_CED));
406
407 for (i = 0; i < 16;) {
408 int in;
409 in = inw(MFM_DATAIN);
410 result[i++] = in >> 8;
411 result[i++] = in;
412 }
413 outw (CMD_RCAL, MFM_COMMAND);
414}
415
416/* ------------------------------------------------------------------------------------- */
417
418static void mfm_rw_intr(void)
419{
420 int old_status; /* Holds status on entry, we read to see if the command just finished */
421#ifdef DEBUG
422 console_printf("mfm_rw_intr...dataleft=%d\n", hdc63463_dataleft);
423 print_status();
424#endif
425
426 /* Now don't handle the error until BSY drops */
427 if ((mfm_status & (STAT_DER | STAT_ABN)) && ((mfm_status&STAT_BSY)==0)) {
428 /* Something has gone wrong - let's try that again */
429 outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */
430 if (cont) {
431 DBG("mfm_rw_intr: DER/ABN err\n");
432 cont->error();
433 cont->redo();
434 };
435 return;
436 };
437
438 /* OK so what ever happened it's not an error, now I reckon we are left between
439 a choice of command end or some data which is ready to be collected */
440 /* I think we have to transfer data while the interrupt line is on and its
441 not any other type of interrupt */
442 if (rq_data_dir(CURRENT) == WRITE) {
443 extern void hdc63463_writedma(void);
444 if ((hdc63463_dataleft <= 0) && (!(mfm_status & STAT_CED))) {
445 printk("mfm_rw_intr: Apparent DMA write request when no more to DMA\n");
446 if (cont) {
447 cont->error();
448 cont->redo();
449 };
450 return;
451 };
452 hdc63463_writedma();
453 } else {
454 extern void hdc63463_readdma(void);
455 if ((hdc63463_dataleft <= 0) && (!(mfm_status & STAT_CED))) {
456 printk("mfm_rw_intr: Apparent DMA read request when no more to DMA\n");
457 if (cont) {
458 cont->error();
459 cont->redo();
460 };
461 return;
462 };
463 DBG("Going to try read dma..............status=0x%x, buffer=%p\n", mfm_status, hdc63463_dataptr);
464 hdc63463_readdma();
465 }; /* Read */
466
467 if (hdc63463_dataptr != ((unsigned int) Copy_buffer + 256)) {
468 /* If we didn't actually manage to get any data on this interrupt - but why? We got the interrupt */
469 /* Ah - well looking at the status its just when we get command end; so no problem */
470 /*console_printf("mfm: dataptr mismatch. dataptr=0x%08x Copy_buffer+256=0x%08p\n",
471 hdc63463_dataptr,Copy_buffer+256);
472 print_status(); */
473 } else {
474 Sectors256LeftInCurrent--;
475 Copy_buffer += 256;
476 Copy_Sector++;
477
478 /* We have come to the end of this request */
479 if (!Sectors256LeftInCurrent) {
480 DBG("mfm: end_request for CURRENT=0x%p CURRENT(sector=%d current_nr_sectors=%d nr_sectors=%d)\n",
481 CURRENT, CURRENT->sector, CURRENT->current_nr_sectors, CURRENT->nr_sectors);
482
483 CURRENT->nr_sectors -= CURRENT->current_nr_sectors;
484 CURRENT->sector += CURRENT->current_nr_sectors;
485 SectorsLeftInRequest -= CURRENT->current_nr_sectors;
486
487 end_request(CURRENT, 1);
488 if (SectorsLeftInRequest) {
489 hdc63463_dataptr = (unsigned int) CURRENT->buffer;
490 Copy_buffer = CURRENT->buffer;
491 Sectors256LeftInCurrent = CURRENT->current_nr_sectors * 2;
492 errors = &(CURRENT->errors);
493 /* These should match the present calculations of the next logical sector
494 on the device
495 Copy_Sector=CURRENT->sector*2; */
496
497 if (Copy_Sector != CURRENT->sector * 2)
498#ifdef DEBUG
499 /*console_printf*/printk("mfm: Copy_Sector mismatch. Copy_Sector=%d CURRENT->sector*2=%d\n",
500 Copy_Sector, CURRENT->sector * 2);
501#else
502 printk("mfm: Copy_Sector mismatch! Eek!\n");
503#endif
504 }; /* CURRENT */
505 }; /* Sectors256LeftInCurrent */
506 };
507
508 old_status = mfm_status;
509 mfm_status = inw(MFM_STATUS);
510 if (mfm_status & (STAT_DER | STAT_ABN)) {
511 /* Something has gone wrong - let's try that again */
512 if (cont) {
513 DBG("mfm_rw_intr: DER/ABN error\n");
514 cont->error();
515 cont->redo();
516 };
517 return;
518 };
519
520 /* If this code wasn't entered due to command_end but there is
521 now a command end we must read the command results out. If it was
522 entered like this then mfm_interrupt_handler would have done the
523 job. */
524 if ((!((old_status & (STAT_CPR | STAT_BSY)) == STAT_CPR)) &&
525 ((mfm_status & (STAT_CPR | STAT_BSY)) == STAT_CPR)) {
526 int len = 0;
527 while (len < 16) {
528 int in;
529 in = inw(MFM_DATAIN);
530 result[len++] = in >> 8;
531 result[len++] = in;
532 };
533 }; /* Result read */
534
535 /*console_printf ("mfm_rw_intr nearexit [%02X]\n", __raw_readb(mfm_IRQPollLoc)); */
536
537 /* If end of command move on */
538 if (mfm_status & (STAT_CED)) {
539 outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */
540 /* End of command - trigger the next command */
541 if (cont) {
542 cont->done(1);
543 }
544 DBG("mfm_rw_intr: returned from cont->done\n");
545 } else {
546 /* Its going to generate another interrupt */
547 do_mfm = mfm_rw_intr;
548 };
549}
550
551static void mfm_setup_rw(void)
552{
553 DBG("setting up for rw...\n");
554
555 do_mfm = mfm_rw_intr;
556 issue_command(raw_cmd.cmdcode, raw_cmd.cmddata, raw_cmd.cmdlen);
557}
558
559static void mfm_recal_intr(void)
560{
561#ifdef DEBUG
562 console_printf("recal intr - status = ");
563 print_status();
564#endif
565 outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */
566 if (mfm_status & (STAT_DER | STAT_ABN)) {
567 printk("recal failed\n");
568 MFM_DRV_INFO.cylinder = NEED_2_RECAL;
569 if (cont) {
570 cont->error();
571 cont->redo();
572 }
573 return;
574 }
575 /* Thats seek end - we are finished */
576 if (mfm_status & STAT_SED) {
577 issue_command(CMD_POD, NULL, 0);
578 MFM_DRV_INFO.cylinder = 0;
579 mfm_seek();
580 return;
581 }
582 /* Command end without seek end (see data sheet p.20) for parallel seek
583 - we have to send a POL command to wait for the seek */
584 if (mfm_status & STAT_CED) {
585 do_mfm = mfm_recal_intr;
586 issue_command(CMD_POL, NULL, 0);
587 return;
588 }
589 printk("recal: unknown status\n");
590}
591
592static void mfm_seek_intr(void)
593{
594#ifdef DEBUG
595 console_printf("seek intr - status = ");
596 print_status();
597#endif
598 outw(CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */
599 if (mfm_status & (STAT_DER | STAT_ABN)) {
600 printk("seek failed\n");
601 MFM_DRV_INFO.cylinder = NEED_2_RECAL;
602 if (cont) {
603 cont->error();
604 cont->redo();
605 }
606 return;
607 }
608 if (mfm_status & STAT_SED) {
609 issue_command(CMD_POD, NULL, 0);
610 MFM_DRV_INFO.cylinder = raw_cmd.cylinder;
611 mfm_seek();
612 return;
613 }
614 if (mfm_status & STAT_CED) {
615 do_mfm = mfm_seek_intr;
616 issue_command(CMD_POL, NULL, 0);
617 return;
618 }
619 printk("seek: unknown status\n");
620}
621
622/* IDEA2 seems to work better - its what RiscOS sets my
623 * disc to - on its SECOND call to specify!
624 */
625#define IDEA2
626#ifndef IDEA2
627#define SPEC_SL 0x16
628#define SPEC_SH 0xa9 /* Step pulse high=21, Record Length=001 (256 bytes) */
629#else
630#define SPEC_SL 0x00 /* OM2 - SL - step pulse low */
631#define SPEC_SH 0x21 /* Step pulse high=4, Record Length=001 (256 bytes) */
632#endif
633
634static void mfm_setupspecify (int drive, unsigned char *cmdb)
635{
636 cmdb[0] = 0x1f; /* OM0 - !SECT,!MOD,!DIF,PADP,ECD,CRCP,CRCI,ACOR */
637 cmdb[1] = 0xc3; /* OM1 - DTM,BRST,!CEDM,!SEDM,!DERM,0,AMEX,PSK */
638 cmdb[2] = SPEC_SL; /* OM2 - SL - step pulse low */
639 cmdb[3] = (number_mfm_drives == 1) ? 0x02 : 0x06; /* 1 or 2 drives */
640 cmdb[4] = 0xfc | ((mfm_info[drive].cylinders - 1) >> 8);/* RW time over/high part of number of cylinders */
641 cmdb[5] = mfm_info[drive].cylinders - 1; /* low part of number of cylinders */
642 cmdb[6] = mfm_info[drive].heads - 1; /* Number of heads */
643 cmdb[7] = mfm_info[drive].sectors - 1; /* Number of sectors */
644 cmdb[8] = SPEC_SH;
645 cmdb[9] = 0x0a; /* gap length 1 */
646 cmdb[10] = 0x0d; /* gap length 2 */
647 cmdb[11] = 0x0c; /* gap length 3 */
648 cmdb[12] = (mfm_info[drive].precomp - 1) >> 8; /* pre comp cylinder */
649 cmdb[13] = mfm_info[drive].precomp - 1;
650 cmdb[14] = (mfm_info[drive].lowcurrent - 1) >> 8; /* Low current cylinder */
651 cmdb[15] = mfm_info[drive].lowcurrent - 1;
652}
653
654static void mfm_specify (void)
655{
656 unsigned char cmdb[16];
657
658 DBG("specify...dev=%d lastspecified=%d\n", raw_cmd.dev, lastspecifieddrive);
659 mfm_setupspecify (raw_cmd.dev, cmdb);
660
661 issue_command (CMD_SPC, cmdb, 16);
662 /* Ensure that we will do another specify if we move to the other drive */
663 lastspecifieddrive = raw_cmd.dev;
664 wait_for_completion();
665}
666
667static void mfm_seek(void)
668{
669 unsigned char cmdb[4];
670
671 DBG("seeking...\n");
672 if (MFM_DRV_INFO.cylinder < 0) {
673 do_mfm = mfm_recal_intr;
674 DBG("mfm_seek: about to call specify\n");
675 mfm_specify (); /* DAG added this */
676
677 cmdb[0] = raw_cmd.dev + 1;
678 cmdb[1] = 0;
679
680 issue_command(CMD_RCLB, cmdb, 2);
681 return;
682 }
683 if (MFM_DRV_INFO.cylinder != raw_cmd.cylinder) {
684 cmdb[0] = raw_cmd.dev + 1;
685 cmdb[1] = 0; /* raw_cmd.head; DAG: My data sheet says this should be 0 */
686 cmdb[2] = raw_cmd.cylinder >> 8;
687 cmdb[3] = raw_cmd.cylinder;
688
689 do_mfm = mfm_seek_intr;
690 issue_command(CMD_SEK, cmdb, 4);
691 } else
692 mfm_setup_rw();
693}
694
695static void mfm_initialise(void)
696{
697 DBG("init...\n");
698 mfm_seek();
699}
700
701static void request_done(int uptodate)
702{
703 DBG("mfm:request_done\n");
704 if (uptodate) {
705 unsigned char block[2] = {0, 0};
706
707 /* Apparently worked - let's check bytes left to DMA */
708 if (hdc63463_dataleft != (PartFragRead_SectorsLeft * 256)) {
709 printk("mfm: request_done - dataleft=%d - should be %d - Eek!\n", hdc63463_dataleft, PartFragRead_SectorsLeft * 256);
710 end_request(CURRENT, 0);
711 Busy = 0;
712 };
713 /* Potentially this means that we've done; but we might be doing
714 a partial access, (over two cylinders) or we may have a number
715 of fragments in an image file. First let's deal with partial accesss
716 */
717 if (PartFragRead) {
718 /* Yep - a partial access */
719
720 /* and issue the remainder */
721 issue_request(PartFragRead_RestartBlock, PartFragRead_SectorsLeft, CURRENT);
722 return;
723 }
724
725 /* ah well - perhaps there is another fragment to go */
726
727 /* Increment pointers/counts to start of next fragment */
728 if (SectorsLeftInRequest > 0) printk("mfm: SectorsLeftInRequest>0 - Eek! Shouldn't happen!\n");
729
730 /* No - its the end of the line */
731 /* end_request's should have happened at the end of sector DMAs */
732 /* Turns Drive LEDs off - may slow it down? */
733 if (!elv_next_request(QUEUE))
734 issue_command(CMD_CKV, block, 2);
735
736 Busy = 0;
737 DBG("request_done: About to mfm_request\n");
738 /* Next one please */
739 mfm_request(); /* Moved from mfm_rw_intr */
740 DBG("request_done: returned from mfm_request\n");
741 } else {
742 printk("mfm:request_done: update=0\n");
743 end_request(CURRENT, 0);
744 Busy = 0;
745 }
746}
747
748static void error_handler(void)
749{
750 printk("error detected... status = ");
751 print_status();
752 (*errors)++;
753 if (*errors > MFM_DRV_INFO.errors.abort)
754 cont->done(0);
755 if (*errors > MFM_DRV_INFO.errors.recal)
756 MFM_DRV_INFO.cylinder = NEED_2_RECAL;
757}
758
759static void rw_interrupt(void)
760{
761 printk("rw_interrupt\n");
762}
763
764static struct cont rw_cont =
765{
766 rw_interrupt,
767 error_handler,
768 mfm_rerequest,
769 request_done
770};
771
772/*
773 * Actually gets round to issuing the request - note everything at this
774 * point is in 256 byte sectors not Linux 512 byte blocks
775 */
776static void issue_request(unsigned int block, unsigned int nsect,
777 struct request *req)
778{
779 struct gendisk *disk = req->rq_disk;
780 struct mfm_info *p = disk->private_data;
781 int track, start_head, start_sector;
782 int sectors_to_next_cyl;
783 dev = p - mfm_info;
784
785 track = block / p->sectors;
786 start_sector = block % p->sectors;
787 start_head = track % p->heads;
788
789 /* First get the number of whole tracks which are free before the next
790 track */
791 sectors_to_next_cyl = (p->heads - (start_head + 1)) * p->sectors;
792 /* Then add in the number of sectors left on this track */
793 sectors_to_next_cyl += (p->sectors - start_sector);
794
795 DBG("issue_request: mfm_info[dev].sectors=%d track=%d\n", p->sectors, track);
796
797 raw_cmd.dev = dev;
798 raw_cmd.sector = start_sector;
799 raw_cmd.head = start_head;
800 raw_cmd.cylinder = track / p->heads;
801 raw_cmd.cmdtype = CURRENT->cmd;
802 raw_cmd.cmdcode = rq_data_dir(CURRENT) == WRITE ? CMD_WD : CMD_RD;
803 raw_cmd.cmddata[0] = dev + 1; /* DAG: +1 to get US */
804 raw_cmd.cmddata[1] = raw_cmd.head;
805 raw_cmd.cmddata[2] = raw_cmd.cylinder >> 8;
806 raw_cmd.cmddata[3] = raw_cmd.cylinder;
807 raw_cmd.cmddata[4] = raw_cmd.head;
808 raw_cmd.cmddata[5] = raw_cmd.sector;
809
810 /* Was == and worked - how the heck??? */
811 if (lastspecifieddrive != raw_cmd.dev)
812 mfm_specify ();
813
814 if (nsect <= sectors_to_next_cyl) {
815 raw_cmd.cmddata[6] = nsect >> 8;
816 raw_cmd.cmddata[7] = nsect;
817 PartFragRead = 0; /* All in one */
818 PartFragRead_SectorsLeft = 0; /* Must set this - used in DMA calcs */
819 } else {
820 raw_cmd.cmddata[6] = sectors_to_next_cyl >> 8;
821 raw_cmd.cmddata[7] = sectors_to_next_cyl;
822 PartFragRead = sectors_to_next_cyl; /* only do this many this time */
823 PartFragRead_RestartBlock = block + sectors_to_next_cyl; /* Where to restart from */
824 PartFragRead_SectorsLeft = nsect - sectors_to_next_cyl;
825 }
826 raw_cmd.cmdlen = 8;
827
828 /* Setup DMA pointers */
829 hdc63463_dataptr = (unsigned int) Copy_buffer;
830 hdc63463_dataleft = nsect * 256; /* Better way? */
831
832 DBG("mfm%c: %sing: CHS=%d/%d/%d, sectors=%d, buffer=0x%08lx (%p)\n",
833 raw_cmd.dev + 'a', rq_data_dir(CURRENT) == READ ? "read" : "writ",
834 raw_cmd.cylinder,
835 raw_cmd.head,
836 raw_cmd.sector, nsect, (unsigned long) Copy_buffer, CURRENT);
837
838 cont = &rw_cont;
839 errors = &(CURRENT->errors);
840#if 0
841 mfm_tq.routine = (void (*)(void *)) mfm_initialise;
842 queue_task(&mfm_tq, &tq_immediate);
843 mark_bh(IMMEDIATE_BH);
844#else
845 mfm_initialise();
846#endif
847} /* issue_request */
848
849/*
850 * Called when an error has just happened - need to trick mfm_request
851 * into thinking we weren't busy
852 *
853 * Turn off ints - mfm_request expects them this way
854 */
855static void mfm_rerequest(void)
856{
857 DBG("mfm_rerequest\n");
858 cli();
859 Busy = 0;
860 mfm_request();
861}
862
863static struct gendisk *mfm_gendisk[2];
864
865static void mfm_request(void)
866{
867 DBG("mfm_request CURRENT=%p Busy=%d\n", CURRENT, Busy);
868
869 /* If we are still processing then return; we will get called again */
870 if (Busy) {
871 /* Again seems to be common in 1.3.45 */
872 /*DBG*/printk("mfm_request: Exiting due to busy\n");
873 return;
874 }
875 Busy = 1;
876
877 while (1) {
878 unsigned int block, nsect;
879 struct gendisk *disk;
880
881 DBG("mfm_request: loop start\n");
882 sti();
883
884 DBG("mfm_request: before !CURRENT\n");
885
886 if (!CURRENT) {
887 printk("mfm_request: Exiting due to empty queue (pre)\n");
888 do_mfm = NULL;
889 Busy = 0;
890 return;
891 }
892
893 DBG("mfm_request: before arg extraction\n");
894
895 disk = CURRENT->rq_disk;
896 block = CURRENT->sector;
897 nsect = CURRENT->nr_sectors;
898 if (block >= get_capacity(disk) ||
899 block+nsect > get_capacity(disk)) {
900 printk("%s: bad access: block=%d, count=%d, nr_sects=%ld\n",
901 disk->disk_name, block, nsect, get_capacity(disk));
902 printk("mfm: continue 1\n");
903 end_request(CURRENT, 0);
904 Busy = 0;
905 continue;
906 }
907
908 /* DAG: Linux doesn't cope with this - even though it has an array telling
909 it the hardware block size - silly */
910 block <<= 1; /* Now in 256 byte sectors */
911 nsect <<= 1; /* Ditto */
912
913 SectorsLeftInRequest = nsect >> 1;
914 Sectors256LeftInCurrent = CURRENT->current_nr_sectors * 2;
915 Copy_buffer = CURRENT->buffer;
916 Copy_Sector = CURRENT->sector << 1;
917
918 DBG("mfm_request: block after offset=%d\n", block);
919
920 issue_request(block, nsect, CURRENT);
921
922 break;
923 }
924 DBG("mfm_request: Dropping out bottom\n");
925}
926
927static void do_mfm_request(request_queue_t *q)
928{
929 DBG("do_mfm_request: about to mfm_request\n");
930 mfm_request();
931}
932
933static void mfm_interrupt_handler(int unused, void *dev_id)
934{
935 void (*handler) (void) = do_mfm;
936
937 do_mfm = NULL;
938
939 DBG("mfm_interrupt_handler (handler=0x%p)\n", handler);
940
941 mfm_status = inw(MFM_STATUS);
942
943 /* If CPR (Command Parameter Reject) and not busy it means that the command
944 has some return message to give us */
945 if ((mfm_status & (STAT_CPR | STAT_BSY)) == STAT_CPR) {
946 int len = 0;
947 while (len < 16) {
948 int in;
949 in = inw(MFM_DATAIN);
950 result[len++] = in >> 8;
951 result[len++] = in;
952 }
953 }
954 if (handler) {
955 handler();
956 return;
957 }
958 outw (CMD_RCAL, MFM_COMMAND); /* Clear interrupt condition */
959 printk ("mfm: unexpected interrupt - status = ");
960 print_status ();
961 while (1);
962}
963
964
965
966
967
968/*
969 * Tell the user about the drive if we decided it exists.
970 */
971static void mfm_geometry(int drive)
972{
973 struct mfm_info *p = mfm_info + drive;
974 struct gendisk *disk = mfm_gendisk[drive];
975 disk->private_data = p;
976 if (p->cylinders)
977 printk ("%s: %dMB CHS=%d/%d/%d LCC=%d RECOMP=%d\n",
978 disk->disk_name,
979 p->cylinders * p->heads * p->sectors / 4096,
980 p->cylinders, p->heads, p->sectors,
981 p->lowcurrent, p->precomp);
982 set_capacity(disk, p->cylinders * p->heads * p->sectors / 2);
983}
984
985#ifdef CONFIG_BLK_DEV_MFM_AUTODETECT
986/*
987 * Attempt to detect a drive and find its geometry. The drive has already been
988 * specified...
989 *
990 * We first recalibrate the disk, then try to probe sectors, heads and then
991 * cylinders. NOTE! the cylinder probe may break drives. The xd disk driver
992 * does something along these lines, so I assume that most drives are up to
993 * this mistreatment...
994 */
995static int mfm_detectdrive (int drive)
996{
997 unsigned int mingeo[3], maxgeo[3];
998 unsigned int attribute, need_recal = 1;
999 unsigned char cmdb[8];
1000
1001 memset (mingeo, 0, sizeof (mingeo));
1002 maxgeo[0] = mfm_info[drive].sectors;
1003 maxgeo[1] = mfm_info[drive].heads;
1004 maxgeo[2] = mfm_info[drive].cylinders;
1005
1006 cmdb[0] = drive + 1;
1007 cmdb[6] = 0;
1008 cmdb[7] = 1;
1009 for (attribute = 0; attribute < 3; attribute++) {
1010 while (mingeo[attribute] != maxgeo[attribute]) {
1011 unsigned int variable;
1012
1013 variable = (maxgeo[attribute] + mingeo[attribute]) >> 1;
1014 cmdb[1] = cmdb[2] = cmdb[3] = cmdb[4] = cmdb[5] = 0;
1015
1016 if (need_recal) {
1017 int tries = 5;
1018
1019 do {
1020 issue_command (CMD_RCLB, cmdb, 2);
1021 wait_for_completion ();
1022 wait_for_command_end ();
1023 if (result[1] == 0x20)
1024 break;
1025 } while (result[1] && --tries);
1026 if (result[1]) {
1027 outw (CMD_RCAL, MFM_COMMAND);
1028 return 0;
1029 }
1030 need_recal = 0;
1031 }
1032
1033 switch (attribute) {
1034 case 0:
1035 cmdb[5] = variable;
1036 issue_command (CMD_CMPD, cmdb, 8);
1037 break;
1038 case 1:
1039 cmdb[1] = variable;
1040 cmdb[4] = variable;
1041 issue_command (CMD_CMPD, cmdb, 8);
1042 break;
1043 case 2:
1044 cmdb[2] = variable >> 8;
1045 cmdb[3] = variable;
1046 issue_command (CMD_SEK, cmdb, 4);
1047 break;
1048 }
1049 wait_for_completion ();
1050 wait_for_command_end ();
1051
1052 switch (result[1]) {
1053 case 0x00:
1054 case 0x50:
1055 mingeo[attribute] = variable + 1;
1056 break;
1057
1058 case 0x20:
1059 outw (CMD_RCAL, MFM_COMMAND);
1060 return 0;
1061
1062 case 0x24:
1063 need_recal = 1;
1064 default:
1065 maxgeo[attribute] = variable;
1066 break;
1067 }
1068 }
1069 }
1070 mfm_info[drive].cylinders = mingeo[2];
1071 mfm_info[drive].lowcurrent = mingeo[2];
1072 mfm_info[drive].precomp = mingeo[2] / 2;
1073 mfm_info[drive].heads = mingeo[1];
1074 mfm_info[drive].sectors = mingeo[0];
1075 outw (CMD_RCAL, MFM_COMMAND);
1076 return 1;
1077}
1078#endif
1079
1080/*
1081 * Initialise all drive information for this controller.
1082 */
1083static int mfm_initdrives(void)
1084{
1085 int drive;
1086
1087 if (number_mfm_drives > MFM_MAXDRIVES) {
1088 number_mfm_drives = MFM_MAXDRIVES;
1089 printk("No. of ADFS MFM drives is greater than MFM_MAXDRIVES - you can't have that many!\n");
1090 }
1091
1092 for (drive = 0; drive < number_mfm_drives; drive++) {
1093 mfm_info[drive].lowcurrent = 1;
1094 mfm_info[drive].precomp = 1;
1095 mfm_info[drive].cylinder = -1;
1096 mfm_info[drive].errors.recal = 0;
1097 mfm_info[drive].errors.report = 0;
1098 mfm_info[drive].errors.abort = 4;
1099
1100#ifdef CONFIG_BLK_DEV_MFM_AUTODETECT
1101 mfm_info[drive].cylinders = 1024;
1102 mfm_info[drive].heads = 8;
1103 mfm_info[drive].sectors = 64;
1104 {
1105 unsigned char cmdb[16];
1106
1107 mfm_setupspecify (drive, cmdb);
1108 cmdb[1] &= ~0x81;
1109 issue_command (CMD_SPC, cmdb, 16);
1110 wait_for_completion ();
1111 if (!mfm_detectdrive (drive)) {
1112 mfm_info[drive].cylinders = 0;
1113 mfm_info[drive].heads = 0;
1114 mfm_info[drive].sectors = 0;
1115 }
1116 cmdb[0] = cmdb[1] = 0;
1117 issue_command (CMD_CKV, cmdb, 2);
1118 }
1119#else
1120 mfm_info[drive].cylinders = 1; /* its going to have to figure it out from the partition info */
1121 mfm_info[drive].heads = 4;
1122 mfm_info[drive].sectors = 32;
1123#endif
1124 }
1125 return number_mfm_drives;
1126}
1127
1128
1129
1130/*
1131 * The 'front' end of the mfm driver follows...
1132 */
1133
1134static int mfm_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1135{
1136 struct mfm_info *p = bdev->bd_disk->private_data;
1137
1138 geo->heads = p->heads;
1139 geo->sectors = p->sectors;
1140 geo->cylinders = p->cylinders;
1141 return 0;
1142}
1143
1144/*
1145 * This is to handle various kernel command line parameters
1146 * specific to this driver.
1147 */
1148void mfm_setup(char *str, int *ints)
1149{
1150 return;
1151}
1152
1153/*
1154 * Set the CHS from the ADFS boot block if it is present. This is not ideal
1155 * since if there are any non-ADFS partitions on the disk, this won't work!
1156 * Hence, I want to get rid of this...
1157 */
1158void xd_set_geometry(struct block_device *bdev, unsigned char secsptrack,
1159 unsigned char heads, unsigned int secsize)
1160{
1161 struct mfm_info *p = bdev->bd_disk->private_data;
1162 int drive = p - mfm_info;
1163 unsigned long disksize = bdev->bd_inode->i_size;
1164
1165 if (p->cylinders == 1) {
1166 p->sectors = secsptrack;
1167 p->heads = heads;
1168 p->cylinders = discsize / (secsptrack * heads * secsize);
1169
1170 if ((heads < 1) || (p->cylinders > 1024)) {
1171 printk("%s: Insane disc shape! Setting to 512/4/32\n",
1172 bdev->bd_disk->disk_name);
1173
1174 /* These values are fairly arbitary, but are there so that if your
1175 * lucky you can pick apart your disc to find out what is going on -
1176 * I reckon these figures won't hurt MOST drives
1177 */
1178 p->sectors = 32;
1179 p->heads = 4;
1180 p->cylinders = 512;
1181 }
1182 if (raw_cmd.dev == drive)
1183 mfm_specify ();
1184 mfm_geometry (drive);
1185 }
1186}
1187
1188static struct block_device_operations mfm_fops =
1189{
1190 .owner = THIS_MODULE,
1191 .getgeo = mfm_getgeo,
1192};
1193
1194/*
1195 * See if there is a controller at the address presently at mfm_addr
1196 *
1197 * We check to see if the controller is busy - if it is, we abort it first,
1198 * and check that the chip is no longer busy after at least 180 clock cycles.
1199 * We then issue a command and check that the BSY or CPR bits are set.
1200 */
1201static int mfm_probecontroller (unsigned int mfm_addr)
1202{
1203 if (inw (MFM_STATUS) & STAT_BSY) {
1204 outw (CMD_ABT, MFM_COMMAND);
1205 udelay (50);
1206 if (inw (MFM_STATUS) & STAT_BSY)
1207 return 0;
1208 }
1209
1210 if (inw (MFM_STATUS) & STAT_CED)
1211 outw (CMD_RCAL, MFM_COMMAND);
1212
1213 outw (CMD_SEK, MFM_COMMAND);
1214
1215 if (inw (MFM_STATUS) & (STAT_BSY | STAT_CPR)) {
1216 unsigned int count = 2000;
1217 while (inw (MFM_STATUS) & STAT_BSY) {
1218 udelay (500);
1219 if (!--count)
1220 return 0;
1221 }
1222
1223 outw (CMD_RCAL, MFM_COMMAND);
1224 }
1225 return 1;
1226}
1227
1228static int mfm_do_init(unsigned char irqmask)
1229{
1230 int i, ret;
1231
1232 printk("mfm: found at address %08X, interrupt %d\n", mfm_addr, mfm_irq);
1233
1234 ret = -EBUSY;
1235 if (!request_region (mfm_addr, 10, "mfm"))
1236 goto out1;
1237
1238 ret = register_blkdev(MAJOR_NR, "mfm");
1239 if (ret)
1240 goto out2;
1241
1242 /* Stuff for the assembler routines to get to */
1243 hdc63463_baseaddress = ioaddr(mfm_addr);
1244 hdc63463_irqpolladdress = mfm_IRQPollLoc;
1245 hdc63463_irqpollmask = irqmask;
1246
1247 mfm_queue = blk_init_queue(do_mfm_request, &mfm_lock);
1248 if (!mfm_queue)
1249 goto out2a;
1250
1251 Busy = 0;
1252 lastspecifieddrive = -1;
1253
1254 mfm_drives = mfm_initdrives();
1255 if (!mfm_drives) {
1256 ret = -ENODEV;
1257 goto out3;
1258 }
1259
1260 for (i = 0; i < mfm_drives; i++) {
1261 struct gendisk *disk = alloc_disk(64);
1262 if (!disk)
1263 goto Enomem;
1264 disk->major = MAJOR_NR;
1265 disk->first_minor = i << 6;
1266 disk->fops = &mfm_fops;
1267 sprintf(disk->disk_name, "mfm%c", 'a'+i);
1268 mfm_gendisk[i] = disk;
1269 }
1270
1271 printk("mfm: detected %d hard drive%s\n", mfm_drives,
1272 mfm_drives == 1 ? "" : "s");
1273 ret = request_irq(mfm_irq, mfm_interrupt_handler, IRQF_DISABLED, "MFM harddisk", NULL);
1274 if (ret) {
1275 printk("mfm: unable to get IRQ%d\n", mfm_irq);
1276 goto out4;
1277 }
1278
1279 if (mfm_irqenable)
1280 outw(0x80, mfm_irqenable); /* Required to enable IRQs from MFM podule */
1281
1282 for (i = 0; i < mfm_drives; i++) {
1283 mfm_geometry(i);
1284 mfm_gendisk[i]->queue = mfm_queue;
1285 add_disk(mfm_gendisk[i]);
1286 }
1287 return 0;
1288
1289out4:
1290 for (i = 0; i < mfm_drives; i++)
1291 put_disk(mfm_gendisk[i]);
1292out3:
1293 blk_cleanup_queue(mfm_queue);
1294out2a:
1295 unregister_blkdev(MAJOR_NR, "mfm");
1296out2:
1297 release_region(mfm_addr, 10);
1298out1:
1299 return ret;
1300Enomem:
1301 while (i--)
1302 put_disk(mfm_gendisk[i]);
1303 goto out3;
1304}
1305
1306static void mfm_do_exit(void)
1307{
1308 int i;
1309
1310 free_irq(mfm_irq, NULL);
1311 for (i = 0; i < mfm_drives; i++) {
1312 del_gendisk(mfm_gendisk[i]);
1313 put_disk(mfm_gendisk[i]);
1314 }
1315 blk_cleanup_queue(mfm_queue);
1316 unregister_blkdev(MAJOR_NR, "mfm");
1317 if (mfm_addr)
1318 release_region(mfm_addr, 10);
1319}
1320
1321static int __devinit mfm_probe(struct expansion_card *ec, struct ecard_id *id)
1322{
1323 if (mfm_addr)
1324 return -EBUSY;
1325
1326 mfm_addr = ecard_address(ec, ECARD_IOC, ECARD_MEDIUM) + 0x800;
1327 mfm_IRQPollLoc = ioaddr(mfm_addr + 0x400);
1328 mfm_irqenable = mfm_IRQPollLoc;
1329 mfm_irq = ec->irq;
1330
1331 return mfm_do_init(0x08);
1332}
1333
1334static void __devexit mfm_remove(struct expansion_card *ec)
1335{
1336 outw (0, mfm_irqenable); /* Required to enable IRQs from MFM podule */
1337 mfm_do_exit();
1338}
1339
1340static const struct ecard_id mfm_cids[] = {
1341 { MANU_ACORN, PROD_ACORN_MFM },
1342 { 0xffff, 0xffff },
1343};
1344
1345static struct ecard_driver mfm_driver = {
1346 .probe = mfm_probe,
1347 .remove = __devexit(mfm_remove),
1348 .id_table = mfm_cids,
1349 .drv = {
1350 .name = "mfm",
1351 },
1352};
1353
1354/*
1355 * Look for a MFM controller - first check the motherboard, then the podules
1356 * The podules have an extra interrupt enable that needs to be played with
1357 *
1358 * The HDC is accessed at MEDIUM IOC speeds.
1359 */
1360static int __init mfm_init (void)
1361{
1362 unsigned char irqmask;
1363
1364 if (mfm_probecontroller(ONBOARD_MFM_ADDRESS)) {
1365 mfm_addr = ONBOARD_MFM_ADDRESS;
1366 mfm_IRQPollLoc = IOC_IRQSTATB;
1367 mfm_irqenable = 0;
1368 mfm_irq = IRQ_HARDDISK;
1369 return mfm_do_init(0x08); /* IL3 pin */
1370 } else {
1371 return ecard_register_driver(&mfm_driver);
1372 }
1373}
1374
1375static void __exit mfm_exit(void)
1376{
1377 if (mfm_addr == ONBOARD_MFM_ADDRESS)
1378 mfm_do_exit();
1379 else
1380 ecard_unregister_driver(&mfm_driver);
1381}
1382
1383module_init(mfm_init)
1384module_exit(mfm_exit)
1385MODULE_LICENSE("GPL");
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 408b45168aba..f1372de4ce79 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -43,50 +43,30 @@ menuconfig ACPI
43if ACPI 43if ACPI
44 44
45config ACPI_SLEEP 45config ACPI_SLEEP
46 bool "Sleep States"
47 depends on X86 && (!SMP || SUSPEND_SMP)
48 default y
49 ---help---
50 This option adds support for ACPI suspend states.
51
52 With this option, you will be able to put the system "to sleep".
53 Sleep states are low power states for the system and devices. All
54 of the system operating state is saved to either memory or disk
55 (depending on the state), to allow the system to resume operation
56 quickly at your request.
57
58 Although this option sounds really nifty, barely any of the device
59 drivers have been converted to the new driver model and hence few
60 have proper power management support.
61
62 This option is not recommended for anyone except those doing driver
63 power management development.
64
65config ACPI_SLEEP_PROC_FS
66 bool 46 bool
67 depends on ACPI_SLEEP && PROC_FS 47 depends on PM_SLEEP
68 default y 48 default y
69 49
70config ACPI_SLEEP_PROC_SLEEP
71 bool "/proc/acpi/sleep (deprecated)"
72 depends on ACPI_SLEEP_PROC_FS
73 default n
74 ---help---
75 Create /proc/acpi/sleep
76 Deprecated by /sys/power/state
77
78config ACPI_PROCFS 50config ACPI_PROCFS
79 bool "Procfs interface (deprecated)" 51 bool "Deprecated /proc/acpi files"
80 default y 52 depends on PROC_FS
81 ---help--- 53 ---help---
82 The Procfs interface for ACPI is made optional for backward compatibility. 54 For backwards compatibility, this option allows
83 As the same functions are duplicated in the sysfs interface 55 depricated /proc/acpi/ files to exist, even when
84 and this proc interface will be removed some time later, 56 they have been replaced by functions in /sys.
85 it's marked as deprecated. 57 The deprecated files (and their replacements) include:
86 ( /proc/acpi/debug_layer && debug_level are deprecated by 58
87 /sys/module/acpi/parameters/debug_layer && debug_level. 59 /proc/acpi/sleep (/sys/power/state)
88 /proc/acpi/info is deprecated by 60 /proc/acpi/info (/sys/modules/acpi/parameters/acpica_version)
89 /sys/module/acpi/parameters/acpica_version ) 61 /proc/acpi/dsdt (/sys/firmware/acpi/tables/DSDT)
62 /proc/acpi/fadt (/sys/firmware/acpi/tables/FACP)
63 /proc/acpi/debug_layer (/sys/module/acpi/parameters/debug_layer)
64 /proc/acpi/debug_level (/sys/module/acpi/parameters/debug_level)
65
66 This option has no effect on /proc/acpi/ files
67 and functions which do not yet exist in /sys.
68
69 Say N to delete /proc/acpi/ files that have moved to /sys/
90 70
91config ACPI_AC 71config ACPI_AC
92 tristate "AC Adapter" 72 tristate "AC Adapter"
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 37c7dc4f9fe5..d8b35093527a 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -34,7 +34,6 @@
34 34
35#define ACPI_AC_COMPONENT 0x00020000 35#define ACPI_AC_COMPONENT 0x00020000
36#define ACPI_AC_CLASS "ac_adapter" 36#define ACPI_AC_CLASS "ac_adapter"
37#define ACPI_AC_HID "ACPI0003"
38#define ACPI_AC_DEVICE_NAME "AC Adapter" 37#define ACPI_AC_DEVICE_NAME "AC Adapter"
39#define ACPI_AC_FILE_STATE "state" 38#define ACPI_AC_FILE_STATE "state"
40#define ACPI_AC_NOTIFY_STATUS 0x80 39#define ACPI_AC_NOTIFY_STATUS 0x80
@@ -56,10 +55,16 @@ static int acpi_ac_add(struct acpi_device *device);
56static int acpi_ac_remove(struct acpi_device *device, int type); 55static int acpi_ac_remove(struct acpi_device *device, int type);
57static int acpi_ac_open_fs(struct inode *inode, struct file *file); 56static int acpi_ac_open_fs(struct inode *inode, struct file *file);
58 57
58const static struct acpi_device_id ac_device_ids[] = {
59 {"ACPI0003", 0},
60 {"", 0},
61};
62MODULE_DEVICE_TABLE(acpi, ac_device_ids);
63
59static struct acpi_driver acpi_ac_driver = { 64static struct acpi_driver acpi_ac_driver = {
60 .name = "ac", 65 .name = "ac",
61 .class = ACPI_AC_CLASS, 66 .class = ACPI_AC_CLASS,
62 .ids = ACPI_AC_HID, 67 .ids = ac_device_ids,
63 .ops = { 68 .ops = {
64 .add = acpi_ac_add, 69 .add = acpi_ac_add,
65 .remove = acpi_ac_remove, 70 .remove = acpi_ac_remove,
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index e65628a03085..5f1127ad5a95 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -53,10 +53,16 @@ static int acpi_memory_device_add(struct acpi_device *device);
53static int acpi_memory_device_remove(struct acpi_device *device, int type); 53static int acpi_memory_device_remove(struct acpi_device *device, int type);
54static int acpi_memory_device_start(struct acpi_device *device); 54static int acpi_memory_device_start(struct acpi_device *device);
55 55
56static const struct acpi_device_id memory_device_ids[] = {
57 {ACPI_MEMORY_DEVICE_HID, 0},
58 {"", 0},
59};
60MODULE_DEVICE_TABLE(acpi, memory_device_ids);
61
56static struct acpi_driver acpi_memory_device_driver = { 62static struct acpi_driver acpi_memory_device_driver = {
57 .name = "acpi_memhotplug", 63 .name = "acpi_memhotplug",
58 .class = ACPI_MEMORY_DEVICE_CLASS, 64 .class = ACPI_MEMORY_DEVICE_CLASS,
59 .ids = ACPI_MEMORY_DEVICE_HID, 65 .ids = memory_device_ids,
60 .ops = { 66 .ops = {
61 .add = acpi_memory_device_add, 67 .add = acpi_memory_device_add,
62 .remove = acpi_memory_device_remove, 68 .remove = acpi_memory_device_remove,
diff --git a/drivers/acpi/asus_acpi.c b/drivers/acpi/asus_acpi.c
index 3cd79caad70c..9c4bd220c44f 100644
--- a/drivers/acpi/asus_acpi.c
+++ b/drivers/acpi/asus_acpi.c
@@ -56,7 +56,6 @@
56#define ACPI_HOTK_NAME "Asus Laptop ACPI Extras Driver" 56#define ACPI_HOTK_NAME "Asus Laptop ACPI Extras Driver"
57#define ACPI_HOTK_CLASS "hotkey" 57#define ACPI_HOTK_CLASS "hotkey"
58#define ACPI_HOTK_DEVICE_NAME "Hotkey" 58#define ACPI_HOTK_DEVICE_NAME "Hotkey"
59#define ACPI_HOTK_HID "ATK0100"
60 59
61/* 60/*
62 * Some events we use, same for all Asus 61 * Some events we use, same for all Asus
@@ -426,14 +425,20 @@ static struct acpi_table_header *asus_info;
426static struct asus_hotk *hotk; 425static struct asus_hotk *hotk;
427 426
428/* 427/*
429 * The hotkey driver declaration 428 * The hotkey driver and autoloading declaration
430 */ 429 */
431static int asus_hotk_add(struct acpi_device *device); 430static int asus_hotk_add(struct acpi_device *device);
432static int asus_hotk_remove(struct acpi_device *device, int type); 431static int asus_hotk_remove(struct acpi_device *device, int type);
432static const struct acpi_device_id asus_device_ids[] = {
433 {"ATK0100", 0},
434 {"", 0},
435};
436MODULE_DEVICE_TABLE(acpi, asus_device_ids);
437
433static struct acpi_driver asus_hotk_driver = { 438static struct acpi_driver asus_hotk_driver = {
434 .name = "asus_acpi", 439 .name = "asus_acpi",
435 .class = ACPI_HOTK_CLASS, 440 .class = ACPI_HOTK_CLASS,
436 .ids = ACPI_HOTK_HID, 441 .ids = asus_device_ids,
437 .ops = { 442 .ops = {
438 .add = asus_hotk_add, 443 .add = asus_hotk_add,
439 .remove = asus_hotk_remove, 444 .remove = asus_hotk_remove,
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index cad932de383d..81651032791b 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -41,7 +41,6 @@
41 41
42#define ACPI_BATTERY_COMPONENT 0x00040000 42#define ACPI_BATTERY_COMPONENT 0x00040000
43#define ACPI_BATTERY_CLASS "battery" 43#define ACPI_BATTERY_CLASS "battery"
44#define ACPI_BATTERY_HID "PNP0C0A"
45#define ACPI_BATTERY_DEVICE_NAME "Battery" 44#define ACPI_BATTERY_DEVICE_NAME "Battery"
46#define ACPI_BATTERY_NOTIFY_STATUS 0x80 45#define ACPI_BATTERY_NOTIFY_STATUS 0x80
47#define ACPI_BATTERY_NOTIFY_INFO 0x81 46#define ACPI_BATTERY_NOTIFY_INFO 0x81
@@ -74,10 +73,16 @@ static int acpi_battery_add(struct acpi_device *device);
74static int acpi_battery_remove(struct acpi_device *device, int type); 73static int acpi_battery_remove(struct acpi_device *device, int type);
75static int acpi_battery_resume(struct acpi_device *device); 74static int acpi_battery_resume(struct acpi_device *device);
76 75
76static const struct acpi_device_id battery_device_ids[] = {
77 {"PNP0C0A", 0},
78 {"", 0},
79};
80MODULE_DEVICE_TABLE(acpi, battery_device_ids);
81
77static struct acpi_driver acpi_battery_driver = { 82static struct acpi_driver acpi_battery_driver = {
78 .name = "battery", 83 .name = "battery",
79 .class = ACPI_BATTERY_CLASS, 84 .class = ACPI_BATTERY_CLASS,
80 .ids = ACPI_BATTERY_HID, 85 .ids = battery_device_ids,
81 .ops = { 86 .ops = {
82 .add = acpi_battery_add, 87 .add = acpi_battery_add,
83 .resume = acpi_battery_resume, 88 .resume = acpi_battery_resume,
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index cb4110b50cd0..540581338ef5 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -66,6 +66,16 @@ MODULE_AUTHOR("Paul Diefenbaugh");
66MODULE_DESCRIPTION("ACPI Button Driver"); 66MODULE_DESCRIPTION("ACPI Button Driver");
67MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
68 68
69static const struct acpi_device_id button_device_ids[] = {
70 {ACPI_BUTTON_HID_LID, 0},
71 {ACPI_BUTTON_HID_SLEEP, 0},
72 {ACPI_BUTTON_HID_SLEEPF, 0},
73 {ACPI_BUTTON_HID_POWER, 0},
74 {ACPI_BUTTON_HID_POWERF, 0},
75 {"", 0},
76};
77MODULE_DEVICE_TABLE(acpi, button_device_ids);
78
69static int acpi_button_add(struct acpi_device *device); 79static int acpi_button_add(struct acpi_device *device);
70static int acpi_button_remove(struct acpi_device *device, int type); 80static int acpi_button_remove(struct acpi_device *device, int type);
71static int acpi_button_info_open_fs(struct inode *inode, struct file *file); 81static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
@@ -74,7 +84,7 @@ static int acpi_button_state_open_fs(struct inode *inode, struct file *file);
74static struct acpi_driver acpi_button_driver = { 84static struct acpi_driver acpi_button_driver = {
75 .name = "button", 85 .name = "button",
76 .class = ACPI_BUTTON_CLASS, 86 .class = ACPI_BUTTON_CLASS,
77 .ids = "button_power,button_sleep,PNP0C0D,PNP0C0C,PNP0C0E", 87 .ids = button_device_ids,
78 .ops = { 88 .ops = {
79 .add = acpi_button_add, 89 .add = acpi_button_add,
80 .remove = acpi_button_remove, 90 .remove = acpi_button_remove,
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 0dd3bf7c0ed1..3c25ec7a1871 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -52,10 +52,18 @@ MODULE_LICENSE("GPL");
52static int acpi_container_add(struct acpi_device *device); 52static int acpi_container_add(struct acpi_device *device);
53static int acpi_container_remove(struct acpi_device *device, int type); 53static int acpi_container_remove(struct acpi_device *device, int type);
54 54
55static const struct acpi_device_id container_device_ids[] = {
56 {"ACPI0004", 0},
57 {"PNP0A05", 0},
58 {"PNP0A06", 0},
59 {"", 0},
60};
61MODULE_DEVICE_TABLE(acpi, container_device_ids);
62
55static struct acpi_driver acpi_container_driver = { 63static struct acpi_driver acpi_container_driver = {
56 .name = "container", 64 .name = "container",
57 .class = ACPI_CONTAINER_CLASS, 65 .class = ACPI_CONTAINER_CLASS,
58 .ids = "ACPI0004,PNP0A05,PNP0A06", 66 .ids = container_device_ids,
59 .ops = { 67 .ops = {
60 .add = acpi_container_add, 68 .add = acpi_container_add,
61 .remove = acpi_container_remove, 69 .remove = acpi_container_remove,
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 10e851021eca..469f3f57f881 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -41,7 +41,6 @@
41#include <acpi/actypes.h> 41#include <acpi/actypes.h>
42 42
43#define ACPI_EC_CLASS "embedded_controller" 43#define ACPI_EC_CLASS "embedded_controller"
44#define ACPI_EC_HID "PNP0C09"
45#define ACPI_EC_DEVICE_NAME "Embedded Controller" 44#define ACPI_EC_DEVICE_NAME "Embedded Controller"
46#define ACPI_EC_FILE_INFO "info" 45#define ACPI_EC_FILE_INFO "info"
47 46
@@ -82,10 +81,15 @@ static int acpi_ec_start(struct acpi_device *device);
82static int acpi_ec_stop(struct acpi_device *device, int type); 81static int acpi_ec_stop(struct acpi_device *device, int type);
83static int acpi_ec_add(struct acpi_device *device); 82static int acpi_ec_add(struct acpi_device *device);
84 83
84static const struct acpi_device_id ec_device_ids[] = {
85 {"PNP0C09", 0},
86 {"", 0},
87};
88
85static struct acpi_driver acpi_ec_driver = { 89static struct acpi_driver acpi_ec_driver = {
86 .name = "ec", 90 .name = "ec",
87 .class = ACPI_EC_CLASS, 91 .class = ACPI_EC_CLASS,
88 .ids = ACPI_EC_HID, 92 .ids = ec_device_ids,
89 .ops = { 93 .ops = {
90 .add = acpi_ec_add, 94 .add = acpi_ec_add,
91 .remove = acpi_ec_remove, 95 .remove = acpi_ec_remove,
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index 23ee7bc4a705..b1aaa0e84588 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -378,7 +378,7 @@ static u8 acpi_ev_match_pci_root_bridge(char *id)
378static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node) 378static u8 acpi_ev_is_pci_root_bridge(struct acpi_namespace_node *node)
379{ 379{
380 acpi_status status; 380 acpi_status status;
381 struct acpi_device_id hid; 381 struct acpica_device_id hid;
382 struct acpi_compatible_id_list *cid; 382 struct acpi_compatible_id_list *cid;
383 acpi_native_uint i; 383 acpi_native_uint i;
384 384
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index ec655c539492..c81f6bdb68b8 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -50,10 +50,16 @@ static int acpi_fan_remove(struct acpi_device *device, int type);
50static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state); 50static int acpi_fan_suspend(struct acpi_device *device, pm_message_t state);
51static int acpi_fan_resume(struct acpi_device *device); 51static int acpi_fan_resume(struct acpi_device *device);
52 52
53static const struct acpi_device_id fan_device_ids[] = {
54 {"PNP0C0B", 0},
55 {"", 0},
56};
57MODULE_DEVICE_TABLE(acpi, fan_device_ids);
58
53static struct acpi_driver acpi_fan_driver = { 59static struct acpi_driver acpi_fan_driver = {
54 .name = "fan", 60 .name = "fan",
55 .class = ACPI_FAN_CLASS, 61 .class = ACPI_FAN_CLASS,
56 .ids = "PNP0C0B", 62 .ids = fan_device_ids,
57 .ops = { 63 .ops = {
58 .add = acpi_fan_add, 64 .add = acpi_fan_add,
59 .remove = acpi_fan_remove, 65 .remove = acpi_fan_remove,
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index be4f2899de74..ab65b2c2560e 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -440,7 +440,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
440 acpi_status status; 440 acpi_status status;
441 struct acpi_namespace_node *node; 441 struct acpi_namespace_node *node;
442 u32 flags; 442 u32 flags;
443 struct acpi_device_id hid; 443 struct acpica_device_id hid;
444 struct acpi_compatible_id_list *cid; 444 struct acpi_compatible_id_list *cid;
445 acpi_native_uint i; 445 acpi_native_uint i;
446 446
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 3448edd61dc4..c9f526e55392 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -46,7 +46,6 @@
46#define _COMPONENT ACPI_PCI_COMPONENT 46#define _COMPONENT ACPI_PCI_COMPONENT
47ACPI_MODULE_NAME("pci_link"); 47ACPI_MODULE_NAME("pci_link");
48#define ACPI_PCI_LINK_CLASS "pci_irq_routing" 48#define ACPI_PCI_LINK_CLASS "pci_irq_routing"
49#define ACPI_PCI_LINK_HID "PNP0C0F"
50#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link" 49#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link"
51#define ACPI_PCI_LINK_FILE_INFO "info" 50#define ACPI_PCI_LINK_FILE_INFO "info"
52#define ACPI_PCI_LINK_FILE_STATUS "state" 51#define ACPI_PCI_LINK_FILE_STATUS "state"
@@ -54,10 +53,16 @@ ACPI_MODULE_NAME("pci_link");
54static int acpi_pci_link_add(struct acpi_device *device); 53static int acpi_pci_link_add(struct acpi_device *device);
55static int acpi_pci_link_remove(struct acpi_device *device, int type); 54static int acpi_pci_link_remove(struct acpi_device *device, int type);
56 55
56static struct acpi_device_id link_device_ids[] = {
57 {"PNP0C0F", 0},
58 {"", 0},
59};
60MODULE_DEVICE_TABLE(acpi, link_device_ids);
61
57static struct acpi_driver acpi_pci_link_driver = { 62static struct acpi_driver acpi_pci_link_driver = {
58 .name = "pci_link", 63 .name = "pci_link",
59 .class = ACPI_PCI_LINK_CLASS, 64 .class = ACPI_PCI_LINK_CLASS,
60 .ids = ACPI_PCI_LINK_HID, 65 .ids = link_device_ids,
61 .ops = { 66 .ops = {
62 .add = acpi_pci_link_add, 67 .add = acpi_pci_link_add,
63 .remove = acpi_pci_link_remove, 68 .remove = acpi_pci_link_remove,
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index ad4145a37786..f14ff1ffab29 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -38,16 +38,21 @@
38#define _COMPONENT ACPI_PCI_COMPONENT 38#define _COMPONENT ACPI_PCI_COMPONENT
39ACPI_MODULE_NAME("pci_root"); 39ACPI_MODULE_NAME("pci_root");
40#define ACPI_PCI_ROOT_CLASS "pci_bridge" 40#define ACPI_PCI_ROOT_CLASS "pci_bridge"
41#define ACPI_PCI_ROOT_HID "PNP0A03"
42#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" 41#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge"
43static int acpi_pci_root_add(struct acpi_device *device); 42static int acpi_pci_root_add(struct acpi_device *device);
44static int acpi_pci_root_remove(struct acpi_device *device, int type); 43static int acpi_pci_root_remove(struct acpi_device *device, int type);
45static int acpi_pci_root_start(struct acpi_device *device); 44static int acpi_pci_root_start(struct acpi_device *device);
46 45
46static struct acpi_device_id root_device_ids[] = {
47 {"PNP0A03", 0},
48 {"", 0},
49};
50MODULE_DEVICE_TABLE(acpi, root_device_ids);
51
47static struct acpi_driver acpi_pci_root_driver = { 52static struct acpi_driver acpi_pci_root_driver = {
48 .name = "pci_root", 53 .name = "pci_root",
49 .class = ACPI_PCI_ROOT_CLASS, 54 .class = ACPI_PCI_ROOT_CLASS,
50 .ids = ACPI_PCI_ROOT_HID, 55 .ids = root_device_ids,
51 .ops = { 56 .ops = {
52 .add = acpi_pci_root_add, 57 .add = acpi_pci_root_add,
53 .remove = acpi_pci_root_remove, 58 .remove = acpi_pci_root_remove,
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c
index 4ffecd179702..57b9a2998fd0 100644
--- a/drivers/acpi/power.c
+++ b/drivers/acpi/power.c
@@ -59,10 +59,16 @@ static int acpi_power_remove(struct acpi_device *device, int type);
59static int acpi_power_resume(struct acpi_device *device); 59static int acpi_power_resume(struct acpi_device *device);
60static int acpi_power_open_fs(struct inode *inode, struct file *file); 60static int acpi_power_open_fs(struct inode *inode, struct file *file);
61 61
62static struct acpi_device_id power_device_ids[] = {
63 {ACPI_POWER_HID, 0},
64 {"", 0},
65};
66MODULE_DEVICE_TABLE(acpi, power_device_ids);
67
62static struct acpi_driver acpi_power_driver = { 68static struct acpi_driver acpi_power_driver = {
63 .name = "power", 69 .name = "power",
64 .class = ACPI_POWER_CLASS, 70 .class = ACPI_POWER_CLASS,
65 .ids = ACPI_POWER_HID, 71 .ids = power_device_ids,
66 .ops = { 72 .ops = {
67 .add = acpi_power_add, 73 .add = acpi_power_add,
68 .remove = acpi_power_remove, 74 .remove = acpi_power_remove,
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 81aceb5da7c7..498422343f38 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -88,10 +88,16 @@ static int acpi_processor_handle_eject(struct acpi_processor *pr);
88extern int acpi_processor_tstate_has_changed(struct acpi_processor *pr); 88extern int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
89 89
90 90
91static const struct acpi_device_id processor_device_ids[] = {
92 {ACPI_PROCESSOR_HID, 0},
93 {"", 0},
94};
95MODULE_DEVICE_TABLE(acpi, processor_device_ids);
96
91static struct acpi_driver acpi_processor_driver = { 97static struct acpi_driver acpi_processor_driver = {
92 .name = "processor", 98 .name = "processor",
93 .class = ACPI_PROCESSOR_CLASS, 99 .class = ACPI_PROCESSOR_CLASS,
94 .ids = ACPI_PROCESSOR_HID, 100 .ids = processor_device_ids,
95 .ops = { 101 .ops = {
96 .add = acpi_processor_add, 102 .add = acpi_processor_add,
97 .remove = acpi_processor_remove, 103 .remove = acpi_processor_remove,
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 3f55d1f90c11..0b8204e7082a 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -47,6 +47,9 @@ ACPI_MODULE_NAME("processor_throttling");
47static int acpi_processor_get_throttling(struct acpi_processor *pr); 47static int acpi_processor_get_throttling(struct acpi_processor *pr);
48int acpi_processor_set_throttling(struct acpi_processor *pr, int state); 48int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
49 49
50/*
51 * _TPC - Throttling Present Capabilities
52 */
50static int acpi_processor_get_platform_limit(struct acpi_processor *pr) 53static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
51{ 54{
52 acpi_status status = 0; 55 acpi_status status = 0;
@@ -55,8 +58,10 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
55 if (!pr) 58 if (!pr)
56 return -EINVAL; 59 return -EINVAL;
57 status = acpi_evaluate_integer(pr->handle, "_TPC", NULL, &tpc); 60 status = acpi_evaluate_integer(pr->handle, "_TPC", NULL, &tpc);
58 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 61 if (ACPI_FAILURE(status)) {
59 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TPC")); 62 if (status != AE_NOT_FOUND) {
63 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TPC"));
64 }
60 return -ENODEV; 65 return -ENODEV;
61 } 66 }
62 pr->throttling_platform_limit = (int)tpc; 67 pr->throttling_platform_limit = (int)tpc;
@@ -68,9 +73,9 @@ int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
68 return acpi_processor_get_platform_limit(pr); 73 return acpi_processor_get_platform_limit(pr);
69} 74}
70 75
71/* -------------------------------------------------------------------------- 76/*
72 _PTC, _TSS, _TSD support 77 * _PTC - Processor Throttling Control (and status) register location
73 -------------------------------------------------------------------------- */ 78 */
74static int acpi_processor_get_throttling_control(struct acpi_processor *pr) 79static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
75{ 80{
76 int result = 0; 81 int result = 0;
@@ -81,7 +86,9 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
81 86
82 status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer); 87 status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
83 if (ACPI_FAILURE(status)) { 88 if (ACPI_FAILURE(status)) {
84 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PTC")); 89 if (status != AE_NOT_FOUND) {
90 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PTC"));
91 }
85 return -ENODEV; 92 return -ENODEV;
86 } 93 }
87 94
@@ -132,6 +139,10 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
132 139
133 return result; 140 return result;
134} 141}
142
143/*
144 * _TSS - Throttling Supported States
145 */
135static int acpi_processor_get_throttling_states(struct acpi_processor *pr) 146static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
136{ 147{
137 int result = 0; 148 int result = 0;
@@ -144,7 +155,9 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
144 155
145 status = acpi_evaluate_object(pr->handle, "_TSS", NULL, &buffer); 156 status = acpi_evaluate_object(pr->handle, "_TSS", NULL, &buffer);
146 if (ACPI_FAILURE(status)) { 157 if (ACPI_FAILURE(status)) {
147 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TSS")); 158 if (status != AE_NOT_FOUND) {
159 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TSS"));
160 }
148 return -ENODEV; 161 return -ENODEV;
149 } 162 }
150 163
@@ -201,6 +214,10 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
201 214
202 return result; 215 return result;
203} 216}
217
218/*
219 * _TSD - T-State Dependencies
220 */
204static int acpi_processor_get_tsd(struct acpi_processor *pr) 221static int acpi_processor_get_tsd(struct acpi_processor *pr)
205{ 222{
206 int result = 0; 223 int result = 0;
@@ -213,6 +230,9 @@ static int acpi_processor_get_tsd(struct acpi_processor *pr)
213 230
214 status = acpi_evaluate_object(pr->handle, "_TSD", NULL, &buffer); 231 status = acpi_evaluate_object(pr->handle, "_TSD", NULL, &buffer);
215 if (ACPI_FAILURE(status)) { 232 if (ACPI_FAILURE(status)) {
233 if (status != AE_NOT_FOUND) {
234 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TSD"));
235 }
216 return -ENODEV; 236 return -ENODEV;
217 } 237 }
218 238
@@ -525,9 +545,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
525 int result = 0; 545 int result = 0;
526 int step = 0; 546 int step = 0;
527 int i = 0; 547 int i = 0;
528 int no_ptc = 0;
529 int no_tss = 0;
530 int no_tsd = 0;
531 548
532 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 549 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
533 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", 550 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -538,12 +555,14 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
538 if (!pr) 555 if (!pr)
539 return -EINVAL; 556 return -EINVAL;
540 557
541 /* TBD: Support ACPI 2.0 objects */ 558 /*
542 no_ptc = acpi_processor_get_throttling_control(pr); 559 * Evaluate _PTC, _TSS and _TPC
543 no_tss = acpi_processor_get_throttling_states(pr); 560 * They must all be present or none of them can be used.
544 no_tsd = acpi_processor_get_tsd(pr); 561 */
545 562 if (acpi_processor_get_throttling_control(pr) ||
546 if (no_ptc || no_tss) { 563 acpi_processor_get_throttling_states(pr) ||
564 acpi_processor_get_platform_limit(pr))
565 {
547 pr->throttling.acpi_processor_get_throttling = 566 pr->throttling.acpi_processor_get_throttling =
548 &acpi_processor_get_throttling_fadt; 567 &acpi_processor_get_throttling_fadt;
549 pr->throttling.acpi_processor_set_throttling = 568 pr->throttling.acpi_processor_set_throttling =
@@ -555,6 +574,8 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
555 &acpi_processor_set_throttling_ptc; 574 &acpi_processor_set_throttling_ptc;
556 } 575 }
557 576
577 acpi_processor_get_tsd(pr);
578
558 if (!pr->throttling.address) { 579 if (!pr->throttling.address) {
559 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); 580 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
560 return 0; 581 return 0;
@@ -658,18 +679,20 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
658 pr->throttling.state_count - 1); 679 pr->throttling.state_count - 1);
659 680
660 seq_puts(seq, "states:\n"); 681 seq_puts(seq, "states:\n");
661 if (acpi_processor_get_throttling == acpi_processor_get_throttling_fadt) 682 if (pr->throttling.acpi_processor_get_throttling ==
683 acpi_processor_get_throttling_fadt) {
662 for (i = 0; i < pr->throttling.state_count; i++) 684 for (i = 0; i < pr->throttling.state_count; i++)
663 seq_printf(seq, " %cT%d: %02d%%\n", 685 seq_printf(seq, " %cT%d: %02d%%\n",
664 (i == pr->throttling.state ? '*' : ' '), i, 686 (i == pr->throttling.state ? '*' : ' '), i,
665 (pr->throttling.states[i].performance ? pr-> 687 (pr->throttling.states[i].performance ? pr->
666 throttling.states[i].performance / 10 : 0)); 688 throttling.states[i].performance / 10 : 0));
667 else 689 } else {
668 for (i = 0; i < pr->throttling.state_count; i++) 690 for (i = 0; i < pr->throttling.state_count; i++)
669 seq_printf(seq, " %cT%d: %02d%%\n", 691 seq_printf(seq, " %cT%d: %02d%%\n",
670 (i == pr->throttling.state ? '*' : ' '), i, 692 (i == pr->throttling.state ? '*' : ' '), i,
671 (int)pr->throttling.states_tss[i]. 693 (int)pr->throttling.states_tss[i].
672 freqpercentage); 694 freqpercentage);
695 }
673 696
674 end: 697 end:
675 return 0; 698 return 0;
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 974d00ccfe84..7d8e78ea13a5 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -38,7 +38,6 @@
38#define ACPI_SBS_CLASS "sbs" 38#define ACPI_SBS_CLASS "sbs"
39#define ACPI_AC_CLASS "ac_adapter" 39#define ACPI_AC_CLASS "ac_adapter"
40#define ACPI_BATTERY_CLASS "battery" 40#define ACPI_BATTERY_CLASS "battery"
41#define ACPI_SBS_HID "ACPI0002"
42#define ACPI_SBS_DEVICE_NAME "Smart Battery System" 41#define ACPI_SBS_DEVICE_NAME "Smart Battery System"
43#define ACPI_SBS_FILE_INFO "info" 42#define ACPI_SBS_FILE_INFO "info"
44#define ACPI_SBS_FILE_STATE "state" 43#define ACPI_SBS_FILE_STATE "state"
@@ -124,10 +123,17 @@ static int acpi_sbs_add(struct acpi_device *device);
124static int acpi_sbs_remove(struct acpi_device *device, int type); 123static int acpi_sbs_remove(struct acpi_device *device, int type);
125static int acpi_sbs_resume(struct acpi_device *device); 124static int acpi_sbs_resume(struct acpi_device *device);
126 125
126static const struct acpi_device_id sbs_device_ids[] = {
127 {"ACPI0001", 0},
128 {"ACPI0005", 0},
129 {"", 0},
130};
131MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
132
127static struct acpi_driver acpi_sbs_driver = { 133static struct acpi_driver acpi_sbs_driver = {
128 .name = "sbs", 134 .name = "sbs",
129 .class = ACPI_SBS_CLASS, 135 .class = ACPI_SBS_CLASS,
130 .ids = "ACPI0001,ACPI0005", 136 .ids = sbs_device_ids,
131 .ops = { 137 .ops = {
132 .add = acpi_sbs_add, 138 .add = acpi_sbs_add,
133 .remove = acpi_sbs_remove, 139 .remove = acpi_sbs_remove,
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 6b3b8a522476..be74347d1354 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -16,7 +16,7 @@ ACPI_MODULE_NAME("scan");
16extern struct acpi_device *acpi_root; 16extern struct acpi_device *acpi_root;
17 17
18#define ACPI_BUS_CLASS "system_bus" 18#define ACPI_BUS_CLASS "system_bus"
19#define ACPI_BUS_HID "ACPI_BUS" 19#define ACPI_BUS_HID "LNXSYBUS"
20#define ACPI_BUS_DEVICE_NAME "System Bus" 20#define ACPI_BUS_DEVICE_NAME "System Bus"
21 21
22static LIST_HEAD(acpi_device_list); 22static LIST_HEAD(acpi_device_list);
@@ -29,6 +29,62 @@ struct acpi_device_bus_id{
29 unsigned int instance_no; 29 unsigned int instance_no;
30 struct list_head node; 30 struct list_head node;
31}; 31};
32
33/*
34 * Creates hid/cid(s) string needed for modalias and uevent
35 * e.g. on a device with hid:IBM0001 and cid:ACPI0001 you get:
36 * char *modalias: "acpi:IBM0001:ACPI0001"
37*/
38int create_modalias(struct acpi_device *acpi_dev, char *modalias, int size){
39
40 int len;
41
42 if (!acpi_dev->flags.hardware_id)
43 return -ENODEV;
44
45 len = snprintf(modalias, size, "acpi:%s:",
46 acpi_dev->pnp.hardware_id);
47 if (len < 0 || len >= size)
48 return -EINVAL;
49 size -= len;
50
51 if (acpi_dev->flags.compatible_ids) {
52 struct acpi_compatible_id_list *cid_list;
53 int i;
54 int count;
55
56 cid_list = acpi_dev->pnp.cid_list;
57 for (i = 0; i < cid_list->count; i++) {
58 count = snprintf(&modalias[len], size, "%s:",
59 cid_list->id[i].value);
60 if (count < 0 || count >= size) {
61 printk(KERN_ERR "acpi: %s cid[%i] exceeds event buffer size",
62 acpi_dev->pnp.device_name, i);
63 break;
64 }
65 len += count;
66 size -= count;
67 }
68 }
69
70 modalias[len] = '\0';
71 return len;
72}
73
74static ssize_t
75acpi_device_modalias_show(struct device *dev, struct device_attribute *attr, char *buf) {
76 struct acpi_device *acpi_dev = to_acpi_device(dev);
77 int len;
78
79 /* Device has no HID and no CID or string is >1024 */
80 len = create_modalias(acpi_dev, buf, 1024);
81 if (len <= 0)
82 return 0;
83 buf[len++] = '\n';
84 return len;
85}
86static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
87
32static int acpi_eject_operation(acpi_handle handle, int lockable) 88static int acpi_eject_operation(acpi_handle handle, int lockable)
33{ 89{
34 struct acpi_object_list arg_list; 90 struct acpi_object_list arg_list;
@@ -154,6 +210,12 @@ static int acpi_device_setup_files(struct acpi_device *dev)
154 goto end; 210 goto end;
155 } 211 }
156 212
213 if (dev->flags.hardware_id || dev->flags.compatible_ids){
214 result = device_create_file(&dev->dev, &dev_attr_modalias);
215 if(result)
216 goto end;
217 }
218
157 /* 219 /*
158 * If device has _EJ0, 'eject' file is created that is used to trigger 220 * If device has _EJ0, 'eject' file is created that is used to trigger
159 * hot-removal function from userland. 221 * hot-removal function from userland.
@@ -178,6 +240,9 @@ static void acpi_device_remove_files(struct acpi_device *dev)
178 if (ACPI_SUCCESS(status)) 240 if (ACPI_SUCCESS(status))
179 device_remove_file(&dev->dev, &dev_attr_eject); 241 device_remove_file(&dev->dev, &dev_attr_eject);
180 242
243 if (dev->flags.hardware_id || dev->flags.compatible_ids)
244 device_remove_file(&dev->dev, &dev_attr_modalias);
245
181 if(dev->flags.hardware_id) 246 if(dev->flags.hardware_id)
182 device_remove_file(&dev->dev, &dev_attr_hid); 247 device_remove_file(&dev->dev, &dev_attr_hid);
183 if(dev->handle) 248 if(dev->handle)
@@ -186,6 +251,37 @@ static void acpi_device_remove_files(struct acpi_device *dev)
186/* -------------------------------------------------------------------------- 251/* --------------------------------------------------------------------------
187 ACPI Bus operations 252 ACPI Bus operations
188 -------------------------------------------------------------------------- */ 253 -------------------------------------------------------------------------- */
254
255int acpi_match_device_ids(struct acpi_device *device,
256 const struct acpi_device_id *ids)
257{
258 const struct acpi_device_id *id;
259
260 if (device->flags.hardware_id) {
261 for (id = ids; id->id[0]; id++) {
262 if (!strcmp((char*)id->id, device->pnp.hardware_id))
263 return 0;
264 }
265 }
266
267 if (device->flags.compatible_ids) {
268 struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
269 int i;
270
271 for (id = ids; id->id[0]; id++) {
272 /* compare multiple _CID entries against driver ids */
273 for (i = 0; i < cid_list->count; i++) {
274 if (!strcmp((char*)id->id,
275 cid_list->id[i].value))
276 return 0;
277 }
278 }
279 }
280
281 return -ENOENT;
282}
283EXPORT_SYMBOL(acpi_match_device_ids);
284
189static void acpi_device_release(struct device *dev) 285static void acpi_device_release(struct device *dev)
190{ 286{
191 struct acpi_device *acpi_dev = to_acpi_device(dev); 287 struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -219,37 +315,19 @@ static int acpi_bus_match(struct device *dev, struct device_driver *drv)
219 struct acpi_device *acpi_dev = to_acpi_device(dev); 315 struct acpi_device *acpi_dev = to_acpi_device(dev);
220 struct acpi_driver *acpi_drv = to_acpi_driver(drv); 316 struct acpi_driver *acpi_drv = to_acpi_driver(drv);
221 317
222 return !acpi_match_ids(acpi_dev, acpi_drv->ids); 318 return !acpi_match_device_ids(acpi_dev, acpi_drv->ids);
223} 319}
224 320
225static int acpi_device_uevent(struct device *dev, char **envp, int num_envp, 321static int acpi_device_uevent(struct device *dev, char **envp, int num_envp,
226 char *buffer, int buffer_size) 322 char *buffer, int buffer_size)
227{ 323{
228 struct acpi_device *acpi_dev = to_acpi_device(dev); 324 struct acpi_device *acpi_dev = to_acpi_device(dev);
229 int i = 0, length = 0, ret = 0;
230
231 if (acpi_dev->flags.hardware_id)
232 ret = add_uevent_var(envp, num_envp, &i,
233 buffer, buffer_size, &length,
234 "HWID=%s", acpi_dev->pnp.hardware_id);
235 if (ret)
236 return -ENOMEM;
237 if (acpi_dev->flags.compatible_ids) {
238 int j;
239 struct acpi_compatible_id_list *cid_list;
240 325
241 cid_list = acpi_dev->pnp.cid_list; 326 strcpy(buffer, "MODALIAS=");
242 327 if (create_modalias(acpi_dev, buffer + 9, buffer_size - 9) > 0) {
243 for (j = 0; j < cid_list->count; j++) { 328 envp[0] = buffer;
244 ret = add_uevent_var(envp, num_envp, &i, buffer, 329 envp[1] = NULL;
245 buffer_size, &length, "COMPTID=%s",
246 cid_list->id[j].value);
247 if (ret)
248 return -ENOMEM;
249 }
250 } 330 }
251
252 envp[i] = NULL;
253 return 0; 331 return 0;
254} 332}
255 333
@@ -543,25 +621,6 @@ void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context)
543 return; 621 return;
544} 622}
545 623
546int acpi_match_ids(struct acpi_device *device, char *ids)
547{
548 if (device->flags.hardware_id)
549 if (strstr(ids, device->pnp.hardware_id))
550 return 0;
551
552 if (device->flags.compatible_ids) {
553 struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
554 int i;
555
556 /* compare multiple _CID entries against driver ids */
557 for (i = 0; i < cid_list->count; i++) {
558 if (strstr(ids, cid_list->id[i].value))
559 return 0;
560 }
561 }
562 return -ENOENT;
563}
564
565static int acpi_bus_get_perf_flags(struct acpi_device *device) 624static int acpi_bus_get_perf_flags(struct acpi_device *device)
566{ 625{
567 device->performance.state = ACPI_STATE_UNKNOWN; 626 device->performance.state = ACPI_STATE_UNKNOWN;
@@ -624,6 +683,13 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
624 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 683 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
625 union acpi_object *package = NULL; 684 union acpi_object *package = NULL;
626 685
686 struct acpi_device_id button_device_ids[] = {
687 {"PNP0C0D", 0},
688 {"PNP0C0C", 0},
689 {"PNP0C0E", 0},
690 {"", 0},
691 };
692
627 693
628 /* _PRW */ 694 /* _PRW */
629 status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer); 695 status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
@@ -643,7 +709,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
643 709
644 device->wakeup.flags.valid = 1; 710 device->wakeup.flags.valid = 1;
645 /* Power button, Lid switch always enable wakeup */ 711 /* Power button, Lid switch always enable wakeup */
646 if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E")) 712 if (!acpi_match_device_ids(device, button_device_ids))
647 device->wakeup.flags.run_wake = 1; 713 device->wakeup.flags.run_wake = 1;
648 714
649 end: 715 end:
diff --git a/drivers/acpi/sleep/Makefile b/drivers/acpi/sleep/Makefile
index d6c017709c85..195a4f69c0f7 100644
--- a/drivers/acpi/sleep/Makefile
+++ b/drivers/acpi/sleep/Makefile
@@ -1,5 +1,5 @@
1obj-y := poweroff.o wakeup.o 1obj-y := poweroff.o wakeup.o
2obj-$(CONFIG_ACPI_SLEEP) += main.o 2obj-$(CONFIG_ACPI_SLEEP) += main.o
3obj-$(CONFIG_ACPI_SLEEP_PROC_FS) += proc.o 3obj-$(CONFIG_ACPI_SLEEP) += proc.o
4 4
5EXTRA_CFLAGS += $(ACPI_CFLAGS) 5EXTRA_CFLAGS += $(ACPI_CFLAGS)
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 3279e72a94f8..e8cff5dd4cbc 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -21,6 +21,9 @@
21 21
22u8 sleep_states[ACPI_S_STATE_COUNT]; 22u8 sleep_states[ACPI_S_STATE_COUNT];
23 23
24static u32 acpi_target_sleep_state = ACPI_STATE_S0;
25
26#ifdef CONFIG_SUSPEND
24static struct pm_ops acpi_pm_ops; 27static struct pm_ops acpi_pm_ops;
25 28
26extern void do_suspend_lowlevel(void); 29extern void do_suspend_lowlevel(void);
@@ -35,34 +38,49 @@ static u32 acpi_suspend_states[] = {
35static int init_8259A_after_S1; 38static int init_8259A_after_S1;
36 39
37/** 40/**
41 * acpi_pm_set_target - Set the target system sleep state to the state
42 * associated with given @pm_state, if supported.
43 */
44
45static int acpi_pm_set_target(suspend_state_t pm_state)
46{
47 u32 acpi_state = acpi_suspend_states[pm_state];
48 int error = 0;
49
50 if (sleep_states[acpi_state]) {
51 acpi_target_sleep_state = acpi_state;
52 } else {
53 printk(KERN_ERR "ACPI does not support this state: %d\n",
54 pm_state);
55 error = -ENOSYS;
56 }
57 return error;
58}
59
60/**
38 * acpi_pm_prepare - Do preliminary suspend work. 61 * acpi_pm_prepare - Do preliminary suspend work.
39 * @pm_state: suspend state we're entering. 62 * @pm_state: ignored
40 * 63 *
41 * Make sure we support the state. If we do, and we need it, set the 64 * If necessary, set the firmware waking vector and do arch-specific
42 * firmware waking vector and do arch-specific nastiness to get the 65 * nastiness to get the wakeup code to the waking vector.
43 * wakeup code to the waking vector.
44 */ 66 */
45 67
46extern int acpi_sleep_prepare(u32 acpi_state);
47extern void acpi_power_off(void);
48
49static int acpi_pm_prepare(suspend_state_t pm_state) 68static int acpi_pm_prepare(suspend_state_t pm_state)
50{ 69{
51 u32 acpi_state = acpi_suspend_states[pm_state]; 70 int error = acpi_sleep_prepare(acpi_target_sleep_state);
52 71
53 if (!sleep_states[acpi_state]) { 72 if (error)
54 printk("acpi_pm_prepare does not support %d \n", pm_state); 73 acpi_target_sleep_state = ACPI_STATE_S0;
55 return -EPERM; 74
56 } 75 return error;
57 return acpi_sleep_prepare(acpi_state);
58} 76}
59 77
60/** 78/**
61 * acpi_pm_enter - Actually enter a sleep state. 79 * acpi_pm_enter - Actually enter a sleep state.
62 * @pm_state: State we're entering. 80 * @pm_state: ignored
63 * 81 *
64 * Flush caches and go to sleep. For STR or STD, we have to call 82 * Flush caches and go to sleep. For STR we have to call arch-specific
65 * arch-specific assembly, which in turn call acpi_enter_sleep_state(). 83 * assembly, which in turn call acpi_enter_sleep_state().
66 * It's unfortunate, but it works. Please fix if you're feeling frisky. 84 * It's unfortunate, but it works. Please fix if you're feeling frisky.
67 */ 85 */
68 86
@@ -70,31 +88,31 @@ static int acpi_pm_enter(suspend_state_t pm_state)
70{ 88{
71 acpi_status status = AE_OK; 89 acpi_status status = AE_OK;
72 unsigned long flags = 0; 90 unsigned long flags = 0;
73 u32 acpi_state = acpi_suspend_states[pm_state]; 91 u32 acpi_state = acpi_target_sleep_state;
74 92
75 ACPI_FLUSH_CPU_CACHE(); 93 ACPI_FLUSH_CPU_CACHE();
76 94
77 /* Do arch specific saving of state. */ 95 /* Do arch specific saving of state. */
78 if (pm_state > PM_SUSPEND_STANDBY) { 96 if (acpi_state == ACPI_STATE_S3) {
79 int error = acpi_save_state_mem(); 97 int error = acpi_save_state_mem();
80 if (error) 98
99 if (error) {
100 acpi_target_sleep_state = ACPI_STATE_S0;
81 return error; 101 return error;
102 }
82 } 103 }
83 104
84 local_irq_save(flags); 105 local_irq_save(flags);
85 acpi_enable_wakeup_device(acpi_state); 106 acpi_enable_wakeup_device(acpi_state);
86 switch (pm_state) { 107 switch (acpi_state) {
87 case PM_SUSPEND_STANDBY: 108 case ACPI_STATE_S1:
88 barrier(); 109 barrier();
89 status = acpi_enter_sleep_state(acpi_state); 110 status = acpi_enter_sleep_state(acpi_state);
90 break; 111 break;
91 112
92 case PM_SUSPEND_MEM: 113 case ACPI_STATE_S3:
93 do_suspend_lowlevel(); 114 do_suspend_lowlevel();
94 break; 115 break;
95
96 default:
97 return -EINVAL;
98 } 116 }
99 117
100 /* ACPI 3.0 specs (P62) says that it's the responsabilty 118 /* ACPI 3.0 specs (P62) says that it's the responsabilty
@@ -107,12 +125,8 @@ static int acpi_pm_enter(suspend_state_t pm_state)
107 local_irq_restore(flags); 125 local_irq_restore(flags);
108 printk(KERN_DEBUG "Back to C!\n"); 126 printk(KERN_DEBUG "Back to C!\n");
109 127
110 /* restore processor state 128 /* restore processor state */
111 * We should only be here if we're coming back from STR or STD. 129 if (acpi_state == ACPI_STATE_S3)
112 * And, in the case of the latter, the memory image should have already
113 * been loaded from disk.
114 */
115 if (pm_state > PM_SUSPEND_STANDBY)
116 acpi_restore_state_mem(); 130 acpi_restore_state_mem();
117 131
118 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 132 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
@@ -120,7 +134,7 @@ static int acpi_pm_enter(suspend_state_t pm_state)
120 134
121/** 135/**
122 * acpi_pm_finish - Finish up suspend sequence. 136 * acpi_pm_finish - Finish up suspend sequence.
123 * @pm_state: State we're coming out of. 137 * @pm_state: ignored
124 * 138 *
125 * This is called after we wake back up (or if entering the sleep state 139 * This is called after we wake back up (or if entering the sleep state
126 * failed). 140 * failed).
@@ -128,7 +142,7 @@ static int acpi_pm_enter(suspend_state_t pm_state)
128 142
129static int acpi_pm_finish(suspend_state_t pm_state) 143static int acpi_pm_finish(suspend_state_t pm_state)
130{ 144{
131 u32 acpi_state = acpi_suspend_states[pm_state]; 145 u32 acpi_state = acpi_target_sleep_state;
132 146
133 acpi_leave_sleep_state(acpi_state); 147 acpi_leave_sleep_state(acpi_state);
134 acpi_disable_wakeup_device(acpi_state); 148 acpi_disable_wakeup_device(acpi_state);
@@ -136,28 +150,17 @@ static int acpi_pm_finish(suspend_state_t pm_state)
136 /* reset firmware waking vector */ 150 /* reset firmware waking vector */
137 acpi_set_firmware_waking_vector((acpi_physical_address) 0); 151 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
138 152
153 acpi_target_sleep_state = ACPI_STATE_S0;
154
155#ifdef CONFIG_X86
139 if (init_8259A_after_S1) { 156 if (init_8259A_after_S1) {
140 printk("Broken toshiba laptop -> kicking interrupts\n"); 157 printk("Broken toshiba laptop -> kicking interrupts\n");
141 init_8259A(0); 158 init_8259A(0);
142 } 159 }
160#endif
143 return 0; 161 return 0;
144} 162}
145 163
146int acpi_suspend(u32 acpi_state)
147{
148 suspend_state_t states[] = {
149 [1] = PM_SUSPEND_STANDBY,
150 [3] = PM_SUSPEND_MEM,
151 [5] = PM_SUSPEND_MAX
152 };
153
154 if (acpi_state < 6 && states[acpi_state])
155 return pm_suspend(states[acpi_state]);
156 if (acpi_state == 4)
157 return hibernate();
158 return -EINVAL;
159}
160
161static int acpi_pm_state_valid(suspend_state_t pm_state) 164static int acpi_pm_state_valid(suspend_state_t pm_state)
162{ 165{
163 u32 acpi_state; 166 u32 acpi_state;
@@ -176,12 +179,34 @@ static int acpi_pm_state_valid(suspend_state_t pm_state)
176 179
177static struct pm_ops acpi_pm_ops = { 180static struct pm_ops acpi_pm_ops = {
178 .valid = acpi_pm_state_valid, 181 .valid = acpi_pm_state_valid,
182 .set_target = acpi_pm_set_target,
179 .prepare = acpi_pm_prepare, 183 .prepare = acpi_pm_prepare,
180 .enter = acpi_pm_enter, 184 .enter = acpi_pm_enter,
181 .finish = acpi_pm_finish, 185 .finish = acpi_pm_finish,
182}; 186};
183 187
184#ifdef CONFIG_SOFTWARE_SUSPEND 188/*
189 * Toshiba fails to preserve interrupts over S1, reinitialization
190 * of 8259 is needed after S1 resume.
191 */
192static int __init init_ints_after_s1(struct dmi_system_id *d)
193{
194 printk(KERN_WARNING "%s with broken S1 detected.\n", d->ident);
195 init_8259A_after_S1 = 1;
196 return 0;
197}
198
199static struct dmi_system_id __initdata acpisleep_dmi_table[] = {
200 {
201 .callback = init_ints_after_s1,
202 .ident = "Toshiba Satellite 4030cdt",
203 .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),},
204 },
205 {},
206};
207#endif /* CONFIG_SUSPEND */
208
209#ifdef CONFIG_HIBERNATION
185static int acpi_hibernation_prepare(void) 210static int acpi_hibernation_prepare(void)
186{ 211{
187 return acpi_sleep_prepare(ACPI_STATE_S4); 212 return acpi_sleep_prepare(ACPI_STATE_S4);
@@ -233,41 +258,114 @@ static struct hibernation_ops acpi_hibernation_ops = {
233 .pre_restore = acpi_hibernation_pre_restore, 258 .pre_restore = acpi_hibernation_pre_restore,
234 .restore_cleanup = acpi_hibernation_restore_cleanup, 259 .restore_cleanup = acpi_hibernation_restore_cleanup,
235}; 260};
236#endif /* CONFIG_SOFTWARE_SUSPEND */ 261#endif /* CONFIG_HIBERNATION */
237 262
238/* 263int acpi_suspend(u32 acpi_state)
239 * Toshiba fails to preserve interrupts over S1, reinitialization
240 * of 8259 is needed after S1 resume.
241 */
242static int __init init_ints_after_s1(struct dmi_system_id *d)
243{ 264{
244 printk(KERN_WARNING "%s with broken S1 detected.\n", d->ident); 265 suspend_state_t states[] = {
245 init_8259A_after_S1 = 1; 266 [1] = PM_SUSPEND_STANDBY,
246 return 0; 267 [3] = PM_SUSPEND_MEM,
268 [5] = PM_SUSPEND_MAX
269 };
270
271 if (acpi_state < 6 && states[acpi_state])
272 return pm_suspend(states[acpi_state]);
273 if (acpi_state == 4)
274 return hibernate();
275 return -EINVAL;
247} 276}
248 277
249static struct dmi_system_id __initdata acpisleep_dmi_table[] = { 278/**
250 { 279 * acpi_pm_device_sleep_state - return preferred power state of ACPI device
251 .callback = init_ints_after_s1, 280 * in the system sleep state given by %acpi_target_sleep_state
252 .ident = "Toshiba Satellite 4030cdt", 281 * @dev: device to examine
253 .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),}, 282 * @wake: if set, the device should be able to wake up the system
254 }, 283 * @d_min_p: used to store the upper limit of allowed states range
255 {}, 284 * Return value: preferred power state of the device on success, -ENODEV on
256}; 285 * failure (ie. if there's no 'struct acpi_device' for @dev)
286 *
287 * Find the lowest power (highest number) ACPI device power state that
288 * device @dev can be in while the system is in the sleep state represented
289 * by %acpi_target_sleep_state. If @wake is nonzero, the device should be
290 * able to wake up the system from this sleep state. If @d_min_p is set,
291 * the highest power (lowest number) device power state of @dev allowed
292 * in this system sleep state is stored at the location pointed to by it.
293 *
294 * The caller must ensure that @dev is valid before using this function.
295 * The caller is also responsible for figuring out if the device is
296 * supposed to be able to wake up the system and passing this information
297 * via @wake.
298 */
299
300int acpi_pm_device_sleep_state(struct device *dev, int wake, int *d_min_p)
301{
302 acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
303 struct acpi_device *adev;
304 char acpi_method[] = "_SxD";
305 unsigned long d_min, d_max;
306
307 if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
308 printk(KERN_ERR "ACPI handle has no context!\n");
309 return -ENODEV;
310 }
311
312 acpi_method[2] = '0' + acpi_target_sleep_state;
313 /*
314 * If the sleep state is S0, we will return D3, but if the device has
315 * _S0W, we will use the value from _S0W
316 */
317 d_min = ACPI_STATE_D0;
318 d_max = ACPI_STATE_D3;
319
320 /*
321 * If present, _SxD methods return the minimum D-state (highest power
322 * state) we can use for the corresponding S-states. Otherwise, the
323 * minimum D-state is D0 (ACPI 3.x).
324 *
325 * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer
326 * provided -- that's our fault recovery, we ignore retval.
327 */
328 if (acpi_target_sleep_state > ACPI_STATE_S0)
329 acpi_evaluate_integer(handle, acpi_method, NULL, &d_min);
330
331 /*
332 * If _PRW says we can wake up the system from the target sleep state,
333 * the D-state returned by _SxD is sufficient for that (we assume a
334 * wakeup-aware driver if wake is set). Still, if _SxW exists
335 * (ACPI 3.x), it should return the maximum (lowest power) D-state that
336 * can wake the system. _S0W may be valid, too.
337 */
338 if (acpi_target_sleep_state == ACPI_STATE_S0 ||
339 (wake && adev->wakeup.state.enabled &&
340 adev->wakeup.sleep_state <= acpi_target_sleep_state)) {
341 acpi_method[3] = 'W';
342 acpi_evaluate_integer(handle, acpi_method, NULL, &d_max);
343 /* Sanity check */
344 if (d_max < d_min)
345 d_min = d_max;
346 }
347
348 if (d_min_p)
349 *d_min_p = d_min;
350 return d_max;
351}
257 352
258int __init acpi_sleep_init(void) 353int __init acpi_sleep_init(void)
259{ 354{
355 acpi_status status;
356 u8 type_a, type_b;
357#ifdef CONFIG_SUSPEND
260 int i = 0; 358 int i = 0;
261 359
262 dmi_check_system(acpisleep_dmi_table); 360 dmi_check_system(acpisleep_dmi_table);
361#endif
263 362
264 if (acpi_disabled) 363 if (acpi_disabled)
265 return 0; 364 return 0;
266 365
366#ifdef CONFIG_SUSPEND
267 printk(KERN_INFO PREFIX "(supports"); 367 printk(KERN_INFO PREFIX "(supports");
268 for (i = 0; i < ACPI_S_STATE_COUNT; i++) { 368 for (i = ACPI_STATE_S0; i < ACPI_STATE_S4; i++) {
269 acpi_status status;
270 u8 type_a, type_b;
271 status = acpi_get_sleep_type_data(i, &type_a, &type_b); 369 status = acpi_get_sleep_type_data(i, &type_a, &type_b);
272 if (ACPI_SUCCESS(status)) { 370 if (ACPI_SUCCESS(status)) {
273 sleep_states[i] = 1; 371 sleep_states[i] = 1;
@@ -277,10 +375,14 @@ int __init acpi_sleep_init(void)
277 printk(")\n"); 375 printk(")\n");
278 376
279 pm_set_ops(&acpi_pm_ops); 377 pm_set_ops(&acpi_pm_ops);
378#endif
280 379
281#ifdef CONFIG_SOFTWARE_SUSPEND 380#ifdef CONFIG_HIBERNATION
282 if (sleep_states[ACPI_STATE_S4]) 381 status = acpi_get_sleep_type_data(ACPI_STATE_S4, &type_a, &type_b);
382 if (ACPI_SUCCESS(status)) {
283 hibernation_set_ops(&acpi_hibernation_ops); 383 hibernation_set_ops(&acpi_hibernation_ops);
384 sleep_states[ACPI_STATE_S4] = 1;
385 }
284#else 386#else
285 sleep_states[ACPI_STATE_S4] = 0; 387 sleep_states[ACPI_STATE_S4] = 0;
286#endif 388#endif
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c
index 61f1822cc350..66b62b0d3609 100644
--- a/drivers/acpi/sleep/proc.c
+++ b/drivers/acpi/sleep/proc.c
@@ -14,8 +14,16 @@
14#include "sleep.h" 14#include "sleep.h"
15 15
16#define _COMPONENT ACPI_SYSTEM_COMPONENT 16#define _COMPONENT ACPI_SYSTEM_COMPONENT
17
18/*
19 * this file provides support for:
20 * /proc/acpi/sleep
21 * /proc/acpi/alarm
22 * /proc/acpi/wakeup
23 */
24
17ACPI_MODULE_NAME("sleep") 25ACPI_MODULE_NAME("sleep")
18#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 26#ifdef CONFIG_ACPI_PROCFS_SLEEP
19static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset) 27static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset)
20{ 28{
21 int i; 29 int i;
@@ -58,7 +66,7 @@ acpi_system_write_sleep(struct file *file,
58 goto Done; 66 goto Done;
59 } 67 }
60 state = simple_strtoul(str, NULL, 0); 68 state = simple_strtoul(str, NULL, 0);
61#ifdef CONFIG_SOFTWARE_SUSPEND 69#ifdef CONFIG_HIBERNATION
62 if (state == 4) { 70 if (state == 4) {
63 error = hibernate(); 71 error = hibernate();
64 goto Done; 72 goto Done;
@@ -68,9 +76,9 @@ acpi_system_write_sleep(struct file *file,
68 Done: 76 Done:
69 return error ? error : count; 77 return error ? error : count;
70} 78}
71#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 79#endif /* CONFIG_ACPI_PROCFS_SLEEP */
72 80
73#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) 81#if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE) || !defined(CONFIG_X86)
74/* use /sys/class/rtc/rtcX/wakealarm instead; it's not ACPI-specific */ 82/* use /sys/class/rtc/rtcX/wakealarm instead; it's not ACPI-specific */
75#else 83#else
76#define HAVE_ACPI_LEGACY_ALARM 84#define HAVE_ACPI_LEGACY_ALARM
@@ -463,7 +471,7 @@ static const struct file_operations acpi_system_wakeup_device_fops = {
463 .release = single_release, 471 .release = single_release,
464}; 472};
465 473
466#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 474#ifdef CONFIG_ACPI_PROCFS_SLEEP
467static const struct file_operations acpi_system_sleep_fops = { 475static const struct file_operations acpi_system_sleep_fops = {
468 .open = acpi_system_sleep_open_fs, 476 .open = acpi_system_sleep_open_fs,
469 .read = seq_read, 477 .read = seq_read,
@@ -471,7 +479,7 @@ static const struct file_operations acpi_system_sleep_fops = {
471 .llseek = seq_lseek, 479 .llseek = seq_lseek,
472 .release = single_release, 480 .release = single_release,
473}; 481};
474#endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ 482#endif /* CONFIG_ACPI_PROCFS_SLEEP */
475 483
476#ifdef HAVE_ACPI_LEGACY_ALARM 484#ifdef HAVE_ACPI_LEGACY_ALARM
477static const struct file_operations acpi_system_alarm_fops = { 485static const struct file_operations acpi_system_alarm_fops = {
@@ -498,14 +506,14 @@ static int __init acpi_sleep_proc_init(void)
498 if (acpi_disabled) 506 if (acpi_disabled)
499 return 0; 507 return 0;
500 508
501#ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP 509#ifdef CONFIG_ACPI_PROCFS_SLEEP
502 /* 'sleep' [R/W] */ 510 /* 'sleep' [R/W] */
503 entry = 511 entry =
504 create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR, 512 create_proc_entry("sleep", S_IFREG | S_IRUGO | S_IWUSR,
505 acpi_root_dir); 513 acpi_root_dir);
506 if (entry) 514 if (entry)
507 entry->proc_fops = &acpi_system_sleep_fops; 515 entry->proc_fops = &acpi_system_sleep_fops;
508#endif 516#endif /* CONFIG_ACPI_PROCFS */
509 517
510#ifdef HAVE_ACPI_LEGACY_ALARM 518#ifdef HAVE_ACPI_LEGACY_ALARM
511 /* 'alarm' [R/W] */ 519 /* 'alarm' [R/W] */
diff --git a/drivers/acpi/sleep/sleep.h b/drivers/acpi/sleep/sleep.h
index f3e70397a7d6..ff1f8504f497 100644
--- a/drivers/acpi/sleep/sleep.h
+++ b/drivers/acpi/sleep/sleep.h
@@ -6,3 +6,5 @@ extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
6extern void acpi_enable_wakeup_device(u8 sleep_state); 6extern void acpi_enable_wakeup_device(u8 sleep_state);
7extern void acpi_disable_wakeup_device(u8 sleep_state); 7extern void acpi_disable_wakeup_device(u8 sleep_state);
8extern void acpi_gpe_sleep_prepare(u32 sleep_state); 8extern void acpi_gpe_sleep_prepare(u32 sleep_state);
9
10extern int acpi_sleep_prepare(u32 acpi_state);
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c
index fab8f2694f03..97c27ddb144d 100644
--- a/drivers/acpi/sleep/wakeup.c
+++ b/drivers/acpi/sleep/wakeup.c
@@ -17,7 +17,6 @@ ACPI_MODULE_NAME("wakeup_devices")
17extern struct list_head acpi_wakeup_device_list; 17extern struct list_head acpi_wakeup_device_list;
18extern spinlock_t acpi_device_lock; 18extern spinlock_t acpi_device_lock;
19 19
20#ifdef CONFIG_ACPI_SLEEP
21/** 20/**
22 * acpi_enable_wakeup_device_prep - prepare wakeup devices 21 * acpi_enable_wakeup_device_prep - prepare wakeup devices
23 * @sleep_state: ACPI state 22 * @sleep_state: ACPI state
@@ -180,7 +179,6 @@ static int __init acpi_wakeup_device_init(void)
180} 179}
181 180
182late_initcall(acpi_wakeup_device_init); 181late_initcall(acpi_wakeup_device_init);
183#endif
184 182
185/* 183/*
186 * Disable all wakeup GPEs before entering requested sleep state. 184 * Disable all wakeup GPEs before entering requested sleep state.
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 58f1338981bc..5a62de1b7f2a 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -92,10 +92,16 @@ static int acpi_thermal_polling_open_fs(struct inode *inode, struct file *file);
92static ssize_t acpi_thermal_write_polling(struct file *, const char __user *, 92static ssize_t acpi_thermal_write_polling(struct file *, const char __user *,
93 size_t, loff_t *); 93 size_t, loff_t *);
94 94
95static const struct acpi_device_id thermal_device_ids[] = {
96 {ACPI_THERMAL_HID, 0},
97 {"", 0},
98};
99MODULE_DEVICE_TABLE(acpi, thermal_device_ids);
100
95static struct acpi_driver acpi_thermal_driver = { 101static struct acpi_driver acpi_thermal_driver = {
96 .name = "thermal", 102 .name = "thermal",
97 .class = ACPI_THERMAL_CLASS, 103 .class = ACPI_THERMAL_CLASS,
98 .ids = ACPI_THERMAL_HID, 104 .ids = thermal_device_ids,
99 .ops = { 105 .ops = {
100 .add = acpi_thermal_add, 106 .add = acpi_thermal_add,
101 .remove = acpi_thermal_remove, 107 .remove = acpi_thermal_remove,
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
index f112af433e36..0042b7e78b26 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/utilities/uteval.c
@@ -407,7 +407,7 @@ acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length)
407 407
408acpi_status 408acpi_status
409acpi_ut_execute_HID(struct acpi_namespace_node *device_node, 409acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
410 struct acpi_device_id *hid) 410 struct acpica_device_id *hid)
411{ 411{
412 union acpi_operand_object *obj_desc; 412 union acpi_operand_object *obj_desc;
413 acpi_status status; 413 acpi_status status;
@@ -609,7 +609,7 @@ acpi_ut_execute_CID(struct acpi_namespace_node * device_node,
609 609
610acpi_status 610acpi_status
611acpi_ut_execute_UID(struct acpi_namespace_node *device_node, 611acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
612 struct acpi_device_id *uid) 612 struct acpica_device_id *uid)
613{ 613{
614 union acpi_operand_object *obj_desc; 614 union acpi_operand_object *obj_desc;
615 acpi_status status; 615 acpi_status status;
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 04ea697f72bf..d98701941981 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -74,10 +74,16 @@ MODULE_LICENSE("GPL");
74static int acpi_video_bus_add(struct acpi_device *device); 74static int acpi_video_bus_add(struct acpi_device *device);
75static int acpi_video_bus_remove(struct acpi_device *device, int type); 75static int acpi_video_bus_remove(struct acpi_device *device, int type);
76 76
77static const struct acpi_device_id video_device_ids[] = {
78 {ACPI_VIDEO_HID, 0},
79 {"", 0},
80};
81MODULE_DEVICE_TABLE(acpi, video_device_ids);
82
77static struct acpi_driver acpi_video_bus = { 83static struct acpi_driver acpi_video_bus = {
78 .name = "video", 84 .name = "video",
79 .class = ACPI_VIDEO_CLASS, 85 .class = ACPI_VIDEO_CLASS,
80 .ids = ACPI_VIDEO_HID, 86 .ids = video_device_ids,
81 .ops = { 87 .ops = {
82 .add = acpi_video_bus_add, 88 .add = acpi_video_bus_add,
83 .remove = acpi_video_bus_remove, 89 .remove = acpi_video_bus_remove,
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index d9fa329fd157..ad070861bb53 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -91,6 +91,7 @@
91#include <linux/device.h> 91#include <linux/device.h>
92#include <scsi/scsi_host.h> 92#include <scsi/scsi_host.h>
93#include <linux/libata.h> 93#include <linux/libata.h>
94#include <linux/dmi.h>
94 95
95#define DRV_NAME "ata_piix" 96#define DRV_NAME "ata_piix"
96#define DRV_VERSION "2.11" 97#define DRV_VERSION "2.11"
@@ -140,6 +141,9 @@ enum {
140 RV = -3, /* reserved */ 141 RV = -3, /* reserved */
141 142
142 PIIX_AHCI_DEVICE = 6, 143 PIIX_AHCI_DEVICE = 6,
144
145 /* host->flags bits */
146 PIIX_HOST_BROKEN_SUSPEND = (1 << 24),
143}; 147};
144 148
145struct piix_map_db { 149struct piix_map_db {
@@ -159,6 +163,10 @@ static void piix_set_piomode (struct ata_port *ap, struct ata_device *adev);
159static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev); 163static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev);
160static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev); 164static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev);
161static int ich_pata_cable_detect(struct ata_port *ap); 165static int ich_pata_cable_detect(struct ata_port *ap);
166#ifdef CONFIG_PM
167static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
168static int piix_pci_device_resume(struct pci_dev *pdev);
169#endif
162 170
163static unsigned int in_module_init = 1; 171static unsigned int in_module_init = 1;
164 172
@@ -255,8 +263,8 @@ static struct pci_driver piix_pci_driver = {
255 .probe = piix_init_one, 263 .probe = piix_init_one,
256 .remove = ata_pci_remove_one, 264 .remove = ata_pci_remove_one,
257#ifdef CONFIG_PM 265#ifdef CONFIG_PM
258 .suspend = ata_pci_device_suspend, 266 .suspend = piix_pci_device_suspend,
259 .resume = ata_pci_device_resume, 267 .resume = piix_pci_device_resume,
260#endif 268#endif
261}; 269};
262 270
@@ -881,6 +889,107 @@ static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev)
881 do_pata_set_dmamode(ap, adev, 1); 889 do_pata_set_dmamode(ap, adev, 1);
882} 890}
883 891
892#ifdef CONFIG_PM
893static struct dmi_system_id piix_broken_suspend_dmi_table[] = {
894 {
895 .ident = "TECRA M5",
896 .matches = {
897 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
898 DMI_MATCH(DMI_PRODUCT_NAME, "TECRA M5"),
899 },
900 },
901 {
902 .ident = "Satellite U200",
903 .matches = {
904 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
905 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite U200"),
906 },
907 },
908 {
909 .ident = "Satellite U205",
910 .matches = {
911 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
912 DMI_MATCH(DMI_PRODUCT_NAME, "Satellite U205"),
913 },
914 },
915 {
916 .ident = "Portege M500",
917 .matches = {
918 DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
919 DMI_MATCH(DMI_PRODUCT_NAME, "PORTEGE M500"),
920 },
921 },
922 { }
923};
924
925static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
926{
927 struct ata_host *host = dev_get_drvdata(&pdev->dev);
928 unsigned long flags;
929 int rc = 0;
930
931 rc = ata_host_suspend(host, mesg);
932 if (rc)
933 return rc;
934
935 /* Some braindamaged ACPI suspend implementations expect the
936 * controller to be awake on entry; otherwise, it burns cpu
937 * cycles and power trying to do something to the sleeping
938 * beauty.
939 */
940 if (dmi_check_system(piix_broken_suspend_dmi_table) &&
941 mesg.event == PM_EVENT_SUSPEND) {
942 pci_save_state(pdev);
943
944 /* mark its power state as "unknown", since we don't
945 * know if e.g. the BIOS will change its device state
946 * when we suspend.
947 */
948 if (pdev->current_state == PCI_D0)
949 pdev->current_state = PCI_UNKNOWN;
950
951 /* tell resume that it's waking up from broken suspend */
952 spin_lock_irqsave(&host->lock, flags);
953 host->flags |= PIIX_HOST_BROKEN_SUSPEND;
954 spin_unlock_irqrestore(&host->lock, flags);
955 } else
956 ata_pci_device_do_suspend(pdev, mesg);
957
958 return 0;
959}
960
961static int piix_pci_device_resume(struct pci_dev *pdev)
962{
963 struct ata_host *host = dev_get_drvdata(&pdev->dev);
964 unsigned long flags;
965 int rc;
966
967 if (host->flags & PIIX_HOST_BROKEN_SUSPEND) {
968 spin_lock_irqsave(&host->lock, flags);
969 host->flags &= ~PIIX_HOST_BROKEN_SUSPEND;
970 spin_unlock_irqrestore(&host->lock, flags);
971
972 pci_set_power_state(pdev, PCI_D0);
973 pci_restore_state(pdev);
974
975 /* PCI device wasn't disabled during suspend. Use
976 * __pci_reenable_device() to avoid affecting the
977 * enable count.
978 */
979 rc = __pci_reenable_device(pdev);
980 if (rc)
981 dev_printk(KERN_ERR, &pdev->dev, "failed to enable "
982 "device after resume (%d)\n", rc);
983 } else
984 rc = ata_pci_device_do_resume(pdev);
985
986 if (rc == 0)
987 ata_host_resume(host);
988
989 return rc;
990}
991#endif
992
884#define AHCI_PCI_BAR 5 993#define AHCI_PCI_BAR 5
885#define AHCI_GLOBAL_CTL 0x04 994#define AHCI_GLOBAL_CTL 0x04
886#define AHCI_ENABLE (1 << 31) 995#define AHCI_ENABLE (1 << 31)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 12ac0b511f79..e83647651b31 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -768,7 +768,7 @@ static void ata_scsi_dev_config(struct scsi_device *sdev,
768 * Decrement max hw segments accordingly. 768 * Decrement max hw segments accordingly.
769 */ 769 */
770 if (dev->class == ATA_DEV_ATAPI) { 770 if (dev->class == ATA_DEV_ATAPI) {
771 request_queue_t *q = sdev->request_queue; 771 struct request_queue *q = sdev->request_queue;
772 blk_queue_max_hw_segments(q, q->max_hw_segments - 1); 772 blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
773 } 773 }
774 774
diff --git a/drivers/ata/pata_ali.c b/drivers/ata/pata_ali.c
index 010436795d20..e8a28e94fe47 100644
--- a/drivers/ata/pata_ali.c
+++ b/drivers/ata/pata_ali.c
@@ -45,7 +45,7 @@ static struct dmi_system_id cable_dmi_table[] = {
45 .ident = "HP Pavilion N5430", 45 .ident = "HP Pavilion N5430",
46 .matches = { 46 .matches = {
47 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 47 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
48 DMI_MATCH(DMI_BOARD_NAME, "OmniBook N32N-736"), 48 DMI_MATCH(DMI_BOARD_VERSION, "OmniBook N32N-736"),
49 }, 49 },
50 }, 50 },
51 { } 51 { }
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index b0af65aadde3..84d9c5568567 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -26,7 +26,7 @@
26#include <linux/libata.h> 26#include <linux/libata.h>
27 27
28#define DRV_NAME "pata_hpt37x" 28#define DRV_NAME "pata_hpt37x"
29#define DRV_VERSION "0.6.6" 29#define DRV_VERSION "0.6.7"
30 30
31struct hpt_clock { 31struct hpt_clock {
32 u8 xfer_speed; 32 u8 xfer_speed;
@@ -1103,17 +1103,17 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1103 1103
1104 /* Select the DPLL clock. */ 1104 /* Select the DPLL clock. */
1105 pci_write_config_byte(dev, 0x5b, 0x21); 1105 pci_write_config_byte(dev, 0x5b, 0x21);
1106 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low); 1106 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low | 0x100);
1107 1107
1108 for(adjust = 0; adjust < 8; adjust++) { 1108 for(adjust = 0; adjust < 8; adjust++) {
1109 if (hpt37x_calibrate_dpll(dev)) 1109 if (hpt37x_calibrate_dpll(dev))
1110 break; 1110 break;
1111 /* See if it'll settle at a fractionally different clock */ 1111 /* See if it'll settle at a fractionally different clock */
1112 if ((adjust & 3) == 3) { 1112 if (adjust & 1)
1113 f_low --; 1113 f_low -= adjust >> 1;
1114 f_high ++; 1114 else
1115 } 1115 f_high += adjust >> 1;
1116 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low); 1116 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low | 0x100);
1117 } 1117 }
1118 if (adjust == 8) { 1118 if (adjust == 8) {
1119 printk(KERN_WARNING "hpt37x: DPLL did not stabilize.\n"); 1119 printk(KERN_WARNING "hpt37x: DPLL did not stabilize.\n");
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 3599ab2506d2..e6738bcbe5a9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -24,8 +24,6 @@
24#include "base.h" 24#include "base.h"
25#include "power/power.h" 25#include "power/power.h"
26 26
27extern const char *kobject_actions[];
28
29int (*platform_notify)(struct device * dev) = NULL; 27int (*platform_notify)(struct device * dev) = NULL;
30int (*platform_notify_remove)(struct device * dev) = NULL; 28int (*platform_notify_remove)(struct device * dev) = NULL;
31 29
@@ -680,8 +678,7 @@ static int device_add_class_symlinks(struct device *dev)
680 if (error) 678 if (error)
681 goto out_subsys; 679 goto out_subsys;
682 } 680 }
683 /* only bus-device parents get a "device"-link */ 681 if (dev->parent) {
684 if (dev->parent && dev->parent->bus) {
685 error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, 682 error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,
686 "device"); 683 "device");
687 if (error) 684 if (error)
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index fe7ef3394144..40545071e3c9 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -53,7 +53,7 @@ static ssize_t store_online(struct sys_device *dev, const char *buf,
53 ret = count; 53 ret = count;
54 return ret; 54 return ret;
55} 55}
56static SYSDEV_ATTR(online, 0600, show_online, store_online); 56static SYSDEV_ATTR(online, 0644, show_online, store_online);
57 57
58static void __devinit register_cpu_control(struct cpu *cpu) 58static void __devinit register_cpu_control(struct cpu *cpu)
59{ 59{
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 53f0ee6f3016..b24efd4e3e3d 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -232,6 +232,7 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size)
232/** 232/**
233 * firmware_data_write - write method for firmware 233 * firmware_data_write - write method for firmware
234 * @kobj: kobject for the device 234 * @kobj: kobject for the device
235 * @bin_attr: bin_attr structure
235 * @buffer: buffer being written 236 * @buffer: buffer being written
236 * @offset: buffer offset for write in total data store area 237 * @offset: buffer offset for write in total data store area
237 * @count: buffer size 238 * @count: buffer size
diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile
index 966a5e287415..9caeaea753a3 100644
--- a/drivers/base/power/Makefile
+++ b/drivers/base/power/Makefile
@@ -1,5 +1,5 @@
1obj-y := shutdown.o 1obj-y := shutdown.o
2obj-$(CONFIG_PM) += main.o suspend.o resume.o sysfs.o 2obj-$(CONFIG_PM_SLEEP) += main.o suspend.o resume.o sysfs.o
3obj-$(CONFIG_PM_TRACE) += trace.o 3obj-$(CONFIG_PM_TRACE) += trace.o
4 4
5ifeq ($(CONFIG_DEBUG_DRIVER),y) 5ifeq ($(CONFIG_DEBUG_DRIVER),y)
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 591a0dd5deee..8ba0830cbc03 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -5,7 +5,7 @@
5extern void device_shutdown(void); 5extern void device_shutdown(void);
6 6
7 7
8#ifdef CONFIG_PM 8#ifdef CONFIG_PM_SLEEP
9 9
10/* 10/*
11 * main.c 11 * main.c
@@ -62,7 +62,7 @@ extern int resume_device(struct device *);
62 */ 62 */
63extern int suspend_device(struct device *, pm_message_t); 63extern int suspend_device(struct device *, pm_message_t);
64 64
65#else /* CONFIG_PM */ 65#else /* CONFIG_PM_SLEEP */
66 66
67 67
68static inline int device_pm_add(struct device * dev) 68static inline int device_pm_add(struct device * dev)
diff --git a/drivers/base/power/shutdown.c b/drivers/base/power/shutdown.c
index a47ee1b70d20..56e8eaaac012 100644
--- a/drivers/base/power/shutdown.c
+++ b/drivers/base/power/shutdown.c
@@ -44,7 +44,5 @@ void device_shutdown(void)
44 dev->driver->shutdown(dev); 44 dev->driver->shutdown(dev);
45 } 45 }
46 } 46 }
47
48 sysdev_shutdown();
49} 47}
50 48
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index a7a099027fca..014e72121b5a 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -31,4 +31,4 @@ obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
31obj-$(CONFIG_BLK_DEV_UB) += ub.o 31obj-$(CONFIG_BLK_DEV_UB) += ub.o
32 32
33obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o 33obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
34obj-$(CONFIG_LGUEST_GUEST) += lguest_blk.o 34obj-$(CONFIG_LGUEST_BLOCK) += lguest_blk.o
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c
index 6ce8b897e262..c9751b2b57e6 100644
--- a/drivers/block/amiflop.c
+++ b/drivers/block/amiflop.c
@@ -1422,7 +1422,7 @@ static void redo_fd_request(void)
1422 goto repeat; 1422 goto repeat;
1423} 1423}
1424 1424
1425static void do_fd_request(request_queue_t * q) 1425static void do_fd_request(struct request_queue * q)
1426{ 1426{
1427 redo_fd_request(); 1427 redo_fd_request();
1428} 1428}
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 1d8466817943..ba07f762c4cb 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -138,7 +138,7 @@ struct aoedev {
138 u16 maxbcnt; 138 u16 maxbcnt;
139 struct work_struct work;/* disk create work struct */ 139 struct work_struct work;/* disk create work struct */
140 struct gendisk *gd; 140 struct gendisk *gd;
141 request_queue_t blkq; 141 struct request_queue blkq;
142 struct hd_geometry geo; 142 struct hd_geometry geo;
143 sector_t ssize; 143 sector_t ssize;
144 struct timer_list timer; 144 struct timer_list timer;
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index 4f598270fa31..007faaf008e7 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -125,7 +125,7 @@ aoeblk_release(struct inode *inode, struct file *filp)
125} 125}
126 126
127static int 127static int
128aoeblk_make_request(request_queue_t *q, struct bio *bio) 128aoeblk_make_request(struct request_queue *q, struct bio *bio)
129{ 129{
130 struct aoedev *d; 130 struct aoedev *d;
131 struct buf *buf; 131 struct buf *buf;
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 14d6b9492750..94268c75d04f 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -1466,7 +1466,7 @@ repeat:
1466} 1466}
1467 1467
1468 1468
1469void do_fd_request(request_queue_t * q) 1469void do_fd_request(struct request_queue * q)
1470{ 1470{
1471 unsigned long flags; 1471 unsigned long flags;
1472 1472
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index a2d6612b80d2..a11b2bd54bbe 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -139,7 +139,7 @@ static struct board_type products[] = {
139 139
140static ctlr_info_t *hba[MAX_CTLR]; 140static ctlr_info_t *hba[MAX_CTLR];
141 141
142static void do_cciss_request(request_queue_t *q); 142static void do_cciss_request(struct request_queue *q);
143static irqreturn_t do_cciss_intr(int irq, void *dev_id); 143static irqreturn_t do_cciss_intr(int irq, void *dev_id);
144static int cciss_open(struct inode *inode, struct file *filep); 144static int cciss_open(struct inode *inode, struct file *filep);
145static int cciss_release(struct inode *inode, struct file *filep); 145static int cciss_release(struct inode *inode, struct file *filep);
@@ -1584,7 +1584,7 @@ static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
1584 */ 1584 */
1585 if (h->gendisk[0] != disk) { 1585 if (h->gendisk[0] != disk) {
1586 if (disk) { 1586 if (disk) {
1587 request_queue_t *q = disk->queue; 1587 struct request_queue *q = disk->queue;
1588 if (disk->flags & GENHD_FL_UP) 1588 if (disk->flags & GENHD_FL_UP)
1589 del_gendisk(disk); 1589 del_gendisk(disk);
1590 if (q) { 1590 if (q) {
@@ -2511,7 +2511,7 @@ after_error_processing:
2511/* 2511/*
2512 * Get a request and submit it to the controller. 2512 * Get a request and submit it to the controller.
2513 */ 2513 */
2514static void do_cciss_request(request_queue_t *q) 2514static void do_cciss_request(struct request_queue *q)
2515{ 2515{
2516 ctlr_info_t *h = q->queuedata; 2516 ctlr_info_t *h = q->queuedata;
2517 CommandList_struct *c; 2517 CommandList_struct *c;
@@ -3227,12 +3227,15 @@ static int alloc_cciss_hba(void)
3227 for (i = 0; i < MAX_CTLR; i++) { 3227 for (i = 0; i < MAX_CTLR; i++) {
3228 if (!hba[i]) { 3228 if (!hba[i]) {
3229 ctlr_info_t *p; 3229 ctlr_info_t *p;
3230
3230 p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); 3231 p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
3231 if (!p) 3232 if (!p)
3232 goto Enomem; 3233 goto Enomem;
3233 p->gendisk[0] = alloc_disk(1 << NWD_SHIFT); 3234 p->gendisk[0] = alloc_disk(1 << NWD_SHIFT);
3234 if (!p->gendisk[0]) 3235 if (!p->gendisk[0]) {
3236 kfree(p);
3235 goto Enomem; 3237 goto Enomem;
3238 }
3236 hba[i] = p; 3239 hba[i] = p;
3237 return i; 3240 return i;
3238 } 3241 }
@@ -3380,7 +3383,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3380 do { 3383 do {
3381 drive_info_struct *drv = &(hba[i]->drv[j]); 3384 drive_info_struct *drv = &(hba[i]->drv[j]);
3382 struct gendisk *disk = hba[i]->gendisk[j]; 3385 struct gendisk *disk = hba[i]->gendisk[j];
3383 request_queue_t *q; 3386 struct request_queue *q;
3384 3387
3385 /* Check if the disk was allocated already */ 3388 /* Check if the disk was allocated already */
3386 if (!disk){ 3389 if (!disk){
@@ -3523,7 +3526,7 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
3523 for (j = 0; j < CISS_MAX_LUN; j++) { 3526 for (j = 0; j < CISS_MAX_LUN; j++) {
3524 struct gendisk *disk = hba[i]->gendisk[j]; 3527 struct gendisk *disk = hba[i]->gendisk[j];
3525 if (disk) { 3528 if (disk) {
3526 request_queue_t *q = disk->queue; 3529 struct request_queue *q = disk->queue;
3527 3530
3528 if (disk->flags & GENHD_FL_UP) 3531 if (disk->flags & GENHD_FL_UP)
3529 del_gendisk(disk); 3532 del_gendisk(disk);
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index b94cd1c32131..be4e3477d83b 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -161,7 +161,7 @@ static int ida_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
161static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo); 161static int ida_getgeo(struct block_device *bdev, struct hd_geometry *geo);
162static int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io); 162static int ida_ctlr_ioctl(ctlr_info_t *h, int dsk, ida_ioctl_t *io);
163 163
164static void do_ida_request(request_queue_t *q); 164static void do_ida_request(struct request_queue *q);
165static void start_io(ctlr_info_t *h); 165static void start_io(ctlr_info_t *h);
166 166
167static inline void addQ(cmdlist_t **Qptr, cmdlist_t *c); 167static inline void addQ(cmdlist_t **Qptr, cmdlist_t *c);
@@ -391,7 +391,7 @@ static void __devexit cpqarray_remove_one_eisa (int i)
391/* pdev is NULL for eisa */ 391/* pdev is NULL for eisa */
392static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev) 392static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev)
393{ 393{
394 request_queue_t *q; 394 struct request_queue *q;
395 int j; 395 int j;
396 396
397 /* 397 /*
@@ -886,7 +886,7 @@ static inline cmdlist_t *removeQ(cmdlist_t **Qptr, cmdlist_t *c)
886 * are in here (either via the dummy do_ida_request functions or by being 886 * are in here (either via the dummy do_ida_request functions or by being
887 * called from the interrupt handler 887 * called from the interrupt handler
888 */ 888 */
889static void do_ida_request(request_queue_t *q) 889static void do_ida_request(struct request_queue *q)
890{ 890{
891 ctlr_info_t *h = q->queuedata; 891 ctlr_info_t *h = q->queuedata;
892 cmdlist_t *c; 892 cmdlist_t *c;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index fe088045dd08..085b7794fb3e 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -251,7 +251,7 @@ static int irqdma_allocated;
251 251
252static struct request *current_req; 252static struct request *current_req;
253static struct request_queue *floppy_queue; 253static struct request_queue *floppy_queue;
254static void do_fd_request(request_queue_t * q); 254static void do_fd_request(struct request_queue * q);
255 255
256#ifndef fd_get_dma_residue 256#ifndef fd_get_dma_residue
257#define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA) 257#define fd_get_dma_residue() get_dma_residue(FLOPPY_DMA)
@@ -2981,7 +2981,7 @@ static void process_fd_request(void)
2981 schedule_bh(redo_fd_request); 2981 schedule_bh(redo_fd_request);
2982} 2982}
2983 2983
2984static void do_fd_request(request_queue_t * q) 2984static void do_fd_request(struct request_queue * q)
2985{ 2985{
2986 if (max_buffer_sectors == 0) { 2986 if (max_buffer_sectors == 0) {
2987 printk("VFS: do_fd_request called on non-open device\n"); 2987 printk("VFS: do_fd_request called on non-open device\n");
diff --git a/drivers/block/lguest_blk.c b/drivers/block/lguest_blk.c
index 1634c2dd25ec..93e3c4001bf5 100644
--- a/drivers/block/lguest_blk.c
+++ b/drivers/block/lguest_blk.c
@@ -1,6 +1,12 @@
1/* A simple block driver for lguest. 1/*D:400
2 * The Guest block driver
2 * 3 *
3 * Copyright 2006 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation 4 * This is a simple block driver, which appears as /dev/lgba, lgbb, lgbc etc.
5 * The mechanism is simple: we place the information about the request in the
6 * device page, then use SEND_DMA (containing the data for a write, or an empty
7 * "ping" DMA for a read).
8 :*/
9/* Copyright 2006 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
4 * 10 *
5 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
@@ -25,27 +31,50 @@
25 31
26static char next_block_index = 'a'; 32static char next_block_index = 'a';
27 33
34/*D:420 Here is the structure which holds all the information we need about
35 * each Guest block device.
36 *
37 * I'm sure at this stage, you're wondering "hey, where was the adventure I was
38 * promised?" and thinking "Rusty sucks, I shall say nasty things about him on
39 * my blog". I think Real adventures have boring bits, too, and you're in the
40 * middle of one. But it gets better. Just not quite yet. */
28struct blockdev 41struct blockdev
29{ 42{
43 /* The block queue infrastructure wants a spinlock: it is held while it
44 * calls our block request function. We grab it in our interrupt
45 * handler so the responses don't mess with new requests. */
30 spinlock_t lock; 46 spinlock_t lock;
31 47
32 /* The disk structure for the kernel. */ 48 /* The disk structure registered with kernel. */
33 struct gendisk *disk; 49 struct gendisk *disk;
34 50
35 /* The major number for this disk. */ 51 /* The major device number for this disk, and the interrupt. We only
52 * really keep them here for completeness; we'd need them if we
53 * supported device unplugging. */
36 int major; 54 int major;
37 int irq; 55 int irq;
38 56
57 /* The physical address of this device's memory page */
39 unsigned long phys_addr; 58 unsigned long phys_addr;
40 /* The mapped block page. */ 59 /* The mapped memory page for convenient acces. */
41 struct lguest_block_page *lb_page; 60 struct lguest_block_page *lb_page;
42 61
43 /* We only have a single request outstanding at a time. */ 62 /* We only have a single request outstanding at a time: this is it. */
44 struct lguest_dma dma; 63 struct lguest_dma dma;
45 struct request *req; 64 struct request *req;
46}; 65};
47 66
48/* Jens gave me this nice helper to end all chunks of a request. */ 67/*D:495 We originally used end_request() throughout the driver, but it turns
68 * out that end_request() is deprecated, and doesn't actually end the request
69 * (which seems like a good reason to deprecate it!). It simply ends the first
70 * bio. So if we had 3 bios in a "struct request" we would do all 3,
71 * end_request(), do 2, end_request(), do 1 and end_request(): twice as much
72 * work as we needed to do.
73 *
74 * This reinforced to me that I do not understand the block layer.
75 *
76 * Nonetheless, Jens Axboe gave me this nice helper to end all chunks of a
77 * request. This improved disk speed by 130%. */
49static void end_entire_request(struct request *req, int uptodate) 78static void end_entire_request(struct request *req, int uptodate)
50{ 79{
51 if (end_that_request_first(req, uptodate, req->hard_nr_sectors)) 80 if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
@@ -55,30 +84,62 @@ static void end_entire_request(struct request *req, int uptodate)
55 end_that_request_last(req, uptodate); 84 end_that_request_last(req, uptodate);
56} 85}
57 86
87/* I'm told there are only two stories in the world worth telling: love and
88 * hate. So there used to be a love scene here like this:
89 *
90 * Launcher: We could make beautiful I/O together, you and I.
91 * Guest: My, that's a big disk!
92 *
93 * Unfortunately, it was just too raunchy for our otherwise-gentle tale. */
94
95/*D:490 This is the interrupt handler, called when a block read or write has
96 * been completed for us. */
58static irqreturn_t lgb_irq(int irq, void *_bd) 97static irqreturn_t lgb_irq(int irq, void *_bd)
59{ 98{
99 /* We handed our "struct blockdev" as the argument to request_irq(), so
100 * it is passed through to us here. This tells us which device we're
101 * dealing with in case we have more than one. */
60 struct blockdev *bd = _bd; 102 struct blockdev *bd = _bd;
61 unsigned long flags; 103 unsigned long flags;
62 104
105 /* We weren't doing anything? Strange, but could happen if we shared
106 * interrupts (we don't!). */
63 if (!bd->req) { 107 if (!bd->req) {
64 pr_debug("No work!\n"); 108 pr_debug("No work!\n");
65 return IRQ_NONE; 109 return IRQ_NONE;
66 } 110 }
67 111
112 /* Not done yet? That's equally strange. */
68 if (!bd->lb_page->result) { 113 if (!bd->lb_page->result) {
69 pr_debug("No result!\n"); 114 pr_debug("No result!\n");
70 return IRQ_NONE; 115 return IRQ_NONE;
71 } 116 }
72 117
118 /* We have to grab the lock before ending the request. */
73 spin_lock_irqsave(&bd->lock, flags); 119 spin_lock_irqsave(&bd->lock, flags);
120 /* "result" is 1 for success, 2 for failure: end_entire_request() wants
121 * to know whether this succeeded or not. */
74 end_entire_request(bd->req, bd->lb_page->result == 1); 122 end_entire_request(bd->req, bd->lb_page->result == 1);
123 /* Clear out request, it's done. */
75 bd->req = NULL; 124 bd->req = NULL;
125 /* Reset incoming DMA for next time. */
76 bd->dma.used_len = 0; 126 bd->dma.used_len = 0;
127 /* Ready for more reads or writes */
77 blk_start_queue(bd->disk->queue); 128 blk_start_queue(bd->disk->queue);
78 spin_unlock_irqrestore(&bd->lock, flags); 129 spin_unlock_irqrestore(&bd->lock, flags);
130
131 /* The interrupt was for us, we dealt with it. */
79 return IRQ_HANDLED; 132 return IRQ_HANDLED;
80} 133}
81 134
135/*D:480 The block layer's "struct request" contains a number of "struct bio"s,
136 * each of which contains "struct bio_vec"s, each of which contains a page, an
137 * offset and a length.
138 *
139 * Fortunately there are iterators to help us walk through the "struct
140 * request". Even more fortunately, there were plenty of places to steal the
141 * code from. We pack the "struct request" into our "struct lguest_dma" and
142 * return the total length. */
82static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma) 143static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma)
83{ 144{
84 unsigned int i = 0, idx, len = 0; 145 unsigned int i = 0, idx, len = 0;
@@ -87,8 +148,13 @@ static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma)
87 rq_for_each_bio(bio, req) { 148 rq_for_each_bio(bio, req) {
88 struct bio_vec *bvec; 149 struct bio_vec *bvec;
89 bio_for_each_segment(bvec, bio, idx) { 150 bio_for_each_segment(bvec, bio, idx) {
151 /* We told the block layer not to give us too many. */
90 BUG_ON(i == LGUEST_MAX_DMA_SECTIONS); 152 BUG_ON(i == LGUEST_MAX_DMA_SECTIONS);
153 /* If we had a zero-length segment, it would look like
154 * the end of the data referred to by the "struct
155 * lguest_dma", so make sure that doesn't happen. */
91 BUG_ON(!bvec->bv_len); 156 BUG_ON(!bvec->bv_len);
157 /* Convert page & offset to a physical address */
92 dma->addr[i] = page_to_phys(bvec->bv_page) 158 dma->addr[i] = page_to_phys(bvec->bv_page)
93 + bvec->bv_offset; 159 + bvec->bv_offset;
94 dma->len[i] = bvec->bv_len; 160 dma->len[i] = bvec->bv_len;
@@ -96,26 +162,39 @@ static unsigned int req_to_dma(struct request *req, struct lguest_dma *dma)
96 i++; 162 i++;
97 } 163 }
98 } 164 }
165 /* If the array isn't full, we mark the end with a 0 length */
99 if (i < LGUEST_MAX_DMA_SECTIONS) 166 if (i < LGUEST_MAX_DMA_SECTIONS)
100 dma->len[i] = 0; 167 dma->len[i] = 0;
101 return len; 168 return len;
102} 169}
103 170
171/* This creates an empty DMA, useful for prodding the Host without sending data
172 * (ie. when we want to do a read) */
104static void empty_dma(struct lguest_dma *dma) 173static void empty_dma(struct lguest_dma *dma)
105{ 174{
106 dma->len[0] = 0; 175 dma->len[0] = 0;
107} 176}
108 177
178/*D:470 Setting up a request is fairly easy: */
109static void setup_req(struct blockdev *bd, 179static void setup_req(struct blockdev *bd,
110 int type, struct request *req, struct lguest_dma *dma) 180 int type, struct request *req, struct lguest_dma *dma)
111{ 181{
182 /* The type is 1 (write) or 0 (read). */
112 bd->lb_page->type = type; 183 bd->lb_page->type = type;
184 /* The sector on disk where the read or write starts. */
113 bd->lb_page->sector = req->sector; 185 bd->lb_page->sector = req->sector;
186 /* The result is initialized to 0 (unfinished). */
114 bd->lb_page->result = 0; 187 bd->lb_page->result = 0;
188 /* The current request (so we can end it in the interrupt handler). */
115 bd->req = req; 189 bd->req = req;
190 /* The number of bytes: returned as a side-effect of req_to_dma(),
191 * which packs the block layer's "struct request" into our "struct
192 * lguest_dma" */
116 bd->lb_page->bytes = req_to_dma(req, dma); 193 bd->lb_page->bytes = req_to_dma(req, dma);
117} 194}
118 195
196/*D:450 Write is pretty straightforward: we pack the request into a "struct
197 * lguest_dma", then use SEND_DMA to send the request. */
119static void do_write(struct blockdev *bd, struct request *req) 198static void do_write(struct blockdev *bd, struct request *req)
120{ 199{
121 struct lguest_dma send; 200 struct lguest_dma send;
@@ -126,6 +205,9 @@ static void do_write(struct blockdev *bd, struct request *req)
126 lguest_send_dma(bd->phys_addr, &send); 205 lguest_send_dma(bd->phys_addr, &send);
127} 206}
128 207
208/* Read is similar to write, except we pack the request into our receive
209 * "struct lguest_dma" and send through an empty DMA just to tell the Host that
210 * there's a request pending. */
129static void do_read(struct blockdev *bd, struct request *req) 211static void do_read(struct blockdev *bd, struct request *req)
130{ 212{
131 struct lguest_dma ping; 213 struct lguest_dma ping;
@@ -137,21 +219,30 @@ static void do_read(struct blockdev *bd, struct request *req)
137 lguest_send_dma(bd->phys_addr, &ping); 219 lguest_send_dma(bd->phys_addr, &ping);
138} 220}
139 221
140static void do_lgb_request(request_queue_t *q) 222/*D:440 This where requests come in: we get handed the request queue and are
223 * expected to pull a "struct request" off it until we've finished them or
224 * we're waiting for a reply: */
225static void do_lgb_request(struct request_queue *q)
141{ 226{
142 struct blockdev *bd; 227 struct blockdev *bd;
143 struct request *req; 228 struct request *req;
144 229
145again: 230again:
231 /* This sometimes returns NULL even on the very first time around. I
232 * wonder if it's something to do with letting elves handle the request
233 * queue... */
146 req = elv_next_request(q); 234 req = elv_next_request(q);
147 if (!req) 235 if (!req)
148 return; 236 return;
149 237
238 /* We attached the struct blockdev to the disk: get it back */
150 bd = req->rq_disk->private_data; 239 bd = req->rq_disk->private_data;
151 /* Sometimes we get repeated requests after blk_stop_queue. */ 240 /* Sometimes we get repeated requests after blk_stop_queue(), but we
241 * can only handle one at a time. */
152 if (bd->req) 242 if (bd->req)
153 return; 243 return;
154 244
245 /* We only do reads and writes: no tricky business! */
155 if (!blk_fs_request(req)) { 246 if (!blk_fs_request(req)) {
156 pr_debug("Got non-command 0x%08x\n", req->cmd_type); 247 pr_debug("Got non-command 0x%08x\n", req->cmd_type);
157 req->errors++; 248 req->errors++;
@@ -164,20 +255,31 @@ again:
164 else 255 else
165 do_read(bd, req); 256 do_read(bd, req);
166 257
167 /* Wait for interrupt to tell us it's done. */ 258 /* We've put out the request, so stop any more coming in until we get
259 * an interrupt, which takes us to lgb_irq() to re-enable the queue. */
168 blk_stop_queue(q); 260 blk_stop_queue(q);
169} 261}
170 262
263/*D:430 This is the "struct block_device_operations" we attach to the disk at
264 * the end of lguestblk_probe(). It doesn't seem to want much. */
171static struct block_device_operations lguestblk_fops = { 265static struct block_device_operations lguestblk_fops = {
172 .owner = THIS_MODULE, 266 .owner = THIS_MODULE,
173}; 267};
174 268
269/*D:425 Setting up a disk device seems to involve a lot of code. I'm not sure
270 * quite why. I do know that the IDE code sent two or three of the maintainers
271 * insane, perhaps this is the fringe of the same disease?
272 *
273 * As in the console code, the probe function gets handed the generic
274 * lguest_device from lguest_bus.c: */
175static int lguestblk_probe(struct lguest_device *lgdev) 275static int lguestblk_probe(struct lguest_device *lgdev)
176{ 276{
177 struct blockdev *bd; 277 struct blockdev *bd;
178 int err; 278 int err;
179 int irqflags = IRQF_SHARED; 279 int irqflags = IRQF_SHARED;
180 280
281 /* First we allocate our own "struct blockdev" and initialize the easy
282 * fields. */
181 bd = kmalloc(sizeof(*bd), GFP_KERNEL); 283 bd = kmalloc(sizeof(*bd), GFP_KERNEL);
182 if (!bd) 284 if (!bd)
183 return -ENOMEM; 285 return -ENOMEM;
@@ -187,59 +289,100 @@ static int lguestblk_probe(struct lguest_device *lgdev)
187 bd->req = NULL; 289 bd->req = NULL;
188 bd->dma.used_len = 0; 290 bd->dma.used_len = 0;
189 bd->dma.len[0] = 0; 291 bd->dma.len[0] = 0;
292 /* The descriptor in the lguest_devices array provided by the Host
293 * gives the Guest the physical page number of the device's page. */
190 bd->phys_addr = (lguest_devices[lgdev->index].pfn << PAGE_SHIFT); 294 bd->phys_addr = (lguest_devices[lgdev->index].pfn << PAGE_SHIFT);
191 295
296 /* We use lguest_map() to get a pointer to the device page */
192 bd->lb_page = lguest_map(bd->phys_addr, 1); 297 bd->lb_page = lguest_map(bd->phys_addr, 1);
193 if (!bd->lb_page) { 298 if (!bd->lb_page) {
194 err = -ENOMEM; 299 err = -ENOMEM;
195 goto out_free_bd; 300 goto out_free_bd;
196 } 301 }
197 302
303 /* We need a major device number: 0 means "assign one dynamically". */
198 bd->major = register_blkdev(0, "lguestblk"); 304 bd->major = register_blkdev(0, "lguestblk");
199 if (bd->major < 0) { 305 if (bd->major < 0) {
200 err = bd->major; 306 err = bd->major;
201 goto out_unmap; 307 goto out_unmap;
202 } 308 }
203 309
310 /* This allocates a "struct gendisk" where we pack all the information
311 * about the disk which the rest of Linux sees. We ask for one minor
312 * number; I do wonder if we should be asking for more. */
204 bd->disk = alloc_disk(1); 313 bd->disk = alloc_disk(1);
205 if (!bd->disk) { 314 if (!bd->disk) {
206 err = -ENOMEM; 315 err = -ENOMEM;
207 goto out_unregister_blkdev; 316 goto out_unregister_blkdev;
208 } 317 }
209 318
319 /* Every disk needs a queue for requests to come in: we set up the
320 * queue with a callback function (the core of our driver) and the lock
321 * to use. */
210 bd->disk->queue = blk_init_queue(do_lgb_request, &bd->lock); 322 bd->disk->queue = blk_init_queue(do_lgb_request, &bd->lock);
211 if (!bd->disk->queue) { 323 if (!bd->disk->queue) {
212 err = -ENOMEM; 324 err = -ENOMEM;
213 goto out_put_disk; 325 goto out_put_disk;
214 } 326 }
215 327
216 /* We can only handle a certain number of sg entries */ 328 /* We can only handle a certain number of pointers in our SEND_DMA
329 * call, so we set that with blk_queue_max_hw_segments(). This is not
330 * to be confused with blk_queue_max_phys_segments() of course! I
331 * know, who could possibly confuse the two?
332 *
333 * Well, it's simple to tell them apart: this one seems to work and the
334 * other one didn't. */
217 blk_queue_max_hw_segments(bd->disk->queue, LGUEST_MAX_DMA_SECTIONS); 335 blk_queue_max_hw_segments(bd->disk->queue, LGUEST_MAX_DMA_SECTIONS);
218 /* Buffers must not cross page boundaries */ 336
337 /* Due to technical limitations of our Host (and simple coding) we
338 * can't have a single buffer which crosses a page boundary. Tell it
339 * here. This means that our maximum request size is 16
340 * (LGUEST_MAX_DMA_SECTIONS) pages. */
219 blk_queue_segment_boundary(bd->disk->queue, PAGE_SIZE-1); 341 blk_queue_segment_boundary(bd->disk->queue, PAGE_SIZE-1);
220 342
343 /* We name our disk: this becomes the device name when udev does its
344 * magic thing and creates the device node, such as /dev/lgba.
345 * next_block_index is a global which starts at 'a'. Unfortunately
346 * this simple increment logic means that the 27th disk will be called
347 * "/dev/lgb{". In that case, I recommend having at least 29 disks, so
348 * your /dev directory will be balanced. */
221 sprintf(bd->disk->disk_name, "lgb%c", next_block_index++); 349 sprintf(bd->disk->disk_name, "lgb%c", next_block_index++);
350
351 /* We look to the device descriptor again to see if this device's
352 * interrupts are expected to be random. If they are, we tell the irq
353 * subsystem. At the moment this bit is always set. */
222 if (lguest_devices[lgdev->index].features & LGUEST_DEVICE_F_RANDOMNESS) 354 if (lguest_devices[lgdev->index].features & LGUEST_DEVICE_F_RANDOMNESS)
223 irqflags |= IRQF_SAMPLE_RANDOM; 355 irqflags |= IRQF_SAMPLE_RANDOM;
356
357 /* Now we have the name and irqflags, we can request the interrupt; we
358 * give it the "struct blockdev" we have set up to pass to lgb_irq()
359 * when there is an interrupt. */
224 err = request_irq(bd->irq, lgb_irq, irqflags, bd->disk->disk_name, bd); 360 err = request_irq(bd->irq, lgb_irq, irqflags, bd->disk->disk_name, bd);
225 if (err) 361 if (err)
226 goto out_cleanup_queue; 362 goto out_cleanup_queue;
227 363
364 /* We bind our one-entry DMA pool to the key for this block device so
365 * the Host can reply to our requests. The key is equal to the
366 * physical address of the device's page, which is conveniently
367 * unique. */
228 err = lguest_bind_dma(bd->phys_addr, &bd->dma, 1, bd->irq); 368 err = lguest_bind_dma(bd->phys_addr, &bd->dma, 1, bd->irq);
229 if (err) 369 if (err)
230 goto out_free_irq; 370 goto out_free_irq;
231 371
372 /* We finish our disk initialization and add the disk to the system. */
232 bd->disk->major = bd->major; 373 bd->disk->major = bd->major;
233 bd->disk->first_minor = 0; 374 bd->disk->first_minor = 0;
234 bd->disk->private_data = bd; 375 bd->disk->private_data = bd;
235 bd->disk->fops = &lguestblk_fops; 376 bd->disk->fops = &lguestblk_fops;
236 /* This is initialized to the disk size by the other end. */ 377 /* This is initialized to the disk size by the Launcher. */
237 set_capacity(bd->disk, bd->lb_page->num_sectors); 378 set_capacity(bd->disk, bd->lb_page->num_sectors);
238 add_disk(bd->disk); 379 add_disk(bd->disk);
239 380
240 printk(KERN_INFO "%s: device %i at major %d\n", 381 printk(KERN_INFO "%s: device %i at major %d\n",
241 bd->disk->disk_name, lgdev->index, bd->major); 382 bd->disk->disk_name, lgdev->index, bd->major);
242 383
384 /* We don't need to keep the "struct blockdev" around, but if we ever
385 * implemented device removal, we'd need this. */
243 lgdev->private = bd; 386 lgdev->private = bd;
244 return 0; 387 return 0;
245 388
@@ -258,6 +401,8 @@ out_free_bd:
258 return err; 401 return err;
259} 402}
260 403
404/*D:410 The boilerplate code for registering the lguest block driver is just
405 * like the console: */
261static struct lguest_driver lguestblk_drv = { 406static struct lguest_driver lguestblk_drv = {
262 .name = "lguestblk", 407 .name = "lguestblk",
263 .owner = THIS_MODULE, 408 .owner = THIS_MODULE,
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index e425daa1eac3..9f015fce4135 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -529,7 +529,7 @@ static struct bio *loop_get_bio(struct loop_device *lo)
529 return bio; 529 return bio;
530} 530}
531 531
532static int loop_make_request(request_queue_t *q, struct bio *old_bio) 532static int loop_make_request(struct request_queue *q, struct bio *old_bio)
533{ 533{
534 struct loop_device *lo = q->queuedata; 534 struct loop_device *lo = q->queuedata;
535 int rw = bio_rw(old_bio); 535 int rw = bio_rw(old_bio);
@@ -558,7 +558,7 @@ out:
558/* 558/*
559 * kick off io on the underlying address space 559 * kick off io on the underlying address space
560 */ 560 */
561static void loop_unplug(request_queue_t *q) 561static void loop_unplug(struct request_queue *q)
562{ 562{
563 struct loop_device *lo = q->queuedata; 563 struct loop_device *lo = q->queuedata;
564 564
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index c12951024090..be92c658f06e 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -100,7 +100,7 @@ static const char *nbdcmd_to_ascii(int cmd)
100static void nbd_end_request(struct request *req) 100static void nbd_end_request(struct request *req)
101{ 101{
102 int uptodate = (req->errors == 0) ? 1 : 0; 102 int uptodate = (req->errors == 0) ? 1 : 0;
103 request_queue_t *q = req->q; 103 struct request_queue *q = req->q;
104 unsigned long flags; 104 unsigned long flags;
105 105
106 dprintk(DBG_BLKDEV, "%s: request %p: %s\n", req->rq_disk->disk_name, 106 dprintk(DBG_BLKDEV, "%s: request %p: %s\n", req->rq_disk->disk_name,
@@ -410,7 +410,7 @@ static void nbd_clear_que(struct nbd_device *lo)
410 * { printk( "Warning: Ignoring result!\n"); nbd_end_request( req ); } 410 * { printk( "Warning: Ignoring result!\n"); nbd_end_request( req ); }
411 */ 411 */
412 412
413static void do_nbd_request(request_queue_t * q) 413static void do_nbd_request(struct request_queue * q)
414{ 414{
415 struct request *req; 415 struct request *req;
416 416
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index 1eeb8f2cde71..b8a994a2b013 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -183,7 +183,7 @@ static int pcd_packet(struct cdrom_device_info *cdi,
183static int pcd_detect(void); 183static int pcd_detect(void);
184static void pcd_probe_capabilities(void); 184static void pcd_probe_capabilities(void);
185static void do_pcd_read_drq(void); 185static void do_pcd_read_drq(void);
186static void do_pcd_request(request_queue_t * q); 186static void do_pcd_request(struct request_queue * q);
187static void do_pcd_read(void); 187static void do_pcd_read(void);
188 188
189struct pcd_unit { 189struct pcd_unit {
@@ -713,7 +713,7 @@ static int pcd_detect(void)
713/* I/O request processing */ 713/* I/O request processing */
714static struct request_queue *pcd_queue; 714static struct request_queue *pcd_queue;
715 715
716static void do_pcd_request(request_queue_t * q) 716static void do_pcd_request(struct request_queue * q)
717{ 717{
718 if (pcd_busy) 718 if (pcd_busy)
719 return; 719 return;
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 31e01488eb51..df819f8a95a6 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -698,7 +698,7 @@ static enum action pd_identify(struct pd_unit *disk)
698 698
699/* end of io request engine */ 699/* end of io request engine */
700 700
701static void do_pd_request(request_queue_t * q) 701static void do_pd_request(struct request_queue * q)
702{ 702{
703 if (pd_req) 703 if (pd_req)
704 return; 704 return;
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 5826508f6731..ceffa6034e20 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -202,7 +202,7 @@ module_param_array(drive3, int, NULL, 0);
202#define ATAPI_WRITE_10 0x2a 202#define ATAPI_WRITE_10 0x2a
203 203
204static int pf_open(struct inode *inode, struct file *file); 204static int pf_open(struct inode *inode, struct file *file);
205static void do_pf_request(request_queue_t * q); 205static void do_pf_request(struct request_queue * q);
206static int pf_ioctl(struct inode *inode, struct file *file, 206static int pf_ioctl(struct inode *inode, struct file *file,
207 unsigned int cmd, unsigned long arg); 207 unsigned int cmd, unsigned long arg);
208static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo); 208static int pf_getgeo(struct block_device *bdev, struct hd_geometry *geo);
@@ -760,7 +760,7 @@ static void pf_end_request(int uptodate)
760 } 760 }
761} 761}
762 762
763static void do_pf_request(request_queue_t * q) 763static void do_pf_request(struct request_queue * q)
764{ 764{
765 if (pf_busy) 765 if (pf_busy)
766 return; 766 return;
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 31be33e4f119..fadbfd880bab 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -752,7 +752,7 @@ static inline struct bio *pkt_get_list_first(struct bio **list_head, struct bio
752 */ 752 */
753static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *cgc) 753static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *cgc)
754{ 754{
755 request_queue_t *q = bdev_get_queue(pd->bdev); 755 struct request_queue *q = bdev_get_queue(pd->bdev);
756 struct request *rq; 756 struct request *rq;
757 int ret = 0; 757 int ret = 0;
758 758
@@ -979,7 +979,7 @@ static void pkt_iosched_process_queue(struct pktcdvd_device *pd)
979 * Special care is needed if the underlying block device has a small 979 * Special care is needed if the underlying block device has a small
980 * max_phys_segments value. 980 * max_phys_segments value.
981 */ 981 */
982static int pkt_set_segment_merging(struct pktcdvd_device *pd, request_queue_t *q) 982static int pkt_set_segment_merging(struct pktcdvd_device *pd, struct request_queue *q)
983{ 983{
984 if ((pd->settings.size << 9) / CD_FRAMESIZE <= q->max_phys_segments) { 984 if ((pd->settings.size << 9) / CD_FRAMESIZE <= q->max_phys_segments) {
985 /* 985 /*
@@ -2314,7 +2314,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, int write)
2314{ 2314{
2315 int ret; 2315 int ret;
2316 long lba; 2316 long lba;
2317 request_queue_t *q; 2317 struct request_queue *q;
2318 2318
2319 /* 2319 /*
2320 * We need to re-open the cdrom device without O_NONBLOCK to be able 2320 * We need to re-open the cdrom device without O_NONBLOCK to be able
@@ -2477,7 +2477,7 @@ static int pkt_end_io_read_cloned(struct bio *bio, unsigned int bytes_done, int
2477 return 0; 2477 return 0;
2478} 2478}
2479 2479
2480static int pkt_make_request(request_queue_t *q, struct bio *bio) 2480static int pkt_make_request(struct request_queue *q, struct bio *bio)
2481{ 2481{
2482 struct pktcdvd_device *pd; 2482 struct pktcdvd_device *pd;
2483 char b[BDEVNAME_SIZE]; 2483 char b[BDEVNAME_SIZE];
@@ -2626,7 +2626,7 @@ end_io:
2626 2626
2627 2627
2628 2628
2629static int pkt_merge_bvec(request_queue_t *q, struct bio *bio, struct bio_vec *bvec) 2629static int pkt_merge_bvec(struct request_queue *q, struct bio *bio, struct bio_vec *bvec)
2630{ 2630{
2631 struct pktcdvd_device *pd = q->queuedata; 2631 struct pktcdvd_device *pd = q->queuedata;
2632 sector_t zone = ZONE(bio->bi_sector, pd); 2632 sector_t zone = ZONE(bio->bi_sector, pd);
@@ -2647,7 +2647,7 @@ static int pkt_merge_bvec(request_queue_t *q, struct bio *bio, struct bio_vec *b
2647 2647
2648static void pkt_init_queue(struct pktcdvd_device *pd) 2648static void pkt_init_queue(struct pktcdvd_device *pd)
2649{ 2649{
2650 request_queue_t *q = pd->disk->queue; 2650 struct request_queue *q = pd->disk->queue;
2651 2651
2652 blk_queue_make_request(q, pkt_make_request); 2652 blk_queue_make_request(q, pkt_make_request);
2653 blk_queue_hardsect_size(q, CD_FRAMESIZE); 2653 blk_queue_hardsect_size(q, CD_FRAMESIZE);
diff --git a/drivers/block/ps2esdi.c b/drivers/block/ps2esdi.c
index 688a4fb0dc99..3c796e236253 100644
--- a/drivers/block/ps2esdi.c
+++ b/drivers/block/ps2esdi.c
@@ -64,7 +64,7 @@ static void reset_ctrl(void);
64 64
65static int ps2esdi_geninit(void); 65static int ps2esdi_geninit(void);
66 66
67static void do_ps2esdi_request(request_queue_t * q); 67static void do_ps2esdi_request(struct request_queue * q);
68 68
69static void ps2esdi_readwrite(int cmd, struct request *req); 69static void ps2esdi_readwrite(int cmd, struct request *req);
70 70
@@ -473,7 +473,7 @@ static void __init ps2esdi_get_device_cfg(void)
473} 473}
474 474
475/* strategy routine that handles most of the IO requests */ 475/* strategy routine that handles most of the IO requests */
476static void do_ps2esdi_request(request_queue_t * q) 476static void do_ps2esdi_request(struct request_queue * q)
477{ 477{
478 struct request *req; 478 struct request *req;
479 /* since, this routine is called with interrupts cleared - they 479 /* since, this routine is called with interrupts cleared - they
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index 170fb33dba97..aa8b890c80d7 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -190,7 +190,7 @@ static int ps3disk_submit_flush_request(struct ps3_storage_device *dev,
190} 190}
191 191
192static void ps3disk_do_request(struct ps3_storage_device *dev, 192static void ps3disk_do_request(struct ps3_storage_device *dev,
193 request_queue_t *q) 193 struct request_queue *q)
194{ 194{
195 struct request *req; 195 struct request *req;
196 196
@@ -211,7 +211,7 @@ static void ps3disk_do_request(struct ps3_storage_device *dev,
211 } 211 }
212} 212}
213 213
214static void ps3disk_request(request_queue_t *q) 214static void ps3disk_request(struct request_queue *q)
215{ 215{
216 struct ps3_storage_device *dev = q->queuedata; 216 struct ps3_storage_device *dev = q->queuedata;
217 struct ps3disk_private *priv = dev->sbd.core.driver_data; 217 struct ps3disk_private *priv = dev->sbd.core.driver_data;
@@ -404,7 +404,7 @@ static int ps3disk_identify(struct ps3_storage_device *dev)
404 return 0; 404 return 0;
405} 405}
406 406
407static void ps3disk_prepare_flush(request_queue_t *q, struct request *req) 407static void ps3disk_prepare_flush(struct request_queue *q, struct request *req)
408{ 408{
409 struct ps3_storage_device *dev = q->queuedata; 409 struct ps3_storage_device *dev = q->queuedata;
410 410
@@ -414,7 +414,7 @@ static void ps3disk_prepare_flush(request_queue_t *q, struct request *req)
414 req->cmd_type = REQ_TYPE_FLUSH; 414 req->cmd_type = REQ_TYPE_FLUSH;
415} 415}
416 416
417static int ps3disk_issue_flush(request_queue_t *q, struct gendisk *gendisk, 417static int ps3disk_issue_flush(struct request_queue *q, struct gendisk *gendisk,
418 sector_t *sector) 418 sector_t *sector)
419{ 419{
420 struct ps3_storage_device *dev = q->queuedata; 420 struct ps3_storage_device *dev = q->queuedata;
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index a1512da32410..65150b548f3a 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -264,7 +264,7 @@ static int rd_blkdev_pagecache_IO(int rw, struct bio_vec *vec, sector_t sector,
264 * 19-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Added devfs support 264 * 19-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Added devfs support
265 * 265 *
266 */ 266 */
267static int rd_make_request(request_queue_t *q, struct bio *bio) 267static int rd_make_request(struct request_queue *q, struct bio *bio)
268{ 268{
269 struct block_device *bdev = bio->bi_bdev; 269 struct block_device *bdev = bio->bi_bdev;
270 struct address_space * mapping = bdev->bd_inode->i_mapping; 270 struct address_space * mapping = bdev->bd_inode->i_mapping;
diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index d50b82381155..4dff49256ac2 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -444,7 +444,7 @@ out:
444 return err; 444 return err;
445} 445}
446 446
447static void do_vdc_request(request_queue_t *q) 447static void do_vdc_request(struct request_queue *q)
448{ 448{
449 while (1) { 449 while (1) {
450 struct request *req = elv_next_request(q); 450 struct request *req = elv_next_request(q);
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index 1a65979f1f0f..b4e462f154ea 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -225,7 +225,7 @@ static unsigned short write_postamble[] = {
225static void swim3_select(struct floppy_state *fs, int sel); 225static void swim3_select(struct floppy_state *fs, int sel);
226static void swim3_action(struct floppy_state *fs, int action); 226static void swim3_action(struct floppy_state *fs, int action);
227static int swim3_readbit(struct floppy_state *fs, int bit); 227static int swim3_readbit(struct floppy_state *fs, int bit);
228static void do_fd_request(request_queue_t * q); 228static void do_fd_request(struct request_queue * q);
229static void start_request(struct floppy_state *fs); 229static void start_request(struct floppy_state *fs);
230static void set_timeout(struct floppy_state *fs, int nticks, 230static void set_timeout(struct floppy_state *fs, int nticks,
231 void (*proc)(unsigned long)); 231 void (*proc)(unsigned long));
@@ -290,7 +290,7 @@ static int swim3_readbit(struct floppy_state *fs, int bit)
290 return (stat & DATA) == 0; 290 return (stat & DATA) == 0;
291} 291}
292 292
293static void do_fd_request(request_queue_t * q) 293static void do_fd_request(struct request_queue * q)
294{ 294{
295 int i; 295 int i;
296 for(i=0;i<floppy_count;i++) 296 for(i=0;i<floppy_count;i++)
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 949ae93499e5..402209fec59a 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -278,7 +278,7 @@ struct carm_host {
278 unsigned int state; 278 unsigned int state;
279 u32 fw_ver; 279 u32 fw_ver;
280 280
281 request_queue_t *oob_q; 281 struct request_queue *oob_q;
282 unsigned int n_oob; 282 unsigned int n_oob;
283 283
284 unsigned int hw_sg_used; 284 unsigned int hw_sg_used;
@@ -287,7 +287,7 @@ struct carm_host {
287 287
288 unsigned int wait_q_prod; 288 unsigned int wait_q_prod;
289 unsigned int wait_q_cons; 289 unsigned int wait_q_cons;
290 request_queue_t *wait_q[CARM_MAX_WAIT_Q]; 290 struct request_queue *wait_q[CARM_MAX_WAIT_Q];
291 291
292 unsigned int n_msgs; 292 unsigned int n_msgs;
293 u64 msg_alloc; 293 u64 msg_alloc;
@@ -756,7 +756,7 @@ static inline void carm_end_request_queued(struct carm_host *host,
756 assert(rc == 0); 756 assert(rc == 0);
757} 757}
758 758
759static inline void carm_push_q (struct carm_host *host, request_queue_t *q) 759static inline void carm_push_q (struct carm_host *host, struct request_queue *q)
760{ 760{
761 unsigned int idx = host->wait_q_prod % CARM_MAX_WAIT_Q; 761 unsigned int idx = host->wait_q_prod % CARM_MAX_WAIT_Q;
762 762
@@ -768,7 +768,7 @@ static inline void carm_push_q (struct carm_host *host, request_queue_t *q)
768 BUG_ON(host->wait_q_prod == host->wait_q_cons); /* overrun */ 768 BUG_ON(host->wait_q_prod == host->wait_q_cons); /* overrun */
769} 769}
770 770
771static inline request_queue_t *carm_pop_q(struct carm_host *host) 771static inline struct request_queue *carm_pop_q(struct carm_host *host)
772{ 772{
773 unsigned int idx; 773 unsigned int idx;
774 774
@@ -783,7 +783,7 @@ static inline request_queue_t *carm_pop_q(struct carm_host *host)
783 783
784static inline void carm_round_robin(struct carm_host *host) 784static inline void carm_round_robin(struct carm_host *host)
785{ 785{
786 request_queue_t *q = carm_pop_q(host); 786 struct request_queue *q = carm_pop_q(host);
787 if (q) { 787 if (q) {
788 blk_start_queue(q); 788 blk_start_queue(q);
789 VPRINTK("STARTED QUEUE %p\n", q); 789 VPRINTK("STARTED QUEUE %p\n", q);
@@ -802,7 +802,7 @@ static inline void carm_end_rq(struct carm_host *host, struct carm_request *crq,
802 } 802 }
803} 803}
804 804
805static void carm_oob_rq_fn(request_queue_t *q) 805static void carm_oob_rq_fn(struct request_queue *q)
806{ 806{
807 struct carm_host *host = q->queuedata; 807 struct carm_host *host = q->queuedata;
808 struct carm_request *crq; 808 struct carm_request *crq;
@@ -833,7 +833,7 @@ static void carm_oob_rq_fn(request_queue_t *q)
833 } 833 }
834} 834}
835 835
836static void carm_rq_fn(request_queue_t *q) 836static void carm_rq_fn(struct request_queue *q)
837{ 837{
838 struct carm_port *port = q->queuedata; 838 struct carm_port *port = q->queuedata;
839 struct carm_host *host = port->host; 839 struct carm_host *host = port->host;
@@ -1494,7 +1494,7 @@ static int carm_init_disks(struct carm_host *host)
1494 1494
1495 for (i = 0; i < CARM_MAX_PORTS; i++) { 1495 for (i = 0; i < CARM_MAX_PORTS; i++) {
1496 struct gendisk *disk; 1496 struct gendisk *disk;
1497 request_queue_t *q; 1497 struct request_queue *q;
1498 struct carm_port *port; 1498 struct carm_port *port;
1499 1499
1500 port = &host->port[i]; 1500 port = &host->port[i];
@@ -1538,7 +1538,7 @@ static void carm_free_disks(struct carm_host *host)
1538 for (i = 0; i < CARM_MAX_PORTS; i++) { 1538 for (i = 0; i < CARM_MAX_PORTS; i++) {
1539 struct gendisk *disk = host->port[i].disk; 1539 struct gendisk *disk = host->port[i].disk;
1540 if (disk) { 1540 if (disk) {
1541 request_queue_t *q = disk->queue; 1541 struct request_queue *q = disk->queue;
1542 1542
1543 if (disk->flags & GENHD_FL_UP) 1543 if (disk->flags & GENHD_FL_UP)
1544 del_gendisk(disk); 1544 del_gendisk(disk);
@@ -1571,7 +1571,7 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1571 struct carm_host *host; 1571 struct carm_host *host;
1572 unsigned int pci_dac; 1572 unsigned int pci_dac;
1573 int rc; 1573 int rc;
1574 request_queue_t *q; 1574 struct request_queue *q;
1575 unsigned int i; 1575 unsigned int i;
1576 1576
1577 if (!printed_version++) 1577 if (!printed_version++)
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 8b13d7d2cb63..c57dd2b3a0c8 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -503,7 +503,7 @@ static void ub_cleanup(struct ub_dev *sc)
503{ 503{
504 struct list_head *p; 504 struct list_head *p;
505 struct ub_lun *lun; 505 struct ub_lun *lun;
506 request_queue_t *q; 506 struct request_queue *q;
507 507
508 while (!list_empty(&sc->luns)) { 508 while (!list_empty(&sc->luns)) {
509 p = sc->luns.next; 509 p = sc->luns.next;
@@ -619,7 +619,7 @@ static struct ub_scsi_cmd *ub_cmdq_pop(struct ub_dev *sc)
619 * The request function is our main entry point 619 * The request function is our main entry point
620 */ 620 */
621 621
622static void ub_request_fn(request_queue_t *q) 622static void ub_request_fn(struct request_queue *q)
623{ 623{
624 struct ub_lun *lun = q->queuedata; 624 struct ub_lun *lun = q->queuedata;
625 struct request *rq; 625 struct request *rq;
@@ -2273,7 +2273,7 @@ err_core:
2273static int ub_probe_lun(struct ub_dev *sc, int lnum) 2273static int ub_probe_lun(struct ub_dev *sc, int lnum)
2274{ 2274{
2275 struct ub_lun *lun; 2275 struct ub_lun *lun;
2276 request_queue_t *q; 2276 struct request_queue *q;
2277 struct gendisk *disk; 2277 struct gendisk *disk;
2278 int rc; 2278 int rc;
2279 2279
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index dec74bd23496..6b7c02d6360d 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -114,7 +114,7 @@ struct cardinfo {
114 */ 114 */
115 struct bio *bio, *currentbio, **biotail; 115 struct bio *bio, *currentbio, **biotail;
116 116
117 request_queue_t *queue; 117 struct request_queue *queue;
118 118
119 struct mm_page { 119 struct mm_page {
120 dma_addr_t page_dma; 120 dma_addr_t page_dma;
@@ -357,7 +357,7 @@ static inline void reset_page(struct mm_page *page)
357 page->biotail = & page->bio; 357 page->biotail = & page->bio;
358} 358}
359 359
360static void mm_unplug_device(request_queue_t *q) 360static void mm_unplug_device(struct request_queue *q)
361{ 361{
362 struct cardinfo *card = q->queuedata; 362 struct cardinfo *card = q->queuedata;
363 unsigned long flags; 363 unsigned long flags;
@@ -541,7 +541,7 @@ static void process_page(unsigned long data)
541-- mm_make_request 541-- mm_make_request
542----------------------------------------------------------------------------------- 542-----------------------------------------------------------------------------------
543*/ 543*/
544static int mm_make_request(request_queue_t *q, struct bio *bio) 544static int mm_make_request(struct request_queue *q, struct bio *bio)
545{ 545{
546 struct cardinfo *card = q->queuedata; 546 struct cardinfo *card = q->queuedata;
547 pr_debug("mm_make_request %llu %u\n", 547 pr_debug("mm_make_request %llu %u\n",
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index dae39911a11d..85916e2665d4 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -400,7 +400,7 @@ error_ret:
400/* 400/*
401 * This is the external request processing routine 401 * This is the external request processing routine
402 */ 402 */
403static void do_viodasd_request(request_queue_t *q) 403static void do_viodasd_request(struct request_queue *q)
404{ 404{
405 struct request *req; 405 struct request *req;
406 406
diff --git a/drivers/block/xd.c b/drivers/block/xd.c
index 0d97b7eb818a..624d30f7da3f 100644
--- a/drivers/block/xd.c
+++ b/drivers/block/xd.c
@@ -298,7 +298,7 @@ static u_char __init xd_detect (u_char *controller, unsigned int *address)
298} 298}
299 299
300/* do_xd_request: handle an incoming request */ 300/* do_xd_request: handle an incoming request */
301static void do_xd_request (request_queue_t * q) 301static void do_xd_request (struct request_queue * q)
302{ 302{
303 struct request *req; 303 struct request *req;
304 304
diff --git a/drivers/block/xd.h b/drivers/block/xd.h
index 82e090fea957..cffd44a20383 100644
--- a/drivers/block/xd.h
+++ b/drivers/block/xd.h
@@ -104,7 +104,7 @@ static int xd_manual_geo_init (char *command);
104static u_char xd_detect (u_char *controller, unsigned int *address); 104static u_char xd_detect (u_char *controller, unsigned int *address);
105static u_char xd_initdrives (void (*init_drive)(u_char drive)); 105static u_char xd_initdrives (void (*init_drive)(u_char drive));
106 106
107static void do_xd_request (request_queue_t * q); 107static void do_xd_request (struct request_queue * q);
108static int xd_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg); 108static int xd_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg);
109static int xd_readwrite (u_char operation,XD_INFO *disk,char *buffer,u_int block,u_int count); 109static int xd_readwrite (u_char operation,XD_INFO *disk,char *buffer,u_int block,u_int count);
110static void xd_recalibrate (u_char drive); 110static void xd_recalibrate (u_char drive);
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 6746c29181f8..964e51634f2d 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -241,7 +241,7 @@ static inline void flush_requests(struct blkfront_info *info)
241 * do_blkif_request 241 * do_blkif_request
242 * read a block; request is in a request queue 242 * read a block; request is in a request queue
243 */ 243 */
244static void do_blkif_request(request_queue_t *rq) 244static void do_blkif_request(struct request_queue *rq)
245{ 245{
246 struct blkfront_info *info = NULL; 246 struct blkfront_info *info = NULL;
247 struct request *req; 247 struct request *req;
@@ -287,7 +287,7 @@ wait:
287 287
288static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size) 288static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
289{ 289{
290 request_queue_t *rq; 290 struct request_queue *rq;
291 291
292 rq = blk_init_queue(do_blkif_request, &blkif_io_lock); 292 rq = blk_init_queue(do_blkif_request, &blkif_io_lock);
293 if (rq == NULL) 293 if (rq == NULL)
diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 732ec63b6e9c..cb27e8863d7c 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -458,7 +458,7 @@ static inline void ace_fsm_yieldirq(struct ace_device *ace)
458} 458}
459 459
460/* Get the next read/write request; ending requests that we don't handle */ 460/* Get the next read/write request; ending requests that we don't handle */
461struct request *ace_get_next_request(request_queue_t * q) 461struct request *ace_get_next_request(struct request_queue * q)
462{ 462{
463 struct request *req; 463 struct request *req;
464 464
@@ -825,7 +825,7 @@ static irqreturn_t ace_interrupt(int irq, void *dev_id)
825/* --------------------------------------------------------------------- 825/* ---------------------------------------------------------------------
826 * Block ops 826 * Block ops
827 */ 827 */
828static void ace_request(request_queue_t * q) 828static void ace_request(struct request_queue * q)
829{ 829{
830 struct request *req; 830 struct request *req;
831 struct ace_device *ace; 831 struct ace_device *ace;
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index e40fa98842e5..2d5853cbd4b0 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -67,7 +67,7 @@ static DEFINE_SPINLOCK(z2ram_lock);
67static struct block_device_operations z2_fops; 67static struct block_device_operations z2_fops;
68static struct gendisk *z2ram_gendisk; 68static struct gendisk *z2ram_gendisk;
69 69
70static void do_z2_request(request_queue_t *q) 70static void do_z2_request(struct request_queue *q)
71{ 71{
72 struct request *req; 72 struct request *req;
73 while ((req = elv_next_request(q)) != NULL) { 73 while ((req = elv_next_request(q)) != NULL) {
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 499019bf8f40..67ee3d4b2878 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -2094,7 +2094,7 @@ out:
2094static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, 2094static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
2095 int lba, int nframes) 2095 int lba, int nframes)
2096{ 2096{
2097 request_queue_t *q = cdi->disk->queue; 2097 struct request_queue *q = cdi->disk->queue;
2098 struct request *rq; 2098 struct request *rq;
2099 struct bio *bio; 2099 struct bio *bio;
2100 unsigned int len; 2100 unsigned int len;
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index 44cd7b2ddf09..e51550db1575 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -398,7 +398,7 @@ static void viocd_end_request(struct request *req, int uptodate)
398 398
399static int rwreq; 399static int rwreq;
400 400
401static void do_viocd_request(request_queue_t *q) 401static void do_viocd_request(struct request_queue *q)
402{ 402{
403 struct request *req; 403 struct request *req;
404 404
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index c8dfd18bea44..b391776e5bf3 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -130,6 +130,7 @@ config ROCKETPORT
130config CYCLADES 130config CYCLADES
131 tristate "Cyclades async mux support" 131 tristate "Cyclades async mux support"
132 depends on SERIAL_NONSTANDARD && (PCI || ISA) 132 depends on SERIAL_NONSTANDARD && (PCI || ISA)
133 select FW_LOADER
133 ---help--- 134 ---help---
134 This driver supports Cyclades Z and Y multiserial boards. 135 This driver supports Cyclades Z and Y multiserial boards.
135 You would need something like this to connect more than two modems to 136 You would need something like this to connect more than two modems to
@@ -726,7 +727,7 @@ config NVRAM
726 727
727config RTC 728config RTC
728 tristate "Enhanced Real Time Clock Support" 729 tristate "Enhanced Real Time Clock Support"
729 depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC64 && (!SPARC32 || PCI) && !FRV && !ARM && !SUPERH && !S390 730 depends on !PPC && !PARISC && !IA64 && !M68K && !SPARC && !FRV && !ARM && !SUPERH && !S390
730 ---help--- 731 ---help---
731 If you say Y here and create a character special file /dev/rtc with 732 If you say Y here and create a character special file /dev/rtc with
732 major number 10 and minor number 135 using mknod ("man mknod"), you 733 major number 10 and minor number 135 using mknod ("man mknod"), you
@@ -750,6 +751,28 @@ config RTC
750 To compile this driver as a module, choose M here: the 751 To compile this driver as a module, choose M here: the
751 module will be called rtc. 752 module will be called rtc.
752 753
754config JS_RTC
755 tristate "Enhanced Real Time Clock Support"
756 depends on SPARC32 && PCI
757 ---help---
758 If you say Y here and create a character special file /dev/rtc with
759 major number 10 and minor number 135 using mknod ("man mknod"), you
760 will get access to the real time clock (or hardware clock) built
761 into your computer.
762
763 Every PC has such a clock built in. It can be used to generate
764 signals from as low as 1Hz up to 8192Hz, and can also be used
765 as a 24 hour alarm. It reports status information via the file
766 /proc/driver/rtc and its behaviour is set by various ioctls on
767 /dev/rtc.
768
769 If you think you have a use for such a device (such as periodic data
770 sampling), then say Y here, and read <file:Documentation/rtc.txt>
771 for details.
772
773 To compile this driver as a module, choose M here: the
774 module will be called js-rtc.
775
753config SGI_DS1286 776config SGI_DS1286
754 tristate "SGI DS1286 RTC support" 777 tristate "SGI DS1286 RTC support"
755 depends on SGI_IP22 778 depends on SGI_IP22
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 8fecaf4010b1..d68ddbe70f73 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -97,7 +97,6 @@ obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
97obj-$(CONFIG_GPIO_TB0219) += tb0219.o 97obj-$(CONFIG_GPIO_TB0219) += tb0219.o
98obj-$(CONFIG_TELCLOCK) += tlclk.o 98obj-$(CONFIG_TELCLOCK) += tlclk.o
99 99
100obj-$(CONFIG_WATCHDOG) += watchdog/
101obj-$(CONFIG_MWAVE) += mwave/ 100obj-$(CONFIG_MWAVE) += mwave/
102obj-$(CONFIG_AGP) += agp/ 101obj-$(CONFIG_AGP) += agp/
103obj-$(CONFIG_DRM) += drm/ 102obj-$(CONFIG_DRM) += drm/
@@ -109,6 +108,9 @@ obj-$(CONFIG_TCG_TPM) += tpm/
109 108
110obj-$(CONFIG_PS3_FLASH) += ps3flash.o 109obj-$(CONFIG_PS3_FLASH) += ps3flash.o
111 110
111obj-$(CONFIG_JS_RTC) += js-rtc.o
112js-rtc-y = rtc.o
113
112# Files generated that shall be removed upon make clean 114# Files generated that shall be removed upon make clean
113clean-files := consolemap_deftbl.c defkeymap.c 115clean-files := consolemap_deftbl.c defkeymap.c
114 116
diff --git a/drivers/char/agp/Kconfig b/drivers/char/agp/Kconfig
index a9f9c48c2424..713533d8a86e 100644
--- a/drivers/char/agp/Kconfig
+++ b/drivers/char/agp/Kconfig
@@ -50,7 +50,7 @@ config AGP_ATI
50 50
51config AGP_AMD 51config AGP_AMD
52 tristate "AMD Irongate, 761, and 762 chipset support" 52 tristate "AMD Irongate, 761, and 762 chipset support"
53 depends on AGP && X86_32 53 depends on AGP && (X86_32 || ALPHA)
54 help 54 help
55 This option gives you AGP support for the GLX component of 55 This option gives you AGP support for the GLX component of
56 X on AMD Irongate, 761, and 762 chipsets. 56 X on AMD Irongate, 761, and 762 chipsets.
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index 780e59e588ad..da7513d7b4e7 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -123,21 +123,16 @@ static int ati_create_gatt_pages(int nr_tables)
123 123
124 for (i = 0; i < nr_tables; i++) { 124 for (i = 0; i < nr_tables; i++) {
125 entry = kzalloc(sizeof(struct ati_page_map), GFP_KERNEL); 125 entry = kzalloc(sizeof(struct ati_page_map), GFP_KERNEL);
126 tables[i] = entry;
126 if (entry == NULL) { 127 if (entry == NULL) {
127 while (i > 0) {
128 kfree(tables[i-1]);
129 i--;
130 }
131 kfree(tables);
132 retval = -ENOMEM; 128 retval = -ENOMEM;
133 break; 129 break;
134 } 130 }
135 tables[i] = entry;
136 retval = ati_create_page_map(entry); 131 retval = ati_create_page_map(entry);
137 if (retval != 0) 132 if (retval != 0)
138 break; 133 break;
139 } 134 }
140 ati_generic_private.num_tables = nr_tables; 135 ati_generic_private.num_tables = i;
141 ati_generic_private.gatt_pages = tables; 136 ati_generic_private.gatt_pages = tables;
142 137
143 if (retval != 0) 138 if (retval != 0)
diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
index fcb4b1bf0d4e..ecd4248861b9 100644
--- a/drivers/char/agp/compat_ioctl.c
+++ b/drivers/char/agp/compat_ioctl.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/pci.h> 30#include <linux/pci.h>
31#include <linux/fs.h>
31#include <linux/agpgart.h> 32#include <linux/agpgart.h>
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
33#include "agp.h" 34#include "agp.h"
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
index c7ed617aa7ff..7791e98de51c 100644
--- a/drivers/char/agp/frontend.c
+++ b/drivers/char/agp/frontend.c
@@ -37,6 +37,7 @@
37#include <linux/agpgart.h> 37#include <linux/agpgart.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/mm.h> 39#include <linux/mm.h>
40#include <linux/fs.h>
40#include <linux/sched.h> 41#include <linux/sched.h>
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index d535c406b319..3db4f4076ed4 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -1170,7 +1170,6 @@ void *agp_generic_alloc_page(struct agp_bridge_data *bridge)
1170 map_page_into_agp(page); 1170 map_page_into_agp(page);
1171 1171
1172 get_page(page); 1172 get_page(page);
1173 SetPageLocked(page);
1174 atomic_inc(&agp_bridge->current_memory_agp); 1173 atomic_inc(&agp_bridge->current_memory_agp);
1175 return page_address(page); 1174 return page_address(page);
1176} 1175}
@@ -1187,7 +1186,6 @@ void agp_generic_destroy_page(void *addr)
1187 page = virt_to_page(addr); 1186 page = virt_to_page(addr);
1188 unmap_page_from_agp(page); 1187 unmap_page_from_agp(page);
1189 put_page(page); 1188 put_page(page);
1190 unlock_page(page);
1191 free_page((unsigned long)addr); 1189 free_page((unsigned long)addr);
1192 atomic_dec(&agp_bridge->current_memory_agp); 1190 atomic_dec(&agp_bridge->current_memory_agp);
1193} 1191}
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index a1240603912c..294cdbf4d44d 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -20,7 +20,9 @@
20#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2 20#define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2
21#define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00 21#define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00
22#define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02 22#define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02
23#define PCI_DEVICE_ID_INTEL_82965GME_HB 0x2A10
23#define PCI_DEVICE_ID_INTEL_82965GME_IG 0x2A12 24#define PCI_DEVICE_ID_INTEL_82965GME_IG 0x2A12
25#define PCI_DEVICE_ID_INTEL_82945GME_HB 0x27AC
24#define PCI_DEVICE_ID_INTEL_82945GME_IG 0x27AE 26#define PCI_DEVICE_ID_INTEL_82945GME_IG 0x27AE
25#define PCI_DEVICE_ID_INTEL_G33_HB 0x29C0 27#define PCI_DEVICE_ID_INTEL_G33_HB 0x29C0
26#define PCI_DEVICE_ID_INTEL_G33_IG 0x29C2 28#define PCI_DEVICE_ID_INTEL_G33_IG 0x29C2
@@ -33,7 +35,8 @@
33 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \ 35 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
34 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \ 36 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \
35 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ 37 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \
36 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB) 38 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \
39 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB)
37 40
38#define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \ 41#define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \
39 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \ 42 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \
@@ -213,7 +216,6 @@ static void *i8xx_alloc_pages(void)
213 } 216 }
214 global_flush_tlb(); 217 global_flush_tlb();
215 get_page(page); 218 get_page(page);
216 SetPageLocked(page);
217 atomic_inc(&agp_bridge->current_memory_agp); 219 atomic_inc(&agp_bridge->current_memory_agp);
218 return page_address(page); 220 return page_address(page);
219} 221}
@@ -229,7 +231,6 @@ static void i8xx_destroy_pages(void *addr)
229 change_page_attr(page, 4, PAGE_KERNEL); 231 change_page_attr(page, 4, PAGE_KERNEL);
230 global_flush_tlb(); 232 global_flush_tlb();
231 put_page(page); 233 put_page(page);
232 unlock_page(page);
233 __free_pages(page, 2); 234 __free_pages(page, 2);
234 atomic_dec(&agp_bridge->current_memory_agp); 235 atomic_dec(&agp_bridge->current_memory_agp);
235} 236}
@@ -527,6 +528,7 @@ static void intel_i830_init_gtt_entries(void)
527 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 528 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
528 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 529 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
529 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || 530 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
531 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GME_HB ||
530 IS_I965 || IS_G33) 532 IS_I965 || IS_G33)
531 gtt_entries = MB(48) - KB(size); 533 gtt_entries = MB(48) - KB(size);
532 else 534 else
@@ -538,6 +540,7 @@ static void intel_i830_init_gtt_entries(void)
538 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || 540 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
539 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || 541 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
540 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || 542 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
543 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GME_HB ||
541 IS_I965 || IS_G33) 544 IS_I965 || IS_G33)
542 gtt_entries = MB(64) - KB(size); 545 gtt_entries = MB(64) - KB(size);
543 else 546 else
@@ -1848,9 +1851,9 @@ static const struct intel_driver_description {
1848 NULL, &intel_915_driver }, 1851 NULL, &intel_915_driver },
1849 { PCI_DEVICE_ID_INTEL_82945G_HB, PCI_DEVICE_ID_INTEL_82945G_IG, 0, "945G", 1852 { PCI_DEVICE_ID_INTEL_82945G_HB, PCI_DEVICE_ID_INTEL_82945G_IG, 0, "945G",
1850 NULL, &intel_915_driver }, 1853 NULL, &intel_915_driver },
1851 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GM_IG, 1, "945GM", 1854 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GM_IG, 0, "945GM",
1852 NULL, &intel_915_driver }, 1855 NULL, &intel_915_driver },
1853 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GME_IG, 0, "945GME", 1856 { PCI_DEVICE_ID_INTEL_82945GME_HB, PCI_DEVICE_ID_INTEL_82945GME_IG, 0, "945GME",
1854 NULL, &intel_915_driver }, 1857 NULL, &intel_915_driver },
1855 { PCI_DEVICE_ID_INTEL_82946GZ_HB, PCI_DEVICE_ID_INTEL_82946GZ_IG, 0, "946GZ", 1858 { PCI_DEVICE_ID_INTEL_82946GZ_HB, PCI_DEVICE_ID_INTEL_82946GZ_IG, 0, "946GZ",
1856 NULL, &intel_i965_driver }, 1859 NULL, &intel_i965_driver },
@@ -1860,9 +1863,9 @@ static const struct intel_driver_description {
1860 NULL, &intel_i965_driver }, 1863 NULL, &intel_i965_driver },
1861 { PCI_DEVICE_ID_INTEL_82965G_HB, PCI_DEVICE_ID_INTEL_82965G_IG, 0, "965G", 1864 { PCI_DEVICE_ID_INTEL_82965G_HB, PCI_DEVICE_ID_INTEL_82965G_IG, 0, "965G",
1862 NULL, &intel_i965_driver }, 1865 NULL, &intel_i965_driver },
1863 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GM_IG, 1, "965GM", 1866 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GM_IG, 0, "965GM",
1864 NULL, &intel_i965_driver }, 1867 NULL, &intel_i965_driver },
1865 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GME_IG, 0, "965GME/GLE", 1868 { PCI_DEVICE_ID_INTEL_82965GME_HB, PCI_DEVICE_ID_INTEL_82965GME_IG, 0, "965GME/GLE",
1866 NULL, &intel_i965_driver }, 1869 NULL, &intel_i965_driver },
1867 { PCI_DEVICE_ID_INTEL_7505_0, 0, 0, "E7505", &intel_7505_driver, NULL }, 1870 { PCI_DEVICE_ID_INTEL_7505_0, 0, 0, "E7505", &intel_7505_driver, NULL },
1868 { PCI_DEVICE_ID_INTEL_7205_0, 0, 0, "E7205", &intel_7505_driver, NULL }, 1871 { PCI_DEVICE_ID_INTEL_7205_0, 0, 0, "E7205", &intel_7505_driver, NULL },
@@ -2051,11 +2054,13 @@ static struct pci_device_id agp_intel_pci_table[] = {
2051 ID(PCI_DEVICE_ID_INTEL_82915GM_HB), 2054 ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
2052 ID(PCI_DEVICE_ID_INTEL_82945G_HB), 2055 ID(PCI_DEVICE_ID_INTEL_82945G_HB),
2053 ID(PCI_DEVICE_ID_INTEL_82945GM_HB), 2056 ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
2057 ID(PCI_DEVICE_ID_INTEL_82945GME_HB),
2054 ID(PCI_DEVICE_ID_INTEL_82946GZ_HB), 2058 ID(PCI_DEVICE_ID_INTEL_82946GZ_HB),
2055 ID(PCI_DEVICE_ID_INTEL_82965G_1_HB), 2059 ID(PCI_DEVICE_ID_INTEL_82965G_1_HB),
2056 ID(PCI_DEVICE_ID_INTEL_82965Q_HB), 2060 ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
2057 ID(PCI_DEVICE_ID_INTEL_82965G_HB), 2061 ID(PCI_DEVICE_ID_INTEL_82965G_HB),
2058 ID(PCI_DEVICE_ID_INTEL_82965GM_HB), 2062 ID(PCI_DEVICE_ID_INTEL_82965GM_HB),
2063 ID(PCI_DEVICE_ID_INTEL_82965GME_HB),
2059 ID(PCI_DEVICE_ID_INTEL_G33_HB), 2064 ID(PCI_DEVICE_ID_INTEL_G33_HB),
2060 ID(PCI_DEVICE_ID_INTEL_Q35_HB), 2065 ID(PCI_DEVICE_ID_INTEL_Q35_HB),
2061 ID(PCI_DEVICE_ID_INTEL_Q33_HB), 2066 ID(PCI_DEVICE_ID_INTEL_Q33_HB),
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index cda608c42bea..98cf8abb3e57 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -51,7 +51,6 @@ static void *sgi_tioca_alloc_page(struct agp_bridge_data *bridge)
51 return NULL; 51 return NULL;
52 52
53 get_page(page); 53 get_page(page);
54 SetPageLocked(page);
55 atomic_inc(&agp_bridge->current_memory_agp); 54 atomic_inc(&agp_bridge->current_memory_agp);
56 return page_address(page); 55 return page_address(page);
57} 56}
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index ba0e74ad74bb..77bf4aa217a8 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -73,7 +73,7 @@ static struct clocksource clocksource_hpet = {
73 .name = "hpet", 73 .name = "hpet",
74 .rating = 250, 74 .rating = 250,
75 .read = read_hpet, 75 .read = read_hpet,
76 .mask = 0xffffffffffffffff, 76 .mask = CLOCKSOURCE_MASK(64),
77 .mult = 0, /*to be caluclated*/ 77 .mult = 0, /*to be caluclated*/
78 .shift = 10, 78 .shift = 10,
79 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 79 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
@@ -1007,9 +1007,15 @@ static int hpet_acpi_remove(struct acpi_device *device, int type)
1007 return -EINVAL; 1007 return -EINVAL;
1008} 1008}
1009 1009
1010static const struct acpi_device_id hpet_device_ids[] = {
1011 {"PNP0103", 0},
1012 {"", 0},
1013};
1014MODULE_DEVICE_TABLE(acpi, hpet_device_ids);
1015
1010static struct acpi_driver hpet_acpi_driver = { 1016static struct acpi_driver hpet_acpi_driver = {
1011 .name = "hpet", 1017 .name = "hpet",
1012 .ids = "PNP0103", 1018 .ids = hpet_device_ids,
1013 .ops = { 1019 .ops = {
1014 .add = hpet_acpi_add, 1020 .add = hpet_acpi_add,
1015 .remove = hpet_acpi_remove, 1021 .remove = hpet_acpi_remove,
diff --git a/drivers/char/hvc_lguest.c b/drivers/char/hvc_lguest.c
index e7b889e404a7..feeccbaec438 100644
--- a/drivers/char/hvc_lguest.c
+++ b/drivers/char/hvc_lguest.c
@@ -1,6 +1,22 @@
1/* Simple console for lguest. 1/*D:300
2 * The Guest console driver
2 * 3 *
3 * Copyright (C) 2006 Rusty Russell, IBM Corporation 4 * This is a trivial console driver: we use lguest's DMA mechanism to send
5 * bytes out, and register a DMA buffer to receive bytes in. It is assumed to
6 * be present and available from the very beginning of boot.
7 *
8 * Writing console drivers is one of the few remaining Dark Arts in Linux.
9 * Fortunately for us, the path of virtual consoles has been well-trodden by
10 * the PowerPC folks, who wrote "hvc_console.c" to generically support any
11 * virtual console. We use that infrastructure which only requires us to write
12 * the basic put_chars and get_chars functions and call the right register
13 * functions.
14 :*/
15
16/*M:002 The console can be flooded: while the Guest is processing input the
17 * Host can send more. Buffering in the Host could alleviate this, but it is a
18 * difficult problem in general. :*/
19/* Copyright (C) 2006 Rusty Russell, IBM Corporation
4 * 20 *
5 * This program is free software; you can redistribute it and/or modify 21 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 22 * it under the terms of the GNU General Public License as published by
@@ -21,49 +37,81 @@
21#include <linux/lguest_bus.h> 37#include <linux/lguest_bus.h>
22#include "hvc_console.h" 38#include "hvc_console.h"
23 39
40/*D:340 This is our single console input buffer, with associated "struct
41 * lguest_dma" referring to it. Note the 0-terminated length array, and the
42 * use of physical address for the buffer itself. */
24static char inbuf[256]; 43static char inbuf[256];
25static struct lguest_dma cons_input = { .used_len = 0, 44static struct lguest_dma cons_input = { .used_len = 0,
26 .addr[0] = __pa(inbuf), 45 .addr[0] = __pa(inbuf),
27 .len[0] = sizeof(inbuf), 46 .len[0] = sizeof(inbuf),
28 .len[1] = 0 }; 47 .len[1] = 0 };
29 48
49/*D:310 The put_chars() callback is pretty straightforward.
50 *
51 * First we put the pointer and length in a "struct lguest_dma": we only have
52 * one pointer, so we set the second length to 0. Then we use SEND_DMA to send
53 * the data to (Host) buffers attached to the console key. Usually a device's
54 * key is a physical address within the device's memory, but because the
55 * console device doesn't have any associated physical memory, we use the
56 * LGUEST_CONSOLE_DMA_KEY constant (aka 0). */
30static int put_chars(u32 vtermno, const char *buf, int count) 57static int put_chars(u32 vtermno, const char *buf, int count)
31{ 58{
32 struct lguest_dma dma; 59 struct lguest_dma dma;
33 60
34 /* FIXME: what if it's over a page boundary? */ 61 /* FIXME: DMA buffers in a "struct lguest_dma" are not allowed
62 * to go over page boundaries. This never seems to happen,
63 * but if it did we'd need to fix this code. */
35 dma.len[0] = count; 64 dma.len[0] = count;
36 dma.len[1] = 0; 65 dma.len[1] = 0;
37 dma.addr[0] = __pa(buf); 66 dma.addr[0] = __pa(buf);
38 67
39 lguest_send_dma(LGUEST_CONSOLE_DMA_KEY, &dma); 68 lguest_send_dma(LGUEST_CONSOLE_DMA_KEY, &dma);
69 /* We're expected to return the amount of data we wrote: all of it. */
40 return count; 70 return count;
41} 71}
42 72
73/*D:350 get_chars() is the callback from the hvc_console infrastructure when
74 * an interrupt is received.
75 *
76 * Firstly we see if our buffer has been filled: if not, we return. The rest
77 * of the code deals with the fact that the hvc_console() infrastructure only
78 * asks us for 16 bytes at a time. We keep a "cons_offset" variable for
79 * partially-read buffers. */
43static int get_chars(u32 vtermno, char *buf, int count) 80static int get_chars(u32 vtermno, char *buf, int count)
44{ 81{
45 static int cons_offset; 82 static int cons_offset;
46 83
84 /* Nothing left to see here... */
47 if (!cons_input.used_len) 85 if (!cons_input.used_len)
48 return 0; 86 return 0;
49 87
88 /* You want more than we have to give? Well, try wanting less! */
50 if (cons_input.used_len - cons_offset < count) 89 if (cons_input.used_len - cons_offset < count)
51 count = cons_input.used_len - cons_offset; 90 count = cons_input.used_len - cons_offset;
52 91
92 /* Copy across to their buffer and increment offset. */
53 memcpy(buf, inbuf + cons_offset, count); 93 memcpy(buf, inbuf + cons_offset, count);
54 cons_offset += count; 94 cons_offset += count;
95
96 /* Finished? Zero offset, and reset cons_input so Host will use it
97 * again. */
55 if (cons_offset == cons_input.used_len) { 98 if (cons_offset == cons_input.used_len) {
56 cons_offset = 0; 99 cons_offset = 0;
57 cons_input.used_len = 0; 100 cons_input.used_len = 0;
58 } 101 }
59 return count; 102 return count;
60} 103}
104/*:*/
61 105
62static struct hv_ops lguest_cons = { 106static struct hv_ops lguest_cons = {
63 .get_chars = get_chars, 107 .get_chars = get_chars,
64 .put_chars = put_chars, 108 .put_chars = put_chars,
65}; 109};
66 110
111/*D:320 Console drivers are initialized very early so boot messages can go
112 * out. At this stage, the console is output-only. Our driver checks we're a
113 * Guest, and if so hands hvc_instantiate() the console number (0), priority
114 * (0), and the struct hv_ops containing the put_chars() function. */
67static int __init cons_init(void) 115static int __init cons_init(void)
68{ 116{
69 if (strcmp(paravirt_ops.name, "lguest") != 0) 117 if (strcmp(paravirt_ops.name, "lguest") != 0)
@@ -73,21 +121,46 @@ static int __init cons_init(void)
73} 121}
74console_initcall(cons_init); 122console_initcall(cons_init);
75 123
124/*D:370 To set up and manage our virtual console, we call hvc_alloc() and
125 * stash the result in the private pointer of the "struct lguest_device".
126 * Since we never remove the console device we never need this pointer again,
127 * but using ->private is considered good form, and you never know who's going
128 * to copy your driver.
129 *
130 * Once the console is set up, we bind our input buffer ready for input. */
76static int lguestcons_probe(struct lguest_device *lgdev) 131static int lguestcons_probe(struct lguest_device *lgdev)
77{ 132{
78 int err; 133 int err;
79 134
135 /* The first argument of hvc_alloc() is the virtual console number, so
136 * we use zero. The second argument is the interrupt number.
137 *
138 * The third argument is a "struct hv_ops" containing the put_chars()
139 * and get_chars() pointers. The final argument is the output buffer
140 * size: we use 256 and expect the Host to have room for us to send
141 * that much. */
80 lgdev->private = hvc_alloc(0, lgdev_irq(lgdev), &lguest_cons, 256); 142 lgdev->private = hvc_alloc(0, lgdev_irq(lgdev), &lguest_cons, 256);
81 if (IS_ERR(lgdev->private)) 143 if (IS_ERR(lgdev->private))
82 return PTR_ERR(lgdev->private); 144 return PTR_ERR(lgdev->private);
83 145
146 /* We bind a single DMA buffer at key LGUEST_CONSOLE_DMA_KEY.
147 * "cons_input" is that statically-initialized global DMA buffer we saw
148 * above, and we also give the interrupt we want. */
84 err = lguest_bind_dma(LGUEST_CONSOLE_DMA_KEY, &cons_input, 1, 149 err = lguest_bind_dma(LGUEST_CONSOLE_DMA_KEY, &cons_input, 1,
85 lgdev_irq(lgdev)); 150 lgdev_irq(lgdev));
86 if (err) 151 if (err)
87 printk("lguest console: failed to bind buffer.\n"); 152 printk("lguest console: failed to bind buffer.\n");
88 return err; 153 return err;
89} 154}
155/* Note the use of lgdev_irq() for the interrupt number. We tell hvc_alloc()
156 * to expect input when this interrupt is triggered, and then tell
157 * lguest_bind_dma() that is the interrupt to send us when input comes in. */
90 158
159/*D:360 From now on the console driver follows standard Guest driver form:
160 * register_lguest_driver() registers the device type and probe function, and
161 * the probe function sets up the device.
162 *
163 * The standard "struct lguest_driver": */
91static struct lguest_driver lguestcons_drv = { 164static struct lguest_driver lguestcons_drv = {
92 .name = "lguestcons", 165 .name = "lguestcons",
93 .owner = THIS_MODULE, 166 .owner = THIS_MODULE,
@@ -95,6 +168,7 @@ static struct lguest_driver lguestcons_drv = {
95 .probe = lguestcons_probe, 168 .probe = lguestcons_probe,
96}; 169};
97 170
171/* The standard init function */
98static int __init hvc_lguest_init(void) 172static int __init hvc_lguest_init(void)
99{ 173{
100 return register_lguest_driver(&lguestcons_drv); 174 return register_lguest_driver(&lguestcons_drv);
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 6005b5225772..8d74b8745e60 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -500,7 +500,6 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
500{ 500{
501 int i, j, box; 501 int i, j, box;
502 int err = 0; 502 int err = 0;
503 int status = 0;
504 static int loaded; 503 static int loaded;
505 i2eBordStrPtr pB = NULL; 504 i2eBordStrPtr pB = NULL;
506 int rc = -1; 505 int rc = -1;
@@ -588,6 +587,8 @@ ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize)
588 case PCI: 587 case PCI:
589#ifdef CONFIG_PCI 588#ifdef CONFIG_PCI
590 { 589 {
590 int status;
591
591 pci_dev_i = pci_get_device(PCI_VENDOR_ID_COMPUTONE, 592 pci_dev_i = pci_get_device(PCI_VENDOR_ID_COMPUTONE,
592 PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i); 593 PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i);
593 if (pci_dev_i != NULL) { 594 if (pci_dev_i != NULL) {
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 4edfdda0cf99..96d2f9ee42d6 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2050,6 +2050,7 @@ static __devinit void try_init_dmi(struct dmi_ipmi_data *ipmi_data)
2050 info->si_type = SI_BT; 2050 info->si_type = SI_BT;
2051 break; 2051 break;
2052 default: 2052 default:
2053 kfree(info);
2053 return; 2054 return;
2054 } 2055 }
2055 2056
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 6e55cfb9c65a..e60a74c66e3d 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -25,6 +25,7 @@
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/fs.h>
28#include <linux/mmtimer.h> 29#include <linux/mmtimer.h>
29#include <linux/miscdevice.h> 30#include <linux/miscdevice.h>
30#include <linux/posix-timers.h> 31#include <linux/posix-timers.h>
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index c716ef0dd370..c08a4152ee8f 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -38,6 +38,7 @@
38#include <linux/miscdevice.h> 38#include <linux/miscdevice.h>
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/mm.h> 40#include <linux/mm.h>
41#include <linux/fs.h>
41#include <linux/vmalloc.h> 42#include <linux/vmalloc.h>
42#include <linux/string.h> 43#include <linux/string.h>
43#include <linux/slab.h> 44#include <linux/slab.h>
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 372a37e25620..bbb7f1292665 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: synclink_gt.c,v 4.36 2006/08/28 20:47:14 paulkf Exp $ 2 * $Id: synclink_gt.c,v 4.50 2007/07/25 19:29:25 paulkf Exp $
3 * 3 *
4 * Device driver for Microgate SyncLink GT serial adapters. 4 * Device driver for Microgate SyncLink GT serial adapters.
5 * 5 *
@@ -93,7 +93,7 @@
93 * module identification 93 * module identification
94 */ 94 */
95static char *driver_name = "SyncLink GT"; 95static char *driver_name = "SyncLink GT";
96static char *driver_version = "$Revision: 4.36 $"; 96static char *driver_version = "$Revision: 4.50 $";
97static char *tty_driver_name = "synclink_gt"; 97static char *tty_driver_name = "synclink_gt";
98static char *tty_dev_prefix = "ttySLG"; 98static char *tty_dev_prefix = "ttySLG";
99MODULE_LICENSE("GPL"); 99MODULE_LICENSE("GPL");
@@ -477,6 +477,7 @@ static void tx_set_idle(struct slgt_info *info);
477static unsigned int free_tbuf_count(struct slgt_info *info); 477static unsigned int free_tbuf_count(struct slgt_info *info);
478static void reset_tbufs(struct slgt_info *info); 478static void reset_tbufs(struct slgt_info *info);
479static void tdma_reset(struct slgt_info *info); 479static void tdma_reset(struct slgt_info *info);
480static void tdma_start(struct slgt_info *info);
480static void tx_load(struct slgt_info *info, const char *buf, unsigned int count); 481static void tx_load(struct slgt_info *info, const char *buf, unsigned int count);
481 482
482static void get_signals(struct slgt_info *info); 483static void get_signals(struct slgt_info *info);
@@ -904,6 +905,8 @@ start:
904 spin_lock_irqsave(&info->lock,flags); 905 spin_lock_irqsave(&info->lock,flags);
905 if (!info->tx_active) 906 if (!info->tx_active)
906 tx_start(info); 907 tx_start(info);
908 else
909 tdma_start(info);
907 spin_unlock_irqrestore(&info->lock,flags); 910 spin_unlock_irqrestore(&info->lock,flags);
908 } 911 }
909 912
@@ -3871,44 +3874,58 @@ static void tx_start(struct slgt_info *info)
3871 slgt_irq_on(info, IRQ_TXUNDER + IRQ_TXIDLE); 3874 slgt_irq_on(info, IRQ_TXUNDER + IRQ_TXIDLE);
3872 /* clear tx idle and underrun status bits */ 3875 /* clear tx idle and underrun status bits */
3873 wr_reg16(info, SSR, (unsigned short)(IRQ_TXIDLE + IRQ_TXUNDER)); 3876 wr_reg16(info, SSR, (unsigned short)(IRQ_TXIDLE + IRQ_TXUNDER));
3874
3875 if (!(rd_reg32(info, TDCSR) & BIT0)) {
3876 /* tx DMA stopped, restart tx DMA */
3877 tdma_reset(info);
3878 /* set 1st descriptor address */
3879 wr_reg32(info, TDDAR, info->tbufs[info->tbuf_start].pdesc);
3880 switch(info->params.mode) {
3881 case MGSL_MODE_RAW:
3882 case MGSL_MODE_MONOSYNC:
3883 case MGSL_MODE_BISYNC:
3884 wr_reg32(info, TDCSR, BIT2 + BIT0); /* IRQ + DMA enable */
3885 break;
3886 default:
3887 wr_reg32(info, TDCSR, BIT0); /* DMA enable */
3888 }
3889 }
3890
3891 if (info->params.mode == MGSL_MODE_HDLC) 3877 if (info->params.mode == MGSL_MODE_HDLC)
3892 mod_timer(&info->tx_timer, jiffies + 3878 mod_timer(&info->tx_timer, jiffies +
3893 msecs_to_jiffies(5000)); 3879 msecs_to_jiffies(5000));
3894 } else { 3880 } else {
3895 tdma_reset(info);
3896 /* set 1st descriptor address */
3897 wr_reg32(info, TDDAR, info->tbufs[info->tbuf_start].pdesc);
3898
3899 slgt_irq_off(info, IRQ_TXDATA); 3881 slgt_irq_off(info, IRQ_TXDATA);
3900 slgt_irq_on(info, IRQ_TXIDLE); 3882 slgt_irq_on(info, IRQ_TXIDLE);
3901 /* clear tx idle status bit */ 3883 /* clear tx idle status bit */
3902 wr_reg16(info, SSR, IRQ_TXIDLE); 3884 wr_reg16(info, SSR, IRQ_TXIDLE);
3903
3904 /* enable tx DMA */
3905 wr_reg32(info, TDCSR, BIT0);
3906 } 3885 }
3907 3886 tdma_start(info);
3908 info->tx_active = 1; 3887 info->tx_active = 1;
3909 } 3888 }
3910} 3889}
3911 3890
3891/*
3892 * start transmit DMA if inactive and there are unsent buffers
3893 */
3894static void tdma_start(struct slgt_info *info)
3895{
3896 unsigned int i;
3897
3898 if (rd_reg32(info, TDCSR) & BIT0)
3899 return;
3900
3901 /* transmit DMA inactive, check for unsent buffers */
3902 i = info->tbuf_start;
3903 while (!desc_count(info->tbufs[i])) {
3904 if (++i == info->tbuf_count)
3905 i = 0;
3906 if (i == info->tbuf_current)
3907 return;
3908 }
3909 info->tbuf_start = i;
3910
3911 /* there are unsent buffers, start transmit DMA */
3912
3913 /* reset needed if previous error condition */
3914 tdma_reset(info);
3915
3916 /* set 1st descriptor address */
3917 wr_reg32(info, TDDAR, info->tbufs[info->tbuf_start].pdesc);
3918 switch(info->params.mode) {
3919 case MGSL_MODE_RAW:
3920 case MGSL_MODE_MONOSYNC:
3921 case MGSL_MODE_BISYNC:
3922 wr_reg32(info, TDCSR, BIT2 + BIT0); /* IRQ + DMA enable */
3923 break;
3924 default:
3925 wr_reg32(info, TDCSR, BIT0); /* DMA enable */
3926 }
3927}
3928
3912static void tx_stop(struct slgt_info *info) 3929static void tx_stop(struct slgt_info *info)
3913{ 3930{
3914 unsigned short val; 3931 unsigned short val;
@@ -4642,8 +4659,8 @@ static unsigned int free_tbuf_count(struct slgt_info *info)
4642 i=0; 4659 i=0;
4643 } while (i != info->tbuf_current); 4660 } while (i != info->tbuf_current);
4644 4661
4645 /* last buffer with zero count may be in use, assume it is */ 4662 /* if tx DMA active, last zero count buffer is in use */
4646 if (count) 4663 if (count && (rd_reg32(info, TDCSR) & BIT0))
4647 --count; 4664 --count;
4648 4665
4649 return count; 4666 return count;
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index 16fb23125e96..37bddc1802de 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -55,6 +55,8 @@ config SOFT_WATCHDOG
55 To compile this driver as a module, choose M here: the 55 To compile this driver as a module, choose M here: the
56 module will be called softdog. 56 module will be called softdog.
57 57
58# ALPHA Architecture
59
58# ARM Architecture 60# ARM Architecture
59 61
60config AT91RM9200_WATCHDOG 62config AT91RM9200_WATCHDOG
@@ -189,7 +191,7 @@ config PNX4008_WATCHDOG
189 191
190config IOP_WATCHDOG 192config IOP_WATCHDOG
191 tristate "IOP Watchdog" 193 tristate "IOP Watchdog"
192 depends on WATCHDOG && PLAT_IOP 194 depends on PLAT_IOP
193 select WATCHDOG_NOWAYOUT if (ARCH_IOP32X || ARCH_IOP33X) 195 select WATCHDOG_NOWAYOUT if (ARCH_IOP32X || ARCH_IOP33X)
194 help 196 help
195 Say Y here if to include support for the watchdog timer 197 Say Y here if to include support for the watchdog timer
@@ -203,15 +205,48 @@ config IOP_WATCHDOG
203 operating as an Root Complex and/or Central Resource, the PCI-X 205 operating as an Root Complex and/or Central Resource, the PCI-X
204 and/or PCIe busses will also be reset. THIS IS A VERY BIG HAMMER. 206 and/or PCIe busses will also be reset. THIS IS A VERY BIG HAMMER.
205 207
208config DAVINCI_WATCHDOG
209 tristate "DaVinci watchdog"
210 depends on ARCH_DAVINCI
211 help
212 Say Y here if to include support for the watchdog timer
213 in the DaVinci DM644x/DM646x processors.
214 To compile this driver as a module, choose M here: the
215 module will be called davinci_wdt.
216
217 NOTE: once enabled, this timer cannot be disabled.
218 Say N if you are unsure.
219
220# ARM26 Architecture
221
206# AVR32 Architecture 222# AVR32 Architecture
207 223
208config AT32AP700X_WDT 224config AT32AP700X_WDT
209 tristate "AT32AP700x watchdog" 225 tristate "AT32AP700x watchdog"
210 depends on WATCHDOG && CPU_AT32AP7000 226 depends on CPU_AT32AP7000
211 help 227 help
212 Watchdog timer embedded into AT32AP700x devices. This will reboot 228 Watchdog timer embedded into AT32AP700x devices. This will reboot
213 your system when the timeout is reached. 229 your system when the timeout is reached.
214 230
231# BLACKFIN Architecture
232
233config BFIN_WDT
234 tristate "Blackfin On-Chip Watchdog Timer"
235 depends on BLACKFIN
236 ---help---
237 If you say yes here you will get support for the Blackfin On-Chip
238 Watchdog Timer. If you have one of these processors and wish to
239 have watchdog support enabled, say Y, otherwise say N.
240
241 To compile this driver as a module, choose M here: the
242 module will be called bfin_wdt.
243
244# CRIS Architecture
245
246# FRV Architecture
247
248# H8300 Architecture
249
215# X86 (i386 + ia64 + x86_64) Architecture 250# X86 (i386 + ia64 + x86_64) Architecture
216 251
217config ACQUIRE_WDT 252config ACQUIRE_WDT
@@ -540,37 +575,11 @@ config SBC_EPX_C3_WATCHDOG
540 To compile this driver as a module, choose M here: the 575 To compile this driver as a module, choose M here: the
541 module will be called sbc_epx_c3. 576 module will be called sbc_epx_c3.
542 577
543# PowerPC Architecture 578# M32R Architecture
544 579
545config 8xx_WDT 580# M68K Architecture
546 tristate "MPC8xx Watchdog Timer"
547 depends on 8xx
548 581
549config 83xx_WDT 582# M68KNOMMU Architecture
550 tristate "MPC83xx Watchdog Timer"
551 depends on PPC_83xx
552
553config MV64X60_WDT
554 tristate "MV64X60 (Marvell Discovery) Watchdog Timer"
555 depends on MV64X60
556
557config BOOKE_WDT
558 bool "PowerPC Book-E Watchdog Timer"
559 depends on BOOKE || 4xx
560 ---help---
561 Please see Documentation/watchdog/watchdog-api.txt for
562 more information.
563
564# PPC64 Architecture
565
566config WATCHDOG_RTAS
567 tristate "RTAS watchdog"
568 depends on PPC_RTAS
569 help
570 This driver adds watchdog support for the RTAS watchdog.
571
572 To compile this driver as a module, choose M here. The module
573 will be called wdrtas.
574 583
575# MIPS Architecture 584# MIPS Architecture
576 585
@@ -600,6 +609,44 @@ config WDT_RM9K_GPI
600 To compile this driver as a module, choose M here: the 609 To compile this driver as a module, choose M here: the
601 module will be called rm9k_wdt. 610 module will be called rm9k_wdt.
602 611
612# PARISC Architecture
613
614# POWERPC Architecture
615
616config MPC5200_WDT
617 tristate "MPC5200 Watchdog Timer"
618 depends on PPC_MPC52xx
619
620config 8xx_WDT
621 tristate "MPC8xx Watchdog Timer"
622 depends on 8xx
623
624config 83xx_WDT
625 tristate "MPC83xx Watchdog Timer"
626 depends on PPC_83xx
627
628config MV64X60_WDT
629 tristate "MV64X60 (Marvell Discovery) Watchdog Timer"
630 depends on MV64X60
631
632config BOOKE_WDT
633 bool "PowerPC Book-E Watchdog Timer"
634 depends on BOOKE || 4xx
635 ---help---
636 Please see Documentation/watchdog/watchdog-api.txt for
637 more information.
638
639# PPC64 Architecture
640
641config WATCHDOG_RTAS
642 tristate "RTAS watchdog"
643 depends on PPC_RTAS
644 help
645 This driver adds watchdog support for the RTAS watchdog.
646
647 To compile this driver as a module, choose M here. The module
648 will be called wdrtas.
649
603# S390 Architecture 650# S390 Architecture
604 651
605config ZVM_WATCHDOG 652config ZVM_WATCHDOG
@@ -614,7 +661,7 @@ config ZVM_WATCHDOG
614 To compile this driver as a module, choose M here. The module 661 To compile this driver as a module, choose M here. The module
615 will be called vmwatchdog. 662 will be called vmwatchdog.
616 663
617# SUPERH Architecture 664# SUPERH (sh + sh64) Architecture
618 665
619config SH_WDT 666config SH_WDT
620 tristate "SuperH Watchdog" 667 tristate "SuperH Watchdog"
@@ -641,6 +688,8 @@ config SH_WDT_MMAP
641 If you say Y here, user applications will be able to mmap the 688 If you say Y here, user applications will be able to mmap the
642 WDT/CPG registers. 689 WDT/CPG registers.
643 690
691# SPARC Architecture
692
644# SPARC64 Architecture 693# SPARC64 Architecture
645 694
646config WATCHDOG_CP1XXX 695config WATCHDOG_CP1XXX
@@ -665,6 +714,10 @@ config WATCHDOG_RIO
665 machines. The watchdog timeout period is normally one minute but 714 machines. The watchdog timeout period is normally one minute but
666 can be changed with a boot-time parameter. 715 can be changed with a boot-time parameter.
667 716
717# V850 Architecture
718
719# XTENSA Architecture
720
668# 721#
669# ISA-based Watchdog Cards 722# ISA-based Watchdog Cards
670# 723#
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index bdb9d5e3bb41..389f8b14ccc4 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -22,6 +22,8 @@ obj-$(CONFIG_WDTPCI) += wdt_pci.o
22# USB-based Watchdog Cards 22# USB-based Watchdog Cards
23obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o 23obj-$(CONFIG_USBPCWATCHDOG) += pcwd_usb.o
24 24
25# ALPHA Architecture
26
25# ARM Architecture 27# ARM Architecture
26obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o 28obj-$(CONFIG_AT91RM9200_WATCHDOG) += at91rm9200_wdt.o
27obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o 29obj-$(CONFIG_OMAP_WATCHDOG) += omap_wdt.o
@@ -36,10 +38,22 @@ obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o
36obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o 38obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
37obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o 39obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o
38obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o 40obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o
41obj-$(CONFIG_DAVINCI_WATCHDOG) += davinci_wdt.o
42
43# ARM26 Architecture
39 44
40# AVR32 Architecture 45# AVR32 Architecture
41obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o 46obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
42 47
48# BLACKFIN Architecture
49obj-$(CONFIG_BFIN_WDT) += bfin_wdt.o
50
51# CRIS Architecture
52
53# FRV Architecture
54
55# H8300 Architecture
56
43# X86 (i386 + ia64 + x86_64) Architecture 57# X86 (i386 + ia64 + x86_64) Architecture
44obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o 58obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
45obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o 59obj-$(CONFIG_ADVANTECH_WDT) += advantechwdt.o
@@ -66,8 +80,22 @@ obj-$(CONFIG_W83977F_WDT) += w83977f_wdt.o
66obj-$(CONFIG_MACHZ_WDT) += machzwd.o 80obj-$(CONFIG_MACHZ_WDT) += machzwd.o
67obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o 81obj-$(CONFIG_SBC_EPX_C3_WATCHDOG) += sbc_epx_c3.o
68 82
69# PowerPC Architecture 83# M32R Architecture
84
85# M68K Architecture
86
87# M68KNOMMU Architecture
88
89# MIPS Architecture
90obj-$(CONFIG_INDYDOG) += indydog.o
91obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o
92obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o
93
94# PARISC Architecture
95
96# POWERPC Architecture
70obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o 97obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o
98obj-$(CONFIG_MPC5200_WDT) += mpc5200_wdt.o
71obj-$(CONFIG_83xx_WDT) += mpc83xx_wdt.o 99obj-$(CONFIG_83xx_WDT) += mpc83xx_wdt.o
72obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o 100obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
73obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o 101obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
@@ -75,17 +103,18 @@ obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
75# PPC64 Architecture 103# PPC64 Architecture
76obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o 104obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
77 105
78# MIPS Architecture
79obj-$(CONFIG_INDYDOG) += indydog.o
80obj-$(CONFIG_WDT_MTX1) += mtx-1_wdt.o
81obj-$(CONFIG_WDT_RM9K_GPI) += rm9k_wdt.o
82
83# S390 Architecture 106# S390 Architecture
84 107
85# SUPERH Architecture 108# SUPERH (sh + sh64) Architecture
86obj-$(CONFIG_SH_WDT) += shwdt.o 109obj-$(CONFIG_SH_WDT) += shwdt.o
87 110
111# SPARC Architecture
112
88# SPARC64 Architecture 113# SPARC64 Architecture
89 114
115# V850 Architecture
116
117# XTENSA Architecture
118
90# Architecture Independant 119# Architecture Independant
91obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o 120obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
diff --git a/drivers/char/watchdog/bfin_wdt.c b/drivers/char/watchdog/bfin_wdt.c
new file mode 100644
index 000000000000..309d27913fc1
--- /dev/null
+++ b/drivers/char/watchdog/bfin_wdt.c
@@ -0,0 +1,490 @@
1/*
2 * Blackfin On-Chip Watchdog Driver
3 * Supports BF53[123]/BF53[467]/BF54[2489]/BF561
4 *
5 * Originally based on softdog.c
6 * Copyright 2006-2007 Analog Devices Inc.
7 * Copyright 2006-2007 Michele d'Amico
8 * Copyright 1996 Alan Cox <alan@redhat.com>
9 *
10 * Enter bugs at http://blackfin.uclinux.org/
11 *
12 * Licensed under the GPL-2 or later.
13 */
14
15#include <linux/platform_device.h>
16#include <linux/module.h>
17#include <linux/moduleparam.h>
18#include <linux/types.h>
19#include <linux/timer.h>
20#include <linux/miscdevice.h>
21#include <linux/watchdog.h>
22#include <linux/fs.h>
23#include <linux/notifier.h>
24#include <linux/reboot.h>
25#include <linux/init.h>
26#include <linux/interrupt.h>
27#include <asm/blackfin.h>
28#include <asm/uaccess.h>
29
30#define stamp(fmt, args...) pr_debug("%s:%i: " fmt "\n", __func__, __LINE__, ## args)
31#define stampit() stamp("here i am")
32
33#define WATCHDOG_NAME "bfin-wdt"
34#define PFX WATCHDOG_NAME ": "
35
36/* The BF561 has two watchdogs (one per core), but since Linux
37 * only runs on core A, we'll just work with that one.
38 */
39#ifdef BF561_FAMILY
40# define bfin_read_WDOG_CTL() bfin_read_WDOGA_CTL()
41# define bfin_read_WDOG_CNT() bfin_read_WDOGA_CNT()
42# define bfin_read_WDOG_STAT() bfin_read_WDOGA_STAT()
43# define bfin_write_WDOG_CTL(x) bfin_write_WDOGA_CTL(x)
44# define bfin_write_WDOG_CNT(x) bfin_write_WDOGA_CNT(x)
45# define bfin_write_WDOG_STAT(x) bfin_write_WDOGA_STAT(x)
46#endif
47
48/* Bit in SWRST that indicates boot caused by watchdog */
49#define SWRST_RESET_WDOG 0x4000
50
51/* Bit in WDOG_CTL that indicates watchdog has expired (WDR0) */
52#define WDOG_EXPIRED 0x8000
53
54/* Masks for WDEV field in WDOG_CTL register */
55#define ICTL_RESET 0x0
56#define ICTL_NMI 0x2
57#define ICTL_GPI 0x4
58#define ICTL_NONE 0x6
59#define ICTL_MASK 0x6
60
61/* Masks for WDEN field in WDOG_CTL register */
62#define WDEN_MASK 0x0FF0
63#define WDEN_ENABLE 0x0000
64#define WDEN_DISABLE 0x0AD0
65
66/* some defaults */
67#define WATCHDOG_TIMEOUT 20
68
69static unsigned int timeout = WATCHDOG_TIMEOUT;
70static int nowayout = WATCHDOG_NOWAYOUT;
71static struct watchdog_info bfin_wdt_info;
72static unsigned long open_check;
73static char expect_close;
74static spinlock_t bfin_wdt_spinlock = SPIN_LOCK_UNLOCKED;
75
76/**
77 * bfin_wdt_keepalive - Keep the Userspace Watchdog Alive
78 *
79 * The Userspace watchdog got a KeepAlive: schedule the next timeout.
80 */
81static int bfin_wdt_keepalive(void)
82{
83 stampit();
84 bfin_write_WDOG_STAT(0);
85 return 0;
86}
87
88/**
89 * bfin_wdt_stop - Stop the Watchdog
90 *
91 * Stops the on-chip watchdog.
92 */
93static int bfin_wdt_stop(void)
94{
95 stampit();
96 bfin_write_WDOG_CTL(WDEN_DISABLE);
97 return 0;
98}
99
100/**
101 * bfin_wdt_start - Start the Watchdog
102 *
103 * Starts the on-chip watchdog. Automatically loads WDOG_CNT
104 * into WDOG_STAT for us.
105 */
106static int bfin_wdt_start(void)
107{
108 stampit();
109 bfin_write_WDOG_CTL(WDEN_ENABLE | ICTL_RESET);
110 return 0;
111}
112
113/**
114 * bfin_wdt_running - Check Watchdog status
115 *
116 * See if the watchdog is running.
117 */
118static int bfin_wdt_running(void)
119{
120 stampit();
121 return ((bfin_read_WDOG_CTL() & WDEN_MASK) != WDEN_DISABLE);
122}
123
124/**
125 * bfin_wdt_set_timeout - Set the Userspace Watchdog timeout
126 * @t: new timeout value (in seconds)
127 *
128 * Translate the specified timeout in seconds into System Clock
129 * terms which is what the on-chip Watchdog requires.
130 */
131static int bfin_wdt_set_timeout(unsigned long t)
132{
133 u32 cnt;
134 unsigned long flags;
135
136 stampit();
137
138 cnt = t * get_sclk();
139 if (cnt < get_sclk()) {
140 printk(KERN_WARNING PFX "timeout value is too large\n");
141 return -EINVAL;
142 }
143
144 spin_lock_irqsave(&bfin_wdt_spinlock, flags);
145 {
146 int run = bfin_wdt_running();
147 bfin_wdt_stop();
148 bfin_write_WDOG_CNT(cnt);
149 if (run) bfin_wdt_start();
150 }
151 spin_unlock_irqrestore(&bfin_wdt_spinlock, flags);
152
153 timeout = t;
154
155 return 0;
156}
157
158/**
159 * bfin_wdt_open - Open the Device
160 * @inode: inode of device
161 * @file: file handle of device
162 *
163 * Watchdog device is opened and started.
164 */
165static int bfin_wdt_open(struct inode *inode, struct file *file)
166{
167 stampit();
168
169 if (test_and_set_bit(0, &open_check))
170 return -EBUSY;
171
172 if (nowayout)
173 __module_get(THIS_MODULE);
174
175 bfin_wdt_keepalive();
176 bfin_wdt_start();
177
178 return nonseekable_open(inode, file);
179}
180
181/**
182 * bfin_wdt_close - Close the Device
183 * @inode: inode of device
184 * @file: file handle of device
185 *
186 * Watchdog device is closed and stopped.
187 */
188static int bfin_wdt_release(struct inode *inode, struct file *file)
189{
190 stampit();
191
192 if (expect_close == 42) {
193 bfin_wdt_stop();
194 } else {
195 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n");
196 bfin_wdt_keepalive();
197 }
198
199 expect_close = 0;
200 clear_bit(0, &open_check);
201
202 return 0;
203}
204
205/**
206 * bfin_wdt_write - Write to Device
207 * @file: file handle of device
208 * @buf: buffer to write
209 * @count: length of buffer
210 * @ppos: offset
211 *
212 * Pings the watchdog on write.
213 */
214static ssize_t bfin_wdt_write(struct file *file, const char __user *data,
215 size_t len, loff_t *ppos)
216{
217 stampit();
218
219 if (len) {
220 if (!nowayout) {
221 size_t i;
222
223 /* In case it was set long ago */
224 expect_close = 0;
225
226 for (i = 0; i != len; i++) {
227 char c;
228 if (get_user(c, data + i))
229 return -EFAULT;
230 if (c == 'V')
231 expect_close = 42;
232 }
233 }
234 bfin_wdt_keepalive();
235 }
236
237 return len;
238}
239
240/**
241 * bfin_wdt_ioctl - Query Device
242 * @inode: inode of device
243 * @file: file handle of device
244 * @cmd: watchdog command
245 * @arg: argument
246 *
247 * Query basic information from the device or ping it, as outlined by the
248 * watchdog API.
249 */
250static int bfin_wdt_ioctl(struct inode *inode, struct file *file,
251 unsigned int cmd, unsigned long arg)
252{
253 void __user *argp = (void __user *)arg;
254 int __user *p = argp;
255
256 stampit();
257
258 switch (cmd) {
259 default:
260 return -ENOTTY;
261
262 case WDIOC_GETSUPPORT:
263 if (copy_to_user(argp, &bfin_wdt_info, sizeof(bfin_wdt_info)))
264 return -EFAULT;
265 else
266 return 0;
267
268 case WDIOC_GETSTATUS:
269 case WDIOC_GETBOOTSTATUS:
270 return put_user(!!(_bfin_swrst & SWRST_RESET_WDOG), p);
271
272 case WDIOC_KEEPALIVE:
273 bfin_wdt_keepalive();
274 return 0;
275
276 case WDIOC_SETTIMEOUT: {
277 int new_timeout;
278
279 if (get_user(new_timeout, p))
280 return -EFAULT;
281
282 if (bfin_wdt_set_timeout(new_timeout))
283 return -EINVAL;
284 }
285 /* Fall */
286 case WDIOC_GETTIMEOUT:
287 return put_user(timeout, p);
288
289 case WDIOC_SETOPTIONS: {
290 unsigned long flags;
291 int options, ret = -EINVAL;
292
293 if (get_user(options, p))
294 return -EFAULT;
295
296 spin_lock_irqsave(&bfin_wdt_spinlock, flags);
297
298 if (options & WDIOS_DISABLECARD) {
299 bfin_wdt_stop();
300 ret = 0;
301 }
302
303 if (options & WDIOS_ENABLECARD) {
304 bfin_wdt_start();
305 ret = 0;
306 }
307
308 spin_unlock_irqrestore(&bfin_wdt_spinlock, flags);
309
310 return ret;
311 }
312 }
313}
314
315/**
316 * bfin_wdt_notify_sys - Notifier Handler
317 * @this: notifier block
318 * @code: notifier event
319 * @unused: unused
320 *
321 * Handles specific events, such as turning off the watchdog during a
322 * shutdown event.
323 */
324static int bfin_wdt_notify_sys(struct notifier_block *this, unsigned long code,
325 void *unused)
326{
327 stampit();
328
329 if (code == SYS_DOWN || code == SYS_HALT)
330 bfin_wdt_stop();
331
332 return NOTIFY_DONE;
333}
334
335#ifdef CONFIG_PM
336static int state_before_suspend;
337
338/**
339 * bfin_wdt_suspend - suspend the watchdog
340 * @pdev: device being suspended
341 * @state: requested suspend state
342 *
343 * Remember if the watchdog was running and stop it.
344 * TODO: is this even right? Doesn't seem to be any
345 * standard in the watchdog world ...
346 */
347static int bfin_wdt_suspend(struct platform_device *pdev, pm_message_t state)
348{
349 stampit();
350
351 state_before_suspend = bfin_wdt_running();
352 bfin_wdt_stop();
353
354 return 0;
355}
356
357/**
358 * bfin_wdt_resume - resume the watchdog
359 * @pdev: device being resumed
360 *
361 * If the watchdog was running, turn it back on.
362 */
363static int bfin_wdt_resume(struct platform_device *pdev)
364{
365 stampit();
366
367 if (state_before_suspend) {
368 bfin_wdt_set_timeout(timeout);
369 bfin_wdt_start();
370 }
371
372 return 0;
373}
374#else
375# define bfin_wdt_suspend NULL
376# define bfin_wdt_resume NULL
377#endif
378
379static struct platform_device bfin_wdt_device = {
380 .name = WATCHDOG_NAME,
381 .id = -1,
382};
383
384static struct platform_driver bfin_wdt_driver = {
385 .driver = {
386 .name = WATCHDOG_NAME,
387 .owner = THIS_MODULE,
388 },
389 .suspend = bfin_wdt_suspend,
390 .resume = bfin_wdt_resume,
391};
392
393static struct file_operations bfin_wdt_fops = {
394 .owner = THIS_MODULE,
395 .llseek = no_llseek,
396 .write = bfin_wdt_write,
397 .ioctl = bfin_wdt_ioctl,
398 .open = bfin_wdt_open,
399 .release = bfin_wdt_release,
400};
401
402static struct miscdevice bfin_wdt_miscdev = {
403 .minor = WATCHDOG_MINOR,
404 .name = "watchdog",
405 .fops = &bfin_wdt_fops,
406};
407
408static struct watchdog_info bfin_wdt_info = {
409 .identity = "Blackfin Watchdog",
410 .options = WDIOF_SETTIMEOUT |
411 WDIOF_KEEPALIVEPING |
412 WDIOF_MAGICCLOSE,
413};
414
415static struct notifier_block bfin_wdt_notifier = {
416 .notifier_call = bfin_wdt_notify_sys,
417};
418
419/**
420 * bfin_wdt_init - Initialize module
421 *
422 * Registers the device and notifier handler. Actual device
423 * initialization is handled by bfin_wdt_open().
424 */
425static int __init bfin_wdt_init(void)
426{
427 int ret;
428
429 stampit();
430
431 /* Check that the timeout value is within range */
432 if (bfin_wdt_set_timeout(timeout))
433 return -EINVAL;
434
435 /* Since this is an on-chip device and needs no board-specific
436 * resources, we'll handle all the platform device stuff here.
437 */
438 ret = platform_device_register(&bfin_wdt_device);
439 if (ret)
440 return ret;
441
442 ret = platform_driver_probe(&bfin_wdt_driver, NULL);
443 if (ret)
444 return ret;
445
446 ret = register_reboot_notifier(&bfin_wdt_notifier);
447 if (ret) {
448 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret);
449 return ret;
450 }
451
452 ret = misc_register(&bfin_wdt_miscdev);
453 if (ret) {
454 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
455 WATCHDOG_MINOR, ret);
456 unregister_reboot_notifier(&bfin_wdt_notifier);
457 return ret;
458 }
459
460 printk(KERN_INFO PFX "initialized: timeout=%d sec (nowayout=%d)\n",
461 timeout, nowayout);
462
463 return 0;
464}
465
466/**
467 * bfin_wdt_exit - Deinitialize module
468 *
469 * Unregisters the device and notifier handler. Actual device
470 * deinitialization is handled by bfin_wdt_close().
471 */
472static void __exit bfin_wdt_exit(void)
473{
474 misc_deregister(&bfin_wdt_miscdev);
475 unregister_reboot_notifier(&bfin_wdt_notifier);
476}
477
478module_init(bfin_wdt_init);
479module_exit(bfin_wdt_exit);
480
481MODULE_AUTHOR("Michele d'Amico, Mike Frysinger <vapier@gentoo.org>");
482MODULE_DESCRIPTION("Blackfin Watchdog Device Driver");
483MODULE_LICENSE("GPL");
484MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
485
486module_param(timeout, uint, 0);
487MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=((2^32)/SCLK), default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
488
489module_param(nowayout, int, 0);
490MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
diff --git a/drivers/char/watchdog/booke_wdt.c b/drivers/char/watchdog/booke_wdt.c
index 0f5c77ddd39d..d362f5bf658a 100644
--- a/drivers/char/watchdog/booke_wdt.c
+++ b/drivers/char/watchdog/booke_wdt.c
@@ -144,7 +144,7 @@ static int booke_wdt_open (struct inode *inode, struct file *file)
144 booke_wdt_period); 144 booke_wdt_period);
145 } 145 }
146 146
147 return 0; 147 return nonseekable_open(inode, file);
148} 148}
149 149
150static const struct file_operations booke_wdt_fops = { 150static const struct file_operations booke_wdt_fops = {
diff --git a/drivers/char/watchdog/cpu5wdt.c b/drivers/char/watchdog/cpu5wdt.c
index d0d45a8b09f0..5941ca601a3a 100644
--- a/drivers/char/watchdog/cpu5wdt.c
+++ b/drivers/char/watchdog/cpu5wdt.c
@@ -162,6 +162,10 @@ static int cpu5wdt_ioctl(struct inode *inode, struct file *file, unsigned int cm
162 if ( copy_to_user(argp, &value, sizeof(int)) ) 162 if ( copy_to_user(argp, &value, sizeof(int)) )
163 return -EFAULT; 163 return -EFAULT;
164 break; 164 break;
165 case WDIOC_GETBOOTSTATUS:
166 if ( copy_to_user(argp, &value, sizeof(int)) )
167 return -EFAULT;
168 break;
165 case WDIOC_GETSUPPORT: 169 case WDIOC_GETSUPPORT:
166 if ( copy_to_user(argp, &ident, sizeof(ident)) ) 170 if ( copy_to_user(argp, &ident, sizeof(ident)) )
167 return -EFAULT; 171 return -EFAULT;
diff --git a/drivers/char/watchdog/davinci_wdt.c b/drivers/char/watchdog/davinci_wdt.c
new file mode 100644
index 000000000000..19db5302ba6e
--- /dev/null
+++ b/drivers/char/watchdog/davinci_wdt.c
@@ -0,0 +1,281 @@
1/*
2 * drivers/char/watchdog/davinci_wdt.c
3 *
4 * Watchdog driver for DaVinci DM644x/DM646x processors
5 *
6 * Copyright (C) 2006 Texas Instruments.
7 *
8 * 2007 (c) MontaVista Software, Inc. This file is licensed under
9 * the terms of the GNU General Public License version 2. This program
10 * is licensed "as is" without any warranty of any kind, whether express
11 * or implied.
12 */
13
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/types.h>
17#include <linux/kernel.h>
18#include <linux/fs.h>
19#include <linux/miscdevice.h>
20#include <linux/watchdog.h>
21#include <linux/init.h>
22#include <linux/bitops.h>
23#include <linux/platform_device.h>
24#include <linux/spinlock.h>
25
26#include <asm/hardware.h>
27#include <asm/uaccess.h>
28#include <asm/io.h>
29
30#define MODULE_NAME "DAVINCI-WDT: "
31
32#define DEFAULT_HEARTBEAT 60
33#define MAX_HEARTBEAT 600 /* really the max margin is 264/27MHz*/
34
35/* Timer register set definition */
36#define PID12 (0x0)
37#define EMUMGT (0x4)
38#define TIM12 (0x10)
39#define TIM34 (0x14)
40#define PRD12 (0x18)
41#define PRD34 (0x1C)
42#define TCR (0x20)
43#define TGCR (0x24)
44#define WDTCR (0x28)
45
46/* TCR bit definitions */
47#define ENAMODE12_DISABLED (0 << 6)
48#define ENAMODE12_ONESHOT (1 << 6)
49#define ENAMODE12_PERIODIC (2 << 6)
50
51/* TGCR bit definitions */
52#define TIM12RS_UNRESET (1 << 0)
53#define TIM34RS_UNRESET (1 << 1)
54#define TIMMODE_64BIT_WDOG (2 << 2)
55
56/* WDTCR bit definitions */
57#define WDEN (1 << 14)
58#define WDFLAG (1 << 15)
59#define WDKEY_SEQ0 (0xa5c6 << 16)
60#define WDKEY_SEQ1 (0xda7e << 16)
61
62static int heartbeat = DEFAULT_HEARTBEAT;
63
64static spinlock_t io_lock;
65static unsigned long wdt_status;
66#define WDT_IN_USE 0
67#define WDT_OK_TO_CLOSE 1
68#define WDT_REGION_INITED 2
69#define WDT_DEVICE_INITED 3
70
71static struct resource *wdt_mem;
72static void __iomem *wdt_base;
73
74static void wdt_service(void)
75{
76 spin_lock(&io_lock);
77
78 /* put watchdog in service state */
79 davinci_writel(WDKEY_SEQ0, wdt_base + WDTCR);
80 /* put watchdog in active state */
81 davinci_writel(WDKEY_SEQ1, wdt_base + WDTCR);
82
83 spin_unlock(&io_lock);
84}
85
86static void wdt_enable(void)
87{
88 u32 tgcr;
89 u32 timer_margin;
90
91 spin_lock(&io_lock);
92
93 /* disable, internal clock source */
94 davinci_writel(0, wdt_base + TCR);
95 /* reset timer, set mode to 64-bit watchdog, and unreset */
96 davinci_writel(0, wdt_base + TGCR);
97 tgcr = TIMMODE_64BIT_WDOG | TIM12RS_UNRESET | TIM34RS_UNRESET;
98 davinci_writel(tgcr, wdt_base + TGCR);
99 /* clear counter regs */
100 davinci_writel(0, wdt_base + TIM12);
101 davinci_writel(0, wdt_base + TIM34);
102 /* set timeout period */
103 timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) & 0xffffffff);
104 davinci_writel(timer_margin, wdt_base + PRD12);
105 timer_margin = (((u64)heartbeat * CLOCK_TICK_RATE) >> 32);
106 davinci_writel(timer_margin, wdt_base + PRD34);
107 /* enable run continuously */
108 davinci_writel(ENAMODE12_PERIODIC, wdt_base + TCR);
109 /* Once the WDT is in pre-active state write to
110 * TIM12, TIM34, PRD12, PRD34, TCR, TGCR, WDTCR are
111 * write protected (except for the WDKEY field)
112 */
113 /* put watchdog in pre-active state */
114 davinci_writel(WDKEY_SEQ0 | WDEN, wdt_base + WDTCR);
115 /* put watchdog in active state */
116 davinci_writel(WDKEY_SEQ1 | WDEN, wdt_base + WDTCR);
117
118 spin_unlock(&io_lock);
119}
120
121static int davinci_wdt_open(struct inode *inode, struct file *file)
122{
123 if (test_and_set_bit(WDT_IN_USE, &wdt_status))
124 return -EBUSY;
125
126 wdt_enable();
127
128 return nonseekable_open(inode, file);
129}
130
131static ssize_t
132davinci_wdt_write(struct file *file, const char *data, size_t len,
133 loff_t *ppos)
134{
135 if (len)
136 wdt_service();
137
138 return len;
139}
140
141static struct watchdog_info ident = {
142 .options = WDIOF_KEEPALIVEPING,
143 .identity = "DaVinci Watchdog",
144};
145
146static int
147davinci_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
148 unsigned long arg)
149{
150 int ret = -ENOTTY;
151
152 switch (cmd) {
153 case WDIOC_GETSUPPORT:
154 ret = copy_to_user((struct watchdog_info *)arg, &ident,
155 sizeof(ident)) ? -EFAULT : 0;
156 break;
157
158 case WDIOC_GETSTATUS:
159 case WDIOC_GETBOOTSTATUS:
160 ret = put_user(0, (int *)arg);
161 break;
162
163 case WDIOC_GETTIMEOUT:
164 ret = put_user(heartbeat, (int *)arg);
165 break;
166
167 case WDIOC_KEEPALIVE:
168 wdt_service();
169 ret = 0;
170 break;
171 }
172 return ret;
173}
174
175static int davinci_wdt_release(struct inode *inode, struct file *file)
176{
177 wdt_service();
178 clear_bit(WDT_IN_USE, &wdt_status);
179
180 return 0;
181}
182
183static const struct file_operations davinci_wdt_fops = {
184 .owner = THIS_MODULE,
185 .llseek = no_llseek,
186 .write = davinci_wdt_write,
187 .ioctl = davinci_wdt_ioctl,
188 .open = davinci_wdt_open,
189 .release = davinci_wdt_release,
190};
191
192static struct miscdevice davinci_wdt_miscdev = {
193 .minor = WATCHDOG_MINOR,
194 .name = "watchdog",
195 .fops = &davinci_wdt_fops,
196};
197
198static int davinci_wdt_probe(struct platform_device *pdev)
199{
200 int ret = 0, size;
201 struct resource *res;
202
203 spin_lock_init(&io_lock);
204
205 if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
206 heartbeat = DEFAULT_HEARTBEAT;
207
208 printk(KERN_INFO MODULE_NAME
209 "DaVinci Watchdog Timer: heartbeat %d sec\n", heartbeat);
210
211 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
212 if (res == NULL) {
213 printk(KERN_INFO MODULE_NAME
214 "failed to get memory region resource\n");
215 return -ENOENT;
216 }
217
218 size = res->end - res->start + 1;
219 wdt_mem = request_mem_region(res->start, size, pdev->name);
220
221 if (wdt_mem == NULL) {
222 printk(KERN_INFO MODULE_NAME "failed to get memory region\n");
223 return -ENOENT;
224 }
225 wdt_base = (void __iomem *)(res->start);
226
227 ret = misc_register(&davinci_wdt_miscdev);
228 if (ret < 0) {
229 printk(KERN_ERR MODULE_NAME "cannot register misc device\n");
230 release_resource(wdt_mem);
231 kfree(wdt_mem);
232 } else {
233 set_bit(WDT_DEVICE_INITED, &wdt_status);
234 }
235
236 return ret;
237}
238
239static int davinci_wdt_remove(struct platform_device *pdev)
240{
241 misc_deregister(&davinci_wdt_miscdev);
242 if (wdt_mem) {
243 release_resource(wdt_mem);
244 kfree(wdt_mem);
245 wdt_mem = NULL;
246 }
247 return 0;
248}
249
250static struct platform_driver platform_wdt_driver = {
251 .driver = {
252 .name = "watchdog",
253 },
254 .probe = davinci_wdt_probe,
255 .remove = davinci_wdt_remove,
256};
257
258static int __init davinci_wdt_init(void)
259{
260 return platform_driver_register(&platform_wdt_driver);
261}
262
263static void __exit davinci_wdt_exit(void)
264{
265 return platform_driver_unregister(&platform_wdt_driver);
266}
267
268module_init(davinci_wdt_init);
269module_exit(davinci_wdt_exit);
270
271MODULE_AUTHOR("Texas Instruments");
272MODULE_DESCRIPTION("DaVinci Watchdog Driver");
273
274module_param(heartbeat, int, 0);
275MODULE_PARM_DESC(heartbeat,
276 "Watchdog heartbeat period in seconds from 1 to "
277 __MODULE_STRING(MAX_HEARTBEAT) ", default "
278 __MODULE_STRING(DEFAULT_HEARTBEAT));
279
280MODULE_LICENSE("GPL");
281MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c
index eac4f9b9f007..cd5a565bc3a0 100644
--- a/drivers/char/watchdog/iTCO_wdt.c
+++ b/drivers/char/watchdog/iTCO_wdt.c
@@ -39,7 +39,12 @@
39 * 82801HR (ICH8R) : document number 313056-002, 313057-004, 39 * 82801HR (ICH8R) : document number 313056-002, 313057-004,
40 * 82801HH (ICH8DH) : document number 313056-002, 313057-004, 40 * 82801HH (ICH8DH) : document number 313056-002, 313057-004,
41 * 82801HO (ICH8DO) : document number 313056-002, 313057-004, 41 * 82801HO (ICH8DO) : document number 313056-002, 313057-004,
42 * 6300ESB (6300ESB) : document number 300641-003 42 * 82801IB (ICH9) : document number 316972-001, 316973-001,
43 * 82801IR (ICH9R) : document number 316972-001, 316973-001,
44 * 82801IH (ICH9DH) : document number 316972-001, 316973-001,
45 * 6300ESB (6300ESB) : document number 300641-003, 300884-010,
46 * 631xESB (631xESB) : document number 313082-001, 313075-005,
47 * 632xESB (632xESB) : document number 313082-001, 313075-005
43 */ 48 */
44 49
45/* 50/*
@@ -48,8 +53,8 @@
48 53
49/* Module and version information */ 54/* Module and version information */
50#define DRV_NAME "iTCO_wdt" 55#define DRV_NAME "iTCO_wdt"
51#define DRV_VERSION "1.01" 56#define DRV_VERSION "1.02"
52#define DRV_RELDATE "21-Jan-2007" 57#define DRV_RELDATE "26-Jul-2007"
53#define PFX DRV_NAME ": " 58#define PFX DRV_NAME ": "
54 59
55/* Includes */ 60/* Includes */
@@ -92,6 +97,10 @@ enum iTCO_chipsets {
92 TCO_ICH8, /* ICH8 & ICH8R */ 97 TCO_ICH8, /* ICH8 & ICH8R */
93 TCO_ICH8DH, /* ICH8DH */ 98 TCO_ICH8DH, /* ICH8DH */
94 TCO_ICH8DO, /* ICH8DO */ 99 TCO_ICH8DO, /* ICH8DO */
100 TCO_ICH9, /* ICH9 */
101 TCO_ICH9R, /* ICH9R */
102 TCO_ICH9DH, /* ICH9DH */
103 TCO_631XESB, /* 631xESB/632xESB */
95}; 104};
96 105
97static struct { 106static struct {
@@ -118,6 +127,10 @@ static struct {
118 {"ICH8 or ICH8R", 2}, 127 {"ICH8 or ICH8R", 2},
119 {"ICH8DH", 2}, 128 {"ICH8DH", 2},
120 {"ICH8DO", 2}, 129 {"ICH8DO", 2},
130 {"ICH9", 2},
131 {"ICH9R", 2},
132 {"ICH9DH", 2},
133 {"631xESB/632xESB", 2},
121 {NULL,0} 134 {NULL,0}
122}; 135};
123 136
@@ -148,6 +161,25 @@ static struct pci_device_id iTCO_wdt_pci_tbl[] = {
148 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8 }, 161 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8 },
149 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8DH }, 162 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8DH },
150 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8DO }, 163 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH8DO },
164 { PCI_VENDOR_ID_INTEL, 0x2918, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH9 },
165 { PCI_VENDOR_ID_INTEL, 0x2916, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH9R },
166 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_ICH9DH },
167 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
168 { PCI_VENDOR_ID_INTEL, 0x2671, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
169 { PCI_VENDOR_ID_INTEL, 0x2672, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
170 { PCI_VENDOR_ID_INTEL, 0x2673, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
171 { PCI_VENDOR_ID_INTEL, 0x2674, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
172 { PCI_VENDOR_ID_INTEL, 0x2675, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
173 { PCI_VENDOR_ID_INTEL, 0x2676, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
174 { PCI_VENDOR_ID_INTEL, 0x2677, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
175 { PCI_VENDOR_ID_INTEL, 0x2678, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
176 { PCI_VENDOR_ID_INTEL, 0x2679, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
177 { PCI_VENDOR_ID_INTEL, 0x267a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
178 { PCI_VENDOR_ID_INTEL, 0x267b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
179 { PCI_VENDOR_ID_INTEL, 0x267c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
180 { PCI_VENDOR_ID_INTEL, 0x267d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
181 { PCI_VENDOR_ID_INTEL, 0x267e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
182 { PCI_VENDOR_ID_INTEL, 0x267f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, TCO_631XESB },
151 { 0, }, /* End of list */ 183 { 0, }, /* End of list */
152}; 184};
153MODULE_DEVICE_TABLE (pci, iTCO_wdt_pci_tbl); 185MODULE_DEVICE_TABLE (pci, iTCO_wdt_pci_tbl);
diff --git a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c
index a0d27160c80e..6d35bb112a5f 100644
--- a/drivers/char/watchdog/machzwd.c
+++ b/drivers/char/watchdog/machzwd.c
@@ -321,6 +321,7 @@ static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
321 break; 321 break;
322 322
323 case WDIOC_GETSTATUS: 323 case WDIOC_GETSTATUS:
324 case WDIOC_GETBOOTSTATUS:
324 return put_user(0, p); 325 return put_user(0, p);
325 326
326 case WDIOC_KEEPALIVE: 327 case WDIOC_KEEPALIVE:
diff --git a/drivers/char/watchdog/mixcomwd.c b/drivers/char/watchdog/mixcomwd.c
index db2ccb864412..1adf1d56027d 100644
--- a/drivers/char/watchdog/mixcomwd.c
+++ b/drivers/char/watchdog/mixcomwd.c
@@ -215,6 +215,11 @@ static int mixcomwd_ioctl(struct inode *inode, struct file *file,
215 return -EFAULT; 215 return -EFAULT;
216 } 216 }
217 break; 217 break;
218 case WDIOC_GETBOOTSTATUS:
219 if (copy_to_user(p, &status, sizeof(int))) {
220 return -EFAULT;
221 }
222 break;
218 case WDIOC_GETSUPPORT: 223 case WDIOC_GETSUPPORT:
219 if (copy_to_user(argp, &ident, sizeof(ident))) { 224 if (copy_to_user(argp, &ident, sizeof(ident))) {
220 return -EFAULT; 225 return -EFAULT;
diff --git a/drivers/char/watchdog/mpc5200_wdt.c b/drivers/char/watchdog/mpc5200_wdt.c
new file mode 100644
index 000000000000..564143d40610
--- /dev/null
+++ b/drivers/char/watchdog/mpc5200_wdt.c
@@ -0,0 +1,286 @@
1#include <linux/init.h>
2#include <linux/module.h>
3#include <linux/miscdevice.h>
4#include <linux/watchdog.h>
5#include <linux/io.h>
6#include <linux/spinlock.h>
7#include <asm/of_platform.h>
8#include <asm/uaccess.h>
9#include <asm/mpc52xx.h>
10
11
12#define GPT_MODE_WDT (1<<15)
13#define GPT_MODE_CE (1<<12)
14#define GPT_MODE_MS_TIMER (0x4)
15
16
17struct mpc5200_wdt {
18 unsigned count; /* timer ticks before watchdog kicks in */
19 long ipb_freq;
20 struct miscdevice miscdev;
21 struct resource mem;
22 struct mpc52xx_gpt __iomem *regs;
23 spinlock_t io_lock;
24};
25
26/* is_active stores wether or not the /dev/watchdog device is opened */
27static unsigned long is_active;
28
29/* misc devices don't provide a way, to get back to 'dev' or 'miscdev' from
30 * file operations, which sucks. But there can be max 1 watchdog anyway, so...
31 */
32static struct mpc5200_wdt *wdt_global;
33
34
35/* helper to calculate timeout in timer counts */
36static void mpc5200_wdt_set_timeout(struct mpc5200_wdt *wdt, int timeout)
37{
38 /* use biggest prescaler of 64k */
39 wdt->count = (wdt->ipb_freq + 0xffff) / 0x10000 * timeout;
40
41 if (wdt->count > 0xffff)
42 wdt->count = 0xffff;
43}
44/* return timeout in seconds (calculated from timer count) */
45static int mpc5200_wdt_get_timeout(struct mpc5200_wdt *wdt)
46{
47 return wdt->count * 0x10000 / wdt->ipb_freq;
48}
49
50
51/* watchdog operations */
52static int mpc5200_wdt_start(struct mpc5200_wdt *wdt)
53{
54 spin_lock(&wdt->io_lock);
55 /* disable */
56 out_be32(&wdt->regs->mode, 0);
57 /* set timeout, with maximum prescaler */
58 out_be32(&wdt->regs->count, 0x0 | wdt->count);
59 /* enable watchdog */
60 out_be32(&wdt->regs->mode, GPT_MODE_CE | GPT_MODE_WDT | GPT_MODE_MS_TIMER);
61 spin_unlock(&wdt->io_lock);
62
63 return 0;
64}
65static int mpc5200_wdt_ping(struct mpc5200_wdt *wdt)
66{
67 spin_lock(&wdt->io_lock);
68 /* writing A5 to OCPW resets the watchdog */
69 out_be32(&wdt->regs->mode, 0xA5000000 | (0xffffff & in_be32(&wdt->regs->mode)));
70 spin_unlock(&wdt->io_lock);
71 return 0;
72}
73static int mpc5200_wdt_stop(struct mpc5200_wdt *wdt)
74{
75 spin_lock(&wdt->io_lock);
76 /* disable */
77 out_be32(&wdt->regs->mode, 0);
78 spin_unlock(&wdt->io_lock);
79 return 0;
80}
81
82
83/* file operations */
84static ssize_t mpc5200_wdt_write(struct file *file, const char *data,
85 size_t len, loff_t *ppos)
86{
87 struct mpc5200_wdt *wdt = file->private_data;
88 mpc5200_wdt_ping(wdt);
89 return 0;
90}
91static struct watchdog_info mpc5200_wdt_info = {
92 .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
93 .identity = "mpc5200 watchdog on GPT0",
94};
95static int mpc5200_wdt_ioctl(struct inode *inode, struct file *file,
96 unsigned int cmd, unsigned long arg)
97{
98 struct mpc5200_wdt *wdt = file->private_data;
99 int __user *data = (int __user *)arg;
100 int timeout;
101 int ret = 0;
102
103 switch (cmd) {
104 case WDIOC_GETSUPPORT:
105 ret = copy_to_user(data, &mpc5200_wdt_info,
106 sizeof(mpc5200_wdt_info));
107 if (ret)
108 ret = -EFAULT;
109 break;
110
111 case WDIOC_GETSTATUS:
112 case WDIOC_GETBOOTSTATUS:
113 ret = put_user(0, data);
114 break;
115
116 case WDIOC_KEEPALIVE:
117 mpc5200_wdt_ping(wdt);
118 break;
119
120 case WDIOC_SETTIMEOUT:
121 ret = get_user(timeout, data);
122 if (ret)
123 break;
124 mpc5200_wdt_set_timeout(wdt, timeout);
125 mpc5200_wdt_start(wdt);
126 /* fall through and return the timeout */
127
128 case WDIOC_GETTIMEOUT:
129 timeout = mpc5200_wdt_get_timeout(wdt);
130 ret = put_user(timeout, data);
131 break;
132
133 default:
134 ret = -ENOTTY;
135 }
136 return ret;
137}
138static int mpc5200_wdt_open(struct inode *inode, struct file *file)
139{
140 /* /dev/watchdog can only be opened once */
141 if (test_and_set_bit(0, &is_active))
142 return -EBUSY;
143
144 /* Set and activate the watchdog */
145 mpc5200_wdt_set_timeout(wdt_global, 30);
146 mpc5200_wdt_start(wdt_global);
147 file->private_data = wdt_global;
148 return nonseekable_open(inode, file);
149}
150static int mpc5200_wdt_release(struct inode *inode, struct file *file)
151{
152#if WATCHDOG_NOWAYOUT == 0
153 struct mpc5200_wdt *wdt = file->private_data;
154 mpc5200_wdt_stop(wdt);
155 wdt->count = 0; /* == disabled */
156#endif
157 clear_bit(0, &is_active);
158 return 0;
159}
160
161static struct file_operations mpc5200_wdt_fops = {
162 .owner = THIS_MODULE,
163 .write = mpc5200_wdt_write,
164 .ioctl = mpc5200_wdt_ioctl,
165 .open = mpc5200_wdt_open,
166 .release = mpc5200_wdt_release,
167};
168
169/* module operations */
170static int mpc5200_wdt_probe(struct of_device *op, const struct of_device_id *match)
171{
172 struct mpc5200_wdt *wdt;
173 int err;
174 const void *has_wdt;
175 int size;
176
177 has_wdt = of_get_property(op->node, "has-wdt", NULL);
178 if (!has_wdt)
179 return -ENODEV;
180
181 wdt = kzalloc(sizeof(*wdt), GFP_KERNEL);
182 if (!wdt)
183 return -ENOMEM;
184
185 wdt->ipb_freq = mpc52xx_find_ipb_freq(op->node);
186
187 err = of_address_to_resource(op->node, 0, &wdt->mem);
188 if (err)
189 goto out_free;
190 size = wdt->mem.end - wdt->mem.start + 1;
191 if (!request_mem_region(wdt->mem.start, size, "mpc5200_wdt")) {
192 err = -ENODEV;
193 goto out_free;
194 }
195 wdt->regs = ioremap(wdt->mem.start, size);
196 if (!wdt->regs) {
197 err = -ENODEV;
198 goto out_release;
199 }
200
201 dev_set_drvdata(&op->dev, wdt);
202 spin_lock_init(&wdt->io_lock);
203
204 wdt->miscdev = (struct miscdevice) {
205 .minor = WATCHDOG_MINOR,
206 .name = "watchdog",
207 .fops = &mpc5200_wdt_fops,
208 .parent = &op->dev,
209 };
210 wdt_global = wdt;
211 err = misc_register(&wdt->miscdev);
212 if (!err)
213 return 0;
214
215 iounmap(wdt->regs);
216 out_release:
217 release_mem_region(wdt->mem.start, size);
218 out_free:
219 kfree(wdt);
220 return err;
221}
222
223static int mpc5200_wdt_remove(struct of_device *op)
224{
225 struct mpc5200_wdt *wdt = dev_get_drvdata(&op->dev);
226
227 mpc5200_wdt_stop(wdt);
228 misc_deregister(&wdt->miscdev);
229 iounmap(wdt->regs);
230 release_mem_region(wdt->mem.start, wdt->mem.end - wdt->mem.start + 1);
231 kfree(wdt);
232
233 return 0;
234}
235static int mpc5200_wdt_suspend(struct of_device *op, pm_message_t state)
236{
237 struct mpc5200_wdt *wdt = dev_get_drvdata(&op->dev);
238 mpc5200_wdt_stop(wdt);
239 return 0;
240}
241static int mpc5200_wdt_resume(struct of_device *op)
242{
243 struct mpc5200_wdt *wdt = dev_get_drvdata(&op->dev);
244 if (wdt->count)
245 mpc5200_wdt_start(wdt);
246 return 0;
247}
248static int mpc5200_wdt_shutdown(struct of_device *op)
249{
250 struct mpc5200_wdt *wdt = dev_get_drvdata(&op->dev);
251 mpc5200_wdt_stop(wdt);
252 return 0;
253}
254
255static struct of_device_id mpc5200_wdt_match[] = {
256 { .compatible = "mpc5200-gpt", },
257 {},
258};
259static struct of_platform_driver mpc5200_wdt_driver = {
260 .owner = THIS_MODULE,
261 .name = "mpc5200-gpt-wdt",
262 .match_table = mpc5200_wdt_match,
263 .probe = mpc5200_wdt_probe,
264 .remove = mpc5200_wdt_remove,
265 .suspend = mpc5200_wdt_suspend,
266 .resume = mpc5200_wdt_resume,
267 .shutdown = mpc5200_wdt_shutdown,
268};
269
270
271static int __init mpc5200_wdt_init(void)
272{
273 return of_register_platform_driver(&mpc5200_wdt_driver);
274}
275
276static void __exit mpc5200_wdt_exit(void)
277{
278 of_unregister_platform_driver(&mpc5200_wdt_driver);
279}
280
281module_init(mpc5200_wdt_init);
282module_exit(mpc5200_wdt_exit);
283
284MODULE_AUTHOR("Domen Puncer <domen.puncer@telargo.com>");
285MODULE_LICENSE("Dual BSD/GPL");
286MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/char/watchdog/mpc83xx_wdt.c b/drivers/char/watchdog/mpc83xx_wdt.c
index 18ca752e2f90..a0bf95fb9763 100644
--- a/drivers/char/watchdog/mpc83xx_wdt.c
+++ b/drivers/char/watchdog/mpc83xx_wdt.c
@@ -119,6 +119,9 @@ static int mpc83xx_wdt_ioctl(struct inode *inode, struct file *file,
119 switch (cmd) { 119 switch (cmd) {
120 case WDIOC_GETSUPPORT: 120 case WDIOC_GETSUPPORT:
121 return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0; 121 return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
122 case WDIOC_GETSTATUS:
123 case WDIOC_GETBOOTSTATUS:
124 return put_user(0, p);
122 case WDIOC_KEEPALIVE: 125 case WDIOC_KEEPALIVE:
123 mpc83xx_wdt_keepalive(); 126 mpc83xx_wdt_keepalive();
124 return 0; 127 return 0;
diff --git a/drivers/char/watchdog/mpc8xx_wdt.c b/drivers/char/watchdog/mpc8xx_wdt.c
index 8aaed10dd499..85b5734403a5 100644
--- a/drivers/char/watchdog/mpc8xx_wdt.c
+++ b/drivers/char/watchdog/mpc8xx_wdt.c
@@ -57,7 +57,7 @@ static int mpc8xx_wdt_open(struct inode *inode, struct file *file)
57 m8xx_wdt_reset(); 57 m8xx_wdt_reset();
58 mpc8xx_wdt_handler_disable(); 58 mpc8xx_wdt_handler_disable();
59 59
60 return 0; 60 return nonseekable_open(inode, file);
61} 61}
62 62
63static int mpc8xx_wdt_release(struct inode *inode, struct file *file) 63static int mpc8xx_wdt_release(struct inode *inode, struct file *file)
diff --git a/drivers/char/watchdog/mtx-1_wdt.c b/drivers/char/watchdog/mtx-1_wdt.c
index 419ab445c944..dcfd401a7ad7 100644
--- a/drivers/char/watchdog/mtx-1_wdt.c
+++ b/drivers/char/watchdog/mtx-1_wdt.c
@@ -143,6 +143,7 @@ static int mtx1_wdt_ioctl(struct inode *inode, struct file *file, unsigned int c
143 mtx1_wdt_reset(); 143 mtx1_wdt_reset();
144 break; 144 break;
145 case WDIOC_GETSTATUS: 145 case WDIOC_GETSTATUS:
146 case WDIOC_GETBOOTSTATUS:
146 if ( copy_to_user(argp, &value, sizeof(int)) ) 147 if ( copy_to_user(argp, &value, sizeof(int)) )
147 return -EFAULT; 148 return -EFAULT;
148 break; 149 break;
diff --git a/drivers/char/watchdog/mv64x60_wdt.c b/drivers/char/watchdog/mv64x60_wdt.c
index b887cdb01334..0365c317f7e1 100644
--- a/drivers/char/watchdog/mv64x60_wdt.c
+++ b/drivers/char/watchdog/mv64x60_wdt.c
@@ -23,61 +23,101 @@
23#include <linux/watchdog.h> 23#include <linux/watchdog.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25 25
26#include <asm/mv64x60.h> 26#include <linux/mv643xx.h>
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28#include <asm/io.h> 28#include <asm/io.h>
29 29
30/* MV64x60 WDC (config) register access definitions */ 30#define MV64x60_WDT_WDC_OFFSET 0
31#define MV64x60_WDC_CTL1_MASK (3 << 24) 31
32#define MV64x60_WDC_CTL1(val) ((val & 3) << 24) 32/*
33#define MV64x60_WDC_CTL2_MASK (3 << 26) 33 * The watchdog configuration register contains a pair of 2-bit fields,
34#define MV64x60_WDC_CTL2(val) ((val & 3) << 26) 34 * 1. a reload field, bits 27-26, which triggers a reload of
35 * the countdown register, and
36 * 2. an enable field, bits 25-24, which toggles between
37 * enabling and disabling the watchdog timer.
38 * Bit 31 is a read-only field which indicates whether the
39 * watchdog timer is currently enabled.
40 *
41 * The low 24 bits contain the timer reload value.
42 */
43#define MV64x60_WDC_ENABLE_SHIFT 24
44#define MV64x60_WDC_SERVICE_SHIFT 26
45#define MV64x60_WDC_ENABLED_SHIFT 31
46
47#define MV64x60_WDC_ENABLED_TRUE 1
48#define MV64x60_WDC_ENABLED_FALSE 0
35 49
36/* Flags bits */ 50/* Flags bits */
37#define MV64x60_WDOG_FLAG_OPENED 0 51#define MV64x60_WDOG_FLAG_OPENED 0
38#define MV64x60_WDOG_FLAG_ENABLED 1
39 52
40static unsigned long wdt_flags; 53static unsigned long wdt_flags;
41static int wdt_status; 54static int wdt_status;
42static void __iomem *mv64x60_regs; 55static void __iomem *mv64x60_wdt_regs;
43static int mv64x60_wdt_timeout; 56static int mv64x60_wdt_timeout;
57static int mv64x60_wdt_count;
58static unsigned int bus_clk;
59static char expect_close;
60static DEFINE_SPINLOCK(mv64x60_wdt_spinlock);
61
62static int nowayout = WATCHDOG_NOWAYOUT;
63module_param(nowayout, int, 0);
64MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
44 65
45static void mv64x60_wdt_reg_write(u32 val) 66static int mv64x60_wdt_toggle_wdc(int enabled_predicate, int field_shift)
46{ 67{
47 /* Allow write only to CTL1 / CTL2 fields, retaining values in 68 u32 data;
48 * other fields. 69 u32 enabled;
49 */ 70 int ret = 0;
50 u32 data = readl(mv64x60_regs + MV64x60_WDT_WDC); 71
51 data &= ~(MV64x60_WDC_CTL1_MASK | MV64x60_WDC_CTL2_MASK); 72 spin_lock(&mv64x60_wdt_spinlock);
52 data |= val; 73 data = readl(mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
53 writel(data, mv64x60_regs + MV64x60_WDT_WDC); 74 enabled = (data >> MV64x60_WDC_ENABLED_SHIFT) & 1;
75
76 /* only toggle the requested field if enabled state matches predicate */
77 if ((enabled ^ enabled_predicate) == 0) {
78 /* We write a 1, then a 2 -- to the appropriate field */
79 data = (1 << field_shift) | mv64x60_wdt_count;
80 writel(data, mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
81
82 data = (2 << field_shift) | mv64x60_wdt_count;
83 writel(data, mv64x60_wdt_regs + MV64x60_WDT_WDC_OFFSET);
84 ret = 1;
85 }
86 spin_unlock(&mv64x60_wdt_spinlock);
87
88 return ret;
54} 89}
55 90
56static void mv64x60_wdt_service(void) 91static void mv64x60_wdt_service(void)
57{ 92{
58 /* Write 01 followed by 10 to CTL2 */ 93 mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_TRUE,
59 mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x01)); 94 MV64x60_WDC_SERVICE_SHIFT);
60 mv64x60_wdt_reg_write(MV64x60_WDC_CTL2(0x02)); 95}
96
97static void mv64x60_wdt_handler_enable(void)
98{
99 if (mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_FALSE,
100 MV64x60_WDC_ENABLE_SHIFT)) {
101 mv64x60_wdt_service();
102 printk(KERN_NOTICE "mv64x60_wdt: watchdog activated\n");
103 }
61} 104}
62 105
63static void mv64x60_wdt_handler_disable(void) 106static void mv64x60_wdt_handler_disable(void)
64{ 107{
65 if (test_and_clear_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) { 108 if (mv64x60_wdt_toggle_wdc(MV64x60_WDC_ENABLED_TRUE,
66 /* Write 01 followed by 10 to CTL1 */ 109 MV64x60_WDC_ENABLE_SHIFT))
67 mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01));
68 mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02));
69 printk(KERN_NOTICE "mv64x60_wdt: watchdog deactivated\n"); 110 printk(KERN_NOTICE "mv64x60_wdt: watchdog deactivated\n");
70 }
71} 111}
72 112
73static void mv64x60_wdt_handler_enable(void) 113static void mv64x60_wdt_set_timeout(unsigned int timeout)
74{ 114{
75 if (!test_and_set_bit(MV64x60_WDOG_FLAG_ENABLED, &wdt_flags)) { 115 /* maximum bus cycle count is 0xFFFFFFFF */
76 /* Write 01 followed by 10 to CTL1 */ 116 if (timeout > 0xFFFFFFFF / bus_clk)
77 mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x01)); 117 timeout = 0xFFFFFFFF / bus_clk;
78 mv64x60_wdt_reg_write(MV64x60_WDC_CTL1(0x02)); 118
79 printk(KERN_NOTICE "mv64x60_wdt: watchdog activated\n"); 119 mv64x60_wdt_count = timeout * bus_clk >> 8;
80 } 120 mv64x60_wdt_timeout = timeout;
81} 121}
82 122
83static int mv64x60_wdt_open(struct inode *inode, struct file *file) 123static int mv64x60_wdt_open(struct inode *inode, struct file *file)
@@ -85,21 +125,24 @@ static int mv64x60_wdt_open(struct inode *inode, struct file *file)
85 if (test_and_set_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags)) 125 if (test_and_set_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags))
86 return -EBUSY; 126 return -EBUSY;
87 127
88 mv64x60_wdt_service(); 128 if (nowayout)
89 mv64x60_wdt_handler_enable(); 129 __module_get(THIS_MODULE);
90 130
91 nonseekable_open(inode, file); 131 mv64x60_wdt_handler_enable();
92 132
93 return 0; 133 return nonseekable_open(inode, file);
94} 134}
95 135
96static int mv64x60_wdt_release(struct inode *inode, struct file *file) 136static int mv64x60_wdt_release(struct inode *inode, struct file *file)
97{ 137{
98 mv64x60_wdt_service(); 138 if (expect_close == 42)
99 139 mv64x60_wdt_handler_disable();
100#if !defined(CONFIG_WATCHDOG_NOWAYOUT) 140 else {
101 mv64x60_wdt_handler_disable(); 141 printk(KERN_CRIT
102#endif 142 "mv64x60_wdt: unexpected close, not stopping timer!\n");
143 mv64x60_wdt_service();
144 }
145 expect_close = 0;
103 146
104 clear_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags); 147 clear_bit(MV64x60_WDOG_FLAG_OPENED, &wdt_flags);
105 148
@@ -109,8 +152,22 @@ static int mv64x60_wdt_release(struct inode *inode, struct file *file)
109static ssize_t mv64x60_wdt_write(struct file *file, const char __user *data, 152static ssize_t mv64x60_wdt_write(struct file *file, const char __user *data,
110 size_t len, loff_t * ppos) 153 size_t len, loff_t * ppos)
111{ 154{
112 if (len) 155 if (len) {
156 if (!nowayout) {
157 size_t i;
158
159 expect_close = 0;
160
161 for (i = 0; i != len; i++) {
162 char c;
163 if(get_user(c, data + i))
164 return -EFAULT;
165 if (c == 'V')
166 expect_close = 42;
167 }
168 }
113 mv64x60_wdt_service(); 169 mv64x60_wdt_service();
170 }
114 171
115 return len; 172 return len;
116} 173}
@@ -119,9 +176,12 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
119 unsigned int cmd, unsigned long arg) 176 unsigned int cmd, unsigned long arg)
120{ 177{
121 int timeout; 178 int timeout;
179 int options;
122 void __user *argp = (void __user *)arg; 180 void __user *argp = (void __user *)arg;
123 static struct watchdog_info info = { 181 static struct watchdog_info info = {
124 .options = WDIOF_KEEPALIVEPING, 182 .options = WDIOF_SETTIMEOUT |
183 WDIOF_MAGICCLOSE |
184 WDIOF_KEEPALIVEPING,
125 .firmware_version = 0, 185 .firmware_version = 0,
126 .identity = "MV64x60 watchdog", 186 .identity = "MV64x60 watchdog",
127 }; 187 };
@@ -143,7 +203,15 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
143 return -EOPNOTSUPP; 203 return -EOPNOTSUPP;
144 204
145 case WDIOC_SETOPTIONS: 205 case WDIOC_SETOPTIONS:
146 return -EOPNOTSUPP; 206 if (get_user(options, (int __user *)argp))
207 return -EFAULT;
208
209 if (options & WDIOS_DISABLECARD)
210 mv64x60_wdt_handler_disable();
211
212 if (options & WDIOS_ENABLECARD)
213 mv64x60_wdt_handler_enable();
214 break;
147 215
148 case WDIOC_KEEPALIVE: 216 case WDIOC_KEEPALIVE:
149 mv64x60_wdt_service(); 217 mv64x60_wdt_service();
@@ -151,11 +219,13 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
151 break; 219 break;
152 220
153 case WDIOC_SETTIMEOUT: 221 case WDIOC_SETTIMEOUT:
154 return -EOPNOTSUPP; 222 if (get_user(timeout, (int __user *)argp))
223 return -EFAULT;
224 mv64x60_wdt_set_timeout(timeout);
225 /* Fall through */
155 226
156 case WDIOC_GETTIMEOUT: 227 case WDIOC_GETTIMEOUT:
157 timeout = mv64x60_wdt_timeout * HZ; 228 if (put_user(mv64x60_wdt_timeout, (int __user *)argp))
158 if (put_user(timeout, (int __user *)argp))
159 return -EFAULT; 229 return -EFAULT;
160 break; 230 break;
161 231
@@ -184,18 +254,33 @@ static struct miscdevice mv64x60_wdt_miscdev = {
184static int __devinit mv64x60_wdt_probe(struct platform_device *dev) 254static int __devinit mv64x60_wdt_probe(struct platform_device *dev)
185{ 255{
186 struct mv64x60_wdt_pdata *pdata = dev->dev.platform_data; 256 struct mv64x60_wdt_pdata *pdata = dev->dev.platform_data;
187 int bus_clk = 133; 257 struct resource *r;
258 int timeout = 10;
188 259
189 mv64x60_wdt_timeout = 10; 260 bus_clk = 133; /* in MHz */
190 if (pdata) { 261 if (pdata) {
191 mv64x60_wdt_timeout = pdata->timeout; 262 timeout = pdata->timeout;
192 bus_clk = pdata->bus_clk; 263 bus_clk = pdata->bus_clk;
193 } 264 }
194 265
195 mv64x60_regs = mv64x60_get_bridge_vbase(); 266 /* Since bus_clk is truncated MHz, actual frequency could be
267 * up to 1MHz higher. Round up, since it's better to time out
268 * too late than too soon.
269 */
270 bus_clk++;
271 bus_clk *= 1000000; /* convert to Hz */
272
273 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
274 if (!r)
275 return -ENODEV;
196 276
197 writel((mv64x60_wdt_timeout * (bus_clk * 1000000)) >> 8, 277 mv64x60_wdt_regs = ioremap(r->start, r->end - r->start + 1);
198 mv64x60_regs + MV64x60_WDT_WDC); 278 if (mv64x60_wdt_regs == NULL)
279 return -ENOMEM;
280
281 mv64x60_wdt_set_timeout(timeout);
282
283 mv64x60_wdt_handler_disable(); /* in case timer was already running */
199 284
200 return misc_register(&mv64x60_wdt_miscdev); 285 return misc_register(&mv64x60_wdt_miscdev);
201} 286}
@@ -204,9 +289,10 @@ static int __devexit mv64x60_wdt_remove(struct platform_device *dev)
204{ 289{
205 misc_deregister(&mv64x60_wdt_miscdev); 290 misc_deregister(&mv64x60_wdt_miscdev);
206 291
207 mv64x60_wdt_service();
208 mv64x60_wdt_handler_disable(); 292 mv64x60_wdt_handler_disable();
209 293
294 iounmap(mv64x60_wdt_regs);
295
210 return 0; 296 return 0;
211} 297}
212 298
@@ -219,40 +305,16 @@ static struct platform_driver mv64x60_wdt_driver = {
219 }, 305 },
220}; 306};
221 307
222static struct platform_device *mv64x60_wdt_dev;
223
224static int __init mv64x60_wdt_init(void) 308static int __init mv64x60_wdt_init(void)
225{ 309{
226 int ret;
227
228 printk(KERN_INFO "MV64x60 watchdog driver\n"); 310 printk(KERN_INFO "MV64x60 watchdog driver\n");
229 311
230 mv64x60_wdt_dev = platform_device_alloc(MV64x60_WDT_NAME, -1); 312 return platform_driver_register(&mv64x60_wdt_driver);
231 if (!mv64x60_wdt_dev) {
232 ret = -ENOMEM;
233 goto out;
234 }
235
236 ret = platform_device_add(mv64x60_wdt_dev);
237 if (ret) {
238 platform_device_put(mv64x60_wdt_dev);
239 goto out;
240 }
241
242 ret = platform_driver_register(&mv64x60_wdt_driver);
243 if (ret) {
244 platform_device_unregister(mv64x60_wdt_dev);
245 goto out;
246 }
247
248 out:
249 return ret;
250} 313}
251 314
252static void __exit mv64x60_wdt_exit(void) 315static void __exit mv64x60_wdt_exit(void)
253{ 316{
254 platform_driver_unregister(&mv64x60_wdt_driver); 317 platform_driver_unregister(&mv64x60_wdt_driver);
255 platform_device_unregister(mv64x60_wdt_dev);
256} 318}
257 319
258module_init(mv64x60_wdt_init); 320module_init(mv64x60_wdt_init);
diff --git a/drivers/char/watchdog/omap_wdt.c b/drivers/char/watchdog/omap_wdt.c
index b36fa8de2131..719b066f73c4 100644
--- a/drivers/char/watchdog/omap_wdt.c
+++ b/drivers/char/watchdog/omap_wdt.c
@@ -142,7 +142,7 @@ static int omap_wdt_open(struct inode *inode, struct file *file)
142 142
143 omap_wdt_set_timeout(); 143 omap_wdt_set_timeout();
144 omap_wdt_enable(); 144 omap_wdt_enable();
145 return 0; 145 return nonseekable_open(inode, file);
146} 146}
147 147
148static int omap_wdt_release(struct inode *inode, struct file *file) 148static int omap_wdt_release(struct inode *inode, struct file *file)
@@ -197,7 +197,7 @@ omap_wdt_ioctl(struct inode *inode, struct file *file,
197 197
198 switch (cmd) { 198 switch (cmd) {
199 default: 199 default:
200 return -ENOIOCTLCMD; 200 return -ENOTTY;
201 case WDIOC_GETSUPPORT: 201 case WDIOC_GETSUPPORT:
202 return copy_to_user((struct watchdog_info __user *)arg, &ident, 202 return copy_to_user((struct watchdog_info __user *)arg, &ident,
203 sizeof(ident)); 203 sizeof(ident));
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
index 50430bced2f2..5d1c15f83d23 100644
--- a/drivers/char/watchdog/s3c2410_wdt.c
+++ b/drivers/char/watchdog/s3c2410_wdt.c
@@ -52,10 +52,10 @@
52 52
53#include <asm/arch/map.h> 53#include <asm/arch/map.h>
54 54
55#undef S3C24XX_VA_WATCHDOG 55#undef S3C_VA_WATCHDOG
56#define S3C24XX_VA_WATCHDOG (0) 56#define S3C_VA_WATCHDOG (0)
57 57
58#include <asm/arch/regs-watchdog.h> 58#include <asm/plat-s3c/regs-watchdog.h>
59 59
60#define PFX "s3c2410-wdt: " 60#define PFX "s3c2410-wdt: "
61 61
diff --git a/drivers/char/watchdog/sa1100_wdt.c b/drivers/char/watchdog/sa1100_wdt.c
index 33c1137f17d6..3475f47aaa45 100644
--- a/drivers/char/watchdog/sa1100_wdt.c
+++ b/drivers/char/watchdog/sa1100_wdt.c
@@ -45,7 +45,6 @@ static int boot_status;
45 */ 45 */
46static int sa1100dog_open(struct inode *inode, struct file *file) 46static int sa1100dog_open(struct inode *inode, struct file *file)
47{ 47{
48 nonseekable_open(inode, file);
49 if (test_and_set_bit(1,&sa1100wdt_users)) 48 if (test_and_set_bit(1,&sa1100wdt_users))
50 return -EBUSY; 49 return -EBUSY;
51 50
@@ -54,7 +53,7 @@ static int sa1100dog_open(struct inode *inode, struct file *file)
54 OSSR = OSSR_M3; 53 OSSR = OSSR_M3;
55 OWER = OWER_WME; 54 OWER = OWER_WME;
56 OIER |= OIER_E3; 55 OIER |= OIER_E3;
57 return 0; 56 return nonseekable_open(inode, file);
58} 57}
59 58
60/* 59/*
diff --git a/drivers/char/watchdog/sbc60xxwdt.c b/drivers/char/watchdog/sbc60xxwdt.c
index b6282039198c..e4f3cb6090bc 100644
--- a/drivers/char/watchdog/sbc60xxwdt.c
+++ b/drivers/char/watchdog/sbc60xxwdt.c
@@ -191,8 +191,6 @@ static ssize_t fop_write(struct file * file, const char __user * buf, size_t cou
191 191
192static int fop_open(struct inode * inode, struct file * file) 192static int fop_open(struct inode * inode, struct file * file)
193{ 193{
194 nonseekable_open(inode, file);
195
196 /* Just in case we're already talking to someone... */ 194 /* Just in case we're already talking to someone... */
197 if(test_and_set_bit(0, &wdt_is_open)) 195 if(test_and_set_bit(0, &wdt_is_open))
198 return -EBUSY; 196 return -EBUSY;
@@ -202,7 +200,7 @@ static int fop_open(struct inode * inode, struct file * file)
202 200
203 /* Good, fire up the show */ 201 /* Good, fire up the show */
204 wdt_startup(); 202 wdt_startup();
205 return 0; 203 return nonseekable_open(inode, file);
206} 204}
207 205
208static int fop_close(struct inode * inode, struct file * file) 206static int fop_close(struct inode * inode, struct file * file)
diff --git a/drivers/char/watchdog/sc1200wdt.c b/drivers/char/watchdog/sc1200wdt.c
index 2f7ba7a514fe..9670d47190d0 100644
--- a/drivers/char/watchdog/sc1200wdt.c
+++ b/drivers/char/watchdog/sc1200wdt.c
@@ -150,8 +150,6 @@ static inline int sc1200wdt_status(void)
150 150
151static int sc1200wdt_open(struct inode *inode, struct file *file) 151static int sc1200wdt_open(struct inode *inode, struct file *file)
152{ 152{
153 nonseekable_open(inode, file);
154
155 /* allow one at a time */ 153 /* allow one at a time */
156 if (down_trylock(&open_sem)) 154 if (down_trylock(&open_sem))
157 return -EBUSY; 155 return -EBUSY;
@@ -162,7 +160,7 @@ static int sc1200wdt_open(struct inode *inode, struct file *file)
162 sc1200wdt_start(); 160 sc1200wdt_start();
163 printk(KERN_INFO PFX "Watchdog enabled, timeout = %d min(s)", timeout); 161 printk(KERN_INFO PFX "Watchdog enabled, timeout = %d min(s)", timeout);
164 162
165 return 0; 163 return nonseekable_open(inode, file);
166} 164}
167 165
168 166
diff --git a/drivers/char/watchdog/sc520_wdt.c b/drivers/char/watchdog/sc520_wdt.c
index 2676a43895a7..e8594c64d1e6 100644
--- a/drivers/char/watchdog/sc520_wdt.c
+++ b/drivers/char/watchdog/sc520_wdt.c
@@ -248,8 +248,6 @@ static ssize_t fop_write(struct file * file, const char __user * buf, size_t cou
248 248
249static int fop_open(struct inode * inode, struct file * file) 249static int fop_open(struct inode * inode, struct file * file)
250{ 250{
251 nonseekable_open(inode, file);
252
253 /* Just in case we're already talking to someone... */ 251 /* Just in case we're already talking to someone... */
254 if(test_and_set_bit(0, &wdt_is_open)) 252 if(test_and_set_bit(0, &wdt_is_open))
255 return -EBUSY; 253 return -EBUSY;
@@ -258,7 +256,7 @@ static int fop_open(struct inode * inode, struct file * file)
258 256
259 /* Good, fire up the show */ 257 /* Good, fire up the show */
260 wdt_startup(); 258 wdt_startup();
261 return 0; 259 return nonseekable_open(inode, file);
262} 260}
263 261
264static int fop_close(struct inode * inode, struct file * file) 262static int fop_close(struct inode * inode, struct file * file)
diff --git a/drivers/char/watchdog/w83627hf_wdt.c b/drivers/char/watchdog/w83627hf_wdt.c
index b46e7f47d705..df33b3b5a53c 100644
--- a/drivers/char/watchdog/w83627hf_wdt.c
+++ b/drivers/char/watchdog/w83627hf_wdt.c
@@ -4,7 +4,7 @@
4 * (c) Copyright 2007 Vlad Drukker <vlad@storewiz.com> 4 * (c) Copyright 2007 Vlad Drukker <vlad@storewiz.com>
5 * added support for W83627THF. 5 * added support for W83627THF.
6 * 6 *
7 * (c) Copyright 2003 Pádraig Brady <P@draigBrady.com> 7 * (c) Copyright 2003,2007 Pádraig Brady <P@draigBrady.com>
8 * 8 *
9 * Based on advantechwdt.c which is based on wdt.c. 9 * Based on advantechwdt.c which is based on wdt.c.
10 * Original copyright messages: 10 * Original copyright messages:
@@ -42,7 +42,7 @@
42#include <asm/uaccess.h> 42#include <asm/uaccess.h>
43#include <asm/system.h> 43#include <asm/system.h>
44 44
45#define WATCHDOG_NAME "w83627hf/thf WDT" 45#define WATCHDOG_NAME "w83627hf/thf/hg WDT"
46#define PFX WATCHDOG_NAME ": " 46#define PFX WATCHDOG_NAME ": "
47#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ 47#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */
48 48
@@ -57,7 +57,7 @@ MODULE_PARM_DESC(wdt_io, "w83627hf/thf WDT io port (default 0x2E)");
57 57
58static int timeout = WATCHDOG_TIMEOUT; /* in seconds */ 58static int timeout = WATCHDOG_TIMEOUT; /* in seconds */
59module_param(timeout, int, 0); 59module_param(timeout, int, 0);
60MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=63, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) "."); 60MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
61 61
62static int nowayout = WATCHDOG_NOWAYOUT; 62static int nowayout = WATCHDOG_NOWAYOUT;
63module_param(nowayout, int, 0); 63module_param(nowayout, int, 0);
@@ -78,9 +78,9 @@ w83627hf_select_wd_register(void)
78 outb_p(0x87, WDT_EFER); /* Enter extended function mode */ 78 outb_p(0x87, WDT_EFER); /* Enter extended function mode */
79 outb_p(0x87, WDT_EFER); /* Again according to manual */ 79 outb_p(0x87, WDT_EFER); /* Again according to manual */
80 80
81 outb(0x20, WDT_EFER); /* check chip version */ 81 outb(0x20, WDT_EFER); /* check chip version */
82 c = inb(WDT_EFDR); 82 c = inb(WDT_EFDR);
83 if (c == 0x82) { /* W83627THF */ 83 if (c == 0x82) { /* W83627THF */
84 outb_p(0x2b, WDT_EFER); /* select GPIO3 */ 84 outb_p(0x2b, WDT_EFER); /* select GPIO3 */
85 c = ((inb_p(WDT_EFDR) & 0xf7) | 0x04); /* select WDT0 */ 85 c = ((inb_p(WDT_EFDR) & 0xf7) | 0x04); /* select WDT0 */
86 outb_p(0x2b, WDT_EFER); 86 outb_p(0x2b, WDT_EFER);
@@ -114,11 +114,17 @@ w83627hf_init(void)
114 printk (KERN_INFO PFX "Watchdog already running. Resetting timeout to %d sec\n", timeout); 114 printk (KERN_INFO PFX "Watchdog already running. Resetting timeout to %d sec\n", timeout);
115 outb_p(timeout, WDT_EFDR); /* Write back to CRF6 */ 115 outb_p(timeout, WDT_EFDR); /* Write back to CRF6 */
116 } 116 }
117
117 outb_p(0xF5, WDT_EFER); /* Select CRF5 */ 118 outb_p(0xF5, WDT_EFER); /* Select CRF5 */
118 t=inb_p(WDT_EFDR); /* read CRF5 */ 119 t=inb_p(WDT_EFDR); /* read CRF5 */
119 t&=~0x0C; /* set second mode & disable keyboard turning off watchdog */ 120 t&=~0x0C; /* set second mode & disable keyboard turning off watchdog */
120 outb_p(t, WDT_EFDR); /* Write back to CRF5 */ 121 outb_p(t, WDT_EFDR); /* Write back to CRF5 */
121 122
123 outb_p(0xF7, WDT_EFER); /* Select CRF7 */
124 t=inb_p(WDT_EFDR); /* read CRF7 */
125 t&=~0xC0; /* disable keyboard & mouse turning off watchdog */
126 outb_p(t, WDT_EFDR); /* Write back to CRF7 */
127
122 w83627hf_unselect_wd_register(); 128 w83627hf_unselect_wd_register();
123} 129}
124 130
@@ -126,7 +132,7 @@ static void
126wdt_ctrl(int timeout) 132wdt_ctrl(int timeout)
127{ 133{
128 spin_lock(&io_lock); 134 spin_lock(&io_lock);
129 135
130 w83627hf_select_wd_register(); 136 w83627hf_select_wd_register();
131 137
132 outb_p(0xF6, WDT_EFER); /* Select CRF6 */ 138 outb_p(0xF6, WDT_EFER); /* Select CRF6 */
@@ -154,7 +160,7 @@ wdt_disable(void)
154static int 160static int
155wdt_set_heartbeat(int t) 161wdt_set_heartbeat(int t)
156{ 162{
157 if ((t < 1) || (t > 63)) 163 if ((t < 1) || (t > 255))
158 return -EINVAL; 164 return -EINVAL;
159 165
160 timeout = t; 166 timeout = t;
@@ -324,11 +330,11 @@ wdt_init(void)
324 330
325 spin_lock_init(&io_lock); 331 spin_lock_init(&io_lock);
326 332
327 printk(KERN_INFO "WDT driver for the Winbond(TM) W83627HF/THF Super I/O chip initialising.\n"); 333 printk(KERN_INFO "WDT driver for the Winbond(TM) W83627HF/THF/HG Super I/O chip initialising.\n");
328 334
329 if (wdt_set_heartbeat(timeout)) { 335 if (wdt_set_heartbeat(timeout)) {
330 wdt_set_heartbeat(WATCHDOG_TIMEOUT); 336 wdt_set_heartbeat(WATCHDOG_TIMEOUT);
331 printk (KERN_INFO PFX "timeout value must be 1<=timeout<=63, using %d\n", 337 printk (KERN_INFO PFX "timeout value must be 1<=timeout<=255, using %d\n",
332 WATCHDOG_TIMEOUT); 338 WATCHDOG_TIMEOUT);
333 } 339 }
334 340
diff --git a/drivers/dma/iovlock.c b/drivers/dma/iovlock.c
index d637555a833b..e763d723e4cf 100644
--- a/drivers/dma/iovlock.c
+++ b/drivers/dma/iovlock.c
@@ -143,29 +143,6 @@ void dma_unpin_iovec_pages(struct dma_pinned_list *pinned_list)
143 kfree(pinned_list); 143 kfree(pinned_list);
144} 144}
145 145
146static dma_cookie_t dma_memcpy_to_kernel_iovec(struct dma_chan *chan, struct
147 iovec *iov, unsigned char *kdata, size_t len)
148{
149 dma_cookie_t dma_cookie = 0;
150
151 while (len > 0) {
152 if (iov->iov_len) {
153 int copy = min_t(unsigned int, iov->iov_len, len);
154 dma_cookie = dma_async_memcpy_buf_to_buf(
155 chan,
156 iov->iov_base,
157 kdata,
158 copy);
159 kdata += copy;
160 len -= copy;
161 iov->iov_len -= copy;
162 iov->iov_base += copy;
163 }
164 iov++;
165 }
166
167 return dma_cookie;
168}
169 146
170/* 147/*
171 * We have already pinned down the pages we will be using in the iovecs. 148 * We have already pinned down the pages we will be using in the iovecs.
@@ -187,10 +164,6 @@ dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
187 if (!chan) 164 if (!chan)
188 return memcpy_toiovec(iov, kdata, len); 165 return memcpy_toiovec(iov, kdata, len);
189 166
190 /* -> kernel copies (e.g. smbfs) */
191 if (!pinned_list)
192 return dma_memcpy_to_kernel_iovec(chan, iov, kdata, len);
193
194 iovec_idx = 0; 167 iovec_idx = 0;
195 while (iovec_idx < pinned_list->nr_iovecs) { 168 while (iovec_idx < pinned_list->nr_iovecs) {
196 struct dma_page_list *page_list; 169 struct dma_page_list *page_list;
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index 1724c41d2414..98b6b4fb4257 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -8,7 +8,7 @@ menuconfig EDAC
8 bool "EDAC - error detection and reporting (EXPERIMENTAL)" 8 bool "EDAC - error detection and reporting (EXPERIMENTAL)"
9 depends on HAS_IOMEM 9 depends on HAS_IOMEM
10 depends on EXPERIMENTAL 10 depends on EXPERIMENTAL
11 depends on X86 || MIPS || PPC 11 depends on X86 || PPC
12 help 12 help
13 EDAC is designed to report errors in the core system. 13 EDAC is designed to report errors in the core system.
14 These are low-level errors that are reported in the CPU or 14 These are low-level errors that are reported in the CPU or
@@ -126,7 +126,7 @@ config EDAC_I5000
126config EDAC_PASEMI 126config EDAC_PASEMI
127 tristate "PA Semi PWRficient" 127 tristate "PA Semi PWRficient"
128 depends on EDAC_MM_EDAC && PCI 128 depends on EDAC_MM_EDAC && PCI
129 depends on PPC 129 depends on PPC_PASEMI
130 help 130 help
131 Support for error detection and correction on PA Semi 131 Support for error detection and correction on PA Semi
132 PWRficient. 132 PWRficient.
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 4471be362599..063a1bffe38b 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -214,6 +214,13 @@ void edac_mc_free(struct mem_ctl_info *mci)
214} 214}
215EXPORT_SYMBOL_GPL(edac_mc_free); 215EXPORT_SYMBOL_GPL(edac_mc_free);
216 216
217
218/*
219 * find_mci_by_dev
220 *
221 * scan list of controllers looking for the one that manages
222 * the 'dev' device
223 */
217static struct mem_ctl_info *find_mci_by_dev(struct device *dev) 224static struct mem_ctl_info *find_mci_by_dev(struct device *dev)
218{ 225{
219 struct mem_ctl_info *mci; 226 struct mem_ctl_info *mci;
@@ -268,12 +275,6 @@ static void edac_mc_workq_function(struct work_struct *work_req)
268 if (edac_mc_assert_error_check_and_clear() && (mci->edac_check != NULL)) 275 if (edac_mc_assert_error_check_and_clear() && (mci->edac_check != NULL))
269 mci->edac_check(mci); 276 mci->edac_check(mci);
270 277
271 /*
272 * FIXME: temp place holder for PCI checks,
273 * goes away when we break out PCI
274 */
275 edac_pci_do_parity_check();
276
277 mutex_unlock(&mem_ctls_mutex); 278 mutex_unlock(&mem_ctls_mutex);
278 279
279 /* Reschedule */ 280 /* Reschedule */
@@ -314,36 +315,55 @@ static void edac_mc_workq_teardown(struct mem_ctl_info *mci)
314{ 315{
315 int status; 316 int status;
316 317
317 /* if not running POLL, leave now */ 318 status = cancel_delayed_work(&mci->work);
318 if (mci->op_state == OP_RUNNING_POLL) { 319 if (status == 0) {
319 status = cancel_delayed_work(&mci->work); 320 debugf0("%s() not canceled, flush the queue\n",
320 if (status == 0) { 321 __func__);
321 debugf0("%s() not canceled, flush the queue\n",
322 __func__);
323 322
324 /* workq instance might be running, wait for it */ 323 /* workq instance might be running, wait for it */
325 flush_workqueue(edac_workqueue); 324 flush_workqueue(edac_workqueue);
326 }
327 } 325 }
328} 326}
329 327
330/* 328/*
331 * edac_reset_delay_period 329 * edac_mc_reset_delay_period(unsigned long value)
330 *
331 * user space has updated our poll period value, need to
332 * reset our workq delays
332 */ 333 */
333static void edac_reset_delay_period(struct mem_ctl_info *mci, unsigned long value) 334void edac_mc_reset_delay_period(int value)
334{ 335{
335 /* cancel the current workq request */ 336 struct mem_ctl_info *mci;
336 edac_mc_workq_teardown(mci); 337 struct list_head *item;
337 338
338 /* lock the list of devices for the new setup */
339 mutex_lock(&mem_ctls_mutex); 339 mutex_lock(&mem_ctls_mutex);
340 340
341 /* restart the workq request, with new delay value */ 341 /* scan the list and turn off all workq timers, doing so under lock
342 edac_mc_workq_setup(mci, value); 342 */
343 list_for_each(item, &mc_devices) {
344 mci = list_entry(item, struct mem_ctl_info, link);
345
346 if (mci->op_state == OP_RUNNING_POLL)
347 cancel_delayed_work(&mci->work);
348 }
349
350 mutex_unlock(&mem_ctls_mutex);
351
352
353 /* re-walk the list, and reset the poll delay */
354 mutex_lock(&mem_ctls_mutex);
355
356 list_for_each(item, &mc_devices) {
357 mci = list_entry(item, struct mem_ctl_info, link);
358
359 edac_mc_workq_setup(mci, (unsigned long) value);
360 }
343 361
344 mutex_unlock(&mem_ctls_mutex); 362 mutex_unlock(&mem_ctls_mutex);
345} 363}
346 364
365
366
347/* Return 0 on success, 1 on failure. 367/* Return 0 on success, 1 on failure.
348 * Before calling this function, caller must 368 * Before calling this function, caller must
349 * assign a unique value to mci->mc_idx. 369 * assign a unique value to mci->mc_idx.
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index cd090b0677a7..4a0576bd06fc 100644
--- a/drivers/edac/edac_mc_sysfs.c
+++ b/drivers/edac/edac_mc_sysfs.c
@@ -122,6 +122,23 @@ static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count)
122 return count; 122 return count;
123} 123}
124 124
125/*
126 * mc poll_msec time value
127 */
128static ssize_t poll_msec_int_store(void *ptr, const char *buffer, size_t count)
129{
130 int *value = (int *)ptr;
131
132 if (isdigit(*buffer)) {
133 *value = simple_strtoul(buffer, NULL, 0);
134
135 /* notify edac_mc engine to reset the poll period */
136 edac_mc_reset_delay_period(*value);
137 }
138
139 return count;
140}
141
125 142
126/* EDAC sysfs CSROW data structures and methods 143/* EDAC sysfs CSROW data structures and methods
127 */ 144 */
@@ -704,7 +721,7 @@ MEMCTRL_ATTR(edac_mc_log_ce,
704 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store); 721 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store);
705 722
706MEMCTRL_ATTR(edac_mc_poll_msec, 723MEMCTRL_ATTR(edac_mc_poll_msec,
707 S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store); 724 S_IRUGO | S_IWUSR, memctrl_int_show, poll_msec_int_store);
708 725
709/* Base Attributes of the memory ECC object */ 726/* Base Attributes of the memory ECC object */
710static struct memctrl_dev_attribute *memctrl_attr[] = { 727static struct memctrl_dev_attribute *memctrl_attr[] = {
diff --git a/drivers/edac/edac_module.h b/drivers/edac/edac_module.h
index a2134dfc3cc6..cbc419c8ebc1 100644
--- a/drivers/edac/edac_module.h
+++ b/drivers/edac/edac_module.h
@@ -52,6 +52,8 @@ extern void edac_device_workq_setup(struct edac_device_ctl_info *edac_dev,
52extern void edac_device_workq_teardown(struct edac_device_ctl_info *edac_dev); 52extern void edac_device_workq_teardown(struct edac_device_ctl_info *edac_dev);
53extern void edac_device_reset_delay_period(struct edac_device_ctl_info 53extern void edac_device_reset_delay_period(struct edac_device_ctl_info
54 *edac_dev, unsigned long value); 54 *edac_dev, unsigned long value);
55extern void edac_mc_reset_delay_period(int value);
56
55extern void *edac_align_ptr(void *ptr, unsigned size); 57extern void *edac_align_ptr(void *ptr, unsigned size);
56 58
57/* 59/*
@@ -64,6 +66,10 @@ extern int edac_sysfs_pci_setup(void);
64extern void edac_sysfs_pci_teardown(void); 66extern void edac_sysfs_pci_teardown(void);
65extern int edac_pci_get_check_errors(void); 67extern int edac_pci_get_check_errors(void);
66extern int edac_pci_get_poll_msec(void); 68extern int edac_pci_get_poll_msec(void);
69extern void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci);
70extern void edac_pci_handle_pe(struct edac_pci_ctl_info *pci, const char *msg);
71extern void edac_pci_handle_npe(struct edac_pci_ctl_info *pci,
72 const char *msg);
67#else /* CONFIG_PCI */ 73#else /* CONFIG_PCI */
68/* pre-process these away */ 74/* pre-process these away */
69#define edac_pci_do_parity_check() 75#define edac_pci_do_parity_check()
@@ -72,6 +78,8 @@ extern int edac_pci_get_poll_msec(void);
72#define edac_sysfs_pci_teardown() 78#define edac_sysfs_pci_teardown()
73#define edac_pci_get_check_errors() 79#define edac_pci_get_check_errors()
74#define edac_pci_get_poll_msec() 80#define edac_pci_get_poll_msec()
81#define edac_pci_handle_pe()
82#define edac_pci_handle_npe()
75#endif /* CONFIG_PCI */ 83#endif /* CONFIG_PCI */
76 84
77#endif /* __EDAC_MODULE_H__ */ 85#endif /* __EDAC_MODULE_H__ */
diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
index d9cd5e048cee..5dee9f50414b 100644
--- a/drivers/edac/edac_pci.c
+++ b/drivers/edac/edac_pci.c
@@ -31,20 +31,12 @@
31static DEFINE_MUTEX(edac_pci_ctls_mutex); 31static DEFINE_MUTEX(edac_pci_ctls_mutex);
32static struct list_head edac_pci_list = LIST_HEAD_INIT(edac_pci_list); 32static struct list_head edac_pci_list = LIST_HEAD_INIT(edac_pci_list);
33 33
34static inline void edac_lock_pci_list(void)
35{
36 mutex_lock(&edac_pci_ctls_mutex);
37}
38
39static inline void edac_unlock_pci_list(void)
40{
41 mutex_unlock(&edac_pci_ctls_mutex);
42}
43
44/* 34/*
45 * The alloc() and free() functions for the 'edac_pci' control info 35 * edac_pci_alloc_ctl_info
46 * structure. The chip driver will allocate one of these for each 36 *
47 * edac_pci it is going to control/register with the EDAC CORE. 37 * The alloc() function for the 'edac_pci' control info
38 * structure. The chip driver will allocate one of these for each
39 * edac_pci it is going to control/register with the EDAC CORE.
48 */ 40 */
49struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt, 41struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
50 const char *edac_pci_name) 42 const char *edac_pci_name)
@@ -53,47 +45,59 @@ struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
53 void *pvt; 45 void *pvt;
54 unsigned int size; 46 unsigned int size;
55 47
48 debugf1("%s()\n", __func__);
49
56 pci = (struct edac_pci_ctl_info *)0; 50 pci = (struct edac_pci_ctl_info *)0;
57 pvt = edac_align_ptr(&pci[1], sz_pvt); 51 pvt = edac_align_ptr(&pci[1], sz_pvt);
58 size = ((unsigned long)pvt) + sz_pvt; 52 size = ((unsigned long)pvt) + sz_pvt;
59 53
60 if ((pci = kzalloc(size, GFP_KERNEL)) == NULL) 54 /* Alloc the needed control struct memory */
55 pci = kzalloc(size, GFP_KERNEL);
56 if (pci == NULL)
61 return NULL; 57 return NULL;
62 58
59 /* Now much private space */
63 pvt = sz_pvt ? ((char *)pci) + ((unsigned long)pvt) : NULL; 60 pvt = sz_pvt ? ((char *)pci) + ((unsigned long)pvt) : NULL;
64 61
65 pci->pvt_info = pvt; 62 pci->pvt_info = pvt;
66
67 pci->op_state = OP_ALLOC; 63 pci->op_state = OP_ALLOC;
68 64
69 snprintf(pci->name, strlen(edac_pci_name) + 1, "%s", edac_pci_name); 65 snprintf(pci->name, strlen(edac_pci_name) + 1, "%s", edac_pci_name);
70 66
71 return pci; 67 return pci;
72} 68}
73
74EXPORT_SYMBOL_GPL(edac_pci_alloc_ctl_info); 69EXPORT_SYMBOL_GPL(edac_pci_alloc_ctl_info);
75 70
76/* 71/*
77 * edac_pci_free_ctl_info() 72 * edac_pci_free_ctl_info()
78 * frees the memory allocated by edac_pci_alloc_ctl_info() function 73 *
74 * Last action on the pci control structure.
75 *
76 * call the remove sysfs informaton, which will unregister
77 * this control struct's kobj. When that kobj's ref count
78 * goes to zero, its release function will be call and then
79 * kfree() the memory.
79 */ 80 */
80void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci) 81void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci)
81{ 82{
82 kfree(pci); 83 debugf1("%s()\n", __func__);
83}
84 84
85 edac_pci_remove_sysfs(pci);
86}
85EXPORT_SYMBOL_GPL(edac_pci_free_ctl_info); 87EXPORT_SYMBOL_GPL(edac_pci_free_ctl_info);
86 88
87/* 89/*
88 * find_edac_pci_by_dev() 90 * find_edac_pci_by_dev()
89 * scans the edac_pci list for a specific 'struct device *' 91 * scans the edac_pci list for a specific 'struct device *'
92 *
93 * return NULL if not found, or return control struct pointer
90 */ 94 */
91static struct edac_pci_ctl_info *find_edac_pci_by_dev(struct device *dev) 95static struct edac_pci_ctl_info *find_edac_pci_by_dev(struct device *dev)
92{ 96{
93 struct edac_pci_ctl_info *pci; 97 struct edac_pci_ctl_info *pci;
94 struct list_head *item; 98 struct list_head *item;
95 99
96 debugf3("%s()\n", __func__); 100 debugf1("%s()\n", __func__);
97 101
98 list_for_each(item, &edac_pci_list) { 102 list_for_each(item, &edac_pci_list) {
99 pci = list_entry(item, struct edac_pci_ctl_info, link); 103 pci = list_entry(item, struct edac_pci_ctl_info, link);
@@ -118,10 +122,13 @@ static int add_edac_pci_to_global_list(struct edac_pci_ctl_info *pci)
118 struct list_head *item, *insert_before; 122 struct list_head *item, *insert_before;
119 struct edac_pci_ctl_info *rover; 123 struct edac_pci_ctl_info *rover;
120 124
125 debugf1("%s()\n", __func__);
126
121 insert_before = &edac_pci_list; 127 insert_before = &edac_pci_list;
122 128
123 /* Determine if already on the list */ 129 /* Determine if already on the list */
124 if (unlikely((rover = find_edac_pci_by_dev(pci->dev)) != NULL)) 130 rover = find_edac_pci_by_dev(pci->dev);
131 if (unlikely(rover != NULL))
125 goto fail0; 132 goto fail0;
126 133
127 /* Insert in ascending order by 'pci_idx', so find position */ 134 /* Insert in ascending order by 'pci_idx', so find position */
@@ -157,6 +164,8 @@ fail1:
157 164
158/* 165/*
159 * complete_edac_pci_list_del 166 * complete_edac_pci_list_del
167 *
168 * RCU completion callback to indicate item is deleted
160 */ 169 */
161static void complete_edac_pci_list_del(struct rcu_head *head) 170static void complete_edac_pci_list_del(struct rcu_head *head)
162{ 171{
@@ -169,6 +178,8 @@ static void complete_edac_pci_list_del(struct rcu_head *head)
169 178
170/* 179/*
171 * del_edac_pci_from_global_list 180 * del_edac_pci_from_global_list
181 *
182 * remove the PCI control struct from the global list
172 */ 183 */
173static void del_edac_pci_from_global_list(struct edac_pci_ctl_info *pci) 184static void del_edac_pci_from_global_list(struct edac_pci_ctl_info *pci)
174{ 185{
@@ -207,35 +218,52 @@ struct edac_pci_ctl_info *edac_pci_find(int idx)
207 218
208 return NULL; 219 return NULL;
209} 220}
210
211EXPORT_SYMBOL_GPL(edac_pci_find); 221EXPORT_SYMBOL_GPL(edac_pci_find);
212 222
213/* 223/*
214 * edac_pci_workq_function() 224 * edac_pci_workq_function()
215 * performs the operation scheduled by a workq request 225 *
226 * periodic function that performs the operation
227 * scheduled by a workq request, for a given PCI control struct
216 */ 228 */
217static void edac_pci_workq_function(struct work_struct *work_req) 229static void edac_pci_workq_function(struct work_struct *work_req)
218{ 230{
219 struct delayed_work *d_work = (struct delayed_work *)work_req; 231 struct delayed_work *d_work = (struct delayed_work *)work_req;
220 struct edac_pci_ctl_info *pci = to_edac_pci_ctl_work(d_work); 232 struct edac_pci_ctl_info *pci = to_edac_pci_ctl_work(d_work);
233 int msec;
234 unsigned long delay;
221 235
222 edac_lock_pci_list(); 236 debugf3("%s() checking\n", __func__);
223 237
224 if ((pci->op_state == OP_RUNNING_POLL) && 238 mutex_lock(&edac_pci_ctls_mutex);
225 (pci->edac_check != NULL) && (edac_pci_get_check_errors()))
226 pci->edac_check(pci);
227 239
228 edac_unlock_pci_list(); 240 if (pci->op_state == OP_RUNNING_POLL) {
241 /* we might be in POLL mode, but there may NOT be a poll func
242 */
243 if ((pci->edac_check != NULL) && edac_pci_get_check_errors())
244 pci->edac_check(pci);
245
246 /* if we are on a one second period, then use round */
247 msec = edac_pci_get_poll_msec();
248 if (msec == 1000)
249 delay = round_jiffies(msecs_to_jiffies(msec));
250 else
251 delay = msecs_to_jiffies(msec);
252
253 /* Reschedule only if we are in POLL mode */
254 queue_delayed_work(edac_workqueue, &pci->work, delay);
255 }
229 256
230 /* Reschedule */ 257 mutex_unlock(&edac_pci_ctls_mutex);
231 queue_delayed_work(edac_workqueue, &pci->work,
232 msecs_to_jiffies(edac_pci_get_poll_msec()));
233} 258}
234 259
235/* 260/*
236 * edac_pci_workq_setup() 261 * edac_pci_workq_setup()
237 * initialize a workq item for this edac_pci instance 262 * initialize a workq item for this edac_pci instance
238 * passing in the new delay period in msec 263 * passing in the new delay period in msec
264 *
265 * locking model:
266 * called when 'edac_pci_ctls_mutex' is locked
239 */ 267 */
240static void edac_pci_workq_setup(struct edac_pci_ctl_info *pci, 268static void edac_pci_workq_setup(struct edac_pci_ctl_info *pci,
241 unsigned int msec) 269 unsigned int msec)
@@ -255,6 +283,8 @@ static void edac_pci_workq_teardown(struct edac_pci_ctl_info *pci)
255{ 283{
256 int status; 284 int status;
257 285
286 debugf0("%s()\n", __func__);
287
258 status = cancel_delayed_work(&pci->work); 288 status = cancel_delayed_work(&pci->work);
259 if (status == 0) 289 if (status == 0)
260 flush_workqueue(edac_workqueue); 290 flush_workqueue(edac_workqueue);
@@ -262,19 +292,25 @@ static void edac_pci_workq_teardown(struct edac_pci_ctl_info *pci)
262 292
263/* 293/*
264 * edac_pci_reset_delay_period 294 * edac_pci_reset_delay_period
295 *
296 * called with a new period value for the workq period
297 * a) stop current workq timer
298 * b) restart workq timer with new value
265 */ 299 */
266void edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci, 300void edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci,
267 unsigned long value) 301 unsigned long value)
268{ 302{
269 edac_lock_pci_list(); 303 debugf0("%s()\n", __func__);
270 304
271 edac_pci_workq_teardown(pci); 305 edac_pci_workq_teardown(pci);
272 306
307 /* need to lock for the setup */
308 mutex_lock(&edac_pci_ctls_mutex);
309
273 edac_pci_workq_setup(pci, value); 310 edac_pci_workq_setup(pci, value);
274 311
275 edac_unlock_pci_list(); 312 mutex_unlock(&edac_pci_ctls_mutex);
276} 313}
277
278EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period); 314EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
279 315
280/* 316/*
@@ -294,14 +330,13 @@ int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx)
294 debugf0("%s()\n", __func__); 330 debugf0("%s()\n", __func__);
295 331
296 pci->pci_idx = edac_idx; 332 pci->pci_idx = edac_idx;
333 pci->start_time = jiffies;
297 334
298 edac_lock_pci_list(); 335 mutex_lock(&edac_pci_ctls_mutex);
299 336
300 if (add_edac_pci_to_global_list(pci)) 337 if (add_edac_pci_to_global_list(pci))
301 goto fail0; 338 goto fail0;
302 339
303 pci->start_time = jiffies;
304
305 if (edac_pci_create_sysfs(pci)) { 340 if (edac_pci_create_sysfs(pci)) {
306 edac_pci_printk(pci, KERN_WARNING, 341 edac_pci_printk(pci, KERN_WARNING,
307 "failed to create sysfs pci\n"); 342 "failed to create sysfs pci\n");
@@ -323,16 +358,16 @@ int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx)
323 pci->ctl_name, 358 pci->ctl_name,
324 dev_name(pci), edac_op_state_to_string(pci->op_state)); 359 dev_name(pci), edac_op_state_to_string(pci->op_state));
325 360
326 edac_unlock_pci_list(); 361 mutex_unlock(&edac_pci_ctls_mutex);
327 return 0; 362 return 0;
328 363
364 /* error unwind stack */
329fail1: 365fail1:
330 del_edac_pci_from_global_list(pci); 366 del_edac_pci_from_global_list(pci);
331fail0: 367fail0:
332 edac_unlock_pci_list(); 368 mutex_unlock(&edac_pci_ctls_mutex);
333 return 1; 369 return 1;
334} 370}
335
336EXPORT_SYMBOL_GPL(edac_pci_add_device); 371EXPORT_SYMBOL_GPL(edac_pci_add_device);
337 372
338/* 373/*
@@ -354,22 +389,25 @@ struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev)
354 389
355 debugf0("%s()\n", __func__); 390 debugf0("%s()\n", __func__);
356 391
357 edac_lock_pci_list(); 392 mutex_lock(&edac_pci_ctls_mutex);
358 393
359 if ((pci = find_edac_pci_by_dev(dev)) == NULL) { 394 /* ensure the control struct is on the global list
360 edac_unlock_pci_list(); 395 * if not, then leave
396 */
397 pci = find_edac_pci_by_dev(dev);
398 if (pci == NULL) {
399 mutex_unlock(&edac_pci_ctls_mutex);
361 return NULL; 400 return NULL;
362 } 401 }
363 402
364 pci->op_state = OP_OFFLINE; 403 pci->op_state = OP_OFFLINE;
365 404
366 edac_pci_workq_teardown(pci);
367
368 edac_pci_remove_sysfs(pci);
369
370 del_edac_pci_from_global_list(pci); 405 del_edac_pci_from_global_list(pci);
371 406
372 edac_unlock_pci_list(); 407 mutex_unlock(&edac_pci_ctls_mutex);
408
409 /* stop the workq timer */
410 edac_pci_workq_teardown(pci);
373 411
374 edac_printk(KERN_INFO, EDAC_PCI, 412 edac_printk(KERN_INFO, EDAC_PCI,
375 "Removed device %d for %s %s: DEV %s\n", 413 "Removed device %d for %s %s: DEV %s\n",
@@ -377,14 +415,20 @@ struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev)
377 415
378 return pci; 416 return pci;
379} 417}
380
381EXPORT_SYMBOL_GPL(edac_pci_del_device); 418EXPORT_SYMBOL_GPL(edac_pci_del_device);
382 419
420/*
421 * edac_pci_generic_check
422 *
423 * a Generic parity check API
424 */
383void edac_pci_generic_check(struct edac_pci_ctl_info *pci) 425void edac_pci_generic_check(struct edac_pci_ctl_info *pci)
384{ 426{
427 debugf4("%s()\n", __func__);
385 edac_pci_do_parity_check(); 428 edac_pci_do_parity_check();
386} 429}
387 430
431/* free running instance index counter */
388static int edac_pci_idx; 432static int edac_pci_idx;
389#define EDAC_PCI_GENCTL_NAME "EDAC PCI controller" 433#define EDAC_PCI_GENCTL_NAME "EDAC PCI controller"
390 434
@@ -392,6 +436,17 @@ struct edac_pci_gen_data {
392 int edac_idx; 436 int edac_idx;
393}; 437};
394 438
439/*
440 * edac_pci_create_generic_ctl
441 *
442 * A generic constructor for a PCI parity polling device
443 * Some systems have more than one domain of PCI busses.
444 * For systems with one domain, then this API will
445 * provide for a generic poller.
446 *
447 * This routine calls the edac_pci_alloc_ctl_info() for
448 * the generic device, with default values
449 */
395struct edac_pci_ctl_info *edac_pci_create_generic_ctl(struct device *dev, 450struct edac_pci_ctl_info *edac_pci_create_generic_ctl(struct device *dev,
396 const char *mod_name) 451 const char *mod_name)
397{ 452{
@@ -421,13 +476,18 @@ struct edac_pci_ctl_info *edac_pci_create_generic_ctl(struct device *dev,
421 476
422 return pci; 477 return pci;
423} 478}
424
425EXPORT_SYMBOL_GPL(edac_pci_create_generic_ctl); 479EXPORT_SYMBOL_GPL(edac_pci_create_generic_ctl);
426 480
481/*
482 * edac_pci_release_generic_ctl
483 *
484 * The release function of a generic EDAC PCI polling device
485 */
427void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci) 486void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci)
428{ 487{
488 debugf0("%s() pci mod=%s\n", __func__, pci->mod_name);
489
429 edac_pci_del_device(pci->dev); 490 edac_pci_del_device(pci->dev);
430 edac_pci_free_ctl_info(pci); 491 edac_pci_free_ctl_info(pci);
431} 492}
432
433EXPORT_SYMBOL_GPL(edac_pci_release_generic_ctl); 493EXPORT_SYMBOL_GPL(edac_pci_release_generic_ctl);
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index fac94cae2c3d..69f5dddabddf 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -13,22 +13,25 @@
13#include "edac_core.h" 13#include "edac_core.h"
14#include "edac_module.h" 14#include "edac_module.h"
15 15
16/* Turn off this whole feature if PCI is not configured */
16#ifdef CONFIG_PCI 17#ifdef CONFIG_PCI
17 18
18#define EDAC_PCI_SYMLINK "device" 19#define EDAC_PCI_SYMLINK "device"
19 20
20static int check_pci_errors; /* default YES check PCI parity */ 21/* data variables exported via sysfs */
21static int edac_pci_panic_on_pe; /* default no panic on PCI Parity */ 22static int check_pci_errors; /* default NO check PCI parity */
22static int edac_pci_log_pe = 1; /* log PCI parity errors */ 23static int edac_pci_panic_on_pe; /* default NO panic on PCI Parity */
24static int edac_pci_log_pe = 1; /* log PCI parity errors */
23static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */ 25static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
26static int edac_pci_poll_msec = 1000; /* one second workq period */
27
24static atomic_t pci_parity_count = ATOMIC_INIT(0); 28static atomic_t pci_parity_count = ATOMIC_INIT(0);
25static atomic_t pci_nonparity_count = ATOMIC_INIT(0); 29static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
26static int edac_pci_poll_msec = 1000;
27 30
28static struct kobject edac_pci_kobj; /* /sys/devices/system/edac/pci */ 31static struct kobject edac_pci_top_main_kobj;
29static struct completion edac_pci_kobj_complete;
30static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0); 32static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
31 33
34/* getter functions for the data variables */
32int edac_pci_get_check_errors(void) 35int edac_pci_get_check_errors(void)
33{ 36{
34 return check_pci_errors; 37 return check_pci_errors;
@@ -74,17 +77,22 @@ static void edac_pci_instance_release(struct kobject *kobj)
74{ 77{
75 struct edac_pci_ctl_info *pci; 78 struct edac_pci_ctl_info *pci;
76 79
77 debugf1("%s()\n", __func__); 80 debugf0("%s()\n", __func__);
78 81
82 /* Form pointer to containing struct, the pci control struct */
79 pci = to_instance(kobj); 83 pci = to_instance(kobj);
80 complete(&pci->kobj_complete); 84
85 /* decrement reference count on top main kobj */
86 kobject_put(&edac_pci_top_main_kobj);
87
88 kfree(pci); /* Free the control struct */
81} 89}
82 90
83/* instance specific attribute structure */ 91/* instance specific attribute structure */
84struct instance_attribute { 92struct instance_attribute {
85 struct attribute attr; 93 struct attribute attr;
86 ssize_t(*show) (struct edac_pci_ctl_info *, char *); 94 ssize_t(*show) (struct edac_pci_ctl_info *, char *);
87 ssize_t(*store) (struct edac_pci_ctl_info *, const char *, size_t); 95 ssize_t(*store) (struct edac_pci_ctl_info *, const char *, size_t);
88}; 96};
89 97
90/* Function to 'show' fields from the edac_pci 'instance' structure */ 98/* Function to 'show' fields from the edac_pci 'instance' structure */
@@ -112,6 +120,7 @@ static ssize_t edac_pci_instance_store(struct kobject *kobj,
112 return -EIO; 120 return -EIO;
113} 121}
114 122
123/* fs_ops table */
115static struct sysfs_ops pci_instance_ops = { 124static struct sysfs_ops pci_instance_ops = {
116 .show = edac_pci_instance_show, 125 .show = edac_pci_instance_show,
117 .store = edac_pci_instance_store 126 .store = edac_pci_instance_store
@@ -134,48 +143,82 @@ static struct instance_attribute *pci_instance_attr[] = {
134 NULL 143 NULL
135}; 144};
136 145
137/* the ktype for pci instance */ 146/* the ktype for a pci instance */
138static struct kobj_type ktype_pci_instance = { 147static struct kobj_type ktype_pci_instance = {
139 .release = edac_pci_instance_release, 148 .release = edac_pci_instance_release,
140 .sysfs_ops = &pci_instance_ops, 149 .sysfs_ops = &pci_instance_ops,
141 .default_attrs = (struct attribute **)pci_instance_attr, 150 .default_attrs = (struct attribute **)pci_instance_attr,
142}; 151};
143 152
153/*
154 * edac_pci_create_instance_kobj
155 *
156 * construct one EDAC PCI instance's kobject for use
157 */
144static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx) 158static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
145{ 159{
160 struct kobject *main_kobj;
146 int err; 161 int err;
147 162
148 pci->kobj.parent = &edac_pci_kobj; 163 debugf0("%s()\n", __func__);
164
165 /* Set the parent and the instance's ktype */
166 pci->kobj.parent = &edac_pci_top_main_kobj;
149 pci->kobj.ktype = &ktype_pci_instance; 167 pci->kobj.ktype = &ktype_pci_instance;
150 168
151 err = kobject_set_name(&pci->kobj, "pci%d", idx); 169 err = kobject_set_name(&pci->kobj, "pci%d", idx);
152 if (err) 170 if (err)
153 return err; 171 return err;
154 172
173 /* First bump the ref count on the top main kobj, which will
174 * track the number of PCI instances we have, and thus nest
175 * properly on keeping the module loaded
176 */
177 main_kobj = kobject_get(&edac_pci_top_main_kobj);
178 if (!main_kobj) {
179 err = -ENODEV;
180 goto error_out;
181 }
182
183 /* And now register this new kobject under the main kobj */
155 err = kobject_register(&pci->kobj); 184 err = kobject_register(&pci->kobj);
156 if (err != 0) { 185 if (err != 0) {
157 debugf2("%s() failed to register instance pci%d\n", 186 debugf2("%s() failed to register instance pci%d\n",
158 __func__, idx); 187 __func__, idx);
159 return err; 188 kobject_put(&edac_pci_top_main_kobj);
189 goto error_out;
160 } 190 }
161 191
162 debugf1("%s() Register instance 'pci%d' kobject\n", __func__, idx); 192 debugf1("%s() Register instance 'pci%d' kobject\n", __func__, idx);
163 193
164 return 0; 194 return 0;
195
196 /* Error unwind statck */
197error_out:
198 return err;
165} 199}
166 200
167static void 201/*
168edac_pci_delete_instance_kobj(struct edac_pci_ctl_info *pci, int idx) 202 * edac_pci_unregister_sysfs_instance_kobj
203 *
204 * unregister the kobj for the EDAC PCI instance
205 */
206void edac_pci_unregister_sysfs_instance_kobj(struct edac_pci_ctl_info *pci)
169{ 207{
170 init_completion(&pci->kobj_complete); 208 debugf0("%s()\n", __func__);
209
210 /* Unregister the instance kobject and allow its release
211 * function release the main reference count and then
212 * kfree the memory
213 */
171 kobject_unregister(&pci->kobj); 214 kobject_unregister(&pci->kobj);
172 wait_for_completion(&pci->kobj_complete);
173} 215}
174 216
175/***************************** EDAC PCI sysfs root **********************/ 217/***************************** EDAC PCI sysfs root **********************/
176#define to_edacpci(k) container_of(k, struct edac_pci_ctl_info, kobj) 218#define to_edacpci(k) container_of(k, struct edac_pci_ctl_info, kobj)
177#define to_edacpci_attr(a) container_of(a, struct edac_pci_attr, attr) 219#define to_edacpci_attr(a) container_of(a, struct edac_pci_attr, attr)
178 220
221/* simple show/store functions for attributes */
179static ssize_t edac_pci_int_show(void *ptr, char *buffer) 222static ssize_t edac_pci_int_show(void *ptr, char *buffer)
180{ 223{
181 int *value = ptr; 224 int *value = ptr;
@@ -267,118 +310,189 @@ static struct edac_pci_dev_attribute *edac_pci_attr[] = {
267 NULL, 310 NULL,
268}; 311};
269 312
270/* No memory to release */ 313/*
271static void edac_pci_release(struct kobject *kobj) 314 * edac_pci_release_main_kobj
315 *
316 * This release function is called when the reference count to the
317 * passed kobj goes to zero.
318 *
319 * This kobj is the 'main' kobject that EDAC PCI instances
320 * link to, and thus provide for proper nesting counts
321 */
322static void edac_pci_release_main_kobj(struct kobject *kobj)
272{ 323{
273 struct edac_pci_ctl_info *pci;
274 324
275 pci = to_edacpci(kobj); 325 debugf0("%s() here to module_put(THIS_MODULE)\n", __func__);
276 326
277 debugf1("%s()\n", __func__); 327 /* last reference to top EDAC PCI kobject has been removed,
278 complete(&pci->kobj_complete); 328 * NOW release our ref count on the core module
329 */
330 module_put(THIS_MODULE);
279} 331}
280 332
281static struct kobj_type ktype_edac_pci = { 333/* ktype struct for the EDAC PCI main kobj */
282 .release = edac_pci_release, 334static struct kobj_type ktype_edac_pci_main_kobj = {
335 .release = edac_pci_release_main_kobj,
283 .sysfs_ops = &edac_pci_sysfs_ops, 336 .sysfs_ops = &edac_pci_sysfs_ops,
284 .default_attrs = (struct attribute **)edac_pci_attr, 337 .default_attrs = (struct attribute **)edac_pci_attr,
285}; 338};
286 339
287/** 340/**
288 * edac_sysfs_pci_setup() 341 * edac_pci_main_kobj_setup()
289 * 342 *
290 * setup the sysfs for EDAC PCI attributes 343 * setup the sysfs for EDAC PCI attributes
291 * assumes edac_class has already been initialized 344 * assumes edac_class has already been initialized
292 */ 345 */
293int edac_pci_register_main_kobj(void) 346int edac_pci_main_kobj_setup(void)
294{ 347{
295 int err; 348 int err;
296 struct sysdev_class *edac_class; 349 struct sysdev_class *edac_class;
297 350
298 debugf1("%s()\n", __func__); 351 debugf0("%s()\n", __func__);
352
353 /* check and count if we have already created the main kobject */
354 if (atomic_inc_return(&edac_pci_sysfs_refcount) != 1)
355 return 0;
299 356
357 /* First time, so create the main kobject and its
358 * controls and atributes
359 */
300 edac_class = edac_get_edac_class(); 360 edac_class = edac_get_edac_class();
301 if (edac_class == NULL) { 361 if (edac_class == NULL) {
302 debugf1("%s() no edac_class\n", __func__); 362 debugf1("%s() no edac_class\n", __func__);
303 return -ENODEV; 363 err = -ENODEV;
364 goto decrement_count_fail;
304 } 365 }
305 366
306 edac_pci_kobj.ktype = &ktype_edac_pci; 367 /* Need the kobject hook ups, and name setting */
368 edac_pci_top_main_kobj.ktype = &ktype_edac_pci_main_kobj;
369 edac_pci_top_main_kobj.parent = &edac_class->kset.kobj;
307 370
308 edac_pci_kobj.parent = &edac_class->kset.kobj; 371 err = kobject_set_name(&edac_pci_top_main_kobj, "pci");
309
310 err = kobject_set_name(&edac_pci_kobj, "pci");
311 if (err) 372 if (err)
312 return err; 373 goto decrement_count_fail;
374
375 /* Bump the reference count on this module to ensure the
376 * modules isn't unloaded until we deconstruct the top
377 * level main kobj for EDAC PCI
378 */
379 if (!try_module_get(THIS_MODULE)) {
380 debugf1("%s() try_module_get() failed\n", __func__);
381 err = -ENODEV;
382 goto decrement_count_fail;
383 }
313 384
314 /* Instanstiate the pci object */ 385 /* Instanstiate the pci object */
315 /* FIXME: maybe new sysdev_create_subdir() */ 386 /* FIXME: maybe new sysdev_create_subdir() */
316 err = kobject_register(&edac_pci_kobj); 387 err = kobject_register(&edac_pci_top_main_kobj);
317
318 if (err) { 388 if (err) {
319 debugf1("Failed to register '.../edac/pci'\n"); 389 debugf1("Failed to register '.../edac/pci'\n");
320 return err; 390 goto kobject_register_fail;
321 } 391 }
322 392
393 /* At this point, to 'release' the top level kobject
394 * for EDAC PCI, then edac_pci_main_kobj_teardown()
395 * must be used, for resources to be cleaned up properly
396 */
323 debugf1("Registered '.../edac/pci' kobject\n"); 397 debugf1("Registered '.../edac/pci' kobject\n");
324 398
325 return 0; 399 return 0;
400
401 /* Error unwind statck */
402kobject_register_fail:
403 module_put(THIS_MODULE);
404
405decrement_count_fail:
406 /* if are on this error exit, nothing to tear down */
407 atomic_dec(&edac_pci_sysfs_refcount);
408
409 return err;
326} 410}
327 411
328/* 412/*
329 * edac_pci_unregister_main_kobj() 413 * edac_pci_main_kobj_teardown()
330 * 414 *
331 * perform the sysfs teardown for the PCI attributes 415 * if no longer linked (needed) remove the top level EDAC PCI
416 * kobject with its controls and attributes
332 */ 417 */
333void edac_pci_unregister_main_kobj(void) 418static void edac_pci_main_kobj_teardown(void)
334{ 419{
335 debugf0("%s()\n", __func__); 420 debugf0("%s()\n", __func__);
336 init_completion(&edac_pci_kobj_complete); 421
337 kobject_unregister(&edac_pci_kobj); 422 /* Decrement the count and only if no more controller instances
338 wait_for_completion(&edac_pci_kobj_complete); 423 * are connected perform the unregisteration of the top level
424 * main kobj
425 */
426 if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) {
427 debugf0("%s() called kobject_unregister on main kobj\n",
428 __func__);
429 kobject_unregister(&edac_pci_top_main_kobj);
430 }
339} 431}
340 432
433/*
434 *
435 * edac_pci_create_sysfs
436 *
437 * Create the controls/attributes for the specified EDAC PCI device
438 */
341int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci) 439int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci)
342{ 440{
343 int err; 441 int err;
344 struct kobject *edac_kobj = &pci->kobj; 442 struct kobject *edac_kobj = &pci->kobj;
345 443
346 if (atomic_inc_return(&edac_pci_sysfs_refcount) == 1) { 444 debugf0("%s() idx=%d\n", __func__, pci->pci_idx);
347 err = edac_pci_register_main_kobj();
348 if (err) {
349 atomic_dec(&edac_pci_sysfs_refcount);
350 return err;
351 }
352 }
353 445
354 err = edac_pci_create_instance_kobj(pci, pci->pci_idx); 446 /* create the top main EDAC PCI kobject, IF needed */
355 if (err) { 447 err = edac_pci_main_kobj_setup();
356 if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) 448 if (err)
357 edac_pci_unregister_main_kobj(); 449 return err;
358 }
359 450
360 debugf0("%s() idx=%d\n", __func__, pci->pci_idx); 451 /* Create this instance's kobject under the MAIN kobject */
452 err = edac_pci_create_instance_kobj(pci, pci->pci_idx);
453 if (err)
454 goto unregister_cleanup;
361 455
362 err = sysfs_create_link(edac_kobj, &pci->dev->kobj, EDAC_PCI_SYMLINK); 456 err = sysfs_create_link(edac_kobj, &pci->dev->kobj, EDAC_PCI_SYMLINK);
363 if (err) { 457 if (err) {
364 debugf0("%s() sysfs_create_link() returned err= %d\n", 458 debugf0("%s() sysfs_create_link() returned err= %d\n",
365 __func__, err); 459 __func__, err);
366 return err; 460 goto symlink_fail;
367 } 461 }
368 462
369 return 0; 463 return 0;
464
465 /* Error unwind stack */
466symlink_fail:
467 edac_pci_unregister_sysfs_instance_kobj(pci);
468
469unregister_cleanup:
470 edac_pci_main_kobj_teardown();
471
472 return err;
370} 473}
371 474
475/*
476 * edac_pci_remove_sysfs
477 *
478 * remove the controls and attributes for this EDAC PCI device
479 */
372void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci) 480void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci)
373{ 481{
374 debugf0("%s()\n", __func__); 482 debugf0("%s() index=%d\n", __func__, pci->pci_idx);
375
376 edac_pci_delete_instance_kobj(pci, pci->pci_idx);
377 483
484 /* Remove the symlink */
378 sysfs_remove_link(&pci->kobj, EDAC_PCI_SYMLINK); 485 sysfs_remove_link(&pci->kobj, EDAC_PCI_SYMLINK);
379 486
380 if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) 487 /* remove this PCI instance's sysfs entries */
381 edac_pci_unregister_main_kobj(); 488 edac_pci_unregister_sysfs_instance_kobj(pci);
489
490 /* Call the main unregister function, which will determine
491 * if this 'pci' is the last instance.
492 * If it is, the main kobject will be unregistered as a result
493 */
494 debugf0("%s() calling edac_pci_main_kobj_teardown()\n", __func__);
495 edac_pci_main_kobj_teardown();
382} 496}
383 497
384/************************ PCI error handling *************************/ 498/************************ PCI error handling *************************/
@@ -414,13 +528,14 @@ static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
414 return status; 528 return status;
415} 529}
416 530
417typedef void (*pci_parity_check_fn_t) (struct pci_dev * dev);
418 531
419/* Clear any PCI parity errors logged by this device. */ 532/* Clear any PCI parity errors logged by this device. */
420static void edac_pci_dev_parity_clear(struct pci_dev *dev) 533static void edac_pci_dev_parity_clear(struct pci_dev *dev)
421{ 534{
422 u8 header_type; 535 u8 header_type;
423 536
537 debugf0("%s()\n", __func__);
538
424 get_pci_parity_status(dev, 0); 539 get_pci_parity_status(dev, 0);
425 540
426 /* read the device TYPE, looking for bridges */ 541 /* read the device TYPE, looking for bridges */
@@ -433,17 +548,28 @@ static void edac_pci_dev_parity_clear(struct pci_dev *dev)
433/* 548/*
434 * PCI Parity polling 549 * PCI Parity polling
435 * 550 *
551 * Fucntion to retrieve the current parity status
552 * and decode it
553 *
436 */ 554 */
437static void edac_pci_dev_parity_test(struct pci_dev *dev) 555static void edac_pci_dev_parity_test(struct pci_dev *dev)
438{ 556{
557 unsigned long flags;
439 u16 status; 558 u16 status;
440 u8 header_type; 559 u8 header_type;
441 560
442 /* read the STATUS register on this device 561 /* stop any interrupts until we can acquire the status */
443 */ 562 local_irq_save(flags);
563
564 /* read the STATUS register on this device */
444 status = get_pci_parity_status(dev, 0); 565 status = get_pci_parity_status(dev, 0);
445 566
446 debugf2("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id); 567 /* read the device TYPE, looking for bridges */
568 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
569
570 local_irq_restore(flags);
571
572 debugf4("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id);
447 573
448 /* check the status reg for errors */ 574 /* check the status reg for errors */
449 if (status) { 575 if (status) {
@@ -471,16 +597,14 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
471 } 597 }
472 } 598 }
473 599
474 /* read the device TYPE, looking for bridges */
475 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
476 600
477 debugf2("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id); 601 debugf4("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id);
478 602
479 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 603 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
480 /* On bridges, need to examine secondary status register */ 604 /* On bridges, need to examine secondary status register */
481 status = get_pci_parity_status(dev, 1); 605 status = get_pci_parity_status(dev, 1);
482 606
483 debugf2("PCI SEC_STATUS= 0x%04x %s\n", status, dev->dev.bus_id); 607 debugf4("PCI SEC_STATUS= 0x%04x %s\n", status, dev->dev.bus_id);
484 608
485 /* check the secondary status reg for errors */ 609 /* check the secondary status reg for errors */
486 if (status) { 610 if (status) {
@@ -510,9 +634,12 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
510 } 634 }
511} 635}
512 636
637/* reduce some complexity in definition of the iterator */
638typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev);
639
513/* 640/*
514 * pci_dev parity list iterator 641 * pci_dev parity list iterator
515 * Scan the PCI device list for one iteration, looking for SERRORs 642 * Scan the PCI device list for one pass, looking for SERRORs
516 * Master Parity ERRORS or Parity ERRORs on primary or secondary devices 643 * Master Parity ERRORS or Parity ERRORs on primary or secondary devices
517 */ 644 */
518static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn) 645static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
@@ -535,22 +662,22 @@ static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
535 */ 662 */
536void edac_pci_do_parity_check(void) 663void edac_pci_do_parity_check(void)
537{ 664{
538 unsigned long flags;
539 int before_count; 665 int before_count;
540 666
541 debugf3("%s()\n", __func__); 667 debugf3("%s()\n", __func__);
542 668
669 /* if policy has PCI check off, leave now */
543 if (!check_pci_errors) 670 if (!check_pci_errors)
544 return; 671 return;
545 672
546 before_count = atomic_read(&pci_parity_count); 673 before_count = atomic_read(&pci_parity_count);
547 674
548 /* scan all PCI devices looking for a Parity Error on devices and 675 /* scan all PCI devices looking for a Parity Error on devices and
549 * bridges 676 * bridges.
677 * The iterator calls pci_get_device() which might sleep, thus
678 * we cannot disable interrupts in this scan.
550 */ 679 */
551 local_irq_save(flags);
552 edac_pci_dev_parity_iterator(edac_pci_dev_parity_test); 680 edac_pci_dev_parity_iterator(edac_pci_dev_parity_test);
553 local_irq_restore(flags);
554 681
555 /* Only if operator has selected panic on PCI Error */ 682 /* Only if operator has selected panic on PCI Error */
556 if (edac_pci_get_panic_on_pe()) { 683 if (edac_pci_get_panic_on_pe()) {
@@ -560,6 +687,12 @@ void edac_pci_do_parity_check(void)
560 } 687 }
561} 688}
562 689
690/*
691 * edac_pci_clear_parity_errors
692 *
693 * function to perform an iteration over the PCI devices
694 * and clearn their current status
695 */
563void edac_pci_clear_parity_errors(void) 696void edac_pci_clear_parity_errors(void)
564{ 697{
565 /* Clear any PCI bus parity errors that devices initially have logged 698 /* Clear any PCI bus parity errors that devices initially have logged
@@ -567,6 +700,12 @@ void edac_pci_clear_parity_errors(void)
567 */ 700 */
568 edac_pci_dev_parity_iterator(edac_pci_dev_parity_clear); 701 edac_pci_dev_parity_iterator(edac_pci_dev_parity_clear);
569} 702}
703
704/*
705 * edac_pci_handle_pe
706 *
707 * Called to handle a PARITY ERROR event
708 */
570void edac_pci_handle_pe(struct edac_pci_ctl_info *pci, const char *msg) 709void edac_pci_handle_pe(struct edac_pci_ctl_info *pci, const char *msg)
571{ 710{
572 711
@@ -584,9 +723,14 @@ void edac_pci_handle_pe(struct edac_pci_ctl_info *pci, const char *msg)
584 */ 723 */
585 edac_pci_do_parity_check(); 724 edac_pci_do_parity_check();
586} 725}
587
588EXPORT_SYMBOL_GPL(edac_pci_handle_pe); 726EXPORT_SYMBOL_GPL(edac_pci_handle_pe);
589 727
728
729/*
730 * edac_pci_handle_npe
731 *
732 * Called to handle a NON-PARITY ERROR event
733 */
590void edac_pci_handle_npe(struct edac_pci_ctl_info *pci, const char *msg) 734void edac_pci_handle_npe(struct edac_pci_ctl_info *pci, const char *msg)
591{ 735{
592 736
@@ -604,7 +748,6 @@ void edac_pci_handle_npe(struct edac_pci_ctl_info *pci, const char *msg)
604 */ 748 */
605 edac_pci_do_parity_check(); 749 edac_pci_do_parity_check();
606} 750}
607
608EXPORT_SYMBOL_GPL(edac_pci_handle_npe); 751EXPORT_SYMBOL_GPL(edac_pci_handle_npe);
609 752
610/* 753/*
diff --git a/drivers/edac/i3000_edac.c b/drivers/edac/i3000_edac.c
index 0ecfdc432f87..e895f9f887ab 100644
--- a/drivers/edac/i3000_edac.c
+++ b/drivers/edac/i3000_edac.c
@@ -275,7 +275,7 @@ static int i3000_probe1(struct pci_dev *pdev, int dev_idx)
275 unsigned char *c0dra = dra, *c1dra = &dra[I3000_RANKS_PER_CHANNEL / 2]; 275 unsigned char *c0dra = dra, *c1dra = &dra[I3000_RANKS_PER_CHANNEL / 2];
276 unsigned char *c0drb = drb, *c1drb = &drb[I3000_RANKS_PER_CHANNEL]; 276 unsigned char *c0drb = drb, *c1drb = &drb[I3000_RANKS_PER_CHANNEL];
277 unsigned long mchbar; 277 unsigned long mchbar;
278 void *window; 278 void __iomem *window;
279 279
280 debugf0("MC: %s()\n", __func__); 280 debugf0("MC: %s()\n", __func__);
281 281
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index dbdca6f10e46..192953b29b28 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -520,6 +520,16 @@ config SENSORS_SMSC47B397
520 This driver can also be built as a module. If so, the module 520 This driver can also be built as a module. If so, the module
521 will be called smsc47b397. 521 will be called smsc47b397.
522 522
523config SENSORS_THMC50
524 tristate "Texas Instruments THMC50 / Analog Devices ADM1022"
525 depends on I2C && EXPERIMENTAL
526 help
527 If you say yes here you get support for Texas Instruments THMC50
528 sensor chips and clones: the Analog Devices ADM1022.
529
530 This driver can also be built as a module. If so, the module
531 will be called thmc50.
532
523config SENSORS_VIA686A 533config SENSORS_VIA686A
524 tristate "VIA686A" 534 tristate "VIA686A"
525 depends on PCI 535 depends on PCI
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index 59f81fae40a0..d04f90031ebf 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
56obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o 56obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
57obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o 57obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
58obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o 58obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
59obj-$(CONFIG_SENSORS_THMC50) += thmc50.o
59obj-$(CONFIG_SENSORS_VIA686A) += via686a.o 60obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
60obj-$(CONFIG_SENSORS_VT1211) += vt1211.o 61obj-$(CONFIG_SENSORS_VT1211) += vt1211.o
61obj-$(CONFIG_SENSORS_VT8231) += vt8231.o 62obj-$(CONFIG_SENSORS_VT8231) += vt8231.o
diff --git a/drivers/hwmon/abituguru3.c b/drivers/hwmon/abituguru3.c
index a003d104ca45..cdd8b6dea16d 100644
--- a/drivers/hwmon/abituguru3.c
+++ b/drivers/hwmon/abituguru3.c
@@ -691,8 +691,9 @@ static int abituguru3_read(struct abituguru3_data *data, u8 bank, u8 offset,
691 691
692/* Sensor settings are stored 1 byte per offset with the bytes 692/* Sensor settings are stored 1 byte per offset with the bytes
693 placed add consecutive offsets. */ 693 placed add consecutive offsets. */
694int abituguru3_read_increment_offset(struct abituguru3_data *data, u8 bank, 694static int abituguru3_read_increment_offset(struct abituguru3_data *data,
695 u8 offset, u8 count, u8 *buf, int offset_count) 695 u8 bank, u8 offset, u8 count,
696 u8 *buf, int offset_count)
696{ 697{
697 int i, x; 698 int i, x;
698 699
diff --git a/drivers/hwmon/ams/ams-core.c b/drivers/hwmon/ams/ams-core.c
index 6db973739725..a112a03e8f29 100644
--- a/drivers/hwmon/ams/ams-core.c
+++ b/drivers/hwmon/ams/ams-core.c
@@ -23,7 +23,6 @@
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/module.h>
27#include <asm/pmac_pfunc.h> 26#include <asm/pmac_pfunc.h>
28#include <asm/of_platform.h> 27#include <asm/of_platform.h>
29 28
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index fd1281f42209..941729a131f5 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -79,11 +79,15 @@
79 79
80/* 80/*
81 * Temperature sensors keys (sp78 - 2 bytes). 81 * Temperature sensors keys (sp78 - 2 bytes).
82 * First set for Macbook(Pro), second for Macmini.
83 */ 82 */
84static const char* temperature_sensors_sets[][13] = { 83static const char* temperature_sensors_sets[][13] = {
84/* Set 0: Macbook Pro */
85 { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H", 85 { "TA0P", "TB0T", "TC0D", "TC0P", "TG0H", "TG0P", "TG0T", "Th0H",
86 "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL }, 86 "Th1H", "Tm0P", "Ts0P", "Ts1P", NULL },
87/* Set 1: Macbook set */
88 { "TB0T", "TC0D", "TC0P", "TM0P", "TN0P", "TN1P", "Th0H", "Th0S",
89 "Th1H", "Ts0P", NULL },
90/* Set 2: Macmini set */
87 { "TC0D", "TC0P", NULL } 91 { "TC0D", "TC0P", NULL }
88}; 92};
89 93
@@ -1150,10 +1154,10 @@ static void applesmc_release_accelerometer(void)
1150static __initdata struct dmi_match_data applesmc_dmi_data[] = { 1154static __initdata struct dmi_match_data applesmc_dmi_data[] = {
1151/* MacBook Pro: accelerometer, backlight and temperature set 0 */ 1155/* MacBook Pro: accelerometer, backlight and temperature set 0 */
1152 { .accelerometer = 1, .light = 1, .temperature_set = 0 }, 1156 { .accelerometer = 1, .light = 1, .temperature_set = 0 },
1153/* MacBook: accelerometer and temperature set 0 */ 1157/* MacBook: accelerometer and temperature set 1 */
1154 { .accelerometer = 1, .light = 0, .temperature_set = 0 }, 1158 { .accelerometer = 1, .light = 0, .temperature_set = 1 },
1155/* MacBook: temperature set 1 */ 1159/* MacMini: temperature set 2 */
1156 { .accelerometer = 0, .light = 0, .temperature_set = 1 } 1160 { .accelerometer = 0, .light = 0, .temperature_set = 2 },
1157}; 1161};
1158 1162
1159/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1". 1163/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index be3aaa5d0b91..e9cbc727664d 100644
--- a/drivers/hwmon/dme1737.c
+++ b/drivers/hwmon/dme1737.c
@@ -750,7 +750,7 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
750 res = (data->alarms >> DME1737_BIT_ALARM_TEMP[ix]) & 0x01; 750 res = (data->alarms >> DME1737_BIT_ALARM_TEMP[ix]) & 0x01;
751 break; 751 break;
752 case SYS_TEMP_FAULT: 752 case SYS_TEMP_FAULT:
753 res = (data->temp[ix] == 0x0800); 753 res = (((u16)data->temp[ix] & 0xff00) == 0x8000);
754 break; 754 break;
755 default: 755 default:
756 res = 0; 756 res = 0;
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c
index 19717752cfca..b34b546c68b8 100644
--- a/drivers/hwmon/fscher.c
+++ b/drivers/hwmon/fscher.c
@@ -441,6 +441,8 @@ static struct fscher_data *fscher_update_device(struct device *dev)
441 data->watchdog[2] = fscher_read_value(client, FSCHER_REG_WDOG_CONTROL); 441 data->watchdog[2] = fscher_read_value(client, FSCHER_REG_WDOG_CONTROL);
442 442
443 data->global_event = fscher_read_value(client, FSCHER_REG_EVENT_STATE); 443 data->global_event = fscher_read_value(client, FSCHER_REG_EVENT_STATE);
444 data->global_control = fscher_read_value(client,
445 FSCHER_REG_CONTROL);
444 446
445 data->last_updated = jiffies; 447 data->last_updated = jiffies;
446 data->valid = 1; 448 data->valid = 1;
@@ -599,7 +601,7 @@ static ssize_t set_control(struct i2c_client *client, struct fscher_data *data,
599 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01; 601 unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01;
600 602
601 mutex_lock(&data->update_lock); 603 mutex_lock(&data->update_lock);
602 data->global_control &= ~v; 604 data->global_control = v;
603 fscher_write_value(client, reg, v); 605 fscher_write_value(client, reg, v);
604 mutex_unlock(&data->update_lock); 606 mutex_unlock(&data->update_lock);
605 return count; 607 return count;
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index eff6036e15c0..d75dba9b810b 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -252,7 +252,7 @@ struct it87_data {
252 252
253 253
254static int it87_probe(struct platform_device *pdev); 254static int it87_probe(struct platform_device *pdev);
255static int it87_remove(struct platform_device *pdev); 255static int __devexit it87_remove(struct platform_device *pdev);
256 256
257static int it87_read_value(struct it87_data *data, u8 reg); 257static int it87_read_value(struct it87_data *data, u8 reg);
258static void it87_write_value(struct it87_data *data, u8 reg, u8 value); 258static void it87_write_value(struct it87_data *data, u8 reg, u8 value);
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index 9fb572f03ba5..565c4e679b8d 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -864,7 +864,7 @@ static int __init lm78_isa_found(unsigned short address)
864 /* Determine the chip type */ 864 /* Determine the chip type */
865 outb_p(LM78_REG_CHIPID, address + LM78_ADDR_REG_OFFSET); 865 outb_p(LM78_REG_CHIPID, address + LM78_ADDR_REG_OFFSET);
866 val = inb_p(address + LM78_DATA_REG_OFFSET); 866 val = inb_p(address + LM78_DATA_REG_OFFSET);
867 if (val == 0x00 /* LM78 */ 867 if (val == 0x00 || val == 0x20 /* LM78 */
868 || val == 0x40 /* LM78-J */ 868 || val == 0x40 /* LM78-J */
869 || (val & 0xfe) == 0xc0) /* LM79 */ 869 || (val & 0xfe) == 0xc0) /* LM79 */
870 found = 1; 870 found = 1;
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 48833fff4920..af541d67245d 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -585,7 +585,7 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
585 * those of the man_id register. 585 * those of the man_id register.
586 */ 586 */
587 if (chip_id == man_id 587 if (chip_id == man_id
588 && (address == 0x4F || address == 0x4D) 588 && (address == 0x4C || address == 0x4D)
589 && (reg_config1 & 0x1F) == (man_id & 0x0F) 589 && (reg_config1 & 0x1F) == (man_id & 0x0F)
590 && reg_convrate <= 0x09) { 590 && reg_convrate <= 0x09) {
591 kind = max6657; 591 kind = max6657;
diff --git a/drivers/hwmon/lm93.c b/drivers/hwmon/lm93.c
index 23edf4fe4221..d84f8bf6f284 100644
--- a/drivers/hwmon/lm93.c
+++ b/drivers/hwmon/lm93.c
@@ -234,7 +234,7 @@ struct lm93_data {
234 struct { 234 struct {
235 u8 min; 235 u8 min;
236 u8 max; 236 u8 max;
237 } temp_lim[3]; 237 } temp_lim[4];
238 238
239 /* vin1 - vin16: low and high limits */ 239 /* vin1 - vin16: low and high limits */
240 struct { 240 struct {
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index cb72526c346a..f57c75d59a5b 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -220,7 +220,7 @@ struct pc87360_data {
220 */ 220 */
221 221
222static int pc87360_probe(struct platform_device *pdev); 222static int pc87360_probe(struct platform_device *pdev);
223static int pc87360_remove(struct platform_device *pdev); 223static int __devexit pc87360_remove(struct platform_device *pdev);
224 224
225static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, 225static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
226 u8 reg); 226 u8 reg);
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 83321b28cf0e..92956eb3f3c1 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -187,7 +187,7 @@ struct sis5595_data {
187static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ 187static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */
188 188
189static int sis5595_probe(struct platform_device *pdev); 189static int sis5595_probe(struct platform_device *pdev);
190static int sis5595_remove(struct platform_device *pdev); 190static int __devexit sis5595_remove(struct platform_device *pdev);
191 191
192static int sis5595_read_value(struct sis5595_data *data, u8 reg); 192static int sis5595_read_value(struct sis5595_data *data, u8 reg);
193static void sis5595_write_value(struct sis5595_data *data, u8 reg, u8 value); 193static void sis5595_write_value(struct sis5595_data *data, u8 reg, u8 value);
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 1de2f2be8708..338ee4f54614 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -134,7 +134,7 @@ struct smsc47m1_sio_data {
134 134
135 135
136static int smsc47m1_probe(struct platform_device *pdev); 136static int smsc47m1_probe(struct platform_device *pdev);
137static int smsc47m1_remove(struct platform_device *pdev); 137static int __devexit smsc47m1_remove(struct platform_device *pdev);
138static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, 138static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
139 int init); 139 int init);
140 140
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c
new file mode 100644
index 000000000000..9395b52d9b99
--- /dev/null
+++ b/drivers/hwmon/thmc50.c
@@ -0,0 +1,440 @@
1/*
2 thmc50.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (C) 2007 Krzysztof Helt <krzysztof.h1@wp.pl>
5 Based on 2.4 driver by Frodo Looijaard <frodol@dds.nl> and
6 Philip Edelbrock <phil@netroedge.com>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/
22
23#include <linux/module.h>
24#include <linux/init.h>
25#include <linux/slab.h>
26#include <linux/i2c.h>
27#include <linux/hwmon.h>
28#include <linux/hwmon-sysfs.h>
29#include <linux/err.h>
30#include <linux/mutex.h>
31
32MODULE_LICENSE("GPL");
33
34/* Addresses to scan */
35static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
36
37/* Insmod parameters */
38I2C_CLIENT_INSMOD_2(thmc50, adm1022);
39I2C_CLIENT_MODULE_PARM(adm1022_temp3, "List of adapter,address pairs "
40 "to enable 3rd temperature (ADM1022 only)");
41
42/* Many THMC50 constants specified below */
43
44/* The THMC50 registers */
45#define THMC50_REG_CONF 0x40
46#define THMC50_REG_COMPANY_ID 0x3E
47#define THMC50_REG_DIE_CODE 0x3F
48#define THMC50_REG_ANALOG_OUT 0x19
49
50const static u8 THMC50_REG_TEMP[] = { 0x27, 0x26, 0x20 };
51const static u8 THMC50_REG_TEMP_MIN[] = { 0x3A, 0x38, 0x2C };
52const static u8 THMC50_REG_TEMP_MAX[] = { 0x39, 0x37, 0x2B };
53
54#define THMC50_REG_CONF_nFANOFF 0x20
55
56/* Each client has this additional data */
57struct thmc50_data {
58 struct i2c_client client;
59 struct class_device *class_dev;
60
61 struct mutex update_lock;
62 enum chips type;
63 unsigned long last_updated; /* In jiffies */
64 char has_temp3; /* !=0 if it is ADM1022 in temp3 mode */
65 char valid; /* !=0 if following fields are valid */
66
67 /* Register values */
68 s8 temp_input[3];
69 s8 temp_max[3];
70 s8 temp_min[3];
71 u8 analog_out;
72};
73
74static int thmc50_attach_adapter(struct i2c_adapter *adapter);
75static int thmc50_detach_client(struct i2c_client *client);
76static void thmc50_init_client(struct i2c_client *client);
77static struct thmc50_data *thmc50_update_device(struct device *dev);
78
79static struct i2c_driver thmc50_driver = {
80 .driver = {
81 .name = "thmc50",
82 },
83 .attach_adapter = thmc50_attach_adapter,
84 .detach_client = thmc50_detach_client,
85};
86
87static ssize_t show_analog_out(struct device *dev,
88 struct device_attribute *attr, char *buf)
89{
90 struct thmc50_data *data = thmc50_update_device(dev);
91 return sprintf(buf, "%d\n", data->analog_out);
92}
93
94static ssize_t set_analog_out(struct device *dev,
95 struct device_attribute *attr,
96 const char *buf, size_t count)
97{
98 struct i2c_client *client = to_i2c_client(dev);
99 struct thmc50_data *data = i2c_get_clientdata(client);
100 int tmp = simple_strtoul(buf, NULL, 10);
101 int config;
102
103 mutex_lock(&data->update_lock);
104 data->analog_out = SENSORS_LIMIT(tmp, 0, 255);
105 i2c_smbus_write_byte_data(client, THMC50_REG_ANALOG_OUT,
106 data->analog_out);
107
108 config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF);
109 if (data->analog_out == 0)
110 config &= ~THMC50_REG_CONF_nFANOFF;
111 else
112 config |= THMC50_REG_CONF_nFANOFF;
113 i2c_smbus_write_byte_data(client, THMC50_REG_CONF, config);
114
115 mutex_unlock(&data->update_lock);
116 return count;
117}
118
119/* There is only one PWM mode = DC */
120static ssize_t show_pwm_mode(struct device *dev, struct device_attribute *attr,
121 char *buf)
122{
123 return sprintf(buf, "0\n");
124}
125
126/* Temperatures */
127static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
128 char *buf)
129{
130 int nr = to_sensor_dev_attr(attr)->index;
131 struct thmc50_data *data = thmc50_update_device(dev);
132 return sprintf(buf, "%d\n", data->temp_input[nr] * 1000);
133}
134
135static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
136 char *buf)
137{
138 int nr = to_sensor_dev_attr(attr)->index;
139 struct thmc50_data *data = thmc50_update_device(dev);
140 return sprintf(buf, "%d\n", data->temp_min[nr] * 1000);
141}
142
143static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
144 const char *buf, size_t count)
145{
146 int nr = to_sensor_dev_attr(attr)->index;
147 struct i2c_client *client = to_i2c_client(dev);
148 struct thmc50_data *data = i2c_get_clientdata(client);
149 int val = simple_strtol(buf, NULL, 10);
150
151 mutex_lock(&data->update_lock);
152 data->temp_min[nr] = SENSORS_LIMIT(val / 1000, -128, 127);
153 i2c_smbus_write_byte_data(client, THMC50_REG_TEMP_MIN[nr],
154 data->temp_min[nr]);
155 mutex_unlock(&data->update_lock);
156 return count;
157}
158
159static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
160 char *buf)
161{
162 int nr = to_sensor_dev_attr(attr)->index;
163 struct thmc50_data *data = thmc50_update_device(dev);
164 return sprintf(buf, "%d\n", data->temp_max[nr] * 1000);
165}
166
167static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
168 const char *buf, size_t count)
169{
170 int nr = to_sensor_dev_attr(attr)->index;
171 struct i2c_client *client = to_i2c_client(dev);
172 struct thmc50_data *data = i2c_get_clientdata(client);
173 int val = simple_strtol(buf, NULL, 10);
174
175 mutex_lock(&data->update_lock);
176 data->temp_max[nr] = SENSORS_LIMIT(val / 1000, -128, 127);
177 i2c_smbus_write_byte_data(client, THMC50_REG_TEMP_MAX[nr],
178 data->temp_max[nr]);
179 mutex_unlock(&data->update_lock);
180 return count;
181}
182
183#define temp_reg(offset) \
184static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \
185 NULL, offset - 1); \
186static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
187 show_temp_min, set_temp_min, offset - 1); \
188static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
189 show_temp_max, set_temp_max, offset - 1);
190
191temp_reg(1);
192temp_reg(2);
193temp_reg(3);
194
195static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_analog_out,
196 set_analog_out, 0);
197static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0);
198
199static struct attribute *thmc50_attributes[] = {
200 &sensor_dev_attr_temp1_max.dev_attr.attr,
201 &sensor_dev_attr_temp1_min.dev_attr.attr,
202 &sensor_dev_attr_temp1_input.dev_attr.attr,
203 &sensor_dev_attr_temp2_max.dev_attr.attr,
204 &sensor_dev_attr_temp2_min.dev_attr.attr,
205 &sensor_dev_attr_temp2_input.dev_attr.attr,
206 &sensor_dev_attr_pwm1.dev_attr.attr,
207 &sensor_dev_attr_pwm1_mode.dev_attr.attr,
208 NULL
209};
210
211static const struct attribute_group thmc50_group = {
212 .attrs = thmc50_attributes,
213};
214
215/* for ADM1022 3rd temperature mode */
216static struct attribute *adm1022_attributes[] = {
217 &sensor_dev_attr_temp3_max.dev_attr.attr,
218 &sensor_dev_attr_temp3_min.dev_attr.attr,
219 &sensor_dev_attr_temp3_input.dev_attr.attr,
220 NULL
221};
222
223static const struct attribute_group adm1022_group = {
224 .attrs = adm1022_attributes,
225};
226
227static int thmc50_detect(struct i2c_adapter *adapter, int address, int kind)
228{
229 unsigned company;
230 unsigned revision;
231 unsigned config;
232 struct i2c_client *client;
233 struct thmc50_data *data;
234 struct device *dev;
235 int err = 0;
236 const char *type_name = "";
237
238 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
239 pr_debug("thmc50: detect failed, "
240 "smbus byte data not supported!\n");
241 goto exit;
242 }
243
244 /* OK. For now, we presume we have a valid client. We now create the
245 client structure, even though we cannot fill it completely yet.
246 But it allows us to access thmc50 registers. */
247 if (!(data = kzalloc(sizeof(struct thmc50_data), GFP_KERNEL))) {
248 pr_debug("thmc50: detect failed, kzalloc failed!\n");
249 err = -ENOMEM;
250 goto exit;
251 }
252
253 client = &data->client;
254 i2c_set_clientdata(client, data);
255 client->addr = address;
256 client->adapter = adapter;
257 client->driver = &thmc50_driver;
258 dev = &client->dev;
259
260 pr_debug("thmc50: Probing for THMC50 at 0x%2X on bus %d\n",
261 client->addr, i2c_adapter_id(client->adapter));
262
263 /* Now, we do the remaining detection. */
264 company = i2c_smbus_read_byte_data(client, THMC50_REG_COMPANY_ID);
265 revision = i2c_smbus_read_byte_data(client, THMC50_REG_DIE_CODE);
266 config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF);
267
268 if (kind == 0)
269 kind = thmc50;
270 else if (kind < 0) {
271 err = -ENODEV;
272 if (revision >= 0xc0 && ((config & 0x10) == 0)) {
273 if (company == 0x49) {
274 kind = thmc50;
275 err = 0;
276 } else if (company == 0x41) {
277 kind = adm1022;
278 err = 0;
279 }
280 }
281 }
282 if (err == -ENODEV) {
283 pr_debug("thmc50: Detection of THMC50/ADM1022 failed\n");
284 goto exit_free;
285 }
286 pr_debug("thmc50: Detected %s (version %x, revision %x)\n",
287 type_name, (revision >> 4) - 0xc, revision & 0xf);
288 data->type = kind;
289
290 if (kind == thmc50)
291 type_name = "thmc50";
292 else if (kind == adm1022) {
293 int id = i2c_adapter_id(client->adapter);
294 int i;
295
296 type_name = "adm1022";
297 data->has_temp3 = (config >> 7) & 1; /* config MSB */
298 for (i = 0; i + 1 < adm1022_temp3_num; i += 2)
299 if (adm1022_temp3[i] == id &&
300 adm1022_temp3[i + 1] == address) {
301 /* enable 2nd remote temp */
302 data->has_temp3 = 1;
303 break;
304 }
305 }
306
307 /* Fill in the remaining client fields & put it into the global list */
308 strlcpy(client->name, type_name, I2C_NAME_SIZE);
309 mutex_init(&data->update_lock);
310
311 /* Tell the I2C layer a new client has arrived */
312 if ((err = i2c_attach_client(client)))
313 goto exit_free;
314
315 thmc50_init_client(client);
316
317 /* Register sysfs hooks */
318 if ((err = sysfs_create_group(&client->dev.kobj, &thmc50_group)))
319 goto exit_detach;
320
321 /* Register ADM1022 sysfs hooks */
322 if (data->type == adm1022)
323 if ((err = sysfs_create_group(&client->dev.kobj,
324 &adm1022_group)))
325 goto exit_remove_sysfs_thmc50;
326
327 /* Register a new directory entry with module sensors */
328 data->class_dev = hwmon_device_register(&client->dev);
329 if (IS_ERR(data->class_dev)) {
330 err = PTR_ERR(data->class_dev);
331 goto exit_remove_sysfs;
332 }
333
334 return 0;
335
336exit_remove_sysfs:
337 if (data->type == adm1022)
338 sysfs_remove_group(&client->dev.kobj, &adm1022_group);
339exit_remove_sysfs_thmc50:
340 sysfs_remove_group(&client->dev.kobj, &thmc50_group);
341exit_detach:
342 i2c_detach_client(client);
343exit_free:
344 kfree(data);
345exit:
346 return err;
347}
348
349static int thmc50_attach_adapter(struct i2c_adapter *adapter)
350{
351 if (!(adapter->class & I2C_CLASS_HWMON))
352 return 0;
353 return i2c_probe(adapter, &addr_data, thmc50_detect);
354}
355
356static int thmc50_detach_client(struct i2c_client *client)
357{
358 struct thmc50_data *data = i2c_get_clientdata(client);
359 int err;
360
361 hwmon_device_unregister(data->class_dev);
362 sysfs_remove_group(&client->dev.kobj, &thmc50_group);
363 if (data->type == adm1022)
364 sysfs_remove_group(&client->dev.kobj, &adm1022_group);
365
366 if ((err = i2c_detach_client(client)))
367 return err;
368
369 kfree(data);
370
371 return 0;
372}
373
374static void thmc50_init_client(struct i2c_client *client)
375{
376 struct thmc50_data *data = i2c_get_clientdata(client);
377 int config;
378
379 data->analog_out = i2c_smbus_read_byte_data(client,
380 THMC50_REG_ANALOG_OUT);
381 /* set up to at least 1 */
382 if (data->analog_out == 0) {
383 data->analog_out = 1;
384 i2c_smbus_write_byte_data(client, THMC50_REG_ANALOG_OUT,
385 data->analog_out);
386 }
387 config = i2c_smbus_read_byte_data(client, THMC50_REG_CONF);
388 config |= 0x1; /* start the chip if it is in standby mode */
389 if (data->has_temp3)
390 config |= 0x80; /* enable 2nd remote temp */
391 i2c_smbus_write_byte_data(client, THMC50_REG_CONF, config);
392}
393
394static struct thmc50_data *thmc50_update_device(struct device *dev)
395{
396 struct i2c_client *client = to_i2c_client(dev);
397 struct thmc50_data *data = i2c_get_clientdata(client);
398 int timeout = HZ / 5 + (data->type == thmc50 ? HZ : 0);
399
400 mutex_lock(&data->update_lock);
401
402 if (time_after(jiffies, data->last_updated + timeout)
403 || !data->valid) {
404
405 int temps = data->has_temp3 ? 3 : 2;
406 int i;
407 for (i = 0; i < temps; i++) {
408 data->temp_input[i] = i2c_smbus_read_byte_data(client,
409 THMC50_REG_TEMP[i]);
410 data->temp_max[i] = i2c_smbus_read_byte_data(client,
411 THMC50_REG_TEMP_MAX[i]);
412 data->temp_min[i] = i2c_smbus_read_byte_data(client,
413 THMC50_REG_TEMP_MIN[i]);
414 }
415 data->analog_out =
416 i2c_smbus_read_byte_data(client, THMC50_REG_ANALOG_OUT);
417 data->last_updated = jiffies;
418 data->valid = 1;
419 }
420
421 mutex_unlock(&data->update_lock);
422
423 return data;
424}
425
426static int __init sm_thmc50_init(void)
427{
428 return i2c_add_driver(&thmc50_driver);
429}
430
431static void __exit sm_thmc50_exit(void)
432{
433 i2c_del_driver(&thmc50_driver);
434}
435
436MODULE_AUTHOR("Krzysztof Helt <krzysztof.h1@wp.pl>");
437MODULE_DESCRIPTION("THMC50 driver");
438
439module_init(sm_thmc50_init);
440module_exit(sm_thmc50_exit);
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index 24a6851491d0..696c8a2e5374 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -314,7 +314,7 @@ struct via686a_data {
314static struct pci_dev *s_bridge; /* pointer to the (only) via686a */ 314static struct pci_dev *s_bridge; /* pointer to the (only) via686a */
315 315
316static int via686a_probe(struct platform_device *pdev); 316static int via686a_probe(struct platform_device *pdev);
317static int via686a_remove(struct platform_device *pdev); 317static int __devexit via686a_remove(struct platform_device *pdev);
318 318
319static inline int via686a_read_value(struct via686a_data *data, u8 reg) 319static inline int via686a_read_value(struct via686a_data *data, u8 reg)
320{ 320{
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index c604972f0186..3e63eaf19041 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -167,7 +167,7 @@ struct vt8231_data {
167 167
168static struct pci_dev *s_bridge; 168static struct pci_dev *s_bridge;
169static int vt8231_probe(struct platform_device *pdev); 169static int vt8231_probe(struct platform_device *pdev);
170static int vt8231_remove(struct platform_device *pdev); 170static int __devexit vt8231_remove(struct platform_device *pdev);
171static struct vt8231_data *vt8231_update_device(struct device *dev); 171static struct vt8231_data *vt8231_update_device(struct device *dev);
172static void vt8231_init_device(struct vt8231_data *data); 172static void vt8231_init_device(struct vt8231_data *data);
173 173
@@ -751,7 +751,7 @@ exit_release:
751 return err; 751 return err;
752} 752}
753 753
754static int vt8231_remove(struct platform_device *pdev) 754static int __devexit vt8231_remove(struct platform_device *pdev)
755{ 755{
756 struct vt8231_data *data = platform_get_drvdata(pdev); 756 struct vt8231_data *data = platform_get_drvdata(pdev);
757 int i; 757 int i;
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 1ce78179b005..7a4a15f4bf8b 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -387,7 +387,7 @@ struct w83627hf_sio_data {
387 387
388 388
389static int w83627hf_probe(struct platform_device *pdev); 389static int w83627hf_probe(struct platform_device *pdev);
390static int w83627hf_remove(struct platform_device *pdev); 390static int __devexit w83627hf_remove(struct platform_device *pdev);
391 391
392static int w83627hf_read_value(struct w83627hf_data *data, u16 reg); 392static int w83627hf_read_value(struct w83627hf_data *data, u16 reg);
393static int w83627hf_write_value(struct w83627hf_data *data, u16 reg, u16 value); 393static int w83627hf_write_value(struct w83627hf_data *data, u16 reg, u16 value);
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index da1647869f91..1842f523c23d 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -92,9 +92,9 @@ config I2C_AU1550
92 92
93config I2C_BLACKFIN_TWI 93config I2C_BLACKFIN_TWI
94 tristate "Blackfin TWI I2C support" 94 tristate "Blackfin TWI I2C support"
95 depends on BF534 || BF536 || BF537 95 depends on BF534 || BF536 || BF537 || BF54x
96 help 96 help
97 This is the TWI I2C device driver for Blackfin 534/536/537. 97 This is the TWI I2C device driver for Blackfin 534/536/537/54x.
98 This driver can also be built as a module. If so, the module 98 This driver can also be built as a module. If so, the module
99 will be called i2c-bfin-twi. 99 will be called i2c-bfin-twi.
100 100
diff --git a/drivers/i2c/chips/ds1682.c b/drivers/i2c/chips/ds1682.c
index 5879f0f25495..9e94542c18a2 100644
--- a/drivers/i2c/chips/ds1682.c
+++ b/drivers/i2c/chips/ds1682.c
@@ -75,7 +75,8 @@ static ssize_t ds1682_show(struct device *dev, struct device_attribute *attr,
75 /* Special case: the 32 bit regs are time values with 1/4s 75 /* Special case: the 32 bit regs are time values with 1/4s
76 * resolution, scale them up to milliseconds */ 76 * resolution, scale them up to milliseconds */
77 if (sattr->nr == 4) 77 if (sattr->nr == 4)
78 return sprintf(buf, "%llu\n", ((u64) le32_to_cpu(val)) * 250); 78 return sprintf(buf, "%llu\n",
79 ((unsigned long long)le32_to_cpu(val)) * 250);
79 80
80 /* Format the output string and return # of bytes */ 81 /* Format the output string and return # of bytes */
81 return sprintf(buf, "%li\n", (long)le32_to_cpu(val)); 82 return sprintf(buf, "%li\n", (long)le32_to_cpu(val));
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index 3c3f2ebf3fc9..503ffec2ce07 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -352,7 +352,7 @@ static void tps65010_interrupt(struct tps65010 *tps)
352 /* REVISIT: this might need its own workqueue 352 /* REVISIT: this might need its own workqueue
353 * plus tweaks including deadlock avoidance ... 353 * plus tweaks including deadlock avoidance ...
354 * also needs to get error handling and probably 354 * also needs to get error handling and probably
355 * an #ifdef CONFIG_SOFTWARE_SUSPEND 355 * an #ifdef CONFIG_HIBERNATION
356 */ 356 */
357 hibernate(); 357 hibernate();
358#endif 358#endif
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index b1a9b81c211f..e049f65bc3a2 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -833,7 +833,7 @@ config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ
833 depends on BLK_DEV_IDE_AU1XXX 833 depends on BLK_DEV_IDE_AU1XXX
834 834
835config IDE_ARM 835config IDE_ARM
836 def_bool ARM && (ARCH_A5K || ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK) 836 def_bool ARM && (ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK)
837 837
838config BLK_DEV_IDE_ICSIDE 838config BLK_DEV_IDE_ICSIDE
839 tristate "ICS IDE interface support" 839 tristate "ICS IDE interface support"
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c
index a3d6744e870a..bce2bec81413 100644
--- a/drivers/ide/arm/ide_arm.c
+++ b/drivers/ide/arm/ide_arm.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * ARM/ARM26 default IDE host driver 2 * ARM default IDE host driver
3 * 3 *
4 * Copyright (C) 2004 Bartlomiej Zolnierkiewicz 4 * Copyright (C) 2004 Bartlomiej Zolnierkiewicz
5 * Based on code by: Russell King, Ian Molton and Alexander Schulz. 5 * Based on code by: Russell King, Ian Molton and Alexander Schulz.
@@ -14,12 +14,6 @@
14#include <asm/mach-types.h> 14#include <asm/mach-types.h>
15#include <asm/irq.h> 15#include <asm/irq.h>
16 16
17#ifdef CONFIG_ARM26
18# define IDE_ARM_HOST (machine_is_a5k())
19#else
20# define IDE_ARM_HOST (1)
21#endif
22
23#ifdef CONFIG_ARCH_CLPS7500 17#ifdef CONFIG_ARCH_CLPS7500
24# include <asm/arch/hardware.h> 18# include <asm/arch/hardware.h>
25# 19#
@@ -32,12 +26,10 @@
32 26
33void __init ide_arm_init(void) 27void __init ide_arm_init(void)
34{ 28{
35 if (IDE_ARM_HOST) { 29 hw_regs_t hw;
36 hw_regs_t hw;
37 30
38 memset(&hw, 0, sizeof(hw)); 31 memset(&hw, 0, sizeof(hw));
39 ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); 32 ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206);
40 hw.irq = IDE_ARM_IRQ; 33 hw.irq = IDE_ARM_IRQ;
41 ide_register_hw(&hw, 1, NULL); 34 ide_register_hw(&hw, 1, NULL);
42 }
43} 35}
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 1486eb212ccc..ca843522f91d 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -3071,7 +3071,7 @@ static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; }
3071/* 3071/*
3072 * standard prep_rq_fn that builds 10 byte cmds 3072 * standard prep_rq_fn that builds 10 byte cmds
3073 */ 3073 */
3074static int ide_cdrom_prep_fs(request_queue_t *q, struct request *rq) 3074static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq)
3075{ 3075{
3076 int hard_sect = queue_hardsect_size(q); 3076 int hard_sect = queue_hardsect_size(q);
3077 long block = (long)rq->hard_sector / (hard_sect >> 9); 3077 long block = (long)rq->hard_sector / (hard_sect >> 9);
@@ -3137,7 +3137,7 @@ static int ide_cdrom_prep_pc(struct request *rq)
3137 return BLKPREP_OK; 3137 return BLKPREP_OK;
3138} 3138}
3139 3139
3140static int ide_cdrom_prep_fn(request_queue_t *q, struct request *rq) 3140static int ide_cdrom_prep_fn(struct request_queue *q, struct request *rq)
3141{ 3141{
3142 if (blk_fs_request(rq)) 3142 if (blk_fs_request(rq))
3143 return ide_cdrom_prep_fs(q, rq); 3143 return ide_cdrom_prep_fs(q, rq);
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index b1304a7f3e0a..5ce4216f72a2 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -679,7 +679,7 @@ static ide_proc_entry_t idedisk_proc[] = {
679}; 679};
680#endif /* CONFIG_IDE_PROC_FS */ 680#endif /* CONFIG_IDE_PROC_FS */
681 681
682static void idedisk_prepare_flush(request_queue_t *q, struct request *rq) 682static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
683{ 683{
684 ide_drive_t *drive = q->queuedata; 684 ide_drive_t *drive = q->queuedata;
685 685
@@ -697,7 +697,7 @@ static void idedisk_prepare_flush(request_queue_t *q, struct request *rq)
697 rq->buffer = rq->cmd; 697 rq->buffer = rq->cmd;
698} 698}
699 699
700static int idedisk_issue_flush(request_queue_t *q, struct gendisk *disk, 700static int idedisk_issue_flush(struct request_queue *q, struct gendisk *disk,
701 sector_t *error_sector) 701 sector_t *error_sector)
702{ 702{
703 ide_drive_t *drive = q->queuedata; 703 ide_drive_t *drive = q->queuedata;
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 484c50e71446..aa9f5f0b1e67 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -1327,7 +1327,7 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
1327/* 1327/*
1328 * Passes the stuff to ide_do_request 1328 * Passes the stuff to ide_do_request
1329 */ 1329 */
1330void do_ide_request(request_queue_t *q) 1330void do_ide_request(struct request_queue *q)
1331{ 1331{
1332 ide_drive_t *drive = q->queuedata; 1332 ide_drive_t *drive = q->queuedata;
1333 1333
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 5a4c5ea12f89..3a2a9a338fd9 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -945,7 +945,7 @@ static void save_match(ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match)
945 */ 945 */
946static int ide_init_queue(ide_drive_t *drive) 946static int ide_init_queue(ide_drive_t *drive)
947{ 947{
948 request_queue_t *q; 948 struct request_queue *q;
949 ide_hwif_t *hwif = HWIF(drive); 949 ide_hwif_t *hwif = HWIF(drive);
950 int max_sectors = 256; 950 int max_sectors = 256;
951 int max_sg_entries = PRD_ENTRIES; 951 int max_sg_entries = PRD_ENTRIES;
diff --git a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c
index 8f2db8dd35f7..8e05d88e81ba 100644
--- a/drivers/ide/legacy/hd.c
+++ b/drivers/ide/legacy/hd.c
@@ -652,7 +652,7 @@ repeat:
652 } 652 }
653} 653}
654 654
655static void do_hd_request (request_queue_t * q) 655static void do_hd_request (struct request_queue * q)
656{ 656{
657 disable_irq(HD_IRQ); 657 disable_irq(HD_IRQ);
658 hd_request(); 658 hd_request();
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index f668d235e6be..bf19ddfa6cda 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -551,8 +551,8 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name)
551 unsigned long dma_base = pci_resource_start(dev, 1); 551 unsigned long dma_base = pci_resource_start(dev, 1);
552 unsigned long ctl_size = pci_resource_len(dev, 0); 552 unsigned long ctl_size = pci_resource_len(dev, 0);
553 unsigned long dma_size = pci_resource_len(dev, 1); 553 unsigned long dma_size = pci_resource_len(dev, 1);
554 void *ctl_addr; 554 void __iomem *ctl_addr;
555 void *dma_addr; 555 void __iomem *dma_addr;
556 int i; 556 int i;
557 557
558 for (i = 0; i < MAX_HWIFS; i++) { 558 for (i = 0; i < MAX_HWIFS; i++) {
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 336e5ff4cfcf..cadf0479cce5 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -2677,7 +2677,7 @@ static long raw1394_iso_xmit_recv_packets32(struct file *file, unsigned int cmd,
2677 struct raw1394_iso_packets32 __user *arg) 2677 struct raw1394_iso_packets32 __user *arg)
2678{ 2678{
2679 compat_uptr_t infos32; 2679 compat_uptr_t infos32;
2680 void *infos; 2680 void __user *infos;
2681 long err = -EFAULT; 2681 long err = -EFAULT;
2682 struct raw1394_iso_packets __user *dst = compat_alloc_user_space(sizeof(struct raw1394_iso_packets)); 2682 struct raw1394_iso_packets __user *dst = compat_alloc_user_space(sizeof(struct raw1394_iso_packets));
2683 2683
diff --git a/drivers/infiniband/hw/amso1100/c2_qp.c b/drivers/infiniband/hw/amso1100/c2_qp.c
index 420c1380f5c3..01d07862ea86 100644
--- a/drivers/infiniband/hw/amso1100/c2_qp.c
+++ b/drivers/infiniband/hw/amso1100/c2_qp.c
@@ -506,6 +506,7 @@ int c2_alloc_qp(struct c2_dev *c2dev,
506 qp->send_sgl_depth = qp_attrs->cap.max_send_sge; 506 qp->send_sgl_depth = qp_attrs->cap.max_send_sge;
507 qp->rdma_write_sgl_depth = qp_attrs->cap.max_send_sge; 507 qp->rdma_write_sgl_depth = qp_attrs->cap.max_send_sge;
508 qp->recv_sgl_depth = qp_attrs->cap.max_recv_sge; 508 qp->recv_sgl_depth = qp_attrs->cap.max_recv_sge;
509 init_waitqueue_head(&qp->wait);
509 510
510 /* Initialize the SQ MQ */ 511 /* Initialize the SQ MQ */
511 q_size = be32_to_cpu(reply->sq_depth); 512 q_size = be32_to_cpu(reply->sq_depth);
diff --git a/drivers/infiniband/hw/ehca/ehca_classes.h b/drivers/infiniband/hw/ehca/ehca_classes.h
index 3725aa8664d9..b5e960305316 100644
--- a/drivers/infiniband/hw/ehca/ehca_classes.h
+++ b/drivers/infiniband/hw/ehca/ehca_classes.h
@@ -322,6 +322,7 @@ extern int ehca_static_rate;
322extern int ehca_port_act_time; 322extern int ehca_port_act_time;
323extern int ehca_use_hp_mr; 323extern int ehca_use_hp_mr;
324extern int ehca_scaling_code; 324extern int ehca_scaling_code;
325extern int ehca_mr_largepage;
325 326
326struct ipzu_queue_resp { 327struct ipzu_queue_resp {
327 u32 qe_size; /* queue entry size */ 328 u32 qe_size; /* queue entry size */
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index 71c0799b3500..ee06d8bd7396 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -116,7 +116,7 @@ static void print_error_data(struct ehca_shca *shca, void *data,
116 } 116 }
117 default: 117 default:
118 ehca_err(&shca->ib_device, 118 ehca_err(&shca->ib_device,
119 "Unknown errror type: %lx on %s.", 119 "Unknown error type: %lx on %s.",
120 type, shca->ib_device.name); 120 type, shca->ib_device.name);
121 break; 121 break;
122 } 122 }
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index c1b868b79d67..d97eda3e1da0 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -40,10 +40,10 @@
40 * POSSIBILITY OF SUCH DAMAGE. 40 * POSSIBILITY OF SUCH DAMAGE.
41 */ 41 */
42 42
43#include <rdma/ib_umem.h>
44
45#include <asm/current.h> 43#include <asm/current.h>
46 44
45#include <rdma/ib_umem.h>
46
47#include "ehca_iverbs.h" 47#include "ehca_iverbs.h"
48#include "ehca_mrmw.h" 48#include "ehca_mrmw.h"
49#include "hcp_if.h" 49#include "hcp_if.h"
@@ -64,8 +64,6 @@ enum ehca_mr_pgsize {
64 EHCA_MR_PGSIZE16M = 0x1000000L 64 EHCA_MR_PGSIZE16M = 0x1000000L
65}; 65};
66 66
67extern int ehca_mr_largepage;
68
69static u32 ehca_encode_hwpage_size(u32 pgsize) 67static u32 ehca_encode_hwpage_size(u32 pgsize)
70{ 68{
71 u32 idx = 0; 69 u32 idx = 0;
diff --git a/drivers/infiniband/hw/ehca/ehca_pd.c b/drivers/infiniband/hw/ehca/ehca_pd.c
index 3dafd7ff36cd..43bcf085fcf2 100644
--- a/drivers/infiniband/hw/ehca/ehca_pd.c
+++ b/drivers/infiniband/hw/ehca/ehca_pd.c
@@ -88,7 +88,6 @@ int ehca_dealloc_pd(struct ib_pd *pd)
88 u32 cur_pid = current->tgid; 88 u32 cur_pid = current->tgid;
89 struct ehca_pd *my_pd = container_of(pd, struct ehca_pd, ib_pd); 89 struct ehca_pd *my_pd = container_of(pd, struct ehca_pd, ib_pd);
90 int i, leftovers = 0; 90 int i, leftovers = 0;
91 extern struct kmem_cache *small_qp_cache;
92 struct ipz_small_queue_page *page, *tmp; 91 struct ipz_small_queue_page *page, *tmp;
93 92
94 if (my_pd->ib_pd.uobject && my_pd->ib_pd.uobject->context && 93 if (my_pd->ib_pd.uobject && my_pd->ib_pd.uobject->context &&
diff --git a/drivers/infiniband/hw/ehca/hcp_if.c b/drivers/infiniband/hw/ehca/hcp_if.c
index fdbfebea7d11..24f454162f24 100644
--- a/drivers/infiniband/hw/ehca/hcp_if.c
+++ b/drivers/infiniband/hw/ehca/hcp_if.c
@@ -758,7 +758,6 @@ u64 hipz_h_register_rpage_mr(const struct ipz_adapter_handle adapter_handle,
758 const u64 logical_address_of_page, 758 const u64 logical_address_of_page,
759 const u64 count) 759 const u64 count)
760{ 760{
761 extern int ehca_debug_level;
762 u64 ret; 761 u64 ret;
763 762
764 if (unlikely(ehca_debug_level >= 2)) { 763 if (unlikely(ehca_debug_level >= 2)) {
diff --git a/drivers/infiniband/hw/ehca/ipz_pt_fn.h b/drivers/infiniband/hw/ehca/ipz_pt_fn.h
index c6937a044e8a..a801274ea337 100644
--- a/drivers/infiniband/hw/ehca/ipz_pt_fn.h
+++ b/drivers/infiniband/hw/ehca/ipz_pt_fn.h
@@ -54,6 +54,8 @@
54struct ehca_pd; 54struct ehca_pd;
55struct ipz_small_queue_page; 55struct ipz_small_queue_page;
56 56
57extern struct kmem_cache *small_qp_cache;
58
57/* struct generic ehca page */ 59/* struct generic ehca page */
58struct ipz_page { 60struct ipz_page {
59 u8 entries[EHCA_PAGESIZE]; 61 u8 entries[EHCA_PAGESIZE];
diff --git a/drivers/infiniband/hw/ipath/ipath_common.h b/drivers/infiniband/hw/ipath/ipath_common.h
index b4b786d0dfca..6ad822c35930 100644
--- a/drivers/infiniband/hw/ipath/ipath_common.h
+++ b/drivers/infiniband/hw/ipath/ipath_common.h
@@ -100,8 +100,7 @@ struct infinipath_stats {
100 __u64 sps_hwerrs; 100 __u64 sps_hwerrs;
101 /* number of times IB link changed state unexpectedly */ 101 /* number of times IB link changed state unexpectedly */
102 __u64 sps_iblink; 102 __u64 sps_iblink;
103 /* kernel receive interrupts that didn't read intstat */ 103 __u64 sps_unused; /* was fastrcvint, no longer implemented */
104 __u64 sps_fastrcvint;
105 /* number of kernel (port0) packets received */ 104 /* number of kernel (port0) packets received */
106 __u64 sps_port0pkts; 105 __u64 sps_port0pkts;
107 /* number of "ethernet" packets sent by driver */ 106 /* number of "ethernet" packets sent by driver */
diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c
index a698f1949d10..cf25cdab02f9 100644
--- a/drivers/infiniband/hw/ipath/ipath_diag.c
+++ b/drivers/infiniband/hw/ipath/ipath_diag.c
@@ -44,6 +44,7 @@
44#include <linux/io.h> 44#include <linux/io.h>
45#include <linux/pci.h> 45#include <linux/pci.h>
46#include <linux/vmalloc.h> 46#include <linux/vmalloc.h>
47#include <linux/fs.h>
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48 49
49#include "ipath_kernel.h" 50#include "ipath_kernel.h"
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index 09c5fd84b1e3..6ccba365a24c 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -740,7 +740,7 @@ void ipath_disarm_piobufs(struct ipath_devdata *dd, unsigned first,
740 * pioavail updates to memory to stop. 740 * pioavail updates to memory to stop.
741 */ 741 */
742 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 742 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
743 sendorig & ~IPATH_S_PIOBUFAVAILUPD); 743 sendorig & ~INFINIPATH_S_PIOBUFAVAILUPD);
744 sendorig = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 744 sendorig = ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
745 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 745 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
746 dd->ipath_sendctrl); 746 dd->ipath_sendctrl);
@@ -1614,7 +1614,7 @@ int ipath_waitfor_mdio_cmdready(struct ipath_devdata *dd)
1614 * it's safer to always do it. 1614 * it's safer to always do it.
1615 * PIOAvail bits are updated by the chip as if normal send had happened. 1615 * PIOAvail bits are updated by the chip as if normal send had happened.
1616 */ 1616 */
1617void ipath_cancel_sends(struct ipath_devdata *dd) 1617void ipath_cancel_sends(struct ipath_devdata *dd, int restore_sendctrl)
1618{ 1618{
1619 ipath_dbg("Cancelling all in-progress send buffers\n"); 1619 ipath_dbg("Cancelling all in-progress send buffers\n");
1620 dd->ipath_lastcancel = jiffies+HZ/2; /* skip armlaunch errs a bit */ 1620 dd->ipath_lastcancel = jiffies+HZ/2; /* skip armlaunch errs a bit */
@@ -1627,6 +1627,9 @@ void ipath_cancel_sends(struct ipath_devdata *dd)
1627 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 1627 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
1628 ipath_disarm_piobufs(dd, 0, 1628 ipath_disarm_piobufs(dd, 0,
1629 (unsigned)(dd->ipath_piobcnt2k + dd->ipath_piobcnt4k)); 1629 (unsigned)(dd->ipath_piobcnt2k + dd->ipath_piobcnt4k));
1630 if (restore_sendctrl) /* else done by caller later */
1631 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
1632 dd->ipath_sendctrl);
1630 1633
1631 /* and again, be sure all have hit the chip */ 1634 /* and again, be sure all have hit the chip */
1632 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 1635 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
@@ -1655,7 +1658,7 @@ static void ipath_set_ib_lstate(struct ipath_devdata *dd, int which)
1655 /* flush all queued sends when going to DOWN or INIT, to be sure that 1658 /* flush all queued sends when going to DOWN or INIT, to be sure that
1656 * they don't block MAD packets */ 1659 * they don't block MAD packets */
1657 if (!linkcmd || linkcmd == INFINIPATH_IBCC_LINKCMD_INIT) 1660 if (!linkcmd || linkcmd == INFINIPATH_IBCC_LINKCMD_INIT)
1658 ipath_cancel_sends(dd); 1661 ipath_cancel_sends(dd, 1);
1659 1662
1660 ipath_write_kreg(dd, dd->ipath_kregs->kr_ibcctrl, 1663 ipath_write_kreg(dd, dd->ipath_kregs->kr_ibcctrl,
1661 dd->ipath_ibcctrl | which); 1664 dd->ipath_ibcctrl | which);
@@ -2000,7 +2003,7 @@ void ipath_shutdown_device(struct ipath_devdata *dd)
2000 2003
2001 ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKINITCMD_DISABLE << 2004 ipath_set_ib_lstate(dd, INFINIPATH_IBCC_LINKINITCMD_DISABLE <<
2002 INFINIPATH_IBCC_LINKINITCMD_SHIFT); 2005 INFINIPATH_IBCC_LINKINITCMD_SHIFT);
2003 ipath_cancel_sends(dd); 2006 ipath_cancel_sends(dd, 0);
2004 2007
2005 /* disable IBC */ 2008 /* disable IBC */
2006 dd->ipath_control &= ~INFINIPATH_C_LINKENABLE; 2009 dd->ipath_control &= ~INFINIPATH_C_LINKENABLE;
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6120.c b/drivers/infiniband/hw/ipath/ipath_iba6120.c
index 9868ccda5f26..5b6ac9a1a709 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba6120.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba6120.c
@@ -321,6 +321,8 @@ static const struct ipath_hwerror_msgs ipath_6120_hwerror_msgs[] = {
321 << INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT) 321 << INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT)
322 322
323static int ipath_pe_txe_recover(struct ipath_devdata *); 323static int ipath_pe_txe_recover(struct ipath_devdata *);
324static void ipath_pe_put_tid_2(struct ipath_devdata *, u64 __iomem *,
325 u32, unsigned long);
324 326
325/** 327/**
326 * ipath_pe_handle_hwerrors - display hardware errors. 328 * ipath_pe_handle_hwerrors - display hardware errors.
@@ -555,8 +557,11 @@ static int ipath_pe_boardname(struct ipath_devdata *dd, char *name,
555 ipath_dev_err(dd, "Unsupported InfiniPath hardware revision %u.%u!\n", 557 ipath_dev_err(dd, "Unsupported InfiniPath hardware revision %u.%u!\n",
556 dd->ipath_majrev, dd->ipath_minrev); 558 dd->ipath_majrev, dd->ipath_minrev);
557 ret = 1; 559 ret = 1;
558 } else 560 } else {
559 ret = 0; 561 ret = 0;
562 if (dd->ipath_minrev >= 2)
563 dd->ipath_f_put_tid = ipath_pe_put_tid_2;
564 }
560 565
561 return ret; 566 return ret;
562} 567}
@@ -1220,7 +1225,7 @@ static void ipath_pe_clear_tids(struct ipath_devdata *dd, unsigned port)
1220 port * dd->ipath_rcvtidcnt * sizeof(*tidbase)); 1225 port * dd->ipath_rcvtidcnt * sizeof(*tidbase));
1221 1226
1222 for (i = 0; i < dd->ipath_rcvtidcnt; i++) 1227 for (i = 0; i < dd->ipath_rcvtidcnt; i++)
1223 ipath_pe_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EXPECTED, 1228 dd->ipath_f_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EXPECTED,
1224 tidinv); 1229 tidinv);
1225 1230
1226 tidbase = (u64 __iomem *) 1231 tidbase = (u64 __iomem *)
@@ -1229,7 +1234,7 @@ static void ipath_pe_clear_tids(struct ipath_devdata *dd, unsigned port)
1229 port * dd->ipath_rcvegrcnt * sizeof(*tidbase)); 1234 port * dd->ipath_rcvegrcnt * sizeof(*tidbase));
1230 1235
1231 for (i = 0; i < dd->ipath_rcvegrcnt; i++) 1236 for (i = 0; i < dd->ipath_rcvegrcnt; i++)
1232 ipath_pe_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EAGER, 1237 dd->ipath_f_put_tid(dd, &tidbase[i], RCVHQ_RCV_TYPE_EAGER,
1233 tidinv); 1238 tidinv);
1234} 1239}
1235 1240
@@ -1395,10 +1400,11 @@ void ipath_init_iba6120_funcs(struct ipath_devdata *dd)
1395 dd->ipath_f_quiet_serdes = ipath_pe_quiet_serdes; 1400 dd->ipath_f_quiet_serdes = ipath_pe_quiet_serdes;
1396 dd->ipath_f_bringup_serdes = ipath_pe_bringup_serdes; 1401 dd->ipath_f_bringup_serdes = ipath_pe_bringup_serdes;
1397 dd->ipath_f_clear_tids = ipath_pe_clear_tids; 1402 dd->ipath_f_clear_tids = ipath_pe_clear_tids;
1398 if (dd->ipath_minrev >= 2) 1403 /*
1399 dd->ipath_f_put_tid = ipath_pe_put_tid_2; 1404 * this may get changed after we read the chip revision,
1400 else 1405 * but we start with the safe version for all revs
1401 dd->ipath_f_put_tid = ipath_pe_put_tid; 1406 */
1407 dd->ipath_f_put_tid = ipath_pe_put_tid;
1402 dd->ipath_f_cleanup = ipath_setup_pe_cleanup; 1408 dd->ipath_f_cleanup = ipath_setup_pe_cleanup;
1403 dd->ipath_f_setextled = ipath_setup_pe_setextled; 1409 dd->ipath_f_setextled = ipath_setup_pe_setextled;
1404 dd->ipath_f_get_base_info = ipath_pe_get_base_info; 1410 dd->ipath_f_get_base_info = ipath_pe_get_base_info;
diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c
index 49951d583804..9dd0bacf8461 100644
--- a/drivers/infiniband/hw/ipath/ipath_init_chip.c
+++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c
@@ -782,7 +782,7 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit)
782 * Follows early_init because some chips have to initialize 782 * Follows early_init because some chips have to initialize
783 * PIO buffers in early_init to avoid false parity errors. 783 * PIO buffers in early_init to avoid false parity errors.
784 */ 784 */
785 ipath_cancel_sends(dd); 785 ipath_cancel_sends(dd, 0);
786 786
787 /* early_init sets rcvhdrentsize and rcvhdrsize, so this must be 787 /* early_init sets rcvhdrentsize and rcvhdrsize, so this must be
788 * done after early_init */ 788 * done after early_init */
@@ -851,13 +851,14 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit)
851 ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask, 851 ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrmask,
852 dd->ipath_hwerrmask); 852 dd->ipath_hwerrmask);
853 853
854 dd->ipath_maskederrs = dd->ipath_ignorederrs;
855 /* clear all */ 854 /* clear all */
856 ipath_write_kreg(dd, dd->ipath_kregs->kr_errorclear, -1LL); 855 ipath_write_kreg(dd, dd->ipath_kregs->kr_errorclear, -1LL);
857 /* enable errors that are masked, at least this first time. */ 856 /* enable errors that are masked, at least this first time. */
858 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask, 857 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask,
859 ~dd->ipath_maskederrs); 858 ~dd->ipath_maskederrs);
860 /* clear any interrups up to this point (ints still not enabled) */ 859 dd->ipath_errormask = ipath_read_kreg64(dd,
860 dd->ipath_kregs->kr_errormask);
861 /* clear any interrupts up to this point (ints still not enabled) */
861 ipath_write_kreg(dd, dd->ipath_kregs->kr_intclear, -1LL); 862 ipath_write_kreg(dd, dd->ipath_kregs->kr_intclear, -1LL);
862 863
863 /* 864 /*
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
index 1fd91c59f246..b29fe7e9b11a 100644
--- a/drivers/infiniband/hw/ipath/ipath_intr.c
+++ b/drivers/infiniband/hw/ipath/ipath_intr.c
@@ -303,7 +303,7 @@ static void handle_e_ibstatuschanged(struct ipath_devdata *dd,
303 * Flush all queued sends when link went to DOWN or INIT, 303 * Flush all queued sends when link went to DOWN or INIT,
304 * to be sure that they don't block SMA and other MAD packets 304 * to be sure that they don't block SMA and other MAD packets
305 */ 305 */
306 ipath_cancel_sends(dd); 306 ipath_cancel_sends(dd, 1);
307 } 307 }
308 else if (lstate == IPATH_IBSTATE_INIT || lstate == IPATH_IBSTATE_ARM || 308 else if (lstate == IPATH_IBSTATE_INIT || lstate == IPATH_IBSTATE_ARM ||
309 lstate == IPATH_IBSTATE_ACTIVE) { 309 lstate == IPATH_IBSTATE_ACTIVE) {
@@ -517,10 +517,7 @@ static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs)
517 517
518 supp_msgs = handle_frequent_errors(dd, errs, msg, &noprint); 518 supp_msgs = handle_frequent_errors(dd, errs, msg, &noprint);
519 519
520 /* 520 /* don't report errors that are masked */
521 * don't report errors that are masked (includes those always
522 * ignored)
523 */
524 errs &= ~dd->ipath_maskederrs; 521 errs &= ~dd->ipath_maskederrs;
525 522
526 /* do these first, they are most important */ 523 /* do these first, they are most important */
@@ -566,19 +563,19 @@ static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs)
566 * ones on this particular interrupt, which also isn't great 563 * ones on this particular interrupt, which also isn't great
567 */ 564 */
568 dd->ipath_maskederrs |= dd->ipath_lasterror | errs; 565 dd->ipath_maskederrs |= dd->ipath_lasterror | errs;
566 dd->ipath_errormask &= ~dd->ipath_maskederrs;
569 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask, 567 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask,
570 ~dd->ipath_maskederrs); 568 dd->ipath_errormask);
571 s_iserr = ipath_decode_err(msg, sizeof msg, 569 s_iserr = ipath_decode_err(msg, sizeof msg,
572 (dd->ipath_maskederrs & ~dd-> 570 dd->ipath_maskederrs);
573 ipath_ignorederrs));
574 571
575 if ((dd->ipath_maskederrs & ~dd->ipath_ignorederrs) & 572 if (dd->ipath_maskederrs &
576 ~(INFINIPATH_E_RRCVEGRFULL | 573 ~(INFINIPATH_E_RRCVEGRFULL |
577 INFINIPATH_E_RRCVHDRFULL | INFINIPATH_E_PKTERRS)) 574 INFINIPATH_E_RRCVHDRFULL | INFINIPATH_E_PKTERRS))
578 ipath_dev_err(dd, "Temporarily disabling " 575 ipath_dev_err(dd, "Temporarily disabling "
579 "error(s) %llx reporting; too frequent (%s)\n", 576 "error(s) %llx reporting; too frequent (%s)\n",
580 (unsigned long long) (dd->ipath_maskederrs & 577 (unsigned long long)dd->ipath_maskederrs,
581 ~dd->ipath_ignorederrs), msg); 578 msg);
582 else { 579 else {
583 /* 580 /*
584 * rcvegrfull and rcvhdrqfull are "normal", 581 * rcvegrfull and rcvhdrqfull are "normal",
@@ -793,19 +790,22 @@ void ipath_clear_freeze(struct ipath_devdata *dd)
793 /* disable error interrupts, to avoid confusion */ 790 /* disable error interrupts, to avoid confusion */
794 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask, 0ULL); 791 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask, 0ULL);
795 792
793 /* also disable interrupts; errormask is sometimes overwriten */
794 ipath_write_kreg(dd, dd->ipath_kregs->kr_intmask, 0ULL);
795
796 /* 796 /*
797 * clear all sends, because they have may been 797 * clear all sends, because they have may been
798 * completed by usercode while in freeze mode, and 798 * completed by usercode while in freeze mode, and
799 * therefore would not be sent, and eventually 799 * therefore would not be sent, and eventually
800 * might cause the process to run out of bufs 800 * might cause the process to run out of bufs
801 */ 801 */
802 ipath_cancel_sends(dd); 802 ipath_cancel_sends(dd, 0);
803 ipath_write_kreg(dd, dd->ipath_kregs->kr_control, 803 ipath_write_kreg(dd, dd->ipath_kregs->kr_control,
804 dd->ipath_control); 804 dd->ipath_control);
805 805
806 /* ensure pio avail updates continue */ 806 /* ensure pio avail updates continue */
807 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 807 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
808 dd->ipath_sendctrl & ~IPATH_S_PIOBUFAVAILUPD); 808 dd->ipath_sendctrl & ~INFINIPATH_S_PIOBUFAVAILUPD);
809 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 809 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
810 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, 810 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
811 dd->ipath_sendctrl); 811 dd->ipath_sendctrl);
@@ -817,7 +817,7 @@ void ipath_clear_freeze(struct ipath_devdata *dd)
817 for (i = 0; i < dd->ipath_pioavregs; i++) { 817 for (i = 0; i < dd->ipath_pioavregs; i++) {
818 /* deal with 6110 chip bug */ 818 /* deal with 6110 chip bug */
819 im = i > 3 ? ((i&1) ? i-1 : i+1) : i; 819 im = i > 3 ? ((i&1) ? i-1 : i+1) : i;
820 val = ipath_read_kreg64(dd, 0x1000+(im*sizeof(u64))); 820 val = ipath_read_kreg64(dd, (0x1000/sizeof(u64))+im);
821 dd->ipath_pioavailregs_dma[i] = dd->ipath_pioavailshadow[i] 821 dd->ipath_pioavailregs_dma[i] = dd->ipath_pioavailshadow[i]
822 = le64_to_cpu(val); 822 = le64_to_cpu(val);
823 } 823 }
@@ -832,7 +832,8 @@ void ipath_clear_freeze(struct ipath_devdata *dd)
832 ipath_write_kreg(dd, dd->ipath_kregs->kr_errorclear, 832 ipath_write_kreg(dd, dd->ipath_kregs->kr_errorclear,
833 E_SPKT_ERRS_IGNORE); 833 E_SPKT_ERRS_IGNORE);
834 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask, 834 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask,
835 ~dd->ipath_maskederrs); 835 dd->ipath_errormask);
836 ipath_write_kreg(dd, dd->ipath_kregs->kr_intmask, -1LL);
836 ipath_write_kreg(dd, dd->ipath_kregs->kr_intclear, 0ULL); 837 ipath_write_kreg(dd, dd->ipath_kregs->kr_intclear, 0ULL);
837} 838}
838 839
@@ -1002,7 +1003,6 @@ irqreturn_t ipath_intr(int irq, void *data)
1002 u32 istat, chk0rcv = 0; 1003 u32 istat, chk0rcv = 0;
1003 ipath_err_t estat = 0; 1004 ipath_err_t estat = 0;
1004 irqreturn_t ret; 1005 irqreturn_t ret;
1005 u32 oldhead, curtail;
1006 static unsigned unexpected = 0; 1006 static unsigned unexpected = 0;
1007 static const u32 port0rbits = (1U<<INFINIPATH_I_RCVAVAIL_SHIFT) | 1007 static const u32 port0rbits = (1U<<INFINIPATH_I_RCVAVAIL_SHIFT) |
1008 (1U<<INFINIPATH_I_RCVURG_SHIFT); 1008 (1U<<INFINIPATH_I_RCVURG_SHIFT);
@@ -1035,36 +1035,6 @@ irqreturn_t ipath_intr(int irq, void *data)
1035 goto bail; 1035 goto bail;
1036 } 1036 }
1037 1037
1038 /*
1039 * We try to avoid reading the interrupt status register, since
1040 * that's a PIO read, and stalls the processor for up to about
1041 * ~0.25 usec. The idea is that if we processed a port0 packet,
1042 * we blindly clear the port 0 receive interrupt bits, and nothing
1043 * else, then return. If other interrupts are pending, the chip
1044 * will re-interrupt us as soon as we write the intclear register.
1045 * We then won't process any more kernel packets (if not the 2nd
1046 * time, then the 3rd or 4th) and we'll then handle the other
1047 * interrupts. We clear the interrupts first so that we don't
1048 * lose intr for later packets that arrive while we are processing.
1049 */
1050 oldhead = dd->ipath_port0head;
1051 curtail = (u32)le64_to_cpu(*dd->ipath_hdrqtailptr);
1052 if (oldhead != curtail) {
1053 if (dd->ipath_flags & IPATH_GPIO_INTR) {
1054 ipath_write_kreg(dd, dd->ipath_kregs->kr_gpio_clear,
1055 (u64) (1 << IPATH_GPIO_PORT0_BIT));
1056 istat = port0rbits | INFINIPATH_I_GPIO;
1057 }
1058 else
1059 istat = port0rbits;
1060 ipath_write_kreg(dd, dd->ipath_kregs->kr_intclear, istat);
1061 ipath_kreceive(dd);
1062 if (oldhead != dd->ipath_port0head) {
1063 ipath_stats.sps_fastrcvint++;
1064 goto done;
1065 }
1066 }
1067
1068 istat = ipath_read_kreg32(dd, dd->ipath_kregs->kr_intstatus); 1038 istat = ipath_read_kreg32(dd, dd->ipath_kregs->kr_intstatus);
1069 1039
1070 if (unlikely(!istat)) { 1040 if (unlikely(!istat)) {
@@ -1225,7 +1195,6 @@ irqreturn_t ipath_intr(int irq, void *data)
1225 handle_layer_pioavail(dd); 1195 handle_layer_pioavail(dd);
1226 } 1196 }
1227 1197
1228done:
1229 ret = IRQ_HANDLED; 1198 ret = IRQ_HANDLED;
1230 1199
1231bail: 1200bail:
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index ace63ef78e6f..7a7966f7e4ff 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -261,18 +261,10 @@ struct ipath_devdata {
261 * limiting of hwerror reporting 261 * limiting of hwerror reporting
262 */ 262 */
263 ipath_err_t ipath_lasthwerror; 263 ipath_err_t ipath_lasthwerror;
264 /* 264 /* errors masked because they occur too fast */
265 * errors masked because they occur too fast, also includes errors
266 * that are always ignored (ipath_ignorederrs)
267 */
268 ipath_err_t ipath_maskederrs; 265 ipath_err_t ipath_maskederrs;
269 /* time in jiffies at which to re-enable maskederrs */ 266 /* time in jiffies at which to re-enable maskederrs */
270 unsigned long ipath_unmasktime; 267 unsigned long ipath_unmasktime;
271 /*
272 * errors always ignored (masked), at least for a given
273 * chip/device, because they are wrong or not useful
274 */
275 ipath_err_t ipath_ignorederrs;
276 /* count of egrfull errors, combined for all ports */ 268 /* count of egrfull errors, combined for all ports */
277 u64 ipath_last_tidfull; 269 u64 ipath_last_tidfull;
278 /* for ipath_qcheck() */ 270 /* for ipath_qcheck() */
@@ -436,6 +428,7 @@ struct ipath_devdata {
436 u64 ipath_lastibcstat; 428 u64 ipath_lastibcstat;
437 /* hwerrmask shadow */ 429 /* hwerrmask shadow */
438 ipath_err_t ipath_hwerrmask; 430 ipath_err_t ipath_hwerrmask;
431 ipath_err_t ipath_errormask; /* errormask shadow */
439 /* interrupt config reg shadow */ 432 /* interrupt config reg shadow */
440 u64 ipath_intconfig; 433 u64 ipath_intconfig;
441 /* kr_sendpiobufbase value */ 434 /* kr_sendpiobufbase value */
@@ -683,7 +676,7 @@ int ipath_unordered_wc(void);
683 676
684void ipath_disarm_piobufs(struct ipath_devdata *, unsigned first, 677void ipath_disarm_piobufs(struct ipath_devdata *, unsigned first,
685 unsigned cnt); 678 unsigned cnt);
686void ipath_cancel_sends(struct ipath_devdata *); 679void ipath_cancel_sends(struct ipath_devdata *, int);
687 680
688int ipath_create_rcvhdrq(struct ipath_devdata *, struct ipath_portdata *); 681int ipath_create_rcvhdrq(struct ipath_devdata *, struct ipath_portdata *);
689void ipath_free_pddata(struct ipath_devdata *, struct ipath_portdata *); 682void ipath_free_pddata(struct ipath_devdata *, struct ipath_portdata *);
diff --git a/drivers/infiniband/hw/ipath/ipath_stats.c b/drivers/infiniband/hw/ipath/ipath_stats.c
index 73ed17d03188..bae4f56f7271 100644
--- a/drivers/infiniband/hw/ipath/ipath_stats.c
+++ b/drivers/infiniband/hw/ipath/ipath_stats.c
@@ -196,6 +196,45 @@ static void ipath_qcheck(struct ipath_devdata *dd)
196 } 196 }
197} 197}
198 198
199static void ipath_chk_errormask(struct ipath_devdata *dd)
200{
201 static u32 fixed;
202 u32 ctrl;
203 unsigned long errormask;
204 unsigned long hwerrs;
205
206 if (!dd->ipath_errormask || !(dd->ipath_flags & IPATH_INITTED))
207 return;
208
209 errormask = ipath_read_kreg64(dd, dd->ipath_kregs->kr_errormask);
210
211 if (errormask == dd->ipath_errormask)
212 return;
213 fixed++;
214
215 hwerrs = ipath_read_kreg64(dd, dd->ipath_kregs->kr_hwerrstatus);
216 ctrl = ipath_read_kreg32(dd, dd->ipath_kregs->kr_control);
217
218 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask,
219 dd->ipath_errormask);
220
221 if ((hwerrs & dd->ipath_hwerrmask) ||
222 (ctrl & INFINIPATH_C_FREEZEMODE)) {
223 /* force re-interrupt of pending events, just in case */
224 ipath_write_kreg(dd, dd->ipath_kregs->kr_hwerrclear, 0ULL);
225 ipath_write_kreg(dd, dd->ipath_kregs->kr_errorclear, 0ULL);
226 ipath_write_kreg(dd, dd->ipath_kregs->kr_intclear, 0ULL);
227 dev_info(&dd->pcidev->dev,
228 "errormask fixed(%u) %lx -> %lx, ctrl %x hwerr %lx\n",
229 fixed, errormask, (unsigned long)dd->ipath_errormask,
230 ctrl, hwerrs);
231 } else
232 ipath_dbg("errormask fixed(%u) %lx -> %lx, no freeze\n",
233 fixed, errormask,
234 (unsigned long)dd->ipath_errormask);
235}
236
237
199/** 238/**
200 * ipath_get_faststats - get word counters from chip before they overflow 239 * ipath_get_faststats - get word counters from chip before they overflow
201 * @opaque - contains a pointer to the infinipath device ipath_devdata 240 * @opaque - contains a pointer to the infinipath device ipath_devdata
@@ -251,14 +290,13 @@ void ipath_get_faststats(unsigned long opaque)
251 dd->ipath_lasterror = 0; 290 dd->ipath_lasterror = 0;
252 if (dd->ipath_lasthwerror) 291 if (dd->ipath_lasthwerror)
253 dd->ipath_lasthwerror = 0; 292 dd->ipath_lasthwerror = 0;
254 if ((dd->ipath_maskederrs & ~dd->ipath_ignorederrs) 293 if (dd->ipath_maskederrs
255 && time_after(jiffies, dd->ipath_unmasktime)) { 294 && time_after(jiffies, dd->ipath_unmasktime)) {
256 char ebuf[256]; 295 char ebuf[256];
257 int iserr; 296 int iserr;
258 iserr = ipath_decode_err(ebuf, sizeof ebuf, 297 iserr = ipath_decode_err(ebuf, sizeof ebuf,
259 (dd->ipath_maskederrs & ~dd-> 298 dd->ipath_maskederrs);
260 ipath_ignorederrs)); 299 if (dd->ipath_maskederrs &
261 if ((dd->ipath_maskederrs & ~dd->ipath_ignorederrs) &
262 ~(INFINIPATH_E_RRCVEGRFULL | INFINIPATH_E_RRCVHDRFULL | 300 ~(INFINIPATH_E_RRCVEGRFULL | INFINIPATH_E_RRCVHDRFULL |
263 INFINIPATH_E_PKTERRS )) 301 INFINIPATH_E_PKTERRS ))
264 ipath_dev_err(dd, "Re-enabling masked errors " 302 ipath_dev_err(dd, "Re-enabling masked errors "
@@ -278,9 +316,12 @@ void ipath_get_faststats(unsigned long opaque)
278 ipath_cdbg(ERRPKT, "Re-enabling packet" 316 ipath_cdbg(ERRPKT, "Re-enabling packet"
279 " problem interrupt (%s)\n", ebuf); 317 " problem interrupt (%s)\n", ebuf);
280 } 318 }
281 dd->ipath_maskederrs = dd->ipath_ignorederrs; 319
320 /* re-enable masked errors */
321 dd->ipath_errormask |= dd->ipath_maskederrs;
282 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask, 322 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask,
283 ~dd->ipath_maskederrs); 323 dd->ipath_errormask);
324 dd->ipath_maskederrs = 0;
284 } 325 }
285 326
286 /* limit qfull messages to ~one per minute per port */ 327 /* limit qfull messages to ~one per minute per port */
@@ -294,6 +335,7 @@ void ipath_get_faststats(unsigned long opaque)
294 } 335 }
295 } 336 }
296 337
338 ipath_chk_errormask(dd);
297done: 339done:
298 mod_timer(&dd->ipath_stats_timer, jiffies + HZ * 5); 340 mod_timer(&dd->ipath_stats_timer, jiffies + HZ * 5);
299} 341}
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index f6315dfb213e..ba0428d872aa 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -1209,7 +1209,6 @@ static void set_datagram_seg(struct mlx4_wqe_datagram_seg *dseg,
1209 memcpy(dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof (struct mlx4_av)); 1209 memcpy(dseg->av, &to_mah(wr->wr.ud.ah)->av, sizeof (struct mlx4_av));
1210 dseg->dqpn = cpu_to_be32(wr->wr.ud.remote_qpn); 1210 dseg->dqpn = cpu_to_be32(wr->wr.ud.remote_qpn);
1211 dseg->qkey = cpu_to_be32(wr->wr.ud.remote_qkey); 1211 dseg->qkey = cpu_to_be32(wr->wr.ud.remote_qkey);
1212
1213} 1212}
1214 1213
1215static void set_data_seg(struct mlx4_wqe_data_seg *dseg, 1214static void set_data_seg(struct mlx4_wqe_data_seg *dseg,
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index 5db314380271..bad8dacafd10 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -548,6 +548,7 @@ iscsi_iser_ep_disconnect(__u64 ep_handle)
548} 548}
549 549
550static struct scsi_host_template iscsi_iser_sht = { 550static struct scsi_host_template iscsi_iser_sht = {
551 .module = THIS_MODULE,
551 .name = "iSCSI Initiator over iSER, v." DRV_VER, 552 .name = "iSCSI Initiator over iSER, v." DRV_VER,
552 .queuecommand = iscsi_queuecommand, 553 .queuecommand = iscsi_queuecommand,
553 .can_queue = ISCSI_DEF_XMIT_CMDS_MAX - 1, 554 .can_queue = ISCSI_DEF_XMIT_CMDS_MAX - 1,
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index ab4b2d9b5327..f1c3d6cebd58 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -186,7 +186,7 @@ struct input_event_compat {
186#elif defined(CONFIG_S390) 186#elif defined(CONFIG_S390)
187# define COMPAT_TEST test_thread_flag(TIF_31BIT) 187# define COMPAT_TEST test_thread_flag(TIF_31BIT)
188#elif defined(CONFIG_MIPS) 188#elif defined(CONFIG_MIPS)
189# define COMPAT_TEST (current->thread.mflags & MF_32BIT_ADDR) 189# define COMPAT_TEST test_thread_flag(TIF_32BIT_ADDR)
190#else 190#else
191# define COMPAT_TEST test_thread_flag(TIF_32BIT) 191# define COMPAT_TEST test_thread_flag(TIF_32BIT)
192#endif 192#endif
diff --git a/drivers/input/misc/atlas_btns.c b/drivers/input/misc/atlas_btns.c
index 0acc3a123604..e43e92fd9e23 100644
--- a/drivers/input/misc/atlas_btns.c
+++ b/drivers/input/misc/atlas_btns.c
@@ -31,7 +31,6 @@
31 31
32#define ACPI_ATLAS_NAME "Atlas ACPI" 32#define ACPI_ATLAS_NAME "Atlas ACPI"
33#define ACPI_ATLAS_CLASS "Atlas" 33#define ACPI_ATLAS_CLASS "Atlas"
34#define ACPI_ATLAS_BUTTON_HID "ASIM0000"
35 34
36static struct input_dev *input_dev; 35static struct input_dev *input_dev;
37 36
@@ -130,10 +129,16 @@ static int atlas_acpi_button_remove(struct acpi_device *device, int type)
130 return status; 129 return status;
131} 130}
132 131
132static const struct acpi_device_id atlas_device_ids[] = {
133 {"ASIM0000", 0},
134 {"", 0},
135};
136MODULE_DEVICE_TABLE(acpi, atlas_device_ids);
137
133static struct acpi_driver atlas_acpi_driver = { 138static struct acpi_driver atlas_acpi_driver = {
134 .name = ACPI_ATLAS_NAME, 139 .name = ACPI_ATLAS_NAME,
135 .class = ACPI_ATLAS_CLASS, 140 .class = ACPI_ATLAS_CLASS,
136 .ids = ACPI_ATLAS_BUTTON_HID, 141 .ids = atlas_device_ids,
137 .ops = { 142 .ops = {
138 .add = atlas_acpi_button_add, 143 .add = atlas_acpi_button_add,
139 .remove = atlas_acpi_button_remove, 144 .remove = atlas_acpi_button_remove,
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index adef447f23ea..5ce632ca6815 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -21,7 +21,7 @@ if SERIO
21config SERIO_I8042 21config SERIO_I8042
22 tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86 22 tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86
23 default y 23 default y
24 depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && !M68K 24 depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && !M68K && !BFIN
25 ---help--- 25 ---help---
26 i8042 is the chip over which the standard AT keyboard and PS/2 26 i8042 is the chip over which the standard AT keyboard and PS/2
27 mouse are connected to the computer. If you use these devices, 27 mouse are connected to the computer. If you use these devices,
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c
index be77ee625bb7..559a0d0244cf 100644
--- a/drivers/isdn/divert/divert_procfs.c
+++ b/drivers/isdn/divert/divert_procfs.c
@@ -70,6 +70,8 @@ put_info_buffer(char *cp)
70 wake_up_interruptible(&(rd_queue)); 70 wake_up_interruptible(&(rd_queue));
71} /* put_info_buffer */ 71} /* put_info_buffer */
72 72
73#ifdef CONFIG_PROC_FS
74
73/**********************************/ 75/**********************************/
74/* deflection device read routine */ 76/* deflection device read routine */
75/**********************************/ 77/**********************************/
@@ -253,8 +255,6 @@ isdn_divert_ioctl(struct inode *inode, struct file *file,
253 return copy_to_user((void __user *)arg, &dioctl, sizeof(dioctl)) ? -EFAULT : 0; 255 return copy_to_user((void __user *)arg, &dioctl, sizeof(dioctl)) ? -EFAULT : 0;
254} /* isdn_divert_ioctl */ 256} /* isdn_divert_ioctl */
255 257
256
257#ifdef CONFIG_PROC_FS
258static const struct file_operations isdn_fops = 258static const struct file_operations isdn_fops =
259{ 259{
260 .owner = THIS_MODULE, 260 .owner = THIS_MODULE,
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index bcbe6835beb4..96856097d15b 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -297,9 +297,6 @@ static struct kvm *kvm_create_vm(void)
297 kvm_io_bus_init(&kvm->pio_bus); 297 kvm_io_bus_init(&kvm->pio_bus);
298 spin_lock_init(&kvm->lock); 298 spin_lock_init(&kvm->lock);
299 INIT_LIST_HEAD(&kvm->active_mmu_pages); 299 INIT_LIST_HEAD(&kvm->active_mmu_pages);
300 spin_lock(&kvm_lock);
301 list_add(&kvm->vm_list, &vm_list);
302 spin_unlock(&kvm_lock);
303 kvm_io_bus_init(&kvm->mmio_bus); 300 kvm_io_bus_init(&kvm->mmio_bus);
304 for (i = 0; i < KVM_MAX_VCPUS; ++i) { 301 for (i = 0; i < KVM_MAX_VCPUS; ++i) {
305 struct kvm_vcpu *vcpu = &kvm->vcpus[i]; 302 struct kvm_vcpu *vcpu = &kvm->vcpus[i];
@@ -309,6 +306,9 @@ static struct kvm *kvm_create_vm(void)
309 vcpu->kvm = kvm; 306 vcpu->kvm = kvm;
310 vcpu->mmu.root_hpa = INVALID_PAGE; 307 vcpu->mmu.root_hpa = INVALID_PAGE;
311 } 308 }
309 spin_lock(&kvm_lock);
310 list_add(&kvm->vm_list, &vm_list);
311 spin_unlock(&kvm_lock);
312 return kvm; 312 return kvm;
313} 313}
314 314
@@ -1070,18 +1070,16 @@ static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
1070 return 0; 1070 return 0;
1071 mark_page_dirty(vcpu->kvm, gpa >> PAGE_SHIFT); 1071 mark_page_dirty(vcpu->kvm, gpa >> PAGE_SHIFT);
1072 virt = kmap_atomic(page, KM_USER0); 1072 virt = kmap_atomic(page, KM_USER0);
1073 if (memcmp(virt + offset_in_page(gpa), val, bytes)) { 1073 kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes);
1074 kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes); 1074 memcpy(virt + offset_in_page(gpa), val, bytes);
1075 memcpy(virt + offset_in_page(gpa), val, bytes);
1076 }
1077 kunmap_atomic(virt, KM_USER0); 1075 kunmap_atomic(virt, KM_USER0);
1078 return 1; 1076 return 1;
1079} 1077}
1080 1078
1081static int emulator_write_emulated(unsigned long addr, 1079static int emulator_write_emulated_onepage(unsigned long addr,
1082 const void *val, 1080 const void *val,
1083 unsigned int bytes, 1081 unsigned int bytes,
1084 struct x86_emulate_ctxt *ctxt) 1082 struct x86_emulate_ctxt *ctxt)
1085{ 1083{
1086 struct kvm_vcpu *vcpu = ctxt->vcpu; 1084 struct kvm_vcpu *vcpu = ctxt->vcpu;
1087 struct kvm_io_device *mmio_dev; 1085 struct kvm_io_device *mmio_dev;
@@ -1113,6 +1111,26 @@ static int emulator_write_emulated(unsigned long addr,
1113 return X86EMUL_CONTINUE; 1111 return X86EMUL_CONTINUE;
1114} 1112}
1115 1113
1114static int emulator_write_emulated(unsigned long addr,
1115 const void *val,
1116 unsigned int bytes,
1117 struct x86_emulate_ctxt *ctxt)
1118{
1119 /* Crossing a page boundary? */
1120 if (((addr + bytes - 1) ^ addr) & PAGE_MASK) {
1121 int rc, now;
1122
1123 now = -addr & ~PAGE_MASK;
1124 rc = emulator_write_emulated_onepage(addr, val, now, ctxt);
1125 if (rc != X86EMUL_CONTINUE)
1126 return rc;
1127 addr += now;
1128 val += now;
1129 bytes -= now;
1130 }
1131 return emulator_write_emulated_onepage(addr, val, bytes, ctxt);
1132}
1133
1116static int emulator_cmpxchg_emulated(unsigned long addr, 1134static int emulator_cmpxchg_emulated(unsigned long addr,
1117 const void *old, 1135 const void *old,
1118 const void *new, 1136 const void *new,
@@ -2414,9 +2432,9 @@ static void cpuid_fix_nx_cap(struct kvm_vcpu *vcpu)
2414 break; 2432 break;
2415 } 2433 }
2416 } 2434 }
2417 if (entry && (entry->edx & EFER_NX) && !(efer & EFER_NX)) { 2435 if (entry && (entry->edx & (1 << 20)) && !(efer & EFER_NX)) {
2418 entry->edx &= ~(1 << 20); 2436 entry->edx &= ~(1 << 20);
2419 printk(KERN_INFO ": guest NX capability removed\n"); 2437 printk(KERN_INFO "kvm: guest NX capability removed\n");
2420 } 2438 }
2421} 2439}
2422 2440
diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c
index 1b800fc00342..1f979cb0df31 100644
--- a/drivers/kvm/x86_emulate.c
+++ b/drivers/kvm/x86_emulate.c
@@ -1178,6 +1178,8 @@ pop_instruction:
1178twobyte_insn: 1178twobyte_insn:
1179 switch (b) { 1179 switch (b) {
1180 case 0x01: /* lgdt, lidt, lmsw */ 1180 case 0x01: /* lgdt, lidt, lmsw */
1181 /* Disable writeback. */
1182 no_wb = 1;
1181 switch (modrm_reg) { 1183 switch (modrm_reg) {
1182 u16 size; 1184 u16 size;
1183 unsigned long address; 1185 unsigned long address;
diff --git a/drivers/lguest/Kconfig b/drivers/lguest/Kconfig
index 43d901fdc77f..888205c3f76b 100644
--- a/drivers/lguest/Kconfig
+++ b/drivers/lguest/Kconfig
@@ -1,6 +1,6 @@
1config LGUEST 1config LGUEST
2 tristate "Linux hypervisor example code" 2 tristate "Linux hypervisor example code"
3 depends on X86 && PARAVIRT && NET && EXPERIMENTAL && !X86_PAE 3 depends on X86 && PARAVIRT && EXPERIMENTAL && !X86_PAE
4 select LGUEST_GUEST 4 select LGUEST_GUEST
5 select HVC_DRIVER 5 select HVC_DRIVER
6 ---help--- 6 ---help---
@@ -18,3 +18,11 @@ config LGUEST_GUEST
18 The guest needs code built-in, even if the host has lguest 18 The guest needs code built-in, even if the host has lguest
19 support as a module. The drivers are tiny, so we build them 19 support as a module. The drivers are tiny, so we build them
20 in too. 20 in too.
21
22config LGUEST_NET
23 tristate
24 depends on LGUEST_GUEST && NET
25
26config LGUEST_BLOCK
27 tristate
28 depends on LGUEST_GUEST && BLOCK
diff --git a/drivers/lguest/Makefile b/drivers/lguest/Makefile
index 55382c7d799c..e5047471c334 100644
--- a/drivers/lguest/Makefile
+++ b/drivers/lguest/Makefile
@@ -5,3 +5,15 @@ obj-$(CONFIG_LGUEST_GUEST) += lguest.o lguest_asm.o lguest_bus.o
5obj-$(CONFIG_LGUEST) += lg.o 5obj-$(CONFIG_LGUEST) += lg.o
6lg-y := core.o hypercalls.o page_tables.o interrupts_and_traps.o \ 6lg-y := core.o hypercalls.o page_tables.o interrupts_and_traps.o \
7 segments.o io.o lguest_user.o switcher.o 7 segments.o io.o lguest_user.o switcher.o
8
9Preparation Preparation!: PREFIX=P
10Guest: PREFIX=G
11Drivers: PREFIX=D
12Launcher: PREFIX=L
13Host: PREFIX=H
14Switcher: PREFIX=S
15Mastery: PREFIX=M
16Beer:
17 @for f in Preparation Guest Drivers Launcher Host Switcher Mastery; do echo "{==- $$f -==}"; make -s $$f; done; echo "{==-==}"
18Preparation Preparation! Guest Drivers Launcher Host Switcher Mastery:
19 @sh ../../Documentation/lguest/extract $(PREFIX) `find ../../* -name '*.[chS]' -wholename '*lguest*'`
diff --git a/drivers/lguest/README b/drivers/lguest/README
new file mode 100644
index 000000000000..b7db39a64c66
--- /dev/null
+++ b/drivers/lguest/README
@@ -0,0 +1,47 @@
1Welcome, friend reader, to lguest.
2
3Lguest is an adventure, with you, the reader, as Hero. I can't think of many
45000-line projects which offer both such capability and glimpses of future
5potential; it is an exciting time to be delving into the source!
6
7But be warned; this is an arduous journey of several hours or more! And as we
8know, all true Heroes are driven by a Noble Goal. Thus I offer a Beer (or
9equivalent) to anyone I meet who has completed this documentation.
10
11So get comfortable and keep your wits about you (both quick and humorous).
12Along your way to the Noble Goal, you will also gain masterly insight into
13lguest, and hypervisors and x86 virtualization in general.
14
15Our Quest is in seven parts: (best read with C highlighting turned on)
16
17I) Preparation
18 - In which our potential hero is flown quickly over the landscape for a
19 taste of its scope. Suitable for the armchair coders and other such
20 persons of faint constitution.
21
22II) Guest
23 - Where we encounter the first tantalising wisps of code, and come to
24 understand the details of the life of a Guest kernel.
25
26III) Drivers
27 - Whereby the Guest finds its voice and become useful, and our
28 understanding of the Guest is completed.
29
30IV) Launcher
31 - Where we trace back to the creation of the Guest, and thus begin our
32 understanding of the Host.
33
34V) Host
35 - Where we master the Host code, through a long and tortuous journey.
36 Indeed, it is here that our hero is tested in the Bit of Despair.
37
38VI) Switcher
39 - Where our understanding of the intertwined nature of Guests and Hosts
40 is completed.
41
42VII) Mastery
43 - Where our fully fledged hero grapples with the Great Question:
44 "What next?"
45
46make Preparation!
47Rusty Russell.
diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
index ce909ec57499..0a46e8837d9a 100644
--- a/drivers/lguest/core.c
+++ b/drivers/lguest/core.c
@@ -1,5 +1,8 @@
1/* World's simplest hypervisor, to test paravirt_ops and show 1/*P:400 This contains run_guest() which actually calls into the Host<->Guest
2 * unbelievers that virtualization is the future. Plus, it's fun! */ 2 * Switcher and analyzes the return, such as determining if the Guest wants the
3 * Host to do something. This file also contains useful helper routines, and a
4 * couple of non-obvious setup and teardown pieces which were implemented after
5 * days of debugging pain. :*/
3#include <linux/module.h> 6#include <linux/module.h>
4#include <linux/stringify.h> 7#include <linux/stringify.h>
5#include <linux/stddef.h> 8#include <linux/stddef.h>
@@ -61,11 +64,33 @@ static struct lguest_pages *lguest_pages(unsigned int cpu)
61 (SWITCHER_ADDR + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]); 64 (SWITCHER_ADDR + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]);
62} 65}
63 66
67/*H:010 We need to set up the Switcher at a high virtual address. Remember the
68 * Switcher is a few hundred bytes of assembler code which actually changes the
69 * CPU to run the Guest, and then changes back to the Host when a trap or
70 * interrupt happens.
71 *
72 * The Switcher code must be at the same virtual address in the Guest as the
73 * Host since it will be running as the switchover occurs.
74 *
75 * Trying to map memory at a particular address is an unusual thing to do, so
76 * it's not a simple one-liner. We also set up the per-cpu parts of the
77 * Switcher here.
78 */
64static __init int map_switcher(void) 79static __init int map_switcher(void)
65{ 80{
66 int i, err; 81 int i, err;
67 struct page **pagep; 82 struct page **pagep;
68 83
84 /*
85 * Map the Switcher in to high memory.
86 *
87 * It turns out that if we choose the address 0xFFC00000 (4MB under the
88 * top virtual address), it makes setting up the page tables really
89 * easy.
90 */
91
92 /* We allocate an array of "struct page"s. map_vm_area() wants the
93 * pages in this form, rather than just an array of pointers. */
69 switcher_page = kmalloc(sizeof(switcher_page[0])*TOTAL_SWITCHER_PAGES, 94 switcher_page = kmalloc(sizeof(switcher_page[0])*TOTAL_SWITCHER_PAGES,
70 GFP_KERNEL); 95 GFP_KERNEL);
71 if (!switcher_page) { 96 if (!switcher_page) {
@@ -73,6 +98,8 @@ static __init int map_switcher(void)
73 goto out; 98 goto out;
74 } 99 }
75 100
101 /* Now we actually allocate the pages. The Guest will see these pages,
102 * so we make sure they're zeroed. */
76 for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) { 103 for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) {
77 unsigned long addr = get_zeroed_page(GFP_KERNEL); 104 unsigned long addr = get_zeroed_page(GFP_KERNEL);
78 if (!addr) { 105 if (!addr) {
@@ -82,6 +109,9 @@ static __init int map_switcher(void)
82 switcher_page[i] = virt_to_page(addr); 109 switcher_page[i] = virt_to_page(addr);
83 } 110 }
84 111
112 /* Now we reserve the "virtual memory area" we want: 0xFFC00000
113 * (SWITCHER_ADDR). We might not get it in theory, but in practice
114 * it's worked so far. */
85 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE, 115 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
86 VM_ALLOC, SWITCHER_ADDR, VMALLOC_END); 116 VM_ALLOC, SWITCHER_ADDR, VMALLOC_END);
87 if (!switcher_vma) { 117 if (!switcher_vma) {
@@ -90,49 +120,105 @@ static __init int map_switcher(void)
90 goto free_pages; 120 goto free_pages;
91 } 121 }
92 122
123 /* This code actually sets up the pages we've allocated to appear at
124 * SWITCHER_ADDR. map_vm_area() takes the vma we allocated above, the
125 * kind of pages we're mapping (kernel pages), and a pointer to our
126 * array of struct pages. It increments that pointer, but we don't
127 * care. */
93 pagep = switcher_page; 128 pagep = switcher_page;
94 err = map_vm_area(switcher_vma, PAGE_KERNEL, &pagep); 129 err = map_vm_area(switcher_vma, PAGE_KERNEL, &pagep);
95 if (err) { 130 if (err) {
96 printk("lguest: map_vm_area failed: %i\n", err); 131 printk("lguest: map_vm_area failed: %i\n", err);
97 goto free_vma; 132 goto free_vma;
98 } 133 }
134
135 /* Now the switcher is mapped at the right address, we can't fail!
136 * Copy in the compiled-in Switcher code (from switcher.S). */
99 memcpy(switcher_vma->addr, start_switcher_text, 137 memcpy(switcher_vma->addr, start_switcher_text,
100 end_switcher_text - start_switcher_text); 138 end_switcher_text - start_switcher_text);
101 139
102 /* Fix up IDT entries to point into copied text. */ 140 /* Most of the switcher.S doesn't care that it's been moved; on Intel,
141 * jumps are relative, and it doesn't access any references to external
142 * code or data.
143 *
144 * The only exception is the interrupt handlers in switcher.S: their
145 * addresses are placed in a table (default_idt_entries), so we need to
146 * update the table with the new addresses. switcher_offset() is a
147 * convenience function which returns the distance between the builtin
148 * switcher code and the high-mapped copy we just made. */
103 for (i = 0; i < IDT_ENTRIES; i++) 149 for (i = 0; i < IDT_ENTRIES; i++)
104 default_idt_entries[i] += switcher_offset(); 150 default_idt_entries[i] += switcher_offset();
105 151
152 /*
153 * Set up the Switcher's per-cpu areas.
154 *
155 * Each CPU gets two pages of its own within the high-mapped region
156 * (aka. "struct lguest_pages"). Much of this can be initialized now,
157 * but some depends on what Guest we are running (which is set up in
158 * copy_in_guest_info()).
159 */
106 for_each_possible_cpu(i) { 160 for_each_possible_cpu(i) {
161 /* lguest_pages() returns this CPU's two pages. */
107 struct lguest_pages *pages = lguest_pages(i); 162 struct lguest_pages *pages = lguest_pages(i);
163 /* This is a convenience pointer to make the code fit one
164 * statement to a line. */
108 struct lguest_ro_state *state = &pages->state; 165 struct lguest_ro_state *state = &pages->state;
109 166
110 /* These fields are static: rest done in copy_in_guest_info */ 167 /* The Global Descriptor Table: the Host has a different one
168 * for each CPU. We keep a descriptor for the GDT which says
169 * where it is and how big it is (the size is actually the last
170 * byte, not the size, hence the "-1"). */
111 state->host_gdt_desc.size = GDT_SIZE-1; 171 state->host_gdt_desc.size = GDT_SIZE-1;
112 state->host_gdt_desc.address = (long)get_cpu_gdt_table(i); 172 state->host_gdt_desc.address = (long)get_cpu_gdt_table(i);
173
174 /* All CPUs on the Host use the same Interrupt Descriptor
175 * Table, so we just use store_idt(), which gets this CPU's IDT
176 * descriptor. */
113 store_idt(&state->host_idt_desc); 177 store_idt(&state->host_idt_desc);
178
179 /* The descriptors for the Guest's GDT and IDT can be filled
180 * out now, too. We copy the GDT & IDT into ->guest_gdt and
181 * ->guest_idt before actually running the Guest. */
114 state->guest_idt_desc.size = sizeof(state->guest_idt)-1; 182 state->guest_idt_desc.size = sizeof(state->guest_idt)-1;
115 state->guest_idt_desc.address = (long)&state->guest_idt; 183 state->guest_idt_desc.address = (long)&state->guest_idt;
116 state->guest_gdt_desc.size = sizeof(state->guest_gdt)-1; 184 state->guest_gdt_desc.size = sizeof(state->guest_gdt)-1;
117 state->guest_gdt_desc.address = (long)&state->guest_gdt; 185 state->guest_gdt_desc.address = (long)&state->guest_gdt;
186
187 /* We know where we want the stack to be when the Guest enters
188 * the switcher: in pages->regs. The stack grows upwards, so
189 * we start it at the end of that structure. */
118 state->guest_tss.esp0 = (long)(&pages->regs + 1); 190 state->guest_tss.esp0 = (long)(&pages->regs + 1);
191 /* And this is the GDT entry to use for the stack: we keep a
192 * couple of special LGUEST entries. */
119 state->guest_tss.ss0 = LGUEST_DS; 193 state->guest_tss.ss0 = LGUEST_DS;
120 /* No I/O for you! */ 194
195 /* x86 can have a finegrained bitmap which indicates what I/O
196 * ports the process can use. We set it to the end of our
197 * structure, meaning "none". */
121 state->guest_tss.io_bitmap_base = sizeof(state->guest_tss); 198 state->guest_tss.io_bitmap_base = sizeof(state->guest_tss);
199
200 /* Some GDT entries are the same across all Guests, so we can
201 * set them up now. */
122 setup_default_gdt_entries(state); 202 setup_default_gdt_entries(state);
203 /* Most IDT entries are the same for all Guests, too.*/
123 setup_default_idt_entries(state, default_idt_entries); 204 setup_default_idt_entries(state, default_idt_entries);
124 205
125 /* Setup LGUEST segments on all cpus */ 206 /* The Host needs to be able to use the LGUEST segments on this
207 * CPU, too, so put them in the Host GDT. */
126 get_cpu_gdt_table(i)[GDT_ENTRY_LGUEST_CS] = FULL_EXEC_SEGMENT; 208 get_cpu_gdt_table(i)[GDT_ENTRY_LGUEST_CS] = FULL_EXEC_SEGMENT;
127 get_cpu_gdt_table(i)[GDT_ENTRY_LGUEST_DS] = FULL_SEGMENT; 209 get_cpu_gdt_table(i)[GDT_ENTRY_LGUEST_DS] = FULL_SEGMENT;
128 } 210 }
129 211
130 /* Initialize entry point into switcher. */ 212 /* In the Switcher, we want the %cs segment register to use the
213 * LGUEST_CS GDT entry: we've put that in the Host and Guest GDTs, so
214 * it will be undisturbed when we switch. To change %cs and jump we
215 * need this structure to feed to Intel's "lcall" instruction. */
131 lguest_entry.offset = (long)switch_to_guest + switcher_offset(); 216 lguest_entry.offset = (long)switch_to_guest + switcher_offset();
132 lguest_entry.segment = LGUEST_CS; 217 lguest_entry.segment = LGUEST_CS;
133 218
134 printk(KERN_INFO "lguest: mapped switcher at %p\n", 219 printk(KERN_INFO "lguest: mapped switcher at %p\n",
135 switcher_vma->addr); 220 switcher_vma->addr);
221 /* And we succeeded... */
136 return 0; 222 return 0;
137 223
138free_vma: 224free_vma:
@@ -146,35 +232,58 @@ free_some_pages:
146out: 232out:
147 return err; 233 return err;
148} 234}
235/*:*/
149 236
237/* Cleaning up the mapping when the module is unloaded is almost...
238 * too easy. */
150static void unmap_switcher(void) 239static void unmap_switcher(void)
151{ 240{
152 unsigned int i; 241 unsigned int i;
153 242
243 /* vunmap() undoes *both* map_vm_area() and __get_vm_area(). */
154 vunmap(switcher_vma->addr); 244 vunmap(switcher_vma->addr);
245 /* Now we just need to free the pages we copied the switcher into */
155 for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) 246 for (i = 0; i < TOTAL_SWITCHER_PAGES; i++)
156 __free_pages(switcher_page[i], 0); 247 __free_pages(switcher_page[i], 0);
157} 248}
158 249
159/* IN/OUT insns: enough to get us past boot-time probing. */ 250/*H:130 Our Guest is usually so well behaved; it never tries to do things it
251 * isn't allowed to. Unfortunately, "struct paravirt_ops" isn't quite
252 * complete, because it doesn't contain replacements for the Intel I/O
253 * instructions. As a result, the Guest sometimes fumbles across one during
254 * the boot process as it probes for various things which are usually attached
255 * to a PC.
256 *
257 * When the Guest uses one of these instructions, we get trap #13 (General
258 * Protection Fault) and come here. We see if it's one of those troublesome
259 * instructions and skip over it. We return true if we did. */
160static int emulate_insn(struct lguest *lg) 260static int emulate_insn(struct lguest *lg)
161{ 261{
162 u8 insn; 262 u8 insn;
163 unsigned int insnlen = 0, in = 0, shift = 0; 263 unsigned int insnlen = 0, in = 0, shift = 0;
264 /* The eip contains the *virtual* address of the Guest's instruction:
265 * guest_pa just subtracts the Guest's page_offset. */
164 unsigned long physaddr = guest_pa(lg, lg->regs->eip); 266 unsigned long physaddr = guest_pa(lg, lg->regs->eip);
165 267
166 /* This only works for addresses in linear mapping... */ 268 /* The guest_pa() function only works for Guest kernel addresses, but
269 * that's all we're trying to do anyway. */
167 if (lg->regs->eip < lg->page_offset) 270 if (lg->regs->eip < lg->page_offset)
168 return 0; 271 return 0;
272
273 /* Decoding x86 instructions is icky. */
169 lgread(lg, &insn, physaddr, 1); 274 lgread(lg, &insn, physaddr, 1);
170 275
171 /* Operand size prefix means it's actually for ax. */ 276 /* 0x66 is an "operand prefix". It means it's using the upper 16 bits
277 of the eax register. */
172 if (insn == 0x66) { 278 if (insn == 0x66) {
173 shift = 16; 279 shift = 16;
280 /* The instruction is 1 byte so far, read the next byte. */
174 insnlen = 1; 281 insnlen = 1;
175 lgread(lg, &insn, physaddr + insnlen, 1); 282 lgread(lg, &insn, physaddr + insnlen, 1);
176 } 283 }
177 284
285 /* We can ignore the lower bit for the moment and decode the 4 opcodes
286 * we need to emulate. */
178 switch (insn & 0xFE) { 287 switch (insn & 0xFE) {
179 case 0xE4: /* in <next byte>,%al */ 288 case 0xE4: /* in <next byte>,%al */
180 insnlen += 2; 289 insnlen += 2;
@@ -191,9 +300,13 @@ static int emulate_insn(struct lguest *lg)
191 insnlen += 1; 300 insnlen += 1;
192 break; 301 break;
193 default: 302 default:
303 /* OK, we don't know what this is, can't emulate. */
194 return 0; 304 return 0;
195 } 305 }
196 306
307 /* If it was an "IN" instruction, they expect the result to be read
308 * into %eax, so we change %eax. We always return all-ones, which
309 * traditionally means "there's nothing there". */
197 if (in) { 310 if (in) {
198 /* Lower bit tells is whether it's a 16 or 32 bit access */ 311 /* Lower bit tells is whether it's a 16 or 32 bit access */
199 if (insn & 0x1) 312 if (insn & 0x1)
@@ -201,28 +314,46 @@ static int emulate_insn(struct lguest *lg)
201 else 314 else
202 lg->regs->eax |= (0xFFFF << shift); 315 lg->regs->eax |= (0xFFFF << shift);
203 } 316 }
317 /* Finally, we've "done" the instruction, so move past it. */
204 lg->regs->eip += insnlen; 318 lg->regs->eip += insnlen;
319 /* Success! */
205 return 1; 320 return 1;
206} 321}
207 322/*:*/
323
324/*L:305
325 * Dealing With Guest Memory.
326 *
327 * When the Guest gives us (what it thinks is) a physical address, we can use
328 * the normal copy_from_user() & copy_to_user() on that address: remember,
329 * Guest physical == Launcher virtual.
330 *
331 * But we can't trust the Guest: it might be trying to access the Launcher
332 * code. We have to check that the range is below the pfn_limit the Launcher
333 * gave us. We have to make sure that addr + len doesn't give us a false
334 * positive by overflowing, too. */
208int lguest_address_ok(const struct lguest *lg, 335int lguest_address_ok(const struct lguest *lg,
209 unsigned long addr, unsigned long len) 336 unsigned long addr, unsigned long len)
210{ 337{
211 return (addr+len) / PAGE_SIZE < lg->pfn_limit && (addr+len >= addr); 338 return (addr+len) / PAGE_SIZE < lg->pfn_limit && (addr+len >= addr);
212} 339}
213 340
214/* Just like get_user, but don't let guest access lguest binary. */ 341/* This is a convenient routine to get a 32-bit value from the Guest (a very
342 * common operation). Here we can see how useful the kill_lguest() routine we
343 * met in the Launcher can be: we return a random value (0) instead of needing
344 * to return an error. */
215u32 lgread_u32(struct lguest *lg, unsigned long addr) 345u32 lgread_u32(struct lguest *lg, unsigned long addr)
216{ 346{
217 u32 val = 0; 347 u32 val = 0;
218 348
219 /* Don't let them access lguest binary */ 349 /* Don't let them access lguest binary. */
220 if (!lguest_address_ok(lg, addr, sizeof(val)) 350 if (!lguest_address_ok(lg, addr, sizeof(val))
221 || get_user(val, (u32 __user *)addr) != 0) 351 || get_user(val, (u32 __user *)addr) != 0)
222 kill_guest(lg, "bad read address %#lx", addr); 352 kill_guest(lg, "bad read address %#lx", addr);
223 return val; 353 return val;
224} 354}
225 355
356/* Same thing for writing a value. */
226void lgwrite_u32(struct lguest *lg, unsigned long addr, u32 val) 357void lgwrite_u32(struct lguest *lg, unsigned long addr, u32 val)
227{ 358{
228 if (!lguest_address_ok(lg, addr, sizeof(val)) 359 if (!lguest_address_ok(lg, addr, sizeof(val))
@@ -230,6 +361,9 @@ void lgwrite_u32(struct lguest *lg, unsigned long addr, u32 val)
230 kill_guest(lg, "bad write address %#lx", addr); 361 kill_guest(lg, "bad write address %#lx", addr);
231} 362}
232 363
364/* This routine is more generic, and copies a range of Guest bytes into a
365 * buffer. If the copy_from_user() fails, we fill the buffer with zeroes, so
366 * the caller doesn't end up using uninitialized kernel memory. */
233void lgread(struct lguest *lg, void *b, unsigned long addr, unsigned bytes) 367void lgread(struct lguest *lg, void *b, unsigned long addr, unsigned bytes)
234{ 368{
235 if (!lguest_address_ok(lg, addr, bytes) 369 if (!lguest_address_ok(lg, addr, bytes)
@@ -240,6 +374,7 @@ void lgread(struct lguest *lg, void *b, unsigned long addr, unsigned bytes)
240 } 374 }
241} 375}
242 376
377/* Similarly, our generic routine to copy into a range of Guest bytes. */
243void lgwrite(struct lguest *lg, unsigned long addr, const void *b, 378void lgwrite(struct lguest *lg, unsigned long addr, const void *b,
244 unsigned bytes) 379 unsigned bytes)
245{ 380{
@@ -247,6 +382,7 @@ void lgwrite(struct lguest *lg, unsigned long addr, const void *b,
247 || copy_to_user((void __user *)addr, b, bytes) != 0) 382 || copy_to_user((void __user *)addr, b, bytes) != 0)
248 kill_guest(lg, "bad write address %#lx len %u", addr, bytes); 383 kill_guest(lg, "bad write address %#lx len %u", addr, bytes);
249} 384}
385/* (end of memory access helper routines) :*/
250 386
251static void set_ts(void) 387static void set_ts(void)
252{ 388{
@@ -257,54 +393,108 @@ static void set_ts(void)
257 write_cr0(cr0|8); 393 write_cr0(cr0|8);
258} 394}
259 395
396/*S:010
397 * We are getting close to the Switcher.
398 *
399 * Remember that each CPU has two pages which are visible to the Guest when it
400 * runs on that CPU. This has to contain the state for that Guest: we copy the
401 * state in just before we run the Guest.
402 *
403 * Each Guest has "changed" flags which indicate what has changed in the Guest
404 * since it last ran. We saw this set in interrupts_and_traps.c and
405 * segments.c.
406 */
260static void copy_in_guest_info(struct lguest *lg, struct lguest_pages *pages) 407static void copy_in_guest_info(struct lguest *lg, struct lguest_pages *pages)
261{ 408{
409 /* Copying all this data can be quite expensive. We usually run the
410 * same Guest we ran last time (and that Guest hasn't run anywhere else
411 * meanwhile). If that's not the case, we pretend everything in the
412 * Guest has changed. */
262 if (__get_cpu_var(last_guest) != lg || lg->last_pages != pages) { 413 if (__get_cpu_var(last_guest) != lg || lg->last_pages != pages) {
263 __get_cpu_var(last_guest) = lg; 414 __get_cpu_var(last_guest) = lg;
264 lg->last_pages = pages; 415 lg->last_pages = pages;
265 lg->changed = CHANGED_ALL; 416 lg->changed = CHANGED_ALL;
266 } 417 }
267 418
268 /* These are pretty cheap, so we do them unconditionally. */ 419 /* These copies are pretty cheap, so we do them unconditionally: */
420 /* Save the current Host top-level page directory. */
269 pages->state.host_cr3 = __pa(current->mm->pgd); 421 pages->state.host_cr3 = __pa(current->mm->pgd);
422 /* Set up the Guest's page tables to see this CPU's pages (and no
423 * other CPU's pages). */
270 map_switcher_in_guest(lg, pages); 424 map_switcher_in_guest(lg, pages);
425 /* Set up the two "TSS" members which tell the CPU what stack to use
426 * for traps which do directly into the Guest (ie. traps at privilege
427 * level 1). */
271 pages->state.guest_tss.esp1 = lg->esp1; 428 pages->state.guest_tss.esp1 = lg->esp1;
272 pages->state.guest_tss.ss1 = lg->ss1; 429 pages->state.guest_tss.ss1 = lg->ss1;
273 430
274 /* Copy direct trap entries. */ 431 /* Copy direct-to-Guest trap entries. */
275 if (lg->changed & CHANGED_IDT) 432 if (lg->changed & CHANGED_IDT)
276 copy_traps(lg, pages->state.guest_idt, default_idt_entries); 433 copy_traps(lg, pages->state.guest_idt, default_idt_entries);
277 434
278 /* Copy all GDT entries but the TSS. */ 435 /* Copy all GDT entries which the Guest can change. */
279 if (lg->changed & CHANGED_GDT) 436 if (lg->changed & CHANGED_GDT)
280 copy_gdt(lg, pages->state.guest_gdt); 437 copy_gdt(lg, pages->state.guest_gdt);
281 /* If only the TLS entries have changed, copy them. */ 438 /* If only the TLS entries have changed, copy them. */
282 else if (lg->changed & CHANGED_GDT_TLS) 439 else if (lg->changed & CHANGED_GDT_TLS)
283 copy_gdt_tls(lg, pages->state.guest_gdt); 440 copy_gdt_tls(lg, pages->state.guest_gdt);
284 441
442 /* Mark the Guest as unchanged for next time. */
285 lg->changed = 0; 443 lg->changed = 0;
286} 444}
287 445
446/* Finally: the code to actually call into the Switcher to run the Guest. */
288static void run_guest_once(struct lguest *lg, struct lguest_pages *pages) 447static void run_guest_once(struct lguest *lg, struct lguest_pages *pages)
289{ 448{
449 /* This is a dummy value we need for GCC's sake. */
290 unsigned int clobber; 450 unsigned int clobber;
291 451
452 /* Copy the guest-specific information into this CPU's "struct
453 * lguest_pages". */
292 copy_in_guest_info(lg, pages); 454 copy_in_guest_info(lg, pages);
293 455
294 /* Put eflags on stack, lcall does rest: suitable for iret return. */ 456 /* Now: we push the "eflags" register on the stack, then do an "lcall".
457 * This is how we change from using the kernel code segment to using
458 * the dedicated lguest code segment, as well as jumping into the
459 * Switcher.
460 *
461 * The lcall also pushes the old code segment (KERNEL_CS) onto the
462 * stack, then the address of this call. This stack layout happens to
463 * exactly match the stack of an interrupt... */
295 asm volatile("pushf; lcall *lguest_entry" 464 asm volatile("pushf; lcall *lguest_entry"
465 /* This is how we tell GCC that %eax ("a") and %ebx ("b")
466 * are changed by this routine. The "=" means output. */
296 : "=a"(clobber), "=b"(clobber) 467 : "=a"(clobber), "=b"(clobber)
468 /* %eax contains the pages pointer. ("0" refers to the
469 * 0-th argument above, ie "a"). %ebx contains the
470 * physical address of the Guest's top-level page
471 * directory. */
297 : "0"(pages), "1"(__pa(lg->pgdirs[lg->pgdidx].pgdir)) 472 : "0"(pages), "1"(__pa(lg->pgdirs[lg->pgdidx].pgdir))
473 /* We tell gcc that all these registers could change,
474 * which means we don't have to save and restore them in
475 * the Switcher. */
298 : "memory", "%edx", "%ecx", "%edi", "%esi"); 476 : "memory", "%edx", "%ecx", "%edi", "%esi");
299} 477}
478/*:*/
300 479
480/*H:030 Let's jump straight to the the main loop which runs the Guest.
481 * Remember, this is called by the Launcher reading /dev/lguest, and we keep
482 * going around and around until something interesting happens. */
301int run_guest(struct lguest *lg, unsigned long __user *user) 483int run_guest(struct lguest *lg, unsigned long __user *user)
302{ 484{
485 /* We stop running once the Guest is dead. */
303 while (!lg->dead) { 486 while (!lg->dead) {
487 /* We need to initialize this, otherwise gcc complains. It's
488 * not (yet) clever enough to see that it's initialized when we
489 * need it. */
304 unsigned int cr2 = 0; /* Damn gcc */ 490 unsigned int cr2 = 0; /* Damn gcc */
305 491
306 /* Hypercalls first: we might have been out to userspace */ 492 /* First we run any hypercalls the Guest wants done: either in
493 * the hypercall ring in "struct lguest_data", or directly by
494 * using int 31 (LGUEST_TRAP_ENTRY). */
307 do_hypercalls(lg); 495 do_hypercalls(lg);
496 /* It's possible the Guest did a SEND_DMA hypercall to the
497 * Launcher, in which case we return from the read() now. */
308 if (lg->dma_is_pending) { 498 if (lg->dma_is_pending) {
309 if (put_user(lg->pending_dma, user) || 499 if (put_user(lg->pending_dma, user) ||
310 put_user(lg->pending_key, user+1)) 500 put_user(lg->pending_key, user+1))
@@ -312,6 +502,7 @@ int run_guest(struct lguest *lg, unsigned long __user *user)
312 return sizeof(unsigned long)*2; 502 return sizeof(unsigned long)*2;
313 } 503 }
314 504
505 /* Check for signals */
315 if (signal_pending(current)) 506 if (signal_pending(current))
316 return -ERESTARTSYS; 507 return -ERESTARTSYS;
317 508
@@ -319,77 +510,154 @@ int run_guest(struct lguest *lg, unsigned long __user *user)
319 if (lg->break_out) 510 if (lg->break_out)
320 return -EAGAIN; 511 return -EAGAIN;
321 512
513 /* Check if there are any interrupts which can be delivered
514 * now: if so, this sets up the hander to be executed when we
515 * next run the Guest. */
322 maybe_do_interrupt(lg); 516 maybe_do_interrupt(lg);
323 517
518 /* All long-lived kernel loops need to check with this horrible
519 * thing called the freezer. If the Host is trying to suspend,
520 * it stops us. */
324 try_to_freeze(); 521 try_to_freeze();
325 522
523 /* Just make absolutely sure the Guest is still alive. One of
524 * those hypercalls could have been fatal, for example. */
326 if (lg->dead) 525 if (lg->dead)
327 break; 526 break;
328 527
528 /* If the Guest asked to be stopped, we sleep. The Guest's
529 * clock timer or LHCALL_BREAK from the Waker will wake us. */
329 if (lg->halted) { 530 if (lg->halted) {
330 set_current_state(TASK_INTERRUPTIBLE); 531 set_current_state(TASK_INTERRUPTIBLE);
331 schedule(); 532 schedule();
332 continue; 533 continue;
333 } 534 }
334 535
536 /* OK, now we're ready to jump into the Guest. First we put up
537 * the "Do Not Disturb" sign: */
335 local_irq_disable(); 538 local_irq_disable();
336 539
337 /* Even if *we* don't want FPU trap, guest might... */ 540 /* Remember the awfully-named TS bit? If the Guest has asked
541 * to set it we set it now, so we can trap and pass that trap
542 * to the Guest if it uses the FPU. */
338 if (lg->ts) 543 if (lg->ts)
339 set_ts(); 544 set_ts();
340 545
341 /* Don't let Guest do SYSENTER: we can't handle it. */ 546 /* SYSENTER is an optimized way of doing system calls. We
547 * can't allow it because it always jumps to privilege level 0.
548 * A normal Guest won't try it because we don't advertise it in
549 * CPUID, but a malicious Guest (or malicious Guest userspace
550 * program) could, so we tell the CPU to disable it before
551 * running the Guest. */
342 if (boot_cpu_has(X86_FEATURE_SEP)) 552 if (boot_cpu_has(X86_FEATURE_SEP))
343 wrmsr(MSR_IA32_SYSENTER_CS, 0, 0); 553 wrmsr(MSR_IA32_SYSENTER_CS, 0, 0);
344 554
555 /* Now we actually run the Guest. It will pop back out when
556 * something interesting happens, and we can examine its
557 * registers to see what it was doing. */
345 run_guest_once(lg, lguest_pages(raw_smp_processor_id())); 558 run_guest_once(lg, lguest_pages(raw_smp_processor_id()));
346 559
347 /* Save cr2 now if we page-faulted. */ 560 /* The "regs" pointer contains two extra entries which are not
561 * really registers: a trap number which says what interrupt or
562 * trap made the switcher code come back, and an error code
563 * which some traps set. */
564
565 /* If the Guest page faulted, then the cr2 register will tell
566 * us the bad virtual address. We have to grab this now,
567 * because once we re-enable interrupts an interrupt could
568 * fault and thus overwrite cr2, or we could even move off to a
569 * different CPU. */
348 if (lg->regs->trapnum == 14) 570 if (lg->regs->trapnum == 14)
349 cr2 = read_cr2(); 571 cr2 = read_cr2();
572 /* Similarly, if we took a trap because the Guest used the FPU,
573 * we have to restore the FPU it expects to see. */
350 else if (lg->regs->trapnum == 7) 574 else if (lg->regs->trapnum == 7)
351 math_state_restore(); 575 math_state_restore();
352 576
577 /* Restore SYSENTER if it's supposed to be on. */
353 if (boot_cpu_has(X86_FEATURE_SEP)) 578 if (boot_cpu_has(X86_FEATURE_SEP))
354 wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0); 579 wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0);
580
581 /* Now we're ready to be interrupted or moved to other CPUs */
355 local_irq_enable(); 582 local_irq_enable();
356 583
584 /* OK, so what happened? */
357 switch (lg->regs->trapnum) { 585 switch (lg->regs->trapnum) {
358 case 13: /* We've intercepted a GPF. */ 586 case 13: /* We've intercepted a GPF. */
587 /* Check if this was one of those annoying IN or OUT
588 * instructions which we need to emulate. If so, we
589 * just go back into the Guest after we've done it. */
359 if (lg->regs->errcode == 0) { 590 if (lg->regs->errcode == 0) {
360 if (emulate_insn(lg)) 591 if (emulate_insn(lg))
361 continue; 592 continue;
362 } 593 }
363 break; 594 break;
364 case 14: /* We've intercepted a page fault. */ 595 case 14: /* We've intercepted a page fault. */
596 /* The Guest accessed a virtual address that wasn't
597 * mapped. This happens a lot: we don't actually set
598 * up most of the page tables for the Guest at all when
599 * we start: as it runs it asks for more and more, and
600 * we set them up as required. In this case, we don't
601 * even tell the Guest that the fault happened.
602 *
603 * The errcode tells whether this was a read or a
604 * write, and whether kernel or userspace code. */
365 if (demand_page(lg, cr2, lg->regs->errcode)) 605 if (demand_page(lg, cr2, lg->regs->errcode))
366 continue; 606 continue;
367 607
368 /* If lguest_data is NULL, this won't hurt. */ 608 /* OK, it's really not there (or not OK): the Guest
609 * needs to know. We write out the cr2 value so it
610 * knows where the fault occurred.
611 *
612 * Note that if the Guest were really messed up, this
613 * could happen before it's done the INITIALIZE
614 * hypercall, so lg->lguest_data will be NULL, so
615 * &lg->lguest_data->cr2 will be address 8. Writing
616 * into that address won't hurt the Host at all,
617 * though. */
369 if (put_user(cr2, &lg->lguest_data->cr2)) 618 if (put_user(cr2, &lg->lguest_data->cr2))
370 kill_guest(lg, "Writing cr2"); 619 kill_guest(lg, "Writing cr2");
371 break; 620 break;
372 case 7: /* We've intercepted a Device Not Available fault. */ 621 case 7: /* We've intercepted a Device Not Available fault. */
373 /* If they don't want to know, just absorb it. */ 622 /* If the Guest doesn't want to know, we already
623 * restored the Floating Point Unit, so we just
624 * continue without telling it. */
374 if (!lg->ts) 625 if (!lg->ts)
375 continue; 626 continue;
376 break; 627 break;
377 case 32 ... 255: /* Real interrupt, fall thru */ 628 case 32 ... 255:
629 /* These values mean a real interrupt occurred, in
630 * which case the Host handler has already been run.
631 * We just do a friendly check if another process
632 * should now be run, then fall through to loop
633 * around: */
378 cond_resched(); 634 cond_resched();
379 case LGUEST_TRAP_ENTRY: /* Handled at top of loop */ 635 case LGUEST_TRAP_ENTRY: /* Handled at top of loop */
380 continue; 636 continue;
381 } 637 }
382 638
639 /* If we get here, it's a trap the Guest wants to know
640 * about. */
383 if (deliver_trap(lg, lg->regs->trapnum)) 641 if (deliver_trap(lg, lg->regs->trapnum))
384 continue; 642 continue;
385 643
644 /* If the Guest doesn't have a handler (either it hasn't
645 * registered any yet, or it's one of the faults we don't let
646 * it handle), it dies with a cryptic error message. */
386 kill_guest(lg, "unhandled trap %li at %#lx (%#lx)", 647 kill_guest(lg, "unhandled trap %li at %#lx (%#lx)",
387 lg->regs->trapnum, lg->regs->eip, 648 lg->regs->trapnum, lg->regs->eip,
388 lg->regs->trapnum == 14 ? cr2 : lg->regs->errcode); 649 lg->regs->trapnum == 14 ? cr2 : lg->regs->errcode);
389 } 650 }
651 /* The Guest is dead => "No such file or directory" */
390 return -ENOENT; 652 return -ENOENT;
391} 653}
392 654
655/* Now we can look at each of the routines this calls, in increasing order of
656 * complexity: do_hypercalls(), emulate_insn(), maybe_do_interrupt(),
657 * deliver_trap() and demand_page(). After all those, we'll be ready to
658 * examine the Switcher, and our philosophical understanding of the Host/Guest
659 * duality will be complete. :*/
660
393int find_free_guest(void) 661int find_free_guest(void)
394{ 662{
395 unsigned int i; 663 unsigned int i;
@@ -407,55 +675,96 @@ static void adjust_pge(void *on)
407 write_cr4(read_cr4() & ~X86_CR4_PGE); 675 write_cr4(read_cr4() & ~X86_CR4_PGE);
408} 676}
409 677
678/*H:000
679 * Welcome to the Host!
680 *
681 * By this point your brain has been tickled by the Guest code and numbed by
682 * the Launcher code; prepare for it to be stretched by the Host code. This is
683 * the heart. Let's begin at the initialization routine for the Host's lg
684 * module.
685 */
410static int __init init(void) 686static int __init init(void)
411{ 687{
412 int err; 688 int err;
413 689
690 /* Lguest can't run under Xen, VMI or itself. It does Tricky Stuff. */
414 if (paravirt_enabled()) { 691 if (paravirt_enabled()) {
415 printk("lguest is afraid of %s\n", paravirt_ops.name); 692 printk("lguest is afraid of %s\n", paravirt_ops.name);
416 return -EPERM; 693 return -EPERM;
417 } 694 }
418 695
696 /* First we put the Switcher up in very high virtual memory. */
419 err = map_switcher(); 697 err = map_switcher();
420 if (err) 698 if (err)
421 return err; 699 return err;
422 700
701 /* Now we set up the pagetable implementation for the Guests. */
423 err = init_pagetables(switcher_page, SHARED_SWITCHER_PAGES); 702 err = init_pagetables(switcher_page, SHARED_SWITCHER_PAGES);
424 if (err) { 703 if (err) {
425 unmap_switcher(); 704 unmap_switcher();
426 return err; 705 return err;
427 } 706 }
707
708 /* The I/O subsystem needs some things initialized. */
428 lguest_io_init(); 709 lguest_io_init();
429 710
711 /* /dev/lguest needs to be registered. */
430 err = lguest_device_init(); 712 err = lguest_device_init();
431 if (err) { 713 if (err) {
432 free_pagetables(); 714 free_pagetables();
433 unmap_switcher(); 715 unmap_switcher();
434 return err; 716 return err;
435 } 717 }
718
719 /* Finally, we need to turn off "Page Global Enable". PGE is an
720 * optimization where page table entries are specially marked to show
721 * they never change. The Host kernel marks all the kernel pages this
722 * way because it's always present, even when userspace is running.
723 *
724 * Lguest breaks this: unbeknownst to the rest of the Host kernel, we
725 * switch to the Guest kernel. If you don't disable this on all CPUs,
726 * you'll get really weird bugs that you'll chase for two days.
727 *
728 * I used to turn PGE off every time we switched to the Guest and back
729 * on when we return, but that slowed the Switcher down noticibly. */
730
731 /* We don't need the complexity of CPUs coming and going while we're
732 * doing this. */
436 lock_cpu_hotplug(); 733 lock_cpu_hotplug();
437 if (cpu_has_pge) { /* We have a broader idea of "global". */ 734 if (cpu_has_pge) { /* We have a broader idea of "global". */
735 /* Remember that this was originally set (for cleanup). */
438 cpu_had_pge = 1; 736 cpu_had_pge = 1;
737 /* adjust_pge is a helper function which sets or unsets the PGE
738 * bit on its CPU, depending on the argument (0 == unset). */
439 on_each_cpu(adjust_pge, (void *)0, 0, 1); 739 on_each_cpu(adjust_pge, (void *)0, 0, 1);
740 /* Turn off the feature in the global feature set. */
440 clear_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability); 741 clear_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability);
441 } 742 }
442 unlock_cpu_hotplug(); 743 unlock_cpu_hotplug();
744
745 /* All good! */
443 return 0; 746 return 0;
444} 747}
445 748
749/* Cleaning up is just the same code, backwards. With a little French. */
446static void __exit fini(void) 750static void __exit fini(void)
447{ 751{
448 lguest_device_remove(); 752 lguest_device_remove();
449 free_pagetables(); 753 free_pagetables();
450 unmap_switcher(); 754 unmap_switcher();
755
756 /* If we had PGE before we started, turn it back on now. */
451 lock_cpu_hotplug(); 757 lock_cpu_hotplug();
452 if (cpu_had_pge) { 758 if (cpu_had_pge) {
453 set_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability); 759 set_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability);
760 /* adjust_pge's argument "1" means set PGE. */
454 on_each_cpu(adjust_pge, (void *)1, 0, 1); 761 on_each_cpu(adjust_pge, (void *)1, 0, 1);
455 } 762 }
456 unlock_cpu_hotplug(); 763 unlock_cpu_hotplug();
457} 764}
458 765
766/* The Host side of lguest can be a module. This is a nice way for people to
767 * play with it. */
459module_init(init); 768module_init(init);
460module_exit(fini); 769module_exit(fini);
461MODULE_LICENSE("GPL"); 770MODULE_LICENSE("GPL");
diff --git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c
index ea52ca451f74..db6caace3b9c 100644
--- a/drivers/lguest/hypercalls.c
+++ b/drivers/lguest/hypercalls.c
@@ -1,5 +1,10 @@
1/* Actual hypercalls, which allow guests to actually do something. 1/*P:500 Just as userspace programs request kernel operations through a system
2 Copyright (C) 2006 Rusty Russell IBM Corporation 2 * call, the Guest requests Host operations through a "hypercall". You might
3 * notice this nomenclature doesn't really follow any logic, but the name has
4 * been around for long enough that we're stuck with it. As you'd expect, this
5 * code is basically a one big switch statement. :*/
6
7/* Copyright (C) 2006 Rusty Russell IBM Corporation
3 8
4 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
@@ -23,37 +28,55 @@
23#include <irq_vectors.h> 28#include <irq_vectors.h>
24#include "lg.h" 29#include "lg.h"
25 30
31/*H:120 This is the core hypercall routine: where the Guest gets what it
32 * wants. Or gets killed. Or, in the case of LHCALL_CRASH, both.
33 *
34 * Remember from the Guest: %eax == which call to make, and the arguments are
35 * packed into %edx, %ebx and %ecx if needed. */
26static void do_hcall(struct lguest *lg, struct lguest_regs *regs) 36static void do_hcall(struct lguest *lg, struct lguest_regs *regs)
27{ 37{
28 switch (regs->eax) { 38 switch (regs->eax) {
29 case LHCALL_FLUSH_ASYNC: 39 case LHCALL_FLUSH_ASYNC:
40 /* This call does nothing, except by breaking out of the Guest
41 * it makes us process all the asynchronous hypercalls. */
30 break; 42 break;
31 case LHCALL_LGUEST_INIT: 43 case LHCALL_LGUEST_INIT:
44 /* You can't get here unless you're already initialized. Don't
45 * do that. */
32 kill_guest(lg, "already have lguest_data"); 46 kill_guest(lg, "already have lguest_data");
33 break; 47 break;
34 case LHCALL_CRASH: { 48 case LHCALL_CRASH: {
49 /* Crash is such a trivial hypercall that we do it in four
50 * lines right here. */
35 char msg[128]; 51 char msg[128];
52 /* If the lgread fails, it will call kill_guest() itself; the
53 * kill_guest() with the message will be ignored. */
36 lgread(lg, msg, regs->edx, sizeof(msg)); 54 lgread(lg, msg, regs->edx, sizeof(msg));
37 msg[sizeof(msg)-1] = '\0'; 55 msg[sizeof(msg)-1] = '\0';
38 kill_guest(lg, "CRASH: %s", msg); 56 kill_guest(lg, "CRASH: %s", msg);
39 break; 57 break;
40 } 58 }
41 case LHCALL_FLUSH_TLB: 59 case LHCALL_FLUSH_TLB:
60 /* FLUSH_TLB comes in two flavors, depending on the
61 * argument: */
42 if (regs->edx) 62 if (regs->edx)
43 guest_pagetable_clear_all(lg); 63 guest_pagetable_clear_all(lg);
44 else 64 else
45 guest_pagetable_flush_user(lg); 65 guest_pagetable_flush_user(lg);
46 break; 66 break;
47 case LHCALL_GET_WALLCLOCK: {
48 struct timespec ts;
49 ktime_get_real_ts(&ts);
50 regs->eax = ts.tv_sec;
51 break;
52 }
53 case LHCALL_BIND_DMA: 67 case LHCALL_BIND_DMA:
68 /* BIND_DMA really wants four arguments, but it's the only call
69 * which does. So the Guest packs the number of buffers and
70 * the interrupt number into the final argument, and we decode
71 * it here. This can legitimately fail, since we currently
72 * place a limit on the number of DMA pools a Guest can have.
73 * So we return true or false from this call. */
54 regs->eax = bind_dma(lg, regs->edx, regs->ebx, 74 regs->eax = bind_dma(lg, regs->edx, regs->ebx,
55 regs->ecx >> 8, regs->ecx & 0xFF); 75 regs->ecx >> 8, regs->ecx & 0xFF);
56 break; 76 break;
77
78 /* All these calls simply pass the arguments through to the right
79 * routines. */
57 case LHCALL_SEND_DMA: 80 case LHCALL_SEND_DMA:
58 send_dma(lg, regs->edx, regs->ebx); 81 send_dma(lg, regs->edx, regs->ebx);
59 break; 82 break;
@@ -81,10 +104,13 @@ static void do_hcall(struct lguest *lg, struct lguest_regs *regs)
81 case LHCALL_SET_CLOCKEVENT: 104 case LHCALL_SET_CLOCKEVENT:
82 guest_set_clockevent(lg, regs->edx); 105 guest_set_clockevent(lg, regs->edx);
83 break; 106 break;
107
84 case LHCALL_TS: 108 case LHCALL_TS:
109 /* This sets the TS flag, as we saw used in run_guest(). */
85 lg->ts = regs->edx; 110 lg->ts = regs->edx;
86 break; 111 break;
87 case LHCALL_HALT: 112 case LHCALL_HALT:
113 /* Similarly, this sets the halted flag for run_guest(). */
88 lg->halted = 1; 114 lg->halted = 1;
89 break; 115 break;
90 default: 116 default:
@@ -92,25 +118,42 @@ static void do_hcall(struct lguest *lg, struct lguest_regs *regs)
92 } 118 }
93} 119}
94 120
95/* We always do queued calls before actual hypercall. */ 121/* Asynchronous hypercalls are easy: we just look in the array in the Guest's
122 * "struct lguest_data" and see if there are any new ones marked "ready".
123 *
124 * We are careful to do these in order: obviously we respect the order the
125 * Guest put them in the ring, but we also promise the Guest that they will
126 * happen before any normal hypercall (which is why we check this before
127 * checking for a normal hcall). */
96static void do_async_hcalls(struct lguest *lg) 128static void do_async_hcalls(struct lguest *lg)
97{ 129{
98 unsigned int i; 130 unsigned int i;
99 u8 st[LHCALL_RING_SIZE]; 131 u8 st[LHCALL_RING_SIZE];
100 132
133 /* For simplicity, we copy the entire call status array in at once. */
101 if (copy_from_user(&st, &lg->lguest_data->hcall_status, sizeof(st))) 134 if (copy_from_user(&st, &lg->lguest_data->hcall_status, sizeof(st)))
102 return; 135 return;
103 136
137
138 /* We process "struct lguest_data"s hcalls[] ring once. */
104 for (i = 0; i < ARRAY_SIZE(st); i++) { 139 for (i = 0; i < ARRAY_SIZE(st); i++) {
105 struct lguest_regs regs; 140 struct lguest_regs regs;
141 /* We remember where we were up to from last time. This makes
142 * sure that the hypercalls are done in the order the Guest
143 * places them in the ring. */
106 unsigned int n = lg->next_hcall; 144 unsigned int n = lg->next_hcall;
107 145
146 /* 0xFF means there's no call here (yet). */
108 if (st[n] == 0xFF) 147 if (st[n] == 0xFF)
109 break; 148 break;
110 149
150 /* OK, we have hypercall. Increment the "next_hcall" cursor,
151 * and wrap back to 0 if we reach the end. */
111 if (++lg->next_hcall == LHCALL_RING_SIZE) 152 if (++lg->next_hcall == LHCALL_RING_SIZE)
112 lg->next_hcall = 0; 153 lg->next_hcall = 0;
113 154
155 /* We copy the hypercall arguments into a fake register
156 * structure. This makes life simple for do_hcall(). */
114 if (get_user(regs.eax, &lg->lguest_data->hcalls[n].eax) 157 if (get_user(regs.eax, &lg->lguest_data->hcalls[n].eax)
115 || get_user(regs.edx, &lg->lguest_data->hcalls[n].edx) 158 || get_user(regs.edx, &lg->lguest_data->hcalls[n].edx)
116 || get_user(regs.ecx, &lg->lguest_data->hcalls[n].ecx) 159 || get_user(regs.ecx, &lg->lguest_data->hcalls[n].ecx)
@@ -119,74 +162,139 @@ static void do_async_hcalls(struct lguest *lg)
119 break; 162 break;
120 } 163 }
121 164
165 /* Do the hypercall, same as a normal one. */
122 do_hcall(lg, &regs); 166 do_hcall(lg, &regs);
167
168 /* Mark the hypercall done. */
123 if (put_user(0xFF, &lg->lguest_data->hcall_status[n])) { 169 if (put_user(0xFF, &lg->lguest_data->hcall_status[n])) {
124 kill_guest(lg, "Writing result for async hypercall"); 170 kill_guest(lg, "Writing result for async hypercall");
125 break; 171 break;
126 } 172 }
127 173
174 /* Stop doing hypercalls if we've just done a DMA to the
175 * Launcher: it needs to service this first. */
128 if (lg->dma_is_pending) 176 if (lg->dma_is_pending)
129 break; 177 break;
130 } 178 }
131} 179}
132 180
181/* Last of all, we look at what happens first of all. The very first time the
182 * Guest makes a hypercall, we end up here to set things up: */
133static void initialize(struct lguest *lg) 183static void initialize(struct lguest *lg)
134{ 184{
135 u32 tsc_speed; 185 u32 tsc_speed;
136 186
187 /* You can't do anything until you're initialized. The Guest knows the
188 * rules, so we're unforgiving here. */
137 if (lg->regs->eax != LHCALL_LGUEST_INIT) { 189 if (lg->regs->eax != LHCALL_LGUEST_INIT) {
138 kill_guest(lg, "hypercall %li before LGUEST_INIT", 190 kill_guest(lg, "hypercall %li before LGUEST_INIT",
139 lg->regs->eax); 191 lg->regs->eax);
140 return; 192 return;
141 } 193 }
142 194
143 /* We only tell the guest to use the TSC if it's reliable. */ 195 /* We insist that the Time Stamp Counter exist and doesn't change with
196 * cpu frequency. Some devious chip manufacturers decided that TSC
197 * changes could be handled in software. I decided that time going
198 * backwards might be good for benchmarks, but it's bad for users.
199 *
200 * We also insist that the TSC be stable: the kernel detects unreliable
201 * TSCs for its own purposes, and we use that here. */
144 if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC) && !check_tsc_unstable()) 202 if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC) && !check_tsc_unstable())
145 tsc_speed = tsc_khz; 203 tsc_speed = tsc_khz;
146 else 204 else
147 tsc_speed = 0; 205 tsc_speed = 0;
148 206
207 /* The pointer to the Guest's "struct lguest_data" is the only
208 * argument. */
149 lg->lguest_data = (struct lguest_data __user *)lg->regs->edx; 209 lg->lguest_data = (struct lguest_data __user *)lg->regs->edx;
150 /* We check here so we can simply copy_to_user/from_user */ 210 /* If we check the address they gave is OK now, we can simply
211 * copy_to_user/from_user from now on rather than using lgread/lgwrite.
212 * I put this in to show that I'm not immune to writing stupid
213 * optimizations. */
151 if (!lguest_address_ok(lg, lg->regs->edx, sizeof(*lg->lguest_data))) { 214 if (!lguest_address_ok(lg, lg->regs->edx, sizeof(*lg->lguest_data))) {
152 kill_guest(lg, "bad guest page %p", lg->lguest_data); 215 kill_guest(lg, "bad guest page %p", lg->lguest_data);
153 return; 216 return;
154 } 217 }
218 /* The Guest tells us where we're not to deliver interrupts by putting
219 * the range of addresses into "struct lguest_data". */
155 if (get_user(lg->noirq_start, &lg->lguest_data->noirq_start) 220 if (get_user(lg->noirq_start, &lg->lguest_data->noirq_start)
156 || get_user(lg->noirq_end, &lg->lguest_data->noirq_end) 221 || get_user(lg->noirq_end, &lg->lguest_data->noirq_end)
157 /* We reserve the top pgd entry. */ 222 /* We tell the Guest that it can't use the top 4MB of virtual
223 * addresses used by the Switcher. */
158 || put_user(4U*1024*1024, &lg->lguest_data->reserve_mem) 224 || put_user(4U*1024*1024, &lg->lguest_data->reserve_mem)
159 || put_user(tsc_speed, &lg->lguest_data->tsc_khz) 225 || put_user(tsc_speed, &lg->lguest_data->tsc_khz)
226 /* We also give the Guest a unique id, as used in lguest_net.c. */
160 || put_user(lg->guestid, &lg->lguest_data->guestid)) 227 || put_user(lg->guestid, &lg->lguest_data->guestid))
161 kill_guest(lg, "bad guest page %p", lg->lguest_data); 228 kill_guest(lg, "bad guest page %p", lg->lguest_data);
162 229
163 /* This is the one case where the above accesses might have 230 /* We write the current time into the Guest's data page once now. */
164 * been the first write to a Guest page. This may have caused 231 write_timestamp(lg);
165 * a copy-on-write fault, but the Guest might be referring to 232
166 * the old (read-only) page. */ 233 /* This is the one case where the above accesses might have been the
234 * first write to a Guest page. This may have caused a copy-on-write
235 * fault, but the Guest might be referring to the old (read-only)
236 * page. */
167 guest_pagetable_clear_all(lg); 237 guest_pagetable_clear_all(lg);
168} 238}
239/* Now we've examined the hypercall code; our Guest can make requests. There
240 * is one other way we can do things for the Guest, as we see in
241 * emulate_insn(). */
169 242
170/* Even if we go out to userspace and come back, we don't want to do 243/*H:110 Tricky point: we mark the hypercall as "done" once we've done it.
171 * the hypercall again. */ 244 * Normally we don't need to do this: the Guest will run again and update the
245 * trap number before we come back around the run_guest() loop to
246 * do_hypercalls().
247 *
248 * However, if we are signalled or the Guest sends DMA to the Launcher, that
249 * loop will exit without running the Guest. When it comes back it would try
250 * to re-run the hypercall. */
172static void clear_hcall(struct lguest *lg) 251static void clear_hcall(struct lguest *lg)
173{ 252{
174 lg->regs->trapnum = 255; 253 lg->regs->trapnum = 255;
175} 254}
176 255
256/*H:100
257 * Hypercalls
258 *
259 * Remember from the Guest, hypercalls come in two flavors: normal and
260 * asynchronous. This file handles both of types.
261 */
177void do_hypercalls(struct lguest *lg) 262void do_hypercalls(struct lguest *lg)
178{ 263{
264 /* Not initialized yet? */
179 if (unlikely(!lg->lguest_data)) { 265 if (unlikely(!lg->lguest_data)) {
266 /* Did the Guest make a hypercall? We might have come back for
267 * some other reason (an interrupt, a different trap). */
180 if (lg->regs->trapnum == LGUEST_TRAP_ENTRY) { 268 if (lg->regs->trapnum == LGUEST_TRAP_ENTRY) {
269 /* Set up the "struct lguest_data" */
181 initialize(lg); 270 initialize(lg);
271 /* The hypercall is done. */
182 clear_hcall(lg); 272 clear_hcall(lg);
183 } 273 }
184 return; 274 return;
185 } 275 }
186 276
277 /* The Guest has initialized.
278 *
279 * Look in the hypercall ring for the async hypercalls: */
187 do_async_hcalls(lg); 280 do_async_hcalls(lg);
281
282 /* If we stopped reading the hypercall ring because the Guest did a
283 * SEND_DMA to the Launcher, we want to return now. Otherwise if the
284 * Guest asked us to do a hypercall, we do it. */
188 if (!lg->dma_is_pending && lg->regs->trapnum == LGUEST_TRAP_ENTRY) { 285 if (!lg->dma_is_pending && lg->regs->trapnum == LGUEST_TRAP_ENTRY) {
189 do_hcall(lg, lg->regs); 286 do_hcall(lg, lg->regs);
287 /* The hypercall is done. */
190 clear_hcall(lg); 288 clear_hcall(lg);
191 } 289 }
192} 290}
291
292/* This routine supplies the Guest with time: it's used for wallclock time at
293 * initial boot and as a rough time source if the TSC isn't available. */
294void write_timestamp(struct lguest *lg)
295{
296 struct timespec now;
297 ktime_get_real_ts(&now);
298 if (put_user(now, &lg->lguest_data->time))
299 kill_guest(lg, "Writing timestamp");
300}
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index bee029bb2c7b..49787e964a0d 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -1,100 +1,160 @@
1/*P:800 Interrupts (traps) are complicated enough to earn their own file.
2 * There are three classes of interrupts:
3 *
4 * 1) Real hardware interrupts which occur while we're running the Guest,
5 * 2) Interrupts for virtual devices attached to the Guest, and
6 * 3) Traps and faults from the Guest.
7 *
8 * Real hardware interrupts must be delivered to the Host, not the Guest.
9 * Virtual interrupts must be delivered to the Guest, but we make them look
10 * just like real hardware would deliver them. Traps from the Guest can be set
11 * up to go directly back into the Guest, but sometimes the Host wants to see
12 * them first, so we also have a way of "reflecting" them into the Guest as if
13 * they had been delivered to it directly. :*/
1#include <linux/uaccess.h> 14#include <linux/uaccess.h>
2#include "lg.h" 15#include "lg.h"
3 16
17/* The address of the interrupt handler is split into two bits: */
4static unsigned long idt_address(u32 lo, u32 hi) 18static unsigned long idt_address(u32 lo, u32 hi)
5{ 19{
6 return (lo & 0x0000FFFF) | (hi & 0xFFFF0000); 20 return (lo & 0x0000FFFF) | (hi & 0xFFFF0000);
7} 21}
8 22
23/* The "type" of the interrupt handler is a 4 bit field: we only support a
24 * couple of types. */
9static int idt_type(u32 lo, u32 hi) 25static int idt_type(u32 lo, u32 hi)
10{ 26{
11 return (hi >> 8) & 0xF; 27 return (hi >> 8) & 0xF;
12} 28}
13 29
30/* An IDT entry can't be used unless the "present" bit is set. */
14static int idt_present(u32 lo, u32 hi) 31static int idt_present(u32 lo, u32 hi)
15{ 32{
16 return (hi & 0x8000); 33 return (hi & 0x8000);
17} 34}
18 35
36/* We need a helper to "push" a value onto the Guest's stack, since that's a
37 * big part of what delivering an interrupt does. */
19static void push_guest_stack(struct lguest *lg, unsigned long *gstack, u32 val) 38static void push_guest_stack(struct lguest *lg, unsigned long *gstack, u32 val)
20{ 39{
40 /* Stack grows upwards: move stack then write value. */
21 *gstack -= 4; 41 *gstack -= 4;
22 lgwrite_u32(lg, *gstack, val); 42 lgwrite_u32(lg, *gstack, val);
23} 43}
24 44
45/*H:210 The set_guest_interrupt() routine actually delivers the interrupt or
46 * trap. The mechanics of delivering traps and interrupts to the Guest are the
47 * same, except some traps have an "error code" which gets pushed onto the
48 * stack as well: the caller tells us if this is one.
49 *
50 * "lo" and "hi" are the two parts of the Interrupt Descriptor Table for this
51 * interrupt or trap. It's split into two parts for traditional reasons: gcc
52 * on i386 used to be frightened by 64 bit numbers.
53 *
54 * We set up the stack just like the CPU does for a real interrupt, so it's
55 * identical for the Guest (and the standard "iret" instruction will undo
56 * it). */
25static void set_guest_interrupt(struct lguest *lg, u32 lo, u32 hi, int has_err) 57static void set_guest_interrupt(struct lguest *lg, u32 lo, u32 hi, int has_err)
26{ 58{
27 unsigned long gstack; 59 unsigned long gstack;
28 u32 eflags, ss, irq_enable; 60 u32 eflags, ss, irq_enable;
29 61
30 /* If they want a ring change, we use new stack and push old ss/esp */ 62 /* There are two cases for interrupts: one where the Guest is already
63 * in the kernel, and a more complex one where the Guest is in
64 * userspace. We check the privilege level to find out. */
31 if ((lg->regs->ss&0x3) != GUEST_PL) { 65 if ((lg->regs->ss&0x3) != GUEST_PL) {
66 /* The Guest told us their kernel stack with the SET_STACK
67 * hypercall: both the virtual address and the segment */
32 gstack = guest_pa(lg, lg->esp1); 68 gstack = guest_pa(lg, lg->esp1);
33 ss = lg->ss1; 69 ss = lg->ss1;
70 /* We push the old stack segment and pointer onto the new
71 * stack: when the Guest does an "iret" back from the interrupt
72 * handler the CPU will notice they're dropping privilege
73 * levels and expect these here. */
34 push_guest_stack(lg, &gstack, lg->regs->ss); 74 push_guest_stack(lg, &gstack, lg->regs->ss);
35 push_guest_stack(lg, &gstack, lg->regs->esp); 75 push_guest_stack(lg, &gstack, lg->regs->esp);
36 } else { 76 } else {
77 /* We're staying on the same Guest (kernel) stack. */
37 gstack = guest_pa(lg, lg->regs->esp); 78 gstack = guest_pa(lg, lg->regs->esp);
38 ss = lg->regs->ss; 79 ss = lg->regs->ss;
39 } 80 }
40 81
41 /* We use IF bit in eflags to indicate whether irqs were enabled 82 /* Remember that we never let the Guest actually disable interrupts, so
42 (it's always 1, since irqs are enabled when guest is running). */ 83 * the "Interrupt Flag" bit is always set. We copy that bit from the
84 * Guest's "irq_enabled" field into the eflags word: the Guest copies
85 * it back in "lguest_iret". */
43 eflags = lg->regs->eflags; 86 eflags = lg->regs->eflags;
44 if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0 87 if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0
45 && !(irq_enable & X86_EFLAGS_IF)) 88 && !(irq_enable & X86_EFLAGS_IF))
46 eflags &= ~X86_EFLAGS_IF; 89 eflags &= ~X86_EFLAGS_IF;
47 90
91 /* An interrupt is expected to push three things on the stack: the old
92 * "eflags" word, the old code segment, and the old instruction
93 * pointer. */
48 push_guest_stack(lg, &gstack, eflags); 94 push_guest_stack(lg, &gstack, eflags);
49 push_guest_stack(lg, &gstack, lg->regs->cs); 95 push_guest_stack(lg, &gstack, lg->regs->cs);
50 push_guest_stack(lg, &gstack, lg->regs->eip); 96 push_guest_stack(lg, &gstack, lg->regs->eip);
51 97
98 /* For the six traps which supply an error code, we push that, too. */
52 if (has_err) 99 if (has_err)
53 push_guest_stack(lg, &gstack, lg->regs->errcode); 100 push_guest_stack(lg, &gstack, lg->regs->errcode);
54 101
55 /* Change the real stack so switcher returns to trap handler */ 102 /* Now we've pushed all the old state, we change the stack, the code
103 * segment and the address to execute. */
56 lg->regs->ss = ss; 104 lg->regs->ss = ss;
57 lg->regs->esp = gstack + lg->page_offset; 105 lg->regs->esp = gstack + lg->page_offset;
58 lg->regs->cs = (__KERNEL_CS|GUEST_PL); 106 lg->regs->cs = (__KERNEL_CS|GUEST_PL);
59 lg->regs->eip = idt_address(lo, hi); 107 lg->regs->eip = idt_address(lo, hi);
60 108
61 /* Disable interrupts for an interrupt gate. */ 109 /* There are two kinds of interrupt handlers: 0xE is an "interrupt
110 * gate" which expects interrupts to be disabled on entry. */
62 if (idt_type(lo, hi) == 0xE) 111 if (idt_type(lo, hi) == 0xE)
63 if (put_user(0, &lg->lguest_data->irq_enabled)) 112 if (put_user(0, &lg->lguest_data->irq_enabled))
64 kill_guest(lg, "Disabling interrupts"); 113 kill_guest(lg, "Disabling interrupts");
65} 114}
66 115
116/*H:200
117 * Virtual Interrupts.
118 *
119 * maybe_do_interrupt() gets called before every entry to the Guest, to see if
120 * we should divert the Guest to running an interrupt handler. */
67void maybe_do_interrupt(struct lguest *lg) 121void maybe_do_interrupt(struct lguest *lg)
68{ 122{
69 unsigned int irq; 123 unsigned int irq;
70 DECLARE_BITMAP(blk, LGUEST_IRQS); 124 DECLARE_BITMAP(blk, LGUEST_IRQS);
71 struct desc_struct *idt; 125 struct desc_struct *idt;
72 126
127 /* If the Guest hasn't even initialized yet, we can do nothing. */
73 if (!lg->lguest_data) 128 if (!lg->lguest_data)
74 return; 129 return;
75 130
76 /* Mask out any interrupts they have blocked. */ 131 /* Take our "irqs_pending" array and remove any interrupts the Guest
132 * wants blocked: the result ends up in "blk". */
77 if (copy_from_user(&blk, lg->lguest_data->blocked_interrupts, 133 if (copy_from_user(&blk, lg->lguest_data->blocked_interrupts,
78 sizeof(blk))) 134 sizeof(blk)))
79 return; 135 return;
80 136
81 bitmap_andnot(blk, lg->irqs_pending, blk, LGUEST_IRQS); 137 bitmap_andnot(blk, lg->irqs_pending, blk, LGUEST_IRQS);
82 138
139 /* Find the first interrupt. */
83 irq = find_first_bit(blk, LGUEST_IRQS); 140 irq = find_first_bit(blk, LGUEST_IRQS);
141 /* None? Nothing to do */
84 if (irq >= LGUEST_IRQS) 142 if (irq >= LGUEST_IRQS)
85 return; 143 return;
86 144
145 /* They may be in the middle of an iret, where they asked us never to
146 * deliver interrupts. */
87 if (lg->regs->eip >= lg->noirq_start && lg->regs->eip < lg->noirq_end) 147 if (lg->regs->eip >= lg->noirq_start && lg->regs->eip < lg->noirq_end)
88 return; 148 return;
89 149
90 /* If they're halted, we re-enable interrupts. */ 150 /* If they're halted, interrupts restart them. */
91 if (lg->halted) { 151 if (lg->halted) {
92 /* Re-enable interrupts. */ 152 /* Re-enable interrupts. */
93 if (put_user(X86_EFLAGS_IF, &lg->lguest_data->irq_enabled)) 153 if (put_user(X86_EFLAGS_IF, &lg->lguest_data->irq_enabled))
94 kill_guest(lg, "Re-enabling interrupts"); 154 kill_guest(lg, "Re-enabling interrupts");
95 lg->halted = 0; 155 lg->halted = 0;
96 } else { 156 } else {
97 /* Maybe they have interrupts disabled? */ 157 /* Otherwise we check if they have interrupts disabled. */
98 u32 irq_enabled; 158 u32 irq_enabled;
99 if (get_user(irq_enabled, &lg->lguest_data->irq_enabled)) 159 if (get_user(irq_enabled, &lg->lguest_data->irq_enabled))
100 irq_enabled = 0; 160 irq_enabled = 0;
@@ -102,112 +162,218 @@ void maybe_do_interrupt(struct lguest *lg)
102 return; 162 return;
103 } 163 }
104 164
165 /* Look at the IDT entry the Guest gave us for this interrupt. The
166 * first 32 (FIRST_EXTERNAL_VECTOR) entries are for traps, so we skip
167 * over them. */
105 idt = &lg->idt[FIRST_EXTERNAL_VECTOR+irq]; 168 idt = &lg->idt[FIRST_EXTERNAL_VECTOR+irq];
169 /* If they don't have a handler (yet?), we just ignore it */
106 if (idt_present(idt->a, idt->b)) { 170 if (idt_present(idt->a, idt->b)) {
171 /* OK, mark it no longer pending and deliver it. */
107 clear_bit(irq, lg->irqs_pending); 172 clear_bit(irq, lg->irqs_pending);
173 /* set_guest_interrupt() takes the interrupt descriptor and a
174 * flag to say whether this interrupt pushes an error code onto
175 * the stack as well: virtual interrupts never do. */
108 set_guest_interrupt(lg, idt->a, idt->b, 0); 176 set_guest_interrupt(lg, idt->a, idt->b, 0);
109 } 177 }
178
179 /* Every time we deliver an interrupt, we update the timestamp in the
180 * Guest's lguest_data struct. It would be better for the Guest if we
181 * did this more often, but it can actually be quite slow: doing it
182 * here is a compromise which means at least it gets updated every
183 * timer interrupt. */
184 write_timestamp(lg);
110} 185}
111 186
187/*H:220 Now we've got the routines to deliver interrupts, delivering traps
188 * like page fault is easy. The only trick is that Intel decided that some
189 * traps should have error codes: */
112static int has_err(unsigned int trap) 190static int has_err(unsigned int trap)
113{ 191{
114 return (trap == 8 || (trap >= 10 && trap <= 14) || trap == 17); 192 return (trap == 8 || (trap >= 10 && trap <= 14) || trap == 17);
115} 193}
116 194
195/* deliver_trap() returns true if it could deliver the trap. */
117int deliver_trap(struct lguest *lg, unsigned int num) 196int deliver_trap(struct lguest *lg, unsigned int num)
118{ 197{
119 u32 lo = lg->idt[num].a, hi = lg->idt[num].b; 198 u32 lo = lg->idt[num].a, hi = lg->idt[num].b;
120 199
200 /* Early on the Guest hasn't set the IDT entries (or maybe it put a
201 * bogus one in): if we fail here, the Guest will be killed. */
121 if (!idt_present(lo, hi)) 202 if (!idt_present(lo, hi))
122 return 0; 203 return 0;
123 set_guest_interrupt(lg, lo, hi, has_err(num)); 204 set_guest_interrupt(lg, lo, hi, has_err(num));
124 return 1; 205 return 1;
125} 206}
126 207
208/*H:250 Here's the hard part: returning to the Host every time a trap happens
209 * and then calling deliver_trap() and re-entering the Guest is slow.
210 * Particularly because Guest userspace system calls are traps (trap 128).
211 *
212 * So we'd like to set up the IDT to tell the CPU to deliver traps directly
213 * into the Guest. This is possible, but the complexities cause the size of
214 * this file to double! However, 150 lines of code is worth writing for taking
215 * system calls down from 1750ns to 270ns. Plus, if lguest didn't do it, all
216 * the other hypervisors would tease it.
217 *
218 * This routine determines if a trap can be delivered directly. */
127static int direct_trap(const struct lguest *lg, 219static int direct_trap(const struct lguest *lg,
128 const struct desc_struct *trap, 220 const struct desc_struct *trap,
129 unsigned int num) 221 unsigned int num)
130{ 222{
131 /* Hardware interrupts don't go to guest (except syscall). */ 223 /* Hardware interrupts don't go to the Guest at all (except system
224 * call). */
132 if (num >= FIRST_EXTERNAL_VECTOR && num != SYSCALL_VECTOR) 225 if (num >= FIRST_EXTERNAL_VECTOR && num != SYSCALL_VECTOR)
133 return 0; 226 return 0;
134 227
135 /* We intercept page fault (demand shadow paging & cr2 saving) 228 /* The Host needs to see page faults (for shadow paging and to save the
136 protection fault (in/out emulation) and device not 229 * fault address), general protection faults (in/out emulation) and
137 available (TS handling), and hypercall */ 230 * device not available (TS handling), and of course, the hypercall
231 * trap. */
138 if (num == 14 || num == 13 || num == 7 || num == LGUEST_TRAP_ENTRY) 232 if (num == 14 || num == 13 || num == 7 || num == LGUEST_TRAP_ENTRY)
139 return 0; 233 return 0;
140 234
141 /* Interrupt gates (0xE) or not present (0x0) can't go direct. */ 235 /* Only trap gates (type 15) can go direct to the Guest. Interrupt
236 * gates (type 14) disable interrupts as they are entered, which we
237 * never let the Guest do. Not present entries (type 0x0) also can't
238 * go direct, of course 8) */
142 return idt_type(trap->a, trap->b) == 0xF; 239 return idt_type(trap->a, trap->b) == 0xF;
143} 240}
144 241/*:*/
242
243/*M:005 The Guest has the ability to turn its interrupt gates into trap gates,
244 * if it is careful. The Host will let trap gates can go directly to the
245 * Guest, but the Guest needs the interrupts atomically disabled for an
246 * interrupt gate. It can do this by pointing the trap gate at instructions
247 * within noirq_start and noirq_end, where it can safely disable interrupts. */
248
249/*M:006 The Guests do not use the sysenter (fast system call) instruction,
250 * because it's hardcoded to enter privilege level 0 and so can't go direct.
251 * It's about twice as fast as the older "int 0x80" system call, so it might
252 * still be worthwhile to handle it in the Switcher and lcall down to the
253 * Guest. The sysenter semantics are hairy tho: search for that keyword in
254 * entry.S :*/
255
256/*H:260 When we make traps go directly into the Guest, we need to make sure
257 * the kernel stack is valid (ie. mapped in the page tables). Otherwise, the
258 * CPU trying to deliver the trap will fault while trying to push the interrupt
259 * words on the stack: this is called a double fault, and it forces us to kill
260 * the Guest.
261 *
262 * Which is deeply unfair, because (literally!) it wasn't the Guests' fault. */
145void pin_stack_pages(struct lguest *lg) 263void pin_stack_pages(struct lguest *lg)
146{ 264{
147 unsigned int i; 265 unsigned int i;
148 266
267 /* Depending on the CONFIG_4KSTACKS option, the Guest can have one or
268 * two pages of stack space. */
149 for (i = 0; i < lg->stack_pages; i++) 269 for (i = 0; i < lg->stack_pages; i++)
270 /* The stack grows *upwards*, hence the subtraction */
150 pin_page(lg, lg->esp1 - i * PAGE_SIZE); 271 pin_page(lg, lg->esp1 - i * PAGE_SIZE);
151} 272}
152 273
274/* Direct traps also mean that we need to know whenever the Guest wants to use
275 * a different kernel stack, so we can change the IDT entries to use that
276 * stack. The IDT entries expect a virtual address, so unlike most addresses
277 * the Guest gives us, the "esp" (stack pointer) value here is virtual, not
278 * physical.
279 *
280 * In Linux each process has its own kernel stack, so this happens a lot: we
281 * change stacks on each context switch. */
153void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages) 282void guest_set_stack(struct lguest *lg, u32 seg, u32 esp, unsigned int pages)
154{ 283{
155 /* You cannot have a stack segment with priv level 0. */ 284 /* You are not allowd have a stack segment with privilege level 0: bad
285 * Guest! */
156 if ((seg & 0x3) != GUEST_PL) 286 if ((seg & 0x3) != GUEST_PL)
157 kill_guest(lg, "bad stack segment %i", seg); 287 kill_guest(lg, "bad stack segment %i", seg);
288 /* We only expect one or two stack pages. */
158 if (pages > 2) 289 if (pages > 2)
159 kill_guest(lg, "bad stack pages %u", pages); 290 kill_guest(lg, "bad stack pages %u", pages);
291 /* Save where the stack is, and how many pages */
160 lg->ss1 = seg; 292 lg->ss1 = seg;
161 lg->esp1 = esp; 293 lg->esp1 = esp;
162 lg->stack_pages = pages; 294 lg->stack_pages = pages;
295 /* Make sure the new stack pages are mapped */
163 pin_stack_pages(lg); 296 pin_stack_pages(lg);
164} 297}
165 298
166/* Set up trap in IDT. */ 299/* All this reference to mapping stacks leads us neatly into the other complex
300 * part of the Host: page table handling. */
301
302/*H:235 This is the routine which actually checks the Guest's IDT entry and
303 * transfers it into our entry in "struct lguest": */
167static void set_trap(struct lguest *lg, struct desc_struct *trap, 304static void set_trap(struct lguest *lg, struct desc_struct *trap,
168 unsigned int num, u32 lo, u32 hi) 305 unsigned int num, u32 lo, u32 hi)
169{ 306{
170 u8 type = idt_type(lo, hi); 307 u8 type = idt_type(lo, hi);
171 308
309 /* We zero-out a not-present entry */
172 if (!idt_present(lo, hi)) { 310 if (!idt_present(lo, hi)) {
173 trap->a = trap->b = 0; 311 trap->a = trap->b = 0;
174 return; 312 return;
175 } 313 }
176 314
315 /* We only support interrupt and trap gates. */
177 if (type != 0xE && type != 0xF) 316 if (type != 0xE && type != 0xF)
178 kill_guest(lg, "bad IDT type %i", type); 317 kill_guest(lg, "bad IDT type %i", type);
179 318
319 /* We only copy the handler address, present bit, privilege level and
320 * type. The privilege level controls where the trap can be triggered
321 * manually with an "int" instruction. This is usually GUEST_PL,
322 * except for system calls which userspace can use. */
180 trap->a = ((__KERNEL_CS|GUEST_PL)<<16) | (lo&0x0000FFFF); 323 trap->a = ((__KERNEL_CS|GUEST_PL)<<16) | (lo&0x0000FFFF);
181 trap->b = (hi&0xFFFFEF00); 324 trap->b = (hi&0xFFFFEF00);
182} 325}
183 326
327/*H:230 While we're here, dealing with delivering traps and interrupts to the
328 * Guest, we might as well complete the picture: how the Guest tells us where
329 * it wants them to go. This would be simple, except making traps fast
330 * requires some tricks.
331 *
332 * We saw the Guest setting Interrupt Descriptor Table (IDT) entries with the
333 * LHCALL_LOAD_IDT_ENTRY hypercall before: that comes here. */
184void load_guest_idt_entry(struct lguest *lg, unsigned int num, u32 lo, u32 hi) 334void load_guest_idt_entry(struct lguest *lg, unsigned int num, u32 lo, u32 hi)
185{ 335{
186 /* Guest never handles: NMI, doublefault, hypercall, spurious irq. */ 336 /* Guest never handles: NMI, doublefault, spurious interrupt or
337 * hypercall. We ignore when it tries to set them. */
187 if (num == 2 || num == 8 || num == 15 || num == LGUEST_TRAP_ENTRY) 338 if (num == 2 || num == 8 || num == 15 || num == LGUEST_TRAP_ENTRY)
188 return; 339 return;
189 340
341 /* Mark the IDT as changed: next time the Guest runs we'll know we have
342 * to copy this again. */
190 lg->changed |= CHANGED_IDT; 343 lg->changed |= CHANGED_IDT;
344
345 /* The IDT which we keep in "struct lguest" only contains 32 entries
346 * for the traps and LGUEST_IRQS (32) entries for interrupts. We
347 * ignore attempts to set handlers for higher interrupt numbers, except
348 * for the system call "interrupt" at 128: we have a special IDT entry
349 * for that. */
191 if (num < ARRAY_SIZE(lg->idt)) 350 if (num < ARRAY_SIZE(lg->idt))
192 set_trap(lg, &lg->idt[num], num, lo, hi); 351 set_trap(lg, &lg->idt[num], num, lo, hi);
193 else if (num == SYSCALL_VECTOR) 352 else if (num == SYSCALL_VECTOR)
194 set_trap(lg, &lg->syscall_idt, num, lo, hi); 353 set_trap(lg, &lg->syscall_idt, num, lo, hi);
195} 354}
196 355
356/* The default entry for each interrupt points into the Switcher routines which
357 * simply return to the Host. The run_guest() loop will then call
358 * deliver_trap() to bounce it back into the Guest. */
197static void default_idt_entry(struct desc_struct *idt, 359static void default_idt_entry(struct desc_struct *idt,
198 int trap, 360 int trap,
199 const unsigned long handler) 361 const unsigned long handler)
200{ 362{
363 /* A present interrupt gate. */
201 u32 flags = 0x8e00; 364 u32 flags = 0x8e00;
202 365
203 /* They can't "int" into any of them except hypercall. */ 366 /* Set the privilege level on the entry for the hypercall: this allows
367 * the Guest to use the "int" instruction to trigger it. */
204 if (trap == LGUEST_TRAP_ENTRY) 368 if (trap == LGUEST_TRAP_ENTRY)
205 flags |= (GUEST_PL << 13); 369 flags |= (GUEST_PL << 13);
206 370
371 /* Now pack it into the IDT entry in its weird format. */
207 idt->a = (LGUEST_CS<<16) | (handler&0x0000FFFF); 372 idt->a = (LGUEST_CS<<16) | (handler&0x0000FFFF);
208 idt->b = (handler&0xFFFF0000) | flags; 373 idt->b = (handler&0xFFFF0000) | flags;
209} 374}
210 375
376/* When the Guest first starts, we put default entries into the IDT. */
211void setup_default_idt_entries(struct lguest_ro_state *state, 377void setup_default_idt_entries(struct lguest_ro_state *state,
212 const unsigned long *def) 378 const unsigned long *def)
213{ 379{
@@ -217,19 +383,25 @@ void setup_default_idt_entries(struct lguest_ro_state *state,
217 default_idt_entry(&state->guest_idt[i], i, def[i]); 383 default_idt_entry(&state->guest_idt[i], i, def[i]);
218} 384}
219 385
386/*H:240 We don't use the IDT entries in the "struct lguest" directly, instead
387 * we copy them into the IDT which we've set up for Guests on this CPU, just
388 * before we run the Guest. This routine does that copy. */
220void copy_traps(const struct lguest *lg, struct desc_struct *idt, 389void copy_traps(const struct lguest *lg, struct desc_struct *idt,
221 const unsigned long *def) 390 const unsigned long *def)
222{ 391{
223 unsigned int i; 392 unsigned int i;
224 393
225 /* All hardware interrupts are same whatever the guest: only the 394 /* We can simply copy the direct traps, otherwise we use the default
226 * traps might be different. */ 395 * ones in the Switcher: they will return to the Host. */
227 for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++) { 396 for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++) {
228 if (direct_trap(lg, &lg->idt[i], i)) 397 if (direct_trap(lg, &lg->idt[i], i))
229 idt[i] = lg->idt[i]; 398 idt[i] = lg->idt[i];
230 else 399 else
231 default_idt_entry(&idt[i], i, def[i]); 400 default_idt_entry(&idt[i], i, def[i]);
232 } 401 }
402
403 /* Don't forget the system call trap! The IDT entries for other
404 * interupts never change, so no need to copy them. */
233 i = SYSCALL_VECTOR; 405 i = SYSCALL_VECTOR;
234 if (direct_trap(lg, &lg->syscall_idt, i)) 406 if (direct_trap(lg, &lg->syscall_idt, i))
235 idt[i] = lg->syscall_idt; 407 idt[i] = lg->syscall_idt;
diff --git a/drivers/lguest/io.c b/drivers/lguest/io.c
index c8eb79266991..ea68613b43f6 100644
--- a/drivers/lguest/io.c
+++ b/drivers/lguest/io.c
@@ -1,5 +1,9 @@
1/* Simple I/O model for guests, based on shared memory. 1/*P:300 The I/O mechanism in lguest is simple yet flexible, allowing the Guest
2 * Copyright (C) 2006 Rusty Russell IBM Corporation 2 * to talk to the Launcher or directly to another Guest. It uses familiar
3 * concepts of DMA and interrupts, plus some neat code stolen from
4 * futexes... :*/
5
6/* Copyright (C) 2006 Rusty Russell IBM Corporation
3 * 7 *
4 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -23,8 +27,36 @@
23#include <linux/uaccess.h> 27#include <linux/uaccess.h>
24#include "lg.h" 28#include "lg.h"
25 29
30/*L:300
31 * I/O
32 *
33 * Getting data in and out of the Guest is quite an art. There are numerous
34 * ways to do it, and they all suck differently. We try to keep things fairly
35 * close to "real" hardware so our Guest's drivers don't look like an alien
36 * visitation in the middle of the Linux code, and yet make sure that Guests
37 * can talk directly to other Guests, not just the Launcher.
38 *
39 * To do this, the Guest gives us a key when it binds or sends DMA buffers.
40 * The key corresponds to a "physical" address inside the Guest (ie. a virtual
41 * address inside the Launcher process). We don't, however, use this key
42 * directly.
43 *
44 * We want Guests which share memory to be able to DMA to each other: two
45 * Launchers can mmap memory the same file, then the Guests can communicate.
46 * Fortunately, the futex code provides us with a way to get a "union
47 * futex_key" corresponding to the memory lying at a virtual address: if the
48 * two processes share memory, the "union futex_key" for that memory will match
49 * even if the memory is mapped at different addresses in each. So we always
50 * convert the keys to "union futex_key"s to compare them.
51 *
52 * Before we dive into this though, we need to look at another set of helper
53 * routines used throughout the Host kernel code to access Guest memory.
54 :*/
26static struct list_head dma_hash[61]; 55static struct list_head dma_hash[61];
27 56
57/* An unfortunate side effect of the Linux double-linked list implementation is
58 * that there's no good way to statically initialize an array of linked
59 * lists. */
28void lguest_io_init(void) 60void lguest_io_init(void)
29{ 61{
30 unsigned int i; 62 unsigned int i;
@@ -56,6 +88,19 @@ kill:
56 return 0; 88 return 0;
57} 89}
58 90
91/*L:330 This is our hash function, using the wonderful Jenkins hash.
92 *
93 * The futex key is a union with three parts: an unsigned long word, a pointer,
94 * and an int "offset". We could use jhash_2words() which takes three u32s.
95 * (Ok, the hash functions are great: the naming sucks though).
96 *
97 * It's nice to be portable to 64-bit platforms, so we use the more generic
98 * jhash2(), which takes an array of u32, the number of u32s, and an initial
99 * u32 to roll in. This is uglier, but breaks down to almost the same code on
100 * 32-bit platforms like this one.
101 *
102 * We want a position in the array, so we modulo ARRAY_SIZE(dma_hash) (ie. 61).
103 */
59static unsigned int hash(const union futex_key *key) 104static unsigned int hash(const union futex_key *key)
60{ 105{
61 return jhash2((u32*)&key->both.word, 106 return jhash2((u32*)&key->both.word,
@@ -64,6 +109,9 @@ static unsigned int hash(const union futex_key *key)
64 % ARRAY_SIZE(dma_hash); 109 % ARRAY_SIZE(dma_hash);
65} 110}
66 111
112/* This is a convenience routine to compare two keys. It's a much bemoaned C
113 * weakness that it doesn't allow '==' on structures or unions, so we have to
114 * open-code it like this. */
67static inline int key_eq(const union futex_key *a, const union futex_key *b) 115static inline int key_eq(const union futex_key *a, const union futex_key *b)
68{ 116{
69 return (a->both.word == b->both.word 117 return (a->both.word == b->both.word
@@ -71,22 +119,36 @@ static inline int key_eq(const union futex_key *a, const union futex_key *b)
71 && a->both.offset == b->both.offset); 119 && a->both.offset == b->both.offset);
72} 120}
73 121
74/* Must hold read lock on dmainfo owner's current->mm->mmap_sem */ 122/*L:360 OK, when we need to actually free up a Guest's DMA array we do several
123 * things, so we have a convenient function to do it.
124 *
125 * The caller must hold a read lock on dmainfo owner's current->mm->mmap_sem
126 * for the drop_futex_key_refs(). */
75static void unlink_dma(struct lguest_dma_info *dmainfo) 127static void unlink_dma(struct lguest_dma_info *dmainfo)
76{ 128{
129 /* You locked this too, right? */
77 BUG_ON(!mutex_is_locked(&lguest_lock)); 130 BUG_ON(!mutex_is_locked(&lguest_lock));
131 /* This is how we know that the entry is free. */
78 dmainfo->interrupt = 0; 132 dmainfo->interrupt = 0;
133 /* Remove it from the hash table. */
79 list_del(&dmainfo->list); 134 list_del(&dmainfo->list);
135 /* Drop the references we were holding (to the inode or mm). */
80 drop_futex_key_refs(&dmainfo->key); 136 drop_futex_key_refs(&dmainfo->key);
81} 137}
82 138
139/*L:350 This is the routine which we call when the Guest asks to unregister a
140 * DMA array attached to a given key. Returns true if the array was found. */
83static int unbind_dma(struct lguest *lg, 141static int unbind_dma(struct lguest *lg,
84 const union futex_key *key, 142 const union futex_key *key,
85 unsigned long dmas) 143 unsigned long dmas)
86{ 144{
87 int i, ret = 0; 145 int i, ret = 0;
88 146
147 /* We don't bother with the hash table, just look through all this
148 * Guest's DMA arrays. */
89 for (i = 0; i < LGUEST_MAX_DMA; i++) { 149 for (i = 0; i < LGUEST_MAX_DMA; i++) {
150 /* In theory it could have more than one array on the same key,
151 * or one array on multiple keys, so we check both */
90 if (key_eq(key, &lg->dma[i].key) && dmas == lg->dma[i].dmas) { 152 if (key_eq(key, &lg->dma[i].key) && dmas == lg->dma[i].dmas) {
91 unlink_dma(&lg->dma[i]); 153 unlink_dma(&lg->dma[i]);
92 ret = 1; 154 ret = 1;
@@ -96,51 +158,91 @@ static int unbind_dma(struct lguest *lg,
96 return ret; 158 return ret;
97} 159}
98 160
161/*L:340 BIND_DMA: this is the hypercall which sets up an array of "struct
162 * lguest_dma" for receiving I/O.
163 *
164 * The Guest wants to bind an array of "struct lguest_dma"s to a particular key
165 * to receive input. This only happens when the Guest is setting up a new
166 * device, so it doesn't have to be very fast.
167 *
168 * It returns 1 on a successful registration (it can fail if we hit the limit
169 * of registrations for this Guest).
170 */
99int bind_dma(struct lguest *lg, 171int bind_dma(struct lguest *lg,
100 unsigned long ukey, unsigned long dmas, u16 numdmas, u8 interrupt) 172 unsigned long ukey, unsigned long dmas, u16 numdmas, u8 interrupt)
101{ 173{
102 unsigned int i; 174 unsigned int i;
103 int ret = 0; 175 int ret = 0;
104 union futex_key key; 176 union futex_key key;
177 /* Futex code needs the mmap_sem. */
105 struct rw_semaphore *fshared = &current->mm->mmap_sem; 178 struct rw_semaphore *fshared = &current->mm->mmap_sem;
106 179
180 /* Invalid interrupt? (We could kill the guest here). */
107 if (interrupt >= LGUEST_IRQS) 181 if (interrupt >= LGUEST_IRQS)
108 return 0; 182 return 0;
109 183
184 /* We need to grab the Big Lguest Lock, because other Guests may be
185 * trying to look through this Guest's DMAs to send something while
186 * we're doing this. */
110 mutex_lock(&lguest_lock); 187 mutex_lock(&lguest_lock);
111 down_read(fshared); 188 down_read(fshared);
112 if (get_futex_key((u32 __user *)ukey, fshared, &key) != 0) { 189 if (get_futex_key((u32 __user *)ukey, fshared, &key) != 0) {
113 kill_guest(lg, "bad dma key %#lx", ukey); 190 kill_guest(lg, "bad dma key %#lx", ukey);
114 goto unlock; 191 goto unlock;
115 } 192 }
193
194 /* We want to keep this key valid once we drop mmap_sem, so we have to
195 * hold a reference. */
116 get_futex_key_refs(&key); 196 get_futex_key_refs(&key);
117 197
198 /* If the Guest specified an interrupt of 0, that means they want to
199 * unregister this array of "struct lguest_dma"s. */
118 if (interrupt == 0) 200 if (interrupt == 0)
119 ret = unbind_dma(lg, &key, dmas); 201 ret = unbind_dma(lg, &key, dmas);
120 else { 202 else {
203 /* Look through this Guest's dma array for an unused entry. */
121 for (i = 0; i < LGUEST_MAX_DMA; i++) { 204 for (i = 0; i < LGUEST_MAX_DMA; i++) {
205 /* If the interrupt is non-zero, the entry is already
206 * used. */
122 if (lg->dma[i].interrupt) 207 if (lg->dma[i].interrupt)
123 continue; 208 continue;
124 209
210 /* OK, a free one! Fill on our details. */
125 lg->dma[i].dmas = dmas; 211 lg->dma[i].dmas = dmas;
126 lg->dma[i].num_dmas = numdmas; 212 lg->dma[i].num_dmas = numdmas;
127 lg->dma[i].next_dma = 0; 213 lg->dma[i].next_dma = 0;
128 lg->dma[i].key = key; 214 lg->dma[i].key = key;
129 lg->dma[i].guestid = lg->guestid; 215 lg->dma[i].guestid = lg->guestid;
130 lg->dma[i].interrupt = interrupt; 216 lg->dma[i].interrupt = interrupt;
217
218 /* Now we add it to the hash table: the position
219 * depends on the futex key that we got. */
131 list_add(&lg->dma[i].list, &dma_hash[hash(&key)]); 220 list_add(&lg->dma[i].list, &dma_hash[hash(&key)]);
221 /* Success! */
132 ret = 1; 222 ret = 1;
133 goto unlock; 223 goto unlock;
134 } 224 }
135 } 225 }
226 /* If we didn't find a slot to put the key in, drop the reference
227 * again. */
136 drop_futex_key_refs(&key); 228 drop_futex_key_refs(&key);
137unlock: 229unlock:
230 /* Unlock and out. */
138 up_read(fshared); 231 up_read(fshared);
139 mutex_unlock(&lguest_lock); 232 mutex_unlock(&lguest_lock);
140 return ret; 233 return ret;
141} 234}
142 235
143/* lgread from another guest */ 236/*L:385 Note that our routines to access a different Guest's memory are called
237 * lgread_other() and lgwrite_other(): these names emphasize that they are only
238 * used when the Guest is *not* the current Guest.
239 *
240 * The interface for copying from another process's memory is called
241 * access_process_vm(), with a final argument of 0 for a read, and 1 for a
242 * write.
243 *
244 * We need lgread_other() to read the destination Guest's "struct lguest_dma"
245 * array. */
144static int lgread_other(struct lguest *lg, 246static int lgread_other(struct lguest *lg,
145 void *buf, u32 addr, unsigned bytes) 247 void *buf, u32 addr, unsigned bytes)
146{ 248{
@@ -153,7 +255,8 @@ static int lgread_other(struct lguest *lg,
153 return 1; 255 return 1;
154} 256}
155 257
156/* lgwrite to another guest */ 258/* "lgwrite()" to another Guest: used to update the destination "used_len" once
259 * we've transferred data into the buffer. */
157static int lgwrite_other(struct lguest *lg, u32 addr, 260static int lgwrite_other(struct lguest *lg, u32 addr,
158 const void *buf, unsigned bytes) 261 const void *buf, unsigned bytes)
159{ 262{
@@ -166,6 +269,15 @@ static int lgwrite_other(struct lguest *lg, u32 addr,
166 return 1; 269 return 1;
167} 270}
168 271
272/*L:400 This is the generic engine which copies from a source "struct
273 * lguest_dma" from this Guest into another Guest's "struct lguest_dma". The
274 * destination Guest's pages have already been mapped, as contained in the
275 * pages array.
276 *
277 * If you're wondering if there's a nice "copy from one process to another"
278 * routine, so was I. But Linux isn't really set up to copy between two
279 * unrelated processes, so we have to write it ourselves.
280 */
169static u32 copy_data(struct lguest *srclg, 281static u32 copy_data(struct lguest *srclg,
170 const struct lguest_dma *src, 282 const struct lguest_dma *src,
171 const struct lguest_dma *dst, 283 const struct lguest_dma *dst,
@@ -174,33 +286,59 @@ static u32 copy_data(struct lguest *srclg,
174 unsigned int totlen, si, di, srcoff, dstoff; 286 unsigned int totlen, si, di, srcoff, dstoff;
175 void *maddr = NULL; 287 void *maddr = NULL;
176 288
289 /* We return the total length transferred. */
177 totlen = 0; 290 totlen = 0;
291
292 /* We keep indexes into the source and destination "struct lguest_dma",
293 * and an offset within each region. */
178 si = di = 0; 294 si = di = 0;
179 srcoff = dstoff = 0; 295 srcoff = dstoff = 0;
296
297 /* We loop until the source or destination is exhausted. */
180 while (si < LGUEST_MAX_DMA_SECTIONS && src->len[si] 298 while (si < LGUEST_MAX_DMA_SECTIONS && src->len[si]
181 && di < LGUEST_MAX_DMA_SECTIONS && dst->len[di]) { 299 && di < LGUEST_MAX_DMA_SECTIONS && dst->len[di]) {
300 /* We can only transfer the rest of the src buffer, or as much
301 * as will fit into the destination buffer. */
182 u32 len = min(src->len[si] - srcoff, dst->len[di] - dstoff); 302 u32 len = min(src->len[si] - srcoff, dst->len[di] - dstoff);
183 303
304 /* For systems using "highmem" we need to use kmap() to access
305 * the page we want. We often use the same page over and over,
306 * so rather than kmap() it on every loop, we set the maddr
307 * pointer to NULL when we need to move to the next
308 * destination page. */
184 if (!maddr) 309 if (!maddr)
185 maddr = kmap(pages[di]); 310 maddr = kmap(pages[di]);
186 311
187 /* FIXME: This is not completely portable, since 312 /* Copy directly from (this Guest's) source address to the
188 archs do different things for copy_to_user_page. */ 313 * destination Guest's kmap()ed buffer. Note that maddr points
314 * to the start of the page: we need to add the offset of the
315 * destination address and offset within the buffer. */
316
317 /* FIXME: This is not completely portable. I looked at
318 * copy_to_user_page(), and some arch's seem to need special
319 * flushes. x86 is fine. */
189 if (copy_from_user(maddr + (dst->addr[di] + dstoff)%PAGE_SIZE, 320 if (copy_from_user(maddr + (dst->addr[di] + dstoff)%PAGE_SIZE,
190 (void __user *)src->addr[si], len) != 0) { 321 (void __user *)src->addr[si], len) != 0) {
322 /* If a copy failed, it's the source's fault. */
191 kill_guest(srclg, "bad address in sending DMA"); 323 kill_guest(srclg, "bad address in sending DMA");
192 totlen = 0; 324 totlen = 0;
193 break; 325 break;
194 } 326 }
195 327
328 /* Increment the total and src & dst offsets */
196 totlen += len; 329 totlen += len;
197 srcoff += len; 330 srcoff += len;
198 dstoff += len; 331 dstoff += len;
332
333 /* Presumably we reached the end of the src or dest buffers: */
199 if (srcoff == src->len[si]) { 334 if (srcoff == src->len[si]) {
335 /* Move to the next buffer at offset 0 */
200 si++; 336 si++;
201 srcoff = 0; 337 srcoff = 0;
202 } 338 }
203 if (dstoff == dst->len[di]) { 339 if (dstoff == dst->len[di]) {
340 /* We need to unmap that destination page and reset
341 * maddr ready for the next one. */
204 kunmap(pages[di]); 342 kunmap(pages[di]);
205 maddr = NULL; 343 maddr = NULL;
206 di++; 344 di++;
@@ -208,13 +346,15 @@ static u32 copy_data(struct lguest *srclg,
208 } 346 }
209 } 347 }
210 348
349 /* If we still had a page mapped at the end, unmap now. */
211 if (maddr) 350 if (maddr)
212 kunmap(pages[di]); 351 kunmap(pages[di]);
213 352
214 return totlen; 353 return totlen;
215} 354}
216 355
217/* Src is us, ie. current. */ 356/*L:390 This is how we transfer a "struct lguest_dma" from the source Guest
357 * (the current Guest which called SEND_DMA) to another Guest. */
218static u32 do_dma(struct lguest *srclg, const struct lguest_dma *src, 358static u32 do_dma(struct lguest *srclg, const struct lguest_dma *src,
219 struct lguest *dstlg, const struct lguest_dma *dst) 359 struct lguest *dstlg, const struct lguest_dma *dst)
220{ 360{
@@ -222,23 +362,31 @@ static u32 do_dma(struct lguest *srclg, const struct lguest_dma *src,
222 u32 ret; 362 u32 ret;
223 struct page *pages[LGUEST_MAX_DMA_SECTIONS]; 363 struct page *pages[LGUEST_MAX_DMA_SECTIONS];
224 364
365 /* We check that both source and destination "struct lguest_dma"s are
366 * within the bounds of the source and destination Guests */
225 if (!check_dma_list(dstlg, dst) || !check_dma_list(srclg, src)) 367 if (!check_dma_list(dstlg, dst) || !check_dma_list(srclg, src))
226 return 0; 368 return 0;
227 369
228 /* First get the destination pages */ 370 /* We need to map the pages which correspond to each parts of
371 * destination buffer. */
229 for (i = 0; i < LGUEST_MAX_DMA_SECTIONS; i++) { 372 for (i = 0; i < LGUEST_MAX_DMA_SECTIONS; i++) {
230 if (dst->len[i] == 0) 373 if (dst->len[i] == 0)
231 break; 374 break;
375 /* get_user_pages() is a complicated function, especially since
376 * we only want a single page. But it works, and returns the
377 * number of pages. Note that we're holding the destination's
378 * mmap_sem, as get_user_pages() requires. */
232 if (get_user_pages(dstlg->tsk, dstlg->mm, 379 if (get_user_pages(dstlg->tsk, dstlg->mm,
233 dst->addr[i], 1, 1, 1, pages+i, NULL) 380 dst->addr[i], 1, 1, 1, pages+i, NULL)
234 != 1) { 381 != 1) {
382 /* This means the destination gave us a bogus buffer */
235 kill_guest(dstlg, "Error mapping DMA pages"); 383 kill_guest(dstlg, "Error mapping DMA pages");
236 ret = 0; 384 ret = 0;
237 goto drop_pages; 385 goto drop_pages;
238 } 386 }
239 } 387 }
240 388
241 /* Now copy until we run out of src or dst. */ 389 /* Now copy the data until we run out of src or dst. */
242 ret = copy_data(srclg, src, dst, pages); 390 ret = copy_data(srclg, src, dst, pages);
243 391
244drop_pages: 392drop_pages:
@@ -247,6 +395,11 @@ drop_pages:
247 return ret; 395 return ret;
248} 396}
249 397
398/*L:380 Transferring data from one Guest to another is not as simple as I'd
399 * like. We've found the "struct lguest_dma_info" bound to the same address as
400 * the send, we need to copy into it.
401 *
402 * This function returns true if the destination array was empty. */
250static int dma_transfer(struct lguest *srclg, 403static int dma_transfer(struct lguest *srclg,
251 unsigned long udma, 404 unsigned long udma,
252 struct lguest_dma_info *dst) 405 struct lguest_dma_info *dst)
@@ -255,15 +408,23 @@ static int dma_transfer(struct lguest *srclg,
255 struct lguest *dstlg; 408 struct lguest *dstlg;
256 u32 i, dma = 0; 409 u32 i, dma = 0;
257 410
411 /* From the "struct lguest_dma_info" we found in the hash, grab the
412 * Guest. */
258 dstlg = &lguests[dst->guestid]; 413 dstlg = &lguests[dst->guestid];
259 /* Get our dma list. */ 414 /* Read in the source "struct lguest_dma" handed to SEND_DMA. */
260 lgread(srclg, &src_dma, udma, sizeof(src_dma)); 415 lgread(srclg, &src_dma, udma, sizeof(src_dma));
261 416
262 /* We can't deadlock against them dmaing to us, because this 417 /* We need the destination's mmap_sem, and we already hold the source's
263 * is all under the lguest_lock. */ 418 * mmap_sem for the futex key lookup. Normally this would suggest that
419 * we could deadlock if the destination Guest was trying to send to
420 * this source Guest at the same time, which is another reason that all
421 * I/O is done under the big lguest_lock. */
264 down_read(&dstlg->mm->mmap_sem); 422 down_read(&dstlg->mm->mmap_sem);
265 423
424 /* Look through the destination DMA array for an available buffer. */
266 for (i = 0; i < dst->num_dmas; i++) { 425 for (i = 0; i < dst->num_dmas; i++) {
426 /* We keep a "next_dma" pointer which often helps us avoid
427 * looking at lots of previously-filled entries. */
267 dma = (dst->next_dma + i) % dst->num_dmas; 428 dma = (dst->next_dma + i) % dst->num_dmas;
268 if (!lgread_other(dstlg, &dst_dma, 429 if (!lgread_other(dstlg, &dst_dma,
269 dst->dmas + dma * sizeof(struct lguest_dma), 430 dst->dmas + dma * sizeof(struct lguest_dma),
@@ -273,30 +434,46 @@ static int dma_transfer(struct lguest *srclg,
273 if (!dst_dma.used_len) 434 if (!dst_dma.used_len)
274 break; 435 break;
275 } 436 }
437
438 /* If we found a buffer, we do the actual data copy. */
276 if (i != dst->num_dmas) { 439 if (i != dst->num_dmas) {
277 unsigned long used_lenp; 440 unsigned long used_lenp;
278 unsigned int ret; 441 unsigned int ret;
279 442
280 ret = do_dma(srclg, &src_dma, dstlg, &dst_dma); 443 ret = do_dma(srclg, &src_dma, dstlg, &dst_dma);
281 /* Put used length in src. */ 444 /* Put used length in the source "struct lguest_dma"'s used_len
445 * field. It's a little tricky to figure out where that is,
446 * though. */
282 lgwrite_u32(srclg, 447 lgwrite_u32(srclg,
283 udma+offsetof(struct lguest_dma, used_len), ret); 448 udma+offsetof(struct lguest_dma, used_len), ret);
449 /* Tranferring 0 bytes is OK if the source buffer was empty. */
284 if (ret == 0 && src_dma.len[0] != 0) 450 if (ret == 0 && src_dma.len[0] != 0)
285 goto fail; 451 goto fail;
286 452
287 /* Make sure destination sees contents before length. */ 453 /* The destination Guest might be running on a different CPU:
454 * we have to make sure that it will see the "used_len" field
455 * change to non-zero *after* it sees the data we copied into
456 * the buffer. Hence a write memory barrier. */
288 wmb(); 457 wmb();
458 /* Figuring out where the destination's used_len field for this
459 * "struct lguest_dma" in the array is also a little ugly. */
289 used_lenp = dst->dmas 460 used_lenp = dst->dmas
290 + dma * sizeof(struct lguest_dma) 461 + dma * sizeof(struct lguest_dma)
291 + offsetof(struct lguest_dma, used_len); 462 + offsetof(struct lguest_dma, used_len);
292 lgwrite_other(dstlg, used_lenp, &ret, sizeof(ret)); 463 lgwrite_other(dstlg, used_lenp, &ret, sizeof(ret));
464 /* Move the cursor for next time. */
293 dst->next_dma++; 465 dst->next_dma++;
294 } 466 }
295 up_read(&dstlg->mm->mmap_sem); 467 up_read(&dstlg->mm->mmap_sem);
296 468
297 /* Do this last so dst doesn't simply sleep on lock. */ 469 /* We trigger the destination interrupt, even if the destination was
470 * empty and we didn't transfer anything: this gives them a chance to
471 * wake up and refill. */
298 set_bit(dst->interrupt, dstlg->irqs_pending); 472 set_bit(dst->interrupt, dstlg->irqs_pending);
473 /* Wake up the destination process. */
299 wake_up_process(dstlg->tsk); 474 wake_up_process(dstlg->tsk);
475 /* If we passed the last "struct lguest_dma", the receive had no
476 * buffers left. */
300 return i == dst->num_dmas; 477 return i == dst->num_dmas;
301 478
302fail: 479fail:
@@ -304,6 +481,8 @@ fail:
304 return 0; 481 return 0;
305} 482}
306 483
484/*L:370 This is the counter-side to the BIND_DMA hypercall; the SEND_DMA
485 * hypercall. We find out who's listening, and send to them. */
307void send_dma(struct lguest *lg, unsigned long ukey, unsigned long udma) 486void send_dma(struct lguest *lg, unsigned long ukey, unsigned long udma)
308{ 487{
309 union futex_key key; 488 union futex_key key;
@@ -313,31 +492,43 @@ void send_dma(struct lguest *lg, unsigned long ukey, unsigned long udma)
313again: 492again:
314 mutex_lock(&lguest_lock); 493 mutex_lock(&lguest_lock);
315 down_read(fshared); 494 down_read(fshared);
495 /* Get the futex key for the key the Guest gave us */
316 if (get_futex_key((u32 __user *)ukey, fshared, &key) != 0) { 496 if (get_futex_key((u32 __user *)ukey, fshared, &key) != 0) {
317 kill_guest(lg, "bad sending DMA key"); 497 kill_guest(lg, "bad sending DMA key");
318 goto unlock; 498 goto unlock;
319 } 499 }
320 /* Shared mapping? Look for other guests... */ 500 /* Since the key must be a multiple of 4, the futex key uses the lower
501 * bit of the "offset" field (which would always be 0) to indicate a
502 * mapping which is shared with other processes (ie. Guests). */
321 if (key.shared.offset & 1) { 503 if (key.shared.offset & 1) {
322 struct lguest_dma_info *i; 504 struct lguest_dma_info *i;
505 /* Look through the hash for other Guests. */
323 list_for_each_entry(i, &dma_hash[hash(&key)], list) { 506 list_for_each_entry(i, &dma_hash[hash(&key)], list) {
507 /* Don't send to ourselves. */
324 if (i->guestid == lg->guestid) 508 if (i->guestid == lg->guestid)
325 continue; 509 continue;
326 if (!key_eq(&key, &i->key)) 510 if (!key_eq(&key, &i->key))
327 continue; 511 continue;
328 512
513 /* If dma_transfer() tells us the destination has no
514 * available buffers, we increment "empty". */
329 empty += dma_transfer(lg, udma, i); 515 empty += dma_transfer(lg, udma, i);
330 break; 516 break;
331 } 517 }
518 /* If the destination is empty, we release our locks and
519 * give the destination Guest a brief chance to restock. */
332 if (empty == 1) { 520 if (empty == 1) {
333 /* Give any recipients one chance to restock. */ 521 /* Give any recipients one chance to restock. */
334 up_read(&current->mm->mmap_sem); 522 up_read(&current->mm->mmap_sem);
335 mutex_unlock(&lguest_lock); 523 mutex_unlock(&lguest_lock);
524 /* Next time, we won't try again. */
336 empty++; 525 empty++;
337 goto again; 526 goto again;
338 } 527 }
339 } else { 528 } else {
340 /* Private mapping: tell our userspace. */ 529 /* Private mapping: Guest is sending to its Launcher. We set
530 * the "dma_is_pending" flag so that the main loop will exit
531 * and the Launcher's read() from /dev/lguest will return. */
341 lg->dma_is_pending = 1; 532 lg->dma_is_pending = 1;
342 lg->pending_dma = udma; 533 lg->pending_dma = udma;
343 lg->pending_key = ukey; 534 lg->pending_key = ukey;
@@ -346,6 +537,7 @@ unlock:
346 up_read(fshared); 537 up_read(fshared);
347 mutex_unlock(&lguest_lock); 538 mutex_unlock(&lguest_lock);
348} 539}
540/*:*/
349 541
350void release_all_dma(struct lguest *lg) 542void release_all_dma(struct lguest *lg)
351{ 543{
@@ -361,7 +553,18 @@ void release_all_dma(struct lguest *lg)
361 up_read(&lg->mm->mmap_sem); 553 up_read(&lg->mm->mmap_sem);
362} 554}
363 555
364/* Userspace wants a dma buffer from this guest. */ 556/*M:007 We only return a single DMA buffer to the Launcher, but it would be
557 * more efficient to return a pointer to the entire array of DMA buffers, which
558 * it can cache and choose one whenever it wants.
559 *
560 * Currently the Launcher uses a write to /dev/lguest, and the return value is
561 * the address of the DMA structure with the interrupt number placed in
562 * dma->used_len. If we wanted to return the entire array, we need to return
563 * the address, array size and interrupt number: this seems to require an
564 * ioctl(). :*/
565
566/*L:320 This routine looks for a DMA buffer registered by the Guest on the
567 * given key (using the BIND_DMA hypercall). */
365unsigned long get_dma_buffer(struct lguest *lg, 568unsigned long get_dma_buffer(struct lguest *lg,
366 unsigned long ukey, unsigned long *interrupt) 569 unsigned long ukey, unsigned long *interrupt)
367{ 570{
@@ -370,15 +573,29 @@ unsigned long get_dma_buffer(struct lguest *lg,
370 struct lguest_dma_info *i; 573 struct lguest_dma_info *i;
371 struct rw_semaphore *fshared = &current->mm->mmap_sem; 574 struct rw_semaphore *fshared = &current->mm->mmap_sem;
372 575
576 /* Take the Big Lguest Lock to stop other Guests sending this Guest DMA
577 * at the same time. */
373 mutex_lock(&lguest_lock); 578 mutex_lock(&lguest_lock);
579 /* To match between Guests sharing the same underlying memory we steal
580 * code from the futex infrastructure. This requires that we hold the
581 * "mmap_sem" for our process (the Launcher), and pass it to the futex
582 * code. */
374 down_read(fshared); 583 down_read(fshared);
584
585 /* This can fail if it's not a valid address, or if the address is not
586 * divisible by 4 (the futex code needs that, we don't really). */
375 if (get_futex_key((u32 __user *)ukey, fshared, &key) != 0) { 587 if (get_futex_key((u32 __user *)ukey, fshared, &key) != 0) {
376 kill_guest(lg, "bad registered DMA buffer"); 588 kill_guest(lg, "bad registered DMA buffer");
377 goto unlock; 589 goto unlock;
378 } 590 }
591 /* Search the hash table for matching entries (the Launcher can only
592 * send to its own Guest for the moment, so the entry must be for this
593 * Guest) */
379 list_for_each_entry(i, &dma_hash[hash(&key)], list) { 594 list_for_each_entry(i, &dma_hash[hash(&key)], list) {
380 if (key_eq(&key, &i->key) && i->guestid == lg->guestid) { 595 if (key_eq(&key, &i->key) && i->guestid == lg->guestid) {
381 unsigned int j; 596 unsigned int j;
597 /* Look through the registered DMA array for an
598 * available buffer. */
382 for (j = 0; j < i->num_dmas; j++) { 599 for (j = 0; j < i->num_dmas; j++) {
383 struct lguest_dma dma; 600 struct lguest_dma dma;
384 601
@@ -387,6 +604,8 @@ unsigned long get_dma_buffer(struct lguest *lg,
387 if (dma.used_len == 0) 604 if (dma.used_len == 0)
388 break; 605 break;
389 } 606 }
607 /* Store the interrupt the Guest wants when the buffer
608 * is used. */
390 *interrupt = i->interrupt; 609 *interrupt = i->interrupt;
391 break; 610 break;
392 } 611 }
@@ -396,4 +615,12 @@ unlock:
396 mutex_unlock(&lguest_lock); 615 mutex_unlock(&lguest_lock);
397 return ret; 616 return ret;
398} 617}
618/*:*/
399 619
620/*L:410 This really has completed the Launcher. Not only have we now finished
621 * the longest chapter in our journey, but this also means we are over halfway
622 * through!
623 *
624 * Enough prevaricating around the bush: it is time for us to dive into the
625 * core of the Host, in "make Host".
626 */
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index 3e2ddfbc816e..64f0abed317c 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -58,9 +58,18 @@ struct lguest_dma_info
58 u8 interrupt; /* 0 when not registered */ 58 u8 interrupt; /* 0 when not registered */
59}; 59};
60 60
61/* We have separate types for the guest's ptes & pgds and the shadow ptes & 61/*H:310 The page-table code owes a great debt of gratitude to Andi Kleen. He
62 * pgds. Since this host might use three-level pagetables and the guest and 62 * reviewed the original code which used "u32" for all page table entries, and
63 * shadow pagetables don't, we can't use the normal pte_t/pgd_t. */ 63 * insisted that it would be far clearer with explicit typing. I thought it
64 * was overkill, but he was right: it is much clearer than it was before.
65 *
66 * We have separate types for the Guest's ptes & pgds and the shadow ptes &
67 * pgds. There's already a Linux type for these (pte_t and pgd_t) but they
68 * change depending on kernel config options (PAE). */
69
70/* Each entry is identical: lower 12 bits of flags and upper 20 bits for the
71 * "page frame number" (0 == first physical page, etc). They are different
72 * types so the compiler will warn us if we mix them improperly. */
64typedef union { 73typedef union {
65 struct { unsigned flags:12, pfn:20; }; 74 struct { unsigned flags:12, pfn:20; };
66 struct { unsigned long val; } raw; 75 struct { unsigned long val; } raw;
@@ -77,8 +86,12 @@ typedef union {
77 struct { unsigned flags:12, pfn:20; }; 86 struct { unsigned flags:12, pfn:20; };
78 struct { unsigned long val; } raw; 87 struct { unsigned long val; } raw;
79} gpte_t; 88} gpte_t;
89
90/* We have two convenient macros to convert a "raw" value as handed to us by
91 * the Guest into the correct Guest PGD or PTE type. */
80#define mkgpte(_val) ((gpte_t){.raw.val = _val}) 92#define mkgpte(_val) ((gpte_t){.raw.val = _val})
81#define mkgpgd(_val) ((gpgd_t){.raw.val = _val}) 93#define mkgpgd(_val) ((gpgd_t){.raw.val = _val})
94/*:*/
82 95
83struct pgdir 96struct pgdir
84{ 97{
@@ -243,7 +256,32 @@ unsigned long get_dma_buffer(struct lguest *lg, unsigned long key,
243 256
244/* hypercalls.c: */ 257/* hypercalls.c: */
245void do_hypercalls(struct lguest *lg); 258void do_hypercalls(struct lguest *lg);
246 259void write_timestamp(struct lguest *lg);
260
261/*L:035
262 * Let's step aside for the moment, to study one important routine that's used
263 * widely in the Host code.
264 *
265 * There are many cases where the Guest does something invalid, like pass crap
266 * to a hypercall. Since only the Guest kernel can make hypercalls, it's quite
267 * acceptable to simply terminate the Guest and give the Launcher a nicely
268 * formatted reason. It's also simpler for the Guest itself, which doesn't
269 * need to check most hypercalls for "success"; if you're still running, it
270 * succeeded.
271 *
272 * Once this is called, the Guest will never run again, so most Host code can
273 * call this then continue as if nothing had happened. This means many
274 * functions don't have to explicitly return an error code, which keeps the
275 * code simple.
276 *
277 * It also means that this can be called more than once: only the first one is
278 * remembered. The only trick is that we still need to kill the Guest even if
279 * we can't allocate memory to store the reason. Linux has a neat way of
280 * packing error codes into invalid pointers, so we use that here.
281 *
282 * Like any macro which uses an "if", it is safely wrapped in a run-once "do {
283 * } while(0)".
284 */
247#define kill_guest(lg, fmt...) \ 285#define kill_guest(lg, fmt...) \
248do { \ 286do { \
249 if (!(lg)->dead) { \ 287 if (!(lg)->dead) { \
@@ -252,6 +290,7 @@ do { \
252 (lg)->dead = ERR_PTR(-ENOMEM); \ 290 (lg)->dead = ERR_PTR(-ENOMEM); \
253 } \ 291 } \
254} while(0) 292} while(0)
293/* (End of aside) :*/
255 294
256static inline unsigned long guest_pa(struct lguest *lg, unsigned long vaddr) 295static inline unsigned long guest_pa(struct lguest *lg, unsigned long vaddr)
257{ 296{
diff --git a/drivers/lguest/lguest.c b/drivers/lguest/lguest.c
index 18dade06d4a9..1bc1546c7fd0 100644
--- a/drivers/lguest/lguest.c
+++ b/drivers/lguest/lguest.c
@@ -1,6 +1,32 @@
1/* 1/*P:010
2 * Lguest specific paravirt-ops implementation 2 * A hypervisor allows multiple Operating Systems to run on a single machine.
3 * To quote David Wheeler: "Any problem in computer science can be solved with
4 * another layer of indirection."
5 *
6 * We keep things simple in two ways. First, we start with a normal Linux
7 * kernel and insert a module (lg.ko) which allows us to run other Linux
8 * kernels the same way we'd run processes. We call the first kernel the Host,
9 * and the others the Guests. The program which sets up and configures Guests
10 * (such as the example in Documentation/lguest/lguest.c) is called the
11 * Launcher.
12 *
13 * Secondly, we only run specially modified Guests, not normal kernels. When
14 * you set CONFIG_LGUEST to 'y' or 'm', this automatically sets
15 * CONFIG_LGUEST_GUEST=y, which compiles this file into the kernel so it knows
16 * how to be a Guest. This means that you can use the same kernel you boot
17 * normally (ie. as a Host) as a Guest.
3 * 18 *
19 * These Guests know that they cannot do privileged operations, such as disable
20 * interrupts, and that they have to ask the Host to do such things explicitly.
21 * This file consists of all the replacements for such low-level native
22 * hardware operations: these special Guest versions call the Host.
23 *
24 * So how does the kernel know it's a Guest? The Guest starts at a special
25 * entry point marked with a magic string, which sets up a few things then
26 * calls here. We replace the native functions in "struct paravirt_ops"
27 * with our Guest versions, then boot like normal. :*/
28
29/*
4 * Copyright (C) 2006, Rusty Russell <rusty@rustcorp.com.au> IBM Corporation. 30 * Copyright (C) 2006, Rusty Russell <rusty@rustcorp.com.au> IBM Corporation.
5 * 31 *
6 * This program is free software; you can redistribute it and/or modify 32 * This program is free software; you can redistribute it and/or modify
@@ -40,6 +66,12 @@
40#include <asm/mce.h> 66#include <asm/mce.h>
41#include <asm/io.h> 67#include <asm/io.h>
42 68
69/*G:010 Welcome to the Guest!
70 *
71 * The Guest in our tale is a simple creature: identical to the Host but
72 * behaving in simplified but equivalent ways. In particular, the Guest is the
73 * same kernel as the Host (or at least, built from the same source code). :*/
74
43/* Declarations for definitions in lguest_guest.S */ 75/* Declarations for definitions in lguest_guest.S */
44extern char lguest_noirq_start[], lguest_noirq_end[]; 76extern char lguest_noirq_start[], lguest_noirq_end[];
45extern const char lgstart_cli[], lgend_cli[]; 77extern const char lgstart_cli[], lgend_cli[];
@@ -58,7 +90,26 @@ struct lguest_data lguest_data = {
58struct lguest_device_desc *lguest_devices; 90struct lguest_device_desc *lguest_devices;
59static cycle_t clock_base; 91static cycle_t clock_base;
60 92
61static enum paravirt_lazy_mode lazy_mode; 93/*G:035 Notice the lazy_hcall() above, rather than hcall(). This is our first
94 * real optimization trick!
95 *
96 * When lazy_mode is set, it means we're allowed to defer all hypercalls and do
97 * them as a batch when lazy_mode is eventually turned off. Because hypercalls
98 * are reasonably expensive, batching them up makes sense. For example, a
99 * large mmap might update dozens of page table entries: that code calls
100 * lguest_lazy_mode(PARAVIRT_LAZY_MMU), does the dozen updates, then calls
101 * lguest_lazy_mode(PARAVIRT_LAZY_NONE).
102 *
103 * So, when we're in lazy mode, we call async_hypercall() to store the call for
104 * future processing. When lazy mode is turned off we issue a hypercall to
105 * flush the stored calls.
106 *
107 * There's also a hack where "mode" is set to "PARAVIRT_LAZY_FLUSH" which
108 * indicates we're to flush any outstanding calls immediately. This is used
109 * when an interrupt handler does a kmap_atomic(): the page table changes must
110 * happen immediately even if we're in the middle of a batch. Usually we're
111 * not, though, so there's nothing to do. */
112static enum paravirt_lazy_mode lazy_mode; /* Note: not SMP-safe! */
62static void lguest_lazy_mode(enum paravirt_lazy_mode mode) 113static void lguest_lazy_mode(enum paravirt_lazy_mode mode)
63{ 114{
64 if (mode == PARAVIRT_LAZY_FLUSH) { 115 if (mode == PARAVIRT_LAZY_FLUSH) {
@@ -82,6 +133,16 @@ static void lazy_hcall(unsigned long call,
82 async_hcall(call, arg1, arg2, arg3); 133 async_hcall(call, arg1, arg2, arg3);
83} 134}
84 135
136/* async_hcall() is pretty simple: I'm quite proud of it really. We have a
137 * ring buffer of stored hypercalls which the Host will run though next time we
138 * do a normal hypercall. Each entry in the ring has 4 slots for the hypercall
139 * arguments, and a "hcall_status" word which is 0 if the call is ready to go,
140 * and 255 once the Host has finished with it.
141 *
142 * If we come around to a slot which hasn't been finished, then the table is
143 * full and we just make the hypercall directly. This has the nice side
144 * effect of causing the Host to run all the stored calls in the ring buffer
145 * which empties it for next time! */
85void async_hcall(unsigned long call, 146void async_hcall(unsigned long call,
86 unsigned long arg1, unsigned long arg2, unsigned long arg3) 147 unsigned long arg1, unsigned long arg2, unsigned long arg3)
87{ 148{
@@ -89,6 +150,9 @@ void async_hcall(unsigned long call,
89 static unsigned int next_call; 150 static unsigned int next_call;
90 unsigned long flags; 151 unsigned long flags;
91 152
153 /* Disable interrupts if not already disabled: we don't want an
154 * interrupt handler making a hypercall while we're already doing
155 * one! */
92 local_irq_save(flags); 156 local_irq_save(flags);
93 if (lguest_data.hcall_status[next_call] != 0xFF) { 157 if (lguest_data.hcall_status[next_call] != 0xFF) {
94 /* Table full, so do normal hcall which will flush table. */ 158 /* Table full, so do normal hcall which will flush table. */
@@ -98,7 +162,7 @@ void async_hcall(unsigned long call,
98 lguest_data.hcalls[next_call].edx = arg1; 162 lguest_data.hcalls[next_call].edx = arg1;
99 lguest_data.hcalls[next_call].ebx = arg2; 163 lguest_data.hcalls[next_call].ebx = arg2;
100 lguest_data.hcalls[next_call].ecx = arg3; 164 lguest_data.hcalls[next_call].ecx = arg3;
101 /* Make sure host sees arguments before "valid" flag. */ 165 /* Arguments must all be written before we mark it to go */
102 wmb(); 166 wmb();
103 lguest_data.hcall_status[next_call] = 0; 167 lguest_data.hcall_status[next_call] = 0;
104 if (++next_call == LHCALL_RING_SIZE) 168 if (++next_call == LHCALL_RING_SIZE)
@@ -106,9 +170,14 @@ void async_hcall(unsigned long call,
106 } 170 }
107 local_irq_restore(flags); 171 local_irq_restore(flags);
108} 172}
173/*:*/
109 174
175/* Wrappers for the SEND_DMA and BIND_DMA hypercalls. This is mainly because
176 * Jeff Garzik complained that __pa() should never appear in drivers, and this
177 * helps remove most of them. But also, it wraps some ugliness. */
110void lguest_send_dma(unsigned long key, struct lguest_dma *dma) 178void lguest_send_dma(unsigned long key, struct lguest_dma *dma)
111{ 179{
180 /* The hcall might not write this if something goes wrong */
112 dma->used_len = 0; 181 dma->used_len = 0;
113 hcall(LHCALL_SEND_DMA, key, __pa(dma), 0); 182 hcall(LHCALL_SEND_DMA, key, __pa(dma), 0);
114} 183}
@@ -116,11 +185,16 @@ void lguest_send_dma(unsigned long key, struct lguest_dma *dma)
116int lguest_bind_dma(unsigned long key, struct lguest_dma *dmas, 185int lguest_bind_dma(unsigned long key, struct lguest_dma *dmas,
117 unsigned int num, u8 irq) 186 unsigned int num, u8 irq)
118{ 187{
188 /* This is the only hypercall which actually wants 5 arguments, and we
189 * only support 4. Fortunately the interrupt number is always less
190 * than 256, so we can pack it with the number of dmas in the final
191 * argument. */
119 if (!hcall(LHCALL_BIND_DMA, key, __pa(dmas), (num << 8) | irq)) 192 if (!hcall(LHCALL_BIND_DMA, key, __pa(dmas), (num << 8) | irq))
120 return -ENOMEM; 193 return -ENOMEM;
121 return 0; 194 return 0;
122} 195}
123 196
197/* Unbinding is the same hypercall as binding, but with 0 num & irq. */
124void lguest_unbind_dma(unsigned long key, struct lguest_dma *dmas) 198void lguest_unbind_dma(unsigned long key, struct lguest_dma *dmas)
125{ 199{
126 hcall(LHCALL_BIND_DMA, key, __pa(dmas), 0); 200 hcall(LHCALL_BIND_DMA, key, __pa(dmas), 0);
@@ -138,35 +212,73 @@ void lguest_unmap(void *addr)
138 iounmap((__force void __iomem *)addr); 212 iounmap((__force void __iomem *)addr);
139} 213}
140 214
215/*G:033
216 * Here are our first native-instruction replacements: four functions for
217 * interrupt control.
218 *
219 * The simplest way of implementing these would be to have "turn interrupts
220 * off" and "turn interrupts on" hypercalls. Unfortunately, this is too slow:
221 * these are by far the most commonly called functions of those we override.
222 *
223 * So instead we keep an "irq_enabled" field inside our "struct lguest_data",
224 * which the Guest can update with a single instruction. The Host knows to
225 * check there when it wants to deliver an interrupt.
226 */
227
228/* save_flags() is expected to return the processor state (ie. "eflags"). The
229 * eflags word contains all kind of stuff, but in practice Linux only cares
230 * about the interrupt flag. Our "save_flags()" just returns that. */
141static unsigned long save_fl(void) 231static unsigned long save_fl(void)
142{ 232{
143 return lguest_data.irq_enabled; 233 return lguest_data.irq_enabled;
144} 234}
145 235
236/* "restore_flags" just sets the flags back to the value given. */
146static void restore_fl(unsigned long flags) 237static void restore_fl(unsigned long flags)
147{ 238{
148 /* FIXME: Check if interrupt pending... */
149 lguest_data.irq_enabled = flags; 239 lguest_data.irq_enabled = flags;
150} 240}
151 241
242/* Interrupts go off... */
152static void irq_disable(void) 243static void irq_disable(void)
153{ 244{
154 lguest_data.irq_enabled = 0; 245 lguest_data.irq_enabled = 0;
155} 246}
156 247
248/* Interrupts go on... */
157static void irq_enable(void) 249static void irq_enable(void)
158{ 250{
159 /* FIXME: Check if interrupt pending... */
160 lguest_data.irq_enabled = X86_EFLAGS_IF; 251 lguest_data.irq_enabled = X86_EFLAGS_IF;
161} 252}
162 253/*:*/
254/*M:003 Note that we don't check for outstanding interrupts when we re-enable
255 * them (or when we unmask an interrupt). This seems to work for the moment,
256 * since interrupts are rare and we'll just get the interrupt on the next timer
257 * tick, but when we turn on CONFIG_NO_HZ, we should revisit this. One way
258 * would be to put the "irq_enabled" field in a page by itself, and have the
259 * Host write-protect it when an interrupt comes in when irqs are disabled.
260 * There will then be a page fault as soon as interrupts are re-enabled. :*/
261
262/*G:034
263 * The Interrupt Descriptor Table (IDT).
264 *
265 * The IDT tells the processor what to do when an interrupt comes in. Each
266 * entry in the table is a 64-bit descriptor: this holds the privilege level,
267 * address of the handler, and... well, who cares? The Guest just asks the
268 * Host to make the change anyway, because the Host controls the real IDT.
269 */
163static void lguest_write_idt_entry(struct desc_struct *dt, 270static void lguest_write_idt_entry(struct desc_struct *dt,
164 int entrynum, u32 low, u32 high) 271 int entrynum, u32 low, u32 high)
165{ 272{
273 /* Keep the local copy up to date. */
166 write_dt_entry(dt, entrynum, low, high); 274 write_dt_entry(dt, entrynum, low, high);
275 /* Tell Host about this new entry. */
167 hcall(LHCALL_LOAD_IDT_ENTRY, entrynum, low, high); 276 hcall(LHCALL_LOAD_IDT_ENTRY, entrynum, low, high);
168} 277}
169 278
279/* Changing to a different IDT is very rare: we keep the IDT up-to-date every
280 * time it is written, so we can simply loop through all entries and tell the
281 * Host about them. */
170static void lguest_load_idt(const struct Xgt_desc_struct *desc) 282static void lguest_load_idt(const struct Xgt_desc_struct *desc)
171{ 283{
172 unsigned int i; 284 unsigned int i;
@@ -176,12 +288,29 @@ static void lguest_load_idt(const struct Xgt_desc_struct *desc)
176 hcall(LHCALL_LOAD_IDT_ENTRY, i, idt[i].a, idt[i].b); 288 hcall(LHCALL_LOAD_IDT_ENTRY, i, idt[i].a, idt[i].b);
177} 289}
178 290
291/*
292 * The Global Descriptor Table.
293 *
294 * The Intel architecture defines another table, called the Global Descriptor
295 * Table (GDT). You tell the CPU where it is (and its size) using the "lgdt"
296 * instruction, and then several other instructions refer to entries in the
297 * table. There are three entries which the Switcher needs, so the Host simply
298 * controls the entire thing and the Guest asks it to make changes using the
299 * LOAD_GDT hypercall.
300 *
301 * This is the opposite of the IDT code where we have a LOAD_IDT_ENTRY
302 * hypercall and use that repeatedly to load a new IDT. I don't think it
303 * really matters, but wouldn't it be nice if they were the same?
304 */
179static void lguest_load_gdt(const struct Xgt_desc_struct *desc) 305static void lguest_load_gdt(const struct Xgt_desc_struct *desc)
180{ 306{
181 BUG_ON((desc->size+1)/8 != GDT_ENTRIES); 307 BUG_ON((desc->size+1)/8 != GDT_ENTRIES);
182 hcall(LHCALL_LOAD_GDT, __pa(desc->address), GDT_ENTRIES, 0); 308 hcall(LHCALL_LOAD_GDT, __pa(desc->address), GDT_ENTRIES, 0);
183} 309}
184 310
311/* For a single GDT entry which changes, we do the lazy thing: alter our GDT,
312 * then tell the Host to reload the entire thing. This operation is so rare
313 * that this naive implementation is reasonable. */
185static void lguest_write_gdt_entry(struct desc_struct *dt, 314static void lguest_write_gdt_entry(struct desc_struct *dt,
186 int entrynum, u32 low, u32 high) 315 int entrynum, u32 low, u32 high)
187{ 316{
@@ -189,19 +318,58 @@ static void lguest_write_gdt_entry(struct desc_struct *dt,
189 hcall(LHCALL_LOAD_GDT, __pa(dt), GDT_ENTRIES, 0); 318 hcall(LHCALL_LOAD_GDT, __pa(dt), GDT_ENTRIES, 0);
190} 319}
191 320
321/* OK, I lied. There are three "thread local storage" GDT entries which change
322 * on every context switch (these three entries are how glibc implements
323 * __thread variables). So we have a hypercall specifically for this case. */
192static void lguest_load_tls(struct thread_struct *t, unsigned int cpu) 324static void lguest_load_tls(struct thread_struct *t, unsigned int cpu)
193{ 325{
194 lazy_hcall(LHCALL_LOAD_TLS, __pa(&t->tls_array), cpu, 0); 326 lazy_hcall(LHCALL_LOAD_TLS, __pa(&t->tls_array), cpu, 0);
195} 327}
328/*:*/
196 329
330/*G:038 That's enough excitement for now, back to ploughing through each of
331 * the paravirt_ops (we're about 1/3 of the way through).
332 *
333 * This is the Local Descriptor Table, another weird Intel thingy. Linux only
334 * uses this for some strange applications like Wine. We don't do anything
335 * here, so they'll get an informative and friendly Segmentation Fault. */
197static void lguest_set_ldt(const void *addr, unsigned entries) 336static void lguest_set_ldt(const void *addr, unsigned entries)
198{ 337{
199} 338}
200 339
340/* This loads a GDT entry into the "Task Register": that entry points to a
341 * structure called the Task State Segment. Some comments scattered though the
342 * kernel code indicate that this used for task switching in ages past, along
343 * with blood sacrifice and astrology.
344 *
345 * Now there's nothing interesting in here that we don't get told elsewhere.
346 * But the native version uses the "ltr" instruction, which makes the Host
347 * complain to the Guest about a Segmentation Fault and it'll oops. So we
348 * override the native version with a do-nothing version. */
201static void lguest_load_tr_desc(void) 349static void lguest_load_tr_desc(void)
202{ 350{
203} 351}
204 352
353/* The "cpuid" instruction is a way of querying both the CPU identity
354 * (manufacturer, model, etc) and its features. It was introduced before the
355 * Pentium in 1993 and keeps getting extended by both Intel and AMD. As you
356 * might imagine, after a decade and a half this treatment, it is now a giant
357 * ball of hair. Its entry in the current Intel manual runs to 28 pages.
358 *
359 * This instruction even it has its own Wikipedia entry. The Wikipedia entry
360 * has been translated into 4 languages. I am not making this up!
361 *
362 * We could get funky here and identify ourselves as "GenuineLguest", but
363 * instead we just use the real "cpuid" instruction. Then I pretty much turned
364 * off feature bits until the Guest booted. (Don't say that: you'll damage
365 * lguest sales!) Shut up, inner voice! (Hey, just pointing out that this is
366 * hardly future proof.) Noone's listening! They don't like you anyway,
367 * parenthetic weirdo!
368 *
369 * Replacing the cpuid so we can turn features off is great for the kernel, but
370 * anyone (including userspace) can just use the raw "cpuid" instruction and
371 * the Host won't even notice since it isn't privileged. So we try not to get
372 * too worked up about it. */
205static void lguest_cpuid(unsigned int *eax, unsigned int *ebx, 373static void lguest_cpuid(unsigned int *eax, unsigned int *ebx,
206 unsigned int *ecx, unsigned int *edx) 374 unsigned int *ecx, unsigned int *edx)
207{ 375{
@@ -214,21 +382,43 @@ static void lguest_cpuid(unsigned int *eax, unsigned int *ebx,
214 *ecx &= 0x00002201; 382 *ecx &= 0x00002201;
215 /* SSE, SSE2, FXSR, MMX, CMOV, CMPXCHG8B, FPU. */ 383 /* SSE, SSE2, FXSR, MMX, CMOV, CMPXCHG8B, FPU. */
216 *edx &= 0x07808101; 384 *edx &= 0x07808101;
217 /* Host wants to know when we flush kernel pages: set PGE. */ 385 /* The Host can do a nice optimization if it knows that the
386 * kernel mappings (addresses above 0xC0000000 or whatever
387 * PAGE_OFFSET is set to) haven't changed. But Linux calls
388 * flush_tlb_user() for both user and kernel mappings unless
389 * the Page Global Enable (PGE) feature bit is set. */
218 *edx |= 0x00002000; 390 *edx |= 0x00002000;
219 break; 391 break;
220 case 0x80000000: 392 case 0x80000000:
221 /* Futureproof this a little: if they ask how much extended 393 /* Futureproof this a little: if they ask how much extended
222 * processor information, limit it to known fields. */ 394 * processor information there is, limit it to known fields. */
223 if (*eax > 0x80000008) 395 if (*eax > 0x80000008)
224 *eax = 0x80000008; 396 *eax = 0x80000008;
225 break; 397 break;
226 } 398 }
227} 399}
228 400
401/* Intel has four control registers, imaginatively named cr0, cr2, cr3 and cr4.
402 * I assume there's a cr1, but it hasn't bothered us yet, so we'll not bother
403 * it. The Host needs to know when the Guest wants to change them, so we have
404 * a whole series of functions like read_cr0() and write_cr0().
405 *
406 * We start with CR0. CR0 allows you to turn on and off all kinds of basic
407 * features, but Linux only really cares about one: the horrifically-named Task
408 * Switched (TS) bit at bit 3 (ie. 8)
409 *
410 * What does the TS bit do? Well, it causes the CPU to trap (interrupt 7) if
411 * the floating point unit is used. Which allows us to restore FPU state
412 * lazily after a task switch, and Linux uses that gratefully, but wouldn't a
413 * name like "FPUTRAP bit" be a little less cryptic?
414 *
415 * We store cr0 (and cr3) locally, because the Host never changes it. The
416 * Guest sometimes wants to read it and we'd prefer not to bother the Host
417 * unnecessarily. */
229static unsigned long current_cr0, current_cr3; 418static unsigned long current_cr0, current_cr3;
230static void lguest_write_cr0(unsigned long val) 419static void lguest_write_cr0(unsigned long val)
231{ 420{
421 /* 8 == TS bit. */
232 lazy_hcall(LHCALL_TS, val & 8, 0, 0); 422 lazy_hcall(LHCALL_TS, val & 8, 0, 0);
233 current_cr0 = val; 423 current_cr0 = val;
234} 424}
@@ -238,17 +428,25 @@ static unsigned long lguest_read_cr0(void)
238 return current_cr0; 428 return current_cr0;
239} 429}
240 430
431/* Intel provided a special instruction to clear the TS bit for people too cool
432 * to use write_cr0() to do it. This "clts" instruction is faster, because all
433 * the vowels have been optimized out. */
241static void lguest_clts(void) 434static void lguest_clts(void)
242{ 435{
243 lazy_hcall(LHCALL_TS, 0, 0, 0); 436 lazy_hcall(LHCALL_TS, 0, 0, 0);
244 current_cr0 &= ~8U; 437 current_cr0 &= ~8U;
245} 438}
246 439
440/* CR2 is the virtual address of the last page fault, which the Guest only ever
441 * reads. The Host kindly writes this into our "struct lguest_data", so we
442 * just read it out of there. */
247static unsigned long lguest_read_cr2(void) 443static unsigned long lguest_read_cr2(void)
248{ 444{
249 return lguest_data.cr2; 445 return lguest_data.cr2;
250} 446}
251 447
448/* CR3 is the current toplevel pagetable page: the principle is the same as
449 * cr0. Keep a local copy, and tell the Host when it changes. */
252static void lguest_write_cr3(unsigned long cr3) 450static void lguest_write_cr3(unsigned long cr3)
253{ 451{
254 lazy_hcall(LHCALL_NEW_PGTABLE, cr3, 0, 0); 452 lazy_hcall(LHCALL_NEW_PGTABLE, cr3, 0, 0);
@@ -260,7 +458,7 @@ static unsigned long lguest_read_cr3(void)
260 return current_cr3; 458 return current_cr3;
261} 459}
262 460
263/* Used to enable/disable PGE, but we don't care. */ 461/* CR4 is used to enable and disable PGE, but we don't care. */
264static unsigned long lguest_read_cr4(void) 462static unsigned long lguest_read_cr4(void)
265{ 463{
266 return 0; 464 return 0;
@@ -270,6 +468,59 @@ static void lguest_write_cr4(unsigned long val)
270{ 468{
271} 469}
272 470
471/*
472 * Page Table Handling.
473 *
474 * Now would be a good time to take a rest and grab a coffee or similarly
475 * relaxing stimulant. The easy parts are behind us, and the trek gradually
476 * winds uphill from here.
477 *
478 * Quick refresher: memory is divided into "pages" of 4096 bytes each. The CPU
479 * maps virtual addresses to physical addresses using "page tables". We could
480 * use one huge index of 1 million entries: each address is 4 bytes, so that's
481 * 1024 pages just to hold the page tables. But since most virtual addresses
482 * are unused, we use a two level index which saves space. The CR3 register
483 * contains the physical address of the top level "page directory" page, which
484 * contains physical addresses of up to 1024 second-level pages. Each of these
485 * second level pages contains up to 1024 physical addresses of actual pages,
486 * or Page Table Entries (PTEs).
487 *
488 * Here's a diagram, where arrows indicate physical addresses:
489 *
490 * CR3 ---> +---------+
491 * | --------->+---------+
492 * | | | PADDR1 |
493 * Top-level | | PADDR2 |
494 * (PMD) page | | |
495 * | | Lower-level |
496 * | | (PTE) page |
497 * | | | |
498 * .... ....
499 *
500 * So to convert a virtual address to a physical address, we look up the top
501 * level, which points us to the second level, which gives us the physical
502 * address of that page. If the top level entry was not present, or the second
503 * level entry was not present, then the virtual address is invalid (we
504 * say "the page was not mapped").
505 *
506 * Put another way, a 32-bit virtual address is divided up like so:
507 *
508 * 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
509 * |<---- 10 bits ---->|<---- 10 bits ---->|<------ 12 bits ------>|
510 * Index into top Index into second Offset within page
511 * page directory page pagetable page
512 *
513 * The kernel spends a lot of time changing both the top-level page directory
514 * and lower-level pagetable pages. The Guest doesn't know physical addresses,
515 * so while it maintains these page tables exactly like normal, it also needs
516 * to keep the Host informed whenever it makes a change: the Host will create
517 * the real page tables based on the Guests'.
518 */
519
520/* The Guest calls this to set a second-level entry (pte), ie. to map a page
521 * into a process' address space. We set the entry then tell the Host the
522 * toplevel and address this corresponds to. The Guest uses one pagetable per
523 * process, so we need to tell the Host which one we're changing (mm->pgd). */
273static void lguest_set_pte_at(struct mm_struct *mm, unsigned long addr, 524static void lguest_set_pte_at(struct mm_struct *mm, unsigned long addr,
274 pte_t *ptep, pte_t pteval) 525 pte_t *ptep, pte_t pteval)
275{ 526{
@@ -277,7 +528,9 @@ static void lguest_set_pte_at(struct mm_struct *mm, unsigned long addr,
277 lazy_hcall(LHCALL_SET_PTE, __pa(mm->pgd), addr, pteval.pte_low); 528 lazy_hcall(LHCALL_SET_PTE, __pa(mm->pgd), addr, pteval.pte_low);
278} 529}
279 530
280/* We only support two-level pagetables at the moment. */ 531/* The Guest calls this to set a top-level entry. Again, we set the entry then
532 * tell the Host which top-level page we changed, and the index of the entry we
533 * changed. */
281static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval) 534static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval)
282{ 535{
283 *pmdp = pmdval; 536 *pmdp = pmdval;
@@ -285,7 +538,15 @@ static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval)
285 (__pa(pmdp)&(PAGE_SIZE-1))/4, 0); 538 (__pa(pmdp)&(PAGE_SIZE-1))/4, 0);
286} 539}
287 540
288/* FIXME: Eliminate all callers of this. */ 541/* There are a couple of legacy places where the kernel sets a PTE, but we
542 * don't know the top level any more. This is useless for us, since we don't
543 * know which pagetable is changing or what address, so we just tell the Host
544 * to forget all of them. Fortunately, this is very rare.
545 *
546 * ... except in early boot when the kernel sets up the initial pagetables,
547 * which makes booting astonishingly slow. So we don't even tell the Host
548 * anything changed until we've done the first page table switch.
549 */
289static void lguest_set_pte(pte_t *ptep, pte_t pteval) 550static void lguest_set_pte(pte_t *ptep, pte_t pteval)
290{ 551{
291 *ptep = pteval; 552 *ptep = pteval;
@@ -294,22 +555,51 @@ static void lguest_set_pte(pte_t *ptep, pte_t pteval)
294 lazy_hcall(LHCALL_FLUSH_TLB, 1, 0, 0); 555 lazy_hcall(LHCALL_FLUSH_TLB, 1, 0, 0);
295} 556}
296 557
558/* Unfortunately for Lguest, the paravirt_ops for page tables were based on
559 * native page table operations. On native hardware you can set a new page
560 * table entry whenever you want, but if you want to remove one you have to do
561 * a TLB flush (a TLB is a little cache of page table entries kept by the CPU).
562 *
563 * So the lguest_set_pte_at() and lguest_set_pmd() functions above are only
564 * called when a valid entry is written, not when it's removed (ie. marked not
565 * present). Instead, this is where we come when the Guest wants to remove a
566 * page table entry: we tell the Host to set that entry to 0 (ie. the present
567 * bit is zero). */
297static void lguest_flush_tlb_single(unsigned long addr) 568static void lguest_flush_tlb_single(unsigned long addr)
298{ 569{
299 /* Simply set it to zero, and it will fault back in. */ 570 /* Simply set it to zero: if it was not, it will fault back in. */
300 lazy_hcall(LHCALL_SET_PTE, current_cr3, addr, 0); 571 lazy_hcall(LHCALL_SET_PTE, current_cr3, addr, 0);
301} 572}
302 573
574/* This is what happens after the Guest has removed a large number of entries.
575 * This tells the Host that any of the page table entries for userspace might
576 * have changed, ie. virtual addresses below PAGE_OFFSET. */
303static void lguest_flush_tlb_user(void) 577static void lguest_flush_tlb_user(void)
304{ 578{
305 lazy_hcall(LHCALL_FLUSH_TLB, 0, 0, 0); 579 lazy_hcall(LHCALL_FLUSH_TLB, 0, 0, 0);
306} 580}
307 581
582/* This is called when the kernel page tables have changed. That's not very
583 * common (unless the Guest is using highmem, which makes the Guest extremely
584 * slow), so it's worth separating this from the user flushing above. */
308static void lguest_flush_tlb_kernel(void) 585static void lguest_flush_tlb_kernel(void)
309{ 586{
310 lazy_hcall(LHCALL_FLUSH_TLB, 1, 0, 0); 587 lazy_hcall(LHCALL_FLUSH_TLB, 1, 0, 0);
311} 588}
312 589
590/*
591 * The Unadvanced Programmable Interrupt Controller.
592 *
593 * This is an attempt to implement the simplest possible interrupt controller.
594 * I spent some time looking though routines like set_irq_chip_and_handler,
595 * set_irq_chip_and_handler_name, set_irq_chip_data and set_phasers_to_stun and
596 * I *think* this is as simple as it gets.
597 *
598 * We can tell the Host what interrupts we want blocked ready for using the
599 * lguest_data.interrupts bitmap, so disabling (aka "masking") them is as
600 * simple as setting a bit. We don't actually "ack" interrupts as such, we
601 * just mask and unmask them. I wonder if we should be cleverer?
602 */
313static void disable_lguest_irq(unsigned int irq) 603static void disable_lguest_irq(unsigned int irq)
314{ 604{
315 set_bit(irq, lguest_data.blocked_interrupts); 605 set_bit(irq, lguest_data.blocked_interrupts);
@@ -318,9 +608,9 @@ static void disable_lguest_irq(unsigned int irq)
318static void enable_lguest_irq(unsigned int irq) 608static void enable_lguest_irq(unsigned int irq)
319{ 609{
320 clear_bit(irq, lguest_data.blocked_interrupts); 610 clear_bit(irq, lguest_data.blocked_interrupts);
321 /* FIXME: If it's pending? */
322} 611}
323 612
613/* This structure describes the lguest IRQ controller. */
324static struct irq_chip lguest_irq_controller = { 614static struct irq_chip lguest_irq_controller = {
325 .name = "lguest", 615 .name = "lguest",
326 .mask = disable_lguest_irq, 616 .mask = disable_lguest_irq,
@@ -328,6 +618,10 @@ static struct irq_chip lguest_irq_controller = {
328 .unmask = enable_lguest_irq, 618 .unmask = enable_lguest_irq,
329}; 619};
330 620
621/* This sets up the Interrupt Descriptor Table (IDT) entry for each hardware
622 * interrupt (except 128, which is used for system calls), and then tells the
623 * Linux infrastructure that each interrupt is controlled by our level-based
624 * lguest interrupt controller. */
331static void __init lguest_init_IRQ(void) 625static void __init lguest_init_IRQ(void)
332{ 626{
333 unsigned int i; 627 unsigned int i;
@@ -340,20 +634,51 @@ static void __init lguest_init_IRQ(void)
340 handle_level_irq); 634 handle_level_irq);
341 } 635 }
342 } 636 }
637 /* This call is required to set up for 4k stacks, where we have
638 * separate stacks for hard and soft interrupts. */
343 irq_ctx_init(smp_processor_id()); 639 irq_ctx_init(smp_processor_id());
344} 640}
345 641
642/*
643 * Time.
644 *
645 * It would be far better for everyone if the Guest had its own clock, but
646 * until then the Host gives us the time on every interrupt.
647 */
346static unsigned long lguest_get_wallclock(void) 648static unsigned long lguest_get_wallclock(void)
347{ 649{
348 return hcall(LHCALL_GET_WALLCLOCK, 0, 0, 0); 650 return lguest_data.time.tv_sec;
349} 651}
350 652
351static cycle_t lguest_clock_read(void) 653static cycle_t lguest_clock_read(void)
352{ 654{
655 unsigned long sec, nsec;
656
657 /* If the Host tells the TSC speed, we can trust that. */
353 if (lguest_data.tsc_khz) 658 if (lguest_data.tsc_khz)
354 return native_read_tsc(); 659 return native_read_tsc();
355 else 660
356 return jiffies; 661 /* If we can't use the TSC, we read the time value written by the Host.
662 * Since it's in two parts (seconds and nanoseconds), we risk reading
663 * it just as it's changing from 99 & 0.999999999 to 100 and 0, and
664 * getting 99 and 0. As Linux tends to come apart under the stress of
665 * time travel, we must be careful: */
666 do {
667 /* First we read the seconds part. */
668 sec = lguest_data.time.tv_sec;
669 /* This read memory barrier tells the compiler and the CPU that
670 * this can't be reordered: we have to complete the above
671 * before going on. */
672 rmb();
673 /* Now we read the nanoseconds part. */
674 nsec = lguest_data.time.tv_nsec;
675 /* Make sure we've done that. */
676 rmb();
677 /* Now if the seconds part has changed, try again. */
678 } while (unlikely(lguest_data.time.tv_sec != sec));
679
680 /* Our non-TSC clock is in real nanoseconds. */
681 return sec*1000000000ULL + nsec;
357} 682}
358 683
359/* This is what we tell the kernel is our clocksource. */ 684/* This is what we tell the kernel is our clocksource. */
@@ -361,8 +686,11 @@ static struct clocksource lguest_clock = {
361 .name = "lguest", 686 .name = "lguest",
362 .rating = 400, 687 .rating = 400,
363 .read = lguest_clock_read, 688 .read = lguest_clock_read,
689 .mask = CLOCKSOURCE_MASK(64),
690 .mult = 1,
364}; 691};
365 692
693/* The "scheduler clock" is just our real clock, adjusted to start at zero */
366static unsigned long long lguest_sched_clock(void) 694static unsigned long long lguest_sched_clock(void)
367{ 695{
368 return cyc2ns(&lguest_clock, lguest_clock_read() - clock_base); 696 return cyc2ns(&lguest_clock, lguest_clock_read() - clock_base);
@@ -428,34 +756,55 @@ static void lguest_time_irq(unsigned int irq, struct irq_desc *desc)
428 local_irq_restore(flags); 756 local_irq_restore(flags);
429} 757}
430 758
759/* At some point in the boot process, we get asked to set up our timing
760 * infrastructure. The kernel doesn't expect timer interrupts before this, but
761 * we cleverly initialized the "blocked_interrupts" field of "struct
762 * lguest_data" so that timer interrupts were blocked until now. */
431static void lguest_time_init(void) 763static void lguest_time_init(void)
432{ 764{
765 /* Set up the timer interrupt (0) to go to our simple timer routine */
433 set_irq_handler(0, lguest_time_irq); 766 set_irq_handler(0, lguest_time_irq);
434 767
435 /* We use the TSC if the Host tells us we can, otherwise a dumb 768 /* Our clock structure look like arch/i386/kernel/tsc.c if we can use
436 * jiffies-based clock. */ 769 * the TSC, otherwise it's a dumb nanosecond-resolution clock. Either
770 * way, the "rating" is initialized so high that it's always chosen
771 * over any other clocksource. */
437 if (lguest_data.tsc_khz) { 772 if (lguest_data.tsc_khz) {
438 lguest_clock.shift = 22; 773 lguest_clock.shift = 22;
439 lguest_clock.mult = clocksource_khz2mult(lguest_data.tsc_khz, 774 lguest_clock.mult = clocksource_khz2mult(lguest_data.tsc_khz,
440 lguest_clock.shift); 775 lguest_clock.shift);
441 lguest_clock.mask = CLOCKSOURCE_MASK(64);
442 lguest_clock.flags = CLOCK_SOURCE_IS_CONTINUOUS; 776 lguest_clock.flags = CLOCK_SOURCE_IS_CONTINUOUS;
443 } else {
444 /* To understand this, start at kernel/time/jiffies.c... */
445 lguest_clock.shift = 8;
446 lguest_clock.mult = (((u64)NSEC_PER_SEC<<8)/ACTHZ) << 8;
447 lguest_clock.mask = CLOCKSOURCE_MASK(32);
448 } 777 }
449 clock_base = lguest_clock_read(); 778 clock_base = lguest_clock_read();
450 clocksource_register(&lguest_clock); 779 clocksource_register(&lguest_clock);
451 780
452 /* We can't set cpumask in the initializer: damn C limitations! */ 781 /* Now we've set up our clock, we can use it as the scheduler clock */
782 paravirt_ops.sched_clock = lguest_sched_clock;
783
784 /* We can't set cpumask in the initializer: damn C limitations! Set it
785 * here and register our timer device. */
453 lguest_clockevent.cpumask = cpumask_of_cpu(0); 786 lguest_clockevent.cpumask = cpumask_of_cpu(0);
454 clockevents_register_device(&lguest_clockevent); 787 clockevents_register_device(&lguest_clockevent);
455 788
789 /* Finally, we unblock the timer interrupt. */
456 enable_lguest_irq(0); 790 enable_lguest_irq(0);
457} 791}
458 792
793/*
794 * Miscellaneous bits and pieces.
795 *
796 * Here is an oddball collection of functions which the Guest needs for things
797 * to work. They're pretty simple.
798 */
799
800/* The Guest needs to tell the host what stack it expects traps to use. For
801 * native hardware, this is part of the Task State Segment mentioned above in
802 * lguest_load_tr_desc(), but to help hypervisors there's this special call.
803 *
804 * We tell the Host the segment we want to use (__KERNEL_DS is the kernel data
805 * segment), the privilege level (we're privilege level 1, the Host is 0 and
806 * will not tolerate us trying to use that), the stack pointer, and the number
807 * of pages in the stack. */
459static void lguest_load_esp0(struct tss_struct *tss, 808static void lguest_load_esp0(struct tss_struct *tss,
460 struct thread_struct *thread) 809 struct thread_struct *thread)
461{ 810{
@@ -463,15 +812,31 @@ static void lguest_load_esp0(struct tss_struct *tss,
463 THREAD_SIZE/PAGE_SIZE); 812 THREAD_SIZE/PAGE_SIZE);
464} 813}
465 814
815/* Let's just say, I wouldn't do debugging under a Guest. */
466static void lguest_set_debugreg(int regno, unsigned long value) 816static void lguest_set_debugreg(int regno, unsigned long value)
467{ 817{
468 /* FIXME: Implement */ 818 /* FIXME: Implement */
469} 819}
470 820
821/* There are times when the kernel wants to make sure that no memory writes are
822 * caught in the cache (that they've all reached real hardware devices). This
823 * doesn't matter for the Guest which has virtual hardware.
824 *
825 * On the Pentium 4 and above, cpuid() indicates that the Cache Line Flush
826 * (clflush) instruction is available and the kernel uses that. Otherwise, it
827 * uses the older "Write Back and Invalidate Cache" (wbinvd) instruction.
828 * Unlike clflush, wbinvd can only be run at privilege level 0. So we can
829 * ignore clflush, but replace wbinvd.
830 */
471static void lguest_wbinvd(void) 831static void lguest_wbinvd(void)
472{ 832{
473} 833}
474 834
835/* If the Guest expects to have an Advanced Programmable Interrupt Controller,
836 * we play dumb by ignoring writes and returning 0 for reads. So it's no
837 * longer Programmable nor Controlling anything, and I don't think 8 lines of
838 * code qualifies for Advanced. It will also never interrupt anything. It
839 * does, however, allow us to get through the Linux boot code. */
475#ifdef CONFIG_X86_LOCAL_APIC 840#ifdef CONFIG_X86_LOCAL_APIC
476static void lguest_apic_write(unsigned long reg, unsigned long v) 841static void lguest_apic_write(unsigned long reg, unsigned long v)
477{ 842{
@@ -483,19 +848,32 @@ static unsigned long lguest_apic_read(unsigned long reg)
483} 848}
484#endif 849#endif
485 850
851/* STOP! Until an interrupt comes in. */
486static void lguest_safe_halt(void) 852static void lguest_safe_halt(void)
487{ 853{
488 hcall(LHCALL_HALT, 0, 0, 0); 854 hcall(LHCALL_HALT, 0, 0, 0);
489} 855}
490 856
857/* Perhaps CRASH isn't the best name for this hypercall, but we use it to get a
858 * message out when we're crashing as well as elegant termination like powering
859 * off.
860 *
861 * Note that the Host always prefers that the Guest speak in physical addresses
862 * rather than virtual addresses, so we use __pa() here. */
491static void lguest_power_off(void) 863static void lguest_power_off(void)
492{ 864{
493 hcall(LHCALL_CRASH, __pa("Power down"), 0, 0); 865 hcall(LHCALL_CRASH, __pa("Power down"), 0, 0);
494} 866}
495 867
868/*
869 * Panicing.
870 *
871 * Don't. But if you did, this is what happens.
872 */
496static int lguest_panic(struct notifier_block *nb, unsigned long l, void *p) 873static int lguest_panic(struct notifier_block *nb, unsigned long l, void *p)
497{ 874{
498 hcall(LHCALL_CRASH, __pa(p), 0, 0); 875 hcall(LHCALL_CRASH, __pa(p), 0, 0);
876 /* The hcall won't return, but to keep gcc happy, we're "done". */
499 return NOTIFY_DONE; 877 return NOTIFY_DONE;
500} 878}
501 879
@@ -503,15 +881,45 @@ static struct notifier_block paniced = {
503 .notifier_call = lguest_panic 881 .notifier_call = lguest_panic
504}; 882};
505 883
884/* Setting up memory is fairly easy. */
506static __init char *lguest_memory_setup(void) 885static __init char *lguest_memory_setup(void)
507{ 886{
508 /* We do this here because lockcheck barfs if before start_kernel */ 887 /* We do this here and not earlier because lockcheck barfs if we do it
888 * before start_kernel() */
509 atomic_notifier_chain_register(&panic_notifier_list, &paniced); 889 atomic_notifier_chain_register(&panic_notifier_list, &paniced);
510 890
891 /* The Linux bootloader header contains an "e820" memory map: the
892 * Launcher populated the first entry with our memory limit. */
511 add_memory_region(E820_MAP->addr, E820_MAP->size, E820_MAP->type); 893 add_memory_region(E820_MAP->addr, E820_MAP->size, E820_MAP->type);
894
895 /* This string is for the boot messages. */
512 return "LGUEST"; 896 return "LGUEST";
513} 897}
514 898
899/*G:050
900 * Patching (Powerfully Placating Performance Pedants)
901 *
902 * We have already seen that "struct paravirt_ops" lets us replace simple
903 * native instructions with calls to the appropriate back end all throughout
904 * the kernel. This allows the same kernel to run as a Guest and as a native
905 * kernel, but it's slow because of all the indirect branches.
906 *
907 * Remember that David Wheeler quote about "Any problem in computer science can
908 * be solved with another layer of indirection"? The rest of that quote is
909 * "... But that usually will create another problem." This is the first of
910 * those problems.
911 *
912 * Our current solution is to allow the paravirt back end to optionally patch
913 * over the indirect calls to replace them with something more efficient. We
914 * patch the four most commonly called functions: disable interrupts, enable
915 * interrupts, restore interrupts and save interrupts. We usually have 10
916 * bytes to patch into: the Guest versions of these operations are small enough
917 * that we can fit comfortably.
918 *
919 * First we need assembly templates of each of the patchable Guest operations,
920 * and these are in lguest_asm.S. */
921
922/*G:060 We construct a table from the assembler templates: */
515static const struct lguest_insns 923static const struct lguest_insns
516{ 924{
517 const char *start, *end; 925 const char *start, *end;
@@ -521,35 +929,52 @@ static const struct lguest_insns
521 [PARAVIRT_PATCH(restore_fl)] = { lgstart_popf, lgend_popf }, 929 [PARAVIRT_PATCH(restore_fl)] = { lgstart_popf, lgend_popf },
522 [PARAVIRT_PATCH(save_fl)] = { lgstart_pushf, lgend_pushf }, 930 [PARAVIRT_PATCH(save_fl)] = { lgstart_pushf, lgend_pushf },
523}; 931};
932
933/* Now our patch routine is fairly simple (based on the native one in
934 * paravirt.c). If we have a replacement, we copy it in and return how much of
935 * the available space we used. */
524static unsigned lguest_patch(u8 type, u16 clobber, void *insns, unsigned len) 936static unsigned lguest_patch(u8 type, u16 clobber, void *insns, unsigned len)
525{ 937{
526 unsigned int insn_len; 938 unsigned int insn_len;
527 939
528 /* Don't touch it if we don't have a replacement */ 940 /* Don't do anything special if we don't have a replacement */
529 if (type >= ARRAY_SIZE(lguest_insns) || !lguest_insns[type].start) 941 if (type >= ARRAY_SIZE(lguest_insns) || !lguest_insns[type].start)
530 return paravirt_patch_default(type, clobber, insns, len); 942 return paravirt_patch_default(type, clobber, insns, len);
531 943
532 insn_len = lguest_insns[type].end - lguest_insns[type].start; 944 insn_len = lguest_insns[type].end - lguest_insns[type].start;
533 945
534 /* Similarly if we can't fit replacement. */ 946 /* Similarly if we can't fit replacement (shouldn't happen, but let's
947 * be thorough). */
535 if (len < insn_len) 948 if (len < insn_len)
536 return paravirt_patch_default(type, clobber, insns, len); 949 return paravirt_patch_default(type, clobber, insns, len);
537 950
951 /* Copy in our instructions. */
538 memcpy(insns, lguest_insns[type].start, insn_len); 952 memcpy(insns, lguest_insns[type].start, insn_len);
539 return insn_len; 953 return insn_len;
540} 954}
541 955
956/*G:030 Once we get to lguest_init(), we know we're a Guest. The paravirt_ops
957 * structure in the kernel provides a single point for (almost) every routine
958 * we have to override to avoid privileged instructions. */
542__init void lguest_init(void *boot) 959__init void lguest_init(void *boot)
543{ 960{
544 /* Copy boot parameters first. */ 961 /* Copy boot parameters first: the Launcher put the physical location
962 * in %esi, and head.S converted that to a virtual address and handed
963 * it to us. */
545 memcpy(&boot_params, boot, PARAM_SIZE); 964 memcpy(&boot_params, boot, PARAM_SIZE);
965 /* The boot parameters also tell us where the command-line is: save
966 * that, too. */
546 memcpy(boot_command_line, __va(boot_params.hdr.cmd_line_ptr), 967 memcpy(boot_command_line, __va(boot_params.hdr.cmd_line_ptr),
547 COMMAND_LINE_SIZE); 968 COMMAND_LINE_SIZE);
548 969
970 /* We're under lguest, paravirt is enabled, and we're running at
971 * privilege level 1, not 0 as normal. */
549 paravirt_ops.name = "lguest"; 972 paravirt_ops.name = "lguest";
550 paravirt_ops.paravirt_enabled = 1; 973 paravirt_ops.paravirt_enabled = 1;
551 paravirt_ops.kernel_rpl = 1; 974 paravirt_ops.kernel_rpl = 1;
552 975
976 /* We set up all the lguest overrides for sensitive operations. These
977 * are detailed with the operations themselves. */
553 paravirt_ops.save_fl = save_fl; 978 paravirt_ops.save_fl = save_fl;
554 paravirt_ops.restore_fl = restore_fl; 979 paravirt_ops.restore_fl = restore_fl;
555 paravirt_ops.irq_disable = irq_disable; 980 paravirt_ops.irq_disable = irq_disable;
@@ -592,21 +1017,50 @@ __init void lguest_init(void *boot)
592 paravirt_ops.time_init = lguest_time_init; 1017 paravirt_ops.time_init = lguest_time_init;
593 paravirt_ops.set_lazy_mode = lguest_lazy_mode; 1018 paravirt_ops.set_lazy_mode = lguest_lazy_mode;
594 paravirt_ops.wbinvd = lguest_wbinvd; 1019 paravirt_ops.wbinvd = lguest_wbinvd;
595 paravirt_ops.sched_clock = lguest_sched_clock; 1020 /* Now is a good time to look at the implementations of these functions
596 1021 * before returning to the rest of lguest_init(). */
1022
1023 /*G:070 Now we've seen all the paravirt_ops, we return to
1024 * lguest_init() where the rest of the fairly chaotic boot setup
1025 * occurs.
1026 *
1027 * The Host expects our first hypercall to tell it where our "struct
1028 * lguest_data" is, so we do that first. */
597 hcall(LHCALL_LGUEST_INIT, __pa(&lguest_data), 0, 0); 1029 hcall(LHCALL_LGUEST_INIT, __pa(&lguest_data), 0, 0);
598 1030
599 /* We use top of mem for initial pagetables. */ 1031 /* The native boot code sets up initial page tables immediately after
1032 * the kernel itself, and sets init_pg_tables_end so they're not
1033 * clobbered. The Launcher places our initial pagetables somewhere at
1034 * the top of our physical memory, so we don't need extra space: set
1035 * init_pg_tables_end to the end of the kernel. */
600 init_pg_tables_end = __pa(pg0); 1036 init_pg_tables_end = __pa(pg0);
601 1037
1038 /* Load the %fs segment register (the per-cpu segment register) with
1039 * the normal data segment to get through booting. */
602 asm volatile ("mov %0, %%fs" : : "r" (__KERNEL_DS) : "memory"); 1040 asm volatile ("mov %0, %%fs" : : "r" (__KERNEL_DS) : "memory");
603 1041
1042 /* Clear the part of the kernel data which is expected to be zero.
1043 * Normally it will be anyway, but if we're loading from a bzImage with
1044 * CONFIG_RELOCATALE=y, the relocations will be sitting here. */
1045 memset(__bss_start, 0, __bss_stop - __bss_start);
1046
1047 /* The Host uses the top of the Guest's virtual address space for the
1048 * Host<->Guest Switcher, and it tells us how much it needs in
1049 * lguest_data.reserve_mem, set up on the LGUEST_INIT hypercall. */
604 reserve_top_address(lguest_data.reserve_mem); 1050 reserve_top_address(lguest_data.reserve_mem);
605 1051
1052 /* If we don't initialize the lock dependency checker now, it crashes
1053 * paravirt_disable_iospace. */
606 lockdep_init(); 1054 lockdep_init();
607 1055
1056 /* The IDE code spends about 3 seconds probing for disks: if we reserve
1057 * all the I/O ports up front it can't get them and so doesn't probe.
1058 * Other device drivers are similar (but less severe). This cuts the
1059 * kernel boot time on my machine from 4.1 seconds to 0.45 seconds. */
608 paravirt_disable_iospace(); 1060 paravirt_disable_iospace();
609 1061
1062 /* This is messy CPU setup stuff which the native boot code does before
1063 * start_kernel, so we have to do, too: */
610 cpu_detect(&new_cpu_data); 1064 cpu_detect(&new_cpu_data);
611 /* head.S usually sets up the first capability word, so do it here. */ 1065 /* head.S usually sets up the first capability word, so do it here. */
612 new_cpu_data.x86_capability[0] = cpuid_edx(1); 1066 new_cpu_data.x86_capability[0] = cpuid_edx(1);
@@ -617,14 +1071,27 @@ __init void lguest_init(void *boot)
617#ifdef CONFIG_X86_MCE 1071#ifdef CONFIG_X86_MCE
618 mce_disabled = 1; 1072 mce_disabled = 1;
619#endif 1073#endif
620
621#ifdef CONFIG_ACPI 1074#ifdef CONFIG_ACPI
622 acpi_disabled = 1; 1075 acpi_disabled = 1;
623 acpi_ht = 0; 1076 acpi_ht = 0;
624#endif 1077#endif
625 1078
1079 /* We set the perferred console to "hvc". This is the "hypervisor
1080 * virtual console" driver written by the PowerPC people, which we also
1081 * adapted for lguest's use. */
626 add_preferred_console("hvc", 0, NULL); 1082 add_preferred_console("hvc", 0, NULL);
627 1083
1084 /* Last of all, we set the power management poweroff hook to point to
1085 * the Guest routine to power off. */
628 pm_power_off = lguest_power_off; 1086 pm_power_off = lguest_power_off;
1087
1088 /* Now we're set up, call start_kernel() in init/main.c and we proceed
1089 * to boot as normal. It never returns. */
629 start_kernel(); 1090 start_kernel();
630} 1091}
1092/*
1093 * This marks the end of stage II of our journey, The Guest.
1094 *
1095 * It is now time for us to explore the nooks and crannies of the three Guest
1096 * devices and complete our understanding of the Guest in "make Drivers".
1097 */
diff --git a/drivers/lguest/lguest_asm.S b/drivers/lguest/lguest_asm.S
index a3dbf22ee365..f182c6a36209 100644
--- a/drivers/lguest/lguest_asm.S
+++ b/drivers/lguest/lguest_asm.S
@@ -4,15 +4,15 @@
4#include <asm/thread_info.h> 4#include <asm/thread_info.h>
5#include <asm/processor-flags.h> 5#include <asm/processor-flags.h>
6 6
7/* 7/*G:020 This is where we begin: we have a magic signature which the launcher
8 * This is where we begin: we have a magic signature which the launcher looks 8 * looks for. The plan is that the Linux boot protocol will be extended with a
9 * for. The plan is that the Linux boot protocol will be extended with a
10 * "platform type" field which will guide us here from the normal entry point, 9 * "platform type" field which will guide us here from the normal entry point,
11 * but for the moment this suffices. We pass the virtual address of the boot 10 * but for the moment this suffices. The normal boot code uses %esi for the
12 * info to lguest_init(). 11 * boot header, so we do too. We convert it to a virtual address by adding
12 * PAGE_OFFSET, and hand it to lguest_init() as its argument (ie. %eax).
13 * 13 *
14 * We put it in .init.text will be discarded after boot. 14 * The .section line puts this code in .init.text so it will be discarded after
15 */ 15 * boot. */
16.section .init.text, "ax", @progbits 16.section .init.text, "ax", @progbits
17.ascii "GenuineLguest" 17.ascii "GenuineLguest"
18 /* Set up initial stack. */ 18 /* Set up initial stack. */
@@ -21,7 +21,9 @@
21 addl $__PAGE_OFFSET, %eax 21 addl $__PAGE_OFFSET, %eax
22 jmp lguest_init 22 jmp lguest_init
23 23
24/* The templates for inline patching. */ 24/*G:055 We create a macro which puts the assembler code between lgstart_ and
25 * lgend_ markers. These templates end up in the .init.text section, so they
26 * are discarded after boot. */
25#define LGUEST_PATCH(name, insns...) \ 27#define LGUEST_PATCH(name, insns...) \
26 lgstart_##name: insns; lgend_##name:; \ 28 lgstart_##name: insns; lgend_##name:; \
27 .globl lgstart_##name; .globl lgend_##name 29 .globl lgstart_##name; .globl lgend_##name
@@ -30,24 +32,61 @@ LGUEST_PATCH(cli, movl $0, lguest_data+LGUEST_DATA_irq_enabled)
30LGUEST_PATCH(sti, movl $X86_EFLAGS_IF, lguest_data+LGUEST_DATA_irq_enabled) 32LGUEST_PATCH(sti, movl $X86_EFLAGS_IF, lguest_data+LGUEST_DATA_irq_enabled)
31LGUEST_PATCH(popf, movl %eax, lguest_data+LGUEST_DATA_irq_enabled) 33LGUEST_PATCH(popf, movl %eax, lguest_data+LGUEST_DATA_irq_enabled)
32LGUEST_PATCH(pushf, movl lguest_data+LGUEST_DATA_irq_enabled, %eax) 34LGUEST_PATCH(pushf, movl lguest_data+LGUEST_DATA_irq_enabled, %eax)
35/*:*/
33 36
34.text 37.text
35/* These demark the EIP range where host should never deliver interrupts. */ 38/* These demark the EIP range where host should never deliver interrupts. */
36.global lguest_noirq_start 39.global lguest_noirq_start
37.global lguest_noirq_end 40.global lguest_noirq_end
38 41
39/* 42/*M:004 When the Host reflects a trap or injects an interrupt into the Guest,
40 * We move eflags word to lguest_data.irq_enabled to restore interrupt state. 43 * it sets the eflags interrupt bit on the stack based on
41 * For page faults, gpfs and virtual interrupts, the hypervisor has saved 44 * lguest_data.irq_enabled, so the Guest iret logic does the right thing when
42 * eflags manually, otherwise it was delivered directly and so eflags reflects 45 * restoring it. However, when the Host sets the Guest up for direct traps,
43 * the real machine IF state, ie. interrupts on. Since the kernel always dies 46 * such as system calls, the processor is the one to push eflags onto the
44 * if it takes such a trap with interrupts disabled anyway, turning interrupts 47 * stack, and the interrupt bit will be 1 (in reality, interrupts are always
45 * back on unconditionally here is OK. 48 * enabled in the Guest).
46 */ 49 *
50 * This turns out to be harmless: the only trap which should happen under Linux
51 * with interrupts disabled is Page Fault (due to our lazy mapping of vmalloc
52 * regions), which has to be reflected through the Host anyway. If another
53 * trap *does* go off when interrupts are disabled, the Guest will panic, and
54 * we'll never get to this iret! :*/
55
56/*G:045 There is one final paravirt_op that the Guest implements, and glancing
57 * at it you can see why I left it to last. It's *cool*! It's in *assembler*!
58 *
59 * The "iret" instruction is used to return from an interrupt or trap. The
60 * stack looks like this:
61 * old address
62 * old code segment & privilege level
63 * old processor flags ("eflags")
64 *
65 * The "iret" instruction pops those values off the stack and restores them all
66 * at once. The only problem is that eflags includes the Interrupt Flag which
67 * the Guest can't change: the CPU will simply ignore it when we do an "iret".
68 * So we have to copy eflags from the stack to lguest_data.irq_enabled before
69 * we do the "iret".
70 *
71 * There are two problems with this: firstly, we need to use a register to do
72 * the copy and secondly, the whole thing needs to be atomic. The first
73 * problem is easy to solve: push %eax on the stack so we can use it, and then
74 * restore it at the end just before the real "iret".
75 *
76 * The second is harder: copying eflags to lguest_data.irq_enabled will turn
77 * interrupts on before we're finished, so we could be interrupted before we
78 * return to userspace or wherever. Our solution to this is to surround the
79 * code with lguest_noirq_start: and lguest_noirq_end: labels. We tell the
80 * Host that it is *never* to interrupt us there, even if interrupts seem to be
81 * enabled. */
47ENTRY(lguest_iret) 82ENTRY(lguest_iret)
48 pushl %eax 83 pushl %eax
49 movl 12(%esp), %eax 84 movl 12(%esp), %eax
50lguest_noirq_start: 85lguest_noirq_start:
86 /* Note the %ss: segment prefix here. Normal data accesses use the
87 * "ds" segment, but that will have already been restored for whatever
88 * we're returning to (such as userspace): we can't trust it. The %ss:
89 * prefix makes sure we use the stack segment, which is still valid. */
51 movl %eax,%ss:lguest_data+LGUEST_DATA_irq_enabled 90 movl %eax,%ss:lguest_data+LGUEST_DATA_irq_enabled
52 popl %eax 91 popl %eax
53 iret 92 iret
diff --git a/drivers/lguest/lguest_bus.c b/drivers/lguest/lguest_bus.c
index 18d6ab21a43b..55a7940ca732 100644
--- a/drivers/lguest/lguest_bus.c
+++ b/drivers/lguest/lguest_bus.c
@@ -1,3 +1,6 @@
1/*P:050 Lguest guests use a very simple bus for devices. It's a simple array
2 * of device descriptors contained just above the top of normal memory. The
3 * lguest bus is 80% tedious boilerplate code. :*/
1#include <linux/init.h> 4#include <linux/init.h>
2#include <linux/bootmem.h> 5#include <linux/bootmem.h>
3#include <linux/lguest_bus.h> 6#include <linux/lguest_bus.h>
@@ -43,6 +46,10 @@ static struct device_attribute lguest_dev_attrs[] = {
43 __ATTR_NULL 46 __ATTR_NULL
44}; 47};
45 48
49/*D:130 The generic bus infrastructure requires a function which says whether a
50 * device matches a driver. For us, it is simple: "struct lguest_driver"
51 * contains a "device_type" field which indicates what type of device it can
52 * handle, so we just cast the args and compare: */
46static int lguest_dev_match(struct device *_dev, struct device_driver *_drv) 53static int lguest_dev_match(struct device *_dev, struct device_driver *_drv)
47{ 54{
48 struct lguest_device *dev = container_of(_dev,struct lguest_device,dev); 55 struct lguest_device *dev = container_of(_dev,struct lguest_device,dev);
@@ -50,6 +57,7 @@ static int lguest_dev_match(struct device *_dev, struct device_driver *_drv)
50 57
51 return (drv->device_type == lguest_devices[dev->index].type); 58 return (drv->device_type == lguest_devices[dev->index].type);
52} 59}
60/*:*/
53 61
54struct lguest_bus { 62struct lguest_bus {
55 struct bus_type bus; 63 struct bus_type bus;
@@ -68,11 +76,24 @@ static struct lguest_bus lguest_bus = {
68 } 76 }
69}; 77};
70 78
79/*D:140 This is the callback which occurs once the bus infrastructure matches
80 * up a device and driver, ie. in response to add_lguest_device() calling
81 * device_register(), or register_lguest_driver() calling driver_register().
82 *
83 * At the moment it's always the latter: the devices are added first, since
84 * scan_devices() is called from a "core_initcall", and the drivers themselves
85 * called later as a normal "initcall". But it would work the other way too.
86 *
87 * So now we have the happy couple, we add the status bit to indicate that we
88 * found a driver. If the driver truly loves the device, it will return
89 * happiness from its probe function (ok, perhaps this wasn't my greatest
90 * analogy), and we set the final "driver ok" bit so the Host sees it's all
91 * green. */
71static int lguest_dev_probe(struct device *_dev) 92static int lguest_dev_probe(struct device *_dev)
72{ 93{
73 int ret; 94 int ret;
74 struct lguest_device *dev = container_of(_dev,struct lguest_device,dev); 95 struct lguest_device*dev = container_of(_dev,struct lguest_device,dev);
75 struct lguest_driver *drv = container_of(dev->dev.driver, 96 struct lguest_driver*drv = container_of(dev->dev.driver,
76 struct lguest_driver, drv); 97 struct lguest_driver, drv);
77 98
78 lguest_devices[dev->index].status |= LGUEST_DEVICE_S_DRIVER; 99 lguest_devices[dev->index].status |= LGUEST_DEVICE_S_DRIVER;
@@ -82,6 +103,10 @@ static int lguest_dev_probe(struct device *_dev)
82 return ret; 103 return ret;
83} 104}
84 105
106/* The last part of the bus infrastructure is the function lguest drivers use
107 * to register themselves. Firstly, we do nothing if there's no lguest bus
108 * (ie. this is not a Guest), otherwise we fill in the embedded generic "struct
109 * driver" fields and call the generic driver_register(). */
85int register_lguest_driver(struct lguest_driver *drv) 110int register_lguest_driver(struct lguest_driver *drv)
86{ 111{
87 if (!lguest_devices) 112 if (!lguest_devices)
@@ -94,12 +119,36 @@ int register_lguest_driver(struct lguest_driver *drv)
94 119
95 return driver_register(&drv->drv); 120 return driver_register(&drv->drv);
96} 121}
122
123/* At the moment we build all the drivers into the kernel because they're so
124 * simple: 8144 bytes for all three of them as I type this. And as the console
125 * really needs to be built in, it's actually only 3527 bytes for the network
126 * and block drivers.
127 *
128 * If they get complex it will make sense for them to be modularized, so we
129 * need to explicitly export the symbol.
130 *
131 * I don't think non-GPL modules make sense, so it's a GPL-only export.
132 */
97EXPORT_SYMBOL_GPL(register_lguest_driver); 133EXPORT_SYMBOL_GPL(register_lguest_driver);
98 134
135/*D:120 This is the core of the lguest bus: actually adding a new device.
136 * It's a separate function because it's neater that way, and because an
137 * earlier version of the code supported hotplug and unplug. They were removed
138 * early on because they were never used.
139 *
140 * As Andrew Tridgell says, "Untested code is buggy code".
141 *
142 * It's worth reading this carefully: we start with an index into the array of
143 * "struct lguest_device_desc"s indicating the device which is new: */
99static void add_lguest_device(unsigned int index) 144static void add_lguest_device(unsigned int index)
100{ 145{
101 struct lguest_device *new; 146 struct lguest_device *new;
102 147
148 /* Each "struct lguest_device_desc" has a "status" field, which the
149 * Guest updates as the device is probed. In the worst case, the Host
150 * can look at these bits to tell what part of device setup failed,
151 * even if the console isn't available. */
103 lguest_devices[index].status |= LGUEST_DEVICE_S_ACKNOWLEDGE; 152 lguest_devices[index].status |= LGUEST_DEVICE_S_ACKNOWLEDGE;
104 new = kmalloc(sizeof(struct lguest_device), GFP_KERNEL); 153 new = kmalloc(sizeof(struct lguest_device), GFP_KERNEL);
105 if (!new) { 154 if (!new) {
@@ -108,12 +157,17 @@ static void add_lguest_device(unsigned int index)
108 return; 157 return;
109 } 158 }
110 159
160 /* The "struct lguest_device" setup is pretty straight-forward example
161 * code. */
111 new->index = index; 162 new->index = index;
112 new->private = NULL; 163 new->private = NULL;
113 memset(&new->dev, 0, sizeof(new->dev)); 164 memset(&new->dev, 0, sizeof(new->dev));
114 new->dev.parent = &lguest_bus.dev; 165 new->dev.parent = &lguest_bus.dev;
115 new->dev.bus = &lguest_bus.bus; 166 new->dev.bus = &lguest_bus.bus;
116 sprintf(new->dev.bus_id, "%u", index); 167 sprintf(new->dev.bus_id, "%u", index);
168
169 /* device_register() causes the bus infrastructure to look for a
170 * matching driver. */
117 if (device_register(&new->dev) != 0) { 171 if (device_register(&new->dev) != 0) {
118 printk(KERN_EMERG "Cannot register lguest device %u\n", index); 172 printk(KERN_EMERG "Cannot register lguest device %u\n", index);
119 lguest_devices[index].status |= LGUEST_DEVICE_S_FAILED; 173 lguest_devices[index].status |= LGUEST_DEVICE_S_FAILED;
@@ -121,6 +175,9 @@ static void add_lguest_device(unsigned int index)
121 } 175 }
122} 176}
123 177
178/*D:110 scan_devices() simply iterates through the device array. The type 0
179 * is reserved to mean "no device", and anything else means we have found a
180 * device: add it. */
124static void scan_devices(void) 181static void scan_devices(void)
125{ 182{
126 unsigned int i; 183 unsigned int i;
@@ -130,12 +187,23 @@ static void scan_devices(void)
130 add_lguest_device(i); 187 add_lguest_device(i);
131} 188}
132 189
190/*D:100 Fairly early in boot, lguest_bus_init() is called to set up the lguest
191 * bus. We check that we are a Guest by checking paravirt_ops.name: there are
192 * other ways of checking, but this seems most obvious to me.
193 *
194 * So we can access the array of "struct lguest_device_desc"s easily, we map
195 * that memory and store the pointer in the global "lguest_devices". Then we
196 * register the bus with the core. Doing two registrations seems clunky to me,
197 * but it seems to be the correct sysfs incantation.
198 *
199 * Finally we call scan_devices() which adds all the devices found in the
200 * "struct lguest_device_desc" array. */
133static int __init lguest_bus_init(void) 201static int __init lguest_bus_init(void)
134{ 202{
135 if (strcmp(paravirt_ops.name, "lguest") != 0) 203 if (strcmp(paravirt_ops.name, "lguest") != 0)
136 return 0; 204 return 0;
137 205
138 /* Devices are in page above top of "normal" mem. */ 206 /* Devices are in a single page above top of "normal" mem */
139 lguest_devices = lguest_map(max_pfn<<PAGE_SHIFT, 1); 207 lguest_devices = lguest_map(max_pfn<<PAGE_SHIFT, 1);
140 208
141 if (bus_register(&lguest_bus.bus) != 0 209 if (bus_register(&lguest_bus.bus) != 0
@@ -145,4 +213,5 @@ static int __init lguest_bus_init(void)
145 scan_devices(); 213 scan_devices();
146 return 0; 214 return 0;
147} 215}
216/* Do this after core stuff, before devices. */
148postcore_initcall(lguest_bus_init); 217postcore_initcall(lguest_bus_init);
diff --git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c
index e90d7a783daf..80d1b58c7698 100644
--- a/drivers/lguest/lguest_user.c
+++ b/drivers/lguest/lguest_user.c
@@ -1,36 +1,70 @@
1/* Userspace control of the guest, via /dev/lguest. */ 1/*P:200 This contains all the /dev/lguest code, whereby the userspace launcher
2 * controls and communicates with the Guest. For example, the first write will
3 * tell us the memory size, pagetable, entry point and kernel address offset.
4 * A read will run the Guest until a signal is pending (-EINTR), or the Guest
5 * does a DMA out to the Launcher. Writes are also used to get a DMA buffer
6 * registered by the Guest and to send the Guest an interrupt. :*/
2#include <linux/uaccess.h> 7#include <linux/uaccess.h>
3#include <linux/miscdevice.h> 8#include <linux/miscdevice.h>
4#include <linux/fs.h> 9#include <linux/fs.h>
5#include "lg.h" 10#include "lg.h"
6 11
12/*L:030 setup_regs() doesn't really belong in this file, but it gives us an
13 * early glimpse deeper into the Host so it's worth having here.
14 *
15 * Most of the Guest's registers are left alone: we used get_zeroed_page() to
16 * allocate the structure, so they will be 0. */
7static void setup_regs(struct lguest_regs *regs, unsigned long start) 17static void setup_regs(struct lguest_regs *regs, unsigned long start)
8{ 18{
9 /* Write out stack in format lguest expects, so we can switch to it. */ 19 /* There are four "segment" registers which the Guest needs to boot:
20 * The "code segment" register (cs) refers to the kernel code segment
21 * __KERNEL_CS, and the "data", "extra" and "stack" segment registers
22 * refer to the kernel data segment __KERNEL_DS.
23 *
24 * The privilege level is packed into the lower bits. The Guest runs
25 * at privilege level 1 (GUEST_PL).*/
10 regs->ds = regs->es = regs->ss = __KERNEL_DS|GUEST_PL; 26 regs->ds = regs->es = regs->ss = __KERNEL_DS|GUEST_PL;
11 regs->cs = __KERNEL_CS|GUEST_PL; 27 regs->cs = __KERNEL_CS|GUEST_PL;
12 regs->eflags = 0x202; /* Interrupts enabled. */ 28
29 /* The "eflags" register contains miscellaneous flags. Bit 1 (0x002)
30 * is supposed to always be "1". Bit 9 (0x200) controls whether
31 * interrupts are enabled. We always leave interrupts enabled while
32 * running the Guest. */
33 regs->eflags = 0x202;
34
35 /* The "Extended Instruction Pointer" register says where the Guest is
36 * running. */
13 regs->eip = start; 37 regs->eip = start;
14 /* esi points to our boot information (physical address 0) */ 38
39 /* %esi points to our boot information, at physical address 0, so don't
40 * touch it. */
15} 41}
16 42
17/* + addr */ 43/*L:310 To send DMA into the Guest, the Launcher needs to be able to ask for a
44 * DMA buffer. This is done by writing LHREQ_GETDMA and the key to
45 * /dev/lguest. */
18static long user_get_dma(struct lguest *lg, const u32 __user *input) 46static long user_get_dma(struct lguest *lg, const u32 __user *input)
19{ 47{
20 unsigned long key, udma, irq; 48 unsigned long key, udma, irq;
21 49
50 /* Fetch the key they wrote to us. */
22 if (get_user(key, input) != 0) 51 if (get_user(key, input) != 0)
23 return -EFAULT; 52 return -EFAULT;
53 /* Look for a free Guest DMA buffer bound to that key. */
24 udma = get_dma_buffer(lg, key, &irq); 54 udma = get_dma_buffer(lg, key, &irq);
25 if (!udma) 55 if (!udma)
26 return -ENOENT; 56 return -ENOENT;
27 57
28 /* We put irq number in udma->used_len. */ 58 /* We need to tell the Launcher what interrupt the Guest expects after
59 * the buffer is filled. We stash it in udma->used_len. */
29 lgwrite_u32(lg, udma + offsetof(struct lguest_dma, used_len), irq); 60 lgwrite_u32(lg, udma + offsetof(struct lguest_dma, used_len), irq);
61
62 /* The (guest-physical) address of the DMA buffer is returned from
63 * the write(). */
30 return udma; 64 return udma;
31} 65}
32 66
33/* To force the Guest to stop running and return to the Launcher, the 67/*L:315 To force the Guest to stop running and return to the Launcher, the
34 * Waker sets writes LHREQ_BREAK and the value "1" to /dev/lguest. The 68 * Waker sets writes LHREQ_BREAK and the value "1" to /dev/lguest. The
35 * Launcher then writes LHREQ_BREAK and "0" to release the Waker. */ 69 * Launcher then writes LHREQ_BREAK and "0" to release the Waker. */
36static int break_guest_out(struct lguest *lg, const u32 __user *input) 70static int break_guest_out(struct lguest *lg, const u32 __user *input)
@@ -54,7 +88,8 @@ static int break_guest_out(struct lguest *lg, const u32 __user *input)
54 } 88 }
55} 89}
56 90
57/* + irq */ 91/*L:050 Sending an interrupt is done by writing LHREQ_IRQ and an interrupt
92 * number to /dev/lguest. */
58static int user_send_irq(struct lguest *lg, const u32 __user *input) 93static int user_send_irq(struct lguest *lg, const u32 __user *input)
59{ 94{
60 u32 irq; 95 u32 irq;
@@ -63,14 +98,19 @@ static int user_send_irq(struct lguest *lg, const u32 __user *input)
63 return -EFAULT; 98 return -EFAULT;
64 if (irq >= LGUEST_IRQS) 99 if (irq >= LGUEST_IRQS)
65 return -EINVAL; 100 return -EINVAL;
101 /* Next time the Guest runs, the core code will see if it can deliver
102 * this interrupt. */
66 set_bit(irq, lg->irqs_pending); 103 set_bit(irq, lg->irqs_pending);
67 return 0; 104 return 0;
68} 105}
69 106
107/*L:040 Once our Guest is initialized, the Launcher makes it run by reading
108 * from /dev/lguest. */
70static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o) 109static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
71{ 110{
72 struct lguest *lg = file->private_data; 111 struct lguest *lg = file->private_data;
73 112
113 /* You must write LHREQ_INITIALIZE first! */
74 if (!lg) 114 if (!lg)
75 return -EINVAL; 115 return -EINVAL;
76 116
@@ -78,27 +118,52 @@ static ssize_t read(struct file *file, char __user *user, size_t size,loff_t*o)
78 if (current != lg->tsk) 118 if (current != lg->tsk)
79 return -EPERM; 119 return -EPERM;
80 120
121 /* If the guest is already dead, we indicate why */
81 if (lg->dead) { 122 if (lg->dead) {
82 size_t len; 123 size_t len;
83 124
125 /* lg->dead either contains an error code, or a string. */
84 if (IS_ERR(lg->dead)) 126 if (IS_ERR(lg->dead))
85 return PTR_ERR(lg->dead); 127 return PTR_ERR(lg->dead);
86 128
129 /* We can only return as much as the buffer they read with. */
87 len = min(size, strlen(lg->dead)+1); 130 len = min(size, strlen(lg->dead)+1);
88 if (copy_to_user(user, lg->dead, len) != 0) 131 if (copy_to_user(user, lg->dead, len) != 0)
89 return -EFAULT; 132 return -EFAULT;
90 return len; 133 return len;
91 } 134 }
92 135
136 /* If we returned from read() last time because the Guest sent DMA,
137 * clear the flag. */
93 if (lg->dma_is_pending) 138 if (lg->dma_is_pending)
94 lg->dma_is_pending = 0; 139 lg->dma_is_pending = 0;
95 140
141 /* Run the Guest until something interesting happens. */
96 return run_guest(lg, (unsigned long __user *)user); 142 return run_guest(lg, (unsigned long __user *)user);
97} 143}
98 144
99/* Take: pfnlimit, pgdir, start, pageoffset. */ 145/*L:020 The initialization write supplies 4 32-bit values (in addition to the
146 * 32-bit LHREQ_INITIALIZE value). These are:
147 *
148 * pfnlimit: The highest (Guest-physical) page number the Guest should be
149 * allowed to access. The Launcher has to live in Guest memory, so it sets
150 * this to ensure the Guest can't reach it.
151 *
152 * pgdir: The (Guest-physical) address of the top of the initial Guest
153 * pagetables (which are set up by the Launcher).
154 *
155 * start: The first instruction to execute ("eip" in x86-speak).
156 *
157 * page_offset: The PAGE_OFFSET constant in the Guest kernel. We should
158 * probably wean the code off this, but it's a very useful constant! Any
159 * address above this is within the Guest kernel, and any kernel address can
160 * quickly converted from physical to virtual by adding PAGE_OFFSET. It's
161 * 0xC0000000 (3G) by default, but it's configurable at kernel build time.
162 */
100static int initialize(struct file *file, const u32 __user *input) 163static int initialize(struct file *file, const u32 __user *input)
101{ 164{
165 /* "struct lguest" contains everything we (the Host) know about a
166 * Guest. */
102 struct lguest *lg; 167 struct lguest *lg;
103 int err, i; 168 int err, i;
104 u32 args[4]; 169 u32 args[4];
@@ -106,7 +171,7 @@ static int initialize(struct file *file, const u32 __user *input)
106 /* We grab the Big Lguest lock, which protects the global array 171 /* We grab the Big Lguest lock, which protects the global array
107 * "lguests" and multiple simultaneous initializations. */ 172 * "lguests" and multiple simultaneous initializations. */
108 mutex_lock(&lguest_lock); 173 mutex_lock(&lguest_lock);
109 174 /* You can't initialize twice! Close the device and start again... */
110 if (file->private_data) { 175 if (file->private_data) {
111 err = -EBUSY; 176 err = -EBUSY;
112 goto unlock; 177 goto unlock;
@@ -117,37 +182,70 @@ static int initialize(struct file *file, const u32 __user *input)
117 goto unlock; 182 goto unlock;
118 } 183 }
119 184
185 /* Find an unused guest. */
120 i = find_free_guest(); 186 i = find_free_guest();
121 if (i < 0) { 187 if (i < 0) {
122 err = -ENOSPC; 188 err = -ENOSPC;
123 goto unlock; 189 goto unlock;
124 } 190 }
191 /* OK, we have an index into the "lguest" array: "lg" is a convenient
192 * pointer. */
125 lg = &lguests[i]; 193 lg = &lguests[i];
194
195 /* Populate the easy fields of our "struct lguest" */
126 lg->guestid = i; 196 lg->guestid = i;
127 lg->pfn_limit = args[0]; 197 lg->pfn_limit = args[0];
128 lg->page_offset = args[3]; 198 lg->page_offset = args[3];
199
200 /* We need a complete page for the Guest registers: they are accessible
201 * to the Guest and we can only grant it access to whole pages. */
129 lg->regs_page = get_zeroed_page(GFP_KERNEL); 202 lg->regs_page = get_zeroed_page(GFP_KERNEL);
130 if (!lg->regs_page) { 203 if (!lg->regs_page) {
131 err = -ENOMEM; 204 err = -ENOMEM;
132 goto release_guest; 205 goto release_guest;
133 } 206 }
207 /* We actually put the registers at the bottom of the page. */
134 lg->regs = (void *)lg->regs_page + PAGE_SIZE - sizeof(*lg->regs); 208 lg->regs = (void *)lg->regs_page + PAGE_SIZE - sizeof(*lg->regs);
135 209
210 /* Initialize the Guest's shadow page tables, using the toplevel
211 * address the Launcher gave us. This allocates memory, so can
212 * fail. */
136 err = init_guest_pagetable(lg, args[1]); 213 err = init_guest_pagetable(lg, args[1]);
137 if (err) 214 if (err)
138 goto free_regs; 215 goto free_regs;
139 216
217 /* Now we initialize the Guest's registers, handing it the start
218 * address. */
140 setup_regs(lg->regs, args[2]); 219 setup_regs(lg->regs, args[2]);
220
221 /* There are a couple of GDT entries the Guest expects when first
222 * booting. */
141 setup_guest_gdt(lg); 223 setup_guest_gdt(lg);
224
225 /* The timer for lguest's clock needs initialization. */
142 init_clockdev(lg); 226 init_clockdev(lg);
227
228 /* We keep a pointer to the Launcher task (ie. current task) for when
229 * other Guests want to wake this one (inter-Guest I/O). */
143 lg->tsk = current; 230 lg->tsk = current;
231 /* We need to keep a pointer to the Launcher's memory map, because if
232 * the Launcher dies we need to clean it up. If we don't keep a
233 * reference, it is destroyed before close() is called. */
144 lg->mm = get_task_mm(lg->tsk); 234 lg->mm = get_task_mm(lg->tsk);
235
236 /* Initialize the queue for the waker to wait on */
145 init_waitqueue_head(&lg->break_wq); 237 init_waitqueue_head(&lg->break_wq);
238
239 /* We remember which CPU's pages this Guest used last, for optimization
240 * when the same Guest runs on the same CPU twice. */
146 lg->last_pages = NULL; 241 lg->last_pages = NULL;
242
243 /* We keep our "struct lguest" in the file's private_data. */
147 file->private_data = lg; 244 file->private_data = lg;
148 245
149 mutex_unlock(&lguest_lock); 246 mutex_unlock(&lguest_lock);
150 247
248 /* And because this is a write() call, we return the length used. */
151 return sizeof(args); 249 return sizeof(args);
152 250
153free_regs: 251free_regs:
@@ -159,9 +257,15 @@ unlock:
159 return err; 257 return err;
160} 258}
161 259
260/*L:010 The first operation the Launcher does must be a write. All writes
261 * start with a 32 bit number: for the first write this must be
262 * LHREQ_INITIALIZE to set up the Guest. After that the Launcher can use
263 * writes of other values to get DMA buffers and send interrupts. */
162static ssize_t write(struct file *file, const char __user *input, 264static ssize_t write(struct file *file, const char __user *input,
163 size_t size, loff_t *off) 265 size_t size, loff_t *off)
164{ 266{
267 /* Once the guest is initialized, we hold the "struct lguest" in the
268 * file private data. */
165 struct lguest *lg = file->private_data; 269 struct lguest *lg = file->private_data;
166 u32 req; 270 u32 req;
167 271
@@ -169,8 +273,11 @@ static ssize_t write(struct file *file, const char __user *input,
169 return -EFAULT; 273 return -EFAULT;
170 input += sizeof(req); 274 input += sizeof(req);
171 275
276 /* If you haven't initialized, you must do that first. */
172 if (req != LHREQ_INITIALIZE && !lg) 277 if (req != LHREQ_INITIALIZE && !lg)
173 return -EINVAL; 278 return -EINVAL;
279
280 /* Once the Guest is dead, all you can do is read() why it died. */
174 if (lg && lg->dead) 281 if (lg && lg->dead)
175 return -ENOENT; 282 return -ENOENT;
176 283
@@ -192,33 +299,72 @@ static ssize_t write(struct file *file, const char __user *input,
192 } 299 }
193} 300}
194 301
302/*L:060 The final piece of interface code is the close() routine. It reverses
303 * everything done in initialize(). This is usually called because the
304 * Launcher exited.
305 *
306 * Note that the close routine returns 0 or a negative error number: it can't
307 * really fail, but it can whine. I blame Sun for this wart, and K&R C for
308 * letting them do it. :*/
195static int close(struct inode *inode, struct file *file) 309static int close(struct inode *inode, struct file *file)
196{ 310{
197 struct lguest *lg = file->private_data; 311 struct lguest *lg = file->private_data;
198 312
313 /* If we never successfully initialized, there's nothing to clean up */
199 if (!lg) 314 if (!lg)
200 return 0; 315 return 0;
201 316
317 /* We need the big lock, to protect from inter-guest I/O and other
318 * Launchers initializing guests. */
202 mutex_lock(&lguest_lock); 319 mutex_lock(&lguest_lock);
203 /* Cancels the hrtimer set via LHCALL_SET_CLOCKEVENT. */ 320 /* Cancels the hrtimer set via LHCALL_SET_CLOCKEVENT. */
204 hrtimer_cancel(&lg->hrt); 321 hrtimer_cancel(&lg->hrt);
322 /* Free any DMA buffers the Guest had bound. */
205 release_all_dma(lg); 323 release_all_dma(lg);
324 /* Free up the shadow page tables for the Guest. */
206 free_guest_pagetable(lg); 325 free_guest_pagetable(lg);
326 /* Now all the memory cleanups are done, it's safe to release the
327 * Launcher's memory management structure. */
207 mmput(lg->mm); 328 mmput(lg->mm);
329 /* If lg->dead doesn't contain an error code it will be NULL or a
330 * kmalloc()ed string, either of which is ok to hand to kfree(). */
208 if (!IS_ERR(lg->dead)) 331 if (!IS_ERR(lg->dead))
209 kfree(lg->dead); 332 kfree(lg->dead);
333 /* We can free up the register page we allocated. */
210 free_page(lg->regs_page); 334 free_page(lg->regs_page);
335 /* We clear the entire structure, which also marks it as free for the
336 * next user. */
211 memset(lg, 0, sizeof(*lg)); 337 memset(lg, 0, sizeof(*lg));
338 /* Release lock and exit. */
212 mutex_unlock(&lguest_lock); 339 mutex_unlock(&lguest_lock);
340
213 return 0; 341 return 0;
214} 342}
215 343
344/*L:000
345 * Welcome to our journey through the Launcher!
346 *
347 * The Launcher is the Host userspace program which sets up, runs and services
348 * the Guest. In fact, many comments in the Drivers which refer to "the Host"
349 * doing things are inaccurate: the Launcher does all the device handling for
350 * the Guest. The Guest can't tell what's done by the the Launcher and what by
351 * the Host.
352 *
353 * Just to confuse you: to the Host kernel, the Launcher *is* the Guest and we
354 * shall see more of that later.
355 *
356 * We begin our understanding with the Host kernel interface which the Launcher
357 * uses: reading and writing a character device called /dev/lguest. All the
358 * work happens in the read(), write() and close() routines: */
216static struct file_operations lguest_fops = { 359static struct file_operations lguest_fops = {
217 .owner = THIS_MODULE, 360 .owner = THIS_MODULE,
218 .release = close, 361 .release = close,
219 .write = write, 362 .write = write,
220 .read = read, 363 .read = read,
221}; 364};
365
366/* This is a textbook example of a "misc" character device. Populate a "struct
367 * miscdevice" and register it with misc_register(). */
222static struct miscdevice lguest_dev = { 368static struct miscdevice lguest_dev = {
223 .minor = MISC_DYNAMIC_MINOR, 369 .minor = MISC_DYNAMIC_MINOR,
224 .name = "lguest", 370 .name = "lguest",
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
index 1b0ba09b1269..b7a924ace684 100644
--- a/drivers/lguest/page_tables.c
+++ b/drivers/lguest/page_tables.c
@@ -1,5 +1,11 @@
1/* Shadow page table operations. 1/*P:700 The pagetable code, on the other hand, still shows the scars of
2 * Copyright (C) Rusty Russell IBM Corporation 2006. 2 * previous encounters. It's functional, and as neat as it can be in the
3 * circumstances, but be wary, for these things are subtle and break easily.
4 * The Guest provides a virtual to physical mapping, but we can neither trust
5 * it nor use it: we verify and convert it here to point the hardware to the
6 * actual Guest pages when running the Guest. :*/
7
8/* Copyright (C) Rusty Russell IBM Corporation 2006.
3 * GPL v2 and any later version */ 9 * GPL v2 and any later version */
4#include <linux/mm.h> 10#include <linux/mm.h>
5#include <linux/types.h> 11#include <linux/types.h>
@@ -9,38 +15,96 @@
9#include <asm/tlbflush.h> 15#include <asm/tlbflush.h>
10#include "lg.h" 16#include "lg.h"
11 17
18/*M:008 We hold reference to pages, which prevents them from being swapped.
19 * It'd be nice to have a callback in the "struct mm_struct" when Linux wants
20 * to swap out. If we had this, and a shrinker callback to trim PTE pages, we
21 * could probably consider launching Guests as non-root. :*/
22
23/*H:300
24 * The Page Table Code
25 *
26 * We use two-level page tables for the Guest. If you're not entirely
27 * comfortable with virtual addresses, physical addresses and page tables then
28 * I recommend you review lguest.c's "Page Table Handling" (with diagrams!).
29 *
30 * The Guest keeps page tables, but we maintain the actual ones here: these are
31 * called "shadow" page tables. Which is a very Guest-centric name: these are
32 * the real page tables the CPU uses, although we keep them up to date to
33 * reflect the Guest's. (See what I mean about weird naming? Since when do
34 * shadows reflect anything?)
35 *
36 * Anyway, this is the most complicated part of the Host code. There are seven
37 * parts to this:
38 * (i) Setting up a page table entry for the Guest when it faults,
39 * (ii) Setting up the page table entry for the Guest stack,
40 * (iii) Setting up a page table entry when the Guest tells us it has changed,
41 * (iv) Switching page tables,
42 * (v) Flushing (thowing away) page tables,
43 * (vi) Mapping the Switcher when the Guest is about to run,
44 * (vii) Setting up the page tables initially.
45 :*/
46
47/* Pages a 4k long, and each page table entry is 4 bytes long, giving us 1024
48 * (or 2^10) entries per page. */
12#define PTES_PER_PAGE_SHIFT 10 49#define PTES_PER_PAGE_SHIFT 10
13#define PTES_PER_PAGE (1 << PTES_PER_PAGE_SHIFT) 50#define PTES_PER_PAGE (1 << PTES_PER_PAGE_SHIFT)
51
52/* 1024 entries in a page table page maps 1024 pages: 4MB. The Switcher is
53 * conveniently placed at the top 4MB, so it uses a separate, complete PTE
54 * page. */
14#define SWITCHER_PGD_INDEX (PTES_PER_PAGE - 1) 55#define SWITCHER_PGD_INDEX (PTES_PER_PAGE - 1)
15 56
57/* We actually need a separate PTE page for each CPU. Remember that after the
58 * Switcher code itself comes two pages for each CPU, and we don't want this
59 * CPU's guest to see the pages of any other CPU. */
16static DEFINE_PER_CPU(spte_t *, switcher_pte_pages); 60static DEFINE_PER_CPU(spte_t *, switcher_pte_pages);
17#define switcher_pte_page(cpu) per_cpu(switcher_pte_pages, cpu) 61#define switcher_pte_page(cpu) per_cpu(switcher_pte_pages, cpu)
18 62
63/*H:320 With our shadow and Guest types established, we need to deal with
64 * them: the page table code is curly enough to need helper functions to keep
65 * it clear and clean.
66 *
67 * The first helper takes a virtual address, and says which entry in the top
68 * level page table deals with that address. Since each top level entry deals
69 * with 4M, this effectively divides by 4M. */
19static unsigned vaddr_to_pgd_index(unsigned long vaddr) 70static unsigned vaddr_to_pgd_index(unsigned long vaddr)
20{ 71{
21 return vaddr >> (PAGE_SHIFT + PTES_PER_PAGE_SHIFT); 72 return vaddr >> (PAGE_SHIFT + PTES_PER_PAGE_SHIFT);
22} 73}
23 74
24/* These access the shadow versions (ie. the ones used by the CPU). */ 75/* There are two functions which return pointers to the shadow (aka "real")
76 * page tables.
77 *
78 * spgd_addr() takes the virtual address and returns a pointer to the top-level
79 * page directory entry for that address. Since we keep track of several page
80 * tables, the "i" argument tells us which one we're interested in (it's
81 * usually the current one). */
25static spgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) 82static spgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr)
26{ 83{
27 unsigned int index = vaddr_to_pgd_index(vaddr); 84 unsigned int index = vaddr_to_pgd_index(vaddr);
28 85
86 /* We kill any Guest trying to touch the Switcher addresses. */
29 if (index >= SWITCHER_PGD_INDEX) { 87 if (index >= SWITCHER_PGD_INDEX) {
30 kill_guest(lg, "attempt to access switcher pages"); 88 kill_guest(lg, "attempt to access switcher pages");
31 index = 0; 89 index = 0;
32 } 90 }
91 /* Return a pointer index'th pgd entry for the i'th page table. */
33 return &lg->pgdirs[i].pgdir[index]; 92 return &lg->pgdirs[i].pgdir[index];
34} 93}
35 94
95/* This routine then takes the PGD entry given above, which contains the
96 * address of the PTE page. It then returns a pointer to the PTE entry for the
97 * given address. */
36static spte_t *spte_addr(struct lguest *lg, spgd_t spgd, unsigned long vaddr) 98static spte_t *spte_addr(struct lguest *lg, spgd_t spgd, unsigned long vaddr)
37{ 99{
38 spte_t *page = __va(spgd.pfn << PAGE_SHIFT); 100 spte_t *page = __va(spgd.pfn << PAGE_SHIFT);
101 /* You should never call this if the PGD entry wasn't valid */
39 BUG_ON(!(spgd.flags & _PAGE_PRESENT)); 102 BUG_ON(!(spgd.flags & _PAGE_PRESENT));
40 return &page[(vaddr >> PAGE_SHIFT) % PTES_PER_PAGE]; 103 return &page[(vaddr >> PAGE_SHIFT) % PTES_PER_PAGE];
41} 104}
42 105
43/* These access the guest versions. */ 106/* These two functions just like the above two, except they access the Guest
107 * page tables. Hence they return a Guest address. */
44static unsigned long gpgd_addr(struct lguest *lg, unsigned long vaddr) 108static unsigned long gpgd_addr(struct lguest *lg, unsigned long vaddr)
45{ 109{
46 unsigned int index = vaddr >> (PAGE_SHIFT + PTES_PER_PAGE_SHIFT); 110 unsigned int index = vaddr >> (PAGE_SHIFT + PTES_PER_PAGE_SHIFT);
@@ -55,12 +119,24 @@ static unsigned long gpte_addr(struct lguest *lg,
55 return gpage + ((vaddr>>PAGE_SHIFT) % PTES_PER_PAGE) * sizeof(gpte_t); 119 return gpage + ((vaddr>>PAGE_SHIFT) % PTES_PER_PAGE) * sizeof(gpte_t);
56} 120}
57 121
58/* Do a virtual -> physical mapping on a user page. */ 122/*H:350 This routine takes a page number given by the Guest and converts it to
123 * an actual, physical page number. It can fail for several reasons: the
124 * virtual address might not be mapped by the Launcher, the write flag is set
125 * and the page is read-only, or the write flag was set and the page was
126 * shared so had to be copied, but we ran out of memory.
127 *
128 * This holds a reference to the page, so release_pte() is careful to
129 * put that back. */
59static unsigned long get_pfn(unsigned long virtpfn, int write) 130static unsigned long get_pfn(unsigned long virtpfn, int write)
60{ 131{
61 struct page *page; 132 struct page *page;
133 /* This value indicates failure. */
62 unsigned long ret = -1UL; 134 unsigned long ret = -1UL;
63 135
136 /* get_user_pages() is a complex interface: it gets the "struct
137 * vm_area_struct" and "struct page" assocated with a range of pages.
138 * It also needs the task's mmap_sem held, and is not very quick.
139 * It returns the number of pages it got. */
64 down_read(&current->mm->mmap_sem); 140 down_read(&current->mm->mmap_sem);
65 if (get_user_pages(current, current->mm, virtpfn << PAGE_SHIFT, 141 if (get_user_pages(current, current->mm, virtpfn << PAGE_SHIFT,
66 1, write, 1, &page, NULL) == 1) 142 1, write, 1, &page, NULL) == 1)
@@ -69,28 +145,47 @@ static unsigned long get_pfn(unsigned long virtpfn, int write)
69 return ret; 145 return ret;
70} 146}
71 147
148/*H:340 Converting a Guest page table entry to a shadow (ie. real) page table
149 * entry can be a little tricky. The flags are (almost) the same, but the
150 * Guest PTE contains a virtual page number: the CPU needs the real page
151 * number. */
72static spte_t gpte_to_spte(struct lguest *lg, gpte_t gpte, int write) 152static spte_t gpte_to_spte(struct lguest *lg, gpte_t gpte, int write)
73{ 153{
74 spte_t spte; 154 spte_t spte;
75 unsigned long pfn; 155 unsigned long pfn;
76 156
77 /* We ignore the global flag. */ 157 /* The Guest sets the global flag, because it thinks that it is using
158 * PGE. We only told it to use PGE so it would tell us whether it was
159 * flushing a kernel mapping or a userspace mapping. We don't actually
160 * use the global bit, so throw it away. */
78 spte.flags = (gpte.flags & ~_PAGE_GLOBAL); 161 spte.flags = (gpte.flags & ~_PAGE_GLOBAL);
162
163 /* We need a temporary "unsigned long" variable to hold the answer from
164 * get_pfn(), because it returns 0xFFFFFFFF on failure, which wouldn't
165 * fit in spte.pfn. get_pfn() finds the real physical number of the
166 * page, given the virtual number. */
79 pfn = get_pfn(gpte.pfn, write); 167 pfn = get_pfn(gpte.pfn, write);
80 if (pfn == -1UL) { 168 if (pfn == -1UL) {
81 kill_guest(lg, "failed to get page %u", gpte.pfn); 169 kill_guest(lg, "failed to get page %u", gpte.pfn);
82 /* Must not put_page() bogus page on cleanup. */ 170 /* When we destroy the Guest, we'll go through the shadow page
171 * tables and release_pte() them. Make sure we don't think
172 * this one is valid! */
83 spte.flags = 0; 173 spte.flags = 0;
84 } 174 }
175 /* Now we assign the page number, and our shadow PTE is complete. */
85 spte.pfn = pfn; 176 spte.pfn = pfn;
86 return spte; 177 return spte;
87} 178}
88 179
180/*H:460 And to complete the chain, release_pte() looks like this: */
89static void release_pte(spte_t pte) 181static void release_pte(spte_t pte)
90{ 182{
183 /* Remember that get_user_pages() took a reference to the page, in
184 * get_pfn()? We have to put it back now. */
91 if (pte.flags & _PAGE_PRESENT) 185 if (pte.flags & _PAGE_PRESENT)
92 put_page(pfn_to_page(pte.pfn)); 186 put_page(pfn_to_page(pte.pfn));
93} 187}
188/*:*/
94 189
95static void check_gpte(struct lguest *lg, gpte_t gpte) 190static void check_gpte(struct lguest *lg, gpte_t gpte)
96{ 191{
@@ -104,11 +199,16 @@ static void check_gpgd(struct lguest *lg, gpgd_t gpgd)
104 kill_guest(lg, "bad page directory entry"); 199 kill_guest(lg, "bad page directory entry");
105} 200}
106 201
107/* FIXME: We hold reference to pages, which prevents them from being 202/*H:330
108 swapped. It'd be nice to have a callback when Linux wants to swap out. */ 203 * (i) Setting up a page table entry for the Guest when it faults
109 204 *
110/* We fault pages in, which allows us to update accessed/dirty bits. 205 * We saw this call in run_guest(): when we see a page fault in the Guest, we
111 * Return true if we got page. */ 206 * come here. That's because we only set up the shadow page tables lazily as
207 * they're needed, so we get page faults all the time and quietly fix them up
208 * and return to the Guest without it knowing.
209 *
210 * If we fixed up the fault (ie. we mapped the address), this routine returns
211 * true. */
112int demand_page(struct lguest *lg, unsigned long vaddr, int errcode) 212int demand_page(struct lguest *lg, unsigned long vaddr, int errcode)
113{ 213{
114 gpgd_t gpgd; 214 gpgd_t gpgd;
@@ -117,106 +217,161 @@ int demand_page(struct lguest *lg, unsigned long vaddr, int errcode)
117 gpte_t gpte; 217 gpte_t gpte;
118 spte_t *spte; 218 spte_t *spte;
119 219
220 /* First step: get the top-level Guest page table entry. */
120 gpgd = mkgpgd(lgread_u32(lg, gpgd_addr(lg, vaddr))); 221 gpgd = mkgpgd(lgread_u32(lg, gpgd_addr(lg, vaddr)));
222 /* Toplevel not present? We can't map it in. */
121 if (!(gpgd.flags & _PAGE_PRESENT)) 223 if (!(gpgd.flags & _PAGE_PRESENT))
122 return 0; 224 return 0;
123 225
226 /* Now look at the matching shadow entry. */
124 spgd = spgd_addr(lg, lg->pgdidx, vaddr); 227 spgd = spgd_addr(lg, lg->pgdidx, vaddr);
125 if (!(spgd->flags & _PAGE_PRESENT)) { 228 if (!(spgd->flags & _PAGE_PRESENT)) {
126 /* Get a page of PTEs for them. */ 229 /* No shadow entry: allocate a new shadow PTE page. */
127 unsigned long ptepage = get_zeroed_page(GFP_KERNEL); 230 unsigned long ptepage = get_zeroed_page(GFP_KERNEL);
128 /* FIXME: Steal from self in this case? */ 231 /* This is not really the Guest's fault, but killing it is
232 * simple for this corner case. */
129 if (!ptepage) { 233 if (!ptepage) {
130 kill_guest(lg, "out of memory allocating pte page"); 234 kill_guest(lg, "out of memory allocating pte page");
131 return 0; 235 return 0;
132 } 236 }
237 /* We check that the Guest pgd is OK. */
133 check_gpgd(lg, gpgd); 238 check_gpgd(lg, gpgd);
239 /* And we copy the flags to the shadow PGD entry. The page
240 * number in the shadow PGD is the page we just allocated. */
134 spgd->raw.val = (__pa(ptepage) | gpgd.flags); 241 spgd->raw.val = (__pa(ptepage) | gpgd.flags);
135 } 242 }
136 243
244 /* OK, now we look at the lower level in the Guest page table: keep its
245 * address, because we might update it later. */
137 gpte_ptr = gpte_addr(lg, gpgd, vaddr); 246 gpte_ptr = gpte_addr(lg, gpgd, vaddr);
138 gpte = mkgpte(lgread_u32(lg, gpte_ptr)); 247 gpte = mkgpte(lgread_u32(lg, gpte_ptr));
139 248
140 /* No page? */ 249 /* If this page isn't in the Guest page tables, we can't page it in. */
141 if (!(gpte.flags & _PAGE_PRESENT)) 250 if (!(gpte.flags & _PAGE_PRESENT))
142 return 0; 251 return 0;
143 252
144 /* Write to read-only page? */ 253 /* Check they're not trying to write to a page the Guest wants
254 * read-only (bit 2 of errcode == write). */
145 if ((errcode & 2) && !(gpte.flags & _PAGE_RW)) 255 if ((errcode & 2) && !(gpte.flags & _PAGE_RW))
146 return 0; 256 return 0;
147 257
148 /* User access to a non-user page? */ 258 /* User access to a kernel page? (bit 3 == user access) */
149 if ((errcode & 4) && !(gpte.flags & _PAGE_USER)) 259 if ((errcode & 4) && !(gpte.flags & _PAGE_USER))
150 return 0; 260 return 0;
151 261
262 /* Check that the Guest PTE flags are OK, and the page number is below
263 * the pfn_limit (ie. not mapping the Launcher binary). */
152 check_gpte(lg, gpte); 264 check_gpte(lg, gpte);
265 /* Add the _PAGE_ACCESSED and (for a write) _PAGE_DIRTY flag */
153 gpte.flags |= _PAGE_ACCESSED; 266 gpte.flags |= _PAGE_ACCESSED;
154 if (errcode & 2) 267 if (errcode & 2)
155 gpte.flags |= _PAGE_DIRTY; 268 gpte.flags |= _PAGE_DIRTY;
156 269
157 /* We're done with the old pte. */ 270 /* Get the pointer to the shadow PTE entry we're going to set. */
158 spte = spte_addr(lg, *spgd, vaddr); 271 spte = spte_addr(lg, *spgd, vaddr);
272 /* If there was a valid shadow PTE entry here before, we release it.
273 * This can happen with a write to a previously read-only entry. */
159 release_pte(*spte); 274 release_pte(*spte);
160 275
161 /* We don't make it writable if this isn't a write: later 276 /* If this is a write, we insist that the Guest page is writable (the
162 * write will fault so we can set dirty bit in guest. */ 277 * final arg to gpte_to_spte()). */
163 if (gpte.flags & _PAGE_DIRTY) 278 if (gpte.flags & _PAGE_DIRTY)
164 *spte = gpte_to_spte(lg, gpte, 1); 279 *spte = gpte_to_spte(lg, gpte, 1);
165 else { 280 else {
281 /* If this is a read, don't set the "writable" bit in the page
282 * table entry, even if the Guest says it's writable. That way
283 * we come back here when a write does actually ocur, so we can
284 * update the Guest's _PAGE_DIRTY flag. */
166 gpte_t ro_gpte = gpte; 285 gpte_t ro_gpte = gpte;
167 ro_gpte.flags &= ~_PAGE_RW; 286 ro_gpte.flags &= ~_PAGE_RW;
168 *spte = gpte_to_spte(lg, ro_gpte, 0); 287 *spte = gpte_to_spte(lg, ro_gpte, 0);
169 } 288 }
170 289
171 /* Now we update dirty/accessed on guest. */ 290 /* Finally, we write the Guest PTE entry back: we've set the
291 * _PAGE_ACCESSED and maybe the _PAGE_DIRTY flags. */
172 lgwrite_u32(lg, gpte_ptr, gpte.raw.val); 292 lgwrite_u32(lg, gpte_ptr, gpte.raw.val);
293
294 /* We succeeded in mapping the page! */
173 return 1; 295 return 1;
174} 296}
175 297
176/* This is much faster than the full demand_page logic. */ 298/*H:360 (ii) Setting up the page table entry for the Guest stack.
299 *
300 * Remember pin_stack_pages() which makes sure the stack is mapped? It could
301 * simply call demand_page(), but as we've seen that logic is quite long, and
302 * usually the stack pages are already mapped anyway, so it's not required.
303 *
304 * This is a quick version which answers the question: is this virtual address
305 * mapped by the shadow page tables, and is it writable? */
177static int page_writable(struct lguest *lg, unsigned long vaddr) 306static int page_writable(struct lguest *lg, unsigned long vaddr)
178{ 307{
179 spgd_t *spgd; 308 spgd_t *spgd;
180 unsigned long flags; 309 unsigned long flags;
181 310
311 /* Look at the top level entry: is it present? */
182 spgd = spgd_addr(lg, lg->pgdidx, vaddr); 312 spgd = spgd_addr(lg, lg->pgdidx, vaddr);
183 if (!(spgd->flags & _PAGE_PRESENT)) 313 if (!(spgd->flags & _PAGE_PRESENT))
184 return 0; 314 return 0;
185 315
316 /* Check the flags on the pte entry itself: it must be present and
317 * writable. */
186 flags = spte_addr(lg, *spgd, vaddr)->flags; 318 flags = spte_addr(lg, *spgd, vaddr)->flags;
187 return (flags & (_PAGE_PRESENT|_PAGE_RW)) == (_PAGE_PRESENT|_PAGE_RW); 319 return (flags & (_PAGE_PRESENT|_PAGE_RW)) == (_PAGE_PRESENT|_PAGE_RW);
188} 320}
189 321
322/* So, when pin_stack_pages() asks us to pin a page, we check if it's already
323 * in the page tables, and if not, we call demand_page() with error code 2
324 * (meaning "write"). */
190void pin_page(struct lguest *lg, unsigned long vaddr) 325void pin_page(struct lguest *lg, unsigned long vaddr)
191{ 326{
192 if (!page_writable(lg, vaddr) && !demand_page(lg, vaddr, 2)) 327 if (!page_writable(lg, vaddr) && !demand_page(lg, vaddr, 2))
193 kill_guest(lg, "bad stack page %#lx", vaddr); 328 kill_guest(lg, "bad stack page %#lx", vaddr);
194} 329}
195 330
331/*H:450 If we chase down the release_pgd() code, it looks like this: */
196static void release_pgd(struct lguest *lg, spgd_t *spgd) 332static void release_pgd(struct lguest *lg, spgd_t *spgd)
197{ 333{
334 /* If the entry's not present, there's nothing to release. */
198 if (spgd->flags & _PAGE_PRESENT) { 335 if (spgd->flags & _PAGE_PRESENT) {
199 unsigned int i; 336 unsigned int i;
337 /* Converting the pfn to find the actual PTE page is easy: turn
338 * the page number into a physical address, then convert to a
339 * virtual address (easy for kernel pages like this one). */
200 spte_t *ptepage = __va(spgd->pfn << PAGE_SHIFT); 340 spte_t *ptepage = __va(spgd->pfn << PAGE_SHIFT);
341 /* For each entry in the page, we might need to release it. */
201 for (i = 0; i < PTES_PER_PAGE; i++) 342 for (i = 0; i < PTES_PER_PAGE; i++)
202 release_pte(ptepage[i]); 343 release_pte(ptepage[i]);
344 /* Now we can free the page of PTEs */
203 free_page((long)ptepage); 345 free_page((long)ptepage);
346 /* And zero out the PGD entry we we never release it twice. */
204 spgd->raw.val = 0; 347 spgd->raw.val = 0;
205 } 348 }
206} 349}
207 350
351/*H:440 (v) Flushing (thowing away) page tables,
352 *
353 * We saw flush_user_mappings() called when we re-used a top-level pgdir page.
354 * It simply releases every PTE page from 0 up to the kernel address. */
208static void flush_user_mappings(struct lguest *lg, int idx) 355static void flush_user_mappings(struct lguest *lg, int idx)
209{ 356{
210 unsigned int i; 357 unsigned int i;
358 /* Release every pgd entry up to the kernel's address. */
211 for (i = 0; i < vaddr_to_pgd_index(lg->page_offset); i++) 359 for (i = 0; i < vaddr_to_pgd_index(lg->page_offset); i++)
212 release_pgd(lg, lg->pgdirs[idx].pgdir + i); 360 release_pgd(lg, lg->pgdirs[idx].pgdir + i);
213} 361}
214 362
363/* The Guest also has a hypercall to do this manually: it's used when a large
364 * number of mappings have been changed. */
215void guest_pagetable_flush_user(struct lguest *lg) 365void guest_pagetable_flush_user(struct lguest *lg)
216{ 366{
367 /* Drop the userspace part of the current page table. */
217 flush_user_mappings(lg, lg->pgdidx); 368 flush_user_mappings(lg, lg->pgdidx);
218} 369}
370/*:*/
219 371
372/* We keep several page tables. This is a simple routine to find the page
373 * table (if any) corresponding to this top-level address the Guest has given
374 * us. */
220static unsigned int find_pgdir(struct lguest *lg, unsigned long pgtable) 375static unsigned int find_pgdir(struct lguest *lg, unsigned long pgtable)
221{ 376{
222 unsigned int i; 377 unsigned int i;
@@ -226,21 +381,30 @@ static unsigned int find_pgdir(struct lguest *lg, unsigned long pgtable)
226 return i; 381 return i;
227} 382}
228 383
384/*H:435 And this is us, creating the new page directory. If we really do
385 * allocate a new one (and so the kernel parts are not there), we set
386 * blank_pgdir. */
229static unsigned int new_pgdir(struct lguest *lg, 387static unsigned int new_pgdir(struct lguest *lg,
230 unsigned long cr3, 388 unsigned long cr3,
231 int *blank_pgdir) 389 int *blank_pgdir)
232{ 390{
233 unsigned int next; 391 unsigned int next;
234 392
393 /* We pick one entry at random to throw out. Choosing the Least
394 * Recently Used might be better, but this is easy. */
235 next = random32() % ARRAY_SIZE(lg->pgdirs); 395 next = random32() % ARRAY_SIZE(lg->pgdirs);
396 /* If it's never been allocated at all before, try now. */
236 if (!lg->pgdirs[next].pgdir) { 397 if (!lg->pgdirs[next].pgdir) {
237 lg->pgdirs[next].pgdir = (spgd_t *)get_zeroed_page(GFP_KERNEL); 398 lg->pgdirs[next].pgdir = (spgd_t *)get_zeroed_page(GFP_KERNEL);
399 /* If the allocation fails, just keep using the one we have */
238 if (!lg->pgdirs[next].pgdir) 400 if (!lg->pgdirs[next].pgdir)
239 next = lg->pgdidx; 401 next = lg->pgdidx;
240 else 402 else
241 /* There are no mappings: you'll need to re-pin */ 403 /* This is a blank page, so there are no kernel
404 * mappings: caller must map the stack! */
242 *blank_pgdir = 1; 405 *blank_pgdir = 1;
243 } 406 }
407 /* Record which Guest toplevel this shadows. */
244 lg->pgdirs[next].cr3 = cr3; 408 lg->pgdirs[next].cr3 = cr3;
245 /* Release all the non-kernel mappings. */ 409 /* Release all the non-kernel mappings. */
246 flush_user_mappings(lg, next); 410 flush_user_mappings(lg, next);
@@ -248,82 +412,161 @@ static unsigned int new_pgdir(struct lguest *lg,
248 return next; 412 return next;
249} 413}
250 414
415/*H:430 (iv) Switching page tables
416 *
417 * This is what happens when the Guest changes page tables (ie. changes the
418 * top-level pgdir). This happens on almost every context switch. */
251void guest_new_pagetable(struct lguest *lg, unsigned long pgtable) 419void guest_new_pagetable(struct lguest *lg, unsigned long pgtable)
252{ 420{
253 int newpgdir, repin = 0; 421 int newpgdir, repin = 0;
254 422
423 /* Look to see if we have this one already. */
255 newpgdir = find_pgdir(lg, pgtable); 424 newpgdir = find_pgdir(lg, pgtable);
425 /* If not, we allocate or mug an existing one: if it's a fresh one,
426 * repin gets set to 1. */
256 if (newpgdir == ARRAY_SIZE(lg->pgdirs)) 427 if (newpgdir == ARRAY_SIZE(lg->pgdirs))
257 newpgdir = new_pgdir(lg, pgtable, &repin); 428 newpgdir = new_pgdir(lg, pgtable, &repin);
429 /* Change the current pgd index to the new one. */
258 lg->pgdidx = newpgdir; 430 lg->pgdidx = newpgdir;
431 /* If it was completely blank, we map in the Guest kernel stack */
259 if (repin) 432 if (repin)
260 pin_stack_pages(lg); 433 pin_stack_pages(lg);
261} 434}
262 435
436/*H:470 Finally, a routine which throws away everything: all PGD entries in all
437 * the shadow page tables. This is used when we destroy the Guest. */
263static void release_all_pagetables(struct lguest *lg) 438static void release_all_pagetables(struct lguest *lg)
264{ 439{
265 unsigned int i, j; 440 unsigned int i, j;
266 441
442 /* Every shadow pagetable this Guest has */
267 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++) 443 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++)
268 if (lg->pgdirs[i].pgdir) 444 if (lg->pgdirs[i].pgdir)
445 /* Every PGD entry except the Switcher at the top */
269 for (j = 0; j < SWITCHER_PGD_INDEX; j++) 446 for (j = 0; j < SWITCHER_PGD_INDEX; j++)
270 release_pgd(lg, lg->pgdirs[i].pgdir + j); 447 release_pgd(lg, lg->pgdirs[i].pgdir + j);
271} 448}
272 449
450/* We also throw away everything when a Guest tells us it's changed a kernel
451 * mapping. Since kernel mappings are in every page table, it's easiest to
452 * throw them all away. This is amazingly slow, but thankfully rare. */
273void guest_pagetable_clear_all(struct lguest *lg) 453void guest_pagetable_clear_all(struct lguest *lg)
274{ 454{
275 release_all_pagetables(lg); 455 release_all_pagetables(lg);
456 /* We need the Guest kernel stack mapped again. */
276 pin_stack_pages(lg); 457 pin_stack_pages(lg);
277} 458}
278 459
460/*H:420 This is the routine which actually sets the page table entry for then
461 * "idx"'th shadow page table.
462 *
463 * Normally, we can just throw out the old entry and replace it with 0: if they
464 * use it demand_page() will put the new entry in. We need to do this anyway:
465 * The Guest expects _PAGE_ACCESSED to be set on its PTE the first time a page
466 * is read from, and _PAGE_DIRTY when it's written to.
467 *
468 * But Avi Kivity pointed out that most Operating Systems (Linux included) set
469 * these bits on PTEs immediately anyway. This is done to save the CPU from
470 * having to update them, but it helps us the same way: if they set
471 * _PAGE_ACCESSED then we can put a read-only PTE entry in immediately, and if
472 * they set _PAGE_DIRTY then we can put a writable PTE entry in immediately.
473 */
279static void do_set_pte(struct lguest *lg, int idx, 474static void do_set_pte(struct lguest *lg, int idx,
280 unsigned long vaddr, gpte_t gpte) 475 unsigned long vaddr, gpte_t gpte)
281{ 476{
477 /* Look up the matching shadow page directot entry. */
282 spgd_t *spgd = spgd_addr(lg, idx, vaddr); 478 spgd_t *spgd = spgd_addr(lg, idx, vaddr);
479
480 /* If the top level isn't present, there's no entry to update. */
283 if (spgd->flags & _PAGE_PRESENT) { 481 if (spgd->flags & _PAGE_PRESENT) {
482 /* Otherwise, we start by releasing the existing entry. */
284 spte_t *spte = spte_addr(lg, *spgd, vaddr); 483 spte_t *spte = spte_addr(lg, *spgd, vaddr);
285 release_pte(*spte); 484 release_pte(*spte);
485
486 /* If they're setting this entry as dirty or accessed, we might
487 * as well put that entry they've given us in now. This shaves
488 * 10% off a copy-on-write micro-benchmark. */
286 if (gpte.flags & (_PAGE_DIRTY | _PAGE_ACCESSED)) { 489 if (gpte.flags & (_PAGE_DIRTY | _PAGE_ACCESSED)) {
287 check_gpte(lg, gpte); 490 check_gpte(lg, gpte);
288 *spte = gpte_to_spte(lg, gpte, gpte.flags&_PAGE_DIRTY); 491 *spte = gpte_to_spte(lg, gpte, gpte.flags&_PAGE_DIRTY);
289 } else 492 } else
493 /* Otherwise we can demand_page() it in later. */
290 spte->raw.val = 0; 494 spte->raw.val = 0;
291 } 495 }
292} 496}
293 497
498/*H:410 Updating a PTE entry is a little trickier.
499 *
500 * We keep track of several different page tables (the Guest uses one for each
501 * process, so it makes sense to cache at least a few). Each of these have
502 * identical kernel parts: ie. every mapping above PAGE_OFFSET is the same for
503 * all processes. So when the page table above that address changes, we update
504 * all the page tables, not just the current one. This is rare.
505 *
506 * The benefit is that when we have to track a new page table, we can copy keep
507 * all the kernel mappings. This speeds up context switch immensely. */
294void guest_set_pte(struct lguest *lg, 508void guest_set_pte(struct lguest *lg,
295 unsigned long cr3, unsigned long vaddr, gpte_t gpte) 509 unsigned long cr3, unsigned long vaddr, gpte_t gpte)
296{ 510{
297 /* Kernel mappings must be changed on all top levels. */ 511 /* Kernel mappings must be changed on all top levels. Slow, but
512 * doesn't happen often. */
298 if (vaddr >= lg->page_offset) { 513 if (vaddr >= lg->page_offset) {
299 unsigned int i; 514 unsigned int i;
300 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++) 515 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++)
301 if (lg->pgdirs[i].pgdir) 516 if (lg->pgdirs[i].pgdir)
302 do_set_pte(lg, i, vaddr, gpte); 517 do_set_pte(lg, i, vaddr, gpte);
303 } else { 518 } else {
519 /* Is this page table one we have a shadow for? */
304 int pgdir = find_pgdir(lg, cr3); 520 int pgdir = find_pgdir(lg, cr3);
305 if (pgdir != ARRAY_SIZE(lg->pgdirs)) 521 if (pgdir != ARRAY_SIZE(lg->pgdirs))
522 /* If so, do the update. */
306 do_set_pte(lg, pgdir, vaddr, gpte); 523 do_set_pte(lg, pgdir, vaddr, gpte);
307 } 524 }
308} 525}
309 526
527/*H:400
528 * (iii) Setting up a page table entry when the Guest tells us it has changed.
529 *
530 * Just like we did in interrupts_and_traps.c, it makes sense for us to deal
531 * with the other side of page tables while we're here: what happens when the
532 * Guest asks for a page table to be updated?
533 *
534 * We already saw that demand_page() will fill in the shadow page tables when
535 * needed, so we can simply remove shadow page table entries whenever the Guest
536 * tells us they've changed. When the Guest tries to use the new entry it will
537 * fault and demand_page() will fix it up.
538 *
539 * So with that in mind here's our code to to update a (top-level) PGD entry:
540 */
310void guest_set_pmd(struct lguest *lg, unsigned long cr3, u32 idx) 541void guest_set_pmd(struct lguest *lg, unsigned long cr3, u32 idx)
311{ 542{
312 int pgdir; 543 int pgdir;
313 544
545 /* The kernel seems to try to initialize this early on: we ignore its
546 * attempts to map over the Switcher. */
314 if (idx >= SWITCHER_PGD_INDEX) 547 if (idx >= SWITCHER_PGD_INDEX)
315 return; 548 return;
316 549
550 /* If they're talking about a page table we have a shadow for... */
317 pgdir = find_pgdir(lg, cr3); 551 pgdir = find_pgdir(lg, cr3);
318 if (pgdir < ARRAY_SIZE(lg->pgdirs)) 552 if (pgdir < ARRAY_SIZE(lg->pgdirs))
553 /* ... throw it away. */
319 release_pgd(lg, lg->pgdirs[pgdir].pgdir + idx); 554 release_pgd(lg, lg->pgdirs[pgdir].pgdir + idx);
320} 555}
321 556
557/*H:500 (vii) Setting up the page tables initially.
558 *
559 * When a Guest is first created, the Launcher tells us where the toplevel of
560 * its first page table is. We set some things up here: */
322int init_guest_pagetable(struct lguest *lg, unsigned long pgtable) 561int init_guest_pagetable(struct lguest *lg, unsigned long pgtable)
323{ 562{
324 /* We assume this in flush_user_mappings, so check now */ 563 /* In flush_user_mappings() we loop from 0 to
564 * "vaddr_to_pgd_index(lg->page_offset)". This assumes it won't hit
565 * the Switcher mappings, so check that now. */
325 if (vaddr_to_pgd_index(lg->page_offset) >= SWITCHER_PGD_INDEX) 566 if (vaddr_to_pgd_index(lg->page_offset) >= SWITCHER_PGD_INDEX)
326 return -EINVAL; 567 return -EINVAL;
568 /* We start on the first shadow page table, and give it a blank PGD
569 * page. */
327 lg->pgdidx = 0; 570 lg->pgdidx = 0;
328 lg->pgdirs[lg->pgdidx].cr3 = pgtable; 571 lg->pgdirs[lg->pgdidx].cr3 = pgtable;
329 lg->pgdirs[lg->pgdidx].pgdir = (spgd_t*)get_zeroed_page(GFP_KERNEL); 572 lg->pgdirs[lg->pgdidx].pgdir = (spgd_t*)get_zeroed_page(GFP_KERNEL);
@@ -332,33 +575,48 @@ int init_guest_pagetable(struct lguest *lg, unsigned long pgtable)
332 return 0; 575 return 0;
333} 576}
334 577
578/* When a Guest dies, our cleanup is fairly simple. */
335void free_guest_pagetable(struct lguest *lg) 579void free_guest_pagetable(struct lguest *lg)
336{ 580{
337 unsigned int i; 581 unsigned int i;
338 582
583 /* Throw away all page table pages. */
339 release_all_pagetables(lg); 584 release_all_pagetables(lg);
585 /* Now free the top levels: free_page() can handle 0 just fine. */
340 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++) 586 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++)
341 free_page((long)lg->pgdirs[i].pgdir); 587 free_page((long)lg->pgdirs[i].pgdir);
342} 588}
343 589
344/* Caller must be preempt-safe */ 590/*H:480 (vi) Mapping the Switcher when the Guest is about to run.
591 *
592 * The Switcher and the two pages for this CPU need to be available to the
593 * Guest (and not the pages for other CPUs). We have the appropriate PTE pages
594 * for each CPU already set up, we just need to hook them in. */
345void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages) 595void map_switcher_in_guest(struct lguest *lg, struct lguest_pages *pages)
346{ 596{
347 spte_t *switcher_pte_page = __get_cpu_var(switcher_pte_pages); 597 spte_t *switcher_pte_page = __get_cpu_var(switcher_pte_pages);
348 spgd_t switcher_pgd; 598 spgd_t switcher_pgd;
349 spte_t regs_pte; 599 spte_t regs_pte;
350 600
351 /* Since switcher less that 4MB, we simply mug top pte page. */ 601 /* Make the last PGD entry for this Guest point to the Switcher's PTE
602 * page for this CPU (with appropriate flags). */
352 switcher_pgd.pfn = __pa(switcher_pte_page) >> PAGE_SHIFT; 603 switcher_pgd.pfn = __pa(switcher_pte_page) >> PAGE_SHIFT;
353 switcher_pgd.flags = _PAGE_KERNEL; 604 switcher_pgd.flags = _PAGE_KERNEL;
354 lg->pgdirs[lg->pgdidx].pgdir[SWITCHER_PGD_INDEX] = switcher_pgd; 605 lg->pgdirs[lg->pgdidx].pgdir[SWITCHER_PGD_INDEX] = switcher_pgd;
355 606
356 /* Map our regs page over stack page. */ 607 /* We also change the Switcher PTE page. When we're running the Guest,
608 * we want the Guest's "regs" page to appear where the first Switcher
609 * page for this CPU is. This is an optimization: when the Switcher
610 * saves the Guest registers, it saves them into the first page of this
611 * CPU's "struct lguest_pages": if we make sure the Guest's register
612 * page is already mapped there, we don't have to copy them out
613 * again. */
357 regs_pte.pfn = __pa(lg->regs_page) >> PAGE_SHIFT; 614 regs_pte.pfn = __pa(lg->regs_page) >> PAGE_SHIFT;
358 regs_pte.flags = _PAGE_KERNEL; 615 regs_pte.flags = _PAGE_KERNEL;
359 switcher_pte_page[(unsigned long)pages/PAGE_SIZE%PTES_PER_PAGE] 616 switcher_pte_page[(unsigned long)pages/PAGE_SIZE%PTES_PER_PAGE]
360 = regs_pte; 617 = regs_pte;
361} 618}
619/*:*/
362 620
363static void free_switcher_pte_pages(void) 621static void free_switcher_pte_pages(void)
364{ 622{
@@ -368,6 +626,10 @@ static void free_switcher_pte_pages(void)
368 free_page((long)switcher_pte_page(i)); 626 free_page((long)switcher_pte_page(i));
369} 627}
370 628
629/*H:520 Setting up the Switcher PTE page for given CPU is fairly easy, given
630 * the CPU number and the "struct page"s for the Switcher code itself.
631 *
632 * Currently the Switcher is less than a page long, so "pages" is always 1. */
371static __init void populate_switcher_pte_page(unsigned int cpu, 633static __init void populate_switcher_pte_page(unsigned int cpu,
372 struct page *switcher_page[], 634 struct page *switcher_page[],
373 unsigned int pages) 635 unsigned int pages)
@@ -375,21 +637,26 @@ static __init void populate_switcher_pte_page(unsigned int cpu,
375 unsigned int i; 637 unsigned int i;
376 spte_t *pte = switcher_pte_page(cpu); 638 spte_t *pte = switcher_pte_page(cpu);
377 639
640 /* The first entries are easy: they map the Switcher code. */
378 for (i = 0; i < pages; i++) { 641 for (i = 0; i < pages; i++) {
379 pte[i].pfn = page_to_pfn(switcher_page[i]); 642 pte[i].pfn = page_to_pfn(switcher_page[i]);
380 pte[i].flags = _PAGE_PRESENT|_PAGE_ACCESSED; 643 pte[i].flags = _PAGE_PRESENT|_PAGE_ACCESSED;
381 } 644 }
382 645
383 /* We only map this CPU's pages, so guest can't see others. */ 646 /* The only other thing we map is this CPU's pair of pages. */
384 i = pages + cpu*2; 647 i = pages + cpu*2;
385 648
386 /* First page (regs) is rw, second (state) is ro. */ 649 /* First page (Guest registers) is writable from the Guest */
387 pte[i].pfn = page_to_pfn(switcher_page[i]); 650 pte[i].pfn = page_to_pfn(switcher_page[i]);
388 pte[i].flags = _PAGE_PRESENT|_PAGE_ACCESSED|_PAGE_RW; 651 pte[i].flags = _PAGE_PRESENT|_PAGE_ACCESSED|_PAGE_RW;
652 /* The second page contains the "struct lguest_ro_state", and is
653 * read-only. */
389 pte[i+1].pfn = page_to_pfn(switcher_page[i+1]); 654 pte[i+1].pfn = page_to_pfn(switcher_page[i+1]);
390 pte[i+1].flags = _PAGE_PRESENT|_PAGE_ACCESSED; 655 pte[i+1].flags = _PAGE_PRESENT|_PAGE_ACCESSED;
391} 656}
392 657
658/*H:510 At boot or module load time, init_pagetables() allocates and populates
659 * the Switcher PTE page for each CPU. */
393__init int init_pagetables(struct page **switcher_page, unsigned int pages) 660__init int init_pagetables(struct page **switcher_page, unsigned int pages)
394{ 661{
395 unsigned int i; 662 unsigned int i;
@@ -404,7 +671,9 @@ __init int init_pagetables(struct page **switcher_page, unsigned int pages)
404 } 671 }
405 return 0; 672 return 0;
406} 673}
674/*:*/
407 675
676/* Cleaning up simply involves freeing the PTE page for each CPU. */
408void free_pagetables(void) 677void free_pagetables(void)
409{ 678{
410 free_switcher_pte_pages(); 679 free_switcher_pte_pages();
diff --git a/drivers/lguest/segments.c b/drivers/lguest/segments.c
index 1b2cfe89dcd5..f675a41a80da 100644
--- a/drivers/lguest/segments.c
+++ b/drivers/lguest/segments.c
@@ -1,16 +1,68 @@
1/*P:600 The x86 architecture has segments, which involve a table of descriptors
2 * which can be used to do funky things with virtual address interpretation.
3 * We originally used to use segments so the Guest couldn't alter the
4 * Guest<->Host Switcher, and then we had to trim Guest segments, and restore
5 * for userspace per-thread segments, but trim again for on userspace->kernel
6 * transitions... This nightmarish creation was contained within this file,
7 * where we knew not to tread without heavy armament and a change of underwear.
8 *
9 * In these modern times, the segment handling code consists of simple sanity
10 * checks, and the worst you'll experience reading this code is butterfly-rash
11 * from frolicking through its parklike serenity. :*/
1#include "lg.h" 12#include "lg.h"
2 13
14/*H:600
15 * We've almost completed the Host; there's just one file to go!
16 *
17 * Segments & The Global Descriptor Table
18 *
19 * (That title sounds like a bad Nerdcore group. Not to suggest that there are
20 * any good Nerdcore groups, but in high school a friend of mine had a band
21 * called Joe Fish and the Chips, so there are definitely worse band names).
22 *
23 * To refresh: the GDT is a table of 8-byte values describing segments. Once
24 * set up, these segments can be loaded into one of the 6 "segment registers".
25 *
26 * GDT entries are passed around as "struct desc_struct"s, which like IDT
27 * entries are split into two 32-bit members, "a" and "b". One day, someone
28 * will clean that up, and be declared a Hero. (No pressure, I'm just saying).
29 *
30 * Anyway, the GDT entry contains a base (the start address of the segment), a
31 * limit (the size of the segment - 1), and some flags. Sounds simple, and it
32 * would be, except those zany Intel engineers decided that it was too boring
33 * to put the base at one end, the limit at the other, and the flags in
34 * between. They decided to shotgun the bits at random throughout the 8 bytes,
35 * like so:
36 *
37 * 0 16 40 48 52 56 63
38 * [ limit part 1 ][ base part 1 ][ flags ][li][fl][base ]
39 * mit ags part 2
40 * part 2
41 *
42 * As a result, this file contains a certain amount of magic numeracy. Let's
43 * begin.
44 */
45
46/* Is the descriptor the Guest wants us to put in OK?
47 *
48 * The flag which Intel says must be zero: must be zero. The descriptor must
49 * be present, (this is actually checked earlier but is here for thorougness),
50 * and the descriptor type must be 1 (a memory segment). */
3static int desc_ok(const struct desc_struct *gdt) 51static int desc_ok(const struct desc_struct *gdt)
4{ 52{
5 /* MBZ=0, P=1, DT=1 */
6 return ((gdt->b & 0x00209000) == 0x00009000); 53 return ((gdt->b & 0x00209000) == 0x00009000);
7} 54}
8 55
56/* Is the segment present? (Otherwise it can't be used by the Guest). */
9static int segment_present(const struct desc_struct *gdt) 57static int segment_present(const struct desc_struct *gdt)
10{ 58{
11 return gdt->b & 0x8000; 59 return gdt->b & 0x8000;
12} 60}
13 61
62/* There are several entries we don't let the Guest set. The TSS entry is the
63 * "Task State Segment" which controls all kinds of delicate things. The
64 * LGUEST_CS and LGUEST_DS entries are reserved for the Switcher, and the
65 * the Guest can't be trusted to deal with double faults. */
14static int ignored_gdt(unsigned int num) 66static int ignored_gdt(unsigned int num)
15{ 67{
16 return (num == GDT_ENTRY_TSS 68 return (num == GDT_ENTRY_TSS
@@ -19,9 +71,18 @@ static int ignored_gdt(unsigned int num)
19 || num == GDT_ENTRY_DOUBLEFAULT_TSS); 71 || num == GDT_ENTRY_DOUBLEFAULT_TSS);
20} 72}
21 73
22/* We don't allow removal of CS, DS or SS; it doesn't make sense. */ 74/* If the Guest asks us to remove an entry from the GDT, we have to be careful.
75 * If one of the segment registers is pointing at that entry the Switcher will
76 * crash when it tries to reload the segment registers for the Guest.
77 *
78 * It doesn't make much sense for the Guest to try to remove its own code, data
79 * or stack segments while they're in use: assume that's a Guest bug. If it's
80 * one of the lesser segment registers using the removed entry, we simply set
81 * that register to 0 (unusable). */
23static void check_segment_use(struct lguest *lg, unsigned int desc) 82static void check_segment_use(struct lguest *lg, unsigned int desc)
24{ 83{
84 /* GDT entries are 8 bytes long, so we divide to get the index and
85 * ignore the bottom bits. */
25 if (lg->regs->gs / 8 == desc) 86 if (lg->regs->gs / 8 == desc)
26 lg->regs->gs = 0; 87 lg->regs->gs = 0;
27 if (lg->regs->fs / 8 == desc) 88 if (lg->regs->fs / 8 == desc)
@@ -33,13 +94,21 @@ static void check_segment_use(struct lguest *lg, unsigned int desc)
33 || lg->regs->ss / 8 == desc) 94 || lg->regs->ss / 8 == desc)
34 kill_guest(lg, "Removed live GDT entry %u", desc); 95 kill_guest(lg, "Removed live GDT entry %u", desc);
35} 96}
36 97/*:*/
98/*M:009 We wouldn't need to check for removal of in-use segments if we handled
99 * faults in the Switcher. However, it's probably not a worthwhile
100 * optimization. :*/
101
102/*H:610 Once the GDT has been changed, we look through the changed entries and
103 * see if they're OK. If not, we'll call kill_guest() and the Guest will never
104 * get to use the invalid entries. */
37static void fixup_gdt_table(struct lguest *lg, unsigned start, unsigned end) 105static void fixup_gdt_table(struct lguest *lg, unsigned start, unsigned end)
38{ 106{
39 unsigned int i; 107 unsigned int i;
40 108
41 for (i = start; i < end; i++) { 109 for (i = start; i < end; i++) {
42 /* We never copy these ones to real gdt */ 110 /* We never copy these ones to real GDT, so we don't care what
111 * they say */
43 if (ignored_gdt(i)) 112 if (ignored_gdt(i))
44 continue; 113 continue;
45 114
@@ -53,41 +122,57 @@ static void fixup_gdt_table(struct lguest *lg, unsigned start, unsigned end)
53 if (!desc_ok(&lg->gdt[i])) 122 if (!desc_ok(&lg->gdt[i]))
54 kill_guest(lg, "Bad GDT descriptor %i", i); 123 kill_guest(lg, "Bad GDT descriptor %i", i);
55 124
56 /* DPL 0 presumably means "for use by guest". */ 125 /* Segment descriptors contain a privilege level: the Guest is
126 * sometimes careless and leaves this as 0, even though it's
127 * running at privilege level 1. If so, we fix it here. */
57 if ((lg->gdt[i].b & 0x00006000) == 0) 128 if ((lg->gdt[i].b & 0x00006000) == 0)
58 lg->gdt[i].b |= (GUEST_PL << 13); 129 lg->gdt[i].b |= (GUEST_PL << 13);
59 130
60 /* Set accessed bit, since gdt isn't writable. */ 131 /* Each descriptor has an "accessed" bit. If we don't set it
132 * now, the CPU will try to set it when the Guest first loads
133 * that entry into a segment register. But the GDT isn't
134 * writable by the Guest, so bad things can happen. */
61 lg->gdt[i].b |= 0x00000100; 135 lg->gdt[i].b |= 0x00000100;
62 } 136 }
63} 137}
64 138
139/* This routine is called at boot or modprobe time for each CPU to set up the
140 * "constant" GDT entries for Guests running on that CPU. */
65void setup_default_gdt_entries(struct lguest_ro_state *state) 141void setup_default_gdt_entries(struct lguest_ro_state *state)
66{ 142{
67 struct desc_struct *gdt = state->guest_gdt; 143 struct desc_struct *gdt = state->guest_gdt;
68 unsigned long tss = (unsigned long)&state->guest_tss; 144 unsigned long tss = (unsigned long)&state->guest_tss;
69 145
70 /* Hypervisor segments. */ 146 /* The hypervisor segments are full 0-4G segments, privilege level 0 */
71 gdt[GDT_ENTRY_LGUEST_CS] = FULL_EXEC_SEGMENT; 147 gdt[GDT_ENTRY_LGUEST_CS] = FULL_EXEC_SEGMENT;
72 gdt[GDT_ENTRY_LGUEST_DS] = FULL_SEGMENT; 148 gdt[GDT_ENTRY_LGUEST_DS] = FULL_SEGMENT;
73 149
74 /* This is the one which we *cannot* copy from guest, since tss 150 /* The TSS segment refers to the TSS entry for this CPU, so we cannot
75 is depended on this lguest_ro_state, ie. this cpu. */ 151 * copy it from the Guest. Forgive the magic flags */
76 gdt[GDT_ENTRY_TSS].a = 0x00000067 | (tss << 16); 152 gdt[GDT_ENTRY_TSS].a = 0x00000067 | (tss << 16);
77 gdt[GDT_ENTRY_TSS].b = 0x00008900 | (tss & 0xFF000000) 153 gdt[GDT_ENTRY_TSS].b = 0x00008900 | (tss & 0xFF000000)
78 | ((tss >> 16) & 0x000000FF); 154 | ((tss >> 16) & 0x000000FF);
79} 155}
80 156
157/* This routine is called before the Guest is run for the first time. */
81void setup_guest_gdt(struct lguest *lg) 158void setup_guest_gdt(struct lguest *lg)
82{ 159{
160 /* Start with full 0-4G segments... */
83 lg->gdt[GDT_ENTRY_KERNEL_CS] = FULL_EXEC_SEGMENT; 161 lg->gdt[GDT_ENTRY_KERNEL_CS] = FULL_EXEC_SEGMENT;
84 lg->gdt[GDT_ENTRY_KERNEL_DS] = FULL_SEGMENT; 162 lg->gdt[GDT_ENTRY_KERNEL_DS] = FULL_SEGMENT;
163 /* ...except the Guest is allowed to use them, so set the privilege
164 * level appropriately in the flags. */
85 lg->gdt[GDT_ENTRY_KERNEL_CS].b |= (GUEST_PL << 13); 165 lg->gdt[GDT_ENTRY_KERNEL_CS].b |= (GUEST_PL << 13);
86 lg->gdt[GDT_ENTRY_KERNEL_DS].b |= (GUEST_PL << 13); 166 lg->gdt[GDT_ENTRY_KERNEL_DS].b |= (GUEST_PL << 13);
87} 167}
88 168
89/* This is a fast version for the common case where only the three TLS entries 169/* Like the IDT, we never simply use the GDT the Guest gives us. We set up the
90 * have changed. */ 170 * GDTs for each CPU, then we copy across the entries each time we want to run
171 * a different Guest on that CPU. */
172
173/* A partial GDT load, for the three "thead-local storage" entries. Otherwise
174 * it's just like load_guest_gdt(). So much, in fact, it would probably be
175 * neater to have a single hypercall to cover both. */
91void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt) 176void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt)
92{ 177{
93 unsigned int i; 178 unsigned int i;
@@ -96,22 +181,31 @@ void copy_gdt_tls(const struct lguest *lg, struct desc_struct *gdt)
96 gdt[i] = lg->gdt[i]; 181 gdt[i] = lg->gdt[i];
97} 182}
98 183
184/* This is the full version */
99void copy_gdt(const struct lguest *lg, struct desc_struct *gdt) 185void copy_gdt(const struct lguest *lg, struct desc_struct *gdt)
100{ 186{
101 unsigned int i; 187 unsigned int i;
102 188
189 /* The default entries from setup_default_gdt_entries() are not
190 * replaced. See ignored_gdt() above. */
103 for (i = 0; i < GDT_ENTRIES; i++) 191 for (i = 0; i < GDT_ENTRIES; i++)
104 if (!ignored_gdt(i)) 192 if (!ignored_gdt(i))
105 gdt[i] = lg->gdt[i]; 193 gdt[i] = lg->gdt[i];
106} 194}
107 195
196/* This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). */
108void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num) 197void load_guest_gdt(struct lguest *lg, unsigned long table, u32 num)
109{ 198{
199 /* We assume the Guest has the same number of GDT entries as the
200 * Host, otherwise we'd have to dynamically allocate the Guest GDT. */
110 if (num > ARRAY_SIZE(lg->gdt)) 201 if (num > ARRAY_SIZE(lg->gdt))
111 kill_guest(lg, "too many gdt entries %i", num); 202 kill_guest(lg, "too many gdt entries %i", num);
112 203
204 /* We read the whole thing in, then fix it up. */
113 lgread(lg, lg->gdt, table, num * sizeof(lg->gdt[0])); 205 lgread(lg, lg->gdt, table, num * sizeof(lg->gdt[0]));
114 fixup_gdt_table(lg, 0, ARRAY_SIZE(lg->gdt)); 206 fixup_gdt_table(lg, 0, ARRAY_SIZE(lg->gdt));
207 /* Mark that the GDT changed so the core knows it has to copy it again,
208 * even if the Guest is run on the same CPU. */
115 lg->changed |= CHANGED_GDT; 209 lg->changed |= CHANGED_GDT;
116} 210}
117 211
@@ -123,3 +217,13 @@ void guest_load_tls(struct lguest *lg, unsigned long gtls)
123 fixup_gdt_table(lg, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); 217 fixup_gdt_table(lg, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1);
124 lg->changed |= CHANGED_GDT_TLS; 218 lg->changed |= CHANGED_GDT_TLS;
125} 219}
220
221/*
222 * With this, we have finished the Host.
223 *
224 * Five of the seven parts of our task are complete. You have made it through
225 * the Bit of Despair (I think that's somewhere in the page table code,
226 * myself).
227 *
228 * Next, we examine "make Switcher". It's short, but intense.
229 */
diff --git a/drivers/lguest/switcher.S b/drivers/lguest/switcher.S
index eadd4cc299d2..d418179ea6b5 100644
--- a/drivers/lguest/switcher.S
+++ b/drivers/lguest/switcher.S
@@ -1,45 +1,136 @@
1/* This code sits at 0xFFC00000 to do the low-level guest<->host switch. 1/*P:900 This is the Switcher: code which sits at 0xFFC00000 to do the low-level
2 * Guest<->Host switch. It is as simple as it can be made, but it's naturally
3 * very specific to x86.
4 *
5 * You have now completed Preparation. If this has whet your appetite; if you
6 * are feeling invigorated and refreshed then the next, more challenging stage
7 * can be found in "make Guest". :*/
2 8
3 There is are two pages above us for this CPU (struct lguest_pages). 9/*S:100
4 The second page (struct lguest_ro_state) becomes read-only after the 10 * Welcome to the Switcher itself!
5 context switch. The first page (the stack for traps) remains writable, 11 *
6 but while we're in here, the guest cannot be running. 12 * This file contains the low-level code which changes the CPU to run the Guest
7*/ 13 * code, and returns to the Host when something happens. Understand this, and
14 * you understand the heart of our journey.
15 *
16 * Because this is in assembler rather than C, our tale switches from prose to
17 * verse. First I tried limericks:
18 *
19 * There once was an eax reg,
20 * To which our pointer was fed,
21 * It needed an add,
22 * Which asm-offsets.h had
23 * But this limerick is hurting my head.
24 *
25 * Next I tried haikus, but fitting the required reference to the seasons in
26 * every stanza was quickly becoming tiresome:
27 *
28 * The %eax reg
29 * Holds "struct lguest_pages" now:
30 * Cherry blossoms fall.
31 *
32 * Then I started with Heroic Verse, but the rhyming requirement leeched away
33 * the content density and led to some uniquely awful oblique rhymes:
34 *
35 * These constants are coming from struct offsets
36 * For use within the asm switcher text.
37 *
38 * Finally, I settled for something between heroic hexameter, and normal prose
39 * with inappropriate linebreaks. Anyway, it aint no Shakespeare.
40 */
41
42// Not all kernel headers work from assembler
43// But these ones are needed: the ENTRY() define
44// And constants extracted from struct offsets
45// To avoid magic numbers and breakage:
46// Should they change the compiler can't save us
47// Down here in the depths of assembler code.
8#include <linux/linkage.h> 48#include <linux/linkage.h>
9#include <asm/asm-offsets.h> 49#include <asm/asm-offsets.h>
10#include "lg.h" 50#include "lg.h"
11 51
52// We mark the start of the code to copy
53// It's placed in .text tho it's never run here
54// You'll see the trick macro at the end
55// Which interleaves data and text to effect.
12.text 56.text
13ENTRY(start_switcher_text) 57ENTRY(start_switcher_text)
14 58
15/* %eax points to lguest pages for this CPU. %ebx contains cr3 value. 59// When we reach switch_to_guest we have just left
16 All normal registers can be clobbered! */ 60// The safe and comforting shores of C code
61// %eax has the "struct lguest_pages" to use
62// Where we save state and still see it from the Guest
63// And %ebx holds the Guest shadow pagetable:
64// Once set we have truly left Host behind.
17ENTRY(switch_to_guest) 65ENTRY(switch_to_guest)
18 /* Save host segments on host stack. */ 66 // We told gcc all its regs could fade,
67 // Clobbered by our journey into the Guest
68 // We could have saved them, if we tried
69 // But time is our master and cycles count.
70
71 // Segment registers must be saved for the Host
72 // We push them on the Host stack for later
19 pushl %es 73 pushl %es
20 pushl %ds 74 pushl %ds
21 pushl %gs 75 pushl %gs
22 pushl %fs 76 pushl %fs
23 /* With CONFIG_FRAME_POINTER, gcc doesn't let us clobber this! */ 77 // But the compiler is fickle, and heeds
78 // No warning of %ebp clobbers
79 // When frame pointers are used. That register
80 // Must be saved and restored or chaos strikes.
24 pushl %ebp 81 pushl %ebp
25 /* Save host stack. */ 82 // The Host's stack is done, now save it away
83 // In our "struct lguest_pages" at offset
84 // Distilled into asm-offsets.h
26 movl %esp, LGUEST_PAGES_host_sp(%eax) 85 movl %esp, LGUEST_PAGES_host_sp(%eax)
27 /* Switch to guest stack: if we get NMI we expect to be there. */ 86
87 // All saved and there's now five steps before us:
88 // Stack, GDT, IDT, TSS
89 // And last of all the page tables are flipped.
90
91 // Yet beware that our stack pointer must be
92 // Always valid lest an NMI hits
93 // %edx does the duty here as we juggle
94 // %eax is lguest_pages: our stack lies within.
28 movl %eax, %edx 95 movl %eax, %edx
29 addl $LGUEST_PAGES_regs, %edx 96 addl $LGUEST_PAGES_regs, %edx
30 movl %edx, %esp 97 movl %edx, %esp
31 /* Switch to guest's GDT, IDT. */ 98
99 // The Guest's GDT we so carefully
100 // Placed in the "struct lguest_pages" before
32 lgdt LGUEST_PAGES_guest_gdt_desc(%eax) 101 lgdt LGUEST_PAGES_guest_gdt_desc(%eax)
102
103 // The Guest's IDT we did partially
104 // Move to the "struct lguest_pages" as well.
33 lidt LGUEST_PAGES_guest_idt_desc(%eax) 105 lidt LGUEST_PAGES_guest_idt_desc(%eax)
34 /* Switch to guest's TSS while GDT still writable. */ 106
107 // The TSS entry which controls traps
108 // Must be loaded up with "ltr" now:
109 // For after we switch over our page tables
110 // It (as the rest) will be writable no more.
111 // (The GDT entry TSS needs
112 // Changes type when we load it: damn Intel!)
35 movl $(GDT_ENTRY_TSS*8), %edx 113 movl $(GDT_ENTRY_TSS*8), %edx
36 ltr %dx 114 ltr %dx
37 /* Set host's TSS GDT entry to available (clear byte 5 bit 2). */ 115
116 // Look back now, before we take this last step!
117 // The Host's TSS entry was also marked used;
118 // Let's clear it again, ere we return.
119 // The GDT descriptor of the Host
120 // Points to the table after two "size" bytes
38 movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx 121 movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
122 // Clear the type field of "used" (byte 5, bit 2)
39 andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx) 123 andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
40 /* Switch to guest page tables: lguest_pages->state now read-only. */ 124
125 // Once our page table's switched, the Guest is live!
126 // The Host fades as we run this final step.
127 // Our "struct lguest_pages" is now read-only.
41 movl %ebx, %cr3 128 movl %ebx, %cr3
42 /* Restore guest regs */ 129
130 // The page table change did one tricky thing:
131 // The Guest's register page has been mapped
132 // Writable onto our %esp (stack) --
133 // We can simply pop off all Guest regs.
43 popl %ebx 134 popl %ebx
44 popl %ecx 135 popl %ecx
45 popl %edx 136 popl %edx
@@ -51,12 +142,27 @@ ENTRY(switch_to_guest)
51 popl %fs 142 popl %fs
52 popl %ds 143 popl %ds
53 popl %es 144 popl %es
54 /* Skip error code and trap number */ 145
146 // Near the base of the stack lurk two strange fields
147 // Which we fill as we exit the Guest
148 // These are the trap number and its error
149 // We can simply step past them on our way.
55 addl $8, %esp 150 addl $8, %esp
151
152 // The last five stack slots hold return address
153 // And everything needed to change privilege
154 // Into the Guest privilege level of 1,
155 // And the stack where the Guest had last left it.
156 // Interrupts are turned back on: we are Guest.
56 iret 157 iret
57 158
159// There are two paths where we switch to the Host
160// So we put the routine in a macro.
161// We are on our way home, back to the Host
162// Interrupted out of the Guest, we come here.
58#define SWITCH_TO_HOST \ 163#define SWITCH_TO_HOST \
59 /* Save guest state */ \ 164 /* We save the Guest state: all registers first \
165 * Laid out just as "struct lguest_regs" defines */ \
60 pushl %es; \ 166 pushl %es; \
61 pushl %ds; \ 167 pushl %ds; \
62 pushl %fs; \ 168 pushl %fs; \
@@ -68,58 +174,119 @@ ENTRY(switch_to_guest)
68 pushl %edx; \ 174 pushl %edx; \
69 pushl %ecx; \ 175 pushl %ecx; \
70 pushl %ebx; \ 176 pushl %ebx; \
71 /* Load lguest ds segment for convenience. */ \ 177 /* Our stack and our code are using segments \
178 * Set in the TSS and IDT \
179 * Yet if we were to touch data we'd use \
180 * Whatever data segment the Guest had. \
181 * Load the lguest ds segment for now. */ \
72 movl $(LGUEST_DS), %eax; \ 182 movl $(LGUEST_DS), %eax; \
73 movl %eax, %ds; \ 183 movl %eax, %ds; \
74 /* Figure out where we are, based on stack (at top of regs). */ \ 184 /* So where are we? Which CPU, which struct? \
185 * The stack is our clue: our TSS sets \
186 * It at the end of "struct lguest_pages" \
187 * And we then pushed and pushed and pushed Guest regs: \
188 * Now stack points atop the "struct lguest_regs". \
189 * Subtract that offset, and we find our struct. */ \
75 movl %esp, %eax; \ 190 movl %esp, %eax; \
76 subl $LGUEST_PAGES_regs, %eax; \ 191 subl $LGUEST_PAGES_regs, %eax; \
77 /* Put trap number in %ebx before we switch cr3 and lose it. */ \ 192 /* Save our trap number: the switch will obscure it \
193 * (The Guest regs are not mapped here in the Host) \
194 * %ebx holds it safe for deliver_to_host */ \
78 movl LGUEST_PAGES_regs_trapnum(%eax), %ebx; \ 195 movl LGUEST_PAGES_regs_trapnum(%eax), %ebx; \
79 /* Switch to host page tables (host GDT, IDT and stack are in host \ 196 /* The Host GDT, IDT and stack! \
80 mem, so need this first) */ \ 197 * All these lie safely hidden from the Guest: \
198 * We must return to the Host page tables \
199 * (Hence that was saved in struct lguest_pages) */ \
81 movl LGUEST_PAGES_host_cr3(%eax), %edx; \ 200 movl LGUEST_PAGES_host_cr3(%eax), %edx; \
82 movl %edx, %cr3; \ 201 movl %edx, %cr3; \
83 /* Set guest's TSS to available (clear byte 5 bit 2). */ \ 202 /* As before, when we looked back at the Host \
203 * As we left and marked TSS unused \
204 * So must we now for the Guest left behind. */ \
84 andb $0xFD, (LGUEST_PAGES_guest_gdt+GDT_ENTRY_TSS*8+5)(%eax); \ 205 andb $0xFD, (LGUEST_PAGES_guest_gdt+GDT_ENTRY_TSS*8+5)(%eax); \
85 /* Switch to host's GDT & IDT. */ \ 206 /* Switch to Host's GDT, IDT. */ \
86 lgdt LGUEST_PAGES_host_gdt_desc(%eax); \ 207 lgdt LGUEST_PAGES_host_gdt_desc(%eax); \
87 lidt LGUEST_PAGES_host_idt_desc(%eax); \ 208 lidt LGUEST_PAGES_host_idt_desc(%eax); \
88 /* Switch to host's stack. */ \ 209 /* Restore the Host's stack where it's saved regs lie */ \
89 movl LGUEST_PAGES_host_sp(%eax), %esp; \ 210 movl LGUEST_PAGES_host_sp(%eax), %esp; \
90 /* Switch to host's TSS */ \ 211 /* Last the TSS: our Host is complete */ \
91 movl $(GDT_ENTRY_TSS*8), %edx; \ 212 movl $(GDT_ENTRY_TSS*8), %edx; \
92 ltr %dx; \ 213 ltr %dx; \
214 /* Restore now the regs saved right at the first. */ \
93 popl %ebp; \ 215 popl %ebp; \
94 popl %fs; \ 216 popl %fs; \
95 popl %gs; \ 217 popl %gs; \
96 popl %ds; \ 218 popl %ds; \
97 popl %es 219 popl %es
98 220
99/* Return to run_guest_once. */ 221// Here's where we come when the Guest has just trapped:
222// (Which trap we'll see has been pushed on the stack).
223// We need only switch back, and the Host will decode
224// Why we came home, and what needs to be done.
100return_to_host: 225return_to_host:
101 SWITCH_TO_HOST 226 SWITCH_TO_HOST
102 iret 227 iret
103 228
229// An interrupt, with some cause external
230// Has ajerked us rudely from the Guest's code
231// Again we must return home to the Host
104deliver_to_host: 232deliver_to_host:
105 SWITCH_TO_HOST 233 SWITCH_TO_HOST
106 /* Decode IDT and jump to hosts' irq handler. When that does iret, it 234 // But now we must go home via that place
107 * will return to run_guest_once. This is a feature. */ 235 // Where that interrupt was supposed to go
236 // Had we not been ensconced, running the Guest.
237 // Here we see the cleverness of our stack:
238 // The Host stack is formed like an interrupt
239 // With EIP, CS and EFLAGS layered.
240 // Interrupt handlers end with "iret"
241 // And that will take us home at long long last.
242
243 // But first we must find the handler to call!
244 // The IDT descriptor for the Host
245 // Has two bytes for size, and four for address:
246 // %edx will hold it for us for now.
108 movl (LGUEST_PAGES_host_idt_desc+2)(%eax), %edx 247 movl (LGUEST_PAGES_host_idt_desc+2)(%eax), %edx
248 // We now know the table address we need,
249 // And saved the trap's number inside %ebx.
250 // Yet the pointer to the handler is smeared
251 // Across the bits of the table entry.
252 // What oracle can tell us how to extract
253 // From such a convoluted encoding?
254 // I consulted gcc, and it gave
255 // These instructions, which I gladly credit:
109 leal (%edx,%ebx,8), %eax 256 leal (%edx,%ebx,8), %eax
110 movzwl (%eax),%edx 257 movzwl (%eax),%edx
111 movl 4(%eax), %eax 258 movl 4(%eax), %eax
112 xorw %ax, %ax 259 xorw %ax, %ax
113 orl %eax, %edx 260 orl %eax, %edx
261 // Now the address of the handler's in %edx
262 // We call it now: its "iret" takes us home.
114 jmp *%edx 263 jmp *%edx
115 264
116/* Real hardware interrupts are delivered straight to the host. Others 265// Every interrupt can come to us here
117 cause us to return to run_guest_once so it can decide what to do. Note 266// But we must truly tell each apart.
118 that some of these are overridden by the guest to deliver directly, and 267// They number two hundred and fifty six
119 never enter here (see load_guest_idt_entry). */ 268// And each must land in a different spot,
269// Push its number on stack, and join the stream.
270
271// And worse, a mere six of the traps stand apart
272// And push on their stack an addition:
273// An error number, thirty two bits long
274// So we punish the other two fifty
275// And make them push a zero so they match.
276
277// Yet two fifty six entries is long
278// And all will look most the same as the last
279// So we create a macro which can make
280// As many entries as we need to fill.
281
282// Note the change to .data then .text:
283// We plant the address of each entry
284// Into a (data) table for the Host
285// To know where each Guest interrupt should go.
120.macro IRQ_STUB N TARGET 286.macro IRQ_STUB N TARGET
121 .data; .long 1f; .text; 1: 287 .data; .long 1f; .text; 1:
122 /* Make an error number for most traps, which don't have one. */ 288 // Trap eight, ten through fourteen and seventeen
289 // Supply an error number. Else zero.
123 .if (\N <> 8) && (\N < 10 || \N > 14) && (\N <> 17) 290 .if (\N <> 8) && (\N < 10 || \N > 14) && (\N <> 17)
124 pushl $0 291 pushl $0
125 .endif 292 .endif
@@ -128,6 +295,8 @@ deliver_to_host:
128 ALIGN 295 ALIGN
129.endm 296.endm
130 297
298// This macro creates numerous entries
299// Using GAS macros which out-power C's.
131.macro IRQ_STUBS FIRST LAST TARGET 300.macro IRQ_STUBS FIRST LAST TARGET
132 irq=\FIRST 301 irq=\FIRST
133 .rept \LAST-\FIRST+1 302 .rept \LAST-\FIRST+1
@@ -136,24 +305,43 @@ deliver_to_host:
136 .endr 305 .endr
137.endm 306.endm
138 307
139/* We intercept every interrupt, because we may need to switch back to 308// Here's the marker for our pointer table
140 * host. Unfortunately we can't tell them apart except by entry 309// Laid in the data section just before
141 * point, so we need 256 entry points. 310// Each macro places the address of code
142 */ 311// Forming an array: each one points to text
312// Which handles interrupt in its turn.
143.data 313.data
144.global default_idt_entries 314.global default_idt_entries
145default_idt_entries: 315default_idt_entries:
146.text 316.text
147 IRQ_STUBS 0 1 return_to_host /* First two traps */ 317 // The first two traps go straight back to the Host
148 IRQ_STUB 2 handle_nmi /* NMI */ 318 IRQ_STUBS 0 1 return_to_host
149 IRQ_STUBS 3 31 return_to_host /* Rest of traps */ 319 // We'll say nothing, yet, about NMI
150 IRQ_STUBS 32 127 deliver_to_host /* Real interrupts */ 320 IRQ_STUB 2 handle_nmi
151 IRQ_STUB 128 return_to_host /* System call (overridden) */ 321 // Other traps also return to the Host
152 IRQ_STUBS 129 255 deliver_to_host /* Other real interrupts */ 322 IRQ_STUBS 3 31 return_to_host
153 323 // All interrupts go via their handlers
154/* We ignore NMI and return. */ 324 IRQ_STUBS 32 127 deliver_to_host
325 // 'Cept system calls coming from userspace
326 // Are to go to the Guest, never the Host.
327 IRQ_STUB 128 return_to_host
328 IRQ_STUBS 129 255 deliver_to_host
329
330// The NMI, what a fabulous beast
331// Which swoops in and stops us no matter that
332// We're suspended between heaven and hell,
333// (Or more likely between the Host and Guest)
334// When in it comes! We are dazed and confused
335// So we do the simplest thing which one can.
336// Though we've pushed the trap number and zero
337// We discard them, return, and hope we live.
155handle_nmi: 338handle_nmi:
156 addl $8, %esp 339 addl $8, %esp
157 iret 340 iret
158 341
342// We are done; all that's left is Mastery
343// And "make Mastery" is a journey long
344// Designed to make your fingers itch to code.
345
346// Here ends the text, the file and poem.
159ENTRY(end_switcher_text) 347ENTRY(end_switcher_text)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 2fc199b0016b..2bcde5798b5a 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -526,7 +526,7 @@ static int __table_get_device(struct dm_table *t, struct dm_target *ti,
526 526
527void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev) 527void dm_set_device_limits(struct dm_target *ti, struct block_device *bdev)
528{ 528{
529 request_queue_t *q = bdev_get_queue(bdev); 529 struct request_queue *q = bdev_get_queue(bdev);
530 struct io_restrictions *rs = &ti->limits; 530 struct io_restrictions *rs = &ti->limits;
531 531
532 /* 532 /*
@@ -979,7 +979,7 @@ int dm_table_any_congested(struct dm_table *t, int bdi_bits)
979 devices = dm_table_get_devices(t); 979 devices = dm_table_get_devices(t);
980 for (d = devices->next; d != devices; d = d->next) { 980 for (d = devices->next; d != devices; d = d->next) {
981 struct dm_dev *dd = list_entry(d, struct dm_dev, list); 981 struct dm_dev *dd = list_entry(d, struct dm_dev, list);
982 request_queue_t *q = bdev_get_queue(dd->bdev); 982 struct request_queue *q = bdev_get_queue(dd->bdev);
983 r |= bdi_congested(&q->backing_dev_info, bdi_bits); 983 r |= bdi_congested(&q->backing_dev_info, bdi_bits);
984 } 984 }
985 985
@@ -992,7 +992,7 @@ void dm_table_unplug_all(struct dm_table *t)
992 992
993 for (d = devices->next; d != devices; d = d->next) { 993 for (d = devices->next; d != devices; d = d->next) {
994 struct dm_dev *dd = list_entry(d, struct dm_dev, list); 994 struct dm_dev *dd = list_entry(d, struct dm_dev, list);
995 request_queue_t *q = bdev_get_queue(dd->bdev); 995 struct request_queue *q = bdev_get_queue(dd->bdev);
996 996
997 if (q->unplug_fn) 997 if (q->unplug_fn)
998 q->unplug_fn(q); 998 q->unplug_fn(q);
@@ -1011,7 +1011,7 @@ int dm_table_flush_all(struct dm_table *t)
1011 1011
1012 for (d = devices->next; d != devices; d = d->next) { 1012 for (d = devices->next; d != devices; d = d->next) {
1013 struct dm_dev *dd = list_entry(d, struct dm_dev, list); 1013 struct dm_dev *dd = list_entry(d, struct dm_dev, list);
1014 request_queue_t *q = bdev_get_queue(dd->bdev); 1014 struct request_queue *q = bdev_get_queue(dd->bdev);
1015 int err; 1015 int err;
1016 1016
1017 if (!q->issue_flush_fn) 1017 if (!q->issue_flush_fn)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 846614e676c6..141ff9fa296e 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -80,7 +80,7 @@ struct mapped_device {
80 80
81 unsigned long flags; 81 unsigned long flags;
82 82
83 request_queue_t *queue; 83 struct request_queue *queue;
84 struct gendisk *disk; 84 struct gendisk *disk;
85 char name[16]; 85 char name[16];
86 86
@@ -792,7 +792,7 @@ static void __split_bio(struct mapped_device *md, struct bio *bio)
792 * The request function that just remaps the bio built up by 792 * The request function that just remaps the bio built up by
793 * dm_merge_bvec. 793 * dm_merge_bvec.
794 */ 794 */
795static int dm_request(request_queue_t *q, struct bio *bio) 795static int dm_request(struct request_queue *q, struct bio *bio)
796{ 796{
797 int r; 797 int r;
798 int rw = bio_data_dir(bio); 798 int rw = bio_data_dir(bio);
@@ -844,7 +844,7 @@ static int dm_request(request_queue_t *q, struct bio *bio)
844 return 0; 844 return 0;
845} 845}
846 846
847static int dm_flush_all(request_queue_t *q, struct gendisk *disk, 847static int dm_flush_all(struct request_queue *q, struct gendisk *disk,
848 sector_t *error_sector) 848 sector_t *error_sector)
849{ 849{
850 struct mapped_device *md = q->queuedata; 850 struct mapped_device *md = q->queuedata;
@@ -859,7 +859,7 @@ static int dm_flush_all(request_queue_t *q, struct gendisk *disk,
859 return ret; 859 return ret;
860} 860}
861 861
862static void dm_unplug_all(request_queue_t *q) 862static void dm_unplug_all(struct request_queue *q)
863{ 863{
864 struct mapped_device *md = q->queuedata; 864 struct mapped_device *md = q->queuedata;
865 struct dm_table *map = dm_get_table(md); 865 struct dm_table *map = dm_get_table(md);
@@ -1110,7 +1110,7 @@ static void __set_size(struct mapped_device *md, sector_t size)
1110 1110
1111static int __bind(struct mapped_device *md, struct dm_table *t) 1111static int __bind(struct mapped_device *md, struct dm_table *t)
1112{ 1112{
1113 request_queue_t *q = md->queue; 1113 struct request_queue *q = md->queue;
1114 sector_t size; 1114 sector_t size;
1115 1115
1116 size = dm_table_get_size(t); 1116 size = dm_table_get_size(t);
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index 4ebd0f2a75ec..cb059cf14c2e 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -167,7 +167,7 @@ static void add_sector(conf_t *conf, sector_t start, int mode)
167 conf->nfaults = n+1; 167 conf->nfaults = n+1;
168} 168}
169 169
170static int make_request(request_queue_t *q, struct bio *bio) 170static int make_request(struct request_queue *q, struct bio *bio)
171{ 171{
172 mddev_t *mddev = q->queuedata; 172 mddev_t *mddev = q->queuedata;
173 conf_t *conf = (conf_t*)mddev->private; 173 conf_t *conf = (conf_t*)mddev->private;
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 192741083196..17f795c3e0ab 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -55,7 +55,7 @@ static inline dev_info_t *which_dev(mddev_t *mddev, sector_t sector)
55 * 55 *
56 * Return amount of bytes we can take at this offset 56 * Return amount of bytes we can take at this offset
57 */ 57 */
58static int linear_mergeable_bvec(request_queue_t *q, struct bio *bio, struct bio_vec *biovec) 58static int linear_mergeable_bvec(struct request_queue *q, struct bio *bio, struct bio_vec *biovec)
59{ 59{
60 mddev_t *mddev = q->queuedata; 60 mddev_t *mddev = q->queuedata;
61 dev_info_t *dev0; 61 dev_info_t *dev0;
@@ -79,20 +79,20 @@ static int linear_mergeable_bvec(request_queue_t *q, struct bio *bio, struct bio
79 return maxsectors << 9; 79 return maxsectors << 9;
80} 80}
81 81
82static void linear_unplug(request_queue_t *q) 82static void linear_unplug(struct request_queue *q)
83{ 83{
84 mddev_t *mddev = q->queuedata; 84 mddev_t *mddev = q->queuedata;
85 linear_conf_t *conf = mddev_to_conf(mddev); 85 linear_conf_t *conf = mddev_to_conf(mddev);
86 int i; 86 int i;
87 87
88 for (i=0; i < mddev->raid_disks; i++) { 88 for (i=0; i < mddev->raid_disks; i++) {
89 request_queue_t *r_queue = bdev_get_queue(conf->disks[i].rdev->bdev); 89 struct request_queue *r_queue = bdev_get_queue(conf->disks[i].rdev->bdev);
90 if (r_queue->unplug_fn) 90 if (r_queue->unplug_fn)
91 r_queue->unplug_fn(r_queue); 91 r_queue->unplug_fn(r_queue);
92 } 92 }
93} 93}
94 94
95static int linear_issue_flush(request_queue_t *q, struct gendisk *disk, 95static int linear_issue_flush(struct request_queue *q, struct gendisk *disk,
96 sector_t *error_sector) 96 sector_t *error_sector)
97{ 97{
98 mddev_t *mddev = q->queuedata; 98 mddev_t *mddev = q->queuedata;
@@ -101,7 +101,7 @@ static int linear_issue_flush(request_queue_t *q, struct gendisk *disk,
101 101
102 for (i=0; i < mddev->raid_disks && ret == 0; i++) { 102 for (i=0; i < mddev->raid_disks && ret == 0; i++) {
103 struct block_device *bdev = conf->disks[i].rdev->bdev; 103 struct block_device *bdev = conf->disks[i].rdev->bdev;
104 request_queue_t *r_queue = bdev_get_queue(bdev); 104 struct request_queue *r_queue = bdev_get_queue(bdev);
105 105
106 if (!r_queue->issue_flush_fn) 106 if (!r_queue->issue_flush_fn)
107 ret = -EOPNOTSUPP; 107 ret = -EOPNOTSUPP;
@@ -118,7 +118,7 @@ static int linear_congested(void *data, int bits)
118 int i, ret = 0; 118 int i, ret = 0;
119 119
120 for (i = 0; i < mddev->raid_disks && !ret ; i++) { 120 for (i = 0; i < mddev->raid_disks && !ret ; i++) {
121 request_queue_t *q = bdev_get_queue(conf->disks[i].rdev->bdev); 121 struct request_queue *q = bdev_get_queue(conf->disks[i].rdev->bdev);
122 ret |= bdi_congested(&q->backing_dev_info, bits); 122 ret |= bdi_congested(&q->backing_dev_info, bits);
123 } 123 }
124 return ret; 124 return ret;
@@ -330,7 +330,7 @@ static int linear_stop (mddev_t *mddev)
330 return 0; 330 return 0;
331} 331}
332 332
333static int linear_make_request (request_queue_t *q, struct bio *bio) 333static int linear_make_request (struct request_queue *q, struct bio *bio)
334{ 334{
335 const int rw = bio_data_dir(bio); 335 const int rw = bio_data_dir(bio);
336 mddev_t *mddev = q->queuedata; 336 mddev_t *mddev = q->queuedata;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 65ddc887dfd7..f883b7e37f3d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -211,7 +211,7 @@ static DEFINE_SPINLOCK(all_mddevs_lock);
211 ) 211 )
212 212
213 213
214static int md_fail_request (request_queue_t *q, struct bio *bio) 214static int md_fail_request (struct request_queue *q, struct bio *bio)
215{ 215{
216 bio_io_error(bio, bio->bi_size); 216 bio_io_error(bio, bio->bi_size);
217 return 0; 217 return 0;
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 14da37fee37b..1e2af43a73b9 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -125,7 +125,7 @@ static void unplug_slaves(mddev_t *mddev)
125 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev); 125 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
126 if (rdev && !test_bit(Faulty, &rdev->flags) 126 if (rdev && !test_bit(Faulty, &rdev->flags)
127 && atomic_read(&rdev->nr_pending)) { 127 && atomic_read(&rdev->nr_pending)) {
128 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 128 struct request_queue *r_queue = bdev_get_queue(rdev->bdev);
129 129
130 atomic_inc(&rdev->nr_pending); 130 atomic_inc(&rdev->nr_pending);
131 rcu_read_unlock(); 131 rcu_read_unlock();
@@ -140,13 +140,13 @@ static void unplug_slaves(mddev_t *mddev)
140 rcu_read_unlock(); 140 rcu_read_unlock();
141} 141}
142 142
143static void multipath_unplug(request_queue_t *q) 143static void multipath_unplug(struct request_queue *q)
144{ 144{
145 unplug_slaves(q->queuedata); 145 unplug_slaves(q->queuedata);
146} 146}
147 147
148 148
149static int multipath_make_request (request_queue_t *q, struct bio * bio) 149static int multipath_make_request (struct request_queue *q, struct bio * bio)
150{ 150{
151 mddev_t *mddev = q->queuedata; 151 mddev_t *mddev = q->queuedata;
152 multipath_conf_t *conf = mddev_to_conf(mddev); 152 multipath_conf_t *conf = mddev_to_conf(mddev);
@@ -199,7 +199,7 @@ static void multipath_status (struct seq_file *seq, mddev_t *mddev)
199 seq_printf (seq, "]"); 199 seq_printf (seq, "]");
200} 200}
201 201
202static int multipath_issue_flush(request_queue_t *q, struct gendisk *disk, 202static int multipath_issue_flush(struct request_queue *q, struct gendisk *disk,
203 sector_t *error_sector) 203 sector_t *error_sector)
204{ 204{
205 mddev_t *mddev = q->queuedata; 205 mddev_t *mddev = q->queuedata;
@@ -211,7 +211,7 @@ static int multipath_issue_flush(request_queue_t *q, struct gendisk *disk,
211 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev); 211 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
212 if (rdev && !test_bit(Faulty, &rdev->flags)) { 212 if (rdev && !test_bit(Faulty, &rdev->flags)) {
213 struct block_device *bdev = rdev->bdev; 213 struct block_device *bdev = rdev->bdev;
214 request_queue_t *r_queue = bdev_get_queue(bdev); 214 struct request_queue *r_queue = bdev_get_queue(bdev);
215 215
216 if (!r_queue->issue_flush_fn) 216 if (!r_queue->issue_flush_fn)
217 ret = -EOPNOTSUPP; 217 ret = -EOPNOTSUPP;
@@ -238,7 +238,7 @@ static int multipath_congested(void *data, int bits)
238 for (i = 0; i < mddev->raid_disks ; i++) { 238 for (i = 0; i < mddev->raid_disks ; i++) {
239 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev); 239 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
240 if (rdev && !test_bit(Faulty, &rdev->flags)) { 240 if (rdev && !test_bit(Faulty, &rdev->flags)) {
241 request_queue_t *q = bdev_get_queue(rdev->bdev); 241 struct request_queue *q = bdev_get_queue(rdev->bdev);
242 242
243 ret |= bdi_congested(&q->backing_dev_info, bits); 243 ret |= bdi_congested(&q->backing_dev_info, bits);
244 /* Just like multipath_map, we just check the 244 /* Just like multipath_map, we just check the
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 2c404f73a377..b8216bc6db45 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -25,7 +25,7 @@
25#define MD_DRIVER 25#define MD_DRIVER
26#define MD_PERSONALITY 26#define MD_PERSONALITY
27 27
28static void raid0_unplug(request_queue_t *q) 28static void raid0_unplug(struct request_queue *q)
29{ 29{
30 mddev_t *mddev = q->queuedata; 30 mddev_t *mddev = q->queuedata;
31 raid0_conf_t *conf = mddev_to_conf(mddev); 31 raid0_conf_t *conf = mddev_to_conf(mddev);
@@ -33,14 +33,14 @@ static void raid0_unplug(request_queue_t *q)
33 int i; 33 int i;
34 34
35 for (i=0; i<mddev->raid_disks; i++) { 35 for (i=0; i<mddev->raid_disks; i++) {
36 request_queue_t *r_queue = bdev_get_queue(devlist[i]->bdev); 36 struct request_queue *r_queue = bdev_get_queue(devlist[i]->bdev);
37 37
38 if (r_queue->unplug_fn) 38 if (r_queue->unplug_fn)
39 r_queue->unplug_fn(r_queue); 39 r_queue->unplug_fn(r_queue);
40 } 40 }
41} 41}
42 42
43static int raid0_issue_flush(request_queue_t *q, struct gendisk *disk, 43static int raid0_issue_flush(struct request_queue *q, struct gendisk *disk,
44 sector_t *error_sector) 44 sector_t *error_sector)
45{ 45{
46 mddev_t *mddev = q->queuedata; 46 mddev_t *mddev = q->queuedata;
@@ -50,7 +50,7 @@ static int raid0_issue_flush(request_queue_t *q, struct gendisk *disk,
50 50
51 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 51 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
52 struct block_device *bdev = devlist[i]->bdev; 52 struct block_device *bdev = devlist[i]->bdev;
53 request_queue_t *r_queue = bdev_get_queue(bdev); 53 struct request_queue *r_queue = bdev_get_queue(bdev);
54 54
55 if (!r_queue->issue_flush_fn) 55 if (!r_queue->issue_flush_fn)
56 ret = -EOPNOTSUPP; 56 ret = -EOPNOTSUPP;
@@ -68,7 +68,7 @@ static int raid0_congested(void *data, int bits)
68 int i, ret = 0; 68 int i, ret = 0;
69 69
70 for (i = 0; i < mddev->raid_disks && !ret ; i++) { 70 for (i = 0; i < mddev->raid_disks && !ret ; i++) {
71 request_queue_t *q = bdev_get_queue(devlist[i]->bdev); 71 struct request_queue *q = bdev_get_queue(devlist[i]->bdev);
72 72
73 ret |= bdi_congested(&q->backing_dev_info, bits); 73 ret |= bdi_congested(&q->backing_dev_info, bits);
74 } 74 }
@@ -268,7 +268,7 @@ static int create_strip_zones (mddev_t *mddev)
268 * 268 *
269 * Return amount of bytes we can accept at this offset 269 * Return amount of bytes we can accept at this offset
270 */ 270 */
271static int raid0_mergeable_bvec(request_queue_t *q, struct bio *bio, struct bio_vec *biovec) 271static int raid0_mergeable_bvec(struct request_queue *q, struct bio *bio, struct bio_vec *biovec)
272{ 272{
273 mddev_t *mddev = q->queuedata; 273 mddev_t *mddev = q->queuedata;
274 sector_t sector = bio->bi_sector + get_start_sect(bio->bi_bdev); 274 sector_t sector = bio->bi_sector + get_start_sect(bio->bi_bdev);
@@ -408,7 +408,7 @@ static int raid0_stop (mddev_t *mddev)
408 return 0; 408 return 0;
409} 409}
410 410
411static int raid0_make_request (request_queue_t *q, struct bio *bio) 411static int raid0_make_request (struct request_queue *q, struct bio *bio)
412{ 412{
413 mddev_t *mddev = q->queuedata; 413 mddev_t *mddev = q->queuedata;
414 unsigned int sect_in_chunk, chunksize_bits, chunk_size, chunk_sects; 414 unsigned int sect_in_chunk, chunksize_bits, chunk_size, chunk_sects;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 00c78b77b13d..650991bddd8e 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -552,7 +552,7 @@ static void unplug_slaves(mddev_t *mddev)
552 for (i=0; i<mddev->raid_disks; i++) { 552 for (i=0; i<mddev->raid_disks; i++) {
553 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 553 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
554 if (rdev && !test_bit(Faulty, &rdev->flags) && atomic_read(&rdev->nr_pending)) { 554 if (rdev && !test_bit(Faulty, &rdev->flags) && atomic_read(&rdev->nr_pending)) {
555 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 555 struct request_queue *r_queue = bdev_get_queue(rdev->bdev);
556 556
557 atomic_inc(&rdev->nr_pending); 557 atomic_inc(&rdev->nr_pending);
558 rcu_read_unlock(); 558 rcu_read_unlock();
@@ -567,7 +567,7 @@ static void unplug_slaves(mddev_t *mddev)
567 rcu_read_unlock(); 567 rcu_read_unlock();
568} 568}
569 569
570static void raid1_unplug(request_queue_t *q) 570static void raid1_unplug(struct request_queue *q)
571{ 571{
572 mddev_t *mddev = q->queuedata; 572 mddev_t *mddev = q->queuedata;
573 573
@@ -575,7 +575,7 @@ static void raid1_unplug(request_queue_t *q)
575 md_wakeup_thread(mddev->thread); 575 md_wakeup_thread(mddev->thread);
576} 576}
577 577
578static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk, 578static int raid1_issue_flush(struct request_queue *q, struct gendisk *disk,
579 sector_t *error_sector) 579 sector_t *error_sector)
580{ 580{
581 mddev_t *mddev = q->queuedata; 581 mddev_t *mddev = q->queuedata;
@@ -587,7 +587,7 @@ static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk,
587 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 587 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
588 if (rdev && !test_bit(Faulty, &rdev->flags)) { 588 if (rdev && !test_bit(Faulty, &rdev->flags)) {
589 struct block_device *bdev = rdev->bdev; 589 struct block_device *bdev = rdev->bdev;
590 request_queue_t *r_queue = bdev_get_queue(bdev); 590 struct request_queue *r_queue = bdev_get_queue(bdev);
591 591
592 if (!r_queue->issue_flush_fn) 592 if (!r_queue->issue_flush_fn)
593 ret = -EOPNOTSUPP; 593 ret = -EOPNOTSUPP;
@@ -615,7 +615,7 @@ static int raid1_congested(void *data, int bits)
615 for (i = 0; i < mddev->raid_disks; i++) { 615 for (i = 0; i < mddev->raid_disks; i++) {
616 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 616 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
617 if (rdev && !test_bit(Faulty, &rdev->flags)) { 617 if (rdev && !test_bit(Faulty, &rdev->flags)) {
618 request_queue_t *q = bdev_get_queue(rdev->bdev); 618 struct request_queue *q = bdev_get_queue(rdev->bdev);
619 619
620 /* Note the '|| 1' - when read_balance prefers 620 /* Note the '|| 1' - when read_balance prefers
621 * non-congested targets, it can be removed 621 * non-congested targets, it can be removed
@@ -765,7 +765,7 @@ do_sync_io:
765 return NULL; 765 return NULL;
766} 766}
767 767
768static int make_request(request_queue_t *q, struct bio * bio) 768static int make_request(struct request_queue *q, struct bio * bio)
769{ 769{
770 mddev_t *mddev = q->queuedata; 770 mddev_t *mddev = q->queuedata;
771 conf_t *conf = mddev_to_conf(mddev); 771 conf_t *conf = mddev_to_conf(mddev);
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index a95ada1cfac4..4e53792aa520 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -453,7 +453,7 @@ static sector_t raid10_find_virt(conf_t *conf, sector_t sector, int dev)
453 * If near_copies == raid_disk, there are no striping issues, 453 * If near_copies == raid_disk, there are no striping issues,
454 * but in that case, the function isn't called at all. 454 * but in that case, the function isn't called at all.
455 */ 455 */
456static int raid10_mergeable_bvec(request_queue_t *q, struct bio *bio, 456static int raid10_mergeable_bvec(struct request_queue *q, struct bio *bio,
457 struct bio_vec *bio_vec) 457 struct bio_vec *bio_vec)
458{ 458{
459 mddev_t *mddev = q->queuedata; 459 mddev_t *mddev = q->queuedata;
@@ -595,7 +595,7 @@ static void unplug_slaves(mddev_t *mddev)
595 for (i=0; i<mddev->raid_disks; i++) { 595 for (i=0; i<mddev->raid_disks; i++) {
596 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 596 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
597 if (rdev && !test_bit(Faulty, &rdev->flags) && atomic_read(&rdev->nr_pending)) { 597 if (rdev && !test_bit(Faulty, &rdev->flags) && atomic_read(&rdev->nr_pending)) {
598 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 598 struct request_queue *r_queue = bdev_get_queue(rdev->bdev);
599 599
600 atomic_inc(&rdev->nr_pending); 600 atomic_inc(&rdev->nr_pending);
601 rcu_read_unlock(); 601 rcu_read_unlock();
@@ -610,7 +610,7 @@ static void unplug_slaves(mddev_t *mddev)
610 rcu_read_unlock(); 610 rcu_read_unlock();
611} 611}
612 612
613static void raid10_unplug(request_queue_t *q) 613static void raid10_unplug(struct request_queue *q)
614{ 614{
615 mddev_t *mddev = q->queuedata; 615 mddev_t *mddev = q->queuedata;
616 616
@@ -618,7 +618,7 @@ static void raid10_unplug(request_queue_t *q)
618 md_wakeup_thread(mddev->thread); 618 md_wakeup_thread(mddev->thread);
619} 619}
620 620
621static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk, 621static int raid10_issue_flush(struct request_queue *q, struct gendisk *disk,
622 sector_t *error_sector) 622 sector_t *error_sector)
623{ 623{
624 mddev_t *mddev = q->queuedata; 624 mddev_t *mddev = q->queuedata;
@@ -630,7 +630,7 @@ static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk,
630 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 630 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
631 if (rdev && !test_bit(Faulty, &rdev->flags)) { 631 if (rdev && !test_bit(Faulty, &rdev->flags)) {
632 struct block_device *bdev = rdev->bdev; 632 struct block_device *bdev = rdev->bdev;
633 request_queue_t *r_queue = bdev_get_queue(bdev); 633 struct request_queue *r_queue = bdev_get_queue(bdev);
634 634
635 if (!r_queue->issue_flush_fn) 635 if (!r_queue->issue_flush_fn)
636 ret = -EOPNOTSUPP; 636 ret = -EOPNOTSUPP;
@@ -658,7 +658,7 @@ static int raid10_congested(void *data, int bits)
658 for (i = 0; i < mddev->raid_disks && ret == 0; i++) { 658 for (i = 0; i < mddev->raid_disks && ret == 0; i++) {
659 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); 659 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
660 if (rdev && !test_bit(Faulty, &rdev->flags)) { 660 if (rdev && !test_bit(Faulty, &rdev->flags)) {
661 request_queue_t *q = bdev_get_queue(rdev->bdev); 661 struct request_queue *q = bdev_get_queue(rdev->bdev);
662 662
663 ret |= bdi_congested(&q->backing_dev_info, bits); 663 ret |= bdi_congested(&q->backing_dev_info, bits);
664 } 664 }
@@ -772,7 +772,7 @@ static void unfreeze_array(conf_t *conf)
772 spin_unlock_irq(&conf->resync_lock); 772 spin_unlock_irq(&conf->resync_lock);
773} 773}
774 774
775static int make_request(request_queue_t *q, struct bio * bio) 775static int make_request(struct request_queue *q, struct bio * bio)
776{ 776{
777 mddev_t *mddev = q->queuedata; 777 mddev_t *mddev = q->queuedata;
778 conf_t *conf = mddev_to_conf(mddev); 778 conf_t *conf = mddev_to_conf(mddev);
@@ -917,6 +917,13 @@ static int make_request(request_queue_t *q, struct bio * bio)
917 bio_list_add(&bl, mbio); 917 bio_list_add(&bl, mbio);
918 } 918 }
919 919
920 if (unlikely(!atomic_read(&r10_bio->remaining))) {
921 /* the array is dead */
922 md_write_end(mddev);
923 raid_end_bio_io(r10_bio);
924 return 0;
925 }
926
920 bitmap_startwrite(mddev->bitmap, bio->bi_sector, r10_bio->sectors, 0); 927 bitmap_startwrite(mddev->bitmap, bio->bi_sector, r10_bio->sectors, 0);
921 spin_lock_irqsave(&conf->device_lock, flags); 928 spin_lock_irqsave(&conf->device_lock, flags);
922 bio_list_merge(&conf->pending_bio_list, &bl); 929 bio_list_merge(&conf->pending_bio_list, &bl);
@@ -1557,7 +1564,6 @@ static void raid10d(mddev_t *mddev)
1557 bio = r10_bio->devs[r10_bio->read_slot].bio; 1564 bio = r10_bio->devs[r10_bio->read_slot].bio;
1558 r10_bio->devs[r10_bio->read_slot].bio = 1565 r10_bio->devs[r10_bio->read_slot].bio =
1559 mddev->ro ? IO_BLOCKED : NULL; 1566 mddev->ro ? IO_BLOCKED : NULL;
1560 bio_put(bio);
1561 mirror = read_balance(conf, r10_bio); 1567 mirror = read_balance(conf, r10_bio);
1562 if (mirror == -1) { 1568 if (mirror == -1) {
1563 printk(KERN_ALERT "raid10: %s: unrecoverable I/O" 1569 printk(KERN_ALERT "raid10: %s: unrecoverable I/O"
@@ -1565,8 +1571,10 @@ static void raid10d(mddev_t *mddev)
1565 bdevname(bio->bi_bdev,b), 1571 bdevname(bio->bi_bdev,b),
1566 (unsigned long long)r10_bio->sector); 1572 (unsigned long long)r10_bio->sector);
1567 raid_end_bio_io(r10_bio); 1573 raid_end_bio_io(r10_bio);
1574 bio_put(bio);
1568 } else { 1575 } else {
1569 const int do_sync = bio_sync(r10_bio->master_bio); 1576 const int do_sync = bio_sync(r10_bio->master_bio);
1577 bio_put(bio);
1570 rdev = conf->mirrors[mirror].rdev; 1578 rdev = conf->mirrors[mirror].rdev;
1571 if (printk_ratelimit()) 1579 if (printk_ratelimit())
1572 printk(KERN_ERR "raid10: %s: redirecting sector %llu to" 1580 printk(KERN_ERR "raid10: %s: redirecting sector %llu to"
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index d90ee145effe..2aff4be35dc4 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -289,7 +289,7 @@ static struct stripe_head *__find_stripe(raid5_conf_t *conf, sector_t sector, in
289} 289}
290 290
291static void unplug_slaves(mddev_t *mddev); 291static void unplug_slaves(mddev_t *mddev);
292static void raid5_unplug_device(request_queue_t *q); 292static void raid5_unplug_device(struct request_queue *q);
293 293
294static struct stripe_head *get_active_stripe(raid5_conf_t *conf, sector_t sector, int disks, 294static struct stripe_head *get_active_stripe(raid5_conf_t *conf, sector_t sector, int disks,
295 int pd_idx, int noblock) 295 int pd_idx, int noblock)
@@ -3182,7 +3182,7 @@ static void unplug_slaves(mddev_t *mddev)
3182 for (i=0; i<mddev->raid_disks; i++) { 3182 for (i=0; i<mddev->raid_disks; i++) {
3183 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev); 3183 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
3184 if (rdev && !test_bit(Faulty, &rdev->flags) && atomic_read(&rdev->nr_pending)) { 3184 if (rdev && !test_bit(Faulty, &rdev->flags) && atomic_read(&rdev->nr_pending)) {
3185 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 3185 struct request_queue *r_queue = bdev_get_queue(rdev->bdev);
3186 3186
3187 atomic_inc(&rdev->nr_pending); 3187 atomic_inc(&rdev->nr_pending);
3188 rcu_read_unlock(); 3188 rcu_read_unlock();
@@ -3197,7 +3197,7 @@ static void unplug_slaves(mddev_t *mddev)
3197 rcu_read_unlock(); 3197 rcu_read_unlock();
3198} 3198}
3199 3199
3200static void raid5_unplug_device(request_queue_t *q) 3200static void raid5_unplug_device(struct request_queue *q)
3201{ 3201{
3202 mddev_t *mddev = q->queuedata; 3202 mddev_t *mddev = q->queuedata;
3203 raid5_conf_t *conf = mddev_to_conf(mddev); 3203 raid5_conf_t *conf = mddev_to_conf(mddev);
@@ -3216,7 +3216,7 @@ static void raid5_unplug_device(request_queue_t *q)
3216 unplug_slaves(mddev); 3216 unplug_slaves(mddev);
3217} 3217}
3218 3218
3219static int raid5_issue_flush(request_queue_t *q, struct gendisk *disk, 3219static int raid5_issue_flush(struct request_queue *q, struct gendisk *disk,
3220 sector_t *error_sector) 3220 sector_t *error_sector)
3221{ 3221{
3222 mddev_t *mddev = q->queuedata; 3222 mddev_t *mddev = q->queuedata;
@@ -3228,7 +3228,7 @@ static int raid5_issue_flush(request_queue_t *q, struct gendisk *disk,
3228 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev); 3228 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
3229 if (rdev && !test_bit(Faulty, &rdev->flags)) { 3229 if (rdev && !test_bit(Faulty, &rdev->flags)) {
3230 struct block_device *bdev = rdev->bdev; 3230 struct block_device *bdev = rdev->bdev;
3231 request_queue_t *r_queue = bdev_get_queue(bdev); 3231 struct request_queue *r_queue = bdev_get_queue(bdev);
3232 3232
3233 if (!r_queue->issue_flush_fn) 3233 if (!r_queue->issue_flush_fn)
3234 ret = -EOPNOTSUPP; 3234 ret = -EOPNOTSUPP;
@@ -3267,7 +3267,7 @@ static int raid5_congested(void *data, int bits)
3267/* We want read requests to align with chunks where possible, 3267/* We want read requests to align with chunks where possible,
3268 * but write requests don't need to. 3268 * but write requests don't need to.
3269 */ 3269 */
3270static int raid5_mergeable_bvec(request_queue_t *q, struct bio *bio, struct bio_vec *biovec) 3270static int raid5_mergeable_bvec(struct request_queue *q, struct bio *bio, struct bio_vec *biovec)
3271{ 3271{
3272 mddev_t *mddev = q->queuedata; 3272 mddev_t *mddev = q->queuedata;
3273 sector_t sector = bio->bi_sector + get_start_sect(bio->bi_bdev); 3273 sector_t sector = bio->bi_sector + get_start_sect(bio->bi_bdev);
@@ -3377,7 +3377,7 @@ static int raid5_align_endio(struct bio *bi, unsigned int bytes, int error)
3377 3377
3378static int bio_fits_rdev(struct bio *bi) 3378static int bio_fits_rdev(struct bio *bi)
3379{ 3379{
3380 request_queue_t *q = bdev_get_queue(bi->bi_bdev); 3380 struct request_queue *q = bdev_get_queue(bi->bi_bdev);
3381 3381
3382 if ((bi->bi_size>>9) > q->max_sectors) 3382 if ((bi->bi_size>>9) > q->max_sectors)
3383 return 0; 3383 return 0;
@@ -3396,7 +3396,7 @@ static int bio_fits_rdev(struct bio *bi)
3396} 3396}
3397 3397
3398 3398
3399static int chunk_aligned_read(request_queue_t *q, struct bio * raid_bio) 3399static int chunk_aligned_read(struct request_queue *q, struct bio * raid_bio)
3400{ 3400{
3401 mddev_t *mddev = q->queuedata; 3401 mddev_t *mddev = q->queuedata;
3402 raid5_conf_t *conf = mddev_to_conf(mddev); 3402 raid5_conf_t *conf = mddev_to_conf(mddev);
@@ -3466,7 +3466,7 @@ static int chunk_aligned_read(request_queue_t *q, struct bio * raid_bio)
3466} 3466}
3467 3467
3468 3468
3469static int make_request(request_queue_t *q, struct bio * bi) 3469static int make_request(struct request_queue *q, struct bio * bi)
3470{ 3470{
3471 mddev_t *mddev = q->queuedata; 3471 mddev_t *mddev = q->queuedata;
3472 raid5_conf_t *conf = mddev_to_conf(mddev); 3472 raid5_conf_t *conf = mddev_to_conf(mddev);
diff --git a/drivers/media/dvb/dvb-usb/af9005-fe.c b/drivers/media/dvb/dvb-usb/af9005-fe.c
index 7195c9461524..b1a9c4cdec93 100644
--- a/drivers/media/dvb/dvb-usb/af9005-fe.c
+++ b/drivers/media/dvb/dvb-usb/af9005-fe.c
@@ -29,8 +29,6 @@
29 29
30struct af9005_fe_state { 30struct af9005_fe_state {
31 struct dvb_usb_device *d; 31 struct dvb_usb_device *d;
32 struct dvb_frontend *tuner;
33
34 fe_status_t stat; 32 fe_status_t stat;
35 33
36 /* retraining parameters */ 34 /* retraining parameters */
@@ -345,8 +343,8 @@ static int af9005_reset_pre_viterbi(struct dvb_frontend *fe)
345 1 & 0xff); 343 1 & 0xff);
346 if (ret) 344 if (ret)
347 return ret; 345 return ret;
348 af9005_write_ofdm_register(state->d, xd_p_fec_super_frm_unit_15_8, 346 ret = af9005_write_ofdm_register(state->d, xd_p_fec_super_frm_unit_15_8,
349 1 >> 8); 347 1 >> 8);
350 if (ret) 348 if (ret)
351 return ret; 349 return ret;
352 /* reset pre viterbi error count */ 350 /* reset pre viterbi error count */
@@ -447,7 +445,7 @@ static int af9005_fe_read_status(struct dvb_frontend *fe, fe_status_t * stat)
447 u8 temp; 445 u8 temp;
448 int ret; 446 int ret;
449 447
450 if (state->tuner == NULL) 448 if (fe->ops.tuner_ops.release == NULL)
451 return -ENODEV; 449 return -ENODEV;
452 450
453 *stat = 0; 451 *stat = 0;
@@ -493,7 +491,7 @@ static int af9005_fe_read_status(struct dvb_frontend *fe, fe_status_t * stat)
493static int af9005_fe_read_ber(struct dvb_frontend *fe, u32 * ber) 491static int af9005_fe_read_ber(struct dvb_frontend *fe, u32 * ber)
494{ 492{
495 struct af9005_fe_state *state = fe->demodulator_priv; 493 struct af9005_fe_state *state = fe->demodulator_priv;
496 if (state->tuner == NULL) 494 if (fe->ops.tuner_ops.release == NULL)
497 return -ENODEV; 495 return -ENODEV;
498 af9005_fe_refresh_state(fe); 496 af9005_fe_refresh_state(fe);
499 *ber = state->ber; 497 *ber = state->ber;
@@ -503,7 +501,7 @@ static int af9005_fe_read_ber(struct dvb_frontend *fe, u32 * ber)
503static int af9005_fe_read_unc_blocks(struct dvb_frontend *fe, u32 * unc) 501static int af9005_fe_read_unc_blocks(struct dvb_frontend *fe, u32 * unc)
504{ 502{
505 struct af9005_fe_state *state = fe->demodulator_priv; 503 struct af9005_fe_state *state = fe->demodulator_priv;
506 if (state->tuner == NULL) 504 if (fe->ops.tuner_ops.release == NULL)
507 return -ENODEV; 505 return -ENODEV;
508 af9005_fe_refresh_state(fe); 506 af9005_fe_refresh_state(fe);
509 *unc = state->unc; 507 *unc = state->unc;
@@ -517,7 +515,7 @@ static int af9005_fe_read_signal_strength(struct dvb_frontend *fe,
517 int ret; 515 int ret;
518 u8 if_gain, rf_gain; 516 u8 if_gain, rf_gain;
519 517
520 if (state->tuner == NULL) 518 if (fe->ops.tuner_ops.release == NULL)
521 return -ENODEV; 519 return -ENODEV;
522 ret = 520 ret =
523 af9005_read_ofdm_register(state->d, xd_r_reg_aagc_rf_gain, 521 af9005_read_ofdm_register(state->d, xd_r_reg_aagc_rf_gain,
@@ -881,10 +879,8 @@ static int af9005_fe_init(struct dvb_frontend *fe)
881 af9005_write_register_bits(state->d, xd_I2C_reg_ofdm_rst, 879 af9005_write_register_bits(state->d, xd_I2C_reg_ofdm_rst,
882 reg_ofdm_rst_pos, reg_ofdm_rst_len, 1))) 880 reg_ofdm_rst_pos, reg_ofdm_rst_len, 1)))
883 return ret; 881 return ret;
884 if ((ret = 882 ret = af9005_write_register_bits(state->d, xd_I2C_reg_ofdm_rst,
885 af9005_write_register_bits(state->d, xd_I2C_reg_ofdm_rst, 883 reg_ofdm_rst_pos, reg_ofdm_rst_len, 0);
886 reg_ofdm_rst_pos, reg_ofdm_rst_len, 0)))
887 return ret;
888 884
889 if (ret) 885 if (ret)
890 return ret; 886 return ret;
@@ -1041,7 +1037,7 @@ static int af9005_fe_init(struct dvb_frontend *fe)
1041 return ret; 1037 return ret;
1042 1038
1043 /* attach tuner and init */ 1039 /* attach tuner and init */
1044 if (state->tuner == NULL) { 1040 if (fe->ops.tuner_ops.release == NULL) {
1045 /* read tuner and board id from eeprom */ 1041 /* read tuner and board id from eeprom */
1046 ret = af9005_read_eeprom(adap->dev, 0xc6, buf, 2); 1042 ret = af9005_read_eeprom(adap->dev, 0xc6, buf, 2);
1047 if (ret) { 1043 if (ret) {
@@ -1058,20 +1054,16 @@ static int af9005_fe_init(struct dvb_frontend *fe)
1058 return ret; 1054 return ret;
1059 } 1055 }
1060 if1 = (u16) (buf[0] << 8) + buf[1]; 1056 if1 = (u16) (buf[0] << 8) + buf[1];
1061 state->tuner = 1057 if (dvb_attach(mt2060_attach, fe, &adap->dev->i2c_adap,
1062 dvb_attach(mt2060_attach, fe, &adap->dev->i2c_adap, 1058 &af9005_mt2060_config, if1) == NULL) {
1063 &af9005_mt2060_config, if1);
1064 if (state->tuner == NULL) {
1065 deb_info("MT2060 attach failed\n"); 1059 deb_info("MT2060 attach failed\n");
1066 return -ENODEV; 1060 return -ENODEV;
1067 } 1061 }
1068 break; 1062 break;
1069 case 3: /* QT1010 */ 1063 case 3: /* QT1010 */
1070 case 9: /* QT1010B */ 1064 case 9: /* QT1010B */
1071 state->tuner = 1065 if (dvb_attach(qt1010_attach, fe, &adap->dev->i2c_adap,
1072 dvb_attach(qt1010_attach, fe, &adap->dev->i2c_adap, 1066 &af9005_qt1010_config) ==NULL) {
1073 &af9005_qt1010_config);
1074 if (state->tuner == NULL) {
1075 deb_info("QT1010 attach failed\n"); 1067 deb_info("QT1010 attach failed\n");
1076 return -ENODEV; 1068 return -ENODEV;
1077 } 1069 }
@@ -1080,7 +1072,7 @@ static int af9005_fe_init(struct dvb_frontend *fe)
1080 err("Unsupported tuner type %d", buf[0]); 1072 err("Unsupported tuner type %d", buf[0]);
1081 return -ENODEV; 1073 return -ENODEV;
1082 } 1074 }
1083 ret = state->tuner->ops.tuner_ops.init(state->tuner); 1075 ret = fe->ops.tuner_ops.init(fe);
1084 if (ret) 1076 if (ret)
1085 return ret; 1077 return ret;
1086 } 1078 }
@@ -1118,7 +1110,7 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe,
1118 1110
1119 deb_info("af9005_fe_set_frontend freq %d bw %d\n", fep->frequency, 1111 deb_info("af9005_fe_set_frontend freq %d bw %d\n", fep->frequency,
1120 fep->u.ofdm.bandwidth); 1112 fep->u.ofdm.bandwidth);
1121 if (state->tuner == NULL) { 1113 if (fe->ops.tuner_ops.release == NULL) {
1122 err("Tuner not attached"); 1114 err("Tuner not attached");
1123 return -ENODEV; 1115 return -ENODEV;
1124 } 1116 }
@@ -1199,7 +1191,7 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe,
1199 return ret; 1191 return ret;
1200 /* set tuner */ 1192 /* set tuner */
1201 deb_info("set tuner\n"); 1193 deb_info("set tuner\n");
1202 ret = state->tuner->ops.tuner_ops.set_params(state->tuner, fep); 1194 ret = fe->ops.tuner_ops.set_params(fe, fep);
1203 if (ret) 1195 if (ret)
1204 return ret; 1196 return ret;
1205 1197
@@ -1435,12 +1427,6 @@ static void af9005_fe_release(struct dvb_frontend *fe)
1435{ 1427{
1436 struct af9005_fe_state *state = 1428 struct af9005_fe_state *state =
1437 (struct af9005_fe_state *)fe->demodulator_priv; 1429 (struct af9005_fe_state *)fe->demodulator_priv;
1438 if (state->tuner != NULL && state->tuner->ops.tuner_ops.release != NULL) {
1439 state->tuner->ops.tuner_ops.release(state->tuner);
1440#ifdef CONFIG_DVB_CORE_ATTACH
1441 symbol_put_addr(state->tuner->ops.tuner_ops.release);
1442#endif
1443 }
1444 kfree(state); 1430 kfree(state);
1445} 1431}
1446 1432
@@ -1458,7 +1444,6 @@ struct dvb_frontend *af9005_fe_attach(struct dvb_usb_device *d)
1458 deb_info("attaching frontend af9005\n"); 1444 deb_info("attaching frontend af9005\n");
1459 1445
1460 state->d = d; 1446 state->d = d;
1461 state->tuner = NULL;
1462 state->opened = 0; 1447 state->opened = 0;
1463 1448
1464 memcpy(&state->frontend.ops, &af9005_fe_ops, 1449 memcpy(&state->frontend.ops, &af9005_fe_ops,
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index 0c0b94767bc1..ca99e439c97c 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -501,7 +501,7 @@ static struct dvb_pll_desc dvb_pll_opera1 = {
501 501
502/* Philips FCV1236D 502/* Philips FCV1236D
503 */ 503 */
504struct dvb_pll_desc dvb_pll_fcv1236d = { 504static struct dvb_pll_desc dvb_pll_fcv1236d = {
505/* Bit_0: RF Input select 505/* Bit_0: RF Input select
506 * Bit_1: 0=digital, 1=analog 506 * Bit_1: 0=digital, 1=analog
507 */ 507 */
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 9dcbffd0aa15..e204e7b4028a 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -509,7 +509,7 @@ config VIDEO_VINO
509 509
510config VIDEO_STRADIS 510config VIDEO_STRADIS
511 tristate "Stradis 4:2:2 MPEG-2 video driver (EXPERIMENTAL)" 511 tristate "Stradis 4:2:2 MPEG-2 video driver (EXPERIMENTAL)"
512 depends on EXPERIMENTAL && PCI && VIDEO_V4L1 && !PPC64 512 depends on EXPERIMENTAL && PCI && VIDEO_V4L1 && VIRT_TO_BUS
513 help 513 help
514 Say Y here to enable support for the Stradis 4:2:2 MPEG-2 video 514 Say Y here to enable support for the Stradis 4:2:2 MPEG-2 video
515 driver for PCI. There is a product page at 515 driver for PCI. There is a product page at
@@ -520,7 +520,7 @@ config VIDEO_ZORAN_ZR36060
520 520
521config VIDEO_ZORAN 521config VIDEO_ZORAN
522 tristate "Zoran ZR36057/36067 Video For Linux" 522 tristate "Zoran ZR36057/36067 Video For Linux"
523 depends on PCI && I2C_ALGOBIT && VIDEO_V4L1 && !PPC64 523 depends on PCI && I2C_ALGOBIT && VIDEO_V4L1 && VIRT_TO_BUS
524 help 524 help
525 Say Y for support for MJPEG capture cards based on the Zoran 525 Say Y for support for MJPEG capture cards based on the Zoran
526 36057/36067 PCI controller chipset. This includes the Iomega 526 36057/36067 PCI controller chipset. This includes the Iomega
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index 387cb2122d4f..f6715007d409 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -33,6 +33,7 @@
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/firmware.h> 35#include <linux/firmware.h>
36#include <net/checksum.h>
36 37
37#include <asm/io.h> 38#include <asm/io.h>
38 39
@@ -45,7 +46,7 @@ static void boot_msp34xx(struct bttv *btv, int pin);
45static void boot_bt832(struct bttv *btv); 46static void boot_bt832(struct bttv *btv);
46static void hauppauge_eeprom(struct bttv *btv); 47static void hauppauge_eeprom(struct bttv *btv);
47static void avermedia_eeprom(struct bttv *btv); 48static void avermedia_eeprom(struct bttv *btv);
48static void osprey_eeprom(struct bttv *btv); 49static void osprey_eeprom(struct bttv *btv, const u8 ee[256]);
49static void modtec_eeprom(struct bttv *btv); 50static void modtec_eeprom(struct bttv *btv);
50static void init_PXC200(struct bttv *btv); 51static void init_PXC200(struct bttv *btv);
51static void init_RTV24(struct bttv *btv); 52static void init_RTV24(struct bttv *btv);
@@ -2843,13 +2844,28 @@ struct tvcard bttv_tvcards[] = {
2843 .has_remote = 1, 2844 .has_remote = 1,
2844 }, 2845 },
2845 /* ---- card 0x8c ---------------------------------- */ 2846 /* ---- card 0x8c ---------------------------------- */
2847 /* Has four Bt878 chips behind a PCI bridge, each chip has:
2848 one external BNC composite input (mux 2)
2849 three internal composite inputs (unknown muxes)
2850 an 18-bit stereo A/D (CS5331A), which has:
2851 one external stereo unblanced (RCA) audio connection
2852 one (or 3?) internal stereo balanced (XLR) audio connection
2853 input is selected via gpio to a 14052B mux
2854 (mask=0x300, unbal=0x000, bal=0x100, ??=0x200,0x300)
2855 gain is controlled via an X9221A chip on the I2C bus @0x28
2856 sample rate is controlled via gpio to an MK1413S
2857 (mask=0x3, 32kHz=0x0, 44.1kHz=0x1, 48kHz=0x2, ??=0x3)
2858 There is neither a tuner nor an svideo input. */
2846 [BTTV_BOARD_OSPREY440] = { 2859 [BTTV_BOARD_OSPREY440] = {
2847 .name = "Osprey 440", 2860 .name = "Osprey 440",
2848 .video_inputs = 1, 2861 .video_inputs = 4,
2849 .audio_inputs = 1, 2862 .audio_inputs = 2, /* this is meaningless */
2850 .tuner = UNSET, 2863 .tuner = UNSET,
2851 .svhs = 1, 2864 .svhs = UNSET,
2852 .muxsel = { 2 }, 2865 .muxsel = { 2, 3, 0, 1 }, /* 3,0,1 are guesses */
2866 .gpiomask = 0x303,
2867 .gpiomute = 0x000, /* int + 32kHz */
2868 .gpiomux = { 0, 0, 0x000, 0x100},
2853 .pll = PLL_28, 2869 .pll = PLL_28,
2854 .tuner_type = UNSET, 2870 .tuner_type = UNSET,
2855 .tuner_addr = ADDR_UNSET, 2871 .tuner_addr = ADDR_UNSET,
@@ -3453,11 +3469,12 @@ void __devinit bttv_init_card2(struct bttv *btv)
3453 case BTTV_BOARD_OSPREY2xx: 3469 case BTTV_BOARD_OSPREY2xx:
3454 case BTTV_BOARD_OSPREY2x0_SVID: 3470 case BTTV_BOARD_OSPREY2x0_SVID:
3455 case BTTV_BOARD_OSPREY2x0: 3471 case BTTV_BOARD_OSPREY2x0:
3472 case BTTV_BOARD_OSPREY440:
3456 case BTTV_BOARD_OSPREY500: 3473 case BTTV_BOARD_OSPREY500:
3457 case BTTV_BOARD_OSPREY540: 3474 case BTTV_BOARD_OSPREY540:
3458 case BTTV_BOARD_OSPREY2000: 3475 case BTTV_BOARD_OSPREY2000:
3459 bttv_readee(btv,eeprom_data,0xa0); 3476 bttv_readee(btv,eeprom_data,0xa0);
3460 osprey_eeprom(btv); 3477 osprey_eeprom(btv, eeprom_data);
3461 break; 3478 break;
3462 case BTTV_BOARD_IDS_EAGLE: 3479 case BTTV_BOARD_IDS_EAGLE:
3463 init_ids_eagle(btv); 3480 init_ids_eagle(btv);
@@ -3748,106 +3765,119 @@ static int __devinit pvr_boot(struct bttv *btv)
3748/* ----------------------------------------------------------------------- */ 3765/* ----------------------------------------------------------------------- */
3749/* some osprey specific stuff */ 3766/* some osprey specific stuff */
3750 3767
3751static void __devinit osprey_eeprom(struct bttv *btv) 3768static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256])
3752{ 3769{
3753 int i = 0; 3770 int i;
3754 unsigned char *ee = eeprom_data; 3771 u32 serial = 0;
3755 unsigned long serial = 0; 3772 int cardid = -1;
3756 3773
3757 if (btv->c.type == 0) { 3774 /* This code will nevery actually get called in this case.... */
3758 /* this might be an antique... check for MMAC label in eeprom */ 3775 if (btv->c.type == BTTV_BOARD_UNKNOWN) {
3759 if ((ee[0]=='M') && (ee[1]=='M') && (ee[2]=='A') && (ee[3]=='C')) { 3776 /* this might be an antique... check for MMAC label in eeprom */
3760 unsigned char checksum = 0; 3777 if (!strncmp(ee, "MMAC", 4)) {
3761 for (i = 0; i < 21; i++) 3778 u8 checksum = 0;
3762 checksum += ee[i]; 3779 for (i = 0; i < 21; i++)
3763 if (checksum != ee[21]) 3780 checksum += ee[i];
3764 return; 3781 if (checksum != ee[21])
3765 btv->c.type = BTTV_BOARD_OSPREY1x0_848; 3782 return;
3766 for (i = 12; i < 21; i++) 3783 cardid = BTTV_BOARD_OSPREY1x0_848;
3767 serial *= 10, serial += ee[i] - '0'; 3784 for (i = 12; i < 21; i++)
3768 } 3785 serial *= 10, serial += ee[i] - '0';
3786 }
3769 } else { 3787 } else {
3770 unsigned short type; 3788 unsigned short type;
3771 int offset = 4*16; 3789
3772 3790 for (i = 4*16; i < 8*16; i += 16) {
3773 for (; offset < 8*16; offset += 16) { 3791 u16 checksum = ip_compute_csum(ee + i, 16);
3774 unsigned short checksum = 0; 3792
3775 /* verify the checksum */ 3793 if ((checksum&0xff) + (checksum>>8) == 0xff)
3776 for (i = 0; i < 14; i++) 3794 break;
3777 checksum += ee[i+offset]; 3795 }
3778 checksum = ~checksum; /* no idea why */ 3796 if (i >= 8*16)
3779 if ((((checksum>>8)&0x0FF) == ee[offset+14]) && 3797 return;
3780 ((checksum & 0x0FF) == ee[offset+15])) { 3798 ee += i;
3781 break; 3799
3782 } 3800 /* found a valid descriptor */
3783 } 3801 type = be16_to_cpup((u16*)(ee+4));
3784 3802
3785 if (offset >= 8*16) 3803 switch(type) {
3786 return; 3804 /* 848 based */
3787 3805 case 0x0004:
3788 /* found a valid descriptor */ 3806 cardid = BTTV_BOARD_OSPREY1x0_848;
3789 type = (ee[offset+4]<<8) | (ee[offset+5]); 3807 break;
3790 3808 case 0x0005:
3791 switch(type) { 3809 cardid = BTTV_BOARD_OSPREY101_848;
3792 /* 848 based */ 3810 break;
3793 case 0x0004: 3811
3794 btv->c.type = BTTV_BOARD_OSPREY1x0_848; 3812 /* 878 based */
3795 break; 3813 case 0x0012:
3796 case 0x0005: 3814 case 0x0013:
3797 btv->c.type = BTTV_BOARD_OSPREY101_848; 3815 cardid = BTTV_BOARD_OSPREY1x0;
3798 break; 3816 break;
3799 3817 case 0x0014:
3800 /* 878 based */ 3818 case 0x0015:
3801 case 0x0012: 3819 cardid = BTTV_BOARD_OSPREY1x1;
3802 case 0x0013: 3820 break;
3803 btv->c.type = BTTV_BOARD_OSPREY1x0; 3821 case 0x0016:
3804 break; 3822 case 0x0017:
3805 case 0x0014: 3823 case 0x0020:
3806 case 0x0015: 3824 cardid = BTTV_BOARD_OSPREY1x1_SVID;
3807 btv->c.type = BTTV_BOARD_OSPREY1x1; 3825 break;
3808 break; 3826 case 0x0018:
3809 case 0x0016: 3827 case 0x0019:
3810 case 0x0017: 3828 case 0x001E:
3811 case 0x0020: 3829 case 0x001F:
3812 btv->c.type = BTTV_BOARD_OSPREY1x1_SVID; 3830 cardid = BTTV_BOARD_OSPREY2xx;
3813 break; 3831 break;
3814 case 0x0018: 3832 case 0x001A:
3815 case 0x0019: 3833 case 0x001B:
3816 case 0x001E: 3834 cardid = BTTV_BOARD_OSPREY2x0_SVID;
3817 case 0x001F: 3835 break;
3818 btv->c.type = BTTV_BOARD_OSPREY2xx; 3836 case 0x0040:
3819 break; 3837 cardid = BTTV_BOARD_OSPREY500;
3820 case 0x001A: 3838 break;
3821 case 0x001B: 3839 case 0x0050:
3822 btv->c.type = BTTV_BOARD_OSPREY2x0_SVID; 3840 case 0x0056:
3823 break; 3841 cardid = BTTV_BOARD_OSPREY540;
3824 case 0x0040: 3842 /* bttv_osprey_540_init(btv); */
3825 btv->c.type = BTTV_BOARD_OSPREY500; 3843 break;
3826 break; 3844 case 0x0060:
3827 case 0x0050: 3845 case 0x0070:
3828 case 0x0056: 3846 case 0x00A0:
3829 btv->c.type = BTTV_BOARD_OSPREY540; 3847 cardid = BTTV_BOARD_OSPREY2x0;
3830 /* bttv_osprey_540_init(btv); */ 3848 /* enable output on select control lines */
3831 break; 3849 gpio_inout(0xffffff,0x000303);
3832 case 0x0060: 3850 break;
3833 case 0x0070: 3851 case 0x00D8:
3834 case 0x00A0: 3852 cardid = BTTV_BOARD_OSPREY440;
3835 btv->c.type = BTTV_BOARD_OSPREY2x0; 3853 break;
3836 /* enable output on select control lines */ 3854 default:
3837 gpio_inout(0xffffff,0x000303); 3855 /* unknown...leave generic, but get serial # */
3838 break; 3856 printk(KERN_INFO "bttv%d: "
3839 default: 3857 "osprey eeprom: unknown card type 0x%04x\n",
3840 /* unknown...leave generic, but get serial # */ 3858 btv->c.nr, type);
3841 break; 3859 break;
3842 } 3860 }
3843 serial = (ee[offset+6] << 24) 3861 serial = be32_to_cpup((u32*)(ee+6));
3844 | (ee[offset+7] << 16) 3862 }
3845 | (ee[offset+8] << 8) 3863
3846 | (ee[offset+9]); 3864 printk(KERN_INFO "bttv%d: osprey eeprom: card=%d '%s' serial=%u\n",
3847 } 3865 btv->c.nr, cardid,
3848 3866 cardid>0 ? bttv_tvcards[cardid].name : "Unknown", serial);
3849 printk(KERN_INFO "bttv%d: osprey eeprom: card=%d name=%s serial=%ld\n", 3867
3850 btv->c.nr, btv->c.type, bttv_tvcards[btv->c.type].name,serial); 3868 if (cardid<0 || btv->c.type == cardid)
3869 return;
3870
3871 /* card type isn't set correctly */
3872 if (card[btv->c.nr] < bttv_num_tvcards) {
3873 printk(KERN_WARNING "bttv%d: osprey eeprom: "
3874 "Not overriding user specified card type\n", btv->c.nr);
3875 } else {
3876 printk(KERN_INFO "bttv%d: osprey eeprom: "
3877 "Changing card type from %d to %d\n", btv->c.nr,
3878 btv->c.type, cardid);
3879 btv->c.type = cardid;
3880 }
3851} 3881}
3852 3882
3853/* ----------------------------------------------------------------------- */ 3883/* ----------------------------------------------------------------------- */
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index 91b588d261ae..8abb34a35816 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -417,6 +417,7 @@ struct ivtv_mailbox_data {
417#define IVTV_F_I_WORK_HANDLER_YUV 17 /* there is work to be done for YUV */ 417#define IVTV_F_I_WORK_HANDLER_YUV 17 /* there is work to be done for YUV */
418#define IVTV_F_I_WORK_HANDLER_PIO 18 /* there is work to be done for PIO */ 418#define IVTV_F_I_WORK_HANDLER_PIO 18 /* there is work to be done for PIO */
419#define IVTV_F_I_PIO 19 /* PIO in progress */ 419#define IVTV_F_I_PIO 19 /* PIO in progress */
420#define IVTV_F_I_DEC_PAUSED 20 /* the decoder is paused */
420 421
421/* Event notifications */ 422/* Event notifications */
422#define IVTV_F_I_EV_DEC_STOPPED 28 /* decoder stopped event */ 423#define IVTV_F_I_EV_DEC_STOPPED 28 /* decoder stopped event */
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 8e97a938398f..5dd519caf81d 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -757,6 +757,7 @@ static void ivtv_stop_decoding(struct ivtv_open_id *id, int flags, u64 pts)
757 itv->output_mode = OUT_NONE; 757 itv->output_mode = OUT_NONE;
758 758
759 itv->speed = 0; 759 itv->speed = 0;
760 clear_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags);
760 ivtv_release_stream(s); 761 ivtv_release_stream(s);
761} 762}
762 763
@@ -799,7 +800,16 @@ int ivtv_v4l2_close(struct inode *inode, struct file *filp)
799 ivtv_unmute(itv); 800 ivtv_unmute(itv);
800 ivtv_release_stream(s); 801 ivtv_release_stream(s);
801 } else if (s->type >= IVTV_DEC_STREAM_TYPE_MPG) { 802 } else if (s->type >= IVTV_DEC_STREAM_TYPE_MPG) {
803 struct ivtv_stream *s_vout = &itv->streams[IVTV_DEC_STREAM_TYPE_VOUT];
804
802 ivtv_stop_decoding(id, VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY, 0); 805 ivtv_stop_decoding(id, VIDEO_CMD_STOP_TO_BLACK | VIDEO_CMD_STOP_IMMEDIATELY, 0);
806
807 /* If all output streams are closed, and if the user doesn't have
808 IVTV_DEC_STREAM_TYPE_VOUT open, then disable VBI on TV-out. */
809 if (itv->output_mode == OUT_NONE && !test_bit(IVTV_F_S_APPL_IO, &s_vout->s_flags)) {
810 /* disable VBI on TV-out */
811 ivtv_disable_vbi(itv);
812 }
803 } else { 813 } else {
804 ivtv_stop_capture(id, 0); 814 ivtv_stop_capture(id, 0);
805 } 815 }
diff --git a/drivers/media/video/ivtv/ivtv-firmware.c b/drivers/media/video/ivtv/ivtv-firmware.c
index d0feabf93080..425eb1063904 100644
--- a/drivers/media/video/ivtv/ivtv-firmware.c
+++ b/drivers/media/video/ivtv/ivtv-firmware.c
@@ -72,8 +72,8 @@ retry:
72 dst++; 72 dst++;
73 src++; 73 src++;
74 } 74 }
75 release_firmware(fw);
76 IVTV_INFO("Loaded %s firmware (%zd bytes)\n", fn, fw->size); 75 IVTV_INFO("Loaded %s firmware (%zd bytes)\n", fn, fw->size);
76 release_firmware(fw);
77 return size; 77 return size;
78 } 78 }
79 IVTV_ERR("Unable to open firmware %s (must be %ld bytes)\n", fn, size); 79 IVTV_ERR("Unable to open firmware %s (must be %ld bytes)\n", fn, size);
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index 4773453e8dab..047624b9e271 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -285,6 +285,10 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id,
285 285
286 if (ivtv_set_output_mode(itv, OUT_MPG) != OUT_MPG) 286 if (ivtv_set_output_mode(itv, OUT_MPG) != OUT_MPG)
287 return -EBUSY; 287 return -EBUSY;
288 if (test_and_clear_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags)) {
289 /* forces ivtv_set_speed to be called */
290 itv->speed = 0;
291 }
288 return ivtv_start_decoding(id, vc->play.speed); 292 return ivtv_start_decoding(id, vc->play.speed);
289 } 293 }
290 294
@@ -309,6 +313,7 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id,
309 if (atomic_read(&itv->decoding) > 0) { 313 if (atomic_read(&itv->decoding) > 0) {
310 ivtv_vapi(itv, CX2341X_DEC_PAUSE_PLAYBACK, 1, 314 ivtv_vapi(itv, CX2341X_DEC_PAUSE_PLAYBACK, 1,
311 (vc->flags & VIDEO_CMD_FREEZE_TO_BLACK) ? 1 : 0); 315 (vc->flags & VIDEO_CMD_FREEZE_TO_BLACK) ? 1 : 0);
316 set_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags);
312 } 317 }
313 break; 318 break;
314 319
@@ -317,8 +322,10 @@ static int ivtv_video_command(struct ivtv *itv, struct ivtv_open_id *id,
317 if (try) break; 322 if (try) break;
318 if (itv->output_mode != OUT_MPG) 323 if (itv->output_mode != OUT_MPG)
319 return -EBUSY; 324 return -EBUSY;
320 if (atomic_read(&itv->decoding) > 0) { 325 if (test_and_clear_bit(IVTV_F_I_DEC_PAUSED, &itv->i_flags)) {
321 ivtv_vapi(itv, CX2341X_DEC_START_PLAYBACK, 2, 0, 0); 326 int speed = itv->speed;
327 itv->speed = 0;
328 return ivtv_start_decoding(id, speed);
322 } 329 }
323 break; 330 break;
324 331
diff --git a/drivers/media/video/ivtv/ivtv-mailbox.c b/drivers/media/video/ivtv/ivtv-mailbox.c
index 814a673712b3..5e3b679202ae 100644
--- a/drivers/media/video/ivtv/ivtv-mailbox.c
+++ b/drivers/media/video/ivtv/ivtv-mailbox.c
@@ -40,6 +40,7 @@
40#define API_HIGH_VOL (1 << 5) /* High volume command (i.e. called during encoding or decoding) */ 40#define API_HIGH_VOL (1 << 5) /* High volume command (i.e. called during encoding or decoding) */
41#define API_NO_WAIT_MB (1 << 4) /* Command may not wait for a free mailbox */ 41#define API_NO_WAIT_MB (1 << 4) /* Command may not wait for a free mailbox */
42#define API_NO_WAIT_RES (1 << 5) /* Command may not wait for the result */ 42#define API_NO_WAIT_RES (1 << 5) /* Command may not wait for the result */
43#define API_NO_POLL (1 << 6) /* Avoid pointless polling */
43 44
44struct ivtv_api_info { 45struct ivtv_api_info {
45 int flags; /* Flags, see above */ 46 int flags; /* Flags, see above */
@@ -51,7 +52,7 @@ struct ivtv_api_info {
51static const struct ivtv_api_info api_info[256] = { 52static const struct ivtv_api_info api_info[256] = {
52 /* MPEG encoder API */ 53 /* MPEG encoder API */
53 API_ENTRY(CX2341X_ENC_PING_FW, API_FAST_RESULT), 54 API_ENTRY(CX2341X_ENC_PING_FW, API_FAST_RESULT),
54 API_ENTRY(CX2341X_ENC_START_CAPTURE, API_RESULT), 55 API_ENTRY(CX2341X_ENC_START_CAPTURE, API_RESULT | API_NO_POLL),
55 API_ENTRY(CX2341X_ENC_STOP_CAPTURE, API_RESULT), 56 API_ENTRY(CX2341X_ENC_STOP_CAPTURE, API_RESULT),
56 API_ENTRY(CX2341X_ENC_SET_AUDIO_ID, API_CACHE), 57 API_ENTRY(CX2341X_ENC_SET_AUDIO_ID, API_CACHE),
57 API_ENTRY(CX2341X_ENC_SET_VIDEO_ID, API_CACHE), 58 API_ENTRY(CX2341X_ENC_SET_VIDEO_ID, API_CACHE),
@@ -96,7 +97,7 @@ static const struct ivtv_api_info api_info[256] = {
96 97
97 /* MPEG decoder API */ 98 /* MPEG decoder API */
98 API_ENTRY(CX2341X_DEC_PING_FW, API_FAST_RESULT), 99 API_ENTRY(CX2341X_DEC_PING_FW, API_FAST_RESULT),
99 API_ENTRY(CX2341X_DEC_START_PLAYBACK, API_RESULT), 100 API_ENTRY(CX2341X_DEC_START_PLAYBACK, API_RESULT | API_NO_POLL),
100 API_ENTRY(CX2341X_DEC_STOP_PLAYBACK, API_RESULT), 101 API_ENTRY(CX2341X_DEC_STOP_PLAYBACK, API_RESULT),
101 API_ENTRY(CX2341X_DEC_SET_PLAYBACK_SPEED, API_RESULT), 102 API_ENTRY(CX2341X_DEC_SET_PLAYBACK_SPEED, API_RESULT),
102 API_ENTRY(CX2341X_DEC_STEP_VIDEO, API_RESULT), 103 API_ENTRY(CX2341X_DEC_STEP_VIDEO, API_RESULT),
@@ -290,6 +291,13 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
290 /* Get results */ 291 /* Get results */
291 then = jiffies; 292 then = jiffies;
292 293
294 if (!(flags & API_NO_POLL)) {
295 /* First try to poll, then switch to delays */
296 for (i = 0; i < 100; i++) {
297 if (readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE)
298 break;
299 }
300 }
293 while (!(readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE)) { 301 while (!(readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE)) {
294 if (jiffies - then > api_timeout) { 302 if (jiffies - then > api_timeout) {
295 IVTV_DEBUG_WARN("Could not get result (%s)\n", api_info[cmd].name); 303 IVTV_DEBUG_WARN("Could not get result (%s)\n", api_info[cmd].name);
@@ -301,7 +309,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[])
301 if (flags & API_NO_WAIT_RES) 309 if (flags & API_NO_WAIT_RES)
302 mdelay(1); 310 mdelay(1);
303 else 311 else
304 ivtv_msleep_timeout(10, 0); 312 ivtv_msleep_timeout(1, 0);
305 } 313 }
306 if (jiffies - then > msecs_to_jiffies(100)) 314 if (jiffies - then > msecs_to_jiffies(100))
307 IVTV_DEBUG_WARN("%s took %u jiffies\n", 315 IVTV_DEBUG_WARN("%s took %u jiffies\n",
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 322b347b67c2..51df3f855031 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -603,10 +603,6 @@ static int ivtv_setup_v4l2_decode_stream(struct ivtv_stream *s)
603 603
604 IVTV_DEBUG_INFO("Setting some initial decoder settings\n"); 604 IVTV_DEBUG_INFO("Setting some initial decoder settings\n");
605 605
606 /* disable VBI signals, if the MPEG stream contains VBI data,
607 then that data will be processed automatically for you. */
608 ivtv_disable_vbi(itv);
609
610 /* set audio mode to left/stereo for dual/stereo mode. */ 606 /* set audio mode to left/stereo for dual/stereo mode. */
611 ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode); 607 ivtv_vapi(itv, CX2341X_DEC_SET_AUDIO_MODE, 2, itv->audio_bilingual_mode, itv->audio_stereo_mode);
612 608
@@ -639,7 +635,7 @@ static int ivtv_setup_v4l2_decode_stream(struct ivtv_stream *s)
639 } 635 }
640 if (ivtv_vapi(itv, CX2341X_DEC_SET_DECODER_SOURCE, 4, datatype, 636 if (ivtv_vapi(itv, CX2341X_DEC_SET_DECODER_SOURCE, 4, datatype,
641 itv->params.width, itv->params.height, itv->params.audio_properties)) { 637 itv->params.width, itv->params.height, itv->params.audio_properties)) {
642 IVTV_DEBUG_WARN("COULDN'T INITIALIZE DECODER SOURCE\n"); 638 IVTV_DEBUG_WARN("Couldn't initialize decoder source\n");
643 } 639 }
644 return 0; 640 return 0;
645} 641}
@@ -909,11 +905,6 @@ int ivtv_stop_v4l2_decode_stream(struct ivtv_stream *s, int flags, u64 pts)
909 clear_bit(IVTV_F_S_STREAMING, &s->s_flags); 905 clear_bit(IVTV_F_S_STREAMING, &s->s_flags);
910 ivtv_flush_queues(s); 906 ivtv_flush_queues(s);
911 907
912 if (!test_bit(IVTV_F_S_PASSTHROUGH, &s->s_flags)) {
913 /* disable VBI on TV-out */
914 ivtv_disable_vbi(itv);
915 }
916
917 /* decrement decoding */ 908 /* decrement decoding */
918 atomic_dec(&itv->decoding); 909 atomic_dec(&itv->decoding);
919 910
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 868b6886fe7f..e3371f972240 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -517,6 +517,7 @@ static int vidioc_g_register (struct file *file, void *priv,
517 __FUNCTION__, errCode); 517 __FUNCTION__, errCode);
518 return errCode; 518 return errCode;
519 } 519 }
520 reg->val = errCode;
520 return 0; 521 return 0;
521} 522}
522 523
@@ -531,8 +532,8 @@ static int vidioc_s_register (struct file *file, void *priv,
531 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip)) 532 if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
532 return -EINVAL; 533 return -EINVAL;
533 /* NT100x has a 8-bit register space */ 534 /* NT100x has a 8-bit register space */
534 reg->val = (u8)usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); 535 errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val);
535 if (reg->val < 0) { 536 if (errCode < 0) {
536 err("%s: VIDIOC_DBG_S_REGISTER failed: error %d", 537 err("%s: VIDIOC_DBG_S_REGISTER failed: error %d",
537 __FUNCTION__, errCode); 538 __FUNCTION__, errCode);
538 return errCode; 539 return errCode;
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
index 8fb4a3414e0a..937c4a616c0e 100644
--- a/drivers/media/video/zoran.h
+++ b/drivers/media/video/zoran.h
@@ -240,11 +240,16 @@ enum gpcs_type {
240 240
241struct zoran_format { 241struct zoran_format {
242 char *name; 242 char *name;
243#ifdef CONFIG_VIDEO_V4L1_COMPAT
243 int palette; 244 int palette;
245#endif
246#ifdef CONFIG_VIDEO_V4L2
244 __u32 fourcc; 247 __u32 fourcc;
245 int colorspace; 248 int colorspace;
249#endif
246 int depth; 250 int depth;
247 __u32 flags; 251 __u32 flags;
252 __u32 vfespfr;
248}; 253};
249/* flags */ 254/* flags */
250#define ZORAN_FORMAT_COMPRESSED 1<<0 255#define ZORAN_FORMAT_COMPRESSED 1<<0
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
index b0752767ee4f..ba2f4ed29483 100644
--- a/drivers/media/video/zoran_device.c
+++ b/drivers/media/video/zoran_device.c
@@ -429,8 +429,6 @@ zr36057_set_vfe (struct zoran *zr,
429 reg |= (HorDcm << ZR36057_VFESPFR_HorDcm); 429 reg |= (HorDcm << ZR36057_VFESPFR_HorDcm);
430 reg |= (VerDcm << ZR36057_VFESPFR_VerDcm); 430 reg |= (VerDcm << ZR36057_VFESPFR_VerDcm);
431 reg |= (DispMode << ZR36057_VFESPFR_DispMode); 431 reg |= (DispMode << ZR36057_VFESPFR_DispMode);
432 if (format->palette != VIDEO_PALETTE_YUV422 && format->palette != VIDEO_PALETTE_YUYV)
433 reg |= ZR36057_VFESPFR_LittleEndian;
434 /* RJ: I don't know, why the following has to be the opposite 432 /* RJ: I don't know, why the following has to be the opposite
435 * of the corresponding ZR36060 setting, but only this way 433 * of the corresponding ZR36060 setting, but only this way
436 * we get the correct colors when uncompressing to the screen */ 434 * we get the correct colors when uncompressing to the screen */
@@ -439,36 +437,6 @@ zr36057_set_vfe (struct zoran *zr,
439 if (zr->norm != VIDEO_MODE_NTSC) 437 if (zr->norm != VIDEO_MODE_NTSC)
440 reg |= ZR36057_VFESPFR_ExtFl; // NEEDED!!!!!!! Wolfgang 438 reg |= ZR36057_VFESPFR_ExtFl; // NEEDED!!!!!!! Wolfgang
441 reg |= ZR36057_VFESPFR_TopField; 439 reg |= ZR36057_VFESPFR_TopField;
442 switch (format->palette) {
443
444 case VIDEO_PALETTE_YUYV:
445 case VIDEO_PALETTE_YUV422:
446 reg |= ZR36057_VFESPFR_YUV422;
447 break;
448
449 case VIDEO_PALETTE_RGB555:
450 reg |= ZR36057_VFESPFR_RGB555 | ZR36057_VFESPFR_ErrDif;
451 break;
452
453 case VIDEO_PALETTE_RGB565:
454 reg |= ZR36057_VFESPFR_RGB565 | ZR36057_VFESPFR_ErrDif;
455 break;
456
457 case VIDEO_PALETTE_RGB24:
458 reg |= ZR36057_VFESPFR_RGB888 | ZR36057_VFESPFR_Pack24;
459 break;
460
461 case VIDEO_PALETTE_RGB32:
462 reg |= ZR36057_VFESPFR_RGB888;
463 break;
464
465 default:
466 dprintk(1,
467 KERN_INFO "%s: set_vfe() - unknown color_fmt=%x\n",
468 ZR_DEVNAME(zr), format->palette);
469 return;
470
471 }
472 if (HorDcm >= 48) { 440 if (HorDcm >= 48) {
473 reg |= 3 << ZR36057_VFESPFR_HFilter; /* 5 tap filter */ 441 reg |= 3 << ZR36057_VFESPFR_HFilter; /* 5 tap filter */
474 } else if (HorDcm >= 32) { 442 } else if (HorDcm >= 32) {
@@ -476,6 +444,7 @@ zr36057_set_vfe (struct zoran *zr,
476 } else if (HorDcm >= 16) { 444 } else if (HorDcm >= 16) {
477 reg |= 1 << ZR36057_VFESPFR_HFilter; /* 3 tap filter */ 445 reg |= 1 << ZR36057_VFESPFR_HFilter; /* 3 tap filter */
478 } 446 }
447 reg |= format->vfespfr;
479 btwrite(reg, ZR36057_VFESPFR); 448 btwrite(reg, ZR36057_VFESPFR);
480 449
481 /* display configuration */ 450 /* display configuration */
@@ -651,11 +620,17 @@ zr36057_set_memgrab (struct zoran *zr,
651 int mode) 620 int mode)
652{ 621{
653 if (mode) { 622 if (mode) {
654 if (btread(ZR36057_VSSFGR) & 623 /* We only check SnapShot and not FrameGrab here. SnapShot==1
655 (ZR36057_VSSFGR_SnapShot | ZR36057_VSSFGR_FrameGrab)) 624 * means a capture is already in progress, but FrameGrab==1
625 * doesn't necessary mean that. It's more correct to say a 1
626 * to 0 transition indicates a capture completed. If a
627 * capture is pending when capturing is tuned off, FrameGrab
628 * will be stuck at 1 until capturing is turned back on.
629 */
630 if (btread(ZR36057_VSSFGR) & ZR36057_VSSFGR_SnapShot)
656 dprintk(1, 631 dprintk(1,
657 KERN_WARNING 632 KERN_WARNING
658 "%s: zr36057_set_memgrab(1) with SnapShot or FrameGrab on!?\n", 633 "%s: zr36057_set_memgrab(1) with SnapShot on!?\n",
659 ZR_DEVNAME(zr)); 634 ZR_DEVNAME(zr));
660 635
661 /* switch on VSync interrupts */ 636 /* switch on VSync interrupts */
@@ -672,11 +647,12 @@ zr36057_set_memgrab (struct zoran *zr,
672 647
673 zr->v4l_memgrab_active = 1; 648 zr->v4l_memgrab_active = 1;
674 } else { 649 } else {
675 zr->v4l_memgrab_active = 0;
676
677 /* switch off VSync interrupts */ 650 /* switch off VSync interrupts */
678 btand(~zr->card.vsync_int, ZR36057_ICR); // SW 651 btand(~zr->card.vsync_int, ZR36057_ICR); // SW
679 652
653 zr->v4l_memgrab_active = 0;
654 zr->v4l_grab_frame = NO_GRAB_ACTIVE;
655
680 /* reenable grabbing to screen if it was running */ 656 /* reenable grabbing to screen if it was running */
681 if (zr->v4l_overlay_active) { 657 if (zr->v4l_overlay_active) {
682 zr36057_overlay(zr, 1); 658 zr36057_overlay(zr, 1);
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 17118a490f81..72a037b75d63 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -99,88 +99,103 @@
99 99
100#include <asm/byteorder.h> 100#include <asm/byteorder.h>
101 101
102const struct zoran_format zoran_formats[] = { 102#if defined(CONFIG_VIDEO_V4L2) && defined(CONFIG_VIDEO_V4L1_COMPAT)
103 { 103#define ZFMT(pal, fcc, cs) \
104 .name = "15-bit RGB", 104 .palette = (pal), .fourcc = (fcc), .colorspace = (cs)
105 .palette = VIDEO_PALETTE_RGB555, 105#elif defined(CONFIG_VIDEO_V4L2)
106#ifdef CONFIG_VIDEO_V4L2 106#define ZFMT(pal, fcc, cs) \
107#ifdef __LITTLE_ENDIAN 107 .fourcc = (fcc), .colorspace = (cs)
108 .fourcc = V4L2_PIX_FMT_RGB555,
109#else 108#else
110 .fourcc = V4L2_PIX_FMT_RGB555X, 109#define ZFMT(pal, fcc, cs) \
111#endif 110 .palette = (pal)
112 .colorspace = V4L2_COLORSPACE_SRGB,
113#endif 111#endif
112
113const struct zoran_format zoran_formats[] = {
114 {
115 .name = "15-bit RGB LE",
116 ZFMT(VIDEO_PALETTE_RGB555,
117 V4L2_PIX_FMT_RGB555, V4L2_COLORSPACE_SRGB),
114 .depth = 15, 118 .depth = 15,
115 .flags = ZORAN_FORMAT_CAPTURE | 119 .flags = ZORAN_FORMAT_CAPTURE |
116 ZORAN_FORMAT_OVERLAY, 120 ZORAN_FORMAT_OVERLAY,
121 .vfespfr = ZR36057_VFESPFR_RGB555|ZR36057_VFESPFR_ErrDif|
122 ZR36057_VFESPFR_LittleEndian,
117 }, { 123 }, {
118 .name = "16-bit RGB", 124 .name = "15-bit RGB BE",
119 .palette = VIDEO_PALETTE_RGB565, 125 ZFMT(-1,
120#ifdef CONFIG_VIDEO_V4L2 126 V4L2_PIX_FMT_RGB555X, V4L2_COLORSPACE_SRGB),
121#ifdef __LITTLE_ENDIAN 127 .depth = 15,
122 .fourcc = V4L2_PIX_FMT_RGB565, 128 .flags = ZORAN_FORMAT_CAPTURE |
123#else 129 ZORAN_FORMAT_OVERLAY,
124 .fourcc = V4L2_PIX_FMT_RGB565X, 130 .vfespfr = ZR36057_VFESPFR_RGB555|ZR36057_VFESPFR_ErrDif,
125#endif 131 }, {
126 .colorspace = V4L2_COLORSPACE_SRGB, 132 .name = "16-bit RGB LE",
127#endif 133 ZFMT(VIDEO_PALETTE_RGB565,
134 V4L2_PIX_FMT_RGB565, V4L2_COLORSPACE_SRGB),
128 .depth = 16, 135 .depth = 16,
129 .flags = ZORAN_FORMAT_CAPTURE | 136 .flags = ZORAN_FORMAT_CAPTURE |
130 ZORAN_FORMAT_OVERLAY, 137 ZORAN_FORMAT_OVERLAY,
138 .vfespfr = ZR36057_VFESPFR_RGB565|ZR36057_VFESPFR_ErrDif|
139 ZR36057_VFESPFR_LittleEndian,
140 }, {
141 .name = "16-bit RGB BE",
142 ZFMT(-1,
143 V4L2_PIX_FMT_RGB565, V4L2_COLORSPACE_SRGB),
144 .depth = 16,
145 .flags = ZORAN_FORMAT_CAPTURE |
146 ZORAN_FORMAT_OVERLAY,
147 .vfespfr = ZR36057_VFESPFR_RGB565|ZR36057_VFESPFR_ErrDif,
131 }, { 148 }, {
132 .name = "24-bit RGB", 149 .name = "24-bit RGB",
133 .palette = VIDEO_PALETTE_RGB24, 150 ZFMT(VIDEO_PALETTE_RGB24,
134#ifdef CONFIG_VIDEO_V4L2 151 V4L2_PIX_FMT_BGR24, V4L2_COLORSPACE_SRGB),
135#ifdef __LITTLE_ENDIAN
136 .fourcc = V4L2_PIX_FMT_BGR24,
137#else
138 .fourcc = V4L2_PIX_FMT_RGB24,
139#endif
140 .colorspace = V4L2_COLORSPACE_SRGB,
141#endif
142 .depth = 24, 152 .depth = 24,
143 .flags = ZORAN_FORMAT_CAPTURE | 153 .flags = ZORAN_FORMAT_CAPTURE |
144 ZORAN_FORMAT_OVERLAY, 154 ZORAN_FORMAT_OVERLAY,
155 .vfespfr = ZR36057_VFESPFR_RGB888|ZR36057_VFESPFR_Pack24,
145 }, { 156 }, {
146 .name = "32-bit RGB", 157 .name = "32-bit RGB LE",
147 .palette = VIDEO_PALETTE_RGB32, 158 ZFMT(VIDEO_PALETTE_RGB32,
148#ifdef CONFIG_VIDEO_V4L2 159 V4L2_PIX_FMT_BGR32, V4L2_COLORSPACE_SRGB),
149#ifdef __LITTLE_ENDIAN 160 .depth = 32,
150 .fourcc = V4L2_PIX_FMT_BGR32, 161 .flags = ZORAN_FORMAT_CAPTURE |
151#else 162 ZORAN_FORMAT_OVERLAY,
152 .fourcc = V4L2_PIX_FMT_RGB32, 163 .vfespfr = ZR36057_VFESPFR_RGB888|ZR36057_VFESPFR_LittleEndian,
153#endif 164 }, {
154 .colorspace = V4L2_COLORSPACE_SRGB, 165 .name = "32-bit RGB BE",
155#endif 166 ZFMT(-1,
167 V4L2_PIX_FMT_RGB32, V4L2_COLORSPACE_SRGB),
156 .depth = 32, 168 .depth = 32,
157 .flags = ZORAN_FORMAT_CAPTURE | 169 .flags = ZORAN_FORMAT_CAPTURE |
158 ZORAN_FORMAT_OVERLAY, 170 ZORAN_FORMAT_OVERLAY,
171 .vfespfr = ZR36057_VFESPFR_RGB888,
159 }, { 172 }, {
160 .name = "4:2:2, packed, YUYV", 173 .name = "4:2:2, packed, YUYV",
161 .palette = VIDEO_PALETTE_YUV422, 174 ZFMT(VIDEO_PALETTE_YUV422,
162#ifdef CONFIG_VIDEO_V4L2 175 V4L2_PIX_FMT_YUYV, V4L2_COLORSPACE_SMPTE170M),
163 .fourcc = V4L2_PIX_FMT_YUYV, 176 .depth = 16,
164 .colorspace = V4L2_COLORSPACE_SMPTE170M, 177 .flags = ZORAN_FORMAT_CAPTURE |
165#endif 178 ZORAN_FORMAT_OVERLAY,
179 .vfespfr = ZR36057_VFESPFR_YUV422,
180 }, {
181 .name = "4:2:2, packed, UYVY",
182 ZFMT(VIDEO_PALETTE_UYVY,
183 V4L2_PIX_FMT_UYVY, V4L2_COLORSPACE_SMPTE170M),
166 .depth = 16, 184 .depth = 16,
167 .flags = ZORAN_FORMAT_CAPTURE | 185 .flags = ZORAN_FORMAT_CAPTURE |
168 ZORAN_FORMAT_OVERLAY, 186 ZORAN_FORMAT_OVERLAY,
187 .vfespfr = ZR36057_VFESPFR_YUV422|ZR36057_VFESPFR_LittleEndian,
169 }, { 188 }, {
170 .name = "Hardware-encoded Motion-JPEG", 189 .name = "Hardware-encoded Motion-JPEG",
171 .palette = -1, 190 ZFMT(-1,
172#ifdef CONFIG_VIDEO_V4L2 191 V4L2_PIX_FMT_MJPEG, V4L2_COLORSPACE_SMPTE170M),
173 .fourcc = V4L2_PIX_FMT_MJPEG,
174 .colorspace = V4L2_COLORSPACE_SMPTE170M,
175#endif
176 .depth = 0, 192 .depth = 0,
177 .flags = ZORAN_FORMAT_CAPTURE | 193 .flags = ZORAN_FORMAT_CAPTURE |
178 ZORAN_FORMAT_PLAYBACK | 194 ZORAN_FORMAT_PLAYBACK |
179 ZORAN_FORMAT_COMPRESSED, 195 ZORAN_FORMAT_COMPRESSED,
180 } 196 }
181}; 197};
182static const int zoran_num_formats = 198#define NUM_FORMATS ARRAY_SIZE(zoran_formats)
183 (sizeof(zoran_formats) / sizeof(struct zoran_format));
184 199
185// RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined 200// RJ: Test only - want to test BUZ_USE_HIMEM even when CONFIG_BIGPHYS_AREA is defined
186 201
@@ -768,13 +783,13 @@ v4l_grab (struct file *file,
768 struct zoran *zr = fh->zr; 783 struct zoran *zr = fh->zr;
769 int res = 0, i; 784 int res = 0, i;
770 785
771 for (i = 0; i < zoran_num_formats; i++) { 786 for (i = 0; i < NUM_FORMATS; i++) {
772 if (zoran_formats[i].palette == mp->format && 787 if (zoran_formats[i].palette == mp->format &&
773 zoran_formats[i].flags & ZORAN_FORMAT_CAPTURE && 788 zoran_formats[i].flags & ZORAN_FORMAT_CAPTURE &&
774 !(zoran_formats[i].flags & ZORAN_FORMAT_COMPRESSED)) 789 !(zoran_formats[i].flags & ZORAN_FORMAT_COMPRESSED))
775 break; 790 break;
776 } 791 }
777 if (i == zoran_num_formats || zoran_formats[i].depth == 0) { 792 if (i == NUM_FORMATS || zoran_formats[i].depth == 0) {
778 dprintk(1, 793 dprintk(1,
779 KERN_ERR 794 KERN_ERR
780 "%s: v4l_grab() - wrong bytes-per-pixel format\n", 795 "%s: v4l_grab() - wrong bytes-per-pixel format\n",
@@ -1173,10 +1188,14 @@ zoran_close_end_session (struct file *file)
1173 1188
1174 /* v4l capture */ 1189 /* v4l capture */
1175 if (fh->v4l_buffers.active != ZORAN_FREE) { 1190 if (fh->v4l_buffers.active != ZORAN_FREE) {
1191 long flags;
1192
1193 spin_lock_irqsave(&zr->spinlock, flags);
1176 zr36057_set_memgrab(zr, 0); 1194 zr36057_set_memgrab(zr, 0);
1177 zr->v4l_buffers.allocated = 0; 1195 zr->v4l_buffers.allocated = 0;
1178 zr->v4l_buffers.active = fh->v4l_buffers.active = 1196 zr->v4l_buffers.active = fh->v4l_buffers.active =
1179 ZORAN_FREE; 1197 ZORAN_FREE;
1198 spin_unlock_irqrestore(&zr->spinlock, flags);
1180 } 1199 }
1181 1200
1182 /* v4l buffers */ 1201 /* v4l buffers */
@@ -2107,7 +2126,7 @@ zoran_do_ioctl (struct inode *inode,
2107 vpict->colour, vpict->contrast, vpict->depth, 2126 vpict->colour, vpict->contrast, vpict->depth,
2108 vpict->palette); 2127 vpict->palette);
2109 2128
2110 for (i = 0; i < zoran_num_formats; i++) { 2129 for (i = 0; i < NUM_FORMATS; i++) {
2111 const struct zoran_format *fmt = &zoran_formats[i]; 2130 const struct zoran_format *fmt = &zoran_formats[i];
2112 2131
2113 if (fmt->palette != -1 && 2132 if (fmt->palette != -1 &&
@@ -2116,7 +2135,7 @@ zoran_do_ioctl (struct inode *inode,
2116 fmt->depth == vpict->depth) 2135 fmt->depth == vpict->depth)
2117 break; 2136 break;
2118 } 2137 }
2119 if (i == zoran_num_formats) { 2138 if (i == NUM_FORMATS) {
2120 dprintk(1, 2139 dprintk(1,
2121 KERN_ERR 2140 KERN_ERR
2122 "%s: VIDIOCSPICT - Invalid palette %d\n", 2141 "%s: VIDIOCSPICT - Invalid palette %d\n",
@@ -2220,10 +2239,10 @@ zoran_do_ioctl (struct inode *inode,
2220 ZR_DEVNAME(zr), vbuf->base, vbuf->width, 2239 ZR_DEVNAME(zr), vbuf->base, vbuf->width,
2221 vbuf->height, vbuf->depth, vbuf->bytesperline); 2240 vbuf->height, vbuf->depth, vbuf->bytesperline);
2222 2241
2223 for (i = 0; i < zoran_num_formats; i++) 2242 for (i = 0; i < NUM_FORMATS; i++)
2224 if (zoran_formats[i].depth == vbuf->depth) 2243 if (zoran_formats[i].depth == vbuf->depth)
2225 break; 2244 break;
2226 if (i == zoran_num_formats) { 2245 if (i == NUM_FORMATS) {
2227 dprintk(1, 2246 dprintk(1,
2228 KERN_ERR 2247 KERN_ERR
2229 "%s: VIDIOCSFBUF - invalid fbuf depth %d\n", 2248 "%s: VIDIOCSFBUF - invalid fbuf depth %d\n",
@@ -2672,14 +2691,14 @@ zoran_do_ioctl (struct inode *inode,
2672 return -EINVAL; 2691 return -EINVAL;
2673 } 2692 }
2674 2693
2675 for (i = 0; i < zoran_num_formats; i++) { 2694 for (i = 0; i < NUM_FORMATS; i++) {
2676 if (zoran_formats[i].flags & flag) 2695 if (zoran_formats[i].flags & flag)
2677 num++; 2696 num++;
2678 if (num == fmt->index) 2697 if (num == fmt->index)
2679 break; 2698 break;
2680 } 2699 }
2681 if (fmt->index < 0 /* late, but not too late */ || 2700 if (fmt->index < 0 /* late, but not too late */ ||
2682 i == zoran_num_formats) 2701 i == NUM_FORMATS)
2683 return -EINVAL; 2702 return -EINVAL;
2684 2703
2685 memset(fmt, 0, sizeof(*fmt)); 2704 memset(fmt, 0, sizeof(*fmt));
@@ -2737,7 +2756,8 @@ zoran_do_ioctl (struct inode *inode,
2737 fmt->fmt.pix.height = 2756 fmt->fmt.pix.height =
2738 fh->v4l_settings.height; 2757 fh->v4l_settings.height;
2739 fmt->fmt.pix.sizeimage = 2758 fmt->fmt.pix.sizeimage =
2740 fh->v4l_buffers.buffer_size; 2759 fh->v4l_settings.bytesperline *
2760 fh->v4l_settings.height;
2741 fmt->fmt.pix.pixelformat = 2761 fmt->fmt.pix.pixelformat =
2742 fh->v4l_settings.format->fourcc; 2762 fh->v4l_settings.format->fourcc;
2743 fmt->fmt.pix.colorspace = 2763 fmt->fmt.pix.colorspace =
@@ -2941,11 +2961,11 @@ zoran_do_ioctl (struct inode *inode,
2941 sfmtjpg_unlock_and_return: 2961 sfmtjpg_unlock_and_return:
2942 mutex_unlock(&zr->resource_lock); 2962 mutex_unlock(&zr->resource_lock);
2943 } else { 2963 } else {
2944 for (i = 0; i < zoran_num_formats; i++) 2964 for (i = 0; i < NUM_FORMATS; i++)
2945 if (fmt->fmt.pix.pixelformat == 2965 if (fmt->fmt.pix.pixelformat ==
2946 zoran_formats[i].fourcc) 2966 zoran_formats[i].fourcc)
2947 break; 2967 break;
2948 if (i == zoran_num_formats) { 2968 if (i == NUM_FORMATS) {
2949 dprintk(1, 2969 dprintk(1,
2950 KERN_ERR 2970 KERN_ERR
2951 "%s: VIDIOC_S_FMT - unknown/unsupported format 0x%x (%4.4s)\n", 2971 "%s: VIDIOC_S_FMT - unknown/unsupported format 0x%x (%4.4s)\n",
@@ -2984,8 +3004,9 @@ zoran_do_ioctl (struct inode *inode,
2984 3004
2985 /* tell the user the 3005 /* tell the user the
2986 * results/missing stuff */ 3006 * results/missing stuff */
2987 fmt->fmt.pix.sizeimage = fh->v4l_buffers.buffer_size /*zr->gbpl * zr->gheight */ 3007 fmt->fmt.pix.sizeimage =
2988 ; 3008 fh->v4l_settings.height *
3009 fh->v4l_settings.bytesperline;
2989 if (BUZ_MAX_HEIGHT < 3010 if (BUZ_MAX_HEIGHT <
2990 (fh->v4l_settings.height * 2)) 3011 (fh->v4l_settings.height * 2))
2991 fmt->fmt.pix.field = 3012 fmt->fmt.pix.field =
@@ -3053,10 +3074,10 @@ zoran_do_ioctl (struct inode *inode,
3053 fb->fmt.bytesperline, fb->fmt.pixelformat, 3074 fb->fmt.bytesperline, fb->fmt.pixelformat,
3054 (char *) &printformat); 3075 (char *) &printformat);
3055 3076
3056 for (i = 0; i < zoran_num_formats; i++) 3077 for (i = 0; i < NUM_FORMATS; i++)
3057 if (zoran_formats[i].fourcc == fb->fmt.pixelformat) 3078 if (zoran_formats[i].fourcc == fb->fmt.pixelformat)
3058 break; 3079 break;
3059 if (i == zoran_num_formats) { 3080 if (i == NUM_FORMATS) {
3060 dprintk(1, 3081 dprintk(1,
3061 KERN_ERR 3082 KERN_ERR
3062 "%s: VIDIOC_S_FBUF - format=0x%x (%4.4s) not allowed\n", 3083 "%s: VIDIOC_S_FBUF - format=0x%x (%4.4s) not allowed\n",
@@ -3439,8 +3460,13 @@ zoran_do_ioctl (struct inode *inode,
3439 goto strmoff_unlock_and_return; 3460 goto strmoff_unlock_and_return;
3440 3461
3441 /* unload capture */ 3462 /* unload capture */
3442 if (zr->v4l_memgrab_active) 3463 if (zr->v4l_memgrab_active) {
3464 long flags;
3465
3466 spin_lock_irqsave(&zr->spinlock, flags);
3443 zr36057_set_memgrab(zr, 0); 3467 zr36057_set_memgrab(zr, 0);
3468 spin_unlock_irqrestore(&zr->spinlock, flags);
3469 }
3444 3470
3445 for (i = 0; i < fh->v4l_buffers.num_buffers; i++) 3471 for (i = 0; i < fh->v4l_buffers.num_buffers; i++)
3446 zr->v4l_buffers.buffer[i].state = 3472 zr->v4l_buffers.buffer[i].state =
@@ -3704,11 +3730,11 @@ zoran_do_ioctl (struct inode *inode,
3704 dprintk(3, KERN_DEBUG "%s: VIDIOC_S_STD - norm=0x%llx\n", 3730 dprintk(3, KERN_DEBUG "%s: VIDIOC_S_STD - norm=0x%llx\n",
3705 ZR_DEVNAME(zr), (unsigned long long)*std); 3731 ZR_DEVNAME(zr), (unsigned long long)*std);
3706 3732
3707 if (*std == V4L2_STD_PAL) 3733 if ((*std & V4L2_STD_PAL) && !(*std & ~V4L2_STD_PAL))
3708 norm = VIDEO_MODE_PAL; 3734 norm = VIDEO_MODE_PAL;
3709 else if (*std == V4L2_STD_NTSC) 3735 else if ((*std & V4L2_STD_NTSC) && !(*std & ~V4L2_STD_NTSC))
3710 norm = VIDEO_MODE_NTSC; 3736 norm = VIDEO_MODE_NTSC;
3711 else if (*std == V4L2_STD_SECAM) 3737 else if ((*std & V4L2_STD_SECAM) && !(*std & ~V4L2_STD_SECAM))
3712 norm = VIDEO_MODE_SECAM; 3738 norm = VIDEO_MODE_SECAM;
3713 else if (*std == V4L2_STD_ALL) 3739 else if (*std == V4L2_STD_ALL)
3714 norm = VIDEO_MODE_AUTO; 3740 norm = VIDEO_MODE_AUTO;
@@ -4149,11 +4175,11 @@ zoran_do_ioctl (struct inode *inode,
4149 V4L2_BUF_TYPE_VIDEO_CAPTURE) { 4175 V4L2_BUF_TYPE_VIDEO_CAPTURE) {
4150 int i; 4176 int i;
4151 4177
4152 for (i = 0; i < zoran_num_formats; i++) 4178 for (i = 0; i < NUM_FORMATS; i++)
4153 if (zoran_formats[i].fourcc == 4179 if (zoran_formats[i].fourcc ==
4154 fmt->fmt.pix.pixelformat) 4180 fmt->fmt.pix.pixelformat)
4155 break; 4181 break;
4156 if (i == zoran_num_formats) { 4182 if (i == NUM_FORMATS) {
4157 res = -EINVAL; 4183 res = -EINVAL;
4158 goto tryfmt_unlock_and_return; 4184 goto tryfmt_unlock_and_return;
4159 } 4185 }
@@ -4213,8 +4239,8 @@ zoran_poll (struct file *file,
4213{ 4239{
4214 struct zoran_fh *fh = file->private_data; 4240 struct zoran_fh *fh = file->private_data;
4215 struct zoran *zr = fh->zr; 4241 struct zoran *zr = fh->zr;
4216 wait_queue_head_t *queue = NULL;
4217 int res = 0, frame; 4242 int res = 0, frame;
4243 unsigned long flags;
4218 4244
4219 /* we should check whether buffers are ready to be synced on 4245 /* we should check whether buffers are ready to be synced on
4220 * (w/o waits - O_NONBLOCK) here 4246 * (w/o waits - O_NONBLOCK) here
@@ -4228,51 +4254,58 @@ zoran_poll (struct file *file,
4228 4254
4229 switch (fh->map_mode) { 4255 switch (fh->map_mode) {
4230 case ZORAN_MAP_MODE_RAW: 4256 case ZORAN_MAP_MODE_RAW:
4231 if (fh->v4l_buffers.active == ZORAN_FREE || 4257 poll_wait(file, &zr->v4l_capq, wait);
4232 zr->v4l_pend_head == zr->v4l_pend_tail) { 4258 frame = zr->v4l_pend[zr->v4l_sync_tail & V4L_MASK_FRAME];
4233 dprintk(1, 4259
4234 "%s: zoran_poll() - no buffers queued\n", 4260 spin_lock_irqsave(&zr->spinlock, flags);
4235 ZR_DEVNAME(zr)); 4261 dprintk(3,
4236 res = POLLNVAL; 4262 KERN_DEBUG
4237 goto poll_unlock_and_return; 4263 "%s: %s() raw - active=%c, sync_tail=%lu/%c, pend_tail=%lu, pend_head=%lu\n",
4238 } 4264 ZR_DEVNAME(zr), __FUNCTION__,
4239 queue = &zr->v4l_capq; 4265 "FAL"[fh->v4l_buffers.active], zr->v4l_sync_tail,
4240 frame = zr->v4l_pend[zr->v4l_pend_tail & V4L_MASK_FRAME]; 4266 "UPMD"[zr->v4l_buffers.buffer[frame].state],
4241 poll_wait(file, queue, wait); 4267 zr->v4l_pend_tail, zr->v4l_pend_head);
4242 if (fh->v4l_buffers.buffer[frame].state == BUZ_STATE_DONE) 4268 /* Process is the one capturing? */
4269 if (fh->v4l_buffers.active != ZORAN_FREE &&
4270 /* Buffer ready to DQBUF? */
4271 zr->v4l_buffers.buffer[frame].state == BUZ_STATE_DONE)
4243 res = POLLIN | POLLRDNORM; 4272 res = POLLIN | POLLRDNORM;
4273 spin_unlock_irqrestore(&zr->spinlock, flags);
4274
4244 break; 4275 break;
4245 4276
4246 case ZORAN_MAP_MODE_JPG_REC: 4277 case ZORAN_MAP_MODE_JPG_REC:
4247 case ZORAN_MAP_MODE_JPG_PLAY: 4278 case ZORAN_MAP_MODE_JPG_PLAY:
4248 if (fh->jpg_buffers.active == ZORAN_FREE || 4279 poll_wait(file, &zr->jpg_capq, wait);
4249 zr->jpg_que_head == zr->jpg_que_tail) {
4250 dprintk(1,
4251 "%s: zoran_poll() - no buffers queued\n",
4252 ZR_DEVNAME(zr));
4253 res = POLLNVAL;
4254 goto poll_unlock_and_return;
4255 }
4256 queue = &zr->jpg_capq;
4257 frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME]; 4280 frame = zr->jpg_pend[zr->jpg_que_tail & BUZ_MASK_FRAME];
4258 poll_wait(file, queue, wait); 4281
4259 if (fh->jpg_buffers.buffer[frame].state == BUZ_STATE_DONE) { 4282 spin_lock_irqsave(&zr->spinlock, flags);
4283 dprintk(3,
4284 KERN_DEBUG
4285 "%s: %s() jpg - active=%c, que_tail=%lu/%c, que_head=%lu, dma=%lu/%lu\n",
4286 ZR_DEVNAME(zr), __FUNCTION__,
4287 "FAL"[fh->jpg_buffers.active], zr->jpg_que_tail,
4288 "UPMD"[zr->jpg_buffers.buffer[frame].state],
4289 zr->jpg_que_head, zr->jpg_dma_tail, zr->jpg_dma_head);
4290 if (fh->jpg_buffers.active != ZORAN_FREE &&
4291 zr->jpg_buffers.buffer[frame].state == BUZ_STATE_DONE) {
4260 if (fh->map_mode == ZORAN_MAP_MODE_JPG_REC) 4292 if (fh->map_mode == ZORAN_MAP_MODE_JPG_REC)
4261 res = POLLIN | POLLRDNORM; 4293 res = POLLIN | POLLRDNORM;
4262 else 4294 else
4263 res = POLLOUT | POLLWRNORM; 4295 res = POLLOUT | POLLWRNORM;
4264 } 4296 }
4297 spin_unlock_irqrestore(&zr->spinlock, flags);
4298
4265 break; 4299 break;
4266 4300
4267 default: 4301 default:
4268 dprintk(1, 4302 dprintk(1,
4303 KERN_ERR
4269 "%s: zoran_poll() - internal error, unknown map_mode=%d\n", 4304 "%s: zoran_poll() - internal error, unknown map_mode=%d\n",
4270 ZR_DEVNAME(zr), fh->map_mode); 4305 ZR_DEVNAME(zr), fh->map_mode);
4271 res = POLLNVAL; 4306 res = POLLNVAL;
4272 goto poll_unlock_and_return;
4273 } 4307 }
4274 4308
4275poll_unlock_and_return:
4276 mutex_unlock(&zr->resource_lock); 4309 mutex_unlock(&zr->resource_lock);
4277 4310
4278 return res; 4311 return res;
@@ -4368,11 +4401,15 @@ zoran_vm_close (struct vm_area_struct *vma)
4368 mutex_lock(&zr->resource_lock); 4401 mutex_lock(&zr->resource_lock);
4369 4402
4370 if (fh->v4l_buffers.active != ZORAN_FREE) { 4403 if (fh->v4l_buffers.active != ZORAN_FREE) {
4404 long flags;
4405
4406 spin_lock_irqsave(&zr->spinlock, flags);
4371 zr36057_set_memgrab(zr, 0); 4407 zr36057_set_memgrab(zr, 0);
4372 zr->v4l_buffers.allocated = 0; 4408 zr->v4l_buffers.allocated = 0;
4373 zr->v4l_buffers.active = 4409 zr->v4l_buffers.active =
4374 fh->v4l_buffers.active = 4410 fh->v4l_buffers.active =
4375 ZORAN_FREE; 4411 ZORAN_FREE;
4412 spin_unlock_irqrestore(&zr->spinlock, flags);
4376 } 4413 }
4377 //v4l_fbuffer_free(file); 4414 //v4l_fbuffer_free(file);
4378 fh->v4l_buffers.allocated = 0; 4415 fh->v4l_buffers.allocated = 0;
diff --git a/drivers/message/fusion/Kconfig b/drivers/message/fusion/Kconfig
index 4494e0fd36c6..f55cc03a75c9 100644
--- a/drivers/message/fusion/Kconfig
+++ b/drivers/message/fusion/Kconfig
@@ -102,4 +102,18 @@ config FUSION_LAN
102 102
103 If unsure whether you really want or need this, say N. 103 If unsure whether you really want or need this, say N.
104 104
105config FUSION_LOGGING
106 bool "Fusion MPT logging facility"
107 depends on FUSION
108 ---help---
109 This turns on a logging facility that can be used to debug a number
110 of Fusion MPT related problems.
111
112 The debug level can be programmed on the fly via SysFS (hex values)
113
114 echo [level] > /sys/class/scsi_host/host#/debug_level
115
116 There are various debug levels that an be found in the source:
117 file:drivers/message/fusion/mptdebug.h
118
105endmenu 119endmenu
diff --git a/drivers/message/fusion/Makefile b/drivers/message/fusion/Makefile
index 6003b46c8438..95c9532cb07c 100644
--- a/drivers/message/fusion/Makefile
+++ b/drivers/message/fusion/Makefile
@@ -1,39 +1,8 @@
1# Fusion MPT drivers; recognized debug defines... 1# Fusion MPT drivers; recognized debug defines...
2# MPT general:
3#EXTRA_CFLAGS += -DMPT_DEBUG
4#EXTRA_CFLAGS += -DMPT_DEBUG_MSG_FRAME
5#EXTRA_CFLAGS += -DMPT_DEBUG_SG
6#EXTRA_CFLAGS += -DMPT_DEBUG_EVENTS
7#EXTRA_CFLAGS += -DMPT_DEBUG_VERBOSE_EVENTS
8#EXTRA_CFLAGS += -DMPT_DEBUG_INIT
9#EXTRA_CFLAGS += -DMPT_DEBUG_EXIT
10#EXTRA_CFLAGS += -DMPT_DEBUG_FAIL
11#EXTRA_CFLAGS += -DMPT_DEBUG_DV
12#EXTRA_CFLAGS += -DMPT_DEBUG_TM
13#EXTRA_CFLAGS += -DMPT_DEBUG_REPLY
14 2
15# 3# enable verbose logging
16# driver/module specifics... 4# CONFIG_FUSION_LOGGING needs to be enabled in Kconfig
17# 5#EXTRA_CFLAGS += -DMPT_DEBUG_VERBOSE
18# For mptbase:
19#CFLAGS_mptbase.o += -DMPT_DEBUG_HANDSHAKE
20#CFLAGS_mptbase.o += -DMPT_DEBUG_CONFIG
21#CFLAGS_mptbase.o += -DMPT_DEBUG_DL
22#CFLAGS_mptbase.o += -DMPT_DEBUG_IRQ
23#CFLAGS_mptbase.o += -DMPT_DEBUG_RESET
24#
25# For mptscsih:
26#CFLAGS_mptscsih.o += -DMPT_DEBUG_SCSI
27#
28# For mptctl:
29#CFLAGS_mptctl.o += -DMPT_DEBUG_IOCTL
30#
31# For mptfc:
32#CFLAGS_mptfc.o += -DMPT_DEBUG_FC
33
34# For mptsas:
35#CFLAGS_mptsas.o += -DMPT_DEBUG_SAS
36#CFLAGS_mptsas.o += -DMPT_DEBUG_SAS_WIDE
37 6
38 7
39#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC 8#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 04f75e24dcec..e866dacde7e5 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -87,6 +87,10 @@ static int mpt_channel_mapping;
87module_param(mpt_channel_mapping, int, 0); 87module_param(mpt_channel_mapping, int, 0);
88MODULE_PARM_DESC(mpt_channel_mapping, " Mapping id's to channels (default=0)"); 88MODULE_PARM_DESC(mpt_channel_mapping, " Mapping id's to channels (default=0)");
89 89
90static int mpt_debug_level;
91module_param(mpt_debug_level, int, 0);
92MODULE_PARM_DESC(mpt_debug_level, " debug level - refer to mptdebug.h - (default=0)");
93
90#ifdef MFCNT 94#ifdef MFCNT
91static int mfcounter = 0; 95static int mfcounter = 0;
92#define PRINT_MF_COUNT 20000 96#define PRINT_MF_COUNT 20000
@@ -179,9 +183,7 @@ static void mpt_get_fw_exp_ver(char *buf, MPT_ADAPTER *ioc);
179 183
180//int mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag); 184//int mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag);
181static int ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *evReply, int *evHandlers); 185static int ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *evReply, int *evHandlers);
182#ifdef MPT_DEBUG_REPLY
183static void mpt_iocstatus_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf); 186static void mpt_iocstatus_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf);
184#endif
185static void mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info); 187static void mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info);
186static void mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info); 188static void mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info);
187static void mpt_sas_log_info(MPT_ADAPTER *ioc, u32 log_info); 189static void mpt_sas_log_info(MPT_ADAPTER *ioc, u32 log_info);
@@ -229,7 +231,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
229 int req_idx = 0; 231 int req_idx = 0;
230 int cb_idx; 232 int cb_idx;
231 233
232 dmfprintk((MYIOC_s_INFO_FMT "Got TURBO reply req_idx=%08x\n", 234 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got TURBO reply req_idx=%08x\n",
233 ioc->name, pa)); 235 ioc->name, pa));
234 236
235 switch (pa >> MPI_CONTEXT_REPLY_TYPE_SHIFT) { 237 switch (pa >> MPI_CONTEXT_REPLY_TYPE_SHIFT) {
@@ -312,9 +314,9 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
312 cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx; 314 cb_idx = mr->u.frame.hwhdr.msgctxu.fld.cb_idx;
313 mf = MPT_INDEX_2_MFPTR(ioc, req_idx); 315 mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
314 316
315 dmfprintk((MYIOC_s_INFO_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n", 317 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got non-TURBO reply=%p req_idx=%x cb_idx=%x Function=%x\n",
316 ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function)); 318 ioc->name, mr, req_idx, cb_idx, mr->u.hdr.Function));
317 DBG_DUMP_REPLY_FRAME(mr) 319 DBG_DUMP_REPLY_FRAME(ioc, (u32 *)mr)
318 320
319 /* Check/log IOC log info 321 /* Check/log IOC log info
320 */ 322 */
@@ -329,10 +331,8 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
329 mpt_sas_log_info(ioc, log_info); 331 mpt_sas_log_info(ioc, log_info);
330 } 332 }
331 333
332#ifdef MPT_DEBUG_REPLY
333 if (ioc_stat & MPI_IOCSTATUS_MASK) 334 if (ioc_stat & MPI_IOCSTATUS_MASK)
334 mpt_iocstatus_info(ioc, (u32)ioc_stat, mf); 335 mpt_iocstatus_info(ioc, (u32)ioc_stat, mf);
335#endif
336 336
337 /* Check for (valid) IO callback! */ 337 /* Check for (valid) IO callback! */
338 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS || 338 if (cb_idx < 1 || cb_idx >= MPT_MAX_PROTOCOL_DRIVERS ||
@@ -414,17 +414,17 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
414 int freereq = 1; 414 int freereq = 1;
415 u8 func; 415 u8 func;
416 416
417 dmfprintk((MYIOC_s_INFO_FMT "mpt_base_reply() called\n", ioc->name)); 417 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mpt_base_reply() called\n", ioc->name));
418 418#ifdef CONFIG_FUSION_LOGGING
419#if defined(MPT_DEBUG_MSG_FRAME) 419 if ((ioc->debug_level & MPT_DEBUG_MSG_FRAME) &&
420 if (!(reply->u.hdr.MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY)) { 420 !(reply->u.hdr.MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY)) {
421 dmfprintk((KERN_INFO MYNAM ": Original request frame (@%p) header\n", mf)); 421 dmfprintk(ioc, printk(KERN_INFO MYNAM ": Original request frame (@%p) header\n", mf));
422 DBG_DUMP_REQUEST_FRAME_HDR(mf) 422 DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)mf)
423 } 423 }
424#endif 424#endif
425 425
426 func = reply->u.hdr.Function; 426 func = reply->u.hdr.Function;
427 dmfprintk((MYIOC_s_INFO_FMT "mpt_base_reply, Function=%02Xh\n", 427 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mpt_base_reply, Function=%02Xh\n",
428 ioc->name, func)); 428 ioc->name, func));
429 429
430 if (func == MPI_FUNCTION_EVENT_NOTIFICATION) { 430 if (func == MPI_FUNCTION_EVENT_NOTIFICATION) {
@@ -435,7 +435,7 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
435 results = ProcessEventNotification(ioc, pEvReply, &evHandlers); 435 results = ProcessEventNotification(ioc, pEvReply, &evHandlers);
436 if (results != evHandlers) { 436 if (results != evHandlers) {
437 /* CHECKME! Any special handling needed here? */ 437 /* CHECKME! Any special handling needed here? */
438 devtverboseprintk((MYIOC_s_WARN_FMT "Called %d event handlers, sum results = %d\n", 438 devtverboseprintk(ioc, printk(MYIOC_s_WARN_FMT "Called %d event handlers, sum results = %d\n",
439 ioc->name, evHandlers, results)); 439 ioc->name, evHandlers, results));
440 } 440 }
441 441
@@ -446,7 +446,7 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
446 if (pEvReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) { 446 if (pEvReply->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) {
447 freereq = 0; 447 freereq = 0;
448 } else { 448 } else {
449 devtverboseprintk((MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p returns Request frame\n", 449 devtverboseprintk(ioc, printk(MYIOC_s_WARN_FMT "EVENT_NOTIFICATION reply %p returns Request frame\n",
450 ioc->name, pEvReply)); 450 ioc->name, pEvReply));
451 } 451 }
452 452
@@ -455,13 +455,13 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
455#endif 455#endif
456 456
457 } else if (func == MPI_FUNCTION_EVENT_ACK) { 457 } else if (func == MPI_FUNCTION_EVENT_ACK) {
458 dprintk((MYIOC_s_INFO_FMT "mpt_base_reply, EventAck reply received\n", 458 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mpt_base_reply, EventAck reply received\n",
459 ioc->name)); 459 ioc->name));
460 } else if (func == MPI_FUNCTION_CONFIG) { 460 } else if (func == MPI_FUNCTION_CONFIG) {
461 CONFIGPARMS *pCfg; 461 CONFIGPARMS *pCfg;
462 unsigned long flags; 462 unsigned long flags;
463 463
464 dcprintk((MYIOC_s_INFO_FMT "config_complete (mf=%p,mr=%p)\n", 464 dcprintk(ioc, printk(MYIOC_s_DEBUG_FMT "config_complete (mf=%p,mr=%p)\n",
465 ioc->name, mf, reply)); 465 ioc->name, mf, reply));
466 466
467 pCfg = * ((CONFIGPARMS **)((u8 *) mf + ioc->req_sz - sizeof(void *))); 467 pCfg = * ((CONFIGPARMS **)((u8 *) mf + ioc->req_sz - sizeof(void *)));
@@ -484,7 +484,7 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
484 u16 status; 484 u16 status;
485 485
486 status = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK; 486 status = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK;
487 dcprintk((KERN_NOTICE " IOCStatus=%04xh, IOCLogInfo=%08xh\n", 487 dcprintk(ioc, printk(KERN_NOTICE " IOCStatus=%04xh, IOCLogInfo=%08xh\n",
488 status, le32_to_cpu(pReply->IOCLogInfo))); 488 status, le32_to_cpu(pReply->IOCLogInfo)));
489 489
490 pCfg->status = status; 490 pCfg->status = status;
@@ -789,7 +789,7 @@ mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc)
789 printk(KERN_INFO "MF Count 0x%x Max 0x%x \n", ioc->mfcnt, ioc->req_depth); 789 printk(KERN_INFO "MF Count 0x%x Max 0x%x \n", ioc->mfcnt, ioc->req_depth);
790#endif 790#endif
791 791
792 dmfprintk((KERN_INFO MYNAM ": %s: mpt_get_msg_frame(%d,%d), got mf=%p\n", 792 dmfprintk(ioc, printk(KERN_INFO MYNAM ": %s: mpt_get_msg_frame(%d,%d), got mf=%p\n",
793 ioc->name, handle, ioc->id, mf)); 793 ioc->name, handle, ioc->id, mf));
794 return mf; 794 return mf;
795} 795}
@@ -820,27 +820,10 @@ mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
820 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx); 820 mf->u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx);
821 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0; 821 mf->u.frame.hwhdr.msgctxu.fld.rsvd = 0;
822 822
823#ifdef MPT_DEBUG_MSG_FRAME 823 DBG_DUMP_PUT_MSG_FRAME(ioc, (u32 *)mf);
824 {
825 u32 *m = mf->u.frame.hwhdr.__hdr;
826 int ii, n;
827
828 printk(KERN_INFO MYNAM ": %s: About to Put msg frame @ %p:\n" KERN_INFO " ",
829 ioc->name, m);
830 n = ioc->req_sz/4 - 1;
831 while (m[n] == 0)
832 n--;
833 for (ii=0; ii<=n; ii++) {
834 if (ii && ((ii%8)==0))
835 printk("\n" KERN_INFO " ");
836 printk(" %08x", le32_to_cpu(m[ii]));
837 }
838 printk("\n");
839 }
840#endif
841 824
842 mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx]; 825 mf_dma_addr = (ioc->req_frames_low_dma + req_offset) | ioc->RequestNB[req_idx];
843 dsgprintk((MYIOC_s_INFO_FMT "mf_dma_addr=%x req_idx=%d RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx, ioc->RequestNB[req_idx])); 826 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mf_dma_addr=%x req_idx=%d RequestNB=%x\n", ioc->name, mf_dma_addr, req_idx, ioc->RequestNB[req_idx]));
844 CHIPREG_WRITE32(&ioc->chip->RequestFifo, mf_dma_addr); 827 CHIPREG_WRITE32(&ioc->chip->RequestFifo, mf_dma_addr);
845} 828}
846 829
@@ -955,7 +938,7 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req,
955 if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE)) 938 if (!(CHIPREG_READ32(&ioc->chip->Doorbell) & MPI_DOORBELL_ACTIVE))
956 return -5; 939 return -5;
957 940
958 dhsprintk((KERN_INFO MYNAM ": %s: mpt_send_handshake_request start, WaitCnt=%d\n", 941 dhsprintk(ioc, printk(KERN_INFO MYNAM ": %s: mpt_send_handshake_request start, WaitCnt=%d\n",
959 ioc->name, ii)); 942 ioc->name, ii));
960 943
961 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); 944 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
@@ -1066,7 +1049,7 @@ mpt_host_page_alloc(MPT_ADAPTER *ioc, pIOCInit_t ioc_init)
1066 host_page_buffer_sz, 1049 host_page_buffer_sz,
1067 &ioc->HostPageBuffer_dma)) != NULL) { 1050 &ioc->HostPageBuffer_dma)) != NULL) {
1068 1051
1069 dinitprintk((MYIOC_s_INFO_FMT 1052 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1070 "host_page_buffer @ %p, dma @ %x, sz=%d bytes\n", 1053 "host_page_buffer @ %p, dma @ %x, sz=%d bytes\n",
1071 ioc->name, ioc->HostPageBuffer, 1054 ioc->name, ioc->HostPageBuffer,
1072 (u32)ioc->HostPageBuffer_dma, 1055 (u32)ioc->HostPageBuffer_dma,
@@ -1410,31 +1393,37 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1410 struct proc_dir_entry *dent, *ent; 1393 struct proc_dir_entry *dent, *ent;
1411#endif 1394#endif
1412 1395
1396 ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC);
1397 if (ioc == NULL) {
1398 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n");
1399 return -ENOMEM;
1400 }
1401
1402 ioc->debug_level = mpt_debug_level;
1403 if (mpt_debug_level)
1404 printk(KERN_INFO MYNAM ": mpt_debug_level=%xh\n", mpt_debug_level);
1405
1413 if (pci_enable_device(pdev)) 1406 if (pci_enable_device(pdev))
1414 return r; 1407 return r;
1415 1408
1416 dinitprintk((KERN_WARNING MYNAM ": mpt_adapter_install\n")); 1409 dinitprintk(ioc, printk(KERN_WARNING MYNAM ": mpt_adapter_install\n"));
1417 1410
1418 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) { 1411 if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
1419 dprintk((KERN_INFO MYNAM 1412 dprintk(ioc, printk(KERN_INFO MYNAM
1420 ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n")); 1413 ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n"));
1421 } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { 1414 } else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
1422 printk(KERN_WARNING MYNAM ": 32 BIT PCI BUS DMA ADDRESSING NOT SUPPORTED\n"); 1415 printk(KERN_WARNING MYNAM ": 32 BIT PCI BUS DMA ADDRESSING NOT SUPPORTED\n");
1423 return r; 1416 return r;
1424 } 1417 }
1425 1418
1426 if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) 1419 if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
1427 dprintk((KERN_INFO MYNAM 1420 dprintk(ioc, printk(KERN_INFO MYNAM
1428 ": Using 64 bit consistent mask\n")); 1421 ": Using 64 bit consistent mask\n"));
1429 else 1422 } else {
1430 dprintk((KERN_INFO MYNAM 1423 dprintk(ioc, printk(KERN_INFO MYNAM
1431 ": Not using 64 bit consistent mask\n")); 1424 ": Not using 64 bit consistent mask\n"));
1432
1433 ioc = kzalloc(sizeof(MPT_ADAPTER), GFP_ATOMIC);
1434 if (ioc == NULL) {
1435 printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n");
1436 return -ENOMEM;
1437 } 1425 }
1426
1438 ioc->alloc_total = sizeof(MPT_ADAPTER); 1427 ioc->alloc_total = sizeof(MPT_ADAPTER);
1439 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */ 1428 ioc->req_sz = MPT_DEFAULT_FRAME_SIZE; /* avoid div by zero! */
1440 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; 1429 ioc->reply_sz = MPT_REPLY_FRAME_SIZE;
@@ -1502,9 +1491,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1502 return -EINVAL; 1491 return -EINVAL;
1503 } 1492 }
1504 ioc->memmap = mem; 1493 ioc->memmap = mem;
1505 dinitprintk((KERN_INFO MYNAM ": mem = %p, mem_phys = %lx\n", mem, mem_phys)); 1494 dinitprintk(ioc, printk(KERN_INFO MYNAM ": mem = %p, mem_phys = %lx\n", mem, mem_phys));
1506 1495
1507 dinitprintk((KERN_INFO MYNAM ": facts @ %p, pfacts[0] @ %p\n", 1496 dinitprintk(ioc, printk(KERN_INFO MYNAM ": facts @ %p, pfacts[0] @ %p\n",
1508 &ioc->facts, &ioc->pfacts[0])); 1497 &ioc->facts, &ioc->pfacts[0]));
1509 1498
1510 ioc->mem_phys = mem_phys; 1499 ioc->mem_phys = mem_phys;
@@ -1830,6 +1819,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1830 int ret = 0; 1819 int ret = 0;
1831 int reset_alt_ioc_active = 0; 1820 int reset_alt_ioc_active = 0;
1832 int irq_allocated = 0; 1821 int irq_allocated = 0;
1822 u8 *a;
1833 1823
1834 printk(KERN_INFO MYNAM ": Initiating %s %s\n", 1824 printk(KERN_INFO MYNAM ": Initiating %s %s\n",
1835 ioc->name, reason==MPT_HOSTEVENT_IOC_BRINGUP ? "bringup" : "recovery"); 1825 ioc->name, reason==MPT_HOSTEVENT_IOC_BRINGUP ? "bringup" : "recovery");
@@ -1858,7 +1848,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1858 1848
1859 if (reset_alt_ioc_active && ioc->alt_ioc) { 1849 if (reset_alt_ioc_active && ioc->alt_ioc) {
1860 /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */ 1850 /* (re)Enable alt-IOC! (reply interrupt, FreeQ) */
1861 dprintk((KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n", 1851 dprintk(ioc, printk(KERN_INFO MYNAM
1852 ": alt-%s reply irq re-enabled\n",
1862 ioc->alt_ioc->name)); 1853 ioc->alt_ioc->name));
1863 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); 1854 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM);
1864 ioc->alt_ioc->active = 1; 1855 ioc->alt_ioc->active = 1;
@@ -1891,7 +1882,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1891 1882
1892 1883
1893 if (ii == 5) { 1884 if (ii == 5) {
1894 dinitprintk((MYIOC_s_INFO_FMT "Retry IocFacts failed rc=%x\n", ioc->name, rc)); 1885 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Retry IocFacts failed rc=%x\n", ioc->name, rc));
1895 ret = -2; 1886 ret = -2;
1896 } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { 1887 } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) {
1897 MptDisplayIocCapabilities(ioc); 1888 MptDisplayIocCapabilities(ioc);
@@ -1899,13 +1890,15 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1899 1890
1900 if (alt_ioc_ready) { 1891 if (alt_ioc_ready) {
1901 if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) { 1892 if ((rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason)) != 0) {
1902 dinitprintk((MYIOC_s_INFO_FMT "Initial Alt IocFacts failed rc=%x\n", ioc->name, rc)); 1893 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1894 "Initial Alt IocFacts failed rc=%x\n", ioc->name, rc));
1903 /* Retry - alt IOC was initialized once 1895 /* Retry - alt IOC was initialized once
1904 */ 1896 */
1905 rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason); 1897 rc = GetIocFacts(ioc->alt_ioc, sleepFlag, reason);
1906 } 1898 }
1907 if (rc) { 1899 if (rc) {
1908 dinitprintk((MYIOC_s_INFO_FMT "Retry Alt IocFacts failed rc=%x\n", ioc->name, rc)); 1900 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1901 "Retry Alt IocFacts failed rc=%x\n", ioc->name, rc));
1909 alt_ioc_ready = 0; 1902 alt_ioc_ready = 0;
1910 reset_alt_ioc_active = 0; 1903 reset_alt_ioc_active = 0;
1911 } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { 1904 } else if (reason == MPT_HOSTEVENT_IOC_BRINGUP) {
@@ -1938,7 +1931,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1938 ioc->pci_irq = ioc->pcidev->irq; 1931 ioc->pci_irq = ioc->pcidev->irq;
1939 pci_set_master(ioc->pcidev); /* ?? */ 1932 pci_set_master(ioc->pcidev); /* ?? */
1940 pci_set_drvdata(ioc->pcidev, ioc); 1933 pci_set_drvdata(ioc->pcidev, ioc);
1941 dprintk((KERN_INFO MYNAM ": %s installed at interrupt " 1934 dprintk(ioc, printk(KERN_INFO MYNAM ": %s installed at interrupt "
1942 "%d\n", ioc->name, ioc->pcidev->irq)); 1935 "%d\n", ioc->name, ioc->pcidev->irq));
1943 } 1936 }
1944 } 1937 }
@@ -1976,7 +1969,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1976 1969
1977 if (reason == MPT_HOSTEVENT_IOC_BRINGUP){ 1970 if (reason == MPT_HOSTEVENT_IOC_BRINGUP){
1978 if (ioc->upload_fw) { 1971 if (ioc->upload_fw) {
1979 ddlprintk((MYIOC_s_INFO_FMT 1972 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1980 "firmware upload required!\n", ioc->name)); 1973 "firmware upload required!\n", ioc->name));
1981 1974
1982 /* Controller is not operational, cannot do upload 1975 /* Controller is not operational, cannot do upload
@@ -1992,7 +1985,8 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1992 * chips (mpt_adapter_disable, 1985 * chips (mpt_adapter_disable,
1993 * mpt_diag_reset) 1986 * mpt_diag_reset)
1994 */ 1987 */
1995 ddlprintk((MYIOC_s_INFO_FMT ": mpt_upload: alt_%s has cached_fw=%p \n", 1988 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1989 ": mpt_upload: alt_%s has cached_fw=%p \n",
1996 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw)); 1990 ioc->name, ioc->alt_ioc->name, ioc->alt_ioc->cached_fw));
1997 ioc->alt_ioc->cached_fw = NULL; 1991 ioc->alt_ioc->cached_fw = NULL;
1998 } 1992 }
@@ -2012,7 +2006,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2012 2006
2013 if (reset_alt_ioc_active && ioc->alt_ioc) { 2007 if (reset_alt_ioc_active && ioc->alt_ioc) {
2014 /* (re)Enable alt-IOC! (reply interrupt) */ 2008 /* (re)Enable alt-IOC! (reply interrupt) */
2015 dinitprintk((KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n", 2009 dinitprintk(ioc, printk(KERN_INFO MYNAM ": alt-%s reply irq re-enabled\n",
2016 ioc->alt_ioc->name)); 2010 ioc->alt_ioc->name));
2017 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM); 2011 CHIPREG_WRITE32(&ioc->alt_ioc->chip->IntMask, MPI_HIM_DIM);
2018 ioc->alt_ioc->active = 1; 2012 ioc->alt_ioc->active = 1;
@@ -2064,13 +2058,13 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2064 * (LANPage1_t stuff) 2058 * (LANPage1_t stuff)
2065 */ 2059 */
2066 (void) GetLanConfigPages(ioc); 2060 (void) GetLanConfigPages(ioc);
2067#ifdef MPT_DEBUG 2061 a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow;
2068 { 2062 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2069 u8 *a = (u8*)&ioc->lan_cnfg_page1.HardwareAddressLow; 2063 "LanAddr = %02X:%02X:%02X:"
2070 dprintk((MYIOC_s_INFO_FMT "LanAddr = %02X:%02X:%02X:%02X:%02X:%02X\n", 2064 "%02X:%02X:%02X\n",
2071 ioc->name, a[5], a[4], a[3], a[2], a[1], a[0] )); 2065 ioc->name, a[5], a[4],
2072 } 2066 a[3], a[2], a[1], a[0] ));
2073#endif 2067
2074 } 2068 }
2075 } else { 2069 } else {
2076 /* Get NVRAM and adapter maximums from SPP 0 and 2 2070 /* Get NVRAM and adapter maximums from SPP 0 and 2
@@ -2107,15 +2101,17 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
2107 rc = handlers = 0; 2101 rc = handlers = 0;
2108 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 2102 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
2109 if ((ret == 0) && MptResetHandlers[ii]) { 2103 if ((ret == 0) && MptResetHandlers[ii]) {
2110 dprintk((MYIOC_s_INFO_FMT "Calling IOC post_reset handler #%d\n", 2104 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2111 ioc->name, ii)); 2105 "Calling IOC post_reset handler #%d\n",
2106 ioc->name, ii));
2112 rc += mpt_signal_reset(ii, ioc, MPT_IOC_POST_RESET); 2107 rc += mpt_signal_reset(ii, ioc, MPT_IOC_POST_RESET);
2113 handlers++; 2108 handlers++;
2114 } 2109 }
2115 2110
2116 if (alt_ioc_ready && MptResetHandlers[ii]) { 2111 if (alt_ioc_ready && MptResetHandlers[ii]) {
2117 drsprintk((MYIOC_s_INFO_FMT "Calling alt-%s post_reset handler #%d\n", 2112 drsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2118 ioc->name, ioc->alt_ioc->name, ii)); 2113 "Calling alt-%s post_reset handler #%d\n",
2114 ioc->name, ioc->alt_ioc->name, ii));
2119 rc += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_POST_RESET); 2115 rc += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_POST_RESET);
2120 handlers++; 2116 handlers++;
2121 } 2117 }
@@ -2153,7 +2149,7 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev)
2153 unsigned int func = PCI_FUNC(pdev->devfn); 2149 unsigned int func = PCI_FUNC(pdev->devfn);
2154 MPT_ADAPTER *ioc_srch; 2150 MPT_ADAPTER *ioc_srch;
2155 2151
2156 dprintk((MYIOC_s_INFO_FMT "PCI device %s devfn=%x/%x," 2152 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "PCI device %s devfn=%x/%x,"
2157 " searching for devfn match on %x or %x\n", 2153 " searching for devfn match on %x or %x\n",
2158 ioc->name, pci_name(pdev), pdev->bus->number, 2154 ioc->name, pci_name(pdev), pdev->bus->number,
2159 pdev->devfn, func-1, func+1)); 2155 pdev->devfn, func-1, func+1));
@@ -2178,7 +2174,7 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev)
2178 ioc_srch->name, ioc_srch->alt_ioc->name); 2174 ioc_srch->name, ioc_srch->alt_ioc->name);
2179 break; 2175 break;
2180 } 2176 }
2181 dprintk((KERN_INFO MYNAM ": FOUND! binding %s <==> %s\n", 2177 dprintk(ioc, printk(KERN_INFO MYNAM ": FOUND! binding %s <==> %s\n",
2182 ioc->name, ioc_srch->name)); 2178 ioc->name, ioc_srch->name));
2183 ioc_srch->alt_ioc = ioc; 2179 ioc_srch->alt_ioc = ioc;
2184 ioc->alt_ioc = ioc_srch; 2180 ioc->alt_ioc = ioc_srch;
@@ -2199,7 +2195,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2199 int ret; 2195 int ret;
2200 2196
2201 if (ioc->cached_fw != NULL) { 2197 if (ioc->cached_fw != NULL) {
2202 ddlprintk((KERN_INFO MYNAM ": mpt_adapter_disable: Pushing FW onto adapter\n")); 2198 ddlprintk(ioc, printk(KERN_INFO MYNAM ": mpt_adapter_disable: Pushing FW onto adapter\n"));
2203 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)ioc->cached_fw, NO_SLEEP)) < 0) { 2199 if ((ret = mpt_downloadboot(ioc, (MpiFwHeader_t *)ioc->cached_fw, NO_SLEEP)) < 0) {
2204 printk(KERN_WARNING MYNAM 2200 printk(KERN_WARNING MYNAM
2205 ": firmware downloadboot failure (%d)!\n", ret); 2201 ": firmware downloadboot failure (%d)!\n", ret);
@@ -2214,7 +2210,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2214 2210
2215 if (ioc->alloc != NULL) { 2211 if (ioc->alloc != NULL) {
2216 sz = ioc->alloc_sz; 2212 sz = ioc->alloc_sz;
2217 dexitprintk((KERN_INFO MYNAM ": %s.free @ %p, sz=%d bytes\n", 2213 dexitprintk(ioc, printk(KERN_INFO MYNAM ": %s.free @ %p, sz=%d bytes\n",
2218 ioc->name, ioc->alloc, ioc->alloc_sz)); 2214 ioc->name, ioc->alloc, ioc->alloc_sz));
2219 pci_free_consistent(ioc->pcidev, sz, 2215 pci_free_consistent(ioc->pcidev, sz,
2220 ioc->alloc, ioc->alloc_dma); 2216 ioc->alloc, ioc->alloc_dma);
@@ -2256,7 +2252,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2256 2252
2257 if (ioc->spi_data.pIocPg4 != NULL) { 2253 if (ioc->spi_data.pIocPg4 != NULL) {
2258 sz = ioc->spi_data.IocPg4Sz; 2254 sz = ioc->spi_data.IocPg4Sz;
2259 pci_free_consistent(ioc->pcidev, sz, 2255 pci_free_consistent(ioc->pcidev, sz,
2260 ioc->spi_data.pIocPg4, 2256 ioc->spi_data.pIocPg4,
2261 ioc->spi_data.IocPg4_dma); 2257 ioc->spi_data.IocPg4_dma);
2262 ioc->spi_data.pIocPg4 = NULL; 2258 ioc->spi_data.pIocPg4 = NULL;
@@ -2279,7 +2275,7 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2279 ": %s: host page buffers free failed (%d)!\n", 2275 ": %s: host page buffers free failed (%d)!\n",
2280 __FUNCTION__, ret); 2276 __FUNCTION__, ret);
2281 } 2277 }
2282 dexitprintk((KERN_INFO MYNAM ": %s HostPageBuffer free @ %p, sz=%d bytes\n", 2278 dexitprintk(ioc, printk(KERN_INFO MYNAM ": %s HostPageBuffer free @ %p, sz=%d bytes\n",
2283 ioc->name, ioc->HostPageBuffer, ioc->HostPageBuffer_sz)); 2279 ioc->name, ioc->HostPageBuffer, ioc->HostPageBuffer_sz));
2284 pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz, 2280 pci_free_consistent(ioc->pcidev, ioc->HostPageBuffer_sz,
2285 ioc->HostPageBuffer, 2281 ioc->HostPageBuffer,
@@ -2325,7 +2321,7 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
2325#if defined(CONFIG_MTRR) && 0 2321#if defined(CONFIG_MTRR) && 0
2326 if (ioc->mtrr_reg > 0) { 2322 if (ioc->mtrr_reg > 0) {
2327 mtrr_del(ioc->mtrr_reg, 0, 0); 2323 mtrr_del(ioc->mtrr_reg, 0, 0);
2328 dprintk((KERN_INFO MYNAM ": %s: MTRR region de-registered\n", ioc->name)); 2324 dprintk(ioc, printk(KERN_INFO MYNAM ": %s: MTRR region de-registered\n", ioc->name));
2329 } 2325 }
2330#endif 2326#endif
2331 2327
@@ -2333,7 +2329,7 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
2333 list_del(&ioc->list); 2329 list_del(&ioc->list);
2334 2330
2335 sz_last = ioc->alloc_total; 2331 sz_last = ioc->alloc_total;
2336 dprintk((KERN_INFO MYNAM ": %s: free'd %d of %d bytes\n", 2332 dprintk(ioc, printk(KERN_INFO MYNAM ": %s: free'd %d of %d bytes\n",
2337 ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first)); 2333 ioc->name, sz_first-sz_last+(int)sizeof(*ioc), sz_first));
2338 2334
2339 if (ioc->alt_ioc) 2335 if (ioc->alt_ioc)
@@ -2413,7 +2409,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2413 2409
2414 /* Get current [raw] IOC state */ 2410 /* Get current [raw] IOC state */
2415 ioc_state = mpt_GetIocState(ioc, 0); 2411 ioc_state = mpt_GetIocState(ioc, 0);
2416 dhsprintk((KERN_INFO MYNAM "::MakeIocReady, %s [raw] state=%08x\n", ioc->name, ioc_state)); 2412 dhsprintk(ioc, printk(KERN_INFO MYNAM "::MakeIocReady, %s [raw] state=%08x\n", ioc->name, ioc_state));
2417 2413
2418 /* 2414 /*
2419 * Check to see if IOC got left/stuck in doorbell handshake 2415 * Check to see if IOC got left/stuck in doorbell handshake
@@ -2444,7 +2440,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2444 * Hmmm... Did it get left operational? 2440 * Hmmm... Did it get left operational?
2445 */ 2441 */
2446 if ((ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_OPERATIONAL) { 2442 if ((ioc_state & MPI_IOC_STATE_MASK) == MPI_IOC_STATE_OPERATIONAL) {
2447 dinitprintk((MYIOC_s_INFO_FMT "IOC operational unexpected\n", 2443 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "IOC operational unexpected\n",
2448 ioc->name)); 2444 ioc->name));
2449 2445
2450 /* Check WhoInit. 2446 /* Check WhoInit.
@@ -2453,7 +2449,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2453 * Else, fall through to KickStart case 2449 * Else, fall through to KickStart case
2454 */ 2450 */
2455 whoinit = (ioc_state & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT; 2451 whoinit = (ioc_state & MPI_DOORBELL_WHO_INIT_MASK) >> MPI_DOORBELL_WHO_INIT_SHIFT;
2456 dinitprintk((KERN_INFO MYNAM 2452 dinitprintk(ioc, printk(KERN_INFO MYNAM
2457 ": whoinit 0x%x statefault %d force %d\n", 2453 ": whoinit 0x%x statefault %d force %d\n",
2458 whoinit, statefault, force)); 2454 whoinit, statefault, force));
2459 if (whoinit == MPI_WHOINIT_PCI_PEER) 2455 if (whoinit == MPI_WHOINIT_PCI_PEER)
@@ -2589,7 +2585,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
2589 get_facts.Function = MPI_FUNCTION_IOC_FACTS; 2585 get_facts.Function = MPI_FUNCTION_IOC_FACTS;
2590 /* Assert: All other get_facts fields are zero! */ 2586 /* Assert: All other get_facts fields are zero! */
2591 2587
2592 dinitprintk((MYIOC_s_INFO_FMT 2588 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2593 "Sending get IocFacts request req_sz=%d reply_sz=%d\n", 2589 "Sending get IocFacts request req_sz=%d reply_sz=%d\n",
2594 ioc->name, req_sz, reply_sz)); 2590 ioc->name, req_sz, reply_sz));
2595 2591
@@ -2691,8 +2687,9 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
2691 sz = sz >> 1; 2687 sz = sz >> 1;
2692 } 2688 }
2693 ioc->NBShiftFactor = shiftFactor; 2689 ioc->NBShiftFactor = shiftFactor;
2694 dinitprintk((MYIOC_s_INFO_FMT "NB_for_64_byte_frame=%x NBShiftFactor=%x BlockSize=%x\n", 2690 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT
2695 ioc->name, vv, shiftFactor, r)); 2691 "NB_for_64_byte_frame=%x NBShiftFactor=%x BlockSize=%x\n",
2692 ioc->name, vv, shiftFactor, r));
2696 2693
2697 if (reason == MPT_HOSTEVENT_IOC_BRINGUP) { 2694 if (reason == MPT_HOSTEVENT_IOC_BRINGUP) {
2698 /* 2695 /*
@@ -2704,9 +2701,9 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
2704 ioc->reply_sz = MPT_REPLY_FRAME_SIZE; 2701 ioc->reply_sz = MPT_REPLY_FRAME_SIZE;
2705 ioc->reply_depth = min_t(int, MPT_DEFAULT_REPLY_DEPTH, facts->ReplyQueueDepth); 2702 ioc->reply_depth = min_t(int, MPT_DEFAULT_REPLY_DEPTH, facts->ReplyQueueDepth);
2706 2703
2707 dinitprintk((MYIOC_s_INFO_FMT "reply_sz=%3d, reply_depth=%4d\n", 2704 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "reply_sz=%3d, reply_depth=%4d\n",
2708 ioc->name, ioc->reply_sz, ioc->reply_depth)); 2705 ioc->name, ioc->reply_sz, ioc->reply_depth));
2709 dinitprintk((MYIOC_s_INFO_FMT "req_sz =%3d, req_depth =%4d\n", 2706 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "req_sz =%3d, req_depth =%4d\n",
2710 ioc->name, ioc->req_sz, ioc->req_depth)); 2707 ioc->name, ioc->req_sz, ioc->req_depth));
2711 2708
2712 /* Get port facts! */ 2709 /* Get port facts! */
@@ -2765,7 +2762,7 @@ GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2765 get_pfacts.PortNumber = portnum; 2762 get_pfacts.PortNumber = portnum;
2766 /* Assert: All other get_pfacts fields are zero! */ 2763 /* Assert: All other get_pfacts fields are zero! */
2767 2764
2768 dinitprintk((MYIOC_s_INFO_FMT "Sending get PortFacts(%d) request\n", 2765 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending get PortFacts(%d) request\n",
2769 ioc->name, portnum)); 2766 ioc->name, portnum));
2770 2767
2771 /* No non-zero fields in the get_pfacts request are greater than 2768 /* No non-zero fields in the get_pfacts request are greater than
@@ -2841,12 +2838,12 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2841 ioc->upload_fw = 1; 2838 ioc->upload_fw = 1;
2842 else 2839 else
2843 ioc->upload_fw = 0; 2840 ioc->upload_fw = 0;
2844 ddlprintk((MYIOC_s_INFO_FMT "upload_fw %d facts.Flags=%x\n", 2841 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "upload_fw %d facts.Flags=%x\n",
2845 ioc->name, ioc->upload_fw, ioc->facts.Flags)); 2842 ioc->name, ioc->upload_fw, ioc->facts.Flags));
2846 2843
2847 ioc_init.MaxDevices = (U8)ioc->devices_per_bus; 2844 ioc_init.MaxDevices = (U8)ioc->devices_per_bus;
2848 ioc_init.MaxBuses = (U8)ioc->number_of_buses; 2845 ioc_init.MaxBuses = (U8)ioc->number_of_buses;
2849 dinitprintk((MYIOC_s_INFO_FMT "facts.MsgVersion=%x\n", 2846 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "facts.MsgVersion=%x\n",
2850 ioc->name, ioc->facts.MsgVersion)); 2847 ioc->name, ioc->facts.MsgVersion));
2851 if (ioc->facts.MsgVersion >= MPI_VERSION_01_05) { 2848 if (ioc->facts.MsgVersion >= MPI_VERSION_01_05) {
2852 // set MsgVersion and HeaderVersion host driver was built with 2849 // set MsgVersion and HeaderVersion host driver was built with
@@ -2877,7 +2874,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2877 ioc->facts.MaxDevices = ioc_init.MaxDevices; 2874 ioc->facts.MaxDevices = ioc_init.MaxDevices;
2878 ioc->facts.MaxBuses = ioc_init.MaxBuses; 2875 ioc->facts.MaxBuses = ioc_init.MaxBuses;
2879 2876
2880 dhsprintk((MYIOC_s_INFO_FMT "Sending IOCInit (req @ %p)\n", 2877 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending IOCInit (req @ %p)\n",
2881 ioc->name, &ioc_init)); 2878 ioc->name, &ioc_init));
2882 2879
2883 r = mpt_handshake_req_reply_wait(ioc, sizeof(IOCInit_t), (u32*)&ioc_init, 2880 r = mpt_handshake_req_reply_wait(ioc, sizeof(IOCInit_t), (u32*)&ioc_init,
@@ -2891,7 +2888,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2891 * since we don't even look at its contents. 2888 * since we don't even look at its contents.
2892 */ 2889 */
2893 2890
2894 dhsprintk((MYIOC_s_INFO_FMT "Sending PortEnable (req @ %p)\n", 2891 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending PortEnable (req @ %p)\n",
2895 ioc->name, &ioc_init)); 2892 ioc->name, &ioc_init));
2896 2893
2897 if ((r = SendPortEnable(ioc, 0, sleepFlag)) != 0) { 2894 if ((r = SendPortEnable(ioc, 0, sleepFlag)) != 0) {
@@ -2922,7 +2919,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2922 state = mpt_GetIocState(ioc, 1); 2919 state = mpt_GetIocState(ioc, 1);
2923 count++; 2920 count++;
2924 } 2921 }
2925 dinitprintk((MYIOC_s_INFO_FMT "INFO - Wait IOC_OPERATIONAL state (cnt=%d)\n", 2922 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "INFO - Wait IOC_OPERATIONAL state (cnt=%d)\n",
2926 ioc->name, count)); 2923 ioc->name, count));
2927 2924
2928 ioc->aen_event_read_flag=0; 2925 ioc->aen_event_read_flag=0;
@@ -2962,7 +2959,7 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2962/* port_enable.MsgFlags = 0; */ 2959/* port_enable.MsgFlags = 0; */
2963/* port_enable.MsgContext = 0; */ 2960/* port_enable.MsgContext = 0; */
2964 2961
2965 dinitprintk((MYIOC_s_INFO_FMT "Sending Port(%d)Enable (req @ %p)\n", 2962 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending Port(%d)Enable (req @ %p)\n",
2966 ioc->name, portnum, &port_enable)); 2963 ioc->name, portnum, &port_enable));
2967 2964
2968 /* RAID FW may take a long time to enable 2965 /* RAID FW may take a long time to enable
@@ -3015,7 +3012,7 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc)
3015 int sz; 3012 int sz;
3016 3013
3017 sz = ioc->facts.FWImageSize; 3014 sz = ioc->facts.FWImageSize;
3018 dinitprintk((KERN_INFO MYNAM "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n", 3015 dinitprintk(ioc, printk(KERN_INFO MYNAM "free_fw_memory: FW Image @ %p[%p], sz=%d[%x] bytes\n",
3019 ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); 3016 ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));
3020 pci_free_consistent(ioc->pcidev, sz, 3017 pci_free_consistent(ioc->pcidev, sz,
3021 ioc->cached_fw, ioc->cached_fw_dma); 3018 ioc->cached_fw, ioc->cached_fw_dma);
@@ -3059,7 +3056,7 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
3059 3056
3060 mpt_alloc_fw_memory(ioc, sz); 3057 mpt_alloc_fw_memory(ioc, sz);
3061 3058
3062 dinitprintk((KERN_INFO MYNAM ": FW Image @ %p[%p], sz=%d[%x] bytes\n", 3059 dinitprintk(ioc, printk(KERN_INFO MYNAM ": FW Image @ %p[%p], sz=%d[%x] bytes\n",
3063 ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz)); 3060 ioc->cached_fw, (void *)(ulong)ioc->cached_fw_dma, sz, sz));
3064 3061
3065 if (ioc->cached_fw == NULL) { 3062 if (ioc->cached_fw == NULL) {
@@ -3091,14 +3088,14 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
3091 mpt_add_sge(&request[sgeoffset], flagsLength, ioc->cached_fw_dma); 3088 mpt_add_sge(&request[sgeoffset], flagsLength, ioc->cached_fw_dma);
3092 3089
3093 sgeoffset += sizeof(u32) + sizeof(dma_addr_t); 3090 sgeoffset += sizeof(u32) + sizeof(dma_addr_t);
3094 dinitprintk((KERN_INFO MYNAM ": Sending FW Upload (req @ %p) sgeoffset=%d \n", 3091 dinitprintk(ioc, printk(KERN_INFO MYNAM ": Sending FW Upload (req @ %p) sgeoffset=%d \n",
3095 prequest, sgeoffset)); 3092 prequest, sgeoffset));
3096 DBG_DUMP_FW_REQUEST_FRAME(prequest) 3093 DBG_DUMP_FW_REQUEST_FRAME(ioc, (u32 *)prequest)
3097 3094
3098 ii = mpt_handshake_req_reply_wait(ioc, sgeoffset, (u32*)prequest, 3095 ii = mpt_handshake_req_reply_wait(ioc, sgeoffset, (u32*)prequest,
3099 reply_sz, (u16*)preply, 65 /*seconds*/, sleepFlag); 3096 reply_sz, (u16*)preply, 65 /*seconds*/, sleepFlag);
3100 3097
3101 dinitprintk((KERN_INFO MYNAM ": FW Upload completed rc=%x \n", ii)); 3098 dinitprintk(ioc, printk(KERN_INFO MYNAM ": FW Upload completed rc=%x \n", ii));
3102 3099
3103 cmdStatus = -EFAULT; 3100 cmdStatus = -EFAULT;
3104 if (ii == 0) { 3101 if (ii == 0) {
@@ -3113,13 +3110,13 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
3113 cmdStatus = 0; 3110 cmdStatus = 0;
3114 } 3111 }
3115 } 3112 }
3116 dinitprintk((MYIOC_s_INFO_FMT ": do_upload cmdStatus=%d \n", 3113 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": do_upload cmdStatus=%d \n",
3117 ioc->name, cmdStatus)); 3114 ioc->name, cmdStatus));
3118 3115
3119 3116
3120 if (cmdStatus) { 3117 if (cmdStatus) {
3121 3118
3122 ddlprintk((MYIOC_s_INFO_FMT ": fw upload failed, freeing image \n", 3119 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": fw upload failed, freeing image \n",
3123 ioc->name)); 3120 ioc->name));
3124 mpt_free_fw_memory(ioc); 3121 mpt_free_fw_memory(ioc);
3125 } 3122 }
@@ -3154,7 +3151,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3154 u32 load_addr; 3151 u32 load_addr;
3155 u32 ioc_state=0; 3152 u32 ioc_state=0;
3156 3153
3157 ddlprintk((MYIOC_s_INFO_FMT "downloadboot: fw size 0x%x (%d), FW Ptr %p\n", 3154 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "downloadboot: fw size 0x%x (%d), FW Ptr %p\n",
3158 ioc->name, pFwHeader->ImageSize, pFwHeader->ImageSize, pFwHeader)); 3155 ioc->name, pFwHeader->ImageSize, pFwHeader->ImageSize, pFwHeader));
3159 3156
3160 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF); 3157 CHIPREG_WRITE32(&ioc->chip->WriteSequence, 0xFF);
@@ -3179,7 +3176,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3179 for (count = 0; count < 30; count ++) { 3176 for (count = 0; count < 30; count ++) {
3180 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); 3177 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
3181 if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) { 3178 if (!(diag0val & MPI_DIAG_RESET_ADAPTER)) {
3182 ddlprintk((MYIOC_s_INFO_FMT "RESET_ADAPTER cleared, count=%d\n", 3179 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "RESET_ADAPTER cleared, count=%d\n",
3183 ioc->name, count)); 3180 ioc->name, count));
3184 break; 3181 break;
3185 } 3182 }
@@ -3192,7 +3189,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3192 } 3189 }
3193 3190
3194 if ( count == 30 ) { 3191 if ( count == 30 ) {
3195 ddlprintk((MYIOC_s_INFO_FMT "downloadboot failed! " 3192 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "downloadboot failed! "
3196 "Unable to get MPI_DIAG_DRWE mode, diag0val=%x\n", 3193 "Unable to get MPI_DIAG_DRWE mode, diag0val=%x\n",
3197 ioc->name, diag0val)); 3194 ioc->name, diag0val));
3198 return -3; 3195 return -3;
@@ -3218,10 +3215,10 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3218 pci_enable_io_access(ioc->pcidev); 3215 pci_enable_io_access(ioc->pcidev);
3219 3216
3220 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->LoadStartAddress); 3217 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->LoadStartAddress);
3221 ddlprintk((MYIOC_s_INFO_FMT "LoadStart addr written 0x%x \n", 3218 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "LoadStart addr written 0x%x \n",
3222 ioc->name, pFwHeader->LoadStartAddress)); 3219 ioc->name, pFwHeader->LoadStartAddress));
3223 3220
3224 ddlprintk((MYIOC_s_INFO_FMT "Write FW Image: 0x%x bytes @ %p\n", 3221 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Write FW Image: 0x%x bytes @ %p\n",
3225 ioc->name, fwSize*4, ptrFw)); 3222 ioc->name, fwSize*4, ptrFw));
3226 while (fwSize--) { 3223 while (fwSize--) {
3227 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++); 3224 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, *ptrFw++);
@@ -3236,7 +3233,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3236 fwSize = (pExtImage->ImageSize + 3) >> 2; 3233 fwSize = (pExtImage->ImageSize + 3) >> 2;
3237 ptrFw = (u32 *)pExtImage; 3234 ptrFw = (u32 *)pExtImage;
3238 3235
3239 ddlprintk((MYIOC_s_INFO_FMT "Write Ext Image: 0x%x (%d) bytes @ %p load_addr=%x\n", 3236 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Write Ext Image: 0x%x (%d) bytes @ %p load_addr=%x\n",
3240 ioc->name, fwSize*4, fwSize*4, ptrFw, load_addr)); 3237 ioc->name, fwSize*4, fwSize*4, ptrFw, load_addr));
3241 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr); 3238 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, load_addr);
3242 3239
@@ -3247,11 +3244,11 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3247 } 3244 }
3248 3245
3249 /* Write the IopResetVectorRegAddr */ 3246 /* Write the IopResetVectorRegAddr */
3250 ddlprintk((MYIOC_s_INFO_FMT "Write IopResetVector Addr=%x! \n", ioc->name, pFwHeader->IopResetRegAddr)); 3247 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Write IopResetVector Addr=%x! \n", ioc->name, pFwHeader->IopResetRegAddr));
3251 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->IopResetRegAddr); 3248 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwAddress, pFwHeader->IopResetRegAddr);
3252 3249
3253 /* Write the IopResetVectorValue */ 3250 /* Write the IopResetVectorValue */
3254 ddlprintk((MYIOC_s_INFO_FMT "Write IopResetVector Value=%x! \n", ioc->name, pFwHeader->IopResetVectorValue)); 3251 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Write IopResetVector Value=%x! \n", ioc->name, pFwHeader->IopResetVectorValue));
3255 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, pFwHeader->IopResetVectorValue); 3252 CHIPREG_PIO_WRITE32(&ioc->pio_chip->DiagRwData, pFwHeader->IopResetVectorValue);
3256 3253
3257 /* Clear the internal flash bad bit - autoincrementing register, 3254 /* Clear the internal flash bad bit - autoincrementing register,
@@ -3285,11 +3282,11 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3285 pci_disable_io_access(ioc->pcidev); 3282 pci_disable_io_access(ioc->pcidev);
3286 3283
3287 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); 3284 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
3288 ddlprintk((MYIOC_s_INFO_FMT "downloadboot diag0val=%x, " 3285 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "downloadboot diag0val=%x, "
3289 "turning off PREVENT_IOC_BOOT, DISABLE_ARM, RW_ENABLE\n", 3286 "turning off PREVENT_IOC_BOOT, DISABLE_ARM, RW_ENABLE\n",
3290 ioc->name, diag0val)); 3287 ioc->name, diag0val));
3291 diag0val &= ~(MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM | MPI_DIAG_RW_ENABLE); 3288 diag0val &= ~(MPI_DIAG_PREVENT_IOC_BOOT | MPI_DIAG_DISABLE_ARM | MPI_DIAG_RW_ENABLE);
3292 ddlprintk((MYIOC_s_INFO_FMT "downloadboot now diag0val=%x\n", 3289 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "downloadboot now diag0val=%x\n",
3293 ioc->name, diag0val)); 3290 ioc->name, diag0val));
3294 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val); 3291 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val);
3295 3292
@@ -3300,7 +3297,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3300 ioc_state = mpt_GetIocState(ioc, 0); 3297 ioc_state = mpt_GetIocState(ioc, 0);
3301 if ( (GetIocFacts(ioc, sleepFlag, 3298 if ( (GetIocFacts(ioc, sleepFlag,
3302 MPT_HOSTEVENT_IOC_BRINGUP)) != 0 ) { 3299 MPT_HOSTEVENT_IOC_BRINGUP)) != 0 ) {
3303 ddlprintk((MYIOC_s_INFO_FMT "GetIocFacts failed: IocState=%x\n", 3300 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "GetIocFacts failed: IocState=%x\n",
3304 ioc->name, ioc_state)); 3301 ioc->name, ioc_state));
3305 return -EFAULT; 3302 return -EFAULT;
3306 } 3303 }
@@ -3308,17 +3305,20 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3308 3305
3309 for (count=0; count<HZ*20; count++) { 3306 for (count=0; count<HZ*20; count++) {
3310 if ((ioc_state = mpt_GetIocState(ioc, 0)) & MPI_IOC_STATE_READY) { 3307 if ((ioc_state = mpt_GetIocState(ioc, 0)) & MPI_IOC_STATE_READY) {
3311 ddlprintk((MYIOC_s_INFO_FMT "downloadboot successful! (count=%d) IocState=%x\n", 3308 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3312 ioc->name, count, ioc_state)); 3309 "downloadboot successful! (count=%d) IocState=%x\n",
3310 ioc->name, count, ioc_state));
3313 if (ioc->bus_type == SAS) { 3311 if (ioc->bus_type == SAS) {
3314 return 0; 3312 return 0;
3315 } 3313 }
3316 if ((SendIocInit(ioc, sleepFlag)) != 0) { 3314 if ((SendIocInit(ioc, sleepFlag)) != 0) {
3317 ddlprintk((MYIOC_s_INFO_FMT "downloadboot: SendIocInit failed\n", 3315 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3316 "downloadboot: SendIocInit failed\n",
3318 ioc->name)); 3317 ioc->name));
3319 return -EFAULT; 3318 return -EFAULT;
3320 } 3319 }
3321 ddlprintk((MYIOC_s_INFO_FMT "downloadboot: SendIocInit successful\n", 3320 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3321 "downloadboot: SendIocInit successful\n",
3322 ioc->name)); 3322 ioc->name));
3323 return 0; 3323 return 0;
3324 } 3324 }
@@ -3328,8 +3328,8 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3328 mdelay (10); 3328 mdelay (10);
3329 } 3329 }
3330 } 3330 }
3331 ddlprintk((MYIOC_s_INFO_FMT "downloadboot failed! IocState=%x\n", 3331 ddlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3332 ioc->name, ioc_state)); 3332 "downloadboot failed! IocState=%x\n",ioc->name, ioc_state));
3333 return -EFAULT; 3333 return -EFAULT;
3334} 3334}
3335 3335
@@ -3366,7 +3366,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3366 u32 ioc_state=0; 3366 u32 ioc_state=0;
3367 int cnt,cntdn; 3367 int cnt,cntdn;
3368 3368
3369 dinitprintk((KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name)); 3369 dinitprintk(ioc, printk(KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name));
3370 if (ioc->bus_type == SPI) { 3370 if (ioc->bus_type == SPI) {
3371 /* Always issue a Msg Unit Reset first. This will clear some 3371 /* Always issue a Msg Unit Reset first. This will clear some
3372 * SCSI bus hang conditions. 3372 * SCSI bus hang conditions.
@@ -3384,14 +3384,14 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3384 if (hard_reset_done < 0) 3384 if (hard_reset_done < 0)
3385 return hard_reset_done; 3385 return hard_reset_done;
3386 3386
3387 dinitprintk((MYIOC_s_INFO_FMT "Diagnostic reset successful!\n", 3387 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Diagnostic reset successful!\n",
3388 ioc->name)); 3388 ioc->name));
3389 3389
3390 cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 2; /* 2 seconds */ 3390 cntdn = ((sleepFlag == CAN_SLEEP) ? HZ : 1000) * 2; /* 2 seconds */
3391 for (cnt=0; cnt<cntdn; cnt++) { 3391 for (cnt=0; cnt<cntdn; cnt++) {
3392 ioc_state = mpt_GetIocState(ioc, 1); 3392 ioc_state = mpt_GetIocState(ioc, 1);
3393 if ((ioc_state == MPI_IOC_STATE_READY) || (ioc_state == MPI_IOC_STATE_OPERATIONAL)) { 3393 if ((ioc_state == MPI_IOC_STATE_READY) || (ioc_state == MPI_IOC_STATE_OPERATIONAL)) {
3394 dinitprintk((MYIOC_s_INFO_FMT "KickStart successful! (cnt=%d)\n", 3394 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "KickStart successful! (cnt=%d)\n",
3395 ioc->name, cnt)); 3395 ioc->name, cnt));
3396 return hard_reset_done; 3396 return hard_reset_done;
3397 } 3397 }
@@ -3434,15 +3434,13 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3434 u32 doorbell; 3434 u32 doorbell;
3435 int hard_reset_done = 0; 3435 int hard_reset_done = 0;
3436 int count = 0; 3436 int count = 0;
3437#ifdef MPT_DEBUG
3438 u32 diag1val = 0; 3437 u32 diag1val = 0;
3439#endif
3440 3438
3441 /* Clear any existing interrupts */ 3439 /* Clear any existing interrupts */
3442 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0); 3440 CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
3443 3441
3444 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) { 3442 if (ioc->pcidev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) {
3445 drsprintk((MYIOC_s_WARN_FMT "%s: Doorbell=%p; 1078 reset " 3443 drsprintk(ioc, printk(MYIOC_s_WARN_FMT "%s: Doorbell=%p; 1078 reset "
3446 "address=%p\n", ioc->name, __FUNCTION__, 3444 "address=%p\n", ioc->name, __FUNCTION__,
3447 &ioc->chip->Doorbell, &ioc->chip->Reset_1078)); 3445 &ioc->chip->Doorbell, &ioc->chip->Reset_1078));
3448 CHIPREG_WRITE32(&ioc->chip->Reset_1078, 0x07); 3446 CHIPREG_WRITE32(&ioc->chip->Reset_1078, 0x07);
@@ -3455,7 +3453,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3455 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell); 3453 doorbell = CHIPREG_READ32(&ioc->chip->Doorbell);
3456 doorbell &= MPI_IOC_STATE_MASK; 3454 doorbell &= MPI_IOC_STATE_MASK;
3457 3455
3458 drsprintk((MYIOC_s_INFO_FMT 3456 drsprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3459 "looking for READY STATE: doorbell=%x" 3457 "looking for READY STATE: doorbell=%x"
3460 " count=%d\n", 3458 " count=%d\n",
3461 ioc->name, doorbell, count)); 3459 ioc->name, doorbell, count));
@@ -3475,12 +3473,12 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3475 /* Use "Diagnostic reset" method! (only thing available!) */ 3473 /* Use "Diagnostic reset" method! (only thing available!) */
3476 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); 3474 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
3477 3475
3478#ifdef MPT_DEBUG 3476 if (ioc->debug_level & MPT_DEBUG) {
3479 if (ioc->alt_ioc) 3477 if (ioc->alt_ioc)
3480 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); 3478 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic);
3481 dprintk((MYIOC_s_INFO_FMT "DbG1: diag0=%08x, diag1=%08x\n", 3479 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "DbG1: diag0=%08x, diag1=%08x\n",
3482 ioc->name, diag0val, diag1val)); 3480 ioc->name, diag0val, diag1val));
3483#endif 3481 }
3484 3482
3485 /* Do the reset if we are told to ignore the reset history 3483 /* Do the reset if we are told to ignore the reset history
3486 * or if the reset history is 0 3484 * or if the reset history is 0
@@ -3514,16 +3512,16 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3514 3512
3515 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); 3513 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
3516 3514
3517 dprintk((MYIOC_s_INFO_FMT "Wrote magic DiagWriteEn sequence (%x)\n", 3515 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Wrote magic DiagWriteEn sequence (%x)\n",
3518 ioc->name, diag0val)); 3516 ioc->name, diag0val));
3519 } 3517 }
3520 3518
3521#ifdef MPT_DEBUG 3519 if (ioc->debug_level & MPT_DEBUG) {
3522 if (ioc->alt_ioc) 3520 if (ioc->alt_ioc)
3523 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); 3521 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic);
3524 dprintk((MYIOC_s_INFO_FMT "DbG2: diag0=%08x, diag1=%08x\n", 3522 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "DbG2: diag0=%08x, diag1=%08x\n",
3525 ioc->name, diag0val, diag1val)); 3523 ioc->name, diag0val, diag1val));
3526#endif 3524 }
3527 /* 3525 /*
3528 * Disable the ARM (Bug fix) 3526 * Disable the ARM (Bug fix)
3529 * 3527 *
@@ -3537,7 +3535,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3537 */ 3535 */
3538 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER); 3536 CHIPREG_WRITE32(&ioc->chip->Diagnostic, diag0val | MPI_DIAG_RESET_ADAPTER);
3539 hard_reset_done = 1; 3537 hard_reset_done = 1;
3540 dprintk((MYIOC_s_INFO_FMT "Diagnostic reset performed\n", 3538 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Diagnostic reset performed\n",
3541 ioc->name)); 3539 ioc->name));
3542 3540
3543 /* 3541 /*
@@ -3552,12 +3550,14 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3552 3550
3553 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 3551 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
3554 if (MptResetHandlers[ii]) { 3552 if (MptResetHandlers[ii]) {
3555 dprintk((MYIOC_s_INFO_FMT "Calling IOC pre_reset handler #%d\n", 3553 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3556 ioc->name, ii)); 3554 "Calling IOC pre_reset handler #%d\n",
3555 ioc->name, ii));
3557 r += mpt_signal_reset(ii, ioc, MPT_IOC_PRE_RESET); 3556 r += mpt_signal_reset(ii, ioc, MPT_IOC_PRE_RESET);
3558 if (ioc->alt_ioc) { 3557 if (ioc->alt_ioc) {
3559 dprintk((MYIOC_s_INFO_FMT "Calling alt-%s pre_reset handler #%d\n", 3558 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3560 ioc->name, ioc->alt_ioc->name, ii)); 3559 "Calling alt-%s pre_reset handler #%d\n",
3560 ioc->name, ioc->alt_ioc->name, ii));
3561 r += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_PRE_RESET); 3561 r += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_PRE_RESET);
3562 } 3562 }
3563 } 3563 }
@@ -3580,7 +3580,7 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3580 break; 3580 break;
3581 } 3581 }
3582 3582
3583 dprintk((MYIOC_s_INFO_FMT "cached_fw: diag0val=%x count=%d\n", 3583 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "cached_fw: diag0val=%x count=%d\n",
3584 iocp->name, diag0val, count)); 3584 iocp->name, diag0val, count));
3585 /* wait 1 sec */ 3585 /* wait 1 sec */
3586 if (sleepFlag == CAN_SLEEP) { 3586 if (sleepFlag == CAN_SLEEP) {
@@ -3621,12 +3621,12 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3621 } 3621 }
3622 3622
3623 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic); 3623 diag0val = CHIPREG_READ32(&ioc->chip->Diagnostic);
3624#ifdef MPT_DEBUG 3624 if (ioc->debug_level & MPT_DEBUG) {
3625 if (ioc->alt_ioc) 3625 if (ioc->alt_ioc)
3626 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); 3626 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic);
3627 dprintk((MYIOC_s_INFO_FMT "DbG3: diag0=%08x, diag1=%08x\n", 3627 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "DbG3: diag0=%08x, diag1=%08x\n",
3628 ioc->name, diag0val, diag1val)); 3628 ioc->name, diag0val, diag1val));
3629#endif 3629 }
3630 3630
3631 /* Clear RESET_HISTORY bit! Place board in the 3631 /* Clear RESET_HISTORY bit! Place board in the
3632 * diagnostic mode to update the diag register. 3632 * diagnostic mode to update the diag register.
@@ -3680,12 +3680,12 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3680 return -3; 3680 return -3;
3681 } 3681 }
3682 3682
3683#ifdef MPT_DEBUG 3683 if (ioc->debug_level & MPT_DEBUG) {
3684 if (ioc->alt_ioc) 3684 if (ioc->alt_ioc)
3685 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic); 3685 diag1val = CHIPREG_READ32(&ioc->alt_ioc->chip->Diagnostic);
3686 dprintk((MYIOC_s_INFO_FMT "DbG4: diag0=%08x, diag1=%08x\n", 3686 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "DbG4: diag0=%08x, diag1=%08x\n",
3687 ioc->name, diag0val, diag1val)); 3687 ioc->name, diag0val, diag1val));
3688#endif 3688 }
3689 3689
3690 /* 3690 /*
3691 * Reset flag that says we've enabled event notification 3691 * Reset flag that says we've enabled event notification
@@ -3717,7 +3717,7 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag)
3717 u32 state; 3717 u32 state;
3718 int cntdn, count; 3718 int cntdn, count;
3719 3719
3720 drsprintk((KERN_INFO MYNAM ": %s: Sending IOC reset(0x%02x)!\n", 3720 drsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending IOC reset(0x%02x)!\n",
3721 ioc->name, reset_type)); 3721 ioc->name, reset_type));
3722 CHIPREG_WRITE32(&ioc->chip->Doorbell, reset_type<<MPI_DOORBELL_FUNCTION_SHIFT); 3722 CHIPREG_WRITE32(&ioc->chip->Doorbell, reset_type<<MPI_DOORBELL_FUNCTION_SHIFT);
3723 if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0) 3723 if ((r = WaitForDoorbellAck(ioc, 5, sleepFlag)) < 0)
@@ -3782,14 +3782,14 @@ initChainBuffers(MPT_ADAPTER *ioc)
3782 return -1; 3782 return -1;
3783 3783
3784 ioc->ReqToChain = (int *) mem; 3784 ioc->ReqToChain = (int *) mem;
3785 dinitprintk((KERN_INFO MYNAM ": %s ReqToChain alloc @ %p, sz=%d bytes\n", 3785 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ReqToChain alloc @ %p, sz=%d bytes\n",
3786 ioc->name, mem, sz)); 3786 ioc->name, mem, sz));
3787 mem = kmalloc(sz, GFP_ATOMIC); 3787 mem = kmalloc(sz, GFP_ATOMIC);
3788 if (mem == NULL) 3788 if (mem == NULL)
3789 return -1; 3789 return -1;
3790 3790
3791 ioc->RequestNB = (int *) mem; 3791 ioc->RequestNB = (int *) mem;
3792 dinitprintk((KERN_INFO MYNAM ": %s RequestNB alloc @ %p, sz=%d bytes\n", 3792 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "RequestNB alloc @ %p, sz=%d bytes\n",
3793 ioc->name, mem, sz)); 3793 ioc->name, mem, sz));
3794 } 3794 }
3795 for (ii = 0; ii < ioc->req_depth; ii++) { 3795 for (ii = 0; ii < ioc->req_depth; ii++) {
@@ -3819,7 +3819,7 @@ initChainBuffers(MPT_ADAPTER *ioc)
3819 numSGE = 1 + (scale - 1) * (ioc->facts.MaxChainDepth-1) + scale + 3819 numSGE = 1 + (scale - 1) * (ioc->facts.MaxChainDepth-1) + scale +
3820 (ioc->req_sz - 64) / (sizeof(dma_addr_t) + sizeof(u32)); 3820 (ioc->req_sz - 64) / (sizeof(dma_addr_t) + sizeof(u32));
3821 } 3821 }
3822 dinitprintk((KERN_INFO MYNAM ": %s num_sge=%d numSGE=%d\n", 3822 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "num_sge=%d numSGE=%d\n",
3823 ioc->name, num_sge, numSGE)); 3823 ioc->name, num_sge, numSGE));
3824 3824
3825 if ( numSGE > MPT_SCSI_SG_DEPTH ) 3825 if ( numSGE > MPT_SCSI_SG_DEPTH )
@@ -3832,7 +3832,7 @@ initChainBuffers(MPT_ADAPTER *ioc)
3832 } 3832 }
3833 num_chain++; 3833 num_chain++;
3834 3834
3835 dinitprintk((KERN_INFO MYNAM ": %s Now numSGE=%d num_sge=%d num_chain=%d\n", 3835 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Now numSGE=%d num_sge=%d num_chain=%d\n",
3836 ioc->name, numSGE, num_sge, num_chain)); 3836 ioc->name, numSGE, num_sge, num_chain));
3837 3837
3838 if (ioc->bus_type == SPI) 3838 if (ioc->bus_type == SPI)
@@ -3849,7 +3849,7 @@ initChainBuffers(MPT_ADAPTER *ioc)
3849 return -1; 3849 return -1;
3850 3850
3851 ioc->ChainToChain = (int *) mem; 3851 ioc->ChainToChain = (int *) mem;
3852 dinitprintk((KERN_INFO MYNAM ": %s ChainToChain alloc @ %p, sz=%d bytes\n", 3852 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ChainToChain alloc @ %p, sz=%d bytes\n",
3853 ioc->name, mem, sz)); 3853 ioc->name, mem, sz));
3854 } else { 3854 } else {
3855 mem = (u8 *) ioc->ChainToChain; 3855 mem = (u8 *) ioc->ChainToChain;
@@ -3885,22 +3885,22 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
3885 return -1; 3885 return -1;
3886 3886
3887 total_size = reply_sz = (ioc->reply_sz * ioc->reply_depth); 3887 total_size = reply_sz = (ioc->reply_sz * ioc->reply_depth);
3888 dinitprintk((KERN_INFO MYNAM ": %s.ReplyBuffer sz=%d bytes, ReplyDepth=%d\n", 3888 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ReplyBuffer sz=%d bytes, ReplyDepth=%d\n",
3889 ioc->name, ioc->reply_sz, ioc->reply_depth)); 3889 ioc->name, ioc->reply_sz, ioc->reply_depth));
3890 dinitprintk((KERN_INFO MYNAM ": %s.ReplyBuffer sz=%d[%x] bytes\n", 3890 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ReplyBuffer sz=%d[%x] bytes\n",
3891 ioc->name, reply_sz, reply_sz)); 3891 ioc->name, reply_sz, reply_sz));
3892 3892
3893 sz = (ioc->req_sz * ioc->req_depth); 3893 sz = (ioc->req_sz * ioc->req_depth);
3894 dinitprintk((KERN_INFO MYNAM ": %s.RequestBuffer sz=%d bytes, RequestDepth=%d\n", 3894 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "RequestBuffer sz=%d bytes, RequestDepth=%d\n",
3895 ioc->name, ioc->req_sz, ioc->req_depth)); 3895 ioc->name, ioc->req_sz, ioc->req_depth));
3896 dinitprintk((KERN_INFO MYNAM ": %s.RequestBuffer sz=%d[%x] bytes\n", 3896 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "RequestBuffer sz=%d[%x] bytes\n",
3897 ioc->name, sz, sz)); 3897 ioc->name, sz, sz));
3898 total_size += sz; 3898 total_size += sz;
3899 3899
3900 sz = num_chain * ioc->req_sz; /* chain buffer pool size */ 3900 sz = num_chain * ioc->req_sz; /* chain buffer pool size */
3901 dinitprintk((KERN_INFO MYNAM ": %s.ChainBuffer sz=%d bytes, ChainDepth=%d\n", 3901 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ChainBuffer sz=%d bytes, ChainDepth=%d\n",
3902 ioc->name, ioc->req_sz, num_chain)); 3902 ioc->name, ioc->req_sz, num_chain));
3903 dinitprintk((KERN_INFO MYNAM ": %s.ChainBuffer sz=%d[%x] bytes num_chain=%d\n", 3903 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ChainBuffer sz=%d[%x] bytes num_chain=%d\n",
3904 ioc->name, sz, sz, num_chain)); 3904 ioc->name, sz, sz, num_chain));
3905 3905
3906 total_size += sz; 3906 total_size += sz;
@@ -3911,7 +3911,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
3911 goto out_fail; 3911 goto out_fail;
3912 } 3912 }
3913 3913
3914 dinitprintk((KERN_INFO MYNAM ": %s.Total alloc @ %p[%p], sz=%d[%x] bytes\n", 3914 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Total alloc @ %p[%p], sz=%d[%x] bytes\n",
3915 ioc->name, mem, (void *)(ulong)alloc_dma, total_size, total_size)); 3915 ioc->name, mem, (void *)(ulong)alloc_dma, total_size, total_size));
3916 3916
3917 memset(mem, 0, total_size); 3917 memset(mem, 0, total_size);
@@ -3922,7 +3922,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
3922 ioc->reply_frames = (MPT_FRAME_HDR *) mem; 3922 ioc->reply_frames = (MPT_FRAME_HDR *) mem;
3923 ioc->reply_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF); 3923 ioc->reply_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF);
3924 3924
3925 dinitprintk((KERN_INFO MYNAM ": %s ReplyBuffers @ %p[%p]\n", 3925 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ReplyBuffers @ %p[%p]\n",
3926 ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma)); 3926 ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma));
3927 3927
3928 alloc_dma += reply_sz; 3928 alloc_dma += reply_sz;
@@ -3933,7 +3933,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
3933 ioc->req_frames = (MPT_FRAME_HDR *) mem; 3933 ioc->req_frames = (MPT_FRAME_HDR *) mem;
3934 ioc->req_frames_dma = alloc_dma; 3934 ioc->req_frames_dma = alloc_dma;
3935 3935
3936 dinitprintk((KERN_INFO MYNAM ": %s RequestBuffers @ %p[%p]\n", 3936 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "RequestBuffers @ %p[%p]\n",
3937 ioc->name, mem, (void *)(ulong)alloc_dma)); 3937 ioc->name, mem, (void *)(ulong)alloc_dma));
3938 3938
3939 ioc->req_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF); 3939 ioc->req_frames_low_dma = (u32) (alloc_dma & 0xFFFFFFFF);
@@ -3947,7 +3947,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
3947 ioc->mtrr_reg = mtrr_add(ioc->req_frames_dma, 3947 ioc->mtrr_reg = mtrr_add(ioc->req_frames_dma,
3948 sz, 3948 sz,
3949 MTRR_TYPE_WRCOMB, 1); 3949 MTRR_TYPE_WRCOMB, 1);
3950 dprintk((MYIOC_s_INFO_FMT "MTRR region registered (base:size=%08x:%x)\n", 3950 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "MTRR region registered (base:size=%08x:%x)\n",
3951 ioc->name, ioc->req_frames_dma, sz)); 3951 ioc->name, ioc->req_frames_dma, sz));
3952#endif 3952#endif
3953 3953
@@ -3959,7 +3959,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
3959 ioc->ChainBuffer = mem; 3959 ioc->ChainBuffer = mem;
3960 ioc->ChainBufferDMA = alloc_dma; 3960 ioc->ChainBufferDMA = alloc_dma;
3961 3961
3962 dinitprintk((KERN_INFO MYNAM " :%s ChainBuffers @ %p(%p)\n", 3962 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ChainBuffers @ %p(%p)\n",
3963 ioc->name, ioc->ChainBuffer, (void *)(ulong)ioc->ChainBufferDMA)); 3963 ioc->name, ioc->ChainBuffer, (void *)(ulong)ioc->ChainBufferDMA));
3964 3964
3965 /* Initialize the free chain Q. 3965 /* Initialize the free chain Q.
@@ -4004,7 +4004,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
4004 4004
4005 ioc->sense_buf_low_dma = (u32) (ioc->sense_buf_pool_dma & 0xFFFFFFFF); 4005 ioc->sense_buf_low_dma = (u32) (ioc->sense_buf_pool_dma & 0xFFFFFFFF);
4006 ioc->alloc_total += sz; 4006 ioc->alloc_total += sz;
4007 dinitprintk((KERN_INFO MYNAM ": %s.SenseBuffers @ %p[%p]\n", 4007 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SenseBuffers @ %p[%p]\n",
4008 ioc->name, ioc->sense_buf_pool, (void *)(ulong)ioc->sense_buf_pool_dma)); 4008 ioc->name, ioc->sense_buf_pool, (void *)(ulong)ioc->sense_buf_pool_dma));
4009 4009
4010 } 4010 }
@@ -4012,7 +4012,7 @@ PrimeIocFifos(MPT_ADAPTER *ioc)
4012 /* Post Reply frames to FIFO 4012 /* Post Reply frames to FIFO
4013 */ 4013 */
4014 alloc_dma = ioc->alloc_dma; 4014 alloc_dma = ioc->alloc_dma;
4015 dinitprintk((KERN_INFO MYNAM ": %s.ReplyBuffers @ %p[%p]\n", 4015 dinitprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ReplyBuffers @ %p[%p]\n",
4016 ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma)); 4016 ioc->name, ioc->reply_frames, (void *)(ulong)alloc_dma));
4017 4017
4018 for (i = 0; i < ioc->reply_depth; i++) { 4018 for (i = 0; i < ioc->reply_depth; i++) {
@@ -4093,7 +4093,7 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,
4093 if ((t = WaitForDoorbellInt(ioc, 5, sleepFlag)) < 0) 4093 if ((t = WaitForDoorbellInt(ioc, 5, sleepFlag)) < 0)
4094 failcnt++; 4094 failcnt++;
4095 4095
4096 dhsprintk((MYIOC_s_INFO_FMT "HandShake request start reqBytes=%d, WaitCnt=%d%s\n", 4096 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HandShake request start reqBytes=%d, WaitCnt=%d%s\n",
4097 ioc->name, reqBytes, t, failcnt ? " - MISSING DOORBELL HANDSHAKE!" : "")); 4097 ioc->name, reqBytes, t, failcnt ? " - MISSING DOORBELL HANDSHAKE!" : ""));
4098 4098
4099 /* Read doorbell and check for active bit */ 4099 /* Read doorbell and check for active bit */
@@ -4128,10 +4128,10 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,
4128 failcnt++; 4128 failcnt++;
4129 } 4129 }
4130 4130
4131 dhsprintk((KERN_INFO MYNAM ": Handshake request frame (@%p) header\n", req)); 4131 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Handshake request frame (@%p) header\n", ioc->name, req));
4132 DBG_DUMP_REQUEST_FRAME_HDR(req) 4132 DBG_DUMP_REQUEST_FRAME_HDR(ioc, (u32 *)req)
4133 4133
4134 dhsprintk((MYIOC_s_INFO_FMT "HandShake request post done, WaitCnt=%d%s\n", 4134 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HandShake request post done, WaitCnt=%d%s\n",
4135 ioc->name, t, failcnt ? " - MISSING DOORBELL ACK!" : "")); 4135 ioc->name, t, failcnt ? " - MISSING DOORBELL ACK!" : ""));
4136 4136
4137 /* 4137 /*
@@ -4140,7 +4140,7 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,
4140 if (!failcnt && (t = WaitForDoorbellReply(ioc, maxwait, sleepFlag)) < 0) 4140 if (!failcnt && (t = WaitForDoorbellReply(ioc, maxwait, sleepFlag)) < 0)
4141 failcnt++; 4141 failcnt++;
4142 4142
4143 dhsprintk((MYIOC_s_INFO_FMT "HandShake reply count=%d%s\n", 4143 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HandShake reply count=%d%s\n",
4144 ioc->name, t, failcnt ? " - MISSING DOORBELL REPLY!" : "")); 4144 ioc->name, t, failcnt ? " - MISSING DOORBELL REPLY!" : ""));
4145 4145
4146 /* 4146 /*
@@ -4196,7 +4196,7 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
4196 } 4196 }
4197 4197
4198 if (cntdn) { 4198 if (cntdn) {
4199 dprintk((MYIOC_s_INFO_FMT "WaitForDoorbell ACK (count=%d)\n", 4199 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "WaitForDoorbell ACK (count=%d)\n",
4200 ioc->name, count)); 4200 ioc->name, count));
4201 return count; 4201 return count;
4202 } 4202 }
@@ -4245,7 +4245,7 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
4245 } 4245 }
4246 4246
4247 if (cntdn) { 4247 if (cntdn) {
4248 dprintk((MYIOC_s_INFO_FMT "WaitForDoorbell INT (cnt=%d) howlong=%d\n", 4248 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "WaitForDoorbell INT (cnt=%d) howlong=%d\n",
4249 ioc->name, count, howlong)); 4249 ioc->name, count, howlong));
4250 return count; 4250 return count;
4251 } 4251 }
@@ -4297,7 +4297,7 @@ WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
4297 } 4297 }
4298 } 4298 }
4299 4299
4300 dhsprintk((MYIOC_s_INFO_FMT "WaitCnt=%d First handshake reply word=%08x%s\n", 4300 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "WaitCnt=%d First handshake reply word=%08x%s\n",
4301 ioc->name, t, le32_to_cpu(*(u32 *)hs_reply), 4301 ioc->name, t, le32_to_cpu(*(u32 *)hs_reply),
4302 failcnt ? " - MISSING DOORBELL HANDSHAKE!" : "")); 4302 failcnt ? " - MISSING DOORBELL HANDSHAKE!" : ""));
4303 4303
@@ -4333,10 +4333,10 @@ WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
4333 } 4333 }
4334#endif 4334#endif
4335 4335
4336 dhsprintk((MYIOC_s_INFO_FMT "Got Handshake reply:\n", ioc->name)); 4336 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Got Handshake reply:\n", ioc->name));
4337 DBG_DUMP_REPLY_FRAME(mptReply) 4337 DBG_DUMP_REPLY_FRAME(ioc, (u32 *)mptReply)
4338 4338
4339 dhsprintk((MYIOC_s_INFO_FMT "WaitForDoorbell REPLY WaitCnt=%d (sz=%d)\n", 4339 dhsprintk(ioc, printk(MYIOC_s_DEBUG_FMT "WaitForDoorbell REPLY WaitCnt=%d (sz=%d)\n",
4340 ioc->name, t, u16cnt/2)); 4340 ioc->name, t, u16cnt/2));
4341 return u16cnt/2; 4341 return u16cnt/2;
4342} 4342}
@@ -4761,7 +4761,7 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4761 4761
4762 ioc->spi_data.nvram = (int *) mem; 4762 ioc->spi_data.nvram = (int *) mem;
4763 4763
4764 dprintk((MYIOC_s_INFO_FMT "SCSI device NVRAM settings @ %p, sz=%d\n", 4764 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SCSI device NVRAM settings @ %p, sz=%d\n",
4765 ioc->name, ioc->spi_data.nvram, sz)); 4765 ioc->name, ioc->spi_data.nvram, sz));
4766 } 4766 }
4767 4767
@@ -4797,7 +4797,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4797 ioc->spi_data.minSyncFactor = MPT_ASYNC; 4797 ioc->spi_data.minSyncFactor = MPT_ASYNC;
4798 ioc->spi_data.busType = MPT_HOST_BUS_UNKNOWN; 4798 ioc->spi_data.busType = MPT_HOST_BUS_UNKNOWN;
4799 rc = 1; 4799 rc = 1;
4800 ddvprintk((MYIOC_s_INFO_FMT "Unable to read PortPage0 minSyncFactor=%x\n", 4800 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
4801 "Unable to read PortPage0 minSyncFactor=%x\n",
4801 ioc->name, ioc->spi_data.minSyncFactor)); 4802 ioc->name, ioc->spi_data.minSyncFactor));
4802 } else { 4803 } else {
4803 /* Save the Port Page 0 data 4804 /* Save the Port Page 0 data
@@ -4808,7 +4809,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4808 4809
4809 if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) { 4810 if ( (pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_QAS) == 0 ) {
4810 ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS; 4811 ioc->spi_data.noQas |= MPT_TARGET_NO_NEGO_QAS;
4811 ddvprintk((KERN_INFO MYNAM " :%s noQas due to Capabilities=%x\n", 4812 ddvprintk(ioc, printk(KERN_INFO MYNAM
4813 " :%s noQas due to Capabilities=%x\n",
4812 ioc->name, pPP0->Capabilities)); 4814 ioc->name, pPP0->Capabilities));
4813 } 4815 }
4814 ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0; 4816 ioc->spi_data.maxBusWidth = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_WIDE ? 1 : 0;
@@ -4817,7 +4819,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4817 ioc->spi_data.maxSyncOffset = (u8) (data >> 16); 4819 ioc->spi_data.maxSyncOffset = (u8) (data >> 16);
4818 data = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_MIN_SYNC_PERIOD_MASK; 4820 data = pPP0->Capabilities & MPI_SCSIPORTPAGE0_CAP_MIN_SYNC_PERIOD_MASK;
4819 ioc->spi_data.minSyncFactor = (u8) (data >> 8); 4821 ioc->spi_data.minSyncFactor = (u8) (data >> 8);
4820 ddvprintk((MYIOC_s_INFO_FMT "PortPage0 minSyncFactor=%x\n", 4822 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
4823 "PortPage0 minSyncFactor=%x\n",
4821 ioc->name, ioc->spi_data.minSyncFactor)); 4824 ioc->name, ioc->spi_data.minSyncFactor));
4822 } else { 4825 } else {
4823 ioc->spi_data.maxSyncOffset = 0; 4826 ioc->spi_data.maxSyncOffset = 0;
@@ -4833,7 +4836,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4833 4836
4834 if (ioc->spi_data.minSyncFactor < MPT_ULTRA) { 4837 if (ioc->spi_data.minSyncFactor < MPT_ULTRA) {
4835 ioc->spi_data.minSyncFactor = MPT_ULTRA; 4838 ioc->spi_data.minSyncFactor = MPT_ULTRA;
4836 ddvprintk((MYIOC_s_INFO_FMT "HVD or SE detected, minSyncFactor=%x\n", 4839 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
4840 "HVD or SE detected, minSyncFactor=%x\n",
4837 ioc->name, ioc->spi_data.minSyncFactor)); 4841 ioc->name, ioc->spi_data.minSyncFactor));
4838 } 4842 }
4839 } 4843 }
@@ -4949,10 +4953,10 @@ mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum)
4949 ioc->spi_data.sdp0version = cfg.cfghdr.hdr->PageVersion; 4953 ioc->spi_data.sdp0version = cfg.cfghdr.hdr->PageVersion;
4950 ioc->spi_data.sdp0length = cfg.cfghdr.hdr->PageLength; 4954 ioc->spi_data.sdp0length = cfg.cfghdr.hdr->PageLength;
4951 4955
4952 dcprintk((MYIOC_s_INFO_FMT "Headers: 0: version %d length %d\n", 4956 dcprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Headers: 0: version %d length %d\n",
4953 ioc->name, ioc->spi_data.sdp0version, ioc->spi_data.sdp0length)); 4957 ioc->name, ioc->spi_data.sdp0version, ioc->spi_data.sdp0length));
4954 4958
4955 dcprintk((MYIOC_s_INFO_FMT "Headers: 1: version %d length %d\n", 4959 dcprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Headers: 1: version %d length %d\n",
4956 ioc->name, ioc->spi_data.sdp1version, ioc->spi_data.sdp1length)); 4960 ioc->name, ioc->spi_data.sdp1version, ioc->spi_data.sdp1length));
4957 return 0; 4961 return 0;
4958} 4962}
@@ -5361,12 +5365,12 @@ mpt_read_ioc_pg_1(MPT_ADAPTER *ioc)
5361 cfg.physAddr = ioc1_dma; 5365 cfg.physAddr = ioc1_dma;
5362 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT; 5366 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
5363 if (mpt_config(ioc, &cfg) == 0) { 5367 if (mpt_config(ioc, &cfg) == 0) {
5364 5368
5365 tmp = le32_to_cpu(pIoc1->Flags) & MPI_IOCPAGE1_REPLY_COALESCING; 5369 tmp = le32_to_cpu(pIoc1->Flags) & MPI_IOCPAGE1_REPLY_COALESCING;
5366 if (tmp == MPI_IOCPAGE1_REPLY_COALESCING) { 5370 if (tmp == MPI_IOCPAGE1_REPLY_COALESCING) {
5367 tmp = le32_to_cpu(pIoc1->CoalescingTimeout); 5371 tmp = le32_to_cpu(pIoc1->CoalescingTimeout);
5368 5372
5369 dprintk((MYIOC_s_INFO_FMT "Coalescing Enabled Timeout = %d\n", 5373 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Coalescing Enabled Timeout = %d\n",
5370 ioc->name, tmp)); 5374 ioc->name, tmp));
5371 5375
5372 if (tmp > MPT_COALESCING_TIMEOUT) { 5376 if (tmp > MPT_COALESCING_TIMEOUT) {
@@ -5377,26 +5381,29 @@ mpt_read_ioc_pg_1(MPT_ADAPTER *ioc)
5377 cfg.dir = 1; 5381 cfg.dir = 1;
5378 cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT; 5382 cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
5379 if (mpt_config(ioc, &cfg) == 0) { 5383 if (mpt_config(ioc, &cfg) == 0) {
5380 dprintk((MYIOC_s_INFO_FMT "Reset Current Coalescing Timeout to = %d\n", 5384 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Reset Current Coalescing Timeout to = %d\n",
5381 ioc->name, MPT_COALESCING_TIMEOUT)); 5385 ioc->name, MPT_COALESCING_TIMEOUT));
5382 5386
5383 cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_NVRAM; 5387 cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_NVRAM;
5384 if (mpt_config(ioc, &cfg) == 0) { 5388 if (mpt_config(ioc, &cfg) == 0) {
5385 dprintk((MYIOC_s_INFO_FMT "Reset NVRAM Coalescing Timeout to = %d\n", 5389 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
5390 "Reset NVRAM Coalescing Timeout to = %d\n",
5386 ioc->name, MPT_COALESCING_TIMEOUT)); 5391 ioc->name, MPT_COALESCING_TIMEOUT));
5387 } else { 5392 } else {
5388 dprintk((MYIOC_s_INFO_FMT "Reset NVRAM Coalescing Timeout Failed\n", 5393 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
5389 ioc->name)); 5394 "Reset NVRAM Coalescing Timeout Failed\n",
5395 ioc->name));
5390 } 5396 }
5391 5397
5392 } else { 5398 } else {
5393 dprintk((MYIOC_s_WARN_FMT "Reset of Current Coalescing Timeout Failed!\n", 5399 dprintk(ioc, printk(MYIOC_s_WARN_FMT
5394 ioc->name)); 5400 "Reset of Current Coalescing Timeout Failed!\n",
5401 ioc->name));
5395 } 5402 }
5396 } 5403 }
5397 5404
5398 } else { 5405 } else {
5399 dprintk((MYIOC_s_WARN_FMT "Coalescing Disabled\n", ioc->name)); 5406 dprintk(ioc, printk(MYIOC_s_WARN_FMT "Coalescing Disabled\n", ioc->name));
5400 } 5407 }
5401 } 5408 }
5402 5409
@@ -5461,13 +5468,13 @@ SendEventNotification(MPT_ADAPTER *ioc, u8 EvSwitch)
5461 5468
5462 evnp = (EventNotification_t *) mpt_get_msg_frame(mpt_base_index, ioc); 5469 evnp = (EventNotification_t *) mpt_get_msg_frame(mpt_base_index, ioc);
5463 if (evnp == NULL) { 5470 if (evnp == NULL) {
5464 devtverboseprintk((MYIOC_s_WARN_FMT "Unable to allocate event request frame!\n", 5471 devtverboseprintk(ioc, printk(MYIOC_s_WARN_FMT "Unable to allocate event request frame!\n",
5465 ioc->name)); 5472 ioc->name));
5466 return 0; 5473 return 0;
5467 } 5474 }
5468 memset(evnp, 0, sizeof(*evnp)); 5475 memset(evnp, 0, sizeof(*evnp));
5469 5476
5470 devtverboseprintk((MYIOC_s_INFO_FMT "Sending EventNotification (%d) request %p\n", ioc->name, EvSwitch, evnp)); 5477 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending EventNotification (%d) request %p\n", ioc->name, EvSwitch, evnp));
5471 5478
5472 evnp->Function = MPI_FUNCTION_EVENT_NOTIFICATION; 5479 evnp->Function = MPI_FUNCTION_EVENT_NOTIFICATION;
5473 evnp->ChainOffset = 0; 5480 evnp->ChainOffset = 0;
@@ -5491,12 +5498,12 @@ SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp)
5491 EventAck_t *pAck; 5498 EventAck_t *pAck;
5492 5499
5493 if ((pAck = (EventAck_t *) mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) { 5500 if ((pAck = (EventAck_t *) mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) {
5494 dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n", 5501 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
5495 ioc->name,__FUNCTION__)); 5502 ioc->name,__FUNCTION__));
5496 return -1; 5503 return -1;
5497 } 5504 }
5498 5505
5499 devtverboseprintk((MYIOC_s_INFO_FMT "Sending EventAck\n", ioc->name)); 5506 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending EventAck\n", ioc->name));
5500 5507
5501 pAck->Function = MPI_FUNCTION_EVENT_ACK; 5508 pAck->Function = MPI_FUNCTION_EVENT_ACK;
5502 pAck->ChainOffset = 0; 5509 pAck->ChainOffset = 0;
@@ -5541,7 +5548,7 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg)
5541 */ 5548 */
5542 in_isr = in_interrupt(); 5549 in_isr = in_interrupt();
5543 if (in_isr) { 5550 if (in_isr) {
5544 dcprintk((MYIOC_s_WARN_FMT "Config request not allowed in ISR context!\n", 5551 dcprintk(ioc, printk(MYIOC_s_WARN_FMT "Config request not allowed in ISR context!\n",
5545 ioc->name)); 5552 ioc->name));
5546 return -EPERM; 5553 return -EPERM;
5547 } 5554 }
@@ -5549,7 +5556,7 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg)
5549 /* Get and Populate a free Frame 5556 /* Get and Populate a free Frame
5550 */ 5557 */
5551 if ((mf = mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) { 5558 if ((mf = mpt_get_msg_frame(mpt_base_index, ioc)) == NULL) {
5552 dcprintk((MYIOC_s_WARN_FMT "mpt_config: no msg frames!\n", 5559 dcprintk(ioc, printk(MYIOC_s_WARN_FMT "mpt_config: no msg frames!\n",
5553 ioc->name)); 5560 ioc->name));
5554 return -EAGAIN; 5561 return -EAGAIN;
5555 } 5562 }
@@ -5594,13 +5601,13 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg)
5594 if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == MPI_CONFIG_PAGETYPE_EXTENDED) { 5601 if ((pCfg->cfghdr.hdr->PageType & MPI_CONFIG_PAGETYPE_MASK) == MPI_CONFIG_PAGETYPE_EXTENDED) {
5595 flagsLength |= pExtHdr->ExtPageLength * 4; 5602 flagsLength |= pExtHdr->ExtPageLength * 4;
5596 5603
5597 dcprintk((MYIOC_s_INFO_FMT "Sending Config request type %d, page %d and action %d\n", 5604 dcprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending Config request type %d, page %d and action %d\n",
5598 ioc->name, pReq->ExtPageType, pReq->Header.PageNumber, pReq->Action)); 5605 ioc->name, pReq->ExtPageType, pReq->Header.PageNumber, pReq->Action));
5599 } 5606 }
5600 else { 5607 else {
5601 flagsLength |= pCfg->cfghdr.hdr->PageLength * 4; 5608 flagsLength |= pCfg->cfghdr.hdr->PageLength * 4;
5602 5609
5603 dcprintk((MYIOC_s_INFO_FMT "Sending Config request type %d, page %d and action %d\n", 5610 dcprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Sending Config request type %d, page %d and action %d\n",
5604 ioc->name, pReq->Header.PageType, pReq->Header.PageNumber, pReq->Action)); 5611 ioc->name, pReq->Header.PageType, pReq->Header.PageNumber, pReq->Action));
5605 } 5612 }
5606 5613
@@ -5650,7 +5657,7 @@ mpt_timer_expired(unsigned long data)
5650{ 5657{
5651 MPT_ADAPTER *ioc = (MPT_ADAPTER *) data; 5658 MPT_ADAPTER *ioc = (MPT_ADAPTER *) data;
5652 5659
5653 dcprintk((MYIOC_s_WARN_FMT "mpt_timer_expired! \n", ioc->name)); 5660 dcprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mpt_timer_expired! \n", ioc->name));
5654 5661
5655 /* Perform a FW reload */ 5662 /* Perform a FW reload */
5656 if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0) 5663 if (mpt_HardResetHandler(ioc, NO_SLEEP) < 0)
@@ -5660,7 +5667,7 @@ mpt_timer_expired(unsigned long data)
5660 * Hard reset clean-up will wake up 5667 * Hard reset clean-up will wake up
5661 * process and free all resources. 5668 * process and free all resources.
5662 */ 5669 */
5663 dcprintk((MYIOC_s_WARN_FMT "mpt_timer_expired complete!\n", ioc->name)); 5670 dcprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mpt_timer_expired complete!\n", ioc->name));
5664 5671
5665 return; 5672 return;
5666} 5673}
@@ -5679,7 +5686,7 @@ mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
5679 CONFIGPARMS *pCfg; 5686 CONFIGPARMS *pCfg;
5680 unsigned long flags; 5687 unsigned long flags;
5681 5688
5682 dprintk((KERN_WARNING MYNAM 5689 dprintk(ioc, printk(KERN_DEBUG MYNAM
5683 ": IOC %s_reset routed to MPT base driver!\n", 5690 ": IOC %s_reset routed to MPT base driver!\n",
5684 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( 5691 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
5685 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); 5692 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
@@ -6050,7 +6057,7 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
6050 int rc; 6057 int rc;
6051 unsigned long flags; 6058 unsigned long flags;
6052 6059
6053 dtmprintk((MYIOC_s_INFO_FMT "HardResetHandler Entered!\n", ioc->name)); 6060 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HardResetHandler Entered!\n", ioc->name));
6054#ifdef MFCNT 6061#ifdef MFCNT
6055 printk(MYIOC_s_INFO_FMT "HardResetHandler Entered!\n", ioc->name); 6062 printk(MYIOC_s_INFO_FMT "HardResetHandler Entered!\n", ioc->name);
6056 printk("MF count 0x%x !\n", ioc->mfcnt); 6063 printk("MF count 0x%x !\n", ioc->mfcnt);
@@ -6082,11 +6089,11 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
6082 6089
6083 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 6090 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
6084 if (MptResetHandlers[ii]) { 6091 if (MptResetHandlers[ii]) {
6085 dtmprintk((MYIOC_s_INFO_FMT "Calling IOC reset_setup handler #%d\n", 6092 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling IOC reset_setup handler #%d\n",
6086 ioc->name, ii)); 6093 ioc->name, ii));
6087 r += mpt_signal_reset(ii, ioc, MPT_IOC_SETUP_RESET); 6094 r += mpt_signal_reset(ii, ioc, MPT_IOC_SETUP_RESET);
6088 if (ioc->alt_ioc) { 6095 if (ioc->alt_ioc) {
6089 dtmprintk((MYIOC_s_INFO_FMT "Calling alt-%s setup reset handler #%d\n", 6096 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Calling alt-%s setup reset handler #%d\n",
6090 ioc->name, ioc->alt_ioc->name, ii)); 6097 ioc->name, ioc->alt_ioc->name, ii));
6091 r += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_SETUP_RESET); 6098 r += mpt_signal_reset(ii, ioc->alt_ioc, MPT_IOC_SETUP_RESET);
6092 } 6099 }
@@ -6108,7 +6115,7 @@ mpt_HardResetHandler(MPT_ADAPTER *ioc, int sleepFlag)
6108 ioc->alt_ioc->diagPending = 0; 6115 ioc->alt_ioc->diagPending = 0;
6109 spin_unlock_irqrestore(&ioc->diagLock, flags); 6116 spin_unlock_irqrestore(&ioc->diagLock, flags);
6110 6117
6111 dtmprintk((MYIOC_s_INFO_FMT "HardResetHandler rc = %d!\n", ioc->name, rc)); 6118 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "HardResetHandler rc = %d!\n", ioc->name, rc));
6112 6119
6113 return rc; 6120 return rc;
6114} 6121}
@@ -6509,16 +6516,18 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6509 } 6516 }
6510 6517
6511 EventDescriptionStr(event, evData0, evStr); 6518 EventDescriptionStr(event, evData0, evStr);
6512 devtprintk((MYIOC_s_INFO_FMT "MPT event:(%02Xh) : %s\n", 6519 devtprintk(ioc, printk(MYIOC_s_DEBUG_FMT "MPT event:(%02Xh) : %s\n",
6513 ioc->name, 6520 ioc->name,
6514 event, 6521 event,
6515 evStr)); 6522 evStr));
6516 6523
6517#if defined(MPT_DEBUG) || defined(MPT_DEBUG_VERBOSE_EVENTS) 6524#ifdef CONFIG_FUSION_LOGGING
6518 printk(KERN_INFO MYNAM ": Event data:\n" KERN_INFO); 6525 devtverboseprintk(ioc, printk(KERN_DEBUG MYNAM
6526 ": Event data:\n"));
6519 for (ii = 0; ii < evDataLen; ii++) 6527 for (ii = 0; ii < evDataLen; ii++)
6520 printk(" %08x", le32_to_cpu(pEventReply->Data[ii])); 6528 devtverboseprintk(ioc, printk(" %08x",
6521 printk("\n"); 6529 le32_to_cpu(pEventReply->Data[ii])));
6530 devtverboseprintk(ioc, printk(KERN_DEBUG "\n"));
6522#endif 6531#endif
6523 6532
6524 /* 6533 /*
@@ -6573,7 +6582,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6573 */ 6582 */
6574 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) { 6583 for (ii=MPT_MAX_PROTOCOL_DRIVERS-1; ii; ii--) {
6575 if (MptEvHandlers[ii]) { 6584 if (MptEvHandlers[ii]) {
6576 devtverboseprintk((MYIOC_s_INFO_FMT "Routing Event to event handler #%d\n", 6585 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Routing Event to event handler #%d\n",
6577 ioc->name, ii)); 6586 ioc->name, ii));
6578 r += (*(MptEvHandlers[ii]))(ioc, pEventReply); 6587 r += (*(MptEvHandlers[ii]))(ioc, pEventReply);
6579 handlers++; 6588 handlers++;
@@ -6585,10 +6594,10 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6585 * If needed, send (a single) EventAck. 6594 * If needed, send (a single) EventAck.
6586 */ 6595 */
6587 if (pEventReply->AckRequired == MPI_EVENT_NOTIFICATION_ACK_REQUIRED) { 6596 if (pEventReply->AckRequired == MPI_EVENT_NOTIFICATION_ACK_REQUIRED) {
6588 devtverboseprintk((MYIOC_s_WARN_FMT 6597 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT
6589 "EventAck required\n",ioc->name)); 6598 "EventAck required\n",ioc->name));
6590 if ((ii = SendEventAck(ioc, pEventReply)) != 0) { 6599 if ((ii = SendEventAck(ioc, pEventReply)) != 0) {
6591 devtverboseprintk((MYIOC_s_WARN_FMT "SendEventAck returned %d\n", 6600 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SendEventAck returned %d\n",
6592 ioc->name, ii)); 6601 ioc->name, ii));
6593 } 6602 }
6594 } 6603 }
@@ -6935,7 +6944,6 @@ union loginfo_type {
6935 sas_loginfo.dw.code, sas_loginfo.dw.subcode); 6944 sas_loginfo.dw.code, sas_loginfo.dw.subcode);
6936} 6945}
6937 6946
6938#ifdef MPT_DEBUG_REPLY
6939/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6947/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6940/** 6948/**
6941 * mpt_iocstatus_info_config - IOCSTATUS information for config pages 6949 * mpt_iocstatus_info_config - IOCSTATUS information for config pages
@@ -7240,7 +7248,6 @@ mpt_iocstatus_info(MPT_ADAPTER *ioc, u32 ioc_status, MPT_FRAME_HDR *mf)
7240 7248
7241 printk(MYIOC_s_INFO_FMT "IOCStatus(0x%04X): %s\n", ioc->name, status, desc); 7249 printk(MYIOC_s_INFO_FMT "IOCStatus(0x%04X): %s\n", ioc->name, status, desc);
7242} 7250}
7243#endif
7244 7251
7245/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 7252/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
7246EXPORT_SYMBOL(mpt_attach); 7253EXPORT_SYMBOL(mpt_attach);
@@ -7305,11 +7312,7 @@ fusion_init(void)
7305 7312
7306 /* Register for hard reset handling callbacks. 7313 /* Register for hard reset handling callbacks.
7307 */ 7314 */
7308 if (mpt_reset_register(mpt_base_index, mpt_ioc_reset) == 0) { 7315 mpt_reset_register(mpt_base_index, mpt_ioc_reset);
7309 dprintk((KERN_INFO MYNAM ": Register for IOC reset notification\n"));
7310 } else {
7311 /* FIXME! */
7312 }
7313 7316
7314#ifdef CONFIG_PROC_FS 7317#ifdef CONFIG_PROC_FS
7315 (void) procmpt_create(); 7318 (void) procmpt_create();
@@ -7328,8 +7331,6 @@ static void __exit
7328fusion_exit(void) 7331fusion_exit(void)
7329{ 7332{
7330 7333
7331 dexitprintk((KERN_INFO MYNAM ": fusion_exit() called!\n"));
7332
7333 mpt_reset_deregister(mpt_base_index); 7334 mpt_reset_deregister(mpt_base_index);
7334 7335
7335#ifdef CONFIG_PROC_FS 7336#ifdef CONFIG_PROC_FS
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 98eb9c688e17..15ff22645844 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -186,6 +186,7 @@
186 * MPT drivers. NOTE: Users of these macro defs must 186 * MPT drivers. NOTE: Users of these macro defs must
187 * themselves define their own MYNAM. 187 * themselves define their own MYNAM.
188 */ 188 */
189#define MYIOC_s_DEBUG_FMT KERN_DEBUG MYNAM ": %s: "
189#define MYIOC_s_INFO_FMT KERN_INFO MYNAM ": %s: " 190#define MYIOC_s_INFO_FMT KERN_INFO MYNAM ": %s: "
190#define MYIOC_s_NOTE_FMT KERN_NOTICE MYNAM ": %s: " 191#define MYIOC_s_NOTE_FMT KERN_NOTICE MYNAM ": %s: "
191#define MYIOC_s_WARN_FMT KERN_WARNING MYNAM ": %s: WARNING - " 192#define MYIOC_s_WARN_FMT KERN_WARNING MYNAM ": %s: WARNING - "
@@ -543,6 +544,7 @@ typedef struct _MPT_ADAPTER
543 char board_tracer[16]; 544 char board_tracer[16];
544 u16 nvdata_version_persistent; 545 u16 nvdata_version_persistent;
545 u16 nvdata_version_default; 546 u16 nvdata_version_default;
547 int debug_level;
546 u8 io_missing_delay; 548 u8 io_missing_delay;
547 u8 device_missing_delay; 549 u8 device_missing_delay;
548 SYSIF_REGS __iomem *chip; /* == c8817000 (mmap) */ 550 SYSIF_REGS __iomem *chip; /* == c8817000 (mmap) */
@@ -718,171 +720,7 @@ typedef struct _mpt_sge {
718/* 720/*
719 * Funky (private) macros... 721 * Funky (private) macros...
720 */ 722 */
721#ifdef MPT_DEBUG 723#include "mptdebug.h"
722#define dprintk(x) printk x
723#else
724#define dprintk(x)
725#endif
726
727#ifdef MPT_DEBUG_INIT
728#define dinitprintk(x) printk x
729#define DBG_DUMP_FW_REQUEST_FRAME(mfp) \
730 { int i, n = 10; \
731 u32 *m = (u32 *)(mfp); \
732 printk(KERN_INFO " "); \
733 for (i=0; i<n; i++) \
734 printk(" %08x", le32_to_cpu(m[i])); \
735 printk("\n"); \
736 }
737#else
738#define dinitprintk(x)
739#define DBG_DUMP_FW_REQUEST_FRAME(mfp)
740#endif
741
742#ifdef MPT_DEBUG_EXIT
743#define dexitprintk(x) printk x
744#else
745#define dexitprintk(x)
746#endif
747
748#if defined MPT_DEBUG_FAIL || defined (MPT_DEBUG_SG)
749#define dfailprintk(x) printk x
750#else
751#define dfailprintk(x)
752#endif
753
754#ifdef MPT_DEBUG_HANDSHAKE
755#define dhsprintk(x) printk x
756#else
757#define dhsprintk(x)
758#endif
759
760#if defined(MPT_DEBUG_EVENTS) || defined(MPT_DEBUG_VERBOSE_EVENTS)
761#define devtprintk(x) printk x
762#else
763#define devtprintk(x)
764#endif
765
766#ifdef MPT_DEBUG_VERBOSE_EVENTS
767#define devtverboseprintk(x) printk x
768#else
769#define devtverboseprintk(x)
770#endif
771
772#ifdef MPT_DEBUG_RESET
773#define drsprintk(x) printk x
774#else
775#define drsprintk(x)
776#endif
777
778//#if defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
779#if defined(MPT_DEBUG_MSG_FRAME)
780#define dmfprintk(x) printk x
781#define DBG_DUMP_REQUEST_FRAME(mfp) \
782 { int i, n = 24; \
783 u32 *m = (u32 *)(mfp); \
784 for (i=0; i<n; i++) { \
785 if (i && ((i%8)==0)) \
786 printk("\n"); \
787 printk("%08x ", le32_to_cpu(m[i])); \
788 } \
789 printk("\n"); \
790 }
791#else
792#define dmfprintk(x)
793#define DBG_DUMP_REQUEST_FRAME(mfp)
794#endif
795
796#ifdef MPT_DEBUG_IRQ
797#define dirqprintk(x) printk x
798#else
799#define dirqprintk(x)
800#endif
801
802#ifdef MPT_DEBUG_SG
803#define dsgprintk(x) printk x
804#else
805#define dsgprintk(x)
806#endif
807
808#if defined(MPT_DEBUG_DL) || defined(MPT_DEBUG)
809#define ddlprintk(x) printk x
810#else
811#define ddlprintk(x)
812#endif
813
814#ifdef MPT_DEBUG_DV
815#define ddvprintk(x) printk x
816#else
817#define ddvprintk(x)
818#endif
819
820#if defined(MPT_DEBUG_DV) || defined(MPT_DEBUG_DV_TINY)
821#define ddvtprintk(x) printk x
822#else
823#define ddvtprintk(x)
824#endif
825
826#ifdef MPT_DEBUG_IOCTL
827#define dctlprintk(x) printk x
828#else
829#define dctlprintk(x)
830#endif
831
832#ifdef MPT_DEBUG_REPLY
833#define dreplyprintk(x) printk x
834#else
835#define dreplyprintk(x)
836#endif
837
838#ifdef DMPT_DEBUG_FC
839#define dfcprintk(x) printk x
840#else
841#define dfcprintk(x)
842#endif
843
844#ifdef MPT_DEBUG_TM
845#define dtmprintk(x) printk x
846#define DBG_DUMP_TM_REQUEST_FRAME(mfp) \
847 { u32 *m = (u32 *)(mfp); \
848 int i, n = 13; \
849 printk("TM_REQUEST:\n"); \
850 for (i=0; i<n; i++) { \
851 if (i && ((i%8)==0)) \
852 printk("\n"); \
853 printk("%08x ", le32_to_cpu(m[i])); \
854 } \
855 printk("\n"); \
856 }
857#define DBG_DUMP_TM_REPLY_FRAME(mfp) \
858 { u32 *m = (u32 *)(mfp); \
859 int i, n = (le32_to_cpu(m[0]) & 0x00FF0000) >> 16; \
860 printk("TM_REPLY MessageLength=%d:\n", n); \
861 for (i=0; i<n; i++) { \
862 if (i && ((i%8)==0)) \
863 printk("\n"); \
864 printk(" %08x", le32_to_cpu(m[i])); \
865 } \
866 printk("\n"); \
867 }
868#else
869#define dtmprintk(x)
870#define DBG_DUMP_TM_REQUEST_FRAME(mfp)
871#define DBG_DUMP_TM_REPLY_FRAME(mfp)
872#endif
873
874#if defined(MPT_DEBUG_CONFIG) || defined(MPT_DEBUG)
875#define dcprintk(x) printk x
876#else
877#define dcprintk(x)
878#endif
879
880#if defined(MPT_DEBUG_SCSI) || defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
881#define dsprintk(x) printk x
882#else
883#define dsprintk(x)
884#endif
885
886 724
887#define MPT_INDEX_2_MFPTR(ioc,idx) \ 725#define MPT_INDEX_2_MFPTR(ioc,idx) \
888 (MPT_FRAME_HDR*)( (u8*)(ioc)->req_frames + (ioc)->req_sz * (idx) ) 726 (MPT_FRAME_HDR*)( (u8*)(ioc)->req_frames + (ioc)->req_sz * (idx) )
@@ -893,36 +731,6 @@ typedef struct _mpt_sge {
893#define MPT_INDEX_2_RFPTR(ioc,idx) \ 731#define MPT_INDEX_2_RFPTR(ioc,idx) \
894 (MPT_FRAME_HDR*)( (u8*)(ioc)->reply_frames + (ioc)->req_sz * (idx) ) 732 (MPT_FRAME_HDR*)( (u8*)(ioc)->reply_frames + (ioc)->req_sz * (idx) )
895 733
896#if defined(MPT_DEBUG) || defined(MPT_DEBUG_MSG_FRAME)
897#define DBG_DUMP_REPLY_FRAME(mfp) \
898 { u32 *m = (u32 *)(mfp); \
899 int i, n = (le32_to_cpu(m[0]) & 0x00FF0000) >> 16; \
900 printk(KERN_INFO " "); \
901 for (i=0; i<n; i++) \
902 printk(" %08x", le32_to_cpu(m[i])); \
903 printk("\n"); \
904 }
905#define DBG_DUMP_REQUEST_FRAME_HDR(mfp) \
906 { int i, n = 3; \
907 u32 *m = (u32 *)(mfp); \
908 printk(KERN_INFO " "); \
909 for (i=0; i<n; i++) \
910 printk(" %08x", le32_to_cpu(m[i])); \
911 printk("\n"); \
912 }
913#else
914#define DBG_DUMP_REPLY_FRAME(mfp)
915#define DBG_DUMP_REQUEST_FRAME_HDR(mfp)
916#endif
917
918// debug sas wide ports
919#ifdef MPT_DEBUG_SAS_WIDE
920#define dsaswideprintk(x) printk x
921#else
922#define dsaswideprintk(x)
923#endif
924
925
926/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 734/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
927 735
928#define SCSI_STD_SENSE_BYTES 18 736#define SCSI_STD_SENSE_BYTES 18
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 58e6c319cc76..89695e705bdc 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -181,7 +181,7 @@ static inline int
181mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock) 181mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock)
182{ 182{
183 int rc = 0; 183 int rc = 0;
184 dctlprintk((KERN_INFO MYNAM "::mptctl_syscall_down(%p,%d) called\n", ioc, nonblock)); 184// dctlprintk(ioc, printk(KERN_DEBUG MYNAM "::mptctl_syscall_down(%p,%d) called\n", ioc, nonblock));
185 185
186 if (nonblock) { 186 if (nonblock) {
187 if (!mutex_trylock(&ioc->ioctl->ioctl_mutex)) 187 if (!mutex_trylock(&ioc->ioctl->ioctl_mutex))
@@ -190,7 +190,7 @@ mptctl_syscall_down(MPT_ADAPTER *ioc, int nonblock)
190 if (mutex_lock_interruptible(&ioc->ioctl->ioctl_mutex)) 190 if (mutex_lock_interruptible(&ioc->ioctl->ioctl_mutex))
191 rc = -ERESTARTSYS; 191 rc = -ERESTARTSYS;
192 } 192 }
193 dctlprintk((KERN_INFO MYNAM "::mptctl_syscall_down return %d\n", rc)); 193// dctlprintk(ioc, printk(KERN_DEBUG MYNAM "::mptctl_syscall_down return %d\n", rc));
194 return rc; 194 return rc;
195} 195}
196 196
@@ -209,18 +209,19 @@ mptctl_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply)
209 u16 iocStatus; 209 u16 iocStatus;
210 u8 cmd; 210 u8 cmd;
211 211
212 dctlprintk(("mptctl_reply()!\n"));
213 if (req) 212 if (req)
214 cmd = req->u.hdr.Function; 213 cmd = req->u.hdr.Function;
215 else 214 else
216 return 1; 215 return 1;
216 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\tcompleting mpi function (0x%02X), req=%p, "
217 "reply=%p\n", ioc->name, req->u.hdr.Function, req, reply));
217 218
218 if (ioc->ioctl) { 219 if (ioc->ioctl) {
219 220
220 if (reply==NULL) { 221 if (reply==NULL) {
221 222
222 dctlprintk(("mptctl_reply() NULL Reply " 223 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_reply() NULL Reply "
223 "Function=%x!\n", cmd)); 224 "Function=%x!\n", ioc->name, cmd));
224 225
225 ioc->ioctl->status |= MPT_IOCTL_STATUS_COMMAND_GOOD; 226 ioc->ioctl->status |= MPT_IOCTL_STATUS_COMMAND_GOOD;
226 ioc->ioctl->reset &= ~MPTCTL_RESET_OK; 227 ioc->ioctl->reset &= ~MPTCTL_RESET_OK;
@@ -233,14 +234,9 @@ mptctl_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply)
233 234
234 } 235 }
235 236
236 dctlprintk(("mptctl_reply() with req=%p "
237 "reply=%p Function=%x!\n", req, reply, cmd));
238
239 /* Copy the reply frame (which much exist 237 /* Copy the reply frame (which much exist
240 * for non-SCSI I/O) to the IOC structure. 238 * for non-SCSI I/O) to the IOC structure.
241 */ 239 */
242 dctlprintk(("Copying Reply Frame @%p to ioc%d!\n",
243 reply, ioc->id));
244 memcpy(ioc->ioctl->ReplyFrame, reply, 240 memcpy(ioc->ioctl->ReplyFrame, reply,
245 min(ioc->reply_sz, 4*reply->u.reply.MsgLength)); 241 min(ioc->reply_sz, 4*reply->u.reply.MsgLength));
246 ioc->ioctl->status |= MPT_IOCTL_STATUS_RF_VALID; 242 ioc->ioctl->status |= MPT_IOCTL_STATUS_RF_VALID;
@@ -252,8 +248,24 @@ mptctl_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply)
252 if (iocStatus == MPI_IOCSTATUS_SUCCESS) 248 if (iocStatus == MPI_IOCSTATUS_SUCCESS)
253 ioc->ioctl->status |= MPT_IOCTL_STATUS_COMMAND_GOOD; 249 ioc->ioctl->status |= MPT_IOCTL_STATUS_COMMAND_GOOD;
254 250
251 if (iocStatus || reply->u.reply.IOCLogInfo)
252 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\tiocstatus (0x%04X), "
253 "loginfo (0x%08X)\n", ioc->name,
254 iocStatus,
255 le32_to_cpu(reply->u.reply.IOCLogInfo)));
256
255 if ((cmd == MPI_FUNCTION_SCSI_IO_REQUEST) || 257 if ((cmd == MPI_FUNCTION_SCSI_IO_REQUEST) ||
256 (cmd == MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH)) { 258 (cmd == MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH)) {
259
260 if (reply->u.sreply.SCSIStatus || reply->u.sreply.SCSIState)
261 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
262 "\tscsi_status (0x%02x), scsi_state (0x%02x), "
263 "tag = (0x%04x), transfer_count (0x%08x)\n", ioc->name,
264 reply->u.sreply.SCSIStatus,
265 reply->u.sreply.SCSIState,
266 le16_to_cpu(reply->u.sreply.TaskTag),
267 le32_to_cpu(reply->u.sreply.TransferCount)));
268
257 ioc->ioctl->reset &= ~MPTCTL_RESET_OK; 269 ioc->ioctl->reset &= ~MPTCTL_RESET_OK;
258 270
259 if ((iocStatus == MPI_IOCSTATUS_SCSI_DATA_UNDERRUN) || 271 if ((iocStatus == MPI_IOCSTATUS_SCSI_DATA_UNDERRUN) ||
@@ -298,8 +310,8 @@ static void mptctl_timeout_expired (MPT_IOCTL *ioctl)
298{ 310{
299 int rc = 1; 311 int rc = 1;
300 312
301 dctlprintk((KERN_NOTICE MYNAM ": Timeout Expired! Host %d\n", 313 dctlprintk(ioctl->ioc, printk(MYIOC_s_DEBUG_FMT ": Timeout Expired! Host %d\n",
302 ioctl->ioc->id)); 314 ioctl->ioc->name, ioctl->ioc->id));
303 if (ioctl == NULL) 315 if (ioctl == NULL)
304 return; 316 return;
305 317
@@ -311,7 +323,7 @@ static void mptctl_timeout_expired (MPT_IOCTL *ioctl)
311 /* Issue a reset for this device. 323 /* Issue a reset for this device.
312 * The IOC is not responding. 324 * The IOC is not responding.
313 */ 325 */
314 dctlprintk((MYIOC_s_INFO_FMT "Calling HardReset! \n", 326 dctlprintk(ioctl->ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n",
315 ioctl->ioc->name)); 327 ioctl->ioc->name));
316 mpt_HardResetHandler(ioctl->ioc, CAN_SLEEP); 328 mpt_HardResetHandler(ioctl->ioc, CAN_SLEEP);
317 } 329 }
@@ -350,14 +362,14 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl)
350 /* Send request 362 /* Send request
351 */ 363 */
352 if ((mf = mpt_get_msg_frame(mptctl_id, ioctl->ioc)) == NULL) { 364 if ((mf = mpt_get_msg_frame(mptctl_id, ioctl->ioc)) == NULL) {
353 dctlprintk((MYIOC_s_WARN_FMT "IssueTaskMgmt, no msg frames!!\n", 365 dtmprintk(ioctl->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt, no msg frames!!\n",
354 ioctl->ioc->name)); 366 ioctl->ioc->name));
355 367
356 mptctl_free_tm_flags(ioctl->ioc); 368 mptctl_free_tm_flags(ioctl->ioc);
357 return -ENOMEM; 369 return -ENOMEM;
358 } 370 }
359 371
360 dtmprintk((MYIOC_s_INFO_FMT "IssueTaskMgmt request @ %p\n", 372 dtmprintk(ioctl->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n",
361 ioctl->ioc->name, mf)); 373 ioctl->ioc->name, mf));
362 374
363 pScsiTm = (SCSITaskMgmt_t *) mf; 375 pScsiTm = (SCSITaskMgmt_t *) mf;
@@ -377,15 +389,15 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl)
377 pScsiTm->Reserved2[ii] = 0; 389 pScsiTm->Reserved2[ii] = 0;
378 390
379 pScsiTm->TaskMsgContext = 0; 391 pScsiTm->TaskMsgContext = 0;
380 dtmprintk((MYIOC_s_INFO_FMT 392 dtmprintk(ioctl->ioc, printk(MYIOC_s_DEBUG_FMT
381 "mptctl_bus_reset: issued.\n", ioctl->ioc->name)); 393 "mptctl_bus_reset: issued.\n", ioctl->ioc->name));
382 394
383 DBG_DUMP_TM_REQUEST_FRAME((u32 *)mf); 395 DBG_DUMP_TM_REQUEST_FRAME(ioctl->ioc, (u32 *)mf);
384 396
385 ioctl->wait_done=0; 397 ioctl->wait_done=0;
386 if ((retval = mpt_send_handshake_request(mptctl_id, ioctl->ioc, 398 if ((retval = mpt_send_handshake_request(mptctl_id, ioctl->ioc,
387 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP)) != 0) { 399 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP)) != 0) {
388 dfailprintk((MYIOC_s_ERR_FMT "_send_handshake FAILED!" 400 dfailprintk(ioctl->ioc, printk(MYIOC_s_ERR_FMT "_send_handshake FAILED!"
389 " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, 401 " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd,
390 hd->ioc, mf)); 402 hd->ioc, mf));
391 goto mptctl_bus_reset_done; 403 goto mptctl_bus_reset_done;
@@ -456,7 +468,7 @@ static int
456mptctl_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) 468mptctl_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
457{ 469{
458 MPT_IOCTL *ioctl = ioc->ioctl; 470 MPT_IOCTL *ioctl = ioc->ioctl;
459 dctlprintk((KERN_INFO MYNAM ": IOC %s_reset routed to IOCTL driver!\n", 471 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": IOC %s_reset routed to IOCTL driver!\n",ioc->name,
460 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( 472 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
461 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); 473 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
462 474
@@ -487,7 +499,8 @@ mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
487 499
488 event = le32_to_cpu(pEvReply->Event) & 0xFF; 500 event = le32_to_cpu(pEvReply->Event) & 0xFF;
489 501
490 dctlprintk(("%s() called\n", __FUNCTION__)); 502 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "%s() called\n",
503 ioc->name, __FUNCTION__));
491 if(async_queue == NULL) 504 if(async_queue == NULL)
492 return 1; 505 return 1;
493 506
@@ -497,8 +510,10 @@ mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
497 */ 510 */
498 if (event == 0x21 ) { 511 if (event == 0x21 ) {
499 ioc->aen_event_read_flag=1; 512 ioc->aen_event_read_flag=1;
500 dctlprintk(("Raised SIGIO to application\n")); 513 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Raised SIGIO to application\n",
501 devtverboseprintk(("Raised SIGIO to application\n")); 514 ioc->name));
515 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT
516 "Raised SIGIO to application\n", ioc->name));
502 kill_fasync(&async_queue, SIGIO, POLL_IN); 517 kill_fasync(&async_queue, SIGIO, POLL_IN);
503 return 1; 518 return 1;
504 } 519 }
@@ -515,8 +530,10 @@ mptctl_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
515 */ 530 */
516 if (ioc->events && (ioc->eventTypes & ( 1 << event))) { 531 if (ioc->events && (ioc->eventTypes & ( 1 << event))) {
517 ioc->aen_event_read_flag=1; 532 ioc->aen_event_read_flag=1;
518 dctlprintk(("Raised SIGIO to application\n")); 533 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT
519 devtverboseprintk(("Raised SIGIO to application\n")); 534 "Raised SIGIO to application\n", ioc->name));
535 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT
536 "Raised SIGIO to application\n", ioc->name));
520 kill_fasync(&async_queue, SIGIO, POLL_IN); 537 kill_fasync(&async_queue, SIGIO, POLL_IN);
521 } 538 }
522 return 1; 539 return 1;
@@ -530,14 +547,12 @@ mptctl_fasync(int fd, struct file *filep, int mode)
530 list_for_each_entry(ioc, &ioc_list, list) 547 list_for_each_entry(ioc, &ioc_list, list)
531 ioc->aen_event_read_flag=0; 548 ioc->aen_event_read_flag=0;
532 549
533 dctlprintk(("%s() called\n", __FUNCTION__));
534 return fasync_helper(fd, filep, mode, &async_queue); 550 return fasync_helper(fd, filep, mode, &async_queue);
535} 551}
536 552
537static int 553static int
538mptctl_release(struct inode *inode, struct file *filep) 554mptctl_release(struct inode *inode, struct file *filep)
539{ 555{
540 dctlprintk(("%s() called\n", __FUNCTION__));
541 return fasync_helper(-1, filep, 0, &async_queue); 556 return fasync_helper(-1, filep, 0, &async_queue);
542} 557}
543 558
@@ -558,8 +573,6 @@ __mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
558 int ret; 573 int ret;
559 MPT_ADAPTER *iocp = NULL; 574 MPT_ADAPTER *iocp = NULL;
560 575
561 dctlprintk(("mptctl_ioctl() called\n"));
562
563 if (copy_from_user(&khdr, uhdr, sizeof(khdr))) { 576 if (copy_from_user(&khdr, uhdr, sizeof(khdr))) {
564 printk(KERN_ERR "%s::mptctl_ioctl() @%d - " 577 printk(KERN_ERR "%s::mptctl_ioctl() @%d - "
565 "Unable to copy mpt_ioctl_header data @ %p\n", 578 "Unable to copy mpt_ioctl_header data @ %p\n",
@@ -574,13 +587,13 @@ __mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
574 iocnumX = khdr.iocnum & 0xFF; 587 iocnumX = khdr.iocnum & 0xFF;
575 if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || 588 if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
576 (iocp == NULL)) { 589 (iocp == NULL)) {
577 dctlprintk((KERN_ERR "%s::mptctl_ioctl() @%d - ioc%d not found!\n", 590 printk(KERN_DEBUG "%s::mptctl_ioctl() @%d - ioc%d not found!\n",
578 __FILE__, __LINE__, iocnumX)); 591 __FILE__, __LINE__, iocnumX);
579 return -ENODEV; 592 return -ENODEV;
580 } 593 }
581 594
582 if (!iocp->active) { 595 if (!iocp->active) {
583 printk(KERN_ERR "%s::mptctl_ioctl() @%d - Controller disabled.\n", 596 printk(KERN_DEBUG "%s::mptctl_ioctl() @%d - Controller disabled.\n",
584 __FILE__, __LINE__); 597 __FILE__, __LINE__);
585 return -EFAULT; 598 return -EFAULT;
586 } 599 }
@@ -612,8 +625,6 @@ __mptctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
612 if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0) 625 if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)
613 return ret; 626 return ret;
614 627
615 dctlprintk((MYIOC_s_INFO_FMT ": mptctl_ioctl()\n", iocp->name));
616
617 if (cmd == MPTFWDOWNLOAD) 628 if (cmd == MPTFWDOWNLOAD)
618 ret = mptctl_fw_download(arg); 629 ret = mptctl_fw_download(arg);
619 else if (cmd == MPTCOMMAND) 630 else if (cmd == MPTCOMMAND)
@@ -648,8 +659,6 @@ static int mptctl_do_reset(unsigned long arg)
648 struct mpt_ioctl_diag_reset krinfo; 659 struct mpt_ioctl_diag_reset krinfo;
649 MPT_ADAPTER *iocp; 660 MPT_ADAPTER *iocp;
650 661
651 dctlprintk((KERN_INFO "mptctl_do_reset called.\n"));
652
653 if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) { 662 if (copy_from_user(&krinfo, urinfo, sizeof(struct mpt_ioctl_diag_reset))) {
654 printk(KERN_ERR "%s@%d::mptctl_do_reset - " 663 printk(KERN_ERR "%s@%d::mptctl_do_reset - "
655 "Unable to copy mpt_ioctl_diag_reset struct @ %p\n", 664 "Unable to copy mpt_ioctl_diag_reset struct @ %p\n",
@@ -658,11 +667,14 @@ static int mptctl_do_reset(unsigned long arg)
658 } 667 }
659 668
660 if (mpt_verify_adapter(krinfo.hdr.iocnum, &iocp) < 0) { 669 if (mpt_verify_adapter(krinfo.hdr.iocnum, &iocp) < 0) {
661 dctlprintk((KERN_ERR "%s@%d::mptctl_do_reset - ioc%d not found!\n", 670 printk(KERN_DEBUG "%s@%d::mptctl_do_reset - ioc%d not found!\n",
662 __FILE__, __LINE__, krinfo.hdr.iocnum)); 671 __FILE__, __LINE__, krinfo.hdr.iocnum);
663 return -ENODEV; /* (-6) No such device or address */ 672 return -ENODEV; /* (-6) No such device or address */
664 } 673 }
665 674
675 dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "mptctl_do_reset called.\n",
676 iocp->name));
677
666 if (mpt_HardResetHandler(iocp, CAN_SLEEP) != 0) { 678 if (mpt_HardResetHandler(iocp, CAN_SLEEP) != 0) {
667 printk (KERN_ERR "%s@%d::mptctl_do_reset - reset failed.\n", 679 printk (KERN_ERR "%s@%d::mptctl_do_reset - reset failed.\n",
668 __FILE__, __LINE__); 680 __FILE__, __LINE__);
@@ -695,7 +707,6 @@ mptctl_fw_download(unsigned long arg)
695 struct mpt_fw_xfer __user *ufwdl = (void __user *) arg; 707 struct mpt_fw_xfer __user *ufwdl = (void __user *) arg;
696 struct mpt_fw_xfer kfwdl; 708 struct mpt_fw_xfer kfwdl;
697 709
698 dctlprintk((KERN_INFO "mptctl_fwdl called. mptctl_id = %xh\n", mptctl_id)); //tc
699 if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) { 710 if (copy_from_user(&kfwdl, ufwdl, sizeof(struct mpt_fw_xfer))) {
700 printk(KERN_ERR "%s@%d::_ioctl_fwdl - " 711 printk(KERN_ERR "%s@%d::_ioctl_fwdl - "
701 "Unable to copy mpt_fw_xfer struct @ %p\n", 712 "Unable to copy mpt_fw_xfer struct @ %p\n",
@@ -744,15 +755,8 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen)
744 u16 iocstat; 755 u16 iocstat;
745 pFWDownloadReply_t ReplyMsg = NULL; 756 pFWDownloadReply_t ReplyMsg = NULL;
746 757
747 dctlprintk(("mptctl_do_fwdl called. mptctl_id = %xh.\n", mptctl_id));
748
749 dctlprintk(("DbG: kfwdl.bufp = %p\n", ufwbuf));
750 dctlprintk(("DbG: kfwdl.fwlen = %d\n", (int)fwlen));
751 dctlprintk(("DbG: kfwdl.ioc = %04xh\n", ioc));
752
753 if (mpt_verify_adapter(ioc, &iocp) < 0) { 758 if (mpt_verify_adapter(ioc, &iocp) < 0) {
754 dctlprintk(("ioctl_fwdl - ioc%d not found!\n", 759 printk(KERN_DEBUG "ioctl_fwdl - ioc%d not found!\n", ioc);
755 ioc));
756 return -ENODEV; /* (-6) No such device or address */ 760 return -ENODEV; /* (-6) No such device or address */
757 } else { 761 } else {
758 762
@@ -761,6 +765,16 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen)
761 if ((mf = mpt_get_msg_frame(mptctl_id, iocp)) == NULL) 765 if ((mf = mpt_get_msg_frame(mptctl_id, iocp)) == NULL)
762 return -EAGAIN; 766 return -EAGAIN;
763 } 767 }
768
769 dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT
770 "mptctl_do_fwdl called. mptctl_id = %xh.\n", iocp->name, mptctl_id));
771 dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.bufp = %p\n",
772 iocp->name, ufwbuf));
773 dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.fwlen = %d\n",
774 iocp->name, (int)fwlen));
775 dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: kfwdl.ioc = %04xh\n",
776 iocp->name, ioc));
777
764 dlmsg = (FWDownload_t*) mf; 778 dlmsg = (FWDownload_t*) mf;
765 ptsge = (FWDownloadTCSGE_t *) &dlmsg->SGL; 779 ptsge = (FWDownloadTCSGE_t *) &dlmsg->SGL;
766 sgOut = (char *) (ptsge + 1); 780 sgOut = (char *) (ptsge + 1);
@@ -829,7 +843,8 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen)
829 goto fwdl_out; 843 goto fwdl_out;
830 } 844 }
831 845
832 dctlprintk(("DbG: sgl buffer = %p, sgfrags = %d\n", sgl, numfrags)); 846 dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "DbG: sgl buffer = %p, sgfrags = %d\n",
847 iocp->name, sgl, numfrags));
833 848
834 /* 849 /*
835 * Parse SG list, copying sgl itself, 850 * Parse SG list, copying sgl itself,
@@ -865,15 +880,7 @@ mptctl_do_fw_download(int ioc, char __user *ufwbuf, size_t fwlen)
865 sgOut += (sizeof(dma_addr_t) + sizeof(u32)); 880 sgOut += (sizeof(dma_addr_t) + sizeof(u32));
866 } 881 }
867 882
868#ifdef MPT_DEBUG 883 DBG_DUMP_FW_DOWNLOAD(iocp, (u32 *)mf, numfrags);
869 {
870 u32 *m = (u32 *)mf;
871 printk(KERN_INFO MYNAM ": F/W download request:\n" KERN_INFO " ");
872 for (i=0; i < 7+numfrags*2; i++)
873 printk(" %08x", le32_to_cpu(m[i]));
874 printk("\n");
875 }
876#endif
877 884
878 /* 885 /*
879 * Finally, perform firmware download. 886 * Finally, perform firmware download.
@@ -1049,13 +1056,11 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags,
1049 *frags = numfrags; 1056 *frags = numfrags;
1050 *blp = buflist; 1057 *blp = buflist;
1051 1058
1052 dctlprintk((KERN_INFO MYNAM "-SG: kbuf_alloc_2_sgl() - " 1059 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "-SG: kbuf_alloc_2_sgl() - "
1053 "%d SG frags generated!\n", 1060 "%d SG frags generated!\n", ioc->name, numfrags));
1054 numfrags));
1055 1061
1056 dctlprintk((KERN_INFO MYNAM "-SG: kbuf_alloc_2_sgl() - " 1062 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "-SG: kbuf_alloc_2_sgl() - "
1057 "last (big) alloc_sz=%d\n", 1063 "last (big) alloc_sz=%d\n", ioc->name, alloc_sz));
1058 alloc_sz));
1059 1064
1060 return sglbuf; 1065 return sglbuf;
1061 1066
@@ -1139,7 +1144,8 @@ kfree_sgl(MptSge_t *sgl, dma_addr_t sgl_dma, struct buflist *buflist, MPT_ADAPTE
1139 1144
1140 pci_free_consistent(ioc->pcidev, MAX_SGL_BYTES, sgl, sgl_dma); 1145 pci_free_consistent(ioc->pcidev, MAX_SGL_BYTES, sgl, sgl_dma);
1141 kfree(buflist); 1146 kfree(buflist);
1142 dctlprintk((KERN_INFO MYNAM "-SG: Free'd 1 SGL buf + %d kbufs!\n", n)); 1147 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "-SG: Free'd 1 SGL buf + %d kbufs!\n",
1148 ioc->name, n));
1143} 1149}
1144 1150
1145/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1151/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -1166,7 +1172,6 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
1166 struct scsi_device *sdev; 1172 struct scsi_device *sdev;
1167 VirtDevice *vdev; 1173 VirtDevice *vdev;
1168 1174
1169 dctlprintk((": mptctl_getiocinfo called.\n"));
1170 /* Add of PCI INFO results in unaligned access for 1175 /* Add of PCI INFO results in unaligned access for
1171 * IA64 and Sparc. Reset long to int. Return no PCI 1176 * IA64 and Sparc. Reset long to int. Return no PCI
1172 * data for obsolete format. 1177 * data for obsolete format.
@@ -1199,8 +1204,8 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
1199 1204
1200 if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) || 1205 if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) ||
1201 (ioc == NULL)) { 1206 (ioc == NULL)) {
1202 dctlprintk((KERN_ERR "%s::mptctl_getiocinfo() @%d - ioc%d not found!\n", 1207 printk(KERN_DEBUG "%s::mptctl_getiocinfo() @%d - ioc%d not found!\n",
1203 __FILE__, __LINE__, iocnum)); 1208 __FILE__, __LINE__, iocnum);
1204 kfree(karg); 1209 kfree(karg);
1205 return -ENODEV; 1210 return -ENODEV;
1206 } 1211 }
@@ -1214,6 +1219,9 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
1214 return -EFAULT; 1219 return -EFAULT;
1215 } 1220 }
1216 1221
1222 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_getiocinfo called.\n",
1223 ioc->name));
1224
1217 /* Fill in the data and return the structure to the calling 1225 /* Fill in the data and return the structure to the calling
1218 * program 1226 * program
1219 */ 1227 */
@@ -1320,7 +1328,6 @@ mptctl_gettargetinfo (unsigned long arg)
1320 u8 port; 1328 u8 port;
1321 struct scsi_device *sdev; 1329 struct scsi_device *sdev;
1322 1330
1323 dctlprintk(("mptctl_gettargetinfo called.\n"));
1324 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) { 1331 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_targetinfo))) {
1325 printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - " 1332 printk(KERN_ERR "%s@%d::mptctl_gettargetinfo - "
1326 "Unable to read in mpt_ioctl_targetinfo struct @ %p\n", 1333 "Unable to read in mpt_ioctl_targetinfo struct @ %p\n",
@@ -1330,11 +1337,13 @@ mptctl_gettargetinfo (unsigned long arg)
1330 1337
1331 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || 1338 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
1332 (ioc == NULL)) { 1339 (ioc == NULL)) {
1333 dctlprintk((KERN_ERR "%s::mptctl_gettargetinfo() @%d - ioc%d not found!\n", 1340 printk(KERN_DEBUG "%s::mptctl_gettargetinfo() @%d - ioc%d not found!\n",
1334 __FILE__, __LINE__, iocnum)); 1341 __FILE__, __LINE__, iocnum);
1335 return -ENODEV; 1342 return -ENODEV;
1336 } 1343 }
1337 1344
1345 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_gettargetinfo called.\n",
1346 ioc->name));
1338 /* Get the port number and set the maximum number of bytes 1347 /* Get the port number and set the maximum number of bytes
1339 * in the returned structure. 1348 * in the returned structure.
1340 * Ignore the port setting. 1349 * Ignore the port setting.
@@ -1434,7 +1443,6 @@ mptctl_readtest (unsigned long arg)
1434 MPT_ADAPTER *ioc; 1443 MPT_ADAPTER *ioc;
1435 int iocnum; 1444 int iocnum;
1436 1445
1437 dctlprintk(("mptctl_readtest called.\n"));
1438 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) { 1446 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_test))) {
1439 printk(KERN_ERR "%s@%d::mptctl_readtest - " 1447 printk(KERN_ERR "%s@%d::mptctl_readtest - "
1440 "Unable to read in mpt_ioctl_test struct @ %p\n", 1448 "Unable to read in mpt_ioctl_test struct @ %p\n",
@@ -1444,11 +1452,13 @@ mptctl_readtest (unsigned long arg)
1444 1452
1445 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || 1453 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
1446 (ioc == NULL)) { 1454 (ioc == NULL)) {
1447 dctlprintk((KERN_ERR "%s::mptctl_readtest() @%d - ioc%d not found!\n", 1455 printk(KERN_DEBUG "%s::mptctl_readtest() @%d - ioc%d not found!\n",
1448 __FILE__, __LINE__, iocnum)); 1456 __FILE__, __LINE__, iocnum);
1449 return -ENODEV; 1457 return -ENODEV;
1450 } 1458 }
1451 1459
1460 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_readtest called.\n",
1461 ioc->name));
1452 /* Fill in the data and return the structure to the calling 1462 /* Fill in the data and return the structure to the calling
1453 * program 1463 * program
1454 */ 1464 */
@@ -1494,7 +1504,6 @@ mptctl_eventquery (unsigned long arg)
1494 MPT_ADAPTER *ioc; 1504 MPT_ADAPTER *ioc;
1495 int iocnum; 1505 int iocnum;
1496 1506
1497 dctlprintk(("mptctl_eventquery called.\n"));
1498 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) { 1507 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) {
1499 printk(KERN_ERR "%s@%d::mptctl_eventquery - " 1508 printk(KERN_ERR "%s@%d::mptctl_eventquery - "
1500 "Unable to read in mpt_ioctl_eventquery struct @ %p\n", 1509 "Unable to read in mpt_ioctl_eventquery struct @ %p\n",
@@ -1504,11 +1513,13 @@ mptctl_eventquery (unsigned long arg)
1504 1513
1505 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || 1514 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
1506 (ioc == NULL)) { 1515 (ioc == NULL)) {
1507 dctlprintk((KERN_ERR "%s::mptctl_eventquery() @%d - ioc%d not found!\n", 1516 printk(KERN_DEBUG "%s::mptctl_eventquery() @%d - ioc%d not found!\n",
1508 __FILE__, __LINE__, iocnum)); 1517 __FILE__, __LINE__, iocnum);
1509 return -ENODEV; 1518 return -ENODEV;
1510 } 1519 }
1511 1520
1521 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventquery called.\n",
1522 ioc->name));
1512 karg.eventEntries = MPTCTL_EVENT_LOG_SIZE; 1523 karg.eventEntries = MPTCTL_EVENT_LOG_SIZE;
1513 karg.eventTypes = ioc->eventTypes; 1524 karg.eventTypes = ioc->eventTypes;
1514 1525
@@ -1532,7 +1543,6 @@ mptctl_eventenable (unsigned long arg)
1532 MPT_ADAPTER *ioc; 1543 MPT_ADAPTER *ioc;
1533 int iocnum; 1544 int iocnum;
1534 1545
1535 dctlprintk(("mptctl_eventenable called.\n"));
1536 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) { 1546 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventenable))) {
1537 printk(KERN_ERR "%s@%d::mptctl_eventenable - " 1547 printk(KERN_ERR "%s@%d::mptctl_eventenable - "
1538 "Unable to read in mpt_ioctl_eventenable struct @ %p\n", 1548 "Unable to read in mpt_ioctl_eventenable struct @ %p\n",
@@ -1542,11 +1552,13 @@ mptctl_eventenable (unsigned long arg)
1542 1552
1543 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || 1553 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
1544 (ioc == NULL)) { 1554 (ioc == NULL)) {
1545 dctlprintk((KERN_ERR "%s::mptctl_eventenable() @%d - ioc%d not found!\n", 1555 printk(KERN_DEBUG "%s::mptctl_eventenable() @%d - ioc%d not found!\n",
1546 __FILE__, __LINE__, iocnum)); 1556 __FILE__, __LINE__, iocnum);
1547 return -ENODEV; 1557 return -ENODEV;
1548 } 1558 }
1549 1559
1560 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventenable called.\n",
1561 ioc->name));
1550 if (ioc->events == NULL) { 1562 if (ioc->events == NULL) {
1551 /* Have not yet allocated memory - do so now. 1563 /* Have not yet allocated memory - do so now.
1552 */ 1564 */
@@ -1579,7 +1591,6 @@ mptctl_eventreport (unsigned long arg)
1579 int iocnum; 1591 int iocnum;
1580 int numBytes, maxEvents, max; 1592 int numBytes, maxEvents, max;
1581 1593
1582 dctlprintk(("mptctl_eventreport called.\n"));
1583 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) { 1594 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventreport))) {
1584 printk(KERN_ERR "%s@%d::mptctl_eventreport - " 1595 printk(KERN_ERR "%s@%d::mptctl_eventreport - "
1585 "Unable to read in mpt_ioctl_eventreport struct @ %p\n", 1596 "Unable to read in mpt_ioctl_eventreport struct @ %p\n",
@@ -1589,10 +1600,12 @@ mptctl_eventreport (unsigned long arg)
1589 1600
1590 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || 1601 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
1591 (ioc == NULL)) { 1602 (ioc == NULL)) {
1592 dctlprintk((KERN_ERR "%s::mptctl_eventreport() @%d - ioc%d not found!\n", 1603 printk(KERN_DEBUG "%s::mptctl_eventreport() @%d - ioc%d not found!\n",
1593 __FILE__, __LINE__, iocnum)); 1604 __FILE__, __LINE__, iocnum);
1594 return -ENODEV; 1605 return -ENODEV;
1595 } 1606 }
1607 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventreport called.\n",
1608 ioc->name));
1596 1609
1597 numBytes = karg.hdr.maxDataSize - sizeof(mpt_ioctl_header); 1610 numBytes = karg.hdr.maxDataSize - sizeof(mpt_ioctl_header);
1598 maxEvents = numBytes/sizeof(MPT_IOCTL_EVENTS); 1611 maxEvents = numBytes/sizeof(MPT_IOCTL_EVENTS);
@@ -1632,7 +1645,6 @@ mptctl_replace_fw (unsigned long arg)
1632 int iocnum; 1645 int iocnum;
1633 int newFwSize; 1646 int newFwSize;
1634 1647
1635 dctlprintk(("mptctl_replace_fw called.\n"));
1636 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) { 1648 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_replace_fw))) {
1637 printk(KERN_ERR "%s@%d::mptctl_replace_fw - " 1649 printk(KERN_ERR "%s@%d::mptctl_replace_fw - "
1638 "Unable to read in mpt_ioctl_replace_fw struct @ %p\n", 1650 "Unable to read in mpt_ioctl_replace_fw struct @ %p\n",
@@ -1642,11 +1654,13 @@ mptctl_replace_fw (unsigned long arg)
1642 1654
1643 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || 1655 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
1644 (ioc == NULL)) { 1656 (ioc == NULL)) {
1645 dctlprintk((KERN_ERR "%s::mptctl_replace_fw() @%d - ioc%d not found!\n", 1657 printk(KERN_DEBUG "%s::mptctl_replace_fw() @%d - ioc%d not found!\n",
1646 __FILE__, __LINE__, iocnum)); 1658 __FILE__, __LINE__, iocnum);
1647 return -ENODEV; 1659 return -ENODEV;
1648 } 1660 }
1649 1661
1662 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_replace_fw called.\n",
1663 ioc->name));
1650 /* If caching FW, Free the old FW image 1664 /* If caching FW, Free the old FW image
1651 */ 1665 */
1652 if (ioc->cached_fw == NULL) 1666 if (ioc->cached_fw == NULL)
@@ -1704,7 +1718,6 @@ mptctl_mpt_command (unsigned long arg)
1704 int iocnum; 1718 int iocnum;
1705 int rc; 1719 int rc;
1706 1720
1707 dctlprintk(("mptctl_command called.\n"));
1708 1721
1709 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) { 1722 if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_command))) {
1710 printk(KERN_ERR "%s@%d::mptctl_mpt_command - " 1723 printk(KERN_ERR "%s@%d::mptctl_mpt_command - "
@@ -1715,8 +1728,8 @@ mptctl_mpt_command (unsigned long arg)
1715 1728
1716 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || 1729 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
1717 (ioc == NULL)) { 1730 (ioc == NULL)) {
1718 dctlprintk((KERN_ERR "%s::mptctl_mpt_command() @%d - ioc%d not found!\n", 1731 printk(KERN_DEBUG "%s::mptctl_mpt_command() @%d - ioc%d not found!\n",
1719 __FILE__, __LINE__, iocnum)); 1732 __FILE__, __LINE__, iocnum);
1720 return -ENODEV; 1733 return -ENODEV;
1721 } 1734 }
1722 1735
@@ -1756,13 +1769,12 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
1756 ulong timeout; 1769 ulong timeout;
1757 struct scsi_device *sdev; 1770 struct scsi_device *sdev;
1758 1771
1759 dctlprintk(("mptctl_do_mpt_command called.\n"));
1760 bufIn.kptr = bufOut.kptr = NULL; 1772 bufIn.kptr = bufOut.kptr = NULL;
1761 1773
1762 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || 1774 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
1763 (ioc == NULL)) { 1775 (ioc == NULL)) {
1764 dctlprintk((KERN_ERR "%s::mptctl_do_mpt_command() @%d - ioc%d not found!\n", 1776 printk(KERN_DEBUG "%s::mptctl_do_mpt_command() @%d - ioc%d not found!\n",
1765 __FILE__, __LINE__, iocnum)); 1777 __FILE__, __LINE__, iocnum);
1766 return -ENODEV; 1778 return -ENODEV;
1767 } 1779 }
1768 if (!ioc->ioctl) { 1780 if (!ioc->ioctl) {
@@ -1816,6 +1828,9 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
1816 1828
1817 /* Verify that this request is allowed. 1829 /* Verify that this request is allowed.
1818 */ 1830 */
1831 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sending mpi function (0x%02X), req=%p\n",
1832 ioc->name, hdr->Function, mf));
1833
1819 switch (hdr->Function) { 1834 switch (hdr->Function) {
1820 case MPI_FUNCTION_IOC_FACTS: 1835 case MPI_FUNCTION_IOC_FACTS:
1821 case MPI_FUNCTION_PORT_FACTS: 1836 case MPI_FUNCTION_PORT_FACTS:
@@ -1823,6 +1838,18 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
1823 break; 1838 break;
1824 1839
1825 case MPI_FUNCTION_CONFIG: 1840 case MPI_FUNCTION_CONFIG:
1841 {
1842 Config_t *config_frame;
1843 config_frame = (Config_t *)mf;
1844 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "\ttype=0x%02x ext_type=0x%02x "
1845 "number=0x%02x action=0x%02x\n", ioc->name,
1846 config_frame->Header.PageType,
1847 config_frame->ExtPageType,
1848 config_frame->Header.PageNumber,
1849 config_frame->Action));
1850 break;
1851 }
1852
1826 case MPI_FUNCTION_FC_COMMON_TRANSPORT_SEND: 1853 case MPI_FUNCTION_FC_COMMON_TRANSPORT_SEND:
1827 case MPI_FUNCTION_FC_EX_LINK_SRVC_SEND: 1854 case MPI_FUNCTION_FC_EX_LINK_SRVC_SEND:
1828 case MPI_FUNCTION_FW_UPLOAD: 1855 case MPI_FUNCTION_FW_UPLOAD:
@@ -2158,12 +2185,12 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
2158 ioc->ioctl->wait_done = 0; 2185 ioc->ioctl->wait_done = 0;
2159 if (hdr->Function == MPI_FUNCTION_SCSI_TASK_MGMT) { 2186 if (hdr->Function == MPI_FUNCTION_SCSI_TASK_MGMT) {
2160 2187
2161 DBG_DUMP_TM_REQUEST_FRAME((u32 *)mf); 2188 DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf);
2162 2189
2163 if (mpt_send_handshake_request(mptctl_id, ioc, 2190 if (mpt_send_handshake_request(mptctl_id, ioc,
2164 sizeof(SCSITaskMgmt_t), (u32*)mf, 2191 sizeof(SCSITaskMgmt_t), (u32*)mf,
2165 CAN_SLEEP) != 0) { 2192 CAN_SLEEP) != 0) {
2166 dfailprintk((MYIOC_s_ERR_FMT "_send_handshake FAILED!" 2193 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT "_send_handshake FAILED!"
2167 " (ioc %p, mf %p) \n", ioc->name, 2194 " (ioc %p, mf %p) \n", ioc->name,
2168 ioc, mf)); 2195 ioc, mf));
2169 mptctl_free_tm_flags(ioc); 2196 mptctl_free_tm_flags(ioc);
@@ -2303,7 +2330,6 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
2303 MPT_FRAME_HDR *mf = NULL; 2330 MPT_FRAME_HDR *mf = NULL;
2304 MPIHeader_t *mpi_hdr; 2331 MPIHeader_t *mpi_hdr;
2305 2332
2306 dctlprintk((": mptctl_hp_hostinfo called.\n"));
2307 /* Reset long to int. Should affect IA64 and SPARC only 2333 /* Reset long to int. Should affect IA64 and SPARC only
2308 */ 2334 */
2309 if (data_size == sizeof(hp_host_info_t)) 2335 if (data_size == sizeof(hp_host_info_t))
@@ -2322,10 +2348,12 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
2322 2348
2323 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || 2349 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
2324 (ioc == NULL)) { 2350 (ioc == NULL)) {
2325 dctlprintk((KERN_ERR "%s::mptctl_hp_hostinfo() @%d - ioc%d not found!\n", 2351 printk(KERN_DEBUG "%s::mptctl_hp_hostinfo() @%d - ioc%d not found!\n",
2326 __FILE__, __LINE__, iocnum)); 2352 __FILE__, __LINE__, iocnum);
2327 return -ENODEV; 2353 return -ENODEV;
2328 } 2354 }
2355 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": mptctl_hp_hostinfo called.\n",
2356 ioc->name));
2329 2357
2330 /* Fill in the data and return the structure to the calling 2358 /* Fill in the data and return the structure to the calling
2331 * program 2359 * program
@@ -2441,7 +2469,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
2441 * Gather ISTWI(Industry Standard Two Wire Interface) Data 2469 * Gather ISTWI(Industry Standard Two Wire Interface) Data
2442 */ 2470 */
2443 if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) { 2471 if ((mf = mpt_get_msg_frame(mptctl_id, ioc)) == NULL) {
2444 dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames!!\n", 2472 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames!!\n",
2445 ioc->name,__FUNCTION__)); 2473 ioc->name,__FUNCTION__));
2446 goto out; 2474 goto out;
2447 } 2475 }
@@ -2474,7 +2502,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
2474 HZ*MPT_IOCTL_DEFAULT_TIMEOUT /* 10 sec */); 2502 HZ*MPT_IOCTL_DEFAULT_TIMEOUT /* 10 sec */);
2475 2503
2476 if(rc <=0 && (ioc->ioctl->wait_done != 1 )) { 2504 if(rc <=0 && (ioc->ioctl->wait_done != 1 )) {
2477 /* 2505 /*
2478 * Now we need to reset the board 2506 * Now we need to reset the board
2479 */ 2507 */
2480 mpt_free_msg_frame(ioc, mf); 2508 mpt_free_msg_frame(ioc, mf);
@@ -2482,7 +2510,7 @@ mptctl_hp_hostinfo(unsigned long arg, unsigned int data_size)
2482 goto out; 2510 goto out;
2483 } 2511 }
2484 2512
2485 /* 2513 /*
2486 *ISTWI Data Definition 2514 *ISTWI Data Definition
2487 * pbuf[0] = FW_VERSION = 0x4 2515 * pbuf[0] = FW_VERSION = 0x4
2488 * pbuf[1] = Bay Count = 6 or 4 or 2, depending on 2516 * pbuf[1] = Bay Count = 6 or 4 or 2, depending on
@@ -2538,7 +2566,6 @@ mptctl_hp_targetinfo(unsigned long arg)
2538 ConfigPageHeader_t hdr; 2566 ConfigPageHeader_t hdr;
2539 int tmp, np, rc = 0; 2567 int tmp, np, rc = 0;
2540 2568
2541 dctlprintk((": mptctl_hp_targetinfo called.\n"));
2542 if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) { 2569 if (copy_from_user(&karg, uarg, sizeof(hp_target_info_t))) {
2543 printk(KERN_ERR "%s@%d::mptctl_hp_targetinfo - " 2570 printk(KERN_ERR "%s@%d::mptctl_hp_targetinfo - "
2544 "Unable to read in hp_host_targetinfo struct @ %p\n", 2571 "Unable to read in hp_host_targetinfo struct @ %p\n",
@@ -2548,10 +2575,12 @@ mptctl_hp_targetinfo(unsigned long arg)
2548 2575
2549 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || 2576 if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) ||
2550 (ioc == NULL)) { 2577 (ioc == NULL)) {
2551 dctlprintk((KERN_ERR "%s::mptctl_hp_targetinfo() @%d - ioc%d not found!\n", 2578 printk(KERN_DEBUG "%s::mptctl_hp_targetinfo() @%d - ioc%d not found!\n",
2552 __FILE__, __LINE__, iocnum)); 2579 __FILE__, __LINE__, iocnum);
2553 return -ENODEV; 2580 return -ENODEV;
2554 } 2581 }
2582 dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT ": mptctl_hp_targetinfo called.\n",
2583 ioc->name));
2555 2584
2556 /* There is nothing to do for FCP parts. 2585 /* There is nothing to do for FCP parts.
2557 */ 2586 */
@@ -2694,7 +2723,6 @@ compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd,
2694 int nonblock = (filp->f_flags & O_NONBLOCK); 2723 int nonblock = (filp->f_flags & O_NONBLOCK);
2695 int ret; 2724 int ret;
2696 2725
2697 dctlprintk((KERN_INFO MYNAM "::compat_mptfwxfer_ioctl() called\n"));
2698 2726
2699 if (copy_from_user(&kfw32, (char __user *)arg, sizeof(kfw32))) 2727 if (copy_from_user(&kfw32, (char __user *)arg, sizeof(kfw32)))
2700 return -EFAULT; 2728 return -EFAULT;
@@ -2703,14 +2731,16 @@ compat_mptfwxfer_ioctl(struct file *filp, unsigned int cmd,
2703 iocnumX = kfw32.iocnum & 0xFF; 2731 iocnumX = kfw32.iocnum & 0xFF;
2704 if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || 2732 if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
2705 (iocp == NULL)) { 2733 (iocp == NULL)) {
2706 dctlprintk((KERN_ERR MYNAM "::compat_mptfwxfer_ioctl @%d - ioc%d not found!\n", 2734 printk(KERN_DEBUG MYNAM "::compat_mptfwxfer_ioctl @%d - ioc%d not found!\n",
2707 __LINE__, iocnumX)); 2735 __LINE__, iocnumX);
2708 return -ENODEV; 2736 return -ENODEV;
2709 } 2737 }
2710 2738
2711 if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0) 2739 if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)
2712 return ret; 2740 return ret;
2713 2741
2742 dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "compat_mptfwxfer_ioctl() called\n",
2743 iocp->name));
2714 kfw.iocnum = iocnum; 2744 kfw.iocnum = iocnum;
2715 kfw.fwlen = kfw32.fwlen; 2745 kfw.fwlen = kfw32.fwlen;
2716 kfw.bufp = compat_ptr(kfw32.bufp); 2746 kfw.bufp = compat_ptr(kfw32.bufp);
@@ -2734,8 +2764,6 @@ compat_mpt_command(struct file *filp, unsigned int cmd,
2734 int nonblock = (filp->f_flags & O_NONBLOCK); 2764 int nonblock = (filp->f_flags & O_NONBLOCK);
2735 int ret; 2765 int ret;
2736 2766
2737 dctlprintk((KERN_INFO MYNAM "::compat_mpt_command() called\n"));
2738
2739 if (copy_from_user(&karg32, (char __user *)arg, sizeof(karg32))) 2767 if (copy_from_user(&karg32, (char __user *)arg, sizeof(karg32)))
2740 return -EFAULT; 2768 return -EFAULT;
2741 2769
@@ -2743,14 +2771,16 @@ compat_mpt_command(struct file *filp, unsigned int cmd,
2743 iocnumX = karg32.hdr.iocnum & 0xFF; 2771 iocnumX = karg32.hdr.iocnum & 0xFF;
2744 if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) || 2772 if (((iocnum = mpt_verify_adapter(iocnumX, &iocp)) < 0) ||
2745 (iocp == NULL)) { 2773 (iocp == NULL)) {
2746 dctlprintk((KERN_ERR MYNAM "::compat_mpt_command @%d - ioc%d not found!\n", 2774 printk(KERN_DEBUG MYNAM "::compat_mpt_command @%d - ioc%d not found!\n",
2747 __LINE__, iocnumX)); 2775 __LINE__, iocnumX);
2748 return -ENODEV; 2776 return -ENODEV;
2749 } 2777 }
2750 2778
2751 if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0) 2779 if ((ret = mptctl_syscall_down(iocp, nonblock)) != 0)
2752 return ret; 2780 return ret;
2753 2781
2782 dctlprintk(iocp, printk(MYIOC_s_DEBUG_FMT "compat_mpt_command() called\n",
2783 iocp->name));
2754 /* Copy data to karg */ 2784 /* Copy data to karg */
2755 karg.hdr.iocnum = karg32.hdr.iocnum; 2785 karg.hdr.iocnum = karg32.hdr.iocnum;
2756 karg.hdr.port = karg32.hdr.port; 2786 karg.hdr.port = karg32.hdr.port;
@@ -2878,11 +2908,7 @@ static int __init mptctl_init(void)
2878 2908
2879 show_mptmod_ver(my_NAME, my_VERSION); 2909 show_mptmod_ver(my_NAME, my_VERSION);
2880 2910
2881 if(mpt_device_driver_register(&mptctl_driver, 2911 mpt_device_driver_register(&mptctl_driver, MPTCTL_DRIVER);
2882 MPTCTL_DRIVER) != 0 ) {
2883 dprintk((KERN_INFO MYNAM
2884 ": failed to register dd callbacks\n"));
2885 }
2886 2912
2887 /* Register this device */ 2913 /* Register this device */
2888 err = misc_register(&mptctl_miscdev); 2914 err = misc_register(&mptctl_miscdev);
@@ -2905,16 +2931,8 @@ static int __init mptctl_init(void)
2905 goto out_fail; 2931 goto out_fail;
2906 } 2932 }
2907 2933
2908 if (mpt_reset_register(mptctl_id, mptctl_ioc_reset) == 0) { 2934 mpt_reset_register(mptctl_id, mptctl_ioc_reset);
2909 dprintk((KERN_INFO MYNAM ": Registered for IOC reset notifications\n")); 2935 mpt_event_register(mptctl_id, mptctl_event_process);
2910 } else {
2911 /* FIXME! */
2912 }
2913
2914 if (mpt_event_register(mptctl_id, mptctl_event_process) == 0) {
2915 devtverboseprintk((KERN_INFO MYNAM
2916 ": Registered for IOC event notifications\n"));
2917 }
2918 2936
2919 return 0; 2937 return 0;
2920 2938
@@ -2934,11 +2952,9 @@ static void mptctl_exit(void)
2934 2952
2935 /* De-register reset handler from base module */ 2953 /* De-register reset handler from base module */
2936 mpt_reset_deregister(mptctl_id); 2954 mpt_reset_deregister(mptctl_id);
2937 dprintk((KERN_INFO MYNAM ": Deregistered for IOC reset notifications\n"));
2938 2955
2939 /* De-register callback handler from base module */ 2956 /* De-register callback handler from base module */
2940 mpt_deregister(mptctl_id); 2957 mpt_deregister(mptctl_id);
2941 printk(KERN_INFO MYNAM ": Deregistered from Fusion MPT base driver\n");
2942 2958
2943 mpt_device_driver_deregister(MPTCTL_DRIVER); 2959 mpt_device_driver_deregister(MPTCTL_DRIVER);
2944 2960
diff --git a/drivers/message/fusion/mptdebug.h b/drivers/message/fusion/mptdebug.h
new file mode 100644
index 000000000000..ffdb0a6191b4
--- /dev/null
+++ b/drivers/message/fusion/mptdebug.h
@@ -0,0 +1,288 @@
1/*
2 * linux/drivers/message/fusion/mptdebug.h
3 * For use with LSI PCI chip/adapter(s)
4 * running LSI Fusion MPT (Message Passing Technology) firmware.
5 *
6 * Copyright (c) 1999-2007 LSI Corporation
7 * (mailto:DL-MPTFusionLinux@lsi.com)
8 *
9 */
10/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
11
12#ifndef MPTDEBUG_H_INCLUDED
13#define MPTDEBUG_H_INCLUDED
14
15/*
16 * debug level can be programmed on the fly via SysFS (hex values)
17 *
18 * Example: (programming for MPT_DEBUG_EVENTS on host 5)
19 *
20 * echo 8 > /sys/class/scsi_host/host5/debug_level
21 *
22 * --------------------------------------------------------
23 * mpt_debug_level - command line parameter
24 * this allow enabling debug at driver load time (for all iocs)
25 *
26 * Example (programming for MPT_DEBUG_EVENTS)
27 *
28 * insmod mptbase.ko mpt_debug_level=8
29 *
30 * --------------------------------------------------------
31 * CONFIG_FUSION_LOGGING - enables compiling debug into driver
32 * this can be enabled in the driver Makefile
33 *
34 *
35 * --------------------------------------------------------
36 * Please note most debug prints are set to logging priority = debug
37 * This is the lowest level, and most verbose. Please refer to manual
38 * pages for syslogd or syslogd-ng on how to configure this.
39 */
40
41#define MPT_DEBUG 0x00000001
42#define MPT_DEBUG_MSG_FRAME 0x00000002
43#define MPT_DEBUG_SG 0x00000004
44#define MPT_DEBUG_EVENTS 0x00000008
45#define MPT_DEBUG_VERBOSE_EVENTS 0x00000010
46#define MPT_DEBUG_INIT 0x00000020
47#define MPT_DEBUG_EXIT 0x00000040
48#define MPT_DEBUG_FAIL 0x00000080
49#define MPT_DEBUG_TM 0x00000100
50#define MPT_DEBUG_DV 0x00000200
51#define MPT_DEBUG_REPLY 0x00000400
52#define MPT_DEBUG_HANDSHAKE 0x00000800
53#define MPT_DEBUG_CONFIG 0x00001000
54#define MPT_DEBUG_DL 0x00002000
55#define MPT_DEBUG_RESET 0x00008000
56#define MPT_DEBUG_SCSI 0x00010000
57#define MPT_DEBUG_IOCTL 0x00020000
58#define MPT_DEBUG_FC 0x00080000
59#define MPT_DEBUG_SAS 0x00100000
60#define MPT_DEBUG_SAS_WIDE 0x00200000
61
62/*
63 * CONFIG_FUSION_LOGGING - enabled in Kconfig
64 */
65
66#ifdef CONFIG_FUSION_LOGGING
67#define MPT_CHECK_LOGGING(IOC, CMD, BITS) \
68{ \
69 if (IOC->debug_level & BITS) \
70 CMD; \
71}
72#else
73#define MPT_CHECK_LOGGING(IOC, CMD, BITS)
74#endif
75
76
77/*
78 * debug macros
79 */
80
81#define dprintk(IOC, CMD) \
82 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG)
83
84#define dsgprintk(IOC, CMD) \
85 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SG)
86
87#define devtprintk(IOC, CMD) \
88 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EVENTS)
89
90#define devtverboseprintk(IOC, CMD) \
91 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_VERBOSE_EVENTS)
92
93#define dinitprintk(IOC, CMD) \
94 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_INIT)
95
96#define dexitprintk(IOC, CMD) \
97 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_EXIT)
98
99#define dfailprintk(IOC, CMD) \
100 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FAIL)
101
102#define dtmprintk(IOC, CMD) \
103 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_TM)
104
105#define ddvprintk(IOC, CMD) \
106 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DV)
107
108#define dreplyprintk(IOC, CMD) \
109 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_REPLY)
110
111#define dhsprintk(IOC, CMD) \
112 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_HANDSHAKE)
113
114#define dcprintk(IOC, CMD) \
115 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_CONFIG)
116
117#define ddlprintk(IOC, CMD) \
118 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_DL)
119
120#define drsprintk(IOC, CMD) \
121 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_RESET)
122
123#define dsprintk(IOC, CMD) \
124 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SCSI)
125
126#define dctlprintk(IOC, CMD) \
127 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_IOCTL)
128
129#define dfcprintk(IOC, CMD) \
130 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_FC)
131
132#define dsasprintk(IOC, CMD) \
133 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS)
134
135#define dsaswideprintk(IOC, CMD) \
136 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_SAS_WIDE)
137
138
139
140/*
141 * Verbose logging
142 */
143#if defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING)
144static inline void
145DBG_DUMP_FW_DOWNLOAD(MPT_ADAPTER *ioc, u32 *mfp, int numfrags)
146{
147 int i;
148
149 if (!(ioc->debug_level & MPT_DEBUG))
150 return;
151 printk(KERN_DEBUG "F/W download request:\n");
152 for (i=0; i < 7+numfrags*2; i++)
153 printk(" %08x", le32_to_cpu(mfp[i]));
154 printk("\n");
155}
156
157static inline void
158DBG_DUMP_PUT_MSG_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
159{
160 int ii, n;
161
162 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
163 return;
164 printk(KERN_DEBUG "%s: About to Put msg frame @ %p:\n",
165 ioc->name, mfp);
166 n = ioc->req_sz/4 - 1;
167 while (mfp[n] == 0)
168 n--;
169 for (ii=0; ii<=n; ii++) {
170 if (ii && ((ii%8)==0))
171 printk("\n");
172 printk(" %08x", le32_to_cpu(mfp[ii]));
173 }
174 printk("\n");
175}
176
177static inline void
178DBG_DUMP_FW_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
179{
180 int i, n;
181
182 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
183 return;
184 n = 10;
185 printk(KERN_INFO " ");
186 for (i = 0; i < n; i++)
187 printk(" %08x", le32_to_cpu(mfp[i]));
188 printk("\n");
189}
190
191static inline void
192DBG_DUMP_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
193{
194 int i, n;
195
196 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
197 return;
198 n = 24;
199 for (i=0; i<n; i++) {
200 if (i && ((i%8)==0))
201 printk("\n");
202 printk("%08x ", le32_to_cpu(mfp[i]));
203 }
204 printk("\n");
205}
206
207static inline void
208DBG_DUMP_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
209{
210 int i, n;
211
212 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
213 return;
214 n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
215 printk(KERN_INFO " ");
216 for (i=0; i<n; i++)
217 printk(" %08x", le32_to_cpu(mfp[i]));
218 printk("\n");
219}
220
221static inline void
222DBG_DUMP_REQUEST_FRAME_HDR(MPT_ADAPTER *ioc, u32 *mfp)
223{
224 int i, n;
225
226 if (!(ioc->debug_level & MPT_DEBUG_MSG_FRAME))
227 return;
228 n = 3;
229 printk(KERN_INFO " ");
230 for (i=0; i<n; i++)
231 printk(" %08x", le32_to_cpu(mfp[i]));
232 printk("\n");
233}
234
235static inline void
236DBG_DUMP_TM_REQUEST_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
237{
238 int i, n;
239
240 if (!(ioc->debug_level & MPT_DEBUG_TM))
241 return;
242 n = 13;
243 printk(KERN_DEBUG "TM_REQUEST:\n");
244 for (i=0; i<n; i++) {
245 if (i && ((i%8)==0))
246 printk("\n");
247 printk("%08x ", le32_to_cpu(mfp[i]));
248 }
249 printk("\n");
250}
251
252static inline void
253DBG_DUMP_TM_REPLY_FRAME(MPT_ADAPTER *ioc, u32 *mfp)
254{
255 int i, n;
256
257 if (!(ioc->debug_level & MPT_DEBUG_TM))
258 return;
259 n = (le32_to_cpu(mfp[0]) & 0x00FF0000) >> 16;
260 printk(KERN_DEBUG "TM_REPLY MessageLength=%d:\n", n);
261 for (i=0; i<n; i++) {
262 if (i && ((i%8)==0))
263 printk("\n");
264 printk(" %08x", le32_to_cpu(mfp[i]));
265 }
266 printk("\n");
267}
268
269#define dmfprintk(IOC, CMD) \
270 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
271
272# else /* ifdef MPT_DEBUG_MF */
273
274#define DBG_DUMP_FW_DOWNLOAD(IOC, mfp, numfrags)
275#define DBG_DUMP_PUT_MSG_FRAME(IOC, mfp)
276#define DBG_DUMP_FW_REQUEST_FRAME(IOC, mfp)
277#define DBG_DUMP_REQUEST_FRAME(IOC, mfp)
278#define DBG_DUMP_REPLY_FRAME(IOC, mfp)
279#define DBG_DUMP_REQUEST_FRAME_HDR(IOC, mfp)
280#define DBG_DUMP_TM_REQUEST_FRAME(IOC, mfp)
281#define DBG_DUMP_TM_REPLY_FRAME(IOC, mfp)
282
283#define dmfprintk(IOC, CMD) \
284 MPT_CHECK_LOGGING(IOC, CMD, MPT_DEBUG_MSG_FRAME)
285
286#endif /* defined(MPT_DEBUG_VERBOSE) && defined(CONFIG_FUSION_LOGGING) */
287
288#endif /* ifndef MPTDEBUG_H_INCLUDED */
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index f2ebaa9992fe..8422c25e4a3e 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -188,16 +188,18 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
188 int (*func)(struct scsi_cmnd *SCpnt), 188 int (*func)(struct scsi_cmnd *SCpnt),
189 const char *caller) 189 const char *caller)
190{ 190{
191 MPT_SCSI_HOST *hd;
191 struct scsi_device *sdev = SCpnt->device; 192 struct scsi_device *sdev = SCpnt->device;
192 struct Scsi_Host *shost = sdev->host; 193 struct Scsi_Host *shost = sdev->host;
193 struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); 194 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
194 unsigned long flags; 195 unsigned long flags;
195 int ready; 196 int ready;
196 197
198 hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata;
197 spin_lock_irqsave(shost->host_lock, flags); 199 spin_lock_irqsave(shost->host_lock, flags);
198 while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) { 200 while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY) {
199 spin_unlock_irqrestore(shost->host_lock, flags); 201 spin_unlock_irqrestore(shost->host_lock, flags);
200 dfcprintk ((MYIOC_s_INFO_FMT 202 dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT
201 "mptfc_block_error_handler.%d: %d:%d, port status is " 203 "mptfc_block_error_handler.%d: %d:%d, port status is "
202 "DID_IMM_RETRY, deferring %s recovery.\n", 204 "DID_IMM_RETRY, deferring %s recovery.\n",
203 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, 205 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
@@ -209,7 +211,7 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
209 spin_unlock_irqrestore(shost->host_lock, flags); 211 spin_unlock_irqrestore(shost->host_lock, flags);
210 212
211 if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata) { 213 if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata) {
212 dfcprintk ((MYIOC_s_INFO_FMT 214 dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT
213 "%s.%d: %d:%d, failing recovery, " 215 "%s.%d: %d:%d, failing recovery, "
214 "port state %d, vdev %p.\n", caller, 216 "port state %d, vdev %p.\n", caller,
215 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, 217 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
@@ -218,7 +220,7 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
218 SCpnt->device->hostdata)); 220 SCpnt->device->hostdata));
219 return FAILED; 221 return FAILED;
220 } 222 }
221 dfcprintk ((MYIOC_s_INFO_FMT 223 dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT
222 "%s.%d: %d:%d, executing recovery.\n", caller, 224 "%s.%d: %d:%d, executing recovery.\n", caller,
223 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name, 225 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->name,
224 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no, 226 ((MPT_SCSI_HOST *) shost->hostdata)->ioc->sh->host_no,
@@ -483,7 +485,7 @@ mptfc_register_dev(MPT_ADAPTER *ioc, int channel, FCDevicePage0_t *pg0)
483 485
484 pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low; 486 pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low;
485 nn = (u64)ri->pg0.WWNN.High << 32 | (u64)ri->pg0.WWNN.Low; 487 nn = (u64)ri->pg0.WWNN.High << 32 | (u64)ri->pg0.WWNN.Low;
486 dfcprintk ((MYIOC_s_INFO_FMT 488 dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
487 "mptfc_reg_dev.%d: %x, %llx / %llx, tid %d, " 489 "mptfc_reg_dev.%d: %x, %llx / %llx, tid %d, "
488 "rport tid %d, tmo %d\n", 490 "rport tid %d, tmo %d\n",
489 ioc->name, 491 ioc->name,
@@ -559,6 +561,35 @@ mptfc_target_alloc(struct scsi_target *starget)
559 561
560 return rc; 562 return rc;
561} 563}
564/*
565 * mptfc_dump_lun_info
566 * @ioc
567 * @rport
568 * @sdev
569 *
570 */
571static void
572mptfc_dump_lun_info(MPT_ADAPTER *ioc, struct fc_rport *rport, struct scsi_device *sdev,
573 VirtTarget *vtarget)
574{
575 u64 nn, pn;
576 struct mptfc_rport_info *ri;
577
578 ri = *((struct mptfc_rport_info **)rport->dd_data);
579 pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low;
580 nn = (u64)ri->pg0.WWNN.High << 32 | (u64)ri->pg0.WWNN.Low;
581 dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
582 "mptfc_slv_alloc.%d: num_luns %d, sdev.id %d, "
583 "CurrentTargetID %d, %x %llx %llx\n",
584 ioc->name,
585 sdev->host->host_no,
586 vtarget->num_luns,
587 sdev->id, ri->pg0.CurrentTargetID,
588 ri->pg0.PortIdentifier,
589 (unsigned long long)pn,
590 (unsigned long long)nn));
591}
592
562 593
563/* 594/*
564 * OS entry point to allow host driver to alloc memory 595 * OS entry point to allow host driver to alloc memory
@@ -606,25 +637,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
606 vtarget->num_luns++; 637 vtarget->num_luns++;
607 638
608 639
609#ifdef DMPT_DEBUG_FC 640 mptfc_dump_lun_info(hd->ioc, rport, sdev, vtarget);
610 {
611 u64 nn, pn;
612 struct mptfc_rport_info *ri;
613 ri = *((struct mptfc_rport_info **)rport->dd_data);
614 pn = (u64)ri->pg0.WWPN.High << 32 | (u64)ri->pg0.WWPN.Low;
615 nn = (u64)ri->pg0.WWNN.High << 32 | (u64)ri->pg0.WWNN.Low;
616 dfcprintk ((MYIOC_s_INFO_FMT
617 "mptfc_slv_alloc.%d: num_luns %d, sdev.id %d, "
618 "CurrentTargetID %d, %x %llx %llx\n",
619 hd->ioc->name,
620 sdev->host->host_no,
621 vtarget->num_luns,
622 sdev->id, ri->pg0.CurrentTargetID,
623 ri->pg0.PortIdentifier,
624 (unsigned long long)pn,
625 (unsigned long long)nn));
626 }
627#endif
628 641
629 return 0; 642 return 0;
630} 643}
@@ -653,27 +666,12 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
653 /* dd_data is null until finished adding target */ 666 /* dd_data is null until finished adding target */
654 ri = *((struct mptfc_rport_info **)rport->dd_data); 667 ri = *((struct mptfc_rport_info **)rport->dd_data);
655 if (unlikely(!ri)) { 668 if (unlikely(!ri)) {
656 dfcprintk ((MYIOC_s_INFO_FMT
657 "mptfc_qcmd.%d: %d:%d, dd_data is null.\n",
658 ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->name,
659 ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->sh->host_no,
660 SCpnt->device->id,SCpnt->device->lun));
661 SCpnt->result = DID_IMM_RETRY << 16; 669 SCpnt->result = DID_IMM_RETRY << 16;
662 done(SCpnt); 670 done(SCpnt);
663 return 0; 671 return 0;
664 } 672 }
665 673
666 err = mptscsih_qcmd(SCpnt,done); 674 return mptscsih_qcmd(SCpnt,done);
667#ifdef DMPT_DEBUG_FC
668 if (unlikely(err)) {
669 dfcprintk ((MYIOC_s_INFO_FMT
670 "mptfc_qcmd.%d: %d:%d, mptscsih_qcmd returns non-zero, (%x).\n",
671 ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->name,
672 ((MPT_SCSI_HOST *) SCpnt->device->host->hostdata)->ioc->sh->host_no,
673 SCpnt->device->id,SCpnt->device->lun,err));
674 }
675#endif
676 return err;
677} 675}
678 676
679/* 677/*
@@ -1041,7 +1039,7 @@ mptfc_setup_reset(struct work_struct *work)
1041 1039
1042 pn = (u64)ri->pg0.WWPN.High << 32 | 1040 pn = (u64)ri->pg0.WWPN.High << 32 |
1043 (u64)ri->pg0.WWPN.Low; 1041 (u64)ri->pg0.WWPN.Low;
1044 dfcprintk ((MYIOC_s_INFO_FMT 1042 dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
1045 "mptfc_setup_reset.%d: %llx deleted\n", 1043 "mptfc_setup_reset.%d: %llx deleted\n",
1046 ioc->name, 1044 ioc->name,
1047 ioc->sh->host_no, 1045 ioc->sh->host_no,
@@ -1088,7 +1086,7 @@ mptfc_rescan_devices(struct work_struct *work)
1088 1086
1089 pn = (u64)ri->pg0.WWPN.High << 32 | 1087 pn = (u64)ri->pg0.WWPN.High << 32 |
1090 (u64)ri->pg0.WWPN.Low; 1088 (u64)ri->pg0.WWPN.Low;
1091 dfcprintk ((MYIOC_s_INFO_FMT 1089 dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
1092 "mptfc_rescan.%d: %llx deleted\n", 1090 "mptfc_rescan.%d: %llx deleted\n",
1093 ioc->name, 1091 ioc->name,
1094 ioc->sh->host_no, 1092 ioc->sh->host_no,
@@ -1212,7 +1210,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1212 1210
1213 if (numSGE < sh->sg_tablesize) { 1211 if (numSGE < sh->sg_tablesize) {
1214 /* Reset this value */ 1212 /* Reset this value */
1215 dprintk((MYIOC_s_INFO_FMT 1213 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1216 "Resetting sg_tablesize to %d from %d\n", 1214 "Resetting sg_tablesize to %d from %d\n",
1217 ioc->name, numSGE, sh->sg_tablesize)); 1215 ioc->name, numSGE, sh->sg_tablesize));
1218 sh->sg_tablesize = numSGE; 1216 sh->sg_tablesize = numSGE;
@@ -1232,7 +1230,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1232 goto out_mptfc_probe; 1230 goto out_mptfc_probe;
1233 } 1231 }
1234 1232
1235 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n", 1233 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n",
1236 ioc->name, hd->ScsiLookup)); 1234 ioc->name, hd->ScsiLookup));
1237 1235
1238 /* Clear the TM flags 1236 /* Clear the TM flags
@@ -1264,7 +1262,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1264 sh->transportt = mptfc_transport_template; 1262 sh->transportt = mptfc_transport_template;
1265 error = scsi_add_host (sh, &ioc->pcidev->dev); 1263 error = scsi_add_host (sh, &ioc->pcidev->dev);
1266 if(error) { 1264 if(error) {
1267 dprintk((KERN_ERR MYNAM 1265 dprintk(ioc, printk(KERN_ERR MYNAM
1268 "scsi_add_host failed\n")); 1266 "scsi_add_host failed\n"));
1269 goto out_mptfc_probe; 1267 goto out_mptfc_probe;
1270 } 1268 }
@@ -1323,7 +1321,7 @@ mptfc_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
1323 unsigned long flags; 1321 unsigned long flags;
1324 int rc=1; 1322 int rc=1;
1325 1323
1326 devtverboseprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n", 1324 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n",
1327 ioc->name, event)); 1325 ioc->name, event));
1328 1326
1329 if (ioc->sh == NULL || 1327 if (ioc->sh == NULL ||
@@ -1357,8 +1355,8 @@ mptfc_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
1357 return rc; 1355 return rc;
1358 1356
1359 1357
1360 dtmprintk((KERN_WARNING MYNAM 1358 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1361 ": IOC %s_reset routed to FC host driver!\n", 1359 ": IOC %s_reset routed to FC host driver!\n",ioc->name,
1362 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( 1360 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
1363 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); 1361 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
1364 1362
@@ -1413,15 +1411,8 @@ mptfc_init(void)
1413 mptfcTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTFC_DRIVER); 1411 mptfcTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTFC_DRIVER);
1414 mptfcInternalCtx = mpt_register(mptscsih_scandv_complete, MPTFC_DRIVER); 1412 mptfcInternalCtx = mpt_register(mptscsih_scandv_complete, MPTFC_DRIVER);
1415 1413
1416 if (mpt_event_register(mptfcDoneCtx, mptfc_event_process) == 0) { 1414 mpt_event_register(mptfcDoneCtx, mptfc_event_process);
1417 devtverboseprintk((KERN_INFO MYNAM 1415 mpt_reset_register(mptfcDoneCtx, mptfc_ioc_reset);
1418 ": Registered for IOC event notifications\n"));
1419 }
1420
1421 if (mpt_reset_register(mptfcDoneCtx, mptfc_ioc_reset) == 0) {
1422 dprintk((KERN_INFO MYNAM
1423 ": Registered for IOC reset notifications\n"));
1424 }
1425 1416
1426 error = pci_register_driver(&mptfc_driver); 1417 error = pci_register_driver(&mptfc_driver);
1427 if (error) 1418 if (error)
@@ -1486,12 +1477,7 @@ mptfc_exit(void)
1486 fc_release_transport(mptfc_transport_template); 1477 fc_release_transport(mptfc_transport_template);
1487 1478
1488 mpt_reset_deregister(mptfcDoneCtx); 1479 mpt_reset_deregister(mptfcDoneCtx);
1489 dprintk((KERN_INFO MYNAM
1490 ": Deregistered for IOC reset notifications\n"));
1491
1492 mpt_event_deregister(mptfcDoneCtx); 1480 mpt_event_deregister(mptfcDoneCtx);
1493 dprintk((KERN_INFO MYNAM
1494 ": Deregistered for IOC event notifications\n"));
1495 1481
1496 mpt_deregister(mptfcInternalCtx); 1482 mpt_deregister(mptfcInternalCtx);
1497 mpt_deregister(mptfcTaskCtx); 1483 mpt_deregister(mptfcTaskCtx);
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 7e8a90cb484e..01fc397fdd97 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -1524,8 +1524,7 @@ static int __init mpt_lan_init (void)
1524 1524
1525 dlprintk((KERN_INFO MYNAM ": Registered for IOC reset notifications\n")); 1525 dlprintk((KERN_INFO MYNAM ": Registered for IOC reset notifications\n"));
1526 1526
1527 if (mpt_device_driver_register(&mptlan_driver, MPTLAN_DRIVER)) 1527 mpt_device_driver_register(&mptlan_driver, MPTLAN_DRIVER);
1528 dprintk((KERN_INFO MYNAM ": failed to register dd callbacks\n"));
1529 return 0; 1528 return 0;
1530} 1529}
1531 1530
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index d50664640512..29add83da588 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -201,103 +201,91 @@ struct mptsas_enclosure {
201 u8 sep_channel; /* SEP channel logical channel id */ 201 u8 sep_channel; /* SEP channel logical channel id */
202}; 202};
203 203
204#ifdef MPT_DEBUG_SAS 204static void mptsas_print_phy_data(MPT_ADAPTER *ioc,
205static void mptsas_print_phy_data(MPI_SAS_IO_UNIT0_PHY_DATA *phy_data) 205 MPI_SAS_IO_UNIT0_PHY_DATA *phy_data)
206{ 206{
207 printk("---- IO UNIT PAGE 0 ------------\n"); 207 dsasprintk(ioc, printk(KERN_DEBUG "---- IO UNIT PAGE 0 ------------\n"));
208 printk("Handle=0x%X\n", 208 dsasprintk(ioc, printk(KERN_DEBUG "Handle=0x%X\n",
209 le16_to_cpu(phy_data->AttachedDeviceHandle)); 209 le16_to_cpu(phy_data->AttachedDeviceHandle)));
210 printk("Controller Handle=0x%X\n", 210 dsasprintk(ioc, printk(KERN_DEBUG "Controller Handle=0x%X\n",
211 le16_to_cpu(phy_data->ControllerDevHandle)); 211 le16_to_cpu(phy_data->ControllerDevHandle)));
212 printk("Port=0x%X\n", phy_data->Port); 212 dsasprintk(ioc, printk(KERN_DEBUG "Port=0x%X\n", phy_data->Port));
213 printk("Port Flags=0x%X\n", phy_data->PortFlags); 213 dsasprintk(ioc, printk(KERN_DEBUG "Port Flags=0x%X\n", phy_data->PortFlags));
214 printk("PHY Flags=0x%X\n", phy_data->PhyFlags); 214 dsasprintk(ioc, printk(KERN_DEBUG "PHY Flags=0x%X\n", phy_data->PhyFlags));
215 printk("Negotiated Link Rate=0x%X\n", phy_data->NegotiatedLinkRate); 215 dsasprintk(ioc, printk(KERN_DEBUG "Negotiated Link Rate=0x%X\n", phy_data->NegotiatedLinkRate));
216 printk("Controller PHY Device Info=0x%X\n", 216 dsasprintk(ioc, printk(KERN_DEBUG "Controller PHY Device Info=0x%X\n",
217 le32_to_cpu(phy_data->ControllerPhyDeviceInfo)); 217 le32_to_cpu(phy_data->ControllerPhyDeviceInfo)));
218 printk("DiscoveryStatus=0x%X\n", 218 dsasprintk(ioc, printk(KERN_DEBUG "DiscoveryStatus=0x%X\n\n",
219 le32_to_cpu(phy_data->DiscoveryStatus)); 219 le32_to_cpu(phy_data->DiscoveryStatus)));
220 printk("\n");
221} 220}
222 221
223static void mptsas_print_phy_pg0(SasPhyPage0_t *pg0) 222static void mptsas_print_phy_pg0(MPT_ADAPTER *ioc, SasPhyPage0_t *pg0)
224{ 223{
225 __le64 sas_address; 224 __le64 sas_address;
226 225
227 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); 226 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64));
228 227
229 printk("---- SAS PHY PAGE 0 ------------\n"); 228 dsasprintk(ioc, printk(KERN_DEBUG "---- SAS PHY PAGE 0 ------------\n"));
230 printk("Attached Device Handle=0x%X\n", 229 dsasprintk(ioc, printk(KERN_DEBUG "Attached Device Handle=0x%X\n",
231 le16_to_cpu(pg0->AttachedDevHandle)); 230 le16_to_cpu(pg0->AttachedDevHandle)));
232 printk("SAS Address=0x%llX\n", 231 dsasprintk(ioc, printk(KERN_DEBUG "SAS Address=0x%llX\n",
233 (unsigned long long)le64_to_cpu(sas_address)); 232 (unsigned long long)le64_to_cpu(sas_address)));
234 printk("Attached PHY Identifier=0x%X\n", pg0->AttachedPhyIdentifier); 233 dsasprintk(ioc, printk(KERN_DEBUG "Attached PHY Identifier=0x%X\n", pg0->AttachedPhyIdentifier));
235 printk("Attached Device Info=0x%X\n", 234 dsasprintk(ioc, printk(KERN_DEBUG "Attached Device Info=0x%X\n",
236 le32_to_cpu(pg0->AttachedDeviceInfo)); 235 le32_to_cpu(pg0->AttachedDeviceInfo)));
237 printk("Programmed Link Rate=0x%X\n", pg0->ProgrammedLinkRate); 236 dsasprintk(ioc, printk(KERN_DEBUG "Programmed Link Rate=0x%X\n", pg0->ProgrammedLinkRate));
238 printk("Change Count=0x%X\n", pg0->ChangeCount); 237 dsasprintk(ioc, printk(KERN_DEBUG "Change Count=0x%X\n", pg0->ChangeCount));
239 printk("PHY Info=0x%X\n", le32_to_cpu(pg0->PhyInfo)); 238 dsasprintk(ioc, printk(KERN_DEBUG "PHY Info=0x%X\n\n", le32_to_cpu(pg0->PhyInfo)));
240 printk("\n");
241} 239}
242 240
243static void mptsas_print_phy_pg1(SasPhyPage1_t *pg1) 241static void mptsas_print_phy_pg1(MPT_ADAPTER *ioc, SasPhyPage1_t *pg1)
244{ 242{
245 printk("---- SAS PHY PAGE 1 ------------\n"); 243 dsasprintk(ioc, printk(KERN_DEBUG "---- SAS PHY PAGE 1 ------------\n"));
246 printk("Invalid Dword Count=0x%x\n", pg1->InvalidDwordCount); 244 dsasprintk(ioc, printk(KERN_DEBUG "Invalid Dword Count=0x%x\n", pg1->InvalidDwordCount));
247 printk("Running Disparity Error Count=0x%x\n", 245 dsasprintk(ioc, printk(KERN_DEBUG "Running Disparity Error Count=0x%x\n",
248 pg1->RunningDisparityErrorCount); 246 pg1->RunningDisparityErrorCount));
249 printk("Loss Dword Synch Count=0x%x\n", pg1->LossDwordSynchCount); 247 dsasprintk(ioc, printk(KERN_DEBUG "Loss Dword Synch Count=0x%x\n", pg1->LossDwordSynchCount));
250 printk("PHY Reset Problem Count=0x%x\n", pg1->PhyResetProblemCount); 248 dsasprintk(ioc, printk(KERN_DEBUG "PHY Reset Problem Count=0x%x\n\n", pg1->PhyResetProblemCount));
251 printk("\n");
252} 249}
253 250
254static void mptsas_print_device_pg0(SasDevicePage0_t *pg0) 251static void mptsas_print_device_pg0(MPT_ADAPTER *ioc, SasDevicePage0_t *pg0)
255{ 252{
256 __le64 sas_address; 253 __le64 sas_address;
257 254
258 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64)); 255 memcpy(&sas_address, &pg0->SASAddress, sizeof(__le64));
259 256
260 printk("---- SAS DEVICE PAGE 0 ---------\n"); 257 dsasprintk(ioc, printk(KERN_DEBUG "---- SAS DEVICE PAGE 0 ---------\n"));
261 printk("Handle=0x%X\n" ,le16_to_cpu(pg0->DevHandle)); 258 dsasprintk(ioc, printk(KERN_DEBUG "Handle=0x%X\n" ,le16_to_cpu(pg0->DevHandle)));
262 printk("Parent Handle=0x%X\n" ,le16_to_cpu(pg0->ParentDevHandle)); 259 dsasprintk(ioc, printk(KERN_DEBUG "Parent Handle=0x%X\n" ,le16_to_cpu(pg0->ParentDevHandle)));
263 printk("Enclosure Handle=0x%X\n", le16_to_cpu(pg0->EnclosureHandle)); 260 dsasprintk(ioc, printk(KERN_DEBUG "Enclosure Handle=0x%X\n", le16_to_cpu(pg0->EnclosureHandle)));
264 printk("Slot=0x%X\n", le16_to_cpu(pg0->Slot)); 261 dsasprintk(ioc, printk(KERN_DEBUG "Slot=0x%X\n", le16_to_cpu(pg0->Slot)));
265 printk("SAS Address=0x%llX\n", (unsigned long long) 262 dsasprintk(ioc, printk(KERN_DEBUG "SAS Address=0x%llX\n", (unsigned long long)
266 le64_to_cpu(sas_address)); 263 le64_to_cpu(sas_address)));
267 printk("Target ID=0x%X\n", pg0->TargetID); 264 dsasprintk(ioc, printk(KERN_DEBUG "Target ID=0x%X\n", pg0->TargetID));
268 printk("Bus=0x%X\n", pg0->Bus); 265 dsasprintk(ioc, printk(KERN_DEBUG "Bus=0x%X\n", pg0->Bus));
269 /* The PhyNum field specifies the PHY number of the parent 266 /* The PhyNum field specifies the PHY number of the parent
270 * device this device is linked to 267 * device this device is linked to
271 */ 268 */
272 printk("Parent Phy Num=0x%X\n", pg0->PhyNum); 269 dsasprintk(ioc, printk(KERN_DEBUG "Parent Phy Num=0x%X\n", pg0->PhyNum));
273 printk("Access Status=0x%X\n", le16_to_cpu(pg0->AccessStatus)); 270 dsasprintk(ioc, printk(KERN_DEBUG "Access Status=0x%X\n", le16_to_cpu(pg0->AccessStatus)));
274 printk("Device Info=0x%X\n", le32_to_cpu(pg0->DeviceInfo)); 271 dsasprintk(ioc, printk(KERN_DEBUG "Device Info=0x%X\n", le32_to_cpu(pg0->DeviceInfo)));
275 printk("Flags=0x%X\n", le16_to_cpu(pg0->Flags)); 272 dsasprintk(ioc, printk(KERN_DEBUG "Flags=0x%X\n", le16_to_cpu(pg0->Flags)));
276 printk("Physical Port=0x%X\n", pg0->PhysicalPort); 273 dsasprintk(ioc, printk(KERN_DEBUG "Physical Port=0x%X\n\n", pg0->PhysicalPort));
277 printk("\n");
278} 274}
279 275
280static void mptsas_print_expander_pg1(SasExpanderPage1_t *pg1) 276static void mptsas_print_expander_pg1(MPT_ADAPTER *ioc, SasExpanderPage1_t *pg1)
281{ 277{
282 printk("---- SAS EXPANDER PAGE 1 ------------\n"); 278 dsasprintk(ioc, printk(KERN_DEBUG "---- SAS EXPANDER PAGE 1 ------------\n"));
283 279 dsasprintk(ioc, printk(KERN_DEBUG "Physical Port=0x%X\n", pg1->PhysicalPort));
284 printk("Physical Port=0x%X\n", pg1->PhysicalPort); 280 dsasprintk(ioc, printk(KERN_DEBUG "PHY Identifier=0x%X\n", pg1->PhyIdentifier));
285 printk("PHY Identifier=0x%X\n", pg1->PhyIdentifier); 281 dsasprintk(ioc, printk(KERN_DEBUG "Negotiated Link Rate=0x%X\n", pg1->NegotiatedLinkRate));
286 printk("Negotiated Link Rate=0x%X\n", pg1->NegotiatedLinkRate); 282 dsasprintk(ioc, printk(KERN_DEBUG "Programmed Link Rate=0x%X\n", pg1->ProgrammedLinkRate));
287 printk("Programmed Link Rate=0x%X\n", pg1->ProgrammedLinkRate); 283 dsasprintk(ioc, printk(KERN_DEBUG "Hardware Link Rate=0x%X\n", pg1->HwLinkRate));
288 printk("Hardware Link Rate=0x%X\n", pg1->HwLinkRate); 284 dsasprintk(ioc, printk(KERN_DEBUG "Owner Device Handle=0x%X\n",
289 printk("Owner Device Handle=0x%X\n", 285 le16_to_cpu(pg1->OwnerDevHandle)));
290 le16_to_cpu(pg1->OwnerDevHandle)); 286 dsasprintk(ioc, printk(KERN_DEBUG "Attached Device Handle=0x%X\n\n",
291 printk("Attached Device Handle=0x%X\n", 287 le16_to_cpu(pg1->AttachedDevHandle)));
292 le16_to_cpu(pg1->AttachedDevHandle));
293} 288}
294#else
295#define mptsas_print_phy_data(phy_data) do { } while (0)
296#define mptsas_print_phy_pg0(pg0) do { } while (0)
297#define mptsas_print_phy_pg1(pg1) do { } while (0)
298#define mptsas_print_device_pg0(pg0) do { } while (0)
299#define mptsas_print_expander_pg1(pg1) do { } while (0)
300#endif
301 289
302static inline MPT_ADAPTER *phy_to_ioc(struct sas_phy *phy) 290static inline MPT_ADAPTER *phy_to_ioc(struct sas_phy *phy)
303{ 291{
@@ -354,7 +342,7 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
354 342
355/* no mutex */ 343/* no mutex */
356static void 344static void
357mptsas_port_delete(struct mptsas_portinfo_details * port_details) 345mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
358{ 346{
359 struct mptsas_portinfo *port_info; 347 struct mptsas_portinfo *port_info;
360 struct mptsas_phyinfo *phy_info; 348 struct mptsas_phyinfo *phy_info;
@@ -366,7 +354,7 @@ mptsas_port_delete(struct mptsas_portinfo_details * port_details)
366 port_info = port_details->port_info; 354 port_info = port_details->port_info;
367 phy_info = port_info->phy_info; 355 phy_info = port_info->phy_info;
368 356
369 dsaswideprintk((KERN_DEBUG "%s: [%p]: num_phys=%02d " 357 dsaswideprintk(ioc, printk(KERN_DEBUG "%s: [%p]: num_phys=%02d "
370 "bitmask=0x%016llX\n", __FUNCTION__, port_details, 358 "bitmask=0x%016llX\n", __FUNCTION__, port_details,
371 port_details->num_phys, (unsigned long long) 359 port_details->num_phys, (unsigned long long)
372 port_details->phy_bitmask)); 360 port_details->phy_bitmask));
@@ -390,20 +378,19 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
390} 378}
391 379
392static inline void 380static inline void
393mptsas_set_rphy(struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy) 381mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
394{ 382{
395 if (phy_info->port_details) { 383 if (phy_info->port_details) {
396 phy_info->port_details->rphy = rphy; 384 phy_info->port_details->rphy = rphy;
397 dsaswideprintk((KERN_DEBUG "sas_rphy_add: rphy=%p\n", rphy)); 385 dsaswideprintk(ioc, printk(KERN_DEBUG "sas_rphy_add: rphy=%p\n", rphy));
398 } 386 }
399 387
400#ifdef MPT_DEBUG_SAS_WIDE
401 if (rphy) { 388 if (rphy) {
402 dev_printk(KERN_DEBUG, &rphy->dev, "add:"); 389 dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
403 printk("rphy=%p release=%p\n", 390 &rphy->dev, "add:"));
404 rphy, rphy->dev.release); 391 dsaswideprintk(ioc, printk(KERN_DEBUG "rphy=%p release=%p\n",
392 rphy, rphy->dev.release));
405 } 393 }
406#endif
407} 394}
408 395
409static inline struct sas_port * 396static inline struct sas_port *
@@ -416,18 +403,17 @@ mptsas_get_port(struct mptsas_phyinfo *phy_info)
416} 403}
417 404
418static inline void 405static inline void
419mptsas_set_port(struct mptsas_phyinfo *phy_info, struct sas_port *port) 406mptsas_set_port(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_port *port)
420{ 407{
421 if (phy_info->port_details) 408 if (phy_info->port_details)
422 phy_info->port_details->port = port; 409 phy_info->port_details->port = port;
423 410
424#ifdef MPT_DEBUG_SAS_WIDE
425 if (port) { 411 if (port) {
426 dev_printk(KERN_DEBUG, &port->dev, "add: "); 412 dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
427 printk("port=%p release=%p\n", 413 &port->dev, "add:"));
428 port, port->dev.release); 414 dsaswideprintk(ioc, printk(KERN_DEBUG "port=%p release=%p\n",
415 port, port->dev.release));
429 } 416 }
430#endif
431} 417}
432 418
433static inline struct scsi_target * 419static inline struct scsi_target *
@@ -477,7 +463,7 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
477 * Removing a phy from a port, letting the last 463 * Removing a phy from a port, letting the last
478 * phy be removed by firmware events. 464 * phy be removed by firmware events.
479 */ 465 */
480 dsaswideprintk((KERN_DEBUG 466 dsaswideprintk(ioc, printk(KERN_DEBUG
481 "%s: [%p]: deleting phy = %d\n", 467 "%s: [%p]: deleting phy = %d\n",
482 __FUNCTION__, port_details, i)); 468 __FUNCTION__, port_details, i));
483 port_details->num_phys--; 469 port_details->num_phys--;
@@ -493,7 +479,7 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
493 phy_info = port_info->phy_info; 479 phy_info = port_info->phy_info;
494 for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) { 480 for (i = 0 ; i < port_info->num_phys ; i++, phy_info++) {
495 sas_address = phy_info->attached.sas_address; 481 sas_address = phy_info->attached.sas_address;
496 dsaswideprintk((KERN_DEBUG "phy_id=%d sas_address=0x%018llX\n", 482 dsaswideprintk(ioc, printk(KERN_DEBUG "phy_id=%d sas_address=0x%018llX\n",
497 i, (unsigned long long)sas_address)); 483 i, (unsigned long long)sas_address));
498 if (!sas_address) 484 if (!sas_address)
499 continue; 485 continue;
@@ -512,7 +498,7 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
512 port_details->phy_bitmask |= 498 port_details->phy_bitmask |=
513 (1 << phy_info->phy_id); 499 (1 << phy_info->phy_id);
514 phy_info->sas_port_add_phy=1; 500 phy_info->sas_port_add_phy=1;
515 dsaswideprintk((KERN_DEBUG "\t\tForming port\n\t\t" 501 dsaswideprintk(ioc, printk(KERN_DEBUG "\t\tForming port\n\t\t"
516 "phy_id=%d sas_address=0x%018llX\n", 502 "phy_id=%d sas_address=0x%018llX\n",
517 i, (unsigned long long)sas_address)); 503 i, (unsigned long long)sas_address));
518 phy_info->port_details = port_details; 504 phy_info->port_details = port_details;
@@ -529,7 +515,7 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
529 continue; 515 continue;
530 if (phy_info_cmp->port_details == port_details ) 516 if (phy_info_cmp->port_details == port_details )
531 continue; 517 continue;
532 dsaswideprintk((KERN_DEBUG 518 dsaswideprintk(ioc, printk(KERN_DEBUG
533 "\t\tphy_id=%d sas_address=0x%018llX\n", 519 "\t\tphy_id=%d sas_address=0x%018llX\n",
534 j, (unsigned long long) 520 j, (unsigned long long)
535 phy_info_cmp->attached.sas_address)); 521 phy_info_cmp->attached.sas_address));
@@ -559,21 +545,19 @@ mptsas_setup_wide_ports(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
559 545
560 out: 546 out:
561 547
562#ifdef MPT_DEBUG_SAS_WIDE
563 for (i = 0; i < port_info->num_phys; i++) { 548 for (i = 0; i < port_info->num_phys; i++) {
564 port_details = port_info->phy_info[i].port_details; 549 port_details = port_info->phy_info[i].port_details;
565 if (!port_details) 550 if (!port_details)
566 continue; 551 continue;
567 dsaswideprintk((KERN_DEBUG 552 dsaswideprintk(ioc, printk(KERN_DEBUG
568 "%s: [%p]: phy_id=%02d num_phys=%02d " 553 "%s: [%p]: phy_id=%02d num_phys=%02d "
569 "bitmask=0x%016llX\n", __FUNCTION__, 554 "bitmask=0x%016llX\n", __FUNCTION__,
570 port_details, i, port_details->num_phys, 555 port_details, i, port_details->num_phys,
571 (unsigned long long)port_details->phy_bitmask)); 556 (unsigned long long)port_details->phy_bitmask));
572 dsaswideprintk((KERN_DEBUG"\t\tport = %p rphy=%p\n", 557 dsaswideprintk(ioc, printk(KERN_DEBUG"\t\tport = %p rphy=%p\n",
573 port_details->port, port_details->rphy)); 558 port_details->port, port_details->rphy));
574 } 559 }
575 dsaswideprintk((KERN_DEBUG"\n")); 560 dsaswideprintk(ioc, printk(KERN_DEBUG"\n"));
576#endif
577 mutex_unlock(&ioc->sas_topology_mutex); 561 mutex_unlock(&ioc->sas_topology_mutex);
578} 562}
579 563
@@ -622,7 +606,7 @@ mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id)
622 SCSITaskMgmt_t *pScsiTm; 606 SCSITaskMgmt_t *pScsiTm;
623 607
624 if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) { 608 if ((mf = mpt_get_msg_frame(ioc->TaskCtx, ioc)) == NULL) {
625 dfailprintk((MYIOC_s_WARN_FMT "%s, no msg frames @%d!!\n", 609 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, no msg frames @%d!!\n",
626 ioc->name,__FUNCTION__, __LINE__)); 610 ioc->name,__FUNCTION__, __LINE__));
627 return 0; 611 return 0;
628 } 612 }
@@ -637,12 +621,12 @@ mptsas_target_reset(MPT_ADAPTER *ioc, u8 channel, u8 id)
637 pScsiTm->TaskType = MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET; 621 pScsiTm->TaskType = MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET;
638 pScsiTm->MsgFlags = MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION; 622 pScsiTm->MsgFlags = MPI_SCSITASKMGMT_MSGFLAGS_LIPRESET_RESET_OPTION;
639 623
640 DBG_DUMP_TM_REQUEST_FRAME(mf); 624 DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)mf);
641 625
642 if (mpt_send_handshake_request(ioc->TaskCtx, ioc, 626 if (mpt_send_handshake_request(ioc->TaskCtx, ioc,
643 sizeof(SCSITaskMgmt_t), (u32 *)mf, NO_SLEEP)) { 627 sizeof(SCSITaskMgmt_t), (u32 *)mf, NO_SLEEP)) {
644 mpt_free_msg_frame(ioc, mf); 628 mpt_free_msg_frame(ioc, mf);
645 dfailprintk((MYIOC_s_WARN_FMT "%s, tm handshake failed @%d!!\n", 629 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, tm handshake failed @%d!!\n",
646 ioc->name,__FUNCTION__, __LINE__)); 630 ioc->name,__FUNCTION__, __LINE__));
647 return 0; 631 return 0;
648 } 632 }
@@ -681,7 +665,7 @@ mptsas_target_reset_queue(MPT_ADAPTER *ioc,
681 target_reset_list = kzalloc(sizeof(*target_reset_list), 665 target_reset_list = kzalloc(sizeof(*target_reset_list),
682 GFP_ATOMIC); 666 GFP_ATOMIC);
683 if (!target_reset_list) { 667 if (!target_reset_list) {
684 dfailprintk((MYIOC_s_WARN_FMT "%s, failed to allocate mem @%d..!!\n", 668 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, failed to allocate mem @%d..!!\n",
685 ioc->name,__FUNCTION__, __LINE__)); 669 ioc->name,__FUNCTION__, __LINE__));
686 return; 670 return;
687 } 671 }
@@ -748,7 +732,7 @@ mptsas_dev_reset_complete(MPT_ADAPTER *ioc)
748 732
749 ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 733 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
750 if (!ev) { 734 if (!ev) {
751 dfailprintk((MYIOC_s_WARN_FMT "%s, failed to allocate mem @%d..!!\n", 735 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s, failed to allocate mem @%d..!!\n",
752 ioc->name,__FUNCTION__, __LINE__)); 736 ioc->name,__FUNCTION__, __LINE__));
753 return; 737 return;
754 } 738 }
@@ -1168,7 +1152,7 @@ static int mptsas_get_linkerrors(struct sas_phy *phy)
1168 if (error) 1152 if (error)
1169 goto out_free_consistent; 1153 goto out_free_consistent;
1170 1154
1171 mptsas_print_phy_pg1(buffer); 1155 mptsas_print_phy_pg1(ioc, buffer);
1172 1156
1173 phy->invalid_dword_count = le32_to_cpu(buffer->InvalidDwordCount); 1157 phy->invalid_dword_count = le32_to_cpu(buffer->InvalidDwordCount);
1174 phy->running_disparity_error_count = 1158 phy->running_disparity_error_count =
@@ -1397,7 +1381,7 @@ mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
1397 le16_to_cpu(buffer->NvdataVersionDefault); 1381 le16_to_cpu(buffer->NvdataVersionDefault);
1398 1382
1399 for (i = 0; i < port_info->num_phys; i++) { 1383 for (i = 0; i < port_info->num_phys; i++) {
1400 mptsas_print_phy_data(&buffer->PhyData[i]); 1384 mptsas_print_phy_data(ioc, &buffer->PhyData[i]);
1401 port_info->phy_info[i].phy_id = i; 1385 port_info->phy_info[i].phy_id = i;
1402 port_info->phy_info[i].port_id = 1386 port_info->phy_info[i].port_id =
1403 buffer->PhyData[i].Port; 1387 buffer->PhyData[i].Port;
@@ -1522,7 +1506,7 @@ mptsas_sas_phy_pg0(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
1522 if (error) 1506 if (error)
1523 goto out_free_consistent; 1507 goto out_free_consistent;
1524 1508
1525 mptsas_print_phy_pg0(buffer); 1509 mptsas_print_phy_pg0(ioc, buffer);
1526 1510
1527 phy_info->hw_link_rate = buffer->HwLinkRate; 1511 phy_info->hw_link_rate = buffer->HwLinkRate;
1528 phy_info->programmed_link_rate = buffer->ProgrammedLinkRate; 1512 phy_info->programmed_link_rate = buffer->ProgrammedLinkRate;
@@ -1589,7 +1573,7 @@ mptsas_sas_device_pg0(MPT_ADAPTER *ioc, struct mptsas_devinfo *device_info,
1589 if (error) 1573 if (error)
1590 goto out_free_consistent; 1574 goto out_free_consistent;
1591 1575
1592 mptsas_print_device_pg0(buffer); 1576 mptsas_print_device_pg0(ioc, buffer);
1593 1577
1594 device_info->handle = le16_to_cpu(buffer->DevHandle); 1578 device_info->handle = le16_to_cpu(buffer->DevHandle);
1595 device_info->handle_parent = le16_to_cpu(buffer->ParentDevHandle); 1579 device_info->handle_parent = le16_to_cpu(buffer->ParentDevHandle);
@@ -1737,7 +1721,7 @@ mptsas_sas_expander_pg1(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
1737 goto out_free_consistent; 1721 goto out_free_consistent;
1738 1722
1739 1723
1740 mptsas_print_expander_pg1(buffer); 1724 mptsas_print_expander_pg1(ioc, buffer);
1741 1725
1742 /* save config data */ 1726 /* save config data */
1743 phy_info->phy_id = buffer->PhyIdentifier; 1727 phy_info->phy_id = buffer->PhyIdentifier;
@@ -1946,17 +1930,17 @@ static int mptsas_probe_one_phy(struct device *dev,
1946 } 1930 }
1947 error = sas_port_add(port); 1931 error = sas_port_add(port);
1948 if (error) { 1932 if (error) {
1949 dfailprintk((MYIOC_s_ERR_FMT 1933 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
1950 "%s: exit at line=%d\n", ioc->name, 1934 "%s: exit at line=%d\n", ioc->name,
1951 __FUNCTION__, __LINE__)); 1935 __FUNCTION__, __LINE__));
1952 goto out; 1936 goto out;
1953 } 1937 }
1954 mptsas_set_port(phy_info, port); 1938 mptsas_set_port(ioc, phy_info, port);
1955 dsaswideprintk((KERN_DEBUG 1939 dsaswideprintk(ioc, printk(KERN_DEBUG
1956 "sas_port_alloc: port=%p dev=%p port_id=%d\n", 1940 "sas_port_alloc: port=%p dev=%p port_id=%d\n",
1957 port, dev, port->port_identifier)); 1941 port, dev, port->port_identifier));
1958 } 1942 }
1959 dsaswideprintk((KERN_DEBUG "sas_port_add_phy: phy_id=%d\n", 1943 dsaswideprintk(ioc, printk(KERN_DEBUG "sas_port_add_phy: phy_id=%d\n",
1960 phy_info->phy_id)); 1944 phy_info->phy_id));
1961 sas_port_add_phy(port, phy_info->phy); 1945 sas_port_add_phy(port, phy_info->phy);
1962 phy_info->sas_port_add_phy = 0; 1946 phy_info->sas_port_add_phy = 0;
@@ -2017,7 +2001,7 @@ static int mptsas_probe_one_phy(struct device *dev,
2017 break; 2001 break;
2018 } 2002 }
2019 if (!rphy) { 2003 if (!rphy) {
2020 dfailprintk((MYIOC_s_ERR_FMT 2004 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2021 "%s: exit at line=%d\n", ioc->name, 2005 "%s: exit at line=%d\n", ioc->name,
2022 __FUNCTION__, __LINE__)); 2006 __FUNCTION__, __LINE__));
2023 goto out; 2007 goto out;
@@ -2026,13 +2010,13 @@ static int mptsas_probe_one_phy(struct device *dev,
2026 rphy->identify = identify; 2010 rphy->identify = identify;
2027 error = sas_rphy_add(rphy); 2011 error = sas_rphy_add(rphy);
2028 if (error) { 2012 if (error) {
2029 dfailprintk((MYIOC_s_ERR_FMT 2013 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2030 "%s: exit at line=%d\n", ioc->name, 2014 "%s: exit at line=%d\n", ioc->name,
2031 __FUNCTION__, __LINE__)); 2015 __FUNCTION__, __LINE__));
2032 sas_rphy_free(rphy); 2016 sas_rphy_free(rphy);
2033 goto out; 2017 goto out;
2034 } 2018 }
2035 mptsas_set_rphy(phy_info, rphy); 2019 mptsas_set_rphy(ioc, phy_info, rphy);
2036 } 2020 }
2037 2021
2038 out: 2022 out:
@@ -2258,18 +2242,17 @@ mptsas_delete_expander_phys(MPT_ADAPTER *ioc)
2258 if (phy_info->attached.sas_address != 2242 if (phy_info->attached.sas_address !=
2259 expander_sas_address) 2243 expander_sas_address)
2260 continue; 2244 continue;
2261#ifdef MPT_DEBUG_SAS_WIDE 2245 dsaswideprintk(ioc,
2262 dev_printk(KERN_DEBUG, &port->dev, 2246 dev_printk(KERN_DEBUG, &port->dev,
2263 "delete port (%d)\n", port->port_identifier); 2247 "delete port (%d)\n", port->port_identifier));
2264#endif
2265 sas_port_delete(port); 2248 sas_port_delete(port);
2266 mptsas_port_delete(phy_info->port_details); 2249 mptsas_port_delete(ioc, phy_info->port_details);
2267 } 2250 }
2268 next_port: 2251 next_port:
2269 2252
2270 phy_info = port_info->phy_info; 2253 phy_info = port_info->phy_info;
2271 for (i = 0; i < port_info->num_phys; i++, phy_info++) 2254 for (i = 0; i < port_info->num_phys; i++, phy_info++)
2272 mptsas_port_delete(phy_info->port_details); 2255 mptsas_port_delete(ioc, phy_info->port_details);
2273 2256
2274 list_del(&port_info->list); 2257 list_del(&port_info->list);
2275 kfree(port_info->phy_info); 2258 kfree(port_info->phy_info);
@@ -2555,7 +2538,7 @@ mptsas_hotplug_work(struct work_struct *work)
2555 (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID << 2538 (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
2556 MPI_SAS_DEVICE_PGAD_FORM_SHIFT), 2539 MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
2557 (ev->channel << 8) + ev->id)) { 2540 (ev->channel << 8) + ev->id)) {
2558 dfailprintk((MYIOC_s_ERR_FMT 2541 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2559 "%s: exit at line=%d\n", ioc->name, 2542 "%s: exit at line=%d\n", ioc->name,
2560 __FUNCTION__, __LINE__)); 2543 __FUNCTION__, __LINE__));
2561 break; 2544 break;
@@ -2575,20 +2558,20 @@ mptsas_hotplug_work(struct work_struct *work)
2575 * Sanity checks, for non-existing phys and remote rphys. 2558 * Sanity checks, for non-existing phys and remote rphys.
2576 */ 2559 */
2577 if (!phy_info){ 2560 if (!phy_info){
2578 dfailprintk((MYIOC_s_ERR_FMT 2561 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2579 "%s: exit at line=%d\n", ioc->name, 2562 "%s: exit at line=%d\n", ioc->name,
2580 __FUNCTION__, __LINE__)); 2563 __FUNCTION__, __LINE__));
2581 break; 2564 break;
2582 } 2565 }
2583 if (!phy_info->port_details) { 2566 if (!phy_info->port_details) {
2584 dfailprintk((MYIOC_s_ERR_FMT 2567 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2585 "%s: exit at line=%d\n", ioc->name, 2568 "%s: exit at line=%d\n", ioc->name,
2586 __FUNCTION__, __LINE__)); 2569 __FUNCTION__, __LINE__));
2587 break; 2570 break;
2588 } 2571 }
2589 rphy = mptsas_get_rphy(phy_info); 2572 rphy = mptsas_get_rphy(phy_info);
2590 if (!rphy) { 2573 if (!rphy) {
2591 dfailprintk((MYIOC_s_ERR_FMT 2574 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2592 "%s: exit at line=%d\n", ioc->name, 2575 "%s: exit at line=%d\n", ioc->name,
2593 __FUNCTION__, __LINE__)); 2576 __FUNCTION__, __LINE__));
2594 break; 2577 break;
@@ -2596,7 +2579,7 @@ mptsas_hotplug_work(struct work_struct *work)
2596 2579
2597 port = mptsas_get_port(phy_info); 2580 port = mptsas_get_port(phy_info);
2598 if (!port) { 2581 if (!port) {
2599 dfailprintk((MYIOC_s_ERR_FMT 2582 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2600 "%s: exit at line=%d\n", ioc->name, 2583 "%s: exit at line=%d\n", ioc->name,
2601 __FUNCTION__, __LINE__)); 2584 __FUNCTION__, __LINE__));
2602 break; 2585 break;
@@ -2607,7 +2590,7 @@ mptsas_hotplug_work(struct work_struct *work)
2607 vtarget = starget->hostdata; 2590 vtarget = starget->hostdata;
2608 2591
2609 if (!vtarget) { 2592 if (!vtarget) {
2610 dfailprintk((MYIOC_s_ERR_FMT 2593 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2611 "%s: exit at line=%d\n", ioc->name, 2594 "%s: exit at line=%d\n", ioc->name,
2612 __FUNCTION__, __LINE__)); 2595 __FUNCTION__, __LINE__));
2613 break; 2596 break;
@@ -2645,12 +2628,10 @@ mptsas_hotplug_work(struct work_struct *work)
2645 printk(MYIOC_s_INFO_FMT 2628 printk(MYIOC_s_INFO_FMT
2646 "removing %s device, channel %d, id %d, phy %d\n", 2629 "removing %s device, channel %d, id %d, phy %d\n",
2647 ioc->name, ds, ev->channel, ev->id, phy_info->phy_id); 2630 ioc->name, ds, ev->channel, ev->id, phy_info->phy_id);
2648#ifdef MPT_DEBUG_SAS_WIDE
2649 dev_printk(KERN_DEBUG, &port->dev, 2631 dev_printk(KERN_DEBUG, &port->dev,
2650 "delete port (%d)\n", port->port_identifier); 2632 "delete port (%d)\n", port->port_identifier);
2651#endif
2652 sas_port_delete(port); 2633 sas_port_delete(port);
2653 mptsas_port_delete(phy_info->port_details); 2634 mptsas_port_delete(ioc, phy_info->port_details);
2654 break; 2635 break;
2655 case MPTSAS_ADD_DEVICE: 2636 case MPTSAS_ADD_DEVICE:
2656 2637
@@ -2664,7 +2645,7 @@ mptsas_hotplug_work(struct work_struct *work)
2664 (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID << 2645 (MPI_SAS_DEVICE_PGAD_FORM_BUS_TARGET_ID <<
2665 MPI_SAS_DEVICE_PGAD_FORM_SHIFT), 2646 MPI_SAS_DEVICE_PGAD_FORM_SHIFT),
2666 (ev->channel << 8) + ev->id)) { 2647 (ev->channel << 8) + ev->id)) {
2667 dfailprintk((MYIOC_s_ERR_FMT 2648 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2668 "%s: exit at line=%d\n", ioc->name, 2649 "%s: exit at line=%d\n", ioc->name,
2669 __FUNCTION__, __LINE__)); 2650 __FUNCTION__, __LINE__));
2670 break; 2651 break;
@@ -2676,7 +2657,7 @@ mptsas_hotplug_work(struct work_struct *work)
2676 sas_device.sas_address); 2657 sas_device.sas_address);
2677 2658
2678 if (!phy_info || !phy_info->port_details) { 2659 if (!phy_info || !phy_info->port_details) {
2679 dfailprintk((MYIOC_s_ERR_FMT 2660 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2680 "%s: exit at line=%d\n", ioc->name, 2661 "%s: exit at line=%d\n", ioc->name,
2681 __FUNCTION__, __LINE__)); 2662 __FUNCTION__, __LINE__));
2682 break; 2663 break;
@@ -2688,7 +2669,7 @@ mptsas_hotplug_work(struct work_struct *work)
2688 vtarget = starget->hostdata; 2669 vtarget = starget->hostdata;
2689 2670
2690 if (!vtarget) { 2671 if (!vtarget) {
2691 dfailprintk((MYIOC_s_ERR_FMT 2672 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2692 "%s: exit at line=%d\n", ioc->name, 2673 "%s: exit at line=%d\n", ioc->name,
2693 __FUNCTION__, __LINE__)); 2674 __FUNCTION__, __LINE__));
2694 break; 2675 break;
@@ -2711,7 +2692,7 @@ mptsas_hotplug_work(struct work_struct *work)
2711 } 2692 }
2712 2693
2713 if (mptsas_get_rphy(phy_info)) { 2694 if (mptsas_get_rphy(phy_info)) {
2714 dfailprintk((MYIOC_s_ERR_FMT 2695 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2715 "%s: exit at line=%d\n", ioc->name, 2696 "%s: exit at line=%d\n", ioc->name,
2716 __FUNCTION__, __LINE__)); 2697 __FUNCTION__, __LINE__));
2717 if (ev->channel) printk("%d\n", __LINE__); 2698 if (ev->channel) printk("%d\n", __LINE__);
@@ -2720,7 +2701,7 @@ mptsas_hotplug_work(struct work_struct *work)
2720 2701
2721 port = mptsas_get_port(phy_info); 2702 port = mptsas_get_port(phy_info);
2722 if (!port) { 2703 if (!port) {
2723 dfailprintk((MYIOC_s_ERR_FMT 2704 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2724 "%s: exit at line=%d\n", ioc->name, 2705 "%s: exit at line=%d\n", ioc->name,
2725 __FUNCTION__, __LINE__)); 2706 __FUNCTION__, __LINE__));
2726 break; 2707 break;
@@ -2745,7 +2726,7 @@ mptsas_hotplug_work(struct work_struct *work)
2745 mptsas_parse_device_info(&identify, &phy_info->attached); 2726 mptsas_parse_device_info(&identify, &phy_info->attached);
2746 rphy = sas_end_device_alloc(port); 2727 rphy = sas_end_device_alloc(port);
2747 if (!rphy) { 2728 if (!rphy) {
2748 dfailprintk((MYIOC_s_ERR_FMT 2729 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2749 "%s: exit at line=%d\n", ioc->name, 2730 "%s: exit at line=%d\n", ioc->name,
2750 __FUNCTION__, __LINE__)); 2731 __FUNCTION__, __LINE__));
2751 break; /* non-fatal: an rphy can be added later */ 2732 break; /* non-fatal: an rphy can be added later */
@@ -2753,13 +2734,13 @@ mptsas_hotplug_work(struct work_struct *work)
2753 2734
2754 rphy->identify = identify; 2735 rphy->identify = identify;
2755 if (sas_rphy_add(rphy)) { 2736 if (sas_rphy_add(rphy)) {
2756 dfailprintk((MYIOC_s_ERR_FMT 2737 dfailprintk(ioc, printk(MYIOC_s_ERR_FMT
2757 "%s: exit at line=%d\n", ioc->name, 2738 "%s: exit at line=%d\n", ioc->name,
2758 __FUNCTION__, __LINE__)); 2739 __FUNCTION__, __LINE__));
2759 sas_rphy_free(rphy); 2740 sas_rphy_free(rphy);
2760 break; 2741 break;
2761 } 2742 }
2762 mptsas_set_rphy(phy_info, rphy); 2743 mptsas_set_rphy(ioc, phy_info, rphy);
2763 break; 2744 break;
2764 case MPTSAS_ADD_RAID: 2745 case MPTSAS_ADD_RAID:
2765 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL, 2746 sdev = scsi_device_lookup(ioc->sh, MPTSAS_RAID_CHANNEL,
@@ -3175,7 +3156,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
3175 3156
3176 if (numSGE < sh->sg_tablesize) { 3157 if (numSGE < sh->sg_tablesize) {
3177 /* Reset this value */ 3158 /* Reset this value */
3178 dprintk((MYIOC_s_INFO_FMT 3159 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT
3179 "Resetting sg_tablesize to %d from %d\n", 3160 "Resetting sg_tablesize to %d from %d\n",
3180 ioc->name, numSGE, sh->sg_tablesize)); 3161 ioc->name, numSGE, sh->sg_tablesize));
3181 sh->sg_tablesize = numSGE; 3162 sh->sg_tablesize = numSGE;
@@ -3193,7 +3174,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
3193 goto out_mptsas_probe; 3174 goto out_mptsas_probe;
3194 } 3175 }
3195 3176
3196 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n", 3177 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n",
3197 ioc->name, hd->ScsiLookup)); 3178 ioc->name, hd->ScsiLookup));
3198 3179
3199 /* Clear the TM flags 3180 /* Clear the TM flags
@@ -3233,7 +3214,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
3233 3214
3234 error = scsi_add_host(sh, &ioc->pcidev->dev); 3215 error = scsi_add_host(sh, &ioc->pcidev->dev);
3235 if (error) { 3216 if (error) {
3236 dprintk((KERN_ERR MYNAM 3217 dprintk(ioc, printk(KERN_ERR MYNAM
3237 "scsi_add_host failed\n")); 3218 "scsi_add_host failed\n"));
3238 goto out_mptsas_probe; 3219 goto out_mptsas_probe;
3239 } 3220 }
@@ -3261,7 +3242,7 @@ static void __devexit mptsas_remove(struct pci_dev *pdev)
3261 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) { 3242 list_for_each_entry_safe(p, n, &ioc->sas_topology, list) {
3262 list_del(&p->list); 3243 list_del(&p->list);
3263 for (i = 0 ; i < p->num_phys ; i++) 3244 for (i = 0 ; i < p->num_phys ; i++)
3264 mptsas_port_delete(p->phy_info[i].port_details); 3245 mptsas_port_delete(ioc, p->phy_info[i].port_details);
3265 kfree(p->phy_info); 3246 kfree(p->phy_info);
3266 kfree(p); 3247 kfree(p);
3267 } 3248 }
@@ -3316,15 +3297,8 @@ mptsas_init(void)
3316 mpt_register(mptscsih_scandv_complete, MPTSAS_DRIVER); 3297 mpt_register(mptscsih_scandv_complete, MPTSAS_DRIVER);
3317 mptsasMgmtCtx = mpt_register(mptsas_mgmt_done, MPTSAS_DRIVER); 3298 mptsasMgmtCtx = mpt_register(mptsas_mgmt_done, MPTSAS_DRIVER);
3318 3299
3319 if (mpt_event_register(mptsasDoneCtx, mptsas_event_process) == 0) { 3300 mpt_event_register(mptsasDoneCtx, mptsas_event_process);
3320 devtverboseprintk((KERN_INFO MYNAM 3301 mpt_reset_register(mptsasDoneCtx, mptsas_ioc_reset);
3321 ": Registered for IOC event notifications\n"));
3322 }
3323
3324 if (mpt_reset_register(mptsasDoneCtx, mptsas_ioc_reset) == 0) {
3325 dprintk((KERN_INFO MYNAM
3326 ": Registered for IOC reset notifications\n"));
3327 }
3328 3302
3329 error = pci_register_driver(&mptsas_driver); 3303 error = pci_register_driver(&mptsas_driver);
3330 if (error) 3304 if (error)
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index fd3aa2619f42..5431529741ad 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -191,7 +191,7 @@ mptscsih_getFreeChainBuffer(MPT_ADAPTER *ioc, int *retIndex)
191 int rc; 191 int rc;
192 int chain_idx; 192 int chain_idx;
193 193
194 dsgprintk((MYIOC_s_INFO_FMT "getFreeChainBuffer called\n", 194 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer called\n",
195 ioc->name)); 195 ioc->name));
196 spin_lock_irqsave(&ioc->FreeQlock, flags); 196 spin_lock_irqsave(&ioc->FreeQlock, flags);
197 if (!list_empty(&ioc->FreeChainQ)) { 197 if (!list_empty(&ioc->FreeChainQ)) {
@@ -203,12 +203,12 @@ mptscsih_getFreeChainBuffer(MPT_ADAPTER *ioc, int *retIndex)
203 offset = (u8 *)chainBuf - (u8 *)ioc->ChainBuffer; 203 offset = (u8 *)chainBuf - (u8 *)ioc->ChainBuffer;
204 chain_idx = offset / ioc->req_sz; 204 chain_idx = offset / ioc->req_sz;
205 rc = SUCCESS; 205 rc = SUCCESS;
206 dsgprintk((MYIOC_s_ERR_FMT "getFreeChainBuffer chainBuf=%p ChainBuffer=%p offset=%d chain_idx=%d\n", 206 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer chainBuf=%p ChainBuffer=%p offset=%d chain_idx=%d\n",
207 ioc->name, chainBuf, ioc->ChainBuffer, offset, chain_idx)); 207 ioc->name, chainBuf, ioc->ChainBuffer, offset, chain_idx));
208 } else { 208 } else {
209 rc = FAILED; 209 rc = FAILED;
210 chain_idx = MPT_HOST_NO_CHAIN; 210 chain_idx = MPT_HOST_NO_CHAIN;
211 dfailprintk((MYIOC_s_INFO_FMT "getFreeChainBuffer failed\n", 211 dfailprintk(ioc, printk(MYIOC_s_DEBUG_FMT "getFreeChainBuffer failed\n",
212 ioc->name)); 212 ioc->name));
213 } 213 }
214 spin_unlock_irqrestore(&ioc->FreeQlock, flags); 214 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
@@ -337,7 +337,7 @@ nextSGEset:
337 */ 337 */
338 pReq->ChainOffset = 0; 338 pReq->ChainOffset = 0;
339 RequestNB = (((sgeOffset - 1) >> ioc->NBShiftFactor) + 1) & 0x03; 339 RequestNB = (((sgeOffset - 1) >> ioc->NBShiftFactor) + 1) & 0x03;
340 dsgprintk((MYIOC_s_INFO_FMT 340 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT
341 "Single Buffer RequestNB=%x, sgeOffset=%d\n", ioc->name, RequestNB, sgeOffset)); 341 "Single Buffer RequestNB=%x, sgeOffset=%d\n", ioc->name, RequestNB, sgeOffset));
342 ioc->RequestNB[req_idx] = RequestNB; 342 ioc->RequestNB[req_idx] = RequestNB;
343 } 343 }
@@ -353,7 +353,7 @@ nextSGEset:
353 * Loop until done. 353 * Loop until done.
354 */ 354 */
355 355
356 dsgprintk((MYIOC_s_INFO_FMT "SG: Chain Required! sg done %d\n", 356 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "SG: Chain Required! sg done %d\n",
357 ioc->name, sg_done)); 357 ioc->name, sg_done));
358 358
359 /* Set LAST_ELEMENT flag for last non-chain element 359 /* Set LAST_ELEMENT flag for last non-chain element
@@ -386,7 +386,7 @@ nextSGEset:
386 */ 386 */
387 pReq->ChainOffset = (u8) (sgeOffset >> 2); 387 pReq->ChainOffset = (u8) (sgeOffset >> 2);
388 RequestNB = (((sgeOffset - 1) >> ioc->NBShiftFactor) + 1) & 0x03; 388 RequestNB = (((sgeOffset - 1) >> ioc->NBShiftFactor) + 1) & 0x03;
389 dsgprintk((MYIOC_s_ERR_FMT "Chain Buffer Needed, RequestNB=%x sgeOffset=%d\n", ioc->name, RequestNB, sgeOffset)); 389 dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Chain Buffer Needed, RequestNB=%x sgeOffset=%d\n", ioc->name, RequestNB, sgeOffset));
390 ioc->RequestNB[req_idx] = RequestNB; 390 ioc->RequestNB[req_idx] = RequestNB;
391 } 391 }
392 392
@@ -397,7 +397,7 @@ nextSGEset:
397 * in current buffer. Get a chain buffer. 397 * in current buffer. Get a chain buffer.
398 */ 398 */
399 if ((mptscsih_getFreeChainBuffer(ioc, &newIndex)) == FAILED) { 399 if ((mptscsih_getFreeChainBuffer(ioc, &newIndex)) == FAILED) {
400 dfailprintk((MYIOC_s_INFO_FMT 400 dfailprintk(ioc, printk(MYIOC_s_DEBUG_FMT
401 "getFreeChainBuffer FAILED SCSI cmd=%02x (%p)\n", 401 "getFreeChainBuffer FAILED SCSI cmd=%02x (%p)\n",
402 ioc->name, pReq->CDB[0], SCpnt)); 402 ioc->name, pReq->CDB[0], SCpnt));
403 return FAILED; 403 return FAILED;
@@ -419,7 +419,7 @@ nextSGEset:
419 * out the Address and Flags fields. 419 * out the Address and Flags fields.
420 */ 420 */
421 chainSge = (char *) psge; 421 chainSge = (char *) psge;
422 dsgprintk((KERN_INFO " Current buff @ %p (index 0x%x)", 422 dsgprintk(ioc, printk(KERN_DEBUG " Current buff @ %p (index 0x%x)",
423 psge, req_idx)); 423 psge, req_idx));
424 424
425 /* Start the SGE for the next buffer 425 /* Start the SGE for the next buffer
@@ -428,7 +428,7 @@ nextSGEset:
428 sgeOffset = 0; 428 sgeOffset = 0;
429 sg_done = 0; 429 sg_done = 0;
430 430
431 dsgprintk((KERN_INFO " Chain buff @ %p (index 0x%x)\n", 431 dsgprintk(ioc, printk(KERN_DEBUG " Chain buff @ %p (index 0x%x)\n",
432 psge, chain_idx)); 432 psge, chain_idx));
433 433
434 /* Start the SGE for the next buffer 434 /* Start the SGE for the next buffer
@@ -456,7 +456,7 @@ mptscsih_issue_sep_command(MPT_ADAPTER *ioc, VirtTarget *vtarget,
456 return; 456 return;
457 457
458 if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) { 458 if ((mf = mpt_get_msg_frame(ioc->InternalCtx, ioc)) == NULL) {
459 dfailprintk((MYIOC_s_WARN_FMT "%s: no msg frames!!\n", 459 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT "%s: no msg frames!!\n",
460 ioc->name,__FUNCTION__)); 460 ioc->name,__FUNCTION__));
461 return; 461 return;
462 } 462 }
@@ -467,93 +467,158 @@ mptscsih_issue_sep_command(MPT_ADAPTER *ioc, VirtTarget *vtarget,
467 SEPMsg->TargetID = vtarget->id; 467 SEPMsg->TargetID = vtarget->id;
468 SEPMsg->Action = MPI_SEP_REQ_ACTION_WRITE_STATUS; 468 SEPMsg->Action = MPI_SEP_REQ_ACTION_WRITE_STATUS;
469 SEPMsg->SlotStatus = SlotStatus; 469 SEPMsg->SlotStatus = SlotStatus;
470 devtverboseprintk((MYIOC_s_WARN_FMT 470 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT
471 "Sending SEP cmd=%x channel=%d id=%d\n", 471 "Sending SEP cmd=%x channel=%d id=%d\n",
472 ioc->name, SlotStatus, SEPMsg->Bus, SEPMsg->TargetID)); 472 ioc->name, SlotStatus, SEPMsg->Bus, SEPMsg->TargetID));
473 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf); 473 mpt_put_msg_frame(ioc->DoneCtx, ioc, mf);
474} 474}
475 475
476#ifdef MPT_DEBUG_REPLY 476#ifdef CONFIG_FUSION_LOGGING
477/** 477/**
478 * mptscsih_iocstatus_info_scsiio - IOCSTATUS information for SCSIIO 478 * mptscsih_info_scsiio - debug print info on reply frame
479 * @ioc: Pointer to MPT_ADAPTER structure 479 * @ioc: Pointer to MPT_ADAPTER structure
480 * @ioc_status: U32 IOCStatus word from IOC
481 * @scsi_status: U8 sam status from target
482 * @scsi_state: U8 scsi state
483 * @sc: original scsi cmnd pointer 480 * @sc: original scsi cmnd pointer
484 * @mf: Pointer to MPT request frame 481 * @pScsiReply: Pointer to MPT reply frame
482 *
483 * MPT_DEBUG_REPLY needs to be enabled to obtain this info
485 * 484 *
486 * Refer to lsi/mpi.h. 485 * Refer to lsi/mpi.h.
487 **/ 486 **/
488static void 487static void
489mptscsih_iocstatus_info_scsiio(MPT_ADAPTER *ioc, u32 ioc_status, 488mptscsih_info_scsiio(MPT_ADAPTER *ioc, struct scsi_cmnd *sc, SCSIIOReply_t * pScsiReply)
490 u8 scsi_status, u8 scsi_state, struct scsi_cmnd *sc)
491{ 489{
492 char extend_desc[EVENT_DESCR_STR_SZ]; 490 char *desc = NULL;
493 char *desc = NULL; 491 char *desc1 = NULL;
492 u16 ioc_status;
493 u8 skey, asc, ascq;
494
495 ioc_status = le16_to_cpu(pScsiReply->IOCStatus) & MPI_IOCSTATUS_MASK;
494 496
495 switch (ioc_status) { 497 switch (ioc_status) {
496 498
497 case MPI_IOCSTATUS_SCSI_INVALID_BUS: /* 0x0041 */ 499 case MPI_IOCSTATUS_SUCCESS:
498 desc = "SCSI Invalid Bus"; 500 desc = "success";
499 break; 501 break;
500 502 case MPI_IOCSTATUS_SCSI_INVALID_BUS:
501 case MPI_IOCSTATUS_SCSI_INVALID_TARGETID: /* 0x0042 */ 503 desc = "invalid bus";
502 desc = "SCSI Invalid TargetID";
503 break; 504 break;
504 505 case MPI_IOCSTATUS_SCSI_INVALID_TARGETID:
505 case MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE: /* 0x0043 */ 506 desc = "invalid target_id";
506 /*
507 * Inquiry is issued for device scanning
508 */
509 if (sc->cmnd[0] != 0x12)
510 desc = "SCSI Device Not There";
511 break; 507 break;
512 508 case MPI_IOCSTATUS_SCSI_DEVICE_NOT_THERE:
513 case MPI_IOCSTATUS_SCSI_DATA_OVERRUN: /* 0x0044 */ 509 desc = "device not there";
514 desc = "SCSI Data Overrun";
515 break; 510 break;
516 511 case MPI_IOCSTATUS_SCSI_DATA_OVERRUN:
517 case MPI_IOCSTATUS_SCSI_IO_DATA_ERROR: /* 0x0046 */ 512 desc = "data overrun";
518 desc = "SCSI I/O Data Error";
519 break; 513 break;
520 514 case MPI_IOCSTATUS_SCSI_DATA_UNDERRUN:
521 case MPI_IOCSTATUS_SCSI_PROTOCOL_ERROR: /* 0x0047 */ 515 desc = "data underrun";
522 desc = "SCSI Protocol Error";
523 break; 516 break;
524 517 case MPI_IOCSTATUS_SCSI_IO_DATA_ERROR:
525 case MPI_IOCSTATUS_SCSI_TASK_TERMINATED: /* 0x0048 */ 518 desc = "I/O data error";
526 desc = "SCSI Task Terminated";
527 break; 519 break;
528 520 case MPI_IOCSTATUS_SCSI_PROTOCOL_ERROR:
529 case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */ 521 desc = "protocol error";
530 desc = "SCSI Residual Mismatch";
531 break; 522 break;
532 523 case MPI_IOCSTATUS_SCSI_TASK_TERMINATED:
533 case MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED: /* 0x004A */ 524 desc = "task terminated";
534 desc = "SCSI Task Management Failed";
535 break; 525 break;
536 526 case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH:
537 case MPI_IOCSTATUS_SCSI_IOC_TERMINATED: /* 0x004B */ 527 desc = "residual mismatch";
538 desc = "SCSI IOC Terminated"; 528 break;
529 case MPI_IOCSTATUS_SCSI_TASK_MGMT_FAILED:
530 desc = "task management failed";
531 break;
532 case MPI_IOCSTATUS_SCSI_IOC_TERMINATED:
533 desc = "IOC terminated";
534 break;
535 case MPI_IOCSTATUS_SCSI_EXT_TERMINATED:
536 desc = "ext terminated";
539 break; 537 break;
538 default:
539 desc = "";
540 break;
541 }
542
543 switch (pScsiReply->SCSIStatus)
544 {
540 545
541 case MPI_IOCSTATUS_SCSI_EXT_TERMINATED: /* 0x004C */ 546 case MPI_SCSI_STATUS_SUCCESS:
542 desc = "SCSI Ext Terminated"; 547 desc1 = "success";
548 break;
549 case MPI_SCSI_STATUS_CHECK_CONDITION:
550 desc1 = "check condition";
551 break;
552 case MPI_SCSI_STATUS_CONDITION_MET:
553 desc1 = "condition met";
554 break;
555 case MPI_SCSI_STATUS_BUSY:
556 desc1 = "busy";
557 break;
558 case MPI_SCSI_STATUS_INTERMEDIATE:
559 desc1 = "intermediate";
560 break;
561 case MPI_SCSI_STATUS_INTERMEDIATE_CONDMET:
562 desc1 = "intermediate condmet";
563 break;
564 case MPI_SCSI_STATUS_RESERVATION_CONFLICT:
565 desc1 = "reservation conflict";
566 break;
567 case MPI_SCSI_STATUS_COMMAND_TERMINATED:
568 desc1 = "command terminated";
569 break;
570 case MPI_SCSI_STATUS_TASK_SET_FULL:
571 desc1 = "task set full";
572 break;
573 case MPI_SCSI_STATUS_ACA_ACTIVE:
574 desc1 = "aca active";
575 break;
576 case MPI_SCSI_STATUS_FCPEXT_DEVICE_LOGGED_OUT:
577 desc1 = "fcpext device logged out";
578 break;
579 case MPI_SCSI_STATUS_FCPEXT_NO_LINK:
580 desc1 = "fcpext no link";
581 break;
582 case MPI_SCSI_STATUS_FCPEXT_UNASSIGNED:
583 desc1 = "fcpext unassigned";
584 break;
585 default:
586 desc1 = "";
543 break; 587 break;
544 } 588 }
545 589
546 if (!desc) 590 scsi_print_command(sc);
547 return; 591 printk(KERN_DEBUG "\tfw_channel = %d, fw_id = %d\n",
592 pScsiReply->Bus, pScsiReply->TargetID);
593 printk(KERN_DEBUG "\trequest_len = %d, underflow = %d, resid = %d\n",
594 scsi_bufflen(sc), sc->underflow, scsi_get_resid(sc));
595 printk(KERN_DEBUG "\ttag = %d, transfer_count = %d, sc->result = %08X\n",
596 le16_to_cpu(pScsiReply->TaskTag),
597 le32_to_cpu(pScsiReply->TransferCount), sc->result);
548 598
549 snprintf(extend_desc, EVENT_DESCR_STR_SZ, 599 printk(KERN_DEBUG "\tiocstatus = %s (0x%04x), "
550 "[%d:%d:%d:%d] cmd=%02Xh, sam_status=%02Xh state=%02Xh", 600 "scsi_status = %s (0x%02x), scsi_state = (0x%02x)\n",
551 sc->device->host->host_no, 601 desc, ioc_status,
552 sc->device->channel, sc->device->id, sc->device->lun, 602 desc1, pScsiReply->SCSIStatus,
553 sc->cmnd[0], scsi_status, scsi_state); 603 pScsiReply->SCSIState);
554 604
555 printk(MYIOC_s_INFO_FMT "IOCStatus(0x%04X): %s: %s\n", 605 if (pScsiReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_VALID) {
556 ioc->name, ioc_status, desc, extend_desc); 606 skey = sc->sense_buffer[2] & 0x0F;
607 asc = sc->sense_buffer[12];
608 ascq = sc->sense_buffer[13];
609
610 printk(KERN_DEBUG "\t[sense_key,asc,ascq]: "
611 "[0x%02x,0x%02x,0x%02x]\n",
612 skey, asc, ascq);
613 }
614
615 /*
616 * Look for + dump FCP ResponseInfo[]!
617 */
618 if (pScsiReply->SCSIState & MPI_SCSI_STATE_RESPONSE_INFO_VALID &&
619 pScsiReply->ResponseInfo)
620 printk(KERN_DEBUG "response_info = %08xh\n",
621 le32_to_cpu(pScsiReply->ResponseInfo));
557} 622}
558#endif 623#endif
559 624
@@ -627,11 +692,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
627 pScsiReply = (SCSIIOReply_t *) mr; 692 pScsiReply = (SCSIIOReply_t *) mr;
628 693
629 if((ioc->facts.MsgVersion >= MPI_VERSION_01_05) && pScsiReply){ 694 if((ioc->facts.MsgVersion >= MPI_VERSION_01_05) && pScsiReply){
630 dmfprintk((MYIOC_s_INFO_FMT 695 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT
631 "ScsiDone (mf=%p,mr=%p,sc=%p,idx=%d,task-tag=%d)\n", 696 "ScsiDone (mf=%p,mr=%p,sc=%p,idx=%d,task-tag=%d)\n",
632 ioc->name, mf, mr, sc, req_idx, pScsiReply->TaskTag)); 697 ioc->name, mf, mr, sc, req_idx, pScsiReply->TaskTag));
633 }else{ 698 }else{
634 dmfprintk((MYIOC_s_INFO_FMT 699 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT
635 "ScsiDone (mf=%p,mr=%p,sc=%p,idx=%d)\n", 700 "ScsiDone (mf=%p,mr=%p,sc=%p,idx=%d)\n",
636 ioc->name, mf, mr, sc, req_idx)); 701 ioc->name, mf, mr, sc, req_idx));
637 } 702 }
@@ -759,7 +824,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
759 sc->result=DID_SOFT_ERROR << 16; 824 sc->result=DID_SOFT_ERROR << 16;
760 else /* Sufficient data transfer occurred */ 825 else /* Sufficient data transfer occurred */
761 sc->result = (DID_OK << 16) | scsi_status; 826 sc->result = (DID_OK << 16) | scsi_status;
762 dreplyprintk((KERN_NOTICE 827 dreplyprintk(ioc, printk(KERN_DEBUG
763 "RESIDUAL_MISMATCH: result=%x on channel=%d id=%d\n", 828 "RESIDUAL_MISMATCH: result=%x on channel=%d id=%d\n",
764 sc->result, sc->device->channel, sc->device->id)); 829 sc->result, sc->device->channel, sc->device->id));
765 break; 830 break;
@@ -792,9 +857,11 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
792 } 857 }
793 } 858 }
794 859
795 dreplyprintk((KERN_NOTICE " sc->underflow={report ERR if < %02xh bytes xfer'd}\n", 860
861 dreplyprintk(ioc, printk(KERN_DEBUG " sc->underflow={report ERR if < %02xh bytes xfer'd}\n",
796 sc->underflow)); 862 sc->underflow));
797 dreplyprintk((KERN_NOTICE " ActBytesXferd=%02xh\n", xfer_cnt)); 863 dreplyprintk(ioc, printk(KERN_DEBUG " ActBytesXferd=%02xh\n", xfer_cnt));
864
798 /* Report Queue Full 865 /* Report Queue Full
799 */ 866 */
800 if (scsi_status == MPI_SCSI_STATUS_TASK_SET_FULL) 867 if (scsi_status == MPI_SCSI_STATUS_TASK_SET_FULL)
@@ -871,27 +938,9 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
871 938
872 } /* switch(status) */ 939 } /* switch(status) */
873 940
874#ifdef MPT_DEBUG_REPLY 941#ifdef CONFIG_FUSION_LOGGING
875 if (sc->result) { 942 if (sc->result && (ioc->debug_level & MPT_DEBUG_REPLY))
876 943 mptscsih_info_scsiio(ioc, sc, pScsiReply);
877 mptscsih_iocstatus_info_scsiio(ioc, status,
878 scsi_status, scsi_state, sc);
879
880 dreplyprintk(("%s: [%d:%d:%d:%d] cmd=0x%02x "
881 "result=0x%08x\n\tiocstatus=0x%04X "
882 "scsi_state=0x%02X scsi_status=0x%02X "
883 "loginfo=0x%08X\n", __FUNCTION__,
884 sc->device->host->host_no, sc->device->channel, sc->device->id,
885 sc->device->lun, sc->cmnd[0], sc->result, status,
886 scsi_state, scsi_status, log_info));
887
888 dreplyprintk(("%s: [%d:%d:%d:%d] resid=%d "
889 "bufflen=%d xfer_cnt=%d\n", __FUNCTION__,
890 sc->device->host->host_no,
891 sc->device->channel, sc->device->id,
892 sc->device->lun, scsi_get_resid(sc),
893 scsi_bufflen(sc), xfer_cnt));
894 }
895#endif 944#endif
896 945
897 } /* end of address reply case */ 946 } /* end of address reply case */
@@ -925,7 +974,7 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
925 int ii; 974 int ii;
926 int max = ioc->req_depth; 975 int max = ioc->req_depth;
927 976
928 dprintk((KERN_INFO MYNAM ": flush_ScsiLookup called\n")); 977 dprintk(ioc, printk(KERN_DEBUG MYNAM ": flush_ScsiLookup called\n"));
929 for (ii= 0; ii < max; ii++) { 978 for (ii= 0; ii < max; ii++) {
930 if ((SCpnt = hd->ScsiLookup[ii]) != NULL) { 979 if ((SCpnt = hd->ScsiLookup[ii]) != NULL) {
931 980
@@ -937,7 +986,7 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
937 hd->ScsiLookup[ii] = NULL; 986 hd->ScsiLookup[ii] = NULL;
938 987
939 mf = MPT_INDEX_2_MFPTR(ioc, ii); 988 mf = MPT_INDEX_2_MFPTR(ioc, ii);
940 dmfprintk(( "flush: ScsiDone (mf=%p,sc=%p)\n", 989 dmfprintk(ioc, printk(KERN_DEBUG MYNAM ": flush: ScsiDone (mf=%p,sc=%p)\n",
941 mf, SCpnt)); 990 mf, SCpnt));
942 991
943 /* Free Chain buffers */ 992 /* Free Chain buffers */
@@ -987,7 +1036,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
987 struct scsi_cmnd *sc; 1036 struct scsi_cmnd *sc;
988 struct scsi_lun lun; 1037 struct scsi_lun lun;
989 1038
990 dsprintk((KERN_INFO MYNAM ": search_running channel %d id %d lun %d max %d\n", 1039 dsprintk(hd->ioc, printk(KERN_DEBUG MYNAM ": search_running channel %d id %d lun %d max %d\n",
991 vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, max)); 1040 vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, max));
992 1041
993 for (ii=0; ii < max; ii++) { 1042 for (ii=0; ii < max; ii++) {
@@ -1020,9 +1069,9 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
1020 scsi_dma_unmap(sc); 1069 scsi_dma_unmap(sc);
1021 sc->host_scribble = NULL; 1070 sc->host_scribble = NULL;
1022 sc->result = DID_NO_CONNECT << 16; 1071 sc->result = DID_NO_CONNECT << 16;
1023 dsprintk(( "search_running: found (sc=%p, mf = %p) " 1072 sdev_printk(KERN_INFO, sc->device, "completing cmds: fw_channel %d,"
1024 "channel %d id %d, lun %d \n", sc, mf, 1073 "fw_id %d, sc=%p, mf = %p, idx=%x\n", vdevice->vtarget->channel,
1025 vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun)); 1074 vdevice->vtarget->id, sc, mf, ii);
1026 sc->scsi_done(sc); 1075 sc->scsi_done(sc);
1027 } 1076 }
1028 } 1077 }
@@ -1057,7 +1106,7 @@ mptscsih_report_queue_full(struct scsi_cmnd *sc, SCSIIOReply_t *pScsiReply, SCSI
1057 return; 1106 return;
1058 1107
1059 if (time - hd->last_queue_full > 10 * HZ) { 1108 if (time - hd->last_queue_full > 10 * HZ) {
1060 dprintk((MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n", 1109 dprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "Device (%d:%d:%d) reported QUEUE_FULL!\n",
1061 hd->ioc->name, 0, sc->device->id, sc->device->lun)); 1110 hd->ioc->name, 0, sc->device->id, sc->device->lun));
1062 hd->last_queue_full = time; 1111 hd->last_queue_full = time;
1063 } 1112 }
@@ -1098,7 +1147,7 @@ mptscsih_remove(struct pci_dev *pdev)
1098 hd->ScsiLookup = NULL; 1147 hd->ScsiLookup = NULL;
1099 } 1148 }
1100 1149
1101 dprintk((MYIOC_s_INFO_FMT 1150 dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT
1102 "Free'd ScsiLookup (%d) memory\n", 1151 "Free'd ScsiLookup (%d) memory\n",
1103 hd->ioc->name, sz1)); 1152 hd->ioc->name, sz1));
1104 1153
@@ -1317,17 +1366,19 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1317 u32 cmd_len; 1366 u32 cmd_len;
1318 int my_idx; 1367 int my_idx;
1319 int ii; 1368 int ii;
1369 MPT_ADAPTER *ioc;
1320 1370
1321 hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata; 1371 hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata;
1372 ioc = hd->ioc;
1322 lun = SCpnt->device->lun; 1373 lun = SCpnt->device->lun;
1323 SCpnt->scsi_done = done; 1374 SCpnt->scsi_done = done;
1324 1375
1325 dmfprintk((MYIOC_s_INFO_FMT "qcmd: SCpnt=%p, done()=%p\n", 1376 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "qcmd: SCpnt=%p, done()=%p\n",
1326 (hd && hd->ioc) ? hd->ioc->name : "ioc?", SCpnt, done)); 1377 ioc->name, SCpnt, done));
1327 1378
1328 if (hd->resetPending) { 1379 if (hd->resetPending) {
1329 dtmprintk((MYIOC_s_WARN_FMT "qcmd: SCpnt=%p timeout + 60HZ\n", 1380 dtmprintk(ioc, printk(MYIOC_s_WARN_FMT "qcmd: SCpnt=%p timeout + 60HZ\n",
1330 (hd && hd->ioc) ? hd->ioc->name : "ioc?", SCpnt)); 1381 ioc->name, SCpnt));
1331 return SCSI_MLQUEUE_HOST_BUSY; 1382 return SCSI_MLQUEUE_HOST_BUSY;
1332 } 1383 }
1333 1384
@@ -1335,8 +1386,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1335 * Put together a MPT SCSI request... 1386 * Put together a MPT SCSI request...
1336 */ 1387 */
1337 if ((mf = mpt_get_msg_frame(hd->ioc->DoneCtx, hd->ioc)) == NULL) { 1388 if ((mf = mpt_get_msg_frame(hd->ioc->DoneCtx, hd->ioc)) == NULL) {
1338 dprintk((MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n", 1389 dprintk(ioc, printk(MYIOC_s_WARN_FMT "QueueCmd, no msg frames!!\n",
1339 hd->ioc->name)); 1390 ioc->name));
1340 return SCSI_MLQUEUE_HOST_BUSY; 1391 return SCSI_MLQUEUE_HOST_BUSY;
1341 } 1392 }
1342 1393
@@ -1422,9 +1473,9 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1422 hd->ScsiLookup[my_idx] = SCpnt; 1473 hd->ScsiLookup[my_idx] = SCpnt;
1423 1474
1424 mpt_put_msg_frame(hd->ioc->DoneCtx, hd->ioc, mf); 1475 mpt_put_msg_frame(hd->ioc->DoneCtx, hd->ioc, mf);
1425 dmfprintk((MYIOC_s_INFO_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n", 1476 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Issued SCSI cmd (%p) mf=%p idx=%d\n",
1426 hd->ioc->name, SCpnt, mf, my_idx)); 1477 ioc->name, SCpnt, mf, my_idx));
1427 DBG_DUMP_REQUEST_FRAME(mf) 1478 DBG_DUMP_REQUEST_FRAME(ioc, (u32 *)mf)
1428 return 0; 1479 return 0;
1429 1480
1430 fail: 1481 fail:
@@ -1475,7 +1526,7 @@ mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx)
1475 list_add_tail(&chain->u.frame.linkage.list, &ioc->FreeChainQ); 1526 list_add_tail(&chain->u.frame.linkage.list, &ioc->FreeChainQ);
1476 spin_unlock_irqrestore(&ioc->FreeQlock, flags); 1527 spin_unlock_irqrestore(&ioc->FreeQlock, flags);
1477 1528
1478 dmfprintk((MYIOC_s_INFO_FMT "FreeChainBuffers (index %d)\n", 1529 dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT "FreeChainBuffers (index %d)\n",
1479 ioc->name, chain_idx)); 1530 ioc->name, chain_idx));
1480 1531
1481 /* handle next */ 1532 /* handle next */
@@ -1519,7 +1570,7 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int c
1519 unsigned long flags; 1570 unsigned long flags;
1520 1571
1521 ioc = hd->ioc; 1572 ioc = hd->ioc;
1522 dtmprintk((MYIOC_s_INFO_FMT "TMHandler Entered!\n", ioc->name)); 1573 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TMHandler Entered!\n", ioc->name));
1523 1574
1524 // SJR - CHECKME - Can we avoid this here? 1575 // SJR - CHECKME - Can we avoid this here?
1525 // (mpt_HardResetHandler has this check...) 1576 // (mpt_HardResetHandler has this check...)
@@ -1539,20 +1590,20 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int c
1539 */ 1590 */
1540 if (mptscsih_tm_pending_wait(hd) == FAILED) { 1591 if (mptscsih_tm_pending_wait(hd) == FAILED) {
1541 if (type == MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK) { 1592 if (type == MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK) {
1542 dtmprintk((KERN_INFO MYNAM ": %s: TMHandler abort: " 1593 dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: TMHandler abort: "
1543 "Timed out waiting for last TM (%d) to complete! \n", 1594 "Timed out waiting for last TM (%d) to complete! \n",
1544 hd->ioc->name, hd->tmPending)); 1595 ioc->name, hd->tmPending));
1545 return FAILED; 1596 return FAILED;
1546 } else if (type == MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET) { 1597 } else if (type == MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET) {
1547 dtmprintk((KERN_INFO MYNAM ": %s: TMHandler target " 1598 dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: TMHandler target "
1548 "reset: Timed out waiting for last TM (%d) " 1599 "reset: Timed out waiting for last TM (%d) "
1549 "to complete! \n", hd->ioc->name, 1600 "to complete! \n", ioc->name,
1550 hd->tmPending)); 1601 hd->tmPending));
1551 return FAILED; 1602 return FAILED;
1552 } else if (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) { 1603 } else if (type == MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS) {
1553 dtmprintk((KERN_INFO MYNAM ": %s: TMHandler bus reset: " 1604 dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: TMHandler bus reset: "
1554 "Timed out waiting for last TM (%d) to complete! \n", 1605 "Timed out waiting for last TM (%d) to complete! \n",
1555 hd->ioc->name, hd->tmPending)); 1606 ioc->name, hd->tmPending));
1556 return FAILED; 1607 return FAILED;
1557 } 1608 }
1558 } else { 1609 } else {
@@ -1591,12 +1642,13 @@ mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int c
1591 ctx2abort, timeout); 1642 ctx2abort, timeout);
1592 if (rc) 1643 if (rc)
1593 printk(MYIOC_s_INFO_FMT "Issue of TaskMgmt failed!\n", 1644 printk(MYIOC_s_INFO_FMT "Issue of TaskMgmt failed!\n",
1594 hd->ioc->name); 1645 ioc->name);
1595 else 1646 else
1596 dtmprintk((MYIOC_s_INFO_FMT "Issue of TaskMgmt Successful!\n", 1647 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Issue of TaskMgmt Successful!\n",
1597 hd->ioc->name)); 1648 ioc->name));
1598 1649
1599 dtmprintk((MYIOC_s_INFO_FMT "TMHandler rc = %d!\n", hd->ioc->name, rc)); 1650 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1651 "TMHandler rc = %d!\n", ioc->name, rc));
1600 1652
1601 return rc; 1653 return rc;
1602} 1654}
@@ -1632,11 +1684,11 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
1632 /* Return Fail to calling function if no message frames available. 1684 /* Return Fail to calling function if no message frames available.
1633 */ 1685 */
1634 if ((mf = mpt_get_msg_frame(hd->ioc->TaskCtx, hd->ioc)) == NULL) { 1686 if ((mf = mpt_get_msg_frame(hd->ioc->TaskCtx, hd->ioc)) == NULL) {
1635 dfailprintk((MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n", 1687 dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "IssueTaskMgmt, no msg frames!!\n",
1636 hd->ioc->name)); 1688 hd->ioc->name));
1637 return FAILED; 1689 return FAILED;
1638 } 1690 }
1639 dtmprintk((MYIOC_s_INFO_FMT "IssueTaskMgmt request @ %p\n", 1691 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt request @ %p\n",
1640 hd->ioc->name, mf)); 1692 hd->ioc->name, mf));
1641 1693
1642 /* Format the Request 1694 /* Format the Request
@@ -1660,27 +1712,27 @@ mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, i
1660 1712
1661 pScsiTm->TaskMsgContext = ctx2abort; 1713 pScsiTm->TaskMsgContext = ctx2abort;
1662 1714
1663 dtmprintk((MYIOC_s_INFO_FMT "IssueTaskMgmt: ctx2abort (0x%08x) " 1715 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "IssueTaskMgmt: ctx2abort (0x%08x) "
1664 "type=%d\n", hd->ioc->name, ctx2abort, type)); 1716 "type=%d\n", hd->ioc->name, ctx2abort, type));
1665 1717
1666 DBG_DUMP_TM_REQUEST_FRAME((u32 *)pScsiTm); 1718 DBG_DUMP_TM_REQUEST_FRAME(ioc, (u32 *)pScsiTm);
1667 1719
1668 if ((retval = mpt_send_handshake_request(hd->ioc->TaskCtx, hd->ioc, 1720 if ((retval = mpt_send_handshake_request(hd->ioc->TaskCtx, hd->ioc,
1669 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP)) != 0) { 1721 sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP)) != 0) {
1670 dfailprintk((MYIOC_s_ERR_FMT "send_handshake FAILED!" 1722 dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "send_handshake FAILED!"
1671 " (hd %p, ioc %p, mf %p, rc=%d) \n", hd->ioc->name, hd, 1723 " (hd %p, ioc %p, mf %p, rc=%d) \n", hd->ioc->name, hd,
1672 hd->ioc, mf, retval)); 1724 hd->ioc, mf, retval));
1673 goto fail_out; 1725 goto fail_out;
1674 } 1726 }
1675 1727
1676 if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) { 1728 if(mptscsih_tm_wait_for_completion(hd, timeout) == FAILED) {
1677 dfailprintk((MYIOC_s_ERR_FMT "task management request TIMED OUT!" 1729 dfailprintk(hd->ioc, printk(MYIOC_s_ERR_FMT "task management request TIMED OUT!"
1678 " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd, 1730 " (hd %p, ioc %p, mf %p) \n", hd->ioc->name, hd,
1679 hd->ioc, mf)); 1731 hd->ioc, mf));
1680 dtmprintk((MYIOC_s_INFO_FMT "Calling HardReset! \n", 1732 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Calling HardReset! \n",
1681 hd->ioc->name)); 1733 hd->ioc->name));
1682 retval = mpt_HardResetHandler(hd->ioc, CAN_SLEEP); 1734 retval = mpt_HardResetHandler(hd->ioc, CAN_SLEEP);
1683 dtmprintk((MYIOC_s_INFO_FMT "rc=%d \n", 1735 dtmprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "rc=%d \n",
1684 hd->ioc->name, retval)); 1736 hd->ioc->name, retval));
1685 goto fail_out; 1737 goto fail_out;
1686 } 1738 }
@@ -1748,8 +1800,8 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1748 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL) { 1800 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL) {
1749 SCpnt->result = DID_RESET << 16; 1801 SCpnt->result = DID_RESET << 16;
1750 SCpnt->scsi_done(SCpnt); 1802 SCpnt->scsi_done(SCpnt);
1751 dfailprintk((KERN_INFO MYNAM ": mptscsih_abort: Can't locate " 1803 printk(KERN_DEBUG MYNAM ": mptscsih_abort: Can't locate "
1752 "host! (sc=%p)\n", SCpnt)); 1804 "host! (sc=%p)\n", SCpnt);
1753 return FAILED; 1805 return FAILED;
1754 } 1806 }
1755 1807
@@ -1760,7 +1812,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1760 1812
1761 vdevice = SCpnt->device->hostdata; 1813 vdevice = SCpnt->device->hostdata;
1762 if (!vdevice || !vdevice->vtarget) { 1814 if (!vdevice || !vdevice->vtarget) {
1763 dtmprintk((MYIOC_s_DEBUG_FMT "task abort: device has been " 1815 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: device has been "
1764 "deleted (sc=%p)\n", ioc->name, SCpnt)); 1816 "deleted (sc=%p)\n", ioc->name, SCpnt));
1765 SCpnt->result = DID_NO_CONNECT << 16; 1817 SCpnt->result = DID_NO_CONNECT << 16;
1766 SCpnt->scsi_done(SCpnt); 1818 SCpnt->scsi_done(SCpnt);
@@ -1771,7 +1823,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1771 /* Task aborts are not supported for hidden raid components. 1823 /* Task aborts are not supported for hidden raid components.
1772 */ 1824 */
1773 if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) { 1825 if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) {
1774 dtmprintk((MYIOC_s_DEBUG_FMT "task abort: hidden raid " 1826 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "task abort: hidden raid "
1775 "component (sc=%p)\n", ioc->name, SCpnt)); 1827 "component (sc=%p)\n", ioc->name, SCpnt));
1776 SCpnt->result = DID_RESET << 16; 1828 SCpnt->result = DID_RESET << 16;
1777 retval = FAILED; 1829 retval = FAILED;
@@ -1785,7 +1837,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1785 * Do OS callback. 1837 * Do OS callback.
1786 */ 1838 */
1787 SCpnt->result = DID_RESET << 16; 1839 SCpnt->result = DID_RESET << 16;
1788 dtmprintk((KERN_INFO MYNAM ": %s: mptscsih_abort: " 1840 dtmprintk(ioc, printk(KERN_DEBUG MYNAM ": %s: mptscsih_abort: "
1789 "Command not in the active list! (sc=%p)\n", ioc->name, 1841 "Command not in the active list! (sc=%p)\n", ioc->name,
1790 SCpnt)); 1842 SCpnt));
1791 retval = 0; 1843 retval = 0;
@@ -1850,8 +1902,8 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1850 /* If we can't locate our host adapter structure, return FAILED status. 1902 /* If we can't locate our host adapter structure, return FAILED status.
1851 */ 1903 */
1852 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ 1904 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){
1853 dtmprintk((KERN_INFO MYNAM ": mptscsih_dev_reset: Can't " 1905 printk(KERN_DEBUG MYNAM ": mptscsih_dev_reset: Can't "
1854 "locate host! (sc=%p)\n", SCpnt)); 1906 "locate host! (sc=%p)\n", SCpnt);
1855 return FAILED; 1907 return FAILED;
1856 } 1908 }
1857 1909
@@ -1913,8 +1965,8 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1913 /* If we can't locate our host adapter structure, return FAILED status. 1965 /* If we can't locate our host adapter structure, return FAILED status.
1914 */ 1966 */
1915 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ 1967 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){
1916 dtmprintk((KERN_INFO MYNAM ": mptscsih_bus_reset: Can't " 1968 printk(KERN_DEBUG MYNAM ": mptscsih_bus_reset: Can't "
1917 "locate host! (sc=%p)\n", SCpnt )); 1969 "locate host! (sc=%p)\n", SCpnt );
1918 return FAILED; 1970 return FAILED;
1919 } 1971 }
1920 1972
@@ -1957,8 +2009,8 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
1957 2009
1958 /* If we can't locate the host to reset, then we failed. */ 2010 /* If we can't locate the host to reset, then we failed. */
1959 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){ 2011 if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){
1960 dtmprintk( ( KERN_INFO MYNAM ": mptscsih_host_reset: Can't " 2012 printk( KERN_DEBUG MYNAM ": mptscsih_host_reset: Can't "
1961 "locate host! (sc=%p)\n", SCpnt)); 2013 "locate host! (sc=%p)\n", SCpnt);
1962 return FAILED; 2014 return FAILED;
1963 } 2015 }
1964 2016
@@ -2106,16 +2158,16 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
2106 u8 tmType; 2158 u8 tmType;
2107 u32 termination_count; 2159 u32 termination_count;
2108 2160
2109 dtmprintk((MYIOC_s_WARN_FMT "TaskMgmt completed (mf=%p,mr=%p)\n", 2161 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "TaskMgmt completed (mf=%p,mr=%p)\n",
2110 ioc->name, mf, mr)); 2162 ioc->name, mf, mr));
2111 if (!ioc->sh) { 2163 if (!ioc->sh) {
2112 dtmprintk((MYIOC_s_WARN_FMT 2164 dtmprintk(ioc, printk(MYIOC_s_WARN_FMT
2113 "TaskMgmt Complete: NULL Scsi Host Ptr\n", ioc->name)); 2165 "TaskMgmt Complete: NULL Scsi Host Ptr\n", ioc->name));
2114 return 1; 2166 return 1;
2115 } 2167 }
2116 2168
2117 if (mr == NULL) { 2169 if (mr == NULL) {
2118 dtmprintk((MYIOC_s_WARN_FMT 2170 dtmprintk(ioc, printk(MYIOC_s_WARN_FMT
2119 "ERROR! TaskMgmt Reply: NULL Request %p\n", ioc->name, mf)); 2171 "ERROR! TaskMgmt Reply: NULL Request %p\n", ioc->name, mf));
2120 return 1; 2172 return 1;
2121 } 2173 }
@@ -2131,19 +2183,21 @@ mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *m
2131 pScsiTmReply->ResponseCode) 2183 pScsiTmReply->ResponseCode)
2132 mptscsih_taskmgmt_response_code(ioc, 2184 mptscsih_taskmgmt_response_code(ioc,
2133 pScsiTmReply->ResponseCode); 2185 pScsiTmReply->ResponseCode);
2134 DBG_DUMP_TM_REPLY_FRAME((u32 *)pScsiTmReply); 2186 DBG_DUMP_TM_REPLY_FRAME(ioc, (u32 *)pScsiTmReply);
2135 2187
2136#if defined(MPT_DEBUG_REPLY) || defined(MPT_DEBUG_TM) 2188#ifdef CONFIG_FUSION_LOGGING
2137 printk("%s: ha=%d [%d:%d:0] task_type=0x%02X " 2189 if ((ioc->debug_level & MPT_DEBUG_REPLY) ||
2138 "iocstatus=0x%04X\n\tloginfo=0x%08X response_code=0x%02X " 2190 (ioc->debug_level & MPT_DEBUG_TM ))
2139 "term_cmnds=%d\n", __FUNCTION__, ioc->id, pScsiTmReply->Bus, 2191 printk("%s: ha=%d [%d:%d:0] task_type=0x%02X "
2140 pScsiTmReply->TargetID, pScsiTmReq->TaskType, 2192 "iocstatus=0x%04X\n\tloginfo=0x%08X response_code=0x%02X "
2141 le16_to_cpu(pScsiTmReply->IOCStatus), 2193 "term_cmnds=%d\n", __FUNCTION__, ioc->id, pScsiTmReply->Bus,
2142 le32_to_cpu(pScsiTmReply->IOCLogInfo),pScsiTmReply->ResponseCode, 2194 pScsiTmReply->TargetID, pScsiTmReq->TaskType,
2143 le32_to_cpu(pScsiTmReply->TerminationCount)); 2195 le16_to_cpu(pScsiTmReply->IOCStatus),
2196 le32_to_cpu(pScsiTmReply->IOCLogInfo),pScsiTmReply->ResponseCode,
2197 le32_to_cpu(pScsiTmReply->TerminationCount));
2144#endif 2198#endif
2145 if (!iocstatus) { 2199 if (!iocstatus) {
2146 dtmprintk((MYIOC_s_WARN_FMT " TaskMgmt SUCCESS\n", ioc->name)); 2200 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT " TaskMgmt SUCCESS\n", ioc->name));
2147 hd->abortSCpnt = NULL; 2201 hd->abortSCpnt = NULL;
2148 goto out; 2202 goto out;
2149 } 2203 }
@@ -2224,10 +2278,6 @@ mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev,
2224 geom[1] = sectors; 2278 geom[1] = sectors;
2225 geom[2] = cylinders; 2279 geom[2] = cylinders;
2226 2280
2227 dprintk((KERN_NOTICE
2228 ": bios_param: Id=%i Lun=%i Channel=%i CHS=%i/%i/%i\n",
2229 sdev->id, sdev->lun, sdev->channel, (int)cylinders, heads, sectors));
2230
2231 return 0; 2281 return 0;
2232} 2282}
2233 2283
@@ -2393,11 +2443,11 @@ mptscsih_slave_configure(struct scsi_device *sdev)
2393 vtarget = starget->hostdata; 2443 vtarget = starget->hostdata;
2394 vdevice = sdev->hostdata; 2444 vdevice = sdev->hostdata;
2395 2445
2396 dsprintk((MYIOC_s_INFO_FMT 2446 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT
2397 "device @ %p, channel=%d, id=%d, lun=%d\n", 2447 "device @ %p, channel=%d, id=%d, lun=%d\n",
2398 hd->ioc->name, sdev, sdev->channel, sdev->id, sdev->lun)); 2448 hd->ioc->name, sdev, sdev->channel, sdev->id, sdev->lun));
2399 if (hd->ioc->bus_type == SPI) 2449 if (hd->ioc->bus_type == SPI)
2400 dsprintk((MYIOC_s_INFO_FMT 2450 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT
2401 "sdtr %d wdtr %d ppr %d inq length=%d\n", 2451 "sdtr %d wdtr %d ppr %d inq length=%d\n",
2402 hd->ioc->name, sdev->sdtr, sdev->wdtr, 2452 hd->ioc->name, sdev->sdtr, sdev->wdtr,
2403 sdev->ppr, sdev->inquiry_len)); 2453 sdev->ppr, sdev->inquiry_len));
@@ -2411,19 +2461,19 @@ mptscsih_slave_configure(struct scsi_device *sdev)
2411 vdevice->configured_lun = 1; 2461 vdevice->configured_lun = 1;
2412 mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH); 2462 mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH);
2413 2463
2414 dsprintk((MYIOC_s_INFO_FMT 2464 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT
2415 "Queue depth=%d, tflags=%x\n", 2465 "Queue depth=%d, tflags=%x\n",
2416 hd->ioc->name, sdev->queue_depth, vtarget->tflags)); 2466 hd->ioc->name, sdev->queue_depth, vtarget->tflags));
2417 2467
2418 if (hd->ioc->bus_type == SPI) 2468 if (hd->ioc->bus_type == SPI)
2419 dsprintk((MYIOC_s_INFO_FMT 2469 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT
2420 "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n", 2470 "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n",
2421 hd->ioc->name, vtarget->negoFlags, vtarget->maxOffset, 2471 hd->ioc->name, vtarget->negoFlags, vtarget->maxOffset,
2422 vtarget->minSyncFactor)); 2472 vtarget->minSyncFactor));
2423 2473
2424slave_configure_exit: 2474slave_configure_exit:
2425 2475
2426 dsprintk((MYIOC_s_INFO_FMT 2476 dsprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT
2427 "tagged %d, simple %d, ordered %d\n", 2477 "tagged %d, simple %d, ordered %d\n",
2428 hd->ioc->name,sdev->tagged_supported, sdev->simple_tags, 2478 hd->ioc->name,sdev->tagged_supported, sdev->simple_tags,
2429 sdev->ordered_tags)); 2479 sdev->ordered_tags));
@@ -2490,7 +2540,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2490 } 2540 }
2491 } 2541 }
2492 } else { 2542 } else {
2493 dprintk((MYIOC_s_INFO_FMT "Hmmm... SenseData len=0! (?)\n", 2543 dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Hmmm... SenseData len=0! (?)\n",
2494 hd->ioc->name)); 2544 hd->ioc->name));
2495 } 2545 }
2496} 2546}
@@ -2520,7 +2570,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2520 unsigned long flags; 2570 unsigned long flags;
2521 int ii; 2571 int ii;
2522 2572
2523 dtmprintk((KERN_WARNING MYNAM 2573 dtmprintk(ioc, printk(KERN_DEBUG MYNAM
2524 ": IOC %s_reset routed to SCSI host driver!\n", 2574 ": IOC %s_reset routed to SCSI host driver!\n",
2525 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : ( 2575 reset_phase==MPT_IOC_SETUP_RESET ? "setup" : (
2526 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post"))); 2576 reset_phase==MPT_IOC_PRE_RESET ? "pre" : "post")));
@@ -2535,7 +2585,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2535 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata; 2585 hd = (MPT_SCSI_HOST *) ioc->sh->hostdata;
2536 2586
2537 if (reset_phase == MPT_IOC_SETUP_RESET) { 2587 if (reset_phase == MPT_IOC_SETUP_RESET) {
2538 dtmprintk((MYIOC_s_WARN_FMT "Setup-Diag Reset\n", ioc->name)); 2588 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Setup-Diag Reset\n", ioc->name));
2539 2589
2540 /* Clean Up: 2590 /* Clean Up:
2541 * 1. Set Hard Reset Pending Flag 2591 * 1. Set Hard Reset Pending Flag
@@ -2544,7 +2594,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2544 hd->resetPending = 1; 2594 hd->resetPending = 1;
2545 2595
2546 } else if (reset_phase == MPT_IOC_PRE_RESET) { 2596 } else if (reset_phase == MPT_IOC_PRE_RESET) {
2547 dtmprintk((MYIOC_s_WARN_FMT "Pre-Diag Reset\n", ioc->name)); 2597 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Pre-Diag Reset\n", ioc->name));
2548 2598
2549 /* 2. Flush running commands 2599 /* 2. Flush running commands
2550 * Clean ScsiLookup (and associated memory) 2600 * Clean ScsiLookup (and associated memory)
@@ -2564,10 +2614,10 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2564 mpt_free_msg_frame(ioc, hd->cmdPtr); 2614 mpt_free_msg_frame(ioc, hd->cmdPtr);
2565 } 2615 }
2566 2616
2567 dtmprintk((MYIOC_s_WARN_FMT "Pre-Reset complete.\n", ioc->name)); 2617 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Pre-Reset complete.\n", ioc->name));
2568 2618
2569 } else { 2619 } else {
2570 dtmprintk((MYIOC_s_WARN_FMT "Post-Diag Reset\n", ioc->name)); 2620 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Post-Diag Reset\n", ioc->name));
2571 2621
2572 /* Once a FW reload begins, all new OS commands are 2622 /* Once a FW reload begins, all new OS commands are
2573 * redirected to the doneQ w/ a reset status. 2623 * redirected to the doneQ w/ a reset status.
@@ -2607,7 +2657,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2607 hd->cmdPtr = NULL; 2657 hd->cmdPtr = NULL;
2608 } 2658 }
2609 2659
2610 dtmprintk((MYIOC_s_WARN_FMT "Post-Reset complete.\n", ioc->name)); 2660 dtmprintk(ioc, printk(MYIOC_s_DEBUG_FMT "Post-Reset complete.\n", ioc->name));
2611 2661
2612 } 2662 }
2613 2663
@@ -2621,7 +2671,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2621 MPT_SCSI_HOST *hd; 2671 MPT_SCSI_HOST *hd;
2622 u8 event = le32_to_cpu(pEvReply->Event) & 0xFF; 2672 u8 event = le32_to_cpu(pEvReply->Event) & 0xFF;
2623 2673
2624 devtverboseprintk((MYIOC_s_INFO_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n", 2674 devtverboseprintk(ioc, printk(MYIOC_s_DEBUG_FMT "MPT event (=%02Xh) routed to SCSI host driver!\n",
2625 ioc->name, event)); 2675 ioc->name, event));
2626 2676
2627 if (ioc->sh == NULL || 2677 if (ioc->sh == NULL ||
@@ -2663,7 +2713,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2663 case MPI_EVENT_STATE_CHANGE: /* 02 */ 2713 case MPI_EVENT_STATE_CHANGE: /* 02 */
2664 case MPI_EVENT_EVENT_CHANGE: /* 0A */ 2714 case MPI_EVENT_EVENT_CHANGE: /* 0A */
2665 default: 2715 default:
2666 dprintk((KERN_INFO " Ignoring event (=%02Xh)\n", event)); 2716 dprintk(ioc, printk(KERN_DEBUG MYNAM ": Ignoring event (=%02Xh)\n", event));
2667 break; 2717 break;
2668 } 2718 }
2669 2719
@@ -2724,7 +2774,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2724 } 2774 }
2725 hd->cmdPtr = NULL; 2775 hd->cmdPtr = NULL;
2726 2776
2727 ddvprintk((MYIOC_s_INFO_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n", 2777 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScanDvComplete (mf=%p,mr=%p,idx=%d)\n",
2728 hd->ioc->name, mf, mr, req_idx)); 2778 hd->ioc->name, mf, mr, req_idx));
2729 2779
2730 hd->pLocal = &hd->localReply; 2780 hd->pLocal = &hd->localReply;
@@ -2744,9 +2794,6 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2744 status = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK; 2794 status = le16_to_cpu(pReply->IOCStatus) & MPI_IOCSTATUS_MASK;
2745 scsi_status = pReply->SCSIStatus; 2795 scsi_status = pReply->SCSIStatus;
2746 2796
2747 ddvtprintk((KERN_NOTICE " IOCStatus=%04xh, SCSIState=%02xh, SCSIStatus=%02xh, IOCLogInfo=%08xh\n",
2748 status, pReply->SCSIState, scsi_status,
2749 le32_to_cpu(pReply->IOCLogInfo)));
2750 2797
2751 switch(status) { 2798 switch(status) {
2752 2799
@@ -2799,7 +2846,7 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2799 SCSI_STD_SENSE_BYTES); 2846 SCSI_STD_SENSE_BYTES);
2800 memcpy(hd->pLocal->sense, sense_data, sz); 2847 memcpy(hd->pLocal->sense, sense_data, sz);
2801 2848
2802 ddvprintk((KERN_NOTICE " Check Condition, sense ptr %p\n", 2849 ddvprintk(ioc, printk(KERN_DEBUG " Check Condition, sense ptr %p\n",
2803 sense_data)); 2850 sense_data));
2804 } else if (pReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_FAILED) { 2851 } else if (pReply->SCSIState & MPI_SCSI_STATE_AUTOSENSE_FAILED) {
2805 if (pReq->CDB[0] == INQUIRY) 2852 if (pReq->CDB[0] == INQUIRY)
@@ -2830,8 +2877,6 @@ mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
2830 2877
2831 } /* switch(status) */ 2878 } /* switch(status) */
2832 2879
2833 ddvtprintk((KERN_NOTICE " completionCode set to %08xh\n",
2834 completionCode));
2835 } /* end of address reply case */ 2880 } /* end of address reply case */
2836 2881
2837 hd->pLocal->completion = completionCode; 2882 hd->pLocal->completion = completionCode;
@@ -2862,7 +2907,7 @@ mptscsih_timer_expired(unsigned long data)
2862{ 2907{
2863 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data; 2908 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *) data;
2864 2909
2865 ddvprintk((MYIOC_s_WARN_FMT "Timer Expired! Cmd %p\n", hd->ioc->name, hd->cmdPtr)); 2910 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired! Cmd %p\n", hd->ioc->name, hd->cmdPtr));
2866 2911
2867 if (hd->cmdPtr) { 2912 if (hd->cmdPtr) {
2868 MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr; 2913 MPIHeader_t *cmd = (MPIHeader_t *)hd->cmdPtr;
@@ -2874,7 +2919,6 @@ mptscsih_timer_expired(unsigned long data)
2874 * If new eh code, do nothing. Wait for OS cmd timeout 2919 * If new eh code, do nothing. Wait for OS cmd timeout
2875 * for bus reset. 2920 * for bus reset.
2876 */ 2921 */
2877 ddvtprintk((MYIOC_s_NOTE_FMT "DV Cmd Timeout: NoOp\n", hd->ioc->name));
2878 } else { 2922 } else {
2879 /* Perform a FW reload */ 2923 /* Perform a FW reload */
2880 if (mpt_HardResetHandler(hd->ioc, NO_SLEEP) < 0) { 2924 if (mpt_HardResetHandler(hd->ioc, NO_SLEEP) < 0) {
@@ -2891,7 +2935,7 @@ mptscsih_timer_expired(unsigned long data)
2891 * The FW will reply to all outstanding commands, callback will finish cleanup. 2935 * The FW will reply to all outstanding commands, callback will finish cleanup.
2892 * Hard reset clean-up will free all resources. 2936 * Hard reset clean-up will free all resources.
2893 */ 2937 */
2894 ddvprintk((MYIOC_s_WARN_FMT "Timer Expired Complete!\n", hd->ioc->name)); 2938 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Timer Expired Complete!\n", hd->ioc->name));
2895 2939
2896 return; 2940 return;
2897} 2941}
@@ -2932,7 +2976,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
2932 2976
2933 in_isr = in_interrupt(); 2977 in_isr = in_interrupt();
2934 if (in_isr) { 2978 if (in_isr) {
2935 dprintk((MYIOC_s_WARN_FMT "Internal SCSI IO request not allowed in ISR context!\n", 2979 dprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Internal SCSI IO request not allowed in ISR context!\n",
2936 hd->ioc->name)); 2980 hd->ioc->name));
2937 return -EPERM; 2981 return -EPERM;
2938 } 2982 }
@@ -3035,7 +3079,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3035 /* Get and Populate a free Frame 3079 /* Get and Populate a free Frame
3036 */ 3080 */
3037 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { 3081 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) {
3038 ddvprintk((MYIOC_s_WARN_FMT "No msg frames!\n", 3082 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "No msg frames!\n",
3039 hd->ioc->name)); 3083 hd->ioc->name));
3040 return -EBUSY; 3084 return -EBUSY;
3041 } 3085 }
@@ -3075,7 +3119,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3075 3119
3076 if (cmd == REQUEST_SENSE) { 3120 if (cmd == REQUEST_SENSE) {
3077 pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED); 3121 pScsiReq->Control = cpu_to_le32(dir | MPI_SCSIIO_CONTROL_UNTAGGED);
3078 ddvprintk((MYIOC_s_INFO_FMT "Untagged! 0x%2x\n", 3122 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Untagged! 0x%2x\n",
3079 hd->ioc->name, cmd)); 3123 hd->ioc->name, cmd));
3080 } 3124 }
3081 3125
@@ -3086,7 +3130,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3086 pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma 3130 pScsiReq->SenseBufferLowAddr = cpu_to_le32(hd->ioc->sense_buf_low_dma
3087 + (my_idx * MPT_SENSE_BUFFER_ALLOC)); 3131 + (my_idx * MPT_SENSE_BUFFER_ALLOC));
3088 3132
3089 ddvprintk((MYIOC_s_INFO_FMT "Sending Command 0x%x for (%d:%d:%d)\n", 3133 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "Sending Command 0x%x for (%d:%d:%d)\n",
3090 hd->ioc->name, cmd, io->channel, io->id, io->lun)); 3134 hd->ioc->name, cmd, io->channel, io->id, io->lun));
3091 3135
3092 if (dir == MPI_SCSIIO_CONTROL_READ) { 3136 if (dir == MPI_SCSIIO_CONTROL_READ) {
@@ -3138,7 +3182,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3138 } else { 3182 } else {
3139 rc = -EFAULT; 3183 rc = -EFAULT;
3140 /* This should never happen. */ 3184 /* This should never happen. */
3141 ddvprintk((MYIOC_s_INFO_FMT "_do_cmd: Null pLocal!!!\n", 3185 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "_do_cmd: Null pLocal!!!\n",
3142 hd->ioc->name)); 3186 hd->ioc->name));
3143 } 3187 }
3144 3188
@@ -3324,6 +3368,35 @@ mptscsih_device_delay_show(struct class_device *cdev, char *buf)
3324static CLASS_DEVICE_ATTR(device_delay, S_IRUGO, 3368static CLASS_DEVICE_ATTR(device_delay, S_IRUGO,
3325 mptscsih_device_delay_show, NULL); 3369 mptscsih_device_delay_show, NULL);
3326 3370
3371static ssize_t
3372mptscsih_debug_level_show(struct class_device *cdev, char *buf)
3373{
3374 struct Scsi_Host *host = class_to_shost(cdev);
3375 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3376 MPT_ADAPTER *ioc = hd->ioc;
3377
3378 return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level);
3379}
3380static ssize_t
3381mptscsih_debug_level_store(struct class_device *cdev, const char *buf,
3382 size_t count)
3383{
3384 struct Scsi_Host *host = class_to_shost(cdev);
3385 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3386 MPT_ADAPTER *ioc = hd->ioc;
3387 int val = 0;
3388
3389 if (sscanf(buf, "%x", &val) != 1)
3390 return -EINVAL;
3391
3392 ioc->debug_level = val;
3393 printk(MYIOC_s_INFO_FMT "debug_level=%08xh\n",
3394 ioc->name, ioc->debug_level);
3395 return strlen(buf);
3396}
3397static CLASS_DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR,
3398 mptscsih_debug_level_show, mptscsih_debug_level_store);
3399
3327struct class_device_attribute *mptscsih_host_attrs[] = { 3400struct class_device_attribute *mptscsih_host_attrs[] = {
3328 &class_device_attr_version_fw, 3401 &class_device_attr_version_fw,
3329 &class_device_attr_version_bios, 3402 &class_device_attr_version_bios,
@@ -3336,6 +3409,7 @@ struct class_device_attribute *mptscsih_host_attrs[] = {
3336 &class_device_attr_board_tracer, 3409 &class_device_attr_board_tracer,
3337 &class_device_attr_io_delay, 3410 &class_device_attr_io_delay,
3338 &class_device_attr_device_delay, 3411 &class_device_attr_device_delay,
3412 &class_device_attr_debug_level,
3339 NULL, 3413 NULL,
3340}; 3414};
3341EXPORT_SYMBOL(mptscsih_host_attrs); 3415EXPORT_SYMBOL(mptscsih_host_attrs);
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 947fe2901800..8c98420640a5 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -138,7 +138,9 @@ mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
138 else { 138 else {
139 factor = MPT_ULTRA320; 139 factor = MPT_ULTRA320;
140 if (scsi_device_qas(sdev)) { 140 if (scsi_device_qas(sdev)) {
141 ddvprintk((KERN_INFO "Enabling QAS due to byte56=%02x on id=%d!\n", scsi_device_qas(sdev), id)); 141 ddvprintk(hd->ioc,
142 printk(KERN_DEBUG "Enabling QAS due to "
143 "byte56=%02x on id=%d!\n", scsi_device_qas(sdev), id));
142 noQas = 0; 144 noQas = 0;
143 } 145 }
144 if (sdev->type == TYPE_TAPE && 146 if (sdev->type == TYPE_TAPE &&
@@ -225,7 +227,8 @@ mptspi_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target,
225 /* Disable QAS in a mixed configuration case 227 /* Disable QAS in a mixed configuration case
226 */ 228 */
227 229
228 ddvprintk((KERN_INFO "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id)); 230 ddvprintk(hd->ioc, printk(KERN_DEBUG
231 "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id));
229 } 232 }
230} 233}
231 234
@@ -256,8 +259,8 @@ mptspi_writeIOCPage4(MPT_SCSI_HOST *hd, u8 channel , u8 id)
256 /* Get a MF for this command. 259 /* Get a MF for this command.
257 */ 260 */
258 if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) { 261 if ((mf = mpt_get_msg_frame(ioc->DoneCtx, ioc)) == NULL) {
259 dfailprintk((MYIOC_s_WARN_FMT "writeIOCPage4 : no msg frames!\n", 262 dfailprintk(ioc, printk(MYIOC_s_WARN_FMT
260 ioc->name)); 263 "writeIOCPage4 : no msg frames!\n",ioc->name));
261 return -EAGAIN; 264 return -EAGAIN;
262 } 265 }
263 266
@@ -297,7 +300,7 @@ mptspi_writeIOCPage4(MPT_SCSI_HOST *hd, u8 channel , u8 id)
297 300
298 mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma); 301 mpt_add_sge((char *)&pReq->PageBufferSGE, flagsLength, dataDma);
299 302
300 ddvprintk((MYIOC_s_INFO_FMT 303 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
301 "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n", 304 "writeIOCPage4: MaxSEP=%d ActiveSEP=%d id=%d bus=%d\n",
302 ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, id, channel)); 305 ioc->name, IOCPage4Ptr->MaxSEP, IOCPage4Ptr->ActiveSEP, id, channel));
303 306
@@ -422,7 +425,7 @@ static int mptspi_target_alloc(struct scsi_target *starget)
422 if (starget->channel == 0 && 425 if (starget->channel == 0 &&
423 mptspi_is_raid(hd, starget->id)) { 426 mptspi_is_raid(hd, starget->id)) {
424 vtarget->raidVolume = 1; 427 vtarget->raidVolume = 1;
425 ddvprintk((KERN_INFO 428 ddvprintk(hd->ioc, printk(KERN_DEBUG
426 "RAID Volume @ channel=%d id=%d\n", starget->channel, 429 "RAID Volume @ channel=%d id=%d\n", starget->channel,
427 starget->id)); 430 starget->id));
428 } 431 }
@@ -462,7 +465,7 @@ mptspi_target_destroy(struct scsi_target *starget)
462static void 465static void
463mptspi_print_write_nego(struct _MPT_SCSI_HOST *hd, struct scsi_target *starget, u32 ii) 466mptspi_print_write_nego(struct _MPT_SCSI_HOST *hd, struct scsi_target *starget, u32 ii)
464{ 467{
465 ddvprintk((MYIOC_s_INFO_FMT "id=%d Requested = 0x%08x" 468 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "id=%d Requested = 0x%08x"
466 " ( %s factor = 0x%02x @ offset = 0x%02x %s%s%s%s%s%s%s%s)\n", 469 " ( %s factor = 0x%02x @ offset = 0x%02x %s%s%s%s%s%s%s%s)\n",
467 hd->ioc->name, starget->id, ii, 470 hd->ioc->name, starget->id, ii,
468 ii & MPI_SCSIDEVPAGE0_NP_WIDE ? "Wide ": "", 471 ii & MPI_SCSIDEVPAGE0_NP_WIDE ? "Wide ": "",
@@ -487,7 +490,7 @@ mptspi_print_write_nego(struct _MPT_SCSI_HOST *hd, struct scsi_target *starget,
487static void 490static void
488mptspi_print_read_nego(struct _MPT_SCSI_HOST *hd, struct scsi_target *starget, u32 ii) 491mptspi_print_read_nego(struct _MPT_SCSI_HOST *hd, struct scsi_target *starget, u32 ii)
489{ 492{
490 ddvprintk((MYIOC_s_INFO_FMT "id=%d Read = 0x%08x" 493 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "id=%d Read = 0x%08x"
491 " ( %s factor = 0x%02x @ offset = 0x%02x %s%s%s%s%s%s%s%s)\n", 494 " ( %s factor = 0x%02x @ offset = 0x%02x %s%s%s%s%s%s%s%s)\n",
492 hd->ioc->name, starget->id, ii, 495 hd->ioc->name, starget->id, ii,
493 ii & MPI_SCSIDEVPAGE0_NP_WIDE ? "Wide ": "", 496 ii & MPI_SCSIDEVPAGE0_NP_WIDE ? "Wide ": "",
@@ -613,7 +616,7 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id)
613 /* Get and Populate a free Frame 616 /* Get and Populate a free Frame
614 */ 617 */
615 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) { 618 if ((mf = mpt_get_msg_frame(hd->ioc->InternalCtx, hd->ioc)) == NULL) {
616 ddvprintk((MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n", 619 ddvprintk(hd->ioc, printk(MYIOC_s_WARN_FMT "_do_raid: no msg frames!\n",
617 hd->ioc->name)); 620 hd->ioc->name));
618 return -EAGAIN; 621 return -EAGAIN;
619 } 622 }
@@ -635,7 +638,7 @@ mptscsih_quiesce_raid(MPT_SCSI_HOST *hd, int quiesce, u8 channel, u8 id)
635 mpt_add_sge((char *)&pReq->ActionDataSGE, 638 mpt_add_sge((char *)&pReq->ActionDataSGE,
636 MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1); 639 MPT_SGE_FLAGS_SSIMPLE_READ | 0, (dma_addr_t) -1);
637 640
638 ddvprintk((MYIOC_s_INFO_FMT "RAID Volume action=%x channel=%d id=%d\n", 641 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "RAID Volume action=%x channel=%d id=%d\n",
639 hd->ioc->name, pReq->Action, channel, id)); 642 hd->ioc->name, pReq->Action, channel, id));
640 643
641 hd->pLocal = NULL; 644 hd->pLocal = NULL;
@@ -735,7 +738,7 @@ static int mptspi_slave_configure(struct scsi_device *sdev)
735 if (ret) 738 if (ret)
736 return ret; 739 return ret;
737 740
738 ddvprintk((MYIOC_s_INFO_FMT "id=%d min_period=0x%02x" 741 ddvprintk(hd->ioc, printk(MYIOC_s_DEBUG_FMT "id=%d min_period=0x%02x"
739 " max_offset=0x%02x max_width=%d\n", hd->ioc->name, 742 " max_offset=0x%02x max_width=%d\n", hd->ioc->name,
740 sdev->id, spi_min_period(scsi_target(sdev)), 743 sdev->id, spi_min_period(scsi_target(sdev)),
741 spi_max_offset(scsi_target(sdev)), 744 spi_max_offset(scsi_target(sdev)),
@@ -768,10 +771,8 @@ mptspi_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
768 return 0; 771 return 0;
769 } 772 }
770 773
771#ifdef MPT_DEBUG_DV
772 if (spi_dv_pending(scsi_target(SCpnt->device))) 774 if (spi_dv_pending(scsi_target(SCpnt->device)))
773 scsi_print_command(SCpnt); 775 ddvprintk(hd->ioc, scsi_print_command(SCpnt));
774#endif
775 776
776 return mptscsih_qcmd(SCpnt,done); 777 return mptscsih_qcmd(SCpnt,done);
777} 778}
@@ -1415,7 +1416,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1415 1416
1416 if (numSGE < sh->sg_tablesize) { 1417 if (numSGE < sh->sg_tablesize) {
1417 /* Reset this value */ 1418 /* Reset this value */
1418 dprintk((MYIOC_s_INFO_FMT 1419 dprintk(ioc, printk(MYIOC_s_INFO_FMT
1419 "Resetting sg_tablesize to %d from %d\n", 1420 "Resetting sg_tablesize to %d from %d\n",
1420 ioc->name, numSGE, sh->sg_tablesize)); 1421 ioc->name, numSGE, sh->sg_tablesize));
1421 sh->sg_tablesize = numSGE; 1422 sh->sg_tablesize = numSGE;
@@ -1435,7 +1436,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1435 goto out_mptspi_probe; 1436 goto out_mptspi_probe;
1436 } 1437 }
1437 1438
1438 dprintk((MYIOC_s_INFO_FMT "ScsiLookup @ %p\n", 1439 dprintk(ioc, printk(MYIOC_s_DEBUG_FMT "ScsiLookup @ %p\n",
1439 ioc->name, hd->ScsiLookup)); 1440 ioc->name, hd->ScsiLookup));
1440 1441
1441 /* Clear the TM flags 1442 /* Clear the TM flags
@@ -1463,7 +1464,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1463 ioc->spi_data.Saf_Te = mpt_saf_te; 1464 ioc->spi_data.Saf_Te = mpt_saf_te;
1464 1465
1465 hd->negoNvram = MPT_SCSICFG_USE_NVRAM; 1466 hd->negoNvram = MPT_SCSICFG_USE_NVRAM;
1466 ddvprintk((MYIOC_s_INFO_FMT 1467 ddvprintk(ioc, printk(MYIOC_s_DEBUG_FMT
1467 "saf_te %x\n", 1468 "saf_te %x\n",
1468 ioc->name, 1469 ioc->name,
1469 mpt_saf_te)); 1470 mpt_saf_te));
@@ -1481,7 +1482,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1481 1482
1482 error = scsi_add_host (sh, &ioc->pcidev->dev); 1483 error = scsi_add_host (sh, &ioc->pcidev->dev);
1483 if(error) { 1484 if(error) {
1484 dprintk((KERN_ERR MYNAM 1485 dprintk(ioc, printk(KERN_ERR MYNAM
1485 "scsi_add_host failed\n")); 1486 "scsi_add_host failed\n"));
1486 goto out_mptspi_probe; 1487 goto out_mptspi_probe;
1487 } 1488 }
@@ -1536,15 +1537,8 @@ mptspi_init(void)
1536 mptspiTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTSPI_DRIVER); 1537 mptspiTaskCtx = mpt_register(mptscsih_taskmgmt_complete, MPTSPI_DRIVER);
1537 mptspiInternalCtx = mpt_register(mptscsih_scandv_complete, MPTSPI_DRIVER); 1538 mptspiInternalCtx = mpt_register(mptscsih_scandv_complete, MPTSPI_DRIVER);
1538 1539
1539 if (mpt_event_register(mptspiDoneCtx, mptspi_event_process) == 0) { 1540 mpt_event_register(mptspiDoneCtx, mptspi_event_process);
1540 devtverboseprintk((KERN_INFO MYNAM 1541 mpt_reset_register(mptspiDoneCtx, mptspi_ioc_reset);
1541 ": Registered for IOC event notifications\n"));
1542 }
1543
1544 if (mpt_reset_register(mptspiDoneCtx, mptspi_ioc_reset) == 0) {
1545 dprintk((KERN_INFO MYNAM
1546 ": Registered for IOC reset notifications\n"));
1547 }
1548 1542
1549 error = pci_register_driver(&mptspi_driver); 1543 error = pci_register_driver(&mptspi_driver);
1550 if (error) 1544 if (error)
@@ -1564,12 +1558,7 @@ mptspi_exit(void)
1564 pci_unregister_driver(&mptspi_driver); 1558 pci_unregister_driver(&mptspi_driver);
1565 1559
1566 mpt_reset_deregister(mptspiDoneCtx); 1560 mpt_reset_deregister(mptspiDoneCtx);
1567 dprintk((KERN_INFO MYNAM
1568 ": Deregistered for IOC reset notifications\n"));
1569
1570 mpt_event_deregister(mptspiDoneCtx); 1561 mpt_event_deregister(mptspiDoneCtx);
1571 dprintk((KERN_INFO MYNAM
1572 ": Deregistered for IOC event notifications\n"));
1573 1562
1574 mpt_deregister(mptspiInternalCtx); 1563 mpt_deregister(mptspiInternalCtx);
1575 mpt_deregister(mptspiTaskCtx); 1564 mpt_deregister(mptspiTaskCtx);
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index 988c8ce47f58..50b2c7334410 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -159,7 +159,7 @@ static int i2o_block_device_flush(struct i2o_device *dev)
159 * Returns 0 on success or negative error code on failure. 159 * Returns 0 on success or negative error code on failure.
160 */ 160 */
161 161
162static int i2o_block_issue_flush(request_queue_t * queue, struct gendisk *disk, 162static int i2o_block_issue_flush(struct request_queue * queue, struct gendisk *disk,
163 sector_t * error_sector) 163 sector_t * error_sector)
164{ 164{
165 struct i2o_block_device *i2o_blk_dev = queue->queuedata; 165 struct i2o_block_device *i2o_blk_dev = queue->queuedata;
@@ -445,7 +445,7 @@ static void i2o_block_end_request(struct request *req, int uptodate,
445{ 445{
446 struct i2o_block_request *ireq = req->special; 446 struct i2o_block_request *ireq = req->special;
447 struct i2o_block_device *dev = ireq->i2o_blk_dev; 447 struct i2o_block_device *dev = ireq->i2o_blk_dev;
448 request_queue_t *q = req->q; 448 struct request_queue *q = req->q;
449 unsigned long flags; 449 unsigned long flags;
450 450
451 if (end_that_request_chunk(req, uptodate, nr_bytes)) { 451 if (end_that_request_chunk(req, uptodate, nr_bytes)) {
@@ -744,7 +744,7 @@ static int i2o_block_transfer(struct request *req)
744{ 744{
745 struct i2o_block_device *dev = req->rq_disk->private_data; 745 struct i2o_block_device *dev = req->rq_disk->private_data;
746 struct i2o_controller *c; 746 struct i2o_controller *c;
747 int tid = dev->i2o_dev->lct_data.tid; 747 u32 tid = dev->i2o_dev->lct_data.tid;
748 struct i2o_message *msg; 748 struct i2o_message *msg;
749 u32 *mptr; 749 u32 *mptr;
750 struct i2o_block_request *ireq = req->special; 750 struct i2o_block_request *ireq = req->special;
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c
index f75306059971..d0fc4fd212e6 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/misc/asus-laptop.c
@@ -53,7 +53,6 @@
53#define ASUS_HOTK_NAME "Asus Laptop Support" 53#define ASUS_HOTK_NAME "Asus Laptop Support"
54#define ASUS_HOTK_CLASS "hotkey" 54#define ASUS_HOTK_CLASS "hotkey"
55#define ASUS_HOTK_DEVICE_NAME "Hotkey" 55#define ASUS_HOTK_DEVICE_NAME "Hotkey"
56#define ASUS_HOTK_HID "ATK0100"
57#define ASUS_HOTK_FILE "asus-laptop" 56#define ASUS_HOTK_FILE "asus-laptop"
58#define ASUS_HOTK_PREFIX "\\_SB.ATKD." 57#define ASUS_HOTK_PREFIX "\\_SB.ATKD."
59 58
@@ -197,12 +196,18 @@ static struct asus_hotk *hotk;
197/* 196/*
198 * The hotkey driver declaration 197 * The hotkey driver declaration
199 */ 198 */
199static const struct acpi_device_id asus_device_ids[] = {
200 {"ATK0100", 0},
201 {"", 0},
202};
203MODULE_DEVICE_TABLE(acpi, asus_device_ids);
204
200static int asus_hotk_add(struct acpi_device *device); 205static int asus_hotk_add(struct acpi_device *device);
201static int asus_hotk_remove(struct acpi_device *device, int type); 206static int asus_hotk_remove(struct acpi_device *device, int type);
202static struct acpi_driver asus_hotk_driver = { 207static struct acpi_driver asus_hotk_driver = {
203 .name = ASUS_HOTK_NAME, 208 .name = ASUS_HOTK_NAME,
204 .class = ASUS_HOTK_CLASS, 209 .class = ASUS_HOTK_CLASS,
205 .ids = ASUS_HOTK_HID, 210 .ids = asus_device_ids,
206 .ops = { 211 .ops = {
207 .add = asus_hotk_add, 212 .add = asus_hotk_add,
208 .remove = asus_hotk_remove, 213 .remove = asus_hotk_remove,
@@ -1067,19 +1072,16 @@ static void asus_backlight_exit(void)
1067} 1072}
1068 1073
1069#define ASUS_LED_UNREGISTER(object) \ 1074#define ASUS_LED_UNREGISTER(object) \
1070 if(object##_led.class_dev \ 1075 led_classdev_unregister(&object##_led)
1071 && !IS_ERR(object##_led.class_dev)) \
1072 led_classdev_unregister(&object##_led)
1073 1076
1074static void asus_led_exit(void) 1077static void asus_led_exit(void)
1075{ 1078{
1079 destroy_workqueue(led_workqueue);
1076 ASUS_LED_UNREGISTER(mled); 1080 ASUS_LED_UNREGISTER(mled);
1077 ASUS_LED_UNREGISTER(tled); 1081 ASUS_LED_UNREGISTER(tled);
1078 ASUS_LED_UNREGISTER(pled); 1082 ASUS_LED_UNREGISTER(pled);
1079 ASUS_LED_UNREGISTER(rled); 1083 ASUS_LED_UNREGISTER(rled);
1080 ASUS_LED_UNREGISTER(gled); 1084 ASUS_LED_UNREGISTER(gled);
1081
1082 destroy_workqueue(led_workqueue);
1083} 1085}
1084 1086
1085static void __exit asus_laptop_exit(void) 1087static void __exit asus_laptop_exit(void)
@@ -1135,29 +1137,42 @@ static int asus_led_init(struct device *dev)
1135 1137
1136 rv = ASUS_LED_REGISTER(mled, dev); 1138 rv = ASUS_LED_REGISTER(mled, dev);
1137 if (rv) 1139 if (rv)
1138 return rv; 1140 goto out;
1139 1141
1140 rv = ASUS_LED_REGISTER(tled, dev); 1142 rv = ASUS_LED_REGISTER(tled, dev);
1141 if (rv) 1143 if (rv)
1142 return rv; 1144 goto out1;
1143 1145
1144 rv = ASUS_LED_REGISTER(rled, dev); 1146 rv = ASUS_LED_REGISTER(rled, dev);
1145 if (rv) 1147 if (rv)
1146 return rv; 1148 goto out2;
1147 1149
1148 rv = ASUS_LED_REGISTER(pled, dev); 1150 rv = ASUS_LED_REGISTER(pled, dev);
1149 if (rv) 1151 if (rv)
1150 return rv; 1152 goto out3;
1151 1153
1152 rv = ASUS_LED_REGISTER(gled, dev); 1154 rv = ASUS_LED_REGISTER(gled, dev);
1153 if (rv) 1155 if (rv)
1154 return rv; 1156 goto out4;
1155 1157
1156 led_workqueue = create_singlethread_workqueue("led_workqueue"); 1158 led_workqueue = create_singlethread_workqueue("led_workqueue");
1157 if (!led_workqueue) 1159 if (!led_workqueue)
1158 return -ENOMEM; 1160 goto out5;
1159 1161
1160 return 0; 1162 return 0;
1163out5:
1164 rv = -ENOMEM;
1165 ASUS_LED_UNREGISTER(gled);
1166out4:
1167 ASUS_LED_UNREGISTER(pled);
1168out3:
1169 ASUS_LED_UNREGISTER(rled);
1170out2:
1171 ASUS_LED_UNREGISTER(tled);
1172out1:
1173 ASUS_LED_UNREGISTER(mled);
1174out:
1175 return rv;
1161} 1176}
1162 1177
1163static int __init asus_laptop_init(void) 1178static int __init asus_laptop_init(void)
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index 303e48ca0e8a..14ee06c8f127 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -1124,10 +1124,22 @@ static int sony_nc_remove(struct acpi_device *device, int type)
1124 return 0; 1124 return 0;
1125} 1125}
1126 1126
1127static const struct acpi_device_id sony_device_ids[] = {
1128 {SONY_NC_HID, 0},
1129 {SONY_PIC_HID, 0},
1130 {"", 0},
1131};
1132MODULE_DEVICE_TABLE(acpi, sony_device_ids);
1133
1134static const struct acpi_device_id sony_nc_device_ids[] = {
1135 {SONY_NC_HID, 0},
1136 {"", 0},
1137};
1138
1127static struct acpi_driver sony_nc_driver = { 1139static struct acpi_driver sony_nc_driver = {
1128 .name = SONY_NC_DRIVER_NAME, 1140 .name = SONY_NC_DRIVER_NAME,
1129 .class = SONY_NC_CLASS, 1141 .class = SONY_NC_CLASS,
1130 .ids = SONY_NC_HID, 1142 .ids = sony_nc_device_ids,
1131 .owner = THIS_MODULE, 1143 .owner = THIS_MODULE,
1132 .ops = { 1144 .ops = {
1133 .add = sony_nc_add, 1145 .add = sony_nc_add,
@@ -2470,10 +2482,15 @@ static int sony_pic_resume(struct acpi_device *device)
2470 return 0; 2482 return 0;
2471} 2483}
2472 2484
2485static const struct acpi_device_id sony_pic_device_ids[] = {
2486 {SONY_PIC_HID, 0},
2487 {"", 0},
2488};
2489
2473static struct acpi_driver sony_pic_driver = { 2490static struct acpi_driver sony_pic_driver = {
2474 .name = SONY_PIC_DRIVER_NAME, 2491 .name = SONY_PIC_DRIVER_NAME,
2475 .class = SONY_PIC_CLASS, 2492 .class = SONY_PIC_CLASS,
2476 .ids = SONY_PIC_HID, 2493 .ids = sony_pic_device_ids,
2477 .owner = THIS_MODULE, 2494 .owner = THIS_MODULE,
2478 .ops = { 2495 .ops = {
2479 .add = sony_pic_add, 2496 .add = sony_pic_add,
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index f15a58f7403f..fa80f355e522 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -411,12 +411,13 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
411 411
412 sprintf(ibm->acpi->driver->name, "%s_%s", IBM_NAME, ibm->name); 412 sprintf(ibm->acpi->driver->name, "%s_%s", IBM_NAME, ibm->name);
413 ibm->acpi->driver->ids = ibm->acpi->hid; 413 ibm->acpi->driver->ids = ibm->acpi->hid;
414
414 ibm->acpi->driver->ops.add = &tpacpi_device_add; 415 ibm->acpi->driver->ops.add = &tpacpi_device_add;
415 416
416 rc = acpi_bus_register_driver(ibm->acpi->driver); 417 rc = acpi_bus_register_driver(ibm->acpi->driver);
417 if (rc < 0) { 418 if (rc < 0) {
418 printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n", 419 printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
419 ibm->acpi->hid, rc); 420 ibm->name, rc);
420 kfree(ibm->acpi->driver); 421 kfree(ibm->acpi->driver);
421 ibm->acpi->driver = NULL; 422 ibm->acpi->driver = NULL;
422 } else if (!rc) 423 } else if (!rc)
@@ -1316,8 +1317,13 @@ errexit:
1316 return res; 1317 return res;
1317} 1318}
1318 1319
1320static const struct acpi_device_id ibm_htk_device_ids[] = {
1321 {IBM_HKEY_HID, 0},
1322 {"", 0},
1323};
1324
1319static struct tp_acpi_drv_struct ibm_hotkey_acpidriver = { 1325static struct tp_acpi_drv_struct ibm_hotkey_acpidriver = {
1320 .hid = IBM_HKEY_HID, 1326 .hid = ibm_htk_device_ids,
1321 .notify = hotkey_notify, 1327 .notify = hotkey_notify,
1322 .handle = &hkey_handle, 1328 .handle = &hkey_handle,
1323 .type = ACPI_DEVICE_NOTIFY, 1329 .type = ACPI_DEVICE_NOTIFY,
@@ -2080,6 +2086,11 @@ IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */
2080/* don't list other alternatives as we install a notify handler on the 570 */ 2086/* don't list other alternatives as we install a notify handler on the 570 */
2081IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */ 2087IBM_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */
2082 2088
2089static const struct acpi_device_id ibm_pci_device_ids[] = {
2090 {PCI_ROOT_HID_STRING, 0},
2091 {"", 0},
2092};
2093
2083static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = { 2094static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
2084 { 2095 {
2085 .notify = dock_notify, 2096 .notify = dock_notify,
@@ -2090,7 +2101,7 @@ static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
2090 /* THIS ONE MUST NEVER BE USED FOR DRIVER AUTOLOADING. 2101 /* THIS ONE MUST NEVER BE USED FOR DRIVER AUTOLOADING.
2091 * We just use it to get notifications of dock hotplug 2102 * We just use it to get notifications of dock hotplug
2092 * in very old thinkpads */ 2103 * in very old thinkpads */
2093 .hid = PCI_ROOT_HID_STRING, 2104 .hid = ibm_pci_device_ids,
2094 .notify = dock_notify, 2105 .notify = dock_notify,
2095 .handle = &pci_handle, 2106 .handle = &pci_handle,
2096 .type = ACPI_SYSTEM_NOTIFY, 2107 .type = ACPI_SYSTEM_NOTIFY,
@@ -2149,7 +2160,8 @@ static int __init dock_init2(struct ibm_init_struct *iibm)
2149static void dock_notify(struct ibm_struct *ibm, u32 event) 2160static void dock_notify(struct ibm_struct *ibm, u32 event)
2150{ 2161{
2151 int docked = dock_docked(); 2162 int docked = dock_docked();
2152 int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, PCI_ROOT_HID_STRING); 2163 int pci = ibm->acpi->hid && ibm->acpi->device &&
2164 acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids);
2153 2165
2154 if (event == 1 && !pci) /* 570 */ 2166 if (event == 1 && !pci) /* 570 */
2155 acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */ 2167 acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index b7a4a888cc8b..88af089d6494 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -193,7 +193,7 @@ static void thinkpad_acpi_module_exit(void);
193struct ibm_struct; 193struct ibm_struct;
194 194
195struct tp_acpi_drv_struct { 195struct tp_acpi_drv_struct {
196 char *hid; 196 const struct acpi_device_id *hid;
197 struct acpi_driver *driver; 197 struct acpi_driver *driver;
198 198
199 void (*notify) (struct ibm_struct *, u32); 199 void (*notify) (struct ibm_struct *, u32);
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index b53dac8d1b69..c9a289c6c139 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/queue.c 2 * linux/drivers/mmc/card/queue.c
3 * 3 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved. 4 * Copyright (C) 2003 Russell King, All Rights Reserved.
5 * Copyright 2006-2007 Pierre Ossman 5 * Copyright 2006-2007 Pierre Ossman
@@ -83,7 +83,7 @@ static int mmc_queue_thread(void *d)
83 * on any queue on this host, and attempt to issue it. This may 83 * on any queue on this host, and attempt to issue it. This may
84 * not be the queue we were asked to process. 84 * not be the queue we were asked to process.
85 */ 85 */
86static void mmc_request(request_queue_t *q) 86static void mmc_request(struct request_queue *q)
87{ 87{
88 struct mmc_queue *mq = q->queuedata; 88 struct mmc_queue *mq = q->queuedata;
89 struct request *req; 89 struct request *req;
@@ -211,7 +211,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
211 211
212void mmc_cleanup_queue(struct mmc_queue *mq) 212void mmc_cleanup_queue(struct mmc_queue *mq)
213{ 213{
214 request_queue_t *q = mq->queue; 214 struct request_queue *q = mq->queue;
215 unsigned long flags; 215 unsigned long flags;
216 216
217 /* Mark that we should start throwing out stragglers */ 217 /* Mark that we should start throwing out stragglers */
@@ -252,7 +252,7 @@ EXPORT_SYMBOL(mmc_cleanup_queue);
252 */ 252 */
253void mmc_queue_suspend(struct mmc_queue *mq) 253void mmc_queue_suspend(struct mmc_queue *mq)
254{ 254{
255 request_queue_t *q = mq->queue; 255 struct request_queue *q = mq->queue;
256 unsigned long flags; 256 unsigned long flags;
257 257
258 if (!(mq->flags & MMC_QUEUE_SUSPENDED)) { 258 if (!(mq->flags & MMC_QUEUE_SUSPENDED)) {
@@ -272,7 +272,7 @@ void mmc_queue_suspend(struct mmc_queue *mq)
272 */ 272 */
273void mmc_queue_resume(struct mmc_queue *mq) 273void mmc_queue_resume(struct mmc_queue *mq)
274{ 274{
275 request_queue_t *q = mq->queue; 275 struct request_queue *q = mq->queue;
276 unsigned long flags; 276 unsigned long flags;
277 277
278 if (mq->flags & MMC_QUEUE_SUSPENDED) { 278 if (mq->flags & MMC_QUEUE_SUSPENDED) {
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 348b566bf4fd..fe0e785ed7d2 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -209,10 +209,30 @@ struct mmc_card *mmc_alloc_card(struct mmc_host *host)
209int mmc_add_card(struct mmc_card *card) 209int mmc_add_card(struct mmc_card *card)
210{ 210{
211 int ret; 211 int ret;
212 const char *type;
212 213
213 snprintf(card->dev.bus_id, sizeof(card->dev.bus_id), 214 snprintf(card->dev.bus_id, sizeof(card->dev.bus_id),
214 "%s:%04x", mmc_hostname(card->host), card->rca); 215 "%s:%04x", mmc_hostname(card->host), card->rca);
215 216
217 switch (card->type) {
218 case MMC_TYPE_MMC:
219 type = "MMC";
220 break;
221 case MMC_TYPE_SD:
222 type = "SD";
223 if (mmc_card_blockaddr(card))
224 type = "SDHC";
225 break;
226 default:
227 type = "?";
228 break;
229 }
230
231 printk(KERN_INFO "%s: new %s%s card at address %04x\n",
232 mmc_hostname(card->host),
233 mmc_card_highspeed(card) ? "high speed " : "",
234 type, card->rca);
235
216 card->dev.uevent_suppress = 1; 236 card->dev.uevent_suppress = 1;
217 237
218 ret = device_add(&card->dev); 238 ret = device_add(&card->dev);
@@ -243,6 +263,9 @@ int mmc_add_card(struct mmc_card *card)
243void mmc_remove_card(struct mmc_card *card) 263void mmc_remove_card(struct mmc_card *card)
244{ 264{
245 if (mmc_card_present(card)) { 265 if (mmc_card_present(card)) {
266 printk(KERN_INFO "%s: card %04x removed\n",
267 mmc_hostname(card->host), card->rca);
268
246 if (card->host->bus_ops->sysfs_remove) 269 if (card->host->bus_ops->sysfs_remove)
247 card->host->bus_ops->sysfs_remove(card->host, card); 270 card->host->bus_ops->sysfs_remove(card->host, card);
248 device_del(&card->dev); 271 device_del(&card->dev);
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index b5d8a6d90cca..bfd2ae5bd669 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -68,32 +68,41 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
68 struct mmc_command *cmd = mrq->cmd; 68 struct mmc_command *cmd = mrq->cmd;
69 int err = cmd->error; 69 int err = cmd->error;
70 70
71 pr_debug("%s: req done (CMD%u): %d/%d/%d: %08x %08x %08x %08x\n",
72 mmc_hostname(host), cmd->opcode, err,
73 mrq->data ? mrq->data->error : 0,
74 mrq->stop ? mrq->stop->error : 0,
75 cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]);
76
77 if (err && cmd->retries) { 71 if (err && cmd->retries) {
72 pr_debug("%s: req failed (CMD%u): %d, retrying...\n",
73 mmc_hostname(host), cmd->opcode, err);
74
78 cmd->retries--; 75 cmd->retries--;
79 cmd->error = 0; 76 cmd->error = 0;
80 host->ops->request(host, mrq); 77 host->ops->request(host, mrq);
81 } else if (mrq->done) { 78 } else {
82 mrq->done(mrq); 79 pr_debug("%s: req done (CMD%u): %d: %08x %08x %08x %08x\n",
80 mmc_hostname(host), cmd->opcode, err,
81 cmd->resp[0], cmd->resp[1],
82 cmd->resp[2], cmd->resp[3]);
83
84 if (mrq->data) {
85 pr_debug("%s: %d bytes transferred: %d\n",
86 mmc_hostname(host),
87 mrq->data->bytes_xfered, mrq->data->error);
88 }
89
90 if (mrq->stop) {
91 pr_debug("%s: (CMD%u): %d: %08x %08x %08x %08x\n",
92 mmc_hostname(host), mrq->stop->opcode,
93 mrq->stop->error,
94 mrq->stop->resp[0], mrq->stop->resp[1],
95 mrq->stop->resp[2], mrq->stop->resp[3]);
96 }
97
98 if (mrq->done)
99 mrq->done(mrq);
83 } 100 }
84} 101}
85 102
86EXPORT_SYMBOL(mmc_request_done); 103EXPORT_SYMBOL(mmc_request_done);
87 104
88/** 105static void
89 * mmc_start_request - start a command on a host
90 * @host: MMC host to start command on
91 * @mrq: MMC request to start
92 *
93 * Queue a command on the specified host. We expect the
94 * caller to be holding the host lock with interrupts disabled.
95 */
96void
97mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) 106mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
98{ 107{
99#ifdef CONFIG_MMC_DEBUG 108#ifdef CONFIG_MMC_DEBUG
@@ -104,6 +113,21 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
104 mmc_hostname(host), mrq->cmd->opcode, 113 mmc_hostname(host), mrq->cmd->opcode,
105 mrq->cmd->arg, mrq->cmd->flags); 114 mrq->cmd->arg, mrq->cmd->flags);
106 115
116 if (mrq->data) {
117 pr_debug("%s: blksz %d blocks %d flags %08x "
118 "tsac %d ms nsac %d\n",
119 mmc_hostname(host), mrq->data->blksz,
120 mrq->data->blocks, mrq->data->flags,
121 mrq->data->timeout_ns / 10000000,
122 mrq->data->timeout_clks);
123 }
124
125 if (mrq->stop) {
126 pr_debug("%s: CMD%u arg %08x flags %08x\n",
127 mmc_hostname(host), mrq->stop->opcode,
128 mrq->stop->arg, mrq->stop->flags);
129 }
130
107 WARN_ON(!host->claimed); 131 WARN_ON(!host->claimed);
108 132
109 mrq->cmd->error = 0; 133 mrq->cmd->error = 0;
@@ -133,14 +157,21 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
133 host->ops->request(host, mrq); 157 host->ops->request(host, mrq);
134} 158}
135 159
136EXPORT_SYMBOL(mmc_start_request);
137
138static void mmc_wait_done(struct mmc_request *mrq) 160static void mmc_wait_done(struct mmc_request *mrq)
139{ 161{
140 complete(mrq->done_data); 162 complete(mrq->done_data);
141} 163}
142 164
143int mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq) 165/**
166 * mmc_wait_for_req - start a request and wait for completion
167 * @host: MMC host to start command
168 * @mrq: MMC request to start
169 *
170 * Start a new MMC custom command request for a host, and wait
171 * for the command to complete. Does not attempt to parse the
172 * response.
173 */
174void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
144{ 175{
145 DECLARE_COMPLETION_ONSTACK(complete); 176 DECLARE_COMPLETION_ONSTACK(complete);
146 177
@@ -150,8 +181,6 @@ int mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
150 mmc_start_request(host, mrq); 181 mmc_start_request(host, mrq);
151 182
152 wait_for_completion(&complete); 183 wait_for_completion(&complete);
153
154 return 0;
155} 184}
156 185
157EXPORT_SYMBOL(mmc_wait_for_req); 186EXPORT_SYMBOL(mmc_wait_for_req);
@@ -192,6 +221,9 @@ EXPORT_SYMBOL(mmc_wait_for_cmd);
192 * @data: data phase for command 221 * @data: data phase for command
193 * @card: the MMC card associated with the data transfer 222 * @card: the MMC card associated with the data transfer
194 * @write: flag to differentiate reads from writes 223 * @write: flag to differentiate reads from writes
224 *
225 * Computes the data timeout parameters according to the
226 * correct algorithm given the card type.
195 */ 227 */
196void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card, 228void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card,
197 int write) 229 int write)
@@ -240,21 +272,18 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card,
240EXPORT_SYMBOL(mmc_set_data_timeout); 272EXPORT_SYMBOL(mmc_set_data_timeout);
241 273
242/** 274/**
243 * __mmc_claim_host - exclusively claim a host 275 * mmc_claim_host - exclusively claim a host
244 * @host: mmc host to claim 276 * @host: mmc host to claim
245 * @card: mmc card to claim host for
246 *
247 * Claim a host for a set of operations. If a valid card
248 * is passed and this wasn't the last card selected, select
249 * the card before returning.
250 * 277 *
251 * Note: you should use mmc_card_claim_host or mmc_claim_host. 278 * Claim a host for a set of operations.
252 */ 279 */
253void mmc_claim_host(struct mmc_host *host) 280void mmc_claim_host(struct mmc_host *host)
254{ 281{
255 DECLARE_WAITQUEUE(wait, current); 282 DECLARE_WAITQUEUE(wait, current);
256 unsigned long flags; 283 unsigned long flags;
257 284
285 might_sleep();
286
258 add_wait_queue(&host->wq, &wait); 287 add_wait_queue(&host->wq, &wait);
259 spin_lock_irqsave(&host->lock, flags); 288 spin_lock_irqsave(&host->lock, flags);
260 while (1) { 289 while (1) {
@@ -433,6 +462,45 @@ static void mmc_power_off(struct mmc_host *host)
433} 462}
434 463
435/* 464/*
465 * Cleanup when the last reference to the bus operator is dropped.
466 */
467void __mmc_release_bus(struct mmc_host *host)
468{
469 BUG_ON(!host);
470 BUG_ON(host->bus_refs);
471 BUG_ON(!host->bus_dead);
472
473 host->bus_ops = NULL;
474}
475
476/*
477 * Increase reference count of bus operator
478 */
479static inline void mmc_bus_get(struct mmc_host *host)
480{
481 unsigned long flags;
482
483 spin_lock_irqsave(&host->lock, flags);
484 host->bus_refs++;
485 spin_unlock_irqrestore(&host->lock, flags);
486}
487
488/*
489 * Decrease reference count of bus operator and free it if
490 * it is the last reference.
491 */
492static inline void mmc_bus_put(struct mmc_host *host)
493{
494 unsigned long flags;
495
496 spin_lock_irqsave(&host->lock, flags);
497 host->bus_refs--;
498 if ((host->bus_refs == 0) && host->bus_ops)
499 __mmc_release_bus(host);
500 spin_unlock_irqrestore(&host->lock, flags);
501}
502
503/*
436 * Assign a mmc bus handler to a host. Only one bus handler may control a 504 * Assign a mmc bus handler to a host. Only one bus handler may control a
437 * host at any given time. 505 * host at any given time.
438 */ 506 */
@@ -481,25 +549,15 @@ void mmc_detach_bus(struct mmc_host *host)
481 mmc_bus_put(host); 549 mmc_bus_put(host);
482} 550}
483 551
484/*
485 * Cleanup when the last reference to the bus operator is dropped.
486 */
487void __mmc_release_bus(struct mmc_host *host)
488{
489 BUG_ON(!host);
490 BUG_ON(host->bus_refs);
491 BUG_ON(!host->bus_dead);
492
493 host->bus_ops = NULL;
494}
495
496/** 552/**
497 * mmc_detect_change - process change of state on a MMC socket 553 * mmc_detect_change - process change of state on a MMC socket
498 * @host: host which changed state. 554 * @host: host which changed state.
499 * @delay: optional delay to wait before detection (jiffies) 555 * @delay: optional delay to wait before detection (jiffies)
500 * 556 *
501 * All we know is that card(s) have been inserted or removed 557 * MMC drivers should call this when they detect a card has been
502 * from the socket(s). We don't know which socket or cards. 558 * inserted or removed. The MMC layer will confirm that any
559 * present card is still functional, and initialize any newly
560 * inserted.
503 */ 561 */
504void mmc_detect_change(struct mmc_host *host, unsigned long delay) 562void mmc_detect_change(struct mmc_host *host, unsigned long delay)
505{ 563{
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index ae006b30dd86..bb2774af9ea9 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -27,28 +27,6 @@ struct mmc_bus_ops {
27void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops); 27void mmc_attach_bus(struct mmc_host *host, const struct mmc_bus_ops *ops);
28void mmc_detach_bus(struct mmc_host *host); 28void mmc_detach_bus(struct mmc_host *host);
29 29
30void __mmc_release_bus(struct mmc_host *host);
31
32static inline void mmc_bus_get(struct mmc_host *host)
33{
34 unsigned long flags;
35
36 spin_lock_irqsave(&host->lock, flags);
37 host->bus_refs++;
38 spin_unlock_irqrestore(&host->lock, flags);
39}
40
41static inline void mmc_bus_put(struct mmc_host *host)
42{
43 unsigned long flags;
44
45 spin_lock_irqsave(&host->lock, flags);
46 host->bus_refs--;
47 if ((host->bus_refs == 0) && host->bus_ops)
48 __mmc_release_bus(host);
49 spin_unlock_irqrestore(&host->lock, flags);
50}
51
52void mmc_set_chip_select(struct mmc_host *host, int mode); 30void mmc_set_chip_select(struct mmc_host *host, int mode);
53void mmc_set_clock(struct mmc_host *host, unsigned int hz); 31void mmc_set_clock(struct mmc_host *host, unsigned int hz);
54void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); 32void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode);
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 1433d95c40bb..6a7e29849603 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -93,6 +93,10 @@ EXPORT_SYMBOL(mmc_alloc_host);
93/** 93/**
94 * mmc_add_host - initialise host hardware 94 * mmc_add_host - initialise host hardware
95 * @host: mmc host 95 * @host: mmc host
96 *
97 * Register the host with the driver model. The host must be
98 * prepared to start servicing requests before this function
99 * completes.
96 */ 100 */
97int mmc_add_host(struct mmc_host *host) 101int mmc_add_host(struct mmc_host *host)
98{ 102{
@@ -126,7 +130,8 @@ EXPORT_SYMBOL(mmc_add_host);
126 * @host: mmc host 130 * @host: mmc host
127 * 131 *
128 * Unregister and remove all cards associated with this host, 132 * Unregister and remove all cards associated with this host,
129 * and power down the MMC bus. 133 * and power down the MMC bus. No new requests will be issued
134 * after this function has returned.
130 */ 135 */
131void mmc_remove_host(struct mmc_host *host) 136void mmc_remove_host(struct mmc_host *host)
132{ 137{
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 66f85bfa8dbb..21d7f48e1d4e 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/mmc.c 2 * linux/drivers/mmc/core/mmc.c
3 * 3 *
4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved. 4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved.
5 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved. 5 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
@@ -100,7 +100,7 @@ static int mmc_decode_cid(struct mmc_card *card)
100 break; 100 break;
101 101
102 default: 102 default:
103 printk("%s: card has unknown MMCA version %d\n", 103 printk(KERN_ERR "%s: card has unknown MMCA version %d\n",
104 mmc_hostname(card->host), card->csd.mmca_vsn); 104 mmc_hostname(card->host), card->csd.mmca_vsn);
105 return -EINVAL; 105 return -EINVAL;
106 } 106 }
@@ -123,7 +123,7 @@ static int mmc_decode_csd(struct mmc_card *card)
123 */ 123 */
124 csd_struct = UNSTUFF_BITS(resp, 126, 2); 124 csd_struct = UNSTUFF_BITS(resp, 126, 2);
125 if (csd_struct != 1 && csd_struct != 2) { 125 if (csd_struct != 1 && csd_struct != 2) {
126 printk("%s: unrecognised CSD structure version %d\n", 126 printk(KERN_ERR "%s: unrecognised CSD structure version %d\n",
127 mmc_hostname(card->host), csd_struct); 127 mmc_hostname(card->host), csd_struct);
128 return -EINVAL; 128 return -EINVAL;
129 } 129 }
@@ -499,14 +499,17 @@ static void mmc_resume(struct mmc_host *host)
499 BUG_ON(!host->card); 499 BUG_ON(!host->card);
500 500
501 mmc_claim_host(host); 501 mmc_claim_host(host);
502
503 err = mmc_init_card(host, host->ocr, host->card); 502 err = mmc_init_card(host, host->ocr, host->card);
503 mmc_release_host(host);
504
504 if (err != MMC_ERR_NONE) { 505 if (err != MMC_ERR_NONE) {
505 mmc_remove(host); 506 mmc_remove(host);
507
508 mmc_claim_host(host);
506 mmc_detach_bus(host); 509 mmc_detach_bus(host);
510 mmc_release_host(host);
507 } 511 }
508 512
509 mmc_release_host(host);
510} 513}
511 514
512#else 515#else
@@ -553,8 +556,10 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
553 /* 556 /*
554 * Can we support the voltage of the card? 557 * Can we support the voltage of the card?
555 */ 558 */
556 if (!host->ocr) 559 if (!host->ocr) {
560 err = -EINVAL;
557 goto err; 561 goto err;
562 }
558 563
559 /* 564 /*
560 * Detect and init the card. 565 * Detect and init the card.
@@ -567,18 +572,21 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
567 572
568 err = mmc_add_card(host->card); 573 err = mmc_add_card(host->card);
569 if (err) 574 if (err)
570 goto reclaim_host; 575 goto remove_card;
571 576
572 return 0; 577 return 0;
573 578
574reclaim_host: 579remove_card:
575 mmc_claim_host(host);
576 mmc_remove_card(host->card); 580 mmc_remove_card(host->card);
577 host->card = NULL; 581 host->card = NULL;
582 mmc_claim_host(host);
578err: 583err:
579 mmc_detach_bus(host); 584 mmc_detach_bus(host);
580 mmc_release_host(host); 585 mmc_release_host(host);
581 586
587 printk(KERN_ERR "%s: error %d whilst initialising MMC card\n",
588 mmc_hostname(host), err);
589
582 return 0; 590 return 0;
583} 591}
584 592
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 7dd720fa5895..913e75f00843 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/mmc_ops.h 2 * linux/drivers/mmc/core/mmc_ops.h
3 * 3 *
4 * Copyright 2006-2007 Pierre Ossman 4 * Copyright 2006-2007 Pierre Ossman
5 * 5 *
diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h
index 7a481e8ca5ea..76d09a93c5d6 100644
--- a/drivers/mmc/core/mmc_ops.h
+++ b/drivers/mmc/core/mmc_ops.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/mmc_ops.h 2 * linux/drivers/mmc/core/mmc_ops.h
3 * 3 *
4 * Copyright 2006-2007 Pierre Ossman 4 * Copyright 2006-2007 Pierre Ossman
5 * 5 *
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 1240684083f1..1edc62b1e5c6 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/sd.c 2 * linux/drivers/mmc/core/sd.c
3 * 3 *
4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved. 4 * Copyright (C) 2003-2004 Russell King, All Rights Reserved.
5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved. 5 * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved.
@@ -149,7 +149,7 @@ static int mmc_decode_csd(struct mmc_card *card)
149 csd->write_partial = 0; 149 csd->write_partial = 0;
150 break; 150 break;
151 default: 151 default:
152 printk("%s: unrecognised CSD structure version %d\n", 152 printk(KERN_ERR "%s: unrecognised CSD structure version %d\n",
153 mmc_hostname(card->host), csd_struct); 153 mmc_hostname(card->host), csd_struct);
154 return -EINVAL; 154 return -EINVAL;
155 } 155 }
@@ -173,7 +173,7 @@ static int mmc_decode_scr(struct mmc_card *card)
173 173
174 scr_struct = UNSTUFF_BITS(resp, 60, 4); 174 scr_struct = UNSTUFF_BITS(resp, 60, 4);
175 if (scr_struct != 0) { 175 if (scr_struct != 0) {
176 printk("%s: unrecognised SCR structure version %d\n", 176 printk(KERN_ERR "%s: unrecognised SCR structure version %d\n",
177 mmc_hostname(card->host), scr_struct); 177 mmc_hostname(card->host), scr_struct);
178 return -EINVAL; 178 return -EINVAL;
179 } 179 }
@@ -206,9 +206,8 @@ static int mmc_read_switch(struct mmc_card *card)
206 206
207 status = kmalloc(64, GFP_KERNEL); 207 status = kmalloc(64, GFP_KERNEL);
208 if (!status) { 208 if (!status) {
209 printk("%s: could not allocate a buffer for switch " 209 printk(KERN_ERR "%s: could not allocate a buffer for "
210 "capabilities.\n", 210 "switch capabilities.\n", mmc_hostname(card->host));
211 mmc_hostname(card->host));
212 return err; 211 return err;
213 } 212 }
214 213
@@ -254,9 +253,8 @@ static int mmc_switch_hs(struct mmc_card *card)
254 253
255 status = kmalloc(64, GFP_KERNEL); 254 status = kmalloc(64, GFP_KERNEL);
256 if (!status) { 255 if (!status) {
257 printk("%s: could not allocate a buffer for switch " 256 printk(KERN_ERR "%s: could not allocate a buffer for "
258 "capabilities.\n", 257 "switch capabilities.\n", mmc_hostname(card->host));
259 mmc_hostname(card->host));
260 return err; 258 return err;
261 } 259 }
262 260
@@ -573,14 +571,17 @@ static void mmc_sd_resume(struct mmc_host *host)
573 BUG_ON(!host->card); 571 BUG_ON(!host->card);
574 572
575 mmc_claim_host(host); 573 mmc_claim_host(host);
576
577 err = mmc_sd_init_card(host, host->ocr, host->card); 574 err = mmc_sd_init_card(host, host->ocr, host->card);
575 mmc_release_host(host);
576
578 if (err != MMC_ERR_NONE) { 577 if (err != MMC_ERR_NONE) {
579 mmc_sd_remove(host); 578 mmc_sd_remove(host);
579
580 mmc_claim_host(host);
580 mmc_detach_bus(host); 581 mmc_detach_bus(host);
582 mmc_release_host(host);
581 } 583 }
582 584
583 mmc_release_host(host);
584} 585}
585 586
586#else 587#else
@@ -634,8 +635,10 @@ int mmc_attach_sd(struct mmc_host *host, u32 ocr)
634 /* 635 /*
635 * Can we support the voltage(s) of the card(s)? 636 * Can we support the voltage(s) of the card(s)?
636 */ 637 */
637 if (!host->ocr) 638 if (!host->ocr) {
639 err = -EINVAL;
638 goto err; 640 goto err;
641 }
639 642
640 /* 643 /*
641 * Detect and init the card. 644 * Detect and init the card.
@@ -648,18 +651,21 @@ int mmc_attach_sd(struct mmc_host *host, u32 ocr)
648 651
649 err = mmc_add_card(host->card); 652 err = mmc_add_card(host->card);
650 if (err) 653 if (err)
651 goto reclaim_host; 654 goto remove_card;
652 655
653 return 0; 656 return 0;
654 657
655reclaim_host: 658remove_card:
656 mmc_claim_host(host);
657 mmc_remove_card(host->card); 659 mmc_remove_card(host->card);
658 host->card = NULL; 660 host->card = NULL;
661 mmc_claim_host(host);
659err: 662err:
660 mmc_detach_bus(host); 663 mmc_detach_bus(host);
661 mmc_release_host(host); 664 mmc_release_host(host);
662 665
666 printk(KERN_ERR "%s: error %d whilst initialising SD card\n",
667 mmc_hostname(host), err);
668
663 return 0; 669 return 0;
664} 670}
665 671
diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
index 9697ce581101..342f340ebc25 100644
--- a/drivers/mmc/core/sd_ops.c
+++ b/drivers/mmc/core/sd_ops.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/sd_ops.h 2 * linux/drivers/mmc/core/sd_ops.h
3 * 3 *
4 * Copyright 2006-2007 Pierre Ossman 4 * Copyright 2006-2007 Pierre Ossman
5 * 5 *
@@ -21,11 +21,40 @@
21#include "core.h" 21#include "core.h"
22#include "sd_ops.h" 22#include "sd_ops.h"
23 23
24static int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
25{
26 int err;
27 struct mmc_command cmd;
28
29 BUG_ON(!host);
30 BUG_ON(card && (card->host != host));
31
32 cmd.opcode = MMC_APP_CMD;
33
34 if (card) {
35 cmd.arg = card->rca << 16;
36 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
37 } else {
38 cmd.arg = 0;
39 cmd.flags = MMC_RSP_R1 | MMC_CMD_BCR;
40 }
41
42 err = mmc_wait_for_cmd(host, &cmd, 0);
43 if (err != MMC_ERR_NONE)
44 return err;
45
46 /* Check that card supported application commands */
47 if (!(cmd.resp[0] & R1_APP_CMD))
48 return MMC_ERR_FAILED;
49
50 return MMC_ERR_NONE;
51}
52
24/** 53/**
25 * mmc_wait_for_app_cmd - start an application command and wait for 54 * mmc_wait_for_app_cmd - start an application command and wait for
26 completion 55 completion
27 * @host: MMC host to start command 56 * @host: MMC host to start command
28 * @rca: RCA to send MMC_APP_CMD to 57 * @card: Card to send MMC_APP_CMD to
29 * @cmd: MMC command to start 58 * @cmd: MMC command to start
30 * @retries: maximum number of retries 59 * @retries: maximum number of retries
31 * 60 *
@@ -77,35 +106,6 @@ int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card,
77 106
78EXPORT_SYMBOL(mmc_wait_for_app_cmd); 107EXPORT_SYMBOL(mmc_wait_for_app_cmd);
79 108
80int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card)
81{
82 int err;
83 struct mmc_command cmd;
84
85 BUG_ON(!host);
86 BUG_ON(card && (card->host != host));
87
88 cmd.opcode = MMC_APP_CMD;
89
90 if (card) {
91 cmd.arg = card->rca << 16;
92 cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
93 } else {
94 cmd.arg = 0;
95 cmd.flags = MMC_RSP_R1 | MMC_CMD_BCR;
96 }
97
98 err = mmc_wait_for_cmd(host, &cmd, 0);
99 if (err != MMC_ERR_NONE)
100 return err;
101
102 /* Check that card supported application commands */
103 if (!(cmd.resp[0] & R1_APP_CMD))
104 return MMC_ERR_FAILED;
105
106 return MMC_ERR_NONE;
107}
108
109int mmc_app_set_bus_width(struct mmc_card *card, int width) 109int mmc_app_set_bus_width(struct mmc_card *card, int width)
110{ 110{
111 int err; 111 int err;
diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h
index 1240fddba5e3..9742d8a30664 100644
--- a/drivers/mmc/core/sd_ops.h
+++ b/drivers/mmc/core/sd_ops.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/sd_ops.h 2 * linux/drivers/mmc/core/sd_ops.h
3 * 3 *
4 * Copyright 2006-2007 Pierre Ossman 4 * Copyright 2006-2007 Pierre Ossman
5 * 5 *
@@ -12,7 +12,6 @@
12#ifndef _MMC_SD_OPS_H 12#ifndef _MMC_SD_OPS_H
13#define _MMC_SD_OPS_H 13#define _MMC_SD_OPS_H
14 14
15int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card);
16int mmc_app_set_bus_width(struct mmc_card *card, int width); 15int mmc_app_set_bus_width(struct mmc_card *card, int width);
17int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); 16int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
18int mmc_send_if_cond(struct mmc_host *host, u32 ocr); 17int mmc_send_if_cond(struct mmc_host *host, u32 ocr);
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c
index 15aab374127e..62564ccde03a 100644
--- a/drivers/mmc/host/at91_mci.c
+++ b/drivers/mmc/host/at91_mci.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/at91_mci.c - ATMEL AT91 MCI Driver 2 * linux/drivers/mmc/host/at91_mci.c - ATMEL AT91 MCI Driver
3 * 3 *
4 * Copyright (C) 2005 Cougar Creek Computing Devices Ltd, All Rights Reserved 4 * Copyright (C) 2005 Cougar Creek Computing Devices Ltd, All Rights Reserved
5 * 5 *
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c
index 52b63f11ddd6..34c99d4ea041 100644
--- a/drivers/mmc/host/au1xmmc.c
+++ b/drivers/mmc/host/au1xmmc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/au1xmmc.c - AU1XX0 MMC driver 2 * linux/drivers/mmc/host/au1xmmc.c - AU1XX0 MMC driver
3 * 3 *
4 * Copyright (c) 2005, Advanced Micro Devices, Inc. 4 * Copyright (c) 2005, Advanced Micro Devices, Inc.
5 * 5 *
diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c
index 7ee2045acbef..54bfc9f25596 100644
--- a/drivers/mmc/host/imxmmc.c
+++ b/drivers/mmc/host/imxmmc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/imxmmc.c - Motorola i.MX MMCI driver 2 * linux/drivers/mmc/host/imxmmc.c - Motorola i.MX MMCI driver
3 * 3 *
4 * Copyright (C) 2004 Sascha Hauer, Pengutronix <sascha@saschahauer.de> 4 * Copyright (C) 2004 Sascha Hauer, Pengutronix <sascha@saschahauer.de>
5 * Copyright (C) 2006 Pavel Pisa, PiKRON <ppisa@pikron.com> 5 * Copyright (C) 2006 Pavel Pisa, PiKRON <ppisa@pikron.com>
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index d11c2d23ceea..be730c0a0352 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/mmci.c - ARM PrimeCell MMCI PL180/1 driver 2 * linux/drivers/mmc/host/mmci.c - ARM PrimeCell MMCI PL180/1 driver
3 * 3 *
4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved. 4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
5 * 5 *
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index 6d7eadc9a678..000e6a919782 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/mmci.h - ARM PrimeCell MMCI PL180/1 driver 2 * linux/drivers/mmc/host/mmci.h - ARM PrimeCell MMCI PL180/1 driver
3 * 3 *
4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved. 4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
5 * 5 *
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c
index b0824a38f425..0cf97edc5f58 100644
--- a/drivers/mmc/host/omap.c
+++ b/drivers/mmc/host/omap.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/media/mmc/omap.c 2 * linux/drivers/mmc/host/omap.c
3 * 3 *
4 * Copyright (C) 2004 Nokia Corporation 4 * Copyright (C) 2004 Nokia Corporation
5 * Written by Tuukka Tikkanen and Juha Yrjölä<juha.yrjola@nokia.com> 5 * Written by Tuukka Tikkanen and Juha Yrjölä<juha.yrjola@nokia.com>
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index f8985c508bb9..ff960334b337 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/pxa.c - PXA MMCI driver 2 * linux/drivers/mmc/host/pxa.c - PXA MMCI driver
3 * 3 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved. 4 * Copyright (C) 2003 Russell King, All Rights Reserved.
5 * 5 *
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 4a24db028d87..f2bc87ac24f7 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/sdhci.c - Secure Digital Host Controller Interface driver 2 * linux/drivers/mmc/host/sdhci.c - Secure Digital Host Controller Interface driver
3 * 3 *
4 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved. 4 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
5 * 5 *
@@ -34,6 +34,7 @@ static unsigned int debug_quirks = 0;
34/* Controller doesn't like some resets when there is no card inserted. */ 34/* Controller doesn't like some resets when there is no card inserted. */
35#define SDHCI_QUIRK_NO_CARD_NO_RESET (1<<2) 35#define SDHCI_QUIRK_NO_CARD_NO_RESET (1<<2)
36#define SDHCI_QUIRK_SINGLE_POWER_WRITE (1<<3) 36#define SDHCI_QUIRK_SINGLE_POWER_WRITE (1<<3)
37#define SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS (1<<4)
37 38
38static const struct pci_device_id pci_ids[] __devinitdata = { 39static const struct pci_device_id pci_ids[] __devinitdata = {
39 { 40 {
@@ -78,6 +79,24 @@ static const struct pci_device_id pci_ids[] __devinitdata = {
78 .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE, 79 .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE,
79 }, 80 },
80 81
82 {
83 .vendor = PCI_VENDOR_ID_ENE,
84 .device = PCI_DEVICE_ID_ENE_CB714_SD,
85 .subvendor = PCI_ANY_ID,
86 .subdevice = PCI_ANY_ID,
87 .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE |
88 SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS,
89 },
90
91 {
92 .vendor = PCI_VENDOR_ID_ENE,
93 .device = PCI_DEVICE_ID_ENE_CB714_SD_2,
94 .subvendor = PCI_ANY_ID,
95 .subdevice = PCI_ANY_ID,
96 .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE |
97 SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS,
98 },
99
81 { /* Generic SD host controller */ 100 { /* Generic SD host controller */
82 PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00) 101 PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00)
83 }, 102 },
@@ -361,11 +380,6 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
361 if (data == NULL) 380 if (data == NULL)
362 return; 381 return;
363 382
364 DBG("blksz %04x blks %04x flags %08x\n",
365 data->blksz, data->blocks, data->flags);
366 DBG("tsac %d ms nsac %d clk\n",
367 data->timeout_ns / 1000000, data->timeout_clks);
368
369 /* Sanity checks */ 383 /* Sanity checks */
370 BUG_ON(data->blksz * data->blocks > 524288); 384 BUG_ON(data->blksz * data->blocks > 524288);
371 BUG_ON(data->blksz > host->mmc->max_blk_size); 385 BUG_ON(data->blksz > host->mmc->max_blk_size);
@@ -476,8 +490,6 @@ static void sdhci_finish_data(struct sdhci_host *host)
476 data->error = MMC_ERR_FAILED; 490 data->error = MMC_ERR_FAILED;
477 } 491 }
478 492
479 DBG("Ending data transfer (%d bytes)\n", data->bytes_xfered);
480
481 if (data->stop) { 493 if (data->stop) {
482 /* 494 /*
483 * The controller needs a reset of internal state machines 495 * The controller needs a reset of internal state machines
@@ -501,8 +513,6 @@ static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
501 513
502 WARN_ON(host->cmd); 514 WARN_ON(host->cmd);
503 515
504 DBG("Sending cmd (%x)\n", cmd->opcode);
505
506 /* Wait max 10 ms */ 516 /* Wait max 10 ms */
507 timeout = 10; 517 timeout = 10;
508 518
@@ -590,8 +600,6 @@ static void sdhci_finish_command(struct sdhci_host *host)
590 600
591 host->cmd->error = MMC_ERR_NONE; 601 host->cmd->error = MMC_ERR_NONE;
592 602
593 DBG("Ending cmd (%x)\n", host->cmd->opcode);
594
595 if (host->cmd->data) 603 if (host->cmd->data)
596 host->data = host->cmd->data; 604 host->data = host->cmd->data;
597 else 605 else
@@ -759,6 +767,14 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
759 767
760 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL); 768 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
761 769
770 /*
771 * Some (ENE) controllers go apeshit on some ios operation,
772 * signalling timeout and CRC errors even on CMD0. Resetting
773 * it on each ios seems to solve the problem.
774 */
775 if(host->chip->quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS)
776 sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
777
762 mmiowb(); 778 mmiowb();
763 spin_unlock_irqrestore(&host->lock, flags); 779 spin_unlock_irqrestore(&host->lock, flags);
764} 780}
@@ -835,8 +851,6 @@ static void sdhci_tasklet_finish(unsigned long param)
835 851
836 mrq = host->mrq; 852 mrq = host->mrq;
837 853
838 DBG("Ending request, cmd (%x)\n", mrq->cmd->opcode);
839
840 /* 854 /*
841 * The controller needs a reset of internal state machines 855 * The controller needs a reset of internal state machines
842 * upon error conditions. 856 * upon error conditions.
@@ -922,20 +936,17 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
922 return; 936 return;
923 } 937 }
924 938
925 if (intmask & SDHCI_INT_RESPONSE) 939 if (intmask & SDHCI_INT_TIMEOUT)
926 sdhci_finish_command(host); 940 host->cmd->error = MMC_ERR_TIMEOUT;
927 else { 941 else if (intmask & SDHCI_INT_CRC)
928 if (intmask & SDHCI_INT_TIMEOUT) 942 host->cmd->error = MMC_ERR_BADCRC;
929 host->cmd->error = MMC_ERR_TIMEOUT; 943 else if (intmask & (SDHCI_INT_END_BIT | SDHCI_INT_INDEX))
930 else if (intmask & SDHCI_INT_CRC) 944 host->cmd->error = MMC_ERR_FAILED;
931 host->cmd->error = MMC_ERR_BADCRC;
932 else if (intmask & (SDHCI_INT_END_BIT | SDHCI_INT_INDEX))
933 host->cmd->error = MMC_ERR_FAILED;
934 else
935 host->cmd->error = MMC_ERR_INVALID;
936 945
946 if (host->cmd->error != MMC_ERR_NONE)
937 tasklet_schedule(&host->finish_tasklet); 947 tasklet_schedule(&host->finish_tasklet);
938 } 948 else if (intmask & SDHCI_INT_RESPONSE)
949 sdhci_finish_command(host);
939} 950}
940 951
941static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) 952static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index a6c870480b8a..d157776c1149 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/sdhci.h - Secure Digital Host Controller Interface driver 2 * linux/drivers/mmc/host/sdhci.h - Secure Digital Host Controller Interface driver
3 * 3 *
4 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved. 4 * Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
5 * 5 *
diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c
index 867ca6a69298..e0c9808fd424 100644
--- a/drivers/mmc/host/wbsd.c
+++ b/drivers/mmc/host/wbsd.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/wbsd.c - Winbond W83L51xD SD/MMC driver 2 * linux/drivers/mmc/host/wbsd.c - Winbond W83L51xD SD/MMC driver
3 * 3 *
4 * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved. 4 * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved.
5 * 5 *
@@ -207,8 +207,6 @@ static void wbsd_request_end(struct wbsd_host *host, struct mmc_request *mrq)
207{ 207{
208 unsigned long dmaflags; 208 unsigned long dmaflags;
209 209
210 DBGF("Ending request, cmd (%x)\n", mrq->cmd->opcode);
211
212 if (host->dma >= 0) { 210 if (host->dma >= 0) {
213 /* 211 /*
214 * Release ISA DMA controller. 212 * Release ISA DMA controller.
@@ -360,8 +358,6 @@ static void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd)
360 int i; 358 int i;
361 u8 status, isr; 359 u8 status, isr;
362 360
363 DBGF("Sending cmd (%x)\n", cmd->opcode);
364
365 /* 361 /*
366 * Clear accumulated ISR. The interrupt routine 362 * Clear accumulated ISR. The interrupt routine
367 * will fill this one with events that occur during 363 * will fill this one with events that occur during
@@ -411,8 +407,6 @@ static void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd)
411 wbsd_get_short_reply(host, cmd); 407 wbsd_get_short_reply(host, cmd);
412 } 408 }
413 } 409 }
414
415 DBGF("Sent cmd (%x), res %d\n", cmd->opcode, cmd->error);
416} 410}
417 411
418/* 412/*
@@ -550,11 +544,6 @@ static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data)
550 unsigned long dmaflags; 544 unsigned long dmaflags;
551 unsigned int size; 545 unsigned int size;
552 546
553 DBGF("blksz %04x blks %04x flags %08x\n",
554 data->blksz, data->blocks, data->flags);
555 DBGF("tsac %d ms nsac %d clk\n",
556 data->timeout_ns / 1000000, data->timeout_clks);
557
558 /* 547 /*
559 * Calculate size. 548 * Calculate size.
560 */ 549 */
@@ -752,8 +741,6 @@ static void wbsd_finish_data(struct wbsd_host *host, struct mmc_data *data)
752 } 741 }
753 } 742 }
754 743
755 DBGF("Ending data transfer (%d bytes)\n", data->bytes_xfered);
756
757 wbsd_request_end(host, host->mrq); 744 wbsd_request_end(host, host->mrq);
758} 745}
759 746
diff --git a/drivers/mmc/host/wbsd.h b/drivers/mmc/host/wbsd.h
index 873bda1e59b4..0877866f8d28 100644
--- a/drivers/mmc/host/wbsd.h
+++ b/drivers/mmc/host/wbsd.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/mmc/wbsd.h - Winbond W83L51xD SD/MMC driver 2 * linux/drivers/mmc/host/wbsd.h - Winbond W83L51xD SD/MMC driver
3 * 3 *
4 * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved. 4 * Copyright (C) 2004-2007 Pierre Ossman, All Rights Reserved.
5 * 5 *
diff --git a/drivers/mtd/devices/docprobe.c b/drivers/mtd/devices/docprobe.c
index d574916e7821..d8cc94ec4e50 100644
--- a/drivers/mtd/devices/docprobe.c
+++ b/drivers/mtd/devices/docprobe.c
@@ -81,10 +81,7 @@ static unsigned long __initdata doc_locations[] = {
81#endif /* CONFIG_MTD_DOCPROBE_HIGH */ 81#endif /* CONFIG_MTD_DOCPROBE_HIGH */
82#elif defined(__PPC__) 82#elif defined(__PPC__)
83 0xe4000000, 83 0xe4000000,
84#elif defined(CONFIG_MOMENCO_OCELOT) 84#else
85 0x2f000000,
86 0xff000000,
87##else
88#warning Unknown architecture for DiskOnChip. No default probe locations defined 85#warning Unknown architecture for DiskOnChip. No default probe locations defined
89#endif 86#endif
90 0xffffffff }; 87 0xffffffff };
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index f88ebc5b685e..cc6c73442435 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -103,7 +103,7 @@ config MTD_PMC_MSP_RAMROOT
103 103
104config MTD_SUN_UFLASH 104config MTD_SUN_UFLASH
105 tristate "Sun Microsystems userflash support" 105 tristate "Sun Microsystems userflash support"
106 depends on SPARC && MTD_CFI 106 depends on SPARC && MTD_CFI && PCI
107 help 107 help
108 This provides a 'mapping' driver which supports the way in 108 This provides a 'mapping' driver which supports the way in
109 which user-programmable flash chips are connected on various 109 which user-programmable flash chips are connected on various
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index 5f3049a424c4..ab9f5c5db38d 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -56,9 +56,6 @@ static unsigned long __initdata doc_locations[] = {
56#endif /* CONFIG_MTD_DOCPROBE_HIGH */ 56#endif /* CONFIG_MTD_DOCPROBE_HIGH */
57#elif defined(__PPC__) 57#elif defined(__PPC__)
58 0xe4000000, 58 0xe4000000,
59#elif defined(CONFIG_MOMENCO_OCELOT)
60 0x2f000000,
61 0xff000000,
62#else 59#else
63#warning Unknown architecture for DiskOnChip. No default probe locations defined 60#warning Unknown architecture for DiskOnChip. No default probe locations defined
64#endif 61#endif
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 6deb20fc7a08..001c66dd3a94 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -2886,7 +2886,6 @@ static const struct ethtool_ops vortex_ethtool_ops = {
2886 .set_settings = vortex_set_settings, 2886 .set_settings = vortex_set_settings,
2887 .get_link = ethtool_op_get_link, 2887 .get_link = ethtool_op_get_link,
2888 .nway_reset = vortex_nway_reset, 2888 .nway_reset = vortex_nway_reset,
2889 .get_perm_addr = ethtool_op_get_perm_addr,
2890}; 2889};
2891 2890
2892#ifdef CONFIG_PCI 2891#ifdef CONFIG_PCI
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index e970e64bf966..a79f28c7a100 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -1578,7 +1578,6 @@ static const struct ethtool_ops cp_ethtool_ops = {
1578 .set_wol = cp_set_wol, 1578 .set_wol = cp_set_wol,
1579 .get_strings = cp_get_strings, 1579 .get_strings = cp_get_strings,
1580 .get_ethtool_stats = cp_get_ethtool_stats, 1580 .get_ethtool_stats = cp_get_ethtool_stats,
1581 .get_perm_addr = ethtool_op_get_perm_addr,
1582 .get_eeprom_len = cp_get_eeprom_len, 1581 .get_eeprom_len = cp_get_eeprom_len,
1583 .get_eeprom = cp_get_eeprom, 1582 .get_eeprom = cp_get_eeprom,
1584 .set_eeprom = cp_set_eeprom, 1583 .set_eeprom = cp_set_eeprom,
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 327eaa7b4999..f4e4298d24b9 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -2452,7 +2452,6 @@ static const struct ethtool_ops rtl8139_ethtool_ops = {
2452 .get_strings = rtl8139_get_strings, 2452 .get_strings = rtl8139_get_strings,
2453 .get_stats_count = rtl8139_get_stats_count, 2453 .get_stats_count = rtl8139_get_stats_count,
2454 .get_ethtool_stats = rtl8139_get_ethtool_stats, 2454 .get_ethtool_stats = rtl8139_get_ethtool_stats,
2455 .get_perm_addr = ethtool_op_get_perm_addr,
2456}; 2455};
2457 2456
2458static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 2457static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
diff --git a/drivers/net/82596.c b/drivers/net/82596.c
index 3ff1155459a3..d915837193cc 100644
--- a/drivers/net/82596.c
+++ b/drivers/net/82596.c
@@ -57,6 +57,7 @@
57#include <asm/io.h> 57#include <asm/io.h>
58#include <asm/dma.h> 58#include <asm/dma.h>
59#include <asm/pgtable.h> 59#include <asm/pgtable.h>
60#include <asm/cacheflush.h>
60 61
61static char version[] __initdata = 62static char version[] __initdata =
62 "82596.c $Revision: 1.5 $\n"; 63 "82596.c $Revision: 1.5 $\n";
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index f8a602caabcb..81ef81c9a584 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2851,7 +2851,7 @@ config PPPOATM
2851 2851
2852config PPPOL2TP 2852config PPPOL2TP
2853 tristate "PPP over L2TP (EXPERIMENTAL)" 2853 tristate "PPP over L2TP (EXPERIMENTAL)"
2854 depends on EXPERIMENTAL && PPP 2854 depends on EXPERIMENTAL && PPP && INET
2855 help 2855 help
2856 Support for PPP-over-L2TP socket family. L2TP is a protocol 2856 Support for PPP-over-L2TP socket family. L2TP is a protocol
2857 used by ISPs and enterprises to tunnel PPP traffic over UDP 2857 used by ISPs and enterprises to tunnel PPP traffic over UDP
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 336af0635df8..e684212fd8e2 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -18,7 +18,7 @@ gianfar_driver-objs := gianfar.o \
18 gianfar_sysfs.o 18 gianfar_sysfs.o
19 19
20obj-$(CONFIG_UCC_GETH) += ucc_geth_driver.o 20obj-$(CONFIG_UCC_GETH) += ucc_geth_driver.o
21ucc_geth_driver-objs := ucc_geth.o ucc_geth_mii.o 21ucc_geth_driver-objs := ucc_geth.o ucc_geth_mii.o ucc_geth_ethtool.o
22 22
23# 23#
24# link order important here 24# link order important here
@@ -177,7 +177,7 @@ obj-$(CONFIG_ZORRO8390) += zorro8390.o
177obj-$(CONFIG_HPLANCE) += hplance.o 7990.o 177obj-$(CONFIG_HPLANCE) += hplance.o 7990.o
178obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o 178obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o
179obj-$(CONFIG_EQUALIZER) += eql.o 179obj-$(CONFIG_EQUALIZER) += eql.o
180obj-$(CONFIG_LGUEST_GUEST) += lguest_net.o 180obj-$(CONFIG_LGUEST_NET) += lguest_net.o
181obj-$(CONFIG_MIPS_JAZZ_SONIC) += jazzsonic.o 181obj-$(CONFIG_MIPS_JAZZ_SONIC) += jazzsonic.o
182obj-$(CONFIG_MIPS_AU1X00_ENET) += au1000_eth.o 182obj-$(CONFIG_MIPS_AU1X00_ENET) += au1000_eth.o
183obj-$(CONFIG_MIPS_SIM_NET) += mipsnet.o 183obj-$(CONFIG_MIPS_SIM_NET) += mipsnet.o
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index b78a4e5ceeb2..62e660a79387 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -3128,12 +3128,6 @@ static int __devinit read_eeprom_byte(struct net_device *dev,
3128 int result = 0; 3128 int result = 0;
3129 short i; 3129 short i;
3130 3130
3131 if (!dev) {
3132 printk(KERN_ERR "No device!\n");
3133 result = -ENODEV;
3134 goto out;
3135 }
3136
3137 /* 3131 /*
3138 * Don't take interrupts on this CPU will bit banging 3132 * Don't take interrupts on this CPU will bit banging
3139 * the %#%#@$ I2C device 3133 * the %#%#@$ I2C device
diff --git a/drivers/net/atl1/atl1_hw.h b/drivers/net/atl1/atl1_hw.h
index 100c09c66e64..939aa0f53f6e 100644
--- a/drivers/net/atl1/atl1_hw.h
+++ b/drivers/net/atl1/atl1_hw.h
@@ -680,11 +680,6 @@ void atl1_check_options(struct atl1_adapter *adapter);
680#define AUTONEG_ADVERTISE_10_100_ALL 0x000F /* All 10/100 speeds */ 680#define AUTONEG_ADVERTISE_10_100_ALL 0x000F /* All 10/100 speeds */
681#define AUTONEG_ADVERTISE_10_ALL 0x0003 /* 10Mbps Full & Half speeds */ 681#define AUTONEG_ADVERTISE_10_ALL 0x0003 /* 10Mbps Full & Half speeds */
682 682
683/* The size (in bytes) of a ethernet packet */
684#define ENET_HEADER_SIZE 14
685#define MAXIMUM_ETHERNET_FRAME_SIZE 1518 /* with FCS */
686#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* with FCS */
687#define ETHERNET_FCS_SIZE 4
688#define MAX_JUMBO_FRAME_SIZE 0x2800 683#define MAX_JUMBO_FRAME_SIZE 0x2800
689 684
690#define PHY_AUTO_NEG_TIME 45 /* 4.5 Seconds */ 685#define PHY_AUTO_NEG_TIME 45 /* 4.5 Seconds */
@@ -929,8 +924,8 @@ enum atl1_dma_req_block {
929 atl1_dma_req_128 = 0, 924 atl1_dma_req_128 = 0,
930 atl1_dma_req_256 = 1, 925 atl1_dma_req_256 = 1,
931 atl1_dma_req_512 = 2, 926 atl1_dma_req_512 = 2,
932 atl1_dam_req_1024 = 3, 927 atl1_dma_req_1024 = 3,
933 atl1_dam_req_2048 = 4, 928 atl1_dma_req_2048 = 4,
934 atl1_dma_req_4096 = 5 929 atl1_dma_req_4096 = 5
935}; 930};
936 931
diff --git a/drivers/net/atl1/atl1_main.c b/drivers/net/atl1/atl1_main.c
index fd1e156f1747..56f6389a300e 100644
--- a/drivers/net/atl1/atl1_main.c
+++ b/drivers/net/atl1/atl1_main.c
@@ -59,6 +59,7 @@
59#include <linux/skbuff.h> 59#include <linux/skbuff.h>
60#include <linux/etherdevice.h> 60#include <linux/etherdevice.h>
61#include <linux/if_vlan.h> 61#include <linux/if_vlan.h>
62#include <linux/if_ether.h>
62#include <linux/irqreturn.h> 63#include <linux/irqreturn.h>
63#include <linux/workqueue.h> 64#include <linux/workqueue.h>
64#include <linux/timer.h> 65#include <linux/timer.h>
@@ -120,8 +121,8 @@ static int __devinit atl1_sw_init(struct atl1_adapter *adapter)
120 struct atl1_hw *hw = &adapter->hw; 121 struct atl1_hw *hw = &adapter->hw;
121 struct net_device *netdev = adapter->netdev; 122 struct net_device *netdev = adapter->netdev;
122 123
123 hw->max_frame_size = netdev->mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; 124 hw->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
124 hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE; 125 hw->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
125 126
126 adapter->wol = 0; 127 adapter->wol = 0;
127 adapter->rx_buffer_len = (hw->max_frame_size + 7) & ~7; 128 adapter->rx_buffer_len = (hw->max_frame_size + 7) & ~7;
@@ -314,7 +315,7 @@ err_nomem:
314 return -ENOMEM; 315 return -ENOMEM;
315} 316}
316 317
317void atl1_init_ring_ptrs(struct atl1_adapter *adapter) 318static void atl1_init_ring_ptrs(struct atl1_adapter *adapter)
318{ 319{
319 struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; 320 struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring;
320 struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; 321 struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring;
@@ -688,9 +689,9 @@ static int atl1_change_mtu(struct net_device *netdev, int new_mtu)
688{ 689{
689 struct atl1_adapter *adapter = netdev_priv(netdev); 690 struct atl1_adapter *adapter = netdev_priv(netdev);
690 int old_mtu = netdev->mtu; 691 int old_mtu = netdev->mtu;
691 int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; 692 int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
692 693
693 if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) || 694 if ((max_frame < ETH_ZLEN + ETH_FCS_LEN) ||
694 (max_frame > MAX_JUMBO_FRAME_SIZE)) { 695 (max_frame > MAX_JUMBO_FRAME_SIZE)) {
695 dev_warn(&adapter->pdev->dev, "invalid MTU setting\n"); 696 dev_warn(&adapter->pdev->dev, "invalid MTU setting\n");
696 return -EINVAL; 697 return -EINVAL;
@@ -908,8 +909,8 @@ static u32 atl1_configure(struct atl1_adapter *adapter)
908 /* config DMA Engine */ 909 /* config DMA Engine */
909 value = ((((u32) hw->dmar_block) & DMA_CTRL_DMAR_BURST_LEN_MASK) 910 value = ((((u32) hw->dmar_block) & DMA_CTRL_DMAR_BURST_LEN_MASK)
910 << DMA_CTRL_DMAR_BURST_LEN_SHIFT) | 911 << DMA_CTRL_DMAR_BURST_LEN_SHIFT) |
911 ((((u32) hw->dmaw_block) & DMA_CTRL_DMAR_BURST_LEN_MASK) 912 ((((u32) hw->dmaw_block) & DMA_CTRL_DMAW_BURST_LEN_MASK)
912 << DMA_CTRL_DMAR_BURST_LEN_SHIFT) | DMA_CTRL_DMAR_EN | 913 << DMA_CTRL_DMAW_BURST_LEN_SHIFT) | DMA_CTRL_DMAR_EN |
913 DMA_CTRL_DMAW_EN; 914 DMA_CTRL_DMAW_EN;
914 value |= (u32) hw->dma_ord; 915 value |= (u32) hw->dma_ord;
915 if (atl1_rcb_128 == hw->rcb_value) 916 if (atl1_rcb_128 == hw->rcb_value)
@@ -917,7 +918,10 @@ static u32 atl1_configure(struct atl1_adapter *adapter)
917 iowrite32(value, hw->hw_addr + REG_DMA_CTRL); 918 iowrite32(value, hw->hw_addr + REG_DMA_CTRL);
918 919
919 /* config CMB / SMB */ 920 /* config CMB / SMB */
920 value = hw->cmb_rrd | ((u32) hw->cmb_tpd << 16); 921 value = (hw->cmb_tpd > adapter->tpd_ring.count) ?
922 hw->cmb_tpd : adapter->tpd_ring.count;
923 value <<= 16;
924 value |= hw->cmb_rrd;
921 iowrite32(value, hw->hw_addr + REG_CMB_WRITE_TH); 925 iowrite32(value, hw->hw_addr + REG_CMB_WRITE_TH);
922 value = hw->cmb_rx_timer | ((u32) hw->cmb_tx_timer << 16); 926 value = hw->cmb_rx_timer | ((u32) hw->cmb_tx_timer << 16);
923 iowrite32(value, hw->hw_addr + REG_CMB_WRITE_TIMER); 927 iowrite32(value, hw->hw_addr + REG_CMB_WRITE_TIMER);
@@ -1334,7 +1338,7 @@ rrd_ok:
1334 skb = buffer_info->skb; 1338 skb = buffer_info->skb;
1335 length = le16_to_cpu(rrd->xsz.xsum_sz.pkt_size); 1339 length = le16_to_cpu(rrd->xsz.xsum_sz.pkt_size);
1336 1340
1337 skb_put(skb, length - ETHERNET_FCS_SIZE); 1341 skb_put(skb, length - ETH_FCS_LEN);
1338 1342
1339 /* Receive Checksum Offload */ 1343 /* Receive Checksum Offload */
1340 atl1_rx_checksum(adapter, rrd, skb); 1344 atl1_rx_checksum(adapter, rrd, skb);
@@ -1422,7 +1426,7 @@ static void atl1_intr_tx(struct atl1_adapter *adapter)
1422 netif_wake_queue(adapter->netdev); 1426 netif_wake_queue(adapter->netdev);
1423} 1427}
1424 1428
1425static u16 tpd_avail(struct atl1_tpd_ring *tpd_ring) 1429static u16 atl1_tpd_avail(struct atl1_tpd_ring *tpd_ring)
1426{ 1430{
1427 u16 next_to_clean = atomic_read(&tpd_ring->next_to_clean); 1431 u16 next_to_clean = atomic_read(&tpd_ring->next_to_clean);
1428 u16 next_to_use = atomic_read(&tpd_ring->next_to_use); 1432 u16 next_to_use = atomic_read(&tpd_ring->next_to_use);
@@ -1453,7 +1457,7 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb,
1453 tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, 1457 tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
1454 iph->daddr, 0, IPPROTO_TCP, 0); 1458 iph->daddr, 0, IPPROTO_TCP, 0);
1455 ipofst = skb_network_offset(skb); 1459 ipofst = skb_network_offset(skb);
1456 if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */ 1460 if (ipofst != ETH_HLEN) /* 802.3 frame */
1457 tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT; 1461 tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT;
1458 1462
1459 tso->tsopl |= (iph->ihl & 1463 tso->tsopl |= (iph->ihl &
@@ -1708,7 +1712,7 @@ static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1708 return NETDEV_TX_LOCKED; 1712 return NETDEV_TX_LOCKED;
1709 } 1713 }
1710 1714
1711 if (tpd_avail(&adapter->tpd_ring) < count) { 1715 if (atl1_tpd_avail(&adapter->tpd_ring) < count) {
1712 /* not enough descriptors */ 1716 /* not enough descriptors */
1713 netif_stop_queue(netdev); 1717 netif_stop_queue(netdev);
1714 spin_unlock_irqrestore(&adapter->lock, flags); 1718 spin_unlock_irqrestore(&adapter->lock, flags);
diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c
index 1d882360b34d..83da1770bafb 100644
--- a/drivers/net/ax88796.c
+++ b/drivers/net/ax88796.c
@@ -580,7 +580,6 @@ static const struct ethtool_ops ax_ethtool_ops = {
580 .set_settings = ax_set_settings, 580 .set_settings = ax_set_settings,
581 .nway_reset = ax_nway_reset, 581 .nway_reset = ax_nway_reset,
582 .get_link = ax_get_link, 582 .get_link = ax_get_link,
583 .get_perm_addr = ethtool_op_get_perm_addr,
584}; 583};
585 584
586/* setup code */ 585/* setup code */
@@ -819,7 +818,7 @@ static int ax_probe(struct platform_device *pdev)
819 } 818 }
820 819
821 ei_status.mem = ioremap(res->start, size); 820 ei_status.mem = ioremap(res->start, size);
822 dev->base_addr = (long)ei_status.mem; 821 dev->base_addr = (unsigned long)ei_status.mem;
823 822
824 if (ei_status.mem == NULL) { 823 if (ei_status.mem == NULL) {
825 dev_err(&pdev->dev, "Cannot ioremap area (%08zx,%08zx)\n", 824 dev_err(&pdev->dev, "Cannot ioremap area (%08zx,%08zx)\n",
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 37f1b6ff5c12..0795df235492 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -2033,7 +2033,6 @@ static const struct ethtool_ops b44_ethtool_ops = {
2033 .get_strings = b44_get_strings, 2033 .get_strings = b44_get_strings,
2034 .get_stats_count = b44_get_stats_count, 2034 .get_stats_count = b44_get_stats_count,
2035 .get_ethtool_stats = b44_get_ethtool_stats, 2035 .get_ethtool_stats = b44_get_ethtool_stats,
2036 .get_perm_addr = ethtool_op_get_perm_addr,
2037}; 2036};
2038 2037
2039static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 2038static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 9a08d656f1ce..2bb97d464689 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -798,6 +798,7 @@ static void bf537mac_shutdown(struct net_device *dev)
798 */ 798 */
799static int bf537mac_open(struct net_device *dev) 799static int bf537mac_open(struct net_device *dev)
800{ 800{
801 int retval;
801 pr_debug("%s: %s\n", dev->name, __FUNCTION__); 802 pr_debug("%s: %s\n", dev->name, __FUNCTION__);
802 803
803 /* 804 /*
@@ -811,7 +812,10 @@ static int bf537mac_open(struct net_device *dev)
811 } 812 }
812 813
813 /* initial rx and tx list */ 814 /* initial rx and tx list */
814 desc_list_init(); 815 retval = desc_list_init();
816
817 if (retval)
818 return retval;
815 819
816 bf537mac_setphy(dev); 820 bf537mac_setphy(dev);
817 setup_system_regs(dev); 821 setup_system_regs(dev);
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index a729da061bbb..d53dfc5bbae0 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -6269,7 +6269,6 @@ static const struct ethtool_ops bnx2_ethtool_ops = {
6269 .phys_id = bnx2_phys_id, 6269 .phys_id = bnx2_phys_id,
6270 .get_stats_count = bnx2_get_stats_count, 6270 .get_stats_count = bnx2_get_stats_count,
6271 .get_ethtool_stats = bnx2_get_ethtool_stats, 6271 .get_ethtool_stats = bnx2_get_ethtool_stats,
6272 .get_perm_addr = ethtool_op_get_perm_addr,
6273}; 6272};
6274 6273
6275/* Called with rtnl_lock */ 6274/* Called with rtnl_lock */
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index cb9cb3013f42..070b78d959cc 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -613,38 +613,20 @@ down:
613static int bond_update_speed_duplex(struct slave *slave) 613static int bond_update_speed_duplex(struct slave *slave)
614{ 614{
615 struct net_device *slave_dev = slave->dev; 615 struct net_device *slave_dev = slave->dev;
616 static int (* ioctl)(struct net_device *, struct ifreq *, int);
617 struct ifreq ifr;
618 struct ethtool_cmd etool; 616 struct ethtool_cmd etool;
617 int res;
619 618
620 /* Fake speed and duplex */ 619 /* Fake speed and duplex */
621 slave->speed = SPEED_100; 620 slave->speed = SPEED_100;
622 slave->duplex = DUPLEX_FULL; 621 slave->duplex = DUPLEX_FULL;
623 622
624 if (slave_dev->ethtool_ops) { 623 if (!slave_dev->ethtool_ops || !slave_dev->ethtool_ops->get_settings)
625 int res; 624 return -1;
626
627 if (!slave_dev->ethtool_ops->get_settings) {
628 return -1;
629 }
630
631 res = slave_dev->ethtool_ops->get_settings(slave_dev, &etool);
632 if (res < 0) {
633 return -1;
634 }
635
636 goto verify;
637 }
638 625
639 ioctl = slave_dev->do_ioctl; 626 res = slave_dev->ethtool_ops->get_settings(slave_dev, &etool);
640 strncpy(ifr.ifr_name, slave_dev->name, IFNAMSIZ); 627 if (res < 0)
641 etool.cmd = ETHTOOL_GSET;
642 ifr.ifr_data = (char*)&etool;
643 if (!ioctl || (IOCTL(slave_dev, &ifr, SIOCETHTOOL) < 0)) {
644 return -1; 628 return -1;
645 }
646 629
647verify:
648 switch (etool.speed) { 630 switch (etool.speed) {
649 case SPEED_10: 631 case SPEED_10:
650 case SPEED_100: 632 case SPEED_100:
@@ -690,7 +672,6 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de
690 static int (* ioctl)(struct net_device *, struct ifreq *, int); 672 static int (* ioctl)(struct net_device *, struct ifreq *, int);
691 struct ifreq ifr; 673 struct ifreq ifr;
692 struct mii_ioctl_data *mii; 674 struct mii_ioctl_data *mii;
693 struct ethtool_value etool;
694 675
695 if (bond->params.use_carrier) { 676 if (bond->params.use_carrier) {
696 return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0; 677 return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0;
@@ -721,9 +702,10 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de
721 } 702 }
722 } 703 }
723 704
724 /* try SIOCETHTOOL ioctl, some drivers cache ETHTOOL_GLINK */ 705 /*
725 /* for a period of time so we attempt to get link status */ 706 * Some drivers cache ETHTOOL_GLINK for a period of time so we only
726 /* from it last if the above MII ioctls fail... */ 707 * attempt to get link status from it if the above MII ioctls fail.
708 */
727 if (slave_dev->ethtool_ops) { 709 if (slave_dev->ethtool_ops) {
728 if (slave_dev->ethtool_ops->get_link) { 710 if (slave_dev->ethtool_ops->get_link) {
729 u32 link; 711 u32 link;
@@ -734,23 +716,9 @@ static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_de
734 } 716 }
735 } 717 }
736 718
737 if (ioctl) {
738 strncpy(ifr.ifr_name, slave_dev->name, IFNAMSIZ);
739 etool.cmd = ETHTOOL_GLINK;
740 ifr.ifr_data = (char*)&etool;
741 if (IOCTL(slave_dev, &ifr, SIOCETHTOOL) == 0) {
742 if (etool.data == 1) {
743 return BMSR_LSTATUS;
744 } else {
745 dprintk("SIOCETHTOOL shows link down\n");
746 return 0;
747 }
748 }
749 }
750
751 /* 719 /*
752 * If reporting, report that either there's no dev->do_ioctl, 720 * If reporting, report that either there's no dev->do_ioctl,
753 * or both SIOCGMIIREG and SIOCETHTOOL failed (meaning that we 721 * or both SIOCGMIIREG and get_link failed (meaning that we
754 * cannot report link status). If not reporting, pretend 722 * cannot report link status). If not reporting, pretend
755 * we're ok. 723 * we're ok.
756 */ 724 */
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 6fd1e5241833..dc5d26988bb3 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -1583,7 +1583,6 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
1583 .get_wol = get_wol, 1583 .get_wol = get_wol,
1584 .get_tso = ethtool_op_get_tso, 1584 .get_tso = ethtool_op_get_tso,
1585 .set_tso = ethtool_op_set_tso, 1585 .set_tso = ethtool_op_set_tso,
1586 .get_perm_addr = ethtool_op_get_perm_addr
1587}; 1586};
1588 1587
1589static int in_range(int val, int lo, int hi) 1588static int in_range(int val, int lo, int hi)
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index ebcf35e4cf5b..e620ed4c3ff0 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -699,7 +699,7 @@ static int do_cr(struct t3cdev *dev, struct sk_buff *skb)
699 * the buffer. 699 * the buffer.
700 */ 700 */
701static struct sk_buff *cxgb3_get_cpl_reply_skb(struct sk_buff *skb, size_t len, 701static struct sk_buff *cxgb3_get_cpl_reply_skb(struct sk_buff *skb, size_t len,
702 int gfp) 702 gfp_t gfp)
703{ 703{
704 if (likely(!skb_cloned(skb))) { 704 if (likely(!skb_cloned(skb))) {
705 BUG_ON(skb->len < len); 705 BUG_ON(skb->len < len);
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c
index 7df23dc28190..9c8e3f9f5e58 100644
--- a/drivers/net/defxx.c
+++ b/drivers/net/defxx.c
@@ -200,6 +200,7 @@
200 200
201/* Include files */ 201/* Include files */
202#include <linux/bitops.h> 202#include <linux/bitops.h>
203#include <linux/compiler.h>
203#include <linux/delay.h> 204#include <linux/delay.h>
204#include <linux/dma-mapping.h> 205#include <linux/dma-mapping.h>
205#include <linux/eisa.h> 206#include <linux/eisa.h>
@@ -240,8 +241,6 @@ static char version[] __devinitdata =
240 */ 241 */
241#define NEW_SKB_SIZE (PI_RCV_DATA_K_SIZE_MAX+128) 242#define NEW_SKB_SIZE (PI_RCV_DATA_K_SIZE_MAX+128)
242 243
243#define __unused __attribute__ ((unused))
244
245#ifdef CONFIG_PCI 244#ifdef CONFIG_PCI
246#define DFX_BUS_PCI(dev) (dev->bus == &pci_bus_type) 245#define DFX_BUS_PCI(dev) (dev->bus == &pci_bus_type)
247#else 246#else
@@ -375,7 +374,7 @@ static inline void dfx_outl(DFX_board_t *bp, int offset, u32 data)
375 374
376static void dfx_port_write_long(DFX_board_t *bp, int offset, u32 data) 375static void dfx_port_write_long(DFX_board_t *bp, int offset, u32 data)
377{ 376{
378 struct device __unused *bdev = bp->bus_dev; 377 struct device __maybe_unused *bdev = bp->bus_dev;
379 int dfx_bus_tc = DFX_BUS_TC(bdev); 378 int dfx_bus_tc = DFX_BUS_TC(bdev);
380 int dfx_use_mmio = DFX_MMIO || dfx_bus_tc; 379 int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
381 380
@@ -399,7 +398,7 @@ static inline void dfx_inl(DFX_board_t *bp, int offset, u32 *data)
399 398
400static void dfx_port_read_long(DFX_board_t *bp, int offset, u32 *data) 399static void dfx_port_read_long(DFX_board_t *bp, int offset, u32 *data)
401{ 400{
402 struct device __unused *bdev = bp->bus_dev; 401 struct device __maybe_unused *bdev = bp->bus_dev;
403 int dfx_bus_tc = DFX_BUS_TC(bdev); 402 int dfx_bus_tc = DFX_BUS_TC(bdev);
404 int dfx_use_mmio = DFX_MMIO || dfx_bus_tc; 403 int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
405 404
@@ -866,7 +865,7 @@ static void __devinit dfx_bus_uninit(struct net_device *dev)
866 865
867static void __devinit dfx_bus_config_check(DFX_board_t *bp) 866static void __devinit dfx_bus_config_check(DFX_board_t *bp)
868{ 867{
869 struct device __unused *bdev = bp->bus_dev; 868 struct device __maybe_unused *bdev = bp->bus_dev;
870 int dfx_bus_eisa = DFX_BUS_EISA(bdev); 869 int dfx_bus_eisa = DFX_BUS_EISA(bdev);
871 int status; /* return code from adapter port control call */ 870 int status; /* return code from adapter port control call */
872 u32 host_data; /* LW data returned from port control call */ 871 u32 host_data; /* LW data returned from port control call */
@@ -3624,8 +3623,8 @@ static void __devexit dfx_unregister(struct device *bdev)
3624} 3623}
3625 3624
3626 3625
3627static int __devinit __unused dfx_dev_register(struct device *); 3626static int __devinit __maybe_unused dfx_dev_register(struct device *);
3628static int __devexit __unused dfx_dev_unregister(struct device *); 3627static int __devexit __maybe_unused dfx_dev_unregister(struct device *);
3629 3628
3630#ifdef CONFIG_PCI 3629#ifdef CONFIG_PCI
3631static int __devinit dfx_pci_register(struct pci_dev *, 3630static int __devinit dfx_pci_register(struct pci_dev *,
@@ -3699,7 +3698,7 @@ static struct tc_driver dfx_tc_driver = {
3699}; 3698};
3700#endif /* CONFIG_TC */ 3699#endif /* CONFIG_TC */
3701 3700
3702static int __devinit __unused dfx_dev_register(struct device *dev) 3701static int __devinit __maybe_unused dfx_dev_register(struct device *dev)
3703{ 3702{
3704 int status; 3703 int status;
3705 3704
@@ -3709,7 +3708,7 @@ static int __devinit __unused dfx_dev_register(struct device *dev)
3709 return status; 3708 return status;
3710} 3709}
3711 3710
3712static int __devexit __unused dfx_dev_unregister(struct device *dev) 3711static int __devexit __maybe_unused dfx_dev_unregister(struct device *dev)
3713{ 3712{
3714 put_device(dev); 3713 put_device(dev);
3715 dfx_unregister(dev); 3714 dfx_unregister(dev);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 6b6401e9304e..280313b9b069 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2506,7 +2506,6 @@ static const struct ethtool_ops e100_ethtool_ops = {
2506 .phys_id = e100_phys_id, 2506 .phys_id = e100_phys_id,
2507 .get_stats_count = e100_get_stats_count, 2507 .get_stats_count = e100_get_stats_count,
2508 .get_ethtool_stats = e100_get_ethtool_stats, 2508 .get_ethtool_stats = e100_get_ethtool_stats,
2509 .get_perm_addr = ethtool_op_get_perm_addr,
2510}; 2509};
2511 2510
2512static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) 2511static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index bb08375b5f13..c90c92e72d2a 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -1973,7 +1973,6 @@ static const struct ethtool_ops e1000_ethtool_ops = {
1973 .phys_id = e1000_phys_id, 1973 .phys_id = e1000_phys_id,
1974 .get_stats_count = e1000_get_stats_count, 1974 .get_stats_count = e1000_get_stats_count,
1975 .get_ethtool_stats = e1000_get_ethtool_stats, 1975 .get_ethtool_stats = e1000_get_ethtool_stats,
1976 .get_perm_addr = ethtool_op_get_perm_addr,
1977}; 1976};
1978 1977
1979void e1000_set_ethtool_ops(struct net_device *netdev) 1978void e1000_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 489c8b260dd8..8ee2c2c86b42 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -39,7 +39,7 @@
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#define DRV_NAME "ehea" 41#define DRV_NAME "ehea"
42#define DRV_VERSION "EHEA_0071" 42#define DRV_VERSION "EHEA_0072"
43 43
44/* eHEA capability flags */ 44/* eHEA capability flags */
45#define DLPAR_PORT_ADD_REM 1 45#define DLPAR_PORT_ADD_REM 1
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 4c70a9301c1b..58702f54c3fb 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -589,6 +589,23 @@ static int ehea_poll(struct net_device *dev, int *budget)
589 return 1; 589 return 1;
590} 590}
591 591
592#ifdef CONFIG_NET_POLL_CONTROLLER
593static void ehea_netpoll(struct net_device *dev)
594{
595 struct ehea_port *port = netdev_priv(dev);
596
597 netif_rx_schedule(port->port_res[0].d_netdev);
598}
599#endif
600
601static int ehea_poll_firstqueue(struct net_device *dev, int *budget)
602{
603 struct ehea_port *port = netdev_priv(dev);
604 struct net_device *d_dev = port->port_res[0].d_netdev;
605
606 return ehea_poll(d_dev, budget);
607}
608
592static irqreturn_t ehea_recv_irq_handler(int irq, void *param) 609static irqreturn_t ehea_recv_irq_handler(int irq, void *param)
593{ 610{
594 struct ehea_port_res *pr = param; 611 struct ehea_port_res *pr = param;
@@ -2626,7 +2643,10 @@ struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter,
2626 memcpy(dev->dev_addr, &port->mac_addr, ETH_ALEN); 2643 memcpy(dev->dev_addr, &port->mac_addr, ETH_ALEN);
2627 2644
2628 dev->open = ehea_open; 2645 dev->open = ehea_open;
2629 dev->poll = ehea_poll; 2646 dev->poll = ehea_poll_firstqueue;
2647#ifdef CONFIG_NET_POLL_CONTROLLER
2648 dev->poll_controller = ehea_netpoll;
2649#endif
2630 dev->weight = 64; 2650 dev->weight = 64;
2631 dev->stop = ehea_stop; 2651 dev->stop = ehea_stop;
2632 dev->hard_start_xmit = ehea_start_xmit; 2652 dev->hard_start_xmit = ehea_start_xmit;
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 03023dd17829..4e8df910c00d 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -47,6 +47,7 @@
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48#include <asm/io.h> 48#include <asm/io.h>
49#include <asm/pgtable.h> 49#include <asm/pgtable.h>
50#include <asm/cacheflush.h>
50 51
51#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \ 52#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \
52 defined(CONFIG_M5272) || defined(CONFIG_M528x) || \ 53 defined(CONFIG_M5272) || defined(CONFIG_M528x) || \
@@ -98,8 +99,6 @@ static unsigned char fec_mac_default[] = {
98#define FEC_FLASHMAC 0xf0006006 99#define FEC_FLASHMAC 0xf0006006
99#elif defined(CONFIG_GILBARCONAP) || defined(CONFIG_SCALES) 100#elif defined(CONFIG_GILBARCONAP) || defined(CONFIG_SCALES)
100#define FEC_FLASHMAC 0xf0006000 101#define FEC_FLASHMAC 0xf0006000
101#elif defined (CONFIG_MTD_KeyTechnology)
102#define FEC_FLASHMAC 0xffe04000
103#elif defined(CONFIG_CANCam) 102#elif defined(CONFIG_CANCam)
104#define FEC_FLASHMAC 0xf0020000 103#define FEC_FLASHMAC 0xf0020000
105#elif defined (CONFIG_M5272C3) 104#elif defined (CONFIG_M5272C3)
@@ -191,6 +190,8 @@ struct fec_enet_private {
191 /* Hardware registers of the FEC device */ 190 /* Hardware registers of the FEC device */
192 volatile fec_t *hwp; 191 volatile fec_t *hwp;
193 192
193 struct net_device *netdev;
194
194 /* The saved address of a sent-in-place packet/buffer, for skfree(). */ 195 /* The saved address of a sent-in-place packet/buffer, for skfree(). */
195 unsigned char *tx_bounce[TX_RING_SIZE]; 196 unsigned char *tx_bounce[TX_RING_SIZE];
196 struct sk_buff* tx_skbuff[TX_RING_SIZE]; 197 struct sk_buff* tx_skbuff[TX_RING_SIZE];
@@ -1269,7 +1270,7 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1269 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR3); 1270 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR3);
1270 *icrp = 0x00000ddd; 1271 *icrp = 0x00000ddd;
1271 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1); 1272 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
1272 *icrp = (*icrp & 0x70777777) | 0x0d000000; 1273 *icrp = 0x0d000000;
1273} 1274}
1274 1275
1275static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep) 1276static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep)
@@ -1331,7 +1332,7 @@ static void __inline__ fec_disable_phy_intr(void)
1331{ 1332{
1332 volatile unsigned long *icrp; 1333 volatile unsigned long *icrp;
1333 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1); 1334 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
1334 *icrp = (*icrp & 0x70777777) | 0x08000000; 1335 *icrp = 0x08000000;
1335} 1336}
1336 1337
1337static void __inline__ fec_phy_ack_intr(void) 1338static void __inline__ fec_phy_ack_intr(void)
@@ -1339,7 +1340,7 @@ static void __inline__ fec_phy_ack_intr(void)
1339 volatile unsigned long *icrp; 1340 volatile unsigned long *icrp;
1340 /* Acknowledge the interrupt */ 1341 /* Acknowledge the interrupt */
1341 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1); 1342 icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
1342 *icrp = (*icrp & 0x77777777) | 0x08000000; 1343 *icrp = 0x0d000000;
1343} 1344}
1344 1345
1345static void __inline__ fec_localhw_setup(void) 1346static void __inline__ fec_localhw_setup(void)
@@ -1426,6 +1427,29 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1426 *gpio_pehlpar = 0xc0; 1427 *gpio_pehlpar = 0xc0;
1427 } 1428 }
1428#endif 1429#endif
1430
1431#if defined(CONFIG_M527x)
1432 /* Set up gpio outputs for MII lines */
1433 {
1434 volatile u8 *gpio_par_fec;
1435 volatile u16 *gpio_par_feci2c;
1436
1437 gpio_par_feci2c = (volatile u16 *)(MCF_IPSBAR + 0x100082);
1438 /* Set up gpio outputs for FEC0 MII lines */
1439 gpio_par_fec = (volatile u8 *)(MCF_IPSBAR + 0x100078);
1440
1441 *gpio_par_feci2c |= 0x0f00;
1442 *gpio_par_fec |= 0xc0;
1443
1444#if defined(CONFIG_FEC2)
1445 /* Set up gpio outputs for FEC1 MII lines */
1446 gpio_par_fec = (volatile u8 *)(MCF_IPSBAR + 0x100079);
1447
1448 *gpio_par_feci2c |= 0x00a0;
1449 *gpio_par_fec |= 0xc0;
1450#endif /* CONFIG_FEC2 */
1451 }
1452#endif /* CONFIG_M527x */
1429} 1453}
1430 1454
1431static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep) 1455static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep)
@@ -1940,9 +1964,10 @@ static void mii_display_status(struct net_device *dev)
1940 printk(".\n"); 1964 printk(".\n");
1941} 1965}
1942 1966
1943static void mii_display_config(struct net_device *dev) 1967static void mii_display_config(struct work_struct *work)
1944{ 1968{
1945 struct fec_enet_private *fep = netdev_priv(dev); 1969 struct fec_enet_private *fep = container_of(work, struct fec_enet_private, phy_task);
1970 struct net_device *dev = fep->netdev;
1946 uint status = fep->phy_status; 1971 uint status = fep->phy_status;
1947 1972
1948 /* 1973 /*
@@ -1976,9 +2001,10 @@ static void mii_display_config(struct net_device *dev)
1976 fep->sequence_done = 1; 2001 fep->sequence_done = 1;
1977} 2002}
1978 2003
1979static void mii_relink(struct net_device *dev) 2004static void mii_relink(struct work_struct *work)
1980{ 2005{
1981 struct fec_enet_private *fep = netdev_priv(dev); 2006 struct fec_enet_private *fep = container_of(work, struct fec_enet_private, phy_task);
2007 struct net_device *dev = fep->netdev;
1982 int duplex; 2008 int duplex;
1983 2009
1984 /* 2010 /*
@@ -2022,7 +2048,7 @@ static void mii_queue_relink(uint mii_reg, struct net_device *dev)
2022 return; 2048 return;
2023 2049
2024 fep->mii_phy_task_queued = 1; 2050 fep->mii_phy_task_queued = 1;
2025 INIT_WORK(&fep->phy_task, (void*)mii_relink, dev); 2051 INIT_WORK(&fep->phy_task, mii_relink);
2026 schedule_work(&fep->phy_task); 2052 schedule_work(&fep->phy_task);
2027} 2053}
2028 2054
@@ -2035,7 +2061,7 @@ static void mii_queue_config(uint mii_reg, struct net_device *dev)
2035 return; 2061 return;
2036 2062
2037 fep->mii_phy_task_queued = 1; 2063 fep->mii_phy_task_queued = 1;
2038 INIT_WORK(&fep->phy_task, (void*)mii_display_config, dev); 2064 INIT_WORK(&fep->phy_task, mii_display_config);
2039 schedule_work(&fep->phy_task); 2065 schedule_work(&fep->phy_task);
2040} 2066}
2041 2067
@@ -2330,6 +2356,7 @@ int __init fec_enet_init(struct net_device *dev)
2330 2356
2331 fep->index = index; 2357 fep->index = index;
2332 fep->hwp = fecp; 2358 fep->hwp = fecp;
2359 fep->netdev = dev;
2333 2360
2334 /* Whack a reset. We should wait for this. 2361 /* Whack a reset. We should wait for this.
2335 */ 2362 */
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 6d1d50a19783..69f5f365239a 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -178,6 +178,7 @@
178#define DEV_HAS_STATISTICS_V2 0x0800 /* device supports hw statistics version 2 */ 178#define DEV_HAS_STATISTICS_V2 0x0800 /* device supports hw statistics version 2 */
179#define DEV_HAS_TEST_EXTENDED 0x1000 /* device supports extended diagnostic test */ 179#define DEV_HAS_TEST_EXTENDED 0x1000 /* device supports extended diagnostic test */
180#define DEV_HAS_MGMT_UNIT 0x2000 /* device supports management unit */ 180#define DEV_HAS_MGMT_UNIT 0x2000 /* device supports management unit */
181#define DEV_HAS_CORRECT_MACADDR 0x4000 /* device supports correct mac address order */
181 182
182enum { 183enum {
183 NvRegIrqStatus = 0x000, 184 NvRegIrqStatus = 0x000,
@@ -4706,7 +4707,6 @@ static const struct ethtool_ops ops = {
4706 .get_regs_len = nv_get_regs_len, 4707 .get_regs_len = nv_get_regs_len,
4707 .get_regs = nv_get_regs, 4708 .get_regs = nv_get_regs,
4708 .nway_reset = nv_nway_reset, 4709 .nway_reset = nv_nway_reset,
4709 .get_perm_addr = ethtool_op_get_perm_addr,
4710 .get_tso = ethtool_op_get_tso, 4710 .get_tso = ethtool_op_get_tso,
4711 .set_tso = nv_set_tso, 4711 .set_tso = nv_set_tso,
4712 .get_ringparam = nv_get_ringparam, 4712 .get_ringparam = nv_get_ringparam,
@@ -5172,7 +5172,8 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5172 5172
5173 /* check the workaround bit for correct mac address order */ 5173 /* check the workaround bit for correct mac address order */
5174 txreg = readl(base + NvRegTransmitPoll); 5174 txreg = readl(base + NvRegTransmitPoll);
5175 if (txreg & NVREG_TRANSMITPOLL_MAC_ADDR_REV) { 5175 if ((txreg & NVREG_TRANSMITPOLL_MAC_ADDR_REV) ||
5176 (id->driver_data & DEV_HAS_CORRECT_MACADDR)) {
5176 /* mac address is already in correct order */ 5177 /* mac address is already in correct order */
5177 dev->dev_addr[0] = (np->orig_mac[0] >> 0) & 0xff; 5178 dev->dev_addr[0] = (np->orig_mac[0] >> 0) & 0xff;
5178 dev->dev_addr[1] = (np->orig_mac[0] >> 8) & 0xff; 5179 dev->dev_addr[1] = (np->orig_mac[0] >> 8) & 0xff;
@@ -5500,51 +5501,67 @@ static struct pci_device_id pci_tbl[] = {
5500 }, 5501 },
5501 { /* MCP61 Ethernet Controller */ 5502 { /* MCP61 Ethernet Controller */
5502 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_16), 5503 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_16),
5503 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5504 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5504 }, 5505 },
5505 { /* MCP61 Ethernet Controller */ 5506 { /* MCP61 Ethernet Controller */
5506 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_17), 5507 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_17),
5507 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5508 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5508 }, 5509 },
5509 { /* MCP61 Ethernet Controller */ 5510 { /* MCP61 Ethernet Controller */
5510 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_18), 5511 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_18),
5511 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5512 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5512 }, 5513 },
5513 { /* MCP61 Ethernet Controller */ 5514 { /* MCP61 Ethernet Controller */
5514 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_19), 5515 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_19),
5515 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5516 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5516 }, 5517 },
5517 { /* MCP65 Ethernet Controller */ 5518 { /* MCP65 Ethernet Controller */
5518 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_20), 5519 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_20),
5519 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5520 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5520 }, 5521 },
5521 { /* MCP65 Ethernet Controller */ 5522 { /* MCP65 Ethernet Controller */
5522 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_21), 5523 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_21),
5523 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5524 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5524 }, 5525 },
5525 { /* MCP65 Ethernet Controller */ 5526 { /* MCP65 Ethernet Controller */
5526 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_22), 5527 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_22),
5527 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5528 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5528 }, 5529 },
5529 { /* MCP65 Ethernet Controller */ 5530 { /* MCP65 Ethernet Controller */
5530 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_23), 5531 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_23),
5531 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5532 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5532 }, 5533 },
5533 { /* MCP67 Ethernet Controller */ 5534 { /* MCP67 Ethernet Controller */
5534 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_24), 5535 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_24),
5535 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5536 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5536 }, 5537 },
5537 { /* MCP67 Ethernet Controller */ 5538 { /* MCP67 Ethernet Controller */
5538 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_25), 5539 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_25),
5539 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5540 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5540 }, 5541 },
5541 { /* MCP67 Ethernet Controller */ 5542 { /* MCP67 Ethernet Controller */
5542 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_26), 5543 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_26),
5543 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5544 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5544 }, 5545 },
5545 { /* MCP67 Ethernet Controller */ 5546 { /* MCP67 Ethernet Controller */
5546 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_27), 5547 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_27),
5547 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5548 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5549 },
5550 { /* MCP73 Ethernet Controller */
5551 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_28),
5552 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5553 },
5554 { /* MCP73 Ethernet Controller */
5555 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_29),
5556 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5557 },
5558 { /* MCP73 Ethernet Controller */
5559 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_30),
5560 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5561 },
5562 { /* MCP73 Ethernet Controller */
5563 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_31),
5564 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5548 }, 5565 },
5549 {0,}, 5566 {0,},
5550}; 5567};
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c
index ac3596f45dd8..100bf410bf5f 100644
--- a/drivers/net/gianfar_mii.c
+++ b/drivers/net/gianfar_mii.c
@@ -245,7 +245,7 @@ int __init gfar_mdio_init(void)
245 return driver_register(&gianfar_mdio_driver); 245 return driver_register(&gianfar_mdio_driver);
246} 246}
247 247
248void __exit gfar_mdio_exit(void) 248void gfar_mdio_exit(void)
249{ 249{
250 driver_unregister(&gianfar_mdio_driver); 250 driver_unregister(&gianfar_mdio_driver);
251} 251}
diff --git a/drivers/net/gianfar_mii.h b/drivers/net/gianfar_mii.h
index 5d3400469514..b373091c7031 100644
--- a/drivers/net/gianfar_mii.h
+++ b/drivers/net/gianfar_mii.h
@@ -42,5 +42,5 @@ struct gfar_mii {
42int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum); 42int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum);
43int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value); 43int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value);
44int __init gfar_mdio_init(void); 44int __init gfar_mdio_init(void);
45void __exit gfar_mdio_exit(void); 45void gfar_mdio_exit(void);
46#endif /* GIANFAR_PHY_H */ 46#endif /* GIANFAR_PHY_H */
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index 656f2789c9ba..cc0ee93669ea 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -413,12 +413,12 @@ static void *bpq_seq_next(struct seq_file *seq, void *v, loff_t *pos)
413 ++*pos; 413 ++*pos;
414 414
415 if (v == SEQ_START_TOKEN) 415 if (v == SEQ_START_TOKEN)
416 p = bpq_devices.next; 416 p = rcu_dereference(bpq_devices.next);
417 else 417 else
418 p = ((struct bpqdev *)v)->bpq_list.next; 418 p = rcu_dereference(((struct bpqdev *)v)->bpq_list.next);
419 419
420 return (p == &bpq_devices) ? NULL 420 return (p == &bpq_devices) ? NULL
421 : rcu_dereference(list_entry(p, struct bpqdev, bpq_list)); 421 : list_entry(p, struct bpqdev, bpq_list);
422} 422}
423 423
424static void bpq_seq_stop(struct seq_file *seq, void *v) 424static void bpq_seq_stop(struct seq_file *seq, void *v)
diff --git a/drivers/net/ixgb/ixgb_ethtool.c b/drivers/net/ixgb/ixgb_ethtool.c
index afde84868bea..0413cd95eda7 100644
--- a/drivers/net/ixgb/ixgb_ethtool.c
+++ b/drivers/net/ixgb/ixgb_ethtool.c
@@ -724,7 +724,6 @@ static const struct ethtool_ops ixgb_ethtool_ops = {
724 .phys_id = ixgb_phys_id, 724 .phys_id = ixgb_phys_id,
725 .get_stats_count = ixgb_get_stats_count, 725 .get_stats_count = ixgb_get_stats_count,
726 .get_ethtool_stats = ixgb_get_ethtool_stats, 726 .get_ethtool_stats = ixgb_get_ethtool_stats,
727 .get_perm_addr = ethtool_op_get_perm_addr,
728}; 727};
729 728
730void ixgb_set_ethtool_ops(struct net_device *netdev) 729void ixgb_set_ethtool_ops(struct net_device *netdev)
diff --git a/drivers/net/lguest_net.c b/drivers/net/lguest_net.c
index 112778652f7d..cab57911a80e 100644
--- a/drivers/net/lguest_net.c
+++ b/drivers/net/lguest_net.c
@@ -1,6 +1,13 @@
1/* A simple network driver for lguest. 1/*D:500
2 * The Guest network driver.
2 * 3 *
3 * Copyright 2006 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation 4 * This is very simple a virtual network driver, and our last Guest driver.
5 * The only trick is that it can talk directly to multiple other recipients
6 * (ie. other Guests on the same network). It can also be used with only the
7 * Host on the network.
8 :*/
9
10/* Copyright 2006 Rusty Russell <rusty@rustcorp.com.au> IBM Corporation
4 * 11 *
5 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
@@ -28,23 +35,47 @@
28#define MAX_LANS 4 35#define MAX_LANS 4
29#define NUM_SKBS 8 36#define NUM_SKBS 8
30 37
38/*M:011 Network code master Jeff Garzik points out numerous shortcomings in
39 * this driver if it aspires to greatness.
40 *
41 * Firstly, it doesn't use "NAPI": the networking's New API, and is poorer for
42 * it. As he says "NAPI means system-wide load leveling, across multiple
43 * network interfaces. Lack of NAPI can mean competition at higher loads."
44 *
45 * He also points out that we don't implement set_mac_address, so users cannot
46 * change the devices hardware address. When I asked why one would want to:
47 * "Bonding, and situations where you /do/ want the MAC address to "leak" out
48 * of the host onto the wider net."
49 *
50 * Finally, he would like module unloading: "It is not unrealistic to think of
51 * [un|re|]loading the net support module in an lguest guest. And, adding
52 * module support makes the programmer more responsible, because they now have
53 * to learn to clean up after themselves. Any driver that cannot clean up
54 * after itself is an incomplete driver in my book."
55 :*/
56
57/*D:530 The "struct lguestnet_info" contains all the information we need to
58 * know about the network device. */
31struct lguestnet_info 59struct lguestnet_info
32{ 60{
33 /* The shared page(s). */ 61 /* The mapped device page(s) (an array of "struct lguest_net"). */
34 struct lguest_net *peer; 62 struct lguest_net *peer;
63 /* The physical address of the device page(s) */
35 unsigned long peer_phys; 64 unsigned long peer_phys;
65 /* The size of the device page(s). */
36 unsigned long mapsize; 66 unsigned long mapsize;
37 67
38 /* The lguest_device I come from */ 68 /* The lguest_device I come from */
39 struct lguest_device *lgdev; 69 struct lguest_device *lgdev;
40 70
41 /* My peerid. */ 71 /* My peerid (ie. my slot in the array). */
42 unsigned int me; 72 unsigned int me;
43 73
44 /* Receive queue. */ 74 /* Receive queue: the network packets waiting to be filled. */
45 struct sk_buff *skb[NUM_SKBS]; 75 struct sk_buff *skb[NUM_SKBS];
46 struct lguest_dma dma[NUM_SKBS]; 76 struct lguest_dma dma[NUM_SKBS];
47}; 77};
78/*:*/
48 79
49/* How many bytes left in this page. */ 80/* How many bytes left in this page. */
50static unsigned int rest_of_page(void *data) 81static unsigned int rest_of_page(void *data)
@@ -52,39 +83,82 @@ static unsigned int rest_of_page(void *data)
52 return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE); 83 return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE);
53} 84}
54 85
55/* Simple convention: offset 4 * peernum. */ 86/*D:570 Each peer (ie. Guest or Host) on the network binds their receive
87 * buffers to a different key: we simply use the physical address of the
88 * device's memory page plus the peer number. The Host insists that all keys
89 * be a multiple of 4, so we multiply the peer number by 4. */
56static unsigned long peer_key(struct lguestnet_info *info, unsigned peernum) 90static unsigned long peer_key(struct lguestnet_info *info, unsigned peernum)
57{ 91{
58 return info->peer_phys + 4 * peernum; 92 return info->peer_phys + 4 * peernum;
59} 93}
60 94
95/* This is the routine which sets up a "struct lguest_dma" to point to a
96 * network packet, similar to req_to_dma() in lguest_blk.c. The structure of a
97 * "struct sk_buff" has grown complex over the years: it consists of a "head"
98 * linear section pointed to by "skb->data", and possibly an array of
99 * "fragments" in the case of a non-linear packet.
100 *
101 * Our receive buffers don't use fragments at all but outgoing skbs might, so
102 * we handle it. */
61static void skb_to_dma(const struct sk_buff *skb, unsigned int headlen, 103static void skb_to_dma(const struct sk_buff *skb, unsigned int headlen,
62 struct lguest_dma *dma) 104 struct lguest_dma *dma)
63{ 105{
64 unsigned int i, seg; 106 unsigned int i, seg;
65 107
108 /* First, we put the linear region into the "struct lguest_dma". Each
109 * entry can't go over a page boundary, so even though all our packets
110 * are 1514 bytes or less, we might need to use two entries here: */
66 for (i = seg = 0; i < headlen; seg++, i += rest_of_page(skb->data+i)) { 111 for (i = seg = 0; i < headlen; seg++, i += rest_of_page(skb->data+i)) {
67 dma->addr[seg] = virt_to_phys(skb->data + i); 112 dma->addr[seg] = virt_to_phys(skb->data + i);
68 dma->len[seg] = min((unsigned)(headlen - i), 113 dma->len[seg] = min((unsigned)(headlen - i),
69 rest_of_page(skb->data + i)); 114 rest_of_page(skb->data + i));
70 } 115 }
116
117 /* Now we handle the fragments: at least they're guaranteed not to go
118 * over a page. skb_shinfo(skb) returns a pointer to the structure
119 * which tells us about the number of fragments and the fragment
120 * array. */
71 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++, seg++) { 121 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++, seg++) {
72 const skb_frag_t *f = &skb_shinfo(skb)->frags[i]; 122 const skb_frag_t *f = &skb_shinfo(skb)->frags[i];
73 /* Should not happen with MTU less than 64k - 2 * PAGE_SIZE. */ 123 /* Should not happen with MTU less than 64k - 2 * PAGE_SIZE. */
74 if (seg == LGUEST_MAX_DMA_SECTIONS) { 124 if (seg == LGUEST_MAX_DMA_SECTIONS) {
125 /* We will end up sending a truncated packet should
126 * this ever happen. Plus, a cool log message! */
75 printk("Woah dude! Megapacket!\n"); 127 printk("Woah dude! Megapacket!\n");
76 break; 128 break;
77 } 129 }
78 dma->addr[seg] = page_to_phys(f->page) + f->page_offset; 130 dma->addr[seg] = page_to_phys(f->page) + f->page_offset;
79 dma->len[seg] = f->size; 131 dma->len[seg] = f->size;
80 } 132 }
133
134 /* If after all that we didn't use the entire "struct lguest_dma"
135 * array, we terminate it with a 0 length. */
81 if (seg < LGUEST_MAX_DMA_SECTIONS) 136 if (seg < LGUEST_MAX_DMA_SECTIONS)
82 dma->len[seg] = 0; 137 dma->len[seg] = 0;
83} 138}
84 139
85/* We overload multicast bit to show promiscuous mode. */ 140/*
141 * Packet transmission.
142 *
143 * Our packet transmission is a little unusual. A real network card would just
144 * send out the packet and leave the receivers to decide if they're interested.
145 * Instead, we look through the network device memory page and see if any of
146 * the ethernet addresses match the packet destination, and if so we send it to
147 * that Guest.
148 *
149 * This is made a little more complicated in two cases. The first case is
150 * broadcast packets: for that we send the packet to all Guests on the network,
151 * one at a time. The second case is "promiscuous" mode, where a Guest wants
152 * to see all the packets on the network. We need a way for the Guest to tell
153 * us it wants to see all packets, so it sets the "multicast" bit on its
154 * published MAC address, which is never valid in a real ethernet address.
155 */
86#define PROMISC_BIT 0x01 156#define PROMISC_BIT 0x01
87 157
158/* This is the callback which is summoned whenever the network device's
159 * multicast or promiscuous state changes. If the card is in promiscuous mode,
160 * we advertise that in our ethernet address in the device's memory. We do the
161 * same if Linux wants any or all multicast traffic. */
88static void lguestnet_set_multicast(struct net_device *dev) 162static void lguestnet_set_multicast(struct net_device *dev)
89{ 163{
90 struct lguestnet_info *info = netdev_priv(dev); 164 struct lguestnet_info *info = netdev_priv(dev);
@@ -95,11 +169,14 @@ static void lguestnet_set_multicast(struct net_device *dev)
95 info->peer[info->me].mac[0] &= ~PROMISC_BIT; 169 info->peer[info->me].mac[0] &= ~PROMISC_BIT;
96} 170}
97 171
172/* A simple test function to see if a peer wants to see all packets.*/
98static int promisc(struct lguestnet_info *info, unsigned int peer) 173static int promisc(struct lguestnet_info *info, unsigned int peer)
99{ 174{
100 return info->peer[peer].mac[0] & PROMISC_BIT; 175 return info->peer[peer].mac[0] & PROMISC_BIT;
101} 176}
102 177
178/* Another simple function to see if a peer's advertised ethernet address
179 * matches a packet's destination ethernet address. */
103static int mac_eq(const unsigned char mac[ETH_ALEN], 180static int mac_eq(const unsigned char mac[ETH_ALEN],
104 struct lguestnet_info *info, unsigned int peer) 181 struct lguestnet_info *info, unsigned int peer)
105{ 182{
@@ -109,6 +186,8 @@ static int mac_eq(const unsigned char mac[ETH_ALEN],
109 return memcmp(mac+1, info->peer[peer].mac+1, ETH_ALEN-1) == 0; 186 return memcmp(mac+1, info->peer[peer].mac+1, ETH_ALEN-1) == 0;
110} 187}
111 188
189/* This is the function which actually sends a packet once we've decided a
190 * peer wants it: */
112static void transfer_packet(struct net_device *dev, 191static void transfer_packet(struct net_device *dev,
113 struct sk_buff *skb, 192 struct sk_buff *skb,
114 unsigned int peernum) 193 unsigned int peernum)
@@ -116,76 +195,134 @@ static void transfer_packet(struct net_device *dev,
116 struct lguestnet_info *info = netdev_priv(dev); 195 struct lguestnet_info *info = netdev_priv(dev);
117 struct lguest_dma dma; 196 struct lguest_dma dma;
118 197
198 /* We use our handy "struct lguest_dma" packing function to prepare
199 * the skb for sending. */
119 skb_to_dma(skb, skb_headlen(skb), &dma); 200 skb_to_dma(skb, skb_headlen(skb), &dma);
120 pr_debug("xfer length %04x (%u)\n", htons(skb->len), skb->len); 201 pr_debug("xfer length %04x (%u)\n", htons(skb->len), skb->len);
121 202
203 /* This is the actual send call which copies the packet. */
122 lguest_send_dma(peer_key(info, peernum), &dma); 204 lguest_send_dma(peer_key(info, peernum), &dma);
205
206 /* Check that the entire packet was transmitted. If not, it could mean
207 * that the other Guest registered a short receive buffer, but this
208 * driver should never do that. More likely, the peer is dead. */
123 if (dma.used_len != skb->len) { 209 if (dma.used_len != skb->len) {
124 dev->stats.tx_carrier_errors++; 210 dev->stats.tx_carrier_errors++;
125 pr_debug("Bad xfer to peer %i: %i of %i (dma %p/%i)\n", 211 pr_debug("Bad xfer to peer %i: %i of %i (dma %p/%i)\n",
126 peernum, dma.used_len, skb->len, 212 peernum, dma.used_len, skb->len,
127 (void *)dma.addr[0], dma.len[0]); 213 (void *)dma.addr[0], dma.len[0]);
128 } else { 214 } else {
215 /* On success we update the stats. */
129 dev->stats.tx_bytes += skb->len; 216 dev->stats.tx_bytes += skb->len;
130 dev->stats.tx_packets++; 217 dev->stats.tx_packets++;
131 } 218 }
132} 219}
133 220
221/* Another helper function to tell is if a slot in the device memory is unused.
222 * Since we always set the Local Assignment bit in the ethernet address, the
223 * first byte can never be 0. */
134static int unused_peer(const struct lguest_net peer[], unsigned int num) 224static int unused_peer(const struct lguest_net peer[], unsigned int num)
135{ 225{
136 return peer[num].mac[0] == 0; 226 return peer[num].mac[0] == 0;
137} 227}
138 228
229/* Finally, here is the routine which handles an outgoing packet. It's called
230 * "start_xmit" for traditional reasons. */
139static int lguestnet_start_xmit(struct sk_buff *skb, struct net_device *dev) 231static int lguestnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
140{ 232{
141 unsigned int i; 233 unsigned int i;
142 int broadcast; 234 int broadcast;
143 struct lguestnet_info *info = netdev_priv(dev); 235 struct lguestnet_info *info = netdev_priv(dev);
236 /* Extract the destination ethernet address from the packet. */
144 const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest; 237 const unsigned char *dest = ((struct ethhdr *)skb->data)->h_dest;
145 238
146 pr_debug("%s: xmit %02x:%02x:%02x:%02x:%02x:%02x\n", 239 pr_debug("%s: xmit %02x:%02x:%02x:%02x:%02x:%02x\n",
147 dev->name, dest[0],dest[1],dest[2],dest[3],dest[4],dest[5]); 240 dev->name, dest[0],dest[1],dest[2],dest[3],dest[4],dest[5]);
148 241
242 /* If it's a multicast packet, we broadcast to everyone. That's not
243 * very efficient, but there are very few applications which actually
244 * use multicast, which is a shame really.
245 *
246 * As etherdevice.h points out: "By definition the broadcast address is
247 * also a multicast address." So we don't have to test for broadcast
248 * packets separately. */
149 broadcast = is_multicast_ether_addr(dest); 249 broadcast = is_multicast_ether_addr(dest);
250
251 /* Look through all the published ethernet addresses to see if we
252 * should send this packet. */
150 for (i = 0; i < info->mapsize/sizeof(struct lguest_net); i++) { 253 for (i = 0; i < info->mapsize/sizeof(struct lguest_net); i++) {
254 /* We don't send to ourselves (we actually can't SEND_DMA to
255 * ourselves anyway), and don't send to unused slots.*/
151 if (i == info->me || unused_peer(info->peer, i)) 256 if (i == info->me || unused_peer(info->peer, i))
152 continue; 257 continue;
153 258
259 /* If it's broadcast we send it. If they want every packet we
260 * send it. If the destination matches their address we send
261 * it. Otherwise we go to the next peer. */
154 if (!broadcast && !promisc(info, i) && !mac_eq(dest, info, i)) 262 if (!broadcast && !promisc(info, i) && !mac_eq(dest, info, i))
155 continue; 263 continue;
156 264
157 pr_debug("lguestnet %s: sending from %i to %i\n", 265 pr_debug("lguestnet %s: sending from %i to %i\n",
158 dev->name, info->me, i); 266 dev->name, info->me, i);
267 /* Our routine which actually does the transfer. */
159 transfer_packet(dev, skb, i); 268 transfer_packet(dev, skb, i);
160 } 269 }
270
271 /* An xmit routine is expected to dispose of the packet, so we do. */
161 dev_kfree_skb(skb); 272 dev_kfree_skb(skb);
273
274 /* As per kernel convention, 0 means success. This is why I love
275 * networking: even if we never sent to anyone, that's still
276 * success! */
162 return 0; 277 return 0;
163} 278}
164 279
165/* Find a new skb to put in this slot in shared mem. */ 280/*D:560
281 * Packet receiving.
282 *
283 * First, here's a helper routine which fills one of our array of receive
284 * buffers: */
166static int fill_slot(struct net_device *dev, unsigned int slot) 285static int fill_slot(struct net_device *dev, unsigned int slot)
167{ 286{
168 struct lguestnet_info *info = netdev_priv(dev); 287 struct lguestnet_info *info = netdev_priv(dev);
169 /* Try to create and register a new one. */ 288
289 /* We can receive ETH_DATA_LEN (1500) byte packets, plus a standard
290 * ethernet header of ETH_HLEN (14) bytes. */
170 info->skb[slot] = netdev_alloc_skb(dev, ETH_HLEN + ETH_DATA_LEN); 291 info->skb[slot] = netdev_alloc_skb(dev, ETH_HLEN + ETH_DATA_LEN);
171 if (!info->skb[slot]) { 292 if (!info->skb[slot]) {
172 printk("%s: could not fill slot %i\n", dev->name, slot); 293 printk("%s: could not fill slot %i\n", dev->name, slot);
173 return -ENOMEM; 294 return -ENOMEM;
174 } 295 }
175 296
297 /* skb_to_dma() is a helper which sets up the "struct lguest_dma" to
298 * point to the data in the skb: we also use it for sending out a
299 * packet. */
176 skb_to_dma(info->skb[slot], ETH_HLEN + ETH_DATA_LEN, &info->dma[slot]); 300 skb_to_dma(info->skb[slot], ETH_HLEN + ETH_DATA_LEN, &info->dma[slot]);
301
302 /* This is a Write Memory Barrier: it ensures that the entry in the
303 * receive buffer array is written *before* we set the "used_len" entry
304 * to 0. If the Host were looking at the receive buffer array from a
305 * different CPU, it could potentially see "used_len = 0" and not see
306 * the updated receive buffer information. This would be a horribly
307 * nasty bug, so make sure the compiler and CPU know this has to happen
308 * first. */
177 wmb(); 309 wmb();
178 /* Now we tell hypervisor it can use the slot. */ 310 /* Writing 0 to "used_len" tells the Host it can use this receive
311 * buffer now. */
179 info->dma[slot].used_len = 0; 312 info->dma[slot].used_len = 0;
180 return 0; 313 return 0;
181} 314}
182 315
316/* This is the actual receive routine. When we receive an interrupt from the
317 * Host to tell us a packet has been delivered, we arrive here: */
183static irqreturn_t lguestnet_rcv(int irq, void *dev_id) 318static irqreturn_t lguestnet_rcv(int irq, void *dev_id)
184{ 319{
185 struct net_device *dev = dev_id; 320 struct net_device *dev = dev_id;
186 struct lguestnet_info *info = netdev_priv(dev); 321 struct lguestnet_info *info = netdev_priv(dev);
187 unsigned int i, done = 0; 322 unsigned int i, done = 0;
188 323
324 /* Look through our entire receive array for an entry which has data
325 * in it. */
189 for (i = 0; i < ARRAY_SIZE(info->dma); i++) { 326 for (i = 0; i < ARRAY_SIZE(info->dma); i++) {
190 unsigned int length; 327 unsigned int length;
191 struct sk_buff *skb; 328 struct sk_buff *skb;
@@ -194,10 +331,16 @@ static irqreturn_t lguestnet_rcv(int irq, void *dev_id)
194 if (length == 0) 331 if (length == 0)
195 continue; 332 continue;
196 333
334 /* We've found one! Remember the skb (we grabbed the length
335 * above), and immediately refill the slot we've taken it
336 * from. */
197 done++; 337 done++;
198 skb = info->skb[i]; 338 skb = info->skb[i];
199 fill_slot(dev, i); 339 fill_slot(dev, i);
200 340
341 /* This shouldn't happen: micropackets could be sent by a
342 * badly-behaved Guest on the network, but the Host will never
343 * stuff more data in the buffer than the buffer length. */
201 if (length < ETH_HLEN || length > ETH_HLEN + ETH_DATA_LEN) { 344 if (length < ETH_HLEN || length > ETH_HLEN + ETH_DATA_LEN) {
202 pr_debug(KERN_WARNING "%s: unbelievable skb len: %i\n", 345 pr_debug(KERN_WARNING "%s: unbelievable skb len: %i\n",
203 dev->name, length); 346 dev->name, length);
@@ -205,36 +348,72 @@ static irqreturn_t lguestnet_rcv(int irq, void *dev_id)
205 continue; 348 continue;
206 } 349 }
207 350
351 /* skb_put(), what a great function! I've ranted about this
352 * function before (http://lkml.org/lkml/1999/9/26/24). You
353 * call it after you've added data to the end of an skb (in
354 * this case, it was the Host which wrote the data). */
208 skb_put(skb, length); 355 skb_put(skb, length);
356
357 /* The ethernet header contains a protocol field: we use the
358 * standard helper to extract it, and place the result in
359 * skb->protocol. The helper also sets up skb->pkt_type and
360 * eats up the ethernet header from the front of the packet. */
209 skb->protocol = eth_type_trans(skb, dev); 361 skb->protocol = eth_type_trans(skb, dev);
210 /* This is a reliable transport. */ 362
363 /* If this device doesn't need checksums for sending, we also
364 * don't need to check the packets when they come in. */
211 if (dev->features & NETIF_F_NO_CSUM) 365 if (dev->features & NETIF_F_NO_CSUM)
212 skb->ip_summed = CHECKSUM_UNNECESSARY; 366 skb->ip_summed = CHECKSUM_UNNECESSARY;
367
368 /* As a last resort for debugging the driver or the lguest I/O
369 * subsystem, you can uncomment the "#define DEBUG" at the top
370 * of this file, which turns all the pr_debug() into printk()
371 * and floods the logs. */
213 pr_debug("Receiving skb proto 0x%04x len %i type %i\n", 372 pr_debug("Receiving skb proto 0x%04x len %i type %i\n",
214 ntohs(skb->protocol), skb->len, skb->pkt_type); 373 ntohs(skb->protocol), skb->len, skb->pkt_type);
215 374
375 /* Update the packet and byte counts (visible from ifconfig,
376 * and good for debugging). */
216 dev->stats.rx_bytes += skb->len; 377 dev->stats.rx_bytes += skb->len;
217 dev->stats.rx_packets++; 378 dev->stats.rx_packets++;
379
380 /* Hand our fresh network packet into the stack's "network
381 * interface receive" routine. That will free the packet
382 * itself when it's finished. */
218 netif_rx(skb); 383 netif_rx(skb);
219 } 384 }
385
386 /* If we found any packets, we assume the interrupt was for us. */
220 return done ? IRQ_HANDLED : IRQ_NONE; 387 return done ? IRQ_HANDLED : IRQ_NONE;
221} 388}
222 389
390/*D:550 This is where we start: when the device is brought up by dhcpd or
391 * ifconfig. At this point we advertise our MAC address to the rest of the
392 * network, and register receive buffers ready for incoming packets. */
223static int lguestnet_open(struct net_device *dev) 393static int lguestnet_open(struct net_device *dev)
224{ 394{
225 int i; 395 int i;
226 struct lguestnet_info *info = netdev_priv(dev); 396 struct lguestnet_info *info = netdev_priv(dev);
227 397
228 /* Set up our MAC address */ 398 /* Copy our MAC address into the device page, so others on the network
399 * can find us. */
229 memcpy(info->peer[info->me].mac, dev->dev_addr, ETH_ALEN); 400 memcpy(info->peer[info->me].mac, dev->dev_addr, ETH_ALEN);
230 401
231 /* Turn on promisc mode if needed */ 402 /* We might already be in promisc mode (dev->flags & IFF_PROMISC). Our
403 * set_multicast callback handles this already, so we call it now. */
232 lguestnet_set_multicast(dev); 404 lguestnet_set_multicast(dev);
233 405
406 /* Allocate packets and put them into our "struct lguest_dma" array.
407 * If we fail to allocate all the packets we could still limp along,
408 * but it's a sign of real stress so we should probably give up now. */
234 for (i = 0; i < ARRAY_SIZE(info->dma); i++) { 409 for (i = 0; i < ARRAY_SIZE(info->dma); i++) {
235 if (fill_slot(dev, i) != 0) 410 if (fill_slot(dev, i) != 0)
236 goto cleanup; 411 goto cleanup;
237 } 412 }
413
414 /* Finally we tell the Host where our array of "struct lguest_dma"
415 * receive buffers is, binding it to the key corresponding to the
416 * device's physical memory plus our peerid. */
238 if (lguest_bind_dma(peer_key(info,info->me), info->dma, 417 if (lguest_bind_dma(peer_key(info,info->me), info->dma,
239 NUM_SKBS, lgdev_irq(info->lgdev)) != 0) 418 NUM_SKBS, lgdev_irq(info->lgdev)) != 0)
240 goto cleanup; 419 goto cleanup;
@@ -245,22 +424,29 @@ cleanup:
245 dev_kfree_skb(info->skb[i]); 424 dev_kfree_skb(info->skb[i]);
246 return -ENOMEM; 425 return -ENOMEM;
247} 426}
427/*:*/
248 428
429/* The close routine is called when the device is no longer in use: we clean up
430 * elegantly. */
249static int lguestnet_close(struct net_device *dev) 431static int lguestnet_close(struct net_device *dev)
250{ 432{
251 unsigned int i; 433 unsigned int i;
252 struct lguestnet_info *info = netdev_priv(dev); 434 struct lguestnet_info *info = netdev_priv(dev);
253 435
254 /* Clear all trace: others might deliver packets, we'll ignore it. */ 436 /* Clear all trace of our existence out of the device memory by setting
437 * the slot which held our MAC address to 0 (unused). */
255 memset(&info->peer[info->me], 0, sizeof(info->peer[info->me])); 438 memset(&info->peer[info->me], 0, sizeof(info->peer[info->me]));
256 439
257 /* Deregister sg lists. */ 440 /* Unregister our array of receive buffers */
258 lguest_unbind_dma(peer_key(info, info->me), info->dma); 441 lguest_unbind_dma(peer_key(info, info->me), info->dma);
259 for (i = 0; i < ARRAY_SIZE(info->dma); i++) 442 for (i = 0; i < ARRAY_SIZE(info->dma); i++)
260 dev_kfree_skb(info->skb[i]); 443 dev_kfree_skb(info->skb[i]);
261 return 0; 444 return 0;
262} 445}
263 446
447/*D:510 The network device probe function is basically a standard ethernet
448 * device setup. It reads the "struct lguest_device_desc" and sets the "struct
449 * net_device". Oh, the line-by-line excitement! Let's skip over it. :*/
264static int lguestnet_probe(struct lguest_device *lgdev) 450static int lguestnet_probe(struct lguest_device *lgdev)
265{ 451{
266 int err, irqf = IRQF_SHARED; 452 int err, irqf = IRQF_SHARED;
@@ -290,10 +476,16 @@ static int lguestnet_probe(struct lguest_device *lgdev)
290 dev->stop = lguestnet_close; 476 dev->stop = lguestnet_close;
291 dev->hard_start_xmit = lguestnet_start_xmit; 477 dev->hard_start_xmit = lguestnet_start_xmit;
292 478
293 /* Turning on/off promisc will call dev->set_multicast_list. 479 /* We don't actually support multicast yet, but turning on/off
294 * We don't actually support multicast yet */ 480 * promisc also calls dev->set_multicast_list. */
295 dev->set_multicast_list = lguestnet_set_multicast; 481 dev->set_multicast_list = lguestnet_set_multicast;
296 SET_NETDEV_DEV(dev, &lgdev->dev); 482 SET_NETDEV_DEV(dev, &lgdev->dev);
483
484 /* The network code complains if you have "scatter-gather" capability
485 * if you don't also handle checksums (it seem that would be
486 * "illogical"). So we use a lie of omission and don't tell it that we
487 * can handle scattered packets unless we also don't want checksums,
488 * even though to us they're completely independent. */
297 if (desc->features & LGUEST_NET_F_NOCSUM) 489 if (desc->features & LGUEST_NET_F_NOCSUM)
298 dev->features = NETIF_F_SG|NETIF_F_NO_CSUM; 490 dev->features = NETIF_F_SG|NETIF_F_NO_CSUM;
299 491
@@ -325,6 +517,9 @@ static int lguestnet_probe(struct lguest_device *lgdev)
325 } 517 }
326 518
327 pr_debug("lguestnet: registered device %s\n", dev->name); 519 pr_debug("lguestnet: registered device %s\n", dev->name);
520 /* Finally, we put the "struct net_device" in the generic "struct
521 * lguest_device"s private pointer. Again, it's not necessary, but
522 * makes sure the cool kernel kids don't tease us. */
328 lgdev->private = dev; 523 lgdev->private = dev;
329 return 0; 524 return 0;
330 525
@@ -352,3 +547,11 @@ module_init(lguestnet_init);
352 547
353MODULE_DESCRIPTION("Lguest network driver"); 548MODULE_DESCRIPTION("Lguest network driver");
354MODULE_LICENSE("GPL"); 549MODULE_LICENSE("GPL");
550
551/*D:580
552 * This is the last of the Drivers, and with this we have covered the many and
553 * wonderous and fine (and boring) details of the Guest.
554 *
555 * "make Launcher" beckons, where we answer questions like "Where do Guests
556 * come from?", and "What do you do when someone asks for optimization?"
557 */
diff --git a/drivers/net/lib8390.c b/drivers/net/lib8390.c
index 5c86e737f954..c429a5002dd6 100644
--- a/drivers/net/lib8390.c
+++ b/drivers/net/lib8390.c
@@ -143,6 +143,52 @@ static void __NS8390_init(struct net_device *dev, int startp);
143 * annoying the transmit function is called bh atomic. That places 143 * annoying the transmit function is called bh atomic. That places
144 * restrictions on the user context callers as disable_irq won't save 144 * restrictions on the user context callers as disable_irq won't save
145 * them. 145 * them.
146 *
147 * Additional explanation of problems with locking by Alan Cox:
148 *
149 * "The author (me) didn't use spin_lock_irqsave because the slowness of the
150 * card means that approach caused horrible problems like losing serial data
151 * at 38400 baud on some chips. Rememeber many 8390 nics on PCI were ISA
152 * chips with FPGA front ends.
153 *
154 * Ok the logic behind the 8390 is very simple:
155 *
156 * Things to know
157 * - IRQ delivery is asynchronous to the PCI bus
158 * - Blocking the local CPU IRQ via spin locks was too slow
159 * - The chip has register windows needing locking work
160 *
161 * So the path was once (I say once as people appear to have changed it
162 * in the mean time and it now looks rather bogus if the changes to use
163 * disable_irq_nosync_irqsave are disabling the local IRQ)
164 *
165 *
166 * Take the page lock
167 * Mask the IRQ on chip
168 * Disable the IRQ (but not mask locally- someone seems to have
169 * broken this with the lock validator stuff)
170 * [This must be _nosync as the page lock may otherwise
171 * deadlock us]
172 * Drop the page lock and turn IRQs back on
173 *
174 * At this point an existing IRQ may still be running but we can't
175 * get a new one
176 *
177 * Take the lock (so we know the IRQ has terminated) but don't mask
178 * the IRQs on the processor
179 * Set irqlock [for debug]
180 *
181 * Transmit (slow as ****)
182 *
183 * re-enable the IRQ
184 *
185 *
186 * We have to use disable_irq because otherwise you will get delayed
187 * interrupts on the APIC bus deadlocking the transmit path.
188 *
189 * Quite hairy but the chip simply wasn't designed for SMP and you can't
190 * even ACK an interrupt without risking corrupting other parallel
191 * activities on the chip." [lkml, 25 Jul 2007]
146 */ 192 */
147 193
148 194
@@ -219,15 +265,6 @@ static void ei_tx_timeout(struct net_device *dev)
219 int txsr, isr, tickssofar = jiffies - dev->trans_start; 265 int txsr, isr, tickssofar = jiffies - dev->trans_start;
220 unsigned long flags; 266 unsigned long flags;
221 267
222#if defined(CONFIG_M32R) && defined(CONFIG_SMP)
223 unsigned long icucr;
224
225 local_irq_save(flags);
226 icucr = inl(M32R_ICU_CR1_PORTL);
227 icucr |= M32R_ICUCR_ISMOD11;
228 outl(icucr, M32R_ICU_CR1_PORTL);
229 local_irq_restore(flags);
230#endif
231 ei_local->stat.tx_errors++; 268 ei_local->stat.tx_errors++;
232 269
233 spin_lock_irqsave(&ei_local->page_lock, flags); 270 spin_lock_irqsave(&ei_local->page_lock, flags);
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 6ba6ed2b480a..5106c2328d12 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -229,7 +229,12 @@ struct net_device loopback_dev = {
229/* Setup and register the loopback device. */ 229/* Setup and register the loopback device. */
230static int __init loopback_init(void) 230static int __init loopback_init(void)
231{ 231{
232 return register_netdev(&loopback_dev); 232 int err = register_netdev(&loopback_dev);
233
234 if (err)
235 panic("loopback: Failed to register netdevice: %d\n", err);
236
237 return err;
233}; 238};
234 239
235module_init(loopback_init); 240module_init(loopback_init);
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c
index d0808fa3ec82..5b87183e62ce 100644
--- a/drivers/net/mlx4/mr.c
+++ b/drivers/net/mlx4/mr.c
@@ -255,10 +255,8 @@ int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access,
255 int err; 255 int err;
256 256
257 index = mlx4_bitmap_alloc(&priv->mr_table.mpt_bitmap); 257 index = mlx4_bitmap_alloc(&priv->mr_table.mpt_bitmap);
258 if (index == -1) { 258 if (index == -1)
259 err = -ENOMEM; 259 return -ENOMEM;
260 goto err;
261 }
262 260
263 mr->iova = iova; 261 mr->iova = iova;
264 mr->size = size; 262 mr->size = size;
@@ -269,15 +267,8 @@ int mlx4_mr_alloc(struct mlx4_dev *dev, u32 pd, u64 iova, u64 size, u32 access,
269 267
270 err = mlx4_mtt_init(dev, npages, page_shift, &mr->mtt); 268 err = mlx4_mtt_init(dev, npages, page_shift, &mr->mtt);
271 if (err) 269 if (err)
272 goto err_index; 270 mlx4_bitmap_free(&priv->mr_table.mpt_bitmap, index);
273
274 return 0;
275
276err_index:
277 mlx4_bitmap_free(&priv->mr_table.mpt_bitmap, index);
278 271
279err:
280 kfree(mr);
281 return err; 272 return err;
282} 273}
283EXPORT_SYMBOL_GPL(mlx4_mr_alloc); 274EXPORT_SYMBOL_GPL(mlx4_mr_alloc);
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index cfdeaf7aa163..f81d9398d605 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -638,7 +638,6 @@ static const struct ethtool_ops ne2k_pci_ethtool_ops = {
638 .get_drvinfo = ne2k_pci_get_drvinfo, 638 .get_drvinfo = ne2k_pci_get_drvinfo,
639 .get_tx_csum = ethtool_op_get_tx_csum, 639 .get_tx_csum = ethtool_op_get_tx_csum,
640 .get_sg = ethtool_op_get_sg, 640 .get_sg = ethtool_op_get_sg,
641 .get_perm_addr = ethtool_op_get_perm_addr,
642}; 641};
643 642
644static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev) 643static void __devexit ne2k_pci_remove_one (struct pci_dev *pdev)
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 325269d8ae38..d4c92cc879d4 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -1179,8 +1179,7 @@ dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
1179 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4)) 1179 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), &ctrl, 4))
1180 printk(KERN_ERR "failed to read dma watchdog status\n"); 1180 printk(KERN_ERR "failed to read dma watchdog status\n");
1181 1181
1182 return ((netxen_get_dma_watchdog_enabled(ctrl) == 0) && 1182 return (netxen_get_dma_watchdog_enabled(ctrl) == 0);
1183 (netxen_get_dma_watchdog_disabled(ctrl) == 0));
1184} 1183}
1185 1184
1186static inline int 1185static inline int
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index 0175f6c353f6..a6138b474b4a 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -755,5 +755,4 @@ struct ethtool_ops netxen_nic_ethtool_ops = {
755 .get_strings = netxen_nic_get_strings, 755 .get_strings = netxen_nic_get_strings,
756 .get_stats_count = netxen_nic_get_stats_count, 756 .get_stats_count = netxen_nic_get_stats_count,
757 .get_ethtool_stats = netxen_nic_get_ethtool_stats, 757 .get_ethtool_stats = netxen_nic_get_ethtool_stats,
758 .get_perm_addr = ethtool_op_get_perm_addr,
759}; 758};
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index b703ccfe040b..08a62acde8bf 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -46,7 +46,7 @@ MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
46MODULE_LICENSE("GPL"); 46MODULE_LICENSE("GPL");
47MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID); 47MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID);
48 48
49char netxen_nic_driver_name[] = "netxen-nic"; 49char netxen_nic_driver_name[] = "netxen_nic";
50static char netxen_nic_driver_string[] = "NetXen Network Driver version " 50static char netxen_nic_driver_string[] = "NetXen Network Driver version "
51 NETXEN_NIC_LINUX_VERSIONID; 51 NETXEN_NIC_LINUX_VERSIONID;
52 52
@@ -335,7 +335,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
335 adapter->ahw.pdev = pdev; 335 adapter->ahw.pdev = pdev;
336 adapter->ahw.pci_func = pci_func_id; 336 adapter->ahw.pci_func = pci_func_id;
337 spin_lock_init(&adapter->tx_lock); 337 spin_lock_init(&adapter->tx_lock);
338 spin_lock_init(&adapter->lock);
339 338
340 /* remap phys address */ 339 /* remap phys address */
341 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ 340 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */
@@ -640,6 +639,10 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
640 NETXEN_CRB_NORMALIZE(adapter, 639 NETXEN_CRB_NORMALIZE(adapter,
641 NETXEN_ROMUSB_GLB_PEGTUNE_DONE)); 640 NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
642 /* Handshake with the card before we register the devices. */ 641 /* Handshake with the card before we register the devices. */
642 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
643 netxen_pinit_from_rom(adapter, 0);
644 msleep(1);
645 netxen_load_firmware(adapter);
643 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 646 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
644 } 647 }
645 648
@@ -782,19 +785,18 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
782 785
783 if (adapter->portnum == 0) { 786 if (adapter->portnum == 0) {
784 if (init_firmware_done) { 787 if (init_firmware_done) {
785 dma_watchdog_shutdown_request(adapter);
786 msleep(100);
787 i = 100; 788 i = 100;
788 while ((dma_watchdog_shutdown_poll_result(adapter) != 1) && i) { 789 do {
789 printk(KERN_INFO "dma_watchdog_shutdown_poll still in progress\n"); 790 if (dma_watchdog_shutdown_request(adapter) == 1)
791 break;
790 msleep(100); 792 msleep(100);
791 i--; 793 if (dma_watchdog_shutdown_poll_result(adapter) == 1)
792 } 794 break;
795 } while (--i);
793 796
794 if (i == 0) { 797 if (i == 0)
795 printk(KERN_ERR "dma_watchdog_shutdown_request failed\n"); 798 printk(KERN_ERR "%s: dma_watchdog_shutdown failed\n",
796 return; 799 netdev->name);
797 }
798 800
799 /* clear the register for future unloads/loads */ 801 /* clear the register for future unloads/loads */
800 writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_CAM_RAM(0x1fc))); 802 writel(0, NETXEN_CRB_NORMALIZE(adapter, NETXEN_CAM_RAM(0x1fc)));
@@ -803,11 +805,9 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
803 805
804 /* leave the hw in the same state as reboot */ 806 /* leave the hw in the same state as reboot */
805 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); 807 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
806 if (netxen_pinit_from_rom(adapter, 0)) 808 netxen_pinit_from_rom(adapter, 0);
807 return;
808 msleep(1); 809 msleep(1);
809 if (netxen_load_firmware(adapter)) 810 netxen_load_firmware(adapter);
810 return;
811 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 811 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
812 } 812 }
813 813
@@ -816,22 +816,21 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
816 printk(KERN_INFO "State: 0x%0x\n", 816 printk(KERN_INFO "State: 0x%0x\n",
817 readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE))); 817 readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)));
818 818
819 dma_watchdog_shutdown_request(adapter);
820 msleep(100);
821 i = 100; 819 i = 100;
822 while ((dma_watchdog_shutdown_poll_result(adapter) != 1) && i) { 820 do {
823 printk(KERN_INFO "dma_watchdog_shutdown_poll still in progress\n"); 821 if (dma_watchdog_shutdown_request(adapter) == 1)
822 break;
824 msleep(100); 823 msleep(100);
825 i--; 824 if (dma_watchdog_shutdown_poll_result(adapter) == 1)
826 } 825 break;
826 } while (--i);
827 827
828 if (i) { 828 if (i) {
829 netxen_free_adapter_offload(adapter); 829 netxen_free_adapter_offload(adapter);
830 } else { 830 } else {
831 printk(KERN_ERR "failed to dma shutdown\n"); 831 printk(KERN_ERR "%s: dma_watchdog_shutdown failed\n",
832 return; 832 netdev->name);
833 } 833 }
834
835 } 834 }
836 835
837 iounmap(adapter->ahw.db_base); 836 iounmap(adapter->ahw.db_base);
@@ -895,8 +894,6 @@ static int netxen_nic_open(struct net_device *netdev)
895 894
896 /* Done here again so that even if phantom sw overwrote it, 895 /* Done here again so that even if phantom sw overwrote it,
897 * we set it */ 896 * we set it */
898 if (adapter->macaddr_set)
899 adapter->macaddr_set(adapter, netdev->dev_addr);
900 if (adapter->init_port 897 if (adapter->init_port
901 && adapter->init_port(adapter, adapter->portnum) != 0) { 898 && adapter->init_port(adapter, adapter->portnum) != 0) {
902 del_timer_sync(&adapter->watchdog_timer); 899 del_timer_sync(&adapter->watchdog_timer);
@@ -904,6 +901,8 @@ static int netxen_nic_open(struct net_device *netdev)
904 netxen_nic_driver_name, adapter->portnum); 901 netxen_nic_driver_name, adapter->portnum);
905 return -EIO; 902 return -EIO;
906 } 903 }
904 if (adapter->macaddr_set)
905 adapter->macaddr_set(adapter, netdev->dev_addr);
907 906
908 netxen_nic_set_link_parameters(adapter); 907 netxen_nic_set_link_parameters(adapter);
909 908
@@ -930,6 +929,8 @@ static int netxen_nic_close(struct net_device *netdev)
930 netif_carrier_off(netdev); 929 netif_carrier_off(netdev);
931 netif_stop_queue(netdev); 930 netif_stop_queue(netdev);
932 931
932 netxen_nic_disable_int(adapter);
933
933 cmd_buff = adapter->cmd_buf_arr; 934 cmd_buff = adapter->cmd_buf_arr;
934 for (i = 0; i < adapter->max_tx_desc_count; i++) { 935 for (i = 0; i < adapter->max_tx_desc_count; i++) {
935 buffrag = cmd_buff->frag_array; 936 buffrag = cmd_buff->frag_array;
@@ -1226,15 +1227,12 @@ static void netxen_tx_timeout_task(struct work_struct *work)
1226{ 1227{
1227 struct netxen_adapter *adapter = 1228 struct netxen_adapter *adapter =
1228 container_of(work, struct netxen_adapter, tx_timeout_task); 1229 container_of(work, struct netxen_adapter, tx_timeout_task);
1229 unsigned long flags;
1230 1230
1231 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n", 1231 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n",
1232 netxen_nic_driver_name, adapter->netdev->name); 1232 netxen_nic_driver_name, adapter->netdev->name);
1233 1233
1234 spin_lock_irqsave(&adapter->lock, flags);
1235 netxen_nic_close(adapter->netdev); 1234 netxen_nic_close(adapter->netdev);
1236 netxen_nic_open(adapter->netdev); 1235 netxen_nic_open(adapter->netdev);
1237 spin_unlock_irqrestore(&adapter->lock, flags);
1238 adapter->netdev->trans_start = jiffies; 1236 adapter->netdev->trans_start = jiffies;
1239 netif_wake_queue(adapter->netdev); 1237 netif_wake_queue(adapter->netdev);
1240} 1238}
@@ -1243,28 +1241,12 @@ static int
1243netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev) 1241netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
1244{ 1242{
1245 u32 ret = 0; 1243 u32 ret = 0;
1246 u32 our_int = 0;
1247 1244
1248 DPRINTK(INFO, "Entered handle ISR\n"); 1245 DPRINTK(INFO, "Entered handle ISR\n");
1249 adapter->stats.ints++; 1246 adapter->stats.ints++;
1250 1247
1251 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
1252 our_int = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
1253 /* not our interrupt */
1254 if ((our_int & (0x80 << adapter->portnum)) == 0)
1255 return ret;
1256 }
1257
1258 netxen_nic_disable_int(adapter); 1248 netxen_nic_disable_int(adapter);
1259 1249
1260 if (adapter->intr_scheme == INTR_SCHEME_PERPORT) {
1261 /* claim interrupt */
1262 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
1263 writel(our_int & ~((u32)(0x80 << adapter->portnum)),
1264 NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
1265 }
1266 }
1267
1268 if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) { 1250 if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) {
1269 if (netif_rx_schedule_prep(netdev)) { 1251 if (netif_rx_schedule_prep(netdev)) {
1270 /* 1252 /*
@@ -1298,6 +1280,7 @@ irqreturn_t netxen_intr(int irq, void *data)
1298{ 1280{
1299 struct netxen_adapter *adapter; 1281 struct netxen_adapter *adapter;
1300 struct net_device *netdev; 1282 struct net_device *netdev;
1283 u32 our_int = 0;
1301 1284
1302 if (unlikely(!irq)) { 1285 if (unlikely(!irq)) {
1303 return IRQ_NONE; /* Not our interrupt */ 1286 return IRQ_NONE; /* Not our interrupt */
@@ -1305,7 +1288,22 @@ irqreturn_t netxen_intr(int irq, void *data)
1305 1288
1306 adapter = (struct netxen_adapter *)data; 1289 adapter = (struct netxen_adapter *)data;
1307 netdev = adapter->netdev; 1290 netdev = adapter->netdev;
1308 /* process our status queue (for all 4 ports) */ 1291
1292 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
1293 our_int = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
1294 /* not our interrupt */
1295 if ((our_int & (0x80 << adapter->portnum)) == 0)
1296 return IRQ_NONE;
1297 }
1298
1299 if (adapter->intr_scheme == INTR_SCHEME_PERPORT) {
1300 /* claim interrupt */
1301 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
1302 writel(our_int & ~((u32)(0x80 << adapter->portnum)),
1303 NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
1304 }
1305 }
1306
1309 if (netif_running(netdev)) 1307 if (netif_running(netdev))
1310 netxen_handle_int(adapter, netdev); 1308 netxen_handle_int(adapter, netdev);
1311 1309
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 73da611fd536..997c2d0c83bb 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -996,7 +996,7 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)
996{ 996{
997 struct net_device *dev = (struct net_device *) dev_id; 997 struct net_device *dev = (struct net_device *) dev_id;
998 mace_private *lp = netdev_priv(dev); 998 mace_private *lp = netdev_priv(dev);
999 kio_addr_t ioaddr = dev->base_addr; 999 kio_addr_t ioaddr;
1000 int status; 1000 int status;
1001 int IntrCnt = MACE_MAX_IR_ITERATIONS; 1001 int IntrCnt = MACE_MAX_IR_ITERATIONS;
1002 1002
@@ -1006,6 +1006,8 @@ static irqreturn_t mace_interrupt(int irq, void *dev_id)
1006 return IRQ_NONE; 1006 return IRQ_NONE;
1007 } 1007 }
1008 1008
1009 ioaddr = dev->base_addr;
1010
1009 if (lp->tx_irq_disabled) { 1011 if (lp->tx_irq_disabled) {
1010 printk( 1012 printk(
1011 (lp->tx_irq_disabled? 1013 (lp->tx_irq_disabled?
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 7912dbd14251..af6728cb49c3 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -1368,6 +1368,7 @@ static int smc_start_xmit(struct sk_buff *skb, struct net_device *dev)
1368 kio_addr_t ioaddr = dev->base_addr; 1368 kio_addr_t ioaddr = dev->base_addr;
1369 u_short num_pages; 1369 u_short num_pages;
1370 short time_out, ir; 1370 short time_out, ir;
1371 unsigned long flags;
1371 1372
1372 netif_stop_queue(dev); 1373 netif_stop_queue(dev);
1373 1374
@@ -1395,6 +1396,7 @@ static int smc_start_xmit(struct sk_buff *skb, struct net_device *dev)
1395 /* A packet is now waiting. */ 1396 /* A packet is now waiting. */
1396 smc->packets_waiting++; 1397 smc->packets_waiting++;
1397 1398
1399 spin_lock_irqsave(&smc->lock, flags);
1398 SMC_SELECT_BANK(2); /* Paranoia, we should always be in window 2 */ 1400 SMC_SELECT_BANK(2); /* Paranoia, we should always be in window 2 */
1399 1401
1400 /* need MC_RESET to keep the memory consistent. errata? */ 1402 /* need MC_RESET to keep the memory consistent. errata? */
@@ -1411,6 +1413,7 @@ static int smc_start_xmit(struct sk_buff *skb, struct net_device *dev)
1411 /* Acknowledge the interrupt, send the packet. */ 1413 /* Acknowledge the interrupt, send the packet. */
1412 outw((ir&0xff00) | IM_ALLOC_INT, ioaddr + INTERRUPT); 1414 outw((ir&0xff00) | IM_ALLOC_INT, ioaddr + INTERRUPT);
1413 smc_hardware_send_packet(dev); /* Send the packet now.. */ 1415 smc_hardware_send_packet(dev); /* Send the packet now.. */
1416 spin_unlock_irqrestore(&smc->lock, flags);
1414 return 0; 1417 return 0;
1415 } 1418 }
1416 } 1419 }
@@ -1418,6 +1421,7 @@ static int smc_start_xmit(struct sk_buff *skb, struct net_device *dev)
1418 /* Otherwise defer until the Tx-space-allocated interrupt. */ 1421 /* Otherwise defer until the Tx-space-allocated interrupt. */
1419 DEBUG(2, "%s: memory allocation deferred.\n", dev->name); 1422 DEBUG(2, "%s: memory allocation deferred.\n", dev->name);
1420 outw((IM_ALLOC_INT << 8) | (ir & 0xff00), ioaddr + INTERRUPT); 1423 outw((IM_ALLOC_INT << 8) | (ir & 0xff00), ioaddr + INTERRUPT);
1424 spin_unlock_irqrestore(&smc->lock, flags);
1421 1425
1422 return 0; 1426 return 0;
1423} 1427}
@@ -1523,6 +1527,7 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id)
1523 DEBUG(3, "%s: SMC91c92 interrupt %d at %#x.\n", dev->name, 1527 DEBUG(3, "%s: SMC91c92 interrupt %d at %#x.\n", dev->name,
1524 irq, ioaddr); 1528 irq, ioaddr);
1525 1529
1530 spin_lock(&smc->lock);
1526 smc->watchdog = 0; 1531 smc->watchdog = 0;
1527 saved_bank = inw(ioaddr + BANK_SELECT); 1532 saved_bank = inw(ioaddr + BANK_SELECT);
1528 if ((saved_bank & 0xff00) != 0x3300) { 1533 if ((saved_bank & 0xff00) != 0x3300) {
@@ -1620,6 +1625,7 @@ irq_done:
1620 readb(smc->base+MEGAHERTZ_ISR); 1625 readb(smc->base+MEGAHERTZ_ISR);
1621 } 1626 }
1622#endif 1627#endif
1628 spin_unlock(&smc->lock);
1623 return IRQ_RETVAL(handled); 1629 return IRQ_RETVAL(handled);
1624} 1630}
1625 1631
@@ -1902,6 +1908,9 @@ static void media_check(u_long arg)
1902 kio_addr_t ioaddr = dev->base_addr; 1908 kio_addr_t ioaddr = dev->base_addr;
1903 u_short i, media, saved_bank; 1909 u_short i, media, saved_bank;
1904 u_short link; 1910 u_short link;
1911 unsigned long flags;
1912
1913 spin_lock_irqsave(&smc->lock, flags);
1905 1914
1906 saved_bank = inw(ioaddr + BANK_SELECT); 1915 saved_bank = inw(ioaddr + BANK_SELECT);
1907 1916
@@ -1934,6 +1943,7 @@ static void media_check(u_long arg)
1934 smc->media.expires = jiffies + HZ/100; 1943 smc->media.expires = jiffies + HZ/100;
1935 add_timer(&smc->media); 1944 add_timer(&smc->media);
1936 SMC_SELECT_BANK(saved_bank); 1945 SMC_SELECT_BANK(saved_bank);
1946 spin_unlock_irqrestore(&smc->lock, flags);
1937 return; 1947 return;
1938 } 1948 }
1939 1949
@@ -2007,6 +2017,7 @@ reschedule:
2007 smc->media.expires = jiffies + HZ; 2017 smc->media.expires = jiffies + HZ;
2008 add_timer(&smc->media); 2018 add_timer(&smc->media);
2009 SMC_SELECT_BANK(saved_bank); 2019 SMC_SELECT_BANK(saved_bank);
2020 spin_unlock_irqrestore(&smc->lock, flags);
2010} 2021}
2011 2022
2012static int smc_link_ok(struct net_device *dev) 2023static int smc_link_ok(struct net_device *dev)
@@ -2094,14 +2105,14 @@ static int smc_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2094 u16 saved_bank = inw(ioaddr + BANK_SELECT); 2105 u16 saved_bank = inw(ioaddr + BANK_SELECT);
2095 int ret; 2106 int ret;
2096 2107
2097 SMC_SELECT_BANK(3);
2098 spin_lock_irq(&smc->lock); 2108 spin_lock_irq(&smc->lock);
2109 SMC_SELECT_BANK(3);
2099 if (smc->cfg & CFG_MII_SELECT) 2110 if (smc->cfg & CFG_MII_SELECT)
2100 ret = mii_ethtool_gset(&smc->mii_if, ecmd); 2111 ret = mii_ethtool_gset(&smc->mii_if, ecmd);
2101 else 2112 else
2102 ret = smc_netdev_get_ecmd(dev, ecmd); 2113 ret = smc_netdev_get_ecmd(dev, ecmd);
2103 spin_unlock_irq(&smc->lock);
2104 SMC_SELECT_BANK(saved_bank); 2114 SMC_SELECT_BANK(saved_bank);
2115 spin_unlock_irq(&smc->lock);
2105 return ret; 2116 return ret;
2106} 2117}
2107 2118
@@ -2112,14 +2123,14 @@ static int smc_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2112 u16 saved_bank = inw(ioaddr + BANK_SELECT); 2123 u16 saved_bank = inw(ioaddr + BANK_SELECT);
2113 int ret; 2124 int ret;
2114 2125
2115 SMC_SELECT_BANK(3);
2116 spin_lock_irq(&smc->lock); 2126 spin_lock_irq(&smc->lock);
2127 SMC_SELECT_BANK(3);
2117 if (smc->cfg & CFG_MII_SELECT) 2128 if (smc->cfg & CFG_MII_SELECT)
2118 ret = mii_ethtool_sset(&smc->mii_if, ecmd); 2129 ret = mii_ethtool_sset(&smc->mii_if, ecmd);
2119 else 2130 else
2120 ret = smc_netdev_set_ecmd(dev, ecmd); 2131 ret = smc_netdev_set_ecmd(dev, ecmd);
2121 spin_unlock_irq(&smc->lock);
2122 SMC_SELECT_BANK(saved_bank); 2132 SMC_SELECT_BANK(saved_bank);
2133 spin_unlock_irq(&smc->lock);
2123 return ret; 2134 return ret;
2124} 2135}
2125 2136
@@ -2130,11 +2141,11 @@ static u32 smc_get_link(struct net_device *dev)
2130 u16 saved_bank = inw(ioaddr + BANK_SELECT); 2141 u16 saved_bank = inw(ioaddr + BANK_SELECT);
2131 u32 ret; 2142 u32 ret;
2132 2143
2133 SMC_SELECT_BANK(3);
2134 spin_lock_irq(&smc->lock); 2144 spin_lock_irq(&smc->lock);
2145 SMC_SELECT_BANK(3);
2135 ret = smc_link_ok(dev); 2146 ret = smc_link_ok(dev);
2136 spin_unlock_irq(&smc->lock);
2137 SMC_SELECT_BANK(saved_bank); 2147 SMC_SELECT_BANK(saved_bank);
2148 spin_unlock_irq(&smc->lock);
2138 return ret; 2149 return ret;
2139} 2150}
2140 2151
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 465485a3fbc6..e6a67531de99 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1515,7 +1515,6 @@ static const struct ethtool_ops pcnet32_ethtool_ops = {
1515 .phys_id = pcnet32_phys_id, 1515 .phys_id = pcnet32_phys_id,
1516 .get_regs_len = pcnet32_get_regs_len, 1516 .get_regs_len = pcnet32_get_regs_len,
1517 .get_regs = pcnet32_get_regs, 1517 .get_regs = pcnet32_get_regs,
1518 .get_perm_addr = ethtool_op_get_perm_addr,
1519}; 1518};
1520 1519
1521/* only probes for non-PCI devices, the rest are handled by 1520/* only probes for non-PCI devices, the rest are handled by
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index 6a5385647911..8874497b6bbf 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -109,7 +109,7 @@ static int vsc824x_config_intr(struct phy_device *phydev)
109 */ 109 */
110 err = phy_read(phydev, MII_VSC8244_ISTAT); 110 err = phy_read(phydev, MII_VSC8244_ISTAT);
111 111
112 if (err) 112 if (err < 0)
113 return err; 113 return err;
114 114
115 err = phy_write(phydev, MII_VSC8244_IMASK, 0); 115 err = phy_write(phydev, MII_VSC8244_IMASK, 0);
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index 6f98834e6ace..68631a5721ac 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -108,19 +108,24 @@ static inline int cmp_addr(struct pppoe_addr *a, unsigned long sid, char *addr)
108 (memcmp(a->remote,addr,ETH_ALEN) == 0)); 108 (memcmp(a->remote,addr,ETH_ALEN) == 0));
109} 109}
110 110
111static int hash_item(unsigned long sid, unsigned char *addr) 111#if 8%PPPOE_HASH_BITS
112#error 8 must be a multiple of PPPOE_HASH_BITS
113#endif
114
115static int hash_item(unsigned int sid, unsigned char *addr)
112{ 116{
113 char hash = 0; 117 unsigned char hash = 0;
114 int i, j; 118 unsigned int i;
115 119
116 for (i = 0; i < ETH_ALEN ; ++i) { 120 for (i = 0 ; i < ETH_ALEN ; i++) {
117 for (j = 0; j < 8/PPPOE_HASH_BITS ; ++j) { 121 hash ^= addr[i];
118 hash ^= addr[i] >> ( j * PPPOE_HASH_BITS ); 122 }
119 } 123 for (i = 0 ; i < sizeof(sid_t)*8 ; i += 8 ){
124 hash ^= sid>>i;
125 }
126 for (i = 8 ; (i>>=1) >= PPPOE_HASH_BITS ; ) {
127 hash ^= hash>>i;
120 } 128 }
121
122 for (i = 0; i < (sizeof(unsigned long)*8) / PPPOE_HASH_BITS ; ++i)
123 hash ^= sid >> (i*PPPOE_HASH_BITS);
124 129
125 return hash & ( PPPOE_HASH_SIZE - 1 ); 130 return hash & ( PPPOE_HASH_SIZE - 1 );
126} 131}
@@ -664,8 +669,8 @@ static int pppoe_ioctl(struct socket *sock, unsigned int cmd,
664{ 669{
665 struct sock *sk = sock->sk; 670 struct sock *sk = sock->sk;
666 struct pppox_sock *po = pppox_sk(sk); 671 struct pppox_sock *po = pppox_sk(sk);
667 int val = 0; 672 int val;
668 int err = 0; 673 int err;
669 674
670 switch (cmd) { 675 switch (cmd) {
671 case PPPIOCGMRU: 676 case PPPIOCGMRU:
@@ -754,8 +759,9 @@ static int pppoe_ioctl(struct socket *sock, unsigned int cmd,
754 err = 0; 759 err = 0;
755 break; 760 break;
756 761
757 default:; 762 default:
758 }; 763 err = -ENOTTY;
764 }
759 765
760 return err; 766 return err;
761} 767}
@@ -773,6 +779,7 @@ static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock,
773 struct net_device *dev; 779 struct net_device *dev;
774 char *start; 780 char *start;
775 781
782 lock_sock(sk);
776 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) { 783 if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) {
777 error = -ENOTCONN; 784 error = -ENOTCONN;
778 goto end; 785 goto end;
@@ -783,8 +790,6 @@ static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock,
783 hdr.code = 0; 790 hdr.code = 0;
784 hdr.sid = po->num; 791 hdr.sid = po->num;
785 792
786 lock_sock(sk);
787
788 dev = po->pppoe_dev; 793 dev = po->pppoe_dev;
789 794
790 error = -EMSGSIZE; 795 error = -EMSGSIZE;
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index f87176055d0e..266e8b38fe10 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -2054,7 +2054,7 @@ end:
2054 */ 2054 */
2055static int pppol2tp_tunnel_getsockopt(struct sock *sk, 2055static int pppol2tp_tunnel_getsockopt(struct sock *sk,
2056 struct pppol2tp_tunnel *tunnel, 2056 struct pppol2tp_tunnel *tunnel,
2057 int optname, int __user *val) 2057 int optname, int *val)
2058{ 2058{
2059 int err = 0; 2059 int err = 0;
2060 2060
@@ -2077,7 +2077,7 @@ static int pppol2tp_tunnel_getsockopt(struct sock *sk,
2077 */ 2077 */
2078static int pppol2tp_session_getsockopt(struct sock *sk, 2078static int pppol2tp_session_getsockopt(struct sock *sk,
2079 struct pppol2tp_session *session, 2079 struct pppol2tp_session *session,
2080 int optname, int __user *val) 2080 int optname, int *val)
2081{ 2081{
2082 int err = 0; 2082 int err = 0;
2083 2083
diff --git a/drivers/net/pppox.c b/drivers/net/pppox.c
index f3e47d0c2b3c..25c52b55c38f 100644
--- a/drivers/net/pppox.c
+++ b/drivers/net/pppox.c
@@ -73,7 +73,7 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
73{ 73{
74 struct sock *sk = sock->sk; 74 struct sock *sk = sock->sk;
75 struct pppox_sock *po = pppox_sk(sk); 75 struct pppox_sock *po = pppox_sk(sk);
76 int rc = 0; 76 int rc;
77 77
78 lock_sock(sk); 78 lock_sock(sk);
79 79
@@ -94,12 +94,9 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
94 break; 94 break;
95 } 95 }
96 default: 96 default:
97 if (pppox_protos[sk->sk_protocol]->ioctl) 97 rc = pppox_protos[sk->sk_protocol]->ioctl ?
98 rc = pppox_protos[sk->sk_protocol]->ioctl(sock, cmd, 98 pppox_protos[sk->sk_protocol]->ioctl(sock, cmd, arg) : -ENOTTY;
99 arg); 99 }
100
101 break;
102 };
103 100
104 release_sock(sk); 101 release_sock(sk);
105 return rc; 102 return rc;
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c
index 08d25066f051..13d1c0a2a25f 100644
--- a/drivers/net/ps3_gelic_net.c
+++ b/drivers/net/ps3_gelic_net.c
@@ -290,7 +290,8 @@ static void gelic_net_release_rx_chain(struct gelic_net_card *card)
290 descr->buf_addr = 0; 290 descr->buf_addr = 0;
291 dev_kfree_skb_any(descr->skb); 291 dev_kfree_skb_any(descr->skb);
292 descr->skb = NULL; 292 descr->skb = NULL;
293 descr->dmac_cmd_status = GELIC_NET_DESCR_NOT_IN_USE; 293 gelic_net_set_descr_status(descr,
294 GELIC_NET_DESCR_NOT_IN_USE);
294 } 295 }
295 descr = descr->next; 296 descr = descr->next;
296 } while (descr != card->rx_chain.head); 297 } while (descr != card->rx_chain.head);
@@ -374,7 +375,7 @@ static void gelic_net_release_tx_descr(struct gelic_net_card *card,
374 descr->skb = NULL; 375 descr->skb = NULL;
375 376
376 /* set descr status */ 377 /* set descr status */
377 descr->dmac_cmd_status = GELIC_NET_DMAC_CMDSTAT_NOT_IN_USE; 378 gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE);
378} 379}
379 380
380/** 381/**
@@ -403,26 +404,29 @@ static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop)
403 "%s: forcing end of tx descriptor " \ 404 "%s: forcing end of tx descriptor " \
404 "with status %x\n", 405 "with status %x\n",
405 __func__, status); 406 __func__, status);
406 card->netdev_stats.tx_dropped++; 407 card->netdev->stats.tx_dropped++;
407 break; 408 break;
408 409
409 case GELIC_NET_DESCR_COMPLETE: 410 case GELIC_NET_DESCR_COMPLETE:
410 card->netdev_stats.tx_packets++; 411 if (tx_chain->tail->skb) {
411 card->netdev_stats.tx_bytes += 412 card->netdev->stats.tx_packets++;
412 tx_chain->tail->skb->len; 413 card->netdev->stats.tx_bytes +=
414 tx_chain->tail->skb->len;
415 }
413 break; 416 break;
414 417
415 case GELIC_NET_DESCR_CARDOWNED: 418 case GELIC_NET_DESCR_CARDOWNED:
416 /* pending tx request */ 419 /* pending tx request */
417 default: 420 default:
418 /* any other value (== GELIC_NET_DESCR_NOT_IN_USE) */ 421 /* any other value (== GELIC_NET_DESCR_NOT_IN_USE) */
419 goto out; 422 if (!stop)
423 goto out;
420 } 424 }
421 gelic_net_release_tx_descr(card, tx_chain->tail); 425 gelic_net_release_tx_descr(card, tx_chain->tail);
422 release = 1; 426 release ++;
423 } 427 }
424out: 428out:
425 if (!stop && release) 429 if (!stop && (2 < release))
426 netif_wake_queue(card->netdev); 430 netif_wake_queue(card->netdev);
427} 431}
428 432
@@ -659,19 +663,21 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card,
659{ 663{
660 dma_addr_t buf[2]; 664 dma_addr_t buf[2];
661 unsigned int vlan_len; 665 unsigned int vlan_len;
666 struct gelic_net_descr *sec_descr = descr->next;
662 667
663 if (skb->len < GELIC_NET_VLAN_POS) 668 if (skb->len < GELIC_NET_VLAN_POS)
664 return -EINVAL; 669 return -EINVAL;
665 670
666 memcpy(&descr->vlan, skb->data, GELIC_NET_VLAN_POS); 671 vlan_len = GELIC_NET_VLAN_POS;
672 memcpy(&descr->vlan, skb->data, vlan_len);
667 if (card->vlan_index != -1) { 673 if (card->vlan_index != -1) {
674 /* internal vlan tag used */
668 descr->vlan.h_vlan_proto = htons(ETH_P_8021Q); /* vlan 0x8100*/ 675 descr->vlan.h_vlan_proto = htons(ETH_P_8021Q); /* vlan 0x8100*/
669 descr->vlan.h_vlan_TCI = htons(card->vlan_id[card->vlan_index]); 676 descr->vlan.h_vlan_TCI = htons(card->vlan_id[card->vlan_index]);
670 vlan_len = GELIC_NET_VLAN_POS + VLAN_HLEN; /* VLAN_HLEN=4 */ 677 vlan_len += VLAN_HLEN; /* added for above two lines */
671 } else 678 }
672 vlan_len = GELIC_NET_VLAN_POS; /* no vlan tag */
673 679
674 /* first descr */ 680 /* map data area */
675 buf[0] = dma_map_single(ctodev(card), &descr->vlan, 681 buf[0] = dma_map_single(ctodev(card), &descr->vlan,
676 vlan_len, DMA_TO_DEVICE); 682 vlan_len, DMA_TO_DEVICE);
677 683
@@ -682,20 +688,6 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card,
682 return -ENOMEM; 688 return -ENOMEM;
683 } 689 }
684 690
685 descr->buf_addr = buf[0];
686 descr->buf_size = vlan_len;
687 descr->skb = skb; /* not used */
688 descr->data_status = 0;
689 gelic_net_set_txdescr_cmdstat(descr, skb, 1); /* not the frame end */
690
691 /* second descr */
692 card->tx_chain.head = card->tx_chain.head->next;
693 descr->next_descr_addr = descr->next->bus_addr;
694 descr = descr->next;
695 if (gelic_net_get_descr_status(descr) != GELIC_NET_DESCR_NOT_IN_USE)
696 /* XXX will be removed */
697 dev_err(ctodev(card), "descr is not free!\n");
698
699 buf[1] = dma_map_single(ctodev(card), skb->data + GELIC_NET_VLAN_POS, 691 buf[1] = dma_map_single(ctodev(card), skb->data + GELIC_NET_VLAN_POS,
700 skb->len - GELIC_NET_VLAN_POS, 692 skb->len - GELIC_NET_VLAN_POS,
701 DMA_TO_DEVICE); 693 DMA_TO_DEVICE);
@@ -710,13 +702,24 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card,
710 return -ENOMEM; 702 return -ENOMEM;
711 } 703 }
712 704
713 descr->buf_addr = buf[1]; 705 /* first descr */
714 descr->buf_size = skb->len - GELIC_NET_VLAN_POS; 706 descr->buf_addr = buf[0];
715 descr->skb = skb; 707 descr->buf_size = vlan_len;
708 descr->skb = NULL; /* not used */
716 descr->data_status = 0; 709 descr->data_status = 0;
717 descr->next_descr_addr = 0; /* terminate hw descr */ 710 descr->next_descr_addr = descr->next->bus_addr;
718 gelic_net_set_txdescr_cmdstat(descr, skb, 0); 711 gelic_net_set_txdescr_cmdstat(descr, skb, 1); /* not the frame end */
719 712
713 /* second descr */
714 sec_descr->buf_addr = buf[1];
715 sec_descr->buf_size = skb->len - GELIC_NET_VLAN_POS;
716 sec_descr->skb = skb;
717 sec_descr->data_status = 0;
718 sec_descr->next_descr_addr = 0; /* terminate hw descr */
719 gelic_net_set_txdescr_cmdstat(sec_descr, skb, 0);
720
721 /* bump free descriptor pointer */
722 card->tx_chain.head = sec_descr->next;
720 return 0; 723 return 0;
721} 724}
722 725
@@ -729,7 +732,7 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card,
729static int gelic_net_kick_txdma(struct gelic_net_card *card, 732static int gelic_net_kick_txdma(struct gelic_net_card *card,
730 struct gelic_net_descr *descr) 733 struct gelic_net_descr *descr)
731{ 734{
732 int status = -ENXIO; 735 int status = 0;
733 int count = 10; 736 int count = 10;
734 737
735 if (card->tx_dma_progress) 738 if (card->tx_dma_progress)
@@ -763,47 +766,62 @@ static int gelic_net_kick_txdma(struct gelic_net_card *card,
763static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) 766static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
764{ 767{
765 struct gelic_net_card *card = netdev_priv(netdev); 768 struct gelic_net_card *card = netdev_priv(netdev);
766 struct gelic_net_descr *descr = NULL; 769 struct gelic_net_descr *descr;
767 int result; 770 int result;
768 unsigned long flags; 771 unsigned long flags;
769 772
770 spin_lock_irqsave(&card->tx_dma_lock, flags); 773 spin_lock_irqsave(&card->tx_dma_lock, flags);
771 774
772 gelic_net_release_tx_chain(card, 0); 775 gelic_net_release_tx_chain(card, 0);
773 if (!skb) 776
774 goto kick;
775 descr = gelic_net_get_next_tx_descr(card); 777 descr = gelic_net_get_next_tx_descr(card);
776 if (!descr) { 778 if (!descr) {
779 /*
780 * no more descriptors free
781 */
777 netif_stop_queue(netdev); 782 netif_stop_queue(netdev);
778 spin_unlock_irqrestore(&card->tx_dma_lock, flags); 783 spin_unlock_irqrestore(&card->tx_dma_lock, flags);
779 return NETDEV_TX_BUSY; 784 return NETDEV_TX_BUSY;
780 } 785 }
781 result = gelic_net_prepare_tx_descr_v(card, descr, skb);
782
783 if (result)
784 goto error;
785 786
786 card->tx_chain.head = card->tx_chain.head->next; 787 result = gelic_net_prepare_tx_descr_v(card, descr, skb);
787 788 if (result) {
788 if (descr->prev) 789 /*
789 descr->prev->next_descr_addr = descr->bus_addr; 790 * DMA map failed. As chanses are that failure
790kick: 791 * would continue, just release skb and return
792 */
793 card->netdev->stats.tx_dropped++;
794 dev_kfree_skb_any(skb);
795 spin_unlock_irqrestore(&card->tx_dma_lock, flags);
796 return NETDEV_TX_OK;
797 }
798 /*
799 * link this prepared descriptor to previous one
800 * to achieve high performance
801 */
802 descr->prev->next_descr_addr = descr->bus_addr;
791 /* 803 /*
792 * as hardware descriptor is modified in the above lines, 804 * as hardware descriptor is modified in the above lines,
793 * ensure that the hardware sees it 805 * ensure that the hardware sees it
794 */ 806 */
795 wmb(); 807 wmb();
796 if (gelic_net_kick_txdma(card, card->tx_chain.tail)) 808 if (gelic_net_kick_txdma(card, descr)) {
797 goto error; 809 /*
810 * kick failed.
811 * release descriptors which were just prepared
812 */
813 card->netdev->stats.tx_dropped++;
814 gelic_net_release_tx_descr(card, descr);
815 gelic_net_release_tx_descr(card, descr->next);
816 card->tx_chain.tail = descr->next->next;
817 dev_info(ctodev(card), "%s: kick failure\n", __func__);
818 } else {
819 /* OK, DMA started/reserved */
820 netdev->trans_start = jiffies;
821 }
798 822
799 netdev->trans_start = jiffies;
800 spin_unlock_irqrestore(&card->tx_dma_lock, flags); 823 spin_unlock_irqrestore(&card->tx_dma_lock, flags);
801 return NETDEV_TX_OK; 824 return NETDEV_TX_OK;
802
803error:
804 card->netdev_stats.tx_dropped++;
805 spin_unlock_irqrestore(&card->tx_dma_lock, flags);
806 return NETDEV_TX_LOCKED;
807} 825}
808 826
809/** 827/**
@@ -854,8 +872,8 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr,
854 skb->ip_summed = CHECKSUM_NONE; 872 skb->ip_summed = CHECKSUM_NONE;
855 873
856 /* update netdevice statistics */ 874 /* update netdevice statistics */
857 card->netdev_stats.rx_packets++; 875 card->netdev->stats.rx_packets++;
858 card->netdev_stats.rx_bytes += skb->len; 876 card->netdev->stats.rx_bytes += skb->len;
859 877
860 /* pass skb up to stack */ 878 /* pass skb up to stack */
861 netif_receive_skb(skb); 879 netif_receive_skb(skb);
@@ -895,38 +913,67 @@ static int gelic_net_decode_one_descr(struct gelic_net_card *card)
895 (status == GELIC_NET_DESCR_FORCE_END)) { 913 (status == GELIC_NET_DESCR_FORCE_END)) {
896 dev_info(ctodev(card), "dropping RX descriptor with state %x\n", 914 dev_info(ctodev(card), "dropping RX descriptor with state %x\n",
897 status); 915 status);
898 card->netdev_stats.rx_dropped++; 916 card->netdev->stats.rx_dropped++;
899 goto refill; 917 goto refill;
900 } 918 }
901 919
902 if ((status != GELIC_NET_DESCR_COMPLETE) && 920 if (status == GELIC_NET_DESCR_BUFFER_FULL) {
903 (status != GELIC_NET_DESCR_FRAME_END)) { 921 /*
922 * Buffer full would occur if and only if
923 * the frame length was longer than the size of this
924 * descriptor's buffer. If the frame length was equal
925 * to or shorter than buffer'size, FRAME_END condition
926 * would occur.
927 * Anyway this frame was longer than the MTU,
928 * just drop it.
929 */
930 dev_info(ctodev(card), "overlength frame\n");
931 goto refill;
932 }
933 /*
934 * descriptoers any other than FRAME_END here should
935 * be treated as error.
936 */
937 if (status != GELIC_NET_DESCR_FRAME_END) {
904 dev_dbg(ctodev(card), "RX descriptor with state %x\n", 938 dev_dbg(ctodev(card), "RX descriptor with state %x\n",
905 status); 939 status);
906 goto refill; 940 goto refill;
907 } 941 }
908 942
909 /* ok, we've got a packet in descr */ 943 /* ok, we've got a packet in descr */
910 gelic_net_pass_skb_up(descr, card); /* 1: skb_up sccess */ 944 gelic_net_pass_skb_up(descr, card);
911
912refill: 945refill:
913 descr->next_descr_addr = 0; /* unlink the descr */ 946 /*
947 * So that always DMAC can see the end
948 * of the descriptor chain to avoid
949 * from unwanted DMAC overrun.
950 */
951 descr->next_descr_addr = 0;
914 952
915 /* change the descriptor state: */ 953 /* change the descriptor state: */
916 gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); 954 gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE);
917 955
918 /* refill one desc 956 /*
919 * FIXME: this can fail, but for now, just leave this 957 * this call can fail, but for now, just leave this
920 * descriptor without skb 958 * decriptor without skb
921 */ 959 */
922 gelic_net_prepare_rx_descr(card, descr); 960 gelic_net_prepare_rx_descr(card, descr);
961
923 chain->head = descr; 962 chain->head = descr;
924 chain->tail = descr->next; 963 chain->tail = descr->next;
964
965 /*
966 * Set this descriptor the end of the chain.
967 */
925 descr->prev->next_descr_addr = descr->bus_addr; 968 descr->prev->next_descr_addr = descr->bus_addr;
926 969
970 /*
971 * If dmac chain was met, DMAC stopped.
972 * thus re-enable it
973 */
927 if (dmac_chain_ended) { 974 if (dmac_chain_ended) {
928 gelic_net_enable_rxdmac(card); 975 card->rx_dma_restart_required = 1;
929 dev_dbg(ctodev(card), "reenable rx dma\n"); 976 dev_dbg(ctodev(card), "reenable rx dma scheduled\n");
930 } 977 }
931 978
932 return 1; 979 return 1;
@@ -968,20 +1015,6 @@ static int gelic_net_poll(struct net_device *netdev, int *budget)
968 } else 1015 } else
969 return 1; 1016 return 1;
970} 1017}
971
972/**
973 * gelic_net_get_stats - get interface statistics
974 * @netdev: interface device structure
975 *
976 * returns the interface statistics residing in the gelic_net_card struct
977 */
978static struct net_device_stats *gelic_net_get_stats(struct net_device *netdev)
979{
980 struct gelic_net_card *card = netdev_priv(netdev);
981
982 return &card->netdev_stats;
983}
984
985/** 1018/**
986 * gelic_net_change_mtu - changes the MTU of an interface 1019 * gelic_net_change_mtu - changes the MTU of an interface
987 * @netdev: interface device structure 1020 * @netdev: interface device structure
@@ -1016,6 +1049,11 @@ static irqreturn_t gelic_net_interrupt(int irq, void *ptr)
1016 if (!status) 1049 if (!status)
1017 return IRQ_NONE; 1050 return IRQ_NONE;
1018 1051
1052 if (card->rx_dma_restart_required) {
1053 card->rx_dma_restart_required = 0;
1054 gelic_net_enable_rxdmac(card);
1055 }
1056
1019 if (status & GELIC_NET_RXINT) { 1057 if (status & GELIC_NET_RXINT) {
1020 gelic_net_rx_irq_off(card); 1058 gelic_net_rx_irq_off(card);
1021 netif_rx_schedule(netdev); 1059 netif_rx_schedule(netdev);
@@ -1024,9 +1062,10 @@ static irqreturn_t gelic_net_interrupt(int irq, void *ptr)
1024 if (status & GELIC_NET_TXINT) { 1062 if (status & GELIC_NET_TXINT) {
1025 spin_lock_irqsave(&card->tx_dma_lock, flags); 1063 spin_lock_irqsave(&card->tx_dma_lock, flags);
1026 card->tx_dma_progress = 0; 1064 card->tx_dma_progress = 0;
1065 gelic_net_release_tx_chain(card, 0);
1066 /* kick outstanding tx descriptor if any */
1067 gelic_net_kick_txdma(card, card->tx_chain.tail);
1027 spin_unlock_irqrestore(&card->tx_dma_lock, flags); 1068 spin_unlock_irqrestore(&card->tx_dma_lock, flags);
1028 /* start pending DMA */
1029 gelic_net_xmit(NULL, netdev);
1030 } 1069 }
1031 return IRQ_HANDLED; 1070 return IRQ_HANDLED;
1032} 1071}
@@ -1068,7 +1107,7 @@ static int gelic_net_open_device(struct gelic_net_card *card)
1068 } 1107 }
1069 1108
1070 result = request_irq(card->netdev->irq, gelic_net_interrupt, 1109 result = request_irq(card->netdev->irq, gelic_net_interrupt,
1071 IRQF_DISABLED, "gelic network", card->netdev); 1110 IRQF_DISABLED, card->netdev->name, card->netdev);
1072 1111
1073 if (result) { 1112 if (result) {
1074 dev_info(ctodev(card), "%s:%d: request_irq failed (%d)\n", 1113 dev_info(ctodev(card), "%s:%d: request_irq failed (%d)\n",
@@ -1107,7 +1146,7 @@ static int gelic_net_open(struct net_device *netdev)
1107 card->descr, GELIC_NET_TX_DESCRIPTORS)) 1146 card->descr, GELIC_NET_TX_DESCRIPTORS))
1108 goto alloc_tx_failed; 1147 goto alloc_tx_failed;
1109 if (gelic_net_init_chain(card, &card->rx_chain, 1148 if (gelic_net_init_chain(card, &card->rx_chain,
1110 card->descr + GELIC_NET_RX_DESCRIPTORS, 1149 card->descr + GELIC_NET_TX_DESCRIPTORS,
1111 GELIC_NET_RX_DESCRIPTORS)) 1150 GELIC_NET_RX_DESCRIPTORS))
1112 goto alloc_rx_failed; 1151 goto alloc_rx_failed;
1113 1152
@@ -1129,7 +1168,6 @@ static int gelic_net_open(struct net_device *netdev)
1129 1168
1130 netif_start_queue(netdev); 1169 netif_start_queue(netdev);
1131 netif_carrier_on(netdev); 1170 netif_carrier_on(netdev);
1132 netif_poll_enable(netdev);
1133 1171
1134 return 0; 1172 return 0;
1135 1173
@@ -1141,7 +1179,6 @@ alloc_tx_failed:
1141 return -ENOMEM; 1179 return -ENOMEM;
1142} 1180}
1143 1181
1144#ifdef GELIC_NET_ETHTOOL
1145static void gelic_net_get_drvinfo (struct net_device *netdev, 1182static void gelic_net_get_drvinfo (struct net_device *netdev,
1146 struct ethtool_drvinfo *info) 1183 struct ethtool_drvinfo *info)
1147{ 1184{
@@ -1261,7 +1298,6 @@ static struct ethtool_ops gelic_net_ethtool_ops = {
1261 .get_rx_csum = gelic_net_get_rx_csum, 1298 .get_rx_csum = gelic_net_get_rx_csum,
1262 .set_rx_csum = gelic_net_set_rx_csum, 1299 .set_rx_csum = gelic_net_set_rx_csum,
1263}; 1300};
1264#endif
1265 1301
1266/** 1302/**
1267 * gelic_net_tx_timeout_task - task scheduled by the watchdog timeout 1303 * gelic_net_tx_timeout_task - task scheduled by the watchdog timeout
@@ -1320,7 +1356,6 @@ static void gelic_net_setup_netdev_ops(struct net_device *netdev)
1320 netdev->open = &gelic_net_open; 1356 netdev->open = &gelic_net_open;
1321 netdev->stop = &gelic_net_stop; 1357 netdev->stop = &gelic_net_stop;
1322 netdev->hard_start_xmit = &gelic_net_xmit; 1358 netdev->hard_start_xmit = &gelic_net_xmit;
1323 netdev->get_stats = &gelic_net_get_stats;
1324 netdev->set_multicast_list = &gelic_net_set_multi; 1359 netdev->set_multicast_list = &gelic_net_set_multi;
1325 netdev->change_mtu = &gelic_net_change_mtu; 1360 netdev->change_mtu = &gelic_net_change_mtu;
1326 /* tx watchdog */ 1361 /* tx watchdog */
@@ -1329,9 +1364,7 @@ static void gelic_net_setup_netdev_ops(struct net_device *netdev)
1329 /* NAPI */ 1364 /* NAPI */
1330 netdev->poll = &gelic_net_poll; 1365 netdev->poll = &gelic_net_poll;
1331 netdev->weight = GELIC_NET_NAPI_WEIGHT; 1366 netdev->weight = GELIC_NET_NAPI_WEIGHT;
1332#ifdef GELIC_NET_ETHTOOL
1333 netdev->ethtool_ops = &gelic_net_ethtool_ops; 1367 netdev->ethtool_ops = &gelic_net_ethtool_ops;
1334#endif
1335} 1368}
1336 1369
1337/** 1370/**
diff --git a/drivers/net/ps3_gelic_net.h b/drivers/net/ps3_gelic_net.h
index 5e1c28654e16..a9c4c4fc2547 100644
--- a/drivers/net/ps3_gelic_net.h
+++ b/drivers/net/ps3_gelic_net.h
@@ -28,21 +28,12 @@
28#ifndef _GELIC_NET_H 28#ifndef _GELIC_NET_H
29#define _GELIC_NET_H 29#define _GELIC_NET_H
30 30
31#define GELIC_NET_DRV_NAME "Gelic Network Driver"
32#define GELIC_NET_DRV_VERSION "1.0"
33
34#define GELIC_NET_ETHTOOL /* use ethtool */
35
36/* ioctl */
37#define GELIC_NET_GET_MODE (SIOCDEVPRIVATE + 0)
38#define GELIC_NET_SET_MODE (SIOCDEVPRIVATE + 1)
39
40/* descriptors */ 31/* descriptors */
41#define GELIC_NET_RX_DESCRIPTORS 128 /* num of descriptors */ 32#define GELIC_NET_RX_DESCRIPTORS 128 /* num of descriptors */
42#define GELIC_NET_TX_DESCRIPTORS 128 /* num of descriptors */ 33#define GELIC_NET_TX_DESCRIPTORS 128 /* num of descriptors */
43 34
44#define GELIC_NET_MAX_MTU 2308 35#define GELIC_NET_MAX_MTU VLAN_ETH_FRAME_LEN
45#define GELIC_NET_MIN_MTU 64 36#define GELIC_NET_MIN_MTU VLAN_ETH_ZLEN
46#define GELIC_NET_RXBUF_ALIGN 128 37#define GELIC_NET_RXBUF_ALIGN 128
47#define GELIC_NET_RX_CSUM_DEFAULT 1 /* hw chksum */ 38#define GELIC_NET_RX_CSUM_DEFAULT 1 /* hw chksum */
48#define GELIC_NET_WATCHDOG_TIMEOUT 5*HZ 39#define GELIC_NET_WATCHDOG_TIMEOUT 5*HZ
@@ -90,7 +81,8 @@ enum gelic_net_int1_status {
90 */ 81 */
91#define GELIC_NET_RXVLNPKT 0x00200000 /* VLAN packet */ 82#define GELIC_NET_RXVLNPKT 0x00200000 /* VLAN packet */
92/* bit 20..16 reserved */ 83/* bit 20..16 reserved */
93#define GELIC_NET_RXRECNUM 0x0000ff00 /* reception receipt number */ 84#define GELIC_NET_RXRRECNUM 0x0000ff00 /* reception receipt number */
85#define GELIC_NET_RXRRECNUM_SHIFT 8
94/* bit 7..0 reserved */ 86/* bit 7..0 reserved */
95 87
96#define GELIC_NET_TXDESC_TAIL 0 88#define GELIC_NET_TXDESC_TAIL 0
@@ -133,19 +125,19 @@ enum gelic_net_int1_status {
133 * interrupt status */ 125 * interrupt status */
134 126
135#define GELIC_NET_DMAC_CMDSTAT_CHAIN_END 0x00000002 /* RXDCEIS:DMA stopped */ 127#define GELIC_NET_DMAC_CMDSTAT_CHAIN_END 0x00000002 /* RXDCEIS:DMA stopped */
136#define GELIC_NET_DMAC_CMDSTAT_NOT_IN_USE 0xb0000000
137#define GELIC_NET_DESCR_IND_PROC_SHIFT 28 128#define GELIC_NET_DESCR_IND_PROC_SHIFT 28
138#define GELIC_NET_DESCR_IND_PROC_MASKO 0x0fffffff 129#define GELIC_NET_DESCR_IND_PROC_MASKO 0x0fffffff
139 130
140 131
141enum gelic_net_descr_status { 132enum gelic_net_descr_status {
142 GELIC_NET_DESCR_COMPLETE = 0x00, /* used in rx and tx */ 133 GELIC_NET_DESCR_COMPLETE = 0x00, /* used in tx */
134 GELIC_NET_DESCR_BUFFER_FULL = 0x00, /* used in rx */
143 GELIC_NET_DESCR_RESPONSE_ERROR = 0x01, /* used in rx and tx */ 135 GELIC_NET_DESCR_RESPONSE_ERROR = 0x01, /* used in rx and tx */
144 GELIC_NET_DESCR_PROTECTION_ERROR = 0x02, /* used in rx and tx */ 136 GELIC_NET_DESCR_PROTECTION_ERROR = 0x02, /* used in rx and tx */
145 GELIC_NET_DESCR_FRAME_END = 0x04, /* used in rx */ 137 GELIC_NET_DESCR_FRAME_END = 0x04, /* used in rx */
146 GELIC_NET_DESCR_FORCE_END = 0x05, /* used in rx and tx */ 138 GELIC_NET_DESCR_FORCE_END = 0x05, /* used in rx and tx */
147 GELIC_NET_DESCR_CARDOWNED = 0x0a, /* used in rx and tx */ 139 GELIC_NET_DESCR_CARDOWNED = 0x0a, /* used in rx and tx */
148 GELIC_NET_DESCR_NOT_IN_USE /* any other value */ 140 GELIC_NET_DESCR_NOT_IN_USE = 0x0b /* any other value */
149}; 141};
150/* for lv1_net_control */ 142/* for lv1_net_control */
151#define GELIC_NET_GET_MAC_ADDRESS 0x0000000000000001 143#define GELIC_NET_GET_MAC_ADDRESS 0x0000000000000001
@@ -216,10 +208,10 @@ struct gelic_net_card {
216 208
217 struct gelic_net_descr_chain tx_chain; 209 struct gelic_net_descr_chain tx_chain;
218 struct gelic_net_descr_chain rx_chain; 210 struct gelic_net_descr_chain rx_chain;
211 int rx_dma_restart_required;
219 /* gurad dmac descriptor chain*/ 212 /* gurad dmac descriptor chain*/
220 spinlock_t chain_lock; 213 spinlock_t chain_lock;
221 214
222 struct net_device_stats netdev_stats;
223 int rx_csum; 215 int rx_csum;
224 /* guard tx_dma_progress */ 216 /* guard tx_dma_progress */
225 spinlock_t tx_dma_lock; 217 spinlock_t tx_dma_lock;
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index 8be8be451ada..69da95b5ad0c 100755
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -1904,7 +1904,6 @@ static void ql_get_pauseparam(struct net_device *ndev,
1904static const struct ethtool_ops ql3xxx_ethtool_ops = { 1904static const struct ethtool_ops ql3xxx_ethtool_ops = {
1905 .get_settings = ql_get_settings, 1905 .get_settings = ql_get_settings,
1906 .get_drvinfo = ql_get_drvinfo, 1906 .get_drvinfo = ql_get_drvinfo,
1907 .get_perm_addr = ethtool_op_get_perm_addr,
1908 .get_link = ethtool_op_get_link, 1907 .get_link = ethtool_op_get_link,
1909 .get_msglevel = ql_get_msglevel, 1908 .get_msglevel = ql_get_msglevel,
1910 .set_msglevel = ql_set_msglevel, 1909 .set_msglevel = ql_set_msglevel,
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index bb6896ae3151..c9333b9dd51a 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1066,7 +1066,6 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {
1066 .get_strings = rtl8169_get_strings, 1066 .get_strings = rtl8169_get_strings,
1067 .get_stats_count = rtl8169_get_stats_count, 1067 .get_stats_count = rtl8169_get_stats_count,
1068 .get_ethtool_stats = rtl8169_get_ethtool_stats, 1068 .get_ethtool_stats = rtl8169_get_ethtool_stats,
1069 .get_perm_addr = ethtool_op_get_perm_addr,
1070}; 1069};
1071 1070
1072static void rtl8169_write_gmii_reg_bit(void __iomem *ioaddr, int reg, 1071static void rtl8169_write_gmii_reg_bit(void __iomem *ioaddr, int reg,
diff --git a/drivers/net/s2io-regs.h b/drivers/net/s2io-regs.h
index 4cb710bbe729..cfa267914476 100644
--- a/drivers/net/s2io-regs.h
+++ b/drivers/net/s2io-regs.h
@@ -747,10 +747,9 @@ struct XENA_dev_config {
747#define MC_ERR_REG_MIRI_CRI_ERR_1 BIT(23) 747#define MC_ERR_REG_MIRI_CRI_ERR_1 BIT(23)
748#define MC_ERR_REG_SM_ERR BIT(31) 748#define MC_ERR_REG_SM_ERR BIT(31)
749#define MC_ERR_REG_ECC_ALL_SNG (BIT(2) | BIT(3) | BIT(4) | BIT(5) |\ 749#define MC_ERR_REG_ECC_ALL_SNG (BIT(2) | BIT(3) | BIT(4) | BIT(5) |\
750 BIT(6) | BIT(7) | BIT(17) | BIT(19)) 750 BIT(17) | BIT(19))
751#define MC_ERR_REG_ECC_ALL_DBL (BIT(10) | BIT(11) | BIT(12) |\ 751#define MC_ERR_REG_ECC_ALL_DBL (BIT(10) | BIT(11) | BIT(12) |\
752 BIT(13) | BIT(14) | BIT(15) |\ 752 BIT(13) | BIT(18) | BIT(20))
753 BIT(18) | BIT(20))
754 u64 mc_err_mask; 753 u64 mc_err_mask;
755 u64 mc_err_alarm; 754 u64 mc_err_alarm;
756 755
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index afef6c0c59fe..2be0a0f1b48f 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -32,12 +32,12 @@
32 * rx_ring_sz: This defines the number of receive blocks each ring can have. 32 * rx_ring_sz: This defines the number of receive blocks each ring can have.
33 * This is also an array of size 8. 33 * This is also an array of size 8.
34 * rx_ring_mode: This defines the operation mode of all 8 rings. The valid 34 * rx_ring_mode: This defines the operation mode of all 8 rings. The valid
35 * values are 1, 2 and 3. 35 * values are 1, 2.
36 * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver. 36 * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver.
37 * tx_fifo_len: This too is an array of 8. Each element defines the number of 37 * tx_fifo_len: This too is an array of 8. Each element defines the number of
38 * Tx descriptors that can be associated with each corresponding FIFO. 38 * Tx descriptors that can be associated with each corresponding FIFO.
39 * intr_type: This defines the type of interrupt. The values can be 0(INTA), 39 * intr_type: This defines the type of interrupt. The values can be 0(INTA),
40 * 1(MSI), 2(MSI_X). Default value is '0(INTA)' 40 * 2(MSI_X). Default value is '0(INTA)'
41 * lro: Specifies whether to enable Large Receive Offload (LRO) or not. 41 * lro: Specifies whether to enable Large Receive Offload (LRO) or not.
42 * Possible values '1' for enable '0' for disable. Default is '0' 42 * Possible values '1' for enable '0' for disable. Default is '0'
43 * lro_max_pkts: This parameter defines maximum number of packets can be 43 * lro_max_pkts: This parameter defines maximum number of packets can be
@@ -84,14 +84,14 @@
84#include "s2io.h" 84#include "s2io.h"
85#include "s2io-regs.h" 85#include "s2io-regs.h"
86 86
87#define DRV_VERSION "2.0.23.1" 87#define DRV_VERSION "2.0.25.1"
88 88
89/* S2io Driver name & version. */ 89/* S2io Driver name & version. */
90static char s2io_driver_name[] = "Neterion"; 90static char s2io_driver_name[] = "Neterion";
91static char s2io_driver_version[] = DRV_VERSION; 91static char s2io_driver_version[] = DRV_VERSION;
92 92
93static int rxd_size[4] = {32,48,48,64}; 93static int rxd_size[2] = {32,48};
94static int rxd_count[4] = {127,85,85,63}; 94static int rxd_count[2] = {127,85};
95 95
96static inline int RXD_IS_UP2DT(struct RxD_t *rxdp) 96static inline int RXD_IS_UP2DT(struct RxD_t *rxdp)
97{ 97{
@@ -282,6 +282,7 @@ static char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = {
282 ("lro_flush_due_to_max_pkts"), 282 ("lro_flush_due_to_max_pkts"),
283 ("lro_avg_aggr_pkts"), 283 ("lro_avg_aggr_pkts"),
284 ("mem_alloc_fail_cnt"), 284 ("mem_alloc_fail_cnt"),
285 ("pci_map_fail_cnt"),
285 ("watchdog_timer_cnt"), 286 ("watchdog_timer_cnt"),
286 ("mem_allocated"), 287 ("mem_allocated"),
287 ("mem_freed"), 288 ("mem_freed"),
@@ -426,7 +427,7 @@ S2IO_PARM_INT(bimodal, 0);
426S2IO_PARM_INT(l3l4hdr_size, 128); 427S2IO_PARM_INT(l3l4hdr_size, 128);
427/* Frequency of Rx desc syncs expressed as power of 2 */ 428/* Frequency of Rx desc syncs expressed as power of 2 */
428S2IO_PARM_INT(rxsync_frequency, 3); 429S2IO_PARM_INT(rxsync_frequency, 3);
429/* Interrupt type. Values can be 0(INTA), 1(MSI), 2(MSI_X) */ 430/* Interrupt type. Values can be 0(INTA), 2(MSI_X) */
430S2IO_PARM_INT(intr_type, 0); 431S2IO_PARM_INT(intr_type, 0);
431/* Large receive offload feature */ 432/* Large receive offload feature */
432S2IO_PARM_INT(lro, 0); 433S2IO_PARM_INT(lro, 0);
@@ -701,7 +702,7 @@ static int init_shared_mem(struct s2io_nic *nic)
701 (u64) tmp_p_addr_next; 702 (u64) tmp_p_addr_next;
702 } 703 }
703 } 704 }
704 if (nic->rxd_mode >= RXD_MODE_3A) { 705 if (nic->rxd_mode == RXD_MODE_3B) {
705 /* 706 /*
706 * Allocation of Storages for buffer addresses in 2BUFF mode 707 * Allocation of Storages for buffer addresses in 2BUFF mode
707 * and the buffers as well. 708 * and the buffers as well.
@@ -870,7 +871,7 @@ static void free_shared_mem(struct s2io_nic *nic)
870 } 871 }
871 } 872 }
872 873
873 if (nic->rxd_mode >= RXD_MODE_3A) { 874 if (nic->rxd_mode == RXD_MODE_3B) {
874 /* Freeing buffer storage addresses in 2BUFF mode. */ 875 /* Freeing buffer storage addresses in 2BUFF mode. */
875 for (i = 0; i < config->rx_ring_num; i++) { 876 for (i = 0; i < config->rx_ring_num; i++) {
876 blk_cnt = config->rx_cfg[i].num_rxd / 877 blk_cnt = config->rx_cfg[i].num_rxd /
@@ -2233,44 +2234,6 @@ static void stop_nic(struct s2io_nic *nic)
2233 writeq(val64, &bar0->adapter_control); 2234 writeq(val64, &bar0->adapter_control);
2234} 2235}
2235 2236
2236static int fill_rxd_3buf(struct s2io_nic *nic, struct RxD_t *rxdp, struct \
2237 sk_buff *skb)
2238{
2239 struct net_device *dev = nic->dev;
2240 struct sk_buff *frag_list;
2241 void *tmp;
2242
2243 /* Buffer-1 receives L3/L4 headers */
2244 ((struct RxD3*)rxdp)->Buffer1_ptr = pci_map_single
2245 (nic->pdev, skb->data, l3l4hdr_size + 4,
2246 PCI_DMA_FROMDEVICE);
2247
2248 /* skb_shinfo(skb)->frag_list will have L4 data payload */
2249 skb_shinfo(skb)->frag_list = dev_alloc_skb(dev->mtu + ALIGN_SIZE);
2250 if (skb_shinfo(skb)->frag_list == NULL) {
2251 nic->mac_control.stats_info->sw_stat.mem_alloc_fail_cnt++;
2252 DBG_PRINT(INFO_DBG, "%s: dev_alloc_skb failed\n ", dev->name);
2253 return -ENOMEM ;
2254 }
2255 frag_list = skb_shinfo(skb)->frag_list;
2256 skb->truesize += frag_list->truesize;
2257 nic->mac_control.stats_info->sw_stat.mem_allocated
2258 += frag_list->truesize;
2259 frag_list->next = NULL;
2260 tmp = (void *)ALIGN((long)frag_list->data, ALIGN_SIZE + 1);
2261 frag_list->data = tmp;
2262 skb_reset_tail_pointer(frag_list);
2263
2264 /* Buffer-2 receives L4 data payload */
2265 ((struct RxD3*)rxdp)->Buffer2_ptr = pci_map_single(nic->pdev,
2266 frag_list->data, dev->mtu,
2267 PCI_DMA_FROMDEVICE);
2268 rxdp->Control_2 |= SET_BUFFER1_SIZE_3(l3l4hdr_size + 4);
2269 rxdp->Control_2 |= SET_BUFFER2_SIZE_3(dev->mtu);
2270
2271 return SUCCESS;
2272}
2273
2274/** 2237/**
2275 * fill_rx_buffers - Allocates the Rx side skbs 2238 * fill_rx_buffers - Allocates the Rx side skbs
2276 * @nic: device private variable 2239 * @nic: device private variable
@@ -2307,6 +2270,9 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2307 unsigned long flags; 2270 unsigned long flags;
2308 struct RxD_t *first_rxdp = NULL; 2271 struct RxD_t *first_rxdp = NULL;
2309 u64 Buffer0_ptr = 0, Buffer1_ptr = 0; 2272 u64 Buffer0_ptr = 0, Buffer1_ptr = 0;
2273 struct RxD1 *rxdp1;
2274 struct RxD3 *rxdp3;
2275 struct swStat *stats = &nic->mac_control.stats_info->sw_stat;
2310 2276
2311 mac_control = &nic->mac_control; 2277 mac_control = &nic->mac_control;
2312 config = &nic->config; 2278 config = &nic->config;
@@ -2359,7 +2325,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2359 (block_no * (rxd_count[nic->rxd_mode] + 1)) + off; 2325 (block_no * (rxd_count[nic->rxd_mode] + 1)) + off;
2360 } 2326 }
2361 if ((rxdp->Control_1 & RXD_OWN_XENA) && 2327 if ((rxdp->Control_1 & RXD_OWN_XENA) &&
2362 ((nic->rxd_mode >= RXD_MODE_3A) && 2328 ((nic->rxd_mode == RXD_MODE_3B) &&
2363 (rxdp->Control_2 & BIT(0)))) { 2329 (rxdp->Control_2 & BIT(0)))) {
2364 mac_control->rings[ring_no].rx_curr_put_info. 2330 mac_control->rings[ring_no].rx_curr_put_info.
2365 offset = off; 2331 offset = off;
@@ -2370,10 +2336,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2370 HEADER_802_2_SIZE + HEADER_SNAP_SIZE; 2336 HEADER_802_2_SIZE + HEADER_SNAP_SIZE;
2371 if (nic->rxd_mode == RXD_MODE_1) 2337 if (nic->rxd_mode == RXD_MODE_1)
2372 size += NET_IP_ALIGN; 2338 size += NET_IP_ALIGN;
2373 else if (nic->rxd_mode == RXD_MODE_3B)
2374 size = dev->mtu + ALIGN_SIZE + BUF0_LEN + 4;
2375 else 2339 else
2376 size = l3l4hdr_size + ALIGN_SIZE + BUF0_LEN + 4; 2340 size = dev->mtu + ALIGN_SIZE + BUF0_LEN + 4;
2377 2341
2378 /* allocate skb */ 2342 /* allocate skb */
2379 skb = dev_alloc_skb(size); 2343 skb = dev_alloc_skb(size);
@@ -2392,33 +2356,35 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2392 += skb->truesize; 2356 += skb->truesize;
2393 if (nic->rxd_mode == RXD_MODE_1) { 2357 if (nic->rxd_mode == RXD_MODE_1) {
2394 /* 1 buffer mode - normal operation mode */ 2358 /* 1 buffer mode - normal operation mode */
2359 rxdp1 = (struct RxD1*)rxdp;
2395 memset(rxdp, 0, sizeof(struct RxD1)); 2360 memset(rxdp, 0, sizeof(struct RxD1));
2396 skb_reserve(skb, NET_IP_ALIGN); 2361 skb_reserve(skb, NET_IP_ALIGN);
2397 ((struct RxD1*)rxdp)->Buffer0_ptr = pci_map_single 2362 rxdp1->Buffer0_ptr = pci_map_single
2398 (nic->pdev, skb->data, size - NET_IP_ALIGN, 2363 (nic->pdev, skb->data, size - NET_IP_ALIGN,
2399 PCI_DMA_FROMDEVICE); 2364 PCI_DMA_FROMDEVICE);
2365 if( (rxdp1->Buffer0_ptr == 0) ||
2366 (rxdp1->Buffer0_ptr ==
2367 DMA_ERROR_CODE))
2368 goto pci_map_failed;
2369
2400 rxdp->Control_2 = 2370 rxdp->Control_2 =
2401 SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); 2371 SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN);
2402 2372
2403 } else if (nic->rxd_mode >= RXD_MODE_3A) { 2373 } else if (nic->rxd_mode == RXD_MODE_3B) {
2404 /* 2374 /*
2405 * 2 or 3 buffer mode - 2375 * 2 buffer mode -
2406 * Both 2 buffer mode and 3 buffer mode provides 128 2376 * 2 buffer mode provides 128
2407 * byte aligned receive buffers. 2377 * byte aligned receive buffers.
2408 *
2409 * 3 buffer mode provides header separation where in
2410 * skb->data will have L3/L4 headers where as
2411 * skb_shinfo(skb)->frag_list will have the L4 data
2412 * payload
2413 */ 2378 */
2414 2379
2380 rxdp3 = (struct RxD3*)rxdp;
2415 /* save buffer pointers to avoid frequent dma mapping */ 2381 /* save buffer pointers to avoid frequent dma mapping */
2416 Buffer0_ptr = ((struct RxD3*)rxdp)->Buffer0_ptr; 2382 Buffer0_ptr = rxdp3->Buffer0_ptr;
2417 Buffer1_ptr = ((struct RxD3*)rxdp)->Buffer1_ptr; 2383 Buffer1_ptr = rxdp3->Buffer1_ptr;
2418 memset(rxdp, 0, sizeof(struct RxD3)); 2384 memset(rxdp, 0, sizeof(struct RxD3));
2419 /* restore the buffer pointers for dma sync*/ 2385 /* restore the buffer pointers for dma sync*/
2420 ((struct RxD3*)rxdp)->Buffer0_ptr = Buffer0_ptr; 2386 rxdp3->Buffer0_ptr = Buffer0_ptr;
2421 ((struct RxD3*)rxdp)->Buffer1_ptr = Buffer1_ptr; 2387 rxdp3->Buffer1_ptr = Buffer1_ptr;
2422 2388
2423 ba = &mac_control->rings[ring_no].ba[block_no][off]; 2389 ba = &mac_control->rings[ring_no].ba[block_no][off];
2424 skb_reserve(skb, BUF0_LEN); 2390 skb_reserve(skb, BUF0_LEN);
@@ -2428,14 +2394,18 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2428 skb->data = (void *) (unsigned long)tmp; 2394 skb->data = (void *) (unsigned long)tmp;
2429 skb_reset_tail_pointer(skb); 2395 skb_reset_tail_pointer(skb);
2430 2396
2431 if (!(((struct RxD3*)rxdp)->Buffer0_ptr)) 2397 if (!(rxdp3->Buffer0_ptr))
2432 ((struct RxD3*)rxdp)->Buffer0_ptr = 2398 rxdp3->Buffer0_ptr =
2433 pci_map_single(nic->pdev, ba->ba_0, BUF0_LEN, 2399 pci_map_single(nic->pdev, ba->ba_0, BUF0_LEN,
2434 PCI_DMA_FROMDEVICE); 2400 PCI_DMA_FROMDEVICE);
2435 else 2401 else
2436 pci_dma_sync_single_for_device(nic->pdev, 2402 pci_dma_sync_single_for_device(nic->pdev,
2437 (dma_addr_t) ((struct RxD3*)rxdp)->Buffer0_ptr, 2403 (dma_addr_t) rxdp3->Buffer0_ptr,
2438 BUF0_LEN, PCI_DMA_FROMDEVICE); 2404 BUF0_LEN, PCI_DMA_FROMDEVICE);
2405 if( (rxdp3->Buffer0_ptr == 0) ||
2406 (rxdp3->Buffer0_ptr == DMA_ERROR_CODE))
2407 goto pci_map_failed;
2408
2439 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); 2409 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
2440 if (nic->rxd_mode == RXD_MODE_3B) { 2410 if (nic->rxd_mode == RXD_MODE_3B) {
2441 /* Two buffer mode */ 2411 /* Two buffer mode */
@@ -2444,33 +2414,30 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2444 * Buffer2 will have L3/L4 header plus 2414 * Buffer2 will have L3/L4 header plus
2445 * L4 payload 2415 * L4 payload
2446 */ 2416 */
2447 ((struct RxD3*)rxdp)->Buffer2_ptr = pci_map_single 2417 rxdp3->Buffer2_ptr = pci_map_single
2448 (nic->pdev, skb->data, dev->mtu + 4, 2418 (nic->pdev, skb->data, dev->mtu + 4,
2449 PCI_DMA_FROMDEVICE); 2419 PCI_DMA_FROMDEVICE);
2450 2420
2451 /* Buffer-1 will be dummy buffer. Not used */ 2421 if( (rxdp3->Buffer2_ptr == 0) ||
2452 if (!(((struct RxD3*)rxdp)->Buffer1_ptr)) { 2422 (rxdp3->Buffer2_ptr == DMA_ERROR_CODE))
2453 ((struct RxD3*)rxdp)->Buffer1_ptr = 2423 goto pci_map_failed;
2424
2425 rxdp3->Buffer1_ptr =
2454 pci_map_single(nic->pdev, 2426 pci_map_single(nic->pdev,
2455 ba->ba_1, BUF1_LEN, 2427 ba->ba_1, BUF1_LEN,
2456 PCI_DMA_FROMDEVICE); 2428 PCI_DMA_FROMDEVICE);
2429 if( (rxdp3->Buffer1_ptr == 0) ||
2430 (rxdp3->Buffer1_ptr == DMA_ERROR_CODE)) {
2431 pci_unmap_single
2432 (nic->pdev,
2433 (dma_addr_t)skb->data,
2434 dev->mtu + 4,
2435 PCI_DMA_FROMDEVICE);
2436 goto pci_map_failed;
2457 } 2437 }
2458 rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1); 2438 rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1);
2459 rxdp->Control_2 |= SET_BUFFER2_SIZE_3 2439 rxdp->Control_2 |= SET_BUFFER2_SIZE_3
2460 (dev->mtu + 4); 2440 (dev->mtu + 4);
2461 } else {
2462 /* 3 buffer mode */
2463 if (fill_rxd_3buf(nic, rxdp, skb) == -ENOMEM) {
2464 nic->mac_control.stats_info->sw_stat.\
2465 mem_freed += skb->truesize;
2466 dev_kfree_skb_irq(skb);
2467 if (first_rxdp) {
2468 wmb();
2469 first_rxdp->Control_1 |=
2470 RXD_OWN_XENA;
2471 }
2472 return -ENOMEM ;
2473 }
2474 } 2441 }
2475 rxdp->Control_2 |= BIT(0); 2442 rxdp->Control_2 |= BIT(0);
2476 } 2443 }
@@ -2505,6 +2472,11 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2505 } 2472 }
2506 2473
2507 return SUCCESS; 2474 return SUCCESS;
2475pci_map_failed:
2476 stats->pci_map_fail_cnt++;
2477 stats->mem_freed += skb->truesize;
2478 dev_kfree_skb_irq(skb);
2479 return -ENOMEM;
2508} 2480}
2509 2481
2510static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk) 2482static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk)
@@ -2515,6 +2487,8 @@ static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk)
2515 struct RxD_t *rxdp; 2487 struct RxD_t *rxdp;
2516 struct mac_info *mac_control; 2488 struct mac_info *mac_control;
2517 struct buffAdd *ba; 2489 struct buffAdd *ba;
2490 struct RxD1 *rxdp1;
2491 struct RxD3 *rxdp3;
2518 2492
2519 mac_control = &sp->mac_control; 2493 mac_control = &sp->mac_control;
2520 for (j = 0 ; j < rxd_count[sp->rxd_mode]; j++) { 2494 for (j = 0 ; j < rxd_count[sp->rxd_mode]; j++) {
@@ -2526,40 +2500,30 @@ static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk)
2526 continue; 2500 continue;
2527 } 2501 }
2528 if (sp->rxd_mode == RXD_MODE_1) { 2502 if (sp->rxd_mode == RXD_MODE_1) {
2503 rxdp1 = (struct RxD1*)rxdp;
2529 pci_unmap_single(sp->pdev, (dma_addr_t) 2504 pci_unmap_single(sp->pdev, (dma_addr_t)
2530 ((struct RxD1*)rxdp)->Buffer0_ptr, 2505 rxdp1->Buffer0_ptr,
2531 dev->mtu + 2506 dev->mtu +
2532 HEADER_ETHERNET_II_802_3_SIZE 2507 HEADER_ETHERNET_II_802_3_SIZE
2533 + HEADER_802_2_SIZE + 2508 + HEADER_802_2_SIZE +
2534 HEADER_SNAP_SIZE, 2509 HEADER_SNAP_SIZE,
2535 PCI_DMA_FROMDEVICE); 2510 PCI_DMA_FROMDEVICE);
2536 memset(rxdp, 0, sizeof(struct RxD1)); 2511 memset(rxdp, 0, sizeof(struct RxD1));
2537 } else if(sp->rxd_mode == RXD_MODE_3B) { 2512 } else if(sp->rxd_mode == RXD_MODE_3B) {
2513 rxdp3 = (struct RxD3*)rxdp;
2538 ba = &mac_control->rings[ring_no]. 2514 ba = &mac_control->rings[ring_no].
2539 ba[blk][j]; 2515 ba[blk][j];
2540 pci_unmap_single(sp->pdev, (dma_addr_t) 2516 pci_unmap_single(sp->pdev, (dma_addr_t)
2541 ((struct RxD3*)rxdp)->Buffer0_ptr, 2517 rxdp3->Buffer0_ptr,
2542 BUF0_LEN, 2518 BUF0_LEN,
2543 PCI_DMA_FROMDEVICE);
2544 pci_unmap_single(sp->pdev, (dma_addr_t)
2545 ((struct RxD3*)rxdp)->Buffer1_ptr,
2546 BUF1_LEN,
2547 PCI_DMA_FROMDEVICE);
2548 pci_unmap_single(sp->pdev, (dma_addr_t)
2549 ((struct RxD3*)rxdp)->Buffer2_ptr,
2550 dev->mtu + 4,
2551 PCI_DMA_FROMDEVICE);
2552 memset(rxdp, 0, sizeof(struct RxD3));
2553 } else {
2554 pci_unmap_single(sp->pdev, (dma_addr_t)
2555 ((struct RxD3*)rxdp)->Buffer0_ptr, BUF0_LEN,
2556 PCI_DMA_FROMDEVICE); 2519 PCI_DMA_FROMDEVICE);
2557 pci_unmap_single(sp->pdev, (dma_addr_t) 2520 pci_unmap_single(sp->pdev, (dma_addr_t)
2558 ((struct RxD3*)rxdp)->Buffer1_ptr, 2521 rxdp3->Buffer1_ptr,
2559 l3l4hdr_size + 4, 2522 BUF1_LEN,
2560 PCI_DMA_FROMDEVICE); 2523 PCI_DMA_FROMDEVICE);
2561 pci_unmap_single(sp->pdev, (dma_addr_t) 2524 pci_unmap_single(sp->pdev, (dma_addr_t)
2562 ((struct RxD3*)rxdp)->Buffer2_ptr, dev->mtu, 2525 rxdp3->Buffer2_ptr,
2526 dev->mtu + 4,
2563 PCI_DMA_FROMDEVICE); 2527 PCI_DMA_FROMDEVICE);
2564 memset(rxdp, 0, sizeof(struct RxD3)); 2528 memset(rxdp, 0, sizeof(struct RxD3));
2565 } 2529 }
@@ -2756,6 +2720,8 @@ static void rx_intr_handler(struct ring_info *ring_data)
2756 struct sk_buff *skb; 2720 struct sk_buff *skb;
2757 int pkt_cnt = 0; 2721 int pkt_cnt = 0;
2758 int i; 2722 int i;
2723 struct RxD1* rxdp1;
2724 struct RxD3* rxdp3;
2759 2725
2760 spin_lock(&nic->rx_lock); 2726 spin_lock(&nic->rx_lock);
2761 if (atomic_read(&nic->card_state) == CARD_DOWN) { 2727 if (atomic_read(&nic->card_state) == CARD_DOWN) {
@@ -2796,32 +2762,23 @@ static void rx_intr_handler(struct ring_info *ring_data)
2796 return; 2762 return;
2797 } 2763 }
2798 if (nic->rxd_mode == RXD_MODE_1) { 2764 if (nic->rxd_mode == RXD_MODE_1) {
2765 rxdp1 = (struct RxD1*)rxdp;
2799 pci_unmap_single(nic->pdev, (dma_addr_t) 2766 pci_unmap_single(nic->pdev, (dma_addr_t)
2800 ((struct RxD1*)rxdp)->Buffer0_ptr, 2767 rxdp1->Buffer0_ptr,
2801 dev->mtu + 2768 dev->mtu +
2802 HEADER_ETHERNET_II_802_3_SIZE + 2769 HEADER_ETHERNET_II_802_3_SIZE +
2803 HEADER_802_2_SIZE + 2770 HEADER_802_2_SIZE +
2804 HEADER_SNAP_SIZE, 2771 HEADER_SNAP_SIZE,
2805 PCI_DMA_FROMDEVICE); 2772 PCI_DMA_FROMDEVICE);
2806 } else if (nic->rxd_mode == RXD_MODE_3B) { 2773 } else if (nic->rxd_mode == RXD_MODE_3B) {
2774 rxdp3 = (struct RxD3*)rxdp;
2807 pci_dma_sync_single_for_cpu(nic->pdev, (dma_addr_t) 2775 pci_dma_sync_single_for_cpu(nic->pdev, (dma_addr_t)
2808 ((struct RxD3*)rxdp)->Buffer0_ptr, 2776 rxdp3->Buffer0_ptr,
2809 BUF0_LEN, PCI_DMA_FROMDEVICE); 2777 BUF0_LEN, PCI_DMA_FROMDEVICE);
2810 pci_unmap_single(nic->pdev, (dma_addr_t)
2811 ((struct RxD3*)rxdp)->Buffer2_ptr,
2812 dev->mtu + 4,
2813 PCI_DMA_FROMDEVICE);
2814 } else {
2815 pci_dma_sync_single_for_cpu(nic->pdev, (dma_addr_t)
2816 ((struct RxD3*)rxdp)->Buffer0_ptr, BUF0_LEN,
2817 PCI_DMA_FROMDEVICE);
2818 pci_unmap_single(nic->pdev, (dma_addr_t)
2819 ((struct RxD3*)rxdp)->Buffer1_ptr,
2820 l3l4hdr_size + 4,
2821 PCI_DMA_FROMDEVICE);
2822 pci_unmap_single(nic->pdev, (dma_addr_t) 2778 pci_unmap_single(nic->pdev, (dma_addr_t)
2823 ((struct RxD3*)rxdp)->Buffer2_ptr, 2779 rxdp3->Buffer2_ptr,
2824 dev->mtu, PCI_DMA_FROMDEVICE); 2780 dev->mtu + 4,
2781 PCI_DMA_FROMDEVICE);
2825 } 2782 }
2826 prefetch(skb->data); 2783 prefetch(skb->data);
2827 rx_osm_handler(ring_data, rxdp); 2784 rx_osm_handler(ring_data, rxdp);
@@ -3425,23 +3382,8 @@ static void s2io_reset(struct s2io_nic * sp)
3425 /* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */ 3382 /* Back up the PCI-X CMD reg, dont want to lose MMRBC, OST settings */
3426 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd)); 3383 pci_read_config_word(sp->pdev, PCIX_COMMAND_REGISTER, &(pci_cmd));
3427 3384
3428 if (sp->device_type == XFRAME_II_DEVICE) {
3429 int ret;
3430 ret = pci_set_power_state(sp->pdev, 3);
3431 if (!ret)
3432 ret = pci_set_power_state(sp->pdev, 0);
3433 else {
3434 DBG_PRINT(ERR_DBG,"%s PME based SW_Reset failed!\n",
3435 __FUNCTION__);
3436 goto old_way;
3437 }
3438 msleep(20);
3439 goto new_way;
3440 }
3441old_way:
3442 val64 = SW_RESET_ALL; 3385 val64 = SW_RESET_ALL;
3443 writeq(val64, &bar0->sw_reset); 3386 writeq(val64, &bar0->sw_reset);
3444new_way:
3445 if (strstr(sp->product_name, "CX4")) { 3387 if (strstr(sp->product_name, "CX4")) {
3446 msleep(750); 3388 msleep(750);
3447 } 3389 }
@@ -3731,56 +3673,6 @@ static void store_xmsi_data(struct s2io_nic *nic)
3731 } 3673 }
3732} 3674}
3733 3675
3734int s2io_enable_msi(struct s2io_nic *nic)
3735{
3736 struct XENA_dev_config __iomem *bar0 = nic->bar0;
3737 u16 msi_ctrl, msg_val;
3738 struct config_param *config = &nic->config;
3739 struct net_device *dev = nic->dev;
3740 u64 val64, tx_mat, rx_mat;
3741 int i, err;
3742
3743 val64 = readq(&bar0->pic_control);
3744 val64 &= ~BIT(1);
3745 writeq(val64, &bar0->pic_control);
3746
3747 err = pci_enable_msi(nic->pdev);
3748 if (err) {
3749 DBG_PRINT(ERR_DBG, "%s: enabling MSI failed\n",
3750 nic->dev->name);
3751 return err;
3752 }
3753
3754 /*
3755 * Enable MSI and use MSI-1 in stead of the standard MSI-0
3756 * for interrupt handling.
3757 */
3758 pci_read_config_word(nic->pdev, 0x4c, &msg_val);
3759 msg_val ^= 0x1;
3760 pci_write_config_word(nic->pdev, 0x4c, msg_val);
3761 pci_read_config_word(nic->pdev, 0x4c, &msg_val);
3762
3763 pci_read_config_word(nic->pdev, 0x42, &msi_ctrl);
3764 msi_ctrl |= 0x10;
3765 pci_write_config_word(nic->pdev, 0x42, msi_ctrl);
3766
3767 /* program MSI-1 into all usable Tx_Mat and Rx_Mat fields */
3768 tx_mat = readq(&bar0->tx_mat0_n[0]);
3769 for (i=0; i<config->tx_fifo_num; i++) {
3770 tx_mat |= TX_MAT_SET(i, 1);
3771 }
3772 writeq(tx_mat, &bar0->tx_mat0_n[0]);
3773
3774 rx_mat = readq(&bar0->rx_mat);
3775 for (i=0; i<config->rx_ring_num; i++) {
3776 rx_mat |= RX_MAT_SET(i, 1);
3777 }
3778 writeq(rx_mat, &bar0->rx_mat);
3779
3780 dev->irq = nic->pdev->irq;
3781 return 0;
3782}
3783
3784static int s2io_enable_msi_x(struct s2io_nic *nic) 3676static int s2io_enable_msi_x(struct s2io_nic *nic)
3785{ 3677{
3786 struct XENA_dev_config __iomem *bar0 = nic->bar0; 3678 struct XENA_dev_config __iomem *bar0 = nic->bar0;
@@ -4001,6 +3893,7 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4001 struct mac_info *mac_control; 3893 struct mac_info *mac_control;
4002 struct config_param *config; 3894 struct config_param *config;
4003 int offload_type; 3895 int offload_type;
3896 struct swStat *stats = &sp->mac_control.stats_info->sw_stat;
4004 3897
4005 mac_control = &sp->mac_control; 3898 mac_control = &sp->mac_control;
4006 config = &sp->config; 3899 config = &sp->config;
@@ -4085,11 +3978,18 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4085 txdp->Buffer_Pointer = pci_map_single(sp->pdev, 3978 txdp->Buffer_Pointer = pci_map_single(sp->pdev,
4086 sp->ufo_in_band_v, 3979 sp->ufo_in_band_v,
4087 sizeof(u64), PCI_DMA_TODEVICE); 3980 sizeof(u64), PCI_DMA_TODEVICE);
3981 if((txdp->Buffer_Pointer == 0) ||
3982 (txdp->Buffer_Pointer == DMA_ERROR_CODE))
3983 goto pci_map_failed;
4088 txdp++; 3984 txdp++;
4089 } 3985 }
4090 3986
4091 txdp->Buffer_Pointer = pci_map_single 3987 txdp->Buffer_Pointer = pci_map_single
4092 (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE); 3988 (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE);
3989 if((txdp->Buffer_Pointer == 0) ||
3990 (txdp->Buffer_Pointer == DMA_ERROR_CODE))
3991 goto pci_map_failed;
3992
4093 txdp->Host_Control = (unsigned long) skb; 3993 txdp->Host_Control = (unsigned long) skb;
4094 txdp->Control_1 |= TXD_BUFFER0_SIZE(frg_len); 3994 txdp->Control_1 |= TXD_BUFFER0_SIZE(frg_len);
4095 if (offload_type == SKB_GSO_UDP) 3995 if (offload_type == SKB_GSO_UDP)
@@ -4146,6 +4046,13 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4146 spin_unlock_irqrestore(&sp->tx_lock, flags); 4046 spin_unlock_irqrestore(&sp->tx_lock, flags);
4147 4047
4148 return 0; 4048 return 0;
4049pci_map_failed:
4050 stats->pci_map_fail_cnt++;
4051 netif_stop_queue(dev);
4052 stats->mem_freed += skb->truesize;
4053 dev_kfree_skb(skb);
4054 spin_unlock_irqrestore(&sp->tx_lock, flags);
4055 return 0;
4149} 4056}
4150 4057
4151static void 4058static void
@@ -4186,39 +4093,6 @@ static int s2io_chk_rx_buffers(struct s2io_nic *sp, int rng_n)
4186 return 0; 4093 return 0;
4187} 4094}
4188 4095
4189static irqreturn_t s2io_msi_handle(int irq, void *dev_id)
4190{
4191 struct net_device *dev = (struct net_device *) dev_id;
4192 struct s2io_nic *sp = dev->priv;
4193 int i;
4194 struct mac_info *mac_control;
4195 struct config_param *config;
4196
4197 atomic_inc(&sp->isr_cnt);
4198 mac_control = &sp->mac_control;
4199 config = &sp->config;
4200 DBG_PRINT(INTR_DBG, "%s: MSI handler\n", __FUNCTION__);
4201
4202 /* If Intr is because of Rx Traffic */
4203 for (i = 0; i < config->rx_ring_num; i++)
4204 rx_intr_handler(&mac_control->rings[i]);
4205
4206 /* If Intr is because of Tx Traffic */
4207 for (i = 0; i < config->tx_fifo_num; i++)
4208 tx_intr_handler(&mac_control->fifos[i]);
4209
4210 /*
4211 * If the Rx buffer count is below the panic threshold then
4212 * reallocate the buffers from the interrupt handler itself,
4213 * else schedule a tasklet to reallocate the buffers.
4214 */
4215 for (i = 0; i < config->rx_ring_num; i++)
4216 s2io_chk_rx_buffers(sp, i);
4217
4218 atomic_dec(&sp->isr_cnt);
4219 return IRQ_HANDLED;
4220}
4221
4222static irqreturn_t s2io_msix_ring_handle(int irq, void *dev_id) 4096static irqreturn_t s2io_msix_ring_handle(int irq, void *dev_id)
4223{ 4097{
4224 struct ring_info *ring = (struct ring_info *)dev_id; 4098 struct ring_info *ring = (struct ring_info *)dev_id;
@@ -4927,19 +4801,17 @@ static void s2io_ethtool_gringparam(struct net_device *dev,
4927 ering->rx_max_pending = MAX_RX_DESC_1; 4801 ering->rx_max_pending = MAX_RX_DESC_1;
4928 else if (sp->rxd_mode == RXD_MODE_3B) 4802 else if (sp->rxd_mode == RXD_MODE_3B)
4929 ering->rx_max_pending = MAX_RX_DESC_2; 4803 ering->rx_max_pending = MAX_RX_DESC_2;
4930 else if (sp->rxd_mode == RXD_MODE_3A)
4931 ering->rx_max_pending = MAX_RX_DESC_3;
4932 4804
4933 ering->tx_max_pending = MAX_TX_DESC; 4805 ering->tx_max_pending = MAX_TX_DESC;
4934 for (i = 0 ; i < sp->config.tx_fifo_num ; i++) { 4806 for (i = 0 ; i < sp->config.tx_fifo_num ; i++)
4935 tx_desc_count += sp->config.tx_cfg[i].fifo_len; 4807 tx_desc_count += sp->config.tx_cfg[i].fifo_len;
4936 } 4808
4937 DBG_PRINT(INFO_DBG,"\nmax txds : %d\n",sp->config.max_txds); 4809 DBG_PRINT(INFO_DBG,"\nmax txds : %d\n",sp->config.max_txds);
4938 ering->tx_pending = tx_desc_count; 4810 ering->tx_pending = tx_desc_count;
4939 rx_desc_count = 0; 4811 rx_desc_count = 0;
4940 for (i = 0 ; i < sp->config.rx_ring_num ; i++) { 4812 for (i = 0 ; i < sp->config.rx_ring_num ; i++)
4941 rx_desc_count += sp->config.rx_cfg[i].num_rxd; 4813 rx_desc_count += sp->config.rx_cfg[i].num_rxd;
4942 } 4814
4943 ering->rx_pending = rx_desc_count; 4815 ering->rx_pending = rx_desc_count;
4944 4816
4945 ering->rx_mini_max_pending = 0; 4817 ering->rx_mini_max_pending = 0;
@@ -5923,6 +5795,7 @@ static void s2io_get_ethtool_stats(struct net_device *dev,
5923 else 5795 else
5924 tmp_stats[i++] = 0; 5796 tmp_stats[i++] = 0;
5925 tmp_stats[i++] = stat_info->sw_stat.mem_alloc_fail_cnt; 5797 tmp_stats[i++] = stat_info->sw_stat.mem_alloc_fail_cnt;
5798 tmp_stats[i++] = stat_info->sw_stat.pci_map_fail_cnt;
5926 tmp_stats[i++] = stat_info->sw_stat.watchdog_timer_cnt; 5799 tmp_stats[i++] = stat_info->sw_stat.watchdog_timer_cnt;
5927 tmp_stats[i++] = stat_info->sw_stat.mem_allocated; 5800 tmp_stats[i++] = stat_info->sw_stat.mem_allocated;
5928 tmp_stats[i++] = stat_info->sw_stat.mem_freed; 5801 tmp_stats[i++] = stat_info->sw_stat.mem_freed;
@@ -6266,9 +6139,10 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6266 u64 *temp2, int size) 6139 u64 *temp2, int size)
6267{ 6140{
6268 struct net_device *dev = sp->dev; 6141 struct net_device *dev = sp->dev;
6269 struct sk_buff *frag_list; 6142 struct swStat *stats = &sp->mac_control.stats_info->sw_stat;
6270 6143
6271 if ((sp->rxd_mode == RXD_MODE_1) && (rxdp->Host_Control == 0)) { 6144 if ((sp->rxd_mode == RXD_MODE_1) && (rxdp->Host_Control == 0)) {
6145 struct RxD1 *rxdp1 = (struct RxD1 *)rxdp;
6272 /* allocate skb */ 6146 /* allocate skb */
6273 if (*skb) { 6147 if (*skb) {
6274 DBG_PRINT(INFO_DBG, "SKB is not NULL\n"); 6148 DBG_PRINT(INFO_DBG, "SKB is not NULL\n");
@@ -6277,7 +6151,7 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6277 * using same mapped address for the Rxd 6151 * using same mapped address for the Rxd
6278 * buffer pointer 6152 * buffer pointer
6279 */ 6153 */
6280 ((struct RxD1*)rxdp)->Buffer0_ptr = *temp0; 6154 rxdp1->Buffer0_ptr = *temp0;
6281 } else { 6155 } else {
6282 *skb = dev_alloc_skb(size); 6156 *skb = dev_alloc_skb(size);
6283 if (!(*skb)) { 6157 if (!(*skb)) {
@@ -6294,18 +6168,23 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6294 * such it will be used for next rxd whose 6168 * such it will be used for next rxd whose
6295 * Host Control is NULL 6169 * Host Control is NULL
6296 */ 6170 */
6297 ((struct RxD1*)rxdp)->Buffer0_ptr = *temp0 = 6171 rxdp1->Buffer0_ptr = *temp0 =
6298 pci_map_single( sp->pdev, (*skb)->data, 6172 pci_map_single( sp->pdev, (*skb)->data,
6299 size - NET_IP_ALIGN, 6173 size - NET_IP_ALIGN,
6300 PCI_DMA_FROMDEVICE); 6174 PCI_DMA_FROMDEVICE);
6175 if( (rxdp1->Buffer0_ptr == 0) ||
6176 (rxdp1->Buffer0_ptr == DMA_ERROR_CODE)) {
6177 goto memalloc_failed;
6178 }
6301 rxdp->Host_Control = (unsigned long) (*skb); 6179 rxdp->Host_Control = (unsigned long) (*skb);
6302 } 6180 }
6303 } else if ((sp->rxd_mode == RXD_MODE_3B) && (rxdp->Host_Control == 0)) { 6181 } else if ((sp->rxd_mode == RXD_MODE_3B) && (rxdp->Host_Control == 0)) {
6182 struct RxD3 *rxdp3 = (struct RxD3 *)rxdp;
6304 /* Two buffer Mode */ 6183 /* Two buffer Mode */
6305 if (*skb) { 6184 if (*skb) {
6306 ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2; 6185 rxdp3->Buffer2_ptr = *temp2;
6307 ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0; 6186 rxdp3->Buffer0_ptr = *temp0;
6308 ((struct RxD3*)rxdp)->Buffer1_ptr = *temp1; 6187 rxdp3->Buffer1_ptr = *temp1;
6309 } else { 6188 } else {
6310 *skb = dev_alloc_skb(size); 6189 *skb = dev_alloc_skb(size);
6311 if (!(*skb)) { 6190 if (!(*skb)) {
@@ -6318,73 +6197,47 @@ static int set_rxd_buffer_pointer(struct s2io_nic *sp, struct RxD_t *rxdp,
6318 } 6197 }
6319 sp->mac_control.stats_info->sw_stat.mem_allocated 6198 sp->mac_control.stats_info->sw_stat.mem_allocated
6320 += (*skb)->truesize; 6199 += (*skb)->truesize;
6321 ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 = 6200 rxdp3->Buffer2_ptr = *temp2 =
6322 pci_map_single(sp->pdev, (*skb)->data, 6201 pci_map_single(sp->pdev, (*skb)->data,
6323 dev->mtu + 4, 6202 dev->mtu + 4,
6324 PCI_DMA_FROMDEVICE); 6203 PCI_DMA_FROMDEVICE);
6325 ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 = 6204 if( (rxdp3->Buffer2_ptr == 0) ||
6205 (rxdp3->Buffer2_ptr == DMA_ERROR_CODE)) {
6206 goto memalloc_failed;
6207 }
6208 rxdp3->Buffer0_ptr = *temp0 =
6326 pci_map_single( sp->pdev, ba->ba_0, BUF0_LEN, 6209 pci_map_single( sp->pdev, ba->ba_0, BUF0_LEN,
6327 PCI_DMA_FROMDEVICE); 6210 PCI_DMA_FROMDEVICE);
6211 if( (rxdp3->Buffer0_ptr == 0) ||
6212 (rxdp3->Buffer0_ptr == DMA_ERROR_CODE)) {
6213 pci_unmap_single (sp->pdev,
6214 (dma_addr_t)(*skb)->data,
6215 dev->mtu + 4, PCI_DMA_FROMDEVICE);
6216 goto memalloc_failed;
6217 }
6328 rxdp->Host_Control = (unsigned long) (*skb); 6218 rxdp->Host_Control = (unsigned long) (*skb);
6329 6219
6330 /* Buffer-1 will be dummy buffer not used */ 6220 /* Buffer-1 will be dummy buffer not used */
6331 ((struct RxD3*)rxdp)->Buffer1_ptr = *temp1 = 6221 rxdp3->Buffer1_ptr = *temp1 =
6332 pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN, 6222 pci_map_single(sp->pdev, ba->ba_1, BUF1_LEN,
6333 PCI_DMA_FROMDEVICE);
6334 }
6335 } else if ((rxdp->Host_Control == 0)) {
6336 /* Three buffer mode */
6337 if (*skb) {
6338 ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0;
6339 ((struct RxD3*)rxdp)->Buffer1_ptr = *temp1;
6340 ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2;
6341 } else {
6342 *skb = dev_alloc_skb(size);
6343 if (!(*skb)) {
6344 DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name);
6345 DBG_PRINT(INFO_DBG, "memory to allocate ");
6346 DBG_PRINT(INFO_DBG, "3 buf mode SKBs\n");
6347 sp->mac_control.stats_info->sw_stat. \
6348 mem_alloc_fail_cnt++;
6349 return -ENOMEM;
6350 }
6351 sp->mac_control.stats_info->sw_stat.mem_allocated
6352 += (*skb)->truesize;
6353 ((struct RxD3*)rxdp)->Buffer0_ptr = *temp0 =
6354 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN,
6355 PCI_DMA_FROMDEVICE);
6356 /* Buffer-1 receives L3/L4 headers */
6357 ((struct RxD3*)rxdp)->Buffer1_ptr = *temp1 =
6358 pci_map_single( sp->pdev, (*skb)->data,
6359 l3l4hdr_size + 4,
6360 PCI_DMA_FROMDEVICE); 6223 PCI_DMA_FROMDEVICE);
6361 /* 6224 if( (rxdp3->Buffer1_ptr == 0) ||
6362 * skb_shinfo(skb)->frag_list will have L4 6225 (rxdp3->Buffer1_ptr == DMA_ERROR_CODE)) {
6363 * data payload 6226 pci_unmap_single (sp->pdev,
6364 */ 6227 (dma_addr_t)(*skb)->data,
6365 skb_shinfo(*skb)->frag_list = dev_alloc_skb(dev->mtu + 6228 dev->mtu + 4, PCI_DMA_FROMDEVICE);
6366 ALIGN_SIZE); 6229 goto memalloc_failed;
6367 if (skb_shinfo(*skb)->frag_list == NULL) {
6368 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb \
6369 failed\n ", dev->name);
6370 sp->mac_control.stats_info->sw_stat. \
6371 mem_alloc_fail_cnt++;
6372 return -ENOMEM ;
6373 } 6230 }
6374 frag_list = skb_shinfo(*skb)->frag_list;
6375 frag_list->next = NULL;
6376 sp->mac_control.stats_info->sw_stat.mem_allocated
6377 += frag_list->truesize;
6378 /*
6379 * Buffer-2 receives L4 data payload
6380 */
6381 ((struct RxD3*)rxdp)->Buffer2_ptr = *temp2 =
6382 pci_map_single( sp->pdev, frag_list->data,
6383 dev->mtu, PCI_DMA_FROMDEVICE);
6384 } 6231 }
6385 } 6232 }
6386 return 0; 6233 return 0;
6234 memalloc_failed:
6235 stats->pci_map_fail_cnt++;
6236 stats->mem_freed += (*skb)->truesize;
6237 dev_kfree_skb(*skb);
6238 return -ENOMEM;
6387} 6239}
6240
6388static void set_rxd_buffer_size(struct s2io_nic *sp, struct RxD_t *rxdp, 6241static void set_rxd_buffer_size(struct s2io_nic *sp, struct RxD_t *rxdp,
6389 int size) 6242 int size)
6390{ 6243{
@@ -6395,10 +6248,6 @@ static void set_rxd_buffer_size(struct s2io_nic *sp, struct RxD_t *rxdp,
6395 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); 6248 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
6396 rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1); 6249 rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1);
6397 rxdp->Control_2 |= SET_BUFFER2_SIZE_3( dev->mtu + 4); 6250 rxdp->Control_2 |= SET_BUFFER2_SIZE_3( dev->mtu + 4);
6398 } else {
6399 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
6400 rxdp->Control_2 |= SET_BUFFER1_SIZE_3(l3l4hdr_size + 4);
6401 rxdp->Control_2 |= SET_BUFFER2_SIZE_3(dev->mtu);
6402 } 6251 }
6403} 6252}
6404 6253
@@ -6420,8 +6269,6 @@ static int rxd_owner_bit_reset(struct s2io_nic *sp)
6420 size += NET_IP_ALIGN; 6269 size += NET_IP_ALIGN;
6421 else if (sp->rxd_mode == RXD_MODE_3B) 6270 else if (sp->rxd_mode == RXD_MODE_3B)
6422 size = dev->mtu + ALIGN_SIZE + BUF0_LEN + 4; 6271 size = dev->mtu + ALIGN_SIZE + BUF0_LEN + 4;
6423 else
6424 size = l3l4hdr_size + ALIGN_SIZE + BUF0_LEN + 4;
6425 6272
6426 for (i = 0; i < config->rx_ring_num; i++) { 6273 for (i = 0; i < config->rx_ring_num; i++) {
6427 blk_cnt = config->rx_cfg[i].num_rxd / 6274 blk_cnt = config->rx_cfg[i].num_rxd /
@@ -6431,7 +6278,7 @@ static int rxd_owner_bit_reset(struct s2io_nic *sp)
6431 for (k = 0; k < rxd_count[sp->rxd_mode]; k++) { 6278 for (k = 0; k < rxd_count[sp->rxd_mode]; k++) {
6432 rxdp = mac_control->rings[i]. 6279 rxdp = mac_control->rings[i].
6433 rx_blocks[j].rxds[k].virt_addr; 6280 rx_blocks[j].rxds[k].virt_addr;
6434 if(sp->rxd_mode >= RXD_MODE_3A) 6281 if(sp->rxd_mode == RXD_MODE_3B)
6435 ba = &mac_control->rings[i].ba[j][k]; 6282 ba = &mac_control->rings[i].ba[j][k];
6436 if (set_rxd_buffer_pointer(sp, rxdp, ba, 6283 if (set_rxd_buffer_pointer(sp, rxdp, ba,
6437 &skb,(u64 *)&temp0_64, 6284 &skb,(u64 *)&temp0_64,
@@ -6458,9 +6305,7 @@ static int s2io_add_isr(struct s2io_nic * sp)
6458 struct net_device *dev = sp->dev; 6305 struct net_device *dev = sp->dev;
6459 int err = 0; 6306 int err = 0;
6460 6307
6461 if (sp->intr_type == MSI) 6308 if (sp->intr_type == MSI_X)
6462 ret = s2io_enable_msi(sp);
6463 else if (sp->intr_type == MSI_X)
6464 ret = s2io_enable_msi_x(sp); 6309 ret = s2io_enable_msi_x(sp);
6465 if (ret) { 6310 if (ret) {
6466 DBG_PRINT(ERR_DBG, "%s: Defaulting to INTA\n", dev->name); 6311 DBG_PRINT(ERR_DBG, "%s: Defaulting to INTA\n", dev->name);
@@ -6471,16 +6316,6 @@ static int s2io_add_isr(struct s2io_nic * sp)
6471 store_xmsi_data(sp); 6316 store_xmsi_data(sp);
6472 6317
6473 /* After proper initialization of H/W, register ISR */ 6318 /* After proper initialization of H/W, register ISR */
6474 if (sp->intr_type == MSI) {
6475 err = request_irq((int) sp->pdev->irq, s2io_msi_handle,
6476 IRQF_SHARED, sp->name, dev);
6477 if (err) {
6478 pci_disable_msi(sp->pdev);
6479 DBG_PRINT(ERR_DBG, "%s: MSI registration failed\n",
6480 dev->name);
6481 return -1;
6482 }
6483 }
6484 if (sp->intr_type == MSI_X) { 6319 if (sp->intr_type == MSI_X) {
6485 int i, msix_tx_cnt=0,msix_rx_cnt=0; 6320 int i, msix_tx_cnt=0,msix_rx_cnt=0;
6486 6321
@@ -6567,14 +6402,6 @@ static void s2io_rem_isr(struct s2io_nic * sp)
6567 pci_disable_msix(sp->pdev); 6402 pci_disable_msix(sp->pdev);
6568 } else { 6403 } else {
6569 free_irq(sp->pdev->irq, dev); 6404 free_irq(sp->pdev->irq, dev);
6570 if (sp->intr_type == MSI) {
6571 u16 val;
6572
6573 pci_disable_msi(sp->pdev);
6574 pci_read_config_word(sp->pdev, 0x4c, &val);
6575 val ^= 0x1;
6576 pci_write_config_word(sp->pdev, 0x4c, val);
6577 }
6578 } 6405 }
6579 /* Waiting till all Interrupt handlers are complete */ 6406 /* Waiting till all Interrupt handlers are complete */
6580 cnt = 0; 6407 cnt = 0;
@@ -6907,6 +6734,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6907 } 6734 }
6908 6735
6909 /* Updating statistics */ 6736 /* Updating statistics */
6737 sp->stats.rx_packets++;
6910 rxdp->Host_Control = 0; 6738 rxdp->Host_Control = 0;
6911 if (sp->rxd_mode == RXD_MODE_1) { 6739 if (sp->rxd_mode == RXD_MODE_1) {
6912 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); 6740 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2);
@@ -6914,7 +6742,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6914 sp->stats.rx_bytes += len; 6742 sp->stats.rx_bytes += len;
6915 skb_put(skb, len); 6743 skb_put(skb, len);
6916 6744
6917 } else if (sp->rxd_mode >= RXD_MODE_3A) { 6745 } else if (sp->rxd_mode == RXD_MODE_3B) {
6918 int get_block = ring_data->rx_curr_get_info.block_index; 6746 int get_block = ring_data->rx_curr_get_info.block_index;
6919 int get_off = ring_data->rx_curr_get_info.offset; 6747 int get_off = ring_data->rx_curr_get_info.offset;
6920 int buf0_len = RXD_GET_BUFFER0_SIZE_3(rxdp->Control_2); 6748 int buf0_len = RXD_GET_BUFFER0_SIZE_3(rxdp->Control_2);
@@ -6924,18 +6752,7 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
6924 struct buffAdd *ba = &ring_data->ba[get_block][get_off]; 6752 struct buffAdd *ba = &ring_data->ba[get_block][get_off];
6925 sp->stats.rx_bytes += buf0_len + buf2_len; 6753 sp->stats.rx_bytes += buf0_len + buf2_len;
6926 memcpy(buff, ba->ba_0, buf0_len); 6754 memcpy(buff, ba->ba_0, buf0_len);
6927 6755 skb_put(skb, buf2_len);
6928 if (sp->rxd_mode == RXD_MODE_3A) {
6929 int buf1_len = RXD_GET_BUFFER1_SIZE_3(rxdp->Control_2);
6930
6931 skb_put(skb, buf1_len);
6932 skb->len += buf2_len;
6933 skb->data_len += buf2_len;
6934 skb_put(skb_shinfo(skb)->frag_list, buf2_len);
6935 sp->stats.rx_bytes += buf1_len;
6936
6937 } else
6938 skb_put(skb, buf2_len);
6939 } 6756 }
6940 6757
6941 if ((rxdp->Control_1 & TCP_OR_UDP_FRAME) && ((!sp->lro) || 6758 if ((rxdp->Control_1 & TCP_OR_UDP_FRAME) && ((!sp->lro) ||
@@ -7131,7 +6948,7 @@ static int s2io_verify_parm(struct pci_dev *pdev, u8 *dev_intr_type)
7131 *dev_intr_type = INTA; 6948 *dev_intr_type = INTA;
7132 } 6949 }
7133#else 6950#else
7134 if (*dev_intr_type > MSI_X) { 6951 if ((*dev_intr_type != INTA) && (*dev_intr_type != MSI_X)) {
7135 DBG_PRINT(ERR_DBG, "s2io: Wrong intr_type requested. " 6952 DBG_PRINT(ERR_DBG, "s2io: Wrong intr_type requested. "
7136 "Defaulting to INTA\n"); 6953 "Defaulting to INTA\n");
7137 *dev_intr_type = INTA; 6954 *dev_intr_type = INTA;
@@ -7145,10 +6962,10 @@ static int s2io_verify_parm(struct pci_dev *pdev, u8 *dev_intr_type)
7145 *dev_intr_type = INTA; 6962 *dev_intr_type = INTA;
7146 } 6963 }
7147 6964
7148 if (rx_ring_mode > 3) { 6965 if ((rx_ring_mode != 1) && (rx_ring_mode != 2)) {
7149 DBG_PRINT(ERR_DBG, "s2io: Requested ring mode not supported\n"); 6966 DBG_PRINT(ERR_DBG, "s2io: Requested ring mode not supported\n");
7150 DBG_PRINT(ERR_DBG, "s2io: Defaulting to 3-buffer mode\n"); 6967 DBG_PRINT(ERR_DBG, "s2io: Defaulting to 1-buffer mode\n");
7151 rx_ring_mode = 3; 6968 rx_ring_mode = 1;
7152 } 6969 }
7153 return SUCCESS; 6970 return SUCCESS;
7154} 6971}
@@ -7240,28 +7057,10 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7240 pci_disable_device(pdev); 7057 pci_disable_device(pdev);
7241 return -ENOMEM; 7058 return -ENOMEM;
7242 } 7059 }
7243 if (dev_intr_type != MSI_X) { 7060 if ((ret = pci_request_regions(pdev, s2io_driver_name))) {
7244 if (pci_request_regions(pdev, s2io_driver_name)) { 7061 DBG_PRINT(ERR_DBG, "%s: Request Regions failed - %x \n", __FUNCTION__, ret);
7245 DBG_PRINT(ERR_DBG, "Request Regions failed\n"); 7062 pci_disable_device(pdev);
7246 pci_disable_device(pdev); 7063 return -ENODEV;
7247 return -ENODEV;
7248 }
7249 }
7250 else {
7251 if (!(request_mem_region(pci_resource_start(pdev, 0),
7252 pci_resource_len(pdev, 0), s2io_driver_name))) {
7253 DBG_PRINT(ERR_DBG, "bar0 Request Regions failed\n");
7254 pci_disable_device(pdev);
7255 return -ENODEV;
7256 }
7257 if (!(request_mem_region(pci_resource_start(pdev, 2),
7258 pci_resource_len(pdev, 2), s2io_driver_name))) {
7259 DBG_PRINT(ERR_DBG, "bar1 Request Regions failed\n");
7260 release_mem_region(pci_resource_start(pdev, 0),
7261 pci_resource_len(pdev, 0));
7262 pci_disable_device(pdev);
7263 return -ENODEV;
7264 }
7265 } 7064 }
7266 7065
7267 dev = alloc_etherdev(sizeof(struct s2io_nic)); 7066 dev = alloc_etherdev(sizeof(struct s2io_nic));
@@ -7288,8 +7087,6 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7288 sp->rxd_mode = RXD_MODE_1; 7087 sp->rxd_mode = RXD_MODE_1;
7289 if (rx_ring_mode == 2) 7088 if (rx_ring_mode == 2)
7290 sp->rxd_mode = RXD_MODE_3B; 7089 sp->rxd_mode = RXD_MODE_3B;
7291 if (rx_ring_mode == 3)
7292 sp->rxd_mode = RXD_MODE_3A;
7293 7090
7294 sp->intr_type = dev_intr_type; 7091 sp->intr_type = dev_intr_type;
7295 7092
@@ -7565,10 +7362,6 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7565 DBG_PRINT(ERR_DBG, "%s: 2-Buffer receive mode enabled\n", 7362 DBG_PRINT(ERR_DBG, "%s: 2-Buffer receive mode enabled\n",
7566 dev->name); 7363 dev->name);
7567 break; 7364 break;
7568 case RXD_MODE_3A:
7569 DBG_PRINT(ERR_DBG, "%s: 3-Buffer receive mode enabled\n",
7570 dev->name);
7571 break;
7572 } 7365 }
7573 7366
7574 if (napi) 7367 if (napi)
@@ -7577,9 +7370,6 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7577 case INTA: 7370 case INTA:
7578 DBG_PRINT(ERR_DBG, "%s: Interrupt type INTA\n", dev->name); 7371 DBG_PRINT(ERR_DBG, "%s: Interrupt type INTA\n", dev->name);
7579 break; 7372 break;
7580 case MSI:
7581 DBG_PRINT(ERR_DBG, "%s: Interrupt type MSI\n", dev->name);
7582 break;
7583 case MSI_X: 7373 case MSI_X:
7584 DBG_PRINT(ERR_DBG, "%s: Interrupt type MSI-X\n", dev->name); 7374 DBG_PRINT(ERR_DBG, "%s: Interrupt type MSI-X\n", dev->name);
7585 break; 7375 break;
@@ -7619,14 +7409,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7619 mem_alloc_failed: 7409 mem_alloc_failed:
7620 free_shared_mem(sp); 7410 free_shared_mem(sp);
7621 pci_disable_device(pdev); 7411 pci_disable_device(pdev);
7622 if (dev_intr_type != MSI_X) 7412 pci_release_regions(pdev);
7623 pci_release_regions(pdev);
7624 else {
7625 release_mem_region(pci_resource_start(pdev, 0),
7626 pci_resource_len(pdev, 0));
7627 release_mem_region(pci_resource_start(pdev, 2),
7628 pci_resource_len(pdev, 2));
7629 }
7630 pci_set_drvdata(pdev, NULL); 7413 pci_set_drvdata(pdev, NULL);
7631 free_netdev(dev); 7414 free_netdev(dev);
7632 7415
@@ -7661,14 +7444,7 @@ static void __devexit s2io_rem_nic(struct pci_dev *pdev)
7661 free_shared_mem(sp); 7444 free_shared_mem(sp);
7662 iounmap(sp->bar0); 7445 iounmap(sp->bar0);
7663 iounmap(sp->bar1); 7446 iounmap(sp->bar1);
7664 if (sp->intr_type != MSI_X) 7447 pci_release_regions(pdev);
7665 pci_release_regions(pdev);
7666 else {
7667 release_mem_region(pci_resource_start(pdev, 0),
7668 pci_resource_len(pdev, 0));
7669 release_mem_region(pci_resource_start(pdev, 2),
7670 pci_resource_len(pdev, 2));
7671 }
7672 pci_set_drvdata(pdev, NULL); 7448 pci_set_drvdata(pdev, NULL);
7673 free_netdev(dev); 7449 free_netdev(dev);
7674 pci_disable_device(pdev); 7450 pci_disable_device(pdev);
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 3887fe63a908..92983ee7df8c 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -74,6 +74,10 @@ static int debug_level = ERR_DBG;
74/* DEBUG message print. */ 74/* DEBUG message print. */
75#define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args) 75#define DBG_PRINT(dbg_level, args...) if(!(debug_level<dbg_level)) printk(args)
76 76
77#ifndef DMA_ERROR_CODE
78#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
79#endif
80
77/* Protocol assist features of the NIC */ 81/* Protocol assist features of the NIC */
78#define L3_CKSUM_OK 0xFFFF 82#define L3_CKSUM_OK 0xFFFF
79#define L4_CKSUM_OK 0xFFFF 83#define L4_CKSUM_OK 0xFFFF
@@ -97,6 +101,7 @@ struct swStat {
97 unsigned long long num_aggregations; 101 unsigned long long num_aggregations;
98 /* Other statistics */ 102 /* Other statistics */
99 unsigned long long mem_alloc_fail_cnt; 103 unsigned long long mem_alloc_fail_cnt;
104 unsigned long long pci_map_fail_cnt;
100 unsigned long long watchdog_timer_cnt; 105 unsigned long long watchdog_timer_cnt;
101 unsigned long long mem_allocated; 106 unsigned long long mem_allocated;
102 unsigned long long mem_freed; 107 unsigned long long mem_freed;
@@ -575,8 +580,7 @@ struct RxD_block {
575#define SIZE_OF_BLOCK 4096 580#define SIZE_OF_BLOCK 4096
576 581
577#define RXD_MODE_1 0 /* One Buffer mode */ 582#define RXD_MODE_1 0 /* One Buffer mode */
578#define RXD_MODE_3A 1 /* Three Buffer mode */ 583#define RXD_MODE_3B 1 /* Two Buffer mode */
579#define RXD_MODE_3B 2 /* Two Buffer mode */
580 584
581/* Structure to hold virtual addresses of Buf0 and Buf1 in 585/* Structure to hold virtual addresses of Buf0 and Buf1 in
582 * 2buf mode. */ 586 * 2buf mode. */
@@ -876,7 +880,6 @@ struct s2io_nic {
876 u16 lro_max_aggr_per_sess; 880 u16 lro_max_aggr_per_sess;
877 881
878#define INTA 0 882#define INTA 0
879#define MSI 1
880#define MSI_X 2 883#define MSI_X 2
881 u8 intr_type; 884 u8 intr_type;
882 885
@@ -1020,8 +1023,6 @@ static int s2io_poll(struct net_device *dev, int *budget);
1020static void s2io_init_pci(struct s2io_nic * sp); 1023static void s2io_init_pci(struct s2io_nic * sp);
1021static int s2io_set_mac_addr(struct net_device *dev, u8 * addr); 1024static int s2io_set_mac_addr(struct net_device *dev, u8 * addr);
1022static void s2io_alarm_handle(unsigned long data); 1025static void s2io_alarm_handle(unsigned long data);
1023static int s2io_enable_msi(struct s2io_nic *nic);
1024static irqreturn_t s2io_msi_handle(int irq, void *dev_id);
1025static irqreturn_t 1026static irqreturn_t
1026s2io_msix_ring_handle(int irq, void *dev_id); 1027s2io_msix_ring_handle(int irq, void *dev_id);
1027static irqreturn_t 1028static irqreturn_t
diff --git a/drivers/net/sc92031.c b/drivers/net/sc92031.c
index 5b7284c955dc..872cb1cc9c41 100644
--- a/drivers/net/sc92031.c
+++ b/drivers/net/sc92031.c
@@ -1402,7 +1402,6 @@ static struct ethtool_ops sc92031_ethtool_ops = {
1402 .get_strings = sc92031_ethtool_get_strings, 1402 .get_strings = sc92031_ethtool_get_strings,
1403 .get_stats_count = sc92031_ethtool_get_stats_count, 1403 .get_stats_count = sc92031_ethtool_get_stats_count,
1404 .get_ethtool_stats = sc92031_ethtool_get_ethtool_stats, 1404 .get_ethtool_stats = sc92031_ethtool_get_ethtool_stats,
1405 .get_perm_addr = ethtool_op_get_perm_addr,
1406 .get_ufo = ethtool_op_get_ufo, 1405 .get_ufo = ethtool_op_get_ufo,
1407}; 1406};
1408 1407
diff --git a/drivers/net/skfp/pmf.c b/drivers/net/skfp/pmf.c
index efc639c013fd..ea85de918233 100644
--- a/drivers/net/skfp/pmf.c
+++ b/drivers/net/skfp/pmf.c
@@ -575,7 +575,7 @@ void smt_add_para(struct s_smc *smc, struct s_pcon *pcon, u_short para,
575 int sp_len ; 575 int sp_len ;
576 576
577 /* 577 /*
578 * skip if errror 578 * skip if error
579 */ 579 */
580 if (pcon->pc_err) 580 if (pcon->pc_err)
581 return ; 581 return ;
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 776692946562..e3d8520209b8 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -821,7 +821,6 @@ static const struct ethtool_ops skge_ethtool_ops = {
821 .phys_id = skge_phys_id, 821 .phys_id = skge_phys_id,
822 .get_stats_count = skge_get_stats_count, 822 .get_stats_count = skge_get_stats_count,
823 .get_ethtool_stats = skge_get_ethtool_stats, 823 .get_ethtool_stats = skge_get_ethtool_stats,
824 .get_perm_addr = ethtool_op_get_perm_addr,
825}; 824};
826 825
827/* 826/*
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 13f08a390e1f..e7a2eadcc3b0 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -3548,7 +3548,6 @@ static const struct ethtool_ops sky2_ethtool_ops = {
3548 .phys_id = sky2_phys_id, 3548 .phys_id = sky2_phys_id,
3549 .get_stats_count = sky2_get_stats_count, 3549 .get_stats_count = sky2_get_stats_count,
3550 .get_ethtool_stats = sky2_get_ethtool_stats, 3550 .get_ethtool_stats = sky2_get_ethtool_stats,
3551 .get_perm_addr = ethtool_op_get_perm_addr,
3552}; 3551};
3553 3552
3554#ifdef CONFIG_SKY2_DEBUG 3553#ifdef CONFIG_SKY2_DEBUG
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index af0c9831074c..a8f2af8f778a 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -1586,7 +1586,6 @@ static const struct ethtool_ops ethtool_ops = {
1586 .get_link = get_link, 1586 .get_link = get_link,
1587 .get_msglevel = get_msglevel, 1587 .get_msglevel = get_msglevel,
1588 .set_msglevel = set_msglevel, 1588 .set_msglevel = set_msglevel,
1589 .get_perm_addr = ethtool_op_get_perm_addr,
1590}; 1589};
1591 1590
1592static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1591static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index 053b7cb0d944..68e4f660367d 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -99,8 +99,7 @@ static char lancestr[] = "LANCE";
99#include <asm/byteorder.h> /* Used by the checksum routines */ 99#include <asm/byteorder.h> /* Used by the checksum routines */
100#include <asm/idprom.h> 100#include <asm/idprom.h>
101#include <asm/sbus.h> 101#include <asm/sbus.h>
102#include <asm/openprom.h> 102#include <asm/prom.h>
103#include <asm/oplib.h>
104#include <asm/auxio.h> /* For tpe-link-test? setting */ 103#include <asm/auxio.h> /* For tpe-link-test? setting */
105#include <asm/irq.h> 104#include <asm/irq.h>
106 105
@@ -1326,6 +1325,7 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev,
1326 struct sbus_dev *lebuffer) 1325 struct sbus_dev *lebuffer)
1327{ 1326{
1328 static unsigned version_printed; 1327 static unsigned version_printed;
1328 struct device_node *dp = sdev->ofdev.node;
1329 struct net_device *dev; 1329 struct net_device *dev;
1330 struct lance_private *lp; 1330 struct lance_private *lp;
1331 int i; 1331 int i;
@@ -1389,54 +1389,46 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev,
1389 lp->rx = lance_rx_dvma; 1389 lp->rx = lance_rx_dvma;
1390 lp->tx = lance_tx_dvma; 1390 lp->tx = lance_tx_dvma;
1391 } 1391 }
1392 lp->busmaster_regval = prom_getintdefault(sdev->prom_node, 1392 lp->busmaster_regval = of_getintprop_default(dp, "busmaster-regval",
1393 "busmaster-regval", 1393 (LE_C3_BSWP |
1394 (LE_C3_BSWP | LE_C3_ACON | 1394 LE_C3_ACON |
1395 LE_C3_BCON)); 1395 LE_C3_BCON));
1396 1396
1397 lp->name = lancestr; 1397 lp->name = lancestr;
1398 lp->ledma = ledma; 1398 lp->ledma = ledma;
1399 1399
1400 lp->burst_sizes = 0; 1400 lp->burst_sizes = 0;
1401 if (lp->ledma) { 1401 if (lp->ledma) {
1402 char prop[6]; 1402 struct device_node *ledma_dp = ledma->sdev->ofdev.node;
1403 const char *prop;
1403 unsigned int sbmask; 1404 unsigned int sbmask;
1404 u32 csr; 1405 u32 csr;
1405 1406
1406 /* Find burst-size property for ledma */ 1407 /* Find burst-size property for ledma */
1407 lp->burst_sizes = prom_getintdefault(ledma->sdev->prom_node, 1408 lp->burst_sizes = of_getintprop_default(ledma_dp,
1408 "burst-sizes", 0); 1409 "burst-sizes", 0);
1409 1410
1410 /* ledma may be capable of fast bursts, but sbus may not. */ 1411 /* ledma may be capable of fast bursts, but sbus may not. */
1411 sbmask = prom_getintdefault(ledma->sdev->bus->prom_node, 1412 sbmask = of_getintprop_default(ledma_dp, "burst-sizes",
1412 "burst-sizes", DMA_BURSTBITS); 1413 DMA_BURSTBITS);
1413 lp->burst_sizes &= sbmask; 1414 lp->burst_sizes &= sbmask;
1414 1415
1415 /* Get the cable-selection property */ 1416 /* Get the cable-selection property */
1416 memset(prop, 0, sizeof(prop)); 1417 prop = of_get_property(ledma_dp, "cable-selection", NULL);
1417 prom_getstring(ledma->sdev->prom_node, "cable-selection", 1418 if (!prop || prop[0] == '\0') {
1418 prop, sizeof(prop)); 1419 struct device_node *nd;
1419 if (prop[0] == 0) {
1420 int topnd, nd;
1421 1420
1422 printk(KERN_INFO "SunLance: using auto-carrier-detection.\n"); 1421 printk(KERN_INFO "SunLance: using "
1422 "auto-carrier-detection.\n");
1423 1423
1424 /* Is this found at /options .attributes in all 1424 nd = of_find_node_by_path("/options");
1425 * Prom versions? XXX
1426 */
1427 topnd = prom_getchild(prom_root_node);
1428
1429 nd = prom_searchsiblings(topnd, "options");
1430 if (!nd) 1425 if (!nd)
1431 goto no_link_test; 1426 goto no_link_test;
1432 1427
1433 if (!prom_node_has_property(nd, "tpe-link-test?")) 1428 prop = of_get_property(nd, "tpe-link-test?", NULL);
1429 if (!prop)
1434 goto no_link_test; 1430 goto no_link_test;
1435 1431
1436 memset(prop, 0, sizeof(prop));
1437 prom_getstring(nd, "tpe-link-test?", prop,
1438 sizeof(prop));
1439
1440 if (strcmp(prop, "true")) { 1432 if (strcmp(prop, "true")) {
1441 printk(KERN_NOTICE "SunLance: warning: overriding option " 1433 printk(KERN_NOTICE "SunLance: warning: overriding option "
1442 "'tpe-link-test?'\n"); 1434 "'tpe-link-test?'\n");
diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c
index 61f98251feab..ff1028a597df 100644
--- a/drivers/net/sunvnet.c
+++ b/drivers/net/sunvnet.c
@@ -906,7 +906,6 @@ static const struct ethtool_ops vnet_ethtool_ops = {
906 .get_msglevel = vnet_get_msglevel, 906 .get_msglevel = vnet_get_msglevel,
907 .set_msglevel = vnet_set_msglevel, 907 .set_msglevel = vnet_set_msglevel,
908 .get_link = ethtool_op_get_link, 908 .get_link = ethtool_op_get_link,
909 .get_perm_addr = ethtool_op_get_perm_addr,
910}; 909};
911 910
912static void vnet_port_free_tx_bufs(struct vnet_port *port) 911static void vnet_port_free_tx_bufs(struct vnet_port *port)
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c
index 7f94ca930988..ec41469eee82 100644
--- a/drivers/net/tc35815.c
+++ b/drivers/net/tc35815.c
@@ -2198,7 +2198,6 @@ static const struct ethtool_ops tc35815_ethtool_ops = {
2198 .get_strings = tc35815_get_strings, 2198 .get_strings = tc35815_get_strings,
2199 .get_stats_count = tc35815_get_stats_count, 2199 .get_stats_count = tc35815_get_stats_count,
2200 .get_ethtool_stats = tc35815_get_ethtool_stats, 2200 .get_ethtool_stats = tc35815_get_ethtool_stats,
2201 .get_perm_addr = ethtool_op_get_perm_addr,
2202}; 2201};
2203 2202
2204static int tc35815_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 2203static int tc35815_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 887b9a5cfe48..dc41c055ebb5 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -9294,7 +9294,6 @@ static const struct ethtool_ops tg3_ethtool_ops = {
9294 .get_ethtool_stats = tg3_get_ethtool_stats, 9294 .get_ethtool_stats = tg3_get_ethtool_stats,
9295 .get_coalesce = tg3_get_coalesce, 9295 .get_coalesce = tg3_get_coalesce,
9296 .set_coalesce = tg3_set_coalesce, 9296 .set_coalesce = tg3_set_coalesce,
9297 .get_perm_addr = ethtool_op_get_perm_addr,
9298}; 9297};
9299 9298
9300static void __devinit tg3_get_eeprom_size(struct tg3 *tp) 9299static void __devinit tg3_get_eeprom_size(struct tg3 *tp)
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index f87d76981ab7..eca984f89bbf 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1471,14 +1471,6 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1471 sa_offset = 2; /* Grrr, damn Matrox boards. */ 1471 sa_offset = 2; /* Grrr, damn Matrox boards. */
1472 multiport_cnt = 4; 1472 multiport_cnt = 4;
1473 } 1473 }
1474#ifdef CONFIG_DDB5477
1475 if ((pdev->bus->number == 0) && (PCI_SLOT(pdev->devfn) == 4)) {
1476 /* DDB5477 MAC address in first EEPROM locations. */
1477 sa_offset = 0;
1478 /* No media table either */
1479 tp->flags &= ~HAS_MEDIA_TABLE;
1480 }
1481#endif
1482#ifdef CONFIG_MIPS_COBALT 1474#ifdef CONFIG_MIPS_COBALT
1483 if ((pdev->bus->number == 0) && 1475 if ((pdev->bus->number == 0) &&
1484 ((PCI_SLOT(pdev->devfn) == 7) || 1476 ((PCI_SLOT(pdev->devfn) == 7) ||
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index e4736a3b1b7a..12e01b24105a 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -43,10 +43,6 @@
43 43
44#undef DEBUG 44#undef DEBUG
45 45
46#define DRV_DESC "QE UCC Gigabit Ethernet Controller"
47#define DRV_NAME "ucc_geth"
48#define DRV_VERSION "1.1"
49
50#define ugeth_printk(level, format, arg...) \ 46#define ugeth_printk(level, format, arg...) \
51 printk(level format "\n", ## arg) 47 printk(level format "\n", ## arg)
52 48
@@ -64,9 +60,19 @@
64#else 60#else
65#define ugeth_vdbg(fmt, args...) do { } while (0) 61#define ugeth_vdbg(fmt, args...) do { } while (0)
66#endif /* UGETH_VERBOSE_DEBUG */ 62#endif /* UGETH_VERBOSE_DEBUG */
63#define UGETH_MSG_DEFAULT (NETIF_MSG_IFUP << 1 ) - 1
67 64
65void uec_set_ethtool_ops(struct net_device *netdev);
66
68static DEFINE_SPINLOCK(ugeth_lock); 67static DEFINE_SPINLOCK(ugeth_lock);
69 68
69static struct {
70 u32 msg_enable;
71} debug = { -1 };
72
73module_param_named(debug, debug.msg_enable, int, 0);
74MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 0xffff=all)");
75
70static struct ucc_geth_info ugeth_primary_info = { 76static struct ucc_geth_info ugeth_primary_info = {
71 .uf_info = { 77 .uf_info = {
72 .bd_mem_part = MEM_PART_SYSTEM, 78 .bd_mem_part = MEM_PART_SYSTEM,
@@ -104,6 +110,7 @@ static struct ucc_geth_info ugeth_primary_info = {
104 .maxRetransmission = 0xf, 110 .maxRetransmission = 0xf,
105 .collisionWindow = 0x37, 111 .collisionWindow = 0x37,
106 .receiveFlowControl = 1, 112 .receiveFlowControl = 1,
113 .transmitFlowControl = 1,
107 .maxGroupAddrInHash = 4, 114 .maxGroupAddrInHash = 4,
108 .maxIndAddrInHash = 4, 115 .maxIndAddrInHash = 4,
109 .prel = 7, 116 .prel = 7,
@@ -139,7 +146,9 @@ static struct ucc_geth_info ugeth_primary_info = {
139 .numStationAddresses = UCC_GETH_NUM_OF_STATION_ADDRESSES_1, 146 .numStationAddresses = UCC_GETH_NUM_OF_STATION_ADDRESSES_1,
140 .largestexternallookupkeysize = 147 .largestexternallookupkeysize =
141 QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_NONE, 148 QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_NONE,
142 .statisticsMode = UCC_GETH_STATISTICS_GATHERING_MODE_NONE, 149 .statisticsMode = UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE |
150 UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX |
151 UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX,
143 .vlanOperationTagged = UCC_GETH_VLAN_OPERATION_TAGGED_NOP, 152 .vlanOperationTagged = UCC_GETH_VLAN_OPERATION_TAGGED_NOP,
144 .vlanOperationNonTagged = UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP, 153 .vlanOperationNonTagged = UCC_GETH_VLAN_OPERATION_NON_TAGGED_NOP,
145 .rxQoSMode = UCC_GETH_QOS_MODE_DEFAULT, 154 .rxQoSMode = UCC_GETH_QOS_MODE_DEFAULT,
@@ -281,7 +290,8 @@ static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
281 290
282 for (i = 0; i < num_entries; i++) { 291 for (i = 0; i < num_entries; i++) {
283 if ((snum = qe_get_snum()) < 0) { 292 if ((snum = qe_get_snum()) < 0) {
284 ugeth_err("fill_init_enet_entries: Can not get SNUM."); 293 if (netif_msg_ifup(ugeth))
294 ugeth_err("fill_init_enet_entries: Can not get SNUM.");
285 return snum; 295 return snum;
286 } 296 }
287 if ((i == 0) && skip_page_for_first_entry) 297 if ((i == 0) && skip_page_for_first_entry)
@@ -291,8 +301,8 @@ static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
291 init_enet_offset = 301 init_enet_offset =
292 qe_muram_alloc(thread_size, thread_alignment); 302 qe_muram_alloc(thread_size, thread_alignment);
293 if (IS_ERR_VALUE(init_enet_offset)) { 303 if (IS_ERR_VALUE(init_enet_offset)) {
294 ugeth_err 304 if (netif_msg_ifup(ugeth))
295 ("fill_init_enet_entries: Can not allocate DPRAM memory."); 305 ugeth_err("fill_init_enet_entries: Can not allocate DPRAM memory.");
296 qe_put_snum((u8) snum); 306 qe_put_snum((u8) snum);
297 return -ENOMEM; 307 return -ENOMEM;
298 } 308 }
@@ -1200,7 +1210,7 @@ static int init_inter_frame_gap_params(u8 non_btb_cs_ipg,
1200 return 0; 1210 return 0;
1201} 1211}
1202 1212
1203static int init_flow_control_params(u32 automatic_flow_control_mode, 1213int init_flow_control_params(u32 automatic_flow_control_mode,
1204 int rx_flow_control_enable, 1214 int rx_flow_control_enable,
1205 int tx_flow_control_enable, 1215 int tx_flow_control_enable,
1206 u16 pause_period, 1216 u16 pause_period,
@@ -1486,9 +1496,9 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1486 1496
1487 ret_val = init_preamble_length(ug_info->prel, &ug_regs->maccfg2); 1497 ret_val = init_preamble_length(ug_info->prel, &ug_regs->maccfg2);
1488 if (ret_val != 0) { 1498 if (ret_val != 0) {
1489 ugeth_err 1499 if (netif_msg_probe(ugeth))
1490 ("%s: Preamble length must be between 3 and 7 inclusive.", 1500 ugeth_err("%s: Preamble length must be between 3 and 7 inclusive.",
1491 __FUNCTION__); 1501 __FUNCTION__);
1492 return ret_val; 1502 return ret_val;
1493 } 1503 }
1494 1504
@@ -1726,7 +1736,8 @@ static int ugeth_enable(struct ucc_geth_private *ugeth, enum comm_dir mode)
1726 1736
1727 /* check if the UCC number is in range. */ 1737 /* check if the UCC number is in range. */
1728 if (ugeth->ug_info->uf_info.ucc_num >= UCC_MAX_NUM) { 1738 if (ugeth->ug_info->uf_info.ucc_num >= UCC_MAX_NUM) {
1729 ugeth_err("%s: ucc_num out of range.", __FUNCTION__); 1739 if (netif_msg_probe(ugeth))
1740 ugeth_err("%s: ucc_num out of range.", __FUNCTION__);
1730 return -EINVAL; 1741 return -EINVAL;
1731 } 1742 }
1732 1743
@@ -1754,7 +1765,8 @@ static int ugeth_disable(struct ucc_geth_private * ugeth, enum comm_dir mode)
1754 1765
1755 /* check if the UCC number is in range. */ 1766 /* check if the UCC number is in range. */
1756 if (ugeth->ug_info->uf_info.ucc_num >= UCC_MAX_NUM) { 1767 if (ugeth->ug_info->uf_info.ucc_num >= UCC_MAX_NUM) {
1757 ugeth_err("%s: ucc_num out of range.", __FUNCTION__); 1768 if (netif_msg_probe(ugeth))
1769 ugeth_err("%s: ucc_num out of range.", __FUNCTION__);
1758 return -EINVAL; 1770 return -EINVAL;
1759 } 1771 }
1760 1772
@@ -2306,7 +2318,9 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
2306 2318
2307 if (!((uf_info->bd_mem_part == MEM_PART_SYSTEM) || 2319 if (!((uf_info->bd_mem_part == MEM_PART_SYSTEM) ||
2308 (uf_info->bd_mem_part == MEM_PART_MURAM))) { 2320 (uf_info->bd_mem_part == MEM_PART_MURAM))) {
2309 ugeth_err("%s: Bad memory partition value.", __FUNCTION__); 2321 if (netif_msg_probe(ugeth))
2322 ugeth_err("%s: Bad memory partition value.",
2323 __FUNCTION__);
2310 return -EINVAL; 2324 return -EINVAL;
2311 } 2325 }
2312 2326
@@ -2315,9 +2329,10 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
2315 if ((ug_info->bdRingLenRx[i] < UCC_GETH_RX_BD_RING_SIZE_MIN) || 2329 if ((ug_info->bdRingLenRx[i] < UCC_GETH_RX_BD_RING_SIZE_MIN) ||
2316 (ug_info->bdRingLenRx[i] % 2330 (ug_info->bdRingLenRx[i] %
2317 UCC_GETH_RX_BD_RING_SIZE_ALIGNMENT)) { 2331 UCC_GETH_RX_BD_RING_SIZE_ALIGNMENT)) {
2318 ugeth_err 2332 if (netif_msg_probe(ugeth))
2319 ("%s: Rx BD ring length must be multiple of 4," 2333 ugeth_err
2320 " no smaller than 8.", __FUNCTION__); 2334 ("%s: Rx BD ring length must be multiple of 4, no smaller than 8.",
2335 __FUNCTION__);
2321 return -EINVAL; 2336 return -EINVAL;
2322 } 2337 }
2323 } 2338 }
@@ -2325,9 +2340,10 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
2325 /* Tx BD lengths */ 2340 /* Tx BD lengths */
2326 for (i = 0; i < ug_info->numQueuesTx; i++) { 2341 for (i = 0; i < ug_info->numQueuesTx; i++) {
2327 if (ug_info->bdRingLenTx[i] < UCC_GETH_TX_BD_RING_SIZE_MIN) { 2342 if (ug_info->bdRingLenTx[i] < UCC_GETH_TX_BD_RING_SIZE_MIN) {
2328 ugeth_err 2343 if (netif_msg_probe(ugeth))
2329 ("%s: Tx BD ring length must be no smaller than 2.", 2344 ugeth_err
2330 __FUNCTION__); 2345 ("%s: Tx BD ring length must be no smaller than 2.",
2346 __FUNCTION__);
2331 return -EINVAL; 2347 return -EINVAL;
2332 } 2348 }
2333 } 2349 }
@@ -2335,31 +2351,35 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
2335 /* mrblr */ 2351 /* mrblr */
2336 if ((uf_info->max_rx_buf_length == 0) || 2352 if ((uf_info->max_rx_buf_length == 0) ||
2337 (uf_info->max_rx_buf_length % UCC_GETH_MRBLR_ALIGNMENT)) { 2353 (uf_info->max_rx_buf_length % UCC_GETH_MRBLR_ALIGNMENT)) {
2338 ugeth_err 2354 if (netif_msg_probe(ugeth))
2339 ("%s: max_rx_buf_length must be non-zero multiple of 128.", 2355 ugeth_err
2340 __FUNCTION__); 2356 ("%s: max_rx_buf_length must be non-zero multiple of 128.",
2357 __FUNCTION__);
2341 return -EINVAL; 2358 return -EINVAL;
2342 } 2359 }
2343 2360
2344 /* num Tx queues */ 2361 /* num Tx queues */
2345 if (ug_info->numQueuesTx > NUM_TX_QUEUES) { 2362 if (ug_info->numQueuesTx > NUM_TX_QUEUES) {
2346 ugeth_err("%s: number of tx queues too large.", __FUNCTION__); 2363 if (netif_msg_probe(ugeth))
2364 ugeth_err("%s: number of tx queues too large.", __FUNCTION__);
2347 return -EINVAL; 2365 return -EINVAL;
2348 } 2366 }
2349 2367
2350 /* num Rx queues */ 2368 /* num Rx queues */
2351 if (ug_info->numQueuesRx > NUM_RX_QUEUES) { 2369 if (ug_info->numQueuesRx > NUM_RX_QUEUES) {
2352 ugeth_err("%s: number of rx queues too large.", __FUNCTION__); 2370 if (netif_msg_probe(ugeth))
2371 ugeth_err("%s: number of rx queues too large.", __FUNCTION__);
2353 return -EINVAL; 2372 return -EINVAL;
2354 } 2373 }
2355 2374
2356 /* l2qt */ 2375 /* l2qt */
2357 for (i = 0; i < UCC_GETH_VLAN_PRIORITY_MAX; i++) { 2376 for (i = 0; i < UCC_GETH_VLAN_PRIORITY_MAX; i++) {
2358 if (ug_info->l2qt[i] >= ug_info->numQueuesRx) { 2377 if (ug_info->l2qt[i] >= ug_info->numQueuesRx) {
2359 ugeth_err 2378 if (netif_msg_probe(ugeth))
2360 ("%s: VLAN priority table entry must not be" 2379 ugeth_err
2361 " larger than number of Rx queues.", 2380 ("%s: VLAN priority table entry must not be"
2362 __FUNCTION__); 2381 " larger than number of Rx queues.",
2382 __FUNCTION__);
2363 return -EINVAL; 2383 return -EINVAL;
2364 } 2384 }
2365 } 2385 }
@@ -2367,26 +2387,29 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
2367 /* l3qt */ 2387 /* l3qt */
2368 for (i = 0; i < UCC_GETH_IP_PRIORITY_MAX; i++) { 2388 for (i = 0; i < UCC_GETH_IP_PRIORITY_MAX; i++) {
2369 if (ug_info->l3qt[i] >= ug_info->numQueuesRx) { 2389 if (ug_info->l3qt[i] >= ug_info->numQueuesRx) {
2370 ugeth_err 2390 if (netif_msg_probe(ugeth))
2371 ("%s: IP priority table entry must not be" 2391 ugeth_err
2372 " larger than number of Rx queues.", 2392 ("%s: IP priority table entry must not be"
2373 __FUNCTION__); 2393 " larger than number of Rx queues.",
2394 __FUNCTION__);
2374 return -EINVAL; 2395 return -EINVAL;
2375 } 2396 }
2376 } 2397 }
2377 2398
2378 if (ug_info->cam && !ug_info->ecamptr) { 2399 if (ug_info->cam && !ug_info->ecamptr) {
2379 ugeth_err("%s: If cam mode is chosen, must supply cam ptr.", 2400 if (netif_msg_probe(ugeth))
2380 __FUNCTION__); 2401 ugeth_err("%s: If cam mode is chosen, must supply cam ptr.",
2402 __FUNCTION__);
2381 return -EINVAL; 2403 return -EINVAL;
2382 } 2404 }
2383 2405
2384 if ((ug_info->numStationAddresses != 2406 if ((ug_info->numStationAddresses !=
2385 UCC_GETH_NUM_OF_STATION_ADDRESSES_1) 2407 UCC_GETH_NUM_OF_STATION_ADDRESSES_1)
2386 && ug_info->rxExtendedFiltering) { 2408 && ug_info->rxExtendedFiltering) {
2387 ugeth_err("%s: Number of station addresses greater than 1 " 2409 if (netif_msg_probe(ugeth))
2388 "not allowed in extended parsing mode.", 2410 ugeth_err("%s: Number of station addresses greater than 1 "
2389 __FUNCTION__); 2411 "not allowed in extended parsing mode.",
2412 __FUNCTION__);
2390 return -EINVAL; 2413 return -EINVAL;
2391 } 2414 }
2392 2415
@@ -2399,7 +2422,8 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
2399 uf_info->uccm_mask |= (UCCE_TXBF_SINGLE_MASK << i); 2422 uf_info->uccm_mask |= (UCCE_TXBF_SINGLE_MASK << i);
2400 /* Initialize the general fast UCC block. */ 2423 /* Initialize the general fast UCC block. */
2401 if (ucc_fast_init(uf_info, &ugeth->uccf)) { 2424 if (ucc_fast_init(uf_info, &ugeth->uccf)) {
2402 ugeth_err("%s: Failed to init uccf.", __FUNCTION__); 2425 if (netif_msg_probe(ugeth))
2426 ugeth_err("%s: Failed to init uccf.", __FUNCTION__);
2403 ucc_geth_memclean(ugeth); 2427 ucc_geth_memclean(ugeth);
2404 return -ENOMEM; 2428 return -ENOMEM;
2405 } 2429 }
@@ -2452,7 +2476,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2452 numThreadsRxNumerical = 8; 2476 numThreadsRxNumerical = 8;
2453 break; 2477 break;
2454 default: 2478 default:
2455 ugeth_err("%s: Bad number of Rx threads value.", __FUNCTION__); 2479 if (netif_msg_ifup(ugeth))
2480 ugeth_err("%s: Bad number of Rx threads value.",
2481 __FUNCTION__);
2456 ucc_geth_memclean(ugeth); 2482 ucc_geth_memclean(ugeth);
2457 return -EINVAL; 2483 return -EINVAL;
2458 break; 2484 break;
@@ -2475,7 +2501,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2475 numThreadsTxNumerical = 8; 2501 numThreadsTxNumerical = 8;
2476 break; 2502 break;
2477 default: 2503 default:
2478 ugeth_err("%s: Bad number of Tx threads value.", __FUNCTION__); 2504 if (netif_msg_ifup(ugeth))
2505 ugeth_err("%s: Bad number of Tx threads value.",
2506 __FUNCTION__);
2479 ucc_geth_memclean(ugeth); 2507 ucc_geth_memclean(ugeth);
2480 return -EINVAL; 2508 return -EINVAL;
2481 break; 2509 break;
@@ -2507,7 +2535,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2507 /* For more details see the hardware spec. */ 2535 /* For more details see the hardware spec. */
2508 init_flow_control_params(ug_info->aufc, 2536 init_flow_control_params(ug_info->aufc,
2509 ug_info->receiveFlowControl, 2537 ug_info->receiveFlowControl,
2510 1, 2538 ug_info->transmitFlowControl,
2511 ug_info->pausePeriod, 2539 ug_info->pausePeriod,
2512 ug_info->extensionField, 2540 ug_info->extensionField,
2513 &uf_regs->upsmr, 2541 &uf_regs->upsmr,
@@ -2527,8 +2555,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2527 ug_info->backToBackInterFrameGap, 2555 ug_info->backToBackInterFrameGap,
2528 &ug_regs->ipgifg); 2556 &ug_regs->ipgifg);
2529 if (ret_val != 0) { 2557 if (ret_val != 0) {
2530 ugeth_err("%s: IPGIFG initialization parameter too large.", 2558 if (netif_msg_ifup(ugeth))
2531 __FUNCTION__); 2559 ugeth_err("%s: IPGIFG initialization parameter too large.",
2560 __FUNCTION__);
2532 ucc_geth_memclean(ugeth); 2561 ucc_geth_memclean(ugeth);
2533 return ret_val; 2562 return ret_val;
2534 } 2563 }
@@ -2544,7 +2573,8 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2544 ug_info->collisionWindow, 2573 ug_info->collisionWindow,
2545 &ug_regs->hafdup); 2574 &ug_regs->hafdup);
2546 if (ret_val != 0) { 2575 if (ret_val != 0) {
2547 ugeth_err("%s: Half Duplex initialization parameter too large.", 2576 if (netif_msg_ifup(ugeth))
2577 ugeth_err("%s: Half Duplex initialization parameter too large.",
2548 __FUNCTION__); 2578 __FUNCTION__);
2549 ucc_geth_memclean(ugeth); 2579 ucc_geth_memclean(ugeth);
2550 return ret_val; 2580 return ret_val;
@@ -2597,9 +2627,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2597 tx_bd_ring_offset[j]); 2627 tx_bd_ring_offset[j]);
2598 } 2628 }
2599 if (!ugeth->p_tx_bd_ring[j]) { 2629 if (!ugeth->p_tx_bd_ring[j]) {
2600 ugeth_err 2630 if (netif_msg_ifup(ugeth))
2601 ("%s: Can not allocate memory for Tx bd rings.", 2631 ugeth_err
2602 __FUNCTION__); 2632 ("%s: Can not allocate memory for Tx bd rings.",
2633 __FUNCTION__);
2603 ucc_geth_memclean(ugeth); 2634 ucc_geth_memclean(ugeth);
2604 return -ENOMEM; 2635 return -ENOMEM;
2605 } 2636 }
@@ -2632,9 +2663,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2632 rx_bd_ring_offset[j]); 2663 rx_bd_ring_offset[j]);
2633 } 2664 }
2634 if (!ugeth->p_rx_bd_ring[j]) { 2665 if (!ugeth->p_rx_bd_ring[j]) {
2635 ugeth_err 2666 if (netif_msg_ifup(ugeth))
2636 ("%s: Can not allocate memory for Rx bd rings.", 2667 ugeth_err
2637 __FUNCTION__); 2668 ("%s: Can not allocate memory for Rx bd rings.",
2669 __FUNCTION__);
2638 ucc_geth_memclean(ugeth); 2670 ucc_geth_memclean(ugeth);
2639 return -ENOMEM; 2671 return -ENOMEM;
2640 } 2672 }
@@ -2648,8 +2680,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2648 GFP_KERNEL); 2680 GFP_KERNEL);
2649 2681
2650 if (ugeth->tx_skbuff[j] == NULL) { 2682 if (ugeth->tx_skbuff[j] == NULL) {
2651 ugeth_err("%s: Could not allocate tx_skbuff", 2683 if (netif_msg_ifup(ugeth))
2652 __FUNCTION__); 2684 ugeth_err("%s: Could not allocate tx_skbuff",
2685 __FUNCTION__);
2653 ucc_geth_memclean(ugeth); 2686 ucc_geth_memclean(ugeth);
2654 return -ENOMEM; 2687 return -ENOMEM;
2655 } 2688 }
@@ -2679,8 +2712,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2679 GFP_KERNEL); 2712 GFP_KERNEL);
2680 2713
2681 if (ugeth->rx_skbuff[j] == NULL) { 2714 if (ugeth->rx_skbuff[j] == NULL) {
2682 ugeth_err("%s: Could not allocate rx_skbuff", 2715 if (netif_msg_ifup(ugeth))
2683 __FUNCTION__); 2716 ugeth_err("%s: Could not allocate rx_skbuff",
2717 __FUNCTION__);
2684 ucc_geth_memclean(ugeth); 2718 ucc_geth_memclean(ugeth);
2685 return -ENOMEM; 2719 return -ENOMEM;
2686 } 2720 }
@@ -2711,9 +2745,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2711 qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram), 2745 qe_muram_alloc(sizeof(struct ucc_geth_tx_global_pram),
2712 UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT); 2746 UCC_GETH_TX_GLOBAL_PRAM_ALIGNMENT);
2713 if (IS_ERR_VALUE(ugeth->tx_glbl_pram_offset)) { 2747 if (IS_ERR_VALUE(ugeth->tx_glbl_pram_offset)) {
2714 ugeth_err 2748 if (netif_msg_ifup(ugeth))
2715 ("%s: Can not allocate DPRAM memory for p_tx_glbl_pram.", 2749 ugeth_err
2716 __FUNCTION__); 2750 ("%s: Can not allocate DPRAM memory for p_tx_glbl_pram.",
2751 __FUNCTION__);
2717 ucc_geth_memclean(ugeth); 2752 ucc_geth_memclean(ugeth);
2718 return -ENOMEM; 2753 return -ENOMEM;
2719 } 2754 }
@@ -2733,9 +2768,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2733 32 * (numThreadsTxNumerical == 1), 2768 32 * (numThreadsTxNumerical == 1),
2734 UCC_GETH_THREAD_DATA_ALIGNMENT); 2769 UCC_GETH_THREAD_DATA_ALIGNMENT);
2735 if (IS_ERR_VALUE(ugeth->thread_dat_tx_offset)) { 2770 if (IS_ERR_VALUE(ugeth->thread_dat_tx_offset)) {
2736 ugeth_err 2771 if (netif_msg_ifup(ugeth))
2737 ("%s: Can not allocate DPRAM memory for p_thread_data_tx.", 2772 ugeth_err
2738 __FUNCTION__); 2773 ("%s: Can not allocate DPRAM memory for p_thread_data_tx.",
2774 __FUNCTION__);
2739 ucc_geth_memclean(ugeth); 2775 ucc_geth_memclean(ugeth);
2740 return -ENOMEM; 2776 return -ENOMEM;
2741 } 2777 }
@@ -2761,9 +2797,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2761 sizeof(struct ucc_geth_send_queue_qd), 2797 sizeof(struct ucc_geth_send_queue_qd),
2762 UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT); 2798 UCC_GETH_SEND_QUEUE_QUEUE_DESCRIPTOR_ALIGNMENT);
2763 if (IS_ERR_VALUE(ugeth->send_q_mem_reg_offset)) { 2799 if (IS_ERR_VALUE(ugeth->send_q_mem_reg_offset)) {
2764 ugeth_err 2800 if (netif_msg_ifup(ugeth))
2765 ("%s: Can not allocate DPRAM memory for p_send_q_mem_reg.", 2801 ugeth_err
2766 __FUNCTION__); 2802 ("%s: Can not allocate DPRAM memory for p_send_q_mem_reg.",
2803 __FUNCTION__);
2767 ucc_geth_memclean(ugeth); 2804 ucc_geth_memclean(ugeth);
2768 return -ENOMEM; 2805 return -ENOMEM;
2769 } 2806 }
@@ -2804,9 +2841,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2804 qe_muram_alloc(sizeof(struct ucc_geth_scheduler), 2841 qe_muram_alloc(sizeof(struct ucc_geth_scheduler),
2805 UCC_GETH_SCHEDULER_ALIGNMENT); 2842 UCC_GETH_SCHEDULER_ALIGNMENT);
2806 if (IS_ERR_VALUE(ugeth->scheduler_offset)) { 2843 if (IS_ERR_VALUE(ugeth->scheduler_offset)) {
2807 ugeth_err 2844 if (netif_msg_ifup(ugeth))
2808 ("%s: Can not allocate DPRAM memory for p_scheduler.", 2845 ugeth_err
2809 __FUNCTION__); 2846 ("%s: Can not allocate DPRAM memory for p_scheduler.",
2847 __FUNCTION__);
2810 ucc_geth_memclean(ugeth); 2848 ucc_geth_memclean(ugeth);
2811 return -ENOMEM; 2849 return -ENOMEM;
2812 } 2850 }
@@ -2852,9 +2890,11 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2852 (struct ucc_geth_tx_firmware_statistics_pram), 2890 (struct ucc_geth_tx_firmware_statistics_pram),
2853 UCC_GETH_TX_STATISTICS_ALIGNMENT); 2891 UCC_GETH_TX_STATISTICS_ALIGNMENT);
2854 if (IS_ERR_VALUE(ugeth->tx_fw_statistics_pram_offset)) { 2892 if (IS_ERR_VALUE(ugeth->tx_fw_statistics_pram_offset)) {
2855 ugeth_err 2893 if (netif_msg_ifup(ugeth))
2856 ("%s: Can not allocate DPRAM memory for" 2894 ugeth_err
2857 " p_tx_fw_statistics_pram.", __FUNCTION__); 2895 ("%s: Can not allocate DPRAM memory for"
2896 " p_tx_fw_statistics_pram.",
2897 __FUNCTION__);
2858 ucc_geth_memclean(ugeth); 2898 ucc_geth_memclean(ugeth);
2859 return -ENOMEM; 2899 return -ENOMEM;
2860 } 2900 }
@@ -2891,9 +2931,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2891 qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram), 2931 qe_muram_alloc(sizeof(struct ucc_geth_rx_global_pram),
2892 UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT); 2932 UCC_GETH_RX_GLOBAL_PRAM_ALIGNMENT);
2893 if (IS_ERR_VALUE(ugeth->rx_glbl_pram_offset)) { 2933 if (IS_ERR_VALUE(ugeth->rx_glbl_pram_offset)) {
2894 ugeth_err 2934 if (netif_msg_ifup(ugeth))
2895 ("%s: Can not allocate DPRAM memory for p_rx_glbl_pram.", 2935 ugeth_err
2896 __FUNCTION__); 2936 ("%s: Can not allocate DPRAM memory for p_rx_glbl_pram.",
2937 __FUNCTION__);
2897 ucc_geth_memclean(ugeth); 2938 ucc_geth_memclean(ugeth);
2898 return -ENOMEM; 2939 return -ENOMEM;
2899 } 2940 }
@@ -2912,9 +2953,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2912 sizeof(struct ucc_geth_thread_data_rx), 2953 sizeof(struct ucc_geth_thread_data_rx),
2913 UCC_GETH_THREAD_DATA_ALIGNMENT); 2954 UCC_GETH_THREAD_DATA_ALIGNMENT);
2914 if (IS_ERR_VALUE(ugeth->thread_dat_rx_offset)) { 2955 if (IS_ERR_VALUE(ugeth->thread_dat_rx_offset)) {
2915 ugeth_err 2956 if (netif_msg_ifup(ugeth))
2916 ("%s: Can not allocate DPRAM memory for p_thread_data_rx.", 2957 ugeth_err
2917 __FUNCTION__); 2958 ("%s: Can not allocate DPRAM memory for p_thread_data_rx.",
2959 __FUNCTION__);
2918 ucc_geth_memclean(ugeth); 2960 ucc_geth_memclean(ugeth);
2919 return -ENOMEM; 2961 return -ENOMEM;
2920 } 2962 }
@@ -2935,9 +2977,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2935 (struct ucc_geth_rx_firmware_statistics_pram), 2977 (struct ucc_geth_rx_firmware_statistics_pram),
2936 UCC_GETH_RX_STATISTICS_ALIGNMENT); 2978 UCC_GETH_RX_STATISTICS_ALIGNMENT);
2937 if (IS_ERR_VALUE(ugeth->rx_fw_statistics_pram_offset)) { 2979 if (IS_ERR_VALUE(ugeth->rx_fw_statistics_pram_offset)) {
2938 ugeth_err 2980 if (netif_msg_ifup(ugeth))
2939 ("%s: Can not allocate DPRAM memory for" 2981 ugeth_err
2940 " p_rx_fw_statistics_pram.", __FUNCTION__); 2982 ("%s: Can not allocate DPRAM memory for"
2983 " p_rx_fw_statistics_pram.", __FUNCTION__);
2941 ucc_geth_memclean(ugeth); 2984 ucc_geth_memclean(ugeth);
2942 return -ENOMEM; 2985 return -ENOMEM;
2943 } 2986 }
@@ -2957,9 +3000,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2957 sizeof(struct ucc_geth_rx_interrupt_coalescing_entry) 3000 sizeof(struct ucc_geth_rx_interrupt_coalescing_entry)
2958 + 4, UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT); 3001 + 4, UCC_GETH_RX_INTERRUPT_COALESCING_ALIGNMENT);
2959 if (IS_ERR_VALUE(ugeth->rx_irq_coalescing_tbl_offset)) { 3002 if (IS_ERR_VALUE(ugeth->rx_irq_coalescing_tbl_offset)) {
2960 ugeth_err 3003 if (netif_msg_ifup(ugeth))
2961 ("%s: Can not allocate DPRAM memory for" 3004 ugeth_err
2962 " p_rx_irq_coalescing_tbl.", __FUNCTION__); 3005 ("%s: Can not allocate DPRAM memory for"
3006 " p_rx_irq_coalescing_tbl.", __FUNCTION__);
2963 ucc_geth_memclean(ugeth); 3007 ucc_geth_memclean(ugeth);
2964 return -ENOMEM; 3008 return -ENOMEM;
2965 } 3009 }
@@ -3025,9 +3069,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3025 sizeof(struct ucc_geth_rx_prefetched_bds)), 3069 sizeof(struct ucc_geth_rx_prefetched_bds)),
3026 UCC_GETH_RX_BD_QUEUES_ALIGNMENT); 3070 UCC_GETH_RX_BD_QUEUES_ALIGNMENT);
3027 if (IS_ERR_VALUE(ugeth->rx_bd_qs_tbl_offset)) { 3071 if (IS_ERR_VALUE(ugeth->rx_bd_qs_tbl_offset)) {
3028 ugeth_err 3072 if (netif_msg_ifup(ugeth))
3029 ("%s: Can not allocate DPRAM memory for p_rx_bd_qs_tbl.", 3073 ugeth_err
3030 __FUNCTION__); 3074 ("%s: Can not allocate DPRAM memory for p_rx_bd_qs_tbl.",
3075 __FUNCTION__);
3031 ucc_geth_memclean(ugeth); 3076 ucc_geth_memclean(ugeth);
3032 return -ENOMEM; 3077 return -ENOMEM;
3033 } 3078 }
@@ -3102,8 +3147,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3102 /* initialize extended filtering */ 3147 /* initialize extended filtering */
3103 if (ug_info->rxExtendedFiltering) { 3148 if (ug_info->rxExtendedFiltering) {
3104 if (!ug_info->extendedFilteringChainPointer) { 3149 if (!ug_info->extendedFilteringChainPointer) {
3105 ugeth_err("%s: Null Extended Filtering Chain Pointer.", 3150 if (netif_msg_ifup(ugeth))
3106 __FUNCTION__); 3151 ugeth_err("%s: Null Extended Filtering Chain Pointer.",
3152 __FUNCTION__);
3107 ucc_geth_memclean(ugeth); 3153 ucc_geth_memclean(ugeth);
3108 return -EINVAL; 3154 return -EINVAL;
3109 } 3155 }
@@ -3114,9 +3160,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3114 qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram), 3160 qe_muram_alloc(sizeof(struct ucc_geth_exf_global_pram),
3115 UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT); 3161 UCC_GETH_RX_EXTENDED_FILTERING_GLOBAL_PARAMETERS_ALIGNMENT);
3116 if (IS_ERR_VALUE(ugeth->exf_glbl_param_offset)) { 3162 if (IS_ERR_VALUE(ugeth->exf_glbl_param_offset)) {
3117 ugeth_err 3163 if (netif_msg_ifup(ugeth))
3118 ("%s: Can not allocate DPRAM memory for" 3164 ugeth_err
3119 " p_exf_glbl_param.", __FUNCTION__); 3165 ("%s: Can not allocate DPRAM memory for"
3166 " p_exf_glbl_param.", __FUNCTION__);
3120 ucc_geth_memclean(ugeth); 3167 ucc_geth_memclean(ugeth);
3121 return -ENOMEM; 3168 return -ENOMEM;
3122 } 3169 }
@@ -3161,9 +3208,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3161 */ 3208 */
3162 if (!(ugeth->p_init_enet_param_shadow = 3209 if (!(ugeth->p_init_enet_param_shadow =
3163 kmalloc(sizeof(struct ucc_geth_init_pram), GFP_KERNEL))) { 3210 kmalloc(sizeof(struct ucc_geth_init_pram), GFP_KERNEL))) {
3164 ugeth_err 3211 if (netif_msg_ifup(ugeth))
3165 ("%s: Can not allocate memory for" 3212 ugeth_err
3166 " p_UccInitEnetParamShadows.", __FUNCTION__); 3213 ("%s: Can not allocate memory for"
3214 " p_UccInitEnetParamShadows.", __FUNCTION__);
3167 ucc_geth_memclean(ugeth); 3215 ucc_geth_memclean(ugeth);
3168 return -ENOMEM; 3216 return -ENOMEM;
3169 } 3217 }
@@ -3196,8 +3244,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3196 QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_8_BYTES) 3244 QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_8_BYTES)
3197 && (ug_info->largestexternallookupkeysize != 3245 && (ug_info->largestexternallookupkeysize !=
3198 QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_16_BYTES)) { 3246 QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_16_BYTES)) {
3199 ugeth_err("%s: Invalid largest External Lookup Key Size.", 3247 if (netif_msg_ifup(ugeth))
3200 __FUNCTION__); 3248 ugeth_err("%s: Invalid largest External Lookup Key Size.",
3249 __FUNCTION__);
3201 ucc_geth_memclean(ugeth); 3250 ucc_geth_memclean(ugeth);
3202 return -EINVAL; 3251 return -EINVAL;
3203 } 3252 }
@@ -3222,8 +3271,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3222 /* Rx needs one extra for terminator */ 3271 /* Rx needs one extra for terminator */
3223 , size, UCC_GETH_THREAD_RX_PRAM_ALIGNMENT, 3272 , size, UCC_GETH_THREAD_RX_PRAM_ALIGNMENT,
3224 ug_info->riscRx, 1)) != 0) { 3273 ug_info->riscRx, 1)) != 0) {
3225 ugeth_err("%s: Can not fill p_init_enet_param_shadow.", 3274 if (netif_msg_ifup(ugeth))
3226 __FUNCTION__); 3275 ugeth_err("%s: Can not fill p_init_enet_param_shadow.",
3276 __FUNCTION__);
3227 ucc_geth_memclean(ugeth); 3277 ucc_geth_memclean(ugeth);
3228 return ret_val; 3278 return ret_val;
3229 } 3279 }
@@ -3237,8 +3287,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3237 sizeof(struct ucc_geth_thread_tx_pram), 3287 sizeof(struct ucc_geth_thread_tx_pram),
3238 UCC_GETH_THREAD_TX_PRAM_ALIGNMENT, 3288 UCC_GETH_THREAD_TX_PRAM_ALIGNMENT,
3239 ug_info->riscTx, 0)) != 0) { 3289 ug_info->riscTx, 0)) != 0) {
3240 ugeth_err("%s: Can not fill p_init_enet_param_shadow.", 3290 if (netif_msg_ifup(ugeth))
3241 __FUNCTION__); 3291 ugeth_err("%s: Can not fill p_init_enet_param_shadow.",
3292 __FUNCTION__);
3242 ucc_geth_memclean(ugeth); 3293 ucc_geth_memclean(ugeth);
3243 return ret_val; 3294 return ret_val;
3244 } 3295 }
@@ -3246,8 +3297,9 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3246 /* Load Rx bds with buffers */ 3297 /* Load Rx bds with buffers */
3247 for (i = 0; i < ug_info->numQueuesRx; i++) { 3298 for (i = 0; i < ug_info->numQueuesRx; i++) {
3248 if ((ret_val = rx_bd_buffer_set(ugeth, (u8) i)) != 0) { 3299 if ((ret_val = rx_bd_buffer_set(ugeth, (u8) i)) != 0) {
3249 ugeth_err("%s: Can not fill Rx bds with buffers.", 3300 if (netif_msg_ifup(ugeth))
3250 __FUNCTION__); 3301 ugeth_err("%s: Can not fill Rx bds with buffers.",
3302 __FUNCTION__);
3251 ucc_geth_memclean(ugeth); 3303 ucc_geth_memclean(ugeth);
3252 return ret_val; 3304 return ret_val;
3253 } 3305 }
@@ -3256,9 +3308,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3256 /* Allocate InitEnet command parameter structure */ 3308 /* Allocate InitEnet command parameter structure */
3257 init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4); 3309 init_enet_pram_offset = qe_muram_alloc(sizeof(struct ucc_geth_init_pram), 4);
3258 if (IS_ERR_VALUE(init_enet_pram_offset)) { 3310 if (IS_ERR_VALUE(init_enet_pram_offset)) {
3259 ugeth_err 3311 if (netif_msg_ifup(ugeth))
3260 ("%s: Can not allocate DPRAM memory for p_init_enet_pram.", 3312 ugeth_err
3261 __FUNCTION__); 3313 ("%s: Can not allocate DPRAM memory for p_init_enet_pram.",
3314 __FUNCTION__);
3262 ucc_geth_memclean(ugeth); 3315 ucc_geth_memclean(ugeth);
3263 return -ENOMEM; 3316 return -ENOMEM;
3264 } 3317 }
@@ -3428,8 +3481,9 @@ static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit
3428 if (!skb || 3481 if (!skb ||
3429 (!(bd_status & (R_F | R_L))) || 3482 (!(bd_status & (R_F | R_L))) ||
3430 (bd_status & R_ERRORS_FATAL)) { 3483 (bd_status & R_ERRORS_FATAL)) {
3431 ugeth_vdbg("%s, %d: ERROR!!! skb - 0x%08x", 3484 if (netif_msg_rx_err(ugeth))
3432 __FUNCTION__, __LINE__, (u32) skb); 3485 ugeth_err("%s, %d: ERROR!!! skb - 0x%08x",
3486 __FUNCTION__, __LINE__, (u32) skb);
3433 if (skb) 3487 if (skb)
3434 dev_kfree_skb_any(skb); 3488 dev_kfree_skb_any(skb);
3435 3489
@@ -3458,7 +3512,8 @@ static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit
3458 3512
3459 skb = get_new_skb(ugeth, bd); 3513 skb = get_new_skb(ugeth, bd);
3460 if (!skb) { 3514 if (!skb) {
3461 ugeth_warn("%s: No Rx Data Buffer", __FUNCTION__); 3515 if (netif_msg_rx_err(ugeth))
3516 ugeth_warn("%s: No Rx Data Buffer", __FUNCTION__);
3462 ugeth->stats.rx_dropped++; 3517 ugeth->stats.rx_dropped++;
3463 break; 3518 break;
3464 } 3519 }
@@ -3649,28 +3704,32 @@ static int ucc_geth_open(struct net_device *dev)
3649 3704
3650 /* Test station address */ 3705 /* Test station address */
3651 if (dev->dev_addr[0] & ENET_GROUP_ADDR) { 3706 if (dev->dev_addr[0] & ENET_GROUP_ADDR) {
3652 ugeth_err("%s: Multicast address used for station address" 3707 if (netif_msg_ifup(ugeth))
3653 " - is this what you wanted?", __FUNCTION__); 3708 ugeth_err("%s: Multicast address used for station address"
3709 " - is this what you wanted?", __FUNCTION__);
3654 return -EINVAL; 3710 return -EINVAL;
3655 } 3711 }
3656 3712
3657 err = ucc_struct_init(ugeth); 3713 err = ucc_struct_init(ugeth);
3658 if (err) { 3714 if (err) {
3659 ugeth_err("%s: Cannot configure internal struct, aborting.", dev->name); 3715 if (netif_msg_ifup(ugeth))
3716 ugeth_err("%s: Cannot configure internal struct, aborting.", dev->name);
3660 return err; 3717 return err;
3661 } 3718 }
3662 3719
3663 err = ucc_geth_startup(ugeth); 3720 err = ucc_geth_startup(ugeth);
3664 if (err) { 3721 if (err) {
3665 ugeth_err("%s: Cannot configure net device, aborting.", 3722 if (netif_msg_ifup(ugeth))
3666 dev->name); 3723 ugeth_err("%s: Cannot configure net device, aborting.",
3724 dev->name);
3667 return err; 3725 return err;
3668 } 3726 }
3669 3727
3670 err = adjust_enet_interface(ugeth); 3728 err = adjust_enet_interface(ugeth);
3671 if (err) { 3729 if (err) {
3672 ugeth_err("%s: Cannot configure net device, aborting.", 3730 if (netif_msg_ifup(ugeth))
3673 dev->name); 3731 ugeth_err("%s: Cannot configure net device, aborting.",
3732 dev->name);
3674 return err; 3733 return err;
3675 } 3734 }
3676 3735
@@ -3687,7 +3746,8 @@ static int ucc_geth_open(struct net_device *dev)
3687 3746
3688 err = init_phy(dev); 3747 err = init_phy(dev);
3689 if (err) { 3748 if (err) {
3690 ugeth_err("%s: Cannot initialize PHY, aborting.", dev->name); 3749 if (netif_msg_ifup(ugeth))
3750 ugeth_err("%s: Cannot initialize PHY, aborting.", dev->name);
3691 return err; 3751 return err;
3692 } 3752 }
3693 3753
@@ -3697,15 +3757,17 @@ static int ucc_geth_open(struct net_device *dev)
3697 request_irq(ugeth->ug_info->uf_info.irq, ucc_geth_irq_handler, 0, 3757 request_irq(ugeth->ug_info->uf_info.irq, ucc_geth_irq_handler, 0,
3698 "UCC Geth", dev); 3758 "UCC Geth", dev);
3699 if (err) { 3759 if (err) {
3700 ugeth_err("%s: Cannot get IRQ for net device, aborting.", 3760 if (netif_msg_ifup(ugeth))
3701 dev->name); 3761 ugeth_err("%s: Cannot get IRQ for net device, aborting.",
3762 dev->name);
3702 ucc_geth_stop(ugeth); 3763 ucc_geth_stop(ugeth);
3703 return err; 3764 return err;
3704 } 3765 }
3705 3766
3706 err = ugeth_enable(ugeth, COMM_DIR_RX_AND_TX); 3767 err = ugeth_enable(ugeth, COMM_DIR_RX_AND_TX);
3707 if (err) { 3768 if (err) {
3708 ugeth_err("%s: Cannot enable net device, aborting.", dev->name); 3769 if (netif_msg_ifup(ugeth))
3770 ugeth_err("%s: Cannot enable net device, aborting.", dev->name);
3709 ucc_geth_stop(ugeth); 3771 ucc_geth_stop(ugeth);
3710 return err; 3772 return err;
3711 } 3773 }
@@ -3732,8 +3794,6 @@ static int ucc_geth_close(struct net_device *dev)
3732 return 0; 3794 return 0;
3733} 3795}
3734 3796
3735const struct ethtool_ops ucc_geth_ethtool_ops = { };
3736
3737static phy_interface_t to_phy_interface(const char *phy_connection_type) 3797static phy_interface_t to_phy_interface(const char *phy_connection_type)
3738{ 3798{
3739 if (strcasecmp(phy_connection_type, "mii") == 0) 3799 if (strcasecmp(phy_connection_type, "mii") == 0)
@@ -3790,6 +3850,13 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
3790 return -ENODEV; 3850 return -ENODEV;
3791 3851
3792 ug_info = &ugeth_info[ucc_num]; 3852 ug_info = &ugeth_info[ucc_num];
3853 if (ug_info == NULL) {
3854 if (netif_msg_probe(&debug))
3855 ugeth_err("%s: [%d] Missing additional data!",
3856 __FUNCTION__, ucc_num);
3857 return -ENODEV;
3858 }
3859
3793 ug_info->uf_info.ucc_num = ucc_num; 3860 ug_info->uf_info.ucc_num = ucc_num;
3794 3861
3795 prop = of_get_property(np, "rx-clock", NULL); 3862 prop = of_get_property(np, "rx-clock", NULL);
@@ -3868,15 +3935,10 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
3868 3935
3869 ug_info->mdio_bus = res.start; 3936 ug_info->mdio_bus = res.start;
3870 3937
3871 printk(KERN_INFO "ucc_geth: UCC%1d at 0x%8x (irq = %d) \n", 3938 if (netif_msg_probe(&debug))
3872 ug_info->uf_info.ucc_num + 1, ug_info->uf_info.regs, 3939 printk(KERN_INFO "ucc_geth: UCC%1d at 0x%8x (irq = %d) \n",
3873 ug_info->uf_info.irq); 3940 ug_info->uf_info.ucc_num + 1, ug_info->uf_info.regs,
3874 3941 ug_info->uf_info.irq);
3875 if (ug_info == NULL) {
3876 ugeth_err("%s: [%d] Missing additional data!", __FUNCTION__,
3877 ucc_num);
3878 return -ENODEV;
3879 }
3880 3942
3881 /* Create an ethernet device instance */ 3943 /* Create an ethernet device instance */
3882 dev = alloc_etherdev(sizeof(*ugeth)); 3944 dev = alloc_etherdev(sizeof(*ugeth));
@@ -3896,6 +3958,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
3896 SET_NETDEV_DEV(dev, device); 3958 SET_NETDEV_DEV(dev, device);
3897 3959
3898 /* Fill in the dev structure */ 3960 /* Fill in the dev structure */
3961 uec_set_ethtool_ops(dev);
3899 dev->open = ucc_geth_open; 3962 dev->open = ucc_geth_open;
3900 dev->hard_start_xmit = ucc_geth_start_xmit; 3963 dev->hard_start_xmit = ucc_geth_start_xmit;
3901 dev->tx_timeout = ucc_geth_timeout; 3964 dev->tx_timeout = ucc_geth_timeout;
@@ -3909,16 +3972,16 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
3909// dev->change_mtu = ucc_geth_change_mtu; 3972// dev->change_mtu = ucc_geth_change_mtu;
3910 dev->mtu = 1500; 3973 dev->mtu = 1500;
3911 dev->set_multicast_list = ucc_geth_set_multi; 3974 dev->set_multicast_list = ucc_geth_set_multi;
3912 dev->ethtool_ops = &ucc_geth_ethtool_ops;
3913 3975
3914 ugeth->msg_enable = (NETIF_MSG_IFUP << 1 ) - 1; 3976 ugeth->msg_enable = netif_msg_init(debug.msg_enable, UGETH_MSG_DEFAULT);
3915 ugeth->phy_interface = phy_interface; 3977 ugeth->phy_interface = phy_interface;
3916 ugeth->max_speed = max_speed; 3978 ugeth->max_speed = max_speed;
3917 3979
3918 err = register_netdev(dev); 3980 err = register_netdev(dev);
3919 if (err) { 3981 if (err) {
3920 ugeth_err("%s: Cannot register net device, aborting.", 3982 if (netif_msg_probe(ugeth))
3921 dev->name); 3983 ugeth_err("%s: Cannot register net device, aborting.",
3984 dev->name);
3922 free_netdev(dev); 3985 free_netdev(dev);
3923 return err; 3986 return err;
3924 } 3987 }
@@ -3972,7 +4035,8 @@ static int __init ucc_geth_init(void)
3972 if (ret) 4035 if (ret)
3973 return ret; 4036 return ret;
3974 4037
3975 printk(KERN_INFO "ucc_geth: " DRV_DESC "\n"); 4038 if (netif_msg_drv(&debug))
4039 printk(KERN_INFO "ucc_geth: " DRV_DESC "\n");
3976 for (i = 0; i < 8; i++) 4040 for (i = 0; i < 8; i++)
3977 memcpy(&(ugeth_info[i]), &ugeth_primary_info, 4041 memcpy(&(ugeth_info[i]), &ugeth_primary_info,
3978 sizeof(ugeth_primary_info)); 4042 sizeof(ugeth_primary_info));
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
index a29e1c3ca4b7..bb4dac8c0c65 100644
--- a/drivers/net/ucc_geth.h
+++ b/drivers/net/ucc_geth.h
@@ -30,6 +30,10 @@
30 30
31#include "ucc_geth_mii.h" 31#include "ucc_geth_mii.h"
32 32
33#define DRV_DESC "QE UCC Gigabit Ethernet Controller"
34#define DRV_NAME "ucc_geth"
35#define DRV_VERSION "1.1"
36
33#define NUM_TX_QUEUES 8 37#define NUM_TX_QUEUES 8
34#define NUM_RX_QUEUES 8 38#define NUM_RX_QUEUES 8
35#define NUM_BDS_IN_PREFETCHED_BDS 4 39#define NUM_BDS_IN_PREFETCHED_BDS 4
@@ -896,6 +900,7 @@ struct ucc_geth_hardware_statistics {
896#define UCC_GETH_TX_VTAG_TABLE_ENTRY_MAX 8 900#define UCC_GETH_TX_VTAG_TABLE_ENTRY_MAX 8
897#define UCC_GETH_RX_BD_RING_SIZE_MIN 8 901#define UCC_GETH_RX_BD_RING_SIZE_MIN 8
898#define UCC_GETH_TX_BD_RING_SIZE_MIN 2 902#define UCC_GETH_TX_BD_RING_SIZE_MIN 2
903#define UCC_GETH_BD_RING_SIZE_MAX 0xffff
899 904
900#define UCC_GETH_SIZE_OF_BD QE_SIZEOF_BD 905#define UCC_GETH_SIZE_OF_BD QE_SIZEOF_BD
901 906
@@ -1135,6 +1140,7 @@ struct ucc_geth_info {
1135 int bro; 1140 int bro;
1136 int ecm; 1141 int ecm;
1137 int receiveFlowControl; 1142 int receiveFlowControl;
1143 int transmitFlowControl;
1138 u8 maxGroupAddrInHash; 1144 u8 maxGroupAddrInHash;
1139 u8 maxIndAddrInHash; 1145 u8 maxIndAddrInHash;
1140 u8 prel; 1146 u8 prel;
diff --git a/drivers/net/ucc_geth_ethtool.c b/drivers/net/ucc_geth_ethtool.c
new file mode 100644
index 000000000000..a8994c7b8583
--- /dev/null
+++ b/drivers/net/ucc_geth_ethtool.c
@@ -0,0 +1,388 @@
1/*
2 * Copyright (c) 2007 Freescale Semiconductor, Inc. All rights reserved.
3 *
4 * Description: QE UCC Gigabit Ethernet Ethtool API Set
5 *
6 * Author: Li Yang <leoli@freescale.com>
7 *
8 * Limitation:
9 * Can only get/set setttings of the first queue.
10 * Need to re-open the interface manually after changing some paramters.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 */
17
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/errno.h>
21#include <linux/slab.h>
22#include <linux/stddef.h>
23#include <linux/interrupt.h>
24#include <linux/netdevice.h>
25#include <linux/etherdevice.h>
26#include <linux/skbuff.h>
27#include <linux/spinlock.h>
28#include <linux/mm.h>
29#include <linux/delay.h>
30#include <linux/dma-mapping.h>
31#include <linux/fsl_devices.h>
32#include <linux/ethtool.h>
33#include <linux/mii.h>
34#include <linux/phy.h>
35
36#include <asm/io.h>
37#include <asm/irq.h>
38#include <asm/uaccess.h>
39#include <asm/types.h>
40#include <asm/uaccess.h>
41
42#include "ucc_geth.h"
43#include "ucc_geth_mii.h"
44
45static char hw_stat_gstrings[][ETH_GSTRING_LEN] = {
46 "tx-64-frames",
47 "tx-65-127-frames",
48 "tx-128-255-frames",
49 "rx-64-frames",
50 "rx-65-127-frames",
51 "rx-128-255-frames",
52 "tx-bytes-ok",
53 "tx-pause-frames",
54 "tx-multicast-frames",
55 "tx-broadcast-frames",
56 "rx-frames",
57 "rx-bytes-ok",
58 "rx-bytes-all",
59 "rx-multicast-frames",
60 "rx-broadcast-frames",
61 "stats-counter-carry",
62 "stats-counter-mask",
63 "rx-dropped-frames",
64};
65
66static char tx_fw_stat_gstrings[][ETH_GSTRING_LEN] = {
67 "tx-single-collision",
68 "tx-multiple-collision",
69 "tx-late-collsion",
70 "tx-aborted-frames",
71 "tx-lost-frames",
72 "tx-carrier-sense-errors",
73 "tx-frames-ok",
74 "tx-excessive-differ-frames",
75 "tx-256-511-frames",
76 "tx-1024-1518-frames",
77 "tx-jumbo-frames",
78};
79
80static char rx_fw_stat_gstrings[][ETH_GSTRING_LEN] = {
81 "rx-crc-errors",
82 "rx-alignment-errors",
83 "rx-in-range-length-errors",
84 "rx-out-of-range-length-errors",
85 "rx-too-long-frames",
86 "rx-runt",
87 "rx-very-long-event",
88 "rx-symbol-errors",
89 "rx-busy-drop-frames",
90 "reserved",
91 "reserved",
92 "rx-mismatch-drop-frames",
93 "rx-small-than-64",
94 "rx-256-511-frames",
95 "rx-512-1023-frames",
96 "rx-1024-1518-frames",
97 "rx-jumbo-frames",
98 "rx-mac-error-loss",
99 "rx-pause-frames",
100 "reserved",
101 "rx-vlan-removed",
102 "rx-vlan-replaced",
103 "rx-vlan-inserted",
104 "rx-ip-checksum-errors",
105};
106
107#define UEC_HW_STATS_LEN ARRAY_SIZE(hw_stat_gstrings)
108#define UEC_TX_FW_STATS_LEN ARRAY_SIZE(tx_fw_stat_gstrings)
109#define UEC_RX_FW_STATS_LEN ARRAY_SIZE(rx_fw_stat_gstrings)
110
111extern int init_flow_control_params(u32 automatic_flow_control_mode,
112 int rx_flow_control_enable,
113 int tx_flow_control_enable, u16 pause_period,
114 u16 extension_field, volatile u32 *upsmr_register,
115 volatile u32 *uempr_register, volatile u32 *maccfg1_register);
116
117static int
118uec_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
119{
120 struct ucc_geth_private *ugeth = netdev_priv(netdev);
121 struct phy_device *phydev = ugeth->phydev;
122 struct ucc_geth_info *ug_info = ugeth->ug_info;
123
124 if (!phydev)
125 return -ENODEV;
126
127 ecmd->maxtxpkt = 1;
128 ecmd->maxrxpkt = ug_info->interruptcoalescingmaxvalue[0];
129
130 return phy_ethtool_gset(phydev, ecmd);
131}
132
133static int
134uec_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
135{
136 struct ucc_geth_private *ugeth = netdev_priv(netdev);
137 struct phy_device *phydev = ugeth->phydev;
138
139 if (!phydev)
140 return -ENODEV;
141
142 return phy_ethtool_sset(phydev, ecmd);
143}
144
145static void
146uec_get_pauseparam(struct net_device *netdev,
147 struct ethtool_pauseparam *pause)
148{
149 struct ucc_geth_private *ugeth = netdev_priv(netdev);
150
151 pause->autoneg = ugeth->phydev->autoneg;
152
153 if (ugeth->ug_info->receiveFlowControl)
154 pause->rx_pause = 1;
155 if (ugeth->ug_info->transmitFlowControl)
156 pause->tx_pause = 1;
157}
158
159static int
160uec_set_pauseparam(struct net_device *netdev,
161 struct ethtool_pauseparam *pause)
162{
163 struct ucc_geth_private *ugeth = netdev_priv(netdev);
164 int ret = 0;
165
166 ugeth->ug_info->receiveFlowControl = pause->rx_pause;
167 ugeth->ug_info->transmitFlowControl = pause->tx_pause;
168
169 if (ugeth->phydev->autoneg) {
170 if (netif_running(netdev)) {
171 /* FIXME: automatically restart */
172 printk(KERN_INFO
173 "Please re-open the interface.\n");
174 }
175 } else {
176 struct ucc_geth_info *ug_info = ugeth->ug_info;
177
178 ret = init_flow_control_params(ug_info->aufc,
179 ug_info->receiveFlowControl,
180 ug_info->transmitFlowControl,
181 ug_info->pausePeriod,
182 ug_info->extensionField,
183 &ugeth->uccf->uf_regs->upsmr,
184 &ugeth->ug_regs->uempr,
185 &ugeth->ug_regs->maccfg1);
186 }
187
188 return ret;
189}
190
191static uint32_t
192uec_get_msglevel(struct net_device *netdev)
193{
194 struct ucc_geth_private *ugeth = netdev_priv(netdev);
195 return ugeth->msg_enable;
196}
197
198static void
199uec_set_msglevel(struct net_device *netdev, uint32_t data)
200{
201 struct ucc_geth_private *ugeth = netdev_priv(netdev);
202 ugeth->msg_enable = data;
203}
204
205static int
206uec_get_regs_len(struct net_device *netdev)
207{
208 return sizeof(struct ucc_geth);
209}
210
211static void
212uec_get_regs(struct net_device *netdev,
213 struct ethtool_regs *regs, void *p)
214{
215 int i;
216 struct ucc_geth_private *ugeth = netdev_priv(netdev);
217 u32 __iomem *ug_regs = (u32 __iomem *)ugeth->ug_regs;
218 u32 *buff = p;
219
220 for (i = 0; i < sizeof(struct ucc_geth) / sizeof(u32); i++)
221 buff[i] = in_be32(&ug_regs[i]);
222}
223
224static void
225uec_get_ringparam(struct net_device *netdev,
226 struct ethtool_ringparam *ring)
227{
228 struct ucc_geth_private *ugeth = netdev_priv(netdev);
229 struct ucc_geth_info *ug_info = ugeth->ug_info;
230 int queue = 0;
231
232 ring->rx_max_pending = UCC_GETH_BD_RING_SIZE_MAX;
233 ring->rx_mini_max_pending = UCC_GETH_BD_RING_SIZE_MAX;
234 ring->rx_jumbo_max_pending = UCC_GETH_BD_RING_SIZE_MAX;
235 ring->tx_max_pending = UCC_GETH_BD_RING_SIZE_MAX;
236
237 ring->rx_pending = ug_info->bdRingLenRx[queue];
238 ring->rx_mini_pending = ug_info->bdRingLenRx[queue];
239 ring->rx_jumbo_pending = ug_info->bdRingLenRx[queue];
240 ring->tx_pending = ug_info->bdRingLenTx[queue];
241}
242
243static int
244uec_set_ringparam(struct net_device *netdev,
245 struct ethtool_ringparam *ring)
246{
247 struct ucc_geth_private *ugeth = netdev_priv(netdev);
248 struct ucc_geth_info *ug_info = ugeth->ug_info;
249 int queue = 0, ret = 0;
250
251 if (ring->rx_pending < UCC_GETH_RX_BD_RING_SIZE_MIN) {
252 printk("%s: RxBD ring size must be no smaller than %d.\n",
253 netdev->name, UCC_GETH_RX_BD_RING_SIZE_MIN);
254 return -EINVAL;
255 }
256 if (ring->rx_pending % UCC_GETH_RX_BD_RING_SIZE_ALIGNMENT) {
257 printk("%s: RxBD ring size must be multiple of %d.\n",
258 netdev->name, UCC_GETH_RX_BD_RING_SIZE_ALIGNMENT);
259 return -EINVAL;
260 }
261 if (ring->tx_pending < UCC_GETH_TX_BD_RING_SIZE_MIN) {
262 printk("%s: TxBD ring size must be no smaller than %d.\n",
263 netdev->name, UCC_GETH_TX_BD_RING_SIZE_MIN);
264 return -EINVAL;
265 }
266
267 ug_info->bdRingLenRx[queue] = ring->rx_pending;
268 ug_info->bdRingLenTx[queue] = ring->tx_pending;
269
270 if (netif_running(netdev)) {
271 /* FIXME: restart automatically */
272 printk(KERN_INFO
273 "Please re-open the interface.\n");
274 }
275
276 return ret;
277}
278
279static int uec_get_stats_count(struct net_device *netdev)
280{
281 struct ucc_geth_private *ugeth = netdev_priv(netdev);
282 u32 stats_mode = ugeth->ug_info->statisticsMode;
283 int len = 0;
284
285 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE)
286 len += UEC_HW_STATS_LEN;
287 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX)
288 len += UEC_TX_FW_STATS_LEN;
289 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX)
290 len += UEC_RX_FW_STATS_LEN;
291
292 return len;
293}
294
295static void uec_get_strings(struct net_device *netdev, u32 stringset, u8 *buf)
296{
297 struct ucc_geth_private *ugeth = netdev_priv(netdev);
298 u32 stats_mode = ugeth->ug_info->statisticsMode;
299
300 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) {
301 memcpy(buf, hw_stat_gstrings, UEC_HW_STATS_LEN *
302 ETH_GSTRING_LEN);
303 buf += UEC_HW_STATS_LEN * ETH_GSTRING_LEN;
304 }
305 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) {
306 memcpy(buf, tx_fw_stat_gstrings, UEC_TX_FW_STATS_LEN *
307 ETH_GSTRING_LEN);
308 buf += UEC_TX_FW_STATS_LEN * ETH_GSTRING_LEN;
309 }
310 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX)
311 memcpy(buf, tx_fw_stat_gstrings, UEC_RX_FW_STATS_LEN *
312 ETH_GSTRING_LEN);
313}
314
315static void uec_get_ethtool_stats(struct net_device *netdev,
316 struct ethtool_stats *stats, uint64_t *data)
317{
318 struct ucc_geth_private *ugeth = netdev_priv(netdev);
319 u32 stats_mode = ugeth->ug_info->statisticsMode;
320 u32 __iomem *base;
321 int i, j = 0;
322
323 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) {
324 base = (u32 __iomem *)&ugeth->ug_regs->tx64;
325 for (i = 0; i < UEC_HW_STATS_LEN; i++)
326 data[j++] = (u64)in_be32(&base[i]);
327 }
328 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) {
329 base = (u32 __iomem *)ugeth->p_tx_fw_statistics_pram;
330 for (i = 0; i < UEC_TX_FW_STATS_LEN; i++)
331 data[j++] = (u64)in_be32(&base[i]);
332 }
333 if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) {
334 base = (u32 __iomem *)ugeth->p_rx_fw_statistics_pram;
335 for (i = 0; i < UEC_RX_FW_STATS_LEN; i++)
336 data[j++] = (u64)in_be32(&base[i]);
337 }
338}
339
340static int uec_nway_reset(struct net_device *netdev)
341{
342 struct ucc_geth_private *ugeth = netdev_priv(netdev);
343
344 return phy_start_aneg(ugeth->phydev);
345}
346
347/* Report driver information */
348static void
349uec_get_drvinfo(struct net_device *netdev,
350 struct ethtool_drvinfo *drvinfo)
351{
352 strncpy(drvinfo->driver, DRV_NAME, 32);
353 strncpy(drvinfo->version, DRV_VERSION, 32);
354 strncpy(drvinfo->fw_version, "N/A", 32);
355 strncpy(drvinfo->bus_info, "QUICC ENGINE", 32);
356 drvinfo->n_stats = uec_get_stats_count(netdev);
357 drvinfo->testinfo_len = 0;
358 drvinfo->eedump_len = 0;
359 drvinfo->regdump_len = uec_get_regs_len(netdev);
360}
361
362static const struct ethtool_ops uec_ethtool_ops = {
363 .get_settings = uec_get_settings,
364 .set_settings = uec_set_settings,
365 .get_drvinfo = uec_get_drvinfo,
366 .get_regs_len = uec_get_regs_len,
367 .get_regs = uec_get_regs,
368 .get_msglevel = uec_get_msglevel,
369 .set_msglevel = uec_set_msglevel,
370 .nway_reset = uec_nway_reset,
371 .get_link = ethtool_op_get_link,
372 .get_ringparam = uec_get_ringparam,
373 .set_ringparam = uec_set_ringparam,
374 .get_pauseparam = uec_get_pauseparam,
375 .set_pauseparam = uec_set_pauseparam,
376 .get_sg = ethtool_op_get_sg,
377 .set_sg = ethtool_op_set_sg,
378 .get_tso = ethtool_op_get_tso,
379 .get_stats_count = uec_get_stats_count,
380 .get_strings = uec_get_strings,
381 .get_ethtool_stats = uec_get_ethtool_stats,
382 .get_perm_addr = ethtool_op_get_perm_addr,
383};
384
385void uec_set_ethtool_ops(struct net_device *netdev)
386{
387 SET_ETHTOOL_OPS(netdev, &uec_ethtool_ops);
388}
diff --git a/drivers/net/ucc_geth_mii.c b/drivers/net/ucc_geth_mii.c
index 7bcb82f50cf7..5f8c2d30a328 100644
--- a/drivers/net/ucc_geth_mii.c
+++ b/drivers/net/ucc_geth_mii.c
@@ -54,8 +54,8 @@
54#define vdbg(format, arg...) do {} while(0) 54#define vdbg(format, arg...) do {} while(0)
55#endif 55#endif
56 56
57#define DRV_DESC "QE UCC Ethernet Controller MII Bus" 57#define MII_DRV_DESC "QE UCC Ethernet Controller MII Bus"
58#define DRV_NAME "fsl-uec_mdio" 58#define MII_DRV_NAME "fsl-uec_mdio"
59 59
60/* Write value to the PHY for this device to the register at regnum, */ 60/* Write value to the PHY for this device to the register at regnum, */
61/* waiting until the write is done before it returns. All PHY */ 61/* waiting until the write is done before it returns. All PHY */
@@ -261,7 +261,7 @@ static struct of_device_id uec_mdio_match[] = {
261}; 261};
262 262
263static struct of_platform_driver uec_mdio_driver = { 263static struct of_platform_driver uec_mdio_driver = {
264 .name = DRV_NAME, 264 .name = MII_DRV_NAME,
265 .probe = uec_mdio_probe, 265 .probe = uec_mdio_probe,
266 .remove = uec_mdio_remove, 266 .remove = uec_mdio_remove,
267 .match_table = uec_mdio_match, 267 .match_table = uec_mdio_match,
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index a05fd97e5bc2..04cba6bf3d54 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -768,11 +768,13 @@ done:
768static void write_bulk_callback(struct urb *urb) 768static void write_bulk_callback(struct urb *urb)
769{ 769{
770 pegasus_t *pegasus = urb->context; 770 pegasus_t *pegasus = urb->context;
771 struct net_device *net = pegasus->net; 771 struct net_device *net;
772 772
773 if (!pegasus) 773 if (!pegasus)
774 return; 774 return;
775 775
776 net = pegasus->net;
777
776 if (!netif_device_present(net) || !netif_running(net)) 778 if (!netif_device_present(net) || !netif_running(net))
777 return; 779 return;
778 780
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index f51c2c138f10..c3fe230695a0 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -1805,7 +1805,6 @@ static const struct ethtool_ops netdev_ethtool_ops = {
1805 .set_wol = rhine_set_wol, 1805 .set_wol = rhine_set_wol,
1806 .get_sg = ethtool_op_get_sg, 1806 .get_sg = ethtool_op_get_sg,
1807 .get_tx_csum = ethtool_op_get_tx_csum, 1807 .get_tx_csum = ethtool_op_get_tx_csum,
1808 .get_perm_addr = ethtool_op_get_perm_addr,
1809}; 1808};
1810 1809
1811static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1810static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index f331843d1102..93574add4063 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -1613,7 +1613,7 @@ static void velocity_error(struct velocity_info *vptr, int status)
1613 if (status & ISR_TXSTLI) { 1613 if (status & ISR_TXSTLI) {
1614 struct mac_regs __iomem * regs = vptr->mac_regs; 1614 struct mac_regs __iomem * regs = vptr->mac_regs;
1615 1615
1616 printk(KERN_ERR "TD structure errror TDindex=%hx\n", readw(&regs->TDIdx[0])); 1616 printk(KERN_ERR "TD structure error TDindex=%hx\n", readw(&regs->TDIdx[0]));
1617 BYTE_REG_BITS_ON(TXESR_TDSTR, &regs->TXESR); 1617 BYTE_REG_BITS_ON(TXESR_TDSTR, &regs->TXESR);
1618 writew(TRDCSR_RUN, &regs->TDCSRClr); 1618 writew(TRDCSR_RUN, &regs->TDCSRClr);
1619 netif_stop_queue(vptr->dev); 1619 netif_stop_queue(vptr->dev);
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 5d58ad55d85c..e2be84001105 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -3445,7 +3445,6 @@ static void __exit parport_pc_exit(void)
3445 pnp_unregister_driver (&parport_pc_pnp_driver); 3445 pnp_unregister_driver (&parport_pc_pnp_driver);
3446 platform_driver_unregister(&parport_pc_platform_driver); 3446 platform_driver_unregister(&parport_pc_platform_driver);
3447 3447
3448 spin_lock(&ports_lock);
3449 while (!list_empty(&ports_list)) { 3448 while (!list_empty(&ports_list)) {
3450 struct parport_pc_private *priv; 3449 struct parport_pc_private *priv;
3451 struct parport *port; 3450 struct parport *port;
@@ -3455,11 +3454,8 @@ static void __exit parport_pc_exit(void)
3455 if (port->dev && port->dev->bus == &platform_bus_type) 3454 if (port->dev && port->dev->bus == &platform_bus_type)
3456 platform_device_unregister( 3455 platform_device_unregister(
3457 to_platform_device(port->dev)); 3456 to_platform_device(port->dev));
3458 spin_unlock(&ports_lock);
3459 parport_pc_unregister_port(port); 3457 parport_pc_unregister_port(port);
3460 spin_lock(&ports_lock);
3461 } 3458 }
3462 spin_unlock(&ports_lock);
3463} 3459}
3464 3460
3465MODULE_AUTHOR("Phil Blundell, Tim Waugh, others"); 3461MODULE_AUTHOR("Phil Blundell, Tim Waugh, others");
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index c8062494009f..5c6a5d043007 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -220,6 +220,7 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
220} 220}
221EXPORT_SYMBOL(pci_osc_control_set); 221EXPORT_SYMBOL(pci_osc_control_set);
222 222
223#ifdef CONFIG_ACPI_SLEEP
223/* 224/*
224 * _SxD returns the D-state with the highest power 225 * _SxD returns the D-state with the highest power
225 * (lowest D-state number) supported in the S-state "x". 226 * (lowest D-state number) supported in the S-state "x".
@@ -245,16 +246,34 @@ EXPORT_SYMBOL(pci_osc_control_set);
245 * currently we simply return _SxD, if present. 246 * currently we simply return _SxD, if present.
246 */ 247 */
247 248
248static int acpi_pci_choose_state(struct pci_dev *pdev, pm_message_t state) 249static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev,
250 pm_message_t state)
249{ 251{
250 /* TBD */ 252 int acpi_state;
251 253
252 return -ENODEV; 254 acpi_state = acpi_pm_device_sleep_state(&pdev->dev,
255 device_may_wakeup(&pdev->dev), NULL);
256 if (acpi_state < 0)
257 return PCI_POWER_ERROR;
258
259 switch (acpi_state) {
260 case ACPI_STATE_D0:
261 return PCI_D0;
262 case ACPI_STATE_D1:
263 return PCI_D1;
264 case ACPI_STATE_D2:
265 return PCI_D2;
266 case ACPI_STATE_D3:
267 return PCI_D3hot;
268 }
269 return PCI_POWER_ERROR;
253} 270}
271#endif
254 272
255static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) 273static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
256{ 274{
257 acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev); 275 acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
276 acpi_handle tmp;
258 static int state_conv[] = { 277 static int state_conv[] = {
259 [0] = 0, 278 [0] = 0,
260 [1] = 1, 279 [1] = 1,
@@ -266,6 +285,9 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
266 285
267 if (!handle) 286 if (!handle)
268 return -ENODEV; 287 return -ENODEV;
288 /* If the ACPI device has _EJ0, ignore the device */
289 if (ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0", &tmp)))
290 return 0;
269 return acpi_bus_set_power(handle, acpi_state); 291 return acpi_bus_set_power(handle, acpi_state);
270} 292}
271 293
@@ -320,7 +342,9 @@ static int __init acpi_pci_init(void)
320 ret = register_acpi_bus_type(&acpi_pci_bus); 342 ret = register_acpi_bus_type(&acpi_pci_bus);
321 if (ret) 343 if (ret)
322 return 0; 344 return 0;
345#ifdef CONFIG_ACPI_SLEEP
323 platform_pci_choose_state = acpi_pci_choose_state; 346 platform_pci_choose_state = acpi_pci_choose_state;
347#endif
324 platform_pci_set_power_state = acpi_pci_set_power_state; 348 platform_pci_set_power_state = acpi_pci_set_power_state;
325 return 0; 349 return 0;
326} 350}
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 03fd59e80fef..1ee9cd9c86e2 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -499,7 +499,7 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
499 return 0; 499 return 0;
500} 500}
501 501
502int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state); 502pci_power_t (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
503 503
504/** 504/**
505 * pci_choose_state - Choose the power state of a PCI device 505 * pci_choose_state - Choose the power state of a PCI device
@@ -513,15 +513,15 @@ int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
513 513
514pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) 514pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
515{ 515{
516 int ret; 516 pci_power_t ret;
517 517
518 if (!pci_find_capability(dev, PCI_CAP_ID_PM)) 518 if (!pci_find_capability(dev, PCI_CAP_ID_PM))
519 return PCI_D0; 519 return PCI_D0;
520 520
521 if (platform_pci_choose_state) { 521 if (platform_pci_choose_state) {
522 ret = platform_pci_choose_state(dev, state); 522 ret = platform_pci_choose_state(dev, state);
523 if (ret >= 0) 523 if (ret != PCI_POWER_ERROR)
524 state.event = ret; 524 return ret;
525 } 525 }
526 526
527 switch (state.event) { 527 switch (state.event) {
@@ -1517,7 +1517,7 @@ EXPORT_SYMBOL(pcie_get_readrq);
1517/** 1517/**
1518 * pcie_set_readrq - set PCI Express maximum memory read request 1518 * pcie_set_readrq - set PCI Express maximum memory read request
1519 * @dev: PCI device to query 1519 * @dev: PCI device to query
1520 * @count: maximum memory read count in bytes 1520 * @rq: maximum memory read count in bytes
1521 * valid values are 128, 256, 512, 1024, 2048, 4096 1521 * valid values are 128, 256, 512, 1024, 2048, 4096
1522 * 1522 *
1523 * If possible sets maximum read byte count 1523 * If possible sets maximum read byte count
@@ -1604,6 +1604,7 @@ early_param("pci", pci_setup);
1604device_initcall(pci_init); 1604device_initcall(pci_init);
1605 1605
1606EXPORT_SYMBOL_GPL(pci_restore_bars); 1606EXPORT_SYMBOL_GPL(pci_restore_bars);
1607EXPORT_SYMBOL(__pci_reenable_device);
1607EXPORT_SYMBOL(pci_enable_device_bars); 1608EXPORT_SYMBOL(pci_enable_device_bars);
1608EXPORT_SYMBOL(pci_enable_device); 1609EXPORT_SYMBOL(pci_enable_device);
1609EXPORT_SYMBOL(pcim_enable_device); 1610EXPORT_SYMBOL(pcim_enable_device);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 3fec13d3add7..c6e132d7c0f7 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -1,6 +1,5 @@
1/* Functions internal to the PCI core code */ 1/* Functions internal to the PCI core code */
2 2
3extern int __must_check __pci_reenable_device(struct pci_dev *);
4extern int pci_uevent(struct device *dev, char **envp, int num_envp, 3extern int pci_uevent(struct device *dev, char **envp, int num_envp,
5 char *buffer, int buffer_size); 4 char *buffer, int buffer_size);
6extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); 5extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
@@ -13,7 +12,7 @@ extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
13 resource_size_t, resource_size_t), 12 resource_size_t, resource_size_t),
14 void *alignf_data); 13 void *alignf_data);
15/* Firmware callbacks */ 14/* Firmware callbacks */
16extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state); 15extern pci_power_t (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
17extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state); 16extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state);
18 17
19extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val); 18extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 7c93a108f9b8..f8b13f0270d7 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -409,6 +409,9 @@ static void socket_shutdown(struct pcmcia_socket *s)
409#endif 409#endif
410 s->functions = 0; 410 s->functions = 0;
411 411
412 /* give socket some time to power down */
413 msleep(100);
414
412 s->ops->get_status(s, &status); 415 s->ops->get_status(s, &status);
413 if (status & SS_POWERON) { 416 if (status & SS_POWERON) {
414 printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); 417 printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s);
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index dd6384b1efce..b6a4f02b01d1 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -2,7 +2,6 @@
2 * card.c - contains functions for managing groups of PnP devices 2 * card.c - contains functions for managing groups of PnP devices
3 * 3 *
4 * Copyright 2002 Adam Belay <ambx1@neo.rr.com> 4 * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
5 *
6 */ 5 */
7 6
8#include <linux/module.h> 7#include <linux/module.h>
@@ -13,26 +12,31 @@
13LIST_HEAD(pnp_cards); 12LIST_HEAD(pnp_cards);
14static LIST_HEAD(pnp_card_drivers); 13static LIST_HEAD(pnp_card_drivers);
15 14
16 15static const struct pnp_card_device_id *match_card(struct pnp_card_driver *drv,
17static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv, struct pnp_card * card) 16 struct pnp_card *card)
18{ 17{
19 const struct pnp_card_device_id * drv_id = drv->id_table; 18 const struct pnp_card_device_id *drv_id = drv->id_table;
20 while (*drv_id->id){ 19
21 if (compare_pnp_id(card->id,drv_id->id)) { 20 while (*drv_id->id) {
21 if (compare_pnp_id(card->id, drv_id->id)) {
22 int i = 0; 22 int i = 0;
23
23 for (;;) { 24 for (;;) {
24 int found; 25 int found;
25 struct pnp_dev *dev; 26 struct pnp_dev *dev;
26 if (i == PNP_MAX_DEVICES || ! *drv_id->devs[i].id) 27
28 if (i == PNP_MAX_DEVICES
29 || !*drv_id->devs[i].id)
27 return drv_id; 30 return drv_id;
28 found = 0; 31 found = 0;
29 card_for_each_dev(card, dev) { 32 card_for_each_dev(card, dev) {
30 if (compare_pnp_id(dev->id, drv_id->devs[i].id)) { 33 if (compare_pnp_id
34 (dev->id, drv_id->devs[i].id)) {
31 found = 1; 35 found = 1;
32 break; 36 break;
33 } 37 }
34 } 38 }
35 if (! found) 39 if (!found)
36 break; 40 break;
37 i++; 41 i++;
38 } 42 }
@@ -42,14 +46,15 @@ static const struct pnp_card_device_id * match_card(struct pnp_card_driver * drv
42 return NULL; 46 return NULL;
43} 47}
44 48
45static void card_remove(struct pnp_dev * dev) 49static void card_remove(struct pnp_dev *dev)
46{ 50{
47 dev->card_link = NULL; 51 dev->card_link = NULL;
48} 52}
49 53
50static void card_remove_first(struct pnp_dev * dev) 54static void card_remove_first(struct pnp_dev *dev)
51{ 55{
52 struct pnp_card_driver * drv = to_pnp_card_driver(dev->driver); 56 struct pnp_card_driver *drv = to_pnp_card_driver(dev->driver);
57
53 if (!dev->card || !drv) 58 if (!dev->card || !drv)
54 return; 59 return;
55 if (drv->remove) 60 if (drv->remove)
@@ -67,7 +72,7 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
67 72
68 if (!drv->probe) 73 if (!drv->probe)
69 return 0; 74 return 0;
70 id = match_card(drv,card); 75 id = match_card(drv, card);
71 if (!id) 76 if (!id)
72 return 0; 77 return 0;
73 78
@@ -94,12 +99,11 @@ static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv)
94 * pnp_add_card_id - adds an EISA id to the specified card 99 * pnp_add_card_id - adds an EISA id to the specified card
95 * @id: pointer to a pnp_id structure 100 * @id: pointer to a pnp_id structure
96 * @card: pointer to the desired card 101 * @card: pointer to the desired card
97 *
98 */ 102 */
99 103int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card)
100int pnp_add_card_id(struct pnp_id *id, struct pnp_card * card)
101{ 104{
102 struct pnp_id * ptr; 105 struct pnp_id *ptr;
106
103 if (!id) 107 if (!id)
104 return -EINVAL; 108 return -EINVAL;
105 if (!card) 109 if (!card)
@@ -115,10 +119,11 @@ int pnp_add_card_id(struct pnp_id *id, struct pnp_card * card)
115 return 0; 119 return 0;
116} 120}
117 121
118static void pnp_free_card_ids(struct pnp_card * card) 122static void pnp_free_card_ids(struct pnp_card *card)
119{ 123{
120 struct pnp_id * id; 124 struct pnp_id *id;
121 struct pnp_id *next; 125 struct pnp_id *next;
126
122 if (!card) 127 if (!card)
123 return; 128 return;
124 id = card->id; 129 id = card->id;
@@ -131,49 +136,55 @@ static void pnp_free_card_ids(struct pnp_card * card)
131 136
132static void pnp_release_card(struct device *dmdev) 137static void pnp_release_card(struct device *dmdev)
133{ 138{
134 struct pnp_card * card = to_pnp_card(dmdev); 139 struct pnp_card *card = to_pnp_card(dmdev);
140
135 pnp_free_card_ids(card); 141 pnp_free_card_ids(card);
136 kfree(card); 142 kfree(card);
137} 143}
138 144
139 145static ssize_t pnp_show_card_name(struct device *dmdev,
140static ssize_t pnp_show_card_name(struct device *dmdev, struct device_attribute *attr, char *buf) 146 struct device_attribute *attr, char *buf)
141{ 147{
142 char *str = buf; 148 char *str = buf;
143 struct pnp_card *card = to_pnp_card(dmdev); 149 struct pnp_card *card = to_pnp_card(dmdev);
144 str += sprintf(str,"%s\n", card->name); 150
151 str += sprintf(str, "%s\n", card->name);
145 return (str - buf); 152 return (str - buf);
146} 153}
147 154
148static DEVICE_ATTR(name,S_IRUGO,pnp_show_card_name,NULL); 155static DEVICE_ATTR(name, S_IRUGO, pnp_show_card_name, NULL);
149 156
150static ssize_t pnp_show_card_ids(struct device *dmdev, struct device_attribute *attr, char *buf) 157static ssize_t pnp_show_card_ids(struct device *dmdev,
158 struct device_attribute *attr, char *buf)
151{ 159{
152 char *str = buf; 160 char *str = buf;
153 struct pnp_card *card = to_pnp_card(dmdev); 161 struct pnp_card *card = to_pnp_card(dmdev);
154 struct pnp_id * pos = card->id; 162 struct pnp_id *pos = card->id;
155 163
156 while (pos) { 164 while (pos) {
157 str += sprintf(str,"%s\n", pos->id); 165 str += sprintf(str, "%s\n", pos->id);
158 pos = pos->next; 166 pos = pos->next;
159 } 167 }
160 return (str - buf); 168 return (str - buf);
161} 169}
162 170
163static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL); 171static DEVICE_ATTR(card_id, S_IRUGO, pnp_show_card_ids, NULL);
164 172
165static int pnp_interface_attach_card(struct pnp_card *card) 173static int pnp_interface_attach_card(struct pnp_card *card)
166{ 174{
167 int rc = device_create_file(&card->dev,&dev_attr_name); 175 int rc = device_create_file(&card->dev, &dev_attr_name);
168 if (rc) return rc;
169 176
170 rc = device_create_file(&card->dev,&dev_attr_card_id); 177 if (rc)
171 if (rc) goto err_name; 178 return rc;
179
180 rc = device_create_file(&card->dev, &dev_attr_card_id);
181 if (rc)
182 goto err_name;
172 183
173 return 0; 184 return 0;
174 185
175err_name: 186 err_name:
176 device_remove_file(&card->dev,&dev_attr_name); 187 device_remove_file(&card->dev, &dev_attr_name);
177 return rc; 188 return rc;
178} 189}
179 190
@@ -181,15 +192,16 @@ err_name:
181 * pnp_add_card - adds a PnP card to the PnP Layer 192 * pnp_add_card - adds a PnP card to the PnP Layer
182 * @card: pointer to the card to add 193 * @card: pointer to the card to add
183 */ 194 */
184 195int pnp_add_card(struct pnp_card *card)
185int pnp_add_card(struct pnp_card * card)
186{ 196{
187 int error; 197 int error;
188 struct list_head * pos, * temp; 198 struct list_head *pos, *temp;
199
189 if (!card || !card->protocol) 200 if (!card || !card->protocol)
190 return -EINVAL; 201 return -EINVAL;
191 202
192 sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number, card->number); 203 sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
204 card->number);
193 card->dev.parent = &card->protocol->dev; 205 card->dev.parent = &card->protocol->dev;
194 card->dev.bus = NULL; 206 card->dev.bus = NULL;
195 card->dev.release = &pnp_release_card; 207 card->dev.release = &pnp_release_card;
@@ -205,18 +217,21 @@ int pnp_add_card(struct pnp_card * card)
205 /* we wait until now to add devices in order to ensure the drivers 217 /* we wait until now to add devices in order to ensure the drivers
206 * will be able to use all of the related devices on the card 218 * will be able to use all of the related devices on the card
207 * without waiting any unresonable length of time */ 219 * without waiting any unresonable length of time */
208 list_for_each(pos,&card->devices){ 220 list_for_each(pos, &card->devices) {
209 struct pnp_dev *dev = card_to_pnp_dev(pos); 221 struct pnp_dev *dev = card_to_pnp_dev(pos);
210 __pnp_add_device(dev); 222 __pnp_add_device(dev);
211 } 223 }
212 224
213 /* match with card drivers */ 225 /* match with card drivers */
214 list_for_each_safe(pos,temp,&pnp_card_drivers){ 226 list_for_each_safe(pos, temp, &pnp_card_drivers) {
215 struct pnp_card_driver * drv = list_entry(pos, struct pnp_card_driver, global_list); 227 struct pnp_card_driver *drv =
216 card_probe(card,drv); 228 list_entry(pos, struct pnp_card_driver,
229 global_list);
230 card_probe(card, drv);
217 } 231 }
218 } else 232 } else
219 pnp_err("sysfs failure, card '%s' will be unavailable", card->dev.bus_id); 233 pnp_err("sysfs failure, card '%s' will be unavailable",
234 card->dev.bus_id);
220 return error; 235 return error;
221} 236}
222 237
@@ -224,10 +239,10 @@ int pnp_add_card(struct pnp_card * card)
224 * pnp_remove_card - removes a PnP card from the PnP Layer 239 * pnp_remove_card - removes a PnP card from the PnP Layer
225 * @card: pointer to the card to remove 240 * @card: pointer to the card to remove
226 */ 241 */
227 242void pnp_remove_card(struct pnp_card *card)
228void pnp_remove_card(struct pnp_card * card)
229{ 243{
230 struct list_head *pos, *temp; 244 struct list_head *pos, *temp;
245
231 if (!card) 246 if (!card)
232 return; 247 return;
233 device_unregister(&card->dev); 248 device_unregister(&card->dev);
@@ -235,7 +250,7 @@ void pnp_remove_card(struct pnp_card * card)
235 list_del(&card->global_list); 250 list_del(&card->global_list);
236 list_del(&card->protocol_list); 251 list_del(&card->protocol_list);
237 spin_unlock(&pnp_lock); 252 spin_unlock(&pnp_lock);
238 list_for_each_safe(pos,temp,&card->devices){ 253 list_for_each_safe(pos, temp, &card->devices) {
239 struct pnp_dev *dev = card_to_pnp_dev(pos); 254 struct pnp_dev *dev = card_to_pnp_dev(pos);
240 pnp_remove_card_device(dev); 255 pnp_remove_card_device(dev);
241 } 256 }
@@ -246,15 +261,14 @@ void pnp_remove_card(struct pnp_card * card)
246 * @card: pointer to the card to add to 261 * @card: pointer to the card to add to
247 * @dev: pointer to the device to add 262 * @dev: pointer to the device to add
248 */ 263 */
249 264int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev)
250int pnp_add_card_device(struct pnp_card * card, struct pnp_dev * dev)
251{ 265{
252 if (!card || !dev || !dev->protocol) 266 if (!card || !dev || !dev->protocol)
253 return -EINVAL; 267 return -EINVAL;
254 dev->dev.parent = &card->dev; 268 dev->dev.parent = &card->dev;
255 dev->card_link = NULL; 269 dev->card_link = NULL;
256 snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x", dev->protocol->number, 270 snprintf(dev->dev.bus_id, BUS_ID_SIZE, "%02x:%02x.%02x",
257 card->number,dev->number); 271 dev->protocol->number, card->number, dev->number);
258 spin_lock(&pnp_lock); 272 spin_lock(&pnp_lock);
259 dev->card = card; 273 dev->card = card;
260 list_add_tail(&dev->card_list, &card->devices); 274 list_add_tail(&dev->card_list, &card->devices);
@@ -266,8 +280,7 @@ int pnp_add_card_device(struct pnp_card * card, struct pnp_dev * dev)
266 * pnp_remove_card_device- removes a device from the specified card 280 * pnp_remove_card_device- removes a device from the specified card
267 * @dev: pointer to the device to remove 281 * @dev: pointer to the device to remove
268 */ 282 */
269 283void pnp_remove_card_device(struct pnp_dev *dev)
270void pnp_remove_card_device(struct pnp_dev * dev)
271{ 284{
272 spin_lock(&pnp_lock); 285 spin_lock(&pnp_lock);
273 dev->card = NULL; 286 dev->card = NULL;
@@ -282,13 +295,14 @@ void pnp_remove_card_device(struct pnp_dev * dev)
282 * @id: pointer to a PnP ID structure that explains the rules for finding the device 295 * @id: pointer to a PnP ID structure that explains the rules for finding the device
283 * @from: Starting place to search from. If NULL it will start from the begining. 296 * @from: Starting place to search from. If NULL it will start from the begining.
284 */ 297 */
285 298struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
286struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from) 299 const char *id, struct pnp_dev *from)
287{ 300{
288 struct list_head * pos; 301 struct list_head *pos;
289 struct pnp_dev * dev; 302 struct pnp_dev *dev;
290 struct pnp_card_driver * drv; 303 struct pnp_card_driver *drv;
291 struct pnp_card * card; 304 struct pnp_card *card;
305
292 if (!clink || !id) 306 if (!clink || !id)
293 goto done; 307 goto done;
294 card = clink->card; 308 card = clink->card;
@@ -302,15 +316,15 @@ struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char
302 } 316 }
303 while (pos != &card->devices) { 317 while (pos != &card->devices) {
304 dev = card_to_pnp_dev(pos); 318 dev = card_to_pnp_dev(pos);
305 if ((!dev->card_link) && compare_pnp_id(dev->id,id)) 319 if ((!dev->card_link) && compare_pnp_id(dev->id, id))
306 goto found; 320 goto found;
307 pos = pos->next; 321 pos = pos->next;
308 } 322 }
309 323
310done: 324 done:
311 return NULL; 325 return NULL;
312 326
313found: 327 found:
314 dev->card_link = clink; 328 dev->card_link = clink;
315 dev->dev.driver = &drv->link.driver; 329 dev->dev.driver = &drv->link.driver;
316 if (pnp_bus_type.probe(&dev->dev)) 330 if (pnp_bus_type.probe(&dev->dev))
@@ -320,7 +334,7 @@ found:
320 334
321 return dev; 335 return dev;
322 336
323err_out: 337 err_out:
324 dev->dev.driver = NULL; 338 dev->dev.driver = NULL;
325 dev->card_link = NULL; 339 dev->card_link = NULL;
326 return NULL; 340 return NULL;
@@ -330,10 +344,10 @@ err_out:
330 * pnp_release_card_device - call this when the driver no longer needs the device 344 * pnp_release_card_device - call this when the driver no longer needs the device
331 * @dev: pointer to the PnP device stucture 345 * @dev: pointer to the PnP device stucture
332 */ 346 */
333 347void pnp_release_card_device(struct pnp_dev *dev)
334void pnp_release_card_device(struct pnp_dev * dev)
335{ 348{
336 struct pnp_card_driver * drv = dev->card_link->driver; 349 struct pnp_card_driver *drv = dev->card_link->driver;
350
337 if (!drv) 351 if (!drv)
338 return; 352 return;
339 drv->link.remove = &card_remove; 353 drv->link.remove = &card_remove;
@@ -347,6 +361,7 @@ void pnp_release_card_device(struct pnp_dev * dev)
347static int card_suspend(struct pnp_dev *dev, pm_message_t state) 361static int card_suspend(struct pnp_dev *dev, pm_message_t state)
348{ 362{
349 struct pnp_card_link *link = dev->card_link; 363 struct pnp_card_link *link = dev->card_link;
364
350 if (link->pm_state.event == state.event) 365 if (link->pm_state.event == state.event)
351 return 0; 366 return 0;
352 link->pm_state = state; 367 link->pm_state = state;
@@ -356,6 +371,7 @@ static int card_suspend(struct pnp_dev *dev, pm_message_t state)
356static int card_resume(struct pnp_dev *dev) 371static int card_resume(struct pnp_dev *dev)
357{ 372{
358 struct pnp_card_link *link = dev->card_link; 373 struct pnp_card_link *link = dev->card_link;
374
359 if (link->pm_state.event == PM_EVENT_ON) 375 if (link->pm_state.event == PM_EVENT_ON)
360 return 0; 376 return 0;
361 link->pm_state = PMSG_ON; 377 link->pm_state = PMSG_ON;
@@ -367,8 +383,7 @@ static int card_resume(struct pnp_dev *dev)
367 * pnp_register_card_driver - registers a PnP card driver with the PnP Layer 383 * pnp_register_card_driver - registers a PnP card driver with the PnP Layer
368 * @drv: pointer to the driver to register 384 * @drv: pointer to the driver to register
369 */ 385 */
370 386int pnp_register_card_driver(struct pnp_card_driver *drv)
371int pnp_register_card_driver(struct pnp_card_driver * drv)
372{ 387{
373 int error; 388 int error;
374 struct list_head *pos, *temp; 389 struct list_head *pos, *temp;
@@ -389,9 +404,10 @@ int pnp_register_card_driver(struct pnp_card_driver * drv)
389 list_add_tail(&drv->global_list, &pnp_card_drivers); 404 list_add_tail(&drv->global_list, &pnp_card_drivers);
390 spin_unlock(&pnp_lock); 405 spin_unlock(&pnp_lock);
391 406
392 list_for_each_safe(pos,temp,&pnp_cards){ 407 list_for_each_safe(pos, temp, &pnp_cards) {
393 struct pnp_card *card = list_entry(pos, struct pnp_card, global_list); 408 struct pnp_card *card =
394 card_probe(card,drv); 409 list_entry(pos, struct pnp_card, global_list);
410 card_probe(card, drv);
395 } 411 }
396 return 0; 412 return 0;
397} 413}
@@ -400,8 +416,7 @@ int pnp_register_card_driver(struct pnp_card_driver * drv)
400 * pnp_unregister_card_driver - unregisters a PnP card driver from the PnP Layer 416 * pnp_unregister_card_driver - unregisters a PnP card driver from the PnP Layer
401 * @drv: pointer to the driver to unregister 417 * @drv: pointer to the driver to unregister
402 */ 418 */
403 419void pnp_unregister_card_driver(struct pnp_card_driver *drv)
404void pnp_unregister_card_driver(struct pnp_card_driver * drv)
405{ 420{
406 spin_lock(&pnp_lock); 421 spin_lock(&pnp_lock);
407 list_del(&drv->global_list); 422 list_del(&drv->global_list);
@@ -409,13 +424,6 @@ void pnp_unregister_card_driver(struct pnp_card_driver * drv)
409 pnp_unregister_driver(&drv->link); 424 pnp_unregister_driver(&drv->link);
410} 425}
411 426
412#if 0
413EXPORT_SYMBOL(pnp_add_card);
414EXPORT_SYMBOL(pnp_remove_card);
415EXPORT_SYMBOL(pnp_add_card_device);
416EXPORT_SYMBOL(pnp_remove_card_device);
417EXPORT_SYMBOL(pnp_add_card_id);
418#endif /* 0 */
419EXPORT_SYMBOL(pnp_request_card_device); 427EXPORT_SYMBOL(pnp_request_card_device);
420EXPORT_SYMBOL(pnp_release_card_device); 428EXPORT_SYMBOL(pnp_release_card_device);
421EXPORT_SYMBOL(pnp_register_card_driver); 429EXPORT_SYMBOL(pnp_register_card_driver);
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index 8e7b2dd38810..61066fdb9e6d 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -2,7 +2,6 @@
2 * core.c - contains all core device and protocol registration functions 2 * core.c - contains all core device and protocol registration functions
3 * 3 *
4 * Copyright 2002 Adam Belay <ambx1@neo.rr.com> 4 * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
5 *
6 */ 5 */
7 6
8#include <linux/pnp.h> 7#include <linux/pnp.h>
@@ -18,7 +17,6 @@
18 17
19#include "base.h" 18#include "base.h"
20 19
21
22static LIST_HEAD(pnp_protocols); 20static LIST_HEAD(pnp_protocols);
23LIST_HEAD(pnp_global); 21LIST_HEAD(pnp_global);
24DEFINE_SPINLOCK(pnp_lock); 22DEFINE_SPINLOCK(pnp_lock);
@@ -36,7 +34,7 @@ void *pnp_alloc(long size)
36 void *result; 34 void *result;
37 35
38 result = kzalloc(size, GFP_KERNEL); 36 result = kzalloc(size, GFP_KERNEL);
39 if (!result){ 37 if (!result) {
40 printk(KERN_ERR "pnp: Out of Memory\n"); 38 printk(KERN_ERR "pnp: Out of Memory\n");
41 return NULL; 39 return NULL;
42 } 40 }
@@ -49,11 +47,10 @@ void *pnp_alloc(long size)
49 * 47 *
50 * Ex protocols: ISAPNP, PNPBIOS, etc 48 * Ex protocols: ISAPNP, PNPBIOS, etc
51 */ 49 */
52
53int pnp_register_protocol(struct pnp_protocol *protocol) 50int pnp_register_protocol(struct pnp_protocol *protocol)
54{ 51{
55 int nodenum; 52 int nodenum;
56 struct list_head * pos; 53 struct list_head *pos;
57 54
58 if (!protocol) 55 if (!protocol)
59 return -EINVAL; 56 return -EINVAL;
@@ -64,9 +61,9 @@ int pnp_register_protocol(struct pnp_protocol *protocol)
64 spin_lock(&pnp_lock); 61 spin_lock(&pnp_lock);
65 62
66 /* assign the lowest unused number */ 63 /* assign the lowest unused number */
67 list_for_each(pos,&pnp_protocols) { 64 list_for_each(pos, &pnp_protocols) {
68 struct pnp_protocol * cur = to_pnp_protocol(pos); 65 struct pnp_protocol *cur = to_pnp_protocol(pos);
69 if (cur->number == nodenum){ 66 if (cur->number == nodenum) {
70 pos = &pnp_protocols; 67 pos = &pnp_protocols;
71 nodenum++; 68 nodenum++;
72 } 69 }
@@ -83,7 +80,6 @@ int pnp_register_protocol(struct pnp_protocol *protocol)
83/** 80/**
84 * pnp_protocol_unregister - removes a pnp protocol from the pnp layer 81 * pnp_protocol_unregister - removes a pnp protocol from the pnp layer
85 * @protocol: pointer to the corresponding pnp_protocol structure 82 * @protocol: pointer to the corresponding pnp_protocol structure
86 *
87 */ 83 */
88void pnp_unregister_protocol(struct pnp_protocol *protocol) 84void pnp_unregister_protocol(struct pnp_protocol *protocol)
89{ 85{
@@ -93,11 +89,11 @@ void pnp_unregister_protocol(struct pnp_protocol *protocol)
93 device_unregister(&protocol->dev); 89 device_unregister(&protocol->dev);
94} 90}
95 91
96
97static void pnp_free_ids(struct pnp_dev *dev) 92static void pnp_free_ids(struct pnp_dev *dev)
98{ 93{
99 struct pnp_id * id; 94 struct pnp_id *id;
100 struct pnp_id * next; 95 struct pnp_id *next;
96
101 if (!dev) 97 if (!dev)
102 return; 98 return;
103 id = dev->id; 99 id = dev->id;
@@ -110,7 +106,8 @@ static void pnp_free_ids(struct pnp_dev *dev)
110 106
111static void pnp_release_device(struct device *dmdev) 107static void pnp_release_device(struct device *dmdev)
112{ 108{
113 struct pnp_dev * dev = to_pnp_dev(dmdev); 109 struct pnp_dev *dev = to_pnp_dev(dmdev);
110
114 pnp_free_option(dev->independent); 111 pnp_free_option(dev->independent);
115 pnp_free_option(dev->dependent); 112 pnp_free_option(dev->dependent);
116 pnp_free_ids(dev); 113 pnp_free_ids(dev);
@@ -120,6 +117,7 @@ static void pnp_release_device(struct device *dmdev)
120int __pnp_add_device(struct pnp_dev *dev) 117int __pnp_add_device(struct pnp_dev *dev)
121{ 118{
122 int ret; 119 int ret;
120
123 pnp_fixup_device(dev); 121 pnp_fixup_device(dev);
124 dev->dev.bus = &pnp_bus_type; 122 dev->dev.bus = &pnp_bus_type;
125 dev->dev.dma_mask = &dev->dma_mask; 123 dev->dev.dma_mask = &dev->dma_mask;
@@ -143,13 +141,13 @@ int __pnp_add_device(struct pnp_dev *dev)
143 * 141 *
144 * adds to driver model, name database, fixups, interface, etc. 142 * adds to driver model, name database, fixups, interface, etc.
145 */ 143 */
146
147int pnp_add_device(struct pnp_dev *dev) 144int pnp_add_device(struct pnp_dev *dev)
148{ 145{
149 if (!dev || !dev->protocol || dev->card) 146 if (!dev || !dev->protocol || dev->card)
150 return -EINVAL; 147 return -EINVAL;
151 dev->dev.parent = &dev->protocol->dev; 148 dev->dev.parent = &dev->protocol->dev;
152 sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number, dev->number); 149 sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number,
150 dev->number);
153 return __pnp_add_device(dev); 151 return __pnp_add_device(dev);
154} 152}
155 153
@@ -162,21 +160,6 @@ void __pnp_remove_device(struct pnp_dev *dev)
162 device_unregister(&dev->dev); 160 device_unregister(&dev->dev);
163} 161}
164 162
165/**
166 * pnp_remove_device - removes a pnp device from the pnp layer
167 * @dev: pointer to dev to add
168 *
169 * this function will free all mem used by dev
170 */
171#if 0
172void pnp_remove_device(struct pnp_dev *dev)
173{
174 if (!dev || dev->card)
175 return;
176 __pnp_remove_device(dev);
177}
178#endif /* 0 */
179
180static int __init pnp_init(void) 163static int __init pnp_init(void)
181{ 164{
182 printk(KERN_INFO "Linux Plug and Play Support v0.97 (c) Adam Belay\n"); 165 printk(KERN_INFO "Linux Plug and Play Support v0.97 (c) Adam Belay\n");
@@ -184,10 +167,3 @@ static int __init pnp_init(void)
184} 167}
185 168
186subsys_initcall(pnp_init); 169subsys_initcall(pnp_init);
187
188#if 0
189EXPORT_SYMBOL(pnp_register_protocol);
190EXPORT_SYMBOL(pnp_unregister_protocol);
191EXPORT_SYMBOL(pnp_add_device);
192EXPORT_SYMBOL(pnp_remove_device);
193#endif /* 0 */
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index e161423b4300..30b8f6f3258a 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -2,7 +2,6 @@
2 * driver.c - device id matching, driver model, etc. 2 * driver.c - device id matching, driver model, etc.
3 * 3 *
4 * Copyright 2002 Adam Belay <ambx1@neo.rr.com> 4 * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
5 *
6 */ 5 */
7 6
8#include <linux/string.h> 7#include <linux/string.h>
@@ -16,12 +15,11 @@
16static int compare_func(const char *ida, const char *idb) 15static int compare_func(const char *ida, const char *idb)
17{ 16{
18 int i; 17 int i;
18
19 /* we only need to compare the last 4 chars */ 19 /* we only need to compare the last 4 chars */
20 for (i=3; i<7; i++) 20 for (i = 3; i < 7; i++) {
21 {
22 if (ida[i] != 'X' && 21 if (ida[i] != 'X' &&
23 idb[i] != 'X' && 22 idb[i] != 'X' && toupper(ida[i]) != toupper(idb[i]))
24 toupper(ida[i]) != toupper(idb[i]))
25 return 0; 23 return 0;
26 } 24 }
27 return 1; 25 return 1;
@@ -31,20 +29,22 @@ int compare_pnp_id(struct pnp_id *pos, const char *id)
31{ 29{
32 if (!pos || !id || (strlen(id) != 7)) 30 if (!pos || !id || (strlen(id) != 7))
33 return 0; 31 return 0;
34 if (memcmp(id,"ANYDEVS",7)==0) 32 if (memcmp(id, "ANYDEVS", 7) == 0)
35 return 1; 33 return 1;
36 while (pos){ 34 while (pos) {
37 if (memcmp(pos->id,id,3)==0) 35 if (memcmp(pos->id, id, 3) == 0)
38 if (compare_func(pos->id,id)==1) 36 if (compare_func(pos->id, id) == 1)
39 return 1; 37 return 1;
40 pos = pos->next; 38 pos = pos->next;
41 } 39 }
42 return 0; 40 return 0;
43} 41}
44 42
45static const struct pnp_device_id * match_device(struct pnp_driver *drv, struct pnp_dev *dev) 43static const struct pnp_device_id *match_device(struct pnp_driver *drv,
44 struct pnp_dev *dev)
46{ 45{
47 const struct pnp_device_id *drv_id = drv->id_table; 46 const struct pnp_device_id *drv_id = drv->id_table;
47
48 if (!drv_id) 48 if (!drv_id)
49 return NULL; 49 return NULL;
50 50
@@ -59,7 +59,7 @@ static const struct pnp_device_id * match_device(struct pnp_driver *drv, struct
59int pnp_device_attach(struct pnp_dev *pnp_dev) 59int pnp_device_attach(struct pnp_dev *pnp_dev)
60{ 60{
61 spin_lock(&pnp_lock); 61 spin_lock(&pnp_lock);
62 if(pnp_dev->status != PNP_READY){ 62 if (pnp_dev->status != PNP_READY) {
63 spin_unlock(&pnp_lock); 63 spin_unlock(&pnp_lock);
64 return -EBUSY; 64 return -EBUSY;
65 } 65 }
@@ -86,7 +86,8 @@ static int pnp_device_probe(struct device *dev)
86 pnp_dev = to_pnp_dev(dev); 86 pnp_dev = to_pnp_dev(dev);
87 pnp_drv = to_pnp_driver(dev->driver); 87 pnp_drv = to_pnp_driver(dev->driver);
88 88
89 pnp_dbg("match found with the PnP device '%s' and the driver '%s'", dev->bus_id,pnp_drv->name); 89 pnp_dbg("match found with the PnP device '%s' and the driver '%s'",
90 dev->bus_id, pnp_drv->name);
90 91
91 error = pnp_device_attach(pnp_dev); 92 error = pnp_device_attach(pnp_dev);
92 if (error < 0) 93 if (error < 0)
@@ -99,7 +100,7 @@ static int pnp_device_probe(struct device *dev)
99 return error; 100 return error;
100 } 101 }
101 } else if ((pnp_drv->flags & PNP_DRIVER_RES_DISABLE) 102 } else if ((pnp_drv->flags & PNP_DRIVER_RES_DISABLE)
102 == PNP_DRIVER_RES_DISABLE) { 103 == PNP_DRIVER_RES_DISABLE) {
103 error = pnp_disable_dev(pnp_dev); 104 error = pnp_disable_dev(pnp_dev);
104 if (error < 0) 105 if (error < 0)
105 return error; 106 return error;
@@ -110,22 +111,22 @@ static int pnp_device_probe(struct device *dev)
110 if (dev_id != NULL) 111 if (dev_id != NULL)
111 error = pnp_drv->probe(pnp_dev, dev_id); 112 error = pnp_drv->probe(pnp_dev, dev_id);
112 } 113 }
113 if (error >= 0){ 114 if (error >= 0) {
114 pnp_dev->driver = pnp_drv; 115 pnp_dev->driver = pnp_drv;
115 error = 0; 116 error = 0;
116 } else 117 } else
117 goto fail; 118 goto fail;
118 return error; 119 return error;
119 120
120fail: 121 fail:
121 pnp_device_detach(pnp_dev); 122 pnp_device_detach(pnp_dev);
122 return error; 123 return error;
123} 124}
124 125
125static int pnp_device_remove(struct device *dev) 126static int pnp_device_remove(struct device *dev)
126{ 127{
127 struct pnp_dev * pnp_dev = to_pnp_dev(dev); 128 struct pnp_dev *pnp_dev = to_pnp_dev(dev);
128 struct pnp_driver * drv = pnp_dev->driver; 129 struct pnp_driver *drv = pnp_dev->driver;
129 130
130 if (drv) { 131 if (drv) {
131 if (drv->remove) 132 if (drv->remove)
@@ -138,8 +139,9 @@ static int pnp_device_remove(struct device *dev)
138 139
139static int pnp_bus_match(struct device *dev, struct device_driver *drv) 140static int pnp_bus_match(struct device *dev, struct device_driver *drv)
140{ 141{
141 struct pnp_dev * pnp_dev = to_pnp_dev(dev); 142 struct pnp_dev *pnp_dev = to_pnp_dev(dev);
142 struct pnp_driver * pnp_drv = to_pnp_driver(drv); 143 struct pnp_driver *pnp_drv = to_pnp_driver(drv);
144
143 if (match_device(pnp_drv, pnp_dev) == NULL) 145 if (match_device(pnp_drv, pnp_dev) == NULL)
144 return 0; 146 return 0;
145 return 1; 147 return 1;
@@ -147,8 +149,8 @@ static int pnp_bus_match(struct device *dev, struct device_driver *drv)
147 149
148static int pnp_bus_suspend(struct device *dev, pm_message_t state) 150static int pnp_bus_suspend(struct device *dev, pm_message_t state)
149{ 151{
150 struct pnp_dev * pnp_dev = to_pnp_dev(dev); 152 struct pnp_dev *pnp_dev = to_pnp_dev(dev);
151 struct pnp_driver * pnp_drv = pnp_dev->driver; 153 struct pnp_driver *pnp_drv = pnp_dev->driver;
152 int error; 154 int error;
153 155
154 if (!pnp_drv) 156 if (!pnp_drv)
@@ -162,23 +164,28 @@ static int pnp_bus_suspend(struct device *dev, pm_message_t state)
162 164
163 if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE) && 165 if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE) &&
164 pnp_can_disable(pnp_dev)) { 166 pnp_can_disable(pnp_dev)) {
165 error = pnp_stop_dev(pnp_dev); 167 error = pnp_stop_dev(pnp_dev);
166 if (error) 168 if (error)
167 return error; 169 return error;
168 } 170 }
169 171
172 if (pnp_dev->protocol && pnp_dev->protocol->suspend)
173 pnp_dev->protocol->suspend(pnp_dev, state);
170 return 0; 174 return 0;
171} 175}
172 176
173static int pnp_bus_resume(struct device *dev) 177static int pnp_bus_resume(struct device *dev)
174{ 178{
175 struct pnp_dev * pnp_dev = to_pnp_dev(dev); 179 struct pnp_dev *pnp_dev = to_pnp_dev(dev);
176 struct pnp_driver * pnp_drv = pnp_dev->driver; 180 struct pnp_driver *pnp_drv = pnp_dev->driver;
177 int error; 181 int error;
178 182
179 if (!pnp_drv) 183 if (!pnp_drv)
180 return 0; 184 return 0;
181 185
186 if (pnp_dev->protocol && pnp_dev->protocol->resume)
187 pnp_dev->protocol->resume(pnp_dev);
188
182 if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)) { 189 if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)) {
183 error = pnp_start_dev(pnp_dev); 190 error = pnp_start_dev(pnp_dev);
184 if (error) 191 if (error)
@@ -192,12 +199,12 @@ static int pnp_bus_resume(struct device *dev)
192} 199}
193 200
194struct bus_type pnp_bus_type = { 201struct bus_type pnp_bus_type = {
195 .name = "pnp", 202 .name = "pnp",
196 .match = pnp_bus_match, 203 .match = pnp_bus_match,
197 .probe = pnp_device_probe, 204 .probe = pnp_device_probe,
198 .remove = pnp_device_remove, 205 .remove = pnp_device_remove,
199 .suspend = pnp_bus_suspend, 206 .suspend = pnp_bus_suspend,
200 .resume = pnp_bus_resume, 207 .resume = pnp_bus_resume,
201}; 208};
202 209
203int pnp_register_driver(struct pnp_driver *drv) 210int pnp_register_driver(struct pnp_driver *drv)
@@ -220,12 +227,11 @@ void pnp_unregister_driver(struct pnp_driver *drv)
220 * pnp_add_id - adds an EISA id to the specified device 227 * pnp_add_id - adds an EISA id to the specified device
221 * @id: pointer to a pnp_id structure 228 * @id: pointer to a pnp_id structure
222 * @dev: pointer to the desired device 229 * @dev: pointer to the desired device
223 *
224 */ 230 */
225
226int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) 231int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev)
227{ 232{
228 struct pnp_id *ptr; 233 struct pnp_id *ptr;
234
229 if (!id) 235 if (!id)
230 return -EINVAL; 236 return -EINVAL;
231 if (!dev) 237 if (!dev)
@@ -243,8 +249,5 @@ int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev)
243 249
244EXPORT_SYMBOL(pnp_register_driver); 250EXPORT_SYMBOL(pnp_register_driver);
245EXPORT_SYMBOL(pnp_unregister_driver); 251EXPORT_SYMBOL(pnp_unregister_driver);
246#if 0
247EXPORT_SYMBOL(pnp_add_id);
248#endif
249EXPORT_SYMBOL(pnp_device_attach); 252EXPORT_SYMBOL(pnp_device_attach);
250EXPORT_SYMBOL(pnp_device_detach); 253EXPORT_SYMBOL(pnp_device_detach);
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index ac9fcd499f3f..fe6684e13e82 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -3,7 +3,6 @@
3 * 3 *
4 * Some code, especially possible resource dumping is based on isapnp_proc.c (c) Jaroslav Kysela <perex@suse.cz> 4 * Some code, especially possible resource dumping is based on isapnp_proc.c (c) Jaroslav Kysela <perex@suse.cz>
5 * Copyright 2002 Adam Belay <ambx1@neo.rr.com> 5 * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
6 *
7 */ 6 */
8 7
9#include <linux/pnp.h> 8#include <linux/pnp.h>
@@ -29,7 +28,7 @@ struct pnp_info_buffer {
29 28
30typedef struct pnp_info_buffer pnp_info_buffer_t; 29typedef struct pnp_info_buffer pnp_info_buffer_t;
31 30
32static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt,...) 31static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt, ...)
33{ 32{
34 va_list args; 33 va_list args;
35 int res; 34 int res;
@@ -48,14 +47,18 @@ static int pnp_printf(pnp_info_buffer_t * buffer, char *fmt,...)
48 return res; 47 return res;
49} 48}
50 49
51static void pnp_print_port(pnp_info_buffer_t *buffer, char *space, struct pnp_port *port) 50static void pnp_print_port(pnp_info_buffer_t * buffer, char *space,
51 struct pnp_port *port)
52{ 52{
53 pnp_printf(buffer, "%sport 0x%x-0x%x, align 0x%x, size 0x%x, %i-bit address decoding\n", 53 pnp_printf(buffer,
54 space, port->min, port->max, port->align ? (port->align-1) : 0, port->size, 54 "%sport 0x%x-0x%x, align 0x%x, size 0x%x, %i-bit address decoding\n",
55 port->flags & PNP_PORT_FLAG_16BITADDR ? 16 : 10); 55 space, port->min, port->max,
56 port->align ? (port->align - 1) : 0, port->size,
57 port->flags & PNP_PORT_FLAG_16BITADDR ? 16 : 10);
56} 58}
57 59
58static void pnp_print_irq(pnp_info_buffer_t *buffer, char *space, struct pnp_irq *irq) 60static void pnp_print_irq(pnp_info_buffer_t * buffer, char *space,
61 struct pnp_irq *irq)
59{ 62{
60 int first = 1, i; 63 int first = 1, i;
61 64
@@ -85,14 +88,15 @@ static void pnp_print_irq(pnp_info_buffer_t *buffer, char *space, struct pnp_irq
85 pnp_printf(buffer, "\n"); 88 pnp_printf(buffer, "\n");
86} 89}
87 90
88static void pnp_print_dma(pnp_info_buffer_t *buffer, char *space, struct pnp_dma *dma) 91static void pnp_print_dma(pnp_info_buffer_t * buffer, char *space,
92 struct pnp_dma *dma)
89{ 93{
90 int first = 1, i; 94 int first = 1, i;
91 char *s; 95 char *s;
92 96
93 pnp_printf(buffer, "%sdma ", space); 97 pnp_printf(buffer, "%sdma ", space);
94 for (i = 0; i < 8; i++) 98 for (i = 0; i < 8; i++)
95 if (dma->map & (1<<i)) { 99 if (dma->map & (1 << i)) {
96 if (!first) { 100 if (!first) {
97 pnp_printf(buffer, ","); 101 pnp_printf(buffer, ",");
98 } else { 102 } else {
@@ -136,12 +140,13 @@ static void pnp_print_dma(pnp_info_buffer_t *buffer, char *space, struct pnp_dma
136 pnp_printf(buffer, " %s\n", s); 140 pnp_printf(buffer, " %s\n", s);
137} 141}
138 142
139static void pnp_print_mem(pnp_info_buffer_t *buffer, char *space, struct pnp_mem *mem) 143static void pnp_print_mem(pnp_info_buffer_t * buffer, char *space,
144 struct pnp_mem *mem)
140{ 145{
141 char *s; 146 char *s;
142 147
143 pnp_printf(buffer, "%sMemory 0x%x-0x%x, align 0x%x, size 0x%x", 148 pnp_printf(buffer, "%sMemory 0x%x-0x%x, align 0x%x, size 0x%x",
144 space, mem->min, mem->max, mem->align, mem->size); 149 space, mem->min, mem->max, mem->align, mem->size);
145 if (mem->flags & IORESOURCE_MEM_WRITEABLE) 150 if (mem->flags & IORESOURCE_MEM_WRITEABLE)
146 pnp_printf(buffer, ", writeable"); 151 pnp_printf(buffer, ", writeable");
147 if (mem->flags & IORESOURCE_MEM_CACHEABLE) 152 if (mem->flags & IORESOURCE_MEM_CACHEABLE)
@@ -168,7 +173,7 @@ static void pnp_print_mem(pnp_info_buffer_t *buffer, char *space, struct pnp_mem
168 pnp_printf(buffer, ", %s\n", s); 173 pnp_printf(buffer, ", %s\n", s);
169} 174}
170 175
171static void pnp_print_option(pnp_info_buffer_t *buffer, char *space, 176static void pnp_print_option(pnp_info_buffer_t * buffer, char *space,
172 struct pnp_option *option, int dep) 177 struct pnp_option *option, int dep)
173{ 178{
174 char *s; 179 char *s;
@@ -179,19 +184,19 @@ static void pnp_print_option(pnp_info_buffer_t *buffer, char *space,
179 184
180 if (dep) { 185 if (dep) {
181 switch (option->priority) { 186 switch (option->priority) {
182 case PNP_RES_PRIORITY_PREFERRED: 187 case PNP_RES_PRIORITY_PREFERRED:
183 s = "preferred"; 188 s = "preferred";
184 break; 189 break;
185 case PNP_RES_PRIORITY_ACCEPTABLE: 190 case PNP_RES_PRIORITY_ACCEPTABLE:
186 s = "acceptable"; 191 s = "acceptable";
187 break; 192 break;
188 case PNP_RES_PRIORITY_FUNCTIONAL: 193 case PNP_RES_PRIORITY_FUNCTIONAL:
189 s = "functional"; 194 s = "functional";
190 break; 195 break;
191 default: 196 default:
192 s = "invalid"; 197 s = "invalid";
193 } 198 }
194 pnp_printf(buffer, "Dependent: %02i - Priority %s\n",dep, s); 199 pnp_printf(buffer, "Dependent: %02i - Priority %s\n", dep, s);
195 } 200 }
196 201
197 for (port = option->port; port; port = port->next) 202 for (port = option->port; port; port = port->next)
@@ -204,16 +209,16 @@ static void pnp_print_option(pnp_info_buffer_t *buffer, char *space,
204 pnp_print_mem(buffer, space, mem); 209 pnp_print_mem(buffer, space, mem);
205} 210}
206 211
207 212static ssize_t pnp_show_options(struct device *dmdev,
208static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *attr, char *buf) 213 struct device_attribute *attr, char *buf)
209{ 214{
210 struct pnp_dev *dev = to_pnp_dev(dmdev); 215 struct pnp_dev *dev = to_pnp_dev(dmdev);
211 struct pnp_option * independent = dev->independent; 216 struct pnp_option *independent = dev->independent;
212 struct pnp_option * dependent = dev->dependent; 217 struct pnp_option *dependent = dev->dependent;
213 int ret, dep = 1; 218 int ret, dep = 1;
214 219
215 pnp_info_buffer_t *buffer = (pnp_info_buffer_t *) 220 pnp_info_buffer_t *buffer = (pnp_info_buffer_t *)
216 pnp_alloc(sizeof(pnp_info_buffer_t)); 221 pnp_alloc(sizeof(pnp_info_buffer_t));
217 if (!buffer) 222 if (!buffer)
218 return -ENOMEM; 223 return -ENOMEM;
219 224
@@ -223,7 +228,7 @@ static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *a
223 if (independent) 228 if (independent)
224 pnp_print_option(buffer, "", independent, 0); 229 pnp_print_option(buffer, "", independent, 0);
225 230
226 while (dependent){ 231 while (dependent) {
227 pnp_print_option(buffer, " ", dependent, dep); 232 pnp_print_option(buffer, " ", dependent, dep);
228 dependent = dependent->next; 233 dependent = dependent->next;
229 dep++; 234 dep++;
@@ -233,10 +238,11 @@ static ssize_t pnp_show_options(struct device *dmdev, struct device_attribute *a
233 return ret; 238 return ret;
234} 239}
235 240
236static DEVICE_ATTR(options,S_IRUGO,pnp_show_options,NULL); 241static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL);
237 242
238 243static ssize_t pnp_show_current_resources(struct device *dmdev,
239static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_attribute *attr, char *buf) 244 struct device_attribute *attr,
245 char *buf)
240{ 246{
241 struct pnp_dev *dev = to_pnp_dev(dmdev); 247 struct pnp_dev *dev = to_pnp_dev(dmdev);
242 int i, ret; 248 int i, ret;
@@ -252,52 +258,56 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_at
252 buffer->buffer = buf; 258 buffer->buffer = buf;
253 buffer->curr = buffer->buffer; 259 buffer->curr = buffer->buffer;
254 260
255 pnp_printf(buffer,"state = "); 261 pnp_printf(buffer, "state = ");
256 if (dev->active) 262 if (dev->active)
257 pnp_printf(buffer,"active\n"); 263 pnp_printf(buffer, "active\n");
258 else 264 else
259 pnp_printf(buffer,"disabled\n"); 265 pnp_printf(buffer, "disabled\n");
260 266
261 for (i = 0; i < PNP_MAX_PORT; i++) { 267 for (i = 0; i < PNP_MAX_PORT; i++) {
262 if (pnp_port_valid(dev, i)) { 268 if (pnp_port_valid(dev, i)) {
263 pnp_printf(buffer,"io"); 269 pnp_printf(buffer, "io");
264 if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED) 270 if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED)
265 pnp_printf(buffer," disabled\n"); 271 pnp_printf(buffer, " disabled\n");
266 else 272 else
267 pnp_printf(buffer," 0x%llx-0x%llx\n", 273 pnp_printf(buffer, " 0x%llx-0x%llx\n",
268 (unsigned long long)pnp_port_start(dev, i), 274 (unsigned long long)
269 (unsigned long long)pnp_port_end(dev, i)); 275 pnp_port_start(dev, i),
276 (unsigned long long)pnp_port_end(dev,
277 i));
270 } 278 }
271 } 279 }
272 for (i = 0; i < PNP_MAX_MEM; i++) { 280 for (i = 0; i < PNP_MAX_MEM; i++) {
273 if (pnp_mem_valid(dev, i)) { 281 if (pnp_mem_valid(dev, i)) {
274 pnp_printf(buffer,"mem"); 282 pnp_printf(buffer, "mem");
275 if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED) 283 if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED)
276 pnp_printf(buffer," disabled\n"); 284 pnp_printf(buffer, " disabled\n");
277 else 285 else
278 pnp_printf(buffer," 0x%llx-0x%llx\n", 286 pnp_printf(buffer, " 0x%llx-0x%llx\n",
279 (unsigned long long)pnp_mem_start(dev, i), 287 (unsigned long long)
280 (unsigned long long)pnp_mem_end(dev, i)); 288 pnp_mem_start(dev, i),
289 (unsigned long long)pnp_mem_end(dev,
290 i));
281 } 291 }
282 } 292 }
283 for (i = 0; i < PNP_MAX_IRQ; i++) { 293 for (i = 0; i < PNP_MAX_IRQ; i++) {
284 if (pnp_irq_valid(dev, i)) { 294 if (pnp_irq_valid(dev, i)) {
285 pnp_printf(buffer,"irq"); 295 pnp_printf(buffer, "irq");
286 if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED) 296 if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED)
287 pnp_printf(buffer," disabled\n"); 297 pnp_printf(buffer, " disabled\n");
288 else 298 else
289 pnp_printf(buffer," %lld\n", 299 pnp_printf(buffer, " %lld\n",
290 (unsigned long long)pnp_irq(dev, i)); 300 (unsigned long long)pnp_irq(dev, i));
291 } 301 }
292 } 302 }
293 for (i = 0; i < PNP_MAX_DMA; i++) { 303 for (i = 0; i < PNP_MAX_DMA; i++) {
294 if (pnp_dma_valid(dev, i)) { 304 if (pnp_dma_valid(dev, i)) {
295 pnp_printf(buffer,"dma"); 305 pnp_printf(buffer, "dma");
296 if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED) 306 if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED)
297 pnp_printf(buffer," disabled\n"); 307 pnp_printf(buffer, " disabled\n");
298 else 308 else
299 pnp_printf(buffer," %lld\n", 309 pnp_printf(buffer, " %lld\n",
300 (unsigned long long)pnp_dma(dev, i)); 310 (unsigned long long)pnp_dma(dev, i));
301 } 311 }
302 } 312 }
303 ret = (buffer->curr - buf); 313 ret = (buffer->curr - buf);
@@ -308,55 +318,57 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, struct device_at
308extern struct semaphore pnp_res_mutex; 318extern struct semaphore pnp_res_mutex;
309 319
310static ssize_t 320static ssize_t
311pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr, const char * ubuf, size_t count) 321pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
322 const char *ubuf, size_t count)
312{ 323{
313 struct pnp_dev *dev = to_pnp_dev(dmdev); 324 struct pnp_dev *dev = to_pnp_dev(dmdev);
314 char *buf = (void *)ubuf; 325 char *buf = (void *)ubuf;
315 int retval = 0; 326 int retval = 0;
316 327
317 if (dev->status & PNP_ATTACHED) { 328 if (dev->status & PNP_ATTACHED) {
318 retval = -EBUSY; 329 retval = -EBUSY;
319 pnp_info("Device %s cannot be configured because it is in use.", dev->dev.bus_id); 330 pnp_info("Device %s cannot be configured because it is in use.",
331 dev->dev.bus_id);
320 goto done; 332 goto done;
321 } 333 }
322 334
323 while (isspace(*buf)) 335 while (isspace(*buf))
324 ++buf; 336 ++buf;
325 if (!strnicmp(buf,"disable",7)) { 337 if (!strnicmp(buf, "disable", 7)) {
326 retval = pnp_disable_dev(dev); 338 retval = pnp_disable_dev(dev);
327 goto done; 339 goto done;
328 } 340 }
329 if (!strnicmp(buf,"activate",8)) { 341 if (!strnicmp(buf, "activate", 8)) {
330 retval = pnp_activate_dev(dev); 342 retval = pnp_activate_dev(dev);
331 goto done; 343 goto done;
332 } 344 }
333 if (!strnicmp(buf,"fill",4)) { 345 if (!strnicmp(buf, "fill", 4)) {
334 if (dev->active) 346 if (dev->active)
335 goto done; 347 goto done;
336 retval = pnp_auto_config_dev(dev); 348 retval = pnp_auto_config_dev(dev);
337 goto done; 349 goto done;
338 } 350 }
339 if (!strnicmp(buf,"auto",4)) { 351 if (!strnicmp(buf, "auto", 4)) {
340 if (dev->active) 352 if (dev->active)
341 goto done; 353 goto done;
342 pnp_init_resource_table(&dev->res); 354 pnp_init_resource_table(&dev->res);
343 retval = pnp_auto_config_dev(dev); 355 retval = pnp_auto_config_dev(dev);
344 goto done; 356 goto done;
345 } 357 }
346 if (!strnicmp(buf,"clear",5)) { 358 if (!strnicmp(buf, "clear", 5)) {
347 if (dev->active) 359 if (dev->active)
348 goto done; 360 goto done;
349 pnp_init_resource_table(&dev->res); 361 pnp_init_resource_table(&dev->res);
350 goto done; 362 goto done;
351 } 363 }
352 if (!strnicmp(buf,"get",3)) { 364 if (!strnicmp(buf, "get", 3)) {
353 down(&pnp_res_mutex); 365 down(&pnp_res_mutex);
354 if (pnp_can_read(dev)) 366 if (pnp_can_read(dev))
355 dev->protocol->get(dev, &dev->res); 367 dev->protocol->get(dev, &dev->res);
356 up(&pnp_res_mutex); 368 up(&pnp_res_mutex);
357 goto done; 369 goto done;
358 } 370 }
359 if (!strnicmp(buf,"set",3)) { 371 if (!strnicmp(buf, "set", 3)) {
360 int nport = 0, nmem = 0, nirq = 0, ndma = 0; 372 int nport = 0, nmem = 0, nirq = 0, ndma = 0;
361 if (dev->active) 373 if (dev->active)
362 goto done; 374 goto done;
@@ -366,65 +378,77 @@ pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr,
366 while (1) { 378 while (1) {
367 while (isspace(*buf)) 379 while (isspace(*buf))
368 ++buf; 380 ++buf;
369 if (!strnicmp(buf,"io",2)) { 381 if (!strnicmp(buf, "io", 2)) {
370 buf += 2; 382 buf += 2;
371 while (isspace(*buf)) 383 while (isspace(*buf))
372 ++buf; 384 ++buf;
373 dev->res.port_resource[nport].start = simple_strtoul(buf,&buf,0); 385 dev->res.port_resource[nport].start =
386 simple_strtoul(buf, &buf, 0);
374 while (isspace(*buf)) 387 while (isspace(*buf))
375 ++buf; 388 ++buf;
376 if(*buf == '-') { 389 if (*buf == '-') {
377 buf += 1; 390 buf += 1;
378 while (isspace(*buf)) 391 while (isspace(*buf))
379 ++buf; 392 ++buf;
380 dev->res.port_resource[nport].end = simple_strtoul(buf,&buf,0); 393 dev->res.port_resource[nport].end =
394 simple_strtoul(buf, &buf, 0);
381 } else 395 } else
382 dev->res.port_resource[nport].end = dev->res.port_resource[nport].start; 396 dev->res.port_resource[nport].end =
383 dev->res.port_resource[nport].flags = IORESOURCE_IO; 397 dev->res.port_resource[nport].start;
398 dev->res.port_resource[nport].flags =
399 IORESOURCE_IO;
384 nport++; 400 nport++;
385 if (nport >= PNP_MAX_PORT) 401 if (nport >= PNP_MAX_PORT)
386 break; 402 break;
387 continue; 403 continue;
388 } 404 }
389 if (!strnicmp(buf,"mem",3)) { 405 if (!strnicmp(buf, "mem", 3)) {
390 buf += 3; 406 buf += 3;
391 while (isspace(*buf)) 407 while (isspace(*buf))
392 ++buf; 408 ++buf;
393 dev->res.mem_resource[nmem].start = simple_strtoul(buf,&buf,0); 409 dev->res.mem_resource[nmem].start =
410 simple_strtoul(buf, &buf, 0);
394 while (isspace(*buf)) 411 while (isspace(*buf))
395 ++buf; 412 ++buf;
396 if(*buf == '-') { 413 if (*buf == '-') {
397 buf += 1; 414 buf += 1;
398 while (isspace(*buf)) 415 while (isspace(*buf))
399 ++buf; 416 ++buf;
400 dev->res.mem_resource[nmem].end = simple_strtoul(buf,&buf,0); 417 dev->res.mem_resource[nmem].end =
418 simple_strtoul(buf, &buf, 0);
401 } else 419 } else
402 dev->res.mem_resource[nmem].end = dev->res.mem_resource[nmem].start; 420 dev->res.mem_resource[nmem].end =
403 dev->res.mem_resource[nmem].flags = IORESOURCE_MEM; 421 dev->res.mem_resource[nmem].start;
422 dev->res.mem_resource[nmem].flags =
423 IORESOURCE_MEM;
404 nmem++; 424 nmem++;
405 if (nmem >= PNP_MAX_MEM) 425 if (nmem >= PNP_MAX_MEM)
406 break; 426 break;
407 continue; 427 continue;
408 } 428 }
409 if (!strnicmp(buf,"irq",3)) { 429 if (!strnicmp(buf, "irq", 3)) {
410 buf += 3; 430 buf += 3;
411 while (isspace(*buf)) 431 while (isspace(*buf))
412 ++buf; 432 ++buf;
413 dev->res.irq_resource[nirq].start = 433 dev->res.irq_resource[nirq].start =
414 dev->res.irq_resource[nirq].end = simple_strtoul(buf,&buf,0); 434 dev->res.irq_resource[nirq].end =
415 dev->res.irq_resource[nirq].flags = IORESOURCE_IRQ; 435 simple_strtoul(buf, &buf, 0);
436 dev->res.irq_resource[nirq].flags =
437 IORESOURCE_IRQ;
416 nirq++; 438 nirq++;
417 if (nirq >= PNP_MAX_IRQ) 439 if (nirq >= PNP_MAX_IRQ)
418 break; 440 break;
419 continue; 441 continue;
420 } 442 }
421 if (!strnicmp(buf,"dma",3)) { 443 if (!strnicmp(buf, "dma", 3)) {
422 buf += 3; 444 buf += 3;
423 while (isspace(*buf)) 445 while (isspace(*buf))
424 ++buf; 446 ++buf;
425 dev->res.dma_resource[ndma].start = 447 dev->res.dma_resource[ndma].start =
426 dev->res.dma_resource[ndma].end = simple_strtoul(buf,&buf,0); 448 dev->res.dma_resource[ndma].end =
427 dev->res.dma_resource[ndma].flags = IORESOURCE_DMA; 449 simple_strtoul(buf, &buf, 0);
450 dev->res.dma_resource[ndma].flags =
451 IORESOURCE_DMA;
428 ndma++; 452 ndma++;
429 if (ndma >= PNP_MAX_DMA) 453 if (ndma >= PNP_MAX_DMA)
430 break; 454 break;
@@ -435,45 +459,50 @@ pnp_set_current_resources(struct device * dmdev, struct device_attribute *attr,
435 up(&pnp_res_mutex); 459 up(&pnp_res_mutex);
436 goto done; 460 goto done;
437 } 461 }
438 done: 462 done:
439 if (retval < 0) 463 if (retval < 0)
440 return retval; 464 return retval;
441 return count; 465 return count;
442} 466}
443 467
444static DEVICE_ATTR(resources,S_IRUGO | S_IWUSR, 468static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR,
445 pnp_show_current_resources,pnp_set_current_resources); 469 pnp_show_current_resources, pnp_set_current_resources);
446 470
447static ssize_t pnp_show_current_ids(struct device *dmdev, struct device_attribute *attr, char *buf) 471static ssize_t pnp_show_current_ids(struct device *dmdev,
472 struct device_attribute *attr, char *buf)
448{ 473{
449 char *str = buf; 474 char *str = buf;
450 struct pnp_dev *dev = to_pnp_dev(dmdev); 475 struct pnp_dev *dev = to_pnp_dev(dmdev);
451 struct pnp_id * pos = dev->id; 476 struct pnp_id *pos = dev->id;
452 477
453 while (pos) { 478 while (pos) {
454 str += sprintf(str,"%s\n", pos->id); 479 str += sprintf(str, "%s\n", pos->id);
455 pos = pos->next; 480 pos = pos->next;
456 } 481 }
457 return (str - buf); 482 return (str - buf);
458} 483}
459 484
460static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL); 485static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL);
461 486
462int pnp_interface_attach_device(struct pnp_dev *dev) 487int pnp_interface_attach_device(struct pnp_dev *dev)
463{ 488{
464 int rc = device_create_file(&dev->dev,&dev_attr_options); 489 int rc = device_create_file(&dev->dev, &dev_attr_options);
465 if (rc) goto err; 490
466 rc = device_create_file(&dev->dev,&dev_attr_resources); 491 if (rc)
467 if (rc) goto err_opt; 492 goto err;
468 rc = device_create_file(&dev->dev,&dev_attr_id); 493 rc = device_create_file(&dev->dev, &dev_attr_resources);
469 if (rc) goto err_res; 494 if (rc)
495 goto err_opt;
496 rc = device_create_file(&dev->dev, &dev_attr_id);
497 if (rc)
498 goto err_res;
470 499
471 return 0; 500 return 0;
472 501
473err_res: 502 err_res:
474 device_remove_file(&dev->dev,&dev_attr_resources); 503 device_remove_file(&dev->dev, &dev_attr_resources);
475err_opt: 504 err_opt:
476 device_remove_file(&dev->dev,&dev_attr_options); 505 device_remove_file(&dev->dev, &dev_attr_options);
477err: 506 err:
478 return rc; 507 return rc;
479} 508}
diff --git a/drivers/pnp/isapnp/compat.c b/drivers/pnp/isapnp/compat.c
index 0697ab88a9ac..10bdcc4d4f7b 100644
--- a/drivers/pnp/isapnp/compat.c
+++ b/drivers/pnp/isapnp/compat.c
@@ -3,34 +3,30 @@
3 * the old isapnp APIs. If possible use the new APIs instead. 3 * the old isapnp APIs. If possible use the new APIs instead.
4 * 4 *
5 * Copyright 2002 Adam Belay <ambx1@neo.rr.com> 5 * Copyright 2002 Adam Belay <ambx1@neo.rr.com>
6 *
7 */ 6 */
8
9/* TODO: see if more isapnp functions are needed here */
10 7
11#include <linux/module.h> 8#include <linux/module.h>
12#include <linux/isapnp.h> 9#include <linux/isapnp.h>
13#include <linux/string.h> 10#include <linux/string.h>
14 11
15static void pnp_convert_id(char *buf, unsigned short vendor, unsigned short device) 12static void pnp_convert_id(char *buf, unsigned short vendor,
13 unsigned short device)
16{ 14{
17 sprintf(buf, "%c%c%c%x%x%x%x", 15 sprintf(buf, "%c%c%c%x%x%x%x",
18 'A' + ((vendor >> 2) & 0x3f) - 1, 16 'A' + ((vendor >> 2) & 0x3f) - 1,
19 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, 17 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
20 'A' + ((vendor >> 8) & 0x1f) - 1, 18 'A' + ((vendor >> 8) & 0x1f) - 1,
21 (device >> 4) & 0x0f, 19 (device >> 4) & 0x0f, device & 0x0f,
22 device & 0x0f, 20 (device >> 12) & 0x0f, (device >> 8) & 0x0f);
23 (device >> 12) & 0x0f,
24 (device >> 8) & 0x0f);
25} 21}
26 22
27struct pnp_card *pnp_find_card(unsigned short vendor, 23struct pnp_card *pnp_find_card(unsigned short vendor, unsigned short device,
28 unsigned short device,
29 struct pnp_card *from) 24 struct pnp_card *from)
30{ 25{
31 char id[8]; 26 char id[8];
32 char any[8]; 27 char any[8];
33 struct list_head *list; 28 struct list_head *list;
29
34 pnp_convert_id(id, vendor, device); 30 pnp_convert_id(id, vendor, device);
35 pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID); 31 pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
36 32
@@ -38,20 +34,20 @@ struct pnp_card *pnp_find_card(unsigned short vendor,
38 34
39 while (list != &pnp_cards) { 35 while (list != &pnp_cards) {
40 struct pnp_card *card = global_to_pnp_card(list); 36 struct pnp_card *card = global_to_pnp_card(list);
41 if (compare_pnp_id(card->id,id) || (memcmp(id,any,7)==0)) 37
38 if (compare_pnp_id(card->id, id) || (memcmp(id, any, 7) == 0))
42 return card; 39 return card;
43 list = list->next; 40 list = list->next;
44 } 41 }
45 return NULL; 42 return NULL;
46} 43}
47 44
48struct pnp_dev *pnp_find_dev(struct pnp_card *card, 45struct pnp_dev *pnp_find_dev(struct pnp_card *card, unsigned short vendor,
49 unsigned short vendor, 46 unsigned short function, struct pnp_dev *from)
50 unsigned short function,
51 struct pnp_dev *from)
52{ 47{
53 char id[8]; 48 char id[8];
54 char any[8]; 49 char any[8];
50
55 pnp_convert_id(id, vendor, function); 51 pnp_convert_id(id, vendor, function);
56 pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID); 52 pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
57 if (card == NULL) { /* look for a logical device from all cards */ 53 if (card == NULL) { /* look for a logical device from all cards */
@@ -63,7 +59,9 @@ struct pnp_dev *pnp_find_dev(struct pnp_card *card,
63 59
64 while (list != &pnp_global) { 60 while (list != &pnp_global) {
65 struct pnp_dev *dev = global_to_pnp_dev(list); 61 struct pnp_dev *dev = global_to_pnp_dev(list);
66 if (compare_pnp_id(dev->id,id) || (memcmp(id,any,7)==0)) 62
63 if (compare_pnp_id(dev->id, id) ||
64 (memcmp(id, any, 7) == 0))
67 return dev; 65 return dev;
68 list = list->next; 66 list = list->next;
69 } 67 }
@@ -78,7 +76,8 @@ struct pnp_dev *pnp_find_dev(struct pnp_card *card,
78 } 76 }
79 while (list != &card->devices) { 77 while (list != &card->devices) {
80 struct pnp_dev *dev = card_to_pnp_dev(list); 78 struct pnp_dev *dev = card_to_pnp_dev(list);
81 if (compare_pnp_id(dev->id,id)) 79
80 if (compare_pnp_id(dev->id, id))
82 return dev; 81 return dev;
83 list = list->next; 82 list = list->next;
84 } 83 }
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index 914d00c423ad..b4e2aa995b53 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -51,10 +51,10 @@
51#define ISAPNP_DEBUG 51#define ISAPNP_DEBUG
52#endif 52#endif
53 53
54int isapnp_disable; /* Disable ISA PnP */ 54int isapnp_disable; /* Disable ISA PnP */
55static int isapnp_rdp; /* Read Data Port */ 55static int isapnp_rdp; /* Read Data Port */
56static int isapnp_reset = 1; /* reset all PnP cards (deactivate) */ 56static int isapnp_reset = 1; /* reset all PnP cards (deactivate) */
57static int isapnp_verbose = 1; /* verbose mode */ 57static int isapnp_verbose = 1; /* verbose mode */
58 58
59MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); 59MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
60MODULE_DESCRIPTION("Generic ISA Plug & Play support"); 60MODULE_DESCRIPTION("Generic ISA Plug & Play support");
@@ -126,7 +126,7 @@ static unsigned short isapnp_read_word(unsigned char idx)
126 unsigned short val; 126 unsigned short val;
127 127
128 val = isapnp_read_byte(idx); 128 val = isapnp_read_byte(idx);
129 val = (val << 8) + isapnp_read_byte(idx+1); 129 val = (val << 8) + isapnp_read_byte(idx + 1);
130 return val; 130 return val;
131} 131}
132 132
@@ -139,7 +139,7 @@ void isapnp_write_byte(unsigned char idx, unsigned char val)
139static void isapnp_write_word(unsigned char idx, unsigned short val) 139static void isapnp_write_word(unsigned char idx, unsigned short val)
140{ 140{
141 isapnp_write_byte(idx, val >> 8); 141 isapnp_write_byte(idx, val >> 8);
142 isapnp_write_byte(idx+1, val); 142 isapnp_write_byte(idx + 1, val);
143} 143}
144 144
145static void isapnp_key(void) 145static void isapnp_key(void)
@@ -193,7 +193,7 @@ static void isapnp_deactivate(unsigned char logdev)
193static void __init isapnp_peek(unsigned char *data, int bytes) 193static void __init isapnp_peek(unsigned char *data, int bytes)
194{ 194{
195 int i, j; 195 int i, j;
196 unsigned char d=0; 196 unsigned char d = 0;
197 197
198 for (i = 1; i <= bytes; i++) { 198 for (i = 1; i <= bytes; i++) {
199 for (j = 0; j < 20; j++) { 199 for (j = 0; j < 20; j++) {
@@ -220,19 +220,18 @@ static int isapnp_next_rdp(void)
220{ 220{
221 int rdp = isapnp_rdp; 221 int rdp = isapnp_rdp;
222 static int old_rdp = 0; 222 static int old_rdp = 0;
223 223
224 if(old_rdp) 224 if (old_rdp) {
225 {
226 release_region(old_rdp, 1); 225 release_region(old_rdp, 1);
227 old_rdp = 0; 226 old_rdp = 0;
228 } 227 }
229 while (rdp <= 0x3ff) { 228 while (rdp <= 0x3ff) {
230 /* 229 /*
231 * We cannot use NE2000 probe spaces for ISAPnP or we 230 * We cannot use NE2000 probe spaces for ISAPnP or we
232 * will lock up machines. 231 * will lock up machines.
233 */ 232 */
234 if ((rdp < 0x280 || rdp > 0x380) && request_region(rdp, 1, "ISAPnP")) 233 if ((rdp < 0x280 || rdp > 0x380)
235 { 234 && request_region(rdp, 1, "ISAPnP")) {
236 isapnp_rdp = rdp; 235 isapnp_rdp = rdp;
237 old_rdp = rdp; 236 old_rdp = rdp;
238 return 0; 237 return 0;
@@ -253,7 +252,6 @@ static inline void isapnp_set_rdp(void)
253 * Perform an isolation. The port selection code now tries to avoid 252 * Perform an isolation. The port selection code now tries to avoid
254 * "dangerous to read" ports. 253 * "dangerous to read" ports.
255 */ 254 */
256
257static int __init isapnp_isolate_rdp_select(void) 255static int __init isapnp_isolate_rdp_select(void)
258{ 256{
259 isapnp_wait(); 257 isapnp_wait();
@@ -282,7 +280,6 @@ static int __init isapnp_isolate_rdp_select(void)
282/* 280/*
283 * Isolate (assign uniqued CSN) to all ISA PnP devices. 281 * Isolate (assign uniqued CSN) to all ISA PnP devices.
284 */ 282 */
285
286static int __init isapnp_isolate(void) 283static int __init isapnp_isolate(void)
287{ 284{
288 unsigned char checksum = 0x6a; 285 unsigned char checksum = 0x6a;
@@ -305,7 +302,9 @@ static int __init isapnp_isolate(void)
305 udelay(250); 302 udelay(250);
306 if (data == 0x55aa) 303 if (data == 0x55aa)
307 bit = 0x01; 304 bit = 0x01;
308 checksum = ((((checksum ^ (checksum >> 1)) & 0x01) ^ bit) << 7) | (checksum >> 1); 305 checksum =
306 ((((checksum ^ (checksum >> 1)) & 0x01) ^ bit) << 7)
307 | (checksum >> 1);
309 bit = 0x00; 308 bit = 0x00;
310 } 309 }
311 for (i = 65; i <= 72; i++) { 310 for (i = 65; i <= 72; i++) {
@@ -351,13 +350,12 @@ static int __init isapnp_isolate(void)
351/* 350/*
352 * Read one tag from stream. 351 * Read one tag from stream.
353 */ 352 */
354
355static int __init isapnp_read_tag(unsigned char *type, unsigned short *size) 353static int __init isapnp_read_tag(unsigned char *type, unsigned short *size)
356{ 354{
357 unsigned char tag, tmp[2]; 355 unsigned char tag, tmp[2];
358 356
359 isapnp_peek(&tag, 1); 357 isapnp_peek(&tag, 1);
360 if (tag == 0) /* invalid tag */ 358 if (tag == 0) /* invalid tag */
361 return -1; 359 return -1;
362 if (tag & 0x80) { /* large item */ 360 if (tag & 0x80) { /* large item */
363 *type = tag; 361 *type = tag;
@@ -368,7 +366,8 @@ static int __init isapnp_read_tag(unsigned char *type, unsigned short *size)
368 *size = tag & 0x07; 366 *size = tag & 0x07;
369 } 367 }
370#if 0 368#if 0
371 printk(KERN_DEBUG "tag = 0x%x, type = 0x%x, size = %i\n", tag, *type, *size); 369 printk(KERN_DEBUG "tag = 0x%x, type = 0x%x, size = %i\n", tag, *type,
370 *size);
372#endif 371#endif
373 if (*type == 0xff && *size == 0xffff) /* probably invalid data */ 372 if (*type == 0xff && *size == 0xffff) /* probably invalid data */
374 return -1; 373 return -1;
@@ -378,7 +377,6 @@ static int __init isapnp_read_tag(unsigned char *type, unsigned short *size)
378/* 377/*
379 * Skip specified number of bytes from stream. 378 * Skip specified number of bytes from stream.
380 */ 379 */
381
382static void __init isapnp_skip_bytes(int count) 380static void __init isapnp_skip_bytes(int count)
383{ 381{
384 isapnp_peek(NULL, count); 382 isapnp_peek(NULL, count);
@@ -387,31 +385,30 @@ static void __init isapnp_skip_bytes(int count)
387/* 385/*
388 * Parse EISA id. 386 * Parse EISA id.
389 */ 387 */
390 388static void isapnp_parse_id(struct pnp_dev *dev, unsigned short vendor,
391static void isapnp_parse_id(struct pnp_dev * dev, unsigned short vendor, unsigned short device) 389 unsigned short device)
392{ 390{
393 struct pnp_id * id; 391 struct pnp_id *id;
392
394 if (!dev) 393 if (!dev)
395 return; 394 return;
396 id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); 395 id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
397 if (!id) 396 if (!id)
398 return; 397 return;
399 sprintf(id->id, "%c%c%c%x%x%x%x", 398 sprintf(id->id, "%c%c%c%x%x%x%x",
400 'A' + ((vendor >> 2) & 0x3f) - 1, 399 'A' + ((vendor >> 2) & 0x3f) - 1,
401 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, 400 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
402 'A' + ((vendor >> 8) & 0x1f) - 1, 401 'A' + ((vendor >> 8) & 0x1f) - 1,
403 (device >> 4) & 0x0f, 402 (device >> 4) & 0x0f,
404 device & 0x0f, 403 device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f);
405 (device >> 12) & 0x0f,
406 (device >> 8) & 0x0f);
407 pnp_add_id(id, dev); 404 pnp_add_id(id, dev);
408} 405}
409 406
410/* 407/*
411 * Parse logical device tag. 408 * Parse logical device tag.
412 */ 409 */
413 410static struct pnp_dev *__init isapnp_parse_device(struct pnp_card *card,
414static struct pnp_dev * __init isapnp_parse_device(struct pnp_card *card, int size, int number) 411 int size, int number)
415{ 412{
416 unsigned char tmp[6]; 413 unsigned char tmp[6];
417 struct pnp_dev *dev; 414 struct pnp_dev *dev;
@@ -435,13 +432,11 @@ static struct pnp_dev * __init isapnp_parse_device(struct pnp_card *card, int si
435 return dev; 432 return dev;
436} 433}
437 434
438
439/* 435/*
440 * Add IRQ resource to resources list. 436 * Add IRQ resource to resources list.
441 */ 437 */
442
443static void __init isapnp_parse_irq_resource(struct pnp_option *option, 438static void __init isapnp_parse_irq_resource(struct pnp_option *option,
444 int size) 439 int size)
445{ 440{
446 unsigned char tmp[3]; 441 unsigned char tmp[3];
447 struct pnp_irq *irq; 442 struct pnp_irq *irq;
@@ -458,15 +453,13 @@ static void __init isapnp_parse_irq_resource(struct pnp_option *option,
458 else 453 else
459 irq->flags = IORESOURCE_IRQ_HIGHEDGE; 454 irq->flags = IORESOURCE_IRQ_HIGHEDGE;
460 pnp_register_irq_resource(option, irq); 455 pnp_register_irq_resource(option, irq);
461 return;
462} 456}
463 457
464/* 458/*
465 * Add DMA resource to resources list. 459 * Add DMA resource to resources list.
466 */ 460 */
467
468static void __init isapnp_parse_dma_resource(struct pnp_option *option, 461static void __init isapnp_parse_dma_resource(struct pnp_option *option,
469 int size) 462 int size)
470{ 463{
471 unsigned char tmp[2]; 464 unsigned char tmp[2];
472 struct pnp_dma *dma; 465 struct pnp_dma *dma;
@@ -478,15 +471,13 @@ static void __init isapnp_parse_dma_resource(struct pnp_option *option,
478 dma->map = tmp[0]; 471 dma->map = tmp[0];
479 dma->flags = tmp[1]; 472 dma->flags = tmp[1];
480 pnp_register_dma_resource(option, dma); 473 pnp_register_dma_resource(option, dma);
481 return;
482} 474}
483 475
484/* 476/*
485 * Add port resource to resources list. 477 * Add port resource to resources list.
486 */ 478 */
487
488static void __init isapnp_parse_port_resource(struct pnp_option *option, 479static void __init isapnp_parse_port_resource(struct pnp_option *option,
489 int size) 480 int size)
490{ 481{
491 unsigned char tmp[7]; 482 unsigned char tmp[7];
492 struct pnp_port *port; 483 struct pnp_port *port;
@@ -500,16 +491,14 @@ static void __init isapnp_parse_port_resource(struct pnp_option *option,
500 port->align = tmp[5]; 491 port->align = tmp[5];
501 port->size = tmp[6]; 492 port->size = tmp[6];
502 port->flags = tmp[0] ? PNP_PORT_FLAG_16BITADDR : 0; 493 port->flags = tmp[0] ? PNP_PORT_FLAG_16BITADDR : 0;
503 pnp_register_port_resource(option,port); 494 pnp_register_port_resource(option, port);
504 return;
505} 495}
506 496
507/* 497/*
508 * Add fixed port resource to resources list. 498 * Add fixed port resource to resources list.
509 */ 499 */
510
511static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option, 500static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option,
512 int size) 501 int size)
513{ 502{
514 unsigned char tmp[3]; 503 unsigned char tmp[3];
515 struct pnp_port *port; 504 struct pnp_port *port;
@@ -522,16 +511,14 @@ static void __init isapnp_parse_fixed_port_resource(struct pnp_option *option,
522 port->size = tmp[2]; 511 port->size = tmp[2];
523 port->align = 0; 512 port->align = 0;
524 port->flags = PNP_PORT_FLAG_FIXED; 513 port->flags = PNP_PORT_FLAG_FIXED;
525 pnp_register_port_resource(option,port); 514 pnp_register_port_resource(option, port);
526 return;
527} 515}
528 516
529/* 517/*
530 * Add memory resource to resources list. 518 * Add memory resource to resources list.
531 */ 519 */
532
533static void __init isapnp_parse_mem_resource(struct pnp_option *option, 520static void __init isapnp_parse_mem_resource(struct pnp_option *option,
534 int size) 521 int size)
535{ 522{
536 unsigned char tmp[9]; 523 unsigned char tmp[9];
537 struct pnp_mem *mem; 524 struct pnp_mem *mem;
@@ -545,16 +532,14 @@ static void __init isapnp_parse_mem_resource(struct pnp_option *option,
545 mem->align = (tmp[6] << 8) | tmp[5]; 532 mem->align = (tmp[6] << 8) | tmp[5];
546 mem->size = ((tmp[8] << 8) | tmp[7]) << 8; 533 mem->size = ((tmp[8] << 8) | tmp[7]) << 8;
547 mem->flags = tmp[0]; 534 mem->flags = tmp[0];
548 pnp_register_mem_resource(option,mem); 535 pnp_register_mem_resource(option, mem);
549 return;
550} 536}
551 537
552/* 538/*
553 * Add 32-bit memory resource to resources list. 539 * Add 32-bit memory resource to resources list.
554 */ 540 */
555
556static void __init isapnp_parse_mem32_resource(struct pnp_option *option, 541static void __init isapnp_parse_mem32_resource(struct pnp_option *option,
557 int size) 542 int size)
558{ 543{
559 unsigned char tmp[17]; 544 unsigned char tmp[17];
560 struct pnp_mem *mem; 545 struct pnp_mem *mem;
@@ -565,18 +550,19 @@ static void __init isapnp_parse_mem32_resource(struct pnp_option *option,
565 return; 550 return;
566 mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; 551 mem->min = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
567 mem->max = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5]; 552 mem->max = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5];
568 mem->align = (tmp[12] << 24) | (tmp[11] << 16) | (tmp[10] << 8) | tmp[9]; 553 mem->align =
569 mem->size = (tmp[16] << 24) | (tmp[15] << 16) | (tmp[14] << 8) | tmp[13]; 554 (tmp[12] << 24) | (tmp[11] << 16) | (tmp[10] << 8) | tmp[9];
555 mem->size =
556 (tmp[16] << 24) | (tmp[15] << 16) | (tmp[14] << 8) | tmp[13];
570 mem->flags = tmp[0]; 557 mem->flags = tmp[0];
571 pnp_register_mem_resource(option,mem); 558 pnp_register_mem_resource(option, mem);
572} 559}
573 560
574/* 561/*
575 * Add 32-bit fixed memory resource to resources list. 562 * Add 32-bit fixed memory resource to resources list.
576 */ 563 */
577
578static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option, 564static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option,
579 int size) 565 int size)
580{ 566{
581 unsigned char tmp[9]; 567 unsigned char tmp[9];
582 struct pnp_mem *mem; 568 struct pnp_mem *mem;
@@ -585,28 +571,29 @@ static void __init isapnp_parse_fixed_mem32_resource(struct pnp_option *option,
585 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 571 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
586 if (!mem) 572 if (!mem)
587 return; 573 return;
588 mem->min = mem->max = (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1]; 574 mem->min = mem->max =
575 (tmp[4] << 24) | (tmp[3] << 16) | (tmp[2] << 8) | tmp[1];
589 mem->size = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5]; 576 mem->size = (tmp[8] << 24) | (tmp[7] << 16) | (tmp[6] << 8) | tmp[5];
590 mem->align = 0; 577 mem->align = 0;
591 mem->flags = tmp[0]; 578 mem->flags = tmp[0];
592 pnp_register_mem_resource(option,mem); 579 pnp_register_mem_resource(option, mem);
593} 580}
594 581
595/* 582/*
596 * Parse card name for ISA PnP device. 583 * Parse card name for ISA PnP device.
597 */ 584 */
598
599static void __init 585static void __init
600isapnp_parse_name(char *name, unsigned int name_max, unsigned short *size) 586isapnp_parse_name(char *name, unsigned int name_max, unsigned short *size)
601{ 587{
602 if (name[0] == '\0') { 588 if (name[0] == '\0') {
603 unsigned short size1 = *size >= name_max ? (name_max - 1) : *size; 589 unsigned short size1 =
590 *size >= name_max ? (name_max - 1) : *size;
604 isapnp_peek(name, size1); 591 isapnp_peek(name, size1);
605 name[size1] = '\0'; 592 name[size1] = '\0';
606 *size -= size1; 593 *size -= size1;
607 594
608 /* clean whitespace from end of string */ 595 /* clean whitespace from end of string */
609 while (size1 > 0 && name[--size1] == ' ') 596 while (size1 > 0 && name[--size1] == ' ')
610 name[size1] = '\0'; 597 name[size1] = '\0';
611 } 598 }
612} 599}
@@ -614,7 +601,6 @@ isapnp_parse_name(char *name, unsigned int name_max, unsigned short *size)
614/* 601/*
615 * Parse resource map for logical device. 602 * Parse resource map for logical device.
616 */ 603 */
617
618static int __init isapnp_create_device(struct pnp_card *card, 604static int __init isapnp_create_device(struct pnp_card *card,
619 unsigned short size) 605 unsigned short size)
620{ 606{
@@ -622,6 +608,7 @@ static int __init isapnp_create_device(struct pnp_card *card,
622 unsigned char type, tmp[17]; 608 unsigned char type, tmp[17];
623 struct pnp_option *option; 609 struct pnp_option *option;
624 struct pnp_dev *dev; 610 struct pnp_dev *dev;
611
625 if ((dev = isapnp_parse_device(card, size, number++)) == NULL) 612 if ((dev = isapnp_parse_device(card, size, number++)) == NULL)
626 return 1; 613 return 1;
627 option = pnp_register_independent_option(dev); 614 option = pnp_register_independent_option(dev);
@@ -629,17 +616,19 @@ static int __init isapnp_create_device(struct pnp_card *card,
629 kfree(dev); 616 kfree(dev);
630 return 1; 617 return 1;
631 } 618 }
632 pnp_add_card_device(card,dev); 619 pnp_add_card_device(card, dev);
633 620
634 while (1) { 621 while (1) {
635 if (isapnp_read_tag(&type, &size)<0) 622 if (isapnp_read_tag(&type, &size) < 0)
636 return 1; 623 return 1;
637 if (skip && type != _STAG_LOGDEVID && type != _STAG_END) 624 if (skip && type != _STAG_LOGDEVID && type != _STAG_END)
638 goto __skip; 625 goto __skip;
639 switch (type) { 626 switch (type) {
640 case _STAG_LOGDEVID: 627 case _STAG_LOGDEVID:
641 if (size >= 5 && size <= 6) { 628 if (size >= 5 && size <= 6) {
642 if ((dev = isapnp_parse_device(card, size, number++)) == NULL) 629 if ((dev =
630 isapnp_parse_device(card, size,
631 number++)) == NULL)
643 return 1; 632 return 1;
644 size = 0; 633 size = 0;
645 skip = 0; 634 skip = 0;
@@ -648,7 +637,7 @@ static int __init isapnp_create_device(struct pnp_card *card,
648 kfree(dev); 637 kfree(dev);
649 return 1; 638 return 1;
650 } 639 }
651 pnp_add_card_device(card,dev); 640 pnp_add_card_device(card, dev);
652 } else { 641 } else {
653 skip = 1; 642 skip = 1;
654 } 643 }
@@ -658,7 +647,8 @@ static int __init isapnp_create_device(struct pnp_card *card,
658 case _STAG_COMPATDEVID: 647 case _STAG_COMPATDEVID:
659 if (size == 4 && compat < DEVICE_COUNT_COMPATIBLE) { 648 if (size == 4 && compat < DEVICE_COUNT_COMPATIBLE) {
660 isapnp_peek(tmp, 4); 649 isapnp_peek(tmp, 4);
661 isapnp_parse_id(dev,(tmp[1] << 8) | tmp[0], (tmp[3] << 8) | tmp[2]); 650 isapnp_parse_id(dev, (tmp[1] << 8) | tmp[0],
651 (tmp[3] << 8) | tmp[2]);
662 compat++; 652 compat++;
663 size = 0; 653 size = 0;
664 } 654 }
@@ -684,7 +674,7 @@ static int __init isapnp_create_device(struct pnp_card *card,
684 priority = 0x100 | tmp[0]; 674 priority = 0x100 | tmp[0];
685 size = 0; 675 size = 0;
686 } 676 }
687 option = pnp_register_dependent_option(dev,priority); 677 option = pnp_register_dependent_option(dev, priority);
688 if (!option) 678 if (!option)
689 return 1; 679 return 1;
690 break; 680 break;
@@ -739,11 +729,13 @@ static int __init isapnp_create_device(struct pnp_card *card,
739 isapnp_skip_bytes(size); 729 isapnp_skip_bytes(size);
740 return 1; 730 return 1;
741 default: 731 default:
742 printk(KERN_ERR "isapnp: unexpected or unknown tag type 0x%x for logical device %i (device %i), ignored\n", type, dev->number, card->number); 732 printk(KERN_ERR
733 "isapnp: unexpected or unknown tag type 0x%x for logical device %i (device %i), ignored\n",
734 type, dev->number, card->number);
743 } 735 }
744 __skip: 736 __skip:
745 if (size > 0) 737 if (size > 0)
746 isapnp_skip_bytes(size); 738 isapnp_skip_bytes(size);
747 } 739 }
748 return 0; 740 return 0;
749} 741}
@@ -751,14 +743,13 @@ static int __init isapnp_create_device(struct pnp_card *card,
751/* 743/*
752 * Parse resource map for ISA PnP card. 744 * Parse resource map for ISA PnP card.
753 */ 745 */
754
755static void __init isapnp_parse_resource_map(struct pnp_card *card) 746static void __init isapnp_parse_resource_map(struct pnp_card *card)
756{ 747{
757 unsigned char type, tmp[17]; 748 unsigned char type, tmp[17];
758 unsigned short size; 749 unsigned short size;
759 750
760 while (1) { 751 while (1) {
761 if (isapnp_read_tag(&type, &size)<0) 752 if (isapnp_read_tag(&type, &size) < 0)
762 return; 753 return;
763 switch (type) { 754 switch (type) {
764 case _STAG_PNPVERNO: 755 case _STAG_PNPVERNO:
@@ -771,7 +762,7 @@ static void __init isapnp_parse_resource_map(struct pnp_card *card)
771 break; 762 break;
772 case _STAG_LOGDEVID: 763 case _STAG_LOGDEVID:
773 if (size >= 5 && size <= 6) { 764 if (size >= 5 && size <= 6) {
774 if (isapnp_create_device(card, size)==1) 765 if (isapnp_create_device(card, size) == 1)
775 return; 766 return;
776 size = 0; 767 size = 0;
777 } 768 }
@@ -779,7 +770,8 @@ static void __init isapnp_parse_resource_map(struct pnp_card *card)
779 case _STAG_VENDOR: 770 case _STAG_VENDOR:
780 break; 771 break;
781 case _LTAG_ANSISTR: 772 case _LTAG_ANSISTR:
782 isapnp_parse_name(card->name, sizeof(card->name), &size); 773 isapnp_parse_name(card->name, sizeof(card->name),
774 &size);
783 break; 775 break;
784 case _LTAG_UNICODESTR: 776 case _LTAG_UNICODESTR:
785 /* silently ignore */ 777 /* silently ignore */
@@ -792,18 +784,19 @@ static void __init isapnp_parse_resource_map(struct pnp_card *card)
792 isapnp_skip_bytes(size); 784 isapnp_skip_bytes(size);
793 return; 785 return;
794 default: 786 default:
795 printk(KERN_ERR "isapnp: unexpected or unknown tag type 0x%x for device %i, ignored\n", type, card->number); 787 printk(KERN_ERR
788 "isapnp: unexpected or unknown tag type 0x%x for device %i, ignored\n",
789 type, card->number);
796 } 790 }
797 __skip: 791 __skip:
798 if (size > 0) 792 if (size > 0)
799 isapnp_skip_bytes(size); 793 isapnp_skip_bytes(size);
800 } 794 }
801} 795}
802 796
803/* 797/*
804 * Compute ISA PnP checksum for first eight bytes. 798 * Compute ISA PnP checksum for first eight bytes.
805 */ 799 */
806
807static unsigned char __init isapnp_checksum(unsigned char *data) 800static unsigned char __init isapnp_checksum(unsigned char *data)
808{ 801{
809 int i, j; 802 int i, j;
@@ -815,7 +808,9 @@ static unsigned char __init isapnp_checksum(unsigned char *data)
815 bit = 0; 808 bit = 0;
816 if (b & (1 << j)) 809 if (b & (1 << j))
817 bit = 1; 810 bit = 1;
818 checksum = ((((checksum ^ (checksum >> 1)) & 0x01) ^ bit) << 7) | (checksum >> 1); 811 checksum =
812 ((((checksum ^ (checksum >> 1)) & 0x01) ^ bit) << 7)
813 | (checksum >> 1);
819 } 814 }
820 } 815 }
821 return checksum; 816 return checksum;
@@ -824,27 +819,25 @@ static unsigned char __init isapnp_checksum(unsigned char *data)
824/* 819/*
825 * Parse EISA id for ISA PnP card. 820 * Parse EISA id for ISA PnP card.
826 */ 821 */
827 822static void isapnp_parse_card_id(struct pnp_card *card, unsigned short vendor,
828static void isapnp_parse_card_id(struct pnp_card * card, unsigned short vendor, unsigned short device) 823 unsigned short device)
829{ 824{
830 struct pnp_id * id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); 825 struct pnp_id *id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
826
831 if (!id) 827 if (!id)
832 return; 828 return;
833 sprintf(id->id, "%c%c%c%x%x%x%x", 829 sprintf(id->id, "%c%c%c%x%x%x%x",
834 'A' + ((vendor >> 2) & 0x3f) - 1, 830 'A' + ((vendor >> 2) & 0x3f) - 1,
835 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1, 831 'A' + (((vendor & 3) << 3) | ((vendor >> 13) & 7)) - 1,
836 'A' + ((vendor >> 8) & 0x1f) - 1, 832 'A' + ((vendor >> 8) & 0x1f) - 1,
837 (device >> 4) & 0x0f, 833 (device >> 4) & 0x0f,
838 device & 0x0f, 834 device & 0x0f, (device >> 12) & 0x0f, (device >> 8) & 0x0f);
839 (device >> 12) & 0x0f, 835 pnp_add_card_id(id, card);
840 (device >> 8) & 0x0f);
841 pnp_add_card_id(id,card);
842} 836}
843 837
844/* 838/*
845 * Build device list for all present ISA PnP devices. 839 * Build device list for all present ISA PnP devices.
846 */ 840 */
847
848static int __init isapnp_build_device_list(void) 841static int __init isapnp_build_device_list(void)
849{ 842{
850 int csn; 843 int csn;
@@ -858,22 +851,29 @@ static int __init isapnp_build_device_list(void)
858 isapnp_peek(header, 9); 851 isapnp_peek(header, 9);
859 checksum = isapnp_checksum(header); 852 checksum = isapnp_checksum(header);
860#if 0 853#if 0
861 printk(KERN_DEBUG "vendor: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", 854 printk(KERN_DEBUG
862 header[0], header[1], header[2], header[3], 855 "vendor: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
863 header[4], header[5], header[6], header[7], header[8]); 856 header[0], header[1], header[2], header[3], header[4],
857 header[5], header[6], header[7], header[8]);
864 printk(KERN_DEBUG "checksum = 0x%x\n", checksum); 858 printk(KERN_DEBUG "checksum = 0x%x\n", checksum);
865#endif 859#endif
866 if ((card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL)) == NULL) 860 if ((card =
861 kzalloc(sizeof(struct pnp_card), GFP_KERNEL)) == NULL)
867 continue; 862 continue;
868 863
869 card->number = csn; 864 card->number = csn;
870 INIT_LIST_HEAD(&card->devices); 865 INIT_LIST_HEAD(&card->devices);
871 isapnp_parse_card_id(card, (header[1] << 8) | header[0], (header[3] << 8) | header[2]); 866 isapnp_parse_card_id(card, (header[1] << 8) | header[0],
872 card->serial = (header[7] << 24) | (header[6] << 16) | (header[5] << 8) | header[4]; 867 (header[3] << 8) | header[2]);
868 card->serial =
869 (header[7] << 24) | (header[6] << 16) | (header[5] << 8) |
870 header[4];
873 isapnp_checksum_value = 0x00; 871 isapnp_checksum_value = 0x00;
874 isapnp_parse_resource_map(card); 872 isapnp_parse_resource_map(card);
875 if (isapnp_checksum_value != 0x00) 873 if (isapnp_checksum_value != 0x00)
876 printk(KERN_ERR "isapnp: checksum for device %i is not valid (0x%x)\n", csn, isapnp_checksum_value); 874 printk(KERN_ERR
875 "isapnp: checksum for device %i is not valid (0x%x)\n",
876 csn, isapnp_checksum_value);
877 card->checksum = isapnp_checksum_value; 877 card->checksum = isapnp_checksum_value;
878 card->protocol = &isapnp_protocol; 878 card->protocol = &isapnp_protocol;
879 879
@@ -890,6 +890,7 @@ static int __init isapnp_build_device_list(void)
890int isapnp_present(void) 890int isapnp_present(void)
891{ 891{
892 struct pnp_card *card; 892 struct pnp_card *card;
893
893 pnp_for_each_card(card) { 894 pnp_for_each_card(card) {
894 if (card->protocol == &isapnp_protocol) 895 if (card->protocol == &isapnp_protocol)
895 return 1; 896 return 1;
@@ -911,13 +912,13 @@ int isapnp_cfg_begin(int csn, int logdev)
911 /* it is possible to set RDP only in the isolation phase */ 912 /* it is possible to set RDP only in the isolation phase */
912 /* Jens Thoms Toerring <Jens.Toerring@physik.fu-berlin.de> */ 913 /* Jens Thoms Toerring <Jens.Toerring@physik.fu-berlin.de> */
913 isapnp_write_byte(0x02, 0x04); /* clear CSN of card */ 914 isapnp_write_byte(0x02, 0x04); /* clear CSN of card */
914 mdelay(2); /* is this necessary? */ 915 mdelay(2); /* is this necessary? */
915 isapnp_wake(csn); /* bring card into sleep state */ 916 isapnp_wake(csn); /* bring card into sleep state */
916 isapnp_wake(0); /* bring card into isolation state */ 917 isapnp_wake(0); /* bring card into isolation state */
917 isapnp_set_rdp(); /* reset the RDP port */ 918 isapnp_set_rdp(); /* reset the RDP port */
918 udelay(1000); /* delay 1000us */ 919 udelay(1000); /* delay 1000us */
919 isapnp_write_byte(0x06, csn); /* reset CSN to previous value */ 920 isapnp_write_byte(0x06, csn); /* reset CSN to previous value */
920 udelay(250); /* is this necessary? */ 921 udelay(250); /* is this necessary? */
921#endif 922#endif
922 if (logdev >= 0) 923 if (logdev >= 0)
923 isapnp_device(logdev); 924 isapnp_device(logdev);
@@ -931,12 +932,10 @@ int isapnp_cfg_end(void)
931 return 0; 932 return 0;
932} 933}
933 934
934
935/* 935/*
936 * Inititialization. 936 * Initialization.
937 */ 937 */
938 938
939
940EXPORT_SYMBOL(isapnp_protocol); 939EXPORT_SYMBOL(isapnp_protocol);
941EXPORT_SYMBOL(isapnp_present); 940EXPORT_SYMBOL(isapnp_present);
942EXPORT_SYMBOL(isapnp_cfg_begin); 941EXPORT_SYMBOL(isapnp_cfg_begin);
@@ -946,7 +945,8 @@ EXPORT_SYMBOL(isapnp_read_byte);
946#endif 945#endif
947EXPORT_SYMBOL(isapnp_write_byte); 946EXPORT_SYMBOL(isapnp_write_byte);
948 947
949static int isapnp_read_resources(struct pnp_dev *dev, struct pnp_resource_table *res) 948static int isapnp_read_resources(struct pnp_dev *dev,
949 struct pnp_resource_table *res)
950{ 950{
951 int tmp, ret; 951 int tmp, ret;
952 952
@@ -960,31 +960,37 @@ static int isapnp_read_resources(struct pnp_dev *dev, struct pnp_resource_table
960 res->port_resource[tmp].flags = IORESOURCE_IO; 960 res->port_resource[tmp].flags = IORESOURCE_IO;
961 } 961 }
962 for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) { 962 for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) {
963 ret = isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8; 963 ret =
964 isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8;
964 if (!ret) 965 if (!ret)
965 continue; 966 continue;
966 res->mem_resource[tmp].start = ret; 967 res->mem_resource[tmp].start = ret;
967 res->mem_resource[tmp].flags = IORESOURCE_MEM; 968 res->mem_resource[tmp].flags = IORESOURCE_MEM;
968 } 969 }
969 for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) { 970 for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) {
970 ret = (isapnp_read_word(ISAPNP_CFG_IRQ + (tmp << 1)) >> 8); 971 ret =
972 (isapnp_read_word(ISAPNP_CFG_IRQ + (tmp << 1)) >>
973 8);
971 if (!ret) 974 if (!ret)
972 continue; 975 continue;
973 res->irq_resource[tmp].start = res->irq_resource[tmp].end = ret; 976 res->irq_resource[tmp].start =
977 res->irq_resource[tmp].end = ret;
974 res->irq_resource[tmp].flags = IORESOURCE_IRQ; 978 res->irq_resource[tmp].flags = IORESOURCE_IRQ;
975 } 979 }
976 for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) { 980 for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) {
977 ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp); 981 ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp);
978 if (ret == 4) 982 if (ret == 4)
979 continue; 983 continue;
980 res->dma_resource[tmp].start = res->dma_resource[tmp].end = ret; 984 res->dma_resource[tmp].start =
985 res->dma_resource[tmp].end = ret;
981 res->dma_resource[tmp].flags = IORESOURCE_DMA; 986 res->dma_resource[tmp].flags = IORESOURCE_DMA;
982 } 987 }
983 } 988 }
984 return 0; 989 return 0;
985} 990}
986 991
987static int isapnp_get_resources(struct pnp_dev *dev, struct pnp_resource_table * res) 992static int isapnp_get_resources(struct pnp_dev *dev,
993 struct pnp_resource_table *res)
988{ 994{
989 int ret; 995 int ret;
990 pnp_init_resource_table(res); 996 pnp_init_resource_table(res);
@@ -994,24 +1000,44 @@ static int isapnp_get_resources(struct pnp_dev *dev, struct pnp_resource_table *
994 return ret; 1000 return ret;
995} 1001}
996 1002
997static int isapnp_set_resources(struct pnp_dev *dev, struct pnp_resource_table * res) 1003static int isapnp_set_resources(struct pnp_dev *dev,
1004 struct pnp_resource_table *res)
998{ 1005{
999 int tmp; 1006 int tmp;
1000 1007
1001 isapnp_cfg_begin(dev->card->number, dev->number); 1008 isapnp_cfg_begin(dev->card->number, dev->number);
1002 dev->active = 1; 1009 dev->active = 1;
1003 for (tmp = 0; tmp < PNP_MAX_PORT && (res->port_resource[tmp].flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO; tmp++) 1010 for (tmp = 0;
1004 isapnp_write_word(ISAPNP_CFG_PORT+(tmp<<1), res->port_resource[tmp].start); 1011 tmp < PNP_MAX_PORT
1005 for (tmp = 0; tmp < PNP_MAX_IRQ && (res->irq_resource[tmp].flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ; tmp++) { 1012 && (res->port_resource[tmp].
1013 flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO;
1014 tmp++)
1015 isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1),
1016 res->port_resource[tmp].start);
1017 for (tmp = 0;
1018 tmp < PNP_MAX_IRQ
1019 && (res->irq_resource[tmp].
1020 flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ;
1021 tmp++) {
1006 int irq = res->irq_resource[tmp].start; 1022 int irq = res->irq_resource[tmp].start;
1007 if (irq == 2) 1023 if (irq == 2)
1008 irq = 9; 1024 irq = 9;
1009 isapnp_write_byte(ISAPNP_CFG_IRQ+(tmp<<1), irq); 1025 isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq);
1010 } 1026 }
1011 for (tmp = 0; tmp < PNP_MAX_DMA && (res->dma_resource[tmp].flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA; tmp++) 1027 for (tmp = 0;
1012 isapnp_write_byte(ISAPNP_CFG_DMA+tmp, res->dma_resource[tmp].start); 1028 tmp < PNP_MAX_DMA
1013 for (tmp = 0; tmp < PNP_MAX_MEM && (res->mem_resource[tmp].flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM; tmp++) 1029 && (res->dma_resource[tmp].
1014 isapnp_write_word(ISAPNP_CFG_MEM+(tmp<<3), (res->mem_resource[tmp].start >> 8) & 0xffff); 1030 flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA;
1031 tmp++)
1032 isapnp_write_byte(ISAPNP_CFG_DMA + tmp,
1033 res->dma_resource[tmp].start);
1034 for (tmp = 0;
1035 tmp < PNP_MAX_MEM
1036 && (res->mem_resource[tmp].
1037 flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM;
1038 tmp++)
1039 isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3),
1040 (res->mem_resource[tmp].start >> 8) & 0xffff);
1015 /* FIXME: We aren't handling 32bit mems properly here */ 1041 /* FIXME: We aren't handling 32bit mems properly here */
1016 isapnp_activate(dev->number); 1042 isapnp_activate(dev->number);
1017 isapnp_cfg_end(); 1043 isapnp_cfg_end();
@@ -1030,9 +1056,9 @@ static int isapnp_disable_resources(struct pnp_dev *dev)
1030} 1056}
1031 1057
1032struct pnp_protocol isapnp_protocol = { 1058struct pnp_protocol isapnp_protocol = {
1033 .name = "ISA Plug and Play", 1059 .name = "ISA Plug and Play",
1034 .get = isapnp_get_resources, 1060 .get = isapnp_get_resources,
1035 .set = isapnp_set_resources, 1061 .set = isapnp_set_resources,
1036 .disable = isapnp_disable_resources, 1062 .disable = isapnp_disable_resources,
1037}; 1063};
1038 1064
@@ -1053,31 +1079,36 @@ static int __init isapnp_init(void)
1053#endif 1079#endif
1054#ifdef ISAPNP_REGION_OK 1080#ifdef ISAPNP_REGION_OK
1055 if (!request_region(_PIDXR, 1, "isapnp index")) { 1081 if (!request_region(_PIDXR, 1, "isapnp index")) {
1056 printk(KERN_ERR "isapnp: Index Register 0x%x already used\n", _PIDXR); 1082 printk(KERN_ERR "isapnp: Index Register 0x%x already used\n",
1083 _PIDXR);
1057 return -EBUSY; 1084 return -EBUSY;
1058 } 1085 }
1059#endif 1086#endif
1060 if (!request_region(_PNPWRP, 1, "isapnp write")) { 1087 if (!request_region(_PNPWRP, 1, "isapnp write")) {
1061 printk(KERN_ERR "isapnp: Write Data Register 0x%x already used\n", _PNPWRP); 1088 printk(KERN_ERR
1089 "isapnp: Write Data Register 0x%x already used\n",
1090 _PNPWRP);
1062#ifdef ISAPNP_REGION_OK 1091#ifdef ISAPNP_REGION_OK
1063 release_region(_PIDXR, 1); 1092 release_region(_PIDXR, 1);
1064#endif 1093#endif
1065 return -EBUSY; 1094 return -EBUSY;
1066 } 1095 }
1067 1096
1068 if(pnp_register_protocol(&isapnp_protocol)<0) 1097 if (pnp_register_protocol(&isapnp_protocol) < 0)
1069 return -EBUSY; 1098 return -EBUSY;
1070 1099
1071 /* 1100 /*
1072 * Print a message. The existing ISAPnP code is hanging machines 1101 * Print a message. The existing ISAPnP code is hanging machines
1073 * so let the user know where. 1102 * so let the user know where.
1074 */ 1103 */
1075 1104
1076 printk(KERN_INFO "isapnp: Scanning for PnP cards...\n"); 1105 printk(KERN_INFO "isapnp: Scanning for PnP cards...\n");
1077 if (isapnp_rdp >= 0x203 && isapnp_rdp <= 0x3ff) { 1106 if (isapnp_rdp >= 0x203 && isapnp_rdp <= 0x3ff) {
1078 isapnp_rdp |= 3; 1107 isapnp_rdp |= 3;
1079 if (!request_region(isapnp_rdp, 1, "isapnp read")) { 1108 if (!request_region(isapnp_rdp, 1, "isapnp read")) {
1080 printk(KERN_ERR "isapnp: Read Data Register 0x%x already used\n", isapnp_rdp); 1109 printk(KERN_ERR
1110 "isapnp: Read Data Register 0x%x already used\n",
1111 isapnp_rdp);
1081#ifdef ISAPNP_REGION_OK 1112#ifdef ISAPNP_REGION_OK
1082 release_region(_PIDXR, 1); 1113 release_region(_PIDXR, 1);
1083#endif 1114#endif
@@ -1089,14 +1120,14 @@ static int __init isapnp_init(void)
1089 isapnp_detected = 1; 1120 isapnp_detected = 1;
1090 if (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff) { 1121 if (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff) {
1091 cards = isapnp_isolate(); 1122 cards = isapnp_isolate();
1092 if (cards < 0 || 1123 if (cards < 0 || (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff)) {
1093 (isapnp_rdp < 0x203 || isapnp_rdp > 0x3ff)) {
1094#ifdef ISAPNP_REGION_OK 1124#ifdef ISAPNP_REGION_OK
1095 release_region(_PIDXR, 1); 1125 release_region(_PIDXR, 1);
1096#endif 1126#endif
1097 release_region(_PNPWRP, 1); 1127 release_region(_PNPWRP, 1);
1098 isapnp_detected = 0; 1128 isapnp_detected = 0;
1099 printk(KERN_INFO "isapnp: No Plug & Play device found\n"); 1129 printk(KERN_INFO
1130 "isapnp: No Plug & Play device found\n");
1100 return 0; 1131 return 0;
1101 } 1132 }
1102 request_region(isapnp_rdp, 1, "isapnp read"); 1133 request_region(isapnp_rdp, 1, "isapnp read");
@@ -1104,19 +1135,23 @@ static int __init isapnp_init(void)
1104 isapnp_build_device_list(); 1135 isapnp_build_device_list();
1105 cards = 0; 1136 cards = 0;
1106 1137
1107 protocol_for_each_card(&isapnp_protocol,card) { 1138 protocol_for_each_card(&isapnp_protocol, card) {
1108 cards++; 1139 cards++;
1109 if (isapnp_verbose) { 1140 if (isapnp_verbose) {
1110 printk(KERN_INFO "isapnp: Card '%s'\n", card->name[0]?card->name:"Unknown"); 1141 printk(KERN_INFO "isapnp: Card '%s'\n",
1142 card->name[0] ? card->name : "Unknown");
1111 if (isapnp_verbose < 2) 1143 if (isapnp_verbose < 2)
1112 continue; 1144 continue;
1113 card_for_each_dev(card,dev) { 1145 card_for_each_dev(card, dev) {
1114 printk(KERN_INFO "isapnp: Device '%s'\n", dev->name[0]?dev->name:"Unknown"); 1146 printk(KERN_INFO "isapnp: Device '%s'\n",
1147 dev->name[0] ? dev->name : "Unknown");
1115 } 1148 }
1116 } 1149 }
1117 } 1150 }
1118 if (cards) { 1151 if (cards) {
1119 printk(KERN_INFO "isapnp: %i Plug & Play card%s detected total\n", cards, cards>1?"s":""); 1152 printk(KERN_INFO
1153 "isapnp: %i Plug & Play card%s detected total\n", cards,
1154 cards > 1 ? "s" : "");
1120 } else { 1155 } else {
1121 printk(KERN_INFO "isapnp: No Plug & Play card found\n"); 1156 printk(KERN_INFO "isapnp: No Plug & Play card found\n");
1122 } 1157 }
@@ -1141,11 +1176,10 @@ __setup("noisapnp", isapnp_setup_disable);
1141 1176
1142static int __init isapnp_setup_isapnp(char *str) 1177static int __init isapnp_setup_isapnp(char *str)
1143{ 1178{
1144 (void)((get_option(&str,&isapnp_rdp) == 2) && 1179 (void)((get_option(&str, &isapnp_rdp) == 2) &&
1145 (get_option(&str,&isapnp_reset) == 2) && 1180 (get_option(&str, &isapnp_reset) == 2) &&
1146 (get_option(&str,&isapnp_verbose) == 2)); 1181 (get_option(&str, &isapnp_verbose) == 2));
1147 return 1; 1182 return 1;
1148} 1183}
1149 1184
1150__setup("isapnp=", isapnp_setup_isapnp); 1185__setup("isapnp=", isapnp_setup_isapnp);
1151
diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c
index 40b724ebe23b..3fbc0f9ffc26 100644
--- a/drivers/pnp/isapnp/proc.c
+++ b/drivers/pnp/isapnp/proc.c
@@ -2,7 +2,6 @@
2 * ISA Plug & Play support 2 * ISA Plug & Play support
3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz> 3 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
4 * 4 *
5 *
6 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
@@ -16,7 +15,6 @@
16 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */ 18 */
21 19
22#include <linux/module.h> 20#include <linux/module.h>
@@ -54,7 +52,8 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
54 return (file->f_pos = new); 52 return (file->f_pos = new);
55} 53}
56 54
57static ssize_t isapnp_proc_bus_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 55static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf,
56 size_t nbytes, loff_t * ppos)
58{ 57{
59 struct inode *ino = file->f_path.dentry->d_inode; 58 struct inode *ino = file->f_path.dentry->d_inode;
60 struct proc_dir_entry *dp = PDE(ino); 59 struct proc_dir_entry *dp = PDE(ino);
@@ -74,7 +73,7 @@ static ssize_t isapnp_proc_bus_read(struct file *file, char __user *buf, size_t
74 return -EINVAL; 73 return -EINVAL;
75 74
76 isapnp_cfg_begin(dev->card->number, dev->number); 75 isapnp_cfg_begin(dev->card->number, dev->number);
77 for ( ; pos < 256 && cnt > 0; pos++, buf++, cnt--) { 76 for (; pos < 256 && cnt > 0; pos++, buf++, cnt--) {
78 unsigned char val; 77 unsigned char val;
79 val = isapnp_read_byte(pos); 78 val = isapnp_read_byte(pos);
80 __put_user(val, buf); 79 __put_user(val, buf);
@@ -85,10 +84,9 @@ static ssize_t isapnp_proc_bus_read(struct file *file, char __user *buf, size_t
85 return nbytes; 84 return nbytes;
86} 85}
87 86
88static const struct file_operations isapnp_proc_bus_file_operations = 87static const struct file_operations isapnp_proc_bus_file_operations = {
89{ 88 .llseek = isapnp_proc_bus_lseek,
90 .llseek = isapnp_proc_bus_lseek, 89 .read = isapnp_proc_bus_read,
91 .read = isapnp_proc_bus_read,
92}; 90};
93 91
94static int isapnp_proc_attach_device(struct pnp_dev *dev) 92static int isapnp_proc_attach_device(struct pnp_dev *dev)
@@ -139,13 +137,14 @@ static int __exit isapnp_proc_detach_bus(struct pnp_card *bus)
139 remove_proc_entry(name, isapnp_proc_bus_dir); 137 remove_proc_entry(name, isapnp_proc_bus_dir);
140 return 0; 138 return 0;
141} 139}
142#endif /* MODULE */ 140#endif /* MODULE */
143 141
144int __init isapnp_proc_init(void) 142int __init isapnp_proc_init(void)
145{ 143{
146 struct pnp_dev *dev; 144 struct pnp_dev *dev;
145
147 isapnp_proc_bus_dir = proc_mkdir("isapnp", proc_bus); 146 isapnp_proc_bus_dir = proc_mkdir("isapnp", proc_bus);
148 protocol_for_each_dev(&isapnp_protocol,dev) { 147 protocol_for_each_dev(&isapnp_protocol, dev) {
149 isapnp_proc_attach_device(dev); 148 isapnp_proc_attach_device(dev);
150 } 149 }
151 return 0; 150 return 0;
@@ -167,4 +166,4 @@ int __exit isapnp_proc_done(void)
167 remove_proc_entry("isapnp", proc_bus); 166 remove_proc_entry("isapnp", proc_bus);
168 return 0; 167 return 0;
169} 168}
170#endif /* MODULE */ 169#endif /* MODULE */
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 57e6ab1004d0..3bda513a6bd3 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -3,7 +3,6 @@
3 * 3 *
4 * based on isapnp.c resource management (c) Jaroslav Kysela <perex@suse.cz> 4 * based on isapnp.c resource management (c) Jaroslav Kysela <perex@suse.cz>
5 * Copyright 2003 Adam Belay <ambx1@neo.rr.com> 5 * Copyright 2003 Adam Belay <ambx1@neo.rr.com>
6 *
7 */ 6 */
8 7
9#include <linux/errno.h> 8#include <linux/errno.h>
@@ -26,7 +25,8 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
26 return -EINVAL; 25 return -EINVAL;
27 26
28 if (idx >= PNP_MAX_PORT) { 27 if (idx >= PNP_MAX_PORT) {
29 pnp_err("More than 4 ports is incompatible with pnp specifications."); 28 pnp_err
29 ("More than 4 ports is incompatible with pnp specifications.");
30 /* pretend we were successful so at least the manager won't try again */ 30 /* pretend we were successful so at least the manager won't try again */
31 return 1; 31 return 1;
32 } 32 }
@@ -41,11 +41,11 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
41 41
42 /* set the initial values */ 42 /* set the initial values */
43 *flags |= rule->flags | IORESOURCE_IO; 43 *flags |= rule->flags | IORESOURCE_IO;
44 *flags &= ~IORESOURCE_UNSET; 44 *flags &= ~IORESOURCE_UNSET;
45 45
46 if (!rule->size) { 46 if (!rule->size) {
47 *flags |= IORESOURCE_DISABLED; 47 *flags |= IORESOURCE_DISABLED;
48 return 1; /* skip disabled resource requests */ 48 return 1; /* skip disabled resource requests */
49 } 49 }
50 50
51 *start = rule->min; 51 *start = rule->min;
@@ -70,7 +70,8 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
70 return -EINVAL; 70 return -EINVAL;
71 71
72 if (idx >= PNP_MAX_MEM) { 72 if (idx >= PNP_MAX_MEM) {
73 pnp_err("More than 8 mems is incompatible with pnp specifications."); 73 pnp_err
74 ("More than 8 mems is incompatible with pnp specifications.");
74 /* pretend we were successful so at least the manager won't try again */ 75 /* pretend we were successful so at least the manager won't try again */
75 return 1; 76 return 1;
76 } 77 }
@@ -85,7 +86,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
85 86
86 /* set the initial values */ 87 /* set the initial values */
87 *flags |= rule->flags | IORESOURCE_MEM; 88 *flags |= rule->flags | IORESOURCE_MEM;
88 *flags &= ~IORESOURCE_UNSET; 89 *flags &= ~IORESOURCE_UNSET;
89 90
90 /* convert pnp flags to standard Linux flags */ 91 /* convert pnp flags to standard Linux flags */
91 if (!(rule->flags & IORESOURCE_MEM_WRITEABLE)) 92 if (!(rule->flags & IORESOURCE_MEM_WRITEABLE))
@@ -99,11 +100,11 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
99 100
100 if (!rule->size) { 101 if (!rule->size) {
101 *flags |= IORESOURCE_DISABLED; 102 *flags |= IORESOURCE_DISABLED;
102 return 1; /* skip disabled resource requests */ 103 return 1; /* skip disabled resource requests */
103 } 104 }
104 105
105 *start = rule->min; 106 *start = rule->min;
106 *end = *start + rule->size -1; 107 *end = *start + rule->size - 1;
107 108
108 /* run through until pnp_check_mem is happy */ 109 /* run through until pnp_check_mem is happy */
109 while (!pnp_check_mem(dev, idx)) { 110 while (!pnp_check_mem(dev, idx)) {
@@ -115,7 +116,7 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
115 return 1; 116 return 1;
116} 117}
117 118
118static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx) 119static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)
119{ 120{
120 resource_size_t *start, *end; 121 resource_size_t *start, *end;
121 unsigned long *flags; 122 unsigned long *flags;
@@ -130,7 +131,8 @@ static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx)
130 return -EINVAL; 131 return -EINVAL;
131 132
132 if (idx >= PNP_MAX_IRQ) { 133 if (idx >= PNP_MAX_IRQ) {
133 pnp_err("More than 2 irqs is incompatible with pnp specifications."); 134 pnp_err
135 ("More than 2 irqs is incompatible with pnp specifications.");
134 /* pretend we were successful so at least the manager won't try again */ 136 /* pretend we were successful so at least the manager won't try again */
135 return 1; 137 return 1;
136 } 138 }
@@ -145,11 +147,11 @@ static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx)
145 147
146 /* set the initial values */ 148 /* set the initial values */
147 *flags |= rule->flags | IORESOURCE_IRQ; 149 *flags |= rule->flags | IORESOURCE_IRQ;
148 *flags &= ~IORESOURCE_UNSET; 150 *flags &= ~IORESOURCE_UNSET;
149 151
150 if (bitmap_empty(rule->map, PNP_IRQ_NR)) { 152 if (bitmap_empty(rule->map, PNP_IRQ_NR)) {
151 *flags |= IORESOURCE_DISABLED; 153 *flags |= IORESOURCE_DISABLED;
152 return 1; /* skip disabled resource requests */ 154 return 1; /* skip disabled resource requests */
153 } 155 }
154 156
155 /* TBD: need check for >16 IRQ */ 157 /* TBD: need check for >16 IRQ */
@@ -159,9 +161,9 @@ static int pnp_assign_irq(struct pnp_dev * dev, struct pnp_irq *rule, int idx)
159 return 1; 161 return 1;
160 } 162 }
161 for (i = 0; i < 16; i++) { 163 for (i = 0; i < 16; i++) {
162 if(test_bit(xtab[i], rule->map)) { 164 if (test_bit(xtab[i], rule->map)) {
163 *start = *end = xtab[i]; 165 *start = *end = xtab[i];
164 if(pnp_check_irq(dev, idx)) 166 if (pnp_check_irq(dev, idx))
165 return 1; 167 return 1;
166 } 168 }
167 } 169 }
@@ -183,7 +185,8 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
183 return -EINVAL; 185 return -EINVAL;
184 186
185 if (idx >= PNP_MAX_DMA) { 187 if (idx >= PNP_MAX_DMA) {
186 pnp_err("More than 2 dmas is incompatible with pnp specifications."); 188 pnp_err
189 ("More than 2 dmas is incompatible with pnp specifications.");
187 /* pretend we were successful so at least the manager won't try again */ 190 /* pretend we were successful so at least the manager won't try again */
188 return 1; 191 return 1;
189 } 192 }
@@ -198,17 +201,17 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
198 201
199 /* set the initial values */ 202 /* set the initial values */
200 *flags |= rule->flags | IORESOURCE_DMA; 203 *flags |= rule->flags | IORESOURCE_DMA;
201 *flags &= ~IORESOURCE_UNSET; 204 *flags &= ~IORESOURCE_UNSET;
202 205
203 if (!rule->map) { 206 if (!rule->map) {
204 *flags |= IORESOURCE_DISABLED; 207 *flags |= IORESOURCE_DISABLED;
205 return 1; /* skip disabled resource requests */ 208 return 1; /* skip disabled resource requests */
206 } 209 }
207 210
208 for (i = 0; i < 8; i++) { 211 for (i = 0; i < 8; i++) {
209 if(rule->map & (1<<xtab[i])) { 212 if (rule->map & (1 << xtab[i])) {
210 *start = *end = xtab[i]; 213 *start = *end = xtab[i];
211 if(pnp_check_dma(dev, idx)) 214 if (pnp_check_dma(dev, idx))
212 return 1; 215 return 1;
213 } 216 }
214 } 217 }
@@ -218,72 +221,80 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
218/** 221/**
219 * pnp_init_resources - Resets a resource table to default values. 222 * pnp_init_resources - Resets a resource table to default values.
220 * @table: pointer to the desired resource table 223 * @table: pointer to the desired resource table
221 *
222 */ 224 */
223void pnp_init_resource_table(struct pnp_resource_table *table) 225void pnp_init_resource_table(struct pnp_resource_table *table)
224{ 226{
225 int idx; 227 int idx;
228
226 for (idx = 0; idx < PNP_MAX_IRQ; idx++) { 229 for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
227 table->irq_resource[idx].name = NULL; 230 table->irq_resource[idx].name = NULL;
228 table->irq_resource[idx].start = -1; 231 table->irq_resource[idx].start = -1;
229 table->irq_resource[idx].end = -1; 232 table->irq_resource[idx].end = -1;
230 table->irq_resource[idx].flags = IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET; 233 table->irq_resource[idx].flags =
234 IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET;
231 } 235 }
232 for (idx = 0; idx < PNP_MAX_DMA; idx++) { 236 for (idx = 0; idx < PNP_MAX_DMA; idx++) {
233 table->dma_resource[idx].name = NULL; 237 table->dma_resource[idx].name = NULL;
234 table->dma_resource[idx].start = -1; 238 table->dma_resource[idx].start = -1;
235 table->dma_resource[idx].end = -1; 239 table->dma_resource[idx].end = -1;
236 table->dma_resource[idx].flags = IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET; 240 table->dma_resource[idx].flags =
241 IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET;
237 } 242 }
238 for (idx = 0; idx < PNP_MAX_PORT; idx++) { 243 for (idx = 0; idx < PNP_MAX_PORT; idx++) {
239 table->port_resource[idx].name = NULL; 244 table->port_resource[idx].name = NULL;
240 table->port_resource[idx].start = 0; 245 table->port_resource[idx].start = 0;
241 table->port_resource[idx].end = 0; 246 table->port_resource[idx].end = 0;
242 table->port_resource[idx].flags = IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET; 247 table->port_resource[idx].flags =
248 IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET;
243 } 249 }
244 for (idx = 0; idx < PNP_MAX_MEM; idx++) { 250 for (idx = 0; idx < PNP_MAX_MEM; idx++) {
245 table->mem_resource[idx].name = NULL; 251 table->mem_resource[idx].name = NULL;
246 table->mem_resource[idx].start = 0; 252 table->mem_resource[idx].start = 0;
247 table->mem_resource[idx].end = 0; 253 table->mem_resource[idx].end = 0;
248 table->mem_resource[idx].flags = IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET; 254 table->mem_resource[idx].flags =
255 IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET;
249 } 256 }
250} 257}
251 258
252/** 259/**
253 * pnp_clean_resources - clears resources that were not manually set 260 * pnp_clean_resources - clears resources that were not manually set
254 * @res: the resources to clean 261 * @res: the resources to clean
255 *
256 */ 262 */
257static void pnp_clean_resource_table(struct pnp_resource_table * res) 263static void pnp_clean_resource_table(struct pnp_resource_table *res)
258{ 264{
259 int idx; 265 int idx;
266
260 for (idx = 0; idx < PNP_MAX_IRQ; idx++) { 267 for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
261 if (!(res->irq_resource[idx].flags & IORESOURCE_AUTO)) 268 if (!(res->irq_resource[idx].flags & IORESOURCE_AUTO))
262 continue; 269 continue;
263 res->irq_resource[idx].start = -1; 270 res->irq_resource[idx].start = -1;
264 res->irq_resource[idx].end = -1; 271 res->irq_resource[idx].end = -1;
265 res->irq_resource[idx].flags = IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET; 272 res->irq_resource[idx].flags =
273 IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET;
266 } 274 }
267 for (idx = 0; idx < PNP_MAX_DMA; idx++) { 275 for (idx = 0; idx < PNP_MAX_DMA; idx++) {
268 if (!(res->dma_resource[idx].flags & IORESOURCE_AUTO)) 276 if (!(res->dma_resource[idx].flags & IORESOURCE_AUTO))
269 continue; 277 continue;
270 res->dma_resource[idx].start = -1; 278 res->dma_resource[idx].start = -1;
271 res->dma_resource[idx].end = -1; 279 res->dma_resource[idx].end = -1;
272 res->dma_resource[idx].flags = IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET; 280 res->dma_resource[idx].flags =
281 IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET;
273 } 282 }
274 for (idx = 0; idx < PNP_MAX_PORT; idx++) { 283 for (idx = 0; idx < PNP_MAX_PORT; idx++) {
275 if (!(res->port_resource[idx].flags & IORESOURCE_AUTO)) 284 if (!(res->port_resource[idx].flags & IORESOURCE_AUTO))
276 continue; 285 continue;
277 res->port_resource[idx].start = 0; 286 res->port_resource[idx].start = 0;
278 res->port_resource[idx].end = 0; 287 res->port_resource[idx].end = 0;
279 res->port_resource[idx].flags = IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET; 288 res->port_resource[idx].flags =
289 IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET;
280 } 290 }
281 for (idx = 0; idx < PNP_MAX_MEM; idx++) { 291 for (idx = 0; idx < PNP_MAX_MEM; idx++) {
282 if (!(res->mem_resource[idx].flags & IORESOURCE_AUTO)) 292 if (!(res->mem_resource[idx].flags & IORESOURCE_AUTO))
283 continue; 293 continue;
284 res->mem_resource[idx].start = 0; 294 res->mem_resource[idx].start = 0;
285 res->mem_resource[idx].end = 0; 295 res->mem_resource[idx].end = 0;
286 res->mem_resource[idx].flags = IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET; 296 res->mem_resource[idx].flags =
297 IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET;
287 } 298 }
288} 299}
289 300
@@ -306,7 +317,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum)
306 return -ENODEV; 317 return -ENODEV;
307 318
308 down(&pnp_res_mutex); 319 down(&pnp_res_mutex);
309 pnp_clean_resource_table(&dev->res); /* start with a fresh slate */ 320 pnp_clean_resource_table(&dev->res); /* start with a fresh slate */
310 if (dev->independent) { 321 if (dev->independent) {
311 port = dev->independent->port; 322 port = dev->independent->port;
312 mem = dev->independent->mem; 323 mem = dev->independent->mem;
@@ -341,10 +352,11 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum)
341 if (depnum) { 352 if (depnum) {
342 struct pnp_option *dep; 353 struct pnp_option *dep;
343 int i; 354 int i;
344 for (i=1,dep=dev->dependent; i<depnum; i++, dep=dep->next) 355 for (i = 1, dep = dev->dependent; i < depnum;
345 if(!dep) 356 i++, dep = dep->next)
357 if (!dep)
346 goto fail; 358 goto fail;
347 port =dep->port; 359 port = dep->port;
348 mem = dep->mem; 360 mem = dep->mem;
349 irq = dep->irq; 361 irq = dep->irq;
350 dma = dep->dma; 362 dma = dep->dma;
@@ -378,7 +390,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum)
378 up(&pnp_res_mutex); 390 up(&pnp_res_mutex);
379 return 1; 391 return 1;
380 392
381fail: 393 fail:
382 pnp_clean_resource_table(&dev->res); 394 pnp_clean_resource_table(&dev->res);
383 up(&pnp_res_mutex); 395 up(&pnp_res_mutex);
384 return 0; 396 return 0;
@@ -392,10 +404,12 @@ fail:
392 * 404 *
393 * This function can be used by drivers that want to manually set thier resources. 405 * This function can be used by drivers that want to manually set thier resources.
394 */ 406 */
395int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table * res, int mode) 407int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
408 int mode)
396{ 409{
397 int i; 410 int i;
398 struct pnp_resource_table * bak; 411 struct pnp_resource_table *bak;
412
399 if (!dev || !res) 413 if (!dev || !res)
400 return -EINVAL; 414 return -EINVAL;
401 if (!pnp_can_configure(dev)) 415 if (!pnp_can_configure(dev))
@@ -409,19 +423,19 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table * res,
409 dev->res = *res; 423 dev->res = *res;
410 if (!(mode & PNP_CONFIG_FORCE)) { 424 if (!(mode & PNP_CONFIG_FORCE)) {
411 for (i = 0; i < PNP_MAX_PORT; i++) { 425 for (i = 0; i < PNP_MAX_PORT; i++) {
412 if(!pnp_check_port(dev,i)) 426 if (!pnp_check_port(dev, i))
413 goto fail; 427 goto fail;
414 } 428 }
415 for (i = 0; i < PNP_MAX_MEM; i++) { 429 for (i = 0; i < PNP_MAX_MEM; i++) {
416 if(!pnp_check_mem(dev,i)) 430 if (!pnp_check_mem(dev, i))
417 goto fail; 431 goto fail;
418 } 432 }
419 for (i = 0; i < PNP_MAX_IRQ; i++) { 433 for (i = 0; i < PNP_MAX_IRQ; i++) {
420 if(!pnp_check_irq(dev,i)) 434 if (!pnp_check_irq(dev, i))
421 goto fail; 435 goto fail;
422 } 436 }
423 for (i = 0; i < PNP_MAX_DMA; i++) { 437 for (i = 0; i < PNP_MAX_DMA; i++) {
424 if(!pnp_check_dma(dev,i)) 438 if (!pnp_check_dma(dev, i))
425 goto fail; 439 goto fail;
426 } 440 }
427 } 441 }
@@ -430,7 +444,7 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table * res,
430 kfree(bak); 444 kfree(bak);
431 return 0; 445 return 0;
432 446
433fail: 447 fail:
434 dev->res = *bak; 448 dev->res = *bak;
435 up(&pnp_res_mutex); 449 up(&pnp_res_mutex);
436 kfree(bak); 450 kfree(bak);
@@ -440,18 +454,18 @@ fail:
440/** 454/**
441 * pnp_auto_config_dev - automatically assigns resources to a device 455 * pnp_auto_config_dev - automatically assigns resources to a device
442 * @dev: pointer to the desired device 456 * @dev: pointer to the desired device
443 *
444 */ 457 */
445int pnp_auto_config_dev(struct pnp_dev *dev) 458int pnp_auto_config_dev(struct pnp_dev *dev)
446{ 459{
447 struct pnp_option *dep; 460 struct pnp_option *dep;
448 int i = 1; 461 int i = 1;
449 462
450 if(!dev) 463 if (!dev)
451 return -EINVAL; 464 return -EINVAL;
452 465
453 if(!pnp_can_configure(dev)) { 466 if (!pnp_can_configure(dev)) {
454 pnp_dbg("Device %s does not support resource configuration.", dev->dev.bus_id); 467 pnp_dbg("Device %s does not support resource configuration.",
468 dev->dev.bus_id);
455 return -ENODEV; 469 return -ENODEV;
456 } 470 }
457 471
@@ -476,23 +490,22 @@ int pnp_auto_config_dev(struct pnp_dev *dev)
476 * pnp_start_dev - low-level start of the PnP device 490 * pnp_start_dev - low-level start of the PnP device
477 * @dev: pointer to the desired device 491 * @dev: pointer to the desired device
478 * 492 *
479 * assumes that resources have alread been allocated 493 * assumes that resources have already been allocated
480 */ 494 */
481
482int pnp_start_dev(struct pnp_dev *dev) 495int pnp_start_dev(struct pnp_dev *dev)
483{ 496{
484 if (!pnp_can_write(dev)) { 497 if (!pnp_can_write(dev)) {
485 pnp_dbg("Device %s does not support activation.", dev->dev.bus_id); 498 pnp_dbg("Device %s does not support activation.",
499 dev->dev.bus_id);
486 return -EINVAL; 500 return -EINVAL;
487 } 501 }
488 502
489 if (dev->protocol->set(dev, &dev->res)<0) { 503 if (dev->protocol->set(dev, &dev->res) < 0) {
490 pnp_err("Failed to activate device %s.", dev->dev.bus_id); 504 pnp_err("Failed to activate device %s.", dev->dev.bus_id);
491 return -EIO; 505 return -EIO;
492 } 506 }
493 507
494 pnp_info("Device %s activated.", dev->dev.bus_id); 508 pnp_info("Device %s activated.", dev->dev.bus_id);
495
496 return 0; 509 return 0;
497} 510}
498 511
@@ -502,20 +515,19 @@ int pnp_start_dev(struct pnp_dev *dev)
502 * 515 *
503 * does not free resources 516 * does not free resources
504 */ 517 */
505
506int pnp_stop_dev(struct pnp_dev *dev) 518int pnp_stop_dev(struct pnp_dev *dev)
507{ 519{
508 if (!pnp_can_disable(dev)) { 520 if (!pnp_can_disable(dev)) {
509 pnp_dbg("Device %s does not support disabling.", dev->dev.bus_id); 521 pnp_dbg("Device %s does not support disabling.",
522 dev->dev.bus_id);
510 return -EINVAL; 523 return -EINVAL;
511 } 524 }
512 if (dev->protocol->disable(dev)<0) { 525 if (dev->protocol->disable(dev) < 0) {
513 pnp_err("Failed to disable device %s.", dev->dev.bus_id); 526 pnp_err("Failed to disable device %s.", dev->dev.bus_id);
514 return -EIO; 527 return -EIO;
515 } 528 }
516 529
517 pnp_info("Device %s disabled.", dev->dev.bus_id); 530 pnp_info("Device %s disabled.", dev->dev.bus_id);
518
519 return 0; 531 return 0;
520} 532}
521 533
@@ -531,9 +543,8 @@ int pnp_activate_dev(struct pnp_dev *dev)
531 543
532 if (!dev) 544 if (!dev)
533 return -EINVAL; 545 return -EINVAL;
534 if (dev->active) { 546 if (dev->active)
535 return 0; /* the device is already active */ 547 return 0; /* the device is already active */
536 }
537 548
538 /* ensure resources are allocated */ 549 /* ensure resources are allocated */
539 if (pnp_auto_config_dev(dev)) 550 if (pnp_auto_config_dev(dev))
@@ -544,7 +555,6 @@ int pnp_activate_dev(struct pnp_dev *dev)
544 return error; 555 return error;
545 556
546 dev->active = 1; 557 dev->active = 1;
547
548 return 1; 558 return 1;
549} 559}
550 560
@@ -558,11 +568,10 @@ int pnp_disable_dev(struct pnp_dev *dev)
558{ 568{
559 int error; 569 int error;
560 570
561 if (!dev) 571 if (!dev)
562 return -EINVAL; 572 return -EINVAL;
563 if (!dev->active) { 573 if (!dev->active)
564 return 0; /* the device is already disabled */ 574 return 0; /* the device is already disabled */
565 }
566 575
567 error = pnp_stop_dev(dev); 576 error = pnp_stop_dev(dev);
568 if (error) 577 if (error)
@@ -583,10 +592,9 @@ int pnp_disable_dev(struct pnp_dev *dev)
583 * @resource: pointer to resource to be changed 592 * @resource: pointer to resource to be changed
584 * @start: start of region 593 * @start: start of region
585 * @size: size of region 594 * @size: size of region
586 *
587 */ 595 */
588void pnp_resource_change(struct resource *resource, resource_size_t start, 596void pnp_resource_change(struct resource *resource, resource_size_t start,
589 resource_size_t size) 597 resource_size_t size)
590{ 598{
591 if (resource == NULL) 599 if (resource == NULL)
592 return; 600 return;
@@ -595,11 +603,7 @@ void pnp_resource_change(struct resource *resource, resource_size_t start,
595 resource->end = start + size - 1; 603 resource->end = start + size - 1;
596} 604}
597 605
598
599EXPORT_SYMBOL(pnp_manual_config_dev); 606EXPORT_SYMBOL(pnp_manual_config_dev);
600#if 0
601EXPORT_SYMBOL(pnp_auto_config_dev);
602#endif
603EXPORT_SYMBOL(pnp_start_dev); 607EXPORT_SYMBOL(pnp_start_dev);
604EXPORT_SYMBOL(pnp_stop_dev); 608EXPORT_SYMBOL(pnp_stop_dev);
605EXPORT_SYMBOL(pnp_activate_dev); 609EXPORT_SYMBOL(pnp_activate_dev);
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index a00548799e98..616fc72190bf 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -21,7 +21,10 @@
21 21
22#include <linux/acpi.h> 22#include <linux/acpi.h>
23#include <linux/pnp.h> 23#include <linux/pnp.h>
24#include <linux/mod_devicetable.h>
24#include <acpi/acpi_bus.h> 25#include <acpi/acpi_bus.h>
26#include <acpi/actypes.h>
27
25#include "pnpacpi.h" 28#include "pnpacpi.h"
26 29
27static int num = 0; 30static int num = 0;
@@ -31,17 +34,19 @@ static int num = 0;
31 * used by the kernel (PCI root, ...), as it is harmless and there were 34 * used by the kernel (PCI root, ...), as it is harmless and there were
32 * already present in pnpbios. But there is an exception for devices that 35 * already present in pnpbios. But there is an exception for devices that
33 * have irqs (PIC, Timer) because we call acpi_register_gsi. 36 * have irqs (PIC, Timer) because we call acpi_register_gsi.
34 * Finaly only devices that have a CRS method need to be in this list. 37 * Finally, only devices that have a CRS method need to be in this list.
35 */ 38 */
36static char __initdata excluded_id_list[] = 39static struct __initdata acpi_device_id excluded_id_list[] = {
37 "PNP0C09," /* EC */ 40 {"PNP0C09", 0}, /* EC */
38 "PNP0C0F," /* Link device */ 41 {"PNP0C0F", 0}, /* Link device */
39 "PNP0000," /* PIC */ 42 {"PNP0000", 0}, /* PIC */
40 "PNP0100," /* Timer */ 43 {"PNP0100", 0}, /* Timer */
41 ; 44 {"", 0},
45};
46
42static inline int is_exclusive_device(struct acpi_device *dev) 47static inline int is_exclusive_device(struct acpi_device *dev)
43{ 48{
44 return (!acpi_match_ids(dev, excluded_id_list)); 49 return (!acpi_match_device_ids(dev, excluded_id_list));
45} 50}
46 51
47/* 52/*
@@ -79,15 +84,18 @@ static void __init pnpidacpi_to_pnpid(char *id, char *str)
79 str[7] = '\0'; 84 str[7] = '\0';
80} 85}
81 86
82static int pnpacpi_get_resources(struct pnp_dev * dev, struct pnp_resource_table * res) 87static int pnpacpi_get_resources(struct pnp_dev *dev,
88 struct pnp_resource_table *res)
83{ 89{
84 acpi_status status; 90 acpi_status status;
85 status = pnpacpi_parse_allocated_resource((acpi_handle)dev->data, 91
86 &dev->res); 92 status = pnpacpi_parse_allocated_resource((acpi_handle) dev->data,
93 &dev->res);
87 return ACPI_FAILURE(status) ? -ENODEV : 0; 94 return ACPI_FAILURE(status) ? -ENODEV : 0;
88} 95}
89 96
90static int pnpacpi_set_resources(struct pnp_dev * dev, struct pnp_resource_table * res) 97static int pnpacpi_set_resources(struct pnp_dev *dev,
98 struct pnp_resource_table *res)
91{ 99{
92 acpi_handle handle = dev->data; 100 acpi_handle handle = dev->data;
93 struct acpi_buffer buffer; 101 struct acpi_buffer buffer;
@@ -114,16 +122,36 @@ static int pnpacpi_disable_resources(struct pnp_dev *dev)
114 acpi_status status; 122 acpi_status status;
115 123
116 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */ 124 /* acpi_unregister_gsi(pnp_irq(dev, 0)); */
117 status = acpi_evaluate_object((acpi_handle)dev->data, 125 status = acpi_evaluate_object((acpi_handle) dev->data,
118 "_DIS", NULL, NULL); 126 "_DIS", NULL, NULL);
119 return ACPI_FAILURE(status) ? -ENODEV : 0; 127 return ACPI_FAILURE(status) ? -ENODEV : 0;
120} 128}
121 129
130#ifdef CONFIG_ACPI_SLEEP
131static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
132{
133 return acpi_bus_set_power((acpi_handle) dev->data,
134 acpi_pm_device_sleep_state(&dev->dev,
135 device_may_wakeup
136 (&dev->dev),
137 NULL));
138}
139
140static int pnpacpi_resume(struct pnp_dev *dev)
141{
142 return acpi_bus_set_power((acpi_handle) dev->data, ACPI_STATE_D0);
143}
144#endif
145
122static struct pnp_protocol pnpacpi_protocol = { 146static struct pnp_protocol pnpacpi_protocol = {
123 .name = "Plug and Play ACPI", 147 .name = "Plug and Play ACPI",
124 .get = pnpacpi_get_resources, 148 .get = pnpacpi_get_resources,
125 .set = pnpacpi_set_resources, 149 .set = pnpacpi_set_resources,
126 .disable = pnpacpi_disable_resources, 150 .disable = pnpacpi_disable_resources,
151#ifdef CONFIG_ACPI_SLEEP
152 .suspend = pnpacpi_suspend,
153 .resume = pnpacpi_resume,
154#endif
127}; 155};
128 156
129static int __init pnpacpi_add_device(struct acpi_device *device) 157static int __init pnpacpi_add_device(struct acpi_device *device)
@@ -135,17 +163,17 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
135 163
136 status = acpi_get_handle(device->handle, "_CRS", &temp); 164 status = acpi_get_handle(device->handle, "_CRS", &temp);
137 if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) || 165 if (ACPI_FAILURE(status) || !ispnpidacpi(acpi_device_hid(device)) ||
138 is_exclusive_device(device)) 166 is_exclusive_device(device))
139 return 0; 167 return 0;
140 168
141 pnp_dbg("ACPI device : hid %s", acpi_device_hid(device)); 169 pnp_dbg("ACPI device : hid %s", acpi_device_hid(device));
142 dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); 170 dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
143 if (!dev) { 171 if (!dev) {
144 pnp_err("Out of memory"); 172 pnp_err("Out of memory");
145 return -ENOMEM; 173 return -ENOMEM;
146 } 174 }
147 dev->data = device->handle; 175 dev->data = device->handle;
148 /* .enabled means if the device can decode the resources */ 176 /* .enabled means the device can decode the resources */
149 dev->active = device->status.enabled; 177 dev->active = device->status.enabled;
150 status = acpi_get_handle(device->handle, "_SRS", &temp); 178 status = acpi_get_handle(device->handle, "_SRS", &temp);
151 if (ACPI_SUCCESS(status)) 179 if (ACPI_SUCCESS(status))
@@ -175,20 +203,23 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
175 pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); 203 pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id);
176 pnp_add_id(dev_id, dev); 204 pnp_add_id(dev_id, dev);
177 205
178 if(dev->active) { 206 if (dev->active) {
179 /* parse allocated resource */ 207 /* parse allocated resource */
180 status = pnpacpi_parse_allocated_resource(device->handle, &dev->res); 208 status = pnpacpi_parse_allocated_resource(device->handle,
209 &dev->res);
181 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 210 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
182 pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s", dev_id->id); 211 pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s",
212 dev_id->id);
183 goto err1; 213 goto err1;
184 } 214 }
185 } 215 }
186 216
187 if(dev->capabilities & PNP_CONFIGURABLE) { 217 if (dev->capabilities & PNP_CONFIGURABLE) {
188 status = pnpacpi_parse_resource_option_data(device->handle, 218 status = pnpacpi_parse_resource_option_data(device->handle,
189 dev); 219 dev);
190 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { 220 if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) {
191 pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s", dev_id->id); 221 pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s",
222 dev_id->id);
192 goto err1; 223 goto err1;
193 } 224 }
194 } 225 }
@@ -214,18 +245,19 @@ static int __init pnpacpi_add_device(struct acpi_device *device)
214 if (!dev->active) 245 if (!dev->active)
215 pnp_init_resource_table(&dev->res); 246 pnp_init_resource_table(&dev->res);
216 pnp_add_device(dev); 247 pnp_add_device(dev);
217 num ++; 248 num++;
218 249
219 return AE_OK; 250 return AE_OK;
220err1: 251 err1:
221 kfree(dev_id); 252 kfree(dev_id);
222err: 253 err:
223 kfree(dev); 254 kfree(dev);
224 return -EINVAL; 255 return -EINVAL;
225} 256}
226 257
227static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, 258static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
228 u32 lvl, void *context, void **rv) 259 u32 lvl, void *context,
260 void **rv)
229{ 261{
230 struct acpi_device *device; 262 struct acpi_device *device;
231 263
@@ -238,23 +270,22 @@ static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
238 270
239static int __init acpi_pnp_match(struct device *dev, void *_pnp) 271static int __init acpi_pnp_match(struct device *dev, void *_pnp)
240{ 272{
241 struct acpi_device *acpi = to_acpi_device(dev); 273 struct acpi_device *acpi = to_acpi_device(dev);
242 struct pnp_dev *pnp = _pnp; 274 struct pnp_dev *pnp = _pnp;
243 275
244 /* true means it matched */ 276 /* true means it matched */
245 return acpi->flags.hardware_id 277 return acpi->flags.hardware_id
246 && !acpi_get_physical_device(acpi->handle) 278 && !acpi_get_physical_device(acpi->handle)
247 && compare_pnp_id(pnp->id, acpi->pnp.hardware_id); 279 && compare_pnp_id(pnp->id, acpi->pnp.hardware_id);
248} 280}
249 281
250static int __init acpi_pnp_find_device(struct device *dev, acpi_handle *handle) 282static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle)
251{ 283{
252 struct device *adev; 284 struct device *adev;
253 struct acpi_device *acpi; 285 struct acpi_device *acpi;
254 286
255 adev = bus_find_device(&acpi_bus_type, NULL, 287 adev = bus_find_device(&acpi_bus_type, NULL,
256 to_pnp_dev(dev), 288 to_pnp_dev(dev), acpi_pnp_match);
257 acpi_pnp_match);
258 if (!adev) 289 if (!adev)
259 return -ENODEV; 290 return -ENODEV;
260 291
@@ -268,7 +299,7 @@ static int __init acpi_pnp_find_device(struct device *dev, acpi_handle *handle)
268 * pnpdev->dev.archdata.acpi_handle point to its ACPI sibling. 299 * pnpdev->dev.archdata.acpi_handle point to its ACPI sibling.
269 */ 300 */
270static struct acpi_bus_type __initdata acpi_pnp_bus = { 301static struct acpi_bus_type __initdata acpi_pnp_bus = {
271 .bus = &pnp_bus_type, 302 .bus = &pnp_bus_type,
272 .find_device = acpi_pnp_find_device, 303 .find_device = acpi_pnp_find_device,
273}; 304};
274 305
@@ -288,6 +319,7 @@ static int __init pnpacpi_init(void)
288 pnp_platform_devices = 1; 319 pnp_platform_devices = 1;
289 return 0; 320 return 0;
290} 321}
322
291subsys_initcall(pnpacpi_init); 323subsys_initcall(pnpacpi_init);
292 324
293static int __init pnpacpi_setup(char *str) 325static int __init pnpacpi_setup(char *str)
@@ -298,8 +330,5 @@ static int __init pnpacpi_setup(char *str)
298 pnpacpi_disabled = 1; 330 pnpacpi_disabled = 1;
299 return 1; 331 return 1;
300} 332}
301__setup("pnpacpi=", pnpacpi_setup);
302 333
303#if 0 334__setup("pnpacpi=", pnpacpi_setup);
304EXPORT_SYMBOL(pnpacpi_protocol);
305#endif
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 118ac9779b3c..ce5027feb3da 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -40,8 +40,7 @@ static int irq_flags(int triggering, int polarity)
40 flag = IORESOURCE_IRQ_LOWLEVEL; 40 flag = IORESOURCE_IRQ_LOWLEVEL;
41 else 41 else
42 flag = IORESOURCE_IRQ_HIGHLEVEL; 42 flag = IORESOURCE_IRQ_HIGHLEVEL;
43 } 43 } else {
44 else {
45 if (polarity == ACPI_ACTIVE_LOW) 44 if (polarity == ACPI_ACTIVE_LOW)
46 flag = IORESOURCE_IRQ_LOWEDGE; 45 flag = IORESOURCE_IRQ_LOWEDGE;
47 else 46 else
@@ -72,9 +71,9 @@ static void decode_irq_flags(int flag, int *triggering, int *polarity)
72 } 71 }
73} 72}
74 73
75static void 74static void pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res,
76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi, 75 u32 gsi, int triggering,
77 int triggering, int polarity, int shareable) 76 int polarity, int shareable)
78{ 77{
79 int i = 0; 78 int i = 0;
80 int irq; 79 int irq;
@@ -83,12 +82,12 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi,
83 return; 82 return;
84 83
85 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && 84 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
86 i < PNP_MAX_IRQ) 85 i < PNP_MAX_IRQ)
87 i++; 86 i++;
88 if (i >= PNP_MAX_IRQ) 87 if (i >= PNP_MAX_IRQ)
89 return; 88 return;
90 89
91 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 90 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
92 res->irq_resource[i].flags |= irq_flags(triggering, polarity); 91 res->irq_resource[i].flags |= irq_flags(triggering, polarity);
93 irq = acpi_register_gsi(gsi, triggering, polarity); 92 irq = acpi_register_gsi(gsi, triggering, polarity);
94 if (irq < 0) { 93 if (irq < 0) {
@@ -147,17 +146,19 @@ static int dma_flags(int type, int bus_master, int transfer)
147 return flags; 146 return flags;
148} 147}
149 148
150static void 149static void pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res,
151pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma, 150 u32 dma, int type,
152 int type, int bus_master, int transfer) 151 int bus_master, int transfer)
153{ 152{
154 int i = 0; 153 int i = 0;
154
155 while (i < PNP_MAX_DMA && 155 while (i < PNP_MAX_DMA &&
156 !(res->dma_resource[i].flags & IORESOURCE_UNSET)) 156 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
157 i++; 157 i++;
158 if (i < PNP_MAX_DMA) { 158 if (i < PNP_MAX_DMA) {
159 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag 159 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
160 res->dma_resource[i].flags |= dma_flags(type, bus_master, transfer); 160 res->dma_resource[i].flags |=
161 dma_flags(type, bus_master, transfer);
161 if (dma == -1) { 162 if (dma == -1) {
162 res->dma_resource[i].flags |= IORESOURCE_DISABLED; 163 res->dma_resource[i].flags |= IORESOURCE_DISABLED;
163 return; 164 return;
@@ -167,19 +168,19 @@ pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma,
167 } 168 }
168} 169}
169 170
170static void 171static void pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
171pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res, 172 u64 io, u64 len, int io_decode)
172 u64 io, u64 len, int io_decode)
173{ 173{
174 int i = 0; 174 int i = 0;
175
175 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && 176 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) &&
176 i < PNP_MAX_PORT) 177 i < PNP_MAX_PORT)
177 i++; 178 i++;
178 if (i < PNP_MAX_PORT) { 179 if (i < PNP_MAX_PORT) {
179 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag 180 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag
180 if (io_decode == ACPI_DECODE_16) 181 if (io_decode == ACPI_DECODE_16)
181 res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR; 182 res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR;
182 if (len <= 0 || (io + len -1) >= 0x10003) { 183 if (len <= 0 || (io + len - 1) >= 0x10003) {
183 res->port_resource[i].flags |= IORESOURCE_DISABLED; 184 res->port_resource[i].flags |= IORESOURCE_DISABLED;
184 return; 185 return;
185 } 186 }
@@ -188,21 +189,22 @@ pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
188 } 189 }
189} 190}
190 191
191static void 192static void pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
192pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res, 193 u64 mem, u64 len,
193 u64 mem, u64 len, int write_protect) 194 int write_protect)
194{ 195{
195 int i = 0; 196 int i = 0;
197
196 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && 198 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) &&
197 (i < PNP_MAX_MEM)) 199 (i < PNP_MAX_MEM))
198 i++; 200 i++;
199 if (i < PNP_MAX_MEM) { 201 if (i < PNP_MAX_MEM) {
200 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag 202 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag
201 if (len <= 0) { 203 if (len <= 0) {
202 res->mem_resource[i].flags |= IORESOURCE_DISABLED; 204 res->mem_resource[i].flags |= IORESOURCE_DISABLED;
203 return; 205 return;
204 } 206 }
205 if(write_protect == ACPI_READ_WRITE_MEMORY) 207 if (write_protect == ACPI_READ_WRITE_MEMORY)
206 res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE; 208 res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE;
207 209
208 res->mem_resource[i].start = mem; 210 res->mem_resource[i].start = mem;
@@ -210,9 +212,8 @@ pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
210 } 212 }
211} 213}
212 214
213static void 215static void pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table,
214pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table, 216 struct acpi_resource *res)
215 struct acpi_resource *res)
216{ 217{
217 struct acpi_resource_address64 addr, *p = &addr; 218 struct acpi_resource_address64 addr, *p = &addr;
218 acpi_status status; 219 acpi_status status;
@@ -220,7 +221,7 @@ pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table,
220 status = acpi_resource_to_address64(res, p); 221 status = acpi_resource_to_address64(res, p);
221 if (!ACPI_SUCCESS(status)) { 222 if (!ACPI_SUCCESS(status)) {
222 pnp_warn("PnPACPI: failed to convert resource type %d", 223 pnp_warn("PnPACPI: failed to convert resource type %d",
223 res->type); 224 res->type);
224 return; 225 return;
225 } 226 }
226 227
@@ -229,17 +230,20 @@ pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table,
229 230
230 if (p->resource_type == ACPI_MEMORY_RANGE) 231 if (p->resource_type == ACPI_MEMORY_RANGE)
231 pnpacpi_parse_allocated_memresource(res_table, 232 pnpacpi_parse_allocated_memresource(res_table,
232 p->minimum, p->address_length, p->info.mem.write_protect); 233 p->minimum, p->address_length,
234 p->info.mem.write_protect);
233 else if (p->resource_type == ACPI_IO_RANGE) 235 else if (p->resource_type == ACPI_IO_RANGE)
234 pnpacpi_parse_allocated_ioresource(res_table, 236 pnpacpi_parse_allocated_ioresource(res_table,
235 p->minimum, p->address_length, 237 p->minimum, p->address_length,
236 p->granularity == 0xfff ? ACPI_DECODE_10 : ACPI_DECODE_16); 238 p->granularity == 0xfff ? ACPI_DECODE_10 :
239 ACPI_DECODE_16);
237} 240}
238 241
239static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 242static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
240 void *data) 243 void *data)
241{ 244{
242 struct pnp_resource_table *res_table = (struct pnp_resource_table *)data; 245 struct pnp_resource_table *res_table =
246 (struct pnp_resource_table *)data;
243 int i; 247 int i;
244 248
245 switch (res->type) { 249 switch (res->type) {
@@ -260,17 +264,17 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
260 case ACPI_RESOURCE_TYPE_DMA: 264 case ACPI_RESOURCE_TYPE_DMA:
261 if (res->data.dma.channel_count > 0) 265 if (res->data.dma.channel_count > 0)
262 pnpacpi_parse_allocated_dmaresource(res_table, 266 pnpacpi_parse_allocated_dmaresource(res_table,
263 res->data.dma.channels[0], 267 res->data.dma.channels[0],
264 res->data.dma.type, 268 res->data.dma.type,
265 res->data.dma.bus_master, 269 res->data.dma.bus_master,
266 res->data.dma.transfer); 270 res->data.dma.transfer);
267 break; 271 break;
268 272
269 case ACPI_RESOURCE_TYPE_IO: 273 case ACPI_RESOURCE_TYPE_IO:
270 pnpacpi_parse_allocated_ioresource(res_table, 274 pnpacpi_parse_allocated_ioresource(res_table,
271 res->data.io.minimum, 275 res->data.io.minimum,
272 res->data.io.address_length, 276 res->data.io.address_length,
273 res->data.io.io_decode); 277 res->data.io.io_decode);
274 break; 278 break;
275 279
276 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 280 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
@@ -279,9 +283,9 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
279 283
280 case ACPI_RESOURCE_TYPE_FIXED_IO: 284 case ACPI_RESOURCE_TYPE_FIXED_IO:
281 pnpacpi_parse_allocated_ioresource(res_table, 285 pnpacpi_parse_allocated_ioresource(res_table,
282 res->data.fixed_io.address, 286 res->data.fixed_io.address,
283 res->data.fixed_io.address_length, 287 res->data.fixed_io.address_length,
284 ACPI_DECODE_10); 288 ACPI_DECODE_10);
285 break; 289 break;
286 290
287 case ACPI_RESOURCE_TYPE_VENDOR: 291 case ACPI_RESOURCE_TYPE_VENDOR:
@@ -292,21 +296,21 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
292 296
293 case ACPI_RESOURCE_TYPE_MEMORY24: 297 case ACPI_RESOURCE_TYPE_MEMORY24:
294 pnpacpi_parse_allocated_memresource(res_table, 298 pnpacpi_parse_allocated_memresource(res_table,
295 res->data.memory24.minimum, 299 res->data.memory24.minimum,
296 res->data.memory24.address_length, 300 res->data.memory24.address_length,
297 res->data.memory24.write_protect); 301 res->data.memory24.write_protect);
298 break; 302 break;
299 case ACPI_RESOURCE_TYPE_MEMORY32: 303 case ACPI_RESOURCE_TYPE_MEMORY32:
300 pnpacpi_parse_allocated_memresource(res_table, 304 pnpacpi_parse_allocated_memresource(res_table,
301 res->data.memory32.minimum, 305 res->data.memory32.minimum,
302 res->data.memory32.address_length, 306 res->data.memory32.address_length,
303 res->data.memory32.write_protect); 307 res->data.memory32.write_protect);
304 break; 308 break;
305 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 309 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
306 pnpacpi_parse_allocated_memresource(res_table, 310 pnpacpi_parse_allocated_memresource(res_table,
307 res->data.fixed_memory32.address, 311 res->data.fixed_memory32.address,
308 res->data.fixed_memory32.address_length, 312 res->data.fixed_memory32.address_length,
309 res->data.fixed_memory32.write_protect); 313 res->data.fixed_memory32.write_protect);
310 break; 314 break;
311 case ACPI_RESOURCE_TYPE_ADDRESS16: 315 case ACPI_RESOURCE_TYPE_ADDRESS16:
312 case ACPI_RESOURCE_TYPE_ADDRESS32: 316 case ACPI_RESOURCE_TYPE_ADDRESS32:
@@ -343,18 +347,21 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
343 return AE_OK; 347 return AE_OK;
344} 348}
345 349
346acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table *res) 350acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle,
351 struct pnp_resource_table * res)
347{ 352{
348 /* Blank the resource table values */ 353 /* Blank the resource table values */
349 pnp_init_resource_table(res); 354 pnp_init_resource_table(res);
350 355
351 return acpi_walk_resources(handle, METHOD_NAME__CRS, pnpacpi_allocated_resource, res); 356 return acpi_walk_resources(handle, METHOD_NAME__CRS,
357 pnpacpi_allocated_resource, res);
352} 358}
353 359
354static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_resource_dma *p) 360static void pnpacpi_parse_dma_option(struct pnp_option *option,
361 struct acpi_resource_dma *p)
355{ 362{
356 int i; 363 int i;
357 struct pnp_dma * dma; 364 struct pnp_dma *dma;
358 365
359 if (p->channel_count == 0) 366 if (p->channel_count == 0)
360 return; 367 return;
@@ -362,18 +369,16 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso
362 if (!dma) 369 if (!dma)
363 return; 370 return;
364 371
365 for(i = 0; i < p->channel_count; i++) 372 for (i = 0; i < p->channel_count; i++)
366 dma->map |= 1 << p->channels[i]; 373 dma->map |= 1 << p->channels[i];
367 374
368 dma->flags = dma_flags(p->type, p->bus_master, p->transfer); 375 dma->flags = dma_flags(p->type, p->bus_master, p->transfer);
369 376
370 pnp_register_dma_resource(option, dma); 377 pnp_register_dma_resource(option, dma);
371 return;
372} 378}
373 379
374
375static void pnpacpi_parse_irq_option(struct pnp_option *option, 380static void pnpacpi_parse_irq_option(struct pnp_option *option,
376 struct acpi_resource_irq *p) 381 struct acpi_resource_irq *p)
377{ 382{
378 int i; 383 int i;
379 struct pnp_irq *irq; 384 struct pnp_irq *irq;
@@ -384,17 +389,16 @@ static void pnpacpi_parse_irq_option(struct pnp_option *option,
384 if (!irq) 389 if (!irq)
385 return; 390 return;
386 391
387 for(i = 0; i < p->interrupt_count; i++) 392 for (i = 0; i < p->interrupt_count; i++)
388 if (p->interrupts[i]) 393 if (p->interrupts[i])
389 __set_bit(p->interrupts[i], irq->map); 394 __set_bit(p->interrupts[i], irq->map);
390 irq->flags = irq_flags(p->triggering, p->polarity); 395 irq->flags = irq_flags(p->triggering, p->polarity);
391 396
392 pnp_register_irq_resource(option, irq); 397 pnp_register_irq_resource(option, irq);
393 return;
394} 398}
395 399
396static void pnpacpi_parse_ext_irq_option(struct pnp_option *option, 400static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
397 struct acpi_resource_extended_irq *p) 401 struct acpi_resource_extended_irq *p)
398{ 402{
399 int i; 403 int i;
400 struct pnp_irq *irq; 404 struct pnp_irq *irq;
@@ -405,18 +409,16 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
405 if (!irq) 409 if (!irq)
406 return; 410 return;
407 411
408 for(i = 0; i < p->interrupt_count; i++) 412 for (i = 0; i < p->interrupt_count; i++)
409 if (p->interrupts[i]) 413 if (p->interrupts[i])
410 __set_bit(p->interrupts[i], irq->map); 414 __set_bit(p->interrupts[i], irq->map);
411 irq->flags = irq_flags(p->triggering, p->polarity); 415 irq->flags = irq_flags(p->triggering, p->polarity);
412 416
413 pnp_register_irq_resource(option, irq); 417 pnp_register_irq_resource(option, irq);
414 return;
415} 418}
416 419
417static void 420static void pnpacpi_parse_port_option(struct pnp_option *option,
418pnpacpi_parse_port_option(struct pnp_option *option, 421 struct acpi_resource_io *io)
419 struct acpi_resource_io *io)
420{ 422{
421 struct pnp_port *port; 423 struct pnp_port *port;
422 424
@@ -430,14 +432,12 @@ pnpacpi_parse_port_option(struct pnp_option *option,
430 port->align = io->alignment; 432 port->align = io->alignment;
431 port->size = io->address_length; 433 port->size = io->address_length;
432 port->flags = ACPI_DECODE_16 == io->io_decode ? 434 port->flags = ACPI_DECODE_16 == io->io_decode ?
433 PNP_PORT_FLAG_16BITADDR : 0; 435 PNP_PORT_FLAG_16BITADDR : 0;
434 pnp_register_port_resource(option, port); 436 pnp_register_port_resource(option, port);
435 return;
436} 437}
437 438
438static void 439static void pnpacpi_parse_fixed_port_option(struct pnp_option *option,
439pnpacpi_parse_fixed_port_option(struct pnp_option *option, 440 struct acpi_resource_fixed_io *io)
440 struct acpi_resource_fixed_io *io)
441{ 441{
442 struct pnp_port *port; 442 struct pnp_port *port;
443 443
@@ -451,12 +451,10 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
451 port->align = 0; 451 port->align = 0;
452 port->flags = PNP_PORT_FLAG_FIXED; 452 port->flags = PNP_PORT_FLAG_FIXED;
453 pnp_register_port_resource(option, port); 453 pnp_register_port_resource(option, port);
454 return;
455} 454}
456 455
457static void 456static void pnpacpi_parse_mem24_option(struct pnp_option *option,
458pnpacpi_parse_mem24_option(struct pnp_option *option, 457 struct acpi_resource_memory24 *p)
459 struct acpi_resource_memory24 *p)
460{ 458{
461 struct pnp_mem *mem; 459 struct pnp_mem *mem;
462 460
@@ -471,15 +469,13 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,
471 mem->size = p->address_length; 469 mem->size = p->address_length;
472 470
473 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 471 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
474 IORESOURCE_MEM_WRITEABLE : 0; 472 IORESOURCE_MEM_WRITEABLE : 0;
475 473
476 pnp_register_mem_resource(option, mem); 474 pnp_register_mem_resource(option, mem);
477 return;
478} 475}
479 476
480static void 477static void pnpacpi_parse_mem32_option(struct pnp_option *option,
481pnpacpi_parse_mem32_option(struct pnp_option *option, 478 struct acpi_resource_memory32 *p)
482 struct acpi_resource_memory32 *p)
483{ 479{
484 struct pnp_mem *mem; 480 struct pnp_mem *mem;
485 481
@@ -494,15 +490,13 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,
494 mem->size = p->address_length; 490 mem->size = p->address_length;
495 491
496 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 492 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
497 IORESOURCE_MEM_WRITEABLE : 0; 493 IORESOURCE_MEM_WRITEABLE : 0;
498 494
499 pnp_register_mem_resource(option, mem); 495 pnp_register_mem_resource(option, mem);
500 return;
501} 496}
502 497
503static void 498static void pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
504pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, 499 struct acpi_resource_fixed_memory32 *p)
505 struct acpi_resource_fixed_memory32 *p)
506{ 500{
507 struct pnp_mem *mem; 501 struct pnp_mem *mem;
508 502
@@ -516,14 +510,13 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
516 mem->align = 0; 510 mem->align = 0;
517 511
518 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 512 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
519 IORESOURCE_MEM_WRITEABLE : 0; 513 IORESOURCE_MEM_WRITEABLE : 0;
520 514
521 pnp_register_mem_resource(option, mem); 515 pnp_register_mem_resource(option, mem);
522 return;
523} 516}
524 517
525static void 518static void pnpacpi_parse_address_option(struct pnp_option *option,
526pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r) 519 struct acpi_resource *r)
527{ 520{
528 struct acpi_resource_address64 addr, *p = &addr; 521 struct acpi_resource_address64 addr, *p = &addr;
529 acpi_status status; 522 acpi_status status;
@@ -532,7 +525,8 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
532 525
533 status = acpi_resource_to_address64(r, p); 526 status = acpi_resource_to_address64(r, p);
534 if (!ACPI_SUCCESS(status)) { 527 if (!ACPI_SUCCESS(status)) {
535 pnp_warn("PnPACPI: failed to convert resource type %d", r->type); 528 pnp_warn("PnPACPI: failed to convert resource type %d",
529 r->type);
536 return; 530 return;
537 } 531 }
538 532
@@ -547,7 +541,8 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
547 mem->size = p->address_length; 541 mem->size = p->address_length;
548 mem->align = 0; 542 mem->align = 0;
549 mem->flags = (p->info.mem.write_protect == 543 mem->flags = (p->info.mem.write_protect ==
550 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; 544 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE
545 : 0;
551 pnp_register_mem_resource(option, mem); 546 pnp_register_mem_resource(option, mem);
552 } else if (p->resource_type == ACPI_IO_RANGE) { 547 } else if (p->resource_type == ACPI_IO_RANGE) {
553 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 548 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
@@ -568,109 +563,108 @@ struct acpipnp_parse_option_s {
568}; 563};
569 564
570static acpi_status pnpacpi_option_resource(struct acpi_resource *res, 565static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
571 void *data) 566 void *data)
572{ 567{
573 int priority = 0; 568 int priority = 0;
574 struct acpipnp_parse_option_s *parse_data = (struct acpipnp_parse_option_s *)data; 569 struct acpipnp_parse_option_s *parse_data =
570 (struct acpipnp_parse_option_s *)data;
575 struct pnp_dev *dev = parse_data->dev; 571 struct pnp_dev *dev = parse_data->dev;
576 struct pnp_option *option = parse_data->option; 572 struct pnp_option *option = parse_data->option;
577 573
578 switch (res->type) { 574 switch (res->type) {
579 case ACPI_RESOURCE_TYPE_IRQ: 575 case ACPI_RESOURCE_TYPE_IRQ:
580 pnpacpi_parse_irq_option(option, &res->data.irq); 576 pnpacpi_parse_irq_option(option, &res->data.irq);
581 break; 577 break;
582 578
583 case ACPI_RESOURCE_TYPE_DMA: 579 case ACPI_RESOURCE_TYPE_DMA:
584 pnpacpi_parse_dma_option(option, &res->data.dma); 580 pnpacpi_parse_dma_option(option, &res->data.dma);
585 break; 581 break;
586 582
587 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 583 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
588 switch (res->data.start_dpf.compatibility_priority) { 584 switch (res->data.start_dpf.compatibility_priority) {
589 case ACPI_GOOD_CONFIGURATION: 585 case ACPI_GOOD_CONFIGURATION:
590 priority = PNP_RES_PRIORITY_PREFERRED; 586 priority = PNP_RES_PRIORITY_PREFERRED;
591 break;
592
593 case ACPI_ACCEPTABLE_CONFIGURATION:
594 priority = PNP_RES_PRIORITY_ACCEPTABLE;
595 break;
596
597 case ACPI_SUB_OPTIMAL_CONFIGURATION:
598 priority = PNP_RES_PRIORITY_FUNCTIONAL;
599 break;
600 default:
601 priority = PNP_RES_PRIORITY_INVALID;
602 break;
603 }
604 /* TBD: Considering performace/robustness bits */
605 option = pnp_register_dependent_option(dev, priority);
606 if (!option)
607 return AE_ERROR;
608 parse_data->option = option;
609 break; 587 break;
610 588
611 case ACPI_RESOURCE_TYPE_END_DEPENDENT: 589 case ACPI_ACCEPTABLE_CONFIGURATION:
612 /*only one EndDependentFn is allowed*/ 590 priority = PNP_RES_PRIORITY_ACCEPTABLE;
613 if (!parse_data->option_independent) {
614 pnp_warn("PnPACPI: more than one EndDependentFn");
615 return AE_ERROR;
616 }
617 parse_data->option = parse_data->option_independent;
618 parse_data->option_independent = NULL;
619 break; 591 break;
620 592
621 case ACPI_RESOURCE_TYPE_IO: 593 case ACPI_SUB_OPTIMAL_CONFIGURATION:
622 pnpacpi_parse_port_option(option, &res->data.io); 594 priority = PNP_RES_PRIORITY_FUNCTIONAL;
623 break; 595 break;
624 596 default:
625 case ACPI_RESOURCE_TYPE_FIXED_IO: 597 priority = PNP_RES_PRIORITY_INVALID;
626 pnpacpi_parse_fixed_port_option(option,
627 &res->data.fixed_io);
628 break; 598 break;
599 }
600 /* TBD: Consider performance/robustness bits */
601 option = pnp_register_dependent_option(dev, priority);
602 if (!option)
603 return AE_ERROR;
604 parse_data->option = option;
605 break;
629 606
630 case ACPI_RESOURCE_TYPE_VENDOR: 607 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
631 case ACPI_RESOURCE_TYPE_END_TAG: 608 /*only one EndDependentFn is allowed */
632 break; 609 if (!parse_data->option_independent) {
610 pnp_warn("PnPACPI: more than one EndDependentFn");
611 return AE_ERROR;
612 }
613 parse_data->option = parse_data->option_independent;
614 parse_data->option_independent = NULL;
615 break;
633 616
634 case ACPI_RESOURCE_TYPE_MEMORY24: 617 case ACPI_RESOURCE_TYPE_IO:
635 pnpacpi_parse_mem24_option(option, &res->data.memory24); 618 pnpacpi_parse_port_option(option, &res->data.io);
636 break; 619 break;
637 620
638 case ACPI_RESOURCE_TYPE_MEMORY32: 621 case ACPI_RESOURCE_TYPE_FIXED_IO:
639 pnpacpi_parse_mem32_option(option, &res->data.memory32); 622 pnpacpi_parse_fixed_port_option(option, &res->data.fixed_io);
640 break; 623 break;
641 624
642 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 625 case ACPI_RESOURCE_TYPE_VENDOR:
643 pnpacpi_parse_fixed_mem32_option(option, 626 case ACPI_RESOURCE_TYPE_END_TAG:
644 &res->data.fixed_memory32); 627 break;
645 break;
646 628
647 case ACPI_RESOURCE_TYPE_ADDRESS16: 629 case ACPI_RESOURCE_TYPE_MEMORY24:
648 case ACPI_RESOURCE_TYPE_ADDRESS32: 630 pnpacpi_parse_mem24_option(option, &res->data.memory24);
649 case ACPI_RESOURCE_TYPE_ADDRESS64: 631 break;
650 pnpacpi_parse_address_option(option, res);
651 break;
652 632
653 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: 633 case ACPI_RESOURCE_TYPE_MEMORY32:
654 break; 634 pnpacpi_parse_mem32_option(option, &res->data.memory32);
635 break;
655 636
656 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 637 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
657 pnpacpi_parse_ext_irq_option(option, 638 pnpacpi_parse_fixed_mem32_option(option,
658 &res->data.extended_irq); 639 &res->data.fixed_memory32);
659 break; 640 break;
660 641
661 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: 642 case ACPI_RESOURCE_TYPE_ADDRESS16:
662 break; 643 case ACPI_RESOURCE_TYPE_ADDRESS32:
644 case ACPI_RESOURCE_TYPE_ADDRESS64:
645 pnpacpi_parse_address_option(option, res);
646 break;
663 647
664 default: 648 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
665 pnp_warn("PnPACPI: unknown resource type %d", res->type); 649 break;
666 return AE_ERROR; 650
651 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
652 pnpacpi_parse_ext_irq_option(option, &res->data.extended_irq);
653 break;
654
655 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
656 break;
657
658 default:
659 pnp_warn("PnPACPI: unknown resource type %d", res->type);
660 return AE_ERROR;
667 } 661 }
668 662
669 return AE_OK; 663 return AE_OK;
670} 664}
671 665
672acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle, 666acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
673 struct pnp_dev *dev) 667 struct pnp_dev * dev)
674{ 668{
675 acpi_status status; 669 acpi_status status;
676 struct acpipnp_parse_option_s parse_data; 670 struct acpipnp_parse_option_s parse_data;
@@ -681,7 +675,7 @@ acpi_status pnpacpi_parse_resource_option_data(acpi_handle handle,
681 parse_data.option_independent = parse_data.option; 675 parse_data.option_independent = parse_data.option;
682 parse_data.dev = dev; 676 parse_data.dev = dev;
683 status = acpi_walk_resources(handle, METHOD_NAME__PRS, 677 status = acpi_walk_resources(handle, METHOD_NAME__PRS,
684 pnpacpi_option_resource, &parse_data); 678 pnpacpi_option_resource, &parse_data);
685 679
686 return status; 680 return status;
687} 681}
@@ -709,7 +703,7 @@ static int pnpacpi_supported_resource(struct acpi_resource *res)
709 * Set resource 703 * Set resource
710 */ 704 */
711static acpi_status pnpacpi_count_resources(struct acpi_resource *res, 705static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
712 void *data) 706 void *data)
713{ 707{
714 int *res_cnt = (int *)data; 708 int *res_cnt = (int *)data;
715 709
@@ -732,14 +726,14 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data)
732} 726}
733 727
734int pnpacpi_build_resource_template(acpi_handle handle, 728int pnpacpi_build_resource_template(acpi_handle handle,
735 struct acpi_buffer *buffer) 729 struct acpi_buffer *buffer)
736{ 730{
737 struct acpi_resource *resource; 731 struct acpi_resource *resource;
738 int res_cnt = 0; 732 int res_cnt = 0;
739 acpi_status status; 733 acpi_status status;
740 734
741 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 735 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
742 pnpacpi_count_resources, &res_cnt); 736 pnpacpi_count_resources, &res_cnt);
743 if (ACPI_FAILURE(status)) { 737 if (ACPI_FAILURE(status)) {
744 pnp_err("Evaluate _CRS failed"); 738 pnp_err("Evaluate _CRS failed");
745 return -EINVAL; 739 return -EINVAL;
@@ -753,7 +747,7 @@ int pnpacpi_build_resource_template(acpi_handle handle,
753 pnp_dbg("Res cnt %d", res_cnt); 747 pnp_dbg("Res cnt %d", res_cnt);
754 resource = (struct acpi_resource *)buffer->pointer; 748 resource = (struct acpi_resource *)buffer->pointer;
755 status = acpi_walk_resources(handle, METHOD_NAME__CRS, 749 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
756 pnpacpi_type_resources, &resource); 750 pnpacpi_type_resources, &resource);
757 if (ACPI_FAILURE(status)) { 751 if (ACPI_FAILURE(status)) {
758 kfree(buffer->pointer); 752 kfree(buffer->pointer);
759 pnp_err("Evaluate _CRS failed"); 753 pnp_err("Evaluate _CRS failed");
@@ -766,7 +760,7 @@ int pnpacpi_build_resource_template(acpi_handle handle,
766} 760}
767 761
768static void pnpacpi_encode_irq(struct acpi_resource *resource, 762static void pnpacpi_encode_irq(struct acpi_resource *resource,
769 struct resource *p) 763 struct resource *p)
770{ 764{
771 int triggering, polarity; 765 int triggering, polarity;
772 766
@@ -782,7 +776,7 @@ static void pnpacpi_encode_irq(struct acpi_resource *resource,
782} 776}
783 777
784static void pnpacpi_encode_ext_irq(struct acpi_resource *resource, 778static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
785 struct resource *p) 779 struct resource *p)
786{ 780{
787 int triggering, polarity; 781 int triggering, polarity;
788 782
@@ -799,32 +793,32 @@ static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
799} 793}
800 794
801static void pnpacpi_encode_dma(struct acpi_resource *resource, 795static void pnpacpi_encode_dma(struct acpi_resource *resource,
802 struct resource *p) 796 struct resource *p)
803{ 797{
804 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */ 798 /* Note: pnp_assign_dma will copy pnp_dma->flags into p->flags */
805 switch (p->flags & IORESOURCE_DMA_SPEED_MASK) { 799 switch (p->flags & IORESOURCE_DMA_SPEED_MASK) {
806 case IORESOURCE_DMA_TYPEA: 800 case IORESOURCE_DMA_TYPEA:
807 resource->data.dma.type = ACPI_TYPE_A; 801 resource->data.dma.type = ACPI_TYPE_A;
808 break; 802 break;
809 case IORESOURCE_DMA_TYPEB: 803 case IORESOURCE_DMA_TYPEB:
810 resource->data.dma.type = ACPI_TYPE_B; 804 resource->data.dma.type = ACPI_TYPE_B;
811 break; 805 break;
812 case IORESOURCE_DMA_TYPEF: 806 case IORESOURCE_DMA_TYPEF:
813 resource->data.dma.type = ACPI_TYPE_F; 807 resource->data.dma.type = ACPI_TYPE_F;
814 break; 808 break;
815 default: 809 default:
816 resource->data.dma.type = ACPI_COMPATIBILITY; 810 resource->data.dma.type = ACPI_COMPATIBILITY;
817 } 811 }
818 812
819 switch (p->flags & IORESOURCE_DMA_TYPE_MASK) { 813 switch (p->flags & IORESOURCE_DMA_TYPE_MASK) {
820 case IORESOURCE_DMA_8BIT: 814 case IORESOURCE_DMA_8BIT:
821 resource->data.dma.transfer = ACPI_TRANSFER_8; 815 resource->data.dma.transfer = ACPI_TRANSFER_8;
822 break; 816 break;
823 case IORESOURCE_DMA_8AND16BIT: 817 case IORESOURCE_DMA_8AND16BIT:
824 resource->data.dma.transfer = ACPI_TRANSFER_8_16; 818 resource->data.dma.transfer = ACPI_TRANSFER_8_16;
825 break; 819 break;
826 default: 820 default:
827 resource->data.dma.transfer = ACPI_TRANSFER_16; 821 resource->data.dma.transfer = ACPI_TRANSFER_16;
828 } 822 }
829 823
830 resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER); 824 resource->data.dma.bus_master = !!(p->flags & IORESOURCE_DMA_MASTER);
@@ -833,31 +827,31 @@ static void pnpacpi_encode_dma(struct acpi_resource *resource,
833} 827}
834 828
835static void pnpacpi_encode_io(struct acpi_resource *resource, 829static void pnpacpi_encode_io(struct acpi_resource *resource,
836 struct resource *p) 830 struct resource *p)
837{ 831{
838 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */ 832 /* Note: pnp_assign_port will copy pnp_port->flags into p->flags */
839 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR)? 833 resource->data.io.io_decode = (p->flags & PNP_PORT_FLAG_16BITADDR) ?
840 ACPI_DECODE_16 : ACPI_DECODE_10; 834 ACPI_DECODE_16 : ACPI_DECODE_10;
841 resource->data.io.minimum = p->start; 835 resource->data.io.minimum = p->start;
842 resource->data.io.maximum = p->end; 836 resource->data.io.maximum = p->end;
843 resource->data.io.alignment = 0; /* Correct? */ 837 resource->data.io.alignment = 0; /* Correct? */
844 resource->data.io.address_length = p->end - p->start + 1; 838 resource->data.io.address_length = p->end - p->start + 1;
845} 839}
846 840
847static void pnpacpi_encode_fixed_io(struct acpi_resource *resource, 841static void pnpacpi_encode_fixed_io(struct acpi_resource *resource,
848 struct resource *p) 842 struct resource *p)
849{ 843{
850 resource->data.fixed_io.address = p->start; 844 resource->data.fixed_io.address = p->start;
851 resource->data.fixed_io.address_length = p->end - p->start + 1; 845 resource->data.fixed_io.address_length = p->end - p->start + 1;
852} 846}
853 847
854static void pnpacpi_encode_mem24(struct acpi_resource *resource, 848static void pnpacpi_encode_mem24(struct acpi_resource *resource,
855 struct resource *p) 849 struct resource *p)
856{ 850{
857 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */ 851 /* Note: pnp_assign_mem will copy pnp_mem->flags into p->flags */
858 resource->data.memory24.write_protect = 852 resource->data.memory24.write_protect =
859 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 853 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
860 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 854 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
861 resource->data.memory24.minimum = p->start; 855 resource->data.memory24.minimum = p->start;
862 resource->data.memory24.maximum = p->end; 856 resource->data.memory24.maximum = p->end;
863 resource->data.memory24.alignment = 0; 857 resource->data.memory24.alignment = 0;
@@ -865,11 +859,11 @@ static void pnpacpi_encode_mem24(struct acpi_resource *resource,
865} 859}
866 860
867static void pnpacpi_encode_mem32(struct acpi_resource *resource, 861static void pnpacpi_encode_mem32(struct acpi_resource *resource,
868 struct resource *p) 862 struct resource *p)
869{ 863{
870 resource->data.memory32.write_protect = 864 resource->data.memory32.write_protect =
871 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 865 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
872 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 866 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
873 resource->data.memory32.minimum = p->start; 867 resource->data.memory32.minimum = p->start;
874 resource->data.memory32.maximum = p->end; 868 resource->data.memory32.maximum = p->end;
875 resource->data.memory32.alignment = 0; 869 resource->data.memory32.alignment = 0;
@@ -877,74 +871,77 @@ static void pnpacpi_encode_mem32(struct acpi_resource *resource,
877} 871}
878 872
879static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource, 873static void pnpacpi_encode_fixed_mem32(struct acpi_resource *resource,
880 struct resource *p) 874 struct resource *p)
881{ 875{
882 resource->data.fixed_memory32.write_protect = 876 resource->data.fixed_memory32.write_protect =
883 (p->flags & IORESOURCE_MEM_WRITEABLE) ? 877 (p->flags & IORESOURCE_MEM_WRITEABLE) ?
884 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY; 878 ACPI_READ_WRITE_MEMORY : ACPI_READ_ONLY_MEMORY;
885 resource->data.fixed_memory32.address = p->start; 879 resource->data.fixed_memory32.address = p->start;
886 resource->data.fixed_memory32.address_length = p->end - p->start + 1; 880 resource->data.fixed_memory32.address_length = p->end - p->start + 1;
887} 881}
888 882
889int pnpacpi_encode_resources(struct pnp_resource_table *res_table, 883int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
890 struct acpi_buffer *buffer) 884 struct acpi_buffer *buffer)
891{ 885{
892 int i = 0; 886 int i = 0;
893 /* pnpacpi_build_resource_template allocates extra mem */ 887 /* pnpacpi_build_resource_template allocates extra mem */
894 int res_cnt = (buffer->length - 1)/sizeof(struct acpi_resource) - 1; 888 int res_cnt = (buffer->length - 1) / sizeof(struct acpi_resource) - 1;
895 struct acpi_resource *resource = (struct acpi_resource*)buffer->pointer; 889 struct acpi_resource *resource =
890 (struct acpi_resource *)buffer->pointer;
896 int port = 0, irq = 0, dma = 0, mem = 0; 891 int port = 0, irq = 0, dma = 0, mem = 0;
897 892
898 pnp_dbg("res cnt %d", res_cnt); 893 pnp_dbg("res cnt %d", res_cnt);
899 while (i < res_cnt) { 894 while (i < res_cnt) {
900 switch(resource->type) { 895 switch (resource->type) {
901 case ACPI_RESOURCE_TYPE_IRQ: 896 case ACPI_RESOURCE_TYPE_IRQ:
902 pnp_dbg("Encode irq"); 897 pnp_dbg("Encode irq");
903 pnpacpi_encode_irq(resource, 898 pnpacpi_encode_irq(resource,
904 &res_table->irq_resource[irq]); 899 &res_table->irq_resource[irq]);
905 irq++; 900 irq++;
906 break; 901 break;
907 902
908 case ACPI_RESOURCE_TYPE_DMA: 903 case ACPI_RESOURCE_TYPE_DMA:
909 pnp_dbg("Encode dma"); 904 pnp_dbg("Encode dma");
910 pnpacpi_encode_dma(resource, 905 pnpacpi_encode_dma(resource,
911 &res_table->dma_resource[dma]); 906 &res_table->dma_resource[dma]);
912 dma++; 907 dma++;
913 break; 908 break;
914 case ACPI_RESOURCE_TYPE_IO: 909 case ACPI_RESOURCE_TYPE_IO:
915 pnp_dbg("Encode io"); 910 pnp_dbg("Encode io");
916 pnpacpi_encode_io(resource, 911 pnpacpi_encode_io(resource,
917 &res_table->port_resource[port]); 912 &res_table->port_resource[port]);
918 port++; 913 port++;
919 break; 914 break;
920 case ACPI_RESOURCE_TYPE_FIXED_IO: 915 case ACPI_RESOURCE_TYPE_FIXED_IO:
921 pnp_dbg("Encode fixed io"); 916 pnp_dbg("Encode fixed io");
922 pnpacpi_encode_fixed_io(resource, 917 pnpacpi_encode_fixed_io(resource,
923 &res_table->port_resource[port]); 918 &res_table->
919 port_resource[port]);
924 port++; 920 port++;
925 break; 921 break;
926 case ACPI_RESOURCE_TYPE_MEMORY24: 922 case ACPI_RESOURCE_TYPE_MEMORY24:
927 pnp_dbg("Encode mem24"); 923 pnp_dbg("Encode mem24");
928 pnpacpi_encode_mem24(resource, 924 pnpacpi_encode_mem24(resource,
929 &res_table->mem_resource[mem]); 925 &res_table->mem_resource[mem]);
930 mem++; 926 mem++;
931 break; 927 break;
932 case ACPI_RESOURCE_TYPE_MEMORY32: 928 case ACPI_RESOURCE_TYPE_MEMORY32:
933 pnp_dbg("Encode mem32"); 929 pnp_dbg("Encode mem32");
934 pnpacpi_encode_mem32(resource, 930 pnpacpi_encode_mem32(resource,
935 &res_table->mem_resource[mem]); 931 &res_table->mem_resource[mem]);
936 mem++; 932 mem++;
937 break; 933 break;
938 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 934 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
939 pnp_dbg("Encode fixed mem32"); 935 pnp_dbg("Encode fixed mem32");
940 pnpacpi_encode_fixed_mem32(resource, 936 pnpacpi_encode_fixed_mem32(resource,
941 &res_table->mem_resource[mem]); 937 &res_table->
938 mem_resource[mem]);
942 mem++; 939 mem++;
943 break; 940 break;
944 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 941 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
945 pnp_dbg("Encode ext irq"); 942 pnp_dbg("Encode ext irq");
946 pnpacpi_encode_ext_irq(resource, 943 pnpacpi_encode_ext_irq(resource,
947 &res_table->irq_resource[irq]); 944 &res_table->irq_resource[irq]);
948 irq++; 945 irq++;
949 break; 946 break;
950 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 947 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
@@ -956,7 +953,7 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
956 case ACPI_RESOURCE_TYPE_ADDRESS64: 953 case ACPI_RESOURCE_TYPE_ADDRESS64:
957 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: 954 case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
958 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER: 955 case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
959 default: /* other type */ 956 default: /* other type */
960 pnp_warn("unknown resource type %d", resource->type); 957 pnp_warn("unknown resource type %d", resource->type);
961 return -EINVAL; 958 return -EINVAL;
962 } 959 }
diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
index a1f0b0ba2bfe..5dba68fe33f5 100644
--- a/drivers/pnp/pnpbios/bioscalls.c
+++ b/drivers/pnp/pnpbios/bioscalls.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * bioscalls.c - the lowlevel layer of the PnPBIOS driver 2 * bioscalls.c - the lowlevel layer of the PnPBIOS driver
3 *
4 */ 3 */
5 4
6#include <linux/types.h> 5#include <linux/types.h>
@@ -26,11 +25,10 @@
26#include "pnpbios.h" 25#include "pnpbios.h"
27 26
28static struct { 27static struct {
29 u16 offset; 28 u16 offset;
30 u16 segment; 29 u16 segment;
31} pnp_bios_callpoint; 30} pnp_bios_callpoint;
32 31
33
34/* 32/*
35 * These are some opcodes for a "static asmlinkage" 33 * These are some opcodes for a "static asmlinkage"
36 * As this code is *not* executed inside the linux kernel segment, but in a 34 * As this code is *not* executed inside the linux kernel segment, but in a
@@ -44,8 +42,7 @@ static struct {
44 42
45asmlinkage void pnp_bios_callfunc(void); 43asmlinkage void pnp_bios_callfunc(void);
46 44
47__asm__( 45__asm__(".text \n"
48 ".text \n"
49 __ALIGN_STR "\n" 46 __ALIGN_STR "\n"
50 "pnp_bios_callfunc:\n" 47 "pnp_bios_callfunc:\n"
51 " pushl %edx \n" 48 " pushl %edx \n"
@@ -55,8 +52,7 @@ __asm__(
55 " lcallw *pnp_bios_callpoint\n" 52 " lcallw *pnp_bios_callpoint\n"
56 " addl $16, %esp \n" 53 " addl $16, %esp \n"
57 " lret \n" 54 " lret \n"
58 ".previous \n" 55 ".previous \n");
59);
60 56
61#define Q2_SET_SEL(cpu, selname, address, size) \ 57#define Q2_SET_SEL(cpu, selname, address, size) \
62do { \ 58do { \
@@ -78,7 +74,6 @@ u32 pnp_bios_is_utter_crap = 0;
78 74
79static spinlock_t pnp_bios_lock; 75static spinlock_t pnp_bios_lock;
80 76
81
82/* 77/*
83 * Support Functions 78 * Support Functions
84 */ 79 */
@@ -97,7 +92,7 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
97 * PnP BIOSes are generally not terribly re-entrant. 92 * PnP BIOSes are generally not terribly re-entrant.
98 * Also, don't rely on them to save everything correctly. 93 * Also, don't rely on them to save everything correctly.
99 */ 94 */
100 if(pnp_bios_is_utter_crap) 95 if (pnp_bios_is_utter_crap)
101 return PNP_FUNCTION_NOT_SUPPORTED; 96 return PNP_FUNCTION_NOT_SUPPORTED;
102 97
103 cpu = get_cpu(); 98 cpu = get_cpu();
@@ -113,112 +108,128 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
113 if (ts2_size) 108 if (ts2_size)
114 Q2_SET_SEL(smp_processor_id(), PNP_TS2, ts2_base, ts2_size); 109 Q2_SET_SEL(smp_processor_id(), PNP_TS2, ts2_base, ts2_size);
115 110
116 __asm__ __volatile__( 111 __asm__ __volatile__("pushl %%ebp\n\t"
117 "pushl %%ebp\n\t" 112 "pushl %%edi\n\t"
118 "pushl %%edi\n\t" 113 "pushl %%esi\n\t"
119 "pushl %%esi\n\t" 114 "pushl %%ds\n\t"
120 "pushl %%ds\n\t" 115 "pushl %%es\n\t"
121 "pushl %%es\n\t" 116 "pushl %%fs\n\t"
122 "pushl %%fs\n\t" 117 "pushl %%gs\n\t"
123 "pushl %%gs\n\t" 118 "pushfl\n\t"
124 "pushfl\n\t" 119 "movl %%esp, pnp_bios_fault_esp\n\t"
125 "movl %%esp, pnp_bios_fault_esp\n\t" 120 "movl $1f, pnp_bios_fault_eip\n\t"
126 "movl $1f, pnp_bios_fault_eip\n\t" 121 "lcall %5,%6\n\t"
127 "lcall %5,%6\n\t" 122 "1:popfl\n\t"
128 "1:popfl\n\t" 123 "popl %%gs\n\t"
129 "popl %%gs\n\t" 124 "popl %%fs\n\t"
130 "popl %%fs\n\t" 125 "popl %%es\n\t"
131 "popl %%es\n\t" 126 "popl %%ds\n\t"
132 "popl %%ds\n\t" 127 "popl %%esi\n\t"
133 "popl %%esi\n\t" 128 "popl %%edi\n\t"
134 "popl %%edi\n\t" 129 "popl %%ebp\n\t":"=a"(status)
135 "popl %%ebp\n\t" 130 :"0"((func) | (((u32) arg1) << 16)),
136 : "=a" (status) 131 "b"((arg2) | (((u32) arg3) << 16)),
137 : "0" ((func) | (((u32)arg1) << 16)), 132 "c"((arg4) | (((u32) arg5) << 16)),
138 "b" ((arg2) | (((u32)arg3) << 16)), 133 "d"((arg6) | (((u32) arg7) << 16)),
139 "c" ((arg4) | (((u32)arg5) << 16)), 134 "i"(PNP_CS32), "i"(0)
140 "d" ((arg6) | (((u32)arg7) << 16)), 135 :"memory");
141 "i" (PNP_CS32),
142 "i" (0)
143 : "memory"
144 );
145 spin_unlock_irqrestore(&pnp_bios_lock, flags); 136 spin_unlock_irqrestore(&pnp_bios_lock, flags);
146 137
147 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40; 138 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
148 put_cpu(); 139 put_cpu();
149 140
150 /* If we get here and this is set then the PnP BIOS faulted on us. */ 141 /* If we get here and this is set then the PnP BIOS faulted on us. */
151 if(pnp_bios_is_utter_crap) 142 if (pnp_bios_is_utter_crap) {
152 { 143 printk(KERN_ERR
153 printk(KERN_ERR "PnPBIOS: Warning! Your PnP BIOS caused a fatal error. Attempting to continue\n"); 144 "PnPBIOS: Warning! Your PnP BIOS caused a fatal error. Attempting to continue\n");
154 printk(KERN_ERR "PnPBIOS: You may need to reboot with the \"pnpbios=off\" option to operate stably\n"); 145 printk(KERN_ERR
155 printk(KERN_ERR "PnPBIOS: Check with your vendor for an updated BIOS\n"); 146 "PnPBIOS: You may need to reboot with the \"pnpbios=off\" option to operate stably\n");
147 printk(KERN_ERR
148 "PnPBIOS: Check with your vendor for an updated BIOS\n");
156 } 149 }
157 150
158 return status; 151 return status;
159} 152}
160 153
161void pnpbios_print_status(const char * module, u16 status) 154void pnpbios_print_status(const char *module, u16 status)
162{ 155{
163 switch(status) { 156 switch (status) {
164 case PNP_SUCCESS: 157 case PNP_SUCCESS:
165 printk(KERN_ERR "PnPBIOS: %s: function successful\n", module); 158 printk(KERN_ERR "PnPBIOS: %s: function successful\n", module);
166 break; 159 break;
167 case PNP_NOT_SET_STATICALLY: 160 case PNP_NOT_SET_STATICALLY:
168 printk(KERN_ERR "PnPBIOS: %s: unable to set static resources\n", module); 161 printk(KERN_ERR "PnPBIOS: %s: unable to set static resources\n",
162 module);
169 break; 163 break;
170 case PNP_UNKNOWN_FUNCTION: 164 case PNP_UNKNOWN_FUNCTION:
171 printk(KERN_ERR "PnPBIOS: %s: invalid function number passed\n", module); 165 printk(KERN_ERR "PnPBIOS: %s: invalid function number passed\n",
166 module);
172 break; 167 break;
173 case PNP_FUNCTION_NOT_SUPPORTED: 168 case PNP_FUNCTION_NOT_SUPPORTED:
174 printk(KERN_ERR "PnPBIOS: %s: function not supported on this system\n", module); 169 printk(KERN_ERR
170 "PnPBIOS: %s: function not supported on this system\n",
171 module);
175 break; 172 break;
176 case PNP_INVALID_HANDLE: 173 case PNP_INVALID_HANDLE:
177 printk(KERN_ERR "PnPBIOS: %s: invalid handle\n", module); 174 printk(KERN_ERR "PnPBIOS: %s: invalid handle\n", module);
178 break; 175 break;
179 case PNP_BAD_PARAMETER: 176 case PNP_BAD_PARAMETER:
180 printk(KERN_ERR "PnPBIOS: %s: invalid parameters were passed\n", module); 177 printk(KERN_ERR "PnPBIOS: %s: invalid parameters were passed\n",
178 module);
181 break; 179 break;
182 case PNP_SET_FAILED: 180 case PNP_SET_FAILED:
183 printk(KERN_ERR "PnPBIOS: %s: unable to set resources\n", module); 181 printk(KERN_ERR "PnPBIOS: %s: unable to set resources\n",
182 module);
184 break; 183 break;
185 case PNP_EVENTS_NOT_PENDING: 184 case PNP_EVENTS_NOT_PENDING:
186 printk(KERN_ERR "PnPBIOS: %s: no events are pending\n", module); 185 printk(KERN_ERR "PnPBIOS: %s: no events are pending\n", module);
187 break; 186 break;
188 case PNP_SYSTEM_NOT_DOCKED: 187 case PNP_SYSTEM_NOT_DOCKED:
189 printk(KERN_ERR "PnPBIOS: %s: the system is not docked\n", module); 188 printk(KERN_ERR "PnPBIOS: %s: the system is not docked\n",
189 module);
190 break; 190 break;
191 case PNP_NO_ISA_PNP_CARDS: 191 case PNP_NO_ISA_PNP_CARDS:
192 printk(KERN_ERR "PnPBIOS: %s: no isapnp cards are installed on this system\n", module); 192 printk(KERN_ERR
193 "PnPBIOS: %s: no isapnp cards are installed on this system\n",
194 module);
193 break; 195 break;
194 case PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES: 196 case PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES:
195 printk(KERN_ERR "PnPBIOS: %s: cannot determine the capabilities of the docking station\n", module); 197 printk(KERN_ERR
198 "PnPBIOS: %s: cannot determine the capabilities of the docking station\n",
199 module);
196 break; 200 break;
197 case PNP_CONFIG_CHANGE_FAILED_NO_BATTERY: 201 case PNP_CONFIG_CHANGE_FAILED_NO_BATTERY:
198 printk(KERN_ERR "PnPBIOS: %s: unable to undock, the system does not have a battery\n", module); 202 printk(KERN_ERR
203 "PnPBIOS: %s: unable to undock, the system does not have a battery\n",
204 module);
199 break; 205 break;
200 case PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT: 206 case PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT:
201 printk(KERN_ERR "PnPBIOS: %s: could not dock due to resource conflicts\n", module); 207 printk(KERN_ERR
208 "PnPBIOS: %s: could not dock due to resource conflicts\n",
209 module);
202 break; 210 break;
203 case PNP_BUFFER_TOO_SMALL: 211 case PNP_BUFFER_TOO_SMALL:
204 printk(KERN_ERR "PnPBIOS: %s: the buffer passed is too small\n", module); 212 printk(KERN_ERR "PnPBIOS: %s: the buffer passed is too small\n",
213 module);
205 break; 214 break;
206 case PNP_USE_ESCD_SUPPORT: 215 case PNP_USE_ESCD_SUPPORT:
207 printk(KERN_ERR "PnPBIOS: %s: use ESCD instead\n", module); 216 printk(KERN_ERR "PnPBIOS: %s: use ESCD instead\n", module);
208 break; 217 break;
209 case PNP_MESSAGE_NOT_SUPPORTED: 218 case PNP_MESSAGE_NOT_SUPPORTED:
210 printk(KERN_ERR "PnPBIOS: %s: the message is unsupported\n", module); 219 printk(KERN_ERR "PnPBIOS: %s: the message is unsupported\n",
220 module);
211 break; 221 break;
212 case PNP_HARDWARE_ERROR: 222 case PNP_HARDWARE_ERROR:
213 printk(KERN_ERR "PnPBIOS: %s: a hardware failure has occured\n", module); 223 printk(KERN_ERR "PnPBIOS: %s: a hardware failure has occured\n",
224 module);
214 break; 225 break;
215 default: 226 default:
216 printk(KERN_ERR "PnPBIOS: %s: unexpected status 0x%x\n", module, status); 227 printk(KERN_ERR "PnPBIOS: %s: unexpected status 0x%x\n", module,
228 status);
217 break; 229 break;
218 } 230 }
219} 231}
220 232
221
222/* 233/*
223 * PnP BIOS Low Level Calls 234 * PnP BIOS Low Level Calls
224 */ 235 */
@@ -243,19 +254,22 @@ void pnpbios_print_status(const char * module, u16 status)
243static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data) 254static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
244{ 255{
245 u16 status; 256 u16 status;
257
246 if (!pnp_bios_present()) 258 if (!pnp_bios_present())
247 return PNP_FUNCTION_NOT_SUPPORTED; 259 return PNP_FUNCTION_NOT_SUPPORTED;
248 status = call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2, PNP_TS1, PNP_DS, 0, 0, 260 status = call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2,
249 data, sizeof(struct pnp_dev_node_info), NULL, 0); 261 PNP_TS1, PNP_DS, 0, 0, data,
262 sizeof(struct pnp_dev_node_info), NULL, 0);
250 data->no_nodes &= 0xff; 263 data->no_nodes &= 0xff;
251 return status; 264 return status;
252} 265}
253 266
254int pnp_bios_dev_node_info(struct pnp_dev_node_info *data) 267int pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
255{ 268{
256 int status = __pnp_bios_dev_node_info( data ); 269 int status = __pnp_bios_dev_node_info(data);
257 if ( status ) 270
258 pnpbios_print_status( "dev_node_info", status ); 271 if (status)
272 pnpbios_print_status("dev_node_info", status);
259 return status; 273 return status;
260} 274}
261 275
@@ -273,17 +287,20 @@ int pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
273 * or volatile current (0) config 287 * or volatile current (0) config
274 * Output: *nodenum=next node or 0xff if no more nodes 288 * Output: *nodenum=next node or 0xff if no more nodes
275 */ 289 */
276static int __pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) 290static int __pnp_bios_get_dev_node(u8 *nodenum, char boot,
291 struct pnp_bios_node *data)
277{ 292{
278 u16 status; 293 u16 status;
279 u16 tmp_nodenum; 294 u16 tmp_nodenum;
295
280 if (!pnp_bios_present()) 296 if (!pnp_bios_present())
281 return PNP_FUNCTION_NOT_SUPPORTED; 297 return PNP_FUNCTION_NOT_SUPPORTED;
282 if ( !boot && pnpbios_dont_use_current_config ) 298 if (!boot && pnpbios_dont_use_current_config)
283 return PNP_FUNCTION_NOT_SUPPORTED; 299 return PNP_FUNCTION_NOT_SUPPORTED;
284 tmp_nodenum = *nodenum; 300 tmp_nodenum = *nodenum;
285 status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0, 301 status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2,
286 &tmp_nodenum, sizeof(tmp_nodenum), data, 65536); 302 boot ? 2 : 1, PNP_DS, 0, &tmp_nodenum,
303 sizeof(tmp_nodenum), data, 65536);
287 *nodenum = tmp_nodenum; 304 *nodenum = tmp_nodenum;
288 return status; 305 return status;
289} 306}
@@ -291,104 +308,66 @@ static int __pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node
291int pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) 308int pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data)
292{ 309{
293 int status; 310 int status;
294 status = __pnp_bios_get_dev_node( nodenum, boot, data ); 311
295 if ( status ) 312 status = __pnp_bios_get_dev_node(nodenum, boot, data);
296 pnpbios_print_status( "get_dev_node", status ); 313 if (status)
314 pnpbios_print_status("get_dev_node", status);
297 return status; 315 return status;
298} 316}
299 317
300
301/* 318/*
302 * Call PnP BIOS with function 0x02, "set system device node" 319 * Call PnP BIOS with function 0x02, "set system device node"
303 * Input: *nodenum = desired node, 320 * Input: *nodenum = desired node,
304 * boot = whether to set nonvolatile boot (!=0) 321 * boot = whether to set nonvolatile boot (!=0)
305 * or volatile current (0) config 322 * or volatile current (0) config
306 */ 323 */
307static int __pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) 324static int __pnp_bios_set_dev_node(u8 nodenum, char boot,
325 struct pnp_bios_node *data)
308{ 326{
309 u16 status; 327 u16 status;
328
310 if (!pnp_bios_present()) 329 if (!pnp_bios_present())
311 return PNP_FUNCTION_NOT_SUPPORTED; 330 return PNP_FUNCTION_NOT_SUPPORTED;
312 if ( !boot && pnpbios_dont_use_current_config ) 331 if (!boot && pnpbios_dont_use_current_config)
313 return PNP_FUNCTION_NOT_SUPPORTED; 332 return PNP_FUNCTION_NOT_SUPPORTED;
314 status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1, boot ? 2 : 1, PNP_DS, 0, 0, 333 status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1,
315 data, 65536, NULL, 0); 334 boot ? 2 : 1, PNP_DS, 0, 0, data, 65536, NULL,
335 0);
316 return status; 336 return status;
317} 337}
318 338
319int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data) 339int pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *data)
320{ 340{
321 int status; 341 int status;
322 status = __pnp_bios_set_dev_node( nodenum, boot, data ); 342
323 if ( status ) { 343 status = __pnp_bios_set_dev_node(nodenum, boot, data);
324 pnpbios_print_status( "set_dev_node", status ); 344 if (status) {
345 pnpbios_print_status("set_dev_node", status);
325 return status; 346 return status;
326 } 347 }
327 if ( !boot ) { /* Update devlist */ 348 if (!boot) { /* Update devlist */
328 status = pnp_bios_get_dev_node( &nodenum, boot, data ); 349 status = pnp_bios_get_dev_node(&nodenum, boot, data);
329 if ( status ) 350 if (status)
330 return status; 351 return status;
331 } 352 }
332 return status; 353 return status;
333} 354}
334 355
335#if needed
336/*
337 * Call PnP BIOS with function 0x03, "get event"
338 */
339static int pnp_bios_get_event(u16 *event)
340{
341 u16 status;
342 if (!pnp_bios_present())
343 return PNP_FUNCTION_NOT_SUPPORTED;
344 status = call_pnp_bios(PNP_GET_EVENT, 0, PNP_TS1, PNP_DS, 0, 0 ,0 ,0,
345 event, sizeof(u16), NULL, 0);
346 return status;
347}
348#endif
349
350#if needed
351/*
352 * Call PnP BIOS with function 0x04, "send message"
353 */
354static int pnp_bios_send_message(u16 message)
355{
356 u16 status;
357 if (!pnp_bios_present())
358 return PNP_FUNCTION_NOT_SUPPORTED;
359 status = call_pnp_bios(PNP_SEND_MESSAGE, message, PNP_DS, 0, 0, 0, 0, 0, 0, 0, 0, 0);
360 return status;
361}
362#endif
363
364/* 356/*
365 * Call PnP BIOS with function 0x05, "get docking station information" 357 * Call PnP BIOS with function 0x05, "get docking station information"
366 */ 358 */
367int pnp_bios_dock_station_info(struct pnp_docking_station_info *data) 359int pnp_bios_dock_station_info(struct pnp_docking_station_info *data)
368{ 360{
369 u16 status; 361 u16 status;
370 if (!pnp_bios_present())
371 return PNP_FUNCTION_NOT_SUPPORTED;
372 status = call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0,
373 data, sizeof(struct pnp_docking_station_info), NULL, 0);
374 return status;
375}
376 362
377#if needed
378/*
379 * Call PnP BIOS with function 0x09, "set statically allocated resource
380 * information"
381 */
382static int pnp_bios_set_stat_res(char *info)
383{
384 u16 status;
385 if (!pnp_bios_present()) 363 if (!pnp_bios_present())
386 return PNP_FUNCTION_NOT_SUPPORTED; 364 return PNP_FUNCTION_NOT_SUPPORTED;
387 status = call_pnp_bios(PNP_SET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, 365 status = call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1,
388 info, *((u16 *) info), 0, 0); 366 PNP_DS, 0, 0, 0, 0, data,
367 sizeof(struct pnp_docking_station_info), NULL,
368 0);
389 return status; 369 return status;
390} 370}
391#endif
392 371
393/* 372/*
394 * Call PnP BIOS with function 0x0a, "get statically allocated resource 373 * Call PnP BIOS with function 0x0a, "get statically allocated resource
@@ -397,36 +376,23 @@ static int pnp_bios_set_stat_res(char *info)
397static int __pnp_bios_get_stat_res(char *info) 376static int __pnp_bios_get_stat_res(char *info)
398{ 377{
399 u16 status; 378 u16 status;
379
400 if (!pnp_bios_present()) 380 if (!pnp_bios_present())
401 return PNP_FUNCTION_NOT_SUPPORTED; 381 return PNP_FUNCTION_NOT_SUPPORTED;
402 status = call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, 382 status = call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1,
403 info, 65536, NULL, 0); 383 PNP_DS, 0, 0, 0, 0, info, 65536, NULL, 0);
404 return status; 384 return status;
405} 385}
406 386
407int pnp_bios_get_stat_res(char *info) 387int pnp_bios_get_stat_res(char *info)
408{ 388{
409 int status; 389 int status;
410 status = __pnp_bios_get_stat_res( info );
411 if ( status )
412 pnpbios_print_status( "get_stat_res", status );
413 return status;
414}
415 390
416#if needed 391 status = __pnp_bios_get_stat_res(info);
417/* 392 if (status)
418 * Call PnP BIOS with function 0x0b, "get APM id table" 393 pnpbios_print_status("get_stat_res", status);
419 */
420static int pnp_bios_apm_id_table(char *table, u16 *size)
421{
422 u16 status;
423 if (!pnp_bios_present())
424 return PNP_FUNCTION_NOT_SUPPORTED;
425 status = call_pnp_bios(PNP_GET_APM_ID_TABLE, 0, PNP_TS2, 0, PNP_TS1, PNP_DS, 0, 0,
426 table, *size, size, sizeof(u16));
427 return status; 394 return status;
428} 395}
429#endif
430 396
431/* 397/*
432 * Call PnP BIOS with function 0x40, "get isa pnp configuration structure" 398 * Call PnP BIOS with function 0x40, "get isa pnp configuration structure"
@@ -434,19 +400,22 @@ static int pnp_bios_apm_id_table(char *table, u16 *size)
434static int __pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) 400static int __pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
435{ 401{
436 u16 status; 402 u16 status;
403
437 if (!pnp_bios_present()) 404 if (!pnp_bios_present())
438 return PNP_FUNCTION_NOT_SUPPORTED; 405 return PNP_FUNCTION_NOT_SUPPORTED;
439 status = call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0, 406 status = call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS,
440 data, sizeof(struct pnp_isa_config_struc), NULL, 0); 407 0, 0, 0, 0, data,
408 sizeof(struct pnp_isa_config_struc), NULL, 0);
441 return status; 409 return status;
442} 410}
443 411
444int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data) 412int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
445{ 413{
446 int status; 414 int status;
447 status = __pnp_bios_isapnp_config( data ); 415
448 if ( status ) 416 status = __pnp_bios_isapnp_config(data);
449 pnpbios_print_status( "isapnp_config", status ); 417 if (status)
418 pnpbios_print_status("isapnp_config", status);
450 return status; 419 return status;
451} 420}
452 421
@@ -456,19 +425,22 @@ int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
456static int __pnp_bios_escd_info(struct escd_info_struc *data) 425static int __pnp_bios_escd_info(struct escd_info_struc *data)
457{ 426{
458 u16 status; 427 u16 status;
428
459 if (!pnp_bios_present()) 429 if (!pnp_bios_present())
460 return ESCD_FUNCTION_NOT_SUPPORTED; 430 return ESCD_FUNCTION_NOT_SUPPORTED;
461 status = call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4, PNP_TS1, PNP_DS, 431 status = call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4,
462 data, sizeof(struct escd_info_struc), NULL, 0); 432 PNP_TS1, PNP_DS, data,
433 sizeof(struct escd_info_struc), NULL, 0);
463 return status; 434 return status;
464} 435}
465 436
466int pnp_bios_escd_info(struct escd_info_struc *data) 437int pnp_bios_escd_info(struct escd_info_struc *data)
467{ 438{
468 int status; 439 int status;
469 status = __pnp_bios_escd_info( data ); 440
470 if ( status ) 441 status = __pnp_bios_escd_info(data);
471 pnpbios_print_status( "escd_info", status ); 442 if (status)
443 pnpbios_print_status("escd_info", status);
472 return status; 444 return status;
473} 445}
474 446
@@ -479,57 +451,42 @@ int pnp_bios_escd_info(struct escd_info_struc *data)
479static int __pnp_bios_read_escd(char *data, u32 nvram_base) 451static int __pnp_bios_read_escd(char *data, u32 nvram_base)
480{ 452{
481 u16 status; 453 u16 status;
454
482 if (!pnp_bios_present()) 455 if (!pnp_bios_present())
483 return ESCD_FUNCTION_NOT_SUPPORTED; 456 return ESCD_FUNCTION_NOT_SUPPORTED;
484 status = call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0, 457 status = call_pnp_bios(PNP_READ_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0,
485 data, 65536, __va(nvram_base), 65536); 458 0, data, 65536, __va(nvram_base), 65536);
486 return status; 459 return status;
487} 460}
488 461
489int pnp_bios_read_escd(char *data, u32 nvram_base) 462int pnp_bios_read_escd(char *data, u32 nvram_base)
490{ 463{
491 int status; 464 int status;
492 status = __pnp_bios_read_escd( data, nvram_base );
493 if ( status )
494 pnpbios_print_status( "read_escd", status );
495 return status;
496}
497 465
498#if needed 466 status = __pnp_bios_read_escd(data, nvram_base);
499/* 467 if (status)
500 * Call PnP BIOS function 0x43, "write ESCD" 468 pnpbios_print_status("read_escd", status);
501 */
502static int pnp_bios_write_escd(char *data, u32 nvram_base)
503{
504 u16 status;
505 if (!pnp_bios_present())
506 return ESCD_FUNCTION_NOT_SUPPORTED;
507 status = call_pnp_bios(PNP_WRITE_ESCD, 0, PNP_TS1, PNP_TS2, PNP_DS, 0, 0, 0,
508 data, 65536, __va(nvram_base), 65536);
509 return status; 469 return status;
510} 470}
511#endif
512
513
514/*
515 * Initialization
516 */
517 471
518void pnpbios_calls_init(union pnp_bios_install_struct *header) 472void pnpbios_calls_init(union pnp_bios_install_struct *header)
519{ 473{
520 int i; 474 int i;
475
521 spin_lock_init(&pnp_bios_lock); 476 spin_lock_init(&pnp_bios_lock);
522 pnp_bios_callpoint.offset = header->fields.pm16offset; 477 pnp_bios_callpoint.offset = header->fields.pm16offset;
523 pnp_bios_callpoint.segment = PNP_CS16; 478 pnp_bios_callpoint.segment = PNP_CS16;
524 479
525 set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); 480 set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));
526 _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); 481 _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));
527 for (i = 0; i < NR_CPUS; i++) { 482 for (i = 0; i < NR_CPUS; i++) {
528 struct desc_struct *gdt = get_cpu_gdt_table(i); 483 struct desc_struct *gdt = get_cpu_gdt_table(i);
529 if (!gdt) 484 if (!gdt)
530 continue; 485 continue;
531 set_base(gdt[GDT_ENTRY_PNPBIOS_CS32], &pnp_bios_callfunc); 486 set_base(gdt[GDT_ENTRY_PNPBIOS_CS32], &pnp_bios_callfunc);
532 set_base(gdt[GDT_ENTRY_PNPBIOS_CS16], __va(header->fields.pm16cseg)); 487 set_base(gdt[GDT_ENTRY_PNPBIOS_CS16],
533 set_base(gdt[GDT_ENTRY_PNPBIOS_DS], __va(header->fields.pm16dseg)); 488 __va(header->fields.pm16cseg));
534 } 489 set_base(gdt[GDT_ENTRY_PNPBIOS_DS],
490 __va(header->fields.pm16dseg));
491 }
535} 492}
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index ed112ee16012..3692a099b45f 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -32,7 +32,7 @@
32 * along with this program; if not, write to the Free Software 32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 */ 34 */
35 35
36/* Change Log 36/* Change Log
37 * 37 *
38 * Adam Belay - <ambx1@neo.rr.com> - March 16, 2003 38 * Adam Belay - <ambx1@neo.rr.com> - March 16, 2003
@@ -71,14 +71,13 @@
71 71
72#include "pnpbios.h" 72#include "pnpbios.h"
73 73
74
75/* 74/*
76 * 75 *
77 * PnP BIOS INTERFACE 76 * PnP BIOS INTERFACE
78 * 77 *
79 */ 78 */
80 79
81static union pnp_bios_install_struct * pnp_bios_install = NULL; 80static union pnp_bios_install_struct *pnp_bios_install = NULL;
82 81
83int pnp_bios_present(void) 82int pnp_bios_present(void)
84{ 83{
@@ -101,36 +100,35 @@ static struct completion unload_sem;
101/* 100/*
102 * (Much of this belongs in a shared routine somewhere) 101 * (Much of this belongs in a shared routine somewhere)
103 */ 102 */
104
105static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) 103static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
106{ 104{
107 char *argv [3], **envp, *buf, *scratch; 105 char *argv[3], **envp, *buf, *scratch;
108 int i = 0, value; 106 int i = 0, value;
109 107
110 if (!current->fs->root) { 108 if (!current->fs->root)
111 return -EAGAIN; 109 return -EAGAIN;
112 } 110 if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL)))
113 if (!(envp = kcalloc(20, sizeof (char *), GFP_KERNEL))) {
114 return -ENOMEM; 111 return -ENOMEM;
115 }
116 if (!(buf = kzalloc(256, GFP_KERNEL))) { 112 if (!(buf = kzalloc(256, GFP_KERNEL))) {
117 kfree (envp); 113 kfree(envp);
118 return -ENOMEM; 114 return -ENOMEM;
119 } 115 }
120 116
121 /* FIXME: if there are actual users of this, it should be integrated into 117 /* FIXME: if there are actual users of this, it should be
122 * the driver core and use the usual infrastructure like sysfs and uevents */ 118 * integrated into the driver core and use the usual infrastructure
123 argv [0] = "/sbin/pnpbios"; 119 * like sysfs and uevents
124 argv [1] = "dock"; 120 */
125 argv [2] = NULL; 121 argv[0] = "/sbin/pnpbios";
122 argv[1] = "dock";
123 argv[2] = NULL;
126 124
127 /* minimal command environment */ 125 /* minimal command environment */
128 envp [i++] = "HOME=/"; 126 envp[i++] = "HOME=/";
129 envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; 127 envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
130 128
131#ifdef DEBUG 129#ifdef DEBUG
132 /* hint that policy agent should enter no-stdout debug mode */ 130 /* hint that policy agent should enter no-stdout debug mode */
133 envp [i++] = "DEBUG=kernel"; 131 envp[i++] = "DEBUG=kernel";
134#endif 132#endif
135 /* extensible set of named bus-specific parameters, 133 /* extensible set of named bus-specific parameters,
136 * supporting multiple driver selection algorithms. 134 * supporting multiple driver selection algorithms.
@@ -138,33 +136,33 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
138 scratch = buf; 136 scratch = buf;
139 137
140 /* action: add, remove */ 138 /* action: add, remove */
141 envp [i++] = scratch; 139 envp[i++] = scratch;
142 scratch += sprintf (scratch, "ACTION=%s", dock?"add":"remove") + 1; 140 scratch += sprintf(scratch, "ACTION=%s", dock ? "add" : "remove") + 1;
143 141
144 /* Report the ident for the dock */ 142 /* Report the ident for the dock */
145 envp [i++] = scratch; 143 envp[i++] = scratch;
146 scratch += sprintf (scratch, "DOCK=%x/%x/%x", 144 scratch += sprintf(scratch, "DOCK=%x/%x/%x",
147 info->location_id, info->serial, info->capabilities); 145 info->location_id, info->serial, info->capabilities);
148 envp[i] = NULL; 146 envp[i] = NULL;
149 147
150 value = call_usermodehelper (argv [0], argv, envp, UMH_WAIT_EXEC); 148 value = call_usermodehelper(argv [0], argv, envp, UMH_WAIT_EXEC);
151 kfree (buf); 149 kfree(buf);
152 kfree (envp); 150 kfree(envp);
153 return 0; 151 return 0;
154} 152}
155 153
156/* 154/*
157 * Poll the PnP docking at regular intervals 155 * Poll the PnP docking at regular intervals
158 */ 156 */
159static int pnp_dock_thread(void * unused) 157static int pnp_dock_thread(void *unused)
160{ 158{
161 static struct pnp_docking_station_info now; 159 static struct pnp_docking_station_info now;
162 int docked = -1, d = 0; 160 int docked = -1, d = 0;
161
163 set_freezable(); 162 set_freezable();
164 while (!unloading) 163 while (!unloading) {
165 {
166 int status; 164 int status;
167 165
168 /* 166 /*
169 * Poll every 2 seconds 167 * Poll every 2 seconds
170 */ 168 */
@@ -175,30 +173,29 @@ static int pnp_dock_thread(void * unused)
175 173
176 status = pnp_bios_dock_station_info(&now); 174 status = pnp_bios_dock_station_info(&now);
177 175
178 switch(status) 176 switch (status) {
179 {
180 /* 177 /*
181 * No dock to manage 178 * No dock to manage
182 */ 179 */
183 case PNP_FUNCTION_NOT_SUPPORTED: 180 case PNP_FUNCTION_NOT_SUPPORTED:
184 complete_and_exit(&unload_sem, 0); 181 complete_and_exit(&unload_sem, 0);
185 case PNP_SYSTEM_NOT_DOCKED: 182 case PNP_SYSTEM_NOT_DOCKED:
186 d = 0; 183 d = 0;
187 break; 184 break;
188 case PNP_SUCCESS: 185 case PNP_SUCCESS:
189 d = 1; 186 d = 1;
190 break; 187 break;
191 default: 188 default:
192 pnpbios_print_status( "pnp_dock_thread", status ); 189 pnpbios_print_status("pnp_dock_thread", status);
193 continue; 190 continue;
194 } 191 }
195 if(d != docked) 192 if (d != docked) {
196 { 193 if (pnp_dock_event(d, &now) == 0) {
197 if(pnp_dock_event(d, &now)==0)
198 {
199 docked = d; 194 docked = d;
200#if 0 195#if 0
201 printk(KERN_INFO "PnPBIOS: Docking station %stached\n", docked?"at":"de"); 196 printk(KERN_INFO
197 "PnPBIOS: Docking station %stached\n",
198 docked ? "at" : "de");
202#endif 199#endif
203 } 200 }
204 } 201 }
@@ -206,21 +203,21 @@ static int pnp_dock_thread(void * unused)
206 complete_and_exit(&unload_sem, 0); 203 complete_and_exit(&unload_sem, 0);
207} 204}
208 205
209#endif /* CONFIG_HOTPLUG */ 206#endif /* CONFIG_HOTPLUG */
210 207
211static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table * res) 208static int pnpbios_get_resources(struct pnp_dev *dev,
209 struct pnp_resource_table *res)
212{ 210{
213 u8 nodenum = dev->number; 211 u8 nodenum = dev->number;
214 struct pnp_bios_node * node; 212 struct pnp_bios_node *node;
215 213
216 /* just in case */ 214 if (!pnpbios_is_dynamic(dev))
217 if(!pnpbios_is_dynamic(dev))
218 return -EPERM; 215 return -EPERM;
219 216
220 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 217 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
221 if (!node) 218 if (!node)
222 return -1; 219 return -1;
223 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { 220 if (pnp_bios_get_dev_node(&nodenum, (char)PNPMODE_DYNAMIC, node)) {
224 kfree(node); 221 kfree(node);
225 return -ENODEV; 222 return -ENODEV;
226 } 223 }
@@ -230,24 +227,24 @@ static int pnpbios_get_resources(struct pnp_dev * dev, struct pnp_resource_table
230 return 0; 227 return 0;
231} 228}
232 229
233static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table * res) 230static int pnpbios_set_resources(struct pnp_dev *dev,
231 struct pnp_resource_table *res)
234{ 232{
235 u8 nodenum = dev->number; 233 u8 nodenum = dev->number;
236 struct pnp_bios_node * node; 234 struct pnp_bios_node *node;
237 int ret; 235 int ret;
238 236
239 /* just in case */
240 if (!pnpbios_is_dynamic(dev)) 237 if (!pnpbios_is_dynamic(dev))
241 return -EPERM; 238 return -EPERM;
242 239
243 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 240 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
244 if (!node) 241 if (!node)
245 return -1; 242 return -1;
246 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { 243 if (pnp_bios_get_dev_node(&nodenum, (char)PNPMODE_DYNAMIC, node)) {
247 kfree(node); 244 kfree(node);
248 return -ENODEV; 245 return -ENODEV;
249 } 246 }
250 if(pnpbios_write_resources_to_node(res, node)<0) { 247 if (pnpbios_write_resources_to_node(res, node) < 0) {
251 kfree(node); 248 kfree(node);
252 return -1; 249 return -1;
253 } 250 }
@@ -258,18 +255,19 @@ static int pnpbios_set_resources(struct pnp_dev * dev, struct pnp_resource_table
258 return ret; 255 return ret;
259} 256}
260 257
261static void pnpbios_zero_data_stream(struct pnp_bios_node * node) 258static void pnpbios_zero_data_stream(struct pnp_bios_node *node)
262{ 259{
263 unsigned char * p = (char *)node->data; 260 unsigned char *p = (char *)node->data;
264 unsigned char * end = (char *)(node->data + node->size); 261 unsigned char *end = (char *)(node->data + node->size);
265 unsigned int len; 262 unsigned int len;
266 int i; 263 int i;
264
267 while ((char *)p < (char *)end) { 265 while ((char *)p < (char *)end) {
268 if(p[0] & 0x80) { /* large tag */ 266 if (p[0] & 0x80) { /* large tag */
269 len = (p[2] << 8) | p[1]; 267 len = (p[2] << 8) | p[1];
270 p += 3; 268 p += 3;
271 } else { 269 } else {
272 if (((p[0]>>3) & 0x0f) == 0x0f) 270 if (((p[0] >> 3) & 0x0f) == 0x0f)
273 return; 271 return;
274 len = p[0] & 0x07; 272 len = p[0] & 0x07;
275 p += 1; 273 p += 1;
@@ -278,24 +276,24 @@ static void pnpbios_zero_data_stream(struct pnp_bios_node * node)
278 p[i] = 0; 276 p[i] = 0;
279 p += len; 277 p += len;
280 } 278 }
281 printk(KERN_ERR "PnPBIOS: Resource structure did not contain an end tag.\n"); 279 printk(KERN_ERR
280 "PnPBIOS: Resource structure did not contain an end tag.\n");
282} 281}
283 282
284static int pnpbios_disable_resources(struct pnp_dev *dev) 283static int pnpbios_disable_resources(struct pnp_dev *dev)
285{ 284{
286 struct pnp_bios_node * node; 285 struct pnp_bios_node *node;
287 u8 nodenum = dev->number; 286 u8 nodenum = dev->number;
288 int ret; 287 int ret;
289 288
290 /* just in case */ 289 if (dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
291 if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
292 return -EPERM; 290 return -EPERM;
293 291
294 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 292 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
295 if (!node) 293 if (!node)
296 return -ENOMEM; 294 return -ENOMEM;
297 295
298 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) { 296 if (pnp_bios_get_dev_node(&nodenum, (char)PNPMODE_DYNAMIC, node)) {
299 kfree(node); 297 kfree(node);
300 return -ENODEV; 298 return -ENODEV;
301 } 299 }
@@ -311,22 +309,22 @@ static int pnpbios_disable_resources(struct pnp_dev *dev)
311/* PnP Layer support */ 309/* PnP Layer support */
312 310
313struct pnp_protocol pnpbios_protocol = { 311struct pnp_protocol pnpbios_protocol = {
314 .name = "Plug and Play BIOS", 312 .name = "Plug and Play BIOS",
315 .get = pnpbios_get_resources, 313 .get = pnpbios_get_resources,
316 .set = pnpbios_set_resources, 314 .set = pnpbios_set_resources,
317 .disable = pnpbios_disable_resources, 315 .disable = pnpbios_disable_resources,
318}; 316};
319 317
320static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node) 318static int insert_device(struct pnp_dev *dev, struct pnp_bios_node *node)
321{ 319{
322 struct list_head * pos; 320 struct list_head *pos;
323 struct pnp_dev * pnp_dev; 321 struct pnp_dev *pnp_dev;
324 struct pnp_id *dev_id; 322 struct pnp_id *dev_id;
325 char id[8]; 323 char id[8];
326 324
327 /* check if the device is already added */ 325 /* check if the device is already added */
328 dev->number = node->handle; 326 dev->number = node->handle;
329 list_for_each (pos, &pnpbios_protocol.devices){ 327 list_for_each(pos, &pnpbios_protocol.devices) {
330 pnp_dev = list_entry(pos, struct pnp_dev, protocol_list); 328 pnp_dev = list_entry(pos, struct pnp_dev, protocol_list);
331 if (dev->number == pnp_dev->number) 329 if (dev->number == pnp_dev->number)
332 return -1; 330 return -1;
@@ -336,8 +334,8 @@ static int insert_device(struct pnp_dev *dev, struct pnp_bios_node * node)
336 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); 334 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
337 if (!dev_id) 335 if (!dev_id)
338 return -1; 336 return -1;
339 pnpid32_to_pnpid(node->eisa_id,id); 337 pnpid32_to_pnpid(node->eisa_id, id);
340 memcpy(dev_id->id,id,7); 338 memcpy(dev_id->id, id, 7);
341 pnp_add_id(dev_id, dev); 339 pnp_add_id(dev_id, dev);
342 pnpbios_parse_data_stream(dev, node); 340 pnpbios_parse_data_stream(dev, node);
343 dev->active = pnp_is_active(dev); 341 dev->active = pnp_is_active(dev);
@@ -375,35 +373,41 @@ static void __init build_devlist(void)
375 if (!node) 373 if (!node)
376 return; 374 return;
377 375
378 for(nodenum=0; nodenum<0xff; ) { 376 for (nodenum = 0; nodenum < 0xff;) {
379 u8 thisnodenum = nodenum; 377 u8 thisnodenum = nodenum;
380 /* eventually we will want to use PNPMODE_STATIC here but for now 378 /* eventually we will want to use PNPMODE_STATIC here but for now
381 * dynamic will help us catch buggy bioses to add to the blacklist. 379 * dynamic will help us catch buggy bioses to add to the blacklist.
382 */ 380 */
383 if (!pnpbios_dont_use_current_config) { 381 if (!pnpbios_dont_use_current_config) {
384 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) 382 if (pnp_bios_get_dev_node
383 (&nodenum, (char)PNPMODE_DYNAMIC, node))
385 break; 384 break;
386 } else { 385 } else {
387 if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_STATIC, node)) 386 if (pnp_bios_get_dev_node
387 (&nodenum, (char)PNPMODE_STATIC, node))
388 break; 388 break;
389 } 389 }
390 nodes_got++; 390 nodes_got++;
391 dev = kzalloc(sizeof (struct pnp_dev), GFP_KERNEL); 391 dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL);
392 if (!dev) 392 if (!dev)
393 break; 393 break;
394 if(insert_device(dev,node)<0) 394 if (insert_device(dev, node) < 0)
395 kfree(dev); 395 kfree(dev);
396 else 396 else
397 devs++; 397 devs++;
398 if (nodenum <= thisnodenum) { 398 if (nodenum <= thisnodenum) {
399 printk(KERN_ERR "PnPBIOS: build_devlist: Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", (unsigned int)nodenum, (unsigned int)thisnodenum); 399 printk(KERN_ERR
400 "PnPBIOS: build_devlist: Node number 0x%x is out of sequence following node 0x%x. Aborting.\n",
401 (unsigned int)nodenum,
402 (unsigned int)thisnodenum);
400 break; 403 break;
401 } 404 }
402 } 405 }
403 kfree(node); 406 kfree(node);
404 407
405 printk(KERN_INFO "PnPBIOS: %i node%s reported by PnP BIOS; %i recorded by driver\n", 408 printk(KERN_INFO
406 nodes_got, nodes_got != 1 ? "s" : "", devs); 409 "PnPBIOS: %i node%s reported by PnP BIOS; %i recorded by driver\n",
410 nodes_got, nodes_got != 1 ? "s" : "", devs);
407} 411}
408 412
409/* 413/*
@@ -412,8 +416,8 @@ static void __init build_devlist(void)
412 * 416 *
413 */ 417 */
414 418
415static int pnpbios_disabled; /* = 0 */ 419static int pnpbios_disabled;
416int pnpbios_dont_use_current_config; /* = 0 */ 420int pnpbios_dont_use_current_config;
417 421
418#ifndef MODULE 422#ifndef MODULE
419static int __init pnpbios_setup(char *str) 423static int __init pnpbios_setup(char *str)
@@ -422,9 +426,9 @@ static int __init pnpbios_setup(char *str)
422 426
423 while ((str != NULL) && (*str != '\0')) { 427 while ((str != NULL) && (*str != '\0')) {
424 if (strncmp(str, "off", 3) == 0) 428 if (strncmp(str, "off", 3) == 0)
425 pnpbios_disabled=1; 429 pnpbios_disabled = 1;
426 if (strncmp(str, "on", 2) == 0) 430 if (strncmp(str, "on", 2) == 0)
427 pnpbios_disabled=0; 431 pnpbios_disabled = 0;
428 invert = (strncmp(str, "no-", 3) == 0); 432 invert = (strncmp(str, "no-", 3) == 0);
429 if (invert) 433 if (invert)
430 str += 3; 434 str += 3;
@@ -453,35 +457,41 @@ static int __init pnpbios_probe_system(void)
453 printk(KERN_INFO "PnPBIOS: Scanning system for PnP BIOS support...\n"); 457 printk(KERN_INFO "PnPBIOS: Scanning system for PnP BIOS support...\n");
454 458
455 /* 459 /*
456 * Search the defined area (0xf0000-0xffff0) for a valid PnP BIOS 460 * Search the defined area (0xf0000-0xffff0) for a valid PnP BIOS
457 * structure and, if one is found, sets up the selectors and 461 * structure and, if one is found, sets up the selectors and
458 * entry points 462 * entry points
459 */ 463 */
460 for (check = (union pnp_bios_install_struct *) __va(0xf0000); 464 for (check = (union pnp_bios_install_struct *)__va(0xf0000);
461 check < (union pnp_bios_install_struct *) __va(0xffff0); 465 check < (union pnp_bios_install_struct *)__va(0xffff0);
462 check = (void *)check + 16) { 466 check = (void *)check + 16) {
463 if (check->fields.signature != PNP_SIGNATURE) 467 if (check->fields.signature != PNP_SIGNATURE)
464 continue; 468 continue;
465 printk(KERN_INFO "PnPBIOS: Found PnP BIOS installation structure at 0x%p\n", check); 469 printk(KERN_INFO
470 "PnPBIOS: Found PnP BIOS installation structure at 0x%p\n",
471 check);
466 length = check->fields.length; 472 length = check->fields.length;
467 if (!length) { 473 if (!length) {
468 printk(KERN_ERR "PnPBIOS: installation structure is invalid, skipping\n"); 474 printk(KERN_ERR
475 "PnPBIOS: installation structure is invalid, skipping\n");
469 continue; 476 continue;
470 } 477 }
471 for (sum = 0, i = 0; i < length; i++) 478 for (sum = 0, i = 0; i < length; i++)
472 sum += check->chars[i]; 479 sum += check->chars[i];
473 if (sum) { 480 if (sum) {
474 printk(KERN_ERR "PnPBIOS: installation structure is corrupted, skipping\n"); 481 printk(KERN_ERR
482 "PnPBIOS: installation structure is corrupted, skipping\n");
475 continue; 483 continue;
476 } 484 }
477 if (check->fields.version < 0x10) { 485 if (check->fields.version < 0x10) {
478 printk(KERN_WARNING "PnPBIOS: PnP BIOS version %d.%d is not supported\n", 486 printk(KERN_WARNING
487 "PnPBIOS: PnP BIOS version %d.%d is not supported\n",
479 check->fields.version >> 4, 488 check->fields.version >> 4,
480 check->fields.version & 15); 489 check->fields.version & 15);
481 continue; 490 continue;
482 } 491 }
483 printk(KERN_INFO "PnPBIOS: PnP BIOS version %d.%d, entry 0x%x:0x%x, dseg 0x%x\n", 492 printk(KERN_INFO
484 check->fields.version >> 4, check->fields.version & 15, 493 "PnPBIOS: PnP BIOS version %d.%d, entry 0x%x:0x%x, dseg 0x%x\n",
494 check->fields.version >> 4, check->fields.version & 15,
485 check->fields.pm16cseg, check->fields.pm16offset, 495 check->fields.pm16cseg, check->fields.pm16offset,
486 check->fields.pm16dseg); 496 check->fields.pm16dseg);
487 pnp_bios_install = check; 497 pnp_bios_install = check;
@@ -499,25 +509,25 @@ static int __init exploding_pnp_bios(struct dmi_system_id *d)
499} 509}
500 510
501static struct dmi_system_id pnpbios_dmi_table[] __initdata = { 511static struct dmi_system_id pnpbios_dmi_table[] __initdata = {
502 { /* PnPBIOS GPF on boot */ 512 { /* PnPBIOS GPF on boot */
503 .callback = exploding_pnp_bios, 513 .callback = exploding_pnp_bios,
504 .ident = "Higraded P14H", 514 .ident = "Higraded P14H",
505 .matches = { 515 .matches = {
506 DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."), 516 DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
507 DMI_MATCH(DMI_BIOS_VERSION, "07.00T"), 517 DMI_MATCH(DMI_BIOS_VERSION, "07.00T"),
508 DMI_MATCH(DMI_SYS_VENDOR, "Higraded"), 518 DMI_MATCH(DMI_SYS_VENDOR, "Higraded"),
509 DMI_MATCH(DMI_PRODUCT_NAME, "P14H"), 519 DMI_MATCH(DMI_PRODUCT_NAME, "P14H"),
510 }, 520 },
511 }, 521 },
512 { /* PnPBIOS GPF on boot */ 522 { /* PnPBIOS GPF on boot */
513 .callback = exploding_pnp_bios, 523 .callback = exploding_pnp_bios,
514 .ident = "ASUS P4P800", 524 .ident = "ASUS P4P800",
515 .matches = { 525 .matches = {
516 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."), 526 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."),
517 DMI_MATCH(DMI_BOARD_NAME, "P4P800"), 527 DMI_MATCH(DMI_BOARD_NAME, "P4P800"),
518 }, 528 },
519 }, 529 },
520 { } 530 {}
521}; 531};
522 532
523static int __init pnpbios_init(void) 533static int __init pnpbios_init(void)
@@ -533,14 +543,13 @@ static int __init pnpbios_init(void)
533 printk(KERN_INFO "PnPBIOS: Disabled\n"); 543 printk(KERN_INFO "PnPBIOS: Disabled\n");
534 return -ENODEV; 544 return -ENODEV;
535 } 545 }
536
537#ifdef CONFIG_PNPACPI 546#ifdef CONFIG_PNPACPI
538 if (!acpi_disabled && !pnpacpi_disabled) { 547 if (!acpi_disabled && !pnpacpi_disabled) {
539 pnpbios_disabled = 1; 548 pnpbios_disabled = 1;
540 printk(KERN_INFO "PnPBIOS: Disabled by ACPI PNP\n"); 549 printk(KERN_INFO "PnPBIOS: Disabled by ACPI PNP\n");
541 return -ENODEV; 550 return -ENODEV;
542 } 551 }
543#endif /* CONFIG_ACPI */ 552#endif /* CONFIG_ACPI */
544 553
545 /* scan the system for pnpbios support */ 554 /* scan the system for pnpbios support */
546 if (!pnpbios_probe_system()) 555 if (!pnpbios_probe_system())
@@ -552,14 +561,16 @@ static int __init pnpbios_init(void)
552 /* read the node info */ 561 /* read the node info */
553 ret = pnp_bios_dev_node_info(&node_info); 562 ret = pnp_bios_dev_node_info(&node_info);
554 if (ret) { 563 if (ret) {
555 printk(KERN_ERR "PnPBIOS: Unable to get node info. Aborting.\n"); 564 printk(KERN_ERR
565 "PnPBIOS: Unable to get node info. Aborting.\n");
556 return ret; 566 return ret;
557 } 567 }
558 568
559 /* register with the pnp layer */ 569 /* register with the pnp layer */
560 ret = pnp_register_protocol(&pnpbios_protocol); 570 ret = pnp_register_protocol(&pnpbios_protocol);
561 if (ret) { 571 if (ret) {
562 printk(KERN_ERR "PnPBIOS: Unable to register driver. Aborting.\n"); 572 printk(KERN_ERR
573 "PnPBIOS: Unable to register driver. Aborting.\n");
563 return ret; 574 return ret;
564 } 575 }
565 576
diff --git a/drivers/pnp/pnpbios/proc.c b/drivers/pnp/pnpbios/proc.c
index 8027073f7919..9c8c07701b65 100644
--- a/drivers/pnp/pnpbios/proc.c
+++ b/drivers/pnp/pnpbios/proc.c
@@ -18,9 +18,6 @@
18 * The other files are human-readable. 18 * The other files are human-readable.
19 */ 19 */
20 20
21//#include <pcmcia/config.h>
22//#include <pcmcia/k_compat.h>
23
24#include <linux/module.h> 21#include <linux/module.h>
25#include <linux/kernel.h> 22#include <linux/kernel.h>
26#include <linux/slab.h> 23#include <linux/slab.h>
@@ -37,42 +34,37 @@ static struct proc_dir_entry *proc_pnp = NULL;
37static struct proc_dir_entry *proc_pnp_boot = NULL; 34static struct proc_dir_entry *proc_pnp_boot = NULL;
38 35
39static int proc_read_pnpconfig(char *buf, char **start, off_t pos, 36static int proc_read_pnpconfig(char *buf, char **start, off_t pos,
40 int count, int *eof, void *data) 37 int count, int *eof, void *data)
41{ 38{
42 struct pnp_isa_config_struc pnps; 39 struct pnp_isa_config_struc pnps;
43 40
44 if (pnp_bios_isapnp_config(&pnps)) 41 if (pnp_bios_isapnp_config(&pnps))
45 return -EIO; 42 return -EIO;
46 return snprintf(buf, count, 43 return snprintf(buf, count,
47 "structure_revision %d\n" 44 "structure_revision %d\n"
48 "number_of_CSNs %d\n" 45 "number_of_CSNs %d\n"
49 "ISA_read_data_port 0x%x\n", 46 "ISA_read_data_port 0x%x\n",
50 pnps.revision, 47 pnps.revision, pnps.no_csns, pnps.isa_rd_data_port);
51 pnps.no_csns,
52 pnps.isa_rd_data_port
53 );
54} 48}
55 49
56static int proc_read_escdinfo(char *buf, char **start, off_t pos, 50static int proc_read_escdinfo(char *buf, char **start, off_t pos,
57 int count, int *eof, void *data) 51 int count, int *eof, void *data)
58{ 52{
59 struct escd_info_struc escd; 53 struct escd_info_struc escd;
60 54
61 if (pnp_bios_escd_info(&escd)) 55 if (pnp_bios_escd_info(&escd))
62 return -EIO; 56 return -EIO;
63 return snprintf(buf, count, 57 return snprintf(buf, count,
64 "min_ESCD_write_size %d\n" 58 "min_ESCD_write_size %d\n"
65 "ESCD_size %d\n" 59 "ESCD_size %d\n"
66 "NVRAM_base 0x%x\n", 60 "NVRAM_base 0x%x\n",
67 escd.min_escd_write_size, 61 escd.min_escd_write_size,
68 escd.escd_size, 62 escd.escd_size, escd.nv_storage_base);
69 escd.nv_storage_base
70 );
71} 63}
72 64
73#define MAX_SANE_ESCD_SIZE (32*1024) 65#define MAX_SANE_ESCD_SIZE (32*1024)
74static int proc_read_escd(char *buf, char **start, off_t pos, 66static int proc_read_escd(char *buf, char **start, off_t pos,
75 int count, int *eof, void *data) 67 int count, int *eof, void *data)
76{ 68{
77 struct escd_info_struc escd; 69 struct escd_info_struc escd;
78 char *tmpbuf; 70 char *tmpbuf;
@@ -83,30 +75,36 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
83 75
84 /* sanity check */ 76 /* sanity check */
85 if (escd.escd_size > MAX_SANE_ESCD_SIZE) { 77 if (escd.escd_size > MAX_SANE_ESCD_SIZE) {
86 printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by BIOS escd_info call is too great\n"); 78 printk(KERN_ERR
79 "PnPBIOS: proc_read_escd: ESCD size reported by BIOS escd_info call is too great\n");
87 return -EFBIG; 80 return -EFBIG;
88 } 81 }
89 82
90 tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL); 83 tmpbuf = kzalloc(escd.escd_size, GFP_KERNEL);
91 if (!tmpbuf) return -ENOMEM; 84 if (!tmpbuf)
85 return -ENOMEM;
92 86
93 if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) { 87 if (pnp_bios_read_escd(tmpbuf, escd.nv_storage_base)) {
94 kfree(tmpbuf); 88 kfree(tmpbuf);
95 return -EIO; 89 return -EIO;
96 } 90 }
97 91
98 escd_size = (unsigned char)(tmpbuf[0]) + (unsigned char)(tmpbuf[1])*256; 92 escd_size =
93 (unsigned char)(tmpbuf[0]) + (unsigned char)(tmpbuf[1]) * 256;
99 94
100 /* sanity check */ 95 /* sanity check */
101 if (escd_size > MAX_SANE_ESCD_SIZE) { 96 if (escd_size > MAX_SANE_ESCD_SIZE) {
102 printk(KERN_ERR "PnPBIOS: proc_read_escd: ESCD size reported by BIOS read_escd call is too great\n"); 97 printk(KERN_ERR
98 "PnPBIOS: proc_read_escd: ESCD size reported by BIOS read_escd call is too great\n");
103 return -EFBIG; 99 return -EFBIG;
104 } 100 }
105 101
106 escd_left_to_read = escd_size - pos; 102 escd_left_to_read = escd_size - pos;
107 if (escd_left_to_read < 0) escd_left_to_read = 0; 103 if (escd_left_to_read < 0)
108 if (escd_left_to_read == 0) *eof = 1; 104 escd_left_to_read = 0;
109 n = min(count,escd_left_to_read); 105 if (escd_left_to_read == 0)
106 *eof = 1;
107 n = min(count, escd_left_to_read);
110 memcpy(buf, tmpbuf + pos, n); 108 memcpy(buf, tmpbuf + pos, n);
111 kfree(tmpbuf); 109 kfree(tmpbuf);
112 *start = buf; 110 *start = buf;
@@ -114,17 +112,17 @@ static int proc_read_escd(char *buf, char **start, off_t pos,
114} 112}
115 113
116static int proc_read_legacyres(char *buf, char **start, off_t pos, 114static int proc_read_legacyres(char *buf, char **start, off_t pos,
117 int count, int *eof, void *data) 115 int count, int *eof, void *data)
118{ 116{
119 /* Assume that the following won't overflow the buffer */ 117 /* Assume that the following won't overflow the buffer */
120 if (pnp_bios_get_stat_res(buf)) 118 if (pnp_bios_get_stat_res(buf))
121 return -EIO; 119 return -EIO;
122 120
123 return count; // FIXME: Return actual length 121 return count; // FIXME: Return actual length
124} 122}
125 123
126static int proc_read_devices(char *buf, char **start, off_t pos, 124static int proc_read_devices(char *buf, char **start, off_t pos,
127 int count, int *eof, void *data) 125 int count, int *eof, void *data)
128{ 126{
129 struct pnp_bios_node *node; 127 struct pnp_bios_node *node;
130 u8 nodenum; 128 u8 nodenum;
@@ -134,9 +132,10 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
134 return 0; 132 return 0;
135 133
136 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 134 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
137 if (!node) return -ENOMEM; 135 if (!node)
136 return -ENOMEM;
138 137
139 for (nodenum=pos; nodenum<0xff; ) { 138 for (nodenum = pos; nodenum < 0xff;) {
140 u8 thisnodenum = nodenum; 139 u8 thisnodenum = nodenum;
141 /* 26 = the number of characters per line sprintf'ed */ 140 /* 26 = the number of characters per line sprintf'ed */
142 if ((p - buf + 26) > count) 141 if ((p - buf + 26) > count)
@@ -148,7 +147,11 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
148 node->type_code[0], node->type_code[1], 147 node->type_code[0], node->type_code[1],
149 node->type_code[2], node->flags); 148 node->type_code[2], node->flags);
150 if (nodenum <= thisnodenum) { 149 if (nodenum <= thisnodenum) {
151 printk(KERN_ERR "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n", "PnPBIOS: proc_read_devices:", (unsigned int)nodenum, (unsigned int)thisnodenum); 150 printk(KERN_ERR
151 "%s Node number 0x%x is out of sequence following node 0x%x. Aborting.\n",
152 "PnPBIOS: proc_read_devices:",
153 (unsigned int)nodenum,
154 (unsigned int)thisnodenum);
152 *eof = 1; 155 *eof = 1;
153 break; 156 break;
154 } 157 }
@@ -156,12 +159,12 @@ static int proc_read_devices(char *buf, char **start, off_t pos,
156 kfree(node); 159 kfree(node);
157 if (nodenum == 0xff) 160 if (nodenum == 0xff)
158 *eof = 1; 161 *eof = 1;
159 *start = (char *)((off_t)nodenum - pos); 162 *start = (char *)((off_t) nodenum - pos);
160 return p - buf; 163 return p - buf;
161} 164}
162 165
163static int proc_read_node(char *buf, char **start, off_t pos, 166static int proc_read_node(char *buf, char **start, off_t pos,
164 int count, int *eof, void *data) 167 int count, int *eof, void *data)
165{ 168{
166 struct pnp_bios_node *node; 169 struct pnp_bios_node *node;
167 int boot = (long)data >> 8; 170 int boot = (long)data >> 8;
@@ -169,7 +172,8 @@ static int proc_read_node(char *buf, char **start, off_t pos,
169 int len; 172 int len;
170 173
171 node = kzalloc(node_info.max_node_size, GFP_KERNEL); 174 node = kzalloc(node_info.max_node_size, GFP_KERNEL);
172 if (!node) return -ENOMEM; 175 if (!node)
176 return -ENOMEM;
173 if (pnp_bios_get_dev_node(&nodenum, boot, node)) { 177 if (pnp_bios_get_dev_node(&nodenum, boot, node)) {
174 kfree(node); 178 kfree(node);
175 return -EIO; 179 return -EIO;
@@ -180,8 +184,8 @@ static int proc_read_node(char *buf, char **start, off_t pos,
180 return len; 184 return len;
181} 185}
182 186
183static int proc_write_node(struct file *file, const char __user *buf, 187static int proc_write_node(struct file *file, const char __user * buf,
184 unsigned long count, void *data) 188 unsigned long count, void *data)
185{ 189{
186 struct pnp_bios_node *node; 190 struct pnp_bios_node *node;
187 int boot = (long)data >> 8; 191 int boot = (long)data >> 8;
@@ -208,12 +212,12 @@ static int proc_write_node(struct file *file, const char __user *buf,
208 goto out; 212 goto out;
209 } 213 }
210 ret = count; 214 ret = count;
211out: 215 out:
212 kfree(node); 216 kfree(node);
213 return ret; 217 return ret;
214} 218}
215 219
216int pnpbios_interface_attach_device(struct pnp_bios_node * node) 220int pnpbios_interface_attach_device(struct pnp_bios_node *node)
217{ 221{
218 char name[3]; 222 char name[3];
219 struct proc_dir_entry *ent; 223 struct proc_dir_entry *ent;
@@ -222,7 +226,7 @@ int pnpbios_interface_attach_device(struct pnp_bios_node * node)
222 226
223 if (!proc_pnp) 227 if (!proc_pnp)
224 return -EIO; 228 return -EIO;
225 if ( !pnpbios_dont_use_current_config ) { 229 if (!pnpbios_dont_use_current_config) {
226 ent = create_proc_entry(name, 0, proc_pnp); 230 ent = create_proc_entry(name, 0, proc_pnp);
227 if (ent) { 231 if (ent) {
228 ent->read_proc = proc_read_node; 232 ent->read_proc = proc_read_node;
@@ -237,7 +241,7 @@ int pnpbios_interface_attach_device(struct pnp_bios_node * node)
237 if (ent) { 241 if (ent) {
238 ent->read_proc = proc_read_node; 242 ent->read_proc = proc_read_node;
239 ent->write_proc = proc_write_node; 243 ent->write_proc = proc_write_node;
240 ent->data = (void *)(long)(node->handle+0x100); 244 ent->data = (void *)(long)(node->handle + 0x100);
241 return 0; 245 return 0;
242 } 246 }
243 247
@@ -249,7 +253,7 @@ int pnpbios_interface_attach_device(struct pnp_bios_node * node)
249 * work and the pnpbios_dont_use_current_config flag 253 * work and the pnpbios_dont_use_current_config flag
250 * should already have been set to the appropriate value 254 * should already have been set to the appropriate value
251 */ 255 */
252int __init pnpbios_proc_init( void ) 256int __init pnpbios_proc_init(void)
253{ 257{
254 proc_pnp = proc_mkdir("pnp", proc_bus); 258 proc_pnp = proc_mkdir("pnp", proc_bus);
255 if (!proc_pnp) 259 if (!proc_pnp)
@@ -258,10 +262,13 @@ int __init pnpbios_proc_init( void )
258 if (!proc_pnp_boot) 262 if (!proc_pnp_boot)
259 return -EIO; 263 return -EIO;
260 create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL); 264 create_proc_read_entry("devices", 0, proc_pnp, proc_read_devices, NULL);
261 create_proc_read_entry("configuration_info", 0, proc_pnp, proc_read_pnpconfig, NULL); 265 create_proc_read_entry("configuration_info", 0, proc_pnp,
262 create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo, NULL); 266 proc_read_pnpconfig, NULL);
267 create_proc_read_entry("escd_info", 0, proc_pnp, proc_read_escdinfo,
268 NULL);
263 create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL); 269 create_proc_read_entry("escd", S_IRUSR, proc_pnp, proc_read_escd, NULL);
264 create_proc_read_entry("legacy_device_resources", 0, proc_pnp, proc_read_legacyres, NULL); 270 create_proc_read_entry("legacy_device_resources", 0, proc_pnp,
271 proc_read_legacyres, NULL);
265 272
266 return 0; 273 return 0;
267} 274}
@@ -274,9 +281,9 @@ void __exit pnpbios_proc_exit(void)
274 if (!proc_pnp) 281 if (!proc_pnp)
275 return; 282 return;
276 283
277 for (i=0; i<0xff; i++) { 284 for (i = 0; i < 0xff; i++) {
278 sprintf(name, "%02x", i); 285 sprintf(name, "%02x", i);
279 if ( !pnpbios_dont_use_current_config ) 286 if (!pnpbios_dont_use_current_config)
280 remove_proc_entry(name, proc_pnp); 287 remove_proc_entry(name, proc_pnp);
281 remove_proc_entry(name, proc_pnp_boot); 288 remove_proc_entry(name, proc_pnp_boot);
282 } 289 }
@@ -287,6 +294,4 @@ void __exit pnpbios_proc_exit(void)
287 remove_proc_entry("devices", proc_pnp); 294 remove_proc_entry("devices", proc_pnp);
288 remove_proc_entry("boot", proc_pnp); 295 remove_proc_entry("boot", proc_pnp);
289 remove_proc_entry("pnp", proc_bus); 296 remove_proc_entry("pnp", proc_bus);
290
291 return;
292} 297}
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 3c2ab8394e3f..04ecd7b67230 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * rsparser.c - parses and encodes pnpbios resource data streams 2 * rsparser.c - parses and encodes pnpbios resource data streams
3 *
4 */ 3 */
5 4
6#include <linux/ctype.h> 5#include <linux/ctype.h>
@@ -12,8 +11,10 @@
12#ifdef CONFIG_PCI 11#ifdef CONFIG_PCI
13#include <linux/pci.h> 12#include <linux/pci.h>
14#else 13#else
15inline void pcibios_penalize_isa_irq(int irq, int active) {} 14inline void pcibios_penalize_isa_irq(int irq, int active)
16#endif /* CONFIG_PCI */ 15{
16}
17#endif /* CONFIG_PCI */
17 18
18#include "pnpbios.h" 19#include "pnpbios.h"
19 20
@@ -52,75 +53,88 @@ inline void pcibios_penalize_isa_irq(int irq, int active) {}
52 * Allocated Resources 53 * Allocated Resources
53 */ 54 */
54 55
55static void 56static void pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res,
56pnpbios_parse_allocated_irqresource(struct pnp_resource_table * res, int irq) 57 int irq)
57{ 58{
58 int i = 0; 59 int i = 0;
59 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_IRQ) i++; 60
61 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
62 && i < PNP_MAX_IRQ)
63 i++;
60 if (i < PNP_MAX_IRQ) { 64 if (i < PNP_MAX_IRQ) {
61 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 65 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
62 if (irq == -1) { 66 if (irq == -1) {
63 res->irq_resource[i].flags |= IORESOURCE_DISABLED; 67 res->irq_resource[i].flags |= IORESOURCE_DISABLED;
64 return; 68 return;
65 } 69 }
66 res->irq_resource[i].start = 70 res->irq_resource[i].start =
67 res->irq_resource[i].end = (unsigned long) irq; 71 res->irq_resource[i].end = (unsigned long)irq;
68 pcibios_penalize_isa_irq(irq, 1); 72 pcibios_penalize_isa_irq(irq, 1);
69 } 73 }
70} 74}
71 75
72static void 76static void pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res,
73pnpbios_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) 77 int dma)
74{ 78{
75 int i = 0; 79 int i = 0;
80
76 while (i < PNP_MAX_DMA && 81 while (i < PNP_MAX_DMA &&
77 !(res->dma_resource[i].flags & IORESOURCE_UNSET)) 82 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
78 i++; 83 i++;
79 if (i < PNP_MAX_DMA) { 84 if (i < PNP_MAX_DMA) {
80 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag 85 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
81 if (dma == -1) { 86 if (dma == -1) {
82 res->dma_resource[i].flags |= IORESOURCE_DISABLED; 87 res->dma_resource[i].flags |= IORESOURCE_DISABLED;
83 return; 88 return;
84 } 89 }
85 res->dma_resource[i].start = 90 res->dma_resource[i].start =
86 res->dma_resource[i].end = (unsigned long) dma; 91 res->dma_resource[i].end = (unsigned long)dma;
87 } 92 }
88} 93}
89 94
90static void 95static void pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res,
91pnpbios_parse_allocated_ioresource(struct pnp_resource_table * res, int io, int len) 96 int io, int len)
92{ 97{
93 int i = 0; 98 int i = 0;
94 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_PORT) i++; 99
100 while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
101 && i < PNP_MAX_PORT)
102 i++;
95 if (i < PNP_MAX_PORT) { 103 if (i < PNP_MAX_PORT) {
96 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag 104 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag
97 if (len <= 0 || (io + len -1) >= 0x10003) { 105 if (len <= 0 || (io + len - 1) >= 0x10003) {
98 res->port_resource[i].flags |= IORESOURCE_DISABLED; 106 res->port_resource[i].flags |= IORESOURCE_DISABLED;
99 return; 107 return;
100 } 108 }
101 res->port_resource[i].start = (unsigned long) io; 109 res->port_resource[i].start = (unsigned long)io;
102 res->port_resource[i].end = (unsigned long)(io + len - 1); 110 res->port_resource[i].end = (unsigned long)(io + len - 1);
103 } 111 }
104} 112}
105 113
106static void 114static void pnpbios_parse_allocated_memresource(struct pnp_resource_table *res,
107pnpbios_parse_allocated_memresource(struct pnp_resource_table * res, int mem, int len) 115 int mem, int len)
108{ 116{
109 int i = 0; 117 int i = 0;
110 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_MEM) i++; 118
119 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
120 && i < PNP_MAX_MEM)
121 i++;
111 if (i < PNP_MAX_MEM) { 122 if (i < PNP_MAX_MEM) {
112 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag 123 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag
113 if (len <= 0) { 124 if (len <= 0) {
114 res->mem_resource[i].flags |= IORESOURCE_DISABLED; 125 res->mem_resource[i].flags |= IORESOURCE_DISABLED;
115 return; 126 return;
116 } 127 }
117 res->mem_resource[i].start = (unsigned long) mem; 128 res->mem_resource[i].start = (unsigned long)mem;
118 res->mem_resource[i].end = (unsigned long)(mem + len - 1); 129 res->mem_resource[i].end = (unsigned long)(mem + len - 1);
119 } 130 }
120} 131}
121 132
122static unsigned char * 133static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p,
123pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, struct pnp_resource_table * res) 134 unsigned char *end,
135 struct
136 pnp_resource_table
137 *res)
124{ 138{
125 unsigned int len, tag; 139 unsigned int len, tag;
126 int io, size, mask, i; 140 int io, size, mask, i;
@@ -134,12 +148,12 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
134 while ((char *)p < (char *)end) { 148 while ((char *)p < (char *)end) {
135 149
136 /* determine the type of tag */ 150 /* determine the type of tag */
137 if (p[0] & LARGE_TAG) { /* large tag */ 151 if (p[0] & LARGE_TAG) { /* large tag */
138 len = (p[2] << 8) | p[1]; 152 len = (p[2] << 8) | p[1];
139 tag = p[0]; 153 tag = p[0];
140 } else { /* small tag */ 154 } else { /* small tag */
141 len = p[0] & 0x07; 155 len = p[0] & 0x07;
142 tag = ((p[0]>>3) & 0x0f); 156 tag = ((p[0] >> 3) & 0x0f);
143 } 157 }
144 158
145 switch (tag) { 159 switch (tag) {
@@ -147,8 +161,8 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
147 case LARGE_TAG_MEM: 161 case LARGE_TAG_MEM:
148 if (len != 9) 162 if (len != 9)
149 goto len_err; 163 goto len_err;
150 io = *(short *) &p[4]; 164 io = *(short *)&p[4];
151 size = *(short *) &p[10]; 165 size = *(short *)&p[10];
152 pnpbios_parse_allocated_memresource(res, io, size); 166 pnpbios_parse_allocated_memresource(res, io, size);
153 break; 167 break;
154 168
@@ -163,16 +177,16 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
163 case LARGE_TAG_MEM32: 177 case LARGE_TAG_MEM32:
164 if (len != 17) 178 if (len != 17)
165 goto len_err; 179 goto len_err;
166 io = *(int *) &p[4]; 180 io = *(int *)&p[4];
167 size = *(int *) &p[16]; 181 size = *(int *)&p[16];
168 pnpbios_parse_allocated_memresource(res, io, size); 182 pnpbios_parse_allocated_memresource(res, io, size);
169 break; 183 break;
170 184
171 case LARGE_TAG_FIXEDMEM32: 185 case LARGE_TAG_FIXEDMEM32:
172 if (len != 9) 186 if (len != 9)
173 goto len_err; 187 goto len_err;
174 io = *(int *) &p[4]; 188 io = *(int *)&p[4];
175 size = *(int *) &p[8]; 189 size = *(int *)&p[8];
176 pnpbios_parse_allocated_memresource(res, io, size); 190 pnpbios_parse_allocated_memresource(res, io, size);
177 break; 191 break;
178 192
@@ -180,9 +194,10 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
180 if (len < 2 || len > 3) 194 if (len < 2 || len > 3)
181 goto len_err; 195 goto len_err;
182 io = -1; 196 io = -1;
183 mask= p[1] + p[2]*256; 197 mask = p[1] + p[2] * 256;
184 for (i=0;i<16;i++, mask=mask>>1) 198 for (i = 0; i < 16; i++, mask = mask >> 1)
185 if(mask & 0x01) io=i; 199 if (mask & 0x01)
200 io = i;
186 pnpbios_parse_allocated_irqresource(res, io); 201 pnpbios_parse_allocated_irqresource(res, io);
187 break; 202 break;
188 203
@@ -191,15 +206,16 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
191 goto len_err; 206 goto len_err;
192 io = -1; 207 io = -1;
193 mask = p[1]; 208 mask = p[1];
194 for (i=0;i<8;i++, mask = mask>>1) 209 for (i = 0; i < 8; i++, mask = mask >> 1)
195 if(mask & 0x01) io=i; 210 if (mask & 0x01)
211 io = i;
196 pnpbios_parse_allocated_dmaresource(res, io); 212 pnpbios_parse_allocated_dmaresource(res, io);
197 break; 213 break;
198 214
199 case SMALL_TAG_PORT: 215 case SMALL_TAG_PORT:
200 if (len != 7) 216 if (len != 7)
201 goto len_err; 217 goto len_err;
202 io = p[2] + p[3] *256; 218 io = p[2] + p[3] * 256;
203 size = p[7]; 219 size = p[7];
204 pnpbios_parse_allocated_ioresource(res, io, size); 220 pnpbios_parse_allocated_ioresource(res, io, size);
205 break; 221 break;
@@ -218,12 +234,14 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
218 234
219 case SMALL_TAG_END: 235 case SMALL_TAG_END:
220 p = p + 2; 236 p = p + 2;
221 return (unsigned char *)p; 237 return (unsigned char *)p;
222 break; 238 break;
223 239
224 default: /* an unkown tag */ 240 default: /* an unkown tag */
225 len_err: 241 len_err:
226 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 242 printk(KERN_ERR
243 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
244 tag, len);
227 break; 245 break;
228 } 246 }
229 247
@@ -234,20 +252,21 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
234 p += len + 1; 252 p += len + 1;
235 } 253 }
236 254
237 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 255 printk(KERN_ERR
256 "PnPBIOS: Resource structure does not contain an end tag.\n");
238 257
239 return NULL; 258 return NULL;
240} 259}
241 260
242
243/* 261/*
244 * Resource Configuration Options 262 * Resource Configuration Options
245 */ 263 */
246 264
247static void 265static void pnpbios_parse_mem_option(unsigned char *p, int size,
248pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) 266 struct pnp_option *option)
249{ 267{
250 struct pnp_mem * mem; 268 struct pnp_mem *mem;
269
251 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 270 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
252 if (!mem) 271 if (!mem)
253 return; 272 return;
@@ -256,14 +275,14 @@ pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option)
256 mem->align = (p[9] << 8) | p[8]; 275 mem->align = (p[9] << 8) | p[8];
257 mem->size = ((p[11] << 8) | p[10]) << 8; 276 mem->size = ((p[11] << 8) | p[10]) << 8;
258 mem->flags = p[3]; 277 mem->flags = p[3];
259 pnp_register_mem_resource(option,mem); 278 pnp_register_mem_resource(option, mem);
260 return;
261} 279}
262 280
263static void 281static void pnpbios_parse_mem32_option(unsigned char *p, int size,
264pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) 282 struct pnp_option *option)
265{ 283{
266 struct pnp_mem * mem; 284 struct pnp_mem *mem;
285
267 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 286 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
268 if (!mem) 287 if (!mem)
269 return; 288 return;
@@ -272,14 +291,13 @@ pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option
272 mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12]; 291 mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12];
273 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16]; 292 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16];
274 mem->flags = p[3]; 293 mem->flags = p[3];
275 pnp_register_mem_resource(option,mem); 294 pnp_register_mem_resource(option, mem);
276 return;
277} 295}
278 296
279static void 297static void pnpbios_parse_fixed_mem32_option(unsigned char *p, int size,
280pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) 298 struct pnp_option *option)
281{ 299{
282 struct pnp_mem * mem; 300 struct pnp_mem *mem;
283 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 301 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
284 if (!mem) 302 if (!mem)
285 return; 303 return;
@@ -287,14 +305,13 @@ pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *
287 mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8]; 305 mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8];
288 mem->align = 0; 306 mem->align = 0;
289 mem->flags = p[3]; 307 mem->flags = p[3];
290 pnp_register_mem_resource(option,mem); 308 pnp_register_mem_resource(option, mem);
291 return;
292} 309}
293 310
294static void 311static void pnpbios_parse_irq_option(unsigned char *p, int size,
295pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) 312 struct pnp_option *option)
296{ 313{
297 struct pnp_irq * irq; 314 struct pnp_irq *irq;
298 unsigned long bits; 315 unsigned long bits;
299 316
300 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); 317 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
@@ -306,27 +323,27 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option)
306 irq->flags = p[3]; 323 irq->flags = p[3];
307 else 324 else
308 irq->flags = IORESOURCE_IRQ_HIGHEDGE; 325 irq->flags = IORESOURCE_IRQ_HIGHEDGE;
309 pnp_register_irq_resource(option,irq); 326 pnp_register_irq_resource(option, irq);
310 return;
311} 327}
312 328
313static void 329static void pnpbios_parse_dma_option(unsigned char *p, int size,
314pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) 330 struct pnp_option *option)
315{ 331{
316 struct pnp_dma * dma; 332 struct pnp_dma *dma;
333
317 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); 334 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
318 if (!dma) 335 if (!dma)
319 return; 336 return;
320 dma->map = p[1]; 337 dma->map = p[1];
321 dma->flags = p[2]; 338 dma->flags = p[2];
322 pnp_register_dma_resource(option,dma); 339 pnp_register_dma_resource(option, dma);
323 return;
324} 340}
325 341
326static void 342static void pnpbios_parse_port_option(unsigned char *p, int size,
327pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) 343 struct pnp_option *option)
328{ 344{
329 struct pnp_port * port; 345 struct pnp_port *port;
346
330 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 347 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
331 if (!port) 348 if (!port)
332 return; 349 return;
@@ -335,14 +352,14 @@ pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option)
335 port->align = p[6]; 352 port->align = p[6];
336 port->size = p[7]; 353 port->size = p[7];
337 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0; 354 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0;
338 pnp_register_port_resource(option,port); 355 pnp_register_port_resource(option, port);
339 return;
340} 356}
341 357
342static void 358static void pnpbios_parse_fixed_port_option(unsigned char *p, int size,
343pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) 359 struct pnp_option *option)
344{ 360{
345 struct pnp_port * port; 361 struct pnp_port *port;
362
346 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 363 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
347 if (!port) 364 if (!port)
348 return; 365 return;
@@ -350,12 +367,12 @@ pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *o
350 port->size = p[3]; 367 port->size = p[3];
351 port->align = 0; 368 port->align = 0;
352 port->flags = PNP_PORT_FLAG_FIXED; 369 port->flags = PNP_PORT_FLAG_FIXED;
353 pnp_register_port_resource(option,port); 370 pnp_register_port_resource(option, port);
354 return;
355} 371}
356 372
357static unsigned char * 373static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p,
358pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struct pnp_dev *dev) 374 unsigned char *end,
375 struct pnp_dev *dev)
359{ 376{
360 unsigned int len, tag; 377 unsigned int len, tag;
361 int priority = 0; 378 int priority = 0;
@@ -371,12 +388,12 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
371 while ((char *)p < (char *)end) { 388 while ((char *)p < (char *)end) {
372 389
373 /* determine the type of tag */ 390 /* determine the type of tag */
374 if (p[0] & LARGE_TAG) { /* large tag */ 391 if (p[0] & LARGE_TAG) { /* large tag */
375 len = (p[2] << 8) | p[1]; 392 len = (p[2] << 8) | p[1];
376 tag = p[0]; 393 tag = p[0];
377 } else { /* small tag */ 394 } else { /* small tag */
378 len = p[0] & 0x07; 395 len = p[0] & 0x07;
379 tag = ((p[0]>>3) & 0x0f); 396 tag = ((p[0] >> 3) & 0x0f);
380 } 397 }
381 398
382 switch (tag) { 399 switch (tag) {
@@ -442,16 +459,19 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
442 if (len != 0) 459 if (len != 0)
443 goto len_err; 460 goto len_err;
444 if (option_independent == option) 461 if (option_independent == option)
445 printk(KERN_WARNING "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n"); 462 printk(KERN_WARNING
463 "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n");
446 option = option_independent; 464 option = option_independent;
447 break; 465 break;
448 466
449 case SMALL_TAG_END: 467 case SMALL_TAG_END:
450 return p + 2; 468 return p + 2;
451 469
452 default: /* an unkown tag */ 470 default: /* an unkown tag */
453 len_err: 471 len_err:
454 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 472 printk(KERN_ERR
473 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
474 tag, len);
455 break; 475 break;
456 } 476 }
457 477
@@ -462,19 +482,18 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
462 p += len + 1; 482 p += len + 1;
463 } 483 }
464 484
465 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 485 printk(KERN_ERR
486 "PnPBIOS: Resource structure does not contain an end tag.\n");
466 487
467 return NULL; 488 return NULL;
468} 489}
469 490
470
471/* 491/*
472 * Compatible Device IDs 492 * Compatible Device IDs
473 */ 493 */
474 494
475#define HEX(id,a) hex[((id)>>a) & 15] 495#define HEX(id,a) hex[((id)>>a) & 15]
476#define CHAR(id,a) (0x40 + (((id)>>a) & 31)) 496#define CHAR(id,a) (0x40 + (((id)>>a) & 31))
477//
478 497
479void pnpid32_to_pnpid(u32 id, char *str) 498void pnpid32_to_pnpid(u32 id, char *str)
480{ 499{
@@ -483,21 +502,20 @@ void pnpid32_to_pnpid(u32 id, char *str)
483 id = be32_to_cpu(id); 502 id = be32_to_cpu(id);
484 str[0] = CHAR(id, 26); 503 str[0] = CHAR(id, 26);
485 str[1] = CHAR(id, 21); 504 str[1] = CHAR(id, 21);
486 str[2] = CHAR(id,16); 505 str[2] = CHAR(id, 16);
487 str[3] = HEX(id, 12); 506 str[3] = HEX(id, 12);
488 str[4] = HEX(id, 8); 507 str[4] = HEX(id, 8);
489 str[5] = HEX(id, 4); 508 str[5] = HEX(id, 4);
490 str[6] = HEX(id, 0); 509 str[6] = HEX(id, 0);
491 str[7] = '\0'; 510 str[7] = '\0';
492
493 return;
494} 511}
495// 512
496#undef CHAR 513#undef CHAR
497#undef HEX 514#undef HEX
498 515
499static unsigned char * 516static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p,
500pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_dev *dev) 517 unsigned char *end,
518 struct pnp_dev *dev)
501{ 519{
502 int len, tag; 520 int len, tag;
503 char id[8]; 521 char id[8];
@@ -509,40 +527,45 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de
509 while ((char *)p < (char *)end) { 527 while ((char *)p < (char *)end) {
510 528
511 /* determine the type of tag */ 529 /* determine the type of tag */
512 if (p[0] & LARGE_TAG) { /* large tag */ 530 if (p[0] & LARGE_TAG) { /* large tag */
513 len = (p[2] << 8) | p[1]; 531 len = (p[2] << 8) | p[1];
514 tag = p[0]; 532 tag = p[0];
515 } else { /* small tag */ 533 } else { /* small tag */
516 len = p[0] & 0x07; 534 len = p[0] & 0x07;
517 tag = ((p[0]>>3) & 0x0f); 535 tag = ((p[0] >> 3) & 0x0f);
518 } 536 }
519 537
520 switch (tag) { 538 switch (tag) {
521 539
522 case LARGE_TAG_ANSISTR: 540 case LARGE_TAG_ANSISTR:
523 strncpy(dev->name, p + 3, len >= PNP_NAME_LEN ? PNP_NAME_LEN - 2 : len); 541 strncpy(dev->name, p + 3,
524 dev->name[len >= PNP_NAME_LEN ? PNP_NAME_LEN - 1 : len] = '\0'; 542 len >= PNP_NAME_LEN ? PNP_NAME_LEN - 2 : len);
543 dev->name[len >=
544 PNP_NAME_LEN ? PNP_NAME_LEN - 1 : len] = '\0';
525 break; 545 break;
526 546
527 case SMALL_TAG_COMPATDEVID: /* compatible ID */ 547 case SMALL_TAG_COMPATDEVID: /* compatible ID */
528 if (len != 4) 548 if (len != 4)
529 goto len_err; 549 goto len_err;
530 dev_id = kzalloc(sizeof (struct pnp_id), GFP_KERNEL); 550 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
531 if (!dev_id) 551 if (!dev_id)
532 return NULL; 552 return NULL;
533 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24,id); 553 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] <<
554 24, id);
534 memcpy(&dev_id->id, id, 7); 555 memcpy(&dev_id->id, id, 7);
535 pnp_add_id(dev_id, dev); 556 pnp_add_id(dev_id, dev);
536 break; 557 break;
537 558
538 case SMALL_TAG_END: 559 case SMALL_TAG_END:
539 p = p + 2; 560 p = p + 2;
540 return (unsigned char *)p; 561 return (unsigned char *)p;
541 break; 562 break;
542 563
543 default: /* an unkown tag */ 564 default: /* an unkown tag */
544 len_err: 565 len_err:
545 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 566 printk(KERN_ERR
567 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
568 tag, len);
546 break; 569 break;
547 } 570 }
548 571
@@ -553,33 +576,34 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de
553 p += len + 1; 576 p += len + 1;
554 } 577 }
555 578
556 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 579 printk(KERN_ERR
580 "PnPBIOS: Resource structure does not contain an end tag.\n");
557 581
558 return NULL; 582 return NULL;
559} 583}
560 584
561
562/* 585/*
563 * Allocated Resource Encoding 586 * Allocated Resource Encoding
564 */ 587 */
565 588
566static void pnpbios_encode_mem(unsigned char *p, struct resource * res) 589static void pnpbios_encode_mem(unsigned char *p, struct resource *res)
567{ 590{
568 unsigned long base = res->start; 591 unsigned long base = res->start;
569 unsigned long len = res->end - res->start + 1; 592 unsigned long len = res->end - res->start + 1;
593
570 p[4] = (base >> 8) & 0xff; 594 p[4] = (base >> 8) & 0xff;
571 p[5] = ((base >> 8) >> 8) & 0xff; 595 p[5] = ((base >> 8) >> 8) & 0xff;
572 p[6] = (base >> 8) & 0xff; 596 p[6] = (base >> 8) & 0xff;
573 p[7] = ((base >> 8) >> 8) & 0xff; 597 p[7] = ((base >> 8) >> 8) & 0xff;
574 p[10] = (len >> 8) & 0xff; 598 p[10] = (len >> 8) & 0xff;
575 p[11] = ((len >> 8) >> 8) & 0xff; 599 p[11] = ((len >> 8) >> 8) & 0xff;
576 return;
577} 600}
578 601
579static void pnpbios_encode_mem32(unsigned char *p, struct resource * res) 602static void pnpbios_encode_mem32(unsigned char *p, struct resource *res)
580{ 603{
581 unsigned long base = res->start; 604 unsigned long base = res->start;
582 unsigned long len = res->end - res->start + 1; 605 unsigned long len = res->end - res->start + 1;
606
583 p[4] = base & 0xff; 607 p[4] = base & 0xff;
584 p[5] = (base >> 8) & 0xff; 608 p[5] = (base >> 8) & 0xff;
585 p[6] = (base >> 16) & 0xff; 609 p[6] = (base >> 16) & 0xff;
@@ -592,12 +616,13 @@ static void pnpbios_encode_mem32(unsigned char *p, struct resource * res)
592 p[17] = (len >> 8) & 0xff; 616 p[17] = (len >> 8) & 0xff;
593 p[18] = (len >> 16) & 0xff; 617 p[18] = (len >> 16) & 0xff;
594 p[19] = (len >> 24) & 0xff; 618 p[19] = (len >> 24) & 0xff;
595 return;
596} 619}
597 620
598static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource * res) 621static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res)
599{ unsigned long base = res->start; 622{
623 unsigned long base = res->start;
600 unsigned long len = res->end - res->start + 1; 624 unsigned long len = res->end - res->start + 1;
625
601 p[4] = base & 0xff; 626 p[4] = base & 0xff;
602 p[5] = (base >> 8) & 0xff; 627 p[5] = (base >> 8) & 0xff;
603 p[6] = (base >> 16) & 0xff; 628 p[6] = (base >> 16) & 0xff;
@@ -606,50 +631,52 @@ static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource * res)
606 p[9] = (len >> 8) & 0xff; 631 p[9] = (len >> 8) & 0xff;
607 p[10] = (len >> 16) & 0xff; 632 p[10] = (len >> 16) & 0xff;
608 p[11] = (len >> 24) & 0xff; 633 p[11] = (len >> 24) & 0xff;
609 return;
610} 634}
611 635
612static void pnpbios_encode_irq(unsigned char *p, struct resource * res) 636static void pnpbios_encode_irq(unsigned char *p, struct resource *res)
613{ 637{
614 unsigned long map = 0; 638 unsigned long map = 0;
639
615 map = 1 << res->start; 640 map = 1 << res->start;
616 p[1] = map & 0xff; 641 p[1] = map & 0xff;
617 p[2] = (map >> 8) & 0xff; 642 p[2] = (map >> 8) & 0xff;
618 return;
619} 643}
620 644
621static void pnpbios_encode_dma(unsigned char *p, struct resource * res) 645static void pnpbios_encode_dma(unsigned char *p, struct resource *res)
622{ 646{
623 unsigned long map = 0; 647 unsigned long map = 0;
648
624 map = 1 << res->start; 649 map = 1 << res->start;
625 p[1] = map & 0xff; 650 p[1] = map & 0xff;
626 return;
627} 651}
628 652
629static void pnpbios_encode_port(unsigned char *p, struct resource * res) 653static void pnpbios_encode_port(unsigned char *p, struct resource *res)
630{ 654{
631 unsigned long base = res->start; 655 unsigned long base = res->start;
632 unsigned long len = res->end - res->start + 1; 656 unsigned long len = res->end - res->start + 1;
657
633 p[2] = base & 0xff; 658 p[2] = base & 0xff;
634 p[3] = (base >> 8) & 0xff; 659 p[3] = (base >> 8) & 0xff;
635 p[4] = base & 0xff; 660 p[4] = base & 0xff;
636 p[5] = (base >> 8) & 0xff; 661 p[5] = (base >> 8) & 0xff;
637 p[7] = len & 0xff; 662 p[7] = len & 0xff;
638 return;
639} 663}
640 664
641static void pnpbios_encode_fixed_port(unsigned char *p, struct resource * res) 665static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res)
642{ 666{
643 unsigned long base = res->start; 667 unsigned long base = res->start;
644 unsigned long len = res->end - res->start + 1; 668 unsigned long len = res->end - res->start + 1;
669
645 p[1] = base & 0xff; 670 p[1] = base & 0xff;
646 p[2] = (base >> 8) & 0xff; 671 p[2] = (base >> 8) & 0xff;
647 p[3] = len & 0xff; 672 p[3] = len & 0xff;
648 return;
649} 673}
650 674
651static unsigned char * 675static unsigned char *pnpbios_encode_allocated_resource_data(unsigned char *p,
652pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, struct pnp_resource_table * res) 676 unsigned char *end,
677 struct
678 pnp_resource_table
679 *res)
653{ 680{
654 unsigned int len, tag; 681 unsigned int len, tag;
655 int port = 0, irq = 0, dma = 0, mem = 0; 682 int port = 0, irq = 0, dma = 0, mem = 0;
@@ -660,12 +687,12 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s
660 while ((char *)p < (char *)end) { 687 while ((char *)p < (char *)end) {
661 688
662 /* determine the type of tag */ 689 /* determine the type of tag */
663 if (p[0] & LARGE_TAG) { /* large tag */ 690 if (p[0] & LARGE_TAG) { /* large tag */
664 len = (p[2] << 8) | p[1]; 691 len = (p[2] << 8) | p[1];
665 tag = p[0]; 692 tag = p[0];
666 } else { /* small tag */ 693 } else { /* small tag */
667 len = p[0] & 0x07; 694 len = p[0] & 0x07;
668 tag = ((p[0]>>3) & 0x0f); 695 tag = ((p[0] >> 3) & 0x0f);
669 } 696 }
670 697
671 switch (tag) { 698 switch (tag) {
@@ -725,12 +752,14 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s
725 752
726 case SMALL_TAG_END: 753 case SMALL_TAG_END:
727 p = p + 2; 754 p = p + 2;
728 return (unsigned char *)p; 755 return (unsigned char *)p;
729 break; 756 break;
730 757
731 default: /* an unkown tag */ 758 default: /* an unkown tag */
732 len_err: 759 len_err:
733 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 760 printk(KERN_ERR
761 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
762 tag, len);
734 break; 763 break;
735 } 764 }
736 765
@@ -741,52 +770,52 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s
741 p += len + 1; 770 p += len + 1;
742 } 771 }
743 772
744 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 773 printk(KERN_ERR
774 "PnPBIOS: Resource structure does not contain an end tag.\n");
745 775
746 return NULL; 776 return NULL;
747} 777}
748 778
749
750/* 779/*
751 * Core Parsing Functions 780 * Core Parsing Functions
752 */ 781 */
753 782
754int 783int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node *node)
755pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node)
756{ 784{
757 unsigned char * p = (char *)node->data; 785 unsigned char *p = (char *)node->data;
758 unsigned char * end = (char *)(node->data + node->size); 786 unsigned char *end = (char *)(node->data + node->size);
759 p = pnpbios_parse_allocated_resource_data(p,end,&dev->res); 787
788 p = pnpbios_parse_allocated_resource_data(p, end, &dev->res);
760 if (!p) 789 if (!p)
761 return -EIO; 790 return -EIO;
762 p = pnpbios_parse_resource_option_data(p,end,dev); 791 p = pnpbios_parse_resource_option_data(p, end, dev);
763 if (!p) 792 if (!p)
764 return -EIO; 793 return -EIO;
765 p = pnpbios_parse_compatible_ids(p,end,dev); 794 p = pnpbios_parse_compatible_ids(p, end, dev);
766 if (!p) 795 if (!p)
767 return -EIO; 796 return -EIO;
768 return 0; 797 return 0;
769} 798}
770 799
771int 800int pnpbios_read_resources_from_node(struct pnp_resource_table *res,
772pnpbios_read_resources_from_node(struct pnp_resource_table *res, 801 struct pnp_bios_node *node)
773 struct pnp_bios_node * node)
774{ 802{
775 unsigned char * p = (char *)node->data; 803 unsigned char *p = (char *)node->data;
776 unsigned char * end = (char *)(node->data + node->size); 804 unsigned char *end = (char *)(node->data + node->size);
777 p = pnpbios_parse_allocated_resource_data(p,end,res); 805
806 p = pnpbios_parse_allocated_resource_data(p, end, res);
778 if (!p) 807 if (!p)
779 return -EIO; 808 return -EIO;
780 return 0; 809 return 0;
781} 810}
782 811
783int 812int pnpbios_write_resources_to_node(struct pnp_resource_table *res,
784pnpbios_write_resources_to_node(struct pnp_resource_table *res, 813 struct pnp_bios_node *node)
785 struct pnp_bios_node * node)
786{ 814{
787 unsigned char * p = (char *)node->data; 815 unsigned char *p = (char *)node->data;
788 unsigned char * end = (char *)(node->data + node->size); 816 unsigned char *end = (char *)(node->data + node->size);
789 p = pnpbios_encode_allocated_resource_data(p,end,res); 817
818 p = pnpbios_encode_allocated_resource_data(p, end, res);
790 if (!p) 819 if (!p)
791 return -EIO; 820 return -EIO;
792 return 0; 821 return 0;
diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
index 7c3236690cc3..90755d4cdb9f 100644
--- a/drivers/pnp/quirks.c
+++ b/drivers/pnp/quirks.c
@@ -19,7 +19,6 @@
19#include <linux/io.h> 19#include <linux/io.h>
20#include "base.h" 20#include "base.h"
21 21
22
23static void quirk_awe32_resources(struct pnp_dev *dev) 22static void quirk_awe32_resources(struct pnp_dev *dev)
24{ 23{
25 struct pnp_port *port, *port2, *port3; 24 struct pnp_port *port, *port2, *port3;
@@ -31,7 +30,7 @@ static void quirk_awe32_resources(struct pnp_dev *dev)
31 * two extra ports (at offset 0x400 and 0x800 from the one given) by 30 * two extra ports (at offset 0x400 and 0x800 from the one given) by
32 * hand. 31 * hand.
33 */ 32 */
34 for ( ; res ; res = res->next ) { 33 for (; res; res = res->next) {
35 port2 = pnp_alloc(sizeof(struct pnp_port)); 34 port2 = pnp_alloc(sizeof(struct pnp_port));
36 if (!port2) 35 if (!port2)
37 return; 36 return;
@@ -58,18 +57,19 @@ static void quirk_cmi8330_resources(struct pnp_dev *dev)
58 struct pnp_option *res = dev->dependent; 57 struct pnp_option *res = dev->dependent;
59 unsigned long tmp; 58 unsigned long tmp;
60 59
61 for ( ; res ; res = res->next ) { 60 for (; res; res = res->next) {
62 61
63 struct pnp_irq *irq; 62 struct pnp_irq *irq;
64 struct pnp_dma *dma; 63 struct pnp_dma *dma;
65 64
66 for( irq = res->irq; irq; irq = irq->next ) { // Valid irqs are 5, 7, 10 65 for (irq = res->irq; irq; irq = irq->next) { // Valid irqs are 5, 7, 10
67 tmp = 0x04A0; 66 tmp = 0x04A0;
68 bitmap_copy(irq->map, &tmp, 16); // 0000 0100 1010 0000 67 bitmap_copy(irq->map, &tmp, 16); // 0000 0100 1010 0000
69 } 68 }
70 69
71 for( dma = res->dma; dma; dma = dma->next ) // Valid 8bit dma channels are 1,3 70 for (dma = res->dma; dma; dma = dma->next) // Valid 8bit dma channels are 1,3
72 if( ( dma->flags & IORESOURCE_DMA_TYPE_MASK ) == IORESOURCE_DMA_8BIT ) 71 if ((dma->flags & IORESOURCE_DMA_TYPE_MASK) ==
72 IORESOURCE_DMA_8BIT)
73 dma->map = 0x000A; 73 dma->map = 0x000A;
74 } 74 }
75 printk(KERN_INFO "pnp: CMI8330 quirk - fixing interrupts and dma\n"); 75 printk(KERN_INFO "pnp: CMI8330 quirk - fixing interrupts and dma\n");
@@ -79,7 +79,7 @@ static void quirk_sb16audio_resources(struct pnp_dev *dev)
79{ 79{
80 struct pnp_port *port; 80 struct pnp_port *port;
81 struct pnp_option *res = dev->dependent; 81 struct pnp_option *res = dev->dependent;
82 int changed = 0; 82 int changed = 0;
83 83
84 /* 84 /*
85 * The default range on the mpu port for these devices is 0x388-0x388. 85 * The default range on the mpu port for these devices is 0x388-0x388.
@@ -87,24 +87,24 @@ static void quirk_sb16audio_resources(struct pnp_dev *dev)
87 * auto-configured. 87 * auto-configured.
88 */ 88 */
89 89
90 for( ; res ; res = res->next ) { 90 for (; res; res = res->next) {
91 port = res->port; 91 port = res->port;
92 if(!port) 92 if (!port)
93 continue; 93 continue;
94 port = port->next; 94 port = port->next;
95 if(!port) 95 if (!port)
96 continue; 96 continue;
97 port = port->next; 97 port = port->next;
98 if(!port) 98 if (!port)
99 continue; 99 continue;
100 if(port->min != port->max) 100 if (port->min != port->max)
101 continue; 101 continue;
102 port->max += 0x70; 102 port->max += 0x70;
103 changed = 1; 103 changed = 1;
104 } 104 }
105 if(changed) 105 if (changed)
106 printk(KERN_INFO "pnp: SB audio device quirk - increasing port range\n"); 106 printk(KERN_INFO
107 return; 107 "pnp: SB audio device quirk - increasing port range\n");
108} 108}
109 109
110static int quirk_smc_fir_enabled(struct pnp_dev *dev) 110static int quirk_smc_fir_enabled(struct pnp_dev *dev)
@@ -124,7 +124,7 @@ static int quirk_smc_fir_enabled(struct pnp_dev *dev)
124 outb(bank, firbase + 7); 124 outb(bank, firbase + 7);
125 125
126 high = inb(firbase + 0); 126 high = inb(firbase + 0);
127 low = inb(firbase + 1); 127 low = inb(firbase + 1);
128 chip = inb(firbase + 2); 128 chip = inb(firbase + 2);
129 129
130 /* This corresponds to the check in smsc_ircc_present() */ 130 /* This corresponds to the check in smsc_ircc_present() */
@@ -153,8 +153,8 @@ static void quirk_smc_enable(struct pnp_dev *dev)
153 */ 153 */
154 dev_err(&dev->dev, "%s not responding at SIR 0x%lx, FIR 0x%lx; " 154 dev_err(&dev->dev, "%s not responding at SIR 0x%lx, FIR 0x%lx; "
155 "auto-configuring\n", dev->id->id, 155 "auto-configuring\n", dev->id->id,
156 (unsigned long) pnp_port_start(dev, 0), 156 (unsigned long)pnp_port_start(dev, 0),
157 (unsigned long) pnp_port_start(dev, 1)); 157 (unsigned long)pnp_port_start(dev, 1));
158 158
159 pnp_disable_dev(dev); 159 pnp_disable_dev(dev);
160 pnp_init_resource_table(&dev->res); 160 pnp_init_resource_table(&dev->res);
@@ -162,8 +162,8 @@ static void quirk_smc_enable(struct pnp_dev *dev)
162 pnp_activate_dev(dev); 162 pnp_activate_dev(dev);
163 if (quirk_smc_fir_enabled(dev)) { 163 if (quirk_smc_fir_enabled(dev)) {
164 dev_err(&dev->dev, "responds at SIR 0x%lx, FIR 0x%lx\n", 164 dev_err(&dev->dev, "responds at SIR 0x%lx, FIR 0x%lx\n",
165 (unsigned long) pnp_port_start(dev, 0), 165 (unsigned long)pnp_port_start(dev, 0),
166 (unsigned long) pnp_port_start(dev, 1)); 166 (unsigned long)pnp_port_start(dev, 1));
167 return; 167 return;
168 } 168 }
169 169
@@ -175,8 +175,8 @@ static void quirk_smc_enable(struct pnp_dev *dev)
175 */ 175 */
176 dev_err(&dev->dev, "not responding at SIR 0x%lx, FIR 0x%lx; " 176 dev_err(&dev->dev, "not responding at SIR 0x%lx, FIR 0x%lx; "
177 "swapping SIR/FIR and reconfiguring\n", 177 "swapping SIR/FIR and reconfiguring\n",
178 (unsigned long) pnp_port_start(dev, 0), 178 (unsigned long)pnp_port_start(dev, 0),
179 (unsigned long) pnp_port_start(dev, 1)); 179 (unsigned long)pnp_port_start(dev, 1));
180 180
181 /* 181 /*
182 * Clear IORESOURCE_AUTO so pnp_activate_dev() doesn't reassign 182 * Clear IORESOURCE_AUTO so pnp_activate_dev() doesn't reassign
@@ -200,8 +200,8 @@ static void quirk_smc_enable(struct pnp_dev *dev)
200 200
201 if (quirk_smc_fir_enabled(dev)) { 201 if (quirk_smc_fir_enabled(dev)) {
202 dev_err(&dev->dev, "responds at SIR 0x%lx, FIR 0x%lx\n", 202 dev_err(&dev->dev, "responds at SIR 0x%lx, FIR 0x%lx\n",
203 (unsigned long) pnp_port_start(dev, 0), 203 (unsigned long)pnp_port_start(dev, 0),
204 (unsigned long) pnp_port_start(dev, 1)); 204 (unsigned long)pnp_port_start(dev, 1));
205 return; 205 return;
206 } 206 }
207 207
@@ -209,7 +209,6 @@ static void quirk_smc_enable(struct pnp_dev *dev)
209 "email bjorn.helgaas@hp.com\n"); 209 "email bjorn.helgaas@hp.com\n");
210} 210}
211 211
212
213/* 212/*
214 * PnP Quirks 213 * PnP Quirks
215 * Cards or devices that need some tweaking due to incomplete resource info 214 * Cards or devices that need some tweaking due to incomplete resource info
@@ -217,21 +216,21 @@ static void quirk_smc_enable(struct pnp_dev *dev)
217 216
218static struct pnp_fixup pnp_fixups[] = { 217static struct pnp_fixup pnp_fixups[] = {
219 /* Soundblaster awe io port quirk */ 218 /* Soundblaster awe io port quirk */
220 { "CTL0021", quirk_awe32_resources }, 219 {"CTL0021", quirk_awe32_resources},
221 { "CTL0022", quirk_awe32_resources }, 220 {"CTL0022", quirk_awe32_resources},
222 { "CTL0023", quirk_awe32_resources }, 221 {"CTL0023", quirk_awe32_resources},
223 /* CMI 8330 interrupt and dma fix */ 222 /* CMI 8330 interrupt and dma fix */
224 { "@X@0001", quirk_cmi8330_resources }, 223 {"@X@0001", quirk_cmi8330_resources},
225 /* Soundblaster audio device io port range quirk */ 224 /* Soundblaster audio device io port range quirk */
226 { "CTL0001", quirk_sb16audio_resources }, 225 {"CTL0001", quirk_sb16audio_resources},
227 { "CTL0031", quirk_sb16audio_resources }, 226 {"CTL0031", quirk_sb16audio_resources},
228 { "CTL0041", quirk_sb16audio_resources }, 227 {"CTL0041", quirk_sb16audio_resources},
229 { "CTL0042", quirk_sb16audio_resources }, 228 {"CTL0042", quirk_sb16audio_resources},
230 { "CTL0043", quirk_sb16audio_resources }, 229 {"CTL0043", quirk_sb16audio_resources},
231 { "CTL0044", quirk_sb16audio_resources }, 230 {"CTL0044", quirk_sb16audio_resources},
232 { "CTL0045", quirk_sb16audio_resources }, 231 {"CTL0045", quirk_sb16audio_resources},
233 { "SMCf010", quirk_smc_enable }, 232 {"SMCf010", quirk_smc_enable},
234 { "" } 233 {""}
235}; 234};
236 235
237void pnp_fixup_device(struct pnp_dev *dev) 236void pnp_fixup_device(struct pnp_dev *dev)
@@ -239,9 +238,8 @@ void pnp_fixup_device(struct pnp_dev *dev)
239 int i = 0; 238 int i = 0;
240 239
241 while (*pnp_fixups[i].id) { 240 while (*pnp_fixups[i].id) {
242 if (compare_pnp_id(dev->id,pnp_fixups[i].id)) { 241 if (compare_pnp_id(dev->id, pnp_fixups[i].id)) {
243 pnp_dbg("Calling quirk for %s", 242 pnp_dbg("Calling quirk for %s", dev->dev.bus_id);
244 dev->dev.bus_id);
245 pnp_fixups[i].quirk_function(dev); 243 pnp_fixups[i].quirk_function(dev);
246 } 244 }
247 i++; 245 i++;
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index a685fbec4604..ea6ec14a0559 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -3,7 +3,6 @@
3 * 3 *
4 * based on isapnp.c resource management (c) Jaroslav Kysela <perex@suse.cz> 4 * based on isapnp.c resource management (c) Jaroslav Kysela <perex@suse.cz>
5 * Copyright 2003 Adam Belay <ambx1@neo.rr.com> 5 * Copyright 2003 Adam Belay <ambx1@neo.rr.com>
6 *
7 */ 6 */
8 7
9#include <linux/module.h> 8#include <linux/module.h>
@@ -20,21 +19,19 @@
20#include <linux/pnp.h> 19#include <linux/pnp.h>
21#include "base.h" 20#include "base.h"
22 21
23static int pnp_reserve_irq[16] = { [0 ... 15] = -1 }; /* reserve (don't use) some IRQ */ 22static int pnp_reserve_irq[16] = {[0 ... 15] = -1 }; /* reserve (don't use) some IRQ */
24static int pnp_reserve_dma[8] = { [0 ... 7] = -1 }; /* reserve (don't use) some DMA */ 23static int pnp_reserve_dma[8] = {[0 ... 7] = -1 }; /* reserve (don't use) some DMA */
25static int pnp_reserve_io[16] = { [0 ... 15] = -1 }; /* reserve (don't use) some I/O region */ 24static int pnp_reserve_io[16] = {[0 ... 15] = -1 }; /* reserve (don't use) some I/O region */
26static int pnp_reserve_mem[16] = { [0 ... 15] = -1 }; /* reserve (don't use) some memory region */ 25static int pnp_reserve_mem[16] = {[0 ... 15] = -1 }; /* reserve (don't use) some memory region */
27
28 26
29/* 27/*
30 * option registration 28 * option registration
31 */ 29 */
32 30
33static struct pnp_option * pnp_build_option(int priority) 31static struct pnp_option *pnp_build_option(int priority)
34{ 32{
35 struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option)); 33 struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option));
36 34
37 /* check if pnp_alloc ran out of memory */
38 if (!option) 35 if (!option)
39 return NULL; 36 return NULL;
40 37
@@ -46,9 +43,10 @@ static struct pnp_option * pnp_build_option(int priority)
46 return option; 43 return option;
47} 44}
48 45
49struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev) 46struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev)
50{ 47{
51 struct pnp_option *option; 48 struct pnp_option *option;
49
52 if (!dev) 50 if (!dev)
53 return NULL; 51 return NULL;
54 52
@@ -61,9 +59,11 @@ struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev)
61 return option; 59 return option;
62} 60}
63 61
64struct pnp_option * pnp_register_dependent_option(struct pnp_dev *dev, int priority) 62struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
63 int priority)
65{ 64{
66 struct pnp_option *option; 65 struct pnp_option *option;
66
67 if (!dev) 67 if (!dev)
68 return NULL; 68 return NULL;
69 69
@@ -82,6 +82,7 @@ struct pnp_option * pnp_register_dependent_option(struct pnp_dev *dev, int prior
82int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) 82int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data)
83{ 83{
84 struct pnp_irq *ptr; 84 struct pnp_irq *ptr;
85
85 if (!option) 86 if (!option)
86 return -EINVAL; 87 return -EINVAL;
87 if (!data) 88 if (!data)
@@ -110,6 +111,7 @@ int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data)
110int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) 111int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data)
111{ 112{
112 struct pnp_dma *ptr; 113 struct pnp_dma *ptr;
114
113 if (!option) 115 if (!option)
114 return -EINVAL; 116 return -EINVAL;
115 if (!data) 117 if (!data)
@@ -129,6 +131,7 @@ int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data)
129int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) 131int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data)
130{ 132{
131 struct pnp_port *ptr; 133 struct pnp_port *ptr;
134
132 if (!option) 135 if (!option)
133 return -EINVAL; 136 return -EINVAL;
134 if (!data) 137 if (!data)
@@ -148,6 +151,7 @@ int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data)
148int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data) 151int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data)
149{ 152{
150 struct pnp_mem *ptr; 153 struct pnp_mem *ptr;
154
151 if (!option) 155 if (!option)
152 return -EINVAL; 156 return -EINVAL;
153 if (!data) 157 if (!data)
@@ -222,7 +226,6 @@ void pnp_free_option(struct pnp_option *option)
222 } 226 }
223} 227}
224 228
225
226/* 229/*
227 * resource validity checking 230 * resource validity checking
228 */ 231 */
@@ -236,11 +239,12 @@ void pnp_free_option(struct pnp_option *option)
236#define cannot_compare(flags) \ 239#define cannot_compare(flags) \
237((flags) & (IORESOURCE_UNSET | IORESOURCE_DISABLED)) 240((flags) & (IORESOURCE_UNSET | IORESOURCE_DISABLED))
238 241
239int pnp_check_port(struct pnp_dev * dev, int idx) 242int pnp_check_port(struct pnp_dev *dev, int idx)
240{ 243{
241 int tmp; 244 int tmp;
242 struct pnp_dev *tdev; 245 struct pnp_dev *tdev;
243 resource_size_t *port, *end, *tport, *tend; 246 resource_size_t *port, *end, *tport, *tend;
247
244 port = &dev->res.port_resource[idx].start; 248 port = &dev->res.port_resource[idx].start;
245 end = &dev->res.port_resource[idx].end; 249 end = &dev->res.port_resource[idx].end;
246 250
@@ -250,8 +254,8 @@ int pnp_check_port(struct pnp_dev * dev, int idx)
250 254
251 /* check if the resource is already in use, skip if the 255 /* check if the resource is already in use, skip if the
252 * device is active because it itself may be in use */ 256 * device is active because it itself may be in use */
253 if(!dev->active) { 257 if (!dev->active) {
254 if (__check_region(&ioport_resource, *port, length(port,end))) 258 if (__check_region(&ioport_resource, *port, length(port, end)))
255 return 0; 259 return 0;
256 } 260 }
257 261
@@ -259,7 +263,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx)
259 for (tmp = 0; tmp < 8; tmp++) { 263 for (tmp = 0; tmp < 8; tmp++) {
260 int rport = pnp_reserve_io[tmp << 1]; 264 int rport = pnp_reserve_io[tmp << 1];
261 int rend = pnp_reserve_io[(tmp << 1) + 1] + rport - 1; 265 int rend = pnp_reserve_io[(tmp << 1) + 1] + rport - 1;
262 if (ranged_conflict(port,end,&rport,&rend)) 266 if (ranged_conflict(port, end, &rport, &rend))
263 return 0; 267 return 0;
264 } 268 }
265 269
@@ -268,7 +272,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx)
268 if (dev->res.port_resource[tmp].flags & IORESOURCE_IO) { 272 if (dev->res.port_resource[tmp].flags & IORESOURCE_IO) {
269 tport = &dev->res.port_resource[tmp].start; 273 tport = &dev->res.port_resource[tmp].start;
270 tend = &dev->res.port_resource[tmp].end; 274 tend = &dev->res.port_resource[tmp].end;
271 if (ranged_conflict(port,end,tport,tend)) 275 if (ranged_conflict(port, end, tport, tend))
272 return 0; 276 return 0;
273 } 277 }
274 } 278 }
@@ -279,11 +283,12 @@ int pnp_check_port(struct pnp_dev * dev, int idx)
279 continue; 283 continue;
280 for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) { 284 for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) {
281 if (tdev->res.port_resource[tmp].flags & IORESOURCE_IO) { 285 if (tdev->res.port_resource[tmp].flags & IORESOURCE_IO) {
282 if (cannot_compare(tdev->res.port_resource[tmp].flags)) 286 if (cannot_compare
287 (tdev->res.port_resource[tmp].flags))
283 continue; 288 continue;
284 tport = &tdev->res.port_resource[tmp].start; 289 tport = &tdev->res.port_resource[tmp].start;
285 tend = &tdev->res.port_resource[tmp].end; 290 tend = &tdev->res.port_resource[tmp].end;
286 if (ranged_conflict(port,end,tport,tend)) 291 if (ranged_conflict(port, end, tport, tend))
287 return 0; 292 return 0;
288 } 293 }
289 } 294 }
@@ -292,11 +297,12 @@ int pnp_check_port(struct pnp_dev * dev, int idx)
292 return 1; 297 return 1;
293} 298}
294 299
295int pnp_check_mem(struct pnp_dev * dev, int idx) 300int pnp_check_mem(struct pnp_dev *dev, int idx)
296{ 301{
297 int tmp; 302 int tmp;
298 struct pnp_dev *tdev; 303 struct pnp_dev *tdev;
299 resource_size_t *addr, *end, *taddr, *tend; 304 resource_size_t *addr, *end, *taddr, *tend;
305
300 addr = &dev->res.mem_resource[idx].start; 306 addr = &dev->res.mem_resource[idx].start;
301 end = &dev->res.mem_resource[idx].end; 307 end = &dev->res.mem_resource[idx].end;
302 308
@@ -306,8 +312,8 @@ int pnp_check_mem(struct pnp_dev * dev, int idx)
306 312
307 /* check if the resource is already in use, skip if the 313 /* check if the resource is already in use, skip if the
308 * device is active because it itself may be in use */ 314 * device is active because it itself may be in use */
309 if(!dev->active) { 315 if (!dev->active) {
310 if (check_mem_region(*addr, length(addr,end))) 316 if (check_mem_region(*addr, length(addr, end)))
311 return 0; 317 return 0;
312 } 318 }
313 319
@@ -315,7 +321,7 @@ int pnp_check_mem(struct pnp_dev * dev, int idx)
315 for (tmp = 0; tmp < 8; tmp++) { 321 for (tmp = 0; tmp < 8; tmp++) {
316 int raddr = pnp_reserve_mem[tmp << 1]; 322 int raddr = pnp_reserve_mem[tmp << 1];
317 int rend = pnp_reserve_mem[(tmp << 1) + 1] + raddr - 1; 323 int rend = pnp_reserve_mem[(tmp << 1) + 1] + raddr - 1;
318 if (ranged_conflict(addr,end,&raddr,&rend)) 324 if (ranged_conflict(addr, end, &raddr, &rend))
319 return 0; 325 return 0;
320 } 326 }
321 327
@@ -324,7 +330,7 @@ int pnp_check_mem(struct pnp_dev * dev, int idx)
324 if (dev->res.mem_resource[tmp].flags & IORESOURCE_MEM) { 330 if (dev->res.mem_resource[tmp].flags & IORESOURCE_MEM) {
325 taddr = &dev->res.mem_resource[tmp].start; 331 taddr = &dev->res.mem_resource[tmp].start;
326 tend = &dev->res.mem_resource[tmp].end; 332 tend = &dev->res.mem_resource[tmp].end;
327 if (ranged_conflict(addr,end,taddr,tend)) 333 if (ranged_conflict(addr, end, taddr, tend))
328 return 0; 334 return 0;
329 } 335 }
330 } 336 }
@@ -335,11 +341,12 @@ int pnp_check_mem(struct pnp_dev * dev, int idx)
335 continue; 341 continue;
336 for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) { 342 for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) {
337 if (tdev->res.mem_resource[tmp].flags & IORESOURCE_MEM) { 343 if (tdev->res.mem_resource[tmp].flags & IORESOURCE_MEM) {
338 if (cannot_compare(tdev->res.mem_resource[tmp].flags)) 344 if (cannot_compare
345 (tdev->res.mem_resource[tmp].flags))
339 continue; 346 continue;
340 taddr = &tdev->res.mem_resource[tmp].start; 347 taddr = &tdev->res.mem_resource[tmp].start;
341 tend = &tdev->res.mem_resource[tmp].end; 348 tend = &tdev->res.mem_resource[tmp].end;
342 if (ranged_conflict(addr,end,taddr,tend)) 349 if (ranged_conflict(addr, end, taddr, tend))
343 return 0; 350 return 0;
344 } 351 }
345 } 352 }
@@ -353,11 +360,11 @@ static irqreturn_t pnp_test_handler(int irq, void *dev_id)
353 return IRQ_HANDLED; 360 return IRQ_HANDLED;
354} 361}
355 362
356int pnp_check_irq(struct pnp_dev * dev, int idx) 363int pnp_check_irq(struct pnp_dev *dev, int idx)
357{ 364{
358 int tmp; 365 int tmp;
359 struct pnp_dev *tdev; 366 struct pnp_dev *tdev;
360 resource_size_t * irq = &dev->res.irq_resource[idx].start; 367 resource_size_t *irq = &dev->res.irq_resource[idx].start;
361 368
362 /* if the resource doesn't exist, don't complain about it */ 369 /* if the resource doesn't exist, don't complain about it */
363 if (cannot_compare(dev->res.irq_resource[idx].flags)) 370 if (cannot_compare(dev->res.irq_resource[idx].flags))
@@ -394,9 +401,9 @@ int pnp_check_irq(struct pnp_dev * dev, int idx)
394 401
395 /* check if the resource is already in use, skip if the 402 /* check if the resource is already in use, skip if the
396 * device is active because it itself may be in use */ 403 * device is active because it itself may be in use */
397 if(!dev->active) { 404 if (!dev->active) {
398 if (request_irq(*irq, pnp_test_handler, 405 if (request_irq(*irq, pnp_test_handler,
399 IRQF_DISABLED|IRQF_PROBE_SHARED, "pnp", NULL)) 406 IRQF_DISABLED | IRQF_PROBE_SHARED, "pnp", NULL))
400 return 0; 407 return 0;
401 free_irq(*irq, NULL); 408 free_irq(*irq, NULL);
402 } 409 }
@@ -407,7 +414,8 @@ int pnp_check_irq(struct pnp_dev * dev, int idx)
407 continue; 414 continue;
408 for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) { 415 for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) {
409 if (tdev->res.irq_resource[tmp].flags & IORESOURCE_IRQ) { 416 if (tdev->res.irq_resource[tmp].flags & IORESOURCE_IRQ) {
410 if (cannot_compare(tdev->res.irq_resource[tmp].flags)) 417 if (cannot_compare
418 (tdev->res.irq_resource[tmp].flags))
411 continue; 419 continue;
412 if ((tdev->res.irq_resource[tmp].start == *irq)) 420 if ((tdev->res.irq_resource[tmp].start == *irq))
413 return 0; 421 return 0;
@@ -418,12 +426,12 @@ int pnp_check_irq(struct pnp_dev * dev, int idx)
418 return 1; 426 return 1;
419} 427}
420 428
421int pnp_check_dma(struct pnp_dev * dev, int idx) 429int pnp_check_dma(struct pnp_dev *dev, int idx)
422{ 430{
423#ifndef CONFIG_IA64 431#ifndef CONFIG_IA64
424 int tmp; 432 int tmp;
425 struct pnp_dev *tdev; 433 struct pnp_dev *tdev;
426 resource_size_t * dma = &dev->res.dma_resource[idx].start; 434 resource_size_t *dma = &dev->res.dma_resource[idx].start;
427 435
428 /* if the resource doesn't exist, don't complain about it */ 436 /* if the resource doesn't exist, don't complain about it */
429 if (cannot_compare(dev->res.dma_resource[idx].flags)) 437 if (cannot_compare(dev->res.dma_resource[idx].flags))
@@ -449,7 +457,7 @@ int pnp_check_dma(struct pnp_dev * dev, int idx)
449 457
450 /* check if the resource is already in use, skip if the 458 /* check if the resource is already in use, skip if the
451 * device is active because it itself may be in use */ 459 * device is active because it itself may be in use */
452 if(!dev->active) { 460 if (!dev->active) {
453 if (request_dma(*dma, "pnp")) 461 if (request_dma(*dma, "pnp"))
454 return 0; 462 return 0;
455 free_dma(*dma); 463 free_dma(*dma);
@@ -461,7 +469,8 @@ int pnp_check_dma(struct pnp_dev * dev, int idx)
461 continue; 469 continue;
462 for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) { 470 for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) {
463 if (tdev->res.dma_resource[tmp].flags & IORESOURCE_DMA) { 471 if (tdev->res.dma_resource[tmp].flags & IORESOURCE_DMA) {
464 if (cannot_compare(tdev->res.dma_resource[tmp].flags)) 472 if (cannot_compare
473 (tdev->res.dma_resource[tmp].flags))
465 continue; 474 continue;
466 if ((tdev->res.dma_resource[tmp].start == *dma)) 475 if ((tdev->res.dma_resource[tmp].start == *dma))
467 return 0; 476 return 0;
@@ -471,30 +480,18 @@ int pnp_check_dma(struct pnp_dev * dev, int idx)
471 480
472 return 1; 481 return 1;
473#else 482#else
474 /* IA64 hasn't legacy DMA */ 483 /* IA64 does not have legacy DMA */
475 return 0; 484 return 0;
476#endif 485#endif
477} 486}
478 487
479
480#if 0
481EXPORT_SYMBOL(pnp_register_dependent_option);
482EXPORT_SYMBOL(pnp_register_independent_option);
483EXPORT_SYMBOL(pnp_register_irq_resource);
484EXPORT_SYMBOL(pnp_register_dma_resource);
485EXPORT_SYMBOL(pnp_register_port_resource);
486EXPORT_SYMBOL(pnp_register_mem_resource);
487#endif /* 0 */
488
489
490/* format is: pnp_reserve_irq=irq1[,irq2] .... */ 488/* format is: pnp_reserve_irq=irq1[,irq2] .... */
491
492static int __init pnp_setup_reserve_irq(char *str) 489static int __init pnp_setup_reserve_irq(char *str)
493{ 490{
494 int i; 491 int i;
495 492
496 for (i = 0; i < 16; i++) 493 for (i = 0; i < 16; i++)
497 if (get_option(&str,&pnp_reserve_irq[i]) != 2) 494 if (get_option(&str, &pnp_reserve_irq[i]) != 2)
498 break; 495 break;
499 return 1; 496 return 1;
500} 497}
@@ -502,13 +499,12 @@ static int __init pnp_setup_reserve_irq(char *str)
502__setup("pnp_reserve_irq=", pnp_setup_reserve_irq); 499__setup("pnp_reserve_irq=", pnp_setup_reserve_irq);
503 500
504/* format is: pnp_reserve_dma=dma1[,dma2] .... */ 501/* format is: pnp_reserve_dma=dma1[,dma2] .... */
505
506static int __init pnp_setup_reserve_dma(char *str) 502static int __init pnp_setup_reserve_dma(char *str)
507{ 503{
508 int i; 504 int i;
509 505
510 for (i = 0; i < 8; i++) 506 for (i = 0; i < 8; i++)
511 if (get_option(&str,&pnp_reserve_dma[i]) != 2) 507 if (get_option(&str, &pnp_reserve_dma[i]) != 2)
512 break; 508 break;
513 return 1; 509 return 1;
514} 510}
@@ -516,13 +512,12 @@ static int __init pnp_setup_reserve_dma(char *str)
516__setup("pnp_reserve_dma=", pnp_setup_reserve_dma); 512__setup("pnp_reserve_dma=", pnp_setup_reserve_dma);
517 513
518/* format is: pnp_reserve_io=io1,size1[,io2,size2] .... */ 514/* format is: pnp_reserve_io=io1,size1[,io2,size2] .... */
519
520static int __init pnp_setup_reserve_io(char *str) 515static int __init pnp_setup_reserve_io(char *str)
521{ 516{
522 int i; 517 int i;
523 518
524 for (i = 0; i < 16; i++) 519 for (i = 0; i < 16; i++)
525 if (get_option(&str,&pnp_reserve_io[i]) != 2) 520 if (get_option(&str, &pnp_reserve_io[i]) != 2)
526 break; 521 break;
527 return 1; 522 return 1;
528} 523}
@@ -530,13 +525,12 @@ static int __init pnp_setup_reserve_io(char *str)
530__setup("pnp_reserve_io=", pnp_setup_reserve_io); 525__setup("pnp_reserve_io=", pnp_setup_reserve_io);
531 526
532/* format is: pnp_reserve_mem=mem1,size1[,mem2,size2] .... */ 527/* format is: pnp_reserve_mem=mem1,size1[,mem2,size2] .... */
533
534static int __init pnp_setup_reserve_mem(char *str) 528static int __init pnp_setup_reserve_mem(char *str)
535{ 529{
536 int i; 530 int i;
537 531
538 for (i = 0; i < 16; i++) 532 for (i = 0; i < 16; i++)
539 if (get_option(&str,&pnp_reserve_mem[i]) != 2) 533 if (get_option(&str, &pnp_reserve_mem[i]) != 2)
540 break; 534 break;
541 return 1; 535 return 1;
542} 536}
diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c
index 946a0dcd627d..13c608f5fb30 100644
--- a/drivers/pnp/support.c
+++ b/drivers/pnp/support.c
@@ -1,8 +1,7 @@
1/* 1/*
2 * support.c - provides standard pnp functions for the use of pnp protocol drivers, 2 * support.c - standard functions for the use of pnp protocol drivers
3 * 3 *
4 * Copyright 2003 Adam Belay <ambx1@neo.rr.com> 4 * Copyright 2003 Adam Belay <ambx1@neo.rr.com>
5 *
6 */ 5 */
7 6
8#include <linux/module.h> 7#include <linux/module.h>
@@ -11,22 +10,18 @@
11#include "base.h" 10#include "base.h"
12 11
13/** 12/**
14 * pnp_is_active - Determines if a device is active based on its current resources 13 * pnp_is_active - Determines if a device is active based on its current
14 * resources
15 * @dev: pointer to the desired PnP device 15 * @dev: pointer to the desired PnP device
16 *
17 */ 16 */
18 17int pnp_is_active(struct pnp_dev *dev)
19int pnp_is_active(struct pnp_dev * dev)
20{ 18{
21 if (!pnp_port_start(dev, 0) && pnp_port_len(dev, 0) <= 1 && 19 if (!pnp_port_start(dev, 0) && pnp_port_len(dev, 0) <= 1 &&
22 !pnp_mem_start(dev, 0) && pnp_mem_len(dev, 0) <= 1 && 20 !pnp_mem_start(dev, 0) && pnp_mem_len(dev, 0) <= 1 &&
23 pnp_irq(dev, 0) == -1 && 21 pnp_irq(dev, 0) == -1 && pnp_dma(dev, 0) == -1)
24 pnp_dma(dev, 0) == -1) 22 return 0;
25 return 0;
26 else 23 else
27 return 1; 24 return 1;
28} 25}
29 26
30
31
32EXPORT_SYMBOL(pnp_is_active); 27EXPORT_SYMBOL(pnp_is_active);
diff --git a/drivers/pnp/system.c b/drivers/pnp/system.c
index a8a95540b1ef..a06f980b3ac9 100644
--- a/drivers/pnp/system.c
+++ b/drivers/pnp/system.c
@@ -16,13 +16,14 @@
16 16
17static const struct pnp_device_id pnp_dev_table[] = { 17static const struct pnp_device_id pnp_dev_table[] = {
18 /* General ID for reserving resources */ 18 /* General ID for reserving resources */
19 { "PNP0c02", 0 }, 19 {"PNP0c02", 0},
20 /* memory controller */ 20 /* memory controller */
21 { "PNP0c01", 0 }, 21 {"PNP0c01", 0},
22 { "", 0 } 22 {"", 0}
23}; 23};
24 24
25static void reserve_range(const char *pnpid, resource_size_t start, resource_size_t end, int port) 25static void reserve_range(const char *pnpid, resource_size_t start,
26 resource_size_t end, int port)
26{ 27{
27 struct resource *res; 28 struct resource *res;
28 char *regionid; 29 char *regionid;
@@ -32,9 +33,9 @@ static void reserve_range(const char *pnpid, resource_size_t start, resource_siz
32 return; 33 return;
33 snprintf(regionid, 16, "pnp %s", pnpid); 34 snprintf(regionid, 16, "pnp %s", pnpid);
34 if (port) 35 if (port)
35 res = request_region(start, end-start+1, regionid); 36 res = request_region(start, end - start + 1, regionid);
36 else 37 else
37 res = request_mem_region(start, end-start+1, regionid); 38 res = request_mem_region(start, end - start + 1, regionid);
38 if (res == NULL) 39 if (res == NULL)
39 kfree(regionid); 40 kfree(regionid);
40 else 41 else
@@ -44,11 +45,10 @@ static void reserve_range(const char *pnpid, resource_size_t start, resource_siz
44 * example do reserve stuff they know about too, so we may well 45 * example do reserve stuff they know about too, so we may well
45 * have double reservations. 46 * have double reservations.
46 */ 47 */
47 printk(KERN_INFO 48 printk(KERN_INFO "pnp: %s: %s range 0x%llx-0x%llx %s reserved\n",
48 "pnp: %s: %s range 0x%llx-0x%llx %s reserved\n", 49 pnpid, port ? "ioport" : "iomem",
49 pnpid, port ? "ioport" : "iomem", 50 (unsigned long long)start, (unsigned long long)end,
50 (unsigned long long)start, (unsigned long long)end, 51 NULL != res ? "has been" : "could not be");
51 NULL != res ? "has been" : "could not be");
52} 52}
53 53
54static void reserve_resources_of_dev(const struct pnp_dev *dev) 54static void reserve_resources_of_dev(const struct pnp_dev *dev)
@@ -74,7 +74,7 @@ static void reserve_resources_of_dev(const struct pnp_dev *dev)
74 continue; /* invalid */ 74 continue; /* invalid */
75 75
76 reserve_range(dev->dev.bus_id, pnp_port_start(dev, i), 76 reserve_range(dev->dev.bus_id, pnp_port_start(dev, i),
77 pnp_port_end(dev, i), 1); 77 pnp_port_end(dev, i), 1);
78 } 78 }
79 79
80 for (i = 0; i < PNP_MAX_MEM; i++) { 80 for (i = 0; i < PNP_MAX_MEM; i++) {
@@ -82,24 +82,22 @@ static void reserve_resources_of_dev(const struct pnp_dev *dev)
82 continue; 82 continue;
83 83
84 reserve_range(dev->dev.bus_id, pnp_mem_start(dev, i), 84 reserve_range(dev->dev.bus_id, pnp_mem_start(dev, i),
85 pnp_mem_end(dev, i), 0); 85 pnp_mem_end(dev, i), 0);
86 } 86 }
87
88 return;
89} 87}
90 88
91static int system_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id) 89static int system_pnp_probe(struct pnp_dev *dev,
90 const struct pnp_device_id *dev_id)
92{ 91{
93 reserve_resources_of_dev(dev); 92 reserve_resources_of_dev(dev);
94 return 0; 93 return 0;
95} 94}
96 95
97static struct pnp_driver system_pnp_driver = { 96static struct pnp_driver system_pnp_driver = {
98 .name = "system", 97 .name = "system",
99 .id_table = pnp_dev_table, 98 .id_table = pnp_dev_table,
100 .flags = PNP_DRIVER_RES_DO_NOT_CHANGE, 99 .flags = PNP_DRIVER_RES_DO_NOT_CHANGE,
101 .probe = system_pnp_probe, 100 .probe = system_pnp_probe,
102 .remove = NULL,
103}; 101};
104 102
105static int __init pnp_system_init(void) 103static int __init pnp_system_init(void)
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 9d8d40d5c8f7..ff9e35cb308d 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -2,15 +2,13 @@
2# RTC class/drivers configuration 2# RTC class/drivers configuration
3# 3#
4 4
5menu "Real Time Clock"
6 depends on !S390
7
8config RTC_LIB 5config RTC_LIB
9 tristate 6 tristate
10 7
11config RTC_CLASS 8menuconfig RTC_CLASS
12 tristate "RTC class" 9 tristate "Real Time Clock"
13 default n 10 default n
11 depends on !S390
14 select RTC_LIB 12 select RTC_LIB
15 help 13 help
16 Generic RTC class support. If you say yes here, you will 14 Generic RTC class support. If you say yes here, you will
@@ -20,6 +18,8 @@ config RTC_CLASS
20 This driver can also be built as a module. If so, the module 18 This driver can also be built as a module. If so, the module
21 will be called rtc-class. 19 will be called rtc-class.
22 20
21if RTC_CLASS
22
23config RTC_HCTOSYS 23config RTC_HCTOSYS
24 bool "Set system time from RTC on startup and resume" 24 bool "Set system time from RTC on startup and resume"
25 depends on RTC_CLASS = y 25 depends on RTC_CLASS = y
@@ -58,11 +58,10 @@ config RTC_DEBUG
58 and individual RTC drivers. 58 and individual RTC drivers.
59 59
60comment "RTC interfaces" 60comment "RTC interfaces"
61 depends on RTC_CLASS
62 61
63config RTC_INTF_SYSFS 62config RTC_INTF_SYSFS
64 boolean "/sys/class/rtc/rtcN (sysfs)" 63 boolean "/sys/class/rtc/rtcN (sysfs)"
65 depends on RTC_CLASS && SYSFS 64 depends on SYSFS
66 default RTC_CLASS 65 default RTC_CLASS
67 help 66 help
68 Say yes here if you want to use your RTCs using sysfs interfaces, 67 Say yes here if you want to use your RTCs using sysfs interfaces,
@@ -73,7 +72,7 @@ config RTC_INTF_SYSFS
73 72
74config RTC_INTF_PROC 73config RTC_INTF_PROC
75 boolean "/proc/driver/rtc (procfs for rtc0)" 74 boolean "/proc/driver/rtc (procfs for rtc0)"
76 depends on RTC_CLASS && PROC_FS 75 depends on PROC_FS
77 default RTC_CLASS 76 default RTC_CLASS
78 help 77 help
79 Say yes here if you want to use your first RTC through the proc 78 Say yes here if you want to use your first RTC through the proc
@@ -85,7 +84,6 @@ config RTC_INTF_PROC
85 84
86config RTC_INTF_DEV 85config RTC_INTF_DEV
87 boolean "/dev/rtcN (character devices)" 86 boolean "/dev/rtcN (character devices)"
88 depends on RTC_CLASS
89 default RTC_CLASS 87 default RTC_CLASS
90 help 88 help
91 Say yes here if you want to use your RTCs using the /dev 89 Say yes here if you want to use your RTCs using the /dev
@@ -107,7 +105,6 @@ config RTC_INTF_DEV_UIE_EMUL
107 105
108config RTC_DRV_TEST 106config RTC_DRV_TEST
109 tristate "Test driver/device" 107 tristate "Test driver/device"
110 depends on RTC_CLASS
111 help 108 help
112 If you say yes here you get support for the 109 If you say yes here you get support for the
113 RTC test driver. It's a software RTC which can be 110 RTC test driver. It's a software RTC which can be
@@ -121,11 +118,12 @@ config RTC_DRV_TEST
121 will be called rtc-test. 118 will be called rtc-test.
122 119
123comment "I2C RTC drivers" 120comment "I2C RTC drivers"
124 depends on RTC_CLASS && I2C 121 depends on I2C
122
123if I2C
125 124
126config RTC_DRV_DS1307 125config RTC_DRV_DS1307
127 tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00" 126 tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00"
128 depends on RTC_CLASS && I2C
129 help 127 help
130 If you say yes here you get support for various compatible RTC 128 If you say yes here you get support for various compatible RTC
131 chips (often with battery backup) connected with I2C. This driver 129 chips (often with battery backup) connected with I2C. This driver
@@ -143,7 +141,6 @@ config RTC_DRV_DS1307
143 141
144config RTC_DRV_DS1672 142config RTC_DRV_DS1672
145 tristate "Dallas/Maxim DS1672" 143 tristate "Dallas/Maxim DS1672"
146 depends on RTC_CLASS && I2C
147 help 144 help
148 If you say yes here you get support for the 145 If you say yes here you get support for the
149 Dallas/Maxim DS1672 timekeeping chip. 146 Dallas/Maxim DS1672 timekeeping chip.
@@ -153,7 +150,6 @@ config RTC_DRV_DS1672
153 150
154config RTC_DRV_MAX6900 151config RTC_DRV_MAX6900
155 tristate "Maxim 6900" 152 tristate "Maxim 6900"
156 depends on RTC_CLASS && I2C
157 help 153 help
158 If you say yes here you will get support for the 154 If you say yes here you will get support for the
159 Maxim MAX6900 I2C RTC chip. 155 Maxim MAX6900 I2C RTC chip.
@@ -163,7 +159,6 @@ config RTC_DRV_MAX6900
163 159
164config RTC_DRV_RS5C372 160config RTC_DRV_RS5C372
165 tristate "Ricoh RS5C372A/B, RV5C386, RV5C387A" 161 tristate "Ricoh RS5C372A/B, RV5C386, RV5C387A"
166 depends on RTC_CLASS && I2C
167 help 162 help
168 If you say yes here you get support for the 163 If you say yes here you get support for the
169 Ricoh RS5C372A, RS5C372B, RV5C386, and RV5C387A RTC chips. 164 Ricoh RS5C372A, RS5C372B, RV5C386, and RV5C387A RTC chips.
@@ -173,7 +168,6 @@ config RTC_DRV_RS5C372
173 168
174config RTC_DRV_ISL1208 169config RTC_DRV_ISL1208
175 tristate "Intersil 1208" 170 tristate "Intersil 1208"
176 depends on RTC_CLASS && I2C
177 help 171 help
178 If you say yes here you get support for the 172 If you say yes here you get support for the
179 Intersil 1208 RTC chip. 173 Intersil 1208 RTC chip.
@@ -183,7 +177,6 @@ config RTC_DRV_ISL1208
183 177
184config RTC_DRV_X1205 178config RTC_DRV_X1205
185 tristate "Xicor/Intersil X1205" 179 tristate "Xicor/Intersil X1205"
186 depends on RTC_CLASS && I2C
187 help 180 help
188 If you say yes here you get support for the 181 If you say yes here you get support for the
189 Xicor/Intersil X1205 RTC chip. 182 Xicor/Intersil X1205 RTC chip.
@@ -193,7 +186,6 @@ config RTC_DRV_X1205
193 186
194config RTC_DRV_PCF8563 187config RTC_DRV_PCF8563
195 tristate "Philips PCF8563/Epson RTC8564" 188 tristate "Philips PCF8563/Epson RTC8564"
196 depends on RTC_CLASS && I2C
197 help 189 help
198 If you say yes here you get support for the 190 If you say yes here you get support for the
199 Philips PCF8563 RTC chip. The Epson RTC8564 191 Philips PCF8563 RTC chip. The Epson RTC8564
@@ -204,7 +196,6 @@ config RTC_DRV_PCF8563
204 196
205config RTC_DRV_PCF8583 197config RTC_DRV_PCF8583
206 tristate "Philips PCF8583" 198 tristate "Philips PCF8583"
207 depends on RTC_CLASS && I2C
208 help 199 help
209 If you say yes here you get support for the Philips PCF8583 200 If you say yes here you get support for the Philips PCF8583
210 RTC chip found on Acorn RiscPCs. This driver supports the 201 RTC chip found on Acorn RiscPCs. This driver supports the
@@ -217,7 +208,6 @@ config RTC_DRV_PCF8583
217 208
218config RTC_DRV_M41T80 209config RTC_DRV_M41T80
219 tristate "ST M41T80 series RTC" 210 tristate "ST M41T80 series RTC"
220 depends on RTC_CLASS && I2C
221 help 211 help
222 If you say Y here you will get support for the 212 If you say Y here you will get support for the
223 ST M41T80 RTC chips series. Currently following chips are 213 ST M41T80 RTC chips series. Currently following chips are
@@ -236,19 +226,21 @@ config RTC_DRV_M41T80_WDT
236 226
237config RTC_DRV_TWL92330 227config RTC_DRV_TWL92330
238 boolean "TI TWL92330/Menelaus" 228 boolean "TI TWL92330/Menelaus"
239 depends on RTC_CLASS && I2C && MENELAUS 229 depends on MENELAUS
240 help 230 help
241 If you say yes here you get support for the RTC on the 231 If you say yes here you get support for the RTC on the
242 TWL92330 "Menelaus" power mangement chip, used with OMAP2 232 TWL92330 "Menelaus" power mangement chip, used with OMAP2
243 platforms. The support is integrated with the rest of 233 platforms. The support is integrated with the rest of
244 the Menelaus driver; it's not separate module. 234 the Menelaus driver; it's not separate module.
245 235
236endif # I2C
237
246comment "SPI RTC drivers" 238comment "SPI RTC drivers"
247 depends on RTC_CLASS && SPI_MASTER 239
240if SPI_MASTER
248 241
249config RTC_DRV_RS5C348 242config RTC_DRV_RS5C348
250 tristate "Ricoh RS5C348A/B" 243 tristate "Ricoh RS5C348A/B"
251 depends on RTC_CLASS && SPI_MASTER
252 help 244 help
253 If you say yes here you get support for the 245 If you say yes here you get support for the
254 Ricoh RS5C348A and RS5C348B RTC chips. 246 Ricoh RS5C348A and RS5C348B RTC chips.
@@ -258,7 +250,6 @@ config RTC_DRV_RS5C348
258 250
259config RTC_DRV_MAX6902 251config RTC_DRV_MAX6902
260 tristate "Maxim 6902" 252 tristate "Maxim 6902"
261 depends on RTC_CLASS && SPI_MASTER
262 help 253 help
263 If you say yes here you will get support for the 254 If you say yes here you will get support for the
264 Maxim MAX6902 SPI RTC chip. 255 Maxim MAX6902 SPI RTC chip.
@@ -266,8 +257,9 @@ config RTC_DRV_MAX6902
266 This driver can also be built as a module. If so, the module 257 This driver can also be built as a module. If so, the module
267 will be called rtc-max6902. 258 will be called rtc-max6902.
268 259
260endif # SPI_MASTER
261
269comment "Platform RTC drivers" 262comment "Platform RTC drivers"
270 depends on RTC_CLASS
271 263
272# this 'CMOS' RTC driver is arch dependent because <asm-generic/rtc.h> 264# this 'CMOS' RTC driver is arch dependent because <asm-generic/rtc.h>
273# requires <asm/mc146818rtc.h> defining CMOS_READ/CMOS_WRITE, and a 265# requires <asm/mc146818rtc.h> defining CMOS_READ/CMOS_WRITE, and a
@@ -275,8 +267,7 @@ comment "Platform RTC drivers"
275 267
276config RTC_DRV_CMOS 268config RTC_DRV_CMOS
277 tristate "PC-style 'CMOS'" 269 tristate "PC-style 'CMOS'"
278 depends on RTC_CLASS && (X86 || ALPHA || ARM26 || ARM \ 270 depends on X86 || ALPHA || ARM || M32R || ATARI || PPC || MIPS
279 || M32R || ATARI || PPC || MIPS)
280 help 271 help
281 Say "yes" here to get direct support for the real time clock 272 Say "yes" here to get direct support for the real time clock
282 found in every PC or ACPI-based system, and some other boards. 273 found in every PC or ACPI-based system, and some other boards.
@@ -294,13 +285,12 @@ config RTC_DRV_CMOS
294 285
295config RTC_DRV_DS1216 286config RTC_DRV_DS1216
296 tristate "Dallas DS1216" 287 tristate "Dallas DS1216"
297 depends on RTC_CLASS && SNI_RM 288 depends on SNI_RM
298 help 289 help
299 If you say yes here you get support for the Dallas DS1216 RTC chips. 290 If you say yes here you get support for the Dallas DS1216 RTC chips.
300 291
301config RTC_DRV_DS1553 292config RTC_DRV_DS1553
302 tristate "Dallas DS1553" 293 tristate "Dallas DS1553"
303 depends on RTC_CLASS
304 help 294 help
305 If you say yes here you get support for the 295 If you say yes here you get support for the
306 Dallas DS1553 timekeeping chip. 296 Dallas DS1553 timekeeping chip.
@@ -320,7 +310,6 @@ config RTC_DRV_STK17TA8
320 310
321config RTC_DRV_DS1742 311config RTC_DRV_DS1742
322 tristate "Dallas DS1742/1743" 312 tristate "Dallas DS1742/1743"
323 depends on RTC_CLASS
324 help 313 help
325 If you say yes here you get support for the 314 If you say yes here you get support for the
326 Dallas DS1742/1743 timekeeping chip. 315 Dallas DS1742/1743 timekeeping chip.
@@ -330,7 +319,6 @@ config RTC_DRV_DS1742
330 319
331config RTC_DRV_M48T86 320config RTC_DRV_M48T86
332 tristate "ST M48T86/Dallas DS12887" 321 tristate "ST M48T86/Dallas DS12887"
333 depends on RTC_CLASS
334 help 322 help
335 If you say Y here you will get support for the 323 If you say Y here you will get support for the
336 ST M48T86 and Dallas DS12887 RTC chips. 324 ST M48T86 and Dallas DS12887 RTC chips.
@@ -340,7 +328,6 @@ config RTC_DRV_M48T86
340 328
341config RTC_DRV_M48T59 329config RTC_DRV_M48T59
342 tristate "ST M48T59" 330 tristate "ST M48T59"
343 depends on RTC_CLASS
344 help 331 help
345 If you say Y here you will get support for the 332 If you say Y here you will get support for the
346 ST M48T59 RTC chip. 333 ST M48T59 RTC chip.
@@ -350,7 +337,6 @@ config RTC_DRV_M48T59
350 337
351config RTC_DRV_V3020 338config RTC_DRV_V3020
352 tristate "EM Microelectronic V3020" 339 tristate "EM Microelectronic V3020"
353 depends on RTC_CLASS
354 help 340 help
355 If you say yes here you will get support for the 341 If you say yes here you will get support for the
356 EM Microelectronic v3020 RTC chip. 342 EM Microelectronic v3020 RTC chip.
@@ -359,19 +345,17 @@ config RTC_DRV_V3020
359 will be called rtc-v3020. 345 will be called rtc-v3020.
360 346
361comment "on-CPU RTC drivers" 347comment "on-CPU RTC drivers"
362 depends on RTC_CLASS
363 348
364config RTC_DRV_OMAP 349config RTC_DRV_OMAP
365 tristate "TI OMAP1" 350 tristate "TI OMAP1"
366 depends on RTC_CLASS && ( \ 351 depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730
367 ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 )
368 help 352 help
369 Say "yes" here to support the real time clock on TI OMAP1 chips. 353 Say "yes" here to support the real time clock on TI OMAP1 chips.
370 This driver can also be built as a module called rtc-omap. 354 This driver can also be built as a module called rtc-omap.
371 355
372config RTC_DRV_S3C 356config RTC_DRV_S3C
373 tristate "Samsung S3C series SoC RTC" 357 tristate "Samsung S3C series SoC RTC"
374 depends on RTC_CLASS && ARCH_S3C2410 358 depends on ARCH_S3C2410
375 help 359 help
376 RTC (Realtime Clock) driver for the clock inbuilt into the 360 RTC (Realtime Clock) driver for the clock inbuilt into the
377 Samsung S3C24XX series of SoCs. This can provide periodic 361 Samsung S3C24XX series of SoCs. This can provide periodic
@@ -387,7 +371,7 @@ config RTC_DRV_S3C
387 371
388config RTC_DRV_EP93XX 372config RTC_DRV_EP93XX
389 tristate "Cirrus Logic EP93XX" 373 tristate "Cirrus Logic EP93XX"
390 depends on RTC_CLASS && ARCH_EP93XX 374 depends on ARCH_EP93XX
391 help 375 help
392 If you say yes here you get support for the 376 If you say yes here you get support for the
393 RTC embedded in the Cirrus Logic EP93XX processors. 377 RTC embedded in the Cirrus Logic EP93XX processors.
@@ -397,7 +381,7 @@ config RTC_DRV_EP93XX
397 381
398config RTC_DRV_SA1100 382config RTC_DRV_SA1100
399 tristate "SA11x0/PXA2xx" 383 tristate "SA11x0/PXA2xx"
400 depends on RTC_CLASS && (ARCH_SA1100 || ARCH_PXA) 384 depends on ARCH_SA1100 || ARCH_PXA
401 help 385 help
402 If you say Y here you will get access to the real time clock 386 If you say Y here you will get access to the real time clock
403 built into your SA11x0 or PXA2xx CPU. 387 built into your SA11x0 or PXA2xx CPU.
@@ -407,7 +391,7 @@ config RTC_DRV_SA1100
407 391
408config RTC_DRV_SH 392config RTC_DRV_SH
409 tristate "SuperH On-Chip RTC" 393 tristate "SuperH On-Chip RTC"
410 depends on RTC_CLASS && SUPERH && (CPU_SH3 || CPU_SH4) 394 depends on RTC_CLASS && (CPU_SH3 || CPU_SH4)
411 help 395 help
412 Say Y here to enable support for the on-chip RTC found in 396 Say Y here to enable support for the on-chip RTC found in
413 most SuperH processors. 397 most SuperH processors.
@@ -417,7 +401,7 @@ config RTC_DRV_SH
417 401
418config RTC_DRV_VR41XX 402config RTC_DRV_VR41XX
419 tristate "NEC VR41XX" 403 tristate "NEC VR41XX"
420 depends on RTC_CLASS && CPU_VR41XX 404 depends on CPU_VR41XX
421 help 405 help
422 If you say Y here you will get access to the real time clock 406 If you say Y here you will get access to the real time clock
423 built into your NEC VR41XX CPU. 407 built into your NEC VR41XX CPU.
@@ -427,7 +411,7 @@ config RTC_DRV_VR41XX
427 411
428config RTC_DRV_PL031 412config RTC_DRV_PL031
429 tristate "ARM AMBA PL031 RTC" 413 tristate "ARM AMBA PL031 RTC"
430 depends on RTC_CLASS && ARM_AMBA 414 depends on ARM_AMBA
431 help 415 help
432 If you say Y here you will get access to ARM AMBA 416 If you say Y here you will get access to ARM AMBA
433 PrimeCell PL031 RTC found on certain ARM SOCs. 417 PrimeCell PL031 RTC found on certain ARM SOCs.
@@ -437,20 +421,20 @@ config RTC_DRV_PL031
437 421
438config RTC_DRV_AT32AP700X 422config RTC_DRV_AT32AP700X
439 tristate "AT32AP700X series RTC" 423 tristate "AT32AP700X series RTC"
440 depends on RTC_CLASS && PLATFORM_AT32AP 424 depends on PLATFORM_AT32AP
441 help 425 help
442 Driver for the internal RTC (Realtime Clock) on Atmel AVR32 426 Driver for the internal RTC (Realtime Clock) on Atmel AVR32
443 AT32AP700x family processors. 427 AT32AP700x family processors.
444 428
445config RTC_DRV_AT91RM9200 429config RTC_DRV_AT91RM9200
446 tristate "AT91RM9200" 430 tristate "AT91RM9200"
447 depends on RTC_CLASS && ARCH_AT91RM9200 431 depends on ARCH_AT91RM9200
448 help 432 help
449 Driver for the Atmel AT91RM9200's internal RTC (Realtime Clock). 433 Driver for the Atmel AT91RM9200's internal RTC (Realtime Clock).
450 434
451config RTC_DRV_BFIN 435config RTC_DRV_BFIN
452 tristate "Blackfin On-Chip RTC" 436 tristate "Blackfin On-Chip RTC"
453 depends on RTC_CLASS && BFIN 437 depends on BFIN
454 help 438 help
455 If you say yes here you will get support for the 439 If you say yes here you will get support for the
456 Blackfin On-Chip Real Time Clock. 440 Blackfin On-Chip Real Time Clock.
@@ -460,8 +444,8 @@ config RTC_DRV_BFIN
460 444
461config RTC_DRV_RS5C313 445config RTC_DRV_RS5C313
462 tristate "Ricoh RS5C313" 446 tristate "Ricoh RS5C313"
463 depends on RTC_CLASS && SH_LANDISK 447 depends on SH_LANDISK
464 help 448 help
465 If you say yes here you get support for the Ricoh RS5C313 RTC chips. 449 If you say yes here you get support for the Ricoh RS5C313 RTC chips.
466 450
467endmenu 451endif # RTC_CLASS
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 7ede9e725360..d3a33aa2696f 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -15,34 +15,36 @@ rtc-core-$(CONFIG_RTC_INTF_DEV) += rtc-dev.o
15rtc-core-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o 15rtc-core-$(CONFIG_RTC_INTF_PROC) += rtc-proc.o
16rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o 16rtc-core-$(CONFIG_RTC_INTF_SYSFS) += rtc-sysfs.o
17 17
18# Keep the list ordered.
19
20obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o
21obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
22obj-$(CONFIG_RTC_DRV_BFIN) += rtc-bfin.o
18obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o 23obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o
19obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o 24obj-$(CONFIG_RTC_DRV_DS1216) += rtc-ds1216.o
20obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o
21obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o
22obj-$(CONFIG_RTC_DRV_AT32AP700X) += rtc-at32ap700x.o
23obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o 25obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o
26obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o
24obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o 27obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o
25obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o 28obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o
29obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o
30obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o
31obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o
32obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o
33obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o
34obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o
35obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o
26obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o 36obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
27obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o 37obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
28obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o 38obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
39obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o
40obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o
41obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
29obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o 42obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
30obj-$(CONFIG_RTC_DRV_S3C) += rtc-s3c.o 43obj-$(CONFIG_RTC_DRV_S3C) += rtc-s3c.o
31obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
32obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o
33obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o
34obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o
35obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o
36obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o
37obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o
38obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o 44obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o
39obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
40obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o
41obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o
42obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o
43obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
44obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
45obj-$(CONFIG_RTC_DRV_SH) += rtc-sh.o 45obj-$(CONFIG_RTC_DRV_SH) += rtc-sh.o
46obj-$(CONFIG_RTC_DRV_BFIN) += rtc-bfin.o 46obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o
47obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o 47obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o
48obj-$(CONFIG_RTC_DRV_DS1216) += rtc-ds1216.o 48obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
49obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
50obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
index 8b3cd31d6a61..10ab3b71ffc6 100644
--- a/drivers/rtc/class.c
+++ b/drivers/rtc/class.c
@@ -46,6 +46,7 @@ static int rtc_suspend(struct device *dev, pm_message_t mesg)
46{ 46{
47 struct rtc_device *rtc = to_rtc_device(dev); 47 struct rtc_device *rtc = to_rtc_device(dev);
48 struct rtc_time tm; 48 struct rtc_time tm;
49 struct timespec ts = current_kernel_time();
49 50
50 if (strncmp(rtc->dev.bus_id, 51 if (strncmp(rtc->dev.bus_id,
51 CONFIG_RTC_HCTOSYS_DEVICE, 52 CONFIG_RTC_HCTOSYS_DEVICE,
@@ -57,8 +58,8 @@ static int rtc_suspend(struct device *dev, pm_message_t mesg)
57 58
58 /* RTC precision is 1 second; adjust delta for avg 1/2 sec err */ 59 /* RTC precision is 1 second; adjust delta for avg 1/2 sec err */
59 set_normalized_timespec(&delta, 60 set_normalized_timespec(&delta,
60 xtime.tv_sec - oldtime, 61 ts.tv_sec - oldtime,
61 xtime.tv_nsec - (NSEC_PER_SEC >> 1)); 62 ts.tv_nsec - (NSEC_PER_SEC >> 1));
62 63
63 return 0; 64 return 0;
64} 65}
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c
index 260ead959918..1aa709dda0d6 100644
--- a/drivers/rtc/rtc-bfin.c
+++ b/drivers/rtc/rtc-bfin.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Blackfin On-Chip Real Time Clock Driver 2 * Blackfin On-Chip Real Time Clock Driver
3 * Supports BF531/BF532/BF533/BF534/BF536/BF537 3 * Supports BF53[123]/BF53[467]/BF54[2489]
4 * 4 *
5 * Copyright 2004-2007 Analog Devices Inc. 5 * Copyright 2004-2007 Analog Devices Inc.
6 * 6 *
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 304535942de2..005fff3a3508 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -348,6 +348,8 @@ static int rtc_dev_ioctl(struct inode *inode, struct file *file,
348 case RTC_IRQP_SET: 348 case RTC_IRQP_SET:
349 if (ops->irq_set_freq) 349 if (ops->irq_set_freq)
350 err = rtc_irq_set_freq(rtc, rtc->irq_task, arg); 350 err = rtc_irq_set_freq(rtc, rtc->irq_task, arg);
351 else
352 err = -ENOTTY;
351 break; 353 break;
352 354
353#if 0 355#if 0
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 5158a625671f..db6f3f0d8982 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -352,7 +352,7 @@ read_rtc:
352 /* oscillator fault? clear flag, and warn */ 352 /* oscillator fault? clear flag, and warn */
353 if (ds1307->regs[DS1307_REG_CONTROL] & DS1338_BIT_OSF) { 353 if (ds1307->regs[DS1307_REG_CONTROL] & DS1338_BIT_OSF) {
354 i2c_smbus_write_byte_data(client, DS1307_REG_CONTROL, 354 i2c_smbus_write_byte_data(client, DS1307_REG_CONTROL,
355 ds1307->regs[DS1337_REG_CONTROL] 355 ds1307->regs[DS1307_REG_CONTROL]
356 & ~DS1338_BIT_OSF); 356 & ~DS1338_BIT_OSF);
357 dev_warn(&client->dev, "SET TIME!\n"); 357 dev_warn(&client->dev, "SET TIME!\n");
358 goto read_rtc; 358 goto read_rtc;
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
index 33b752350ab5..bf60d35f580b 100644
--- a/drivers/rtc/rtc-m48t59.c
+++ b/drivers/rtc/rtc-m48t59.c
@@ -35,7 +35,7 @@
35struct m48t59_private { 35struct m48t59_private {
36 void __iomem *ioaddr; 36 void __iomem *ioaddr;
37 unsigned int size; /* iomem size */ 37 unsigned int size; /* iomem size */
38 unsigned int irq; 38 int irq;
39 struct rtc_device *rtc; 39 struct rtc_device *rtc;
40 spinlock_t lock; /* serialize the NVRAM and RTC access */ 40 spinlock_t lock; /* serialize the NVRAM and RTC access */
41}; 41};
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 54b613053468..8c1012b432bb 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -29,7 +29,7 @@
29 29
30#include <asm/mach/time.h> 30#include <asm/mach/time.h>
31 31
32#include <asm/arch/regs-rtc.h> 32#include <asm/plat-s3c/regs-rtc.h>
33 33
34/* I have yet to find an S3C implementation with more than one 34/* I have yet to find an S3C implementation with more than one
35 * of these rtc blocks in */ 35 * of these rtc blocks in */
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index e0f91dfce0f5..93ee05eeaeba 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -365,6 +365,7 @@ static int sh_rtc_set_time(struct device *dev, struct rtc_time *tm)
365 /* Reset pre-scaler & stop RTC */ 365 /* Reset pre-scaler & stop RTC */
366 tmp = readb(rtc->regbase + RCR2); 366 tmp = readb(rtc->regbase + RCR2);
367 tmp |= RCR2_RESET; 367 tmp |= RCR2_RESET;
368 tmp &= ~RCR2_START;
368 writeb(tmp, rtc->regbase + RCR2); 369 writeb(tmp, rtc->regbase + RCR2);
369 370
370 writeb(BIN2BCD(tm->tm_sec), rtc->regbase + RSECCNT); 371 writeb(BIN2BCD(tm->tm_sec), rtc->regbase + RSECCNT);
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index f10d3facecbe..8288b6b2bf2b 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -258,7 +258,8 @@ static const struct rtc_class_ops stk17ta8_rtc_ops = {
258 .ioctl = stk17ta8_rtc_ioctl, 258 .ioctl = stk17ta8_rtc_ioctl,
259}; 259};
260 260
261static ssize_t stk17ta8_nvram_read(struct kobject *kobj, char *buf, 261static ssize_t stk17ta8_nvram_read(struct kobject *kobj,
262 struct bin_attribute *attr, char *buf,
262 loff_t pos, size_t size) 263 loff_t pos, size_t size)
263{ 264{
264 struct platform_device *pdev = 265 struct platform_device *pdev =
@@ -272,7 +273,8 @@ static ssize_t stk17ta8_nvram_read(struct kobject *kobj, char *buf,
272 return count; 273 return count;
273} 274}
274 275
275static ssize_t stk17ta8_nvram_write(struct kobject *kobj, char *buf, 276static ssize_t stk17ta8_nvram_write(struct kobject *kobj,
277 struct bin_attribute *attr, char *buf,
276 loff_t pos, size_t size) 278 loff_t pos, size_t size)
277{ 279{
278 struct platform_device *pdev = 280 struct platform_device *pdev =
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index bfeca57098fa..e6bfce690ca3 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1187,7 +1187,7 @@ dasd_end_request_cb(struct dasd_ccw_req * cqr, void *data)
1187static void 1187static void
1188__dasd_process_blk_queue(struct dasd_device * device) 1188__dasd_process_blk_queue(struct dasd_device * device)
1189{ 1189{
1190 request_queue_t *queue; 1190 struct request_queue *queue;
1191 struct request *req; 1191 struct request *req;
1192 struct dasd_ccw_req *cqr; 1192 struct dasd_ccw_req *cqr;
1193 int nr_queued; 1193 int nr_queued;
@@ -1740,7 +1740,7 @@ dasd_cancel_req(struct dasd_ccw_req *cqr)
1740 * Dasd request queue function. Called from ll_rw_blk.c 1740 * Dasd request queue function. Called from ll_rw_blk.c
1741 */ 1741 */
1742static void 1742static void
1743do_dasd_request(request_queue_t * queue) 1743do_dasd_request(struct request_queue * queue)
1744{ 1744{
1745 struct dasd_device *device; 1745 struct dasd_device *device;
1746 1746
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 418b4e63a4fa..ea63ba7828f9 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -555,7 +555,7 @@ dasd_eckd_read_conf(struct dasd_device *device)
555 if (conf_data == NULL) { 555 if (conf_data == NULL) {
556 MESSAGE(KERN_WARNING, "%s", "No configuration " 556 MESSAGE(KERN_WARNING, "%s", "No configuration "
557 "data retrieved"); 557 "data retrieved");
558 continue; /* no errror */ 558 continue; /* no error */
559 } 559 }
560 if (conf_len != sizeof (struct dasd_eckd_confdata)) { 560 if (conf_len != sizeof (struct dasd_eckd_confdata)) {
561 MESSAGE(KERN_WARNING, 561 MESSAGE(KERN_WARNING,
@@ -564,7 +564,7 @@ dasd_eckd_read_conf(struct dasd_device *device)
564 conf_len, 564 conf_len,
565 sizeof (struct dasd_eckd_confdata)); 565 sizeof (struct dasd_eckd_confdata));
566 kfree(conf_data); 566 kfree(conf_data);
567 continue; /* no errror */ 567 continue; /* no error */
568 } 568 }
569 /* save first valid configuration data */ 569 /* save first valid configuration data */
570 if (!conf_data_saved){ 570 if (!conf_data_saved){
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 241294cba415..aeda52682446 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -293,7 +293,7 @@ struct dasd_uid {
293struct dasd_device { 293struct dasd_device {
294 /* Block device stuff. */ 294 /* Block device stuff. */
295 struct gendisk *gdp; 295 struct gendisk *gdp;
296 request_queue_t *request_queue; 296 struct request_queue *request_queue;
297 spinlock_t request_queue_lock; 297 spinlock_t request_queue_lock;
298 struct block_device *bdev; 298 struct block_device *bdev;
299 unsigned int devindex; 299 unsigned int devindex;
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index 35765f6a86e0..4d8798bacf97 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -621,7 +621,7 @@ out:
621} 621}
622 622
623static int 623static int
624dcssblk_make_request(request_queue_t *q, struct bio *bio) 624dcssblk_make_request(struct request_queue *q, struct bio *bio)
625{ 625{
626 struct dcssblk_dev_info *dev_info; 626 struct dcssblk_dev_info *dev_info;
627 struct bio_vec *bvec; 627 struct bio_vec *bvec;
diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c
index a04d9120cef0..354a060e5bec 100644
--- a/drivers/s390/block/xpram.c
+++ b/drivers/s390/block/xpram.c
@@ -191,7 +191,7 @@ static unsigned long __init xpram_highest_page_index(void)
191/* 191/*
192 * Block device make request function. 192 * Block device make request function.
193 */ 193 */
194static int xpram_make_request(request_queue_t *q, struct bio *bio) 194static int xpram_make_request(struct request_queue *q, struct bio *bio)
195{ 195{
196 xpram_device_t *xdev = bio->bi_bdev->bd_disk->private_data; 196 xpram_device_t *xdev = bio->bi_bdev->bd_disk->private_data;
197 struct bio_vec *bvec; 197 struct bio_vec *bvec;
diff --git a/drivers/s390/char/Kconfig b/drivers/s390/char/Kconfig
index 3f36cb3910ee..643033890e34 100644
--- a/drivers/s390/char/Kconfig
+++ b/drivers/s390/char/Kconfig
@@ -44,15 +44,9 @@ config CCW_CONSOLE
44 depends on TN3215_CONSOLE || TN3270_CONSOLE 44 depends on TN3215_CONSOLE || TN3270_CONSOLE
45 default y 45 default y
46 46
47config SCLP
48 bool "Support for SCLP"
49 depends on S390
50 help
51 Include support for the SCLP interface to the service element.
52
53config SCLP_TTY 47config SCLP_TTY
54 bool "Support for SCLP line mode terminal" 48 bool "Support for SCLP line mode terminal"
55 depends on SCLP 49 depends on S390
56 help 50 help
57 Include support for IBM SCLP line-mode terminals. 51 Include support for IBM SCLP line-mode terminals.
58 52
@@ -65,7 +59,7 @@ config SCLP_CONSOLE
65 59
66config SCLP_VT220_TTY 60config SCLP_VT220_TTY
67 bool "Support for SCLP VT220-compatible terminal" 61 bool "Support for SCLP VT220-compatible terminal"
68 depends on SCLP 62 depends on S390
69 help 63 help
70 Include support for an IBM SCLP VT220-compatible terminal. 64 Include support for an IBM SCLP VT220-compatible terminal.
71 65
@@ -78,7 +72,7 @@ config SCLP_VT220_CONSOLE
78 72
79config SCLP_CPI 73config SCLP_CPI
80 tristate "Control-Program Identification" 74 tristate "Control-Program Identification"
81 depends on SCLP 75 depends on S390
82 help 76 help
83 This option enables the hardware console interface for system 77 This option enables the hardware console interface for system
84 identification. This is commonly used for workload management and 78 identification. This is commonly used for workload management and
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 743944ad61ec..4f2f81b16cfa 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -147,8 +147,7 @@ raw3270_request_alloc(size_t size)
147 * Allocate a new 3270 ccw request from bootmem. Only works very 147 * Allocate a new 3270 ccw request from bootmem. Only works very
148 * early in the boot process. Only con3270.c should be using this. 148 * early in the boot process. Only con3270.c should be using this.
149 */ 149 */
150struct raw3270_request * 150struct raw3270_request __init *raw3270_request_alloc_bootmem(size_t size)
151raw3270_request_alloc_bootmem(size_t size)
152{ 151{
153 struct raw3270_request *rq; 152 struct raw3270_request *rq;
154 153
@@ -848,8 +847,7 @@ raw3270_setup_device(struct ccw_device *cdev, struct raw3270 *rp, char *ascebc)
848/* 847/*
849 * Setup 3270 device configured as console. 848 * Setup 3270 device configured as console.
850 */ 849 */
851struct raw3270 * 850struct raw3270 __init *raw3270_setup_console(struct ccw_device *cdev)
852raw3270_setup_console(struct ccw_device *cdev)
853{ 851{
854 struct raw3270 *rp; 852 struct raw3270 *rp;
855 char *ascebc; 853 char *ascebc;
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index 726334757bbf..40cd21bc5cc4 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -621,11 +621,24 @@ sclp_vt220_flush_buffer(struct tty_struct *tty)
621/* 621/*
622 * Initialize all relevant components and register driver with system. 622 * Initialize all relevant components and register driver with system.
623 */ 623 */
624static int 624static void __init __sclp_vt220_cleanup(void)
625__sclp_vt220_init(int early) 625{
626 struct list_head *page, *p;
627
628 list_for_each_safe(page, p, &sclp_vt220_empty) {
629 list_del(page);
630 if (slab_is_available())
631 free_page((unsigned long) page);
632 else
633 free_bootmem((unsigned long) page, PAGE_SIZE);
634 }
635}
636
637static int __init __sclp_vt220_init(void)
626{ 638{
627 void *page; 639 void *page;
628 int i; 640 int i;
641 int num_pages;
629 642
630 if (sclp_vt220_initialized) 643 if (sclp_vt220_initialized)
631 return 0; 644 return 0;
@@ -642,13 +655,16 @@ __sclp_vt220_init(int early)
642 sclp_vt220_flush_later = 0; 655 sclp_vt220_flush_later = 0;
643 656
644 /* Allocate pages for output buffering */ 657 /* Allocate pages for output buffering */
645 for (i = 0; i < (early ? MAX_CONSOLE_PAGES : MAX_KMEM_PAGES); i++) { 658 num_pages = slab_is_available() ? MAX_KMEM_PAGES : MAX_CONSOLE_PAGES;
646 if (early) 659 for (i = 0; i < num_pages; i++) {
647 page = alloc_bootmem_low_pages(PAGE_SIZE); 660 if (slab_is_available())
648 else
649 page = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA); 661 page = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA);
650 if (!page) 662 else
663 page = alloc_bootmem_low_pages(PAGE_SIZE);
664 if (!page) {
665 __sclp_vt220_cleanup();
651 return -ENOMEM; 666 return -ENOMEM;
667 }
652 list_add_tail((struct list_head *) page, &sclp_vt220_empty); 668 list_add_tail((struct list_head *) page, &sclp_vt220_empty);
653 } 669 }
654 return 0; 670 return 0;
@@ -662,14 +678,13 @@ static const struct tty_operations sclp_vt220_ops = {
662 .flush_chars = sclp_vt220_flush_chars, 678 .flush_chars = sclp_vt220_flush_chars,
663 .write_room = sclp_vt220_write_room, 679 .write_room = sclp_vt220_write_room,
664 .chars_in_buffer = sclp_vt220_chars_in_buffer, 680 .chars_in_buffer = sclp_vt220_chars_in_buffer,
665 .flush_buffer = sclp_vt220_flush_buffer 681 .flush_buffer = sclp_vt220_flush_buffer,
666}; 682};
667 683
668/* 684/*
669 * Register driver with SCLP and Linux and initialize internal tty structures. 685 * Register driver with SCLP and Linux and initialize internal tty structures.
670 */ 686 */
671static int __init 687static int __init sclp_vt220_tty_init(void)
672sclp_vt220_tty_init(void)
673{ 688{
674 struct tty_driver *driver; 689 struct tty_driver *driver;
675 int rc; 690 int rc;
@@ -679,18 +694,15 @@ sclp_vt220_tty_init(void)
679 driver = alloc_tty_driver(1); 694 driver = alloc_tty_driver(1);
680 if (!driver) 695 if (!driver)
681 return -ENOMEM; 696 return -ENOMEM;
682 rc = __sclp_vt220_init(0); 697 rc = __sclp_vt220_init();
683 if (rc) { 698 if (rc)
684 put_tty_driver(driver); 699 goto out_driver;
685 return rc;
686 }
687 rc = sclp_register(&sclp_vt220_register); 700 rc = sclp_register(&sclp_vt220_register);
688 if (rc) { 701 if (rc) {
689 printk(KERN_ERR SCLP_VT220_PRINT_HEADER 702 printk(KERN_ERR SCLP_VT220_PRINT_HEADER
690 "could not register tty - " 703 "could not register tty - "
691 "sclp_register returned %d\n", rc); 704 "sclp_register returned %d\n", rc);
692 put_tty_driver(driver); 705 goto out_init;
693 return rc;
694 } 706 }
695 707
696 driver->owner = THIS_MODULE; 708 driver->owner = THIS_MODULE;
@@ -709,14 +721,20 @@ sclp_vt220_tty_init(void)
709 printk(KERN_ERR SCLP_VT220_PRINT_HEADER 721 printk(KERN_ERR SCLP_VT220_PRINT_HEADER
710 "could not register tty - " 722 "could not register tty - "
711 "tty_register_driver returned %d\n", rc); 723 "tty_register_driver returned %d\n", rc);
712 put_tty_driver(driver); 724 goto out_sclp;
713 return rc;
714 } 725 }
715 sclp_vt220_driver = driver; 726 sclp_vt220_driver = driver;
716 return 0; 727 return 0;
717}
718 728
719module_init(sclp_vt220_tty_init); 729out_sclp:
730 sclp_unregister(&sclp_vt220_register);
731out_init:
732 __sclp_vt220_cleanup();
733out_driver:
734 put_tty_driver(driver);
735 return rc;
736}
737__initcall(sclp_vt220_tty_init);
720 738
721#ifdef CONFIG_SCLP_VT220_CONSOLE 739#ifdef CONFIG_SCLP_VT220_CONSOLE
722 740
@@ -762,7 +780,7 @@ sclp_vt220_con_init(void)
762 780
763 if (!CONSOLE_IS_SCLP) 781 if (!CONSOLE_IS_SCLP)
764 return 0; 782 return 0;
765 rc = __sclp_vt220_init(1); 783 rc = __sclp_vt220_init();
766 if (rc) 784 if (rc)
767 return rc; 785 return rc;
768 /* Attach linux console */ 786 /* Attach linux console */
diff --git a/drivers/s390/char/tape.h b/drivers/s390/char/tape.h
index 3b52f5c1dbef..dddf8d62c153 100644
--- a/drivers/s390/char/tape.h
+++ b/drivers/s390/char/tape.h
@@ -188,7 +188,7 @@ struct tape_blk_data
188{ 188{
189 struct tape_device * device; 189 struct tape_device * device;
190 /* Block device request queue. */ 190 /* Block device request queue. */
191 request_queue_t * request_queue; 191 struct request_queue * request_queue;
192 spinlock_t request_queue_lock; 192 spinlock_t request_queue_lock;
193 193
194 /* Task to move entries from block request to CCS request queue. */ 194 /* Task to move entries from block request to CCS request queue. */
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
index dd0ecaed592e..eeb92e2ed0cc 100644
--- a/drivers/s390/char/tape_block.c
+++ b/drivers/s390/char/tape_block.c
@@ -147,7 +147,7 @@ static void
147tapeblock_requeue(struct work_struct *work) { 147tapeblock_requeue(struct work_struct *work) {
148 struct tape_blk_data * blkdat; 148 struct tape_blk_data * blkdat;
149 struct tape_device * device; 149 struct tape_device * device;
150 request_queue_t * queue; 150 struct request_queue * queue;
151 int nr_queued; 151 int nr_queued;
152 struct request * req; 152 struct request * req;
153 struct list_head * l; 153 struct list_head * l;
@@ -194,7 +194,7 @@ tapeblock_requeue(struct work_struct *work) {
194 * Tape request queue function. Called from ll_rw_blk.c 194 * Tape request queue function. Called from ll_rw_blk.c
195 */ 195 */
196static void 196static void
197tapeblock_request_fn(request_queue_t *queue) 197tapeblock_request_fn(struct request_queue *queue)
198{ 198{
199 struct tape_device *device; 199 struct tape_device *device;
200 200
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index e90b0f846195..161867cebd8c 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -486,7 +486,7 @@ static ssize_t diag14_read(struct file *file, char __user *ubuf, size_t count,
486 } 486 }
487 if (rc) 487 if (rc)
488 goto fail; 488 goto fail;
489 if (reclen) 489 if (reclen && (copied == 0) && (*offs < PAGE_SIZE))
490 *((u16 *) &buf[FILE_RECLEN_OFFSET]) = reclen; 490 *((u16 *) &buf[FILE_RECLEN_OFFSET]) = reclen;
491 len = min(count - copied, PAGE_SIZE - res); 491 len = min(count - copied, PAGE_SIZE - res);
492 if (copy_to_user(ubuf + copied, buf + res, len)) { 492 if (copy_to_user(ubuf + copied, buf + res, len)) {
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index ec0404874fad..bd5f16f80bf8 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -51,7 +51,7 @@ blacklist_range (range_action action, unsigned int from, unsigned int to,
51 to = from; 51 to = from;
52 52
53 if (from > to || to > __MAX_SUBCHANNEL || ssid > __MAX_SSID) { 53 if (from > to || to > __MAX_SUBCHANNEL || ssid > __MAX_SSID) {
54 printk (KERN_WARNING "Invalid blacklist range " 54 printk (KERN_WARNING "cio: Invalid blacklist range "
55 "0.%x.%04x to 0.%x.%04x, skipping\n", 55 "0.%x.%04x to 0.%x.%04x, skipping\n",
56 ssid, from, ssid, to); 56 ssid, from, ssid, to);
57 return; 57 return;
@@ -119,7 +119,7 @@ blacklist_busid(char **str, int *id0, int *ssid, int *devno)
119 return 0; 119 return 0;
120confused: 120confused:
121 strsep(str, ",\n"); 121 strsep(str, ",\n");
122 printk(KERN_WARNING "Invalid cio_ignore parameter '%s'\n", sav); 122 printk(KERN_WARNING "cio: Invalid cio_ignore parameter '%s'\n", sav);
123 return 1; 123 return 1;
124} 124}
125 125
@@ -166,22 +166,19 @@ blacklist_parse_parameters (char *str, range_action action)
166 continue; 166 continue;
167 } 167 }
168 if (*str == '-') { 168 if (*str == '-') {
169 printk(KERN_WARNING "invalid cio_ignore " 169 printk(KERN_WARNING "cio: invalid cio_ignore "
170 "parameter '%s'\n", 170 "parameter '%s'\n",
171 strsep(&str, ",\n")); 171 strsep(&str, ",\n"));
172 continue; 172 continue;
173 } 173 }
174 if ((from_id0 != to_id0) || 174 if ((from_id0 != to_id0) ||
175 (from_ssid != to_ssid)) { 175 (from_ssid != to_ssid)) {
176 printk(KERN_WARNING "invalid cio_ignore range " 176 printk(KERN_WARNING "cio: invalid cio_ignore "
177 "%x.%x.%04x-%x.%x.%04x\n", 177 "range %x.%x.%04x-%x.%x.%04x\n",
178 from_id0, from_ssid, from, 178 from_id0, from_ssid, from,
179 to_id0, to_ssid, to); 179 to_id0, to_ssid, to);
180 continue; 180 continue;
181 } 181 }
182 pr_debug("blacklist_setup: adding range "
183 "from %x.%x.%04x to %x.%x.%04x\n",
184 from_id0, from_ssid, from, to_id0, to_ssid, to);
185 blacklist_range (ra, from, to, to_ssid); 182 blacklist_range (ra, from, to, to_ssid);
186 } 183 }
187 } 184 }
@@ -239,7 +236,7 @@ blacklist_parse_proc_parameters (char *buf)
239 */ 236 */
240 blacklist_parse_parameters (buf + 4, add); 237 blacklist_parse_parameters (buf + 4, add);
241 } else { 238 } else {
242 printk (KERN_WARNING "cio_ignore: Parse error; \n" 239 printk (KERN_WARNING "cio: cio_ignore: Parse error; \n"
243 KERN_WARNING "try using 'free all|<devno-range>," 240 KERN_WARNING "try using 'free all|<devno-range>,"
244 "<devno-range>,...'\n" 241 "<devno-range>,...'\n"
245 KERN_WARNING "or 'add <devno-range>," 242 KERN_WARNING "or 'add <devno-range>,"
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index e5ccda63e883..b0a18f5176aa 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -359,7 +359,6 @@ ccwgroup_probe (struct device *dev)
359 if ((ret = device_create_file(dev, &dev_attr_online))) 359 if ((ret = device_create_file(dev, &dev_attr_online)))
360 return ret; 360 return ret;
361 361
362 pr_debug("%s: device %s\n", __func__, gdev->dev.bus_id);
363 ret = gdrv->probe ? gdrv->probe(gdev) : -ENODEV; 362 ret = gdrv->probe ? gdrv->probe(gdev) : -ENODEV;
364 if (ret) 363 if (ret)
365 device_remove_file(dev, &dev_attr_online); 364 device_remove_file(dev, &dev_attr_online);
@@ -376,8 +375,6 @@ ccwgroup_remove (struct device *dev)
376 gdev = to_ccwgroupdev(dev); 375 gdev = to_ccwgroupdev(dev);
377 gdrv = to_ccwgroupdrv(dev->driver); 376 gdrv = to_ccwgroupdrv(dev->driver);
378 377
379 pr_debug("%s: device %s\n", __func__, gdev->dev.bus_id);
380
381 device_remove_file(dev, &dev_attr_online); 378 device_remove_file(dev, &dev_attr_online);
382 379
383 if (gdrv && gdrv->remove) 380 if (gdrv && gdrv->remove)
diff --git a/drivers/s390/cio/chp.c b/drivers/s390/cio/chp.c
index b57d93d986c0..920dd71e6434 100644
--- a/drivers/s390/cio/chp.c
+++ b/drivers/s390/cio/chp.c
@@ -121,14 +121,8 @@ static int s390_vary_chpid(struct chp_id chpid, int on)
121 CIO_TRACE_EVENT( 2, dbf_text); 121 CIO_TRACE_EVENT( 2, dbf_text);
122 122
123 status = chp_get_status(chpid); 123 status = chp_get_status(chpid);
124 if (status < 0) {
125 printk(KERN_ERR "Can't vary unknown chpid %x.%02x\n",
126 chpid.cssid, chpid.id);
127 return -EINVAL;
128 }
129
130 if (!on && !status) { 124 if (!on && !status) {
131 printk(KERN_ERR "chpid %x.%02x is already offline\n", 125 printk(KERN_ERR "cio: chpid %x.%02x is already offline\n",
132 chpid.cssid, chpid.id); 126 chpid.cssid, chpid.id);
133 return -EINVAL; 127 return -EINVAL;
134 } 128 }
@@ -421,21 +415,14 @@ int chp_new(struct chp_id chpid)
421 if (ret) 415 if (ret)
422 goto out_free; 416 goto out_free;
423 } else { 417 } else {
424 static int msg_done;
425
426 if (!msg_done) {
427 printk(KERN_WARNING "cio: Channel measurements not "
428 "available, continuing.\n");
429 msg_done = 1;
430 }
431 chp->cmg = -1; 418 chp->cmg = -1;
432 } 419 }
433 420
434 /* make it known to the system */ 421 /* make it known to the system */
435 ret = device_register(&chp->dev); 422 ret = device_register(&chp->dev);
436 if (ret) { 423 if (ret) {
437 printk(KERN_WARNING "%s: could not register %x.%02x\n", 424 CIO_MSG_EVENT(0, "Could not register chp%x.%02x: %d\n",
438 __func__, chpid.cssid, chpid.id); 425 chpid.cssid, chpid.id, ret);
439 goto out_free; 426 goto out_free;
440 } 427 }
441 ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group); 428 ret = sysfs_create_group(&chp->dev.kobj, &chp_attr_group);
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index ea92ac4d6577..597c0c76a2ad 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -990,16 +990,20 @@ out:
990 return ret; 990 return ret;
991} 991}
992 992
993static int __init 993int __init chsc_alloc_sei_area(void)
994chsc_alloc_sei_area(void)
995{ 994{
996 sei_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); 995 sei_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
997 if (!sei_page) 996 if (!sei_page)
998 printk(KERN_WARNING"Can't allocate page for processing of " \ 997 CIO_MSG_EVENT(0, "Can't allocate page for processing of "
999 "chsc machine checks!\n"); 998 "chsc machine checks!\n");
1000 return (sei_page ? 0 : -ENOMEM); 999 return (sei_page ? 0 : -ENOMEM);
1001} 1000}
1002 1001
1002void __init chsc_free_sei_area(void)
1003{
1004 kfree(sei_page);
1005}
1006
1003int __init 1007int __init
1004chsc_enable_facility(int operation_code) 1008chsc_enable_facility(int operation_code)
1005{ 1009{
@@ -1051,8 +1055,6 @@ chsc_enable_facility(int operation_code)
1051 return ret; 1055 return ret;
1052} 1056}
1053 1057
1054subsys_initcall(chsc_alloc_sei_area);
1055
1056struct css_general_char css_general_characteristics; 1058struct css_general_char css_general_characteristics;
1057struct css_chsc_char css_chsc_characteristics; 1059struct css_chsc_char css_chsc_characteristics;
1058 1060
@@ -1073,8 +1075,8 @@ chsc_determine_css_characteristics(void)
1073 1075
1074 scsc_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); 1076 scsc_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
1075 if (!scsc_area) { 1077 if (!scsc_area) {
1076 printk(KERN_WARNING"cio: Was not able to determine available" \ 1078 CIO_MSG_EVENT(0, "Was not able to determine available"
1077 "CHSCs due to no memory.\n"); 1079 "CHSCs due to no memory.\n");
1078 return -ENOMEM; 1080 return -ENOMEM;
1079 } 1081 }
1080 1082
@@ -1083,15 +1085,15 @@ chsc_determine_css_characteristics(void)
1083 1085
1084 result = chsc(scsc_area); 1086 result = chsc(scsc_area);
1085 if (result) { 1087 if (result) {
1086 printk(KERN_WARNING"cio: Was not able to determine " \ 1088 CIO_MSG_EVENT(0, "Was not able to determine available CHSCs, "
1087 "available CHSCs, cc=%i.\n", result); 1089 "cc=%i.\n", result);
1088 result = -EIO; 1090 result = -EIO;
1089 goto exit; 1091 goto exit;
1090 } 1092 }
1091 1093
1092 if (scsc_area->response.code != 1) { 1094 if (scsc_area->response.code != 1) {
1093 printk(KERN_WARNING"cio: Was not able to determine " \ 1095 CIO_MSG_EVENT(0, "Was not able to determine "
1094 "available CHSCs.\n"); 1096 "available CHSCs.\n");
1095 result = -EIO; 1097 result = -EIO;
1096 goto exit; 1098 goto exit;
1097 } 1099 }
diff --git a/drivers/s390/cio/chsc.h b/drivers/s390/cio/chsc.h
index 2ad81d11cf7b..d1f5db1e69b9 100644
--- a/drivers/s390/cio/chsc.h
+++ b/drivers/s390/cio/chsc.h
@@ -79,6 +79,8 @@ extern int chsc_get_ssd_info(struct subchannel_id schid,
79 struct chsc_ssd_info *ssd); 79 struct chsc_ssd_info *ssd);
80extern int chsc_determine_css_characteristics(void); 80extern int chsc_determine_css_characteristics(void);
81extern int css_characteristics_avail; 81extern int css_characteristics_avail;
82extern int chsc_alloc_sei_area(void);
83extern void chsc_free_sei_area(void);
82 84
83extern int chsc_enable_facility(int); 85extern int chsc_enable_facility(int);
84struct channel_subsystem; 86struct channel_subsystem;
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index ea1defba5693..f2708d65be5a 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -47,8 +47,8 @@ cio_setup (char *parm)
47 else if (!strcmp (parm, "no")) 47 else if (!strcmp (parm, "no"))
48 cio_show_msg = 0; 48 cio_show_msg = 0;
49 else 49 else
50 printk (KERN_ERR "cio_setup : invalid cio_msg parameter '%s'", 50 printk(KERN_ERR "cio: cio_setup: "
51 parm); 51 "invalid cio_msg parameter '%s'", parm);
52 return 1; 52 return 1;
53} 53}
54 54
@@ -80,7 +80,6 @@ cio_debug_init (void)
80 goto out_unregister; 80 goto out_unregister;
81 debug_register_view (cio_debug_crw_id, &debug_sprintf_view); 81 debug_register_view (cio_debug_crw_id, &debug_sprintf_view);
82 debug_set_level (cio_debug_crw_id, 2); 82 debug_set_level (cio_debug_crw_id, 2);
83 pr_debug("debugging initialized\n");
84 return 0; 83 return 0;
85 84
86out_unregister: 85out_unregister:
@@ -90,7 +89,7 @@ out_unregister:
90 debug_unregister (cio_debug_trace_id); 89 debug_unregister (cio_debug_trace_id);
91 if (cio_debug_crw_id) 90 if (cio_debug_crw_id)
92 debug_unregister (cio_debug_crw_id); 91 debug_unregister (cio_debug_crw_id);
93 pr_debug("could not initialize debugging\n"); 92 printk(KERN_WARNING"cio: could not initialize debugging\n");
94 return -1; 93 return -1;
95} 94}
96 95
@@ -568,7 +567,7 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
568 */ 567 */
569 if (sch->st != 0) { 568 if (sch->st != 0) {
570 CIO_DEBUG(KERN_INFO, 0, 569 CIO_DEBUG(KERN_INFO, 0,
571 "Subchannel 0.%x.%04x reports " 570 "cio: Subchannel 0.%x.%04x reports "
572 "non-I/O subchannel type %04X\n", 571 "non-I/O subchannel type %04X\n",
573 sch->schid.ssid, sch->schid.sch_no, sch->st); 572 sch->schid.ssid, sch->schid.sch_no, sch->st);
574 /* We stop here for non-io subchannels. */ 573 /* We stop here for non-io subchannels. */
@@ -601,7 +600,7 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
601 sch->lpm = sch->schib.pmcw.pam & sch->opm; 600 sch->lpm = sch->schib.pmcw.pam & sch->opm;
602 601
603 CIO_DEBUG(KERN_INFO, 0, 602 CIO_DEBUG(KERN_INFO, 0,
604 "Detected device %04x on subchannel 0.%x.%04X" 603 "cio: Detected device %04x on subchannel 0.%x.%04X"
605 " - PIM = %02X, PAM = %02X, POM = %02X\n", 604 " - PIM = %02X, PAM = %02X, POM = %02X\n",
606 sch->schib.pmcw.dev, sch->schid.ssid, 605 sch->schib.pmcw.dev, sch->schid.ssid,
607 sch->schid.sch_no, sch->schib.pmcw.pim, 606 sch->schid.sch_no, sch->schib.pmcw.pim,
@@ -766,7 +765,7 @@ cio_get_console_sch_no(void)
766 /* unlike in 2.4, we cannot autoprobe here, since 765 /* unlike in 2.4, we cannot autoprobe here, since
767 * the channel subsystem is not fully initialized. 766 * the channel subsystem is not fully initialized.
768 * With some luck, the HWC console can take over */ 767 * With some luck, the HWC console can take over */
769 printk(KERN_WARNING "No ccw console found!\n"); 768 printk(KERN_WARNING "cio: No ccw console found!\n");
770 return -1; 769 return -1;
771 } 770 }
772 return console_irq; 771 return console_irq;
diff --git a/drivers/s390/cio/cio_debug.h b/drivers/s390/cio/cio_debug.h
index f88844adae1b..c9bf8989930f 100644
--- a/drivers/s390/cio/cio_debug.h
+++ b/drivers/s390/cio/cio_debug.h
@@ -23,6 +23,8 @@ extern debug_info_t *cio_debug_crw_id;
23static inline void 23static inline void
24CIO_HEX_EVENT(int level, void *data, int length) 24CIO_HEX_EVENT(int level, void *data, int length)
25{ 25{
26 if (unlikely(!cio_debug_trace_id))
27 return;
26 while (length > 0) { 28 while (length > 0) {
27 debug_event(cio_debug_trace_id, level, data, length); 29 debug_event(cio_debug_trace_id, level, data, length);
28 length -= cio_debug_trace_id->buf_size; 30 length -= cio_debug_trace_id->buf_size;
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index 28abd697be1a..02fd00b55e1b 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -1185,12 +1185,12 @@ static ssize_t cmb_enable_store(struct device *dev, struct device_attribute *att
1185 case '0': 1185 case '0':
1186 ret = disable_cmf(cdev); 1186 ret = disable_cmf(cdev);
1187 if (ret) 1187 if (ret)
1188 printk(KERN_INFO "disable_cmf failed (%d)\n", ret); 1188 dev_info(&cdev->dev, "disable_cmf failed (%d)\n", ret);
1189 break; 1189 break;
1190 case '1': 1190 case '1':
1191 ret = enable_cmf(cdev); 1191 ret = enable_cmf(cdev);
1192 if (ret && ret != -EBUSY) 1192 if (ret && ret != -EBUSY)
1193 printk(KERN_INFO "enable_cmf failed (%d)\n", ret); 1193 dev_info(&cdev->dev, "enable_cmf failed (%d)\n", ret);
1194 break; 1194 break;
1195 } 1195 }
1196 1196
@@ -1280,10 +1280,10 @@ init_cmf(void)
1280 format_string = "basic"; 1280 format_string = "basic";
1281 cmbops = &cmbops_basic; 1281 cmbops = &cmbops_basic;
1282 if (cmb_area.num_channels > 4096 || cmb_area.num_channels < 1) { 1282 if (cmb_area.num_channels > 4096 || cmb_area.num_channels < 1) {
1283 printk(KERN_ERR "Basic channel measurement facility" 1283 printk(KERN_ERR "cio: Basic channel measurement "
1284 " can only use 1 to 4096 devices\n" 1284 "facility can only use 1 to 4096 devices\n"
1285 KERN_ERR "when the cmf driver is built" 1285 KERN_ERR "when the cmf driver is built"
1286 " as a loadable module\n"); 1286 " as a loadable module\n");
1287 return 1; 1287 return 1;
1288 } 1288 }
1289 break; 1289 break;
@@ -1292,13 +1292,13 @@ init_cmf(void)
1292 cmbops = &cmbops_extended; 1292 cmbops = &cmbops_extended;
1293 break; 1293 break;
1294 default: 1294 default:
1295 printk(KERN_ERR "Invalid format %d for channel " 1295 printk(KERN_ERR "cio: Invalid format %d for channel "
1296 "measurement facility\n", format); 1296 "measurement facility\n", format);
1297 return 1; 1297 return 1;
1298 } 1298 }
1299 1299
1300 printk(KERN_INFO "Channel measurement facility using %s format (%s)\n", 1300 printk(KERN_INFO "cio: Channel measurement facility using %s "
1301 format_string, detect_string); 1301 "format (%s)\n", format_string, detect_string);
1302 return 0; 1302 return 0;
1303} 1303}
1304 1304
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index dfca0ef139fd..1c27a5a06b49 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -109,7 +109,7 @@ css_subchannel_release(struct device *dev)
109 } 109 }
110} 110}
111 111
112int css_sch_device_register(struct subchannel *sch) 112static int css_sch_device_register(struct subchannel *sch)
113{ 113{
114 int ret; 114 int ret;
115 115
@@ -184,8 +184,8 @@ static int css_register_subchannel(struct subchannel *sch)
184 /* make it known to the system */ 184 /* make it known to the system */
185 ret = css_sch_device_register(sch); 185 ret = css_sch_device_register(sch);
186 if (ret) { 186 if (ret) {
187 printk (KERN_WARNING "%s: could not register %s\n", 187 CIO_MSG_EVENT(0, "Could not register sch 0.%x.%04x: %d\n",
188 __func__, sch->dev.bus_id); 188 sch->schid.ssid, sch->schid.sch_no, ret);
189 return ret; 189 return ret;
190 } 190 }
191 return ret; 191 return ret;
@@ -371,15 +371,12 @@ static int __init slow_subchannel_init(void)
371 spin_lock_init(&slow_subchannel_lock); 371 spin_lock_init(&slow_subchannel_lock);
372 slow_subchannel_set = idset_sch_new(); 372 slow_subchannel_set = idset_sch_new();
373 if (!slow_subchannel_set) { 373 if (!slow_subchannel_set) {
374 printk(KERN_WARNING "cio: could not allocate slow subchannel " 374 CIO_MSG_EVENT(0, "could not allocate slow subchannel set\n");
375 "set\n");
376 return -ENOMEM; 375 return -ENOMEM;
377 } 376 }
378 return 0; 377 return 0;
379} 378}
380 379
381subsys_initcall(slow_subchannel_init);
382
383static void css_slow_path_func(struct work_struct *unused) 380static void css_slow_path_func(struct work_struct *unused)
384{ 381{
385 struct subchannel_id schid; 382 struct subchannel_id schid;
@@ -425,8 +422,8 @@ static int reprobe_subchannel(struct subchannel_id schid, void *data)
425 struct subchannel *sch; 422 struct subchannel *sch;
426 int ret; 423 int ret;
427 424
428 CIO_DEBUG(KERN_INFO, 6, "cio: reprobe 0.%x.%04x\n", 425 CIO_MSG_EVENT(6, "cio: reprobe 0.%x.%04x\n",
429 schid.ssid, schid.sch_no); 426 schid.ssid, schid.sch_no);
430 if (need_reprobe) 427 if (need_reprobe)
431 return -EAGAIN; 428 return -EAGAIN;
432 429
@@ -642,9 +639,20 @@ init_channel_subsystem (void)
642{ 639{
643 int ret, i; 640 int ret, i;
644 641
645 if (chsc_determine_css_characteristics() == 0) 642 ret = chsc_determine_css_characteristics();
643 if (ret == -ENOMEM)
644 goto out; /* No need to continue. */
645 if (ret == 0)
646 css_characteristics_avail = 1; 646 css_characteristics_avail = 1;
647 647
648 ret = chsc_alloc_sei_area();
649 if (ret)
650 goto out;
651
652 ret = slow_subchannel_init();
653 if (ret)
654 goto out;
655
648 if ((ret = bus_register(&css_bus_type))) 656 if ((ret = bus_register(&css_bus_type)))
649 goto out; 657 goto out;
650 658
@@ -710,6 +718,10 @@ out_unregister:
710out_bus: 718out_bus:
711 bus_unregister(&css_bus_type); 719 bus_unregister(&css_bus_type);
712out: 720out:
721 chsc_free_sei_area();
722 kfree(slow_subchannel_set);
723 printk(KERN_WARNING"cio: failed to initialize css driver (%d)!\n",
724 ret);
713 return ret; 725 return ret;
714} 726}
715 727
diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h
index ed7977531c3f..5d65e83ca66e 100644
--- a/drivers/s390/cio/css.h
+++ b/drivers/s390/cio/css.h
@@ -139,7 +139,6 @@ struct css_driver {
139 */ 139 */
140extern struct bus_type css_bus_type; 140extern struct bus_type css_bus_type;
141 141
142extern int css_sch_device_register(struct subchannel *);
143extern void css_sch_device_unregister(struct subchannel *); 142extern void css_sch_device_unregister(struct subchannel *);
144extern struct subchannel * get_subchannel_by_schid(struct subchannel_id); 143extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
145extern int css_init_done; 144extern int css_init_done;
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 001682e70f67..297659fa0e26 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -338,15 +338,20 @@ ccw_device_remove_disconnected(struct ccw_device *cdev)
338 rc = device_schedule_callback(&cdev->dev, 338 rc = device_schedule_callback(&cdev->dev,
339 ccw_device_remove_orphan_cb); 339 ccw_device_remove_orphan_cb);
340 if (rc) 340 if (rc)
341 dev_info(&cdev->dev, "Couldn't unregister orphan\n"); 341 CIO_MSG_EVENT(2, "Couldn't unregister orphan "
342 "0.%x.%04x\n",
343 cdev->private->dev_id.ssid,
344 cdev->private->dev_id.devno);
342 return; 345 return;
343 } 346 }
344 /* Deregister subchannel, which will kill the ccw device. */ 347 /* Deregister subchannel, which will kill the ccw device. */
345 rc = device_schedule_callback(cdev->dev.parent, 348 rc = device_schedule_callback(cdev->dev.parent,
346 ccw_device_remove_sch_cb); 349 ccw_device_remove_sch_cb);
347 if (rc) 350 if (rc)
348 dev_info(&cdev->dev, 351 CIO_MSG_EVENT(2, "Couldn't unregister disconnected device "
349 "Couldn't unregister disconnected device\n"); 352 "0.%x.%04x\n",
353 cdev->private->dev_id.ssid,
354 cdev->private->dev_id.devno);
350} 355}
351 356
352int 357int
@@ -379,8 +384,10 @@ ccw_device_set_offline(struct ccw_device *cdev)
379 if (ret == 0) 384 if (ret == 0)
380 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev)); 385 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
381 else { 386 else {
382 pr_debug("ccw_device_offline returned %d, device %s\n", 387 CIO_MSG_EVENT(2, "ccw_device_offline returned %d, "
383 ret, cdev->dev.bus_id); 388 "device 0.%x.%04x\n",
389 ret, cdev->private->dev_id.ssid,
390 cdev->private->dev_id.devno);
384 cdev->online = 1; 391 cdev->online = 1;
385 } 392 }
386 return ret; 393 return ret;
@@ -402,8 +409,10 @@ ccw_device_set_online(struct ccw_device *cdev)
402 if (ret == 0) 409 if (ret == 0)
403 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev)); 410 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
404 else { 411 else {
405 pr_debug("ccw_device_online returned %d, device %s\n", 412 CIO_MSG_EVENT(2, "ccw_device_online returned %d, "
406 ret, cdev->dev.bus_id); 413 "device 0.%x.%04x\n",
414 ret, cdev->private->dev_id.ssid,
415 cdev->private->dev_id.devno);
407 return ret; 416 return ret;
408 } 417 }
409 if (cdev->private->state != DEV_STATE_ONLINE) 418 if (cdev->private->state != DEV_STATE_ONLINE)
@@ -417,9 +426,11 @@ ccw_device_set_online(struct ccw_device *cdev)
417 spin_unlock_irq(cdev->ccwlock); 426 spin_unlock_irq(cdev->ccwlock);
418 if (ret == 0) 427 if (ret == 0)
419 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev)); 428 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
420 else 429 else
421 pr_debug("ccw_device_offline returned %d, device %s\n", 430 CIO_MSG_EVENT(2, "ccw_device_offline returned %d, "
422 ret, cdev->dev.bus_id); 431 "device 0.%x.%04x\n",
432 ret, cdev->private->dev_id.ssid,
433 cdev->private->dev_id.devno);
423 return (ret == 0) ? -ENODEV : ret; 434 return (ret == 0) ? -ENODEV : ret;
424} 435}
425 436
@@ -439,9 +450,10 @@ static int online_store_recog_and_online(struct ccw_device *cdev)
439 if (cdev->id.cu_type == 0) { 450 if (cdev->id.cu_type == 0) {
440 ret = ccw_device_recognition(cdev); 451 ret = ccw_device_recognition(cdev);
441 if (ret) { 452 if (ret) {
442 printk(KERN_WARNING"Couldn't start recognition " 453 CIO_MSG_EVENT(0, "Couldn't start recognition "
443 "for device %s (ret=%d)\n", 454 "for device 0.%x.%04x (ret=%d)\n",
444 cdev->dev.bus_id, ret); 455 cdev->private->dev_id.ssid,
456 cdev->private->dev_id.devno, ret);
445 return ret; 457 return ret;
446 } 458 }
447 wait_event(cdev->private->wait_q, 459 wait_event(cdev->private->wait_q,
@@ -461,8 +473,8 @@ static void online_store_handle_online(struct ccw_device *cdev, int force)
461 if (force && cdev->private->state == DEV_STATE_BOXED) { 473 if (force && cdev->private->state == DEV_STATE_BOXED) {
462 ret = ccw_device_stlck(cdev); 474 ret = ccw_device_stlck(cdev);
463 if (ret) { 475 if (ret) {
464 printk(KERN_WARNING"ccw_device_stlck for device %s " 476 dev_warn(&cdev->dev,
465 "returned %d!\n", cdev->dev.bus_id, ret); 477 "ccw_device_stlck returned %d!\n", ret);
466 return; 478 return;
467 } 479 }
468 if (cdev->id.cu_type == 0) 480 if (cdev->id.cu_type == 0)
@@ -893,8 +905,10 @@ io_subchannel_register(struct work_struct *work)
893 ret = device_reprobe(&cdev->dev); 905 ret = device_reprobe(&cdev->dev);
894 if (ret) 906 if (ret)
895 /* We can't do much here. */ 907 /* We can't do much here. */
896 dev_info(&cdev->dev, "device_reprobe() returned" 908 CIO_MSG_EVENT(2, "device_reprobe() returned"
897 " %d\n", ret); 909 " %d for 0.%x.%04x\n", ret,
910 cdev->private->dev_id.ssid,
911 cdev->private->dev_id.devno);
898 } 912 }
899 goto out; 913 goto out;
900 } 914 }
@@ -907,8 +921,9 @@ io_subchannel_register(struct work_struct *work)
907 /* make it known to the system */ 921 /* make it known to the system */
908 ret = ccw_device_register(cdev); 922 ret = ccw_device_register(cdev);
909 if (ret) { 923 if (ret) {
910 printk (KERN_WARNING "%s: could not register %s\n", 924 CIO_MSG_EVENT(0, "Could not register ccw dev 0.%x.%04x: %d\n",
911 __func__, cdev->dev.bus_id); 925 cdev->private->dev_id.ssid,
926 cdev->private->dev_id.devno, ret);
912 put_device(&cdev->dev); 927 put_device(&cdev->dev);
913 spin_lock_irqsave(sch->lock, flags); 928 spin_lock_irqsave(sch->lock, flags);
914 sch->dev.driver_data = NULL; 929 sch->dev.driver_data = NULL;
@@ -1361,7 +1376,6 @@ ccw_device_remove (struct device *dev)
1361 struct ccw_driver *cdrv = cdev->drv; 1376 struct ccw_driver *cdrv = cdev->drv;
1362 int ret; 1377 int ret;
1363 1378
1364 pr_debug("removing device %s\n", cdev->dev.bus_id);
1365 if (cdrv->remove) 1379 if (cdrv->remove)
1366 cdrv->remove(cdev); 1380 cdrv->remove(cdev);
1367 if (cdev->online) { 1381 if (cdev->online) {
@@ -1374,8 +1388,10 @@ ccw_device_remove (struct device *dev)
1374 dev_fsm_final_state(cdev)); 1388 dev_fsm_final_state(cdev));
1375 else 1389 else
1376 //FIXME: we can't fail! 1390 //FIXME: we can't fail!
1377 pr_debug("ccw_device_offline returned %d, device %s\n", 1391 CIO_MSG_EVENT(2, "ccw_device_offline returned %d, "
1378 ret, cdev->dev.bus_id); 1392 "device 0.%x.%04x\n",
1393 ret, cdev->private->dev_id.ssid,
1394 cdev->private->dev_id.devno);
1379 } 1395 }
1380 ccw_device_set_timeout(cdev, 0); 1396 ccw_device_set_timeout(cdev, 0);
1381 cdev->drv = NULL; 1397 cdev->drv = NULL;
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index 6bba80929577..8633dc537695 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -268,7 +268,7 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
268 switch (state) { 268 switch (state) {
269 case DEV_STATE_NOT_OPER: 269 case DEV_STATE_NOT_OPER:
270 CIO_DEBUG(KERN_WARNING, 2, 270 CIO_DEBUG(KERN_WARNING, 2,
271 "SenseID : unknown device %04x on subchannel " 271 "cio: SenseID : unknown device %04x on subchannel "
272 "0.%x.%04x\n", cdev->private->dev_id.devno, 272 "0.%x.%04x\n", cdev->private->dev_id.devno,
273 sch->schid.ssid, sch->schid.sch_no); 273 sch->schid.ssid, sch->schid.sch_no);
274 break; 274 break;
@@ -293,7 +293,8 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
293 return; 293 return;
294 } 294 }
295 /* Issue device info message. */ 295 /* Issue device info message. */
296 CIO_DEBUG(KERN_INFO, 2, "SenseID : device 0.%x.%04x reports: " 296 CIO_DEBUG(KERN_INFO, 2,
297 "cio: SenseID : device 0.%x.%04x reports: "
297 "CU Type/Mod = %04X/%02X, Dev Type/Mod = " 298 "CU Type/Mod = %04X/%02X, Dev Type/Mod = "
298 "%04X/%02X\n", 299 "%04X/%02X\n",
299 cdev->private->dev_id.ssid, 300 cdev->private->dev_id.ssid,
@@ -303,7 +304,7 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
303 break; 304 break;
304 case DEV_STATE_BOXED: 305 case DEV_STATE_BOXED:
305 CIO_DEBUG(KERN_WARNING, 2, 306 CIO_DEBUG(KERN_WARNING, 2,
306 "SenseID : boxed device %04x on subchannel " 307 "cio: SenseID : boxed device %04x on subchannel "
307 "0.%x.%04x\n", cdev->private->dev_id.devno, 308 "0.%x.%04x\n", cdev->private->dev_id.devno,
308 sch->schid.ssid, sch->schid.sch_no); 309 sch->schid.ssid, sch->schid.sch_no);
309 break; 310 break;
@@ -388,7 +389,7 @@ ccw_device_done(struct ccw_device *cdev, int state)
388 389
389 if (state == DEV_STATE_BOXED) 390 if (state == DEV_STATE_BOXED)
390 CIO_DEBUG(KERN_WARNING, 2, 391 CIO_DEBUG(KERN_WARNING, 2,
391 "Boxed device %04x on subchannel %04x\n", 392 "cio: Boxed device %04x on subchannel %04x\n",
392 cdev->private->dev_id.devno, sch->schid.sch_no); 393 cdev->private->dev_id.devno, sch->schid.sch_no);
393 394
394 if (cdev->private->flags.donotify) { 395 if (cdev->private->flags.donotify) {
@@ -946,9 +947,10 @@ ccw_device_w4sense(struct ccw_device *cdev, enum dev_event dev_event)
946 /* Basic sense hasn't started. Try again. */ 947 /* Basic sense hasn't started. Try again. */
947 ccw_device_do_sense(cdev, irb); 948 ccw_device_do_sense(cdev, irb);
948 else { 949 else {
949 printk(KERN_INFO "Huh? %s(%s): unsolicited " 950 CIO_MSG_EVENT(2, "Huh? 0.%x.%04x: unsolicited "
950 "interrupt...\n", 951 "interrupt during w4sense...\n",
951 __FUNCTION__, cdev->dev.bus_id); 952 cdev->private->dev_id.ssid,
953 cdev->private->dev_id.devno);
952 if (cdev->handler) 954 if (cdev->handler)
953 cdev->handler (cdev, 0, irb); 955 cdev->handler (cdev, 0, irb);
954 } 956 }
@@ -1215,8 +1217,8 @@ ccw_device_nop(struct ccw_device *cdev, enum dev_event dev_event)
1215static void 1217static void
1216ccw_device_bug(struct ccw_device *cdev, enum dev_event dev_event) 1218ccw_device_bug(struct ccw_device *cdev, enum dev_event dev_event)
1217{ 1219{
1218 printk(KERN_EMERG "dev_jumptable[%i][%i] == NULL\n", 1220 CIO_MSG_EVENT(0, "dev_jumptable[%i][%i] == NULL\n",
1219 cdev->private->state, dev_event); 1221 cdev->private->state, dev_event);
1220 BUG(); 1222 BUG();
1221} 1223}
1222 1224
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index a5d263fb55ae..14eba854b155 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -288,253 +288,6 @@ ccw_device_get_path_mask(struct ccw_device *cdev)
288 return sch->lpm; 288 return sch->lpm;
289} 289}
290 290
291static void
292ccw_device_wake_up(struct ccw_device *cdev, unsigned long ip, struct irb *irb)
293{
294 if (!ip)
295 /* unsolicited interrupt */
296 return;
297
298 /* Abuse intparm for error reporting. */
299 if (IS_ERR(irb))
300 cdev->private->intparm = -EIO;
301 else if (irb->scsw.cc == 1)
302 /* Retry for deferred condition code. */
303 cdev->private->intparm = -EAGAIN;
304 else if ((irb->scsw.dstat !=
305 (DEV_STAT_CHN_END|DEV_STAT_DEV_END)) ||
306 (irb->scsw.cstat != 0)) {
307 /*
308 * We didn't get channel end / device end. Check if path
309 * verification has been started; we can retry after it has
310 * finished. We also retry unit checks except for command reject
311 * or intervention required. Also check for long busy
312 * conditions.
313 */
314 if (cdev->private->flags.doverify ||
315 cdev->private->state == DEV_STATE_VERIFY)
316 cdev->private->intparm = -EAGAIN;
317 else if ((irb->scsw.dstat & DEV_STAT_UNIT_CHECK) &&
318 !(irb->ecw[0] &
319 (SNS0_CMD_REJECT | SNS0_INTERVENTION_REQ)))
320 cdev->private->intparm = -EAGAIN;
321 else if ((irb->scsw.dstat & DEV_STAT_ATTENTION) &&
322 (irb->scsw.dstat & DEV_STAT_DEV_END) &&
323 (irb->scsw.dstat & DEV_STAT_UNIT_EXCEP))
324 cdev->private->intparm = -EAGAIN;
325 else
326 cdev->private->intparm = -EIO;
327
328 } else
329 cdev->private->intparm = 0;
330 wake_up(&cdev->private->wait_q);
331}
332
333static int
334__ccw_device_retry_loop(struct ccw_device *cdev, struct ccw1 *ccw, long magic, __u8 lpm)
335{
336 int ret;
337 struct subchannel *sch;
338
339 sch = to_subchannel(cdev->dev.parent);
340 do {
341 ccw_device_set_timeout(cdev, 60 * HZ);
342 ret = cio_start (sch, ccw, lpm);
343 if (ret != 0)
344 ccw_device_set_timeout(cdev, 0);
345 if (ret == -EBUSY) {
346 /* Try again later. */
347 spin_unlock_irq(sch->lock);
348 msleep(10);
349 spin_lock_irq(sch->lock);
350 continue;
351 }
352 if (ret != 0)
353 /* Non-retryable error. */
354 break;
355 /* Wait for end of request. */
356 cdev->private->intparm = magic;
357 spin_unlock_irq(sch->lock);
358 wait_event(cdev->private->wait_q,
359 (cdev->private->intparm == -EIO) ||
360 (cdev->private->intparm == -EAGAIN) ||
361 (cdev->private->intparm == 0));
362 spin_lock_irq(sch->lock);
363 /* Check at least for channel end / device end */
364 if (cdev->private->intparm == -EIO) {
365 /* Non-retryable error. */
366 ret = -EIO;
367 break;
368 }
369 if (cdev->private->intparm == 0)
370 /* Success. */
371 break;
372 /* Try again later. */
373 spin_unlock_irq(sch->lock);
374 msleep(10);
375 spin_lock_irq(sch->lock);
376 } while (1);
377
378 return ret;
379}
380
381/**
382 * read_dev_chars() - read device characteristics
383 * @param cdev target ccw device
384 * @param buffer pointer to buffer for rdc data
385 * @param length size of rdc data
386 * @returns 0 for success, negative error value on failure
387 *
388 * Context:
389 * called for online device, lock not held
390 **/
391int
392read_dev_chars (struct ccw_device *cdev, void **buffer, int length)
393{
394 void (*handler)(struct ccw_device *, unsigned long, struct irb *);
395 struct subchannel *sch;
396 int ret;
397 struct ccw1 *rdc_ccw;
398
399 if (!cdev)
400 return -ENODEV;
401 if (!buffer || !length)
402 return -EINVAL;
403 sch = to_subchannel(cdev->dev.parent);
404
405 CIO_TRACE_EVENT (4, "rddevch");
406 CIO_TRACE_EVENT (4, sch->dev.bus_id);
407
408 rdc_ccw = kzalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
409 if (!rdc_ccw)
410 return -ENOMEM;
411 rdc_ccw->cmd_code = CCW_CMD_RDC;
412 rdc_ccw->count = length;
413 rdc_ccw->flags = CCW_FLAG_SLI;
414 ret = set_normalized_cda (rdc_ccw, (*buffer));
415 if (ret != 0) {
416 kfree(rdc_ccw);
417 return ret;
418 }
419
420 spin_lock_irq(sch->lock);
421 /* Save interrupt handler. */
422 handler = cdev->handler;
423 /* Temporarily install own handler. */
424 cdev->handler = ccw_device_wake_up;
425 if (cdev->private->state != DEV_STATE_ONLINE)
426 ret = -ENODEV;
427 else if (((sch->schib.scsw.stctl & SCSW_STCTL_PRIM_STATUS) &&
428 !(sch->schib.scsw.stctl & SCSW_STCTL_SEC_STATUS)) ||
429 cdev->private->flags.doverify)
430 ret = -EBUSY;
431 else
432 /* 0x00D9C4C3 == ebcdic "RDC" */
433 ret = __ccw_device_retry_loop(cdev, rdc_ccw, 0x00D9C4C3, 0);
434
435 /* Restore interrupt handler. */
436 cdev->handler = handler;
437 spin_unlock_irq(sch->lock);
438
439 clear_normalized_cda (rdc_ccw);
440 kfree(rdc_ccw);
441
442 return ret;
443}
444
445/*
446 * Read Configuration data using path mask
447 */
448int
449read_conf_data_lpm (struct ccw_device *cdev, void **buffer, int *length, __u8 lpm)
450{
451 void (*handler)(struct ccw_device *, unsigned long, struct irb *);
452 struct subchannel *sch;
453 struct ciw *ciw;
454 char *rcd_buf;
455 int ret;
456 struct ccw1 *rcd_ccw;
457
458 if (!cdev)
459 return -ENODEV;
460 if (!buffer || !length)
461 return -EINVAL;
462 sch = to_subchannel(cdev->dev.parent);
463
464 CIO_TRACE_EVENT (4, "rdconf");
465 CIO_TRACE_EVENT (4, sch->dev.bus_id);
466
467 /*
468 * scan for RCD command in extended SenseID data
469 */
470 ciw = ccw_device_get_ciw(cdev, CIW_TYPE_RCD);
471 if (!ciw || ciw->cmd == 0)
472 return -EOPNOTSUPP;
473
474 /* Adjust requested path mask to excluded varied off paths. */
475 if (lpm) {
476 lpm &= sch->opm;
477 if (lpm == 0)
478 return -EACCES;
479 }
480
481 rcd_ccw = kzalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
482 if (!rcd_ccw)
483 return -ENOMEM;
484 rcd_buf = kzalloc(ciw->count, GFP_KERNEL | GFP_DMA);
485 if (!rcd_buf) {
486 kfree(rcd_ccw);
487 return -ENOMEM;
488 }
489 rcd_ccw->cmd_code = ciw->cmd;
490 rcd_ccw->cda = (__u32) __pa (rcd_buf);
491 rcd_ccw->count = ciw->count;
492 rcd_ccw->flags = CCW_FLAG_SLI;
493
494 spin_lock_irq(sch->lock);
495 /* Save interrupt handler. */
496 handler = cdev->handler;
497 /* Temporarily install own handler. */
498 cdev->handler = ccw_device_wake_up;
499 if (cdev->private->state != DEV_STATE_ONLINE)
500 ret = -ENODEV;
501 else if (((sch->schib.scsw.stctl & SCSW_STCTL_PRIM_STATUS) &&
502 !(sch->schib.scsw.stctl & SCSW_STCTL_SEC_STATUS)) ||
503 cdev->private->flags.doverify)
504 ret = -EBUSY;
505 else
506 /* 0x00D9C3C4 == ebcdic "RCD" */
507 ret = __ccw_device_retry_loop(cdev, rcd_ccw, 0x00D9C3C4, lpm);
508
509 /* Restore interrupt handler. */
510 cdev->handler = handler;
511 spin_unlock_irq(sch->lock);
512
513 /*
514 * on success we update the user input parms
515 */
516 if (ret) {
517 kfree (rcd_buf);
518 *buffer = NULL;
519 *length = 0;
520 } else {
521 *length = ciw->count;
522 *buffer = rcd_buf;
523 }
524 kfree(rcd_ccw);
525
526 return ret;
527}
528
529/*
530 * Read Configuration data
531 */
532int
533read_conf_data (struct ccw_device *cdev, void **buffer, int *length)
534{
535 return read_conf_data_lpm (cdev, buffer, length, 0);
536}
537
538/* 291/*
539 * Try to break the lock on a boxed device. 292 * Try to break the lock on a boxed device.
540 */ 293 */
@@ -635,12 +388,6 @@ _ccw_device_get_subchannel_number(struct ccw_device *cdev)
635 return cdev->private->schid.sch_no; 388 return cdev->private->schid.sch_no;
636} 389}
637 390
638int
639_ccw_device_get_device_number(struct ccw_device *cdev)
640{
641 return cdev->private->dev_id.devno;
642}
643
644 391
645MODULE_LICENSE("GPL"); 392MODULE_LICENSE("GPL");
646EXPORT_SYMBOL(ccw_device_set_options_mask); 393EXPORT_SYMBOL(ccw_device_set_options_mask);
@@ -655,9 +402,5 @@ EXPORT_SYMBOL(ccw_device_start_timeout_key);
655EXPORT_SYMBOL(ccw_device_start_key); 402EXPORT_SYMBOL(ccw_device_start_key);
656EXPORT_SYMBOL(ccw_device_get_ciw); 403EXPORT_SYMBOL(ccw_device_get_ciw);
657EXPORT_SYMBOL(ccw_device_get_path_mask); 404EXPORT_SYMBOL(ccw_device_get_path_mask);
658EXPORT_SYMBOL(read_conf_data);
659EXPORT_SYMBOL(read_dev_chars);
660EXPORT_SYMBOL(_ccw_device_get_subchannel_number); 405EXPORT_SYMBOL(_ccw_device_get_subchannel_number);
661EXPORT_SYMBOL(_ccw_device_get_device_number);
662EXPORT_SYMBOL_GPL(ccw_device_get_chp_desc); 406EXPORT_SYMBOL_GPL(ccw_device_get_chp_desc);
663EXPORT_SYMBOL_GPL(read_conf_data_lpm);
diff --git a/drivers/s390/net/ctcmain.c b/drivers/s390/net/ctcmain.c
index b20fd0681733..92e8a37b5022 100644
--- a/drivers/s390/net/ctcmain.c
+++ b/drivers/s390/net/ctcmain.c
@@ -674,7 +674,7 @@ ch_action_txdone(fsm_instance * fi, int event, void *arg)
674 int first = 1; 674 int first = 1;
675 int i; 675 int i;
676 unsigned long duration; 676 unsigned long duration;
677 struct timespec done_stamp = xtime; 677 struct timespec done_stamp = current_kernel_time();
678 678
679 DBF_TEXT(trace, 4, __FUNCTION__); 679 DBF_TEXT(trace, 4, __FUNCTION__);
680 680
@@ -730,7 +730,7 @@ ch_action_txdone(fsm_instance * fi, int event, void *arg)
730 spin_unlock(&ch->collect_lock); 730 spin_unlock(&ch->collect_lock);
731 ch->ccw[1].count = ch->trans_skb->len; 731 ch->ccw[1].count = ch->trans_skb->len;
732 fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch); 732 fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch);
733 ch->prof.send_stamp = xtime; 733 ch->prof.send_stamp = current_kernel_time();
734 rc = ccw_device_start(ch->cdev, &ch->ccw[0], 734 rc = ccw_device_start(ch->cdev, &ch->ccw[0],
735 (unsigned long) ch, 0xff, 0); 735 (unsigned long) ch, 0xff, 0);
736 ch->prof.doios_multi++; 736 ch->prof.doios_multi++;
@@ -2281,7 +2281,7 @@ transmit_skb(struct channel *ch, struct sk_buff *skb)
2281 fsm_newstate(ch->fsm, CH_STATE_TX); 2281 fsm_newstate(ch->fsm, CH_STATE_TX);
2282 fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch); 2282 fsm_addtimer(&ch->timer, CTC_TIMEOUT_5SEC, CH_EVENT_TIMER, ch);
2283 spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags); 2283 spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
2284 ch->prof.send_stamp = xtime; 2284 ch->prof.send_stamp = current_kernel_time();
2285 rc = ccw_device_start(ch->cdev, &ch->ccw[ccw_idx], 2285 rc = ccw_device_start(ch->cdev, &ch->ccw[ccw_idx],
2286 (unsigned long) ch, 0xff, 0); 2286 (unsigned long) ch, 0xff, 0);
2287 spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags); 2287 spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags);
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 3d28e1a5bf79..268889474339 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -753,7 +753,7 @@ static void conn_action_txdone(fsm_instance *fi, int event, void *arg)
753 753
754 header.next = 0; 754 header.next = 0;
755 memcpy(skb_put(conn->tx_buff, NETIUCV_HDRLEN), &header, NETIUCV_HDRLEN); 755 memcpy(skb_put(conn->tx_buff, NETIUCV_HDRLEN), &header, NETIUCV_HDRLEN);
756 conn->prof.send_stamp = xtime; 756 conn->prof.send_stamp = current_kernel_time();
757 txmsg.class = 0; 757 txmsg.class = 0;
758 txmsg.tag = 0; 758 txmsg.tag = 0;
759 rc = iucv_message_send(conn->path, &txmsg, 0, 0, 759 rc = iucv_message_send(conn->path, &txmsg, 0, 0,
@@ -1185,7 +1185,7 @@ static int netiucv_transmit_skb(struct iucv_connection *conn,
1185 memcpy(skb_put(nskb, NETIUCV_HDRLEN), &header, NETIUCV_HDRLEN); 1185 memcpy(skb_put(nskb, NETIUCV_HDRLEN), &header, NETIUCV_HDRLEN);
1186 1186
1187 fsm_newstate(conn->fsm, CONN_STATE_TX); 1187 fsm_newstate(conn->fsm, CONN_STATE_TX);
1188 conn->prof.send_stamp = xtime; 1188 conn->prof.send_stamp = current_kernel_time();
1189 1189
1190 msg.tag = 1; 1190 msg.tag = 1;
1191 msg.class = 0; 1191 msg.class = 0;
diff --git a/drivers/sbus/char/Kconfig b/drivers/sbus/char/Kconfig
index 35a73168333f..400c65bfb8c7 100644
--- a/drivers/sbus/char/Kconfig
+++ b/drivers/sbus/char/Kconfig
@@ -15,6 +15,7 @@ config SUN_OPENPROMIO
15 15
16config SUN_MOSTEK_RTC 16config SUN_MOSTEK_RTC
17 tristate "Mostek real time clock support" 17 tristate "Mostek real time clock support"
18 depends on SPARC32
18 help 19 help
19 The Mostek RTC chip is used on all known Sun computers except 20 The Mostek RTC chip is used on all known Sun computers except
20 some JavaStations. For a JavaStation you need to say Y both here 21 some JavaStations. For a JavaStation you need to say Y both here
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index e821a155b658..0bde26989a23 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -479,11 +479,12 @@ static int kenvctrld(void *__unused)
479 479
480static void attach_one_temp(struct linux_ebus_child *echild, int temp_idx) 480static void attach_one_temp(struct linux_ebus_child *echild, int temp_idx)
481{ 481{
482 struct bbc_cpu_temperature *tp = kmalloc(sizeof(*tp), GFP_KERNEL); 482 struct bbc_cpu_temperature *tp;
483 483
484 tp = kzalloc(sizeof(*tp), GFP_KERNEL);
484 if (!tp) 485 if (!tp)
485 return; 486 return;
486 memset(tp, 0, sizeof(*tp)); 487
487 tp->client = bbc_i2c_attach(echild); 488 tp->client = bbc_i2c_attach(echild);
488 if (!tp->client) { 489 if (!tp->client) {
489 kfree(tp); 490 kfree(tp);
@@ -525,11 +526,12 @@ static void attach_one_temp(struct linux_ebus_child *echild, int temp_idx)
525 526
526static void attach_one_fan(struct linux_ebus_child *echild, int fan_idx) 527static void attach_one_fan(struct linux_ebus_child *echild, int fan_idx)
527{ 528{
528 struct bbc_fan_control *fp = kmalloc(sizeof(*fp), GFP_KERNEL); 529 struct bbc_fan_control *fp;
529 530
531 fp = kzalloc(sizeof(*fp), GFP_KERNEL);
530 if (!fp) 532 if (!fp)
531 return; 533 return;
532 memset(fp, 0, sizeof(*fp)); 534
533 fp->client = bbc_i2c_attach(echild); 535 fp->client = bbc_i2c_attach(echild);
534 if (!fp->client) { 536 if (!fp->client) {
535 kfree(fp); 537 kfree(fp);
diff --git a/drivers/sbus/char/bbc_i2c.c b/drivers/sbus/char/bbc_i2c.c
index fbadd4d761f3..ac8ef2ce07fb 100644
--- a/drivers/sbus/char/bbc_i2c.c
+++ b/drivers/sbus/char/bbc_i2c.c
@@ -357,13 +357,13 @@ static void __init reset_one_i2c(struct bbc_i2c_bus *bp)
357 357
358static int __init attach_one_i2c(struct linux_ebus_device *edev, int index) 358static int __init attach_one_i2c(struct linux_ebus_device *edev, int index)
359{ 359{
360 struct bbc_i2c_bus *bp = kmalloc(sizeof(*bp), GFP_KERNEL); 360 struct bbc_i2c_bus *bp;
361 struct linux_ebus_child *echild; 361 struct linux_ebus_child *echild;
362 int entry; 362 int entry;
363 363
364 bp = kzalloc(sizeof(*bp), GFP_KERNEL);
364 if (!bp) 365 if (!bp)
365 return -ENOMEM; 366 return -ENOMEM;
366 memset(bp, 0, sizeof(*bp));
367 367
368 bp->i2c_control_regs = ioremap(edev->resource[0].start, 0x2); 368 bp->i2c_control_regs = ioremap(edev->resource[0].start, 0x2);
369 if (!bp->i2c_control_regs) 369 if (!bp->i2c_control_regs)
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c
index 5157a2abc58d..4b7079fdc10c 100644
--- a/drivers/sbus/char/jsflash.c
+++ b/drivers/sbus/char/jsflash.c
@@ -185,7 +185,7 @@ static void jsfd_read(char *buf, unsigned long p, size_t togo) {
185 } 185 }
186} 186}
187 187
188static void jsfd_do_request(request_queue_t *q) 188static void jsfd_do_request(struct request_queue *q)
189{ 189{
190 struct request *req; 190 struct request *req;
191 191
diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c
index 26b1d2a17ed2..9269f7fbd363 100644
--- a/drivers/sbus/char/vfc_dev.c
+++ b/drivers/sbus/char/vfc_dev.c
@@ -248,6 +248,7 @@ static int vfc_debug(struct vfc_dev *dev, int cmd, void __user *argp)
248 buffer,inout.len); 248 buffer,inout.len);
249 249
250 if (copy_to_user(argp,&inout,sizeof(inout))) { 250 if (copy_to_user(argp,&inout,sizeof(inout))) {
251 vfc_unlock_device(dev);
251 kfree(buffer); 252 kfree(buffer);
252 return -EFAULT; 253 return -EFAULT;
253 } 254 }
diff --git a/drivers/sbus/sbus.c b/drivers/sbus/sbus.c
index 2553629ec15d..c37d7c2587ff 100644
--- a/drivers/sbus/sbus.c
+++ b/drivers/sbus/sbus.c
@@ -210,6 +210,10 @@ static void __init walk_children(struct device_node *dp, struct sbus_dev *parent
210 210
211 sdev->bus = sbus; 211 sdev->bus = sbus;
212 sdev->parent = parent; 212 sdev->parent = parent;
213 sdev->ofdev.dev.archdata.iommu =
214 sbus->ofdev.dev.archdata.iommu;
215 sdev->ofdev.dev.archdata.stc =
216 sbus->ofdev.dev.archdata.stc;
213 217
214 fill_sbus_device(dp, sdev); 218 fill_sbus_device(dp, sdev);
215 219
@@ -269,6 +273,11 @@ static void __init build_one_sbus(struct device_node *dp, int num_sbus)
269 273
270 sdev->bus = sbus; 274 sdev->bus = sbus;
271 sdev->parent = NULL; 275 sdev->parent = NULL;
276 sdev->ofdev.dev.archdata.iommu =
277 sbus->ofdev.dev.archdata.iommu;
278 sdev->ofdev.dev.archdata.stc =
279 sbus->ofdev.dev.archdata.stc;
280
272 fill_sbus_device(dev_dp, sdev); 281 fill_sbus_device(dev_dp, sdev);
273 282
274 walk_children(dev_dp, sdev, sbus); 283 walk_children(dev_dp, sdev, sbus);
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index a26baab09dbf..6800e578e4b1 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -194,8 +194,7 @@ static inline int aac_valid_context(struct scsi_cmnd *scsicmd,
194 struct scsi_device *device; 194 struct scsi_device *device;
195 195
196 if (unlikely(!scsicmd || !scsicmd->scsi_done )) { 196 if (unlikely(!scsicmd || !scsicmd->scsi_done )) {
197 dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n")) 197 dprintk((KERN_WARNING "aac_valid_context: scsi command corrupt\n"));
198;
199 aac_fib_complete(fibptr); 198 aac_fib_complete(fibptr);
200 aac_fib_free(fibptr); 199 aac_fib_free(fibptr);
201 return 0; 200 return 0;
@@ -1689,23 +1688,23 @@ static void synchronize_callback(void *context, struct fib *fibptr)
1689 if (!aac_valid_context(cmd, fibptr)) 1688 if (!aac_valid_context(cmd, fibptr))
1690 return; 1689 return;
1691 1690
1692 dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n", 1691 dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n",
1693 smp_processor_id(), jiffies)); 1692 smp_processor_id(), jiffies));
1694 BUG_ON(fibptr == NULL); 1693 BUG_ON(fibptr == NULL);
1695 1694
1696 1695
1697 synchronizereply = fib_data(fibptr); 1696 synchronizereply = fib_data(fibptr);
1698 if (le32_to_cpu(synchronizereply->status) == CT_OK) 1697 if (le32_to_cpu(synchronizereply->status) == CT_OK)
1699 cmd->result = DID_OK << 16 | 1698 cmd->result = DID_OK << 16 |
1700 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD; 1699 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1701 else { 1700 else {
1702 struct scsi_device *sdev = cmd->device; 1701 struct scsi_device *sdev = cmd->device;
1703 struct aac_dev *dev = fibptr->dev; 1702 struct aac_dev *dev = fibptr->dev;
1704 u32 cid = sdev_id(sdev); 1703 u32 cid = sdev_id(sdev);
1705 printk(KERN_WARNING 1704 printk(KERN_WARNING
1706 "synchronize_callback: synchronize failed, status = %d\n", 1705 "synchronize_callback: synchronize failed, status = %d\n",
1707 le32_to_cpu(synchronizereply->status)); 1706 le32_to_cpu(synchronizereply->status));
1708 cmd->result = DID_OK << 16 | 1707 cmd->result = DID_OK << 16 |
1709 COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; 1708 COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
1710 set_sense((u8 *)&dev->fsa_dev[cid].sense_data, 1709 set_sense((u8 *)&dev->fsa_dev[cid].sense_data,
1711 HARDWARE_ERROR, 1710 HARDWARE_ERROR,
@@ -1713,7 +1712,7 @@ static void synchronize_callback(void *context, struct fib *fibptr)
1713 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, 1712 ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
1714 0, 0); 1713 0, 0);
1715 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, 1714 memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1716 min(sizeof(dev->fsa_dev[cid].sense_data), 1715 min(sizeof(dev->fsa_dev[cid].sense_data),
1717 sizeof(cmd->sense_buffer))); 1716 sizeof(cmd->sense_buffer)));
1718 } 1717 }
1719 1718
@@ -1731,6 +1730,9 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
1731 struct scsi_device *sdev = scsicmd->device; 1730 struct scsi_device *sdev = scsicmd->device;
1732 int active = 0; 1731 int active = 0;
1733 struct aac_dev *aac; 1732 struct aac_dev *aac;
1733 u64 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) |
1734 (scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
1735 u32 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
1734 unsigned long flags; 1736 unsigned long flags;
1735 1737
1736 /* 1738 /*
@@ -1739,7 +1741,51 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
1739 */ 1741 */
1740 spin_lock_irqsave(&sdev->list_lock, flags); 1742 spin_lock_irqsave(&sdev->list_lock, flags);
1741 list_for_each_entry(cmd, &sdev->cmd_list, list) 1743 list_for_each_entry(cmd, &sdev->cmd_list, list)
1742 if (cmd != scsicmd && cmd->SCp.phase == AAC_OWNER_FIRMWARE) { 1744 if (cmd->SCp.phase == AAC_OWNER_FIRMWARE) {
1745 u64 cmnd_lba;
1746 u32 cmnd_count;
1747
1748 if (cmd->cmnd[0] == WRITE_6) {
1749 cmnd_lba = ((cmd->cmnd[1] & 0x1F) << 16) |
1750 (cmd->cmnd[2] << 8) |
1751 cmd->cmnd[3];
1752 cmnd_count = cmd->cmnd[4];
1753 if (cmnd_count == 0)
1754 cmnd_count = 256;
1755 } else if (cmd->cmnd[0] == WRITE_16) {
1756 cmnd_lba = ((u64)cmd->cmnd[2] << 56) |
1757 ((u64)cmd->cmnd[3] << 48) |
1758 ((u64)cmd->cmnd[4] << 40) |
1759 ((u64)cmd->cmnd[5] << 32) |
1760 ((u64)cmd->cmnd[6] << 24) |
1761 (cmd->cmnd[7] << 16) |
1762 (cmd->cmnd[8] << 8) |
1763 cmd->cmnd[9];
1764 cmnd_count = (cmd->cmnd[10] << 24) |
1765 (cmd->cmnd[11] << 16) |
1766 (cmd->cmnd[12] << 8) |
1767 cmd->cmnd[13];
1768 } else if (cmd->cmnd[0] == WRITE_12) {
1769 cmnd_lba = ((u64)cmd->cmnd[2] << 24) |
1770 (cmd->cmnd[3] << 16) |
1771 (cmd->cmnd[4] << 8) |
1772 cmd->cmnd[5];
1773 cmnd_count = (cmd->cmnd[6] << 24) |
1774 (cmd->cmnd[7] << 16) |
1775 (cmd->cmnd[8] << 8) |
1776 cmd->cmnd[9];
1777 } else if (cmd->cmnd[0] == WRITE_10) {
1778 cmnd_lba = ((u64)cmd->cmnd[2] << 24) |
1779 (cmd->cmnd[3] << 16) |
1780 (cmd->cmnd[4] << 8) |
1781 cmd->cmnd[5];
1782 cmnd_count = (cmd->cmnd[7] << 8) |
1783 cmd->cmnd[8];
1784 } else
1785 continue;
1786 if (((cmnd_lba + cmnd_count) < lba) ||
1787 (count && ((lba + count) < cmnd_lba)))
1788 continue;
1743 ++active; 1789 ++active;
1744 break; 1790 break;
1745 } 1791 }
@@ -1768,7 +1814,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
1768 synchronizecmd->command = cpu_to_le32(VM_ContainerConfig); 1814 synchronizecmd->command = cpu_to_le32(VM_ContainerConfig);
1769 synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE); 1815 synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE);
1770 synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd)); 1816 synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd));
1771 synchronizecmd->count = 1817 synchronizecmd->count =
1772 cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data)); 1818 cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data));
1773 1819
1774 /* 1820 /*
@@ -1790,7 +1836,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
1790 return 0; 1836 return 0;
1791 } 1837 }
1792 1838
1793 printk(KERN_WARNING 1839 printk(KERN_WARNING
1794 "aac_synchronize: aac_fib_send failed with status: %d.\n", status); 1840 "aac_synchronize: aac_fib_send failed with status: %d.\n", status);
1795 aac_fib_complete(cmd_fibcontext); 1841 aac_fib_complete(cmd_fibcontext);
1796 aac_fib_free(cmd_fibcontext); 1842 aac_fib_free(cmd_fibcontext);
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index 400d03403cd5..94727b9375ec 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -12,7 +12,7 @@
12 *----------------------------------------------------------------------------*/ 12 *----------------------------------------------------------------------------*/
13 13
14#ifndef AAC_DRIVER_BUILD 14#ifndef AAC_DRIVER_BUILD
15# define AAC_DRIVER_BUILD 2447 15# define AAC_DRIVER_BUILD 2449
16# define AAC_DRIVER_BRANCH "-ms" 16# define AAC_DRIVER_BRANCH "-ms"
17#endif 17#endif
18#define MAXIMUM_NUM_CONTAINERS 32 18#define MAXIMUM_NUM_CONTAINERS 32
@@ -1807,10 +1807,10 @@ struct aac_aifcmd {
1807 * accounting for the fact capacity could be a 64 bit value 1807 * accounting for the fact capacity could be a 64 bit value
1808 * 1808 *
1809 */ 1809 */
1810static inline u32 cap_to_cyls(sector_t capacity, u32 divisor) 1810static inline unsigned int cap_to_cyls(sector_t capacity, unsigned divisor)
1811{ 1811{
1812 sector_div(capacity, divisor); 1812 sector_div(capacity, divisor);
1813 return (u32)capacity; 1813 return capacity;
1814} 1814}
1815 1815
1816/* SCp.phase values */ 1816/* SCp.phase values */
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index d76e1a8cb93a..813556c60007 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -636,6 +636,8 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
636static int aac_cfg_ioctl(struct inode *inode, struct file *file, 636static int aac_cfg_ioctl(struct inode *inode, struct file *file,
637 unsigned int cmd, unsigned long arg) 637 unsigned int cmd, unsigned long arg)
638{ 638{
639 if (!capable(CAP_SYS_ADMIN))
640 return -EPERM;
639 return aac_do_ioctl(file->private_data, cmd, (void __user *)arg); 641 return aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
640} 642}
641 643
@@ -689,6 +691,8 @@ static int aac_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
689 691
690static long aac_compat_cfg_ioctl(struct file *file, unsigned cmd, unsigned long arg) 692static long aac_compat_cfg_ioctl(struct file *file, unsigned cmd, unsigned long arg)
691{ 693{
694 if (!capable(CAP_SYS_ADMIN))
695 return -EPERM;
692 return aac_compat_do_ioctl((struct aac_dev *)file->private_data, cmd, arg); 696 return aac_compat_do_ioctl((struct aac_dev *)file->private_data, cmd, arg);
693} 697}
694#endif 698#endif
@@ -822,7 +826,7 @@ static ssize_t aac_show_reset_adapter(struct class_device *class_dev,
822 tmp = aac_adapter_check_health(dev); 826 tmp = aac_adapter_check_health(dev);
823 if ((tmp == 0) && dev->in_reset) 827 if ((tmp == 0) && dev->in_reset)
824 tmp = -EBUSY; 828 tmp = -EBUSY;
825 len = snprintf(buf, PAGE_SIZE, "0x%x", tmp); 829 len = snprintf(buf, PAGE_SIZE, "0x%x\n", tmp);
826 return len; 830 return len;
827} 831}
828 832
@@ -1122,9 +1126,8 @@ static int __devinit aac_probe_one(struct pci_dev *pdev,
1122static void aac_shutdown(struct pci_dev *dev) 1126static void aac_shutdown(struct pci_dev *dev)
1123{ 1127{
1124 struct Scsi_Host *shost = pci_get_drvdata(dev); 1128 struct Scsi_Host *shost = pci_get_drvdata(dev);
1125 struct aac_dev *aac = (struct aac_dev *)shost->hostdata;
1126 scsi_block_requests(shost); 1129 scsi_block_requests(shost);
1127 __aac_shutdown(aac); 1130 __aac_shutdown((struct aac_dev *)shost->hostdata);
1128} 1131}
1129 1132
1130static void __devexit aac_remove_one(struct pci_dev *pdev) 1133static void __devexit aac_remove_one(struct pci_dev *pdev)
diff --git a/drivers/scsi/aacraid/nark.c b/drivers/scsi/aacraid/nark.c
index a8ace5677813..c55f7c862f0e 100644
--- a/drivers/scsi/aacraid/nark.c
+++ b/drivers/scsi/aacraid/nark.c
@@ -1,11 +1,10 @@
1/* 1/*
2 * Adaptec AAC series RAID controller driver 2 * Adaptec AAC series RAID controller driver
3 * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com>
4 * 3 *
5 * based on the old aacraid driver that is.. 4 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux. 5 * Adaptec aacraid device driver for Linux.
7 * 6 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 7 * Copyright (c) 2006-2007 Adaptec, Inc. (aacraid@adaptec.com)
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/aacraid/rkt.c b/drivers/scsi/aacraid/rkt.c
index 9c5fcfb398c2..8cd6588a83e3 100644
--- a/drivers/scsi/aacraid/rkt.c
+++ b/drivers/scsi/aacraid/rkt.c
@@ -5,7 +5,7 @@
5 * based on the old aacraid driver that is.. 5 * based on the old aacraid driver that is..
6 * Adaptec aacraid device driver for Linux. 6 * Adaptec aacraid device driver for Linux.
7 * 7 *
8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 8 * Copyright (c) 2000-2007 Adaptec, Inc. (aacraid@adaptec.com)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
diff --git a/drivers/scsi/aacraid/rx.c b/drivers/scsi/aacraid/rx.c
index ebc65b9fea92..73eef3dc5dc6 100644
--- a/drivers/scsi/aacraid/rx.c
+++ b/drivers/scsi/aacraid/rx.c
@@ -472,7 +472,7 @@ static int aac_rx_restart_adapter(struct aac_dev *dev, int bled)
472 else { 472 else {
473 bled = aac_adapter_sync_cmd(dev, IOP_RESET_ALWAYS, 473 bled = aac_adapter_sync_cmd(dev, IOP_RESET_ALWAYS,
474 0, 0, 0, 0, 0, 0, &var, NULL, NULL, NULL, NULL); 474 0, 0, 0, 0, 0, 0, &var, NULL, NULL, NULL, NULL);
475 if (!bled && (var != 0x00000001)) 475 if (!bled && (var != 0x00000001) && (var != 0x3803000F))
476 bled = -EINVAL; 476 bled = -EINVAL;
477 } 477 }
478 if (bled && (bled != -ETIMEDOUT)) 478 if (bled && (bled != -ETIMEDOUT))
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 2b6689709e53..79c0b6e37a3b 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -1,4 +1,4 @@
1#define ASC_VERSION "3.3K" /* AdvanSys Driver Version */ 1#define ASC_VERSION "3.3K" /* AdvanSys Driver Version */
2 2
3/* 3/*
4 * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters 4 * advansys.c - Linux Host Driver for AdvanSys SCSI Adapters
@@ -802,7 +802,6 @@
802#include <linux/pci.h> 802#include <linux/pci.h>
803#endif /* CONFIG_PCI */ 803#endif /* CONFIG_PCI */
804 804
805
806/* 805/*
807 * --- Driver Options 806 * --- Driver Options
808 */ 807 */
@@ -816,18 +815,6 @@
816/* Enable driver tracing. */ 815/* Enable driver tracing. */
817/* #define ADVANSYS_DEBUG */ 816/* #define ADVANSYS_DEBUG */
818 817
819
820/*
821 * --- Debugging Header
822 */
823
824#ifdef ADVANSYS_DEBUG
825#define STATIC
826#else /* ADVANSYS_DEBUG */
827#define STATIC static
828#endif /* ADVANSYS_DEBUG */
829
830
831/* 818/*
832 * --- Asc Library Constants and Macros 819 * --- Asc Library Constants and Macros
833 */ 820 */
@@ -845,10 +832,10 @@
845 * are all consistent at 8, 16, and 32 bits respectively. Pointers 832 * are all consistent at 8, 16, and 32 bits respectively. Pointers
846 * and long types are 64 bits on Alpha and UltraSPARC. 833 * and long types are 64 bits on Alpha and UltraSPARC.
847 */ 834 */
848#define ASC_PADDR __u32 /* Physical/Bus address data type. */ 835#define ASC_PADDR __u32 /* Physical/Bus address data type. */
849#define ASC_VADDR __u32 /* Virtual address data type. */ 836#define ASC_VADDR __u32 /* Virtual address data type. */
850#define ASC_DCNT __u32 /* Unsigned Data count type. */ 837#define ASC_DCNT __u32 /* Unsigned Data count type. */
851#define ASC_SDCNT __s32 /* Signed Data count type. */ 838#define ASC_SDCNT __s32 /* Signed Data count type. */
852 839
853/* 840/*
854 * These macros are used to convert a virtual address to a 841 * These macros are used to convert a virtual address to a
@@ -911,7 +898,7 @@ typedef unsigned char uchar;
911#define CC_VERY_LONG_SG_LIST 0 898#define CC_VERY_LONG_SG_LIST 0
912#define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr) 899#define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
913 900
914#define PortAddr unsigned short /* port address size */ 901#define PortAddr unsigned short /* port address size */
915#define inp(port) inb(port) 902#define inp(port) inb(port)
916#define outp(port, byte) outb((byte), (port)) 903#define outp(port, byte) outb((byte), (port))
917 904
@@ -1038,17 +1025,17 @@ typedef unsigned char uchar;
1038#define ASC_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2) 1025#define ASC_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2)
1039 1026
1040typedef struct { 1027typedef struct {
1041 uchar periph; 1028 uchar periph;
1042 uchar devtype; 1029 uchar devtype;
1043 uchar ver; 1030 uchar ver;
1044 uchar byte3; 1031 uchar byte3;
1045 uchar add_len; 1032 uchar add_len;
1046 uchar res1; 1033 uchar res1;
1047 uchar res2; 1034 uchar res2;
1048 uchar flags; 1035 uchar flags;
1049 uchar vendor_id[8]; 1036 uchar vendor_id[8];
1050 uchar product_id[16]; 1037 uchar product_id[16];
1051 uchar product_rev_level[4]; 1038 uchar product_rev_level[4];
1052} ASC_SCSI_INQUIRY; 1039} ASC_SCSI_INQUIRY;
1053 1040
1054#define ASC_SG_LIST_PER_Q 7 1041#define ASC_SG_LIST_PER_Q 7
@@ -1165,139 +1152,139 @@ typedef struct {
1165#define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6)) 1152#define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
1166 1153
1167typedef struct asc_scsiq_1 { 1154typedef struct asc_scsiq_1 {
1168 uchar status; 1155 uchar status;
1169 uchar q_no; 1156 uchar q_no;
1170 uchar cntl; 1157 uchar cntl;
1171 uchar sg_queue_cnt; 1158 uchar sg_queue_cnt;
1172 uchar target_id; 1159 uchar target_id;
1173 uchar target_lun; 1160 uchar target_lun;
1174 ASC_PADDR data_addr; 1161 ASC_PADDR data_addr;
1175 ASC_DCNT data_cnt; 1162 ASC_DCNT data_cnt;
1176 ASC_PADDR sense_addr; 1163 ASC_PADDR sense_addr;
1177 uchar sense_len; 1164 uchar sense_len;
1178 uchar extra_bytes; 1165 uchar extra_bytes;
1179} ASC_SCSIQ_1; 1166} ASC_SCSIQ_1;
1180 1167
1181typedef struct asc_scsiq_2 { 1168typedef struct asc_scsiq_2 {
1182 ASC_VADDR srb_ptr; 1169 ASC_VADDR srb_ptr;
1183 uchar target_ix; 1170 uchar target_ix;
1184 uchar flag; 1171 uchar flag;
1185 uchar cdb_len; 1172 uchar cdb_len;
1186 uchar tag_code; 1173 uchar tag_code;
1187 ushort vm_id; 1174 ushort vm_id;
1188} ASC_SCSIQ_2; 1175} ASC_SCSIQ_2;
1189 1176
1190typedef struct asc_scsiq_3 { 1177typedef struct asc_scsiq_3 {
1191 uchar done_stat; 1178 uchar done_stat;
1192 uchar host_stat; 1179 uchar host_stat;
1193 uchar scsi_stat; 1180 uchar scsi_stat;
1194 uchar scsi_msg; 1181 uchar scsi_msg;
1195} ASC_SCSIQ_3; 1182} ASC_SCSIQ_3;
1196 1183
1197typedef struct asc_scsiq_4 { 1184typedef struct asc_scsiq_4 {
1198 uchar cdb[ASC_MAX_CDB_LEN]; 1185 uchar cdb[ASC_MAX_CDB_LEN];
1199 uchar y_first_sg_list_qp; 1186 uchar y_first_sg_list_qp;
1200 uchar y_working_sg_qp; 1187 uchar y_working_sg_qp;
1201 uchar y_working_sg_ix; 1188 uchar y_working_sg_ix;
1202 uchar y_res; 1189 uchar y_res;
1203 ushort x_req_count; 1190 ushort x_req_count;
1204 ushort x_reconnect_rtn; 1191 ushort x_reconnect_rtn;
1205 ASC_PADDR x_saved_data_addr; 1192 ASC_PADDR x_saved_data_addr;
1206 ASC_DCNT x_saved_data_cnt; 1193 ASC_DCNT x_saved_data_cnt;
1207} ASC_SCSIQ_4; 1194} ASC_SCSIQ_4;
1208 1195
1209typedef struct asc_q_done_info { 1196typedef struct asc_q_done_info {
1210 ASC_SCSIQ_2 d2; 1197 ASC_SCSIQ_2 d2;
1211 ASC_SCSIQ_3 d3; 1198 ASC_SCSIQ_3 d3;
1212 uchar q_status; 1199 uchar q_status;
1213 uchar q_no; 1200 uchar q_no;
1214 uchar cntl; 1201 uchar cntl;
1215 uchar sense_len; 1202 uchar sense_len;
1216 uchar extra_bytes; 1203 uchar extra_bytes;
1217 uchar res; 1204 uchar res;
1218 ASC_DCNT remain_bytes; 1205 ASC_DCNT remain_bytes;
1219} ASC_QDONE_INFO; 1206} ASC_QDONE_INFO;
1220 1207
1221typedef struct asc_sg_list { 1208typedef struct asc_sg_list {
1222 ASC_PADDR addr; 1209 ASC_PADDR addr;
1223 ASC_DCNT bytes; 1210 ASC_DCNT bytes;
1224} ASC_SG_LIST; 1211} ASC_SG_LIST;
1225 1212
1226typedef struct asc_sg_head { 1213typedef struct asc_sg_head {
1227 ushort entry_cnt; 1214 ushort entry_cnt;
1228 ushort queue_cnt; 1215 ushort queue_cnt;
1229 ushort entry_to_copy; 1216 ushort entry_to_copy;
1230 ushort res; 1217 ushort res;
1231 ASC_SG_LIST sg_list[ASC_MAX_SG_LIST]; 1218 ASC_SG_LIST sg_list[ASC_MAX_SG_LIST];
1232} ASC_SG_HEAD; 1219} ASC_SG_HEAD;
1233 1220
1234#define ASC_MIN_SG_LIST 2 1221#define ASC_MIN_SG_LIST 2
1235 1222
1236typedef struct asc_min_sg_head { 1223typedef struct asc_min_sg_head {
1237 ushort entry_cnt; 1224 ushort entry_cnt;
1238 ushort queue_cnt; 1225 ushort queue_cnt;
1239 ushort entry_to_copy; 1226 ushort entry_to_copy;
1240 ushort res; 1227 ushort res;
1241 ASC_SG_LIST sg_list[ASC_MIN_SG_LIST]; 1228 ASC_SG_LIST sg_list[ASC_MIN_SG_LIST];
1242} ASC_MIN_SG_HEAD; 1229} ASC_MIN_SG_HEAD;
1243 1230
1244#define QCX_SORT (0x0001) 1231#define QCX_SORT (0x0001)
1245#define QCX_COALEASE (0x0002) 1232#define QCX_COALEASE (0x0002)
1246 1233
1247typedef struct asc_scsi_q { 1234typedef struct asc_scsi_q {
1248 ASC_SCSIQ_1 q1; 1235 ASC_SCSIQ_1 q1;
1249 ASC_SCSIQ_2 q2; 1236 ASC_SCSIQ_2 q2;
1250 uchar *cdbptr; 1237 uchar *cdbptr;
1251 ASC_SG_HEAD *sg_head; 1238 ASC_SG_HEAD *sg_head;
1252 ushort remain_sg_entry_cnt; 1239 ushort remain_sg_entry_cnt;
1253 ushort next_sg_index; 1240 ushort next_sg_index;
1254} ASC_SCSI_Q; 1241} ASC_SCSI_Q;
1255 1242
1256typedef struct asc_scsi_req_q { 1243typedef struct asc_scsi_req_q {
1257 ASC_SCSIQ_1 r1; 1244 ASC_SCSIQ_1 r1;
1258 ASC_SCSIQ_2 r2; 1245 ASC_SCSIQ_2 r2;
1259 uchar *cdbptr; 1246 uchar *cdbptr;
1260 ASC_SG_HEAD *sg_head; 1247 ASC_SG_HEAD *sg_head;
1261 uchar *sense_ptr; 1248 uchar *sense_ptr;
1262 ASC_SCSIQ_3 r3; 1249 ASC_SCSIQ_3 r3;
1263 uchar cdb[ASC_MAX_CDB_LEN]; 1250 uchar cdb[ASC_MAX_CDB_LEN];
1264 uchar sense[ASC_MIN_SENSE_LEN]; 1251 uchar sense[ASC_MIN_SENSE_LEN];
1265} ASC_SCSI_REQ_Q; 1252} ASC_SCSI_REQ_Q;
1266 1253
1267typedef struct asc_scsi_bios_req_q { 1254typedef struct asc_scsi_bios_req_q {
1268 ASC_SCSIQ_1 r1; 1255 ASC_SCSIQ_1 r1;
1269 ASC_SCSIQ_2 r2; 1256 ASC_SCSIQ_2 r2;
1270 uchar *cdbptr; 1257 uchar *cdbptr;
1271 ASC_SG_HEAD *sg_head; 1258 ASC_SG_HEAD *sg_head;
1272 uchar *sense_ptr; 1259 uchar *sense_ptr;
1273 ASC_SCSIQ_3 r3; 1260 ASC_SCSIQ_3 r3;
1274 uchar cdb[ASC_MAX_CDB_LEN]; 1261 uchar cdb[ASC_MAX_CDB_LEN];
1275 uchar sense[ASC_MIN_SENSE_LEN]; 1262 uchar sense[ASC_MIN_SENSE_LEN];
1276} ASC_SCSI_BIOS_REQ_Q; 1263} ASC_SCSI_BIOS_REQ_Q;
1277 1264
1278typedef struct asc_risc_q { 1265typedef struct asc_risc_q {
1279 uchar fwd; 1266 uchar fwd;
1280 uchar bwd; 1267 uchar bwd;
1281 ASC_SCSIQ_1 i1; 1268 ASC_SCSIQ_1 i1;
1282 ASC_SCSIQ_2 i2; 1269 ASC_SCSIQ_2 i2;
1283 ASC_SCSIQ_3 i3; 1270 ASC_SCSIQ_3 i3;
1284 ASC_SCSIQ_4 i4; 1271 ASC_SCSIQ_4 i4;
1285} ASC_RISC_Q; 1272} ASC_RISC_Q;
1286 1273
1287typedef struct asc_sg_list_q { 1274typedef struct asc_sg_list_q {
1288 uchar seq_no; 1275 uchar seq_no;
1289 uchar q_no; 1276 uchar q_no;
1290 uchar cntl; 1277 uchar cntl;
1291 uchar sg_head_qp; 1278 uchar sg_head_qp;
1292 uchar sg_list_cnt; 1279 uchar sg_list_cnt;
1293 uchar sg_cur_list_cnt; 1280 uchar sg_cur_list_cnt;
1294} ASC_SG_LIST_Q; 1281} ASC_SG_LIST_Q;
1295 1282
1296typedef struct asc_risc_sg_list_q { 1283typedef struct asc_risc_sg_list_q {
1297 uchar fwd; 1284 uchar fwd;
1298 uchar bwd; 1285 uchar bwd;
1299 ASC_SG_LIST_Q sg; 1286 ASC_SG_LIST_Q sg;
1300 ASC_SG_LIST sg_list[7]; 1287 ASC_SG_LIST sg_list[7];
1301} ASC_RISC_SG_LIST_Q; 1288} ASC_RISC_SG_LIST_Q;
1302 1289
1303#define ASC_EXE_SCSI_IO_MAX_IDLE_LOOP 0x1000000UL 1290#define ASC_EXE_SCSI_IO_MAX_IDLE_LOOP 0x1000000UL
@@ -1431,25 +1418,25 @@ typedef struct asc_risc_sg_list_q {
1431#define SYN_ULTRA_XFER_NS_15 107 1418#define SYN_ULTRA_XFER_NS_15 107
1432 1419
1433typedef struct ext_msg { 1420typedef struct ext_msg {
1434 uchar msg_type; 1421 uchar msg_type;
1435 uchar msg_len; 1422 uchar msg_len;
1436 uchar msg_req; 1423 uchar msg_req;
1437 union { 1424 union {
1438 struct { 1425 struct {
1439 uchar sdtr_xfer_period; 1426 uchar sdtr_xfer_period;
1440 uchar sdtr_req_ack_offset; 1427 uchar sdtr_req_ack_offset;
1441 } sdtr; 1428 } sdtr;
1442 struct { 1429 struct {
1443 uchar wdtr_width; 1430 uchar wdtr_width;
1444 } wdtr; 1431 } wdtr;
1445 struct { 1432 struct {
1446 uchar mdp_b3; 1433 uchar mdp_b3;
1447 uchar mdp_b2; 1434 uchar mdp_b2;
1448 uchar mdp_b1; 1435 uchar mdp_b1;
1449 uchar mdp_b0; 1436 uchar mdp_b0;
1450 } mdp; 1437 } mdp;
1451 } u_ext_msg; 1438 } u_ext_msg;
1452 uchar res; 1439 uchar res;
1453} EXT_MSG; 1440} EXT_MSG;
1454 1441
1455#define xfer_period u_ext_msg.sdtr.sdtr_xfer_period 1442#define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
@@ -1461,24 +1448,24 @@ typedef struct ext_msg {
1461#define mdp_b0 u_ext_msg.mdp_b0 1448#define mdp_b0 u_ext_msg.mdp_b0
1462 1449
1463typedef struct asc_dvc_cfg { 1450typedef struct asc_dvc_cfg {
1464 ASC_SCSI_BIT_ID_TYPE can_tagged_qng; 1451 ASC_SCSI_BIT_ID_TYPE can_tagged_qng;
1465 ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled; 1452 ASC_SCSI_BIT_ID_TYPE cmd_qng_enabled;
1466 ASC_SCSI_BIT_ID_TYPE disc_enable; 1453 ASC_SCSI_BIT_ID_TYPE disc_enable;
1467 ASC_SCSI_BIT_ID_TYPE sdtr_enable; 1454 ASC_SCSI_BIT_ID_TYPE sdtr_enable;
1468 uchar chip_scsi_id; 1455 uchar chip_scsi_id;
1469 uchar isa_dma_speed; 1456 uchar isa_dma_speed;
1470 uchar isa_dma_channel; 1457 uchar isa_dma_channel;
1471 uchar chip_version; 1458 uchar chip_version;
1472 ushort lib_serial_no; 1459 ushort lib_serial_no;
1473 ushort lib_version; 1460 ushort lib_version;
1474 ushort mcode_date; 1461 ushort mcode_date;
1475 ushort mcode_version; 1462 ushort mcode_version;
1476 uchar max_tag_qng[ASC_MAX_TID + 1]; 1463 uchar max_tag_qng[ASC_MAX_TID + 1];
1477 uchar *overrun_buf; 1464 uchar *overrun_buf;
1478 uchar sdtr_period_offset[ASC_MAX_TID + 1]; 1465 uchar sdtr_period_offset[ASC_MAX_TID + 1];
1479 ushort pci_slot_info; 1466 ushort pci_slot_info;
1480 uchar adapter_info[6]; 1467 uchar adapter_info[6];
1481 struct device *dev; 1468 struct device *dev;
1482} ASC_DVC_CFG; 1469} ASC_DVC_CFG;
1483 1470
1484#define ASC_DEF_DVC_CNTL 0xFFFF 1471#define ASC_DEF_DVC_CNTL 0xFFFF
@@ -1501,64 +1488,64 @@ typedef struct asc_dvc_cfg {
1501#define ASC_MIN_TAGGED_CMD 7 1488#define ASC_MIN_TAGGED_CMD 7
1502#define ASC_MAX_SCSI_RESET_WAIT 30 1489#define ASC_MAX_SCSI_RESET_WAIT 30
1503 1490
1504struct asc_dvc_var; /* Forward Declaration. */ 1491struct asc_dvc_var; /* Forward Declaration. */
1505 1492
1506typedef void (* ASC_ISR_CALLBACK)(struct asc_dvc_var *, ASC_QDONE_INFO *); 1493typedef void (*ASC_ISR_CALLBACK) (struct asc_dvc_var *, ASC_QDONE_INFO *);
1507typedef int (* ASC_EXE_CALLBACK)(struct asc_dvc_var *, ASC_SCSI_Q *); 1494typedef int (*ASC_EXE_CALLBACK) (struct asc_dvc_var *, ASC_SCSI_Q *);
1508 1495
1509typedef struct asc_dvc_var { 1496typedef struct asc_dvc_var {
1510 PortAddr iop_base; 1497 PortAddr iop_base;
1511 ushort err_code; 1498 ushort err_code;
1512 ushort dvc_cntl; 1499 ushort dvc_cntl;
1513 ushort bug_fix_cntl; 1500 ushort bug_fix_cntl;
1514 ushort bus_type; 1501 ushort bus_type;
1515 ASC_ISR_CALLBACK isr_callback; 1502 ASC_ISR_CALLBACK isr_callback;
1516 ASC_EXE_CALLBACK exe_callback; 1503 ASC_EXE_CALLBACK exe_callback;
1517 ASC_SCSI_BIT_ID_TYPE init_sdtr; 1504 ASC_SCSI_BIT_ID_TYPE init_sdtr;
1518 ASC_SCSI_BIT_ID_TYPE sdtr_done; 1505 ASC_SCSI_BIT_ID_TYPE sdtr_done;
1519 ASC_SCSI_BIT_ID_TYPE use_tagged_qng; 1506 ASC_SCSI_BIT_ID_TYPE use_tagged_qng;
1520 ASC_SCSI_BIT_ID_TYPE unit_not_ready; 1507 ASC_SCSI_BIT_ID_TYPE unit_not_ready;
1521 ASC_SCSI_BIT_ID_TYPE queue_full_or_busy; 1508 ASC_SCSI_BIT_ID_TYPE queue_full_or_busy;
1522 ASC_SCSI_BIT_ID_TYPE start_motor; 1509 ASC_SCSI_BIT_ID_TYPE start_motor;
1523 uchar scsi_reset_wait; 1510 uchar scsi_reset_wait;
1524 uchar chip_no; 1511 uchar chip_no;
1525 char is_in_int; 1512 char is_in_int;
1526 uchar max_total_qng; 1513 uchar max_total_qng;
1527 uchar cur_total_qng; 1514 uchar cur_total_qng;
1528 uchar in_critical_cnt; 1515 uchar in_critical_cnt;
1529 uchar irq_no; 1516 uchar irq_no;
1530 uchar last_q_shortage; 1517 uchar last_q_shortage;
1531 ushort init_state; 1518 ushort init_state;
1532 uchar cur_dvc_qng[ASC_MAX_TID + 1]; 1519 uchar cur_dvc_qng[ASC_MAX_TID + 1];
1533 uchar max_dvc_qng[ASC_MAX_TID + 1]; 1520 uchar max_dvc_qng[ASC_MAX_TID + 1];
1534 ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1]; 1521 ASC_SCSI_Q *scsiq_busy_head[ASC_MAX_TID + 1];
1535 ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1]; 1522 ASC_SCSI_Q *scsiq_busy_tail[ASC_MAX_TID + 1];
1536 uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO]; 1523 uchar sdtr_period_tbl[ASC_MAX_SYN_XFER_NO];
1537 ASC_DVC_CFG *cfg; 1524 ASC_DVC_CFG *cfg;
1538 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always; 1525 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer_always;
1539 char redo_scam; 1526 char redo_scam;
1540 ushort res2; 1527 ushort res2;
1541 uchar dos_int13_table[ASC_MAX_TID + 1]; 1528 uchar dos_int13_table[ASC_MAX_TID + 1];
1542 ASC_DCNT max_dma_count; 1529 ASC_DCNT max_dma_count;
1543 ASC_SCSI_BIT_ID_TYPE no_scam; 1530 ASC_SCSI_BIT_ID_TYPE no_scam;
1544 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer; 1531 ASC_SCSI_BIT_ID_TYPE pci_fix_asyn_xfer;
1545 uchar max_sdtr_index; 1532 uchar max_sdtr_index;
1546 uchar host_init_sdtr_index; 1533 uchar host_init_sdtr_index;
1547 struct asc_board *drv_ptr; 1534 struct asc_board *drv_ptr;
1548 ASC_DCNT uc_break; 1535 ASC_DCNT uc_break;
1549} ASC_DVC_VAR; 1536} ASC_DVC_VAR;
1550 1537
1551typedef struct asc_dvc_inq_info { 1538typedef struct asc_dvc_inq_info {
1552 uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1]; 1539 uchar type[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
1553} ASC_DVC_INQ_INFO; 1540} ASC_DVC_INQ_INFO;
1554 1541
1555typedef struct asc_cap_info { 1542typedef struct asc_cap_info {
1556 ASC_DCNT lba; 1543 ASC_DCNT lba;
1557 ASC_DCNT blk_size; 1544 ASC_DCNT blk_size;
1558} ASC_CAP_INFO; 1545} ASC_CAP_INFO;
1559 1546
1560typedef struct asc_cap_info_array { 1547typedef struct asc_cap_info_array {
1561 ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1]; 1548 ASC_CAP_INFO cap_info[ASC_MAX_TID + 1][ASC_MAX_LUN + 1];
1562} ASC_CAP_INFO_ARRAY; 1549} ASC_CAP_INFO_ARRAY;
1563 1550
1564#define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001 1551#define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
@@ -1603,23 +1590,23 @@ typedef struct asc_cap_info_array {
1603 ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4) 1590 ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
1604 1591
1605typedef struct asceep_config { 1592typedef struct asceep_config {
1606 ushort cfg_lsw; 1593 ushort cfg_lsw;
1607 ushort cfg_msw; 1594 ushort cfg_msw;
1608 uchar init_sdtr; 1595 uchar init_sdtr;
1609 uchar disc_enable; 1596 uchar disc_enable;
1610 uchar use_cmd_qng; 1597 uchar use_cmd_qng;
1611 uchar start_motor; 1598 uchar start_motor;
1612 uchar max_total_qng; 1599 uchar max_total_qng;
1613 uchar max_tag_qng; 1600 uchar max_tag_qng;
1614 uchar bios_scan; 1601 uchar bios_scan;
1615 uchar power_up_wait; 1602 uchar power_up_wait;
1616 uchar no_scam; 1603 uchar no_scam;
1617 uchar id_speed; /* low order 4 bits is chip scsi id */ 1604 uchar id_speed; /* low order 4 bits is chip scsi id */
1618 /* high order 4 bits is isa dma speed */ 1605 /* high order 4 bits is isa dma speed */
1619 uchar dos_int13_table[ASC_MAX_TID + 1]; 1606 uchar dos_int13_table[ASC_MAX_TID + 1];
1620 uchar adapter_info[6]; 1607 uchar adapter_info[6];
1621 ushort cntl; 1608 ushort cntl;
1622 ushort chksum; 1609 ushort chksum;
1623} ASCEEP_CONFIG; 1610} ASCEEP_CONFIG;
1624 1611
1625#define ASC_PCI_CFG_LSW_SCSI_PARITY 0x0800 1612#define ASC_PCI_CFG_LSW_SCSI_PARITY 0x0800
@@ -1827,8 +1814,8 @@ typedef struct asceep_config {
1827#define ASC_MC_SAVE_DATA_WSIZE 0x40 1814#define ASC_MC_SAVE_DATA_WSIZE 0x40
1828 1815
1829typedef struct asc_mc_saved { 1816typedef struct asc_mc_saved {
1830 ushort data[ASC_MC_SAVE_DATA_WSIZE]; 1817 ushort data[ASC_MC_SAVE_DATA_WSIZE];
1831 ushort code[ASC_MC_SAVE_CODE_WSIZE]; 1818 ushort code[ASC_MC_SAVE_CODE_WSIZE];
1832} ASC_MC_SAVED; 1819} ASC_MC_SAVED;
1833 1820
1834#define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B) 1821#define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
@@ -1900,120 +1887,113 @@ typedef struct asc_mc_saved {
1900#define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID) 1887#define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
1901#define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data) 1888#define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
1902 1889
1903STATIC int AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg); 1890static int AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg);
1904STATIC int AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg); 1891static int AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg);
1905STATIC void AscWaitEEPRead(void); 1892static void AscWaitEEPRead(void);
1906STATIC void AscWaitEEPWrite(void); 1893static void AscWaitEEPWrite(void);
1907STATIC ushort AscReadEEPWord(PortAddr, uchar); 1894static ushort AscReadEEPWord(PortAddr, uchar);
1908STATIC ushort AscWriteEEPWord(PortAddr, uchar, ushort); 1895static ushort AscWriteEEPWord(PortAddr, uchar, ushort);
1909STATIC ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort); 1896static ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
1910STATIC int AscSetEEPConfigOnce(PortAddr, ASCEEP_CONFIG *, ushort); 1897static int AscSetEEPConfigOnce(PortAddr, ASCEEP_CONFIG *, ushort);
1911STATIC int AscSetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort); 1898static int AscSetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
1912STATIC int AscStartChip(PortAddr); 1899static int AscStartChip(PortAddr);
1913STATIC int AscStopChip(PortAddr); 1900static int AscStopChip(PortAddr);
1914STATIC void AscSetChipIH(PortAddr, ushort); 1901static void AscSetChipIH(PortAddr, ushort);
1915STATIC int AscIsChipHalted(PortAddr); 1902static int AscIsChipHalted(PortAddr);
1916STATIC void AscAckInterrupt(PortAddr); 1903static void AscAckInterrupt(PortAddr);
1917STATIC void AscDisableInterrupt(PortAddr); 1904static void AscDisableInterrupt(PortAddr);
1918STATIC void AscEnableInterrupt(PortAddr); 1905static void AscEnableInterrupt(PortAddr);
1919STATIC void AscSetBank(PortAddr, uchar); 1906static void AscSetBank(PortAddr, uchar);
1920STATIC int AscResetChipAndScsiBus(ASC_DVC_VAR *); 1907static int AscResetChipAndScsiBus(ASC_DVC_VAR *);
1921#ifdef CONFIG_ISA 1908#ifdef CONFIG_ISA
1922STATIC ushort AscGetIsaDmaChannel(PortAddr); 1909static ushort AscGetIsaDmaChannel(PortAddr);
1923STATIC ushort AscSetIsaDmaChannel(PortAddr, ushort); 1910static ushort AscSetIsaDmaChannel(PortAddr, ushort);
1924STATIC uchar AscSetIsaDmaSpeed(PortAddr, uchar); 1911static uchar AscSetIsaDmaSpeed(PortAddr, uchar);
1925STATIC uchar AscGetIsaDmaSpeed(PortAddr); 1912static uchar AscGetIsaDmaSpeed(PortAddr);
1926#endif /* CONFIG_ISA */ 1913#endif /* CONFIG_ISA */
1927STATIC uchar AscReadLramByte(PortAddr, ushort); 1914static uchar AscReadLramByte(PortAddr, ushort);
1928STATIC ushort AscReadLramWord(PortAddr, ushort); 1915static ushort AscReadLramWord(PortAddr, ushort);
1929#if CC_VERY_LONG_SG_LIST 1916#if CC_VERY_LONG_SG_LIST
1930STATIC ASC_DCNT AscReadLramDWord(PortAddr, ushort); 1917static ASC_DCNT AscReadLramDWord(PortAddr, ushort);
1931#endif /* CC_VERY_LONG_SG_LIST */ 1918#endif /* CC_VERY_LONG_SG_LIST */
1932STATIC void AscWriteLramWord(PortAddr, ushort, ushort); 1919static void AscWriteLramWord(PortAddr, ushort, ushort);
1933STATIC void AscWriteLramByte(PortAddr, ushort, uchar); 1920static void AscWriteLramByte(PortAddr, ushort, uchar);
1934STATIC ASC_DCNT AscMemSumLramWord(PortAddr, ushort, int); 1921static ASC_DCNT AscMemSumLramWord(PortAddr, ushort, int);
1935STATIC void AscMemWordSetLram(PortAddr, ushort, ushort, int); 1922static void AscMemWordSetLram(PortAddr, ushort, ushort, int);
1936STATIC void AscMemWordCopyPtrToLram(PortAddr, ushort, uchar *, int); 1923static void AscMemWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
1937STATIC void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int); 1924static void AscMemDWordCopyPtrToLram(PortAddr, ushort, uchar *, int);
1938STATIC void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int); 1925static void AscMemWordCopyPtrFromLram(PortAddr, ushort, uchar *, int);
1939STATIC ushort AscInitAscDvcVar(ASC_DVC_VAR *); 1926static ushort AscInitAscDvcVar(ASC_DVC_VAR *);
1940STATIC ushort AscInitFromEEP(ASC_DVC_VAR *); 1927static ushort AscInitFromEEP(ASC_DVC_VAR *);
1941STATIC ushort AscInitFromAscDvcVar(ASC_DVC_VAR *); 1928static ushort AscInitFromAscDvcVar(ASC_DVC_VAR *);
1942STATIC ushort AscInitMicroCodeVar(ASC_DVC_VAR *); 1929static ushort AscInitMicroCodeVar(ASC_DVC_VAR *);
1943STATIC int AscTestExternalLram(ASC_DVC_VAR *); 1930static int AscTestExternalLram(ASC_DVC_VAR *);
1944STATIC uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar); 1931static uchar AscMsgOutSDTR(ASC_DVC_VAR *, uchar, uchar);
1945STATIC uchar AscCalSDTRData(ASC_DVC_VAR *, uchar, uchar); 1932static uchar AscCalSDTRData(ASC_DVC_VAR *, uchar, uchar);
1946STATIC void AscSetChipSDTR(PortAddr, uchar, uchar); 1933static void AscSetChipSDTR(PortAddr, uchar, uchar);
1947STATIC uchar AscGetSynPeriodIndex(ASC_DVC_VAR *, uchar); 1934static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *, uchar);
1948STATIC uchar AscAllocFreeQueue(PortAddr, uchar); 1935static uchar AscAllocFreeQueue(PortAddr, uchar);
1949STATIC uchar AscAllocMultipleFreeQueue(PortAddr, uchar, uchar); 1936static uchar AscAllocMultipleFreeQueue(PortAddr, uchar, uchar);
1950STATIC int AscHostReqRiscHalt(PortAddr); 1937static int AscHostReqRiscHalt(PortAddr);
1951STATIC int AscStopQueueExe(PortAddr); 1938static int AscStopQueueExe(PortAddr);
1952STATIC int AscSendScsiQueue(ASC_DVC_VAR *, 1939static int AscSendScsiQueue(ASC_DVC_VAR *,
1953 ASC_SCSI_Q * scsiq, 1940 ASC_SCSI_Q *scsiq, uchar n_q_required);
1954 uchar n_q_required); 1941static int AscPutReadyQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
1955STATIC int AscPutReadyQueue(ASC_DVC_VAR *, 1942static int AscPutReadySgListQueue(ASC_DVC_VAR *, ASC_SCSI_Q *, uchar);
1956 ASC_SCSI_Q *, uchar); 1943static int AscSetChipSynRegAtID(PortAddr, uchar, uchar);
1957STATIC int AscPutReadySgListQueue(ASC_DVC_VAR *, 1944static int AscSetRunChipSynRegAtID(PortAddr, uchar, uchar);
1958 ASC_SCSI_Q *, uchar); 1945static ushort AscInitLram(ASC_DVC_VAR *);
1959STATIC int AscSetChipSynRegAtID(PortAddr, uchar, uchar); 1946static ushort AscInitQLinkVar(ASC_DVC_VAR *);
1960STATIC int AscSetRunChipSynRegAtID(PortAddr, uchar, uchar); 1947static int AscSetLibErrorCode(ASC_DVC_VAR *, ushort);
1961STATIC ushort AscInitLram(ASC_DVC_VAR *); 1948static int AscIsrChipHalted(ASC_DVC_VAR *);
1962STATIC ushort AscInitQLinkVar(ASC_DVC_VAR *); 1949static uchar _AscCopyLramScsiDoneQ(PortAddr, ushort,
1963STATIC int AscSetLibErrorCode(ASC_DVC_VAR *, ushort); 1950 ASC_QDONE_INFO *, ASC_DCNT);
1964STATIC int AscIsrChipHalted(ASC_DVC_VAR *); 1951static int AscIsrQDone(ASC_DVC_VAR *);
1965STATIC uchar _AscCopyLramScsiDoneQ(PortAddr, ushort, 1952static int AscCompareString(uchar *, uchar *, int);
1966 ASC_QDONE_INFO *, ASC_DCNT);
1967STATIC int AscIsrQDone(ASC_DVC_VAR *);
1968STATIC int AscCompareString(uchar *, uchar *, int);
1969#ifdef CONFIG_ISA 1953#ifdef CONFIG_ISA
1970STATIC ushort AscGetEisaChipCfg(PortAddr); 1954static ushort AscGetEisaChipCfg(PortAddr);
1971STATIC ASC_DCNT AscGetEisaProductID(PortAddr); 1955static ASC_DCNT AscGetEisaProductID(PortAddr);
1972STATIC PortAddr AscSearchIOPortAddrEISA(PortAddr); 1956static PortAddr AscSearchIOPortAddrEISA(PortAddr);
1973STATIC PortAddr AscSearchIOPortAddr11(PortAddr); 1957static PortAddr AscSearchIOPortAddr11(PortAddr);
1974STATIC PortAddr AscSearchIOPortAddr(PortAddr, ushort); 1958static PortAddr AscSearchIOPortAddr(PortAddr, ushort);
1975STATIC void AscSetISAPNPWaitForKey(void); 1959static void AscSetISAPNPWaitForKey(void);
1976#endif /* CONFIG_ISA */ 1960#endif /* CONFIG_ISA */
1977STATIC uchar AscGetChipScsiCtrl(PortAddr); 1961static uchar AscGetChipScsiCtrl(PortAddr);
1978STATIC uchar AscSetChipScsiID(PortAddr, uchar); 1962static uchar AscSetChipScsiID(PortAddr, uchar);
1979STATIC uchar AscGetChipVersion(PortAddr, ushort); 1963static uchar AscGetChipVersion(PortAddr, ushort);
1980STATIC ushort AscGetChipBusType(PortAddr); 1964static ushort AscGetChipBusType(PortAddr);
1981STATIC ASC_DCNT AscLoadMicroCode(PortAddr, ushort, uchar *, ushort); 1965static ASC_DCNT AscLoadMicroCode(PortAddr, ushort, uchar *, ushort);
1982STATIC int AscFindSignature(PortAddr); 1966static int AscFindSignature(PortAddr);
1983STATIC void AscToggleIRQAct(PortAddr); 1967static void AscToggleIRQAct(PortAddr);
1984STATIC uchar AscGetChipIRQ(PortAddr, ushort); 1968static uchar AscGetChipIRQ(PortAddr, ushort);
1985STATIC uchar AscSetChipIRQ(PortAddr, uchar, ushort); 1969static uchar AscSetChipIRQ(PortAddr, uchar, ushort);
1986STATIC ushort AscGetChipBiosAddress(PortAddr, ushort); 1970static ushort AscGetChipBiosAddress(PortAddr, ushort);
1987STATIC inline ulong DvcEnterCritical(void); 1971static inline ulong DvcEnterCritical(void);
1988STATIC inline void DvcLeaveCritical(ulong); 1972static inline void DvcLeaveCritical(ulong);
1989#ifdef CONFIG_PCI 1973#ifdef CONFIG_PCI
1990STATIC uchar DvcReadPCIConfigByte(ASC_DVC_VAR *, ushort); 1974static uchar DvcReadPCIConfigByte(ASC_DVC_VAR *, ushort);
1991STATIC void DvcWritePCIConfigByte(ASC_DVC_VAR *, 1975static void DvcWritePCIConfigByte(ASC_DVC_VAR *, ushort, uchar);
1992 ushort, uchar);
1993#endif /* CONFIG_PCI */ 1976#endif /* CONFIG_PCI */
1994STATIC ushort AscGetChipBiosAddress(PortAddr, ushort); 1977static ushort AscGetChipBiosAddress(PortAddr, ushort);
1995STATIC void DvcSleepMilliSecond(ASC_DCNT); 1978static void DvcSleepMilliSecond(ASC_DCNT);
1996STATIC void DvcDelayNanoSecond(ASC_DVC_VAR *, ASC_DCNT); 1979static void DvcDelayNanoSecond(ASC_DVC_VAR *, ASC_DCNT);
1997STATIC void DvcPutScsiQ(PortAddr, ushort, uchar *, int); 1980static void DvcPutScsiQ(PortAddr, ushort, uchar *, int);
1998STATIC void DvcGetQinfo(PortAddr, ushort, uchar *, int); 1981static void DvcGetQinfo(PortAddr, ushort, uchar *, int);
1999STATIC ushort AscInitGetConfig(ASC_DVC_VAR *); 1982static ushort AscInitGetConfig(ASC_DVC_VAR *);
2000STATIC ushort AscInitSetConfig(ASC_DVC_VAR *); 1983static ushort AscInitSetConfig(ASC_DVC_VAR *);
2001STATIC ushort AscInitAsc1000Driver(ASC_DVC_VAR *); 1984static ushort AscInitAsc1000Driver(ASC_DVC_VAR *);
2002STATIC void AscAsyncFix(ASC_DVC_VAR *, uchar, 1985static void AscAsyncFix(ASC_DVC_VAR *, uchar, ASC_SCSI_INQUIRY *);
2003 ASC_SCSI_INQUIRY *); 1986static int AscTagQueuingSafe(ASC_SCSI_INQUIRY *);
2004STATIC int AscTagQueuingSafe(ASC_SCSI_INQUIRY *); 1987static void AscInquiryHandling(ASC_DVC_VAR *, uchar, ASC_SCSI_INQUIRY *);
2005STATIC void AscInquiryHandling(ASC_DVC_VAR *, 1988static int AscExeScsiQueue(ASC_DVC_VAR *, ASC_SCSI_Q *);
2006 uchar, ASC_SCSI_INQUIRY *); 1989static int AscISR(ASC_DVC_VAR *);
2007STATIC int AscExeScsiQueue(ASC_DVC_VAR *, ASC_SCSI_Q *); 1990static uint AscGetNumOfFreeQueue(ASC_DVC_VAR *, uchar, uchar);
2008STATIC int AscISR(ASC_DVC_VAR *); 1991static int AscSgListToQueue(int);
2009STATIC uint AscGetNumOfFreeQueue(ASC_DVC_VAR *, uchar,
2010 uchar);
2011STATIC int AscSgListToQueue(int);
2012#ifdef CONFIG_ISA 1992#ifdef CONFIG_ISA
2013STATIC void AscEnableIsaDma(uchar); 1993static void AscEnableIsaDma(uchar);
2014#endif /* CONFIG_ISA */ 1994#endif /* CONFIG_ISA */
2015STATIC ASC_DCNT AscGetMaxDmaCount(ushort); 1995static ASC_DCNT AscGetMaxDmaCount(ushort);
2016static const char *advansys_info(struct Scsi_Host *shp); 1996static const char *advansys_info(struct Scsi_Host *shost);
2017 1997
2018/* 1998/*
2019 * --- Adv Library Constants and Macros 1999 * --- Adv Library Constants and Macros
@@ -2035,10 +2015,10 @@ static const char *advansys_info(struct Scsi_Host *shp);
2035 * are all consistent at 8, 16, and 32 bits respectively. Pointers 2015 * are all consistent at 8, 16, and 32 bits respectively. Pointers
2036 * and long types are 64 bits on Alpha and UltraSPARC. 2016 * and long types are 64 bits on Alpha and UltraSPARC.
2037 */ 2017 */
2038#define ADV_PADDR __u32 /* Physical address data type. */ 2018#define ADV_PADDR __u32 /* Physical address data type. */
2039#define ADV_VADDR __u32 /* Virtual address data type. */ 2019#define ADV_VADDR __u32 /* Virtual address data type. */
2040#define ADV_DCNT __u32 /* Unsigned Data count type. */ 2020#define ADV_DCNT __u32 /* Unsigned Data count type. */
2041#define ADV_SDCNT __s32 /* Signed Data count type. */ 2021#define ADV_SDCNT __s32 /* Signed Data count type. */
2042 2022
2043/* 2023/*
2044 * These macros are used to convert a virtual address to a 2024 * These macros are used to convert a virtual address to a
@@ -2051,7 +2031,7 @@ static const char *advansys_info(struct Scsi_Host *shp);
2051#define ADV_VADDR_TO_U32 virt_to_bus 2031#define ADV_VADDR_TO_U32 virt_to_bus
2052#define ADV_U32_TO_VADDR bus_to_virt 2032#define ADV_U32_TO_VADDR bus_to_virt
2053 2033
2054#define AdvPortAddr void __iomem * /* Virtual memory address size */ 2034#define AdvPortAddr void __iomem * /* Virtual memory address size */
2055 2035
2056/* 2036/*
2057 * Define Adv Library required memory access macros. 2037 * Define Adv Library required memory access macros.
@@ -2103,20 +2083,20 @@ static const char *advansys_info(struct Scsi_Host *shp);
2103 2083
2104#define ADV_EEP_DVC_CFG_BEGIN (0x00) 2084#define ADV_EEP_DVC_CFG_BEGIN (0x00)
2105#define ADV_EEP_DVC_CFG_END (0x15) 2085#define ADV_EEP_DVC_CFG_END (0x15)
2106#define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */ 2086#define ADV_EEP_DVC_CTL_BEGIN (0x16) /* location of OEM name */
2107#define ADV_EEP_MAX_WORD_ADDR (0x1E) 2087#define ADV_EEP_MAX_WORD_ADDR (0x1E)
2108 2088
2109#define ADV_EEP_DELAY_MS 100 2089#define ADV_EEP_DELAY_MS 100
2110 2090
2111#define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */ 2091#define ADV_EEPROM_BIG_ENDIAN 0x8000 /* EEPROM Bit 15 */
2112#define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */ 2092#define ADV_EEPROM_BIOS_ENABLE 0x4000 /* EEPROM Bit 14 */
2113/* 2093/*
2114 * For the ASC3550 Bit 13 is Termination Polarity control bit. 2094 * For the ASC3550 Bit 13 is Termination Polarity control bit.
2115 * For later ICs Bit 13 controls whether the CIS (Card Information 2095 * For later ICs Bit 13 controls whether the CIS (Card Information
2116 * Service Section) is loaded from EEPROM. 2096 * Service Section) is loaded from EEPROM.
2117 */ 2097 */
2118#define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */ 2098#define ADV_EEPROM_TERM_POL 0x2000 /* EEPROM Bit 13 */
2119#define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */ 2099#define ADV_EEPROM_CIS_LD 0x2000 /* EEPROM Bit 13 */
2120/* 2100/*
2121 * ASC38C1600 Bit 11 2101 * ASC38C1600 Bit 11
2122 * 2102 *
@@ -2128,280 +2108,277 @@ static const char *advansys_info(struct Scsi_Host *shp);
2128 * INT B in the PCI Configuration Space Int Pin field. If it is 1, then 2108 * INT B in the PCI Configuration Space Int Pin field. If it is 1, then
2129 * Function 1 will specify INT A. 2109 * Function 1 will specify INT A.
2130 */ 2110 */
2131#define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */ 2111#define ADV_EEPROM_INTAB 0x0800 /* EEPROM Bit 11 */
2132 2112
2133typedef struct adveep_3550_config 2113typedef struct adveep_3550_config {
2134{ 2114 /* Word Offset, Description */
2135 /* Word Offset, Description */ 2115
2136 2116 ushort cfg_lsw; /* 00 power up initialization */
2137 ushort cfg_lsw; /* 00 power up initialization */ 2117 /* bit 13 set - Term Polarity Control */
2138 /* bit 13 set - Term Polarity Control */ 2118 /* bit 14 set - BIOS Enable */
2139 /* bit 14 set - BIOS Enable */ 2119 /* bit 15 set - Big Endian Mode */
2140 /* bit 15 set - Big Endian Mode */ 2120 ushort cfg_msw; /* 01 unused */
2141 ushort cfg_msw; /* 01 unused */ 2121 ushort disc_enable; /* 02 disconnect enable */
2142 ushort disc_enable; /* 02 disconnect enable */ 2122 ushort wdtr_able; /* 03 Wide DTR able */
2143 ushort wdtr_able; /* 03 Wide DTR able */ 2123 ushort sdtr_able; /* 04 Synchronous DTR able */
2144 ushort sdtr_able; /* 04 Synchronous DTR able */ 2124 ushort start_motor; /* 05 send start up motor */
2145 ushort start_motor; /* 05 send start up motor */ 2125 ushort tagqng_able; /* 06 tag queuing able */
2146 ushort tagqng_able; /* 06 tag queuing able */ 2126 ushort bios_scan; /* 07 BIOS device control */
2147 ushort bios_scan; /* 07 BIOS device control */ 2127 ushort scam_tolerant; /* 08 no scam */
2148 ushort scam_tolerant; /* 08 no scam */ 2128
2149 2129 uchar adapter_scsi_id; /* 09 Host Adapter ID */
2150 uchar adapter_scsi_id; /* 09 Host Adapter ID */ 2130 uchar bios_boot_delay; /* power up wait */
2151 uchar bios_boot_delay; /* power up wait */ 2131
2152 2132 uchar scsi_reset_delay; /* 10 reset delay */
2153 uchar scsi_reset_delay; /* 10 reset delay */ 2133 uchar bios_id_lun; /* first boot device scsi id & lun */
2154 uchar bios_id_lun; /* first boot device scsi id & lun */ 2134 /* high nibble is lun */
2155 /* high nibble is lun */ 2135 /* low nibble is scsi id */
2156 /* low nibble is scsi id */ 2136
2157 2137 uchar termination; /* 11 0 - automatic */
2158 uchar termination; /* 11 0 - automatic */ 2138 /* 1 - low off / high off */
2159 /* 1 - low off / high off */ 2139 /* 2 - low off / high on */
2160 /* 2 - low off / high on */ 2140 /* 3 - low on / high on */
2161 /* 3 - low on / high on */ 2141 /* There is no low on / high off */
2162 /* There is no low on / high off */ 2142
2163 2143 uchar reserved1; /* reserved byte (not used) */
2164 uchar reserved1; /* reserved byte (not used) */ 2144
2165 2145 ushort bios_ctrl; /* 12 BIOS control bits */
2166 ushort bios_ctrl; /* 12 BIOS control bits */ 2146 /* bit 0 BIOS don't act as initiator. */
2167 /* bit 0 BIOS don't act as initiator. */ 2147 /* bit 1 BIOS > 1 GB support */
2168 /* bit 1 BIOS > 1 GB support */ 2148 /* bit 2 BIOS > 2 Disk Support */
2169 /* bit 2 BIOS > 2 Disk Support */ 2149 /* bit 3 BIOS don't support removables */
2170 /* bit 3 BIOS don't support removables */ 2150 /* bit 4 BIOS support bootable CD */
2171 /* bit 4 BIOS support bootable CD */ 2151 /* bit 5 BIOS scan enabled */
2172 /* bit 5 BIOS scan enabled */ 2152 /* bit 6 BIOS support multiple LUNs */
2173 /* bit 6 BIOS support multiple LUNs */ 2153 /* bit 7 BIOS display of message */
2174 /* bit 7 BIOS display of message */ 2154 /* bit 8 SCAM disabled */
2175 /* bit 8 SCAM disabled */ 2155 /* bit 9 Reset SCSI bus during init. */
2176 /* bit 9 Reset SCSI bus during init. */ 2156 /* bit 10 */
2177 /* bit 10 */ 2157 /* bit 11 No verbose initialization. */
2178 /* bit 11 No verbose initialization. */ 2158 /* bit 12 SCSI parity enabled */
2179 /* bit 12 SCSI parity enabled */ 2159 /* bit 13 */
2180 /* bit 13 */ 2160 /* bit 14 */
2181 /* bit 14 */ 2161 /* bit 15 */
2182 /* bit 15 */ 2162 ushort ultra_able; /* 13 ULTRA speed able */
2183 ushort ultra_able; /* 13 ULTRA speed able */ 2163 ushort reserved2; /* 14 reserved */
2184 ushort reserved2; /* 14 reserved */ 2164 uchar max_host_qng; /* 15 maximum host queuing */
2185 uchar max_host_qng; /* 15 maximum host queuing */ 2165 uchar max_dvc_qng; /* maximum per device queuing */
2186 uchar max_dvc_qng; /* maximum per device queuing */ 2166 ushort dvc_cntl; /* 16 control bit for driver */
2187 ushort dvc_cntl; /* 16 control bit for driver */ 2167 ushort bug_fix; /* 17 control bit for bug fix */
2188 ushort bug_fix; /* 17 control bit for bug fix */ 2168 ushort serial_number_word1; /* 18 Board serial number word 1 */
2189 ushort serial_number_word1; /* 18 Board serial number word 1 */ 2169 ushort serial_number_word2; /* 19 Board serial number word 2 */
2190 ushort serial_number_word2; /* 19 Board serial number word 2 */ 2170 ushort serial_number_word3; /* 20 Board serial number word 3 */
2191 ushort serial_number_word3; /* 20 Board serial number word 3 */ 2171 ushort check_sum; /* 21 EEP check sum */
2192 ushort check_sum; /* 21 EEP check sum */ 2172 uchar oem_name[16]; /* 22 OEM name */
2193 uchar oem_name[16]; /* 22 OEM name */ 2173 ushort dvc_err_code; /* 30 last device driver error code */
2194 ushort dvc_err_code; /* 30 last device driver error code */ 2174 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
2195 ushort adv_err_code; /* 31 last uc and Adv Lib error code */ 2175 ushort adv_err_addr; /* 32 last uc error address */
2196 ushort adv_err_addr; /* 32 last uc error address */ 2176 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
2197 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */ 2177 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
2198 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */ 2178 ushort saved_adv_err_addr; /* 35 saved last uc error address */
2199 ushort saved_adv_err_addr; /* 35 saved last uc error address */ 2179 ushort num_of_err; /* 36 number of error */
2200 ushort num_of_err; /* 36 number of error */
2201} ADVEEP_3550_CONFIG; 2180} ADVEEP_3550_CONFIG;
2202 2181
2203typedef struct adveep_38C0800_config 2182typedef struct adveep_38C0800_config {
2204{ 2183 /* Word Offset, Description */
2205 /* Word Offset, Description */ 2184
2206 2185 ushort cfg_lsw; /* 00 power up initialization */
2207 ushort cfg_lsw; /* 00 power up initialization */ 2186 /* bit 13 set - Load CIS */
2208 /* bit 13 set - Load CIS */ 2187 /* bit 14 set - BIOS Enable */
2209 /* bit 14 set - BIOS Enable */ 2188 /* bit 15 set - Big Endian Mode */
2210 /* bit 15 set - Big Endian Mode */ 2189 ushort cfg_msw; /* 01 unused */
2211 ushort cfg_msw; /* 01 unused */ 2190 ushort disc_enable; /* 02 disconnect enable */
2212 ushort disc_enable; /* 02 disconnect enable */ 2191 ushort wdtr_able; /* 03 Wide DTR able */
2213 ushort wdtr_able; /* 03 Wide DTR able */ 2192 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
2214 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */ 2193 ushort start_motor; /* 05 send start up motor */
2215 ushort start_motor; /* 05 send start up motor */ 2194 ushort tagqng_able; /* 06 tag queuing able */
2216 ushort tagqng_able; /* 06 tag queuing able */ 2195 ushort bios_scan; /* 07 BIOS device control */
2217 ushort bios_scan; /* 07 BIOS device control */ 2196 ushort scam_tolerant; /* 08 no scam */
2218 ushort scam_tolerant; /* 08 no scam */ 2197
2219 2198 uchar adapter_scsi_id; /* 09 Host Adapter ID */
2220 uchar adapter_scsi_id; /* 09 Host Adapter ID */ 2199 uchar bios_boot_delay; /* power up wait */
2221 uchar bios_boot_delay; /* power up wait */ 2200
2222 2201 uchar scsi_reset_delay; /* 10 reset delay */
2223 uchar scsi_reset_delay; /* 10 reset delay */ 2202 uchar bios_id_lun; /* first boot device scsi id & lun */
2224 uchar bios_id_lun; /* first boot device scsi id & lun */ 2203 /* high nibble is lun */
2225 /* high nibble is lun */ 2204 /* low nibble is scsi id */
2226 /* low nibble is scsi id */ 2205
2227 2206 uchar termination_se; /* 11 0 - automatic */
2228 uchar termination_se; /* 11 0 - automatic */ 2207 /* 1 - low off / high off */
2229 /* 1 - low off / high off */ 2208 /* 2 - low off / high on */
2230 /* 2 - low off / high on */ 2209 /* 3 - low on / high on */
2231 /* 3 - low on / high on */ 2210 /* There is no low on / high off */
2232 /* There is no low on / high off */ 2211
2233 2212 uchar termination_lvd; /* 11 0 - automatic */
2234 uchar termination_lvd; /* 11 0 - automatic */ 2213 /* 1 - low off / high off */
2235 /* 1 - low off / high off */ 2214 /* 2 - low off / high on */
2236 /* 2 - low off / high on */ 2215 /* 3 - low on / high on */
2237 /* 3 - low on / high on */ 2216 /* There is no low on / high off */
2238 /* There is no low on / high off */ 2217
2239 2218 ushort bios_ctrl; /* 12 BIOS control bits */
2240 ushort bios_ctrl; /* 12 BIOS control bits */ 2219 /* bit 0 BIOS don't act as initiator. */
2241 /* bit 0 BIOS don't act as initiator. */ 2220 /* bit 1 BIOS > 1 GB support */
2242 /* bit 1 BIOS > 1 GB support */ 2221 /* bit 2 BIOS > 2 Disk Support */
2243 /* bit 2 BIOS > 2 Disk Support */ 2222 /* bit 3 BIOS don't support removables */
2244 /* bit 3 BIOS don't support removables */ 2223 /* bit 4 BIOS support bootable CD */
2245 /* bit 4 BIOS support bootable CD */ 2224 /* bit 5 BIOS scan enabled */
2246 /* bit 5 BIOS scan enabled */ 2225 /* bit 6 BIOS support multiple LUNs */
2247 /* bit 6 BIOS support multiple LUNs */ 2226 /* bit 7 BIOS display of message */
2248 /* bit 7 BIOS display of message */ 2227 /* bit 8 SCAM disabled */
2249 /* bit 8 SCAM disabled */ 2228 /* bit 9 Reset SCSI bus during init. */
2250 /* bit 9 Reset SCSI bus during init. */ 2229 /* bit 10 */
2251 /* bit 10 */ 2230 /* bit 11 No verbose initialization. */
2252 /* bit 11 No verbose initialization. */ 2231 /* bit 12 SCSI parity enabled */
2253 /* bit 12 SCSI parity enabled */ 2232 /* bit 13 */
2254 /* bit 13 */ 2233 /* bit 14 */
2255 /* bit 14 */ 2234 /* bit 15 */
2256 /* bit 15 */ 2235 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
2257 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */ 2236 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
2258 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */ 2237 uchar max_host_qng; /* 15 maximum host queueing */
2259 uchar max_host_qng; /* 15 maximum host queueing */ 2238 uchar max_dvc_qng; /* maximum per device queuing */
2260 uchar max_dvc_qng; /* maximum per device queuing */ 2239 ushort dvc_cntl; /* 16 control bit for driver */
2261 ushort dvc_cntl; /* 16 control bit for driver */ 2240 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
2262 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */ 2241 ushort serial_number_word1; /* 18 Board serial number word 1 */
2263 ushort serial_number_word1; /* 18 Board serial number word 1 */ 2242 ushort serial_number_word2; /* 19 Board serial number word 2 */
2264 ushort serial_number_word2; /* 19 Board serial number word 2 */ 2243 ushort serial_number_word3; /* 20 Board serial number word 3 */
2265 ushort serial_number_word3; /* 20 Board serial number word 3 */ 2244 ushort check_sum; /* 21 EEP check sum */
2266 ushort check_sum; /* 21 EEP check sum */ 2245 uchar oem_name[16]; /* 22 OEM name */
2267 uchar oem_name[16]; /* 22 OEM name */ 2246 ushort dvc_err_code; /* 30 last device driver error code */
2268 ushort dvc_err_code; /* 30 last device driver error code */ 2247 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
2269 ushort adv_err_code; /* 31 last uc and Adv Lib error code */ 2248 ushort adv_err_addr; /* 32 last uc error address */
2270 ushort adv_err_addr; /* 32 last uc error address */ 2249 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
2271 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */ 2250 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
2272 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */ 2251 ushort saved_adv_err_addr; /* 35 saved last uc error address */
2273 ushort saved_adv_err_addr; /* 35 saved last uc error address */ 2252 ushort reserved36; /* 36 reserved */
2274 ushort reserved36; /* 36 reserved */ 2253 ushort reserved37; /* 37 reserved */
2275 ushort reserved37; /* 37 reserved */ 2254 ushort reserved38; /* 38 reserved */
2276 ushort reserved38; /* 38 reserved */ 2255 ushort reserved39; /* 39 reserved */
2277 ushort reserved39; /* 39 reserved */ 2256 ushort reserved40; /* 40 reserved */
2278 ushort reserved40; /* 40 reserved */ 2257 ushort reserved41; /* 41 reserved */
2279 ushort reserved41; /* 41 reserved */ 2258 ushort reserved42; /* 42 reserved */
2280 ushort reserved42; /* 42 reserved */ 2259 ushort reserved43; /* 43 reserved */
2281 ushort reserved43; /* 43 reserved */ 2260 ushort reserved44; /* 44 reserved */
2282 ushort reserved44; /* 44 reserved */ 2261 ushort reserved45; /* 45 reserved */
2283 ushort reserved45; /* 45 reserved */ 2262 ushort reserved46; /* 46 reserved */
2284 ushort reserved46; /* 46 reserved */ 2263 ushort reserved47; /* 47 reserved */
2285 ushort reserved47; /* 47 reserved */ 2264 ushort reserved48; /* 48 reserved */
2286 ushort reserved48; /* 48 reserved */ 2265 ushort reserved49; /* 49 reserved */
2287 ushort reserved49; /* 49 reserved */ 2266 ushort reserved50; /* 50 reserved */
2288 ushort reserved50; /* 50 reserved */ 2267 ushort reserved51; /* 51 reserved */
2289 ushort reserved51; /* 51 reserved */ 2268 ushort reserved52; /* 52 reserved */
2290 ushort reserved52; /* 52 reserved */ 2269 ushort reserved53; /* 53 reserved */
2291 ushort reserved53; /* 53 reserved */ 2270 ushort reserved54; /* 54 reserved */
2292 ushort reserved54; /* 54 reserved */ 2271 ushort reserved55; /* 55 reserved */
2293 ushort reserved55; /* 55 reserved */ 2272 ushort cisptr_lsw; /* 56 CIS PTR LSW */
2294 ushort cisptr_lsw; /* 56 CIS PTR LSW */ 2273 ushort cisprt_msw; /* 57 CIS PTR MSW */
2295 ushort cisprt_msw; /* 57 CIS PTR MSW */ 2274 ushort subsysvid; /* 58 SubSystem Vendor ID */
2296 ushort subsysvid; /* 58 SubSystem Vendor ID */ 2275 ushort subsysid; /* 59 SubSystem ID */
2297 ushort subsysid; /* 59 SubSystem ID */ 2276 ushort reserved60; /* 60 reserved */
2298 ushort reserved60; /* 60 reserved */ 2277 ushort reserved61; /* 61 reserved */
2299 ushort reserved61; /* 61 reserved */ 2278 ushort reserved62; /* 62 reserved */
2300 ushort reserved62; /* 62 reserved */ 2279 ushort reserved63; /* 63 reserved */
2301 ushort reserved63; /* 63 reserved */
2302} ADVEEP_38C0800_CONFIG; 2280} ADVEEP_38C0800_CONFIG;
2303 2281
2304typedef struct adveep_38C1600_config 2282typedef struct adveep_38C1600_config {
2305{ 2283 /* Word Offset, Description */
2306 /* Word Offset, Description */ 2284
2307 2285 ushort cfg_lsw; /* 00 power up initialization */
2308 ushort cfg_lsw; /* 00 power up initialization */ 2286 /* bit 11 set - Func. 0 INTB, Func. 1 INTA */
2309 /* bit 11 set - Func. 0 INTB, Func. 1 INTA */ 2287 /* clear - Func. 0 INTA, Func. 1 INTB */
2310 /* clear - Func. 0 INTA, Func. 1 INTB */ 2288 /* bit 13 set - Load CIS */
2311 /* bit 13 set - Load CIS */ 2289 /* bit 14 set - BIOS Enable */
2312 /* bit 14 set - BIOS Enable */ 2290 /* bit 15 set - Big Endian Mode */
2313 /* bit 15 set - Big Endian Mode */ 2291 ushort cfg_msw; /* 01 unused */
2314 ushort cfg_msw; /* 01 unused */ 2292 ushort disc_enable; /* 02 disconnect enable */
2315 ushort disc_enable; /* 02 disconnect enable */ 2293 ushort wdtr_able; /* 03 Wide DTR able */
2316 ushort wdtr_able; /* 03 Wide DTR able */ 2294 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */
2317 ushort sdtr_speed1; /* 04 SDTR Speed TID 0-3 */ 2295 ushort start_motor; /* 05 send start up motor */
2318 ushort start_motor; /* 05 send start up motor */ 2296 ushort tagqng_able; /* 06 tag queuing able */
2319 ushort tagqng_able; /* 06 tag queuing able */ 2297 ushort bios_scan; /* 07 BIOS device control */
2320 ushort bios_scan; /* 07 BIOS device control */ 2298 ushort scam_tolerant; /* 08 no scam */
2321 ushort scam_tolerant; /* 08 no scam */ 2299
2322 2300 uchar adapter_scsi_id; /* 09 Host Adapter ID */
2323 uchar adapter_scsi_id; /* 09 Host Adapter ID */ 2301 uchar bios_boot_delay; /* power up wait */
2324 uchar bios_boot_delay; /* power up wait */ 2302
2325 2303 uchar scsi_reset_delay; /* 10 reset delay */
2326 uchar scsi_reset_delay; /* 10 reset delay */ 2304 uchar bios_id_lun; /* first boot device scsi id & lun */
2327 uchar bios_id_lun; /* first boot device scsi id & lun */ 2305 /* high nibble is lun */
2328 /* high nibble is lun */ 2306 /* low nibble is scsi id */
2329 /* low nibble is scsi id */ 2307
2330 2308 uchar termination_se; /* 11 0 - automatic */
2331 uchar termination_se; /* 11 0 - automatic */ 2309 /* 1 - low off / high off */
2332 /* 1 - low off / high off */ 2310 /* 2 - low off / high on */
2333 /* 2 - low off / high on */ 2311 /* 3 - low on / high on */
2334 /* 3 - low on / high on */ 2312 /* There is no low on / high off */
2335 /* There is no low on / high off */ 2313
2336 2314 uchar termination_lvd; /* 11 0 - automatic */
2337 uchar termination_lvd; /* 11 0 - automatic */ 2315 /* 1 - low off / high off */
2338 /* 1 - low off / high off */ 2316 /* 2 - low off / high on */
2339 /* 2 - low off / high on */ 2317 /* 3 - low on / high on */
2340 /* 3 - low on / high on */ 2318 /* There is no low on / high off */
2341 /* There is no low on / high off */ 2319
2342 2320 ushort bios_ctrl; /* 12 BIOS control bits */
2343 ushort bios_ctrl; /* 12 BIOS control bits */ 2321 /* bit 0 BIOS don't act as initiator. */
2344 /* bit 0 BIOS don't act as initiator. */ 2322 /* bit 1 BIOS > 1 GB support */
2345 /* bit 1 BIOS > 1 GB support */ 2323 /* bit 2 BIOS > 2 Disk Support */
2346 /* bit 2 BIOS > 2 Disk Support */ 2324 /* bit 3 BIOS don't support removables */
2347 /* bit 3 BIOS don't support removables */ 2325 /* bit 4 BIOS support bootable CD */
2348 /* bit 4 BIOS support bootable CD */ 2326 /* bit 5 BIOS scan enabled */
2349 /* bit 5 BIOS scan enabled */ 2327 /* bit 6 BIOS support multiple LUNs */
2350 /* bit 6 BIOS support multiple LUNs */ 2328 /* bit 7 BIOS display of message */
2351 /* bit 7 BIOS display of message */ 2329 /* bit 8 SCAM disabled */
2352 /* bit 8 SCAM disabled */ 2330 /* bit 9 Reset SCSI bus during init. */
2353 /* bit 9 Reset SCSI bus during init. */ 2331 /* bit 10 Basic Integrity Checking disabled */
2354 /* bit 10 Basic Integrity Checking disabled */ 2332 /* bit 11 No verbose initialization. */
2355 /* bit 11 No verbose initialization. */ 2333 /* bit 12 SCSI parity enabled */
2356 /* bit 12 SCSI parity enabled */ 2334 /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */
2357 /* bit 13 AIPP (Asyn. Info. Ph. Prot.) dis. */ 2335 /* bit 14 */
2358 /* bit 14 */ 2336 /* bit 15 */
2359 /* bit 15 */ 2337 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */
2360 ushort sdtr_speed2; /* 13 SDTR speed TID 4-7 */ 2338 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */
2361 ushort sdtr_speed3; /* 14 SDTR speed TID 8-11 */ 2339 uchar max_host_qng; /* 15 maximum host queueing */
2362 uchar max_host_qng; /* 15 maximum host queueing */ 2340 uchar max_dvc_qng; /* maximum per device queuing */
2363 uchar max_dvc_qng; /* maximum per device queuing */ 2341 ushort dvc_cntl; /* 16 control bit for driver */
2364 ushort dvc_cntl; /* 16 control bit for driver */ 2342 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */
2365 ushort sdtr_speed4; /* 17 SDTR speed 4 TID 12-15 */ 2343 ushort serial_number_word1; /* 18 Board serial number word 1 */
2366 ushort serial_number_word1; /* 18 Board serial number word 1 */ 2344 ushort serial_number_word2; /* 19 Board serial number word 2 */
2367 ushort serial_number_word2; /* 19 Board serial number word 2 */ 2345 ushort serial_number_word3; /* 20 Board serial number word 3 */
2368 ushort serial_number_word3; /* 20 Board serial number word 3 */ 2346 ushort check_sum; /* 21 EEP check sum */
2369 ushort check_sum; /* 21 EEP check sum */ 2347 uchar oem_name[16]; /* 22 OEM name */
2370 uchar oem_name[16]; /* 22 OEM name */ 2348 ushort dvc_err_code; /* 30 last device driver error code */
2371 ushort dvc_err_code; /* 30 last device driver error code */ 2349 ushort adv_err_code; /* 31 last uc and Adv Lib error code */
2372 ushort adv_err_code; /* 31 last uc and Adv Lib error code */ 2350 ushort adv_err_addr; /* 32 last uc error address */
2373 ushort adv_err_addr; /* 32 last uc error address */ 2351 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */
2374 ushort saved_dvc_err_code; /* 33 saved last dev. driver error code */ 2352 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */
2375 ushort saved_adv_err_code; /* 34 saved last uc and Adv Lib error code */ 2353 ushort saved_adv_err_addr; /* 35 saved last uc error address */
2376 ushort saved_adv_err_addr; /* 35 saved last uc error address */ 2354 ushort reserved36; /* 36 reserved */
2377 ushort reserved36; /* 36 reserved */ 2355 ushort reserved37; /* 37 reserved */
2378 ushort reserved37; /* 37 reserved */ 2356 ushort reserved38; /* 38 reserved */
2379 ushort reserved38; /* 38 reserved */ 2357 ushort reserved39; /* 39 reserved */
2380 ushort reserved39; /* 39 reserved */ 2358 ushort reserved40; /* 40 reserved */
2381 ushort reserved40; /* 40 reserved */ 2359 ushort reserved41; /* 41 reserved */
2382 ushort reserved41; /* 41 reserved */ 2360 ushort reserved42; /* 42 reserved */
2383 ushort reserved42; /* 42 reserved */ 2361 ushort reserved43; /* 43 reserved */
2384 ushort reserved43; /* 43 reserved */ 2362 ushort reserved44; /* 44 reserved */
2385 ushort reserved44; /* 44 reserved */ 2363 ushort reserved45; /* 45 reserved */
2386 ushort reserved45; /* 45 reserved */ 2364 ushort reserved46; /* 46 reserved */
2387 ushort reserved46; /* 46 reserved */ 2365 ushort reserved47; /* 47 reserved */
2388 ushort reserved47; /* 47 reserved */ 2366 ushort reserved48; /* 48 reserved */
2389 ushort reserved48; /* 48 reserved */ 2367 ushort reserved49; /* 49 reserved */
2390 ushort reserved49; /* 49 reserved */ 2368 ushort reserved50; /* 50 reserved */
2391 ushort reserved50; /* 50 reserved */ 2369 ushort reserved51; /* 51 reserved */
2392 ushort reserved51; /* 51 reserved */ 2370 ushort reserved52; /* 52 reserved */
2393 ushort reserved52; /* 52 reserved */ 2371 ushort reserved53; /* 53 reserved */
2394 ushort reserved53; /* 53 reserved */ 2372 ushort reserved54; /* 54 reserved */
2395 ushort reserved54; /* 54 reserved */ 2373 ushort reserved55; /* 55 reserved */
2396 ushort reserved55; /* 55 reserved */ 2374 ushort cisptr_lsw; /* 56 CIS PTR LSW */
2397 ushort cisptr_lsw; /* 56 CIS PTR LSW */ 2375 ushort cisprt_msw; /* 57 CIS PTR MSW */
2398 ushort cisprt_msw; /* 57 CIS PTR MSW */ 2376 ushort subsysvid; /* 58 SubSystem Vendor ID */
2399 ushort subsysvid; /* 58 SubSystem Vendor ID */ 2377 ushort subsysid; /* 59 SubSystem ID */
2400 ushort subsysid; /* 59 SubSystem ID */ 2378 ushort reserved60; /* 60 reserved */
2401 ushort reserved60; /* 60 reserved */ 2379 ushort reserved61; /* 61 reserved */
2402 ushort reserved61; /* 61 reserved */ 2380 ushort reserved62; /* 62 reserved */
2403 ushort reserved62; /* 62 reserved */ 2381 ushort reserved63; /* 63 reserved */
2404 ushort reserved63; /* 63 reserved */
2405} ADVEEP_38C1600_CONFIG; 2382} ADVEEP_38C1600_CONFIG;
2406 2383
2407/* 2384/*
@@ -2427,11 +2404,11 @@ typedef struct adveep_38C1600_config
2427#define BIOS_CTRL_SCSI_PARITY 0x1000 2404#define BIOS_CTRL_SCSI_PARITY 0x1000
2428#define BIOS_CTRL_AIPP_DIS 0x2000 2405#define BIOS_CTRL_AIPP_DIS 0x2000
2429 2406
2430#define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */ 2407#define ADV_3550_MEMSIZE 0x2000 /* 8 KB Internal Memory */
2431#define ADV_3550_IOLEN 0x40 /* I/O Port Range in bytes */ 2408#define ADV_3550_IOLEN 0x40 /* I/O Port Range in bytes */
2432 2409
2433#define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */ 2410#define ADV_38C0800_MEMSIZE 0x4000 /* 16 KB Internal Memory */
2434#define ADV_38C0800_IOLEN 0x100 /* I/O Port Range in bytes */ 2411#define ADV_38C0800_IOLEN 0x100 /* I/O Port Range in bytes */
2435 2412
2436/* 2413/*
2437 * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is 2414 * XXX - Since ASC38C1600 Rev.3 has a local RAM failure issue, there is
@@ -2440,9 +2417,9 @@ typedef struct adveep_38C1600_config
2440 * 2417 *
2441 * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory * 2418 * #define ADV_38C1600_MEMSIZE 0x8000L * 32 KB Internal Memory *
2442 */ 2419 */
2443#define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */ 2420#define ADV_38C1600_MEMSIZE 0x4000 /* 16 KB Internal Memory */
2444#define ADV_38C1600_IOLEN 0x100 /* I/O Port Range 256 bytes */ 2421#define ADV_38C1600_IOLEN 0x100 /* I/O Port Range 256 bytes */
2445#define ADV_38C1600_MEMLEN 0x1000 /* Memory Range 4KB bytes */ 2422#define ADV_38C1600_MEMLEN 0x1000 /* Memory Range 4KB bytes */
2446 2423
2447/* 2424/*
2448 * Byte I/O register address from base of 'iop_base'. 2425 * Byte I/O register address from base of 'iop_base'.
@@ -2515,39 +2492,39 @@ typedef struct adveep_38C1600_config
2515/* 2492/*
2516 * Word I/O register address from base of 'iop_base'. 2493 * Word I/O register address from base of 'iop_base'.
2517 */ 2494 */
2518#define IOPW_CHIP_ID_0 0x00 /* CID0 */ 2495#define IOPW_CHIP_ID_0 0x00 /* CID0 */
2519#define IOPW_CTRL_REG 0x02 /* CC */ 2496#define IOPW_CTRL_REG 0x02 /* CC */
2520#define IOPW_RAM_ADDR 0x04 /* LA */ 2497#define IOPW_RAM_ADDR 0x04 /* LA */
2521#define IOPW_RAM_DATA 0x06 /* LD */ 2498#define IOPW_RAM_DATA 0x06 /* LD */
2522#define IOPW_RES_ADDR_08 0x08 2499#define IOPW_RES_ADDR_08 0x08
2523#define IOPW_RISC_CSR 0x0A /* CSR */ 2500#define IOPW_RISC_CSR 0x0A /* CSR */
2524#define IOPW_SCSI_CFG0 0x0C /* CFG0 */ 2501#define IOPW_SCSI_CFG0 0x0C /* CFG0 */
2525#define IOPW_SCSI_CFG1 0x0E /* CFG1 */ 2502#define IOPW_SCSI_CFG1 0x0E /* CFG1 */
2526#define IOPW_RES_ADDR_10 0x10 2503#define IOPW_RES_ADDR_10 0x10
2527#define IOPW_SEL_MASK 0x12 /* SM */ 2504#define IOPW_SEL_MASK 0x12 /* SM */
2528#define IOPW_RES_ADDR_14 0x14 2505#define IOPW_RES_ADDR_14 0x14
2529#define IOPW_FLASH_ADDR 0x16 /* FA */ 2506#define IOPW_FLASH_ADDR 0x16 /* FA */
2530#define IOPW_RES_ADDR_18 0x18 2507#define IOPW_RES_ADDR_18 0x18
2531#define IOPW_EE_CMD 0x1A /* EC */ 2508#define IOPW_EE_CMD 0x1A /* EC */
2532#define IOPW_EE_DATA 0x1C /* ED */ 2509#define IOPW_EE_DATA 0x1C /* ED */
2533#define IOPW_SFIFO_CNT 0x1E /* SFC */ 2510#define IOPW_SFIFO_CNT 0x1E /* SFC */
2534#define IOPW_RES_ADDR_20 0x20 2511#define IOPW_RES_ADDR_20 0x20
2535#define IOPW_Q_BASE 0x22 /* QB */ 2512#define IOPW_Q_BASE 0x22 /* QB */
2536#define IOPW_QP 0x24 /* QP */ 2513#define IOPW_QP 0x24 /* QP */
2537#define IOPW_IX 0x26 /* IX */ 2514#define IOPW_IX 0x26 /* IX */
2538#define IOPW_SP 0x28 /* SP */ 2515#define IOPW_SP 0x28 /* SP */
2539#define IOPW_PC 0x2A /* PC */ 2516#define IOPW_PC 0x2A /* PC */
2540#define IOPW_RES_ADDR_2C 0x2C 2517#define IOPW_RES_ADDR_2C 0x2C
2541#define IOPW_RES_ADDR_2E 0x2E 2518#define IOPW_RES_ADDR_2E 0x2E
2542#define IOPW_SCSI_DATA 0x30 /* SD */ 2519#define IOPW_SCSI_DATA 0x30 /* SD */
2543#define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */ 2520#define IOPW_SCSI_DATA_HSHK 0x32 /* SDH */
2544#define IOPW_SCSI_CTRL 0x34 /* SC */ 2521#define IOPW_SCSI_CTRL 0x34 /* SC */
2545#define IOPW_HSHK_CFG 0x36 /* HCFG */ 2522#define IOPW_HSHK_CFG 0x36 /* HCFG */
2546#define IOPW_SXFR_STATUS 0x36 /* SXS */ 2523#define IOPW_SXFR_STATUS 0x36 /* SXS */
2547#define IOPW_SXFR_CNTL 0x38 /* SXL */ 2524#define IOPW_SXFR_CNTL 0x38 /* SXL */
2548#define IOPW_SXFR_CNTH 0x3A /* SXH */ 2525#define IOPW_SXFR_CNTH 0x3A /* SXH */
2549#define IOPW_RES_ADDR_3C 0x3C 2526#define IOPW_RES_ADDR_3C 0x3C
2550#define IOPW_RFIFO_DATA 0x3E /* RFD */ 2527#define IOPW_RFIFO_DATA 0x3E /* RFD */
2551 2528
2552/* 2529/*
2553 * Doubleword I/O register address from base of 'iop_base'. 2530 * Doubleword I/O register address from base of 'iop_base'.
@@ -2621,36 +2598,36 @@ typedef struct adveep_38C1600_config
2621/* 2598/*
2622 * SCSI_CFG0 Register bit definitions 2599 * SCSI_CFG0 Register bit definitions
2623 */ 2600 */
2624#define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */ 2601#define TIMER_MODEAB 0xC000 /* Watchdog, Second, and Select. Timer Ctrl. */
2625#define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */ 2602#define PARITY_EN 0x2000 /* Enable SCSI Parity Error detection */
2626#define EVEN_PARITY 0x1000 /* Select Even Parity */ 2603#define EVEN_PARITY 0x1000 /* Select Even Parity */
2627#define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */ 2604#define WD_LONG 0x0800 /* Watchdog Interval, 1: 57 min, 0: 13 sec */
2628#define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */ 2605#define QUEUE_128 0x0400 /* Queue Size, 1: 128 byte, 0: 64 byte */
2629#define PRIM_MODE 0x0100 /* Primitive SCSI mode */ 2606#define PRIM_MODE 0x0100 /* Primitive SCSI mode */
2630#define SCAM_EN 0x0080 /* Enable SCAM selection */ 2607#define SCAM_EN 0x0080 /* Enable SCAM selection */
2631#define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */ 2608#define SEL_TMO_LONG 0x0040 /* Sel/Resel Timeout, 1: 400 ms, 0: 1.6 ms */
2632#define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */ 2609#define CFRM_ID 0x0020 /* SCAM id sel. confirm., 1: fast, 0: 6.4 ms */
2633#define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */ 2610#define OUR_ID_EN 0x0010 /* Enable OUR_ID bits */
2634#define OUR_ID 0x000F /* SCSI ID */ 2611#define OUR_ID 0x000F /* SCSI ID */
2635 2612
2636/* 2613/*
2637 * SCSI_CFG1 Register bit definitions 2614 * SCSI_CFG1 Register bit definitions
2638 */ 2615 */
2639#define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */ 2616#define BIG_ENDIAN 0x8000 /* Enable Big Endian Mode MIO:15, EEP:15 */
2640#define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */ 2617#define TERM_POL 0x2000 /* Terminator Polarity Ctrl. MIO:13, EEP:13 */
2641#define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */ 2618#define SLEW_RATE 0x1000 /* SCSI output buffer slew rate */
2642#define FILTER_SEL 0x0C00 /* Filter Period Selection */ 2619#define FILTER_SEL 0x0C00 /* Filter Period Selection */
2643#define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */ 2620#define FLTR_DISABLE 0x0000 /* Input Filtering Disabled */
2644#define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */ 2621#define FLTR_11_TO_20NS 0x0800 /* Input Filtering 11ns to 20ns */
2645#define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */ 2622#define FLTR_21_TO_39NS 0x0C00 /* Input Filtering 21ns to 39ns */
2646#define ACTIVE_DBL 0x0200 /* Disable Active Negation */ 2623#define ACTIVE_DBL 0x0200 /* Disable Active Negation */
2647#define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */ 2624#define DIFF_MODE 0x0100 /* SCSI differential Mode (Read-Only) */
2648#define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */ 2625#define DIFF_SENSE 0x0080 /* 1: No SE cables, 0: SE cable (Read-Only) */
2649#define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */ 2626#define TERM_CTL_SEL 0x0040 /* Enable TERM_CTL_H and TERM_CTL_L */
2650#define TERM_CTL 0x0030 /* External SCSI Termination Bits */ 2627#define TERM_CTL 0x0030 /* External SCSI Termination Bits */
2651#define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */ 2628#define TERM_CTL_H 0x0020 /* Enable External SCSI Upper Termination */
2652#define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */ 2629#define TERM_CTL_L 0x0010 /* Enable External SCSI Lower Termination */
2653#define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */ 2630#define CABLE_DETECT 0x000F /* External SCSI Cable Connection Status */
2654 2631
2655/* 2632/*
2656 * Addendum for ASC-38C0800 Chip 2633 * Addendum for ASC-38C0800 Chip
@@ -2663,24 +2640,23 @@ typedef struct adveep_38C1600_config
2663 * Also each ASC-38C1600 function or channel uses only cable bits [5:4] 2640 * Also each ASC-38C1600 function or channel uses only cable bits [5:4]
2664 * and [1:0]. Bits [14], [7:6], [3:2] are unused. 2641 * and [1:0]. Bits [14], [7:6], [3:2] are unused.
2665 */ 2642 */
2666#define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */ 2643#define DIS_TERM_DRV 0x4000 /* 1: Read c_det[3:0], 0: cannot read */
2667#define HVD_LVD_SE 0x1C00 /* Device Detect Bits */ 2644#define HVD_LVD_SE 0x1C00 /* Device Detect Bits */
2668#define HVD 0x1000 /* HVD Device Detect */ 2645#define HVD 0x1000 /* HVD Device Detect */
2669#define LVD 0x0800 /* LVD Device Detect */ 2646#define LVD 0x0800 /* LVD Device Detect */
2670#define SE 0x0400 /* SE Device Detect */ 2647#define SE 0x0400 /* SE Device Detect */
2671#define TERM_LVD 0x00C0 /* LVD Termination Bits */ 2648#define TERM_LVD 0x00C0 /* LVD Termination Bits */
2672#define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */ 2649#define TERM_LVD_HI 0x0080 /* Enable LVD Upper Termination */
2673#define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */ 2650#define TERM_LVD_LO 0x0040 /* Enable LVD Lower Termination */
2674#define TERM_SE 0x0030 /* SE Termination Bits */ 2651#define TERM_SE 0x0030 /* SE Termination Bits */
2675#define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */ 2652#define TERM_SE_HI 0x0020 /* Enable SE Upper Termination */
2676#define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */ 2653#define TERM_SE_LO 0x0010 /* Enable SE Lower Termination */
2677#define C_DET_LVD 0x000C /* LVD Cable Detect Bits */ 2654#define C_DET_LVD 0x000C /* LVD Cable Detect Bits */
2678#define C_DET3 0x0008 /* Cable Detect for LVD External Wide */ 2655#define C_DET3 0x0008 /* Cable Detect for LVD External Wide */
2679#define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */ 2656#define C_DET2 0x0004 /* Cable Detect for LVD Internal Wide */
2680#define C_DET_SE 0x0003 /* SE Cable Detect Bits */ 2657#define C_DET_SE 0x0003 /* SE Cable Detect Bits */
2681#define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */ 2658#define C_DET1 0x0002 /* Cable Detect for SE Internal Wide */
2682#define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */ 2659#define C_DET0 0x0001 /* Cable Detect for SE Internal Narrow */
2683
2684 2660
2685#define CABLE_ILLEGAL_A 0x7 2661#define CABLE_ILLEGAL_A 0x7
2686 /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */ 2662 /* x 0 0 0 | on on | Illegal (all 3 connectors are used) */
@@ -2691,39 +2667,39 @@ typedef struct adveep_38C1600_config
2691/* 2667/*
2692 * MEM_CFG Register bit definitions 2668 * MEM_CFG Register bit definitions
2693 */ 2669 */
2694#define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */ 2670#define BIOS_EN 0x40 /* BIOS Enable MIO:14,EEP:14 */
2695#define FAST_EE_CLK 0x20 /* Diagnostic Bit */ 2671#define FAST_EE_CLK 0x20 /* Diagnostic Bit */
2696#define RAM_SZ 0x1C /* Specify size of RAM to RISC */ 2672#define RAM_SZ 0x1C /* Specify size of RAM to RISC */
2697#define RAM_SZ_2KB 0x00 /* 2 KB */ 2673#define RAM_SZ_2KB 0x00 /* 2 KB */
2698#define RAM_SZ_4KB 0x04 /* 4 KB */ 2674#define RAM_SZ_4KB 0x04 /* 4 KB */
2699#define RAM_SZ_8KB 0x08 /* 8 KB */ 2675#define RAM_SZ_8KB 0x08 /* 8 KB */
2700#define RAM_SZ_16KB 0x0C /* 16 KB */ 2676#define RAM_SZ_16KB 0x0C /* 16 KB */
2701#define RAM_SZ_32KB 0x10 /* 32 KB */ 2677#define RAM_SZ_32KB 0x10 /* 32 KB */
2702#define RAM_SZ_64KB 0x14 /* 64 KB */ 2678#define RAM_SZ_64KB 0x14 /* 64 KB */
2703 2679
2704/* 2680/*
2705 * DMA_CFG0 Register bit definitions 2681 * DMA_CFG0 Register bit definitions
2706 * 2682 *
2707 * This register is only accessible to the host. 2683 * This register is only accessible to the host.
2708 */ 2684 */
2709#define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */ 2685#define BC_THRESH_ENB 0x80 /* PCI DMA Start Conditions */
2710#define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */ 2686#define FIFO_THRESH 0x70 /* PCI DMA FIFO Threshold */
2711#define FIFO_THRESH_16B 0x00 /* 16 bytes */ 2687#define FIFO_THRESH_16B 0x00 /* 16 bytes */
2712#define FIFO_THRESH_32B 0x20 /* 32 bytes */ 2688#define FIFO_THRESH_32B 0x20 /* 32 bytes */
2713#define FIFO_THRESH_48B 0x30 /* 48 bytes */ 2689#define FIFO_THRESH_48B 0x30 /* 48 bytes */
2714#define FIFO_THRESH_64B 0x40 /* 64 bytes */ 2690#define FIFO_THRESH_64B 0x40 /* 64 bytes */
2715#define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */ 2691#define FIFO_THRESH_80B 0x50 /* 80 bytes (default) */
2716#define FIFO_THRESH_96B 0x60 /* 96 bytes */ 2692#define FIFO_THRESH_96B 0x60 /* 96 bytes */
2717#define FIFO_THRESH_112B 0x70 /* 112 bytes */ 2693#define FIFO_THRESH_112B 0x70 /* 112 bytes */
2718#define START_CTL 0x0C /* DMA start conditions */ 2694#define START_CTL 0x0C /* DMA start conditions */
2719#define START_CTL_TH 0x00 /* Wait threshold level (default) */ 2695#define START_CTL_TH 0x00 /* Wait threshold level (default) */
2720#define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */ 2696#define START_CTL_ID 0x04 /* Wait SDMA/SBUS idle */
2721#define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */ 2697#define START_CTL_THID 0x08 /* Wait threshold and SDMA/SBUS idle */
2722#define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */ 2698#define START_CTL_EMFU 0x0C /* Wait SDMA FIFO empty/full */
2723#define READ_CMD 0x03 /* Memory Read Method */ 2699#define READ_CMD 0x03 /* Memory Read Method */
2724#define READ_CMD_MR 0x00 /* Memory Read */ 2700#define READ_CMD_MR 0x00 /* Memory Read */
2725#define READ_CMD_MRL 0x02 /* Memory Read Long */ 2701#define READ_CMD_MRL 0x02 /* Memory Read Long */
2726#define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */ 2702#define READ_CMD_MRM 0x03 /* Memory Read Multiple (default) */
2727 2703
2728/* 2704/*
2729 * ASC-38C0800 RAM BIST Register bit definitions 2705 * ASC-38C0800 RAM BIST Register bit definitions
@@ -2747,7 +2723,7 @@ typedef struct adveep_38C1600_config
2747 * IOPB_PCI_INT_CFG Bit Field Definitions 2723 * IOPB_PCI_INT_CFG Bit Field Definitions
2748 */ 2724 */
2749 2725
2750#define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */ 2726#define INTAB_LD 0x80 /* Value loaded from EEPROM Bit 11. */
2751 2727
2752/* 2728/*
2753 * Bit 1 can be set to change the interrupt for the Function to operate in 2729 * Bit 1 can be set to change the interrupt for the Function to operate in
@@ -2780,53 +2756,52 @@ typedef struct adveep_38C1600_config
2780#define ADV_BUSY 0 2756#define ADV_BUSY 0
2781#define ADV_ERROR (-1) 2757#define ADV_ERROR (-1)
2782 2758
2783
2784/* 2759/*
2785 * ADV_DVC_VAR 'warn_code' values 2760 * ADV_DVC_VAR 'warn_code' values
2786 */ 2761 */
2787#define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */ 2762#define ASC_WARN_BUSRESET_ERROR 0x0001 /* SCSI Bus Reset error */
2788#define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */ 2763#define ASC_WARN_EEPROM_CHKSUM 0x0002 /* EEP check sum error */
2789#define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */ 2764#define ASC_WARN_EEPROM_TERMINATION 0x0004 /* EEP termination bad field */
2790#define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080 /* PCI config space set error */ 2765#define ASC_WARN_SET_PCI_CONFIG_SPACE 0x0080 /* PCI config space set error */
2791#define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */ 2766#define ASC_WARN_ERROR 0xFFFF /* ADV_ERROR return */
2792 2767
2793#define ADV_MAX_TID 15 /* max. target identifier */ 2768#define ADV_MAX_TID 15 /* max. target identifier */
2794#define ADV_MAX_LUN 7 /* max. logical unit number */ 2769#define ADV_MAX_LUN 7 /* max. logical unit number */
2795 2770
2796/* 2771/*
2797 * Error code values are set in ADV_DVC_VAR 'err_code'. 2772 * Error code values are set in ADV_DVC_VAR 'err_code'.
2798 */ 2773 */
2799#define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */ 2774#define ASC_IERR_WRITE_EEPROM 0x0001 /* write EEPROM error */
2800#define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */ 2775#define ASC_IERR_MCODE_CHKSUM 0x0002 /* micro code check sum error */
2801#define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */ 2776#define ASC_IERR_NO_CARRIER 0x0004 /* No more carrier memory. */
2802#define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */ 2777#define ASC_IERR_START_STOP_CHIP 0x0008 /* start/stop chip failed */
2803#define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */ 2778#define ASC_IERR_CHIP_VERSION 0x0040 /* wrong chip version */
2804#define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */ 2779#define ASC_IERR_SET_SCSI_ID 0x0080 /* set SCSI ID failed */
2805#define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */ 2780#define ASC_IERR_HVD_DEVICE 0x0100 /* HVD attached to LVD connector. */
2806#define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */ 2781#define ASC_IERR_BAD_SIGNATURE 0x0200 /* signature not found */
2807#define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */ 2782#define ASC_IERR_ILLEGAL_CONNECTION 0x0400 /* Illegal cable connection */
2808#define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */ 2783#define ASC_IERR_SINGLE_END_DEVICE 0x0800 /* Single-end used w/differential */
2809#define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */ 2784#define ASC_IERR_REVERSED_CABLE 0x1000 /* Narrow flat cable reversed */
2810#define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */ 2785#define ASC_IERR_BIST_PRE_TEST 0x2000 /* BIST pre-test error */
2811#define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */ 2786#define ASC_IERR_BIST_RAM_TEST 0x4000 /* BIST RAM test error */
2812#define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */ 2787#define ASC_IERR_BAD_CHIPTYPE 0x8000 /* Invalid 'chip_type' setting. */
2813 2788
2814/* 2789/*
2815 * Fixed locations of microcode operating variables. 2790 * Fixed locations of microcode operating variables.
2816 */ 2791 */
2817#define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */ 2792#define ASC_MC_CODE_BEGIN_ADDR 0x0028 /* microcode start address */
2818#define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */ 2793#define ASC_MC_CODE_END_ADDR 0x002A /* microcode end address */
2819#define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */ 2794#define ASC_MC_CODE_CHK_SUM 0x002C /* microcode code checksum */
2820#define ASC_MC_VERSION_DATE 0x0038 /* microcode version */ 2795#define ASC_MC_VERSION_DATE 0x0038 /* microcode version */
2821#define ASC_MC_VERSION_NUM 0x003A /* microcode number */ 2796#define ASC_MC_VERSION_NUM 0x003A /* microcode number */
2822#define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */ 2797#define ASC_MC_BIOSMEM 0x0040 /* BIOS RISC Memory Start */
2823#define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */ 2798#define ASC_MC_BIOSLEN 0x0050 /* BIOS RISC Memory Length */
2824#define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */ 2799#define ASC_MC_BIOS_SIGNATURE 0x0058 /* BIOS Signature 0x55AA */
2825#define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */ 2800#define ASC_MC_BIOS_VERSION 0x005A /* BIOS Version (2 bytes) */
2826#define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */ 2801#define ASC_MC_SDTR_SPEED1 0x0090 /* SDTR Speed for TID 0-3 */
2827#define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */ 2802#define ASC_MC_SDTR_SPEED2 0x0092 /* SDTR Speed for TID 4-7 */
2828#define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */ 2803#define ASC_MC_SDTR_SPEED3 0x0094 /* SDTR Speed for TID 8-11 */
2829#define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */ 2804#define ASC_MC_SDTR_SPEED4 0x0096 /* SDTR Speed for TID 12-15 */
2830#define ASC_MC_CHIP_TYPE 0x009A 2805#define ASC_MC_CHIP_TYPE 0x009A
2831#define ASC_MC_INTRB_CODE 0x009B 2806#define ASC_MC_INTRB_CODE 0x009B
2832#define ASC_MC_WDTR_ABLE 0x009C 2807#define ASC_MC_WDTR_ABLE 0x009C
@@ -2844,9 +2819,9 @@ typedef struct adveep_38C1600_config
2844#define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0 2819#define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
2845#define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0 2820#define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
2846#define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100 2821#define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
2847#define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */ 2822#define ASC_MC_CONTROL_FLAG 0x0122 /* Microcode control flag. */
2848#define ASC_MC_WDTR_DONE 0x0124 2823#define ASC_MC_WDTR_DONE 0x0124
2849#define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */ 2824#define ASC_MC_CAM_MODE_MASK 0x015E /* CAM mode TID bitmask. */
2850#define ASC_MC_ICQ 0x0160 2825#define ASC_MC_ICQ 0x0160
2851#define ASC_MC_IRQ 0x0164 2826#define ASC_MC_IRQ 0x0164
2852#define ASC_MC_PPR_ABLE 0x017A 2827#define ASC_MC_PPR_ABLE 0x017A
@@ -2865,8 +2840,8 @@ typedef struct adveep_38C1600_config
2865 * Flags set by the Adv Library in RISC variable 'control_flag' (0x122) 2840 * Flags set by the Adv Library in RISC variable 'control_flag' (0x122)
2866 * and handled by the microcode. 2841 * and handled by the microcode.
2867 */ 2842 */
2868#define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */ 2843#define CONTROL_FLAG_IGNORE_PERR 0x0001 /* Ignore DMA Parity Errors */
2869#define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */ 2844#define CONTROL_FLAG_ENABLE_AIPP 0x0002 /* Enabled AIPP checking. */
2870 2845
2871/* 2846/*
2872 * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format 2847 * ASC_MC_DEVICE_HSHK_CFG_TABLE microcode table or HSHK_CFG register format
@@ -2875,45 +2850,44 @@ typedef struct adveep_38C1600_config
2875#define HSHK_CFG_RATE 0x0F00 2850#define HSHK_CFG_RATE 0x0F00
2876#define HSHK_CFG_OFFSET 0x001F 2851#define HSHK_CFG_OFFSET 0x001F
2877 2852
2878#define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */ 2853#define ASC_DEF_MAX_HOST_QNG 0xFD /* Max. number of host commands (253) */
2879#define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */ 2854#define ASC_DEF_MIN_HOST_QNG 0x10 /* Min. number of host commands (16) */
2880#define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */ 2855#define ASC_DEF_MAX_DVC_QNG 0x3F /* Max. number commands per device (63) */
2881#define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */ 2856#define ASC_DEF_MIN_DVC_QNG 0x04 /* Min. number commands per device (4) */
2882 2857
2883#define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */ 2858#define ASC_QC_DATA_CHECK 0x01 /* Require ASC_QC_DATA_OUT set or clear. */
2884#define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */ 2859#define ASC_QC_DATA_OUT 0x02 /* Data out DMA transfer. */
2885#define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */ 2860#define ASC_QC_START_MOTOR 0x04 /* Send auto-start motor before request. */
2886#define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */ 2861#define ASC_QC_NO_OVERRUN 0x08 /* Don't report overrun. */
2887#define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */ 2862#define ASC_QC_FREEZE_TIDQ 0x10 /* Freeze TID queue after request. XXX TBD */
2888 2863
2889#define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */ 2864#define ASC_QSC_NO_DISC 0x01 /* Don't allow disconnect for request. */
2890#define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */ 2865#define ASC_QSC_NO_TAGMSG 0x02 /* Don't allow tag queuing for request. */
2891#define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */ 2866#define ASC_QSC_NO_SYNC 0x04 /* Don't use Synch. transfer on request. */
2892#define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */ 2867#define ASC_QSC_NO_WIDE 0x08 /* Don't use Wide transfer on request. */
2893#define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */ 2868#define ASC_QSC_REDO_DTR 0x10 /* Renegotiate WDTR/SDTR before request. */
2894/* 2869/*
2895 * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or 2870 * Note: If a Tag Message is to be sent and neither ASC_QSC_HEAD_TAG or
2896 * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used. 2871 * ASC_QSC_ORDERED_TAG is set, then a Simple Tag Message (0x20) is used.
2897 */ 2872 */
2898#define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */ 2873#define ASC_QSC_HEAD_TAG 0x40 /* Use Head Tag Message (0x21). */
2899#define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */ 2874#define ASC_QSC_ORDERED_TAG 0x80 /* Use Ordered Tag Message (0x22). */
2900 2875
2901/* 2876/*
2902 * All fields here are accessed by the board microcode and need to be 2877 * All fields here are accessed by the board microcode and need to be
2903 * little-endian. 2878 * little-endian.
2904 */ 2879 */
2905typedef struct adv_carr_t 2880typedef struct adv_carr_t {
2906{ 2881 ADV_VADDR carr_va; /* Carrier Virtual Address */
2907 ADV_VADDR carr_va; /* Carrier Virtual Address */ 2882 ADV_PADDR carr_pa; /* Carrier Physical Address */
2908 ADV_PADDR carr_pa; /* Carrier Physical Address */ 2883 ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */
2909 ADV_VADDR areq_vpa; /* ASC_SCSI_REQ_Q Virtual or Physical Address */ 2884 /*
2910 /* 2885 * next_vpa [31:4] Carrier Virtual or Physical Next Pointer
2911 * next_vpa [31:4] Carrier Virtual or Physical Next Pointer 2886 *
2912 * 2887 * next_vpa [3:1] Reserved Bits
2913 * next_vpa [3:1] Reserved Bits 2888 * next_vpa [0] Done Flag set in Response Queue.
2914 * next_vpa [0] Done Flag set in Response Queue. 2889 */
2915 */ 2890 ADV_VADDR next_vpa;
2916 ADV_VADDR next_vpa;
2917} ADV_CARR_T; 2891} ADV_CARR_T;
2918 2892
2919/* 2893/*
@@ -2940,13 +2914,13 @@ typedef struct adv_carr_t
2940 * The Adv Library should limit use to the lower nibble (4 bits) of 2914 * The Adv Library should limit use to the lower nibble (4 bits) of
2941 * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag. 2915 * a_flag. Drivers are free to use the upper nibble (4 bits) of a_flag.
2942 */ 2916 */
2943#define ADV_POLL_REQUEST 0x01 /* poll for request completion */ 2917#define ADV_POLL_REQUEST 0x01 /* poll for request completion */
2944#define ADV_SCSIQ_DONE 0x02 /* request done */ 2918#define ADV_SCSIQ_DONE 0x02 /* request done */
2945#define ADV_DONT_RETRY 0x08 /* don't do retry */ 2919#define ADV_DONT_RETRY 0x08 /* don't do retry */
2946 2920
2947#define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */ 2921#define ADV_CHIP_ASC3550 0x01 /* Ultra-Wide IC */
2948#define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */ 2922#define ADV_CHIP_ASC38C0800 0x02 /* Ultra2-Wide/LVD IC */
2949#define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */ 2923#define ADV_CHIP_ASC38C1600 0x03 /* Ultra3-Wide/LVD2 IC */
2950 2924
2951/* 2925/*
2952 * Adapter temporary configuration structure 2926 * Adapter temporary configuration structure
@@ -2960,30 +2934,30 @@ typedef struct adv_carr_t
2960 * value of the field is never reset. 2934 * value of the field is never reset.
2961 */ 2935 */
2962typedef struct adv_dvc_cfg { 2936typedef struct adv_dvc_cfg {
2963 ushort disc_enable; /* enable disconnection */ 2937 ushort disc_enable; /* enable disconnection */
2964 uchar chip_version; /* chip version */ 2938 uchar chip_version; /* chip version */
2965 uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */ 2939 uchar termination; /* Term. Ctrl. bits 6-5 of SCSI_CFG1 register */
2966 ushort lib_version; /* Adv Library version number */ 2940 ushort lib_version; /* Adv Library version number */
2967 ushort control_flag; /* Microcode Control Flag */ 2941 ushort control_flag; /* Microcode Control Flag */
2968 ushort mcode_date; /* Microcode date */ 2942 ushort mcode_date; /* Microcode date */
2969 ushort mcode_version; /* Microcode version */ 2943 ushort mcode_version; /* Microcode version */
2970 ushort pci_slot_info; /* high byte device/function number */ 2944 ushort pci_slot_info; /* high byte device/function number */
2971 /* bits 7-3 device num., bits 2-0 function num. */ 2945 /* bits 7-3 device num., bits 2-0 function num. */
2972 /* low byte bus num. */ 2946 /* low byte bus num. */
2973 ushort serial1; /* EEPROM serial number word 1 */ 2947 ushort serial1; /* EEPROM serial number word 1 */
2974 ushort serial2; /* EEPROM serial number word 2 */ 2948 ushort serial2; /* EEPROM serial number word 2 */
2975 ushort serial3; /* EEPROM serial number word 3 */ 2949 ushort serial3; /* EEPROM serial number word 3 */
2976 struct device *dev; /* pointer to the pci dev structure for this board */ 2950 struct device *dev; /* pointer to the pci dev structure for this board */
2977} ADV_DVC_CFG; 2951} ADV_DVC_CFG;
2978 2952
2979struct adv_dvc_var; 2953struct adv_dvc_var;
2980struct adv_scsi_req_q; 2954struct adv_scsi_req_q;
2981 2955
2982typedef void (* ADV_ISR_CALLBACK) 2956typedef void (*ADV_ISR_CALLBACK)
2983 (struct adv_dvc_var *, struct adv_scsi_req_q *); 2957 (struct adv_dvc_var *, struct adv_scsi_req_q *);
2984 2958
2985typedef void (* ADV_ASYNC_CALLBACK) 2959typedef void (*ADV_ASYNC_CALLBACK)
2986 (struct adv_dvc_var *, uchar); 2960 (struct adv_dvc_var *, uchar);
2987 2961
2988/* 2962/*
2989 * Adapter operation variable structure. 2963 * Adapter operation variable structure.
@@ -2998,55 +2972,55 @@ typedef void (* ADV_ASYNC_CALLBACK)
2998 * of the feature, the field is cleared. 2972 * of the feature, the field is cleared.
2999 */ 2973 */
3000typedef struct adv_dvc_var { 2974typedef struct adv_dvc_var {
3001 AdvPortAddr iop_base; /* I/O port address */ 2975 AdvPortAddr iop_base; /* I/O port address */
3002 ushort err_code; /* fatal error code */ 2976 ushort err_code; /* fatal error code */
3003 ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */ 2977 ushort bios_ctrl; /* BIOS control word, EEPROM word 12 */
3004 ADV_ISR_CALLBACK isr_callback; 2978 ADV_ISR_CALLBACK isr_callback;
3005 ADV_ASYNC_CALLBACK async_callback; 2979 ADV_ASYNC_CALLBACK async_callback;
3006 ushort wdtr_able; /* try WDTR for a device */ 2980 ushort wdtr_able; /* try WDTR for a device */
3007 ushort sdtr_able; /* try SDTR for a device */ 2981 ushort sdtr_able; /* try SDTR for a device */
3008 ushort ultra_able; /* try SDTR Ultra speed for a device */ 2982 ushort ultra_able; /* try SDTR Ultra speed for a device */
3009 ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */ 2983 ushort sdtr_speed1; /* EEPROM SDTR Speed for TID 0-3 */
3010 ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */ 2984 ushort sdtr_speed2; /* EEPROM SDTR Speed for TID 4-7 */
3011 ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */ 2985 ushort sdtr_speed3; /* EEPROM SDTR Speed for TID 8-11 */
3012 ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */ 2986 ushort sdtr_speed4; /* EEPROM SDTR Speed for TID 12-15 */
3013 ushort tagqng_able; /* try tagged queuing with a device */ 2987 ushort tagqng_able; /* try tagged queuing with a device */
3014 ushort ppr_able; /* PPR message capable per TID bitmask. */ 2988 ushort ppr_able; /* PPR message capable per TID bitmask. */
3015 uchar max_dvc_qng; /* maximum number of tagged commands per device */ 2989 uchar max_dvc_qng; /* maximum number of tagged commands per device */
3016 ushort start_motor; /* start motor command allowed */ 2990 ushort start_motor; /* start motor command allowed */
3017 uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */ 2991 uchar scsi_reset_wait; /* delay in seconds after scsi bus reset */
3018 uchar chip_no; /* should be assigned by caller */ 2992 uchar chip_no; /* should be assigned by caller */
3019 uchar max_host_qng; /* maximum number of Q'ed command allowed */ 2993 uchar max_host_qng; /* maximum number of Q'ed command allowed */
3020 uchar irq_no; /* IRQ number */ 2994 uchar irq_no; /* IRQ number */
3021 ushort no_scam; /* scam_tolerant of EEPROM */ 2995 ushort no_scam; /* scam_tolerant of EEPROM */
3022 struct asc_board *drv_ptr; /* driver pointer to private structure */ 2996 struct asc_board *drv_ptr; /* driver pointer to private structure */
3023 uchar chip_scsi_id; /* chip SCSI target ID */ 2997 uchar chip_scsi_id; /* chip SCSI target ID */
3024 uchar chip_type; 2998 uchar chip_type;
3025 uchar bist_err_code; 2999 uchar bist_err_code;
3026 ADV_CARR_T *carrier_buf; 3000 ADV_CARR_T *carrier_buf;
3027 ADV_CARR_T *carr_freelist; /* Carrier free list. */ 3001 ADV_CARR_T *carr_freelist; /* Carrier free list. */
3028 ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */ 3002 ADV_CARR_T *icq_sp; /* Initiator command queue stopper pointer. */
3029 ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */ 3003 ADV_CARR_T *irq_sp; /* Initiator response queue stopper pointer. */
3030 ushort carr_pending_cnt; /* Count of pending carriers. */ 3004 ushort carr_pending_cnt; /* Count of pending carriers. */
3031 /* 3005 /*
3032 * Note: The following fields will not be used after initialization. The 3006 * Note: The following fields will not be used after initialization. The
3033 * driver may discard the buffer after initialization is done. 3007 * driver may discard the buffer after initialization is done.
3034 */ 3008 */
3035 ADV_DVC_CFG *cfg; /* temporary configuration structure */ 3009 ADV_DVC_CFG *cfg; /* temporary configuration structure */
3036} ADV_DVC_VAR; 3010} ADV_DVC_VAR;
3037 3011
3038#define NO_OF_SG_PER_BLOCK 15 3012#define NO_OF_SG_PER_BLOCK 15
3039 3013
3040typedef struct asc_sg_block { 3014typedef struct asc_sg_block {
3041 uchar reserved1; 3015 uchar reserved1;
3042 uchar reserved2; 3016 uchar reserved2;
3043 uchar reserved3; 3017 uchar reserved3;
3044 uchar sg_cnt; /* Valid entries in block. */ 3018 uchar sg_cnt; /* Valid entries in block. */
3045 ADV_PADDR sg_ptr; /* Pointer to next sg block. */ 3019 ADV_PADDR sg_ptr; /* Pointer to next sg block. */
3046 struct { 3020 struct {
3047 ADV_PADDR sg_addr; /* SG element address. */ 3021 ADV_PADDR sg_addr; /* SG element address. */
3048 ADV_DCNT sg_count; /* SG element count. */ 3022 ADV_DCNT sg_count; /* SG element count. */
3049 } sg_list[NO_OF_SG_PER_BLOCK]; 3023 } sg_list[NO_OF_SG_PER_BLOCK];
3050} ADV_SG_BLOCK; 3024} ADV_SG_BLOCK;
3051 3025
3052/* 3026/*
@@ -3061,37 +3035,37 @@ typedef struct asc_sg_block {
3061 * order. 3035 * order.
3062 */ 3036 */
3063typedef struct adv_scsi_req_q { 3037typedef struct adv_scsi_req_q {
3064 uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */ 3038 uchar cntl; /* Ucode flags and state (ASC_MC_QC_*). */
3065 uchar target_cmd; 3039 uchar target_cmd;
3066 uchar target_id; /* Device target identifier. */ 3040 uchar target_id; /* Device target identifier. */
3067 uchar target_lun; /* Device target logical unit number. */ 3041 uchar target_lun; /* Device target logical unit number. */
3068 ADV_PADDR data_addr; /* Data buffer physical address. */ 3042 ADV_PADDR data_addr; /* Data buffer physical address. */
3069 ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */ 3043 ADV_DCNT data_cnt; /* Data count. Ucode sets to residual. */
3070 ADV_PADDR sense_addr; 3044 ADV_PADDR sense_addr;
3071 ADV_PADDR carr_pa; 3045 ADV_PADDR carr_pa;
3072 uchar mflag; 3046 uchar mflag;
3073 uchar sense_len; 3047 uchar sense_len;
3074 uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */ 3048 uchar cdb_len; /* SCSI CDB length. Must <= 16 bytes. */
3075 uchar scsi_cntl; 3049 uchar scsi_cntl;
3076 uchar done_status; /* Completion status. */ 3050 uchar done_status; /* Completion status. */
3077 uchar scsi_status; /* SCSI status byte. */ 3051 uchar scsi_status; /* SCSI status byte. */
3078 uchar host_status; /* Ucode host status. */ 3052 uchar host_status; /* Ucode host status. */
3079 uchar sg_working_ix; 3053 uchar sg_working_ix;
3080 uchar cdb[12]; /* SCSI CDB bytes 0-11. */ 3054 uchar cdb[12]; /* SCSI CDB bytes 0-11. */
3081 ADV_PADDR sg_real_addr; /* SG list physical address. */ 3055 ADV_PADDR sg_real_addr; /* SG list physical address. */
3082 ADV_PADDR scsiq_rptr; 3056 ADV_PADDR scsiq_rptr;
3083 uchar cdb16[4]; /* SCSI CDB bytes 12-15. */ 3057 uchar cdb16[4]; /* SCSI CDB bytes 12-15. */
3084 ADV_VADDR scsiq_ptr; 3058 ADV_VADDR scsiq_ptr;
3085 ADV_VADDR carr_va; 3059 ADV_VADDR carr_va;
3086 /* 3060 /*
3087 * End of microcode structure - 60 bytes. The rest of the structure 3061 * End of microcode structure - 60 bytes. The rest of the structure
3088 * is used by the Adv Library and ignored by the microcode. 3062 * is used by the Adv Library and ignored by the microcode.
3089 */ 3063 */
3090 ADV_VADDR srb_ptr; 3064 ADV_VADDR srb_ptr;
3091 ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */ 3065 ADV_SG_BLOCK *sg_list_ptr; /* SG list virtual address. */
3092 char *vdata_addr; /* Data buffer virtual address. */ 3066 char *vdata_addr; /* Data buffer virtual address. */
3093 uchar a_flag; 3067 uchar a_flag;
3094 uchar pad[2]; /* Pad out to a word boundary. */ 3068 uchar pad[2]; /* Pad out to a word boundary. */
3095} ADV_SCSI_REQ_Q; 3069} ADV_SCSI_REQ_Q;
3096 3070
3097/* 3071/*
@@ -3103,8 +3077,8 @@ typedef struct adv_scsi_req_q {
3103#define IDLE_CMD_SEND_INT 0x0004 3077#define IDLE_CMD_SEND_INT 0x0004
3104#define IDLE_CMD_ABORT 0x0008 3078#define IDLE_CMD_ABORT 0x0008
3105#define IDLE_CMD_DEVICE_RESET 0x0010 3079#define IDLE_CMD_DEVICE_RESET 0x0010
3106#define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */ 3080#define IDLE_CMD_SCSI_RESET_START 0x0020 /* Assert SCSI Bus Reset */
3107#define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */ 3081#define IDLE_CMD_SCSI_RESET_END 0x0040 /* Deassert SCSI Bus Reset */
3108#define IDLE_CMD_SCSIREQ 0x0080 3082#define IDLE_CMD_SCSIREQ 0x0080
3109 3083
3110#define IDLE_CMD_STATUS_SUCCESS 0x0001 3084#define IDLE_CMD_STATUS_SUCCESS 0x0001
@@ -3118,60 +3092,59 @@ typedef struct adv_scsi_req_q {
3118/* 3092/*
3119 * Wait loop time out values. 3093 * Wait loop time out values.
3120 */ 3094 */
3121#define SCSI_WAIT_10_SEC 10UL /* 10 seconds */ 3095#define SCSI_WAIT_10_SEC 10UL /* 10 seconds */
3122#define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */ 3096#define SCSI_WAIT_100_MSEC 100UL /* 100 milliseconds */
3123#define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */ 3097#define SCSI_US_PER_MSEC 1000 /* microseconds per millisecond */
3124#define SCSI_MS_PER_SEC 1000UL /* milliseconds per second */ 3098#define SCSI_MS_PER_SEC 1000UL /* milliseconds per second */
3125#define SCSI_MAX_RETRY 10 /* retry count */ 3099#define SCSI_MAX_RETRY 10 /* retry count */
3126
3127#define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
3128#define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
3129#define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
3130#define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
3131 3100
3101#define ADV_ASYNC_RDMA_FAILURE 0x01 /* Fatal RDMA failure. */
3102#define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02 /* Detected SCSI Bus Reset. */
3103#define ADV_ASYNC_CARRIER_READY_FAILURE 0x03 /* Carrier Ready failure. */
3104#define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04 /* RDMAed-in data invalid. */
3132 3105
3133#define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */ 3106#define ADV_HOST_SCSI_BUS_RESET 0x80 /* Host Initiated SCSI Bus Reset. */
3134 3107
3135/* 3108/*
3136 * Device drivers must define the following functions. 3109 * Device drivers must define the following functions.
3137 */ 3110 */
3138STATIC inline ulong DvcEnterCritical(void); 3111static inline ulong DvcEnterCritical(void);
3139STATIC inline void DvcLeaveCritical(ulong); 3112static inline void DvcLeaveCritical(ulong);
3140STATIC void DvcSleepMilliSecond(ADV_DCNT); 3113static void DvcSleepMilliSecond(ADV_DCNT);
3141STATIC uchar DvcAdvReadPCIConfigByte(ADV_DVC_VAR *, ushort); 3114static uchar DvcAdvReadPCIConfigByte(ADV_DVC_VAR *, ushort);
3142STATIC void DvcAdvWritePCIConfigByte(ADV_DVC_VAR *, ushort, uchar); 3115static void DvcAdvWritePCIConfigByte(ADV_DVC_VAR *, ushort, uchar);
3143STATIC ADV_PADDR DvcGetPhyAddr(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *, 3116static ADV_PADDR DvcGetPhyAddr(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *,
3144 uchar *, ASC_SDCNT *, int); 3117 uchar *, ASC_SDCNT *, int);
3145STATIC void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort); 3118static void DvcDelayMicroSecond(ADV_DVC_VAR *, ushort);
3146 3119
3147/* 3120/*
3148 * Adv Library functions available to drivers. 3121 * Adv Library functions available to drivers.
3149 */ 3122 */
3150STATIC int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *); 3123static int AdvExeScsiQueue(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
3151STATIC int AdvISR(ADV_DVC_VAR *); 3124static int AdvISR(ADV_DVC_VAR *);
3152STATIC int AdvInitGetConfig(ADV_DVC_VAR *); 3125static int AdvInitGetConfig(ADV_DVC_VAR *);
3153STATIC int AdvInitAsc3550Driver(ADV_DVC_VAR *); 3126static int AdvInitAsc3550Driver(ADV_DVC_VAR *);
3154STATIC int AdvInitAsc38C0800Driver(ADV_DVC_VAR *); 3127static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *);
3155STATIC int AdvInitAsc38C1600Driver(ADV_DVC_VAR *); 3128static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *);
3156STATIC int AdvResetChipAndSB(ADV_DVC_VAR *); 3129static int AdvResetChipAndSB(ADV_DVC_VAR *);
3157STATIC int AdvResetSB(ADV_DVC_VAR *asc_dvc); 3130static int AdvResetSB(ADV_DVC_VAR *asc_dvc);
3158 3131
3159/* 3132/*
3160 * Internal Adv Library functions. 3133 * Internal Adv Library functions.
3161 */ 3134 */
3162STATIC int AdvSendIdleCmd(ADV_DVC_VAR *, ushort, ADV_DCNT); 3135static int AdvSendIdleCmd(ADV_DVC_VAR *, ushort, ADV_DCNT);
3163STATIC void AdvInquiryHandling(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *); 3136static void AdvInquiryHandling(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
3164STATIC int AdvInitFrom3550EEP(ADV_DVC_VAR *); 3137static int AdvInitFrom3550EEP(ADV_DVC_VAR *);
3165STATIC int AdvInitFrom38C0800EEP(ADV_DVC_VAR *); 3138static int AdvInitFrom38C0800EEP(ADV_DVC_VAR *);
3166STATIC int AdvInitFrom38C1600EEP(ADV_DVC_VAR *); 3139static int AdvInitFrom38C1600EEP(ADV_DVC_VAR *);
3167STATIC ushort AdvGet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *); 3140static ushort AdvGet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
3168STATIC void AdvSet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *); 3141static void AdvSet3550EEPConfig(AdvPortAddr, ADVEEP_3550_CONFIG *);
3169STATIC ushort AdvGet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *); 3142static ushort AdvGet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
3170STATIC void AdvSet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *); 3143static void AdvSet38C0800EEPConfig(AdvPortAddr, ADVEEP_38C0800_CONFIG *);
3171STATIC ushort AdvGet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *); 3144static ushort AdvGet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
3172STATIC void AdvSet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *); 3145static void AdvSet38C1600EEPConfig(AdvPortAddr, ADVEEP_38C1600_CONFIG *);
3173STATIC void AdvWaitEEPCmd(AdvPortAddr); 3146static void AdvWaitEEPCmd(AdvPortAddr);
3174STATIC ushort AdvReadEEPWord(AdvPortAddr, int); 3147static ushort AdvReadEEPWord(AdvPortAddr, int);
3175 3148
3176/* 3149/*
3177 * PCI Bus Definitions 3150 * PCI Bus Definitions
@@ -3241,7 +3214,6 @@ do { \
3241#define AdvWriteWordAutoIncLram(iop_base, word) \ 3214#define AdvWriteWordAutoIncLram(iop_base, word) \
3242 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word))) 3215 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
3243 3216
3244
3245/* 3217/*
3246 * Define macro to check for Condor signature. 3218 * Define macro to check for Condor signature.
3247 * 3219 *
@@ -3313,7 +3285,7 @@ do { \
3313 * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values. 3285 * ASC_SCSI_REQ_Q 'done_status' and 'host_status' return values.
3314 */ 3286 */
3315 3287
3316#define QD_NO_STATUS 0x00 /* Request not completed yet. */ 3288#define QD_NO_STATUS 0x00 /* Request not completed yet. */
3317#define QD_NO_ERROR 0x01 3289#define QD_NO_ERROR 0x01
3318#define QD_ABORTED_BY_HOST 0x02 3290#define QD_ABORTED_BY_HOST 0x02
3319#define QD_WITH_ERROR 0x04 3291#define QD_WITH_ERROR 0x04
@@ -3323,30 +3295,29 @@ do { \
3323#define QHSTA_M_DATA_OVER_RUN 0x12 3295#define QHSTA_M_DATA_OVER_RUN 0x12
3324#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13 3296#define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
3325#define QHSTA_M_QUEUE_ABORTED 0x15 3297#define QHSTA_M_QUEUE_ABORTED 0x15
3326#define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */ 3298#define QHSTA_M_SXFR_SDMA_ERR 0x16 /* SXFR_STATUS SCSI DMA Error */
3327#define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */ 3299#define QHSTA_M_SXFR_SXFR_PERR 0x17 /* SXFR_STATUS SCSI Bus Parity Error */
3328#define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */ 3300#define QHSTA_M_RDMA_PERR 0x18 /* RISC PCI DMA parity error */
3329#define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */ 3301#define QHSTA_M_SXFR_OFF_UFLW 0x19 /* SXFR_STATUS Offset Underflow */
3330#define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */ 3302#define QHSTA_M_SXFR_OFF_OFLW 0x20 /* SXFR_STATUS Offset Overflow */
3331#define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */ 3303#define QHSTA_M_SXFR_WD_TMO 0x21 /* SXFR_STATUS Watchdog Timeout */
3332#define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */ 3304#define QHSTA_M_SXFR_DESELECTED 0x22 /* SXFR_STATUS Deselected */
3333/* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */ 3305/* Note: QHSTA_M_SXFR_XFR_OFLW is identical to QHSTA_M_DATA_OVER_RUN. */
3334#define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */ 3306#define QHSTA_M_SXFR_XFR_OFLW 0x12 /* SXFR_STATUS Transfer Overflow */
3335#define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */ 3307#define QHSTA_M_SXFR_XFR_PH_ERR 0x24 /* SXFR_STATUS Transfer Phase Error */
3336#define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */ 3308#define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25 /* SXFR_STATUS Unknown Error */
3337#define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */ 3309#define QHSTA_M_SCSI_BUS_RESET 0x30 /* Request aborted from SBR */
3338#define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */ 3310#define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31 /* Request aborted from unsol. SBR */
3339#define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */ 3311#define QHSTA_M_BUS_DEVICE_RESET 0x32 /* Request aborted from BDR */
3340#define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */ 3312#define QHSTA_M_DIRECTION_ERR 0x35 /* Data Phase mismatch */
3341#define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */ 3313#define QHSTA_M_DIRECTION_ERR_HUNG 0x36 /* Data Phase mismatch and bus hang */
3342#define QHSTA_M_WTM_TIMEOUT 0x41 3314#define QHSTA_M_WTM_TIMEOUT 0x41
3343#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42 3315#define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
3344#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43 3316#define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
3345#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44 3317#define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
3346#define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */ 3318#define QHSTA_M_INVALID_DEVICE 0x45 /* Bad target ID */
3347#define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */ 3319#define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
3348#define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */ 3320#define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
3349
3350 3321
3351/* 3322/*
3352 * Default EEPROM Configuration structure defined in a_init.c. 3323 * Default EEPROM Configuration structure defined in a_init.c.
@@ -3358,12 +3329,12 @@ static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config;
3358/* 3329/*
3359 * DvcGetPhyAddr() flag arguments 3330 * DvcGetPhyAddr() flag arguments
3360 */ 3331 */
3361#define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */ 3332#define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
3362#define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */ 3333#define ADV_ASCGETSGLIST_VADDR 0x02 /* 'addr' is AscGetSGList() virtual addr */
3363#define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */ 3334#define ADV_IS_SENSE_FLAG 0x04 /* 'addr' is sense virtual pointer */
3364#define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */ 3335#define ADV_IS_DATA_FLAG 0x08 /* 'addr' is data virtual pointer */
3365#define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */ 3336#define ADV_IS_SGLIST_FLAG 0x10 /* 'addr' is sglist virtual pointer */
3366#define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */ 3337#define ADV_IS_CARRIER_FLAG 0x20 /* 'addr' is ADV_CARR_T pointer */
3367 3338
3368/* Return the address that is aligned at the next doubleword >= to 'addr'. */ 3339/* Return the address that is aligned at the next doubleword >= to 'addr'. */
3369#define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7) 3340#define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
@@ -3413,43 +3384,42 @@ static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config;
3413#define ADV_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2) 3384#define ADV_INQ_CLOCKING(inq) (((inq)->info & 0x0c) >> 2)
3414 3385
3415typedef struct { 3386typedef struct {
3416 uchar periph; /* peripheral device type [0:4] */ 3387 uchar periph; /* peripheral device type [0:4] */
3417 /* peripheral qualifier [5:7] */ 3388 /* peripheral qualifier [5:7] */
3418 uchar devtype; /* device type modifier (for SCSI I) [0:6] */ 3389 uchar devtype; /* device type modifier (for SCSI I) [0:6] */
3419 /* RMB - removable medium bit [7] */ 3390 /* RMB - removable medium bit [7] */
3420 uchar ver; /* ANSI approved version [0:2] */ 3391 uchar ver; /* ANSI approved version [0:2] */
3421 /* ECMA version [3:5] */ 3392 /* ECMA version [3:5] */
3422 /* ISO version [6:7] */ 3393 /* ISO version [6:7] */
3423 uchar byte3; /* response data format [0:3] */ 3394 uchar byte3; /* response data format [0:3] */
3424 /* 0 SCSI 1 */ 3395 /* 0 SCSI 1 */
3425 /* 1 CCS */ 3396 /* 1 CCS */
3426 /* 2 SCSI-2 */ 3397 /* 2 SCSI-2 */
3427 /* 3-F reserved */ 3398 /* 3-F reserved */
3428 /* reserved [4:5] */ 3399 /* reserved [4:5] */
3429 /* terminate I/O process bit (see 5.6.22) [6] */ 3400 /* terminate I/O process bit (see 5.6.22) [6] */
3430 /* asynch. event notification (processor) [7] */ 3401 /* asynch. event notification (processor) [7] */
3431 uchar add_len; /* additional length */ 3402 uchar add_len; /* additional length */
3432 uchar res1; /* reserved */ 3403 uchar res1; /* reserved */
3433 uchar res2; /* reserved */ 3404 uchar res2; /* reserved */
3434 uchar flags; /* soft reset implemented [0] */ 3405 uchar flags; /* soft reset implemented [0] */
3435 /* command queuing [1] */ 3406 /* command queuing [1] */
3436 /* reserved [2] */ 3407 /* reserved [2] */
3437 /* linked command for this logical unit [3] */ 3408 /* linked command for this logical unit [3] */
3438 /* synchronous data transfer [4] */ 3409 /* synchronous data transfer [4] */
3439 /* wide bus 16 bit data transfer [5] */ 3410 /* wide bus 16 bit data transfer [5] */
3440 /* wide bus 32 bit data transfer [6] */ 3411 /* wide bus 32 bit data transfer [6] */
3441 /* relative addressing mode [7] */ 3412 /* relative addressing mode [7] */
3442 uchar vendor_id[8]; /* vendor identification */ 3413 uchar vendor_id[8]; /* vendor identification */
3443 uchar product_id[16]; /* product identification */ 3414 uchar product_id[16]; /* product identification */
3444 uchar product_rev_level[4]; /* product revision level */ 3415 uchar product_rev_level[4]; /* product revision level */
3445 uchar vendor_specific[20]; /* vendor specific */ 3416 uchar vendor_specific[20]; /* vendor specific */
3446 uchar info; /* information unit supported [0] */ 3417 uchar info; /* information unit supported [0] */
3447 /* quick arbitrate supported [1] */ 3418 /* quick arbitrate supported [1] */
3448 /* clocking field [2:3] */ 3419 /* clocking field [2:3] */
3449 /* reserved [4:7] */ 3420 /* reserved [4:7] */
3450 uchar res3; /* reserved */ 3421 uchar res3; /* reserved */
3451} ADV_SCSI_INQUIRY; /* 58 bytes */ 3422} ADV_SCSI_INQUIRY; /* 58 bytes */
3452
3453 3423
3454/* 3424/*
3455 * --- Driver Constants and Macros 3425 * --- Driver Constants and Macros
@@ -3464,15 +3434,15 @@ typedef struct {
3464 3434
3465/* asc_board_t flags */ 3435/* asc_board_t flags */
3466#define ASC_HOST_IN_RESET 0x01 3436#define ASC_HOST_IN_RESET 0x01
3467#define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */ 3437#define ASC_IS_WIDE_BOARD 0x04 /* AdvanSys Wide Board */
3468#define ASC_SELECT_QUEUE_DEPTHS 0x08 3438#define ASC_SELECT_QUEUE_DEPTHS 0x08
3469 3439
3470#define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0) 3440#define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
3471#define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD) 3441#define ASC_WIDE_BOARD(boardp) ((boardp)->flags & ASC_IS_WIDE_BOARD)
3472 3442
3473#define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */ 3443#define NO_ISA_DMA 0xff /* No ISA DMA Channel Used */
3474 3444
3475#define ASC_INFO_SIZE 128 /* advansys_info() line size */ 3445#define ASC_INFO_SIZE 128 /* advansys_info() line size */
3476 3446
3477#ifdef CONFIG_PROC_FS 3447#ifdef CONFIG_PROC_FS
3478/* /proc/scsi/advansys/[0...] related definitions */ 3448/* /proc/scsi/advansys/[0...] related definitions */
@@ -3514,7 +3484,7 @@ typedef struct {
3514 * REQPTIME(reqp) - reqp's time stamp value 3484 * REQPTIME(reqp) - reqp's time stamp value
3515 * REQTIMESTAMP() - system time stamp value 3485 * REQTIMESTAMP() - system time stamp value
3516 */ 3486 */
3517typedef struct scsi_cmnd REQ, *REQP; 3487typedef struct scsi_cmnd REQ, *REQP;
3518#define REQPNEXT(reqp) ((REQP) ((reqp)->host_scribble)) 3488#define REQPNEXT(reqp) ((REQP) ((reqp)->host_scribble))
3519#define REQPNEXTP(reqp) ((REQP *) &((reqp)->host_scribble)) 3489#define REQPNEXTP(reqp) ((REQP *) &((reqp)->host_scribble))
3520#define REQPTID(reqp) ((reqp)->device->id) 3490#define REQPTID(reqp) ((reqp)->device->id)
@@ -3564,17 +3534,17 @@ typedef struct scsi_cmnd REQ, *REQP;
3564#define PCI_MAX_SLOT 0x1F 3534#define PCI_MAX_SLOT 0x1F
3565#define PCI_MAX_BUS 0xFF 3535#define PCI_MAX_BUS 0xFF
3566#define PCI_IOADDRESS_MASK 0xFFFE 3536#define PCI_IOADDRESS_MASK 0xFFFE
3567#define ASC_PCI_DEVICE_ID_CNT 6 /* PCI Device ID count. */ 3537#define ASC_PCI_DEVICE_ID_CNT 6 /* PCI Device ID count. */
3568 3538
3569#ifndef ADVANSYS_STATS 3539#ifndef ADVANSYS_STATS
3570#define ASC_STATS(shp, counter) 3540#define ASC_STATS(shost, counter)
3571#define ASC_STATS_ADD(shp, counter, count) 3541#define ASC_STATS_ADD(shost, counter, count)
3572#else /* ADVANSYS_STATS */ 3542#else /* ADVANSYS_STATS */
3573#define ASC_STATS(shp, counter) \ 3543#define ASC_STATS(shost, counter) \
3574 (ASC_BOARDP(shp)->asc_stats.counter++) 3544 (ASC_BOARDP(shost)->asc_stats.counter++)
3575 3545
3576#define ASC_STATS_ADD(shp, counter, count) \ 3546#define ASC_STATS_ADD(shost, counter, count) \
3577 (ASC_BOARDP(shp)->asc_stats.counter += (count)) 3547 (ASC_BOARDP(shost)->asc_stats.counter += (count))
3578#endif /* ADVANSYS_STATS */ 3548#endif /* ADVANSYS_STATS */
3579 3549
3580#define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit)) 3550#define ASC_CEILING(val, unit) (((val) + ((unit) - 1))/(unit))
@@ -3617,7 +3587,6 @@ typedef struct scsi_cmnd REQ, *REQP;
3617 printk((s), (a1), (a2), (a3), (a4)); \ 3587 printk((s), (a1), (a2), (a3), (a4)); \
3618 } 3588 }
3619 3589
3620
3621#ifndef ADVANSYS_DEBUG 3590#ifndef ADVANSYS_DEBUG
3622 3591
3623#define ASC_DBG(lvl, s) 3592#define ASC_DBG(lvl, s)
@@ -3746,7 +3715,6 @@ typedef struct scsi_cmnd REQ, *REQP;
3746 3715
3747#endif /* ADVANSYS_ASSERT */ 3716#endif /* ADVANSYS_ASSERT */
3748 3717
3749
3750/* 3718/*
3751 * --- Driver Structures 3719 * --- Driver Structures
3752 */ 3720 */
@@ -3755,27 +3723,27 @@ typedef struct scsi_cmnd REQ, *REQP;
3755 3723
3756/* Per board statistics structure */ 3724/* Per board statistics structure */
3757struct asc_stats { 3725struct asc_stats {
3758 /* Driver Entrypoint Statistics */ 3726 /* Driver Entrypoint Statistics */
3759 ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */ 3727 ADV_DCNT queuecommand; /* # calls to advansys_queuecommand() */
3760 ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */ 3728 ADV_DCNT reset; /* # calls to advansys_eh_bus_reset() */
3761 ADV_DCNT biosparam; /* # calls to advansys_biosparam() */ 3729 ADV_DCNT biosparam; /* # calls to advansys_biosparam() */
3762 ADV_DCNT interrupt; /* # advansys_interrupt() calls */ 3730 ADV_DCNT interrupt; /* # advansys_interrupt() calls */
3763 ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */ 3731 ADV_DCNT callback; /* # calls to asc/adv_isr_callback() */
3764 ADV_DCNT done; /* # calls to request's scsi_done function */ 3732 ADV_DCNT done; /* # calls to request's scsi_done function */
3765 ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */ 3733 ADV_DCNT build_error; /* # asc/adv_build_req() ASC_ERROR returns. */
3766 ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */ 3734 ADV_DCNT adv_build_noreq; /* # adv_build_req() adv_req_t alloc. fail. */
3767 ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */ 3735 ADV_DCNT adv_build_nosg; /* # adv_build_req() adv_sgblk_t alloc. fail. */
3768 /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */ 3736 /* AscExeScsiQueue()/AdvExeScsiQueue() Statistics */
3769 ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */ 3737 ADV_DCNT exe_noerror; /* # ASC_NOERROR returns. */
3770 ADV_DCNT exe_busy; /* # ASC_BUSY returns. */ 3738 ADV_DCNT exe_busy; /* # ASC_BUSY returns. */
3771 ADV_DCNT exe_error; /* # ASC_ERROR returns. */ 3739 ADV_DCNT exe_error; /* # ASC_ERROR returns. */
3772 ADV_DCNT exe_unknown; /* # unknown returns. */ 3740 ADV_DCNT exe_unknown; /* # unknown returns. */
3773 /* Data Transfer Statistics */ 3741 /* Data Transfer Statistics */
3774 ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */ 3742 ADV_DCNT cont_cnt; /* # non-scatter-gather I/O requests received */
3775 ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */ 3743 ADV_DCNT cont_xfer; /* # contiguous transfer 512-bytes */
3776 ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */ 3744 ADV_DCNT sg_cnt; /* # scatter-gather I/O requests received */
3777 ADV_DCNT sg_elem; /* # scatter-gather elements */ 3745 ADV_DCNT sg_elem; /* # scatter-gather elements */
3778 ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */ 3746 ADV_DCNT sg_xfer; /* # scatter-gather transfer 512-bytes */
3779}; 3747};
3780#endif /* ADVANSYS_STATS */ 3748#endif /* ADVANSYS_STATS */
3781 3749
@@ -3783,17 +3751,17 @@ struct asc_stats {
3783 * Request queuing structure 3751 * Request queuing structure
3784 */ 3752 */
3785typedef struct asc_queue { 3753typedef struct asc_queue {
3786 ADV_SCSI_BIT_ID_TYPE q_tidmask; /* queue mask */ 3754 ADV_SCSI_BIT_ID_TYPE q_tidmask; /* queue mask */
3787 REQP q_first[ADV_MAX_TID+1]; /* first queued request */ 3755 REQP q_first[ADV_MAX_TID + 1]; /* first queued request */
3788 REQP q_last[ADV_MAX_TID+1]; /* last queued request */ 3756 REQP q_last[ADV_MAX_TID + 1]; /* last queued request */
3789#ifdef ADVANSYS_STATS 3757#ifdef ADVANSYS_STATS
3790 short q_cur_cnt[ADV_MAX_TID+1]; /* current queue count */ 3758 short q_cur_cnt[ADV_MAX_TID + 1]; /* current queue count */
3791 short q_max_cnt[ADV_MAX_TID+1]; /* maximum queue count */ 3759 short q_max_cnt[ADV_MAX_TID + 1]; /* maximum queue count */
3792 ADV_DCNT q_tot_cnt[ADV_MAX_TID+1]; /* total enqueue count */ 3760 ADV_DCNT q_tot_cnt[ADV_MAX_TID + 1]; /* total enqueue count */
3793 ADV_DCNT q_tot_tim[ADV_MAX_TID+1]; /* total time queued */ 3761 ADV_DCNT q_tot_tim[ADV_MAX_TID + 1]; /* total time queued */
3794 ushort q_max_tim[ADV_MAX_TID+1]; /* maximum time queued */ 3762 ushort q_max_tim[ADV_MAX_TID + 1]; /* maximum time queued */
3795 ushort q_min_tim[ADV_MAX_TID+1]; /* minimum time queued */ 3763 ushort q_min_tim[ADV_MAX_TID + 1]; /* minimum time queued */
3796#endif /* ADVANSYS_STATS */ 3764#endif /* ADVANSYS_STATS */
3797} asc_queue_t; 3765} asc_queue_t;
3798 3766
3799/* 3767/*
@@ -3814,17 +3782,17 @@ typedef struct asc_queue {
3814 * Both structures must be 32 byte aligned. 3782 * Both structures must be 32 byte aligned.
3815 */ 3783 */
3816typedef struct adv_sgblk { 3784typedef struct adv_sgblk {
3817 ADV_SG_BLOCK sg_block; /* Sgblock structure. */ 3785 ADV_SG_BLOCK sg_block; /* Sgblock structure. */
3818 uchar align[32]; /* Sgblock structure padding. */ 3786 uchar align[32]; /* Sgblock structure padding. */
3819 struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */ 3787 struct adv_sgblk *next_sgblkp; /* Next scatter-gather structure. */
3820} adv_sgblk_t; 3788} adv_sgblk_t;
3821 3789
3822typedef struct adv_req { 3790typedef struct adv_req {
3823 ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */ 3791 ADV_SCSI_REQ_Q scsi_req_q; /* Adv Library request structure. */
3824 uchar align[32]; /* Request structure padding. */ 3792 uchar align[32]; /* Request structure padding. */
3825 struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */ 3793 struct scsi_cmnd *cmndp; /* Mid-Level SCSI command pointer. */
3826 adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */ 3794 adv_sgblk_t *sgblkp; /* Adv Library scatter-gather pointer. */
3827 struct adv_req *next_reqp; /* Next Request Structure. */ 3795 struct adv_req *next_reqp; /* Next Request Structure. */
3828} adv_req_t; 3796} adv_req_t;
3829 3797
3830/* 3798/*
@@ -3835,113 +3803,109 @@ typedef struct adv_req {
3835 * field. It is guaranteed to be allocated from DMA-able memory. 3803 * field. It is guaranteed to be allocated from DMA-able memory.
3836 */ 3804 */
3837typedef struct asc_board { 3805typedef struct asc_board {
3838 int id; /* Board Id */ 3806 int id; /* Board Id */
3839 uint flags; /* Board flags */ 3807 uint flags; /* Board flags */
3840 union { 3808 union {
3841 ASC_DVC_VAR asc_dvc_var; /* Narrow board */ 3809 ASC_DVC_VAR asc_dvc_var; /* Narrow board */
3842 ADV_DVC_VAR adv_dvc_var; /* Wide board */ 3810 ADV_DVC_VAR adv_dvc_var; /* Wide board */
3843 } dvc_var; 3811 } dvc_var;
3844 union { 3812 union {
3845 ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */ 3813 ASC_DVC_CFG asc_dvc_cfg; /* Narrow board */
3846 ADV_DVC_CFG adv_dvc_cfg; /* Wide board */ 3814 ADV_DVC_CFG adv_dvc_cfg; /* Wide board */
3847 } dvc_cfg; 3815 } dvc_cfg;
3848 ushort asc_n_io_port; /* Number I/O ports. */ 3816 ushort asc_n_io_port; /* Number I/O ports. */
3849 asc_queue_t active; /* Active command queue */ 3817 asc_queue_t active; /* Active command queue */
3850 asc_queue_t waiting; /* Waiting command queue */ 3818 asc_queue_t waiting; /* Waiting command queue */
3851 asc_queue_t done; /* Done command queue */ 3819 asc_queue_t done; /* Done command queue */
3852 ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */ 3820 ADV_SCSI_BIT_ID_TYPE init_tidmask; /* Target init./valid mask */
3853 struct scsi_device *device[ADV_MAX_TID+1]; /* Mid-Level Scsi Device */ 3821 struct scsi_device *device[ADV_MAX_TID + 1]; /* Mid-Level Scsi Device */
3854 ushort reqcnt[ADV_MAX_TID+1]; /* Starvation request count */ 3822 ushort reqcnt[ADV_MAX_TID + 1]; /* Starvation request count */
3855 ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */ 3823 ADV_SCSI_BIT_ID_TYPE queue_full; /* Queue full mask */
3856 ushort queue_full_cnt[ADV_MAX_TID+1]; /* Queue full count */ 3824 ushort queue_full_cnt[ADV_MAX_TID + 1]; /* Queue full count */
3857 union { 3825 union {
3858 ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */ 3826 ASCEEP_CONFIG asc_eep; /* Narrow EEPROM config. */
3859 ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */ 3827 ADVEEP_3550_CONFIG adv_3550_eep; /* 3550 EEPROM config. */
3860 ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */ 3828 ADVEEP_38C0800_CONFIG adv_38C0800_eep; /* 38C0800 EEPROM config. */
3861 ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */ 3829 ADVEEP_38C1600_CONFIG adv_38C1600_eep; /* 38C1600 EEPROM config. */
3862 } eep_config; 3830 } eep_config;
3863 ulong last_reset; /* Saved last reset time */ 3831 ulong last_reset; /* Saved last reset time */
3864 spinlock_t lock; /* Board spinlock */ 3832 spinlock_t lock; /* Board spinlock */
3865#ifdef CONFIG_PROC_FS 3833#ifdef CONFIG_PROC_FS
3866 /* /proc/scsi/advansys/[0...] */ 3834 /* /proc/scsi/advansys/[0...] */
3867 char *prtbuf; /* /proc print buffer */ 3835 char *prtbuf; /* /proc print buffer */
3868#endif /* CONFIG_PROC_FS */ 3836#endif /* CONFIG_PROC_FS */
3869#ifdef ADVANSYS_STATS 3837#ifdef ADVANSYS_STATS
3870 struct asc_stats asc_stats; /* Board statistics */ 3838 struct asc_stats asc_stats; /* Board statistics */
3871#endif /* ADVANSYS_STATS */ 3839#endif /* ADVANSYS_STATS */
3872 /* 3840 /*
3873 * The following fields are used only for Narrow Boards. 3841 * The following fields are used only for Narrow Boards.
3874 */ 3842 */
3875 /* The following three structures must be in DMA-able memory. */ 3843 /* The following three structures must be in DMA-able memory. */
3876 ASC_SCSI_REQ_Q scsireqq; 3844 ASC_SCSI_REQ_Q scsireqq;
3877 ASC_CAP_INFO cap_info; 3845 ASC_CAP_INFO cap_info;
3878 ASC_SCSI_INQUIRY inquiry; 3846 ASC_SCSI_INQUIRY inquiry;
3879 uchar sdtr_data[ASC_MAX_TID+1]; /* SDTR information */ 3847 uchar sdtr_data[ASC_MAX_TID + 1]; /* SDTR information */
3880 /* 3848 /*
3881 * The following fields are used only for Wide Boards. 3849 * The following fields are used only for Wide Boards.
3882 */ 3850 */
3883 void __iomem *ioremap_addr; /* I/O Memory remap address. */ 3851 void __iomem *ioremap_addr; /* I/O Memory remap address. */
3884 ushort ioport; /* I/O Port address. */ 3852 ushort ioport; /* I/O Port address. */
3885 ADV_CARR_T *orig_carrp; /* ADV_CARR_T memory block. */ 3853 ADV_CARR_T *orig_carrp; /* ADV_CARR_T memory block. */
3886 adv_req_t *orig_reqp; /* adv_req_t memory block. */ 3854 adv_req_t *orig_reqp; /* adv_req_t memory block. */
3887 adv_req_t *adv_reqp; /* Request structures. */ 3855 adv_req_t *adv_reqp; /* Request structures. */
3888 adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */ 3856 adv_sgblk_t *adv_sgblkp; /* Scatter-gather structures. */
3889 ushort bios_signature; /* BIOS Signature. */ 3857 ushort bios_signature; /* BIOS Signature. */
3890 ushort bios_version; /* BIOS Version. */ 3858 ushort bios_version; /* BIOS Version. */
3891 ushort bios_codeseg; /* BIOS Code Segment. */ 3859 ushort bios_codeseg; /* BIOS Code Segment. */
3892 ushort bios_codelen; /* BIOS Code Segment Length. */ 3860 ushort bios_codelen; /* BIOS Code Segment Length. */
3893} asc_board_t; 3861} asc_board_t;
3894 3862
3895/* 3863/*
3896 * PCI configuration structures 3864 * PCI configuration structures
3897 */ 3865 */
3898typedef struct _PCI_DATA_ 3866typedef struct _PCI_DATA_ {
3899{ 3867 uchar type;
3900 uchar type; 3868 uchar bus;
3901 uchar bus; 3869 uchar slot;
3902 uchar slot; 3870 uchar func;
3903 uchar func; 3871 uchar offset;
3904 uchar offset;
3905} PCI_DATA; 3872} PCI_DATA;
3906 3873
3907typedef struct _PCI_DEVICE_ 3874typedef struct _PCI_DEVICE_ {
3908{ 3875 ushort vendorID;
3909 ushort vendorID; 3876 ushort deviceID;
3910 ushort deviceID; 3877 ushort slotNumber;
3911 ushort slotNumber; 3878 ushort slotFound;
3912 ushort slotFound; 3879 uchar busNumber;
3913 uchar busNumber; 3880 uchar maxBusNumber;
3914 uchar maxBusNumber; 3881 uchar devFunc;
3915 uchar devFunc; 3882 ushort startSlot;
3916 ushort startSlot; 3883 ushort endSlot;
3917 ushort endSlot; 3884 uchar bridge;
3918 uchar bridge; 3885 uchar type;
3919 uchar type;
3920} PCI_DEVICE; 3886} PCI_DEVICE;
3921 3887
3922typedef struct _PCI_CONFIG_SPACE_ 3888typedef struct _PCI_CONFIG_SPACE_ {
3923{ 3889 ushort vendorID;
3924 ushort vendorID; 3890 ushort deviceID;
3925 ushort deviceID; 3891 ushort command;
3926 ushort command; 3892 ushort status;
3927 ushort status; 3893 uchar revision;
3928 uchar revision; 3894 uchar classCode[3];
3929 uchar classCode[3]; 3895 uchar cacheSize;
3930 uchar cacheSize; 3896 uchar latencyTimer;
3931 uchar latencyTimer; 3897 uchar headerType;
3932 uchar headerType; 3898 uchar bist;
3933 uchar bist; 3899 ADV_PADDR baseAddress[6];
3934 ADV_PADDR baseAddress[6]; 3900 ushort reserved[4];
3935 ushort reserved[4]; 3901 ADV_PADDR optionRomAddr;
3936 ADV_PADDR optionRomAddr; 3902 ushort reserved2[4];
3937 ushort reserved2[4]; 3903 uchar irqLine;
3938 uchar irqLine; 3904 uchar irqPin;
3939 uchar irqPin; 3905 uchar minGnt;
3940 uchar minGnt; 3906 uchar maxLatency;
3941 uchar maxLatency;
3942} PCI_CONFIG_SPACE; 3907} PCI_CONFIG_SPACE;
3943 3908
3944
3945/* 3909/*
3946 * --- Driver Data 3910 * --- Driver Data
3947 */ 3911 */
@@ -3949,44 +3913,42 @@ typedef struct _PCI_CONFIG_SPACE_
3949/* Note: All driver global data should be initialized. */ 3913/* Note: All driver global data should be initialized. */
3950 3914
3951/* Number of boards detected in system. */ 3915/* Number of boards detected in system. */
3952STATIC int asc_board_count = 0; 3916static int asc_board_count = 0;
3953STATIC struct Scsi_Host *asc_host[ASC_NUM_BOARD_SUPPORTED] = { NULL }; 3917static struct Scsi_Host *asc_host[ASC_NUM_BOARD_SUPPORTED] = { NULL };
3954 3918
3955/* Overrun buffer used by all narrow boards. */ 3919/* Overrun buffer used by all narrow boards. */
3956STATIC uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 }; 3920static uchar overrun_buf[ASC_OVERRUN_BSIZE] = { 0 };
3957 3921
3958/* 3922/*
3959 * Global structures required to issue a command. 3923 * Global structures required to issue a command.
3960 */ 3924 */
3961STATIC ASC_SCSI_Q asc_scsi_q = { { 0 } }; 3925static ASC_SCSI_Q asc_scsi_q = { {0} };
3962STATIC ASC_SG_HEAD asc_sg_head = { 0 }; 3926static ASC_SG_HEAD asc_sg_head = { 0 };
3963 3927
3964/* List of supported bus types. */ 3928/* List of supported bus types. */
3965STATIC ushort asc_bus[ASC_NUM_BUS] __initdata = { 3929static ushort asc_bus[ASC_NUM_BUS] __initdata = {
3966 ASC_IS_ISA, 3930 ASC_IS_ISA,
3967 ASC_IS_VL, 3931 ASC_IS_VL,
3968 ASC_IS_EISA, 3932 ASC_IS_EISA,
3969 ASC_IS_PCI, 3933 ASC_IS_PCI,
3970}; 3934};
3971 3935
3972STATIC int asc_iopflag = ASC_FALSE; 3936static int asc_iopflag = ASC_FALSE;
3973STATIC int asc_ioport[ASC_NUM_IOPORT_PROBE] = { 0, 0, 0, 0 }; 3937static int asc_ioport[ASC_NUM_IOPORT_PROBE] = { 0, 0, 0, 0 };
3974 3938
3975#ifdef ADVANSYS_DEBUG 3939#ifdef ADVANSYS_DEBUG
3976STATIC char * 3940static char *asc_bus_name[ASC_NUM_BUS] = {
3977asc_bus_name[ASC_NUM_BUS] = { 3941 "ASC_IS_ISA",
3978 "ASC_IS_ISA", 3942 "ASC_IS_VL",
3979 "ASC_IS_VL", 3943 "ASC_IS_EISA",
3980 "ASC_IS_EISA", 3944 "ASC_IS_PCI",
3981 "ASC_IS_PCI",
3982}; 3945};
3983 3946
3984STATIC int asc_dbglvl = 3; 3947static int asc_dbglvl = 3;
3985#endif /* ADVANSYS_DEBUG */ 3948#endif /* ADVANSYS_DEBUG */
3986 3949
3987/* Declaration for Asc Library internal data referenced by driver. */ 3950/* Declaration for Asc Library internal data referenced by driver. */
3988STATIC PortAddr _asc_def_iop_base[]; 3951static PortAddr _asc_def_iop_base[];
3989
3990 3952
3991/* 3953/*
3992 * --- Driver Function Prototypes 3954 * --- Driver Function Prototypes
@@ -3994,62 +3956,61 @@ STATIC PortAddr _asc_def_iop_base[];
3994 * advansys.h contains function prototypes for functions global to Linux. 3956 * advansys.h contains function prototypes for functions global to Linux.
3995 */ 3957 */
3996 3958
3997STATIC irqreturn_t advansys_interrupt(int, void *); 3959static irqreturn_t advansys_interrupt(int, void *);
3998STATIC int advansys_slave_configure(struct scsi_device *); 3960static int advansys_slave_configure(struct scsi_device *);
3999STATIC void asc_scsi_done_list(struct scsi_cmnd *); 3961static void asc_scsi_done_list(struct scsi_cmnd *);
4000STATIC int asc_execute_scsi_cmnd(struct scsi_cmnd *); 3962static int asc_execute_scsi_cmnd(struct scsi_cmnd *);
4001STATIC int asc_build_req(asc_board_t *, struct scsi_cmnd *); 3963static int asc_build_req(asc_board_t *, struct scsi_cmnd *);
4002STATIC int adv_build_req(asc_board_t *, struct scsi_cmnd *, ADV_SCSI_REQ_Q **); 3964static int adv_build_req(asc_board_t *, struct scsi_cmnd *, ADV_SCSI_REQ_Q **);
4003STATIC int adv_get_sglist(asc_board_t *, adv_req_t *, struct scsi_cmnd *, int); 3965static int adv_get_sglist(asc_board_t *, adv_req_t *, struct scsi_cmnd *, int);
4004STATIC void asc_isr_callback(ASC_DVC_VAR *, ASC_QDONE_INFO *); 3966static void asc_isr_callback(ASC_DVC_VAR *, ASC_QDONE_INFO *);
4005STATIC void adv_isr_callback(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *); 3967static void adv_isr_callback(ADV_DVC_VAR *, ADV_SCSI_REQ_Q *);
4006STATIC void adv_async_callback(ADV_DVC_VAR *, uchar); 3968static void adv_async_callback(ADV_DVC_VAR *, uchar);
4007STATIC void asc_enqueue(asc_queue_t *, REQP, int); 3969static void asc_enqueue(asc_queue_t *, REQP, int);
4008STATIC REQP asc_dequeue(asc_queue_t *, int); 3970static REQP asc_dequeue(asc_queue_t *, int);
4009STATIC REQP asc_dequeue_list(asc_queue_t *, REQP *, int); 3971static REQP asc_dequeue_list(asc_queue_t *, REQP *, int);
4010STATIC int asc_rmqueue(asc_queue_t *, REQP); 3972static int asc_rmqueue(asc_queue_t *, REQP);
4011STATIC void asc_execute_queue(asc_queue_t *); 3973static void asc_execute_queue(asc_queue_t *);
4012#ifdef CONFIG_PROC_FS 3974#ifdef CONFIG_PROC_FS
4013STATIC int asc_proc_copy(off_t, off_t, char *, int , char *, int); 3975static int asc_proc_copy(off_t, off_t, char *, int, char *, int);
4014STATIC int asc_prt_board_devices(struct Scsi_Host *, char *, int); 3976static int asc_prt_board_devices(struct Scsi_Host *, char *, int);
4015STATIC int asc_prt_adv_bios(struct Scsi_Host *, char *, int); 3977static int asc_prt_adv_bios(struct Scsi_Host *, char *, int);
4016STATIC int asc_get_eeprom_string(ushort *serialnum, uchar *cp); 3978static int asc_get_eeprom_string(ushort *serialnum, uchar *cp);
4017STATIC int asc_prt_asc_board_eeprom(struct Scsi_Host *, char *, int); 3979static int asc_prt_asc_board_eeprom(struct Scsi_Host *, char *, int);
4018STATIC int asc_prt_adv_board_eeprom(struct Scsi_Host *, char *, int); 3980static int asc_prt_adv_board_eeprom(struct Scsi_Host *, char *, int);
4019STATIC int asc_prt_driver_conf(struct Scsi_Host *, char *, int); 3981static int asc_prt_driver_conf(struct Scsi_Host *, char *, int);
4020STATIC int asc_prt_asc_board_info(struct Scsi_Host *, char *, int); 3982static int asc_prt_asc_board_info(struct Scsi_Host *, char *, int);
4021STATIC int asc_prt_adv_board_info(struct Scsi_Host *, char *, int); 3983static int asc_prt_adv_board_info(struct Scsi_Host *, char *, int);
4022STATIC int asc_prt_line(char *, int, char *fmt, ...); 3984static int asc_prt_line(char *, int, char *fmt, ...);
4023#endif /* CONFIG_PROC_FS */ 3985#endif /* CONFIG_PROC_FS */
4024 3986
4025/* Declaration for Asc Library internal functions referenced by driver. */ 3987/* Declaration for Asc Library internal functions referenced by driver. */
4026STATIC int AscFindSignature(PortAddr); 3988static int AscFindSignature(PortAddr);
4027STATIC ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort); 3989static ushort AscGetEEPConfig(PortAddr, ASCEEP_CONFIG *, ushort);
4028 3990
4029/* Statistics function prototypes. */ 3991/* Statistics function prototypes. */
4030#ifdef ADVANSYS_STATS 3992#ifdef ADVANSYS_STATS
4031#ifdef CONFIG_PROC_FS 3993#ifdef CONFIG_PROC_FS
4032STATIC int asc_prt_board_stats(struct Scsi_Host *, char *, int); 3994static int asc_prt_board_stats(struct Scsi_Host *, char *, int);
4033STATIC int asc_prt_target_stats(struct Scsi_Host *, int, char *, int); 3995static int asc_prt_target_stats(struct Scsi_Host *, int, char *, int);
4034#endif /* CONFIG_PROC_FS */ 3996#endif /* CONFIG_PROC_FS */
4035#endif /* ADVANSYS_STATS */ 3997#endif /* ADVANSYS_STATS */
4036 3998
4037/* Debug function prototypes. */ 3999/* Debug function prototypes. */
4038#ifdef ADVANSYS_DEBUG 4000#ifdef ADVANSYS_DEBUG
4039STATIC void asc_prt_scsi_host(struct Scsi_Host *); 4001static void asc_prt_scsi_host(struct Scsi_Host *);
4040STATIC void asc_prt_scsi_cmnd(struct scsi_cmnd *); 4002static void asc_prt_scsi_cmnd(struct scsi_cmnd *);
4041STATIC void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *); 4003static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *);
4042STATIC void asc_prt_asc_dvc_var(ASC_DVC_VAR *); 4004static void asc_prt_asc_dvc_var(ASC_DVC_VAR *);
4043STATIC void asc_prt_asc_scsi_q(ASC_SCSI_Q *); 4005static void asc_prt_asc_scsi_q(ASC_SCSI_Q *);
4044STATIC void asc_prt_asc_qdone_info(ASC_QDONE_INFO *); 4006static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *);
4045STATIC void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *); 4007static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *);
4046STATIC void asc_prt_adv_dvc_var(ADV_DVC_VAR *); 4008static void asc_prt_adv_dvc_var(ADV_DVC_VAR *);
4047STATIC void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *); 4009static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *);
4048STATIC void asc_prt_adv_sgblock(int, ADV_SG_BLOCK *); 4010static void asc_prt_adv_sgblock(int, ADV_SG_BLOCK *);
4049STATIC void asc_prt_hex(char *f, uchar *, int); 4011static void asc_prt_hex(char *f, uchar *, int);
4050#endif /* ADVANSYS_DEBUG */ 4012#endif /* ADVANSYS_DEBUG */
4051 4013
4052
4053#ifdef CONFIG_PROC_FS 4014#ifdef CONFIG_PROC_FS
4054/* 4015/*
4055 * advansys_proc_info() - /proc/scsi/advansys/[0-(ASC_NUM_BOARD_SUPPORTED-1)] 4016 * advansys_proc_info() - /proc/scsi/advansys/[0-(ASC_NUM_BOARD_SUPPORTED-1)]
@@ -4073,1389 +4034,210 @@ STATIC void asc_prt_hex(char *f, uchar *, int);
4073 */ 4034 */
4074static int 4035static int
4075advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start, 4036advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
4076 off_t offset, int length, int inout) 4037 off_t offset, int length, int inout)
4077{ 4038{
4078 struct Scsi_Host *shp; 4039 struct Scsi_Host *shp;
4079 asc_board_t *boardp; 4040 asc_board_t *boardp;
4080 int i; 4041 int i;
4081 char *cp; 4042 char *cp;
4082 int cplen; 4043 int cplen;
4083 int cnt; 4044 int cnt;
4084 int totcnt; 4045 int totcnt;
4085 int leftlen; 4046 int leftlen;
4086 char *curbuf; 4047 char *curbuf;
4087 off_t advoffset; 4048 off_t advoffset;
4088#ifdef ADVANSYS_STATS 4049#ifdef ADVANSYS_STATS
4089 int tgt_id; 4050 int tgt_id;
4090#endif /* ADVANSYS_STATS */ 4051#endif /* ADVANSYS_STATS */
4091 4052
4092 ASC_DBG(1, "advansys_proc_info: begin\n"); 4053 ASC_DBG(1, "advansys_proc_info: begin\n");
4093
4094 /*
4095 * User write not supported.
4096 */
4097 if (inout == TRUE) {
4098 return(-ENOSYS);
4099 }
4100 4054
4101 /* 4055 /*
4102 * User read of /proc/scsi/advansys/[0...] file. 4056 * User write not supported.
4103 */ 4057 */
4104 4058 if (inout == TRUE) {
4105 /* Find the specified board. */ 4059 return (-ENOSYS);
4106 for (i = 0; i < asc_board_count; i++) { 4060 }
4107 if (asc_host[i]->host_no == shost->host_no) {
4108 break;
4109 }
4110 }
4111 if (i == asc_board_count) {
4112 return(-ENOENT);
4113 }
4114
4115 shp = asc_host[i];
4116 boardp = ASC_BOARDP(shp);
4117
4118 /* Copy read data starting at the beginning of the buffer. */
4119 *start = buffer;
4120 curbuf = buffer;
4121 advoffset = 0;
4122 totcnt = 0;
4123 leftlen = length;
4124
4125 /*
4126 * Get board configuration information.
4127 *
4128 * advansys_info() returns the board string from its own static buffer.
4129 */
4130 cp = (char *) advansys_info(shp);
4131 strcat(cp, "\n");
4132 cplen = strlen(cp);
4133 /* Copy board information. */
4134 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4135 totcnt += cnt;
4136 leftlen -= cnt;
4137 if (leftlen == 0) {
4138 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4139 return totcnt;
4140 }
4141 advoffset += cplen;
4142 curbuf += cnt;
4143 4061
4144 /* 4062 /*
4145 * Display Wide Board BIOS Information. 4063 * User read of /proc/scsi/advansys/[0...] file.
4146 */ 4064 */
4147 if (ASC_WIDE_BOARD(boardp)) {
4148 cp = boardp->prtbuf;
4149 cplen = asc_prt_adv_bios(shp, cp, ASC_PRTBUF_SIZE);
4150 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4151 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4152 totcnt += cnt;
4153 leftlen -= cnt;
4154 if (leftlen == 0) {
4155 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4156 return totcnt;
4157 }
4158 advoffset += cplen;
4159 curbuf += cnt;
4160 }
4161 4065
4162 /* 4066 /* Find the specified board. */
4163 * Display driver information for each device attached to the board. 4067 for (i = 0; i < asc_board_count; i++) {
4164 */ 4068 if (asc_host[i]->host_no == shost->host_no) {
4165 cp = boardp->prtbuf; 4069 break;
4166 cplen = asc_prt_board_devices(shp, cp, ASC_PRTBUF_SIZE); 4070 }
4167 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE); 4071 }
4168 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); 4072 if (i == asc_board_count) {
4169 totcnt += cnt; 4073 return (-ENOENT);
4170 leftlen -= cnt; 4074 }
4171 if (leftlen == 0) {
4172 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4173 return totcnt;
4174 }
4175 advoffset += cplen;
4176 curbuf += cnt;
4177 4075
4178 /* 4076 shp = asc_host[i];
4179 * Display EEPROM configuration for the board. 4077 boardp = ASC_BOARDP(shp);
4180 */ 4078
4181 cp = boardp->prtbuf; 4079 /* Copy read data starting at the beginning of the buffer. */
4182 if (ASC_NARROW_BOARD(boardp)) { 4080 *start = buffer;
4183 cplen = asc_prt_asc_board_eeprom(shp, cp, ASC_PRTBUF_SIZE); 4081 curbuf = buffer;
4184 } else { 4082 advoffset = 0;
4185 cplen = asc_prt_adv_board_eeprom(shp, cp, ASC_PRTBUF_SIZE); 4083 totcnt = 0;
4186 } 4084 leftlen = length;
4187 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE); 4085
4188 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); 4086 /*
4189 totcnt += cnt; 4087 * Get board configuration information.
4190 leftlen -= cnt; 4088 *
4191 if (leftlen == 0) { 4089 * advansys_info() returns the board string from its own static buffer.
4192 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt); 4090 */
4193 return totcnt; 4091 cp = (char *)advansys_info(shp);
4194 } 4092 strcat(cp, "\n");
4195 advoffset += cplen; 4093 cplen = strlen(cp);
4196 curbuf += cnt; 4094 /* Copy board information. */
4095 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4096 totcnt += cnt;
4097 leftlen -= cnt;
4098 if (leftlen == 0) {
4099 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4100 return totcnt;
4101 }
4102 advoffset += cplen;
4103 curbuf += cnt;
4104
4105 /*
4106 * Display Wide Board BIOS Information.
4107 */
4108 if (ASC_WIDE_BOARD(boardp)) {
4109 cp = boardp->prtbuf;
4110 cplen = asc_prt_adv_bios(shp, cp, ASC_PRTBUF_SIZE);
4111 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4112 cnt =
4113 asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
4114 cplen);
4115 totcnt += cnt;
4116 leftlen -= cnt;
4117 if (leftlen == 0) {
4118 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4119 return totcnt;
4120 }
4121 advoffset += cplen;
4122 curbuf += cnt;
4123 }
4197 4124
4198 /* 4125 /*
4199 * Display driver configuration and information for the board. 4126 * Display driver information for each device attached to the board.
4200 */ 4127 */
4201 cp = boardp->prtbuf; 4128 cp = boardp->prtbuf;
4202 cplen = asc_prt_driver_conf(shp, cp, ASC_PRTBUF_SIZE); 4129 cplen = asc_prt_board_devices(shp, cp, ASC_PRTBUF_SIZE);
4203 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE); 4130 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4204 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); 4131 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4205 totcnt += cnt; 4132 totcnt += cnt;
4206 leftlen -= cnt; 4133 leftlen -= cnt;
4207 if (leftlen == 0) { 4134 if (leftlen == 0) {
4208 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt); 4135 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4209 return totcnt; 4136 return totcnt;
4210 } 4137 }
4211 advoffset += cplen; 4138 advoffset += cplen;
4212 curbuf += cnt; 4139 curbuf += cnt;
4140
4141 /*
4142 * Display EEPROM configuration for the board.
4143 */
4144 cp = boardp->prtbuf;
4145 if (ASC_NARROW_BOARD(boardp)) {
4146 cplen = asc_prt_asc_board_eeprom(shp, cp, ASC_PRTBUF_SIZE);
4147 } else {
4148 cplen = asc_prt_adv_board_eeprom(shp, cp, ASC_PRTBUF_SIZE);
4149 }
4150 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4151 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4152 totcnt += cnt;
4153 leftlen -= cnt;
4154 if (leftlen == 0) {
4155 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4156 return totcnt;
4157 }
4158 advoffset += cplen;
4159 curbuf += cnt;
4160
4161 /*
4162 * Display driver configuration and information for the board.
4163 */
4164 cp = boardp->prtbuf;
4165 cplen = asc_prt_driver_conf(shp, cp, ASC_PRTBUF_SIZE);
4166 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4167 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4168 totcnt += cnt;
4169 leftlen -= cnt;
4170 if (leftlen == 0) {
4171 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4172 return totcnt;
4173 }
4174 advoffset += cplen;
4175 curbuf += cnt;
4213 4176
4214#ifdef ADVANSYS_STATS 4177#ifdef ADVANSYS_STATS
4215 /* 4178 /*
4216 * Display driver statistics for the board. 4179 * Display driver statistics for the board.
4217 */ 4180 */
4218 cp = boardp->prtbuf; 4181 cp = boardp->prtbuf;
4219 cplen = asc_prt_board_stats(shp, cp, ASC_PRTBUF_SIZE); 4182 cplen = asc_prt_board_stats(shp, cp, ASC_PRTBUF_SIZE);
4220 ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE); 4183 ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
4221 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); 4184 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4222 totcnt += cnt; 4185 totcnt += cnt;
4223 leftlen -= cnt; 4186 leftlen -= cnt;
4224 if (leftlen == 0) { 4187 if (leftlen == 0) {
4225 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt); 4188 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4226 return totcnt; 4189 return totcnt;
4227 } 4190 }
4228 advoffset += cplen; 4191 advoffset += cplen;
4229 curbuf += cnt; 4192 curbuf += cnt;
4230 4193
4231 /* 4194 /*
4232 * Display driver statistics for each target. 4195 * Display driver statistics for each target.
4233 */ 4196 */
4234 for (tgt_id = 0; tgt_id <= ADV_MAX_TID; tgt_id++) { 4197 for (tgt_id = 0; tgt_id <= ADV_MAX_TID; tgt_id++) {
4235 cp = boardp->prtbuf; 4198 cp = boardp->prtbuf;
4236 cplen = asc_prt_target_stats(shp, tgt_id, cp, ASC_PRTBUF_SIZE); 4199 cplen = asc_prt_target_stats(shp, tgt_id, cp, ASC_PRTBUF_SIZE);
4237 ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE); 4200 ASC_ASSERT(cplen <= ASC_PRTBUF_SIZE);
4238 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); 4201 cnt =
4239 totcnt += cnt; 4202 asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
4240 leftlen -= cnt; 4203 cplen);
4241 if (leftlen == 0) { 4204 totcnt += cnt;
4242 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt); 4205 leftlen -= cnt;
4243 return totcnt; 4206 if (leftlen == 0) {
4244 } 4207 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4245 advoffset += cplen; 4208 return totcnt;
4246 curbuf += cnt; 4209 }
4247 } 4210 advoffset += cplen;
4211 curbuf += cnt;
4212 }
4248#endif /* ADVANSYS_STATS */ 4213#endif /* ADVANSYS_STATS */
4249 4214
4250 /* 4215 /*
4251 * Display Asc Library dynamic configuration information 4216 * Display Asc Library dynamic configuration information
4252 * for the board. 4217 * for the board.
4253 */ 4218 */
4254 cp = boardp->prtbuf; 4219 cp = boardp->prtbuf;
4255 if (ASC_NARROW_BOARD(boardp)) { 4220 if (ASC_NARROW_BOARD(boardp)) {
4256 cplen = asc_prt_asc_board_info(shp, cp, ASC_PRTBUF_SIZE); 4221 cplen = asc_prt_asc_board_info(shp, cp, ASC_PRTBUF_SIZE);
4257 } else { 4222 } else {
4258 cplen = asc_prt_adv_board_info(shp, cp, ASC_PRTBUF_SIZE); 4223 cplen = asc_prt_adv_board_info(shp, cp, ASC_PRTBUF_SIZE);
4259 } 4224 }
4260 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE); 4225 ASC_ASSERT(cplen < ASC_PRTBUF_SIZE);
4261 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); 4226 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4262 totcnt += cnt; 4227 totcnt += cnt;
4263 leftlen -= cnt; 4228 leftlen -= cnt;
4264 if (leftlen == 0) { 4229 if (leftlen == 0) {
4265 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt); 4230 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4266 return totcnt; 4231 return totcnt;
4267 } 4232 }
4268 advoffset += cplen; 4233 advoffset += cplen;
4269 curbuf += cnt; 4234 curbuf += cnt;
4270
4271 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
4272
4273 return totcnt;
4274}
4275#endif /* CONFIG_PROC_FS */
4276
4277/*
4278 * advansys_detect()
4279 *
4280 * Detect function for AdvanSys adapters.
4281 *
4282 * Argument is a pointer to the host driver's scsi_hosts entry.
4283 *
4284 * Return number of adapters found.
4285 *
4286 * Note: Because this function is called during system initialization
4287 * it must not call SCSI mid-level functions including scsi_malloc()
4288 * and scsi_free().
4289 */
4290static int __init
4291advansys_detect(struct scsi_host_template *tpnt)
4292{
4293 static int detect_called = ASC_FALSE;
4294 int iop;
4295 int bus;
4296 struct Scsi_Host *shp = NULL;
4297 asc_board_t *boardp = NULL;
4298 ASC_DVC_VAR *asc_dvc_varp = NULL;
4299 ADV_DVC_VAR *adv_dvc_varp = NULL;
4300 adv_sgblk_t *sgp = NULL;
4301 int ioport = 0;
4302 int share_irq = FALSE;
4303 int iolen = 0;
4304 struct device *dev = NULL;
4305#ifdef CONFIG_PCI
4306 int pci_init_search = 0;
4307 struct pci_dev *pci_devicep[ASC_NUM_BOARD_SUPPORTED];
4308 int pci_card_cnt_max = 0;
4309 int pci_card_cnt = 0;
4310 struct pci_dev *pci_devp = NULL;
4311 int pci_device_id_cnt = 0;
4312 unsigned int pci_device_id[ASC_PCI_DEVICE_ID_CNT] = {
4313 PCI_DEVICE_ID_ASP_1200A,
4314 PCI_DEVICE_ID_ASP_ABP940,
4315 PCI_DEVICE_ID_ASP_ABP940U,
4316 PCI_DEVICE_ID_ASP_ABP940UW,
4317 PCI_DEVICE_ID_38C0800_REV1,
4318 PCI_DEVICE_ID_38C1600_REV1
4319 };
4320 ADV_PADDR pci_memory_address;
4321#endif /* CONFIG_PCI */
4322 int warn_code, err_code;
4323 int ret;
4324
4325 if (detect_called == ASC_FALSE) {
4326 detect_called = ASC_TRUE;
4327 } else {
4328 printk("AdvanSys SCSI: advansys_detect() multiple calls ignored\n");
4329 return 0;
4330 }
4331
4332 ASC_DBG(1, "advansys_detect: begin\n");
4333
4334 asc_board_count = 0;
4335
4336 /*
4337 * If I/O port probing has been modified, then verify and
4338 * clean-up the 'asc_ioport' list.
4339 */
4340 if (asc_iopflag == ASC_TRUE) {
4341 for (ioport = 0; ioport < ASC_NUM_IOPORT_PROBE; ioport++) {
4342 ASC_DBG2(1, "advansys_detect: asc_ioport[%d] 0x%x\n",
4343 ioport, asc_ioport[ioport]);
4344 if (asc_ioport[ioport] != 0) {
4345 for (iop = 0; iop < ASC_IOADR_TABLE_MAX_IX; iop++) {
4346 if (_asc_def_iop_base[iop] == asc_ioport[ioport]) {
4347 break;
4348 }
4349 }
4350 if (iop == ASC_IOADR_TABLE_MAX_IX) {
4351 printk(
4352"AdvanSys SCSI: specified I/O Port 0x%X is invalid\n",
4353 asc_ioport[ioport]);
4354 asc_ioport[ioport] = 0;
4355 }
4356 }
4357 }
4358 ioport = 0;
4359 }
4360
4361 for (bus = 0; bus < ASC_NUM_BUS; bus++) {
4362
4363 ASC_DBG2(1, "advansys_detect: bus search type %d (%s)\n",
4364 bus, asc_bus_name[bus]);
4365 iop = 0;
4366
4367 while (asc_board_count < ASC_NUM_BOARD_SUPPORTED) {
4368
4369 ASC_DBG1(2, "advansys_detect: asc_board_count %d\n",
4370 asc_board_count);
4371
4372 switch (asc_bus[bus]) {
4373 case ASC_IS_ISA:
4374 case ASC_IS_VL:
4375#ifdef CONFIG_ISA
4376 if (asc_iopflag == ASC_FALSE) {
4377 iop = AscSearchIOPortAddr(iop, asc_bus[bus]);
4378 } else {
4379 /*
4380 * ISA and VL I/O port scanning has either been
4381 * eliminated or limited to selected ports on
4382 * the LILO command line, /etc/lilo.conf, or
4383 * by setting variables when the module was loaded.
4384 */
4385 ASC_DBG(1, "advansys_detect: I/O port scanning modified\n");
4386 ioport_try_again:
4387 iop = 0;
4388 for (; ioport < ASC_NUM_IOPORT_PROBE; ioport++) {
4389 if ((iop = asc_ioport[ioport]) != 0) {
4390 break;
4391 }
4392 }
4393 if (iop) {
4394 ASC_DBG1(1,
4395 "advansys_detect: probing I/O port 0x%x...\n",
4396 iop);
4397 if (!request_region(iop, ASC_IOADR_GAP, "advansys")){
4398 printk(
4399"AdvanSys SCSI: specified I/O Port 0x%X is busy\n", iop);
4400 /* Don't try this I/O port twice. */
4401 asc_ioport[ioport] = 0;
4402 goto ioport_try_again;
4403 } else if (AscFindSignature(iop) == ASC_FALSE) {
4404 printk(
4405"AdvanSys SCSI: specified I/O Port 0x%X has no adapter\n", iop);
4406 /* Don't try this I/O port twice. */
4407 release_region(iop, ASC_IOADR_GAP);
4408 asc_ioport[ioport] = 0;
4409 goto ioport_try_again;
4410 } else {
4411 /*
4412 * If this isn't an ISA board, then it must be
4413 * a VL board. If currently looking an ISA
4414 * board is being looked for then try for
4415 * another ISA board in 'asc_ioport'.
4416 */
4417 if (asc_bus[bus] == ASC_IS_ISA &&
4418 (AscGetChipVersion(iop, ASC_IS_ISA) &
4419 ASC_CHIP_VER_ISA_BIT) == 0) {
4420 /*
4421 * Don't clear 'asc_ioport[ioport]'. Try
4422 * this board again for VL. Increment
4423 * 'ioport' past this board.
4424 */
4425 ioport++;
4426 release_region(iop, ASC_IOADR_GAP);
4427 goto ioport_try_again;
4428 }
4429 }
4430 /*
4431 * This board appears good, don't try the I/O port
4432 * again by clearing its value. Increment 'ioport'
4433 * for the next iteration.
4434 */
4435 asc_ioport[ioport++] = 0;
4436 }
4437 }
4438#endif /* CONFIG_ISA */
4439 break;
4440
4441 case ASC_IS_EISA:
4442#ifdef CONFIG_ISA
4443 iop = AscSearchIOPortAddr(iop, asc_bus[bus]);
4444#endif /* CONFIG_ISA */
4445 break;
4446
4447 case ASC_IS_PCI:
4448#ifdef CONFIG_PCI
4449 if (pci_init_search == 0) {
4450 int i, j;
4451
4452 pci_init_search = 1;
4453
4454 /* Find all PCI cards. */
4455 while (pci_device_id_cnt < ASC_PCI_DEVICE_ID_CNT) {
4456 if ((pci_devp = pci_find_device(PCI_VENDOR_ID_ASP,
4457 pci_device_id[pci_device_id_cnt], pci_devp)) ==
4458 NULL) {
4459 pci_device_id_cnt++;
4460 } else {
4461 if (pci_enable_device(pci_devp) == 0) {
4462 pci_devicep[pci_card_cnt_max++] = pci_devp;
4463 }
4464 }
4465 }
4466
4467 /*
4468 * Sort PCI cards in ascending order by PCI Bus, Slot,
4469 * and Device Number.
4470 */
4471 for (i = 0; i < pci_card_cnt_max - 1; i++)
4472 {
4473 for (j = i + 1; j < pci_card_cnt_max; j++) {
4474 if ((pci_devicep[j]->bus->number <
4475 pci_devicep[i]->bus->number) ||
4476 ((pci_devicep[j]->bus->number ==
4477 pci_devicep[i]->bus->number) &&
4478 (pci_devicep[j]->devfn <
4479 pci_devicep[i]->devfn))) {
4480 pci_devp = pci_devicep[i];
4481 pci_devicep[i] = pci_devicep[j];
4482 pci_devicep[j] = pci_devp;
4483 }
4484 }
4485 }
4486
4487 pci_card_cnt = 0;
4488 } else {
4489 pci_card_cnt++;
4490 }
4491
4492 if (pci_card_cnt == pci_card_cnt_max) {
4493 iop = 0;
4494 } else {
4495 pci_devp = pci_devicep[pci_card_cnt];
4496
4497 ASC_DBG2(2,
4498 "advansys_detect: devfn %d, bus number %d\n",
4499 pci_devp->devfn, pci_devp->bus->number);
4500 iop = pci_resource_start(pci_devp, 0);
4501 ASC_DBG2(1,
4502 "advansys_detect: vendorID %X, deviceID %X\n",
4503 pci_devp->vendor, pci_devp->device);
4504 ASC_DBG2(2, "advansys_detect: iop %X, irqLine %d\n",
4505 iop, pci_devp->irq);
4506 }
4507 if(pci_devp)
4508 dev = &pci_devp->dev;
4509
4510#endif /* CONFIG_PCI */
4511 break;
4512
4513 default:
4514 ASC_PRINT1("advansys_detect: unknown bus type: %d\n",
4515 asc_bus[bus]);
4516 break;
4517 }
4518 ASC_DBG1(1, "advansys_detect: iop 0x%x\n", iop);
4519
4520 /*
4521 * Adapter not found, try next bus type.
4522 */
4523 if (iop == 0) {
4524 break;
4525 }
4526
4527 /*
4528 * Adapter found.
4529 *
4530 * Register the adapter, get its configuration, and
4531 * initialize it.
4532 */
4533 ASC_DBG(2, "advansys_detect: scsi_register()\n");
4534 shp = scsi_register(tpnt, sizeof(asc_board_t));
4535
4536 if (shp == NULL) {
4537 continue;
4538 }
4539
4540 /* Save a pointer to the Scsi_Host of each board found. */
4541 asc_host[asc_board_count++] = shp;
4542
4543 /* Initialize private per board data */
4544 boardp = ASC_BOARDP(shp);
4545 memset(boardp, 0, sizeof(asc_board_t));
4546 boardp->id = asc_board_count - 1;
4547
4548 /* Initialize spinlock. */
4549 spin_lock_init(&boardp->lock);
4550
4551 /*
4552 * Handle both narrow and wide boards.
4553 *
4554 * If a Wide board was detected, set the board structure
4555 * wide board flag. Set-up the board structure based on
4556 * the board type.
4557 */
4558#ifdef CONFIG_PCI
4559 if (asc_bus[bus] == ASC_IS_PCI &&
4560 (pci_devp->device == PCI_DEVICE_ID_ASP_ABP940UW ||
4561 pci_devp->device == PCI_DEVICE_ID_38C0800_REV1 ||
4562 pci_devp->device == PCI_DEVICE_ID_38C1600_REV1))
4563 {
4564 boardp->flags |= ASC_IS_WIDE_BOARD;
4565 }
4566#endif /* CONFIG_PCI */
4567
4568 if (ASC_NARROW_BOARD(boardp)) {
4569 ASC_DBG(1, "advansys_detect: narrow board\n");
4570 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
4571 asc_dvc_varp->bus_type = asc_bus[bus];
4572 asc_dvc_varp->drv_ptr = boardp;
4573 asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
4574 asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
4575 asc_dvc_varp->iop_base = iop;
4576 asc_dvc_varp->isr_callback = asc_isr_callback;
4577 } else {
4578 ASC_DBG(1, "advansys_detect: wide board\n");
4579 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
4580 adv_dvc_varp->drv_ptr = boardp;
4581 adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
4582 adv_dvc_varp->isr_callback = adv_isr_callback;
4583 adv_dvc_varp->async_callback = adv_async_callback;
4584#ifdef CONFIG_PCI
4585 if (pci_devp->device == PCI_DEVICE_ID_ASP_ABP940UW)
4586 {
4587 ASC_DBG(1, "advansys_detect: ASC-3550\n");
4588 adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
4589 } else if (pci_devp->device == PCI_DEVICE_ID_38C0800_REV1)
4590 {
4591 ASC_DBG(1, "advansys_detect: ASC-38C0800\n");
4592 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
4593 } else
4594 {
4595 ASC_DBG(1, "advansys_detect: ASC-38C1600\n");
4596 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
4597 }
4598#endif /* CONFIG_PCI */
4599
4600 /*
4601 * Map the board's registers into virtual memory for
4602 * PCI slave access. Only memory accesses are used to
4603 * access the board's registers.
4604 *
4605 * Note: The PCI register base address is not always
4606 * page aligned, but the address passed to ioremap()
4607 * must be page aligned. It is guaranteed that the
4608 * PCI register base address will not cross a page
4609 * boundary.
4610 */
4611 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
4612 {
4613 iolen = ADV_3550_IOLEN;
4614 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
4615 {
4616 iolen = ADV_38C0800_IOLEN;
4617 } else
4618 {
4619 iolen = ADV_38C1600_IOLEN;
4620 }
4621#ifdef CONFIG_PCI
4622 pci_memory_address = pci_resource_start(pci_devp, 1);
4623 ASC_DBG1(1, "advansys_detect: pci_memory_address: 0x%lx\n",
4624 (ulong) pci_memory_address);
4625 if ((boardp->ioremap_addr =
4626 ioremap(pci_memory_address & PAGE_MASK,
4627 PAGE_SIZE)) == 0) {
4628 ASC_PRINT3(
4629"advansys_detect: board %d: ioremap(%x, %d) returned NULL\n",
4630 boardp->id, pci_memory_address, iolen);
4631 scsi_unregister(shp);
4632 asc_board_count--;
4633 continue;
4634 }
4635 ASC_DBG1(1, "advansys_detect: ioremap_addr: 0x%lx\n",
4636 (ulong) boardp->ioremap_addr);
4637 adv_dvc_varp->iop_base = (AdvPortAddr)
4638 (boardp->ioremap_addr +
4639 (pci_memory_address - (pci_memory_address & PAGE_MASK)));
4640 ASC_DBG1(1, "advansys_detect: iop_base: 0x%lx\n",
4641 adv_dvc_varp->iop_base);
4642#endif /* CONFIG_PCI */
4643
4644 /*
4645 * Even though it isn't used to access wide boards, other
4646 * than for the debug line below, save I/O Port address so
4647 * that it can be reported.
4648 */
4649 boardp->ioport = iop;
4650
4651 ASC_DBG2(1,
4652"advansys_detect: iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
4653 (ushort) inp(iop + 1), (ushort) inpw(iop));
4654 }
4655
4656#ifdef CONFIG_PROC_FS
4657 /*
4658 * Allocate buffer for printing information from
4659 * /proc/scsi/advansys/[0...].
4660 */
4661 if ((boardp->prtbuf =
4662 kmalloc(ASC_PRTBUF_SIZE, GFP_ATOMIC)) == NULL) {
4663 ASC_PRINT3(
4664"advansys_detect: board %d: kmalloc(%d, %d) returned NULL\n",
4665 boardp->id, ASC_PRTBUF_SIZE, GFP_ATOMIC);
4666 scsi_unregister(shp);
4667 asc_board_count--;
4668 continue;
4669 }
4670#endif /* CONFIG_PROC_FS */
4671
4672 if (ASC_NARROW_BOARD(boardp)) {
4673 asc_dvc_varp->cfg->dev = dev;
4674 /*
4675 * Set the board bus type and PCI IRQ before
4676 * calling AscInitGetConfig().
4677 */
4678 switch (asc_dvc_varp->bus_type) {
4679#ifdef CONFIG_ISA
4680 case ASC_IS_ISA:
4681 shp->unchecked_isa_dma = TRUE;
4682 share_irq = FALSE;
4683 break;
4684 case ASC_IS_VL:
4685 shp->unchecked_isa_dma = FALSE;
4686 share_irq = FALSE;
4687 break;
4688 case ASC_IS_EISA:
4689 shp->unchecked_isa_dma = FALSE;
4690 share_irq = TRUE;
4691 break;
4692#endif /* CONFIG_ISA */
4693#ifdef CONFIG_PCI
4694 case ASC_IS_PCI:
4695 shp->irq = asc_dvc_varp->irq_no = pci_devp->irq;
4696 asc_dvc_varp->cfg->pci_slot_info =
4697 ASC_PCI_MKID(pci_devp->bus->number,
4698 PCI_SLOT(pci_devp->devfn),
4699 PCI_FUNC(pci_devp->devfn));
4700 shp->unchecked_isa_dma = FALSE;
4701 share_irq = TRUE;
4702 break;
4703#endif /* CONFIG_PCI */
4704 default:
4705 ASC_PRINT2(
4706"advansys_detect: board %d: unknown adapter type: %d\n",
4707 boardp->id, asc_dvc_varp->bus_type);
4708 shp->unchecked_isa_dma = TRUE;
4709 share_irq = FALSE;
4710 break;
4711 }
4712 } else {
4713 adv_dvc_varp->cfg->dev = dev;
4714 /*
4715 * For Wide boards set PCI information before calling
4716 * AdvInitGetConfig().
4717 */
4718#ifdef CONFIG_PCI
4719 shp->irq = adv_dvc_varp->irq_no = pci_devp->irq;
4720 adv_dvc_varp->cfg->pci_slot_info =
4721 ASC_PCI_MKID(pci_devp->bus->number,
4722 PCI_SLOT(pci_devp->devfn),
4723 PCI_FUNC(pci_devp->devfn));
4724 shp->unchecked_isa_dma = FALSE;
4725 share_irq = TRUE;
4726#endif /* CONFIG_PCI */
4727 }
4728
4729 /*
4730 * Read the board configuration.
4731 */
4732 if (ASC_NARROW_BOARD(boardp)) {
4733 /*
4734 * NOTE: AscInitGetConfig() may change the board's
4735 * bus_type value. The asc_bus[bus] value should no
4736 * longer be used. If the bus_type field must be
4737 * referenced only use the bit-wise AND operator "&".
4738 */
4739 ASC_DBG(2, "advansys_detect: AscInitGetConfig()\n");
4740 switch(ret = AscInitGetConfig(asc_dvc_varp)) {
4741 case 0: /* No error */
4742 break;
4743 case ASC_WARN_IO_PORT_ROTATE:
4744 ASC_PRINT1(
4745"AscInitGetConfig: board %d: I/O port address modified\n",
4746 boardp->id);
4747 break;
4748 case ASC_WARN_AUTO_CONFIG:
4749 ASC_PRINT1(
4750"AscInitGetConfig: board %d: I/O port increment switch enabled\n",
4751 boardp->id);
4752 break;
4753 case ASC_WARN_EEPROM_CHKSUM:
4754 ASC_PRINT1(
4755"AscInitGetConfig: board %d: EEPROM checksum error\n",
4756 boardp->id);
4757 break;
4758 case ASC_WARN_IRQ_MODIFIED:
4759 ASC_PRINT1(
4760"AscInitGetConfig: board %d: IRQ modified\n",
4761 boardp->id);
4762 break;
4763 case ASC_WARN_CMD_QNG_CONFLICT:
4764 ASC_PRINT1(
4765"AscInitGetConfig: board %d: tag queuing enabled w/o disconnects\n",
4766 boardp->id);
4767 break;
4768 default:
4769 ASC_PRINT2(
4770"AscInitGetConfig: board %d: unknown warning: 0x%x\n",
4771 boardp->id, ret);
4772 break;
4773 }
4774 if ((err_code = asc_dvc_varp->err_code) != 0) {
4775 ASC_PRINT3(
4776"AscInitGetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
4777 boardp->id, asc_dvc_varp->init_state,
4778 asc_dvc_varp->err_code);
4779 }
4780 } else {
4781 ASC_DBG(2, "advansys_detect: AdvInitGetConfig()\n");
4782 if ((ret = AdvInitGetConfig(adv_dvc_varp)) != 0) {
4783 ASC_PRINT2("AdvInitGetConfig: board %d: warning: 0x%x\n",
4784 boardp->id, ret);
4785 }
4786 if ((err_code = adv_dvc_varp->err_code) != 0) {
4787 ASC_PRINT2(
4788"AdvInitGetConfig: board %d error: err_code 0x%x\n",
4789 boardp->id, adv_dvc_varp->err_code);
4790 }
4791 }
4792
4793 if (err_code != 0) {
4794#ifdef CONFIG_PROC_FS
4795 kfree(boardp->prtbuf);
4796#endif /* CONFIG_PROC_FS */
4797 scsi_unregister(shp);
4798 asc_board_count--;
4799 continue;
4800 }
4801
4802 /*
4803 * Save the EEPROM configuration so that it can be displayed
4804 * from /proc/scsi/advansys/[0...].
4805 */
4806 if (ASC_NARROW_BOARD(boardp)) {
4807
4808 ASCEEP_CONFIG *ep;
4809
4810 /*
4811 * Set the adapter's target id bit in the 'init_tidmask' field.
4812 */
4813 boardp->init_tidmask |=
4814 ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
4815
4816 /*
4817 * Save EEPROM settings for the board.
4818 */
4819 ep = &boardp->eep_config.asc_eep;
4820
4821 ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
4822 ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
4823 ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
4824 ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
4825 ep->start_motor = asc_dvc_varp->start_motor;
4826 ep->cntl = asc_dvc_varp->dvc_cntl;
4827 ep->no_scam = asc_dvc_varp->no_scam;
4828 ep->max_total_qng = asc_dvc_varp->max_total_qng;
4829 ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
4830 /* 'max_tag_qng' is set to the same value for every device. */
4831 ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
4832 ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
4833 ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
4834 ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
4835 ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
4836 ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
4837 ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
4838
4839 /*
4840 * Modify board configuration.
4841 */
4842 ASC_DBG(2, "advansys_detect: AscInitSetConfig()\n");
4843 switch (ret = AscInitSetConfig(asc_dvc_varp)) {
4844 case 0: /* No error. */
4845 break;
4846 case ASC_WARN_IO_PORT_ROTATE:
4847 ASC_PRINT1(
4848"AscInitSetConfig: board %d: I/O port address modified\n",
4849 boardp->id);
4850 break;
4851 case ASC_WARN_AUTO_CONFIG:
4852 ASC_PRINT1(
4853"AscInitSetConfig: board %d: I/O port increment switch enabled\n",
4854 boardp->id);
4855 break;
4856 case ASC_WARN_EEPROM_CHKSUM:
4857 ASC_PRINT1(
4858"AscInitSetConfig: board %d: EEPROM checksum error\n",
4859 boardp->id);
4860 break;
4861 case ASC_WARN_IRQ_MODIFIED:
4862 ASC_PRINT1(
4863"AscInitSetConfig: board %d: IRQ modified\n",
4864 boardp->id);
4865 break;
4866 case ASC_WARN_CMD_QNG_CONFLICT:
4867 ASC_PRINT1(
4868"AscInitSetConfig: board %d: tag queuing w/o disconnects\n",
4869 boardp->id);
4870 break;
4871 default:
4872 ASC_PRINT2(
4873"AscInitSetConfig: board %d: unknown warning: 0x%x\n",
4874 boardp->id, ret);
4875 break;
4876 }
4877 if (asc_dvc_varp->err_code != 0) {
4878 ASC_PRINT3(
4879"AscInitSetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
4880 boardp->id, asc_dvc_varp->init_state,
4881 asc_dvc_varp->err_code);
4882#ifdef CONFIG_PROC_FS
4883 kfree(boardp->prtbuf);
4884#endif /* CONFIG_PROC_FS */
4885 scsi_unregister(shp);
4886 asc_board_count--;
4887 continue;
4888 }
4889
4890 /*
4891 * Finish initializing the 'Scsi_Host' structure.
4892 */
4893 /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
4894 if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
4895 shp->irq = asc_dvc_varp->irq_no;
4896 }
4897 } else {
4898 ADVEEP_3550_CONFIG *ep_3550;
4899 ADVEEP_38C0800_CONFIG *ep_38C0800;
4900 ADVEEP_38C1600_CONFIG *ep_38C1600;
4901
4902 /*
4903 * Save Wide EEP Configuration Information.
4904 */
4905 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
4906 {
4907 ep_3550 = &boardp->eep_config.adv_3550_eep;
4908
4909 ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
4910 ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
4911 ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
4912 ep_3550->termination = adv_dvc_varp->cfg->termination;
4913 ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
4914 ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
4915 ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
4916 ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
4917 ep_3550->ultra_able = adv_dvc_varp->ultra_able;
4918 ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
4919 ep_3550->start_motor = adv_dvc_varp->start_motor;
4920 ep_3550->scsi_reset_delay = adv_dvc_varp->scsi_reset_wait;
4921 ep_3550->serial_number_word1 =
4922 adv_dvc_varp->cfg->serial1;
4923 ep_3550->serial_number_word2 =
4924 adv_dvc_varp->cfg->serial2;
4925 ep_3550->serial_number_word3 =
4926 adv_dvc_varp->cfg->serial3;
4927 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
4928 {
4929 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
4930
4931 ep_38C0800->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
4932 ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
4933 ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
4934 ep_38C0800->termination_lvd =
4935 adv_dvc_varp->cfg->termination;
4936 ep_38C0800->disc_enable = adv_dvc_varp->cfg->disc_enable;
4937 ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
4938 ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
4939 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
4940 ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
4941 ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
4942 ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
4943 ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
4944 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
4945 ep_38C0800->start_motor = adv_dvc_varp->start_motor;
4946 ep_38C0800->scsi_reset_delay =
4947 adv_dvc_varp->scsi_reset_wait;
4948 ep_38C0800->serial_number_word1 =
4949 adv_dvc_varp->cfg->serial1;
4950 ep_38C0800->serial_number_word2 =
4951 adv_dvc_varp->cfg->serial2;
4952 ep_38C0800->serial_number_word3 =
4953 adv_dvc_varp->cfg->serial3;
4954 } else
4955 {
4956 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
4957
4958 ep_38C1600->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
4959 ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
4960 ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
4961 ep_38C1600->termination_lvd =
4962 adv_dvc_varp->cfg->termination;
4963 ep_38C1600->disc_enable = adv_dvc_varp->cfg->disc_enable;
4964 ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
4965 ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
4966 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
4967 ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
4968 ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
4969 ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
4970 ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
4971 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
4972 ep_38C1600->start_motor = adv_dvc_varp->start_motor;
4973 ep_38C1600->scsi_reset_delay =
4974 adv_dvc_varp->scsi_reset_wait;
4975 ep_38C1600->serial_number_word1 =
4976 adv_dvc_varp->cfg->serial1;
4977 ep_38C1600->serial_number_word2 =
4978 adv_dvc_varp->cfg->serial2;
4979 ep_38C1600->serial_number_word3 =
4980 adv_dvc_varp->cfg->serial3;
4981 }
4982
4983 /*
4984 * Set the adapter's target id bit in the 'init_tidmask' field.
4985 */
4986 boardp->init_tidmask |=
4987 ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
4988
4989 /*
4990 * Finish initializing the 'Scsi_Host' structure.
4991 */
4992 shp->irq = adv_dvc_varp->irq_no;
4993 }
4994
4995 /*
4996 * Channels are numbered beginning with 0. For AdvanSys one host
4997 * structure supports one channel. Multi-channel boards have a
4998 * separate host structure for each channel.
4999 */
5000 shp->max_channel = 0;
5001 if (ASC_NARROW_BOARD(boardp)) {
5002 shp->max_id = ASC_MAX_TID + 1;
5003 shp->max_lun = ASC_MAX_LUN + 1;
5004
5005 shp->io_port = asc_dvc_varp->iop_base;
5006 boardp->asc_n_io_port = ASC_IOADR_GAP;
5007 shp->this_id = asc_dvc_varp->cfg->chip_scsi_id;
5008
5009 /* Set maximum number of queues the adapter can handle. */
5010 shp->can_queue = asc_dvc_varp->max_total_qng;
5011 } else {
5012 shp->max_id = ADV_MAX_TID + 1;
5013 shp->max_lun = ADV_MAX_LUN + 1;
5014
5015 /*
5016 * Save the I/O Port address and length even though
5017 * I/O ports are not used to access Wide boards.
5018 * Instead the Wide boards are accessed with
5019 * PCI Memory Mapped I/O.
5020 */
5021 shp->io_port = iop;
5022 boardp->asc_n_io_port = iolen;
5023
5024 shp->this_id = adv_dvc_varp->chip_scsi_id;
5025
5026 /* Set maximum number of queues the adapter can handle. */
5027 shp->can_queue = adv_dvc_varp->max_host_qng;
5028 }
5029
5030 /*
5031 * 'n_io_port' currently is one byte.
5032 *
5033 * Set a value to 'n_io_port', but never referenced it because
5034 * it may be truncated.
5035 */
5036 shp->n_io_port = boardp->asc_n_io_port <= 255 ?
5037 boardp->asc_n_io_port : 255;
5038
5039 /*
5040 * Following v1.3.89, 'cmd_per_lun' is no longer needed
5041 * and should be set to zero.
5042 *
5043 * But because of a bug introduced in v1.3.89 if the driver is
5044 * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
5045 * SCSI function 'allocate_device' will panic. To allow the driver
5046 * to work as a module in these kernels set 'cmd_per_lun' to 1.
5047 *
5048 * Note: This is wrong. cmd_per_lun should be set to the depth
5049 * you want on untagged devices always.
5050#ifdef MODULE
5051 */
5052 shp->cmd_per_lun = 1;
5053/* #else
5054 shp->cmd_per_lun = 0;
5055#endif */
5056
5057 /*
5058 * Set the maximum number of scatter-gather elements the
5059 * adapter can handle.
5060 */
5061 if (ASC_NARROW_BOARD(boardp)) {
5062 /*
5063 * Allow two commands with 'sg_tablesize' scatter-gather
5064 * elements to be executed simultaneously. This value is
5065 * the theoretical hardware limit. It may be decreased
5066 * below.
5067 */
5068 shp->sg_tablesize =
5069 (((asc_dvc_varp->max_total_qng - 2) / 2) *
5070 ASC_SG_LIST_PER_Q) + 1;
5071 } else {
5072 shp->sg_tablesize = ADV_MAX_SG_LIST;
5073 }
5074
5075 /*
5076 * The value of 'sg_tablesize' can not exceed the SCSI
5077 * mid-level driver definition of SG_ALL. SG_ALL also
5078 * must not be exceeded, because it is used to define the
5079 * size of the scatter-gather table in 'struct asc_sg_head'.
5080 */
5081 if (shp->sg_tablesize > SG_ALL) {
5082 shp->sg_tablesize = SG_ALL;
5083 }
5084
5085 ASC_DBG1(1, "advansys_detect: sg_tablesize: %d\n",
5086 shp->sg_tablesize);
5087
5088 /* BIOS start address. */
5089 if (ASC_NARROW_BOARD(boardp)) {
5090 shp->base =
5091 ((ulong) AscGetChipBiosAddress(
5092 asc_dvc_varp->iop_base,
5093 asc_dvc_varp->bus_type));
5094 } else {
5095 /*
5096 * Fill-in BIOS board variables. The Wide BIOS saves
5097 * information in LRAM that is used by the driver.
5098 */
5099 AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_SIGNATURE,
5100 boardp->bios_signature);
5101 AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_VERSION,
5102 boardp->bios_version);
5103 AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_CODESEG,
5104 boardp->bios_codeseg);
5105 AdvReadWordLram(adv_dvc_varp->iop_base, BIOS_CODELEN,
5106 boardp->bios_codelen);
5107
5108 ASC_DBG2(1,
5109 "advansys_detect: bios_signature 0x%x, bios_version 0x%x\n",
5110 boardp->bios_signature, boardp->bios_version);
5111
5112 ASC_DBG2(1,
5113 "advansys_detect: bios_codeseg 0x%x, bios_codelen 0x%x\n",
5114 boardp->bios_codeseg, boardp->bios_codelen);
5115
5116 /*
5117 * If the BIOS saved a valid signature, then fill in
5118 * the BIOS code segment base address.
5119 */
5120 if (boardp->bios_signature == 0x55AA) {
5121 /*
5122 * Convert x86 realmode code segment to a linear
5123 * address by shifting left 4.
5124 */
5125 shp->base = ((ulong) boardp->bios_codeseg << 4);
5126 } else {
5127 shp->base = 0;
5128 }
5129 }
5130
5131 /*
5132 * Register Board Resources - I/O Port, DMA, IRQ
5133 */
5134
5135 /*
5136 * Register I/O port range.
5137 *
5138 * For Wide boards the I/O ports are not used to access
5139 * the board, but request the region anyway.
5140 *
5141 * 'shp->n_io_port' is not referenced, because it may be truncated.
5142 */
5143 ASC_DBG2(2,
5144 "advansys_detect: request_region port 0x%lx, len 0x%x\n",
5145 (ulong) shp->io_port, boardp->asc_n_io_port);
5146 if (request_region(shp->io_port, boardp->asc_n_io_port,
5147 "advansys") == NULL) {
5148 ASC_PRINT3(
5149"advansys_detect: board %d: request_region() failed, port 0x%lx, len 0x%x\n",
5150 boardp->id, (ulong) shp->io_port, boardp->asc_n_io_port);
5151#ifdef CONFIG_PROC_FS
5152 kfree(boardp->prtbuf);
5153#endif /* CONFIG_PROC_FS */
5154 scsi_unregister(shp);
5155 asc_board_count--;
5156 continue;
5157 }
5158
5159 /* Register DMA Channel for Narrow boards. */
5160 shp->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
5161#ifdef CONFIG_ISA
5162 if (ASC_NARROW_BOARD(boardp)) {
5163 /* Register DMA channel for ISA bus. */
5164 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
5165 shp->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
5166 if ((ret =
5167 request_dma(shp->dma_channel, "advansys")) != 0) {
5168 ASC_PRINT3(
5169"advansys_detect: board %d: request_dma() %d failed %d\n",
5170 boardp->id, shp->dma_channel, ret);
5171 release_region(shp->io_port, boardp->asc_n_io_port);
5172#ifdef CONFIG_PROC_FS
5173 kfree(boardp->prtbuf);
5174#endif /* CONFIG_PROC_FS */
5175 scsi_unregister(shp);
5176 asc_board_count--;
5177 continue;
5178 }
5179 AscEnableIsaDma(shp->dma_channel);
5180 }
5181 }
5182#endif /* CONFIG_ISA */
5183 4235
5184 /* Register IRQ Number. */ 4236 ASC_DBG1(1, "advansys_proc_info: totcnt %d\n", totcnt);
5185 ASC_DBG1(2, "advansys_detect: request_irq() %d\n", shp->irq);
5186 /*
5187 * If request_irq() fails with the IRQF_DISABLED flag set,
5188 * then try again without the IRQF_DISABLED flag set. This
5189 * allows IRQ sharing to work even with other drivers that
5190 * do not set the IRQF_DISABLED flag.
5191 *
5192 * If IRQF_DISABLED is not set, then interrupts are enabled
5193 * before the driver interrupt function is called.
5194 */
5195 if (((ret = request_irq(shp->irq, advansys_interrupt,
5196 IRQF_DISABLED | (share_irq == TRUE ? IRQF_SHARED : 0),
5197 "advansys", boardp)) != 0) &&
5198 ((ret = request_irq(shp->irq, advansys_interrupt,
5199 (share_irq == TRUE ? IRQF_SHARED : 0),
5200 "advansys", boardp)) != 0))
5201 {
5202 if (ret == -EBUSY) {
5203 ASC_PRINT2(
5204"advansys_detect: board %d: request_irq(): IRQ 0x%x already in use.\n",
5205 boardp->id, shp->irq);
5206 } else if (ret == -EINVAL) {
5207 ASC_PRINT2(
5208"advansys_detect: board %d: request_irq(): IRQ 0x%x not valid.\n",
5209 boardp->id, shp->irq);
5210 } else {
5211 ASC_PRINT3(
5212"advansys_detect: board %d: request_irq(): IRQ 0x%x failed with %d\n",
5213 boardp->id, shp->irq, ret);
5214 }
5215 release_region(shp->io_port, boardp->asc_n_io_port);
5216 iounmap(boardp->ioremap_addr);
5217 if (shp->dma_channel != NO_ISA_DMA) {
5218 free_dma(shp->dma_channel);
5219 }
5220#ifdef CONFIG_PROC_FS
5221 kfree(boardp->prtbuf);
5222#endif /* CONFIG_PROC_FS */
5223 scsi_unregister(shp);
5224 asc_board_count--;
5225 continue;
5226 }
5227
5228 /*
5229 * Initialize board RISC chip and enable interrupts.
5230 */
5231 if (ASC_NARROW_BOARD(boardp)) {
5232 ASC_DBG(2, "advansys_detect: AscInitAsc1000Driver()\n");
5233 warn_code = AscInitAsc1000Driver(asc_dvc_varp);
5234 err_code = asc_dvc_varp->err_code;
5235
5236 if (warn_code || err_code) {
5237 ASC_PRINT4(
5238"advansys_detect: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
5239 boardp->id, asc_dvc_varp->init_state,
5240 warn_code, err_code);
5241 }
5242 } else {
5243 ADV_CARR_T *carrp;
5244 int req_cnt = 0;
5245 adv_req_t *reqp = NULL;
5246 int sg_cnt = 0;
5247
5248 /*
5249 * Allocate buffer carrier structures. The total size
5250 * is about 4 KB, so allocate all at once.
5251 */
5252 carrp =
5253 (ADV_CARR_T *) kmalloc(ADV_CARRIER_BUFSIZE, GFP_ATOMIC);
5254 ASC_DBG1(1, "advansys_detect: carrp 0x%lx\n", (ulong) carrp);
5255
5256 if (carrp == NULL) {
5257 goto kmalloc_error;
5258 }
5259
5260 /*
5261 * Allocate up to 'max_host_qng' request structures for
5262 * the Wide board. The total size is about 16 KB, so
5263 * allocate all at once. If the allocation fails decrement
5264 * and try again.
5265 */
5266 for (req_cnt = adv_dvc_varp->max_host_qng;
5267 req_cnt > 0; req_cnt--) {
5268
5269 reqp = (adv_req_t *)
5270 kmalloc(sizeof(adv_req_t) * req_cnt, GFP_ATOMIC);
5271
5272 ASC_DBG3(1,
5273 "advansys_detect: reqp 0x%lx, req_cnt %d, bytes %lu\n",
5274 (ulong) reqp, req_cnt,
5275 (ulong) sizeof(adv_req_t) * req_cnt);
5276
5277 if (reqp != NULL) {
5278 break;
5279 }
5280 }
5281 if (reqp == NULL)
5282 {
5283 goto kmalloc_error;
5284 }
5285
5286 /*
5287 * Allocate up to ADV_TOT_SG_BLOCK request structures for
5288 * the Wide board. Each structure is about 136 bytes.
5289 */
5290 boardp->adv_sgblkp = NULL;
5291 for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
5292
5293 sgp = (adv_sgblk_t *)
5294 kmalloc(sizeof(adv_sgblk_t), GFP_ATOMIC);
5295
5296 if (sgp == NULL) {
5297 break;
5298 }
5299
5300 sgp->next_sgblkp = boardp->adv_sgblkp;
5301 boardp->adv_sgblkp = sgp;
5302
5303 }
5304 ASC_DBG3(1,
5305 "advansys_detect: sg_cnt %d * %u = %u bytes\n",
5306 sg_cnt, sizeof(adv_sgblk_t),
5307 (unsigned) (sizeof(adv_sgblk_t) * sg_cnt));
5308
5309 /*
5310 * If no request structures or scatter-gather structures could
5311 * be allocated, then return an error. Otherwise continue with
5312 * initialization.
5313 */
5314 kmalloc_error:
5315 if (carrp == NULL)
5316 {
5317 ASC_PRINT1(
5318"advansys_detect: board %d error: failed to kmalloc() carrier buffer.\n",
5319 boardp->id);
5320 err_code = ADV_ERROR;
5321 } else if (reqp == NULL) {
5322 kfree(carrp);
5323 ASC_PRINT1(
5324"advansys_detect: board %d error: failed to kmalloc() adv_req_t buffer.\n",
5325 boardp->id);
5326 err_code = ADV_ERROR;
5327 } else if (boardp->adv_sgblkp == NULL) {
5328 kfree(carrp);
5329 kfree(reqp);
5330 ASC_PRINT1(
5331"advansys_detect: board %d error: failed to kmalloc() adv_sgblk_t buffers.\n",
5332 boardp->id);
5333 err_code = ADV_ERROR;
5334 } else {
5335
5336 /* Save carrier buffer pointer. */
5337 boardp->orig_carrp = carrp;
5338
5339 /*
5340 * Save original pointer for kfree() in case the
5341 * driver is built as a module and can be unloaded.
5342 */
5343 boardp->orig_reqp = reqp;
5344
5345 adv_dvc_varp->carrier_buf = carrp;
5346
5347 /*
5348 * Point 'adv_reqp' to the request structures and
5349 * link them together.
5350 */
5351 req_cnt--;
5352 reqp[req_cnt].next_reqp = NULL;
5353 for (; req_cnt > 0; req_cnt--) {
5354 reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
5355 }
5356 boardp->adv_reqp = &reqp[0];
5357
5358 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
5359 {
5360 ASC_DBG(2,
5361 "advansys_detect: AdvInitAsc3550Driver()\n");
5362 warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
5363 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
5364 ASC_DBG(2,
5365 "advansys_detect: AdvInitAsc38C0800Driver()\n");
5366 warn_code = AdvInitAsc38C0800Driver(adv_dvc_varp);
5367 } else {
5368 ASC_DBG(2,
5369 "advansys_detect: AdvInitAsc38C1600Driver()\n");
5370 warn_code = AdvInitAsc38C1600Driver(adv_dvc_varp);
5371 }
5372 err_code = adv_dvc_varp->err_code;
5373
5374 if (warn_code || err_code) {
5375 ASC_PRINT3(
5376"advansys_detect: board %d error: warn 0x%x, error 0x%x\n",
5377 boardp->id, warn_code, err_code);
5378 }
5379 }
5380 }
5381
5382 if (err_code != 0) {
5383 release_region(shp->io_port, boardp->asc_n_io_port);
5384 if (ASC_WIDE_BOARD(boardp)) {
5385 iounmap(boardp->ioremap_addr);
5386 kfree(boardp->orig_carrp);
5387 boardp->orig_carrp = NULL;
5388 if (boardp->orig_reqp) {
5389 kfree(boardp->orig_reqp);
5390 boardp->orig_reqp = boardp->adv_reqp = NULL;
5391 }
5392 while ((sgp = boardp->adv_sgblkp) != NULL)
5393 {
5394 boardp->adv_sgblkp = sgp->next_sgblkp;
5395 kfree(sgp);
5396 }
5397 }
5398 if (shp->dma_channel != NO_ISA_DMA) {
5399 free_dma(shp->dma_channel);
5400 }
5401#ifdef CONFIG_PROC_FS
5402 kfree(boardp->prtbuf);
5403#endif /* CONFIG_PROC_FS */
5404 free_irq(shp->irq, boardp);
5405 scsi_unregister(shp);
5406 asc_board_count--;
5407 continue;
5408 }
5409 ASC_DBG_PRT_SCSI_HOST(2, shp);
5410 }
5411 }
5412 4237
5413 ASC_DBG1(1, "advansys_detect: done: asc_board_count %d\n", asc_board_count); 4238 return totcnt;
5414 return asc_board_count;
5415} 4239}
5416
5417/*
5418 * advansys_release()
5419 *
5420 * Release resources allocated for a single AdvanSys adapter.
5421 */
5422static int
5423advansys_release(struct Scsi_Host *shp)
5424{
5425 asc_board_t *boardp;
5426
5427 ASC_DBG(1, "advansys_release: begin\n");
5428 boardp = ASC_BOARDP(shp);
5429 free_irq(shp->irq, boardp);
5430 if (shp->dma_channel != NO_ISA_DMA) {
5431 ASC_DBG(1, "advansys_release: free_dma()\n");
5432 free_dma(shp->dma_channel);
5433 }
5434 release_region(shp->io_port, boardp->asc_n_io_port);
5435 if (ASC_WIDE_BOARD(boardp)) {
5436 adv_sgblk_t *sgp = NULL;
5437
5438 iounmap(boardp->ioremap_addr);
5439 kfree(boardp->orig_carrp);
5440 boardp->orig_carrp = NULL;
5441 if (boardp->orig_reqp) {
5442 kfree(boardp->orig_reqp);
5443 boardp->orig_reqp = boardp->adv_reqp = NULL;
5444 }
5445 while ((sgp = boardp->adv_sgblkp) != NULL)
5446 {
5447 boardp->adv_sgblkp = sgp->next_sgblkp;
5448 kfree(sgp);
5449 }
5450 }
5451#ifdef CONFIG_PROC_FS
5452 ASC_ASSERT(boardp->prtbuf != NULL);
5453 kfree(boardp->prtbuf);
5454#endif /* CONFIG_PROC_FS */ 4240#endif /* CONFIG_PROC_FS */
5455 scsi_unregister(shp);
5456 ASC_DBG(1, "advansys_release: end\n");
5457 return 0;
5458}
5459 4241
5460/* 4242/*
5461 * advansys_info() 4243 * advansys_info()
@@ -5466,91 +4248,87 @@ advansys_release(struct Scsi_Host *shp)
5466 * Note: The information line should not exceed ASC_INFO_SIZE bytes, 4248 * Note: The information line should not exceed ASC_INFO_SIZE bytes,
5467 * otherwise the static 'info' array will be overrun. 4249 * otherwise the static 'info' array will be overrun.
5468 */ 4250 */
5469static const char * 4251static const char *advansys_info(struct Scsi_Host *shost)
5470advansys_info(struct Scsi_Host *shp)
5471{ 4252{
5472 static char info[ASC_INFO_SIZE]; 4253 static char info[ASC_INFO_SIZE];
5473 asc_board_t *boardp; 4254 asc_board_t *boardp;
5474 ASC_DVC_VAR *asc_dvc_varp; 4255 ASC_DVC_VAR *asc_dvc_varp;
5475 ADV_DVC_VAR *adv_dvc_varp; 4256 ADV_DVC_VAR *adv_dvc_varp;
5476 char *busname; 4257 char *busname;
5477 int iolen; 4258 int iolen;
5478 char *widename = NULL; 4259 char *widename = NULL;
5479 4260
5480 boardp = ASC_BOARDP(shp); 4261 boardp = ASC_BOARDP(shost);
5481 if (ASC_NARROW_BOARD(boardp)) { 4262 if (ASC_NARROW_BOARD(boardp)) {
5482 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var; 4263 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
5483 ASC_DBG(1, "advansys_info: begin\n"); 4264 ASC_DBG(1, "advansys_info: begin\n");
5484 if (asc_dvc_varp->bus_type & ASC_IS_ISA) { 4265 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
5485 if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) == ASC_IS_ISAPNP) { 4266 if ((asc_dvc_varp->bus_type & ASC_IS_ISAPNP) ==
5486 busname = "ISA PnP"; 4267 ASC_IS_ISAPNP) {
5487 } else { 4268 busname = "ISA PnP";
5488 busname = "ISA"; 4269 } else {
5489 } 4270 busname = "ISA";
5490 /* Don't reference 'shp->n_io_port'; It may be truncated. */ 4271 }
5491 sprintf(info, 4272 /* Don't reference 'shost->n_io_port'; It may be truncated. */
5492"AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X", 4273 sprintf(info,
5493 ASC_VERSION, busname, 4274 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
5494 (ulong) shp->io_port, 4275 ASC_VERSION, busname,
5495 (ulong) shp->io_port + boardp->asc_n_io_port - 1, 4276 (ulong)shost->io_port,
5496 shp->irq, shp->dma_channel); 4277 (ulong)shost->io_port + boardp->asc_n_io_port -
5497 } else { 4278 1, shost->irq, shost->dma_channel);
5498 if (asc_dvc_varp->bus_type & ASC_IS_VL) { 4279 } else {
5499 busname = "VL"; 4280 if (asc_dvc_varp->bus_type & ASC_IS_VL) {
5500 } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) { 4281 busname = "VL";
5501 busname = "EISA"; 4282 } else if (asc_dvc_varp->bus_type & ASC_IS_EISA) {
5502 } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) { 4283 busname = "EISA";
5503 if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA) 4284 } else if (asc_dvc_varp->bus_type & ASC_IS_PCI) {
5504 == ASC_IS_PCI_ULTRA) { 4285 if ((asc_dvc_varp->bus_type & ASC_IS_PCI_ULTRA)
5505 busname = "PCI Ultra"; 4286 == ASC_IS_PCI_ULTRA) {
5506 } else { 4287 busname = "PCI Ultra";
5507 busname = "PCI"; 4288 } else {
5508 } 4289 busname = "PCI";
5509 } else { 4290 }
5510 busname = "?"; 4291 } else {
5511 ASC_PRINT2( "advansys_info: board %d: unknown bus type %d\n", 4292 busname = "?";
5512 boardp->id, asc_dvc_varp->bus_type); 4293 ASC_PRINT2
5513 } 4294 ("advansys_info: board %d: unknown bus type %d\n",
5514 /* Don't reference 'shp->n_io_port'; It may be truncated. */ 4295 boardp->id, asc_dvc_varp->bus_type);
5515 sprintf(info, 4296 }
5516 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X", 4297 /* Don't reference 'shost->n_io_port'; It may be truncated. */
5517 ASC_VERSION, busname, 4298 sprintf(info,
5518 (ulong) shp->io_port, 4299 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
5519 (ulong) shp->io_port + boardp->asc_n_io_port - 1, 4300 ASC_VERSION, busname,
5520 shp->irq); 4301 (ulong)shost->io_port,
5521 } 4302 (ulong)shost->io_port + boardp->asc_n_io_port -
5522 } else { 4303 1, shost->irq);
5523 /* 4304 }
5524 * Wide Adapter Information 4305 } else {
5525 * 4306 /*
5526 * Memory-mapped I/O is used instead of I/O space to access 4307 * Wide Adapter Information
5527 * the adapter, but display the I/O Port range. The Memory 4308 *
5528 * I/O address is displayed through the driver /proc file. 4309 * Memory-mapped I/O is used instead of I/O space to access
5529 */ 4310 * the adapter, but display the I/O Port range. The Memory
5530 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var; 4311 * I/O address is displayed through the driver /proc file.
5531 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) 4312 */
5532 { 4313 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
5533 iolen = ADV_3550_IOLEN; 4314 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
5534 widename = "Ultra-Wide"; 4315 iolen = ADV_3550_IOLEN;
5535 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) 4316 widename = "Ultra-Wide";
5536 { 4317 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
5537 iolen = ADV_38C0800_IOLEN; 4318 iolen = ADV_38C0800_IOLEN;
5538 widename = "Ultra2-Wide"; 4319 widename = "Ultra2-Wide";
5539 } else 4320 } else {
5540 { 4321 iolen = ADV_38C1600_IOLEN;
5541 iolen = ADV_38C1600_IOLEN; 4322 widename = "Ultra3-Wide";
5542 widename = "Ultra3-Wide"; 4323 }
5543 } 4324 sprintf(info,
5544 sprintf(info, "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X", 4325 "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
5545 ASC_VERSION, 4326 ASC_VERSION, widename, (ulong)adv_dvc_varp->iop_base,
5546 widename, 4327 (ulong)adv_dvc_varp->iop_base + iolen - 1, shost->irq);
5547 (ulong) adv_dvc_varp->iop_base, 4328 }
5548 (ulong) adv_dvc_varp->iop_base + iolen - 1, 4329 ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
5549 shp->irq); 4330 ASC_DBG(1, "advansys_info: end\n");
5550 } 4331 return info;
5551 ASC_ASSERT(strlen(info) < ASC_INFO_SIZE);
5552 ASC_DBG(1, "advansys_info: end\n");
5553 return info;
5554} 4332}
5555 4333
5556/* 4334/*
@@ -5560,82 +4338,82 @@ advansys_info(struct Scsi_Host *shp)
5560 * in the 'scp' result field. 4338 * in the 'scp' result field.
5561 */ 4339 */
5562static int 4340static int
5563advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *)) 4341advansys_queuecommand(struct scsi_cmnd *scp, void (*done) (struct scsi_cmnd *))
5564{ 4342{
5565 struct Scsi_Host *shp; 4343 struct Scsi_Host *shost;
5566 asc_board_t *boardp; 4344 asc_board_t *boardp;
5567 ulong flags; 4345 ulong flags;
5568 struct scsi_cmnd *done_scp; 4346 struct scsi_cmnd *done_scp;
5569 4347
5570 shp = scp->device->host; 4348 shost = scp->device->host;
5571 boardp = ASC_BOARDP(shp); 4349 boardp = ASC_BOARDP(shost);
5572 ASC_STATS(shp, queuecommand); 4350 ASC_STATS(shost, queuecommand);
5573 4351
5574 /* host_lock taken by mid-level prior to call but need to protect */ 4352 /* host_lock taken by mid-level prior to call but need to protect */
5575 /* against own ISR */ 4353 /* against own ISR */
5576 spin_lock_irqsave(&boardp->lock, flags); 4354 spin_lock_irqsave(&boardp->lock, flags);
5577 4355
5578 /* 4356 /*
5579 * Block new commands while handling a reset or abort request. 4357 * Block new commands while handling a reset or abort request.
5580 */ 4358 */
5581 if (boardp->flags & ASC_HOST_IN_RESET) { 4359 if (boardp->flags & ASC_HOST_IN_RESET) {
5582 ASC_DBG1(1, 4360 ASC_DBG1(1,
5583 "advansys_queuecommand: scp 0x%lx blocked for reset request\n", 4361 "advansys_queuecommand: scp 0x%lx blocked for reset request\n",
5584 (ulong) scp); 4362 (ulong)scp);
5585 scp->result = HOST_BYTE(DID_RESET); 4363 scp->result = HOST_BYTE(DID_RESET);
5586
5587 /*
5588 * Add blocked requests to the board's 'done' queue. The queued
5589 * requests will be completed at the end of the abort or reset
5590 * handling.
5591 */
5592 asc_enqueue(&boardp->done, scp, ASC_BACK);
5593 spin_unlock_irqrestore(&boardp->lock, flags);
5594 return 0;
5595 }
5596 4364
5597 /* 4365 /*
5598 * Attempt to execute any waiting commands for the board. 4366 * Add blocked requests to the board's 'done' queue. The queued
5599 */ 4367 * requests will be completed at the end of the abort or reset
5600 if (!ASC_QUEUE_EMPTY(&boardp->waiting)) { 4368 * handling.
5601 ASC_DBG(1, 4369 */
5602 "advansys_queuecommand: before asc_execute_queue() waiting\n"); 4370 asc_enqueue(&boardp->done, scp, ASC_BACK);
5603 asc_execute_queue(&boardp->waiting); 4371 spin_unlock_irqrestore(&boardp->lock, flags);
5604 } 4372 return 0;
4373 }
5605 4374
5606 /* 4375 /*
5607 * Save the function pointer to Linux mid-level 'done' function 4376 * Attempt to execute any waiting commands for the board.
5608 * and attempt to execute the command. 4377 */
5609 * 4378 if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
5610 * If ASC_NOERROR is returned the request has been added to the 4379 ASC_DBG(1,
5611 * board's 'active' queue and will be completed by the interrupt 4380 "advansys_queuecommand: before asc_execute_queue() waiting\n");
5612 * handler. 4381 asc_execute_queue(&boardp->waiting);
5613 * 4382 }
5614 * If ASC_BUSY is returned add the request to the board's per 4383
5615 * target waiting list. This is the first time the request has 4384 /*
5616 * been tried. Add it to the back of the waiting list. It will be 4385 * Save the function pointer to Linux mid-level 'done' function
5617 * retried later. 4386 * and attempt to execute the command.
5618 * 4387 *
5619 * If an error occurred, the request will have been placed on the 4388 * If ASC_NOERROR is returned the request has been added to the
5620 * board's 'done' queue and must be completed before returning. 4389 * board's 'active' queue and will be completed by the interrupt
5621 */ 4390 * handler.
5622 scp->scsi_done = done; 4391 *
5623 switch (asc_execute_scsi_cmnd(scp)) { 4392 * If ASC_BUSY is returned add the request to the board's per
5624 case ASC_NOERROR: 4393 * target waiting list. This is the first time the request has
5625 break; 4394 * been tried. Add it to the back of the waiting list. It will be
5626 case ASC_BUSY: 4395 * retried later.
5627 asc_enqueue(&boardp->waiting, scp, ASC_BACK); 4396 *
5628 break; 4397 * If an error occurred, the request will have been placed on the
5629 case ASC_ERROR: 4398 * board's 'done' queue and must be completed before returning.
5630 default: 4399 */
5631 done_scp = asc_dequeue_list(&boardp->done, NULL, ASC_TID_ALL); 4400 scp->scsi_done = done;
5632 /* Interrupts could be enabled here. */ 4401 switch (asc_execute_scsi_cmnd(scp)) {
5633 asc_scsi_done_list(done_scp); 4402 case ASC_NOERROR:
5634 break; 4403 break;
5635 } 4404 case ASC_BUSY:
5636 spin_unlock_irqrestore(&boardp->lock, flags); 4405 asc_enqueue(&boardp->waiting, scp, ASC_BACK);
4406 break;
4407 case ASC_ERROR:
4408 default:
4409 done_scp = asc_dequeue_list(&boardp->done, NULL, ASC_TID_ALL);
4410 /* Interrupts could be enabled here. */
4411 asc_scsi_done_list(done_scp);
4412 break;
4413 }
4414 spin_unlock_irqrestore(&boardp->lock, flags);
5637 4415
5638 return 0; 4416 return 0;
5639} 4417}
5640 4418
5641/* 4419/*
@@ -5647,178 +4425,187 @@ advansys_queuecommand(struct scsi_cmnd *scp, void (*done)(struct scsi_cmnd *))
5647 * sleeping is allowed and no locking other than for host structures is 4425 * sleeping is allowed and no locking other than for host structures is
5648 * required. Returns SUCCESS or FAILED. 4426 * required. Returns SUCCESS or FAILED.
5649 */ 4427 */
5650static int 4428static int advansys_reset(struct scsi_cmnd *scp)
5651advansys_reset(struct scsi_cmnd *scp)
5652{ 4429{
5653 struct Scsi_Host *shp; 4430 struct Scsi_Host *shost;
5654 asc_board_t *boardp; 4431 asc_board_t *boardp;
5655 ASC_DVC_VAR *asc_dvc_varp; 4432 ASC_DVC_VAR *asc_dvc_varp;
5656 ADV_DVC_VAR *adv_dvc_varp; 4433 ADV_DVC_VAR *adv_dvc_varp;
5657 ulong flags; 4434 ulong flags;
5658 struct scsi_cmnd *done_scp = NULL, *last_scp = NULL; 4435 struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
5659 struct scsi_cmnd *tscp, *new_last_scp; 4436 struct scsi_cmnd *tscp, *new_last_scp;
5660 int status; 4437 int status;
5661 int ret = SUCCESS; 4438 int ret = SUCCESS;
5662 4439
5663 ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong) scp); 4440 ASC_DBG1(1, "advansys_reset: 0x%lx\n", (ulong)scp);
5664 4441
5665#ifdef ADVANSYS_STATS 4442#ifdef ADVANSYS_STATS
5666 if (scp->device->host != NULL) { 4443 if (scp->device->host != NULL) {
5667 ASC_STATS(scp->device->host, reset); 4444 ASC_STATS(scp->device->host, reset);
5668 } 4445 }
5669#endif /* ADVANSYS_STATS */ 4446#endif /* ADVANSYS_STATS */
5670 4447
5671 if ((shp = scp->device->host) == NULL) { 4448 if ((shost = scp->device->host) == NULL) {
5672 scp->result = HOST_BYTE(DID_ERROR); 4449 scp->result = HOST_BYTE(DID_ERROR);
5673 return FAILED; 4450 return FAILED;
5674 } 4451 }
5675 4452
5676 boardp = ASC_BOARDP(shp); 4453 boardp = ASC_BOARDP(shost);
5677 4454
5678 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n", 4455 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset started...\n",
5679 boardp->id); 4456 boardp->id);
5680 /* 4457 /*
5681 * Check for re-entrancy. 4458 * Check for re-entrancy.
5682 */ 4459 */
5683 spin_lock_irqsave(&boardp->lock, flags);
5684 if (boardp->flags & ASC_HOST_IN_RESET) {
5685 spin_unlock_irqrestore(&boardp->lock, flags);
5686 return FAILED;
5687 }
5688 boardp->flags |= ASC_HOST_IN_RESET;
5689 spin_unlock_irqrestore(&boardp->lock, flags);
5690
5691 if (ASC_NARROW_BOARD(boardp)) {
5692 /*
5693 * Narrow Board
5694 */
5695 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
5696
5697 /*
5698 * Reset the chip and SCSI bus.
5699 */
5700 ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
5701 status = AscInitAsc1000Driver(asc_dvc_varp);
5702
5703 /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
5704 if (asc_dvc_varp->err_code) {
5705 ASC_PRINT2(
5706 "advansys_reset: board %d: SCSI bus reset error: 0x%x\n",
5707 boardp->id, asc_dvc_varp->err_code);
5708 ret = FAILED;
5709 } else if (status) {
5710 ASC_PRINT2(
5711 "advansys_reset: board %d: SCSI bus reset warning: 0x%x\n",
5712 boardp->id, status);
5713 } else {
5714 ASC_PRINT1(
5715 "advansys_reset: board %d: SCSI bus reset successful.\n",
5716 boardp->id);
5717 }
5718
5719 ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
5720 spin_lock_irqsave(&boardp->lock, flags); 4460 spin_lock_irqsave(&boardp->lock, flags);
4461 if (boardp->flags & ASC_HOST_IN_RESET) {
4462 spin_unlock_irqrestore(&boardp->lock, flags);
4463 return FAILED;
4464 }
4465 boardp->flags |= ASC_HOST_IN_RESET;
4466 spin_unlock_irqrestore(&boardp->lock, flags);
5721 4467
5722 } else { 4468 if (ASC_NARROW_BOARD(boardp)) {
5723 /* 4469 /*
5724 * Wide Board 4470 * Narrow Board
5725 * 4471 */
5726 * If the suggest reset bus flags are set, then reset the bus. 4472 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
5727 * Otherwise only reset the device.
5728 */
5729 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
5730
5731 /*
5732 * Reset the target's SCSI bus.
5733 */
5734 ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
5735 switch (AdvResetChipAndSB(adv_dvc_varp)) {
5736 case ASC_TRUE:
5737 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset successful.\n",
5738 boardp->id);
5739 break;
5740 case ASC_FALSE:
5741 default:
5742 ASC_PRINT1("advansys_reset: board %d: SCSI bus reset error.\n",
5743 boardp->id);
5744 ret = FAILED;
5745 break;
5746 }
5747 spin_lock_irqsave(&boardp->lock, flags);
5748 (void) AdvISR(adv_dvc_varp);
5749 }
5750 /* Board lock is held. */
5751 4473
5752 /* 4474 /*
5753 * Dequeue all board 'done' requests. A pointer to the last request 4475 * Reset the chip and SCSI bus.
5754 * is returned in 'last_scp'. 4476 */
5755 */ 4477 ASC_DBG(1, "advansys_reset: before AscInitAsc1000Driver()\n");
5756 done_scp = asc_dequeue_list(&boardp->done, &last_scp, ASC_TID_ALL); 4478 status = AscInitAsc1000Driver(asc_dvc_varp);
4479
4480 /* Refer to ASC_IERR_* defintions for meaning of 'err_code'. */
4481 if (asc_dvc_varp->err_code) {
4482 ASC_PRINT2
4483 ("advansys_reset: board %d: SCSI bus reset error: 0x%x\n",
4484 boardp->id, asc_dvc_varp->err_code);
4485 ret = FAILED;
4486 } else if (status) {
4487 ASC_PRINT2
4488 ("advansys_reset: board %d: SCSI bus reset warning: 0x%x\n",
4489 boardp->id, status);
4490 } else {
4491 ASC_PRINT1
4492 ("advansys_reset: board %d: SCSI bus reset successful.\n",
4493 boardp->id);
4494 }
4495
4496 ASC_DBG(1, "advansys_reset: after AscInitAsc1000Driver()\n");
4497 spin_lock_irqsave(&boardp->lock, flags);
5757 4498
5758 /* 4499 } else {
5759 * Dequeue all board 'active' requests for all devices and set 4500 /*
5760 * the request status to DID_RESET. A pointer to the last request 4501 * Wide Board
5761 * is returned in 'last_scp'. 4502 *
5762 */ 4503 * If the suggest reset bus flags are set, then reset the bus.
5763 if (done_scp == NULL) { 4504 * Otherwise only reset the device.
5764 done_scp = asc_dequeue_list(&boardp->active, &last_scp, ASC_TID_ALL); 4505 */
5765 for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) { 4506 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
5766 tscp->result = HOST_BYTE(DID_RESET);
5767 }
5768 } else {
5769 /* Append to 'done_scp' at the end with 'last_scp'. */
5770 ASC_ASSERT(last_scp != NULL);
5771 last_scp->host_scribble = (unsigned char *)asc_dequeue_list(
5772 &boardp->active, &new_last_scp, ASC_TID_ALL);
5773 if (new_last_scp != NULL) {
5774 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
5775 for (tscp = REQPNEXT(last_scp); tscp; tscp = REQPNEXT(tscp)) {
5776 tscp->result = HOST_BYTE(DID_RESET);
5777 }
5778 last_scp = new_last_scp;
5779 }
5780 }
5781 4507
5782 /* 4508 /*
5783 * Dequeue all 'waiting' requests and set the request status 4509 * Reset the target's SCSI bus.
5784 * to DID_RESET. 4510 */
5785 */ 4511 ASC_DBG(1, "advansys_reset: before AdvResetChipAndSB()\n");
5786 if (done_scp == NULL) { 4512 switch (AdvResetChipAndSB(adv_dvc_varp)) {
5787 done_scp = asc_dequeue_list(&boardp->waiting, &last_scp, ASC_TID_ALL); 4513 case ASC_TRUE:
5788 for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) { 4514 ASC_PRINT1
5789 tscp->result = HOST_BYTE(DID_RESET); 4515 ("advansys_reset: board %d: SCSI bus reset successful.\n",
5790 } 4516 boardp->id);
5791 } else { 4517 break;
5792 /* Append to 'done_scp' at the end with 'last_scp'. */ 4518 case ASC_FALSE:
5793 ASC_ASSERT(last_scp != NULL); 4519 default:
5794 last_scp->host_scribble = (unsigned char *)asc_dequeue_list( 4520 ASC_PRINT1
5795 &boardp->waiting, &new_last_scp, ASC_TID_ALL); 4521 ("advansys_reset: board %d: SCSI bus reset error.\n",
5796 if (new_last_scp != NULL) { 4522 boardp->id);
5797 ASC_ASSERT(REQPNEXT(last_scp) != NULL); 4523 ret = FAILED;
5798 for (tscp = REQPNEXT(last_scp); tscp; tscp = REQPNEXT(tscp)) { 4524 break;
5799 tscp->result = HOST_BYTE(DID_RESET); 4525 }
5800 } 4526 spin_lock_irqsave(&boardp->lock, flags);
5801 last_scp = new_last_scp; 4527 (void)AdvISR(adv_dvc_varp);
5802 } 4528 }
5803 } 4529 /* Board lock is held. */
4530
4531 /*
4532 * Dequeue all board 'done' requests. A pointer to the last request
4533 * is returned in 'last_scp'.
4534 */
4535 done_scp = asc_dequeue_list(&boardp->done, &last_scp, ASC_TID_ALL);
4536
4537 /*
4538 * Dequeue all board 'active' requests for all devices and set
4539 * the request status to DID_RESET. A pointer to the last request
4540 * is returned in 'last_scp'.
4541 */
4542 if (done_scp == NULL) {
4543 done_scp =
4544 asc_dequeue_list(&boardp->active, &last_scp, ASC_TID_ALL);
4545 for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
4546 tscp->result = HOST_BYTE(DID_RESET);
4547 }
4548 } else {
4549 /* Append to 'done_scp' at the end with 'last_scp'. */
4550 ASC_ASSERT(last_scp != NULL);
4551 last_scp->host_scribble =
4552 (unsigned char *)asc_dequeue_list(&boardp->active,
4553 &new_last_scp,
4554 ASC_TID_ALL);
4555 if (new_last_scp != NULL) {
4556 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
4557 for (tscp = REQPNEXT(last_scp); tscp;
4558 tscp = REQPNEXT(tscp)) {
4559 tscp->result = HOST_BYTE(DID_RESET);
4560 }
4561 last_scp = new_last_scp;
4562 }
4563 }
5804 4564
5805 /* Save the time of the most recently completed reset. */ 4565 /*
5806 boardp->last_reset = jiffies; 4566 * Dequeue all 'waiting' requests and set the request status
4567 * to DID_RESET.
4568 */
4569 if (done_scp == NULL) {
4570 done_scp =
4571 asc_dequeue_list(&boardp->waiting, &last_scp, ASC_TID_ALL);
4572 for (tscp = done_scp; tscp; tscp = REQPNEXT(tscp)) {
4573 tscp->result = HOST_BYTE(DID_RESET);
4574 }
4575 } else {
4576 /* Append to 'done_scp' at the end with 'last_scp'. */
4577 ASC_ASSERT(last_scp != NULL);
4578 last_scp->host_scribble =
4579 (unsigned char *)asc_dequeue_list(&boardp->waiting,
4580 &new_last_scp,
4581 ASC_TID_ALL);
4582 if (new_last_scp != NULL) {
4583 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
4584 for (tscp = REQPNEXT(last_scp); tscp;
4585 tscp = REQPNEXT(tscp)) {
4586 tscp->result = HOST_BYTE(DID_RESET);
4587 }
4588 last_scp = new_last_scp;
4589 }
4590 }
5807 4591
5808 /* Clear reset flag. */ 4592 /* Save the time of the most recently completed reset. */
5809 boardp->flags &= ~ASC_HOST_IN_RESET; 4593 boardp->last_reset = jiffies;
5810 spin_unlock_irqrestore(&boardp->lock, flags);
5811 4594
5812 /* 4595 /* Clear reset flag. */
5813 * Complete all the 'done_scp' requests. 4596 boardp->flags &= ~ASC_HOST_IN_RESET;
5814 */ 4597 spin_unlock_irqrestore(&boardp->lock, flags);
5815 if (done_scp != NULL) {
5816 asc_scsi_done_list(done_scp);
5817 }
5818 4598
5819 ASC_DBG1(1, "advansys_reset: ret %d\n", ret); 4599 /*
4600 * Complete all the 'done_scp' requests.
4601 */
4602 if (done_scp != NULL) {
4603 asc_scsi_done_list(done_scp);
4604 }
5820 4605
5821 return ret; 4606 ASC_DBG1(1, "advansys_reset: ret %d\n", ret);
4607
4608 return ret;
5822} 4609}
5823 4610
5824/* 4611/*
@@ -5834,71 +4621,70 @@ advansys_reset(struct scsi_cmnd *scp)
5834 */ 4621 */
5835static int 4622static int
5836advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev, 4623advansys_biosparam(struct scsi_device *sdev, struct block_device *bdev,
5837 sector_t capacity, int ip[]) 4624 sector_t capacity, int ip[])
5838{ 4625{
5839 asc_board_t *boardp; 4626 asc_board_t *boardp;
5840 4627
5841 ASC_DBG(1, "advansys_biosparam: begin\n"); 4628 ASC_DBG(1, "advansys_biosparam: begin\n");
5842 ASC_STATS(sdev->host, biosparam); 4629 ASC_STATS(sdev->host, biosparam);
5843 boardp = ASC_BOARDP(sdev->host); 4630 boardp = ASC_BOARDP(sdev->host);
5844 if (ASC_NARROW_BOARD(boardp)) { 4631 if (ASC_NARROW_BOARD(boardp)) {
5845 if ((boardp->dvc_var.asc_dvc_var.dvc_cntl & 4632 if ((boardp->dvc_var.asc_dvc_var.dvc_cntl &
5846 ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) { 4633 ASC_CNTL_BIOS_GT_1GB) && capacity > 0x200000) {
5847 ip[0] = 255; 4634 ip[0] = 255;
5848 ip[1] = 63; 4635 ip[1] = 63;
5849 } else { 4636 } else {
5850 ip[0] = 64; 4637 ip[0] = 64;
5851 ip[1] = 32; 4638 ip[1] = 32;
5852 } 4639 }
5853 } else { 4640 } else {
5854 if ((boardp->dvc_var.adv_dvc_var.bios_ctrl & 4641 if ((boardp->dvc_var.adv_dvc_var.bios_ctrl &
5855 BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) { 4642 BIOS_CTRL_EXTENDED_XLAT) && capacity > 0x200000) {
5856 ip[0] = 255; 4643 ip[0] = 255;
5857 ip[1] = 63; 4644 ip[1] = 63;
5858 } else { 4645 } else {
5859 ip[0] = 64; 4646 ip[0] = 64;
5860 ip[1] = 32; 4647 ip[1] = 32;
5861 } 4648 }
5862 } 4649 }
5863 ip[2] = (unsigned long)capacity / (ip[0] * ip[1]); 4650 ip[2] = (unsigned long)capacity / (ip[0] * ip[1]);
5864 ASC_DBG(1, "advansys_biosparam: end\n"); 4651 ASC_DBG(1, "advansys_biosparam: end\n");
5865 return 0; 4652 return 0;
5866} 4653}
5867 4654
5868/* 4655static int __init advansys_detect(struct scsi_host_template *tpnt);
5869 * --- Loadable Driver Support 4656static int advansys_release(struct Scsi_Host *shp);
5870 */
5871 4657
5872static struct scsi_host_template driver_template = { 4658static struct scsi_host_template driver_template = {
5873 .proc_name = "advansys", 4659 .proc_name = "advansys",
5874#ifdef CONFIG_PROC_FS 4660#ifdef CONFIG_PROC_FS
5875 .proc_info = advansys_proc_info, 4661 .proc_info = advansys_proc_info,
5876#endif 4662#endif
5877 .name = "advansys", 4663 .name = "advansys",
5878 .detect = advansys_detect, 4664 .detect = advansys_detect,
5879 .release = advansys_release, 4665 .release = advansys_release,
5880 .info = advansys_info, 4666 .info = advansys_info,
5881 .queuecommand = advansys_queuecommand, 4667 .queuecommand = advansys_queuecommand,
5882 .eh_bus_reset_handler = advansys_reset, 4668 .eh_bus_reset_handler = advansys_reset,
5883 .bios_param = advansys_biosparam, 4669 .bios_param = advansys_biosparam,
5884 .slave_configure = advansys_slave_configure, 4670 .slave_configure = advansys_slave_configure,
5885 /* 4671 /*
5886 * Because the driver may control an ISA adapter 'unchecked_isa_dma' 4672 * Because the driver may control an ISA adapter 'unchecked_isa_dma'
5887 * must be set. The flag will be cleared in advansys_detect for non-ISA 4673 * must be set. The flag will be cleared in advansys_detect for non-ISA
5888 * adapters. Refer to the comment in scsi_module.c for more information. 4674 * adapters. Refer to the comment in scsi_module.c for more information.
5889 */ 4675 */
5890 .unchecked_isa_dma = 1, 4676 .unchecked_isa_dma = 1,
5891 /* 4677 /*
5892 * All adapters controlled by this driver are capable of large 4678 * All adapters controlled by this driver are capable of large
5893 * scatter-gather lists. According to the mid-level SCSI documentation 4679 * scatter-gather lists. According to the mid-level SCSI documentation
5894 * this obviates any performance gain provided by setting 4680 * this obviates any performance gain provided by setting
5895 * 'use_clustering'. But empirically while CPU utilization is increased 4681 * 'use_clustering'. But empirically while CPU utilization is increased
5896 * by enabling clustering, I/O throughput increases as well. 4682 * by enabling clustering, I/O throughput increases as well.
5897 */ 4683 */
5898 .use_clustering = ENABLE_CLUSTERING, 4684 .use_clustering = ENABLE_CLUSTERING,
5899}; 4685};
5900#include "scsi_module.c"
5901 4686
4687#include "scsi_module.c"
5902 4688
5903/* 4689/*
5904 * --- Miscellaneous Driver Functions 4690 * --- Miscellaneous Driver Functions
@@ -5913,130 +4699,138 @@ static struct scsi_host_template driver_template = {
5913 * to the AdvanSys driver which is for a device sharing an interrupt with 4699 * to the AdvanSys driver which is for a device sharing an interrupt with
5914 * an AdvanSys adapter. 4700 * an AdvanSys adapter.
5915 */ 4701 */
5916STATIC irqreturn_t 4702static irqreturn_t advansys_interrupt(int irq, void *dev_id)
5917advansys_interrupt(int irq, void *dev_id)
5918{ 4703{
5919 ulong flags; 4704 ulong flags;
5920 int i; 4705 int i;
5921 asc_board_t *boardp; 4706 asc_board_t *boardp;
5922 struct scsi_cmnd *done_scp = NULL, *last_scp = NULL; 4707 struct scsi_cmnd *done_scp = NULL, *last_scp = NULL;
5923 struct scsi_cmnd *new_last_scp; 4708 struct scsi_cmnd *new_last_scp;
5924 struct Scsi_Host *shp; 4709 struct Scsi_Host *shost;
5925 4710
5926 ASC_DBG(1, "advansys_interrupt: begin\n"); 4711 ASC_DBG(1, "advansys_interrupt: begin\n");
4712
4713 /*
4714 * Check for interrupts on all boards.
4715 * AscISR() will call asc_isr_callback().
4716 */
4717 for (i = 0; i < asc_board_count; i++) {
4718 shost = asc_host[i];
4719 boardp = ASC_BOARDP(shost);
4720 ASC_DBG2(2, "advansys_interrupt: i %d, boardp 0x%lx\n",
4721 i, (ulong)boardp);
4722 spin_lock_irqsave(&boardp->lock, flags);
4723 if (ASC_NARROW_BOARD(boardp)) {
4724 /*
4725 * Narrow Board
4726 */
4727 if (AscIsIntPending(shost->io_port)) {
4728 ASC_STATS(shost, interrupt);
4729 ASC_DBG(1,
4730 "advansys_interrupt: before AscISR()\n");
4731 AscISR(&boardp->dvc_var.asc_dvc_var);
4732 }
4733 } else {
4734 /*
4735 * Wide Board
4736 */
4737 ASC_DBG(1, "advansys_interrupt: before AdvISR()\n");
4738 if (AdvISR(&boardp->dvc_var.adv_dvc_var)) {
4739 ASC_STATS(shost, interrupt);
4740 }
4741 }
5927 4742
5928 /* 4743 /*
5929 * Check for interrupts on all boards. 4744 * Start waiting requests and create a list of completed requests.
5930 * AscISR() will call asc_isr_callback(). 4745 *
5931 */ 4746 * If a reset request is being performed for the board, the reset
5932 for (i = 0; i < asc_board_count; i++) { 4747 * handler will complete pending requests after it has completed.
5933 shp = asc_host[i]; 4748 */
5934 boardp = ASC_BOARDP(shp); 4749 if ((boardp->flags & ASC_HOST_IN_RESET) == 0) {
5935 ASC_DBG2(2, "advansys_interrupt: i %d, boardp 0x%lx\n", 4750 ASC_DBG2(1,
5936 i, (ulong) boardp); 4751 "advansys_interrupt: done_scp 0x%lx, last_scp 0x%lx\n",
5937 spin_lock_irqsave(&boardp->lock, flags); 4752 (ulong)done_scp, (ulong)last_scp);
5938 if (ASC_NARROW_BOARD(boardp)) { 4753
5939 /* 4754 /* Start any waiting commands for the board. */
5940 * Narrow Board 4755 if (!ASC_QUEUE_EMPTY(&boardp->waiting)) {
5941 */ 4756 ASC_DBG(1,
5942 if (AscIsIntPending(shp->io_port)) { 4757 "advansys_interrupt: before asc_execute_queue()\n");
5943 ASC_STATS(shp, interrupt); 4758 asc_execute_queue(&boardp->waiting);
5944 ASC_DBG(1, "advansys_interrupt: before AscISR()\n"); 4759 }
5945 AscISR(&boardp->dvc_var.asc_dvc_var); 4760
5946 } 4761 /*
5947 } else { 4762 * Add to the list of requests that must be completed.
5948 /* 4763 *
5949 * Wide Board 4764 * 'done_scp' will always be NULL on the first iteration
5950 */ 4765 * of this loop. 'last_scp' is set at the same time as
5951 ASC_DBG(1, "advansys_interrupt: before AdvISR()\n"); 4766 * 'done_scp'.
5952 if (AdvISR(&boardp->dvc_var.adv_dvc_var)) { 4767 */
5953 ASC_STATS(shp, interrupt); 4768 if (done_scp == NULL) {
5954 } 4769 done_scp =
5955 } 4770 asc_dequeue_list(&boardp->done, &last_scp,
5956 4771 ASC_TID_ALL);
5957 /* 4772 } else {
5958 * Start waiting requests and create a list of completed requests. 4773 ASC_ASSERT(last_scp != NULL);
5959 * 4774 last_scp->host_scribble =
5960 * If a reset request is being performed for the board, the reset 4775 (unsigned char *)asc_dequeue_list(&boardp->
5961 * handler will complete pending requests after it has completed. 4776 done,
5962 */ 4777 &new_last_scp,
5963 if ((boardp->flags & ASC_HOST_IN_RESET) == 0) { 4778 ASC_TID_ALL);
5964 ASC_DBG2(1, "advansys_interrupt: done_scp 0x%lx, last_scp 0x%lx\n", 4779 if (new_last_scp != NULL) {
5965 (ulong) done_scp, (ulong) last_scp); 4780 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
5966 4781 last_scp = new_last_scp;
5967 /* Start any waiting commands for the board. */ 4782 }
5968 if (!ASC_QUEUE_EMPTY(&boardp->waiting)) { 4783 }
5969 ASC_DBG(1, "advansys_interrupt: before asc_execute_queue()\n"); 4784 }
5970 asc_execute_queue(&boardp->waiting); 4785 spin_unlock_irqrestore(&boardp->lock, flags);
5971 } 4786 }
5972
5973 /*
5974 * Add to the list of requests that must be completed.
5975 *
5976 * 'done_scp' will always be NULL on the first iteration
5977 * of this loop. 'last_scp' is set at the same time as
5978 * 'done_scp'.
5979 */
5980 if (done_scp == NULL) {
5981 done_scp = asc_dequeue_list(&boardp->done, &last_scp,
5982 ASC_TID_ALL);
5983 } else {
5984 ASC_ASSERT(last_scp != NULL);
5985 last_scp->host_scribble = (unsigned char *)asc_dequeue_list(
5986 &boardp->done, &new_last_scp, ASC_TID_ALL);
5987 if (new_last_scp != NULL) {
5988 ASC_ASSERT(REQPNEXT(last_scp) != NULL);
5989 last_scp = new_last_scp;
5990 }
5991 }
5992 }
5993 spin_unlock_irqrestore(&boardp->lock, flags);
5994 }
5995 4787
5996 /* 4788 /*
5997 * If interrupts were enabled on entry, then they 4789 * If interrupts were enabled on entry, then they
5998 * are now enabled here. 4790 * are now enabled here.
5999 * 4791 *
6000 * Complete all requests on the done list. 4792 * Complete all requests on the done list.
6001 */ 4793 */
6002 4794
6003 asc_scsi_done_list(done_scp); 4795 asc_scsi_done_list(done_scp);
6004 4796
6005 ASC_DBG(1, "advansys_interrupt: end\n"); 4797 ASC_DBG(1, "advansys_interrupt: end\n");
6006 return IRQ_HANDLED; 4798 return IRQ_HANDLED;
6007} 4799}
6008 4800
6009/* 4801/*
6010 * Set the number of commands to queue per device for the 4802 * Set the number of commands to queue per device for the
6011 * specified host adapter. 4803 * specified host adapter.
6012 */ 4804 */
6013STATIC int 4805static int advansys_slave_configure(struct scsi_device *device)
6014advansys_slave_configure(struct scsi_device *device)
6015{ 4806{
6016 asc_board_t *boardp; 4807 asc_board_t *boardp;
6017 4808
6018 boardp = ASC_BOARDP(device->host); 4809 boardp = ASC_BOARDP(device->host);
6019 boardp->flags |= ASC_SELECT_QUEUE_DEPTHS; 4810 boardp->flags |= ASC_SELECT_QUEUE_DEPTHS;
6020 /* 4811 /*
6021 * Save a pointer to the device and set its initial/maximum 4812 * Save a pointer to the device and set its initial/maximum
6022 * queue depth. Only save the pointer for a lun0 dev though. 4813 * queue depth. Only save the pointer for a lun0 dev though.
6023 */ 4814 */
6024 if(device->lun == 0) 4815 if (device->lun == 0)
6025 boardp->device[device->id] = device; 4816 boardp->device[device->id] = device;
6026 if(device->tagged_supported) { 4817 if (device->tagged_supported) {
6027 if (ASC_NARROW_BOARD(boardp)) { 4818 if (ASC_NARROW_BOARD(boardp)) {
6028 scsi_adjust_queue_depth(device, MSG_ORDERED_TAG, 4819 scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
6029 boardp->dvc_var.asc_dvc_var.max_dvc_qng[device->id]); 4820 boardp->dvc_var.asc_dvc_var.
6030 } else { 4821 max_dvc_qng[device->id]);
6031 scsi_adjust_queue_depth(device, MSG_ORDERED_TAG, 4822 } else {
6032 boardp->dvc_var.adv_dvc_var.max_dvc_qng); 4823 scsi_adjust_queue_depth(device, MSG_ORDERED_TAG,
6033 } 4824 boardp->dvc_var.adv_dvc_var.
6034 } else { 4825 max_dvc_qng);
6035 scsi_adjust_queue_depth(device, 0, device->host->cmd_per_lun); 4826 }
6036 } 4827 } else {
6037 ASC_DBG4(1, "advansys_slave_configure: device 0x%lx, boardp 0x%lx, id %d, depth %d\n", 4828 scsi_adjust_queue_depth(device, 0, device->host->cmd_per_lun);
6038 (ulong) device, (ulong) boardp, device->id, device->queue_depth); 4829 }
6039 return 0; 4830 ASC_DBG4(1,
4831 "advansys_slave_configure: device 0x%lx, boardp 0x%lx, id %d, depth %d\n",
4832 (ulong)device, (ulong)boardp, device->id, device->queue_depth);
4833 return 0;
6040} 4834}
6041 4835
6042/* 4836/*
@@ -6045,43 +4839,44 @@ advansys_slave_configure(struct scsi_device *device)
6045 * 4839 *
6046 * Interrupts can be enabled on entry. 4840 * Interrupts can be enabled on entry.
6047 */ 4841 */
6048STATIC void 4842static void asc_scsi_done_list(struct scsi_cmnd *scp)
6049asc_scsi_done_list(struct scsi_cmnd *scp)
6050{ 4843{
6051 struct scsi_cmnd *tscp; 4844 struct scsi_cmnd *tscp;
6052 4845
6053 ASC_DBG(2, "asc_scsi_done_list: begin\n"); 4846 ASC_DBG(2, "asc_scsi_done_list: begin\n");
6054 while (scp != NULL) { 4847 while (scp != NULL) {
6055 asc_board_t *boardp; 4848 asc_board_t *boardp;
6056 struct device *dev; 4849 struct device *dev;
6057 4850
6058 ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong) scp); 4851 ASC_DBG1(3, "asc_scsi_done_list: scp 0x%lx\n", (ulong)scp);
6059 tscp = REQPNEXT(scp); 4852 tscp = REQPNEXT(scp);
6060 scp->host_scribble = NULL; 4853 scp->host_scribble = NULL;
6061 4854
6062 boardp = ASC_BOARDP(scp->device->host); 4855 boardp = ASC_BOARDP(scp->device->host);
6063 4856
6064 if (ASC_NARROW_BOARD(boardp)) 4857 if (ASC_NARROW_BOARD(boardp))
6065 dev = boardp->dvc_cfg.asc_dvc_cfg.dev; 4858 dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
6066 else 4859 else
6067 dev = boardp->dvc_cfg.adv_dvc_cfg.dev; 4860 dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
6068 4861
6069 if (scp->use_sg) 4862 if (scp->use_sg)
6070 dma_unmap_sg(dev, (struct scatterlist *)scp->request_buffer, 4863 dma_unmap_sg(dev,
6071 scp->use_sg, scp->sc_data_direction); 4864 (struct scatterlist *)scp->request_buffer,
6072 else if (scp->request_bufflen) 4865 scp->use_sg, scp->sc_data_direction);
6073 dma_unmap_single(dev, scp->SCp.dma_handle, 4866 else if (scp->request_bufflen)
6074 scp->request_bufflen, scp->sc_data_direction); 4867 dma_unmap_single(dev, scp->SCp.dma_handle,
4868 scp->request_bufflen,
4869 scp->sc_data_direction);
6075 4870
6076 ASC_STATS(scp->device->host, done); 4871 ASC_STATS(scp->device->host, done);
6077 ASC_ASSERT(scp->scsi_done != NULL); 4872 ASC_ASSERT(scp->scsi_done != NULL);
6078 4873
6079 scp->scsi_done(scp); 4874 scp->scsi_done(scp);
6080 4875
6081 scp = tscp; 4876 scp = tscp;
6082 } 4877 }
6083 ASC_DBG(2, "asc_scsi_done_list: done\n"); 4878 ASC_DBG(2, "asc_scsi_done_list: done\n");
6084 return; 4879 return;
6085} 4880}
6086 4881
6087/* 4882/*
@@ -6130,168 +4925,170 @@ asc_scsi_done_list(struct scsi_cmnd *scp)
6130 * If ASC_BUSY is returned the request will be enqueued by the 4925 * If ASC_BUSY is returned the request will be enqueued by the
6131 * caller on the target's waiting queue and re-tried later. 4926 * caller on the target's waiting queue and re-tried later.
6132 */ 4927 */
6133STATIC int 4928static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
6134asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
6135{ 4929{
6136 asc_board_t *boardp; 4930 asc_board_t *boardp;
6137 ASC_DVC_VAR *asc_dvc_varp; 4931 ASC_DVC_VAR *asc_dvc_varp;
6138 ADV_DVC_VAR *adv_dvc_varp; 4932 ADV_DVC_VAR *adv_dvc_varp;
6139 ADV_SCSI_REQ_Q *adv_scsiqp; 4933 ADV_SCSI_REQ_Q *adv_scsiqp;
6140 struct scsi_device *device; 4934 struct scsi_device *device;
6141 int ret; 4935 int ret;
6142 4936
6143 ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n", 4937 ASC_DBG2(1, "asc_execute_scsi_cmnd: scp 0x%lx, done 0x%lx\n",
6144 (ulong) scp, (ulong) scp->scsi_done); 4938 (ulong)scp, (ulong)scp->scsi_done);
6145 4939
6146 boardp = ASC_BOARDP(scp->device->host); 4940 boardp = ASC_BOARDP(scp->device->host);
6147 device = boardp->device[scp->device->id]; 4941 device = boardp->device[scp->device->id];
6148 4942
6149 if (ASC_NARROW_BOARD(boardp)) { 4943 if (ASC_NARROW_BOARD(boardp)) {
6150 /* 4944 /*
6151 * Build and execute Narrow Board request. 4945 * Build and execute Narrow Board request.
6152 */ 4946 */
6153 4947
6154 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var; 4948 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
6155 4949
6156 /* 4950 /*
6157 * Build Asc Library request structure using the 4951 * Build Asc Library request structure using the
6158 * global structures 'asc_scsi_req' and 'asc_sg_head'. 4952 * global structures 'asc_scsi_req' and 'asc_sg_head'.
6159 * 4953 *
6160 * If an error is returned, then the request has been 4954 * If an error is returned, then the request has been
6161 * queued on the board done queue. It will be completed 4955 * queued on the board done queue. It will be completed
6162 * by the caller. 4956 * by the caller.
6163 * 4957 *
6164 * asc_build_req() can not return ASC_BUSY. 4958 * asc_build_req() can not return ASC_BUSY.
6165 */ 4959 */
6166 if (asc_build_req(boardp, scp) == ASC_ERROR) { 4960 if (asc_build_req(boardp, scp) == ASC_ERROR) {
6167 ASC_STATS(scp->device->host, build_error); 4961 ASC_STATS(scp->device->host, build_error);
6168 return ASC_ERROR; 4962 return ASC_ERROR;
6169 } 4963 }
6170
6171 /*
6172 * Execute the command. If there is no error, add the command
6173 * to the active queue.
6174 */
6175 switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
6176 case ASC_NOERROR:
6177 ASC_STATS(scp->device->host, exe_noerror);
6178 /*
6179 * Increment monotonically increasing per device successful
6180 * request counter. Wrapping doesn't matter.
6181 */
6182 boardp->reqcnt[scp->device->id]++;
6183 asc_enqueue(&boardp->active, scp, ASC_BACK);
6184 ASC_DBG(1,
6185 "asc_execute_scsi_cmnd: AscExeScsiQueue(), ASC_NOERROR\n");
6186 break;
6187 case ASC_BUSY:
6188 /*
6189 * Caller will enqueue request on the target's waiting queue
6190 * and retry later.
6191 */
6192 ASC_STATS(scp->device->host, exe_busy);
6193 break;
6194 case ASC_ERROR:
6195 ASC_PRINT2(
6196"asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
6197 boardp->id, asc_dvc_varp->err_code);
6198 ASC_STATS(scp->device->host, exe_error);
6199 scp->result = HOST_BYTE(DID_ERROR);
6200 asc_enqueue(&boardp->done, scp, ASC_BACK);
6201 break;
6202 default:
6203 ASC_PRINT2(
6204"asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() unknown, err_code 0x%x\n",
6205 boardp->id, asc_dvc_varp->err_code);
6206 ASC_STATS(scp->device->host, exe_unknown);
6207 scp->result = HOST_BYTE(DID_ERROR);
6208 asc_enqueue(&boardp->done, scp, ASC_BACK);
6209 break;
6210 }
6211 } else {
6212 /*
6213 * Build and execute Wide Board request.
6214 */
6215 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
6216
6217 /*
6218 * Build and get a pointer to an Adv Library request structure.
6219 *
6220 * If the request is successfully built then send it below,
6221 * otherwise return with an error.
6222 */
6223 switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
6224 case ASC_NOERROR:
6225 ASC_DBG(3, "asc_execute_scsi_cmnd: adv_build_req ASC_NOERROR\n");
6226 break;
6227 case ASC_BUSY:
6228 ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req ASC_BUSY\n");
6229 /*
6230 * If busy is returned the request has not been enqueued.
6231 * It will be enqueued by the caller on the target's waiting
6232 * queue and retried later.
6233 *
6234 * The asc_stats fields 'adv_build_noreq' and 'adv_build_nosg'
6235 * count wide board busy conditions. They are updated in
6236 * adv_build_req and adv_get_sglist, respectively.
6237 */
6238 return ASC_BUSY;
6239 case ASC_ERROR:
6240 /*
6241 * If an error is returned, then the request has been
6242 * queued on the board done queue. It will be completed
6243 * by the caller.
6244 */
6245 default:
6246 ASC_DBG(1, "asc_execute_scsi_cmnd: adv_build_req ASC_ERROR\n");
6247 ASC_STATS(scp->device->host, build_error);
6248 return ASC_ERROR;
6249 }
6250
6251 /*
6252 * Execute the command. If there is no error, add the command
6253 * to the active queue.
6254 */
6255 switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
6256 case ASC_NOERROR:
6257 ASC_STATS(scp->device->host, exe_noerror);
6258 /*
6259 * Increment monotonically increasing per device successful
6260 * request counter. Wrapping doesn't matter.
6261 */
6262 boardp->reqcnt[scp->device->id]++;
6263 asc_enqueue(&boardp->active, scp, ASC_BACK);
6264 ASC_DBG(1,
6265 "asc_execute_scsi_cmnd: AdvExeScsiQueue(), ASC_NOERROR\n");
6266 break;
6267 case ASC_BUSY:
6268 /*
6269 * Caller will enqueue request on the target's waiting queue
6270 * and retry later.
6271 */
6272 ASC_STATS(scp->device->host, exe_busy);
6273 break;
6274 case ASC_ERROR:
6275 ASC_PRINT2(
6276"asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
6277 boardp->id, adv_dvc_varp->err_code);
6278 ASC_STATS(scp->device->host, exe_error);
6279 scp->result = HOST_BYTE(DID_ERROR);
6280 asc_enqueue(&boardp->done, scp, ASC_BACK);
6281 break;
6282 default:
6283 ASC_PRINT2(
6284"asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() unknown, err_code 0x%x\n",
6285 boardp->id, adv_dvc_varp->err_code);
6286 ASC_STATS(scp->device->host, exe_unknown);
6287 scp->result = HOST_BYTE(DID_ERROR);
6288 asc_enqueue(&boardp->done, scp, ASC_BACK);
6289 break;
6290 }
6291 }
6292 4964
6293 ASC_DBG(1, "asc_execute_scsi_cmnd: end\n"); 4965 /*
6294 return ret; 4966 * Execute the command. If there is no error, add the command
4967 * to the active queue.
4968 */
4969 switch (ret = AscExeScsiQueue(asc_dvc_varp, &asc_scsi_q)) {
4970 case ASC_NOERROR:
4971 ASC_STATS(scp->device->host, exe_noerror);
4972 /*
4973 * Increment monotonically increasing per device successful
4974 * request counter. Wrapping doesn't matter.
4975 */
4976 boardp->reqcnt[scp->device->id]++;
4977 asc_enqueue(&boardp->active, scp, ASC_BACK);
4978 ASC_DBG(1,
4979 "asc_execute_scsi_cmnd: AscExeScsiQueue(), ASC_NOERROR\n");
4980 break;
4981 case ASC_BUSY:
4982 /*
4983 * Caller will enqueue request on the target's waiting queue
4984 * and retry later.
4985 */
4986 ASC_STATS(scp->device->host, exe_busy);
4987 break;
4988 case ASC_ERROR:
4989 ASC_PRINT2
4990 ("asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
4991 boardp->id, asc_dvc_varp->err_code);
4992 ASC_STATS(scp->device->host, exe_error);
4993 scp->result = HOST_BYTE(DID_ERROR);
4994 asc_enqueue(&boardp->done, scp, ASC_BACK);
4995 break;
4996 default:
4997 ASC_PRINT2
4998 ("asc_execute_scsi_cmnd: board %d: AscExeScsiQueue() unknown, err_code 0x%x\n",
4999 boardp->id, asc_dvc_varp->err_code);
5000 ASC_STATS(scp->device->host, exe_unknown);
5001 scp->result = HOST_BYTE(DID_ERROR);
5002 asc_enqueue(&boardp->done, scp, ASC_BACK);
5003 break;
5004 }
5005 } else {
5006 /*
5007 * Build and execute Wide Board request.
5008 */
5009 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
5010
5011 /*
5012 * Build and get a pointer to an Adv Library request structure.
5013 *
5014 * If the request is successfully built then send it below,
5015 * otherwise return with an error.
5016 */
5017 switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
5018 case ASC_NOERROR:
5019 ASC_DBG(3,
5020 "asc_execute_scsi_cmnd: adv_build_req ASC_NOERROR\n");
5021 break;
5022 case ASC_BUSY:
5023 ASC_DBG(1,
5024 "asc_execute_scsi_cmnd: adv_build_req ASC_BUSY\n");
5025 /*
5026 * If busy is returned the request has not been enqueued.
5027 * It will be enqueued by the caller on the target's waiting
5028 * queue and retried later.
5029 *
5030 * The asc_stats fields 'adv_build_noreq' and 'adv_build_nosg'
5031 * count wide board busy conditions. They are updated in
5032 * adv_build_req and adv_get_sglist, respectively.
5033 */
5034 return ASC_BUSY;
5035 case ASC_ERROR:
5036 /*
5037 * If an error is returned, then the request has been
5038 * queued on the board done queue. It will be completed
5039 * by the caller.
5040 */
5041 default:
5042 ASC_DBG(1,
5043 "asc_execute_scsi_cmnd: adv_build_req ASC_ERROR\n");
5044 ASC_STATS(scp->device->host, build_error);
5045 return ASC_ERROR;
5046 }
5047
5048 /*
5049 * Execute the command. If there is no error, add the command
5050 * to the active queue.
5051 */
5052 switch (ret = AdvExeScsiQueue(adv_dvc_varp, adv_scsiqp)) {
5053 case ASC_NOERROR:
5054 ASC_STATS(scp->device->host, exe_noerror);
5055 /*
5056 * Increment monotonically increasing per device successful
5057 * request counter. Wrapping doesn't matter.
5058 */
5059 boardp->reqcnt[scp->device->id]++;
5060 asc_enqueue(&boardp->active, scp, ASC_BACK);
5061 ASC_DBG(1,
5062 "asc_execute_scsi_cmnd: AdvExeScsiQueue(), ASC_NOERROR\n");
5063 break;
5064 case ASC_BUSY:
5065 /*
5066 * Caller will enqueue request on the target's waiting queue
5067 * and retry later.
5068 */
5069 ASC_STATS(scp->device->host, exe_busy);
5070 break;
5071 case ASC_ERROR:
5072 ASC_PRINT2
5073 ("asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() ASC_ERROR, err_code 0x%x\n",
5074 boardp->id, adv_dvc_varp->err_code);
5075 ASC_STATS(scp->device->host, exe_error);
5076 scp->result = HOST_BYTE(DID_ERROR);
5077 asc_enqueue(&boardp->done, scp, ASC_BACK);
5078 break;
5079 default:
5080 ASC_PRINT2
5081 ("asc_execute_scsi_cmnd: board %d: AdvExeScsiQueue() unknown, err_code 0x%x\n",
5082 boardp->id, adv_dvc_varp->err_code);
5083 ASC_STATS(scp->device->host, exe_unknown);
5084 scp->result = HOST_BYTE(DID_ERROR);
5085 asc_enqueue(&boardp->done, scp, ASC_BACK);
5086 break;
5087 }
5088 }
5089
5090 ASC_DBG(1, "asc_execute_scsi_cmnd: end\n");
5091 return ret;
6295} 5092}
6296 5093
6297/* 5094/*
@@ -6303,131 +5100,140 @@ asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
6303 * If an error occurs, then queue the request on the board done 5100 * If an error occurs, then queue the request on the board done
6304 * queue and return ASC_ERROR. 5101 * queue and return ASC_ERROR.
6305 */ 5102 */
6306STATIC int 5103static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
6307asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
6308{ 5104{
6309 struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev; 5105 struct device *dev = boardp->dvc_cfg.asc_dvc_cfg.dev;
6310 5106
6311 /* 5107 /*
6312 * Mutually exclusive access is required to 'asc_scsi_q' and 5108 * Mutually exclusive access is required to 'asc_scsi_q' and
6313 * 'asc_sg_head' until after the request is started. 5109 * 'asc_sg_head' until after the request is started.
6314 */ 5110 */
6315 memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q)); 5111 memset(&asc_scsi_q, 0, sizeof(ASC_SCSI_Q));
6316 5112
6317 /* 5113 /*
6318 * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'. 5114 * Point the ASC_SCSI_Q to the 'struct scsi_cmnd'.
6319 */ 5115 */
6320 asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp); 5116 asc_scsi_q.q2.srb_ptr = ASC_VADDR_TO_U32(scp);
6321 5117
6322 /* 5118 /*
6323 * Build the ASC_SCSI_Q request. 5119 * Build the ASC_SCSI_Q request.
6324 * 5120 *
6325 * For narrow boards a CDB length maximum of 12 bytes 5121 * For narrow boards a CDB length maximum of 12 bytes
6326 * is supported. 5122 * is supported.
6327 */ 5123 */
6328 if (scp->cmd_len > ASC_MAX_CDB_LEN) { 5124 if (scp->cmd_len > ASC_MAX_CDB_LEN) {
6329 ASC_PRINT3( 5125 ASC_PRINT3
6330"asc_build_req: board %d: cmd_len %d > ASC_MAX_CDB_LEN %d\n", 5126 ("asc_build_req: board %d: cmd_len %d > ASC_MAX_CDB_LEN %d\n",
6331 boardp->id, scp->cmd_len, ASC_MAX_CDB_LEN); 5127 boardp->id, scp->cmd_len, ASC_MAX_CDB_LEN);
6332 scp->result = HOST_BYTE(DID_ERROR); 5128 scp->result = HOST_BYTE(DID_ERROR);
6333 asc_enqueue(&boardp->done, scp, ASC_BACK); 5129 asc_enqueue(&boardp->done, scp, ASC_BACK);
6334 return ASC_ERROR; 5130 return ASC_ERROR;
6335 } 5131 }
6336 asc_scsi_q.cdbptr = &scp->cmnd[0]; 5132 asc_scsi_q.cdbptr = &scp->cmnd[0];
6337 asc_scsi_q.q2.cdb_len = scp->cmd_len; 5133 asc_scsi_q.q2.cdb_len = scp->cmd_len;
6338 asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id); 5134 asc_scsi_q.q1.target_id = ASC_TID_TO_TARGET_ID(scp->device->id);
6339 asc_scsi_q.q1.target_lun = scp->device->lun; 5135 asc_scsi_q.q1.target_lun = scp->device->lun;
6340 asc_scsi_q.q2.target_ix = ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun); 5136 asc_scsi_q.q2.target_ix =
6341 asc_scsi_q.q1.sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0])); 5137 ASC_TIDLUN_TO_IX(scp->device->id, scp->device->lun);
6342 asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer); 5138 asc_scsi_q.q1.sense_addr =
5139 cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
5140 asc_scsi_q.q1.sense_len = sizeof(scp->sense_buffer);
5141
5142 /*
5143 * If there are any outstanding requests for the current target,
5144 * then every 255th request send an ORDERED request. This heuristic
5145 * tries to retain the benefit of request sorting while preventing
5146 * request starvation. 255 is the max number of tags or pending commands
5147 * a device may have outstanding.
5148 *
5149 * The request count is incremented below for every successfully
5150 * started request.
5151 *
5152 */
5153 if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) &&
5154 (boardp->reqcnt[scp->device->id] % 255) == 0) {
5155 asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG;
5156 } else {
5157 asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG;
5158 }
6343 5159
6344 /* 5160 /*
6345 * If there are any outstanding requests for the current target, 5161 * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather
6346 * then every 255th request send an ORDERED request. This heuristic 5162 * buffer command.
6347 * tries to retain the benefit of request sorting while preventing 5163 */
6348 * request starvation. 255 is the max number of tags or pending commands 5164 if (scp->use_sg == 0) {
6349 * a device may have outstanding. 5165 /*
6350 * 5166 * CDB request of single contiguous buffer.
6351 * The request count is incremented below for every successfully 5167 */
6352 * started request. 5168 ASC_STATS(scp->device->host, cont_cnt);
6353 * 5169 scp->SCp.dma_handle = scp->request_bufflen ?
6354 */ 5170 dma_map_single(dev, scp->request_buffer,
6355 if ((boardp->dvc_var.asc_dvc_var.cur_dvc_qng[scp->device->id] > 0) && 5171 scp->request_bufflen,
6356 (boardp->reqcnt[scp->device->id] % 255) == 0) { 5172 scp->sc_data_direction) : 0;
6357 asc_scsi_q.q2.tag_code = MSG_ORDERED_TAG; 5173 asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
6358 } else { 5174 asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
6359 asc_scsi_q.q2.tag_code = MSG_SIMPLE_TAG; 5175 ASC_STATS_ADD(scp->device->host, cont_xfer,
6360 } 5176 ASC_CEILING(scp->request_bufflen, 512));
5177 asc_scsi_q.q1.sg_queue_cnt = 0;
5178 asc_scsi_q.sg_head = NULL;
5179 } else {
5180 /*
5181 * CDB scatter-gather request list.
5182 */
5183 int sgcnt;
5184 int use_sg;
5185 struct scatterlist *slp;
5186
5187 slp = (struct scatterlist *)scp->request_buffer;
5188 use_sg =
5189 dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
5190
5191 if (use_sg > scp->device->host->sg_tablesize) {
5192 ASC_PRINT3
5193 ("asc_build_req: board %d: use_sg %d > sg_tablesize %d\n",
5194 boardp->id, use_sg,
5195 scp->device->host->sg_tablesize);
5196 dma_unmap_sg(dev, slp, scp->use_sg,
5197 scp->sc_data_direction);
5198 scp->result = HOST_BYTE(DID_ERROR);
5199 asc_enqueue(&boardp->done, scp, ASC_BACK);
5200 return ASC_ERROR;
5201 }
5202
5203 ASC_STATS(scp->device->host, sg_cnt);
6361 5204
6362 /* 5205 /*
6363 * Build ASC_SCSI_Q for a contiguous buffer or a scatter-gather 5206 * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
6364 * buffer command. 5207 * structure to point to it.
6365 */ 5208 */
6366 if (scp->use_sg == 0) { 5209 memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
6367 /* 5210
6368 * CDB request of single contiguous buffer. 5211 asc_scsi_q.q1.cntl |= QC_SG_HEAD;
6369 */ 5212 asc_scsi_q.sg_head = &asc_sg_head;
6370 ASC_STATS(scp->device->host, cont_cnt); 5213 asc_scsi_q.q1.data_cnt = 0;
6371 scp->SCp.dma_handle = scp->request_bufflen ? 5214 asc_scsi_q.q1.data_addr = 0;
6372 dma_map_single(dev, scp->request_buffer, 5215 /* This is a byte value, otherwise it would need to be swapped. */
6373 scp->request_bufflen, scp->sc_data_direction) : 0; 5216 asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
6374 asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle); 5217 ASC_STATS_ADD(scp->device->host, sg_elem,
6375 asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen); 5218 asc_sg_head.entry_cnt);
6376 ASC_STATS_ADD(scp->device->host, cont_xfer,
6377 ASC_CEILING(scp->request_bufflen, 512));
6378 asc_scsi_q.q1.sg_queue_cnt = 0;
6379 asc_scsi_q.sg_head = NULL;
6380 } else {
6381 /*
6382 * CDB scatter-gather request list.
6383 */
6384 int sgcnt;
6385 int use_sg;
6386 struct scatterlist *slp;
6387 5219
6388 slp = (struct scatterlist *)scp->request_buffer; 5220 /*
6389 use_sg = dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction); 5221 * Convert scatter-gather list into ASC_SG_HEAD list.
6390 5222 */
6391 if (use_sg > scp->device->host->sg_tablesize) { 5223 for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
6392 ASC_PRINT3( 5224 asc_sg_head.sg_list[sgcnt].addr =
6393"asc_build_req: board %d: use_sg %d > sg_tablesize %d\n", 5225 cpu_to_le32(sg_dma_address(slp));
6394 boardp->id, use_sg, scp->device->host->sg_tablesize); 5226 asc_sg_head.sg_list[sgcnt].bytes =
6395 dma_unmap_sg(dev, slp, scp->use_sg, scp->sc_data_direction); 5227 cpu_to_le32(sg_dma_len(slp));
6396 scp->result = HOST_BYTE(DID_ERROR); 5228 ASC_STATS_ADD(scp->device->host, sg_xfer,
6397 asc_enqueue(&boardp->done, scp, ASC_BACK); 5229 ASC_CEILING(sg_dma_len(slp), 512));
6398 return ASC_ERROR; 5230 }
6399 } 5231 }
6400
6401 ASC_STATS(scp->device->host, sg_cnt);
6402
6403 /*
6404 * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
6405 * structure to point to it.
6406 */
6407 memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
6408
6409 asc_scsi_q.q1.cntl |= QC_SG_HEAD;
6410 asc_scsi_q.sg_head = &asc_sg_head;
6411 asc_scsi_q.q1.data_cnt = 0;
6412 asc_scsi_q.q1.data_addr = 0;
6413 /* This is a byte value, otherwise it would need to be swapped. */
6414 asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
6415 ASC_STATS_ADD(scp->device->host, sg_elem, asc_sg_head.entry_cnt);
6416
6417 /*
6418 * Convert scatter-gather list into ASC_SG_HEAD list.
6419 */
6420 for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
6421 asc_sg_head.sg_list[sgcnt].addr = cpu_to_le32(sg_dma_address(slp));
6422 asc_sg_head.sg_list[sgcnt].bytes = cpu_to_le32(sg_dma_len(slp));
6423 ASC_STATS_ADD(scp->device->host, sg_xfer, ASC_CEILING(sg_dma_len(slp), 512));
6424 }
6425 }
6426 5232
6427 ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q); 5233 ASC_DBG_PRT_ASC_SCSI_Q(2, &asc_scsi_q);
6428 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len); 5234 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
6429 5235
6430 return ASC_NOERROR; 5236 return ASC_NOERROR;
6431} 5237}
6432 5238
6433/* 5239/*
@@ -6440,162 +5246,168 @@ asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
6440 * microcode for DMA addresses or math operations are byte swapped 5246 * microcode for DMA addresses or math operations are byte swapped
6441 * to little-endian order. 5247 * to little-endian order.
6442 */ 5248 */
6443STATIC int 5249static int
6444adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp, 5250adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
6445 ADV_SCSI_REQ_Q **adv_scsiqpp) 5251 ADV_SCSI_REQ_Q **adv_scsiqpp)
6446{ 5252{
6447 adv_req_t *reqp; 5253 adv_req_t *reqp;
6448 ADV_SCSI_REQ_Q *scsiqp; 5254 ADV_SCSI_REQ_Q *scsiqp;
6449 int i; 5255 int i;
6450 int ret; 5256 int ret;
6451 struct device *dev = boardp->dvc_cfg.adv_dvc_cfg.dev; 5257 struct device *dev = boardp->dvc_cfg.adv_dvc_cfg.dev;
6452 5258
6453 /* 5259 /*
6454 * Allocate an adv_req_t structure from the board to execute 5260 * Allocate an adv_req_t structure from the board to execute
6455 * the command. 5261 * the command.
6456 */ 5262 */
6457 if (boardp->adv_reqp == NULL) { 5263 if (boardp->adv_reqp == NULL) {
6458 ASC_DBG(1, "adv_build_req: no free adv_req_t\n"); 5264 ASC_DBG(1, "adv_build_req: no free adv_req_t\n");
6459 ASC_STATS(scp->device->host, adv_build_noreq); 5265 ASC_STATS(scp->device->host, adv_build_noreq);
6460 return ASC_BUSY; 5266 return ASC_BUSY;
6461 } else { 5267 } else {
6462 reqp = boardp->adv_reqp; 5268 reqp = boardp->adv_reqp;
6463 boardp->adv_reqp = reqp->next_reqp; 5269 boardp->adv_reqp = reqp->next_reqp;
6464 reqp->next_reqp = NULL; 5270 reqp->next_reqp = NULL;
6465 } 5271 }
6466
6467 /*
6468 * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
6469 */
6470 scsiqp = (ADV_SCSI_REQ_Q *) ADV_32BALIGN(&reqp->scsi_req_q);
6471
6472 /*
6473 * Initialize the structure.
6474 */
6475 scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
6476
6477 /*
6478 * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
6479 */
6480 scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
6481
6482 /*
6483 * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
6484 */
6485 reqp->cmndp = scp;
6486 5272
6487 /* 5273 /*
6488 * Build the ADV_SCSI_REQ_Q request. 5274 * Get 32-byte aligned ADV_SCSI_REQ_Q and ADV_SG_BLOCK pointers.
6489 */ 5275 */
5276 scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
5277
5278 /*
5279 * Initialize the structure.
5280 */
5281 scsiqp->cntl = scsiqp->scsi_cntl = scsiqp->done_status = 0;
5282
5283 /*
5284 * Set the ADV_SCSI_REQ_Q 'srb_ptr' to point to the adv_req_t structure.
5285 */
5286 scsiqp->srb_ptr = ASC_VADDR_TO_U32(reqp);
5287
5288 /*
5289 * Set the adv_req_t 'cmndp' to point to the struct scsi_cmnd structure.
5290 */
5291 reqp->cmndp = scp;
5292
5293 /*
5294 * Build the ADV_SCSI_REQ_Q request.
5295 */
5296
5297 /*
5298 * Set CDB length and copy it to the request structure.
5299 * For wide boards a CDB length maximum of 16 bytes
5300 * is supported.
5301 */
5302 if (scp->cmd_len > ADV_MAX_CDB_LEN) {
5303 ASC_PRINT3
5304 ("adv_build_req: board %d: cmd_len %d > ADV_MAX_CDB_LEN %d\n",
5305 boardp->id, scp->cmd_len, ADV_MAX_CDB_LEN);
5306 scp->result = HOST_BYTE(DID_ERROR);
5307 asc_enqueue(&boardp->done, scp, ASC_BACK);
5308 return ASC_ERROR;
5309 }
5310 scsiqp->cdb_len = scp->cmd_len;
5311 /* Copy first 12 CDB bytes to cdb[]. */
5312 for (i = 0; i < scp->cmd_len && i < 12; i++) {
5313 scsiqp->cdb[i] = scp->cmnd[i];
5314 }
5315 /* Copy last 4 CDB bytes, if present, to cdb16[]. */
5316 for (; i < scp->cmd_len; i++) {
5317 scsiqp->cdb16[i - 12] = scp->cmnd[i];
5318 }
6490 5319
6491 /* 5320 scsiqp->target_id = scp->device->id;
6492 * Set CDB length and copy it to the request structure. 5321 scsiqp->target_lun = scp->device->lun;
6493 * For wide boards a CDB length maximum of 16 bytes
6494 * is supported.
6495 */
6496 if (scp->cmd_len > ADV_MAX_CDB_LEN) {
6497 ASC_PRINT3(
6498"adv_build_req: board %d: cmd_len %d > ADV_MAX_CDB_LEN %d\n",
6499 boardp->id, scp->cmd_len, ADV_MAX_CDB_LEN);
6500 scp->result = HOST_BYTE(DID_ERROR);
6501 asc_enqueue(&boardp->done, scp, ASC_BACK);
6502 return ASC_ERROR;
6503 }
6504 scsiqp->cdb_len = scp->cmd_len;
6505 /* Copy first 12 CDB bytes to cdb[]. */
6506 for (i = 0; i < scp->cmd_len && i < 12; i++) {
6507 scsiqp->cdb[i] = scp->cmnd[i];
6508 }
6509 /* Copy last 4 CDB bytes, if present, to cdb16[]. */
6510 for (; i < scp->cmd_len; i++) {
6511 scsiqp->cdb16[i - 12] = scp->cmnd[i];
6512 }
6513 5322
6514 scsiqp->target_id = scp->device->id; 5323 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0]));
6515 scsiqp->target_lun = scp->device->lun; 5324 scsiqp->sense_len = sizeof(scp->sense_buffer);
6516 5325
6517 scsiqp->sense_addr = cpu_to_le32(virt_to_bus(&scp->sense_buffer[0])); 5326 /*
6518 scsiqp->sense_len = sizeof(scp->sense_buffer); 5327 * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
5328 * buffer command.
5329 */
6519 5330
6520 /*
6521 * Build ADV_SCSI_REQ_Q for a contiguous buffer or a scatter-gather
6522 * buffer command.
6523 */
6524
6525 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
6526 scsiqp->vdata_addr = scp->request_buffer;
6527 scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
6528
6529 if (scp->use_sg == 0) {
6530 /*
6531 * CDB request of single contiguous buffer.
6532 */
6533 reqp->sgblkp = NULL;
6534 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen); 5331 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
6535 if (scp->request_bufflen) { 5332 scsiqp->vdata_addr = scp->request_buffer;
6536 scsiqp->vdata_addr = scp->request_buffer; 5333 scsiqp->data_addr = cpu_to_le32(virt_to_bus(scp->request_buffer));
6537 scp->SCp.dma_handle =
6538 dma_map_single(dev, scp->request_buffer,
6539 scp->request_bufflen, scp->sc_data_direction);
6540 } else {
6541 scsiqp->vdata_addr = NULL;
6542 scp->SCp.dma_handle = 0;
6543 }
6544 scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
6545 scsiqp->sg_list_ptr = NULL;
6546 scsiqp->sg_real_addr = 0;
6547 ASC_STATS(scp->device->host, cont_cnt);
6548 ASC_STATS_ADD(scp->device->host, cont_xfer,
6549 ASC_CEILING(scp->request_bufflen, 512));
6550 } else {
6551 /*
6552 * CDB scatter-gather request list.
6553 */
6554 struct scatterlist *slp;
6555 int use_sg;
6556 5334
6557 slp = (struct scatterlist *)scp->request_buffer; 5335 if (scp->use_sg == 0) {
6558 use_sg = dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction); 5336 /*
6559 5337 * CDB request of single contiguous buffer.
6560 if (use_sg > ADV_MAX_SG_LIST) { 5338 */
6561 ASC_PRINT3( 5339 reqp->sgblkp = NULL;
6562"adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n", 5340 scsiqp->data_cnt = cpu_to_le32(scp->request_bufflen);
6563 boardp->id, use_sg, scp->device->host->sg_tablesize); 5341 if (scp->request_bufflen) {
6564 dma_unmap_sg(dev, slp, scp->use_sg, scp->sc_data_direction); 5342 scsiqp->vdata_addr = scp->request_buffer;
6565 scp->result = HOST_BYTE(DID_ERROR); 5343 scp->SCp.dma_handle =
6566 asc_enqueue(&boardp->done, scp, ASC_BACK); 5344 dma_map_single(dev, scp->request_buffer,
6567 5345 scp->request_bufflen,
6568 /* 5346 scp->sc_data_direction);
6569 * Free the 'adv_req_t' structure by adding it back to the 5347 } else {
6570 * board free list. 5348 scsiqp->vdata_addr = NULL;
6571 */ 5349 scp->SCp.dma_handle = 0;
6572 reqp->next_reqp = boardp->adv_reqp; 5350 }
6573 boardp->adv_reqp = reqp; 5351 scsiqp->data_addr = cpu_to_le32(scp->SCp.dma_handle);
6574 5352 scsiqp->sg_list_ptr = NULL;
6575 return ASC_ERROR; 5353 scsiqp->sg_real_addr = 0;
6576 } 5354 ASC_STATS(scp->device->host, cont_cnt);
6577 5355 ASC_STATS_ADD(scp->device->host, cont_xfer,
6578 if ((ret = adv_get_sglist(boardp, reqp, scp, use_sg)) != ADV_SUCCESS) { 5356 ASC_CEILING(scp->request_bufflen, 512));
6579 /* 5357 } else {
6580 * Free the adv_req_t structure by adding it back to the 5358 /*
6581 * board free list. 5359 * CDB scatter-gather request list.
6582 */ 5360 */
6583 reqp->next_reqp = boardp->adv_reqp; 5361 struct scatterlist *slp;
6584 boardp->adv_reqp = reqp; 5362 int use_sg;
6585 5363
6586 return ret; 5364 slp = (struct scatterlist *)scp->request_buffer;
6587 } 5365 use_sg =
6588 5366 dma_map_sg(dev, slp, scp->use_sg, scp->sc_data_direction);
6589 ASC_STATS(scp->device->host, sg_cnt); 5367
6590 ASC_STATS_ADD(scp->device->host, sg_elem, use_sg); 5368 if (use_sg > ADV_MAX_SG_LIST) {
6591 } 5369 ASC_PRINT3
5370 ("adv_build_req: board %d: use_sg %d > ADV_MAX_SG_LIST %d\n",
5371 boardp->id, use_sg,
5372 scp->device->host->sg_tablesize);
5373 dma_unmap_sg(dev, slp, scp->use_sg,
5374 scp->sc_data_direction);
5375 scp->result = HOST_BYTE(DID_ERROR);
5376 asc_enqueue(&boardp->done, scp, ASC_BACK);
5377
5378 /*
5379 * Free the 'adv_req_t' structure by adding it back to the
5380 * board free list.
5381 */
5382 reqp->next_reqp = boardp->adv_reqp;
5383 boardp->adv_reqp = reqp;
5384
5385 return ASC_ERROR;
5386 }
5387
5388 if ((ret =
5389 adv_get_sglist(boardp, reqp, scp,
5390 use_sg)) != ADV_SUCCESS) {
5391 /*
5392 * Free the adv_req_t structure by adding it back to the
5393 * board free list.
5394 */
5395 reqp->next_reqp = boardp->adv_reqp;
5396 boardp->adv_reqp = reqp;
5397
5398 return ret;
5399 }
5400
5401 ASC_STATS(scp->device->host, sg_cnt);
5402 ASC_STATS_ADD(scp->device->host, sg_elem, use_sg);
5403 }
6592 5404
6593 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp); 5405 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
6594 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len); 5406 ASC_DBG_PRT_CDB(1, scp->cmnd, scp->cmd_len);
6595 5407
6596 *adv_scsiqpp = scsiqp; 5408 *adv_scsiqpp = scsiqp;
6597 5409
6598 return ASC_NOERROR; 5410 return ASC_NOERROR;
6599} 5411}
6600 5412
6601/* 5413/*
@@ -6610,108 +5422,109 @@ adv_build_req(asc_board_t *boardp, struct scsi_cmnd *scp,
6610 * ADV_SUCCESS(1) - SG List successfully created 5422 * ADV_SUCCESS(1) - SG List successfully created
6611 * ADV_ERROR(-1) - SG List creation failed 5423 * ADV_ERROR(-1) - SG List creation failed
6612 */ 5424 */
6613STATIC int 5425static int
6614adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp, int use_sg) 5426adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp,
5427 int use_sg)
6615{ 5428{
6616 adv_sgblk_t *sgblkp; 5429 adv_sgblk_t *sgblkp;
6617 ADV_SCSI_REQ_Q *scsiqp; 5430 ADV_SCSI_REQ_Q *scsiqp;
6618 struct scatterlist *slp; 5431 struct scatterlist *slp;
6619 int sg_elem_cnt; 5432 int sg_elem_cnt;
6620 ADV_SG_BLOCK *sg_block, *prev_sg_block; 5433 ADV_SG_BLOCK *sg_block, *prev_sg_block;
6621 ADV_PADDR sg_block_paddr; 5434 ADV_PADDR sg_block_paddr;
6622 int i; 5435 int i;
6623 5436
6624 scsiqp = (ADV_SCSI_REQ_Q *) ADV_32BALIGN(&reqp->scsi_req_q); 5437 scsiqp = (ADV_SCSI_REQ_Q *)ADV_32BALIGN(&reqp->scsi_req_q);
6625 slp = (struct scatterlist *) scp->request_buffer; 5438 slp = (struct scatterlist *)scp->request_buffer;
6626 sg_elem_cnt = use_sg; 5439 sg_elem_cnt = use_sg;
6627 prev_sg_block = NULL; 5440 prev_sg_block = NULL;
6628 reqp->sgblkp = NULL; 5441 reqp->sgblkp = NULL;
6629 5442
6630 do 5443 do {
6631 { 5444 /*
6632 /* 5445 * Allocate a 'adv_sgblk_t' structure from the board free
6633 * Allocate a 'adv_sgblk_t' structure from the board free 5446 * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK
6634 * list. One 'adv_sgblk_t' structure holds NO_OF_SG_PER_BLOCK 5447 * (15) scatter-gather elements.
6635 * (15) scatter-gather elements. 5448 */
6636 */ 5449 if ((sgblkp = boardp->adv_sgblkp) == NULL) {
6637 if ((sgblkp = boardp->adv_sgblkp) == NULL) { 5450 ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n");
6638 ASC_DBG(1, "adv_get_sglist: no free adv_sgblk_t\n"); 5451 ASC_STATS(scp->device->host, adv_build_nosg);
6639 ASC_STATS(scp->device->host, adv_build_nosg); 5452
6640 5453 /*
6641 /* 5454 * Allocation failed. Free 'adv_sgblk_t' structures already
6642 * Allocation failed. Free 'adv_sgblk_t' structures already 5455 * allocated for the request.
6643 * allocated for the request. 5456 */
6644 */ 5457 while ((sgblkp = reqp->sgblkp) != NULL) {
6645 while ((sgblkp = reqp->sgblkp) != NULL) 5458 /* Remove 'sgblkp' from the request list. */
6646 { 5459 reqp->sgblkp = sgblkp->next_sgblkp;
6647 /* Remove 'sgblkp' from the request list. */ 5460
6648 reqp->sgblkp = sgblkp->next_sgblkp; 5461 /* Add 'sgblkp' to the board free list. */
6649 5462 sgblkp->next_sgblkp = boardp->adv_sgblkp;
6650 /* Add 'sgblkp' to the board free list. */ 5463 boardp->adv_sgblkp = sgblkp;
6651 sgblkp->next_sgblkp = boardp->adv_sgblkp; 5464 }
6652 boardp->adv_sgblkp = sgblkp; 5465 return ASC_BUSY;
6653 } 5466 } else {
6654 return ASC_BUSY; 5467 /* Complete 'adv_sgblk_t' board allocation. */
6655 } else { 5468 boardp->adv_sgblkp = sgblkp->next_sgblkp;
6656 /* Complete 'adv_sgblk_t' board allocation. */ 5469 sgblkp->next_sgblkp = NULL;
6657 boardp->adv_sgblkp = sgblkp->next_sgblkp; 5470
6658 sgblkp->next_sgblkp = NULL; 5471 /*
6659 5472 * Get 8 byte aligned virtual and physical addresses for
6660 /* 5473 * the allocated ADV_SG_BLOCK structure.
6661 * Get 8 byte aligned virtual and physical addresses for 5474 */
6662 * the allocated ADV_SG_BLOCK structure. 5475 sg_block =
6663 */ 5476 (ADV_SG_BLOCK *)ADV_8BALIGN(&sgblkp->sg_block);
6664 sg_block = (ADV_SG_BLOCK *) ADV_8BALIGN(&sgblkp->sg_block); 5477 sg_block_paddr = virt_to_bus(sg_block);
6665 sg_block_paddr = virt_to_bus(sg_block); 5478
6666 5479 /*
6667 /* 5480 * Check if this is the first 'adv_sgblk_t' for the request.
6668 * Check if this is the first 'adv_sgblk_t' for the request. 5481 */
6669 */ 5482 if (reqp->sgblkp == NULL) {
6670 if (reqp->sgblkp == NULL) 5483 /* Request's first scatter-gather block. */
6671 { 5484 reqp->sgblkp = sgblkp;
6672 /* Request's first scatter-gather block. */ 5485
6673 reqp->sgblkp = sgblkp; 5486 /*
6674 5487 * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical
6675 /* 5488 * address pointers.
6676 * Set ADV_SCSI_REQ_T ADV_SG_BLOCK virtual and physical 5489 */
6677 * address pointers. 5490 scsiqp->sg_list_ptr = sg_block;
6678 */ 5491 scsiqp->sg_real_addr =
6679 scsiqp->sg_list_ptr = sg_block; 5492 cpu_to_le32(sg_block_paddr);
6680 scsiqp->sg_real_addr = cpu_to_le32(sg_block_paddr); 5493 } else {
6681 } else 5494 /* Request's second or later scatter-gather block. */
6682 { 5495 sgblkp->next_sgblkp = reqp->sgblkp;
6683 /* Request's second or later scatter-gather block. */ 5496 reqp->sgblkp = sgblkp;
6684 sgblkp->next_sgblkp = reqp->sgblkp; 5497
6685 reqp->sgblkp = sgblkp; 5498 /*
6686 5499 * Point the previous ADV_SG_BLOCK structure to
6687 /* 5500 * the newly allocated ADV_SG_BLOCK structure.
6688 * Point the previous ADV_SG_BLOCK structure to 5501 */
6689 * the newly allocated ADV_SG_BLOCK structure. 5502 ASC_ASSERT(prev_sg_block != NULL);
6690 */ 5503 prev_sg_block->sg_ptr =
6691 ASC_ASSERT(prev_sg_block != NULL); 5504 cpu_to_le32(sg_block_paddr);
6692 prev_sg_block->sg_ptr = cpu_to_le32(sg_block_paddr); 5505 }
6693 } 5506 }
6694 } 5507
6695 5508 for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) {
6696 for (i = 0; i < NO_OF_SG_PER_BLOCK; i++) 5509 sg_block->sg_list[i].sg_addr =
6697 { 5510 cpu_to_le32(sg_dma_address(slp));
6698 sg_block->sg_list[i].sg_addr = cpu_to_le32(sg_dma_address(slp)); 5511 sg_block->sg_list[i].sg_count =
6699 sg_block->sg_list[i].sg_count = cpu_to_le32(sg_dma_len(slp)); 5512 cpu_to_le32(sg_dma_len(slp));
6700 ASC_STATS_ADD(scp->device->host, sg_xfer, ASC_CEILING(sg_dma_len(slp), 512)); 5513 ASC_STATS_ADD(scp->device->host, sg_xfer,
6701 5514 ASC_CEILING(sg_dma_len(slp), 512));
6702 if (--sg_elem_cnt == 0) 5515
6703 { /* Last ADV_SG_BLOCK and scatter-gather entry. */ 5516 if (--sg_elem_cnt == 0) { /* Last ADV_SG_BLOCK and scatter-gather entry. */
6704 sg_block->sg_cnt = i + 1; 5517 sg_block->sg_cnt = i + 1;
6705 sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */ 5518 sg_block->sg_ptr = 0L; /* Last ADV_SG_BLOCK in list. */
6706 return ADV_SUCCESS; 5519 return ADV_SUCCESS;
6707 } 5520 }
6708 slp++; 5521 slp++;
6709 } 5522 }
6710 sg_block->sg_cnt = NO_OF_SG_PER_BLOCK; 5523 sg_block->sg_cnt = NO_OF_SG_PER_BLOCK;
6711 prev_sg_block = sg_block; 5524 prev_sg_block = sg_block;
6712 } 5525 }
6713 while (1); 5526 while (1);
6714 /* NOTREACHED */ 5527 /* NOTREACHED */
6715} 5528}
6716 5529
6717/* 5530/*
@@ -6719,165 +5532,171 @@ adv_get_sglist(asc_board_t *boardp, adv_req_t *reqp, struct scsi_cmnd *scp, int
6719 * 5532 *
6720 * Interrupt callback function for the Narrow SCSI Asc Library. 5533 * Interrupt callback function for the Narrow SCSI Asc Library.
6721 */ 5534 */
6722STATIC void 5535static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
6723asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
6724{ 5536{
6725 asc_board_t *boardp; 5537 asc_board_t *boardp;
6726 struct scsi_cmnd *scp; 5538 struct scsi_cmnd *scp;
6727 struct Scsi_Host *shp; 5539 struct Scsi_Host *shost;
6728 int i; 5540 int i;
6729 5541
6730 ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n", 5542 ASC_DBG2(1, "asc_isr_callback: asc_dvc_varp 0x%lx, qdonep 0x%lx\n",
6731 (ulong) asc_dvc_varp, (ulong) qdonep); 5543 (ulong)asc_dvc_varp, (ulong)qdonep);
6732 ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep); 5544 ASC_DBG_PRT_ASC_QDONE_INFO(2, qdonep);
5545
5546 /*
5547 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
5548 * command that has been completed.
5549 */
5550 scp = (struct scsi_cmnd *)ASC_U32_TO_VADDR(qdonep->d2.srb_ptr);
5551 ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong)scp);
5552
5553 if (scp == NULL) {
5554 ASC_PRINT("asc_isr_callback: scp is NULL\n");
5555 return;
5556 }
5557 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
5558
5559 /*
5560 * If the request's host pointer is not valid, display a
5561 * message and return.
5562 */
5563 shost = scp->device->host;
5564 for (i = 0; i < asc_board_count; i++) {
5565 if (asc_host[i] == shost) {
5566 break;
5567 }
5568 }
5569 if (i == asc_board_count) {
5570 ASC_PRINT2
5571 ("asc_isr_callback: scp 0x%lx has bad host pointer, host 0x%lx\n",
5572 (ulong)scp, (ulong)shost);
5573 return;
5574 }
6733 5575
6734 /* 5576 ASC_STATS(shost, callback);
6735 * Get the struct scsi_cmnd structure and Scsi_Host structure for the 5577 ASC_DBG1(1, "asc_isr_callback: shost 0x%lx\n", (ulong)shost);
6736 * command that has been completed. 5578
6737 */ 5579 /*
6738 scp = (struct scsi_cmnd *) ASC_U32_TO_VADDR(qdonep->d2.srb_ptr); 5580 * If the request isn't found on the active queue, it may
6739 ASC_DBG1(1, "asc_isr_callback: scp 0x%lx\n", (ulong) scp); 5581 * have been removed to handle a reset request.
6740 5582 * Display a message and return.
6741 if (scp == NULL) { 5583 */
6742 ASC_PRINT("asc_isr_callback: scp is NULL\n"); 5584 boardp = ASC_BOARDP(shost);
6743 return; 5585 ASC_ASSERT(asc_dvc_varp == &boardp->dvc_var.asc_dvc_var);
6744 } 5586 if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
6745 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len); 5587 ASC_PRINT2
5588 ("asc_isr_callback: board %d: scp 0x%lx not on active queue\n",
5589 boardp->id, (ulong)scp);
5590 return;
5591 }
6746 5592
6747 /* 5593 /*
6748 * If the request's host pointer is not valid, display a 5594 * 'qdonep' contains the command's ending status.
6749 * message and return. 5595 */
6750 */ 5596 switch (qdonep->d3.done_stat) {
6751 shp = scp->device->host; 5597 case QD_NO_ERROR:
6752 for (i = 0; i < asc_board_count; i++) { 5598 ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n");
6753 if (asc_host[i] == shp) { 5599 scp->result = 0;
6754 break;
6755 }
6756 }
6757 if (i == asc_board_count) {
6758 ASC_PRINT2(
6759 "asc_isr_callback: scp 0x%lx has bad host pointer, host 0x%lx\n",
6760 (ulong) scp, (ulong) shp);
6761 return;
6762 }
6763 5600
6764 ASC_STATS(shp, callback); 5601 /*
6765 ASC_DBG1(1, "asc_isr_callback: shp 0x%lx\n", (ulong) shp); 5602 * If an INQUIRY command completed successfully, then call
5603 * the AscInquiryHandling() function to set-up the device.
5604 */
5605 if (scp->cmnd[0] == INQUIRY && scp->device->lun == 0 &&
5606 (scp->request_bufflen - qdonep->remain_bytes) >= 8) {
5607 AscInquiryHandling(asc_dvc_varp, scp->device->id & 0x7,
5608 (ASC_SCSI_INQUIRY *)scp->
5609 request_buffer);
5610 }
6766 5611
6767 /* 5612 /*
6768 * If the request isn't found on the active queue, it may 5613 * Check for an underrun condition.
6769 * have been removed to handle a reset request. 5614 *
6770 * Display a message and return. 5615 * If there was no error and an underrun condition, then
6771 */ 5616 * then return the number of underrun bytes.
6772 boardp = ASC_BOARDP(shp); 5617 */
6773 ASC_ASSERT(asc_dvc_varp == &boardp->dvc_var.asc_dvc_var); 5618 if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
6774 if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) { 5619 qdonep->remain_bytes <= scp->request_bufflen) {
6775 ASC_PRINT2( 5620 ASC_DBG1(1,
6776 "asc_isr_callback: board %d: scp 0x%lx not on active queue\n", 5621 "asc_isr_callback: underrun condition %u bytes\n",
6777 boardp->id, (ulong) scp); 5622 (unsigned)qdonep->remain_bytes);
6778 return; 5623 scp->resid = qdonep->remain_bytes;
6779 } 5624 }
5625 break;
5626
5627 case QD_WITH_ERROR:
5628 ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
5629 switch (qdonep->d3.host_stat) {
5630 case QHSTA_NO_ERROR:
5631 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
5632 ASC_DBG(2,
5633 "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
5634 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
5635 sizeof(scp->sense_buffer));
5636 /*
5637 * Note: The 'status_byte()' macro used by target drivers
5638 * defined in scsi.h shifts the status byte returned by
5639 * host drivers right by 1 bit. This is why target drivers
5640 * also use right shifted status byte definitions. For
5641 * instance target drivers use CHECK_CONDITION, defined to
5642 * 0x1, instead of the SCSI defined check condition value
5643 * of 0x2. Host drivers are supposed to return the status
5644 * byte as it is defined by SCSI.
5645 */
5646 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
5647 STATUS_BYTE(qdonep->d3.scsi_stat);
5648 } else {
5649 scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
5650 }
5651 break;
5652
5653 default:
5654 /* QHSTA error occurred */
5655 ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
5656 qdonep->d3.host_stat);
5657 scp->result = HOST_BYTE(DID_BAD_TARGET);
5658 break;
5659 }
5660 break;
5661
5662 case QD_ABORTED_BY_HOST:
5663 ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
5664 scp->result =
5665 HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.
5666 scsi_msg) |
5667 STATUS_BYTE(qdonep->d3.scsi_stat);
5668 break;
5669
5670 default:
5671 ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n",
5672 qdonep->d3.done_stat);
5673 scp->result =
5674 HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.
5675 scsi_msg) |
5676 STATUS_BYTE(qdonep->d3.scsi_stat);
5677 break;
5678 }
6780 5679
6781 /* 5680 /*
6782 * 'qdonep' contains the command's ending status. 5681 * If the 'init_tidmask' bit isn't already set for the target and the
6783 */ 5682 * current request finished normally, then set the bit for the target
6784 switch (qdonep->d3.done_stat) { 5683 * to indicate that a device is present.
6785 case QD_NO_ERROR: 5684 */
6786 ASC_DBG(2, "asc_isr_callback: QD_NO_ERROR\n"); 5685 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
6787 scp->result = 0; 5686 qdonep->d3.done_stat == QD_NO_ERROR &&
6788 5687 qdonep->d3.host_stat == QHSTA_NO_ERROR) {
6789 /* 5688 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
6790 * If an INQUIRY command completed successfully, then call 5689 }
6791 * the AscInquiryHandling() function to set-up the device.
6792 */
6793 if (scp->cmnd[0] == INQUIRY && scp->device->lun == 0 &&
6794 (scp->request_bufflen - qdonep->remain_bytes) >= 8)
6795 {
6796 AscInquiryHandling(asc_dvc_varp, scp->device->id & 0x7,
6797 (ASC_SCSI_INQUIRY *) scp->request_buffer);
6798 }
6799
6800 /*
6801 * Check for an underrun condition.
6802 *
6803 * If there was no error and an underrun condition, then
6804 * then return the number of underrun bytes.
6805 */
6806 if (scp->request_bufflen != 0 && qdonep->remain_bytes != 0 &&
6807 qdonep->remain_bytes <= scp->request_bufflen) {
6808 ASC_DBG1(1, "asc_isr_callback: underrun condition %u bytes\n",
6809 (unsigned) qdonep->remain_bytes);
6810 scp->resid = qdonep->remain_bytes;
6811 }
6812 break;
6813
6814 case QD_WITH_ERROR:
6815 ASC_DBG(2, "asc_isr_callback: QD_WITH_ERROR\n");
6816 switch (qdonep->d3.host_stat) {
6817 case QHSTA_NO_ERROR:
6818 if (qdonep->d3.scsi_stat == SAM_STAT_CHECK_CONDITION) {
6819 ASC_DBG(2, "asc_isr_callback: SAM_STAT_CHECK_CONDITION\n");
6820 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
6821 sizeof(scp->sense_buffer));
6822 /*
6823 * Note: The 'status_byte()' macro used by target drivers
6824 * defined in scsi.h shifts the status byte returned by
6825 * host drivers right by 1 bit. This is why target drivers
6826 * also use right shifted status byte definitions. For
6827 * instance target drivers use CHECK_CONDITION, defined to
6828 * 0x1, instead of the SCSI defined check condition value
6829 * of 0x2. Host drivers are supposed to return the status
6830 * byte as it is defined by SCSI.
6831 */
6832 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
6833 STATUS_BYTE(qdonep->d3.scsi_stat);
6834 } else {
6835 scp->result = STATUS_BYTE(qdonep->d3.scsi_stat);
6836 }
6837 break;
6838
6839 default:
6840 /* QHSTA error occurred */
6841 ASC_DBG1(1, "asc_isr_callback: host_stat 0x%x\n",
6842 qdonep->d3.host_stat);
6843 scp->result = HOST_BYTE(DID_BAD_TARGET);
6844 break;
6845 }
6846 break;
6847
6848 case QD_ABORTED_BY_HOST:
6849 ASC_DBG(1, "asc_isr_callback: QD_ABORTED_BY_HOST\n");
6850 scp->result = HOST_BYTE(DID_ABORT) | MSG_BYTE(qdonep->d3.scsi_msg) |
6851 STATUS_BYTE(qdonep->d3.scsi_stat);
6852 break;
6853
6854 default:
6855 ASC_DBG1(1, "asc_isr_callback: done_stat 0x%x\n", qdonep->d3.done_stat);
6856 scp->result = HOST_BYTE(DID_ERROR) | MSG_BYTE(qdonep->d3.scsi_msg) |
6857 STATUS_BYTE(qdonep->d3.scsi_stat);
6858 break;
6859 }
6860 5690
6861 /* 5691 /*
6862 * If the 'init_tidmask' bit isn't already set for the target and the 5692 * Because interrupts may be enabled by the 'struct scsi_cmnd' done
6863 * current request finished normally, then set the bit for the target 5693 * function, add the command to the end of the board's done queue.
6864 * to indicate that a device is present. 5694 * The done function for the command will be called from
6865 */ 5695 * advansys_interrupt().
6866 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 && 5696 */
6867 qdonep->d3.done_stat == QD_NO_ERROR && 5697 asc_enqueue(&boardp->done, scp, ASC_BACK);
6868 qdonep->d3.host_stat == QHSTA_NO_ERROR) {
6869 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
6870 }
6871 5698
6872 /* 5699 return;
6873 * Because interrupts may be enabled by the 'struct scsi_cmnd' done
6874 * function, add the command to the end of the board's done queue.
6875 * The done function for the command will be called from
6876 * advansys_interrupt().
6877 */
6878 asc_enqueue(&boardp->done, scp, ASC_BACK);
6879
6880 return;
6881} 5700}
6882 5701
6883/* 5702/*
@@ -6885,238 +5704,240 @@ asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)
6885 * 5704 *
6886 * Callback function for the Wide SCSI Adv Library. 5705 * Callback function for the Wide SCSI Adv Library.
6887 */ 5706 */
6888STATIC void 5707static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
6889adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)
6890{ 5708{
6891 asc_board_t *boardp; 5709 asc_board_t *boardp;
6892 adv_req_t *reqp; 5710 adv_req_t *reqp;
6893 adv_sgblk_t *sgblkp; 5711 adv_sgblk_t *sgblkp;
6894 struct scsi_cmnd *scp; 5712 struct scsi_cmnd *scp;
6895 struct Scsi_Host *shp; 5713 struct Scsi_Host *shost;
6896 int i; 5714 int i;
6897 ADV_DCNT resid_cnt; 5715 ADV_DCNT resid_cnt;
6898 5716
6899 5717 ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
6900 ASC_DBG2(1, "adv_isr_callback: adv_dvc_varp 0x%lx, scsiqp 0x%lx\n", 5718 (ulong)adv_dvc_varp, (ulong)scsiqp);
6901 (ulong) adv_dvc_varp, (ulong) scsiqp); 5719 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp);
6902 ASC_DBG_PRT_ADV_SCSI_REQ_Q(2, scsiqp); 5720
6903 5721 /*
6904 /* 5722 * Get the adv_req_t structure for the command that has been
6905 * Get the adv_req_t structure for the command that has been 5723 * completed. The adv_req_t structure actually contains the
6906 * completed. The adv_req_t structure actually contains the 5724 * completed ADV_SCSI_REQ_Q structure.
6907 * completed ADV_SCSI_REQ_Q structure. 5725 */
6908 */ 5726 reqp = (adv_req_t *)ADV_U32_TO_VADDR(scsiqp->srb_ptr);
6909 reqp = (adv_req_t *) ADV_U32_TO_VADDR(scsiqp->srb_ptr); 5727 ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong)reqp);
6910 ASC_DBG1(1, "adv_isr_callback: reqp 0x%lx\n", (ulong) reqp); 5728 if (reqp == NULL) {
6911 if (reqp == NULL) { 5729 ASC_PRINT("adv_isr_callback: reqp is NULL\n");
6912 ASC_PRINT("adv_isr_callback: reqp is NULL\n"); 5730 return;
6913 return; 5731 }
6914 }
6915
6916 /*
6917 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
6918 * command that has been completed.
6919 *
6920 * Note: The adv_req_t request structure and adv_sgblk_t structure,
6921 * if any, are dropped, because a board structure pointer can not be
6922 * determined.
6923 */
6924 scp = reqp->cmndp;
6925 ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong) scp);
6926 if (scp == NULL) {
6927 ASC_PRINT("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
6928 return;
6929 }
6930 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
6931
6932 /*
6933 * If the request's host pointer is not valid, display a message
6934 * and return.
6935 */
6936 shp = scp->device->host;
6937 for (i = 0; i < asc_board_count; i++) {
6938 if (asc_host[i] == shp) {
6939 break;
6940 }
6941 }
6942 /*
6943 * Note: If the host structure is not found, the adv_req_t request
6944 * structure and adv_sgblk_t structure, if any, is dropped.
6945 */
6946 if (i == asc_board_count) {
6947 ASC_PRINT2(
6948 "adv_isr_callback: scp 0x%lx has bad host pointer, host 0x%lx\n",
6949 (ulong) scp, (ulong) shp);
6950 return;
6951 }
6952 5732
6953 ASC_STATS(shp, callback); 5733 /*
6954 ASC_DBG1(1, "adv_isr_callback: shp 0x%lx\n", (ulong) shp); 5734 * Get the struct scsi_cmnd structure and Scsi_Host structure for the
5735 * command that has been completed.
5736 *
5737 * Note: The adv_req_t request structure and adv_sgblk_t structure,
5738 * if any, are dropped, because a board structure pointer can not be
5739 * determined.
5740 */
5741 scp = reqp->cmndp;
5742 ASC_DBG1(1, "adv_isr_callback: scp 0x%lx\n", (ulong)scp);
5743 if (scp == NULL) {
5744 ASC_PRINT
5745 ("adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
5746 return;
5747 }
5748 ASC_DBG_PRT_CDB(2, scp->cmnd, scp->cmd_len);
5749
5750 /*
5751 * If the request's host pointer is not valid, display a message
5752 * and return.
5753 */
5754 shost = scp->device->host;
5755 for (i = 0; i < asc_board_count; i++) {
5756 if (asc_host[i] == shost) {
5757 break;
5758 }
5759 }
5760 /*
5761 * Note: If the host structure is not found, the adv_req_t request
5762 * structure and adv_sgblk_t structure, if any, is dropped.
5763 */
5764 if (i == asc_board_count) {
5765 ASC_PRINT2
5766 ("adv_isr_callback: scp 0x%lx has bad host pointer, host 0x%lx\n",
5767 (ulong)scp, (ulong)shost);
5768 return;
5769 }
6955 5770
6956 /* 5771 ASC_STATS(shost, callback);
6957 * If the request isn't found on the active queue, it may have been 5772 ASC_DBG1(1, "adv_isr_callback: shost 0x%lx\n", (ulong)shost);
6958 * removed to handle a reset request. Display a message and return. 5773
6959 * 5774 /*
6960 * Note: Because the structure may still be in use don't attempt 5775 * If the request isn't found on the active queue, it may have been
6961 * to free the adv_req_t and adv_sgblk_t, if any, structures. 5776 * removed to handle a reset request. Display a message and return.
6962 */ 5777 *
6963 boardp = ASC_BOARDP(shp); 5778 * Note: Because the structure may still be in use don't attempt
6964 ASC_ASSERT(adv_dvc_varp == &boardp->dvc_var.adv_dvc_var); 5779 * to free the adv_req_t and adv_sgblk_t, if any, structures.
6965 if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) { 5780 */
6966 ASC_PRINT2( 5781 boardp = ASC_BOARDP(shost);
6967 "adv_isr_callback: board %d: scp 0x%lx not on active queue\n", 5782 ASC_ASSERT(adv_dvc_varp == &boardp->dvc_var.adv_dvc_var);
6968 boardp->id, (ulong) scp); 5783 if (asc_rmqueue(&boardp->active, scp) == ASC_FALSE) {
6969 return; 5784 ASC_PRINT2
6970 } 5785 ("adv_isr_callback: board %d: scp 0x%lx not on active queue\n",
5786 boardp->id, (ulong)scp);
5787 return;
5788 }
6971 5789
6972 /* 5790 /*
6973 * 'done_status' contains the command's ending status. 5791 * 'done_status' contains the command's ending status.
6974 */ 5792 */
6975 switch (scsiqp->done_status) { 5793 switch (scsiqp->done_status) {
6976 case QD_NO_ERROR: 5794 case QD_NO_ERROR:
6977 ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n"); 5795 ASC_DBG(2, "adv_isr_callback: QD_NO_ERROR\n");
6978 scp->result = 0; 5796 scp->result = 0;
6979
6980 /*
6981 * Check for an underrun condition.
6982 *
6983 * If there was no error and an underrun condition, then
6984 * then return the number of underrun bytes.
6985 */
6986 resid_cnt = le32_to_cpu(scsiqp->data_cnt);
6987 if (scp->request_bufflen != 0 && resid_cnt != 0 &&
6988 resid_cnt <= scp->request_bufflen) {
6989 ASC_DBG1(1, "adv_isr_callback: underrun condition %lu bytes\n",
6990 (ulong) resid_cnt);
6991 scp->resid = resid_cnt;
6992 }
6993 break;
6994
6995 case QD_WITH_ERROR:
6996 ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
6997 switch (scsiqp->host_status) {
6998 case QHSTA_NO_ERROR:
6999 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
7000 ASC_DBG(2, "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
7001 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
7002 sizeof(scp->sense_buffer));
7003 /*
7004 * Note: The 'status_byte()' macro used by target drivers
7005 * defined in scsi.h shifts the status byte returned by
7006 * host drivers right by 1 bit. This is why target drivers
7007 * also use right shifted status byte definitions. For
7008 * instance target drivers use CHECK_CONDITION, defined to
7009 * 0x1, instead of the SCSI defined check condition value
7010 * of 0x2. Host drivers are supposed to return the status
7011 * byte as it is defined by SCSI.
7012 */
7013 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
7014 STATUS_BYTE(scsiqp->scsi_status);
7015 } else {
7016 scp->result = STATUS_BYTE(scsiqp->scsi_status);
7017 }
7018 break;
7019
7020 default:
7021 /* Some other QHSTA error occurred. */
7022 ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
7023 scsiqp->host_status);
7024 scp->result = HOST_BYTE(DID_BAD_TARGET);
7025 break;
7026 }
7027 break;
7028
7029 case QD_ABORTED_BY_HOST:
7030 ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
7031 scp->result = HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
7032 break;
7033
7034 default:
7035 ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n", scsiqp->done_status);
7036 scp->result = HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
7037 break;
7038 }
7039 5797
7040 /* 5798 /*
7041 * If the 'init_tidmask' bit isn't already set for the target and the 5799 * Check for an underrun condition.
7042 * current request finished normally, then set the bit for the target 5800 *
7043 * to indicate that a device is present. 5801 * If there was no error and an underrun condition, then
7044 */ 5802 * then return the number of underrun bytes.
7045 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 && 5803 */
7046 scsiqp->done_status == QD_NO_ERROR && 5804 resid_cnt = le32_to_cpu(scsiqp->data_cnt);
7047 scsiqp->host_status == QHSTA_NO_ERROR) { 5805 if (scp->request_bufflen != 0 && resid_cnt != 0 &&
7048 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id); 5806 resid_cnt <= scp->request_bufflen) {
7049 } 5807 ASC_DBG1(1,
5808 "adv_isr_callback: underrun condition %lu bytes\n",
5809 (ulong)resid_cnt);
5810 scp->resid = resid_cnt;
5811 }
5812 break;
5813
5814 case QD_WITH_ERROR:
5815 ASC_DBG(2, "adv_isr_callback: QD_WITH_ERROR\n");
5816 switch (scsiqp->host_status) {
5817 case QHSTA_NO_ERROR:
5818 if (scsiqp->scsi_status == SAM_STAT_CHECK_CONDITION) {
5819 ASC_DBG(2,
5820 "adv_isr_callback: SAM_STAT_CHECK_CONDITION\n");
5821 ASC_DBG_PRT_SENSE(2, scp->sense_buffer,
5822 sizeof(scp->sense_buffer));
5823 /*
5824 * Note: The 'status_byte()' macro used by target drivers
5825 * defined in scsi.h shifts the status byte returned by
5826 * host drivers right by 1 bit. This is why target drivers
5827 * also use right shifted status byte definitions. For
5828 * instance target drivers use CHECK_CONDITION, defined to
5829 * 0x1, instead of the SCSI defined check condition value
5830 * of 0x2. Host drivers are supposed to return the status
5831 * byte as it is defined by SCSI.
5832 */
5833 scp->result = DRIVER_BYTE(DRIVER_SENSE) |
5834 STATUS_BYTE(scsiqp->scsi_status);
5835 } else {
5836 scp->result = STATUS_BYTE(scsiqp->scsi_status);
5837 }
5838 break;
5839
5840 default:
5841 /* Some other QHSTA error occurred. */
5842 ASC_DBG1(1, "adv_isr_callback: host_status 0x%x\n",
5843 scsiqp->host_status);
5844 scp->result = HOST_BYTE(DID_BAD_TARGET);
5845 break;
5846 }
5847 break;
5848
5849 case QD_ABORTED_BY_HOST:
5850 ASC_DBG(1, "adv_isr_callback: QD_ABORTED_BY_HOST\n");
5851 scp->result =
5852 HOST_BYTE(DID_ABORT) | STATUS_BYTE(scsiqp->scsi_status);
5853 break;
5854
5855 default:
5856 ASC_DBG1(1, "adv_isr_callback: done_status 0x%x\n",
5857 scsiqp->done_status);
5858 scp->result =
5859 HOST_BYTE(DID_ERROR) | STATUS_BYTE(scsiqp->scsi_status);
5860 break;
5861 }
7050 5862
7051 /* 5863 /*
7052 * Because interrupts may be enabled by the 'struct scsi_cmnd' done 5864 * If the 'init_tidmask' bit isn't already set for the target and the
7053 * function, add the command to the end of the board's done queue. 5865 * current request finished normally, then set the bit for the target
7054 * The done function for the command will be called from 5866 * to indicate that a device is present.
7055 * advansys_interrupt(). 5867 */
7056 */ 5868 if ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(scp->device->id)) == 0 &&
7057 asc_enqueue(&boardp->done, scp, ASC_BACK); 5869 scsiqp->done_status == QD_NO_ERROR &&
5870 scsiqp->host_status == QHSTA_NO_ERROR) {
5871 boardp->init_tidmask |= ADV_TID_TO_TIDMASK(scp->device->id);
5872 }
7058 5873
7059 /* 5874 /*
7060 * Free all 'adv_sgblk_t' structures allocated for the request. 5875 * Because interrupts may be enabled by the 'struct scsi_cmnd' done
7061 */ 5876 * function, add the command to the end of the board's done queue.
7062 while ((sgblkp = reqp->sgblkp) != NULL) 5877 * The done function for the command will be called from
7063 { 5878 * advansys_interrupt().
7064 /* Remove 'sgblkp' from the request list. */ 5879 */
7065 reqp->sgblkp = sgblkp->next_sgblkp; 5880 asc_enqueue(&boardp->done, scp, ASC_BACK);
7066 5881
7067 /* Add 'sgblkp' to the board free list. */ 5882 /*
7068 sgblkp->next_sgblkp = boardp->adv_sgblkp; 5883 * Free all 'adv_sgblk_t' structures allocated for the request.
7069 boardp->adv_sgblkp = sgblkp; 5884 */
7070 } 5885 while ((sgblkp = reqp->sgblkp) != NULL) {
5886 /* Remove 'sgblkp' from the request list. */
5887 reqp->sgblkp = sgblkp->next_sgblkp;
5888
5889 /* Add 'sgblkp' to the board free list. */
5890 sgblkp->next_sgblkp = boardp->adv_sgblkp;
5891 boardp->adv_sgblkp = sgblkp;
5892 }
7071 5893
7072 /* 5894 /*
7073 * Free the adv_req_t structure used with the command by adding 5895 * Free the adv_req_t structure used with the command by adding
7074 * it back to the board free list. 5896 * it back to the board free list.
7075 */ 5897 */
7076 reqp->next_reqp = boardp->adv_reqp; 5898 reqp->next_reqp = boardp->adv_reqp;
7077 boardp->adv_reqp = reqp; 5899 boardp->adv_reqp = reqp;
7078 5900
7079 ASC_DBG(1, "adv_isr_callback: done\n"); 5901 ASC_DBG(1, "adv_isr_callback: done\n");
7080 5902
7081 return; 5903 return;
7082} 5904}
7083 5905
7084/* 5906/*
7085 * adv_async_callback() - Adv Library asynchronous event callback function. 5907 * adv_async_callback() - Adv Library asynchronous event callback function.
7086 */ 5908 */
7087STATIC void 5909static void adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
7088adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
7089{ 5910{
7090 switch (code) 5911 switch (code) {
7091 { 5912 case ADV_ASYNC_SCSI_BUS_RESET_DET:
7092 case ADV_ASYNC_SCSI_BUS_RESET_DET: 5913 /*
7093 /* 5914 * The firmware detected a SCSI Bus reset.
7094 * The firmware detected a SCSI Bus reset. 5915 */
7095 */ 5916 ASC_DBG(0,
7096 ASC_DBG(0, "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n"); 5917 "adv_async_callback: ADV_ASYNC_SCSI_BUS_RESET_DET\n");
7097 break; 5918 break;
7098 5919
7099 case ADV_ASYNC_RDMA_FAILURE: 5920 case ADV_ASYNC_RDMA_FAILURE:
7100 /* 5921 /*
7101 * Handle RDMA failure by resetting the SCSI Bus and 5922 * Handle RDMA failure by resetting the SCSI Bus and
7102 * possibly the chip if it is unresponsive. Log the error 5923 * possibly the chip if it is unresponsive. Log the error
7103 * with a unique code. 5924 * with a unique code.
7104 */ 5925 */
7105 ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n"); 5926 ASC_DBG(0, "adv_async_callback: ADV_ASYNC_RDMA_FAILURE\n");
7106 AdvResetChipAndSB(adv_dvc_varp); 5927 AdvResetChipAndSB(adv_dvc_varp);
7107 break; 5928 break;
7108 5929
7109 case ADV_HOST_SCSI_BUS_RESET: 5930 case ADV_HOST_SCSI_BUS_RESET:
7110 /* 5931 /*
7111 * Host generated SCSI bus reset occurred. 5932 * Host generated SCSI bus reset occurred.
7112 */ 5933 */
7113 ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n"); 5934 ASC_DBG(0, "adv_async_callback: ADV_HOST_SCSI_BUS_RESET\n");
7114 break; 5935 break;
7115 5936
7116 default: 5937 default:
7117 ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code); 5938 ASC_DBG1(0, "DvcAsyncCallBack: unknown code 0x%x\n", code);
7118 break; 5939 break;
7119 } 5940 }
7120} 5941}
7121 5942
7122/* 5943/*
@@ -7127,50 +5948,50 @@ adv_async_callback(ADV_DVC_VAR *adv_dvc_varp, uchar code)
7127 * 5948 *
7128 * 'REQPNEXT(reqp)' returns reqp's next pointer. 5949 * 'REQPNEXT(reqp)' returns reqp's next pointer.
7129 */ 5950 */
7130STATIC void 5951static void asc_enqueue(asc_queue_t *ascq, REQP reqp, int flag)
7131asc_enqueue(asc_queue_t *ascq, REQP reqp, int flag)
7132{ 5952{
7133 int tid; 5953 int tid;
7134 5954
7135 ASC_DBG3(3, "asc_enqueue: ascq 0x%lx, reqp 0x%lx, flag %d\n", 5955 ASC_DBG3(3, "asc_enqueue: ascq 0x%lx, reqp 0x%lx, flag %d\n",
7136 (ulong) ascq, (ulong) reqp, flag); 5956 (ulong)ascq, (ulong)reqp, flag);
7137 ASC_ASSERT(reqp != NULL); 5957 ASC_ASSERT(reqp != NULL);
7138 ASC_ASSERT(flag == ASC_FRONT || flag == ASC_BACK); 5958 ASC_ASSERT(flag == ASC_FRONT || flag == ASC_BACK);
7139 tid = REQPTID(reqp); 5959 tid = REQPTID(reqp);
7140 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID); 5960 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
7141 if (flag == ASC_FRONT) { 5961 if (flag == ASC_FRONT) {
7142 reqp->host_scribble = (unsigned char *)ascq->q_first[tid]; 5962 reqp->host_scribble = (unsigned char *)ascq->q_first[tid];
7143 ascq->q_first[tid] = reqp; 5963 ascq->q_first[tid] = reqp;
7144 /* If the queue was empty, set the last pointer. */ 5964 /* If the queue was empty, set the last pointer. */
7145 if (ascq->q_last[tid] == NULL) { 5965 if (ascq->q_last[tid] == NULL) {
7146 ascq->q_last[tid] = reqp; 5966 ascq->q_last[tid] = reqp;
7147 } 5967 }
7148 } else { /* ASC_BACK */ 5968 } else { /* ASC_BACK */
7149 if (ascq->q_last[tid] != NULL) { 5969 if (ascq->q_last[tid] != NULL) {
7150 ascq->q_last[tid]->host_scribble = (unsigned char *)reqp; 5970 ascq->q_last[tid]->host_scribble =
7151 } 5971 (unsigned char *)reqp;
7152 ascq->q_last[tid] = reqp; 5972 }
7153 reqp->host_scribble = NULL; 5973 ascq->q_last[tid] = reqp;
7154 /* If the queue was empty, set the first pointer. */ 5974 reqp->host_scribble = NULL;
7155 if (ascq->q_first[tid] == NULL) { 5975 /* If the queue was empty, set the first pointer. */
7156 ascq->q_first[tid] = reqp; 5976 if (ascq->q_first[tid] == NULL) {
7157 } 5977 ascq->q_first[tid] = reqp;
7158 } 5978 }
7159 /* The queue has at least one entry, set its bit. */ 5979 }
7160 ascq->q_tidmask |= ADV_TID_TO_TIDMASK(tid); 5980 /* The queue has at least one entry, set its bit. */
5981 ascq->q_tidmask |= ADV_TID_TO_TIDMASK(tid);
7161#ifdef ADVANSYS_STATS 5982#ifdef ADVANSYS_STATS
7162 /* Maintain request queue statistics. */ 5983 /* Maintain request queue statistics. */
7163 ascq->q_tot_cnt[tid]++; 5984 ascq->q_tot_cnt[tid]++;
7164 ascq->q_cur_cnt[tid]++; 5985 ascq->q_cur_cnt[tid]++;
7165 if (ascq->q_cur_cnt[tid] > ascq->q_max_cnt[tid]) { 5986 if (ascq->q_cur_cnt[tid] > ascq->q_max_cnt[tid]) {
7166 ascq->q_max_cnt[tid] = ascq->q_cur_cnt[tid]; 5987 ascq->q_max_cnt[tid] = ascq->q_cur_cnt[tid];
7167 ASC_DBG2(2, "asc_enqueue: new q_max_cnt[%d] %d\n", 5988 ASC_DBG2(2, "asc_enqueue: new q_max_cnt[%d] %d\n",
7168 tid, ascq->q_max_cnt[tid]); 5989 tid, ascq->q_max_cnt[tid]);
7169 } 5990 }
7170 REQPTIME(reqp) = REQTIMESTAMP(); 5991 REQPTIME(reqp) = REQTIMESTAMP();
7171#endif /* ADVANSYS_STATS */ 5992#endif /* ADVANSYS_STATS */
7172 ASC_DBG1(3, "asc_enqueue: reqp 0x%lx\n", (ulong) reqp); 5993 ASC_DBG1(3, "asc_enqueue: reqp 0x%lx\n", (ulong)reqp);
7173 return; 5994 return;
7174} 5995}
7175 5996
7176/* 5997/*
@@ -7180,31 +6001,30 @@ asc_enqueue(asc_queue_t *ascq, REQP reqp, int flag)
7180 * 6001 *
7181 * 'REQPNEXT(reqp)' returns reqp's next pointer. 6002 * 'REQPNEXT(reqp)' returns reqp's next pointer.
7182 */ 6003 */
7183STATIC REQP 6004static REQP asc_dequeue(asc_queue_t *ascq, int tid)
7184asc_dequeue(asc_queue_t *ascq, int tid)
7185{ 6005{
7186 REQP reqp; 6006 REQP reqp;
7187 6007
7188 ASC_DBG2(3, "asc_dequeue: ascq 0x%lx, tid %d\n", (ulong) ascq, tid); 6008 ASC_DBG2(3, "asc_dequeue: ascq 0x%lx, tid %d\n", (ulong)ascq, tid);
7189 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID); 6009 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
7190 if ((reqp = ascq->q_first[tid]) != NULL) { 6010 if ((reqp = ascq->q_first[tid]) != NULL) {
7191 ASC_ASSERT(ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid)); 6011 ASC_ASSERT(ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid));
7192 ascq->q_first[tid] = REQPNEXT(reqp); 6012 ascq->q_first[tid] = REQPNEXT(reqp);
7193 /* If the queue is empty, clear its bit and the last pointer. */ 6013 /* If the queue is empty, clear its bit and the last pointer. */
7194 if (ascq->q_first[tid] == NULL) { 6014 if (ascq->q_first[tid] == NULL) {
7195 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid); 6015 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
7196 ASC_ASSERT(ascq->q_last[tid] == reqp); 6016 ASC_ASSERT(ascq->q_last[tid] == reqp);
7197 ascq->q_last[tid] = NULL; 6017 ascq->q_last[tid] = NULL;
7198 } 6018 }
7199#ifdef ADVANSYS_STATS 6019#ifdef ADVANSYS_STATS
7200 /* Maintain request queue statistics. */ 6020 /* Maintain request queue statistics. */
7201 ascq->q_cur_cnt[tid]--; 6021 ascq->q_cur_cnt[tid]--;
7202 ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0); 6022 ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
7203 REQTIMESTAT("asc_dequeue", ascq, reqp, tid); 6023 REQTIMESTAT("asc_dequeue", ascq, reqp, tid);
7204#endif /* ADVANSYS_STATS */ 6024#endif /* ADVANSYS_STATS */
7205 } 6025 }
7206 ASC_DBG1(3, "asc_dequeue: reqp 0x%lx\n", (ulong) reqp); 6026 ASC_DBG1(3, "asc_dequeue: reqp 0x%lx\n", (ulong)reqp);
7207 return reqp; 6027 return reqp;
7208} 6028}
7209 6029
7210/* 6030/*
@@ -7227,74 +6047,76 @@ asc_dequeue(asc_queue_t *ascq, int tid)
7227 * Unfortunately collecting queuing time statistics adds overhead to 6047 * Unfortunately collecting queuing time statistics adds overhead to
7228 * the function that isn't inherent to the function's algorithm. 6048 * the function that isn't inherent to the function's algorithm.
7229 */ 6049 */
7230STATIC REQP 6050static REQP asc_dequeue_list(asc_queue_t *ascq, REQP *lastpp, int tid)
7231asc_dequeue_list(asc_queue_t *ascq, REQP *lastpp, int tid)
7232{ 6051{
7233 REQP firstp, lastp; 6052 REQP firstp, lastp;
7234 int i; 6053 int i;
7235 6054
7236 ASC_DBG2(3, "asc_dequeue_list: ascq 0x%lx, tid %d\n", (ulong) ascq, tid); 6055 ASC_DBG2(3, "asc_dequeue_list: ascq 0x%lx, tid %d\n", (ulong)ascq, tid);
7237 ASC_ASSERT((tid == ASC_TID_ALL) || (tid >= 0 && tid <= ADV_MAX_TID)); 6056 ASC_ASSERT((tid == ASC_TID_ALL) || (tid >= 0 && tid <= ADV_MAX_TID));
7238 6057
7239 /* 6058 /*
7240 * If 'tid' is not ASC_TID_ALL, return requests only for 6059 * If 'tid' is not ASC_TID_ALL, return requests only for
7241 * the specified 'tid'. If 'tid' is ASC_TID_ALL, return all 6060 * the specified 'tid'. If 'tid' is ASC_TID_ALL, return all
7242 * requests for all tids. 6061 * requests for all tids.
7243 */ 6062 */
7244 if (tid != ASC_TID_ALL) { 6063 if (tid != ASC_TID_ALL) {
7245 /* Return all requests for the specified 'tid'. */ 6064 /* Return all requests for the specified 'tid'. */
7246 if ((ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid)) == 0) { 6065 if ((ascq->q_tidmask & ADV_TID_TO_TIDMASK(tid)) == 0) {
7247 /* List is empty; Set first and last return pointers to NULL. */ 6066 /* List is empty; Set first and last return pointers to NULL. */
7248 firstp = lastp = NULL; 6067 firstp = lastp = NULL;
7249 } else { 6068 } else {
7250 firstp = ascq->q_first[tid]; 6069 firstp = ascq->q_first[tid];
7251 lastp = ascq->q_last[tid]; 6070 lastp = ascq->q_last[tid];
7252 ascq->q_first[tid] = ascq->q_last[tid] = NULL; 6071 ascq->q_first[tid] = ascq->q_last[tid] = NULL;
7253 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid); 6072 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
7254#ifdef ADVANSYS_STATS 6073#ifdef ADVANSYS_STATS
7255 { 6074 {
7256 REQP reqp; 6075 REQP reqp;
7257 ascq->q_cur_cnt[tid] = 0; 6076 ascq->q_cur_cnt[tid] = 0;
7258 for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) { 6077 for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
7259 REQTIMESTAT("asc_dequeue_list", ascq, reqp, tid); 6078 REQTIMESTAT("asc_dequeue_list", ascq,
7260 } 6079 reqp, tid);
7261 } 6080 }
6081 }
7262#endif /* ADVANSYS_STATS */ 6082#endif /* ADVANSYS_STATS */
7263 } 6083 }
7264 } else { 6084 } else {
7265 /* Return all requests for all tids. */ 6085 /* Return all requests for all tids. */
7266 firstp = lastp = NULL; 6086 firstp = lastp = NULL;
7267 for (i = 0; i <= ADV_MAX_TID; i++) { 6087 for (i = 0; i <= ADV_MAX_TID; i++) {
7268 if (ascq->q_tidmask & ADV_TID_TO_TIDMASK(i)) { 6088 if (ascq->q_tidmask & ADV_TID_TO_TIDMASK(i)) {
7269 if (firstp == NULL) { 6089 if (firstp == NULL) {
7270 firstp = ascq->q_first[i]; 6090 firstp = ascq->q_first[i];
7271 lastp = ascq->q_last[i]; 6091 lastp = ascq->q_last[i];
7272 } else { 6092 } else {
7273 ASC_ASSERT(lastp != NULL); 6093 ASC_ASSERT(lastp != NULL);
7274 lastp->host_scribble = (unsigned char *)ascq->q_first[i]; 6094 lastp->host_scribble =
7275 lastp = ascq->q_last[i]; 6095 (unsigned char *)ascq->q_first[i];
7276 } 6096 lastp = ascq->q_last[i];
7277 ascq->q_first[i] = ascq->q_last[i] = NULL; 6097 }
7278 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(i); 6098 ascq->q_first[i] = ascq->q_last[i] = NULL;
6099 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(i);
7279#ifdef ADVANSYS_STATS 6100#ifdef ADVANSYS_STATS
7280 ascq->q_cur_cnt[i] = 0; 6101 ascq->q_cur_cnt[i] = 0;
7281#endif /* ADVANSYS_STATS */ 6102#endif /* ADVANSYS_STATS */
7282 } 6103 }
7283 } 6104 }
7284#ifdef ADVANSYS_STATS 6105#ifdef ADVANSYS_STATS
7285 { 6106 {
7286 REQP reqp; 6107 REQP reqp;
7287 for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) { 6108 for (reqp = firstp; reqp; reqp = REQPNEXT(reqp)) {
7288 REQTIMESTAT("asc_dequeue_list", ascq, reqp, reqp->device->id); 6109 REQTIMESTAT("asc_dequeue_list", ascq, reqp,
7289 } 6110 reqp->device->id);
7290 } 6111 }
6112 }
7291#endif /* ADVANSYS_STATS */ 6113#endif /* ADVANSYS_STATS */
7292 } 6114 }
7293 if (lastpp) { 6115 if (lastpp) {
7294 *lastpp = lastp; 6116 *lastpp = lastp;
7295 } 6117 }
7296 ASC_DBG1(3, "asc_dequeue_list: firstp 0x%lx\n", (ulong) firstp); 6118 ASC_DBG1(3, "asc_dequeue_list: firstp 0x%lx\n", (ulong)firstp);
7297 return firstp; 6119 return firstp;
7298} 6120}
7299 6121
7300/* 6122/*
@@ -7307,67 +6129,67 @@ asc_dequeue_list(asc_queue_t *ascq, REQP *lastpp, int tid)
7307 * Return ASC_TRUE if the command was found and removed, 6129 * Return ASC_TRUE if the command was found and removed,
7308 * otherwise return ASC_FALSE. 6130 * otherwise return ASC_FALSE.
7309 */ 6131 */
7310STATIC int 6132static int asc_rmqueue(asc_queue_t *ascq, REQP reqp)
7311asc_rmqueue(asc_queue_t *ascq, REQP reqp)
7312{ 6133{
7313 REQP currp, prevp; 6134 REQP currp, prevp;
7314 int tid; 6135 int tid;
7315 int ret = ASC_FALSE; 6136 int ret = ASC_FALSE;
7316 6137
7317 ASC_DBG2(3, "asc_rmqueue: ascq 0x%lx, reqp 0x%lx\n", 6138 ASC_DBG2(3, "asc_rmqueue: ascq 0x%lx, reqp 0x%lx\n",
7318 (ulong) ascq, (ulong) reqp); 6139 (ulong)ascq, (ulong)reqp);
7319 ASC_ASSERT(reqp != NULL); 6140 ASC_ASSERT(reqp != NULL);
7320 6141
7321 tid = REQPTID(reqp); 6142 tid = REQPTID(reqp);
7322 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID); 6143 ASC_ASSERT(tid >= 0 && tid <= ADV_MAX_TID);
7323 6144
7324 /* 6145 /*
7325 * Handle the common case of 'reqp' being the first 6146 * Handle the common case of 'reqp' being the first
7326 * entry on the queue. 6147 * entry on the queue.
7327 */ 6148 */
7328 if (reqp == ascq->q_first[tid]) { 6149 if (reqp == ascq->q_first[tid]) {
7329 ret = ASC_TRUE; 6150 ret = ASC_TRUE;
7330 ascq->q_first[tid] = REQPNEXT(reqp); 6151 ascq->q_first[tid] = REQPNEXT(reqp);
7331 /* If the queue is now empty, clear its bit and the last pointer. */ 6152 /* If the queue is now empty, clear its bit and the last pointer. */
7332 if (ascq->q_first[tid] == NULL) { 6153 if (ascq->q_first[tid] == NULL) {
7333 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid); 6154 ascq->q_tidmask &= ~ADV_TID_TO_TIDMASK(tid);
7334 ASC_ASSERT(ascq->q_last[tid] == reqp); 6155 ASC_ASSERT(ascq->q_last[tid] == reqp);
7335 ascq->q_last[tid] = NULL; 6156 ascq->q_last[tid] = NULL;
7336 } 6157 }
7337 } else if (ascq->q_first[tid] != NULL) { 6158 } else if (ascq->q_first[tid] != NULL) {
7338 ASC_ASSERT(ascq->q_last[tid] != NULL); 6159 ASC_ASSERT(ascq->q_last[tid] != NULL);
7339 /* 6160 /*
7340 * Because the case of 'reqp' being the first entry has been 6161 * Because the case of 'reqp' being the first entry has been
7341 * handled above and it is known the queue is not empty, if 6162 * handled above and it is known the queue is not empty, if
7342 * 'reqp' is found on the queue it is guaranteed the queue will 6163 * 'reqp' is found on the queue it is guaranteed the queue will
7343 * not become empty and that 'q_first[tid]' will not be changed. 6164 * not become empty and that 'q_first[tid]' will not be changed.
7344 * 6165 *
7345 * Set 'prevp' to the first entry, 'currp' to the second entry, 6166 * Set 'prevp' to the first entry, 'currp' to the second entry,
7346 * and search for 'reqp'. 6167 * and search for 'reqp'.
7347 */ 6168 */
7348 for (prevp = ascq->q_first[tid], currp = REQPNEXT(prevp); 6169 for (prevp = ascq->q_first[tid], currp = REQPNEXT(prevp);
7349 currp; prevp = currp, currp = REQPNEXT(currp)) { 6170 currp; prevp = currp, currp = REQPNEXT(currp)) {
7350 if (currp == reqp) { 6171 if (currp == reqp) {
7351 ret = ASC_TRUE; 6172 ret = ASC_TRUE;
7352 prevp->host_scribble = (unsigned char *)REQPNEXT(currp); 6173 prevp->host_scribble =
7353 reqp->host_scribble = NULL; 6174 (unsigned char *)REQPNEXT(currp);
7354 if (ascq->q_last[tid] == reqp) { 6175 reqp->host_scribble = NULL;
7355 ascq->q_last[tid] = prevp; 6176 if (ascq->q_last[tid] == reqp) {
7356 } 6177 ascq->q_last[tid] = prevp;
7357 break; 6178 }
7358 } 6179 break;
7359 } 6180 }
7360 } 6181 }
6182 }
7361#ifdef ADVANSYS_STATS 6183#ifdef ADVANSYS_STATS
7362 /* Maintain request queue statistics. */ 6184 /* Maintain request queue statistics. */
7363 if (ret == ASC_TRUE) { 6185 if (ret == ASC_TRUE) {
7364 ascq->q_cur_cnt[tid]--; 6186 ascq->q_cur_cnt[tid]--;
7365 REQTIMESTAT("asc_rmqueue", ascq, reqp, tid); 6187 REQTIMESTAT("asc_rmqueue", ascq, reqp, tid);
7366 } 6188 }
7367 ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0); 6189 ASC_ASSERT(ascq->q_cur_cnt[tid] >= 0);
7368#endif /* ADVANSYS_STATS */ 6190#endif /* ADVANSYS_STATS */
7369 ASC_DBG2(3, "asc_rmqueue: reqp 0x%lx, ret %d\n", (ulong) reqp, ret); 6191 ASC_DBG2(3, "asc_rmqueue: reqp 0x%lx, ret %d\n", (ulong)reqp, ret);
7370 return ret; 6192 return ret;
7371} 6193}
7372 6194
7373/* 6195/*
@@ -7375,37 +6197,38 @@ asc_rmqueue(asc_queue_t *ascq, REQP reqp)
7375 * 6197 *
7376 * Calls asc_execute_scsi_cmnd() to execute a REQP/struct scsi_cmnd. 6198 * Calls asc_execute_scsi_cmnd() to execute a REQP/struct scsi_cmnd.
7377 */ 6199 */
7378STATIC void 6200static void asc_execute_queue(asc_queue_t *ascq)
7379asc_execute_queue(asc_queue_t *ascq)
7380{ 6201{
7381 ADV_SCSI_BIT_ID_TYPE scan_tidmask; 6202 ADV_SCSI_BIT_ID_TYPE scan_tidmask;
7382 REQP reqp; 6203 REQP reqp;
7383 int i; 6204 int i;
7384 6205
7385 ASC_DBG1(1, "asc_execute_queue: ascq 0x%lx\n", (ulong) ascq); 6206 ASC_DBG1(1, "asc_execute_queue: ascq 0x%lx\n", (ulong)ascq);
7386 /* 6207 /*
7387 * Execute queued commands for devices attached to 6208 * Execute queued commands for devices attached to
7388 * the current board in round-robin fashion. 6209 * the current board in round-robin fashion.
7389 */ 6210 */
7390 scan_tidmask = ascq->q_tidmask; 6211 scan_tidmask = ascq->q_tidmask;
7391 do { 6212 do {
7392 for (i = 0; i <= ADV_MAX_TID; i++) { 6213 for (i = 0; i <= ADV_MAX_TID; i++) {
7393 if (scan_tidmask & ADV_TID_TO_TIDMASK(i)) { 6214 if (scan_tidmask & ADV_TID_TO_TIDMASK(i)) {
7394 if ((reqp = asc_dequeue(ascq, i)) == NULL) { 6215 if ((reqp = asc_dequeue(ascq, i)) == NULL) {
7395 scan_tidmask &= ~ADV_TID_TO_TIDMASK(i); 6216 scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
7396 } else if (asc_execute_scsi_cmnd((struct scsi_cmnd *) reqp) 6217 } else
7397 == ASC_BUSY) { 6218 if (asc_execute_scsi_cmnd
7398 scan_tidmask &= ~ADV_TID_TO_TIDMASK(i); 6219 ((struct scsi_cmnd *)reqp)
7399 /* 6220 == ASC_BUSY) {
7400 * The request returned ASC_BUSY. Enqueue at the front of 6221 scan_tidmask &= ~ADV_TID_TO_TIDMASK(i);
7401 * target's waiting list to maintain correct ordering. 6222 /*
7402 */ 6223 * The request returned ASC_BUSY. Enqueue at the front of
7403 asc_enqueue(ascq, reqp, ASC_FRONT); 6224 * target's waiting list to maintain correct ordering.
7404 } 6225 */
7405 } 6226 asc_enqueue(ascq, reqp, ASC_FRONT);
7406 } 6227 }
7407 } while (scan_tidmask); 6228 }
7408 return; 6229 }
6230 } while (scan_tidmask);
6231 return;
7409} 6232}
7410 6233
7411#ifdef CONFIG_PROC_FS 6234#ifdef CONFIG_PROC_FS
@@ -7420,102 +6243,102 @@ asc_execute_queue(asc_queue_t *ascq)
7420 * Return the number of characters copied into 'cp'. No more than 6243 * Return the number of characters copied into 'cp'. No more than
7421 * 'cplen' characters will be copied to 'cp'. 6244 * 'cplen' characters will be copied to 'cp'.
7422 */ 6245 */
7423STATIC int 6246static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
7424asc_prt_board_devices(struct Scsi_Host *shp, char *cp, int cplen)
7425{ 6247{
7426 asc_board_t *boardp; 6248 asc_board_t *boardp;
7427 int leftlen; 6249 int leftlen;
7428 int totlen; 6250 int totlen;
7429 int len; 6251 int len;
7430 int chip_scsi_id; 6252 int chip_scsi_id;
7431 int i; 6253 int i;
7432 6254
7433 boardp = ASC_BOARDP(shp); 6255 boardp = ASC_BOARDP(shost);
7434 leftlen = cplen; 6256 leftlen = cplen;
7435 totlen = len = 0; 6257 totlen = len = 0;
7436 6258
7437 len = asc_prt_line(cp, leftlen, 6259 len = asc_prt_line(cp, leftlen,
7438"\nDevice Information for AdvanSys SCSI Host %d:\n", shp->host_no); 6260 "\nDevice Information for AdvanSys SCSI Host %d:\n",
7439 ASC_PRT_NEXT(); 6261 shost->host_no);
7440 6262 ASC_PRT_NEXT();
7441 if (ASC_NARROW_BOARD(boardp)) { 6263
7442 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; 6264 if (ASC_NARROW_BOARD(boardp)) {
7443 } else { 6265 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
7444 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id; 6266 } else {
7445 } 6267 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
6268 }
7446 6269
7447 len = asc_prt_line(cp, leftlen, "Target IDs Detected:"); 6270 len = asc_prt_line(cp, leftlen, "Target IDs Detected:");
7448 ASC_PRT_NEXT(); 6271 ASC_PRT_NEXT();
7449 for (i = 0; i <= ADV_MAX_TID; i++) { 6272 for (i = 0; i <= ADV_MAX_TID; i++) {
7450 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) { 6273 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) {
7451 len = asc_prt_line(cp, leftlen, " %X,", i); 6274 len = asc_prt_line(cp, leftlen, " %X,", i);
7452 ASC_PRT_NEXT(); 6275 ASC_PRT_NEXT();
7453 } 6276 }
7454 } 6277 }
7455 len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id); 6278 len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id);
7456 ASC_PRT_NEXT(); 6279 ASC_PRT_NEXT();
7457 6280
7458 return totlen; 6281 return totlen;
7459} 6282}
7460 6283
7461/* 6284/*
7462 * Display Wide Board BIOS Information. 6285 * Display Wide Board BIOS Information.
7463 */ 6286 */
7464STATIC int 6287static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
7465asc_prt_adv_bios(struct Scsi_Host *shp, char *cp, int cplen)
7466{ 6288{
7467 asc_board_t *boardp; 6289 asc_board_t *boardp;
7468 int leftlen; 6290 int leftlen;
7469 int totlen; 6291 int totlen;
7470 int len; 6292 int len;
7471 ushort major, minor, letter; 6293 ushort major, minor, letter;
7472 6294
7473 boardp = ASC_BOARDP(shp); 6295 boardp = ASC_BOARDP(shost);
7474 leftlen = cplen; 6296 leftlen = cplen;
7475 totlen = len = 0; 6297 totlen = len = 0;
6298
6299 len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
6300 ASC_PRT_NEXT();
6301
6302 /*
6303 * If the BIOS saved a valid signature, then fill in
6304 * the BIOS code segment base address.
6305 */
6306 if (boardp->bios_signature != 0x55AA) {
6307 len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n");
6308 ASC_PRT_NEXT();
6309 len = asc_prt_line(cp, leftlen,
6310 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
6311 ASC_PRT_NEXT();
6312 len = asc_prt_line(cp, leftlen,
6313 "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
6314 ASC_PRT_NEXT();
6315 } else {
6316 major = (boardp->bios_version >> 12) & 0xF;
6317 minor = (boardp->bios_version >> 8) & 0xF;
6318 letter = (boardp->bios_version & 0xFF);
7476 6319
7477 len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: "); 6320 len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
7478 ASC_PRT_NEXT(); 6321 major, minor,
6322 letter >= 26 ? '?' : letter + 'A');
6323 ASC_PRT_NEXT();
7479 6324
7480 /* 6325 /*
7481 * If the BIOS saved a valid signature, then fill in 6326 * Current available ROM BIOS release is 3.1I for UW
7482 * the BIOS code segment base address. 6327 * and 3.2I for U2W. This code doesn't differentiate
7483 */ 6328 * UW and U2W boards.
7484 if (boardp->bios_signature != 0x55AA) { 6329 */
7485 len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n"); 6330 if (major < 3 || (major <= 3 && minor < 1) ||
7486 ASC_PRT_NEXT(); 6331 (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
7487 len = asc_prt_line(cp, leftlen, 6332 len = asc_prt_line(cp, leftlen,
7488"BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n"); 6333 "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
7489 ASC_PRT_NEXT(); 6334 ASC_PRT_NEXT();
7490 len = asc_prt_line(cp, leftlen, 6335 len = asc_prt_line(cp, leftlen,
7491"can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n"); 6336 "ftp://ftp.connectcom.net/pub\n");
7492 ASC_PRT_NEXT(); 6337 ASC_PRT_NEXT();
7493 } else { 6338 }
7494 major = (boardp->bios_version >> 12) & 0xF; 6339 }
7495 minor = (boardp->bios_version >> 8) & 0xF;
7496 letter = (boardp->bios_version & 0xFF);
7497
7498 len = asc_prt_line(cp, leftlen, "%d.%d%c\n",
7499 major, minor, letter >= 26 ? '?' : letter + 'A');
7500 ASC_PRT_NEXT();
7501
7502 /*
7503 * Current available ROM BIOS release is 3.1I for UW
7504 * and 3.2I for U2W. This code doesn't differentiate
7505 * UW and U2W boards.
7506 */
7507 if (major < 3 || (major <= 3 && minor < 1) ||
7508 (major <= 3 && minor <= 1 && letter < ('I'- 'A'))) {
7509 len = asc_prt_line(cp, leftlen,
7510"Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
7511 ASC_PRT_NEXT();
7512 len = asc_prt_line(cp, leftlen,
7513"ftp://ftp.connectcom.net/pub\n");
7514 ASC_PRT_NEXT();
7515 }
7516 }
7517 6340
7518 return totlen; 6341 return totlen;
7519} 6342}
7520 6343
7521/* 6344/*
@@ -7541,80 +6364,79 @@ asc_prt_adv_bios(struct Scsi_Host *shp, char *cp, int cplen)
7541 * 6364 *
7542 * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE. 6365 * Returns ASC_TRUE if serial number found, otherwise returns ASC_FALSE.
7543 */ 6366 */
7544STATIC int 6367static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
7545asc_get_eeprom_string(ushort *serialnum, uchar *cp)
7546{ 6368{
7547 ushort w, num; 6369 ushort w, num;
7548 6370
7549 if ((serialnum[1] & 0xFE00) != ((ushort) 0xAA << 8)) { 6371 if ((serialnum[1] & 0xFE00) != ((ushort)0xAA << 8)) {
7550 return ASC_FALSE; 6372 return ASC_FALSE;
7551 } else { 6373 } else {
7552 /* 6374 /*
7553 * First word - 6 digits. 6375 * First word - 6 digits.
7554 */ 6376 */
7555 w = serialnum[0]; 6377 w = serialnum[0];
7556 6378
7557 /* Product type - 1st digit. */ 6379 /* Product type - 1st digit. */
7558 if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') { 6380 if ((*cp = 'A' + ((w & 0xE000) >> 13)) == 'H') {
7559 /* Product type is P=Prototype */ 6381 /* Product type is P=Prototype */
7560 *cp += 0x8; 6382 *cp += 0x8;
7561 } 6383 }
7562 cp++; 6384 cp++;
7563 6385
7564 /* Manufacturing location - 2nd digit. */ 6386 /* Manufacturing location - 2nd digit. */
7565 *cp++ = 'A' + ((w & 0x1C00) >> 10); 6387 *cp++ = 'A' + ((w & 0x1C00) >> 10);
7566 6388
7567 /* Product ID - 3rd, 4th digits. */ 6389 /* Product ID - 3rd, 4th digits. */
7568 num = w & 0x3FF; 6390 num = w & 0x3FF;
7569 *cp++ = '0' + (num / 100); 6391 *cp++ = '0' + (num / 100);
7570 num %= 100; 6392 num %= 100;
7571 *cp++ = '0' + (num / 10); 6393 *cp++ = '0' + (num / 10);
7572 6394
7573 /* Product revision - 5th digit. */ 6395 /* Product revision - 5th digit. */
7574 *cp++ = 'A' + (num % 10); 6396 *cp++ = 'A' + (num % 10);
7575 6397
7576 /* 6398 /*
7577 * Second word 6399 * Second word
7578 */ 6400 */
7579 w = serialnum[1]; 6401 w = serialnum[1];
7580 6402
7581 /* 6403 /*
7582 * Year - 6th digit. 6404 * Year - 6th digit.
7583 * 6405 *
7584 * If bit 15 of third word is set, then the 6406 * If bit 15 of third word is set, then the
7585 * last digit of the year is greater than 7. 6407 * last digit of the year is greater than 7.
7586 */ 6408 */
7587 if (serialnum[2] & 0x8000) { 6409 if (serialnum[2] & 0x8000) {
7588 *cp++ = '8' + ((w & 0x1C0) >> 6); 6410 *cp++ = '8' + ((w & 0x1C0) >> 6);
7589 } else { 6411 } else {
7590 *cp++ = '0' + ((w & 0x1C0) >> 6); 6412 *cp++ = '0' + ((w & 0x1C0) >> 6);
7591 } 6413 }
7592 6414
7593 /* Week of year - 7th, 8th digits. */ 6415 /* Week of year - 7th, 8th digits. */
7594 num = w & 0x003F; 6416 num = w & 0x003F;
7595 *cp++ = '0' + num / 10; 6417 *cp++ = '0' + num / 10;
7596 num %= 10; 6418 num %= 10;
7597 *cp++ = '0' + num; 6419 *cp++ = '0' + num;
7598 6420
7599 /* 6421 /*
7600 * Third word 6422 * Third word
7601 */ 6423 */
7602 w = serialnum[2] & 0x7FFF; 6424 w = serialnum[2] & 0x7FFF;
7603 6425
7604 /* Serial number - 9th digit. */ 6426 /* Serial number - 9th digit. */
7605 *cp++ = 'A' + (w / 1000); 6427 *cp++ = 'A' + (w / 1000);
7606 6428
7607 /* 10th, 11th, 12th digits. */ 6429 /* 10th, 11th, 12th digits. */
7608 num = w % 1000; 6430 num = w % 1000;
7609 *cp++ = '0' + num / 100; 6431 *cp++ = '0' + num / 100;
7610 num %= 100; 6432 num %= 100;
7611 *cp++ = '0' + num / 10; 6433 *cp++ = '0' + num / 10;
7612 num %= 10; 6434 num %= 10;
7613 *cp++ = '0' + num; 6435 *cp++ = '0' + num;
7614 6436
7615 *cp = '\0'; /* Null Terminate the string. */ 6437 *cp = '\0'; /* Null Terminate the string. */
7616 return ASC_TRUE; 6438 return ASC_TRUE;
7617 } 6439 }
7618} 6440}
7619 6441
7620/* 6442/*
@@ -7628,122 +6450,127 @@ asc_get_eeprom_string(ushort *serialnum, uchar *cp)
7628 * Return the number of characters copied into 'cp'. No more than 6450 * Return the number of characters copied into 'cp'. No more than
7629 * 'cplen' characters will be copied to 'cp'. 6451 * 'cplen' characters will be copied to 'cp'.
7630 */ 6452 */
7631STATIC int 6453static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
7632asc_prt_asc_board_eeprom(struct Scsi_Host *shp, char *cp, int cplen)
7633{ 6454{
7634 asc_board_t *boardp; 6455 asc_board_t *boardp;
7635 ASC_DVC_VAR *asc_dvc_varp; 6456 ASC_DVC_VAR *asc_dvc_varp;
7636 int leftlen; 6457 int leftlen;
7637 int totlen; 6458 int totlen;
7638 int len; 6459 int len;
7639 ASCEEP_CONFIG *ep; 6460 ASCEEP_CONFIG *ep;
7640 int i; 6461 int i;
7641#ifdef CONFIG_ISA 6462#ifdef CONFIG_ISA
7642 int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 }; 6463 int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
7643#endif /* CONFIG_ISA */ 6464#endif /* CONFIG_ISA */
7644 uchar serialstr[13]; 6465 uchar serialstr[13];
7645 6466
7646 boardp = ASC_BOARDP(shp); 6467 boardp = ASC_BOARDP(shost);
7647 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var; 6468 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
7648 ep = &boardp->eep_config.asc_eep; 6469 ep = &boardp->eep_config.asc_eep;
7649 6470
7650 leftlen = cplen; 6471 leftlen = cplen;
7651 totlen = len = 0; 6472 totlen = len = 0;
7652 6473
7653 len = asc_prt_line(cp, leftlen, 6474 len = asc_prt_line(cp, leftlen,
7654"\nEEPROM Settings for AdvanSys SCSI Host %d:\n", shp->host_no); 6475 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
7655 ASC_PRT_NEXT(); 6476 shost->host_no);
7656 6477 ASC_PRT_NEXT();
7657 if (asc_get_eeprom_string((ushort *) &ep->adapter_info[0], serialstr) == 6478
7658 ASC_TRUE) { 6479 if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
7659 len = asc_prt_line(cp, leftlen, " Serial Number: %s\n", serialstr); 6480 == ASC_TRUE) {
7660 ASC_PRT_NEXT(); 6481 len =
7661 } else { 6482 asc_prt_line(cp, leftlen, " Serial Number: %s\n",
7662 if (ep->adapter_info[5] == 0xBB) { 6483 serialstr);
7663 len = asc_prt_line(cp, leftlen, 6484 ASC_PRT_NEXT();
7664 " Default Settings Used for EEPROM-less Adapter.\n"); 6485 } else {
7665 ASC_PRT_NEXT(); 6486 if (ep->adapter_info[5] == 0xBB) {
7666 } else { 6487 len = asc_prt_line(cp, leftlen,
7667 len = asc_prt_line(cp, leftlen, 6488 " Default Settings Used for EEPROM-less Adapter.\n");
7668 " Serial Number Signature Not Present.\n"); 6489 ASC_PRT_NEXT();
7669 ASC_PRT_NEXT(); 6490 } else {
7670 } 6491 len = asc_prt_line(cp, leftlen,
7671 } 6492 " Serial Number Signature Not Present.\n");
6493 ASC_PRT_NEXT();
6494 }
6495 }
7672 6496
7673 len = asc_prt_line(cp, leftlen, 6497 len = asc_prt_line(cp, leftlen,
7674" Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", 6498 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
7675 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng, ep->max_tag_qng); 6499 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
7676 ASC_PRT_NEXT(); 6500 ep->max_tag_qng);
7677 6501 ASC_PRT_NEXT();
7678 len = asc_prt_line(cp, leftlen, 6502
7679" cntl 0x%x, no_scam 0x%x\n", 6503 len = asc_prt_line(cp, leftlen,
7680 ep->cntl, ep->no_scam); 6504 " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
7681 ASC_PRT_NEXT(); 6505 ASC_PRT_NEXT();
7682 6506
7683 len = asc_prt_line(cp, leftlen, 6507 len = asc_prt_line(cp, leftlen, " Target ID: ");
7684" Target ID: "); 6508 ASC_PRT_NEXT();
7685 ASC_PRT_NEXT(); 6509 for (i = 0; i <= ASC_MAX_TID; i++) {
7686 for (i = 0; i <= ASC_MAX_TID; i++) { 6510 len = asc_prt_line(cp, leftlen, " %d", i);
7687 len = asc_prt_line(cp, leftlen, " %d", i); 6511 ASC_PRT_NEXT();
7688 ASC_PRT_NEXT(); 6512 }
7689 } 6513 len = asc_prt_line(cp, leftlen, "\n");
7690 len = asc_prt_line(cp, leftlen, "\n"); 6514 ASC_PRT_NEXT();
7691 ASC_PRT_NEXT(); 6515
7692 6516 len = asc_prt_line(cp, leftlen, " Disconnects: ");
7693 len = asc_prt_line(cp, leftlen, 6517 ASC_PRT_NEXT();
7694" Disconnects: "); 6518 for (i = 0; i <= ASC_MAX_TID; i++) {
7695 ASC_PRT_NEXT(); 6519 len = asc_prt_line(cp, leftlen, " %c",
7696 for (i = 0; i <= ASC_MAX_TID; i++) { 6520 (ep->
7697 len = asc_prt_line(cp, leftlen, " %c", 6521 disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
7698 (ep->disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 6522 'N');
7699 ASC_PRT_NEXT(); 6523 ASC_PRT_NEXT();
7700 } 6524 }
7701 len = asc_prt_line(cp, leftlen, "\n"); 6525 len = asc_prt_line(cp, leftlen, "\n");
7702 ASC_PRT_NEXT(); 6526 ASC_PRT_NEXT();
7703 6527
7704 len = asc_prt_line(cp, leftlen, 6528 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
7705" Command Queuing: "); 6529 ASC_PRT_NEXT();
7706 ASC_PRT_NEXT(); 6530 for (i = 0; i <= ASC_MAX_TID; i++) {
7707 for (i = 0; i <= ASC_MAX_TID; i++) { 6531 len = asc_prt_line(cp, leftlen, " %c",
7708 len = asc_prt_line(cp, leftlen, " %c", 6532 (ep->
7709 (ep->use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 6533 use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
7710 ASC_PRT_NEXT(); 6534 'N');
7711 } 6535 ASC_PRT_NEXT();
7712 len = asc_prt_line(cp, leftlen, "\n"); 6536 }
7713 ASC_PRT_NEXT(); 6537 len = asc_prt_line(cp, leftlen, "\n");
7714 6538 ASC_PRT_NEXT();
7715 len = asc_prt_line(cp, leftlen, 6539
7716" Start Motor: "); 6540 len = asc_prt_line(cp, leftlen, " Start Motor: ");
7717 ASC_PRT_NEXT(); 6541 ASC_PRT_NEXT();
7718 for (i = 0; i <= ASC_MAX_TID; i++) { 6542 for (i = 0; i <= ASC_MAX_TID; i++) {
7719 len = asc_prt_line(cp, leftlen, " %c", 6543 len = asc_prt_line(cp, leftlen, " %c",
7720 (ep->start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 6544 (ep->
7721 ASC_PRT_NEXT(); 6545 start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
7722 } 6546 'N');
7723 len = asc_prt_line(cp, leftlen, "\n"); 6547 ASC_PRT_NEXT();
7724 ASC_PRT_NEXT(); 6548 }
7725 6549 len = asc_prt_line(cp, leftlen, "\n");
7726 len = asc_prt_line(cp, leftlen, 6550 ASC_PRT_NEXT();
7727" Synchronous Transfer:"); 6551
7728 ASC_PRT_NEXT(); 6552 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
7729 for (i = 0; i <= ASC_MAX_TID; i++) { 6553 ASC_PRT_NEXT();
7730 len = asc_prt_line(cp, leftlen, " %c", 6554 for (i = 0; i <= ASC_MAX_TID; i++) {
7731 (ep->init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 6555 len = asc_prt_line(cp, leftlen, " %c",
7732 ASC_PRT_NEXT(); 6556 (ep->
7733 } 6557 init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
7734 len = asc_prt_line(cp, leftlen, "\n"); 6558 'N');
7735 ASC_PRT_NEXT(); 6559 ASC_PRT_NEXT();
6560 }
6561 len = asc_prt_line(cp, leftlen, "\n");
6562 ASC_PRT_NEXT();
7736 6563
7737#ifdef CONFIG_ISA 6564#ifdef CONFIG_ISA
7738 if (asc_dvc_varp->bus_type & ASC_IS_ISA) { 6565 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
7739 len = asc_prt_line(cp, leftlen, 6566 len = asc_prt_line(cp, leftlen,
7740" Host ISA DMA speed: %d MB/S\n", 6567 " Host ISA DMA speed: %d MB/S\n",
7741 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]); 6568 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
7742 ASC_PRT_NEXT(); 6569 ASC_PRT_NEXT();
7743 } 6570 }
7744#endif /* CONFIG_ISA */ 6571#endif /* CONFIG_ISA */
7745 6572
7746 return totlen; 6573 return totlen;
7747} 6574}
7748 6575
7749/* 6576/*
@@ -7757,300 +6584,282 @@ asc_prt_asc_board_eeprom(struct Scsi_Host *shp, char *cp, int cplen)
7757 * Return the number of characters copied into 'cp'. No more than 6584 * Return the number of characters copied into 'cp'. No more than
7758 * 'cplen' characters will be copied to 'cp'. 6585 * 'cplen' characters will be copied to 'cp'.
7759 */ 6586 */
7760STATIC int 6587static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen)
7761asc_prt_adv_board_eeprom(struct Scsi_Host *shp, char *cp, int cplen)
7762{ 6588{
7763 asc_board_t *boardp; 6589 asc_board_t *boardp;
7764 ADV_DVC_VAR *adv_dvc_varp; 6590 ADV_DVC_VAR *adv_dvc_varp;
7765 int leftlen; 6591 int leftlen;
7766 int totlen; 6592 int totlen;
7767 int len; 6593 int len;
7768 int i; 6594 int i;
7769 char *termstr; 6595 char *termstr;
7770 uchar serialstr[13]; 6596 uchar serialstr[13];
7771 ADVEEP_3550_CONFIG *ep_3550 = NULL; 6597 ADVEEP_3550_CONFIG *ep_3550 = NULL;
7772 ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL; 6598 ADVEEP_38C0800_CONFIG *ep_38C0800 = NULL;
7773 ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL; 6599 ADVEEP_38C1600_CONFIG *ep_38C1600 = NULL;
7774 ushort word; 6600 ushort word;
7775 ushort *wordp; 6601 ushort *wordp;
7776 ushort sdtr_speed = 0; 6602 ushort sdtr_speed = 0;
7777 6603
7778 boardp = ASC_BOARDP(shp); 6604 boardp = ASC_BOARDP(shost);
7779 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var; 6605 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
7780 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) 6606 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
7781 { 6607 ep_3550 = &boardp->eep_config.adv_3550_eep;
7782 ep_3550 = &boardp->eep_config.adv_3550_eep; 6608 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
7783 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) 6609 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
7784 { 6610 } else {
7785 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep; 6611 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
7786 } else 6612 }
7787 {
7788 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
7789 }
7790 6613
7791 leftlen = cplen; 6614 leftlen = cplen;
7792 totlen = len = 0; 6615 totlen = len = 0;
7793
7794 len = asc_prt_line(cp, leftlen,
7795"\nEEPROM Settings for AdvanSys SCSI Host %d:\n", shp->host_no);
7796 ASC_PRT_NEXT();
7797
7798 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
7799 {
7800 wordp = &ep_3550->serial_number_word1;
7801 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
7802 {
7803 wordp = &ep_38C0800->serial_number_word1;
7804 } else
7805 {
7806 wordp = &ep_38C1600->serial_number_word1;
7807 }
7808 6616
7809 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) { 6617 len = asc_prt_line(cp, leftlen,
7810 len = asc_prt_line(cp, leftlen, " Serial Number: %s\n", serialstr); 6618 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
7811 ASC_PRT_NEXT(); 6619 shost->host_no);
7812 } else { 6620 ASC_PRT_NEXT();
7813 len = asc_prt_line(cp, leftlen,
7814 " Serial Number Signature Not Present.\n");
7815 ASC_PRT_NEXT();
7816 }
7817 6621
7818 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) 6622 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
7819 { 6623 wordp = &ep_3550->serial_number_word1;
7820 len = asc_prt_line(cp, leftlen, 6624 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
7821" Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", 6625 wordp = &ep_38C0800->serial_number_word1;
7822 ep_3550->adapter_scsi_id, ep_3550->max_host_qng, 6626 } else {
7823 ep_3550->max_dvc_qng); 6627 wordp = &ep_38C1600->serial_number_word1;
7824 ASC_PRT_NEXT(); 6628 }
7825 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
7826 {
7827 len = asc_prt_line(cp, leftlen,
7828" Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
7829 ep_38C0800->adapter_scsi_id, ep_38C0800->max_host_qng,
7830 ep_38C0800->max_dvc_qng);
7831 ASC_PRT_NEXT();
7832 } else
7833 {
7834 len = asc_prt_line(cp, leftlen,
7835" Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
7836 ep_38C1600->adapter_scsi_id, ep_38C1600->max_host_qng,
7837 ep_38C1600->max_dvc_qng);
7838 ASC_PRT_NEXT();
7839 }
7840 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
7841 {
7842 word = ep_3550->termination;
7843 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
7844 {
7845 word = ep_38C0800->termination_lvd;
7846 } else
7847 {
7848 word = ep_38C1600->termination_lvd;
7849 }
7850 switch (word) {
7851 case 1:
7852 termstr = "Low Off/High Off";
7853 break;
7854 case 2:
7855 termstr = "Low Off/High On";
7856 break;
7857 case 3:
7858 termstr = "Low On/High On";
7859 break;
7860 default:
7861 case 0:
7862 termstr = "Automatic";
7863 break;
7864 }
7865 6629
7866 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) 6630 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) {
7867 { 6631 len =
7868 len = asc_prt_line(cp, leftlen, 6632 asc_prt_line(cp, leftlen, " Serial Number: %s\n",
7869" termination: %u (%s), bios_ctrl: 0x%x\n", 6633 serialstr);
7870 ep_3550->termination, termstr, ep_3550->bios_ctrl); 6634 ASC_PRT_NEXT();
7871 ASC_PRT_NEXT(); 6635 } else {
7872 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) 6636 len = asc_prt_line(cp, leftlen,
7873 { 6637 " Serial Number Signature Not Present.\n");
7874 len = asc_prt_line(cp, leftlen, 6638 ASC_PRT_NEXT();
7875" termination: %u (%s), bios_ctrl: 0x%x\n", 6639 }
7876 ep_38C0800->termination_lvd, termstr, ep_38C0800->bios_ctrl);
7877 ASC_PRT_NEXT();
7878 } else
7879 {
7880 len = asc_prt_line(cp, leftlen,
7881" termination: %u (%s), bios_ctrl: 0x%x\n",
7882 ep_38C1600->termination_lvd, termstr, ep_38C1600->bios_ctrl);
7883 ASC_PRT_NEXT();
7884 }
7885 6640
7886 len = asc_prt_line(cp, leftlen, 6641 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
7887" Target ID: "); 6642 len = asc_prt_line(cp, leftlen,
7888 ASC_PRT_NEXT(); 6643 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
7889 for (i = 0; i <= ADV_MAX_TID; i++) { 6644 ep_3550->adapter_scsi_id,
7890 len = asc_prt_line(cp, leftlen, " %X", i); 6645 ep_3550->max_host_qng, ep_3550->max_dvc_qng);
7891 ASC_PRT_NEXT(); 6646 ASC_PRT_NEXT();
7892 } 6647 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
7893 len = asc_prt_line(cp, leftlen, "\n"); 6648 len = asc_prt_line(cp, leftlen,
7894 ASC_PRT_NEXT(); 6649 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
7895 6650 ep_38C0800->adapter_scsi_id,
7896 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) 6651 ep_38C0800->max_host_qng,
7897 { 6652 ep_38C0800->max_dvc_qng);
7898 word = ep_3550->disc_enable; 6653 ASC_PRT_NEXT();
7899 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) 6654 } else {
7900 { 6655 len = asc_prt_line(cp, leftlen,
7901 word = ep_38C0800->disc_enable; 6656 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
7902 } else 6657 ep_38C1600->adapter_scsi_id,
7903 { 6658 ep_38C1600->max_host_qng,
7904 word = ep_38C1600->disc_enable; 6659 ep_38C1600->max_dvc_qng);
7905 } 6660 ASC_PRT_NEXT();
7906 len = asc_prt_line(cp, leftlen, 6661 }
7907" Disconnects: "); 6662 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
7908 ASC_PRT_NEXT(); 6663 word = ep_3550->termination;
7909 for (i = 0; i <= ADV_MAX_TID; i++) { 6664 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
7910 len = asc_prt_line(cp, leftlen, " %c", 6665 word = ep_38C0800->termination_lvd;
7911 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 6666 } else {
7912 ASC_PRT_NEXT(); 6667 word = ep_38C1600->termination_lvd;
7913 } 6668 }
7914 len = asc_prt_line(cp, leftlen, "\n"); 6669 switch (word) {
7915 ASC_PRT_NEXT(); 6670 case 1:
7916 6671 termstr = "Low Off/High Off";
7917 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) 6672 break;
7918 { 6673 case 2:
7919 word = ep_3550->tagqng_able; 6674 termstr = "Low Off/High On";
7920 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) 6675 break;
7921 { 6676 case 3:
7922 word = ep_38C0800->tagqng_able; 6677 termstr = "Low On/High On";
7923 } else 6678 break;
7924 { 6679 default:
7925 word = ep_38C1600->tagqng_able; 6680 case 0:
7926 } 6681 termstr = "Automatic";
7927 len = asc_prt_line(cp, leftlen, 6682 break;
7928" Command Queuing: "); 6683 }
7929 ASC_PRT_NEXT();
7930 for (i = 0; i <= ADV_MAX_TID; i++) {
7931 len = asc_prt_line(cp, leftlen, " %c",
7932 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
7933 ASC_PRT_NEXT();
7934 }
7935 len = asc_prt_line(cp, leftlen, "\n");
7936 ASC_PRT_NEXT();
7937
7938 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
7939 {
7940 word = ep_3550->start_motor;
7941 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
7942 {
7943 word = ep_38C0800->start_motor;
7944 } else
7945 {
7946 word = ep_38C1600->start_motor;
7947 }
7948 len = asc_prt_line(cp, leftlen,
7949" Start Motor: ");
7950 ASC_PRT_NEXT();
7951 for (i = 0; i <= ADV_MAX_TID; i++) {
7952 len = asc_prt_line(cp, leftlen, " %c",
7953 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
7954 ASC_PRT_NEXT();
7955 }
7956 len = asc_prt_line(cp, leftlen, "\n");
7957 ASC_PRT_NEXT();
7958
7959 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
7960 {
7961 len = asc_prt_line(cp, leftlen,
7962" Synchronous Transfer:");
7963 ASC_PRT_NEXT();
7964 for (i = 0; i <= ADV_MAX_TID; i++) {
7965 len = asc_prt_line(cp, leftlen, " %c",
7966 (ep_3550->sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
7967 ASC_PRT_NEXT();
7968 }
7969 len = asc_prt_line(cp, leftlen, "\n");
7970 ASC_PRT_NEXT();
7971 }
7972 6684
7973 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) 6685 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
7974 { 6686 len = asc_prt_line(cp, leftlen,
7975 len = asc_prt_line(cp, leftlen, 6687 " termination: %u (%s), bios_ctrl: 0x%x\n",
7976" Ultra Transfer: "); 6688 ep_3550->termination, termstr,
7977 ASC_PRT_NEXT(); 6689 ep_3550->bios_ctrl);
7978 for (i = 0; i <= ADV_MAX_TID; i++) { 6690 ASC_PRT_NEXT();
7979 len = asc_prt_line(cp, leftlen, " %c", 6691 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
7980 (ep_3550->ultra_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 6692 len = asc_prt_line(cp, leftlen,
7981 ASC_PRT_NEXT(); 6693 " termination: %u (%s), bios_ctrl: 0x%x\n",
7982 } 6694 ep_38C0800->termination_lvd, termstr,
7983 len = asc_prt_line(cp, leftlen, "\n"); 6695 ep_38C0800->bios_ctrl);
7984 ASC_PRT_NEXT(); 6696 ASC_PRT_NEXT();
7985 } 6697 } else {
6698 len = asc_prt_line(cp, leftlen,
6699 " termination: %u (%s), bios_ctrl: 0x%x\n",
6700 ep_38C1600->termination_lvd, termstr,
6701 ep_38C1600->bios_ctrl);
6702 ASC_PRT_NEXT();
6703 }
7986 6704
7987 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) 6705 len = asc_prt_line(cp, leftlen, " Target ID: ");
7988 { 6706 ASC_PRT_NEXT();
7989 word = ep_3550->wdtr_able; 6707 for (i = 0; i <= ADV_MAX_TID; i++) {
7990 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) 6708 len = asc_prt_line(cp, leftlen, " %X", i);
7991 { 6709 ASC_PRT_NEXT();
7992 word = ep_38C0800->wdtr_able; 6710 }
7993 } else 6711 len = asc_prt_line(cp, leftlen, "\n");
7994 { 6712 ASC_PRT_NEXT();
7995 word = ep_38C1600->wdtr_able; 6713
7996 } 6714 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
7997 len = asc_prt_line(cp, leftlen, 6715 word = ep_3550->disc_enable;
7998" Wide Transfer: "); 6716 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
7999 ASC_PRT_NEXT(); 6717 word = ep_38C0800->disc_enable;
8000 for (i = 0; i <= ADV_MAX_TID; i++) { 6718 } else {
8001 len = asc_prt_line(cp, leftlen, " %c", 6719 word = ep_38C1600->disc_enable;
8002 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 6720 }
8003 ASC_PRT_NEXT(); 6721 len = asc_prt_line(cp, leftlen, " Disconnects: ");
8004 } 6722 ASC_PRT_NEXT();
8005 len = asc_prt_line(cp, leftlen, "\n"); 6723 for (i = 0; i <= ADV_MAX_TID; i++) {
8006 ASC_PRT_NEXT(); 6724 len = asc_prt_line(cp, leftlen, " %c",
8007 6725 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8008 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 || 6726 ASC_PRT_NEXT();
8009 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) 6727 }
8010 { 6728 len = asc_prt_line(cp, leftlen, "\n");
8011 len = asc_prt_line(cp, leftlen, 6729 ASC_PRT_NEXT();
8012" Synchronous Transfer Speed (Mhz):\n "); 6730
8013 ASC_PRT_NEXT(); 6731 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
8014 for (i = 0; i <= ADV_MAX_TID; i++) { 6732 word = ep_3550->tagqng_able;
8015 char *speed_str; 6733 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
8016 6734 word = ep_38C0800->tagqng_able;
8017 if (i == 0) 6735 } else {
8018 { 6736 word = ep_38C1600->tagqng_able;
8019 sdtr_speed = adv_dvc_varp->sdtr_speed1; 6737 }
8020 } else if (i == 4) 6738 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
8021 { 6739 ASC_PRT_NEXT();
8022 sdtr_speed = adv_dvc_varp->sdtr_speed2; 6740 for (i = 0; i <= ADV_MAX_TID; i++) {
8023 } else if (i == 8) 6741 len = asc_prt_line(cp, leftlen, " %c",
8024 { 6742 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8025 sdtr_speed = adv_dvc_varp->sdtr_speed3; 6743 ASC_PRT_NEXT();
8026 } else if (i == 12) 6744 }
8027 { 6745 len = asc_prt_line(cp, leftlen, "\n");
8028 sdtr_speed = adv_dvc_varp->sdtr_speed4; 6746 ASC_PRT_NEXT();
8029 } 6747
8030 switch (sdtr_speed & ADV_MAX_TID) 6748 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
8031 { 6749 word = ep_3550->start_motor;
8032 case 0: speed_str = "Off"; break; 6750 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
8033 case 1: speed_str = " 5"; break; 6751 word = ep_38C0800->start_motor;
8034 case 2: speed_str = " 10"; break; 6752 } else {
8035 case 3: speed_str = " 20"; break; 6753 word = ep_38C1600->start_motor;
8036 case 4: speed_str = " 40"; break; 6754 }
8037 case 5: speed_str = " 80"; break; 6755 len = asc_prt_line(cp, leftlen, " Start Motor: ");
8038 default: speed_str = "Unk"; break; 6756 ASC_PRT_NEXT();
8039 } 6757 for (i = 0; i <= ADV_MAX_TID; i++) {
8040 len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str); 6758 len = asc_prt_line(cp, leftlen, " %c",
8041 ASC_PRT_NEXT(); 6759 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
8042 if (i == 7) 6760 ASC_PRT_NEXT();
8043 { 6761 }
8044 len = asc_prt_line(cp, leftlen, "\n "); 6762 len = asc_prt_line(cp, leftlen, "\n");
8045 ASC_PRT_NEXT(); 6763 ASC_PRT_NEXT();
8046 } 6764
8047 sdtr_speed >>= 4; 6765 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
8048 } 6766 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
8049 len = asc_prt_line(cp, leftlen, "\n"); 6767 ASC_PRT_NEXT();
8050 ASC_PRT_NEXT(); 6768 for (i = 0; i <= ADV_MAX_TID; i++) {
8051 } 6769 len = asc_prt_line(cp, leftlen, " %c",
6770 (ep_3550->
6771 sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
6772 'Y' : 'N');
6773 ASC_PRT_NEXT();
6774 }
6775 len = asc_prt_line(cp, leftlen, "\n");
6776 ASC_PRT_NEXT();
6777 }
6778
6779 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6780 len = asc_prt_line(cp, leftlen, " Ultra Transfer: ");
6781 ASC_PRT_NEXT();
6782 for (i = 0; i <= ADV_MAX_TID; i++) {
6783 len = asc_prt_line(cp, leftlen, " %c",
6784 (ep_3550->
6785 ultra_able & ADV_TID_TO_TIDMASK(i))
6786 ? 'Y' : 'N');
6787 ASC_PRT_NEXT();
6788 }
6789 len = asc_prt_line(cp, leftlen, "\n");
6790 ASC_PRT_NEXT();
6791 }
6792
6793 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
6794 word = ep_3550->wdtr_able;
6795 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
6796 word = ep_38C0800->wdtr_able;
6797 } else {
6798 word = ep_38C1600->wdtr_able;
6799 }
6800 len = asc_prt_line(cp, leftlen, " Wide Transfer: ");
6801 ASC_PRT_NEXT();
6802 for (i = 0; i <= ADV_MAX_TID; i++) {
6803 len = asc_prt_line(cp, leftlen, " %c",
6804 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
6805 ASC_PRT_NEXT();
6806 }
6807 len = asc_prt_line(cp, leftlen, "\n");
6808 ASC_PRT_NEXT();
6809
6810 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
6811 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
6812 len = asc_prt_line(cp, leftlen,
6813 " Synchronous Transfer Speed (Mhz):\n ");
6814 ASC_PRT_NEXT();
6815 for (i = 0; i <= ADV_MAX_TID; i++) {
6816 char *speed_str;
6817
6818 if (i == 0) {
6819 sdtr_speed = adv_dvc_varp->sdtr_speed1;
6820 } else if (i == 4) {
6821 sdtr_speed = adv_dvc_varp->sdtr_speed2;
6822 } else if (i == 8) {
6823 sdtr_speed = adv_dvc_varp->sdtr_speed3;
6824 } else if (i == 12) {
6825 sdtr_speed = adv_dvc_varp->sdtr_speed4;
6826 }
6827 switch (sdtr_speed & ADV_MAX_TID) {
6828 case 0:
6829 speed_str = "Off";
6830 break;
6831 case 1:
6832 speed_str = " 5";
6833 break;
6834 case 2:
6835 speed_str = " 10";
6836 break;
6837 case 3:
6838 speed_str = " 20";
6839 break;
6840 case 4:
6841 speed_str = " 40";
6842 break;
6843 case 5:
6844 speed_str = " 80";
6845 break;
6846 default:
6847 speed_str = "Unk";
6848 break;
6849 }
6850 len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str);
6851 ASC_PRT_NEXT();
6852 if (i == 7) {
6853 len = asc_prt_line(cp, leftlen, "\n ");
6854 ASC_PRT_NEXT();
6855 }
6856 sdtr_speed >>= 4;
6857 }
6858 len = asc_prt_line(cp, leftlen, "\n");
6859 ASC_PRT_NEXT();
6860 }
8052 6861
8053 return totlen; 6862 return totlen;
8054} 6863}
8055 6864
8056/* 6865/*
@@ -8062,60 +6871,60 @@ asc_prt_adv_board_eeprom(struct Scsi_Host *shp, char *cp, int cplen)
8062 * Return the number of characters copied into 'cp'. No more than 6871 * Return the number of characters copied into 'cp'. No more than
8063 * 'cplen' characters will be copied to 'cp'. 6872 * 'cplen' characters will be copied to 'cp'.
8064 */ 6873 */
8065STATIC int 6874static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen)
8066asc_prt_driver_conf(struct Scsi_Host *shp, char *cp, int cplen)
8067{ 6875{
8068 asc_board_t *boardp; 6876 asc_board_t *boardp;
8069 int leftlen; 6877 int leftlen;
8070 int totlen; 6878 int totlen;
8071 int len; 6879 int len;
8072 int chip_scsi_id; 6880 int chip_scsi_id;
8073 6881
8074 boardp = ASC_BOARDP(shp); 6882 boardp = ASC_BOARDP(shost);
8075 6883
8076 leftlen = cplen; 6884 leftlen = cplen;
8077 totlen = len = 0; 6885 totlen = len = 0;
8078 6886
8079 len = asc_prt_line(cp, leftlen, 6887 len = asc_prt_line(cp, leftlen,
8080"\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n", 6888 "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
8081 shp->host_no); 6889 shost->host_no);
8082 ASC_PRT_NEXT(); 6890 ASC_PRT_NEXT();
8083 6891
8084 len = asc_prt_line(cp, leftlen, 6892 len = asc_prt_line(cp, leftlen,
8085" host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n", 6893 " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
8086 shp->host_busy, shp->last_reset, shp->max_id, shp->max_lun, 6894 shost->host_busy, shost->last_reset, shost->max_id,
8087 shp->max_channel); 6895 shost->max_lun, shost->max_channel);
8088 ASC_PRT_NEXT(); 6896 ASC_PRT_NEXT();
8089 6897
8090 len = asc_prt_line(cp, leftlen, 6898 len = asc_prt_line(cp, leftlen,
8091" unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n", 6899 " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
8092 shp->unique_id, shp->can_queue, shp->this_id, shp->sg_tablesize, 6900 shost->unique_id, shost->can_queue, shost->this_id,
8093 shp->cmd_per_lun); 6901 shost->sg_tablesize, shost->cmd_per_lun);
8094 ASC_PRT_NEXT(); 6902 ASC_PRT_NEXT();
8095 6903
8096 len = asc_prt_line(cp, leftlen, 6904 len = asc_prt_line(cp, leftlen,
8097" unchecked_isa_dma %d, use_clustering %d\n", 6905 " unchecked_isa_dma %d, use_clustering %d\n",
8098 shp->unchecked_isa_dma, shp->use_clustering); 6906 shost->unchecked_isa_dma, shost->use_clustering);
8099 ASC_PRT_NEXT(); 6907 ASC_PRT_NEXT();
8100 6908
8101 len = asc_prt_line(cp, leftlen, 6909 len = asc_prt_line(cp, leftlen,
8102" flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n", 6910 " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
8103 boardp->flags, boardp->last_reset, jiffies, boardp->asc_n_io_port); 6911 boardp->flags, boardp->last_reset, jiffies,
8104 ASC_PRT_NEXT(); 6912 boardp->asc_n_io_port);
8105 6913 ASC_PRT_NEXT();
8106 /* 'shp->n_io_port' may be truncated because it is only one byte. */ 6914
8107 len = asc_prt_line(cp, leftlen, 6915 /* 'shost->n_io_port' may be truncated because it is only one byte. */
8108" io_port 0x%x, n_io_port 0x%x\n", 6916 len = asc_prt_line(cp, leftlen,
8109 shp->io_port, shp->n_io_port); 6917 " io_port 0x%x, n_io_port 0x%x\n",
8110 ASC_PRT_NEXT(); 6918 shost->io_port, shost->n_io_port);
8111 6919 ASC_PRT_NEXT();
8112 if (ASC_NARROW_BOARD(boardp)) { 6920
8113 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; 6921 if (ASC_NARROW_BOARD(boardp)) {
8114 } else { 6922 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
8115 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id; 6923 } else {
8116 } 6924 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
6925 }
8117 6926
8118 return totlen; 6927 return totlen;
8119} 6928}
8120 6929
8121/* 6930/*
@@ -8129,178 +6938,181 @@ asc_prt_driver_conf(struct Scsi_Host *shp, char *cp, int cplen)
8129 * Return the number of characters copied into 'cp'. No more than 6938 * Return the number of characters copied into 'cp'. No more than
8130 * 'cplen' characters will be copied to 'cp'. 6939 * 'cplen' characters will be copied to 'cp'.
8131 */ 6940 */
8132STATIC int 6941static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
8133asc_prt_asc_board_info(struct Scsi_Host *shp, char *cp, int cplen)
8134{ 6942{
8135 asc_board_t *boardp; 6943 asc_board_t *boardp;
8136 int chip_scsi_id; 6944 int chip_scsi_id;
8137 int leftlen; 6945 int leftlen;
8138 int totlen; 6946 int totlen;
8139 int len; 6947 int len;
8140 ASC_DVC_VAR *v; 6948 ASC_DVC_VAR *v;
8141 ASC_DVC_CFG *c; 6949 ASC_DVC_CFG *c;
8142 int i; 6950 int i;
8143 int renegotiate = 0; 6951 int renegotiate = 0;
8144 6952
8145 boardp = ASC_BOARDP(shp); 6953 boardp = ASC_BOARDP(shost);
8146 v = &boardp->dvc_var.asc_dvc_var; 6954 v = &boardp->dvc_var.asc_dvc_var;
8147 c = &boardp->dvc_cfg.asc_dvc_cfg; 6955 c = &boardp->dvc_cfg.asc_dvc_cfg;
8148 chip_scsi_id = c->chip_scsi_id; 6956 chip_scsi_id = c->chip_scsi_id;
8149 6957
8150 leftlen = cplen; 6958 leftlen = cplen;
8151 totlen = len = 0; 6959 totlen = len = 0;
8152 6960
8153 len = asc_prt_line(cp, leftlen, 6961 len = asc_prt_line(cp, leftlen,
8154"\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n", 6962 "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
8155 shp->host_no); 6963 shost->host_no);
8156 ASC_PRT_NEXT(); 6964 ASC_PRT_NEXT();
8157 6965
8158 len = asc_prt_line(cp, leftlen, 6966 len = asc_prt_line(cp, leftlen,
8159" chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n", 6967 " chip_version %u, lib_version 0x%x, lib_serial_no %u, mcode_date 0x%x\n",
8160 c->chip_version, c->lib_version, c->lib_serial_no, c->mcode_date); 6968 c->chip_version, c->lib_version, c->lib_serial_no,
8161 ASC_PRT_NEXT(); 6969 c->mcode_date);
8162 6970 ASC_PRT_NEXT();
8163 len = asc_prt_line(cp, leftlen, 6971
8164" mcode_version 0x%x, err_code %u\n", 6972 len = asc_prt_line(cp, leftlen,
8165 c->mcode_version, v->err_code); 6973 " mcode_version 0x%x, err_code %u\n",
8166 ASC_PRT_NEXT(); 6974 c->mcode_version, v->err_code);
8167 6975 ASC_PRT_NEXT();
8168 /* Current number of commands waiting for the host. */ 6976
8169 len = asc_prt_line(cp, leftlen, 6977 /* Current number of commands waiting for the host. */
8170" Total Command Pending: %d\n", v->cur_total_qng); 6978 len = asc_prt_line(cp, leftlen,
8171 ASC_PRT_NEXT(); 6979 " Total Command Pending: %d\n", v->cur_total_qng);
8172 6980 ASC_PRT_NEXT();
8173 len = asc_prt_line(cp, leftlen, 6981
8174" Command Queuing:"); 6982 len = asc_prt_line(cp, leftlen, " Command Queuing:");
8175 ASC_PRT_NEXT(); 6983 ASC_PRT_NEXT();
8176 for (i = 0; i <= ASC_MAX_TID; i++) { 6984 for (i = 0; i <= ASC_MAX_TID; i++) {
8177 if ((chip_scsi_id == i) || 6985 if ((chip_scsi_id == i) ||
8178 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 6986 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8179 continue; 6987 continue;
8180 } 6988 }
8181 len = asc_prt_line(cp, leftlen, " %X:%c", 6989 len = asc_prt_line(cp, leftlen, " %X:%c",
8182 i, (v->use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 6990 i,
8183 ASC_PRT_NEXT(); 6991 (v->
8184 } 6992 use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
8185 len = asc_prt_line(cp, leftlen, "\n"); 6993 'Y' : 'N');
8186 ASC_PRT_NEXT(); 6994 ASC_PRT_NEXT();
8187 6995 }
8188 /* Current number of commands waiting for a device. */ 6996 len = asc_prt_line(cp, leftlen, "\n");
8189 len = asc_prt_line(cp, leftlen, 6997 ASC_PRT_NEXT();
8190" Command Queue Pending:"); 6998
8191 ASC_PRT_NEXT(); 6999 /* Current number of commands waiting for a device. */
8192 for (i = 0; i <= ASC_MAX_TID; i++) { 7000 len = asc_prt_line(cp, leftlen, " Command Queue Pending:");
8193 if ((chip_scsi_id == i) || 7001 ASC_PRT_NEXT();
8194 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 7002 for (i = 0; i <= ASC_MAX_TID; i++) {
8195 continue; 7003 if ((chip_scsi_id == i) ||
8196 } 7004 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8197 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]); 7005 continue;
8198 ASC_PRT_NEXT(); 7006 }
8199 } 7007 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]);
8200 len = asc_prt_line(cp, leftlen, "\n"); 7008 ASC_PRT_NEXT();
8201 ASC_PRT_NEXT(); 7009 }
8202 7010 len = asc_prt_line(cp, leftlen, "\n");
8203 /* Current limit on number of commands that can be sent to a device. */ 7011 ASC_PRT_NEXT();
8204 len = asc_prt_line(cp, leftlen, 7012
8205" Command Queue Limit:"); 7013 /* Current limit on number of commands that can be sent to a device. */
8206 ASC_PRT_NEXT(); 7014 len = asc_prt_line(cp, leftlen, " Command Queue Limit:");
8207 for (i = 0; i <= ASC_MAX_TID; i++) { 7015 ASC_PRT_NEXT();
8208 if ((chip_scsi_id == i) || 7016 for (i = 0; i <= ASC_MAX_TID; i++) {
8209 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 7017 if ((chip_scsi_id == i) ||
8210 continue; 7018 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8211 } 7019 continue;
8212 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]); 7020 }
8213 ASC_PRT_NEXT(); 7021 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]);
8214 } 7022 ASC_PRT_NEXT();
8215 len = asc_prt_line(cp, leftlen, "\n"); 7023 }
8216 ASC_PRT_NEXT(); 7024 len = asc_prt_line(cp, leftlen, "\n");
8217 7025 ASC_PRT_NEXT();
8218 /* Indicate whether the device has returned queue full status. */ 7026
8219 len = asc_prt_line(cp, leftlen, 7027 /* Indicate whether the device has returned queue full status. */
8220" Command Queue Full:"); 7028 len = asc_prt_line(cp, leftlen, " Command Queue Full:");
8221 ASC_PRT_NEXT(); 7029 ASC_PRT_NEXT();
8222 for (i = 0; i <= ASC_MAX_TID; i++) { 7030 for (i = 0; i <= ASC_MAX_TID; i++) {
8223 if ((chip_scsi_id == i) || 7031 if ((chip_scsi_id == i) ||
8224 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 7032 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8225 continue; 7033 continue;
8226 } 7034 }
8227 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) { 7035 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) {
8228 len = asc_prt_line(cp, leftlen, " %X:Y-%d", 7036 len = asc_prt_line(cp, leftlen, " %X:Y-%d",
8229 i, boardp->queue_full_cnt[i]); 7037 i, boardp->queue_full_cnt[i]);
8230 } else { 7038 } else {
8231 len = asc_prt_line(cp, leftlen, " %X:N", i); 7039 len = asc_prt_line(cp, leftlen, " %X:N", i);
8232 } 7040 }
8233 ASC_PRT_NEXT(); 7041 ASC_PRT_NEXT();
8234 } 7042 }
8235 len = asc_prt_line(cp, leftlen, "\n"); 7043 len = asc_prt_line(cp, leftlen, "\n");
8236 ASC_PRT_NEXT(); 7044 ASC_PRT_NEXT();
8237 7045
8238 len = asc_prt_line(cp, leftlen, 7046 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
8239" Synchronous Transfer:"); 7047 ASC_PRT_NEXT();
8240 ASC_PRT_NEXT(); 7048 for (i = 0; i <= ASC_MAX_TID; i++) {
8241 for (i = 0; i <= ASC_MAX_TID; i++) { 7049 if ((chip_scsi_id == i) ||
8242 if ((chip_scsi_id == i) || 7050 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8243 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 7051 continue;
8244 continue; 7052 }
8245 } 7053 len = asc_prt_line(cp, leftlen, " %X:%c",
8246 len = asc_prt_line(cp, leftlen, " %X:%c", 7054 i,
8247 i, (v->sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 7055 (v->
8248 ASC_PRT_NEXT(); 7056 sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
8249 } 7057 'N');
8250 len = asc_prt_line(cp, leftlen, "\n"); 7058 ASC_PRT_NEXT();
8251 ASC_PRT_NEXT(); 7059 }
8252 7060 len = asc_prt_line(cp, leftlen, "\n");
8253 for (i = 0; i <= ASC_MAX_TID; i++) { 7061 ASC_PRT_NEXT();
8254 uchar syn_period_ix; 7062
8255 7063 for (i = 0; i <= ASC_MAX_TID; i++) {
8256 if ((chip_scsi_id == i) || 7064 uchar syn_period_ix;
8257 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) || 7065
8258 ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) { 7066 if ((chip_scsi_id == i) ||
8259 continue; 7067 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
8260 } 7068 ((v->init_sdtr & ADV_TID_TO_TIDMASK(i)) == 0)) {
8261 7069 continue;
8262 len = asc_prt_line(cp, leftlen, " %X:", i); 7070 }
8263 ASC_PRT_NEXT(); 7071
8264 7072 len = asc_prt_line(cp, leftlen, " %X:", i);
8265 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) 7073 ASC_PRT_NEXT();
8266 { 7074
8267 len = asc_prt_line(cp, leftlen, " Asynchronous"); 7075 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
8268 ASC_PRT_NEXT(); 7076 len = asc_prt_line(cp, leftlen, " Asynchronous");
8269 } else 7077 ASC_PRT_NEXT();
8270 { 7078 } else {
8271 syn_period_ix = 7079 syn_period_ix =
8272 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index - 1); 7080 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
8273 7081 1);
8274 len = asc_prt_line(cp, leftlen, 7082
8275 " Transfer Period Factor: %d (%d.%d Mhz),", 7083 len = asc_prt_line(cp, leftlen,
8276 v->sdtr_period_tbl[syn_period_ix], 7084 " Transfer Period Factor: %d (%d.%d Mhz),",
8277 250 / v->sdtr_period_tbl[syn_period_ix], 7085 v->sdtr_period_tbl[syn_period_ix],
8278 ASC_TENTHS(250, v->sdtr_period_tbl[syn_period_ix])); 7086 250 /
8279 ASC_PRT_NEXT(); 7087 v->sdtr_period_tbl[syn_period_ix],
8280 7088 ASC_TENTHS(250,
8281 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d", 7089 v->
8282 boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET); 7090 sdtr_period_tbl
8283 ASC_PRT_NEXT(); 7091 [syn_period_ix]));
8284 } 7092 ASC_PRT_NEXT();
8285 7093
8286 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { 7094 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
8287 len = asc_prt_line(cp, leftlen, "*\n"); 7095 boardp->
8288 renegotiate = 1; 7096 sdtr_data[i] & ASC_SYN_MAX_OFFSET);
8289 } else 7097 ASC_PRT_NEXT();
8290 { 7098 }
8291 len = asc_prt_line(cp, leftlen, "\n"); 7099
8292 } 7100 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
8293 ASC_PRT_NEXT(); 7101 len = asc_prt_line(cp, leftlen, "*\n");
8294 } 7102 renegotiate = 1;
7103 } else {
7104 len = asc_prt_line(cp, leftlen, "\n");
7105 }
7106 ASC_PRT_NEXT();
7107 }
8295 7108
8296 if (renegotiate) 7109 if (renegotiate) {
8297 { 7110 len = asc_prt_line(cp, leftlen,
8298 len = asc_prt_line(cp, leftlen, 7111 " * = Re-negotiation pending before next command.\n");
8299 " * = Re-negotiation pending before next command.\n"); 7112 ASC_PRT_NEXT();
8300 ASC_PRT_NEXT(); 7113 }
8301 }
8302 7114
8303 return totlen; 7115 return totlen;
8304} 7116}
8305 7117
8306/* 7118/*
@@ -8314,237 +7126,242 @@ asc_prt_asc_board_info(struct Scsi_Host *shp, char *cp, int cplen)
8314 * Return the number of characters copied into 'cp'. No more than 7126 * Return the number of characters copied into 'cp'. No more than
8315 * 'cplen' characters will be copied to 'cp'. 7127 * 'cplen' characters will be copied to 'cp'.
8316 */ 7128 */
8317STATIC int 7129static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
8318asc_prt_adv_board_info(struct Scsi_Host *shp, char *cp, int cplen)
8319{ 7130{
8320 asc_board_t *boardp; 7131 asc_board_t *boardp;
8321 int leftlen; 7132 int leftlen;
8322 int totlen; 7133 int totlen;
8323 int len; 7134 int len;
8324 int i; 7135 int i;
8325 ADV_DVC_VAR *v; 7136 ADV_DVC_VAR *v;
8326 ADV_DVC_CFG *c; 7137 ADV_DVC_CFG *c;
8327 AdvPortAddr iop_base; 7138 AdvPortAddr iop_base;
8328 ushort chip_scsi_id; 7139 ushort chip_scsi_id;
8329 ushort lramword; 7140 ushort lramword;
8330 uchar lrambyte; 7141 uchar lrambyte;
8331 ushort tagqng_able; 7142 ushort tagqng_able;
8332 ushort sdtr_able, wdtr_able; 7143 ushort sdtr_able, wdtr_able;
8333 ushort wdtr_done, sdtr_done; 7144 ushort wdtr_done, sdtr_done;
8334 ushort period = 0; 7145 ushort period = 0;
8335 int renegotiate = 0; 7146 int renegotiate = 0;
8336 7147
8337 boardp = ASC_BOARDP(shp); 7148 boardp = ASC_BOARDP(shost);
8338 v = &boardp->dvc_var.adv_dvc_var; 7149 v = &boardp->dvc_var.adv_dvc_var;
8339 c = &boardp->dvc_cfg.adv_dvc_cfg; 7150 c = &boardp->dvc_cfg.adv_dvc_cfg;
8340 iop_base = v->iop_base; 7151 iop_base = v->iop_base;
8341 chip_scsi_id = v->chip_scsi_id; 7152 chip_scsi_id = v->chip_scsi_id;
8342 7153
8343 leftlen = cplen; 7154 leftlen = cplen;
8344 totlen = len = 0; 7155 totlen = len = 0;
8345 7156
8346 len = asc_prt_line(cp, leftlen, 7157 len = asc_prt_line(cp, leftlen,
8347"\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n", 7158 "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
8348 shp->host_no); 7159 shost->host_no);
8349 ASC_PRT_NEXT(); 7160 ASC_PRT_NEXT();
8350 7161
8351 len = asc_prt_line(cp, leftlen, 7162 len = asc_prt_line(cp, leftlen,
8352" iop_base 0x%lx, cable_detect: %X, err_code %u\n", 7163 " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
8353 v->iop_base, 7164 v->iop_base,
8354 AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1) & CABLE_DETECT, 7165 AdvReadWordRegister(iop_base,
8355 v->err_code); 7166 IOPW_SCSI_CFG1) & CABLE_DETECT,
8356 ASC_PRT_NEXT(); 7167 v->err_code);
8357 7168 ASC_PRT_NEXT();
8358 len = asc_prt_line(cp, leftlen, 7169
8359" chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n", 7170 len = asc_prt_line(cp, leftlen,
8360 c->chip_version, c->lib_version, c->mcode_date, c->mcode_version); 7171 " chip_version %u, lib_version 0x%x, mcode_date 0x%x, mcode_version 0x%x\n",
8361 ASC_PRT_NEXT(); 7172 c->chip_version, c->lib_version, c->mcode_date,
8362 7173 c->mcode_version);
8363 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able); 7174 ASC_PRT_NEXT();
8364 len = asc_prt_line(cp, leftlen, 7175
8365" Queuing Enabled:"); 7176 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
8366 ASC_PRT_NEXT(); 7177 len = asc_prt_line(cp, leftlen, " Queuing Enabled:");
8367 for (i = 0; i <= ADV_MAX_TID; i++) { 7178 ASC_PRT_NEXT();
8368 if ((chip_scsi_id == i) || 7179 for (i = 0; i <= ADV_MAX_TID; i++) {
8369 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 7180 if ((chip_scsi_id == i) ||
8370 continue; 7181 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8371 } 7182 continue;
8372 7183 }
8373 len = asc_prt_line(cp, leftlen, " %X:%c", 7184
8374 i, (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 7185 len = asc_prt_line(cp, leftlen, " %X:%c",
8375 ASC_PRT_NEXT(); 7186 i,
8376 } 7187 (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
8377 len = asc_prt_line(cp, leftlen, "\n"); 7188 'N');
8378 ASC_PRT_NEXT(); 7189 ASC_PRT_NEXT();
8379 7190 }
8380 len = asc_prt_line(cp, leftlen, 7191 len = asc_prt_line(cp, leftlen, "\n");
8381" Queue Limit:"); 7192 ASC_PRT_NEXT();
8382 ASC_PRT_NEXT(); 7193
8383 for (i = 0; i <= ADV_MAX_TID; i++) { 7194 len = asc_prt_line(cp, leftlen, " Queue Limit:");
8384 if ((chip_scsi_id == i) || 7195 ASC_PRT_NEXT();
8385 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 7196 for (i = 0; i <= ADV_MAX_TID; i++) {
8386 continue; 7197 if ((chip_scsi_id == i) ||
8387 } 7198 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8388 7199 continue;
8389 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i, lrambyte); 7200 }
8390 7201
8391 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte); 7202 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
8392 ASC_PRT_NEXT(); 7203 lrambyte);
8393 } 7204
8394 len = asc_prt_line(cp, leftlen, "\n"); 7205 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
8395 ASC_PRT_NEXT(); 7206 ASC_PRT_NEXT();
8396 7207 }
8397 len = asc_prt_line(cp, leftlen, 7208 len = asc_prt_line(cp, leftlen, "\n");
8398" Command Pending:"); 7209 ASC_PRT_NEXT();
8399 ASC_PRT_NEXT(); 7210
8400 for (i = 0; i <= ADV_MAX_TID; i++) { 7211 len = asc_prt_line(cp, leftlen, " Command Pending:");
8401 if ((chip_scsi_id == i) || 7212 ASC_PRT_NEXT();
8402 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 7213 for (i = 0; i <= ADV_MAX_TID; i++) {
8403 continue; 7214 if ((chip_scsi_id == i) ||
8404 } 7215 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8405 7216 continue;
8406 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i, lrambyte); 7217 }
8407 7218
8408 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte); 7219 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
8409 ASC_PRT_NEXT(); 7220 lrambyte);
8410 } 7221
8411 len = asc_prt_line(cp, leftlen, "\n"); 7222 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte);
8412 ASC_PRT_NEXT(); 7223 ASC_PRT_NEXT();
8413 7224 }
8414 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able); 7225 len = asc_prt_line(cp, leftlen, "\n");
8415 len = asc_prt_line(cp, leftlen, 7226 ASC_PRT_NEXT();
8416" Wide Enabled:"); 7227
8417 ASC_PRT_NEXT(); 7228 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
8418 for (i = 0; i <= ADV_MAX_TID; i++) { 7229 len = asc_prt_line(cp, leftlen, " Wide Enabled:");
8419 if ((chip_scsi_id == i) || 7230 ASC_PRT_NEXT();
8420 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 7231 for (i = 0; i <= ADV_MAX_TID; i++) {
8421 continue; 7232 if ((chip_scsi_id == i) ||
8422 } 7233 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8423 7234 continue;
8424 len = asc_prt_line(cp, leftlen, " %X:%c", 7235 }
8425 i, (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 7236
8426 ASC_PRT_NEXT(); 7237 len = asc_prt_line(cp, leftlen, " %X:%c",
8427 } 7238 i,
8428 len = asc_prt_line(cp, leftlen, "\n"); 7239 (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
8429 ASC_PRT_NEXT(); 7240 'N');
8430 7241 ASC_PRT_NEXT();
8431 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done); 7242 }
8432 len = asc_prt_line(cp, leftlen, 7243 len = asc_prt_line(cp, leftlen, "\n");
8433" Transfer Bit Width:"); 7244 ASC_PRT_NEXT();
8434 ASC_PRT_NEXT(); 7245
8435 for (i = 0; i <= ADV_MAX_TID; i++) { 7246 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
8436 if ((chip_scsi_id == i) || 7247 len = asc_prt_line(cp, leftlen, " Transfer Bit Width:");
8437 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 7248 ASC_PRT_NEXT();
8438 continue; 7249 for (i = 0; i <= ADV_MAX_TID; i++) {
8439 } 7250 if ((chip_scsi_id == i) ||
8440 7251 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8441 AdvReadWordLram(iop_base, ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i), 7252 continue;
8442 lramword); 7253 }
8443 7254
8444 len = asc_prt_line(cp, leftlen, " %X:%d", 7255 AdvReadWordLram(iop_base,
8445 i, (lramword & 0x8000) ? 16 : 8); 7256 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
8446 ASC_PRT_NEXT(); 7257 lramword);
8447 7258
8448 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) && 7259 len = asc_prt_line(cp, leftlen, " %X:%d",
8449 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { 7260 i, (lramword & 0x8000) ? 16 : 8);
8450 len = asc_prt_line(cp, leftlen, "*"); 7261 ASC_PRT_NEXT();
8451 ASC_PRT_NEXT(); 7262
8452 renegotiate = 1; 7263 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
8453 } 7264 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
8454 } 7265 len = asc_prt_line(cp, leftlen, "*");
8455 len = asc_prt_line(cp, leftlen, "\n"); 7266 ASC_PRT_NEXT();
8456 ASC_PRT_NEXT(); 7267 renegotiate = 1;
8457 7268 }
8458 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able); 7269 }
8459 len = asc_prt_line(cp, leftlen, 7270 len = asc_prt_line(cp, leftlen, "\n");
8460" Synchronous Enabled:"); 7271 ASC_PRT_NEXT();
8461 ASC_PRT_NEXT(); 7272
8462 for (i = 0; i <= ADV_MAX_TID; i++) { 7273 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
8463 if ((chip_scsi_id == i) || 7274 len = asc_prt_line(cp, leftlen, " Synchronous Enabled:");
8464 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 7275 ASC_PRT_NEXT();
8465 continue; 7276 for (i = 0; i <= ADV_MAX_TID; i++) {
8466 } 7277 if ((chip_scsi_id == i) ||
8467 7278 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
8468 len = asc_prt_line(cp, leftlen, " %X:%c", 7279 continue;
8469 i, (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 7280 }
8470 ASC_PRT_NEXT(); 7281
8471 } 7282 len = asc_prt_line(cp, leftlen, " %X:%c",
8472 len = asc_prt_line(cp, leftlen, "\n"); 7283 i,
8473 ASC_PRT_NEXT(); 7284 (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
8474 7285 'N');
8475 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done); 7286 ASC_PRT_NEXT();
8476 for (i = 0; i <= ADV_MAX_TID; i++) { 7287 }
8477 7288 len = asc_prt_line(cp, leftlen, "\n");
8478 AdvReadWordLram(iop_base, ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i), 7289 ASC_PRT_NEXT();
8479 lramword); 7290
8480 lramword &= ~0x8000; 7291 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
8481 7292 for (i = 0; i <= ADV_MAX_TID; i++) {
8482 if ((chip_scsi_id == i) || 7293
8483 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) || 7294 AdvReadWordLram(iop_base,
8484 ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) { 7295 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
8485 continue; 7296 lramword);
8486 } 7297 lramword &= ~0x8000;
8487 7298
8488 len = asc_prt_line(cp, leftlen, " %X:", i); 7299 if ((chip_scsi_id == i) ||
8489 ASC_PRT_NEXT(); 7300 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0) ||
8490 7301 ((sdtr_able & ADV_TID_TO_TIDMASK(i)) == 0)) {
8491 if ((lramword & 0x1F) == 0) /* Check for REQ/ACK Offset 0. */ 7302 continue;
8492 { 7303 }
8493 len = asc_prt_line(cp, leftlen, " Asynchronous"); 7304
8494 ASC_PRT_NEXT(); 7305 len = asc_prt_line(cp, leftlen, " %X:", i);
8495 } else 7306 ASC_PRT_NEXT();
8496 { 7307
8497 len = asc_prt_line(cp, leftlen, " Transfer Period Factor: "); 7308 if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
8498 ASC_PRT_NEXT(); 7309 len = asc_prt_line(cp, leftlen, " Asynchronous");
8499 7310 ASC_PRT_NEXT();
8500 if ((lramword & 0x1F00) == 0x1100) /* 80 Mhz */ 7311 } else {
8501 { 7312 len =
8502 len = asc_prt_line(cp, leftlen, "9 (80.0 Mhz),"); 7313 asc_prt_line(cp, leftlen,
8503 ASC_PRT_NEXT(); 7314 " Transfer Period Factor: ");
8504 } else if ((lramword & 0x1F00) == 0x1000) /* 40 Mhz */ 7315 ASC_PRT_NEXT();
8505 { 7316
8506 len = asc_prt_line(cp, leftlen, "10 (40.0 Mhz),"); 7317 if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
8507 ASC_PRT_NEXT(); 7318 len =
8508 } else /* 20 Mhz or below. */ 7319 asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
8509 { 7320 ASC_PRT_NEXT();
8510 period = (((lramword >> 8) * 25) + 50)/4; 7321 } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
8511 7322 len =
8512 if (period == 0) /* Should never happen. */ 7323 asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
8513 { 7324 ASC_PRT_NEXT();
8514 len = asc_prt_line(cp, leftlen, "%d (? Mhz), "); 7325 } else { /* 20 Mhz or below. */
8515 ASC_PRT_NEXT(); 7326
8516 } else 7327 period = (((lramword >> 8) * 25) + 50) / 4;
8517 { 7328
8518 len = asc_prt_line(cp, leftlen, 7329 if (period == 0) { /* Should never happen. */
8519 "%d (%d.%d Mhz),", 7330 len =
8520 period, 250/period, ASC_TENTHS(250, period)); 7331 asc_prt_line(cp, leftlen,
8521 ASC_PRT_NEXT(); 7332 "%d (? Mhz), ");
8522 } 7333 ASC_PRT_NEXT();
8523 } 7334 } else {
8524 7335 len = asc_prt_line(cp, leftlen,
8525 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d", 7336 "%d (%d.%d Mhz),",
8526 lramword & 0x1F); 7337 period, 250 / period,
8527 ASC_PRT_NEXT(); 7338 ASC_TENTHS(250,
8528 } 7339 period));
8529 7340 ASC_PRT_NEXT();
8530 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { 7341 }
8531 len = asc_prt_line(cp, leftlen, "*\n"); 7342 }
8532 renegotiate = 1; 7343
8533 } else 7344 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d",
8534 { 7345 lramword & 0x1F);
8535 len = asc_prt_line(cp, leftlen, "\n"); 7346 ASC_PRT_NEXT();
8536 } 7347 }
8537 ASC_PRT_NEXT(); 7348
8538 } 7349 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
7350 len = asc_prt_line(cp, leftlen, "*\n");
7351 renegotiate = 1;
7352 } else {
7353 len = asc_prt_line(cp, leftlen, "\n");
7354 }
7355 ASC_PRT_NEXT();
7356 }
8539 7357
8540 if (renegotiate) 7358 if (renegotiate) {
8541 { 7359 len = asc_prt_line(cp, leftlen,
8542 len = asc_prt_line(cp, leftlen, 7360 " * = Re-negotiation pending before next command.\n");
8543 " * = Re-negotiation pending before next command.\n"); 7361 ASC_PRT_NEXT();
8544 ASC_PRT_NEXT(); 7362 }
8545 }
8546 7363
8547 return totlen; 7364 return totlen;
8548} 7365}
8549 7366
8550/* 7367/*
@@ -8553,30 +7370,30 @@ asc_prt_adv_board_info(struct Scsi_Host *shp, char *cp, int cplen)
8553 * Copy proc information to a read buffer taking into account the current 7370 * Copy proc information to a read buffer taking into account the current
8554 * read offset in the file and the remaining space in the read buffer. 7371 * read offset in the file and the remaining space in the read buffer.
8555 */ 7372 */
8556STATIC int 7373static int
8557asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen, 7374asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
8558 char *cp, int cplen) 7375 char *cp, int cplen)
8559{ 7376{
8560 int cnt = 0; 7377 int cnt = 0;
8561 7378
8562 ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n", 7379 ASC_DBG3(2, "asc_proc_copy: offset %d, advoffset %d, cplen %d\n",
8563 (unsigned) offset, (unsigned) advoffset, cplen); 7380 (unsigned)offset, (unsigned)advoffset, cplen);
8564 if (offset <= advoffset) { 7381 if (offset <= advoffset) {
8565 /* Read offset below current offset, copy everything. */ 7382 /* Read offset below current offset, copy everything. */
8566 cnt = min(cplen, leftlen); 7383 cnt = min(cplen, leftlen);
8567 ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n", 7384 ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
8568 (ulong) curbuf, (ulong) cp, cnt); 7385 (ulong)curbuf, (ulong)cp, cnt);
8569 memcpy(curbuf, cp, cnt); 7386 memcpy(curbuf, cp, cnt);
8570 } else if (offset < advoffset + cplen) { 7387 } else if (offset < advoffset + cplen) {
8571 /* Read offset within current range, partial copy. */ 7388 /* Read offset within current range, partial copy. */
8572 cnt = (advoffset + cplen) - offset; 7389 cnt = (advoffset + cplen) - offset;
8573 cp = (cp + cplen) - cnt; 7390 cp = (cp + cplen) - cnt;
8574 cnt = min(cnt, leftlen); 7391 cnt = min(cnt, leftlen);
8575 ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n", 7392 ASC_DBG3(2, "asc_proc_copy: curbuf 0x%lx, cp 0x%lx, cnt %d\n",
8576 (ulong) curbuf, (ulong) cp, cnt); 7393 (ulong)curbuf, (ulong)cp, cnt);
8577 memcpy(curbuf, cp, cnt); 7394 memcpy(curbuf, cp, cnt);
8578 } 7395 }
8579 return cnt; 7396 return cnt;
8580} 7397}
8581 7398
8582/* 7399/*
@@ -8590,29 +7407,27 @@ asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
8590 * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack 7407 * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
8591 * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes. 7408 * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
8592 */ 7409 */
8593STATIC int 7410static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
8594asc_prt_line(char *buf, int buflen, char *fmt, ...)
8595{ 7411{
8596 va_list args; 7412 va_list args;
8597 int ret; 7413 int ret;
8598 char s[ASC_PRTLINE_SIZE]; 7414 char s[ASC_PRTLINE_SIZE];
8599 7415
8600 va_start(args, fmt); 7416 va_start(args, fmt);
8601 ret = vsprintf(s, fmt, args); 7417 ret = vsprintf(s, fmt, args);
8602 ASC_ASSERT(ret < ASC_PRTLINE_SIZE); 7418 ASC_ASSERT(ret < ASC_PRTLINE_SIZE);
8603 if (buf == NULL) { 7419 if (buf == NULL) {
8604 (void) printk(s); 7420 (void)printk(s);
8605 ret = 0; 7421 ret = 0;
8606 } else { 7422 } else {
8607 ret = min(buflen, ret); 7423 ret = min(buflen, ret);
8608 memcpy(buf, s, ret); 7424 memcpy(buf, s, ret);
8609 } 7425 }
8610 va_end(args); 7426 va_end(args);
8611 return ret; 7427 return ret;
8612} 7428}
8613#endif /* CONFIG_PROC_FS */ 7429#endif /* CONFIG_PROC_FS */
8614 7430
8615
8616/* 7431/*
8617 * --- Functions Required by the Asc Library 7432 * --- Functions Required by the Asc Library
8618 */ 7433 */
@@ -8623,31 +7438,28 @@ asc_prt_line(char *buf, int buflen, char *fmt, ...)
8623 * from a timer interrupt, because this function may be 7438 * from a timer interrupt, because this function may be
8624 * called when interrupts are disabled. 7439 * called when interrupts are disabled.
8625 */ 7440 */
8626STATIC void 7441static void DvcSleepMilliSecond(ADV_DCNT n)
8627DvcSleepMilliSecond(ADV_DCNT n)
8628{ 7442{
8629 ASC_DBG1(4, "DvcSleepMilliSecond: %lu\n", (ulong) n); 7443 ASC_DBG1(4, "DvcSleepMilliSecond: %lu\n", (ulong)n);
8630 mdelay(n); 7444 mdelay(n);
8631} 7445}
8632 7446
8633/* 7447/*
8634 * Currently and inline noop but leave as a placeholder. 7448 * Currently and inline noop but leave as a placeholder.
8635 * Leave DvcEnterCritical() as a noop placeholder. 7449 * Leave DvcEnterCritical() as a noop placeholder.
8636 */ 7450 */
8637STATIC inline ulong 7451static inline ulong DvcEnterCritical(void)
8638DvcEnterCritical(void)
8639{ 7452{
8640 return 0; 7453 return 0;
8641} 7454}
8642 7455
8643/* 7456/*
8644 * Critical sections are all protected by the board spinlock. 7457 * Critical sections are all protected by the board spinlock.
8645 * Leave DvcLeaveCritical() as a noop placeholder. 7458 * Leave DvcLeaveCritical() as a noop placeholder.
8646 */ 7459 */
8647STATIC inline void 7460static inline void DvcLeaveCritical(ulong flags)
8648DvcLeaveCritical(ulong flags)
8649{ 7461{
8650 return; 7462 return;
8651} 7463}
8652 7464
8653/* 7465/*
@@ -8660,20 +7472,20 @@ DvcLeaveCritical(ulong flags)
8660 * Description: 7472 * Description:
8661 * Output an ASC_SCSI_Q structure to the chip 7473 * Output an ASC_SCSI_Q structure to the chip
8662 */ 7474 */
8663STATIC void 7475static void
8664DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words) 7476DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
8665{ 7477{
8666 int i; 7478 int i;
8667 7479
8668 ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words); 7480 ASC_DBG_PRT_HEX(2, "DvcPutScsiQ", outbuf, 2 * words);
8669 AscSetChipLramAddr(iop_base, s_addr); 7481 AscSetChipLramAddr(iop_base, s_addr);
8670 for (i = 0; i < 2 * words; i += 2) { 7482 for (i = 0; i < 2 * words; i += 2) {
8671 if (i == 4 || i == 20) { 7483 if (i == 4 || i == 20) {
8672 continue; 7484 continue;
8673 } 7485 }
8674 outpw(iop_base + IOP_RAM_DATA, 7486 outpw(iop_base + IOP_RAM_DATA,
8675 ((ushort) outbuf[i + 1] << 8) | outbuf[i]); 7487 ((ushort)outbuf[i + 1] << 8) | outbuf[i]);
8676 } 7488 }
8677} 7489}
8678 7490
8679/* 7491/*
@@ -8686,52 +7498,46 @@ DvcPutScsiQ(PortAddr iop_base, ushort s_addr, uchar *outbuf, int words)
8686 * Description: 7498 * Description:
8687 * Input an ASC_QDONE_INFO structure from the chip 7499 * Input an ASC_QDONE_INFO structure from the chip
8688 */ 7500 */
8689STATIC void 7501static void
8690DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words) 7502DvcGetQinfo(PortAddr iop_base, ushort s_addr, uchar *inbuf, int words)
8691{ 7503{
8692 int i; 7504 int i;
8693 ushort word; 7505 ushort word;
8694 7506
8695 AscSetChipLramAddr(iop_base, s_addr); 7507 AscSetChipLramAddr(iop_base, s_addr);
8696 for (i = 0; i < 2 * words; i += 2) { 7508 for (i = 0; i < 2 * words; i += 2) {
8697 if (i == 10) { 7509 if (i == 10) {
8698 continue; 7510 continue;
8699 } 7511 }
8700 word = inpw(iop_base + IOP_RAM_DATA); 7512 word = inpw(iop_base + IOP_RAM_DATA);
8701 inbuf[i] = word & 0xff; 7513 inbuf[i] = word & 0xff;
8702 inbuf[i + 1] = (word >> 8) & 0xff; 7514 inbuf[i + 1] = (word >> 8) & 0xff;
8703 } 7515 }
8704 ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words); 7516 ASC_DBG_PRT_HEX(2, "DvcGetQinfo", inbuf, 2 * words);
8705} 7517}
8706 7518
8707/* 7519/*
8708 * Read a PCI configuration byte. 7520 * Read a PCI configuration byte.
8709 */ 7521 */
8710STATIC uchar __init 7522static uchar __init DvcReadPCIConfigByte(ASC_DVC_VAR *asc_dvc, ushort offset)
8711DvcReadPCIConfigByte(
8712 ASC_DVC_VAR *asc_dvc,
8713 ushort offset)
8714{ 7523{
8715#ifdef CONFIG_PCI 7524#ifdef CONFIG_PCI
8716 uchar byte_data; 7525 uchar byte_data;
8717 pci_read_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, &byte_data); 7526 pci_read_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, &byte_data);
8718 return byte_data; 7527 return byte_data;
8719#else /* !defined(CONFIG_PCI) */ 7528#else /* !defined(CONFIG_PCI) */
8720 return 0; 7529 return 0;
8721#endif /* !defined(CONFIG_PCI) */ 7530#endif /* !defined(CONFIG_PCI) */
8722} 7531}
8723 7532
8724/* 7533/*
8725 * Write a PCI configuration byte. 7534 * Write a PCI configuration byte.
8726 */ 7535 */
8727STATIC void __init 7536static void __init
8728DvcWritePCIConfigByte( 7537DvcWritePCIConfigByte(ASC_DVC_VAR *asc_dvc, ushort offset, uchar byte_data)
8729 ASC_DVC_VAR *asc_dvc,
8730 ushort offset,
8731 uchar byte_data)
8732{ 7538{
8733#ifdef CONFIG_PCI 7539#ifdef CONFIG_PCI
8734 pci_write_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, byte_data); 7540 pci_write_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, byte_data);
8735#endif /* CONFIG_PCI */ 7541#endif /* CONFIG_PCI */
8736} 7542}
8737 7543
@@ -8739,51 +7545,43 @@ DvcWritePCIConfigByte(
8739 * Return the BIOS address of the adapter at the specified 7545 * Return the BIOS address of the adapter at the specified
8740 * I/O port and with the specified bus type. 7546 * I/O port and with the specified bus type.
8741 */ 7547 */
8742STATIC ushort __init 7548static ushort __init AscGetChipBiosAddress(PortAddr iop_base, ushort bus_type)
8743AscGetChipBiosAddress(
8744 PortAddr iop_base,
8745 ushort bus_type)
8746{ 7549{
8747 ushort cfg_lsw; 7550 ushort cfg_lsw;
8748 ushort bios_addr; 7551 ushort bios_addr;
8749 7552
8750 /* 7553 /*
8751 * The PCI BIOS is re-located by the motherboard BIOS. Because 7554 * The PCI BIOS is re-located by the motherboard BIOS. Because
8752 * of this the driver can not determine where a PCI BIOS is 7555 * of this the driver can not determine where a PCI BIOS is
8753 * loaded and executes. 7556 * loaded and executes.
8754 */ 7557 */
8755 if (bus_type & ASC_IS_PCI) 7558 if (bus_type & ASC_IS_PCI) {
8756 { 7559 return (0);
8757 return(0); 7560 }
8758 }
8759
8760#ifdef CONFIG_ISA 7561#ifdef CONFIG_ISA
8761 if((bus_type & ASC_IS_EISA) != 0) 7562 if ((bus_type & ASC_IS_EISA) != 0) {
8762 { 7563 cfg_lsw = AscGetEisaChipCfg(iop_base);
8763 cfg_lsw = AscGetEisaChipCfg(iop_base); 7564 cfg_lsw &= 0x000F;
8764 cfg_lsw &= 0x000F; 7565 bios_addr = (ushort)(ASC_BIOS_MIN_ADDR +
8765 bios_addr = (ushort)(ASC_BIOS_MIN_ADDR + 7566 (cfg_lsw * ASC_BIOS_BANK_SIZE));
8766 (cfg_lsw * ASC_BIOS_BANK_SIZE)); 7567 return (bios_addr);
8767 return(bios_addr); 7568 } /* if */
8768 }/* if */
8769#endif /* CONFIG_ISA */ 7569#endif /* CONFIG_ISA */
8770 7570
8771 cfg_lsw = AscGetChipCfgLsw(iop_base); 7571 cfg_lsw = AscGetChipCfgLsw(iop_base);
8772 7572
8773 /* 7573 /*
8774 * ISA PnP uses the top bit as the 32K BIOS flag 7574 * ISA PnP uses the top bit as the 32K BIOS flag
8775 */ 7575 */
8776 if (bus_type == ASC_IS_ISAPNP) 7576 if (bus_type == ASC_IS_ISAPNP) {
8777 { 7577 cfg_lsw &= 0x7FFF;
8778 cfg_lsw &= 0x7FFF; 7578 }
8779 }/* if */ 7579 /* if */
8780 7580 bios_addr = (ushort)(((cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE) +
8781 bios_addr = (ushort)(((cfg_lsw >> 12) * ASC_BIOS_BANK_SIZE) + 7581 ASC_BIOS_MIN_ADDR);
8782 ASC_BIOS_MIN_ADDR); 7582 return (bios_addr);
8783 return(bios_addr);
8784} 7583}
8785 7584
8786
8787/* 7585/*
8788 * --- Functions Required by the Adv Library 7586 * --- Functions Required by the Adv Library
8789 */ 7587 */
@@ -8801,49 +7599,44 @@ AscGetChipBiosAddress(
8801 */ 7599 */
8802ADV_PADDR 7600ADV_PADDR
8803DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq, 7601DvcGetPhyAddr(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq,
8804 uchar *vaddr, ADV_SDCNT *lenp, int flag) 7602 uchar *vaddr, ADV_SDCNT *lenp, int flag)
8805{ 7603{
8806 ADV_PADDR paddr; 7604 ADV_PADDR paddr;
8807 7605
8808 paddr = virt_to_bus(vaddr); 7606 paddr = virt_to_bus(vaddr);
8809 7607
8810 ASC_DBG4(4, 7608 ASC_DBG4(4,
8811 "DvcGetPhyAddr: vaddr 0x%lx, lenp 0x%lx *lenp %lu, paddr 0x%lx\n", 7609 "DvcGetPhyAddr: vaddr 0x%lx, lenp 0x%lx *lenp %lu, paddr 0x%lx\n",
8812 (ulong) vaddr, (ulong) lenp, (ulong) *((ulong *) lenp), (ulong) paddr); 7610 (ulong)vaddr, (ulong)lenp, (ulong)*((ulong *)lenp),
7611 (ulong)paddr);
8813 7612
8814 return paddr; 7613 return paddr;
8815} 7614}
8816 7615
8817/* 7616/*
8818 * Read a PCI configuration byte. 7617 * Read a PCI configuration byte.
8819 */ 7618 */
8820STATIC uchar __init 7619static uchar __init DvcAdvReadPCIConfigByte(ADV_DVC_VAR *asc_dvc, ushort offset)
8821DvcAdvReadPCIConfigByte(
8822 ADV_DVC_VAR *asc_dvc,
8823 ushort offset)
8824{ 7620{
8825#ifdef CONFIG_PCI 7621#ifdef CONFIG_PCI
8826 uchar byte_data; 7622 uchar byte_data;
8827 pci_read_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, &byte_data); 7623 pci_read_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, &byte_data);
8828 return byte_data; 7624 return byte_data;
8829#else /* CONFIG_PCI */ 7625#else /* CONFIG_PCI */
8830 return 0; 7626 return 0;
8831#endif /* CONFIG_PCI */ 7627#endif /* CONFIG_PCI */
8832} 7628}
8833 7629
8834/* 7630/*
8835 * Write a PCI configuration byte. 7631 * Write a PCI configuration byte.
8836 */ 7632 */
8837STATIC void __init 7633static void __init
8838DvcAdvWritePCIConfigByte( 7634DvcAdvWritePCIConfigByte(ADV_DVC_VAR *asc_dvc, ushort offset, uchar byte_data)
8839 ADV_DVC_VAR *asc_dvc,
8840 ushort offset,
8841 uchar byte_data)
8842{ 7635{
8843#ifdef CONFIG_PCI 7636#ifdef CONFIG_PCI
8844 pci_write_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, byte_data); 7637 pci_write_config_byte(to_pci_dev(asc_dvc->cfg->dev), offset, byte_data);
8845#else /* CONFIG_PCI */ 7638#else /* CONFIG_PCI */
8846 return; 7639 return;
8847#endif /* CONFIG_PCI */ 7640#endif /* CONFIG_PCI */
8848} 7641}
8849 7642
@@ -8862,97 +7655,98 @@ DvcAdvWritePCIConfigByte(
8862 * Return the number of characters copied into 'cp'. No more than 7655 * Return the number of characters copied into 'cp'. No more than
8863 * 'cplen' characters will be copied to 'cp'. 7656 * 'cplen' characters will be copied to 'cp'.
8864 */ 7657 */
8865STATIC int 7658static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen)
8866asc_prt_board_stats(struct Scsi_Host *shp, char *cp, int cplen)
8867{ 7659{
8868 int leftlen; 7660 int leftlen;
8869 int totlen; 7661 int totlen;
8870 int len; 7662 int len;
8871 struct asc_stats *s; 7663 struct asc_stats *s;
8872 asc_board_t *boardp; 7664 asc_board_t *boardp;
8873
8874 leftlen = cplen;
8875 totlen = len = 0;
8876
8877 boardp = ASC_BOARDP(shp);
8878 s = &boardp->asc_stats;
8879
8880 len = asc_prt_line(cp, leftlen,
8881"\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n", shp->host_no);
8882 ASC_PRT_NEXT();
8883
8884 len = asc_prt_line(cp, leftlen,
8885" queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
8886 s->queuecommand, s->reset, s->biosparam, s->interrupt);
8887 ASC_PRT_NEXT();
8888
8889 len = asc_prt_line(cp, leftlen,
8890" callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
8891 s->callback, s->done, s->build_error, s->adv_build_noreq,
8892 s->adv_build_nosg);
8893 ASC_PRT_NEXT();
8894
8895 len = asc_prt_line(cp, leftlen,
8896" exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
8897 s->exe_noerror, s->exe_busy, s->exe_error, s->exe_unknown);
8898 ASC_PRT_NEXT();
8899
8900 /*
8901 * Display data transfer statistics.
8902 */
8903 if (s->cont_cnt > 0) {
8904 len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
8905 ASC_PRT_NEXT();
8906
8907 len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
8908 s->cont_xfer/2,
8909 ASC_TENTHS(s->cont_xfer, 2));
8910 ASC_PRT_NEXT();
8911
8912 /* Contiguous transfer average size */
8913 len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
8914 (s->cont_xfer/2)/s->cont_cnt,
8915 ASC_TENTHS((s->cont_xfer/2), s->cont_cnt));
8916 ASC_PRT_NEXT();
8917 }
8918 7665
8919 if (s->sg_cnt > 0) { 7666 leftlen = cplen;
7667 totlen = len = 0;
7668
7669 boardp = ASC_BOARDP(shost);
7670 s = &boardp->asc_stats;
7671
7672 len = asc_prt_line(cp, leftlen,
7673 "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
7674 shost->host_no);
7675 ASC_PRT_NEXT();
7676
7677 len = asc_prt_line(cp, leftlen,
7678 " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
7679 s->queuecommand, s->reset, s->biosparam,
7680 s->interrupt);
7681 ASC_PRT_NEXT();
7682
7683 len = asc_prt_line(cp, leftlen,
7684 " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
7685 s->callback, s->done, s->build_error,
7686 s->adv_build_noreq, s->adv_build_nosg);
7687 ASC_PRT_NEXT();
7688
7689 len = asc_prt_line(cp, leftlen,
7690 " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
7691 s->exe_noerror, s->exe_busy, s->exe_error,
7692 s->exe_unknown);
7693 ASC_PRT_NEXT();
7694
7695 /*
7696 * Display data transfer statistics.
7697 */
7698 if (s->cont_cnt > 0) {
7699 len = asc_prt_line(cp, leftlen, " cont_cnt %lu, ", s->cont_cnt);
7700 ASC_PRT_NEXT();
7701
7702 len = asc_prt_line(cp, leftlen, "cont_xfer %lu.%01lu kb ",
7703 s->cont_xfer / 2,
7704 ASC_TENTHS(s->cont_xfer, 2));
7705 ASC_PRT_NEXT();
7706
7707 /* Contiguous transfer average size */
7708 len = asc_prt_line(cp, leftlen, "avg_xfer %lu.%01lu kb\n",
7709 (s->cont_xfer / 2) / s->cont_cnt,
7710 ASC_TENTHS((s->cont_xfer / 2), s->cont_cnt));
7711 ASC_PRT_NEXT();
7712 }
8920 7713
8921 len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ", 7714 if (s->sg_cnt > 0) {
8922 s->sg_cnt, s->sg_elem);
8923 ASC_PRT_NEXT();
8924 7715
8925 len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n", 7716 len = asc_prt_line(cp, leftlen, " sg_cnt %lu, sg_elem %lu, ",
8926 s->sg_xfer/2, 7717 s->sg_cnt, s->sg_elem);
8927 ASC_TENTHS(s->sg_xfer, 2)); 7718 ASC_PRT_NEXT();
8928 ASC_PRT_NEXT();
8929 7719
8930 /* Scatter gather transfer statistics */ 7720 len = asc_prt_line(cp, leftlen, "sg_xfer %lu.%01lu kb\n",
8931 len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ", 7721 s->sg_xfer / 2, ASC_TENTHS(s->sg_xfer, 2));
8932 s->sg_elem/s->sg_cnt, 7722 ASC_PRT_NEXT();
8933 ASC_TENTHS(s->sg_elem, s->sg_cnt));
8934 ASC_PRT_NEXT();
8935 7723
8936 len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ", 7724 /* Scatter gather transfer statistics */
8937 (s->sg_xfer/2)/s->sg_elem, 7725 len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ",
8938 ASC_TENTHS((s->sg_xfer/2), s->sg_elem)); 7726 s->sg_elem / s->sg_cnt,
8939 ASC_PRT_NEXT(); 7727 ASC_TENTHS(s->sg_elem, s->sg_cnt));
7728 ASC_PRT_NEXT();
8940 7729
8941 len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n", 7730 len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ",
8942 (s->sg_xfer/2)/s->sg_cnt, 7731 (s->sg_xfer / 2) / s->sg_elem,
8943 ASC_TENTHS((s->sg_xfer/2), s->sg_cnt)); 7732 ASC_TENTHS((s->sg_xfer / 2), s->sg_elem));
8944 ASC_PRT_NEXT(); 7733 ASC_PRT_NEXT();
8945 }
8946 7734
8947 /* 7735 len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n",
8948 * Display request queuing statistics. 7736 (s->sg_xfer / 2) / s->sg_cnt,
8949 */ 7737 ASC_TENTHS((s->sg_xfer / 2), s->sg_cnt));
8950 len = asc_prt_line(cp, leftlen, 7738 ASC_PRT_NEXT();
8951" Active and Waiting Request Queues (Time Unit: %d HZ):\n", HZ); 7739 }
8952 ASC_PRT_NEXT();
8953 7740
7741 /*
7742 * Display request queuing statistics.
7743 */
7744 len = asc_prt_line(cp, leftlen,
7745 " Active and Waiting Request Queues (Time Unit: %d HZ):\n",
7746 HZ);
7747 ASC_PRT_NEXT();
8954 7748
8955 return totlen; 7749 return totlen;
8956} 7750}
8957 7751
8958/* 7752/*
@@ -8967,70 +7761,89 @@ asc_prt_board_stats(struct Scsi_Host *shp, char *cp, int cplen)
8967 * Return the number of characters copied into 'cp'. No more than 7761 * Return the number of characters copied into 'cp'. No more than
8968 * 'cplen' characters will be copied to 'cp'. 7762 * 'cplen' characters will be copied to 'cp'.
8969 */ 7763 */
8970STATIC int 7764static int
8971asc_prt_target_stats(struct Scsi_Host *shp, int tgt_id, char *cp, int cplen) 7765asc_prt_target_stats(struct Scsi_Host *shost, int tgt_id, char *cp, int cplen)
8972{ 7766{
8973 int leftlen; 7767 int leftlen;
8974 int totlen; 7768 int totlen;
8975 int len; 7769 int len;
8976 struct asc_stats *s; 7770 struct asc_stats *s;
8977 ushort chip_scsi_id; 7771 ushort chip_scsi_id;
8978 asc_board_t *boardp; 7772 asc_board_t *boardp;
8979 asc_queue_t *active; 7773 asc_queue_t *active;
8980 asc_queue_t *waiting; 7774 asc_queue_t *waiting;
8981
8982 leftlen = cplen;
8983 totlen = len = 0;
8984
8985 boardp = ASC_BOARDP(shp);
8986 s = &boardp->asc_stats;
8987
8988 active = &ASC_BOARDP(shp)->active;
8989 waiting = &ASC_BOARDP(shp)->waiting;
8990
8991 if (ASC_NARROW_BOARD(boardp)) {
8992 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
8993 } else {
8994 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
8995 }
8996 7775
8997 if ((chip_scsi_id == tgt_id) || 7776 leftlen = cplen;
8998 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(tgt_id)) == 0)) { 7777 totlen = len = 0;
8999 return 0; 7778
9000 } 7779 boardp = ASC_BOARDP(shost);
7780 s = &boardp->asc_stats;
7781
7782 active = &ASC_BOARDP(shost)->active;
7783 waiting = &ASC_BOARDP(shost)->waiting;
7784
7785 if (ASC_NARROW_BOARD(boardp)) {
7786 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
7787 } else {
7788 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
7789 }
7790
7791 if ((chip_scsi_id == tgt_id) ||
7792 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(tgt_id)) == 0)) {
7793 return 0;
7794 }
9001 7795
9002 do { 7796 do {
9003 if (active->q_tot_cnt[tgt_id] > 0 || waiting->q_tot_cnt[tgt_id] > 0) { 7797 if (active->q_tot_cnt[tgt_id] > 0
9004 len = asc_prt_line(cp, leftlen, " target %d\n", tgt_id); 7798 || waiting->q_tot_cnt[tgt_id] > 0) {
9005 ASC_PRT_NEXT(); 7799 len = asc_prt_line(cp, leftlen, " target %d\n", tgt_id);
9006 7800 ASC_PRT_NEXT();
9007 len = asc_prt_line(cp, leftlen, 7801
9008" active: cnt [cur %d, max %d, tot %u], time [min %d, max %d, avg %lu.%01lu]\n", 7802 len = asc_prt_line(cp, leftlen,
9009 active->q_cur_cnt[tgt_id], active->q_max_cnt[tgt_id], 7803 " active: cnt [cur %d, max %d, tot %u], time [min %d, max %d, avg %lu.%01lu]\n",
9010 active->q_tot_cnt[tgt_id], 7804 active->q_cur_cnt[tgt_id],
9011 active->q_min_tim[tgt_id], active->q_max_tim[tgt_id], 7805 active->q_max_cnt[tgt_id],
9012 (active->q_tot_cnt[tgt_id] == 0) ? 0 : 7806 active->q_tot_cnt[tgt_id],
9013 (active->q_tot_tim[tgt_id]/active->q_tot_cnt[tgt_id]), 7807 active->q_min_tim[tgt_id],
9014 (active->q_tot_cnt[tgt_id] == 0) ? 0 : 7808 active->q_max_tim[tgt_id],
9015 ASC_TENTHS(active->q_tot_tim[tgt_id], 7809 (active->q_tot_cnt[tgt_id] ==
9016 active->q_tot_cnt[tgt_id])); 7810 0) ? 0 : (active->
9017 ASC_PRT_NEXT(); 7811 q_tot_tim[tgt_id] /
9018 7812 active->
9019 len = asc_prt_line(cp, leftlen, 7813 q_tot_cnt[tgt_id]),
9020" waiting: cnt [cur %d, max %d, tot %u], time [min %u, max %u, avg %lu.%01lu]\n", 7814 (active->q_tot_cnt[tgt_id] ==
9021 waiting->q_cur_cnt[tgt_id], waiting->q_max_cnt[tgt_id], 7815 0) ? 0 : ASC_TENTHS(active->
9022 waiting->q_tot_cnt[tgt_id], 7816 q_tot_tim
9023 waiting->q_min_tim[tgt_id], waiting->q_max_tim[tgt_id], 7817 [tgt_id],
9024 (waiting->q_tot_cnt[tgt_id] == 0) ? 0 : 7818 active->
9025 (waiting->q_tot_tim[tgt_id]/waiting->q_tot_cnt[tgt_id]), 7819 q_tot_cnt
9026 (waiting->q_tot_cnt[tgt_id] == 0) ? 0 : 7820 [tgt_id]));
9027 ASC_TENTHS(waiting->q_tot_tim[tgt_id], 7821 ASC_PRT_NEXT();
9028 waiting->q_tot_cnt[tgt_id])); 7822
9029 ASC_PRT_NEXT(); 7823 len = asc_prt_line(cp, leftlen,
9030 } 7824 " waiting: cnt [cur %d, max %d, tot %u], time [min %u, max %u, avg %lu.%01lu]\n",
9031 } while (0); 7825 waiting->q_cur_cnt[tgt_id],
9032 7826 waiting->q_max_cnt[tgt_id],
9033 return totlen; 7827 waiting->q_tot_cnt[tgt_id],
7828 waiting->q_min_tim[tgt_id],
7829 waiting->q_max_tim[tgt_id],
7830 (waiting->q_tot_cnt[tgt_id] ==
7831 0) ? 0 : (waiting->
7832 q_tot_tim[tgt_id] /
7833 waiting->
7834 q_tot_cnt[tgt_id]),
7835 (waiting->q_tot_cnt[tgt_id] ==
7836 0) ? 0 : ASC_TENTHS(waiting->
7837 q_tot_tim
7838 [tgt_id],
7839 waiting->
7840 q_tot_cnt
7841 [tgt_id]));
7842 ASC_PRT_NEXT();
7843 }
7844 } while (0);
7845
7846 return totlen;
9034} 7847}
9035#endif /* CONFIG_PROC_FS */ 7848#endif /* CONFIG_PROC_FS */
9036#endif /* ADVANSYS_STATS */ 7849#endif /* ADVANSYS_STATS */
@@ -9039,207 +7852,181 @@ asc_prt_target_stats(struct Scsi_Host *shp, int tgt_id, char *cp, int cplen)
9039/* 7852/*
9040 * asc_prt_scsi_host() 7853 * asc_prt_scsi_host()
9041 */ 7854 */
9042STATIC void 7855static void asc_prt_scsi_host(struct Scsi_Host *s)
9043asc_prt_scsi_host(struct Scsi_Host *s)
9044{ 7856{
9045 asc_board_t *boardp; 7857 asc_board_t *boardp;
9046 7858
9047 boardp = ASC_BOARDP(s); 7859 boardp = ASC_BOARDP(s);
9048 7860
9049 printk("Scsi_Host at addr 0x%lx\n", (ulong) s); 7861 printk("Scsi_Host at addr 0x%lx\n", (ulong)s);
9050 printk( 7862 printk(" host_busy %u, host_no %d, last_reset %d,\n",
9051" host_busy %u, host_no %d, last_reset %d,\n", 7863 s->host_busy, s->host_no, (unsigned)s->last_reset);
9052 s->host_busy, s->host_no, 7864
9053 (unsigned) s->last_reset); 7865 printk(" base 0x%lx, io_port 0x%lx, n_io_port %u, irq 0x%x,\n",
9054 7866 (ulong)s->base, (ulong)s->io_port, s->n_io_port, s->irq);
9055 printk( 7867
9056" base 0x%lx, io_port 0x%lx, n_io_port %u, irq 0x%x,\n", 7868 printk(" dma_channel %d, this_id %d, can_queue %d,\n",
9057 (ulong) s->base, (ulong) s->io_port, s->n_io_port, s->irq); 7869 s->dma_channel, s->this_id, s->can_queue);
9058 7870
9059 printk( 7871 printk(" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
9060" dma_channel %d, this_id %d, can_queue %d,\n", 7872 s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma);
9061 s->dma_channel, s->this_id, s->can_queue); 7873
9062 7874 if (ASC_NARROW_BOARD(boardp)) {
9063 printk( 7875 asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var);
9064" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n", 7876 asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
9065 s->cmd_per_lun, s->sg_tablesize, s->unchecked_isa_dma); 7877 } else {
9066 7878 asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
9067 if (ASC_NARROW_BOARD(boardp)) { 7879 asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
9068 asc_prt_asc_dvc_var(&ASC_BOARDP(s)->dvc_var.asc_dvc_var); 7880 }
9069 asc_prt_asc_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.asc_dvc_cfg);
9070 } else {
9071 asc_prt_adv_dvc_var(&ASC_BOARDP(s)->dvc_var.adv_dvc_var);
9072 asc_prt_adv_dvc_cfg(&ASC_BOARDP(s)->dvc_cfg.adv_dvc_cfg);
9073 }
9074} 7881}
9075 7882
9076/* 7883/*
9077 * asc_prt_scsi_cmnd() 7884 * asc_prt_scsi_cmnd()
9078 */ 7885 */
9079STATIC void 7886static void asc_prt_scsi_cmnd(struct scsi_cmnd *s)
9080asc_prt_scsi_cmnd(struct scsi_cmnd *s)
9081{ 7887{
9082 printk("struct scsi_cmnd at addr 0x%lx\n", (ulong) s); 7888 printk("struct scsi_cmnd at addr 0x%lx\n", (ulong)s);
9083 7889
9084 printk( 7890 printk(" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n",
9085" host 0x%lx, device 0x%lx, target %u, lun %u, channel %u,\n", 7891 (ulong)s->device->host, (ulong)s->device, s->device->id,
9086 (ulong) s->device->host, (ulong) s->device, s->device->id, s->device->lun, 7892 s->device->lun, s->device->channel);
9087 s->device->channel);
9088 7893
9089 asc_prt_hex(" CDB", s->cmnd, s->cmd_len); 7894 asc_prt_hex(" CDB", s->cmnd, s->cmd_len);
9090 7895
9091 printk ( 7896 printk("sc_data_direction %u, resid %d\n",
9092"sc_data_direction %u, resid %d\n", 7897 s->sc_data_direction, s->resid);
9093 s->sc_data_direction, s->resid);
9094 7898
9095 printk( 7899 printk(" use_sg %u, sglist_len %u\n", s->use_sg, s->sglist_len);
9096" use_sg %u, sglist_len %u\n",
9097 s->use_sg, s->sglist_len);
9098 7900
9099 printk( 7901 printk(" serial_number 0x%x, retries %d, allowed %d\n",
9100" serial_number 0x%x, retries %d, allowed %d\n", 7902 (unsigned)s->serial_number, s->retries, s->allowed);
9101 (unsigned) s->serial_number, s->retries, s->allowed);
9102 7903
9103 printk( 7904 printk(" timeout_per_command %d\n", s->timeout_per_command);
9104" timeout_per_command %d\n",
9105 s->timeout_per_command);
9106 7905
9107 printk( 7906 printk
9108" scsi_done 0x%lx, done 0x%lx, host_scribble 0x%lx, result 0x%x\n", 7907 (" scsi_done 0x%lx, done 0x%lx, host_scribble 0x%lx, result 0x%x\n",
9109 (ulong) s->scsi_done, (ulong) s->done, 7908 (ulong)s->scsi_done, (ulong)s->done, (ulong)s->host_scribble,
9110 (ulong) s->host_scribble, s->result); 7909 s->result);
9111 7910
9112 printk( 7911 printk(" tag %u, pid %u\n", (unsigned)s->tag, (unsigned)s->pid);
9113" tag %u, pid %u\n",
9114 (unsigned) s->tag, (unsigned) s->pid);
9115} 7912}
9116 7913
9117/* 7914/*
9118 * asc_prt_asc_dvc_var() 7915 * asc_prt_asc_dvc_var()
9119 */ 7916 */
9120STATIC void 7917static void asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
9121asc_prt_asc_dvc_var(ASC_DVC_VAR *h)
9122{ 7918{
9123 printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong) h); 7919 printk("ASC_DVC_VAR at addr 0x%lx\n", (ulong)h);
9124 7920
9125 printk( 7921 printk
9126" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl %d,\n", 7922 (" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl %d,\n",
9127 h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl); 7923 h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
9128 7924
9129 printk( 7925 printk
9130" bus_type %d, isr_callback 0x%lx, exe_callback 0x%lx, init_sdtr 0x%x,\n", 7926 (" bus_type %d, isr_callback 0x%lx, exe_callback 0x%lx, init_sdtr 0x%x,\n",
9131 h->bus_type, (ulong) h->isr_callback, (ulong) h->exe_callback, 7927 h->bus_type, (ulong)h->isr_callback, (ulong)h->exe_callback,
9132 (unsigned) h->init_sdtr); 7928 (unsigned)h->init_sdtr);
9133 7929
9134 printk( 7930 printk
9135" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, chip_no 0x%x,\n", 7931 (" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, chip_no 0x%x,\n",
9136 (unsigned) h->sdtr_done, (unsigned) h->use_tagged_qng, 7932 (unsigned)h->sdtr_done, (unsigned)h->use_tagged_qng,
9137 (unsigned) h->unit_not_ready, (unsigned) h->chip_no); 7933 (unsigned)h->unit_not_ready, (unsigned)h->chip_no);
9138 7934
9139 printk( 7935 printk
9140" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait %u,\n", 7936 (" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait %u,\n",
9141 (unsigned) h->queue_full_or_busy, (unsigned) h->start_motor, 7937 (unsigned)h->queue_full_or_busy, (unsigned)h->start_motor,
9142 (unsigned) h->scsi_reset_wait); 7938 (unsigned)h->scsi_reset_wait);
9143 7939
9144 printk( 7940 printk
9145" is_in_int %u, max_total_qng %u, cur_total_qng %u, in_critical_cnt %u,\n", 7941 (" is_in_int %u, max_total_qng %u, cur_total_qng %u, in_critical_cnt %u,\n",
9146 (unsigned) h->is_in_int, (unsigned) h->max_total_qng, 7942 (unsigned)h->is_in_int, (unsigned)h->max_total_qng,
9147 (unsigned) h->cur_total_qng, (unsigned) h->in_critical_cnt); 7943 (unsigned)h->cur_total_qng, (unsigned)h->in_critical_cnt);
9148 7944
9149 printk( 7945 printk
9150" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, pci_fix_asyn_xfer 0x%x,\n", 7946 (" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, pci_fix_asyn_xfer 0x%x,\n",
9151 (unsigned) h->last_q_shortage, (unsigned) h->init_state, 7947 (unsigned)h->last_q_shortage, (unsigned)h->init_state,
9152 (unsigned) h->no_scam, (unsigned) h->pci_fix_asyn_xfer); 7948 (unsigned)h->no_scam, (unsigned)h->pci_fix_asyn_xfer);
9153 7949
9154 printk( 7950 printk(" cfg 0x%lx, irq_no 0x%x\n", (ulong)h->cfg, (unsigned)h->irq_no);
9155" cfg 0x%lx, irq_no 0x%x\n",
9156 (ulong) h->cfg, (unsigned) h->irq_no);
9157} 7951}
9158 7952
9159/* 7953/*
9160 * asc_prt_asc_dvc_cfg() 7954 * asc_prt_asc_dvc_cfg()
9161 */ 7955 */
9162STATIC void 7956static void asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
9163asc_prt_asc_dvc_cfg(ASC_DVC_CFG *h)
9164{ 7957{
9165 printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong) h); 7958 printk("ASC_DVC_CFG at addr 0x%lx\n", (ulong)h);
9166 7959
9167 printk( 7960 printk(" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
9168" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n", 7961 h->can_tagged_qng, h->cmd_qng_enabled);
9169 h->can_tagged_qng, h->cmd_qng_enabled); 7962 printk(" disc_enable 0x%x, sdtr_enable 0x%x,\n",
9170 printk( 7963 h->disc_enable, h->sdtr_enable);
9171" disc_enable 0x%x, sdtr_enable 0x%x,\n", 7964
9172 h->disc_enable, h->sdtr_enable); 7965 printk
9173 7966 (" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n",
9174 printk( 7967 h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel,
9175" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, chip_version %d,\n", 7968 h->chip_version);
9176 h->chip_scsi_id, h->isa_dma_speed, h->isa_dma_channel, 7969
9177 h->chip_version); 7970 printk
9178 7971 (" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n",
9179 printk( 7972 to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version,
9180" pci_device_id %d, lib_serial_no %u, lib_version %u, mcode_date 0x%x,\n", 7973 h->mcode_date);
9181 to_pci_dev(h->dev)->device, h->lib_serial_no, h->lib_version, 7974
9182 h->mcode_date); 7975 printk(" mcode_version %d, overrun_buf 0x%lx\n",
9183 7976 h->mcode_version, (ulong)h->overrun_buf);
9184 printk(
9185" mcode_version %d, overrun_buf 0x%lx\n",
9186 h->mcode_version, (ulong) h->overrun_buf);
9187} 7977}
9188 7978
9189/* 7979/*
9190 * asc_prt_asc_scsi_q() 7980 * asc_prt_asc_scsi_q()
9191 */ 7981 */
9192STATIC void 7982static void asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
9193asc_prt_asc_scsi_q(ASC_SCSI_Q *q)
9194{ 7983{
9195 ASC_SG_HEAD *sgp; 7984 ASC_SG_HEAD *sgp;
9196 int i; 7985 int i;
9197 7986
9198 printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong) q); 7987 printk("ASC_SCSI_Q at addr 0x%lx\n", (ulong)q);
9199 7988
9200 printk( 7989 printk
9201" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n", 7990 (" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
9202 q->q2.target_ix, q->q1.target_lun, 7991 q->q2.target_ix, q->q1.target_lun, (ulong)q->q2.srb_ptr,
9203 (ulong) q->q2.srb_ptr, q->q2.tag_code); 7992 q->q2.tag_code);
9204 7993
9205 printk( 7994 printk
9206" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n", 7995 (" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
9207 (ulong) le32_to_cpu(q->q1.data_addr), 7996 (ulong)le32_to_cpu(q->q1.data_addr),
9208 (ulong) le32_to_cpu(q->q1.data_cnt), 7997 (ulong)le32_to_cpu(q->q1.data_cnt),
9209 (ulong) le32_to_cpu(q->q1.sense_addr), q->q1.sense_len); 7998 (ulong)le32_to_cpu(q->q1.sense_addr), q->q1.sense_len);
9210 7999
9211 printk( 8000 printk(" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
9212" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n", 8001 (ulong)q->cdbptr, q->q2.cdb_len,
9213 (ulong) q->cdbptr, q->q2.cdb_len, 8002 (ulong)q->sg_head, q->q1.sg_queue_cnt);
9214 (ulong) q->sg_head, q->q1.sg_queue_cnt); 8003
9215 8004 if (q->sg_head) {
9216 if (q->sg_head) { 8005 sgp = q->sg_head;
9217 sgp = q->sg_head; 8006 printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong)sgp);
9218 printk("ASC_SG_HEAD at addr 0x%lx\n", (ulong) sgp); 8007 printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt,
9219 printk(" entry_cnt %u, queue_cnt %u\n", sgp->entry_cnt, sgp->queue_cnt); 8008 sgp->queue_cnt);
9220 for (i = 0; i < sgp->entry_cnt; i++) { 8009 for (i = 0; i < sgp->entry_cnt; i++) {
9221 printk(" [%u]: addr 0x%lx, bytes %lu\n", 8010 printk(" [%u]: addr 0x%lx, bytes %lu\n",
9222 i, (ulong) le32_to_cpu(sgp->sg_list[i].addr), 8011 i, (ulong)le32_to_cpu(sgp->sg_list[i].addr),
9223 (ulong) le32_to_cpu(sgp->sg_list[i].bytes)); 8012 (ulong)le32_to_cpu(sgp->sg_list[i].bytes));
9224 } 8013 }
9225 8014
9226 } 8015 }
9227} 8016}
9228 8017
9229/* 8018/*
9230 * asc_prt_asc_qdone_info() 8019 * asc_prt_asc_qdone_info()
9231 */ 8020 */
9232STATIC void 8021static void asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
9233asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
9234{ 8022{
9235 printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong) q); 8023 printk("ASC_QDONE_INFO at addr 0x%lx\n", (ulong)q);
9236 printk( 8024 printk(" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
9237" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n", 8025 (ulong)q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len,
9238 (ulong) q->d2.srb_ptr, q->d2.target_ix, q->d2.cdb_len, 8026 q->d2.tag_code);
9239 q->d2.tag_code); 8027 printk
9240 printk( 8028 (" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
9241" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n", 8029 q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
9242 q->d3.done_stat, q->d3.host_stat, q->d3.scsi_stat, q->d3.scsi_msg);
9243} 8030}
9244 8031
9245/* 8032/*
@@ -9247,41 +8034,33 @@ asc_prt_asc_qdone_info(ASC_QDONE_INFO *q)
9247 * 8034 *
9248 * Display an ADV_DVC_VAR structure. 8035 * Display an ADV_DVC_VAR structure.
9249 */ 8036 */
9250STATIC void 8037static void asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
9251asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
9252{ 8038{
9253 printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong) h); 8039 printk(" ADV_DVC_VAR at addr 0x%lx\n", (ulong)h);
9254 8040
9255 printk( 8041 printk(" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
9256" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n", 8042 (ulong)h->iop_base, h->err_code, (unsigned)h->ultra_able);
9257 (ulong) h->iop_base, h->err_code, (unsigned) h->ultra_able); 8043
9258 8044 printk(" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n",
9259 printk( 8045 (ulong)h->isr_callback, (unsigned)h->sdtr_able,
9260" isr_callback 0x%lx, sdtr_able 0x%x, wdtr_able 0x%x\n", 8046 (unsigned)h->wdtr_able);
9261 (ulong) h->isr_callback, (unsigned) h->sdtr_able, 8047
9262 (unsigned) h->wdtr_able); 8048 printk(" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n",
9263 8049 (unsigned)h->start_motor,
9264 printk( 8050 (unsigned)h->scsi_reset_wait, (unsigned)h->irq_no);
9265" start_motor 0x%x, scsi_reset_wait 0x%x, irq_no 0x%x,\n", 8051
9266 (unsigned) h->start_motor, 8052 printk(" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
9267 (unsigned) h->scsi_reset_wait, (unsigned) h->irq_no); 8053 (unsigned)h->max_host_qng, (unsigned)h->max_dvc_qng,
9268 8054 (ulong)h->carr_freelist);
9269 printk( 8055
9270" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n", 8056 printk(" icq_sp 0x%lx, irq_sp 0x%lx\n",
9271 (unsigned) h->max_host_qng, (unsigned) h->max_dvc_qng, 8057 (ulong)h->icq_sp, (ulong)h->irq_sp);
9272 (ulong) h->carr_freelist); 8058
9273 8059 printk(" no_scam 0x%x, tagqng_able 0x%x\n",
9274 printk( 8060 (unsigned)h->no_scam, (unsigned)h->tagqng_able);
9275" icq_sp 0x%lx, irq_sp 0x%lx\n", 8061
9276 (ulong) h->icq_sp, (ulong) h->irq_sp); 8062 printk(" chip_scsi_id 0x%x, cfg 0x%lx\n",
9277 8063 (unsigned)h->chip_scsi_id, (ulong)h->cfg);
9278 printk(
9279" no_scam 0x%x, tagqng_able 0x%x\n",
9280 (unsigned) h->no_scam, (unsigned) h->tagqng_able);
9281
9282 printk(
9283" chip_scsi_id 0x%x, cfg 0x%lx\n",
9284 (unsigned) h->chip_scsi_id, (ulong) h->cfg);
9285} 8064}
9286 8065
9287/* 8066/*
@@ -9289,26 +8068,21 @@ asc_prt_adv_dvc_var(ADV_DVC_VAR *h)
9289 * 8068 *
9290 * Display an ADV_DVC_CFG structure. 8069 * Display an ADV_DVC_CFG structure.
9291 */ 8070 */
9292STATIC void 8071static void asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
9293asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
9294{ 8072{
9295 printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong) h); 8073 printk(" ADV_DVC_CFG at addr 0x%lx\n", (ulong)h);
9296 8074
9297 printk( 8075 printk(" disc_enable 0x%x, termination 0x%x\n",
9298" disc_enable 0x%x, termination 0x%x\n", 8076 h->disc_enable, h->termination);
9299 h->disc_enable, h->termination);
9300 8077
9301 printk( 8078 printk(" chip_version 0x%x, mcode_date 0x%x\n",
9302" chip_version 0x%x, mcode_date 0x%x\n", 8079 h->chip_version, h->mcode_date);
9303 h->chip_version, h->mcode_date);
9304 8080
9305 printk( 8081 printk(" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n",
9306" mcode_version 0x%x, pci_device_id 0x%x, lib_version %u\n", 8082 h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
9307 h->mcode_version, to_pci_dev(h->dev)->device, h->lib_version);
9308 8083
9309 printk( 8084 printk(" control_flag 0x%x, pci_slot_info 0x%x\n",
9310" control_flag 0x%x, pci_slot_info 0x%x\n", 8085 h->control_flag, h->pci_slot_info);
9311 h->control_flag, h->pci_slot_info);
9312} 8086}
9313 8087
9314/* 8088/*
@@ -9316,60 +8090,54 @@ asc_prt_adv_dvc_cfg(ADV_DVC_CFG *h)
9316 * 8090 *
9317 * Display an ADV_SCSI_REQ_Q structure. 8091 * Display an ADV_SCSI_REQ_Q structure.
9318 */ 8092 */
9319STATIC void 8093static void asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
9320asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
9321{ 8094{
9322 int sg_blk_cnt; 8095 int sg_blk_cnt;
9323 struct asc_sg_block *sg_ptr; 8096 struct asc_sg_block *sg_ptr;
9324 8097
9325 printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong) q); 8098 printk("ADV_SCSI_REQ_Q at addr 0x%lx\n", (ulong)q);
9326 8099
9327 printk( 8100 printk(" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
9328" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n", 8101 q->target_id, q->target_lun, (ulong)q->srb_ptr, q->a_flag);
9329 q->target_id, q->target_lun, (ulong) q->srb_ptr, q->a_flag); 8102
9330 8103 printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
9331 printk(" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n", 8104 q->cntl, (ulong)le32_to_cpu(q->data_addr), (ulong)q->vdata_addr);
9332 q->cntl, (ulong) le32_to_cpu(q->data_addr), (ulong) q->vdata_addr); 8105
9333 8106 printk(" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
9334 printk( 8107 (ulong)le32_to_cpu(q->data_cnt),
9335" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n", 8108 (ulong)le32_to_cpu(q->sense_addr), q->sense_len);
9336 (ulong) le32_to_cpu(q->data_cnt), 8109
9337 (ulong) le32_to_cpu(q->sense_addr), q->sense_len); 8110 printk
9338 8111 (" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
9339 printk( 8112 q->cdb_len, q->done_status, q->host_status, q->scsi_status);
9340" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n", 8113
9341 q->cdb_len, q->done_status, q->host_status, q->scsi_status); 8114 printk(" sg_working_ix 0x%x, target_cmd %u\n",
9342 8115 q->sg_working_ix, q->target_cmd);
9343 printk( 8116
9344" sg_working_ix 0x%x, target_cmd %u\n", 8117 printk(" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
9345 q->sg_working_ix, q->target_cmd); 8118 (ulong)le32_to_cpu(q->scsiq_rptr),
9346 8119 (ulong)le32_to_cpu(q->sg_real_addr), (ulong)q->sg_list_ptr);
9347 printk( 8120
9348" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n", 8121 /* Display the request's ADV_SG_BLOCK structures. */
9349 (ulong) le32_to_cpu(q->scsiq_rptr), 8122 if (q->sg_list_ptr != NULL) {
9350 (ulong) le32_to_cpu(q->sg_real_addr), (ulong) q->sg_list_ptr); 8123 sg_blk_cnt = 0;
9351 8124 while (1) {
9352 /* Display the request's ADV_SG_BLOCK structures. */ 8125 /*
9353 if (q->sg_list_ptr != NULL) 8126 * 'sg_ptr' is a physical address. Convert it to a virtual
9354 { 8127 * address by indexing 'sg_blk_cnt' into the virtual address
9355 sg_blk_cnt = 0; 8128 * array 'sg_list_ptr'.
9356 while (1) { 8129 *
9357 /* 8130 * XXX - Assumes all SG physical blocks are virtually contiguous.
9358 * 'sg_ptr' is a physical address. Convert it to a virtual 8131 */
9359 * address by indexing 'sg_blk_cnt' into the virtual address 8132 sg_ptr =
9360 * array 'sg_list_ptr'. 8133 &(((ADV_SG_BLOCK *)(q->sg_list_ptr))[sg_blk_cnt]);
9361 * 8134 asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
9362 * XXX - Assumes all SG physical blocks are virtually contiguous. 8135 if (sg_ptr->sg_ptr == 0) {
9363 */ 8136 break;
9364 sg_ptr = &(((ADV_SG_BLOCK *) (q->sg_list_ptr))[sg_blk_cnt]); 8137 }
9365 asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr); 8138 sg_blk_cnt++;
9366 if (sg_ptr->sg_ptr == 0) 8139 }
9367 { 8140 }
9368 break;
9369 }
9370 sg_blk_cnt++;
9371 }
9372 }
9373} 8141}
9374 8142
9375/* 8143/*
@@ -9377,24 +8145,23 @@ asc_prt_adv_scsi_req_q(ADV_SCSI_REQ_Q *q)
9377 * 8145 *
9378 * Display an ADV_SG_BLOCK structure. 8146 * Display an ADV_SG_BLOCK structure.
9379 */ 8147 */
9380STATIC void 8148static void asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
9381asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
9382{ 8149{
9383 int i; 8150 int i;
9384 8151
9385 printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n", 8152 printk(" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
9386 (ulong) b, sgblockno); 8153 (ulong)b, sgblockno);
9387 printk(" sg_cnt %u, sg_ptr 0x%lx\n", 8154 printk(" sg_cnt %u, sg_ptr 0x%lx\n",
9388 b->sg_cnt, (ulong) le32_to_cpu(b->sg_ptr)); 8155 b->sg_cnt, (ulong)le32_to_cpu(b->sg_ptr));
9389 ASC_ASSERT(b->sg_cnt <= NO_OF_SG_PER_BLOCK); 8156 ASC_ASSERT(b->sg_cnt <= NO_OF_SG_PER_BLOCK);
9390 if (b->sg_ptr != 0) 8157 if (b->sg_ptr != 0) {
9391 { 8158 ASC_ASSERT(b->sg_cnt == NO_OF_SG_PER_BLOCK);
9392 ASC_ASSERT(b->sg_cnt == NO_OF_SG_PER_BLOCK); 8159 }
9393 } 8160 for (i = 0; i < b->sg_cnt; i++) {
9394 for (i = 0; i < b->sg_cnt; i++) { 8161 printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
9395 printk(" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n", 8162 i, (ulong)b->sg_list[i].sg_addr,
9396 i, (ulong) b->sg_list[i].sg_addr, (ulong) b->sg_list[i].sg_count); 8163 (ulong)b->sg_list[i].sg_count);
9397 } 8164 }
9398} 8165}
9399 8166
9400/* 8167/*
@@ -9403,55 +8170,55 @@ asc_prt_adv_sgblock(int sgblockno, ADV_SG_BLOCK *b)
9403 * Print hexadecimal output in 4 byte groupings 32 bytes 8170 * Print hexadecimal output in 4 byte groupings 32 bytes
9404 * or 8 double-words per line. 8171 * or 8 double-words per line.
9405 */ 8172 */
9406STATIC void 8173static void asc_prt_hex(char *f, uchar *s, int l)
9407asc_prt_hex(char *f, uchar *s, int l)
9408{ 8174{
9409 int i; 8175 int i;
9410 int j; 8176 int j;
9411 int k; 8177 int k;
9412 int m; 8178 int m;
9413 8179
9414 printk("%s: (%d bytes)\n", f, l); 8180 printk("%s: (%d bytes)\n", f, l);
9415 8181
9416 for (i = 0; i < l; i += 32) { 8182 for (i = 0; i < l; i += 32) {
9417 8183
9418 /* Display a maximum of 8 double-words per line. */ 8184 /* Display a maximum of 8 double-words per line. */
9419 if ((k = (l - i) / 4) >= 8) { 8185 if ((k = (l - i) / 4) >= 8) {
9420 k = 8; 8186 k = 8;
9421 m = 0; 8187 m = 0;
9422 } else { 8188 } else {
9423 m = (l - i) % 4; 8189 m = (l - i) % 4;
9424 } 8190 }
9425 8191
9426 for (j = 0; j < k; j++) { 8192 for (j = 0; j < k; j++) {
9427 printk(" %2.2X%2.2X%2.2X%2.2X", 8193 printk(" %2.2X%2.2X%2.2X%2.2X",
9428 (unsigned) s[i+(j*4)], (unsigned) s[i+(j*4)+1], 8194 (unsigned)s[i + (j * 4)],
9429 (unsigned) s[i+(j*4)+2], (unsigned) s[i+(j*4)+3]); 8195 (unsigned)s[i + (j * 4) + 1],
9430 } 8196 (unsigned)s[i + (j * 4) + 2],
9431 8197 (unsigned)s[i + (j * 4) + 3]);
9432 switch (m) { 8198 }
9433 case 0: 8199
9434 default: 8200 switch (m) {
9435 break; 8201 case 0:
9436 case 1: 8202 default:
9437 printk(" %2.2X", 8203 break;
9438 (unsigned) s[i+(j*4)]); 8204 case 1:
9439 break; 8205 printk(" %2.2X", (unsigned)s[i + (j * 4)]);
9440 case 2: 8206 break;
9441 printk(" %2.2X%2.2X", 8207 case 2:
9442 (unsigned) s[i+(j*4)], 8208 printk(" %2.2X%2.2X",
9443 (unsigned) s[i+(j*4)+1]); 8209 (unsigned)s[i + (j * 4)],
9444 break; 8210 (unsigned)s[i + (j * 4) + 1]);
9445 case 3: 8211 break;
9446 printk(" %2.2X%2.2X%2.2X", 8212 case 3:
9447 (unsigned) s[i+(j*4)+1], 8213 printk(" %2.2X%2.2X%2.2X",
9448 (unsigned) s[i+(j*4)+2], 8214 (unsigned)s[i + (j * 4) + 1],
9449 (unsigned) s[i+(j*4)+3]); 8215 (unsigned)s[i + (j * 4) + 2],
9450 break; 8216 (unsigned)s[i + (j * 4) + 3]);
9451 } 8217 break;
9452 8218 }
9453 printk("\n"); 8219
9454 } 8220 printk("\n");
8221 }
9455} 8222}
9456#endif /* ADVANSYS_DEBUG */ 8223#endif /* ADVANSYS_DEBUG */
9457 8224
@@ -9459,3380 +8226,3400 @@ asc_prt_hex(char *f, uchar *s, int l)
9459 * --- Asc Library Functions 8226 * --- Asc Library Functions
9460 */ 8227 */
9461 8228
9462STATIC ushort __init 8229static ushort __init AscGetEisaChipCfg(PortAddr iop_base)
9463AscGetEisaChipCfg(
9464 PortAddr iop_base)
9465{ 8230{
9466 PortAddr eisa_cfg_iop; 8231 PortAddr eisa_cfg_iop;
9467 8232
9468 eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) | 8233 eisa_cfg_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
9469 (PortAddr) (ASC_EISA_CFG_IOP_MASK); 8234 (PortAddr) (ASC_EISA_CFG_IOP_MASK);
9470 return (inpw(eisa_cfg_iop)); 8235 return (inpw(eisa_cfg_iop));
9471} 8236}
9472 8237
9473STATIC uchar __init 8238static uchar __init AscSetChipScsiID(PortAddr iop_base, uchar new_host_id)
9474AscSetChipScsiID(
9475 PortAddr iop_base,
9476 uchar new_host_id
9477)
9478{ 8239{
9479 ushort cfg_lsw; 8240 ushort cfg_lsw;
9480 8241
9481 if (AscGetChipScsiID(iop_base) == new_host_id) { 8242 if (AscGetChipScsiID(iop_base) == new_host_id) {
9482 return (new_host_id); 8243 return (new_host_id);
9483 } 8244 }
9484 cfg_lsw = AscGetChipCfgLsw(iop_base); 8245 cfg_lsw = AscGetChipCfgLsw(iop_base);
9485 cfg_lsw &= 0xF8FF; 8246 cfg_lsw &= 0xF8FF;
9486 cfg_lsw |= (ushort) ((new_host_id & ASC_MAX_TID) << 8); 8247 cfg_lsw |= (ushort)((new_host_id & ASC_MAX_TID) << 8);
9487 AscSetChipCfgLsw(iop_base, cfg_lsw); 8248 AscSetChipCfgLsw(iop_base, cfg_lsw);
9488 return (AscGetChipScsiID(iop_base)); 8249 return (AscGetChipScsiID(iop_base));
9489} 8250}
9490 8251
9491STATIC uchar __init 8252static uchar __init AscGetChipScsiCtrl(PortAddr iop_base)
9492AscGetChipScsiCtrl(
9493 PortAddr iop_base)
9494{ 8253{
9495 uchar sc; 8254 uchar sc;
9496 8255
9497 AscSetBank(iop_base, 1); 8256 AscSetBank(iop_base, 1);
9498 sc = inp(iop_base + IOP_REG_SC); 8257 sc = inp(iop_base + IOP_REG_SC);
9499 AscSetBank(iop_base, 0); 8258 AscSetBank(iop_base, 0);
9500 return (sc); 8259 return (sc);
9501} 8260}
9502 8261
9503STATIC uchar __init 8262static uchar __init AscGetChipVersion(PortAddr iop_base, ushort bus_type)
9504AscGetChipVersion(
9505 PortAddr iop_base,
9506 ushort bus_type
9507)
9508{ 8263{
9509 if ((bus_type & ASC_IS_EISA) != 0) { 8264 if ((bus_type & ASC_IS_EISA) != 0) {
9510 PortAddr eisa_iop; 8265 PortAddr eisa_iop;
9511 uchar revision; 8266 uchar revision;
9512 eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) | 8267 eisa_iop = (PortAddr) ASC_GET_EISA_SLOT(iop_base) |
9513 (PortAddr) ASC_EISA_REV_IOP_MASK; 8268 (PortAddr) ASC_EISA_REV_IOP_MASK;
9514 revision = inp(eisa_iop); 8269 revision = inp(eisa_iop);
9515 return ((uchar) ((ASC_CHIP_MIN_VER_EISA - 1) + revision)); 8270 return ((uchar)((ASC_CHIP_MIN_VER_EISA - 1) + revision));
9516 } 8271 }
9517 return (AscGetChipVerNo(iop_base)); 8272 return (AscGetChipVerNo(iop_base));
9518} 8273}
9519 8274
9520STATIC ushort __init 8275static ushort __init AscGetChipBusType(PortAddr iop_base)
9521AscGetChipBusType(
9522 PortAddr iop_base)
9523{ 8276{
9524 ushort chip_ver; 8277 ushort chip_ver;
9525 8278
9526 chip_ver = AscGetChipVerNo(iop_base); 8279 chip_ver = AscGetChipVerNo(iop_base);
9527 if ( 8280 if ((chip_ver >= ASC_CHIP_MIN_VER_VL)
9528 (chip_ver >= ASC_CHIP_MIN_VER_VL) 8281 && (chip_ver <= ASC_CHIP_MAX_VER_VL)
9529 && (chip_ver <= ASC_CHIP_MAX_VER_VL) 8282 ) {
9530) { 8283 if (((iop_base & 0x0C30) == 0x0C30)
9531 if ( 8284 || ((iop_base & 0x0C50) == 0x0C50)
9532 ((iop_base & 0x0C30) == 0x0C30) 8285 ) {
9533 || ((iop_base & 0x0C50) == 0x0C50) 8286 return (ASC_IS_EISA);
9534) { 8287 }
9535 return (ASC_IS_EISA); 8288 return (ASC_IS_VL);
9536 } 8289 }
9537 return (ASC_IS_VL); 8290 if ((chip_ver >= ASC_CHIP_MIN_VER_ISA) &&
9538 } 8291 (chip_ver <= ASC_CHIP_MAX_VER_ISA)) {
9539 if ((chip_ver >= ASC_CHIP_MIN_VER_ISA) && 8292 if (chip_ver >= ASC_CHIP_MIN_VER_ISA_PNP) {
9540 (chip_ver <= ASC_CHIP_MAX_VER_ISA)) { 8293 return (ASC_IS_ISAPNP);
9541 if (chip_ver >= ASC_CHIP_MIN_VER_ISA_PNP) { 8294 }
9542 return (ASC_IS_ISAPNP); 8295 return (ASC_IS_ISA);
9543 } 8296 } else if ((chip_ver >= ASC_CHIP_MIN_VER_PCI) &&
9544 return (ASC_IS_ISA); 8297 (chip_ver <= ASC_CHIP_MAX_VER_PCI)) {
9545 } else if ((chip_ver >= ASC_CHIP_MIN_VER_PCI) && 8298 return (ASC_IS_PCI);
9546 (chip_ver <= ASC_CHIP_MAX_VER_PCI)) { 8299 }
9547 return (ASC_IS_PCI); 8300 return (0);
9548 }
9549 return (0);
9550} 8301}
9551 8302
9552STATIC ASC_DCNT 8303static ASC_DCNT
9553AscLoadMicroCode( 8304AscLoadMicroCode(PortAddr iop_base,
9554 PortAddr iop_base, 8305 ushort s_addr, uchar *mcode_buf, ushort mcode_size)
9555 ushort s_addr,
9556 uchar *mcode_buf,
9557 ushort mcode_size
9558)
9559{ 8306{
9560 ASC_DCNT chksum; 8307 ASC_DCNT chksum;
9561 ushort mcode_word_size; 8308 ushort mcode_word_size;
9562 ushort mcode_chksum; 8309 ushort mcode_chksum;
9563 8310
9564 /* Write the microcode buffer starting at LRAM address 0. */ 8311 /* Write the microcode buffer starting at LRAM address 0. */
9565 mcode_word_size = (ushort) (mcode_size >> 1); 8312 mcode_word_size = (ushort)(mcode_size >> 1);
9566 AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size); 8313 AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
9567 AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size); 8314 AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
9568 8315
9569 chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size); 8316 chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
9570 ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong) chksum); 8317 ASC_DBG1(1, "AscLoadMicroCode: chksum 0x%lx\n", (ulong)chksum);
9571 mcode_chksum = (ushort) AscMemSumLramWord(iop_base, 8318 mcode_chksum = (ushort)AscMemSumLramWord(iop_base,
9572 (ushort) ASC_CODE_SEC_BEG, 8319 (ushort)ASC_CODE_SEC_BEG,
9573 (ushort) ((mcode_size - s_addr - (ushort) ASC_CODE_SEC_BEG) / 2)); 8320 (ushort)((mcode_size -
9574 ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n", 8321 s_addr - (ushort)
9575 (ulong) mcode_chksum); 8322 ASC_CODE_SEC_BEG) /
9576 AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum); 8323 2));
9577 AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size); 8324 ASC_DBG1(1, "AscLoadMicroCode: mcode_chksum 0x%lx\n",
9578 return (chksum); 8325 (ulong)mcode_chksum);
8326 AscWriteLramWord(iop_base, ASCV_MCODE_CHKSUM_W, mcode_chksum);
8327 AscWriteLramWord(iop_base, ASCV_MCODE_SIZE_W, mcode_size);
8328 return (chksum);
9579} 8329}
9580 8330
9581STATIC int 8331static int AscFindSignature(PortAddr iop_base)
9582AscFindSignature(
9583 PortAddr iop_base
9584)
9585{ 8332{
9586 ushort sig_word; 8333 ushort sig_word;
9587 8334
9588 ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n", 8335 ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureByte(0x%x) 0x%x\n",
9589 iop_base, AscGetChipSignatureByte(iop_base)); 8336 iop_base, AscGetChipSignatureByte(iop_base));
9590 if (AscGetChipSignatureByte(iop_base) == (uchar) ASC_1000_ID1B) { 8337 if (AscGetChipSignatureByte(iop_base) == (uchar)ASC_1000_ID1B) {
9591 ASC_DBG2(1, "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n", 8338 ASC_DBG2(1,
9592 iop_base, AscGetChipSignatureWord(iop_base)); 8339 "AscFindSignature: AscGetChipSignatureWord(0x%x) 0x%x\n",
9593 sig_word = AscGetChipSignatureWord(iop_base); 8340 iop_base, AscGetChipSignatureWord(iop_base));
9594 if ((sig_word == (ushort) ASC_1000_ID0W) || 8341 sig_word = AscGetChipSignatureWord(iop_base);
9595 (sig_word == (ushort) ASC_1000_ID0W_FIX)) { 8342 if ((sig_word == (ushort)ASC_1000_ID0W) ||
9596 return (1); 8343 (sig_word == (ushort)ASC_1000_ID0W_FIX)) {
9597 } 8344 return (1);
9598 } 8345 }
9599 return (0); 8346 }
8347 return (0);
9600} 8348}
9601 8349
9602STATIC PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __initdata = 8350static PortAddr _asc_def_iop_base[ASC_IOADR_TABLE_MAX_IX] __initdata = {
9603{ 8351 0x100, ASC_IOADR_1, 0x120, ASC_IOADR_2, 0x140, ASC_IOADR_3, ASC_IOADR_4,
9604 0x100, ASC_IOADR_1, 0x120, ASC_IOADR_2, 0x140, ASC_IOADR_3, ASC_IOADR_4, 8352 ASC_IOADR_5, ASC_IOADR_6, ASC_IOADR_7, ASC_IOADR_8
9605 ASC_IOADR_5, ASC_IOADR_6, ASC_IOADR_7, ASC_IOADR_8
9606}; 8353};
9607 8354
9608#ifdef CONFIG_ISA 8355#ifdef CONFIG_ISA
9609STATIC uchar _isa_pnp_inited __initdata = 0; 8356static uchar _isa_pnp_inited __initdata = 0;
9610 8357
9611STATIC PortAddr __init 8358static PortAddr __init AscSearchIOPortAddr(PortAddr iop_beg, ushort bus_type)
9612AscSearchIOPortAddr(
9613 PortAddr iop_beg,
9614 ushort bus_type)
9615{ 8359{
9616 if (bus_type & ASC_IS_VL) { 8360 if (bus_type & ASC_IS_VL) {
9617 while ((iop_beg = AscSearchIOPortAddr11(iop_beg)) != 0) { 8361 while ((iop_beg = AscSearchIOPortAddr11(iop_beg)) != 0) {
9618 if (AscGetChipVersion(iop_beg, bus_type) <= ASC_CHIP_MAX_VER_VL) { 8362 if (AscGetChipVersion(iop_beg, bus_type) <=
9619 return (iop_beg); 8363 ASC_CHIP_MAX_VER_VL) {
9620 } 8364 return (iop_beg);
9621 } 8365 }
9622 return (0); 8366 }
9623 } 8367 return (0);
9624 if (bus_type & ASC_IS_ISA) { 8368 }
9625 if (_isa_pnp_inited == 0) { 8369 if (bus_type & ASC_IS_ISA) {
9626 AscSetISAPNPWaitForKey(); 8370 if (_isa_pnp_inited == 0) {
9627 _isa_pnp_inited++; 8371 AscSetISAPNPWaitForKey();
9628 } 8372 _isa_pnp_inited++;
9629 while ((iop_beg = AscSearchIOPortAddr11(iop_beg)) != 0) { 8373 }
9630 if ((AscGetChipVersion(iop_beg, bus_type) & ASC_CHIP_VER_ISA_BIT) != 0) { 8374 while ((iop_beg = AscSearchIOPortAddr11(iop_beg)) != 0) {
9631 return (iop_beg); 8375 if ((AscGetChipVersion(iop_beg, bus_type) &
9632 } 8376 ASC_CHIP_VER_ISA_BIT) != 0) {
9633 } 8377 return (iop_beg);
9634 return (0); 8378 }
9635 } 8379 }
9636 if (bus_type & ASC_IS_EISA) { 8380 return (0);
9637 if ((iop_beg = AscSearchIOPortAddrEISA(iop_beg)) != 0) { 8381 }
9638 return (iop_beg); 8382 if (bus_type & ASC_IS_EISA) {
9639 } 8383 if ((iop_beg = AscSearchIOPortAddrEISA(iop_beg)) != 0) {
9640 return (0); 8384 return (iop_beg);
9641 } 8385 }
9642 return (0); 8386 return (0);
8387 }
8388 return (0);
9643} 8389}
9644 8390
9645STATIC PortAddr __init 8391static PortAddr __init AscSearchIOPortAddr11(PortAddr s_addr)
9646AscSearchIOPortAddr11(
9647 PortAddr s_addr
9648)
9649{ 8392{
9650 int i; 8393 int i;
9651 PortAddr iop_base; 8394 PortAddr iop_base;
9652 8395
9653 for (i = 0; i < ASC_IOADR_TABLE_MAX_IX; i++) { 8396 for (i = 0; i < ASC_IOADR_TABLE_MAX_IX; i++) {
9654 if (_asc_def_iop_base[i] > s_addr) { 8397 if (_asc_def_iop_base[i] > s_addr) {
9655 break; 8398 break;
9656 } 8399 }
9657 } 8400 }
9658 for (; i < ASC_IOADR_TABLE_MAX_IX; i++) { 8401 for (; i < ASC_IOADR_TABLE_MAX_IX; i++) {
9659 iop_base = _asc_def_iop_base[i]; 8402 iop_base = _asc_def_iop_base[i];
9660 if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")){ 8403 if (!request_region(iop_base, ASC_IOADR_GAP, "advansys")) {
9661 ASC_DBG1(1, 8404 ASC_DBG1(1,
9662 "AscSearchIOPortAddr11: check_region() failed I/O port 0x%x\n", 8405 "AscSearchIOPortAddr11: check_region() failed I/O port 0x%x\n",
9663 iop_base); 8406 iop_base);
9664 continue; 8407 continue;
9665 } 8408 }
9666 ASC_DBG1(1, "AscSearchIOPortAddr11: probing I/O port 0x%x\n", iop_base); 8409 ASC_DBG1(1, "AscSearchIOPortAddr11: probing I/O port 0x%x\n",
9667 release_region(iop_base, ASC_IOADR_GAP); 8410 iop_base);
9668 if (AscFindSignature(iop_base)) { 8411 release_region(iop_base, ASC_IOADR_GAP);
9669 return (iop_base); 8412 if (AscFindSignature(iop_base)) {
9670 } 8413 return (iop_base);
9671 } 8414 }
9672 return (0); 8415 }
8416 return (0);
9673} 8417}
9674 8418
9675STATIC void __init 8419static void __init AscSetISAPNPWaitForKey(void)
9676AscSetISAPNPWaitForKey(void)
9677{ 8420{
9678 outp(ASC_ISA_PNP_PORT_ADDR, 0x02); 8421 outp(ASC_ISA_PNP_PORT_ADDR, 0x02);
9679 outp(ASC_ISA_PNP_PORT_WRITE, 0x02); 8422 outp(ASC_ISA_PNP_PORT_WRITE, 0x02);
9680 return; 8423 return;
9681} 8424}
9682#endif /* CONFIG_ISA */ 8425#endif /* CONFIG_ISA */
9683 8426
9684STATIC void __init 8427static void __init AscToggleIRQAct(PortAddr iop_base)
9685AscToggleIRQAct(
9686 PortAddr iop_base
9687)
9688{ 8428{
9689 AscSetChipStatus(iop_base, CIW_IRQ_ACT); 8429 AscSetChipStatus(iop_base, CIW_IRQ_ACT);
9690 AscSetChipStatus(iop_base, 0); 8430 AscSetChipStatus(iop_base, 0);
9691 return; 8431 return;
9692} 8432}
9693 8433
9694STATIC uchar __init 8434static uchar __init AscGetChipIRQ(PortAddr iop_base, ushort bus_type)
9695AscGetChipIRQ(
9696 PortAddr iop_base,
9697 ushort bus_type)
9698{ 8435{
9699 ushort cfg_lsw; 8436 ushort cfg_lsw;
9700 uchar chip_irq; 8437 uchar chip_irq;
9701 8438
9702 if ((bus_type & ASC_IS_EISA) != 0) { 8439 if ((bus_type & ASC_IS_EISA) != 0) {
9703 cfg_lsw = AscGetEisaChipCfg(iop_base); 8440 cfg_lsw = AscGetEisaChipCfg(iop_base);
9704 chip_irq = (uchar) (((cfg_lsw >> 8) & 0x07) + 10); 8441 chip_irq = (uchar)(((cfg_lsw >> 8) & 0x07) + 10);
9705 if ((chip_irq == 13) || (chip_irq > 15)) { 8442 if ((chip_irq == 13) || (chip_irq > 15)) {
9706 return (0); 8443 return (0);
9707 } 8444 }
9708 return (chip_irq); 8445 return (chip_irq);
9709 } 8446 }
9710 if ((bus_type & ASC_IS_VL) != 0) { 8447 if ((bus_type & ASC_IS_VL) != 0) {
9711 cfg_lsw = AscGetChipCfgLsw(iop_base); 8448 cfg_lsw = AscGetChipCfgLsw(iop_base);
9712 chip_irq = (uchar) (((cfg_lsw >> 2) & 0x07)); 8449 chip_irq = (uchar)(((cfg_lsw >> 2) & 0x07));
9713 if ((chip_irq == 0) || 8450 if ((chip_irq == 0) || (chip_irq == 4) || (chip_irq == 7)) {
9714 (chip_irq == 4) || 8451 return (0);
9715 (chip_irq == 7)) { 8452 }
9716 return (0); 8453 return ((uchar)(chip_irq + (ASC_MIN_IRQ_NO - 1)));
9717 } 8454 }
9718 return ((uchar) (chip_irq + (ASC_MIN_IRQ_NO - 1))); 8455 cfg_lsw = AscGetChipCfgLsw(iop_base);
9719 } 8456 chip_irq = (uchar)(((cfg_lsw >> 2) & 0x03));
9720 cfg_lsw = AscGetChipCfgLsw(iop_base); 8457 if (chip_irq == 3)
9721 chip_irq = (uchar) (((cfg_lsw >> 2) & 0x03)); 8458 chip_irq += (uchar)2;
9722 if (chip_irq == 3) 8459 return ((uchar)(chip_irq + ASC_MIN_IRQ_NO));
9723 chip_irq += (uchar) 2;
9724 return ((uchar) (chip_irq + ASC_MIN_IRQ_NO));
9725} 8460}
9726 8461
9727STATIC uchar __init 8462static uchar __init
9728AscSetChipIRQ( 8463AscSetChipIRQ(PortAddr iop_base, uchar irq_no, ushort bus_type)
9729 PortAddr iop_base,
9730 uchar irq_no,
9731 ushort bus_type)
9732{ 8464{
9733 ushort cfg_lsw; 8465 ushort cfg_lsw;
9734 8466
9735 if ((bus_type & ASC_IS_VL) != 0) { 8467 if ((bus_type & ASC_IS_VL) != 0) {
9736 if (irq_no != 0) { 8468 if (irq_no != 0) {
9737 if ((irq_no < ASC_MIN_IRQ_NO) || (irq_no > ASC_MAX_IRQ_NO)) { 8469 if ((irq_no < ASC_MIN_IRQ_NO)
9738 irq_no = 0; 8470 || (irq_no > ASC_MAX_IRQ_NO)) {
9739 } else { 8471 irq_no = 0;
9740 irq_no -= (uchar) ((ASC_MIN_IRQ_NO - 1)); 8472 } else {
9741 } 8473 irq_no -= (uchar)((ASC_MIN_IRQ_NO - 1));
9742 } 8474 }
9743 cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFE3); 8475 }
9744 cfg_lsw |= (ushort) 0x0010; 8476 cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE3);
9745 AscSetChipCfgLsw(iop_base, cfg_lsw); 8477 cfg_lsw |= (ushort)0x0010;
9746 AscToggleIRQAct(iop_base); 8478 AscSetChipCfgLsw(iop_base, cfg_lsw);
9747 cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFE0); 8479 AscToggleIRQAct(iop_base);
9748 cfg_lsw |= (ushort) ((irq_no & 0x07) << 2); 8480 cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFE0);
9749 AscSetChipCfgLsw(iop_base, cfg_lsw); 8481 cfg_lsw |= (ushort)((irq_no & 0x07) << 2);
9750 AscToggleIRQAct(iop_base); 8482 AscSetChipCfgLsw(iop_base, cfg_lsw);
9751 return (AscGetChipIRQ(iop_base, bus_type)); 8483 AscToggleIRQAct(iop_base);
9752 } 8484 return (AscGetChipIRQ(iop_base, bus_type));
9753 if ((bus_type & (ASC_IS_ISA)) != 0) { 8485 }
9754 if (irq_no == 15) 8486 if ((bus_type & (ASC_IS_ISA)) != 0) {
9755 irq_no -= (uchar) 2; 8487 if (irq_no == 15)
9756 irq_no -= (uchar) ASC_MIN_IRQ_NO; 8488 irq_no -= (uchar)2;
9757 cfg_lsw = (ushort) (AscGetChipCfgLsw(iop_base) & 0xFFF3); 8489 irq_no -= (uchar)ASC_MIN_IRQ_NO;
9758 cfg_lsw |= (ushort) ((irq_no & 0x03) << 2); 8490 cfg_lsw = (ushort)(AscGetChipCfgLsw(iop_base) & 0xFFF3);
9759 AscSetChipCfgLsw(iop_base, cfg_lsw); 8491 cfg_lsw |= (ushort)((irq_no & 0x03) << 2);
9760 return (AscGetChipIRQ(iop_base, bus_type)); 8492 AscSetChipCfgLsw(iop_base, cfg_lsw);
9761 } 8493 return (AscGetChipIRQ(iop_base, bus_type));
9762 return (0); 8494 }
8495 return (0);
9763} 8496}
9764 8497
9765#ifdef CONFIG_ISA 8498#ifdef CONFIG_ISA
9766STATIC void __init 8499static void __init AscEnableIsaDma(uchar dma_channel)
9767AscEnableIsaDma(
9768 uchar dma_channel)
9769{ 8500{
9770 if (dma_channel < 4) { 8501 if (dma_channel < 4) {
9771 outp(0x000B, (ushort) (0xC0 | dma_channel)); 8502 outp(0x000B, (ushort)(0xC0 | dma_channel));
9772 outp(0x000A, dma_channel); 8503 outp(0x000A, dma_channel);
9773 } else if (dma_channel < 8) { 8504 } else if (dma_channel < 8) {
9774 outp(0x00D6, (ushort) (0xC0 | (dma_channel - 4))); 8505 outp(0x00D6, (ushort)(0xC0 | (dma_channel - 4)));
9775 outp(0x00D4, (ushort) (dma_channel - 4)); 8506 outp(0x00D4, (ushort)(dma_channel - 4));
9776 } 8507 }
9777 return; 8508 return;
9778} 8509}
9779#endif /* CONFIG_ISA */ 8510#endif /* CONFIG_ISA */
9780 8511
9781STATIC int 8512static int AscIsrChipHalted(ASC_DVC_VAR *asc_dvc)
9782AscIsrChipHalted(
9783 ASC_DVC_VAR *asc_dvc
9784)
9785{ 8513{
9786 EXT_MSG ext_msg; 8514 EXT_MSG ext_msg;
9787 EXT_MSG out_msg; 8515 EXT_MSG out_msg;
9788 ushort halt_q_addr; 8516 ushort halt_q_addr;
9789 int sdtr_accept; 8517 int sdtr_accept;
9790 ushort int_halt_code; 8518 ushort int_halt_code;
9791 ASC_SCSI_BIT_ID_TYPE scsi_busy; 8519 ASC_SCSI_BIT_ID_TYPE scsi_busy;
9792 ASC_SCSI_BIT_ID_TYPE target_id; 8520 ASC_SCSI_BIT_ID_TYPE target_id;
9793 PortAddr iop_base; 8521 PortAddr iop_base;
9794 uchar tag_code; 8522 uchar tag_code;
9795 uchar q_status; 8523 uchar q_status;
9796 uchar halt_qp; 8524 uchar halt_qp;
9797 uchar sdtr_data; 8525 uchar sdtr_data;
9798 uchar target_ix; 8526 uchar target_ix;
9799 uchar q_cntl, tid_no; 8527 uchar q_cntl, tid_no;
9800 uchar cur_dvc_qng; 8528 uchar cur_dvc_qng;
9801 uchar asyn_sdtr; 8529 uchar asyn_sdtr;
9802 uchar scsi_status; 8530 uchar scsi_status;
9803 asc_board_t *boardp; 8531 asc_board_t *boardp;
9804 8532
9805 ASC_ASSERT(asc_dvc->drv_ptr != NULL); 8533 ASC_ASSERT(asc_dvc->drv_ptr != NULL);
9806 boardp = asc_dvc->drv_ptr; 8534 boardp = asc_dvc->drv_ptr;
9807 8535
9808 iop_base = asc_dvc->iop_base; 8536 iop_base = asc_dvc->iop_base;
9809 int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W); 8537 int_halt_code = AscReadLramWord(iop_base, ASCV_HALTCODE_W);
9810 8538
9811 halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B); 8539 halt_qp = AscReadLramByte(iop_base, ASCV_CURCDB_B);
9812 halt_q_addr = ASC_QNO_TO_QADDR(halt_qp); 8540 halt_q_addr = ASC_QNO_TO_QADDR(halt_qp);
9813 target_ix = AscReadLramByte(iop_base, 8541 target_ix = AscReadLramByte(iop_base,
9814 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TARGET_IX)); 8542 (ushort)(halt_q_addr +
9815 q_cntl = AscReadLramByte(iop_base, 8543 (ushort)ASC_SCSIQ_B_TARGET_IX));
9816 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL)); 8544 q_cntl =
9817 tid_no = ASC_TIX_TO_TID(target_ix); 8545 AscReadLramByte(iop_base,
9818 target_id = (uchar) ASC_TID_TO_TARGET_ID(tid_no); 8546 (ushort)(halt_q_addr + (ushort)ASC_SCSIQ_B_CNTL));
9819 if (asc_dvc->pci_fix_asyn_xfer & target_id) { 8547 tid_no = ASC_TIX_TO_TID(target_ix);
9820 asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB; 8548 target_id = (uchar)ASC_TID_TO_TARGET_ID(tid_no);
9821 } else { 8549 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
9822 asyn_sdtr = 0; 8550 asyn_sdtr = ASYN_SDTR_DATA_FIX_PCI_REV_AB;
9823 } 8551 } else {
9824 if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) { 8552 asyn_sdtr = 0;
9825 if (asc_dvc->pci_fix_asyn_xfer & target_id) { 8553 }
9826 AscSetChipSDTR(iop_base, 0, tid_no); 8554 if (int_halt_code == ASC_HALT_DISABLE_ASYN_USE_SYN_FIX) {
9827 boardp->sdtr_data[tid_no] = 0; 8555 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
9828 } 8556 AscSetChipSDTR(iop_base, 0, tid_no);
9829 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0); 8557 boardp->sdtr_data[tid_no] = 0;
9830 return (0); 8558 }
9831 } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) { 8559 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9832 if (asc_dvc->pci_fix_asyn_xfer & target_id) { 8560 return (0);
9833 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no); 8561 } else if (int_halt_code == ASC_HALT_ENABLE_ASYN_USE_SYN_FIX) {
9834 boardp->sdtr_data[tid_no] = asyn_sdtr; 8562 if (asc_dvc->pci_fix_asyn_xfer & target_id) {
9835 } 8563 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
9836 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0); 8564 boardp->sdtr_data[tid_no] = asyn_sdtr;
9837 return (0); 8565 }
9838 } else if (int_halt_code == ASC_HALT_EXTMSG_IN) { 8566 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9839 8567 return (0);
9840 AscMemWordCopyPtrFromLram(iop_base, 8568 } else if (int_halt_code == ASC_HALT_EXTMSG_IN) {
9841 ASCV_MSGIN_BEG, 8569
9842 (uchar *) &ext_msg, 8570 AscMemWordCopyPtrFromLram(iop_base,
9843 sizeof(EXT_MSG) >> 1); 8571 ASCV_MSGIN_BEG,
9844 8572 (uchar *)&ext_msg,
9845 if (ext_msg.msg_type == MS_EXTEND && 8573 sizeof(EXT_MSG) >> 1);
9846 ext_msg.msg_req == MS_SDTR_CODE && 8574
9847 ext_msg.msg_len == MS_SDTR_LEN) { 8575 if (ext_msg.msg_type == MS_EXTEND &&
9848 sdtr_accept = TRUE; 8576 ext_msg.msg_req == MS_SDTR_CODE &&
9849 if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) { 8577 ext_msg.msg_len == MS_SDTR_LEN) {
9850 8578 sdtr_accept = TRUE;
9851 sdtr_accept = FALSE; 8579 if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
9852 ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET; 8580
9853 } 8581 sdtr_accept = FALSE;
9854 if ((ext_msg.xfer_period < 8582 ext_msg.req_ack_offset = ASC_SYN_MAX_OFFSET;
9855 asc_dvc->sdtr_period_tbl[asc_dvc->host_init_sdtr_index]) || 8583 }
9856 (ext_msg.xfer_period > 8584 if ((ext_msg.xfer_period <
9857 asc_dvc->sdtr_period_tbl[asc_dvc->max_sdtr_index])) { 8585 asc_dvc->sdtr_period_tbl[asc_dvc->
9858 sdtr_accept = FALSE; 8586 host_init_sdtr_index])
9859 ext_msg.xfer_period = 8587 || (ext_msg.xfer_period >
9860 asc_dvc->sdtr_period_tbl[asc_dvc->host_init_sdtr_index]; 8588 asc_dvc->sdtr_period_tbl[asc_dvc->
9861 } 8589 max_sdtr_index])) {
9862 if (sdtr_accept) { 8590 sdtr_accept = FALSE;
9863 sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period, 8591 ext_msg.xfer_period =
9864 ext_msg.req_ack_offset); 8592 asc_dvc->sdtr_period_tbl[asc_dvc->
9865 if ((sdtr_data == 0xFF)) { 8593 host_init_sdtr_index];
9866 8594 }
9867 q_cntl |= QC_MSG_OUT; 8595 if (sdtr_accept) {
9868 asc_dvc->init_sdtr &= ~target_id; 8596 sdtr_data =
9869 asc_dvc->sdtr_done &= ~target_id; 8597 AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
9870 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no); 8598 ext_msg.req_ack_offset);
9871 boardp->sdtr_data[tid_no] = asyn_sdtr; 8599 if ((sdtr_data == 0xFF)) {
9872 } 8600
9873 } 8601 q_cntl |= QC_MSG_OUT;
9874 if (ext_msg.req_ack_offset == 0) { 8602 asc_dvc->init_sdtr &= ~target_id;
9875 8603 asc_dvc->sdtr_done &= ~target_id;
9876 q_cntl &= ~QC_MSG_OUT; 8604 AscSetChipSDTR(iop_base, asyn_sdtr,
9877 asc_dvc->init_sdtr &= ~target_id; 8605 tid_no);
9878 asc_dvc->sdtr_done &= ~target_id; 8606 boardp->sdtr_data[tid_no] = asyn_sdtr;
9879 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no); 8607 }
9880 } else { 8608 }
9881 if (sdtr_accept && (q_cntl & QC_MSG_OUT)) { 8609 if (ext_msg.req_ack_offset == 0) {
9882 8610
9883 q_cntl &= ~QC_MSG_OUT; 8611 q_cntl &= ~QC_MSG_OUT;
9884 asc_dvc->sdtr_done |= target_id; 8612 asc_dvc->init_sdtr &= ~target_id;
9885 asc_dvc->init_sdtr |= target_id; 8613 asc_dvc->sdtr_done &= ~target_id;
9886 asc_dvc->pci_fix_asyn_xfer &= ~target_id; 8614 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
9887 sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period, 8615 } else {
9888 ext_msg.req_ack_offset); 8616 if (sdtr_accept && (q_cntl & QC_MSG_OUT)) {
9889 AscSetChipSDTR(iop_base, sdtr_data, tid_no); 8617
9890 boardp->sdtr_data[tid_no] = sdtr_data; 8618 q_cntl &= ~QC_MSG_OUT;
9891 } else { 8619 asc_dvc->sdtr_done |= target_id;
9892 8620 asc_dvc->init_sdtr |= target_id;
9893 q_cntl |= QC_MSG_OUT; 8621 asc_dvc->pci_fix_asyn_xfer &=
9894 AscMsgOutSDTR(asc_dvc, 8622 ~target_id;
9895 ext_msg.xfer_period, 8623 sdtr_data =
9896 ext_msg.req_ack_offset); 8624 AscCalSDTRData(asc_dvc,
9897 asc_dvc->pci_fix_asyn_xfer &= ~target_id; 8625 ext_msg.xfer_period,
9898 sdtr_data = AscCalSDTRData(asc_dvc, ext_msg.xfer_period, 8626 ext_msg.
9899 ext_msg.req_ack_offset); 8627 req_ack_offset);
9900 AscSetChipSDTR(iop_base, sdtr_data, tid_no); 8628 AscSetChipSDTR(iop_base, sdtr_data,
9901 boardp->sdtr_data[tid_no] = sdtr_data; 8629 tid_no);
9902 asc_dvc->sdtr_done |= target_id; 8630 boardp->sdtr_data[tid_no] = sdtr_data;
9903 asc_dvc->init_sdtr |= target_id; 8631 } else {
9904 } 8632
9905 } 8633 q_cntl |= QC_MSG_OUT;
9906 8634 AscMsgOutSDTR(asc_dvc,
9907 AscWriteLramByte(iop_base, 8635 ext_msg.xfer_period,
9908 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL), 8636 ext_msg.req_ack_offset);
9909 q_cntl); 8637 asc_dvc->pci_fix_asyn_xfer &=
9910 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0); 8638 ~target_id;
9911 return (0); 8639 sdtr_data =
9912 } else if (ext_msg.msg_type == MS_EXTEND && 8640 AscCalSDTRData(asc_dvc,
9913 ext_msg.msg_req == MS_WDTR_CODE && 8641 ext_msg.xfer_period,
9914 ext_msg.msg_len == MS_WDTR_LEN) { 8642 ext_msg.
9915 8643 req_ack_offset);
9916 ext_msg.wdtr_width = 0; 8644 AscSetChipSDTR(iop_base, sdtr_data,
9917 AscMemWordCopyPtrToLram(iop_base, 8645 tid_no);
9918 ASCV_MSGOUT_BEG, 8646 boardp->sdtr_data[tid_no] = sdtr_data;
9919 (uchar *) &ext_msg, 8647 asc_dvc->sdtr_done |= target_id;
9920 sizeof(EXT_MSG) >> 1); 8648 asc_dvc->init_sdtr |= target_id;
9921 q_cntl |= QC_MSG_OUT; 8649 }
9922 AscWriteLramByte(iop_base, 8650 }
9923 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL), 8651
9924 q_cntl); 8652 AscWriteLramByte(iop_base,
9925 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0); 8653 (ushort)(halt_q_addr +
9926 return (0); 8654 (ushort)ASC_SCSIQ_B_CNTL),
9927 } else { 8655 q_cntl);
9928 8656 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9929 ext_msg.msg_type = MESSAGE_REJECT; 8657 return (0);
9930 AscMemWordCopyPtrToLram(iop_base, 8658 } else if (ext_msg.msg_type == MS_EXTEND &&
9931 ASCV_MSGOUT_BEG, 8659 ext_msg.msg_req == MS_WDTR_CODE &&
9932 (uchar *) &ext_msg, 8660 ext_msg.msg_len == MS_WDTR_LEN) {
9933 sizeof(EXT_MSG) >> 1); 8661
9934 q_cntl |= QC_MSG_OUT; 8662 ext_msg.wdtr_width = 0;
9935 AscWriteLramByte(iop_base, 8663 AscMemWordCopyPtrToLram(iop_base,
9936 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL), 8664 ASCV_MSGOUT_BEG,
9937 q_cntl); 8665 (uchar *)&ext_msg,
9938 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0); 8666 sizeof(EXT_MSG) >> 1);
9939 return (0); 8667 q_cntl |= QC_MSG_OUT;
9940 } 8668 AscWriteLramByte(iop_base,
9941 } else if (int_halt_code == ASC_HALT_CHK_CONDITION) { 8669 (ushort)(halt_q_addr +
9942 8670 (ushort)ASC_SCSIQ_B_CNTL),
9943 q_cntl |= QC_REQ_SENSE; 8671 q_cntl);
9944 8672 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9945 if ((asc_dvc->init_sdtr & target_id) != 0) { 8673 return (0);
9946 8674 } else {
9947 asc_dvc->sdtr_done &= ~target_id; 8675
9948 8676 ext_msg.msg_type = MESSAGE_REJECT;
9949 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no); 8677 AscMemWordCopyPtrToLram(iop_base,
9950 q_cntl |= QC_MSG_OUT; 8678 ASCV_MSGOUT_BEG,
9951 AscMsgOutSDTR(asc_dvc, 8679 (uchar *)&ext_msg,
9952 asc_dvc->sdtr_period_tbl[(sdtr_data >> 4) & 8680 sizeof(EXT_MSG) >> 1);
9953 (uchar) (asc_dvc->max_sdtr_index - 1)], 8681 q_cntl |= QC_MSG_OUT;
9954 (uchar) (sdtr_data & (uchar) ASC_SYN_MAX_OFFSET)); 8682 AscWriteLramByte(iop_base,
9955 } 8683 (ushort)(halt_q_addr +
9956 8684 (ushort)ASC_SCSIQ_B_CNTL),
9957 AscWriteLramByte(iop_base, 8685 q_cntl);
9958 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL), 8686 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
9959 q_cntl); 8687 return (0);
9960 8688 }
9961 tag_code = AscReadLramByte(iop_base, 8689 } else if (int_halt_code == ASC_HALT_CHK_CONDITION) {
9962 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TAG_CODE)); 8690
9963 tag_code &= 0xDC; 8691 q_cntl |= QC_REQ_SENSE;
9964 if ( 8692
9965 (asc_dvc->pci_fix_asyn_xfer & target_id) 8693 if ((asc_dvc->init_sdtr & target_id) != 0) {
9966 && !(asc_dvc->pci_fix_asyn_xfer_always & target_id) 8694
9967) { 8695 asc_dvc->sdtr_done &= ~target_id;
9968 8696
9969 tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT 8697 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
9970 | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX); 8698 q_cntl |= QC_MSG_OUT;
9971 8699 AscMsgOutSDTR(asc_dvc,
9972 } 8700 asc_dvc->
9973 AscWriteLramByte(iop_base, 8701 sdtr_period_tbl[(sdtr_data >> 4) &
9974 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_TAG_CODE), 8702 (uchar)(asc_dvc->
9975 tag_code); 8703 max_sdtr_index -
9976 8704 1)],
9977 q_status = AscReadLramByte(iop_base, 8705 (uchar)(sdtr_data & (uchar)
9978 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_STATUS)); 8706 ASC_SYN_MAX_OFFSET));
9979 q_status |= (QS_READY | QS_BUSY); 8707 }
9980 AscWriteLramByte(iop_base, 8708
9981 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_STATUS), 8709 AscWriteLramByte(iop_base,
9982 q_status); 8710 (ushort)(halt_q_addr +
9983 8711 (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
9984 scsi_busy = AscReadLramByte(iop_base, 8712
9985 (ushort) ASCV_SCSIBUSY_B); 8713 tag_code = AscReadLramByte(iop_base,
9986 scsi_busy &= ~target_id; 8714 (ushort)(halt_q_addr + (ushort)
9987 AscWriteLramByte(iop_base, (ushort) ASCV_SCSIBUSY_B, scsi_busy); 8715 ASC_SCSIQ_B_TAG_CODE));
9988 8716 tag_code &= 0xDC;
9989 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0); 8717 if ((asc_dvc->pci_fix_asyn_xfer & target_id)
9990 return (0); 8718 && !(asc_dvc->pci_fix_asyn_xfer_always & target_id)
9991 } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) { 8719 ) {
9992 8720
9993 AscMemWordCopyPtrFromLram(iop_base, 8721 tag_code |= (ASC_TAG_FLAG_DISABLE_DISCONNECT
9994 ASCV_MSGOUT_BEG, 8722 | ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX);
9995 (uchar *) &out_msg, 8723
9996 sizeof(EXT_MSG) >> 1); 8724 }
9997 8725 AscWriteLramByte(iop_base,
9998 if ((out_msg.msg_type == MS_EXTEND) && 8726 (ushort)(halt_q_addr +
9999 (out_msg.msg_len == MS_SDTR_LEN) && 8727 (ushort)ASC_SCSIQ_B_TAG_CODE),
10000 (out_msg.msg_req == MS_SDTR_CODE)) { 8728 tag_code);
10001 8729
10002 asc_dvc->init_sdtr &= ~target_id; 8730 q_status = AscReadLramByte(iop_base,
10003 asc_dvc->sdtr_done &= ~target_id; 8731 (ushort)(halt_q_addr + (ushort)
10004 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no); 8732 ASC_SCSIQ_B_STATUS));
10005 boardp->sdtr_data[tid_no] = asyn_sdtr; 8733 q_status |= (QS_READY | QS_BUSY);
10006 } 8734 AscWriteLramByte(iop_base,
10007 q_cntl &= ~QC_MSG_OUT; 8735 (ushort)(halt_q_addr +
10008 AscWriteLramByte(iop_base, 8736 (ushort)ASC_SCSIQ_B_STATUS),
10009 (ushort) (halt_q_addr + (ushort) ASC_SCSIQ_B_CNTL), 8737 q_status);
10010 q_cntl); 8738
10011 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0); 8739 scsi_busy = AscReadLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B);
10012 return (0); 8740 scsi_busy &= ~target_id;
10013 } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) { 8741 AscWriteLramByte(iop_base, (ushort)ASCV_SCSIBUSY_B, scsi_busy);
10014 8742
10015 scsi_status = AscReadLramByte(iop_base, 8743 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10016 (ushort) ((ushort) halt_q_addr + (ushort) ASC_SCSIQ_SCSI_STATUS)); 8744 return (0);
10017 cur_dvc_qng = AscReadLramByte(iop_base, 8745 } else if (int_halt_code == ASC_HALT_SDTR_REJECTED) {
10018 (ushort) ((ushort) ASC_QADR_BEG + (ushort) target_ix)); 8746
10019 if ((cur_dvc_qng > 0) && 8747 AscMemWordCopyPtrFromLram(iop_base,
10020 (asc_dvc->cur_dvc_qng[tid_no] > 0)) { 8748 ASCV_MSGOUT_BEG,
10021 8749 (uchar *)&out_msg,
10022 scsi_busy = AscReadLramByte(iop_base, 8750 sizeof(EXT_MSG) >> 1);
10023 (ushort) ASCV_SCSIBUSY_B); 8751
10024 scsi_busy |= target_id; 8752 if ((out_msg.msg_type == MS_EXTEND) &&
10025 AscWriteLramByte(iop_base, 8753 (out_msg.msg_len == MS_SDTR_LEN) &&
10026 (ushort) ASCV_SCSIBUSY_B, scsi_busy); 8754 (out_msg.msg_req == MS_SDTR_CODE)) {
10027 asc_dvc->queue_full_or_busy |= target_id; 8755
10028 8756 asc_dvc->init_sdtr &= ~target_id;
10029 if (scsi_status == SAM_STAT_TASK_SET_FULL) { 8757 asc_dvc->sdtr_done &= ~target_id;
10030 if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) { 8758 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
10031 cur_dvc_qng -= 1; 8759 boardp->sdtr_data[tid_no] = asyn_sdtr;
10032 asc_dvc->max_dvc_qng[tid_no] = cur_dvc_qng; 8760 }
10033 8761 q_cntl &= ~QC_MSG_OUT;
10034 AscWriteLramByte(iop_base, 8762 AscWriteLramByte(iop_base,
10035 (ushort) ((ushort) ASCV_MAX_DVC_QNG_BEG + 8763 (ushort)(halt_q_addr +
10036 (ushort) tid_no), 8764 (ushort)ASC_SCSIQ_B_CNTL), q_cntl);
10037 cur_dvc_qng); 8765 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10038 8766 return (0);
10039 /* 8767 } else if (int_halt_code == ASC_HALT_SS_QUEUE_FULL) {
10040 * Set the device queue depth to the number of 8768
10041 * active requests when the QUEUE FULL condition 8769 scsi_status = AscReadLramByte(iop_base,
10042 * was encountered. 8770 (ushort)((ushort)halt_q_addr +
10043 */ 8771 (ushort)
10044 boardp->queue_full |= target_id; 8772 ASC_SCSIQ_SCSI_STATUS));
10045 boardp->queue_full_cnt[tid_no] = cur_dvc_qng; 8773 cur_dvc_qng =
10046 } 8774 AscReadLramByte(iop_base,
10047 } 8775 (ushort)((ushort)ASC_QADR_BEG +
10048 } 8776 (ushort)target_ix));
10049 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0); 8777 if ((cur_dvc_qng > 0) && (asc_dvc->cur_dvc_qng[tid_no] > 0)) {
10050 return (0); 8778
10051 } 8779 scsi_busy = AscReadLramByte(iop_base,
8780 (ushort)ASCV_SCSIBUSY_B);
8781 scsi_busy |= target_id;
8782 AscWriteLramByte(iop_base,
8783 (ushort)ASCV_SCSIBUSY_B, scsi_busy);
8784 asc_dvc->queue_full_or_busy |= target_id;
8785
8786 if (scsi_status == SAM_STAT_TASK_SET_FULL) {
8787 if (cur_dvc_qng > ASC_MIN_TAGGED_CMD) {
8788 cur_dvc_qng -= 1;
8789 asc_dvc->max_dvc_qng[tid_no] =
8790 cur_dvc_qng;
8791
8792 AscWriteLramByte(iop_base,
8793 (ushort)((ushort)
8794 ASCV_MAX_DVC_QNG_BEG
8795 + (ushort)
8796 tid_no),
8797 cur_dvc_qng);
8798
8799 /*
8800 * Set the device queue depth to the number of
8801 * active requests when the QUEUE FULL condition
8802 * was encountered.
8803 */
8804 boardp->queue_full |= target_id;
8805 boardp->queue_full_cnt[tid_no] =
8806 cur_dvc_qng;
8807 }
8808 }
8809 }
8810 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
8811 return (0);
8812 }
10052#if CC_VERY_LONG_SG_LIST 8813#if CC_VERY_LONG_SG_LIST
10053 else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) 8814 else if (int_halt_code == ASC_HALT_HOST_COPY_SG_LIST_TO_RISC) {
10054 { 8815 uchar q_no;
10055 uchar q_no; 8816 ushort q_addr;
10056 ushort q_addr; 8817 uchar sg_wk_q_no;
10057 uchar sg_wk_q_no; 8818 uchar first_sg_wk_q_no;
10058 uchar first_sg_wk_q_no; 8819 ASC_SCSI_Q *scsiq; /* Ptr to driver request. */
10059 ASC_SCSI_Q *scsiq; /* Ptr to driver request. */ 8820 ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */
10060 ASC_SG_HEAD *sg_head; /* Ptr to driver SG request. */ 8821 ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */
10061 ASC_SG_LIST_Q scsi_sg_q; /* Structure written to queue. */ 8822 ushort sg_list_dwords;
10062 ushort sg_list_dwords; 8823 ushort sg_entry_cnt;
10063 ushort sg_entry_cnt; 8824 uchar next_qp;
10064 uchar next_qp; 8825 int i;
10065 int i; 8826
10066 8827 q_no = AscReadLramByte(iop_base, (ushort)ASCV_REQ_SG_LIST_QP);
10067 q_no = AscReadLramByte(iop_base, (ushort) ASCV_REQ_SG_LIST_QP); 8828 if (q_no == ASC_QLINK_END) {
10068 if (q_no == ASC_QLINK_END) 8829 return (0);
10069 { 8830 }
10070 return(0); 8831
10071 } 8832 q_addr = ASC_QNO_TO_QADDR(q_no);
10072 8833
10073 q_addr = ASC_QNO_TO_QADDR(q_no); 8834 /*
10074 8835 * Convert the request's SRB pointer to a host ASC_SCSI_REQ
10075 /* 8836 * structure pointer using a macro provided by the driver.
10076 * Convert the request's SRB pointer to a host ASC_SCSI_REQ 8837 * The ASC_SCSI_REQ pointer provides a pointer to the
10077 * structure pointer using a macro provided by the driver. 8838 * host ASC_SG_HEAD structure.
10078 * The ASC_SCSI_REQ pointer provides a pointer to the 8839 */
10079 * host ASC_SG_HEAD structure. 8840 /* Read request's SRB pointer. */
10080 */ 8841 scsiq = (ASC_SCSI_Q *)
10081 /* Read request's SRB pointer. */ 8842 ASC_SRB2SCSIQ(ASC_U32_TO_VADDR(AscReadLramDWord(iop_base,
10082 scsiq = (ASC_SCSI_Q *) 8843 (ushort)
10083 ASC_SRB2SCSIQ( 8844 (q_addr +
10084 ASC_U32_TO_VADDR(AscReadLramDWord(iop_base, 8845 ASC_SCSIQ_D_SRBPTR))));
10085 (ushort) (q_addr + ASC_SCSIQ_D_SRBPTR)))); 8846
10086 8847 /*
10087 /* 8848 * Get request's first and working SG queue.
10088 * Get request's first and working SG queue. 8849 */
10089 */ 8850 sg_wk_q_no = AscReadLramByte(iop_base,
10090 sg_wk_q_no = AscReadLramByte(iop_base, 8851 (ushort)(q_addr +
10091 (ushort) (q_addr + ASC_SCSIQ_B_SG_WK_QP)); 8852 ASC_SCSIQ_B_SG_WK_QP));
10092 8853
10093 first_sg_wk_q_no = AscReadLramByte(iop_base, 8854 first_sg_wk_q_no = AscReadLramByte(iop_base,
10094 (ushort) (q_addr + ASC_SCSIQ_B_FIRST_SG_WK_QP)); 8855 (ushort)(q_addr +
10095 8856 ASC_SCSIQ_B_FIRST_SG_WK_QP));
10096 /* 8857
10097 * Reset request's working SG queue back to the 8858 /*
10098 * first SG queue. 8859 * Reset request's working SG queue back to the
10099 */ 8860 * first SG queue.
10100 AscWriteLramByte(iop_base, 8861 */
10101 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_SG_WK_QP), 8862 AscWriteLramByte(iop_base,
10102 first_sg_wk_q_no); 8863 (ushort)(q_addr +
10103 8864 (ushort)ASC_SCSIQ_B_SG_WK_QP),
10104 sg_head = scsiq->sg_head; 8865 first_sg_wk_q_no);
10105 8866
10106 /* 8867 sg_head = scsiq->sg_head;
10107 * Set sg_entry_cnt to the number of SG elements 8868
10108 * that will be completed on this interrupt. 8869 /*
10109 * 8870 * Set sg_entry_cnt to the number of SG elements
10110 * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1 8871 * that will be completed on this interrupt.
10111 * SG elements. The data_cnt and data_addr fields which 8872 *
10112 * add 1 to the SG element capacity are not used when 8873 * Note: The allocated SG queues contain ASC_MAX_SG_LIST - 1
10113 * restarting SG handling after a halt. 8874 * SG elements. The data_cnt and data_addr fields which
10114 */ 8875 * add 1 to the SG element capacity are not used when
10115 if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) 8876 * restarting SG handling after a halt.
10116 { 8877 */
10117 sg_entry_cnt = ASC_MAX_SG_LIST - 1; 8878 if (scsiq->remain_sg_entry_cnt > (ASC_MAX_SG_LIST - 1)) {
10118 8879 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
10119 /* 8880
10120 * Keep track of remaining number of SG elements that will 8881 /*
10121 * need to be handled on the next interrupt. 8882 * Keep track of remaining number of SG elements that will
10122 */ 8883 * need to be handled on the next interrupt.
10123 scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1); 8884 */
10124 } else 8885 scsiq->remain_sg_entry_cnt -= (ASC_MAX_SG_LIST - 1);
10125 { 8886 } else {
10126 sg_entry_cnt = scsiq->remain_sg_entry_cnt; 8887 sg_entry_cnt = scsiq->remain_sg_entry_cnt;
10127 scsiq->remain_sg_entry_cnt = 0; 8888 scsiq->remain_sg_entry_cnt = 0;
10128 } 8889 }
10129 8890
10130 /* 8891 /*
10131 * Copy SG elements into the list of allocated SG queues. 8892 * Copy SG elements into the list of allocated SG queues.
10132 * 8893 *
10133 * Last index completed is saved in scsiq->next_sg_index. 8894 * Last index completed is saved in scsiq->next_sg_index.
10134 */ 8895 */
10135 next_qp = first_sg_wk_q_no; 8896 next_qp = first_sg_wk_q_no;
10136 q_addr = ASC_QNO_TO_QADDR(next_qp); 8897 q_addr = ASC_QNO_TO_QADDR(next_qp);
10137 scsi_sg_q.sg_head_qp = q_no; 8898 scsi_sg_q.sg_head_qp = q_no;
10138 scsi_sg_q.cntl = QCSG_SG_XFER_LIST; 8899 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
10139 for( i = 0; i < sg_head->queue_cnt; i++) 8900 for (i = 0; i < sg_head->queue_cnt; i++) {
10140 { 8901 scsi_sg_q.seq_no = i + 1;
10141 scsi_sg_q.seq_no = i + 1; 8902 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
10142 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) 8903 sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
10143 { 8904 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
10144 sg_list_dwords = (uchar) (ASC_SG_LIST_PER_Q * 2); 8905 /*
10145 sg_entry_cnt -= ASC_SG_LIST_PER_Q; 8906 * After very first SG queue RISC FW uses next
10146 /* 8907 * SG queue first element then checks sg_list_cnt
10147 * After very first SG queue RISC FW uses next 8908 * against zero and then decrements, so set
10148 * SG queue first element then checks sg_list_cnt 8909 * sg_list_cnt 1 less than number of SG elements
10149 * against zero and then decrements, so set 8910 * in each SG queue.
10150 * sg_list_cnt 1 less than number of SG elements 8911 */
10151 * in each SG queue. 8912 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1;
10152 */ 8913 scsi_sg_q.sg_cur_list_cnt =
10153 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1; 8914 ASC_SG_LIST_PER_Q - 1;
10154 scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q - 1; 8915 } else {
10155 } else { 8916 /*
10156 /* 8917 * This is the last SG queue in the list of
10157 * This is the last SG queue in the list of 8918 * allocated SG queues. If there are more
10158 * allocated SG queues. If there are more 8919 * SG elements than will fit in the allocated
10159 * SG elements than will fit in the allocated 8920 * queues, then set the QCSG_SG_XFER_MORE flag.
10160 * queues, then set the QCSG_SG_XFER_MORE flag. 8921 */
10161 */ 8922 if (scsiq->remain_sg_entry_cnt != 0) {
10162 if (scsiq->remain_sg_entry_cnt != 0) 8923 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
10163 { 8924 } else {
10164 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE; 8925 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
10165 } else 8926 }
10166 { 8927 /* equals sg_entry_cnt * 2 */
10167 scsi_sg_q.cntl |= QCSG_SG_XFER_END; 8928 sg_list_dwords = sg_entry_cnt << 1;
10168 } 8929 scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1;
10169 /* equals sg_entry_cnt * 2 */ 8930 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1;
10170 sg_list_dwords = sg_entry_cnt << 1; 8931 sg_entry_cnt = 0;
10171 scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1; 8932 }
10172 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1; 8933
10173 sg_entry_cnt = 0; 8934 scsi_sg_q.q_no = next_qp;
10174 } 8935 AscMemWordCopyPtrToLram(iop_base,
10175 8936 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
10176 scsi_sg_q.q_no = next_qp; 8937 (uchar *)&scsi_sg_q,
10177 AscMemWordCopyPtrToLram(iop_base, 8938 sizeof(ASC_SG_LIST_Q) >> 1);
10178 q_addr + ASC_SCSIQ_SGHD_CPY_BEG, 8939
10179 (uchar *) &scsi_sg_q, 8940 AscMemDWordCopyPtrToLram(iop_base,
10180 sizeof(ASC_SG_LIST_Q) >> 1); 8941 q_addr + ASC_SGQ_LIST_BEG,
10181 8942 (uchar *)&sg_head->
10182 AscMemDWordCopyPtrToLram(iop_base, 8943 sg_list[scsiq->next_sg_index],
10183 q_addr + ASC_SGQ_LIST_BEG, 8944 sg_list_dwords);
10184 (uchar *) &sg_head->sg_list[scsiq->next_sg_index], 8945
10185 sg_list_dwords); 8946 scsiq->next_sg_index += ASC_SG_LIST_PER_Q;
10186 8947
10187 scsiq->next_sg_index += ASC_SG_LIST_PER_Q; 8948 /*
10188 8949 * If the just completed SG queue contained the
10189 /* 8950 * last SG element, then no more SG queues need
10190 * If the just completed SG queue contained the 8951 * to be written.
10191 * last SG element, then no more SG queues need 8952 */
10192 * to be written. 8953 if (scsi_sg_q.cntl & QCSG_SG_XFER_END) {
10193 */ 8954 break;
10194 if (scsi_sg_q.cntl & QCSG_SG_XFER_END) 8955 }
10195 { 8956
10196 break; 8957 next_qp = AscReadLramByte(iop_base,
10197 } 8958 (ushort)(q_addr +
10198 8959 ASC_SCSIQ_B_FWD));
10199 next_qp = AscReadLramByte( iop_base, 8960 q_addr = ASC_QNO_TO_QADDR(next_qp);
10200 ( ushort )( q_addr+ASC_SCSIQ_B_FWD ) ); 8961 }
10201 q_addr = ASC_QNO_TO_QADDR( next_qp ); 8962
10202 } 8963 /*
10203 8964 * Clear the halt condition so the RISC will be restarted
10204 /* 8965 * after the return.
10205 * Clear the halt condition so the RISC will be restarted 8966 */
10206 * after the return. 8967 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
10207 */ 8968 return (0);
10208 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0); 8969 }
10209 return(0);
10210 }
10211#endif /* CC_VERY_LONG_SG_LIST */ 8970#endif /* CC_VERY_LONG_SG_LIST */
10212 return (0); 8971 return (0);
10213} 8972}
10214 8973
10215STATIC uchar 8974static uchar
10216_AscCopyLramScsiDoneQ( 8975_AscCopyLramScsiDoneQ(PortAddr iop_base,
10217 PortAddr iop_base, 8976 ushort q_addr,
10218 ushort q_addr, 8977 ASC_QDONE_INFO *scsiq, ASC_DCNT max_dma_count)
10219 ASC_QDONE_INFO * scsiq,
10220 ASC_DCNT max_dma_count
10221)
10222{ 8978{
10223 ushort _val; 8979 ushort _val;
10224 uchar sg_queue_cnt; 8980 uchar sg_queue_cnt;
10225 8981
10226 DvcGetQinfo(iop_base, 8982 DvcGetQinfo(iop_base,
10227 q_addr + ASC_SCSIQ_DONE_INFO_BEG, 8983 q_addr + ASC_SCSIQ_DONE_INFO_BEG,
10228 (uchar *) scsiq, 8984 (uchar *)scsiq,
10229 (sizeof (ASC_SCSIQ_2) + sizeof (ASC_SCSIQ_3)) / 2); 8985 (sizeof(ASC_SCSIQ_2) + sizeof(ASC_SCSIQ_3)) / 2);
10230 8986
10231 _val = AscReadLramWord(iop_base, 8987 _val = AscReadLramWord(iop_base,
10232 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS)); 8988 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS));
10233 scsiq->q_status = (uchar) _val; 8989 scsiq->q_status = (uchar)_val;
10234 scsiq->q_no = (uchar) (_val >> 8); 8990 scsiq->q_no = (uchar)(_val >> 8);
10235 _val = AscReadLramWord(iop_base, 8991 _val = AscReadLramWord(iop_base,
10236 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_CNTL)); 8992 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_CNTL));
10237 scsiq->cntl = (uchar) _val; 8993 scsiq->cntl = (uchar)_val;
10238 sg_queue_cnt = (uchar) (_val >> 8); 8994 sg_queue_cnt = (uchar)(_val >> 8);
10239 _val = AscReadLramWord(iop_base, 8995 _val = AscReadLramWord(iop_base,
10240 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_SENSE_LEN)); 8996 (ushort)(q_addr +
10241 scsiq->sense_len = (uchar) _val; 8997 (ushort)ASC_SCSIQ_B_SENSE_LEN));
10242 scsiq->extra_bytes = (uchar) (_val >> 8); 8998 scsiq->sense_len = (uchar)_val;
10243 8999 scsiq->extra_bytes = (uchar)(_val >> 8);
10244 /* 9000
10245 * Read high word of remain bytes from alternate location. 9001 /*
10246 */ 9002 * Read high word of remain bytes from alternate location.
10247 scsiq->remain_bytes = (((ADV_DCNT) AscReadLramWord( iop_base, 9003 */
10248 (ushort) (q_addr+ (ushort) ASC_SCSIQ_W_ALT_DC1))) << 16); 9004 scsiq->remain_bytes = (((ADV_DCNT)AscReadLramWord(iop_base,
10249 /* 9005 (ushort)(q_addr +
10250 * Read low word of remain bytes from original location. 9006 (ushort)
10251 */ 9007 ASC_SCSIQ_W_ALT_DC1)))
10252 scsiq->remain_bytes += AscReadLramWord(iop_base, 9008 << 16);
10253 (ushort) (q_addr+ (ushort) ASC_SCSIQ_DW_REMAIN_XFER_CNT)); 9009 /*
10254 9010 * Read low word of remain bytes from original location.
10255 scsiq->remain_bytes &= max_dma_count; 9011 */
10256 return (sg_queue_cnt); 9012 scsiq->remain_bytes += AscReadLramWord(iop_base,
9013 (ushort)(q_addr + (ushort)
9014 ASC_SCSIQ_DW_REMAIN_XFER_CNT));
9015
9016 scsiq->remain_bytes &= max_dma_count;
9017 return (sg_queue_cnt);
10257} 9018}
10258 9019
10259STATIC int 9020static int AscIsrQDone(ASC_DVC_VAR *asc_dvc)
10260AscIsrQDone(
10261 ASC_DVC_VAR *asc_dvc
10262)
10263{ 9021{
10264 uchar next_qp; 9022 uchar next_qp;
10265 uchar n_q_used; 9023 uchar n_q_used;
10266 uchar sg_list_qp; 9024 uchar sg_list_qp;
10267 uchar sg_queue_cnt; 9025 uchar sg_queue_cnt;
10268 uchar q_cnt; 9026 uchar q_cnt;
10269 uchar done_q_tail; 9027 uchar done_q_tail;
10270 uchar tid_no; 9028 uchar tid_no;
10271 ASC_SCSI_BIT_ID_TYPE scsi_busy; 9029 ASC_SCSI_BIT_ID_TYPE scsi_busy;
10272 ASC_SCSI_BIT_ID_TYPE target_id; 9030 ASC_SCSI_BIT_ID_TYPE target_id;
10273 PortAddr iop_base; 9031 PortAddr iop_base;
10274 ushort q_addr; 9032 ushort q_addr;
10275 ushort sg_q_addr; 9033 ushort sg_q_addr;
10276 uchar cur_target_qng; 9034 uchar cur_target_qng;
10277 ASC_QDONE_INFO scsiq_buf; 9035 ASC_QDONE_INFO scsiq_buf;
10278 ASC_QDONE_INFO *scsiq; 9036 ASC_QDONE_INFO *scsiq;
10279 int false_overrun; 9037 int false_overrun;
10280 ASC_ISR_CALLBACK asc_isr_callback; 9038 ASC_ISR_CALLBACK asc_isr_callback;
10281 9039
10282 iop_base = asc_dvc->iop_base; 9040 iop_base = asc_dvc->iop_base;
10283 asc_isr_callback = asc_dvc->isr_callback; 9041 asc_isr_callback = asc_dvc->isr_callback;
10284 n_q_used = 1; 9042 n_q_used = 1;
10285 scsiq = (ASC_QDONE_INFO *) & scsiq_buf; 9043 scsiq = (ASC_QDONE_INFO *)&scsiq_buf;
10286 done_q_tail = (uchar) AscGetVarDoneQTail(iop_base); 9044 done_q_tail = (uchar)AscGetVarDoneQTail(iop_base);
10287 q_addr = ASC_QNO_TO_QADDR(done_q_tail); 9045 q_addr = ASC_QNO_TO_QADDR(done_q_tail);
10288 next_qp = AscReadLramByte(iop_base, 9046 next_qp = AscReadLramByte(iop_base,
10289 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_FWD)); 9047 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_FWD));
10290 if (next_qp != ASC_QLINK_END) { 9048 if (next_qp != ASC_QLINK_END) {
10291 AscPutVarDoneQTail(iop_base, next_qp); 9049 AscPutVarDoneQTail(iop_base, next_qp);
10292 q_addr = ASC_QNO_TO_QADDR(next_qp); 9050 q_addr = ASC_QNO_TO_QADDR(next_qp);
10293 sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq, 9051 sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
10294 asc_dvc->max_dma_count); 9052 asc_dvc->max_dma_count);
10295 AscWriteLramByte(iop_base, 9053 AscWriteLramByte(iop_base,
10296 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS), 9054 (ushort)(q_addr +
10297 (uchar) (scsiq->q_status & (uchar) ~ (QS_READY | QS_ABORTED))); 9055 (ushort)ASC_SCSIQ_B_STATUS),
10298 tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix); 9056 (uchar)(scsiq->
10299 target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix); 9057 q_status & (uchar)~(QS_READY |
10300 if ((scsiq->cntl & QC_SG_HEAD) != 0) { 9058 QS_ABORTED)));
10301 sg_q_addr = q_addr; 9059 tid_no = ASC_TIX_TO_TID(scsiq->d2.target_ix);
10302 sg_list_qp = next_qp; 9060 target_id = ASC_TIX_TO_TARGET_ID(scsiq->d2.target_ix);
10303 for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) { 9061 if ((scsiq->cntl & QC_SG_HEAD) != 0) {
10304 sg_list_qp = AscReadLramByte(iop_base, 9062 sg_q_addr = q_addr;
10305 (ushort) (sg_q_addr + (ushort) ASC_SCSIQ_B_FWD)); 9063 sg_list_qp = next_qp;
10306 sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp); 9064 for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
10307 if (sg_list_qp == ASC_QLINK_END) { 9065 sg_list_qp = AscReadLramByte(iop_base,
10308 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SG_Q_LINKS); 9066 (ushort)(sg_q_addr
10309 scsiq->d3.done_stat = QD_WITH_ERROR; 9067 + (ushort)
10310 scsiq->d3.host_stat = QHSTA_D_QDONE_SG_LIST_CORRUPTED; 9068 ASC_SCSIQ_B_FWD));
10311 goto FATAL_ERR_QDONE; 9069 sg_q_addr = ASC_QNO_TO_QADDR(sg_list_qp);
10312 } 9070 if (sg_list_qp == ASC_QLINK_END) {
10313 AscWriteLramByte(iop_base, 9071 AscSetLibErrorCode(asc_dvc,
10314 (ushort) (sg_q_addr + (ushort) ASC_SCSIQ_B_STATUS), 9072 ASCQ_ERR_SG_Q_LINKS);
10315 QS_FREE); 9073 scsiq->d3.done_stat = QD_WITH_ERROR;
10316 } 9074 scsiq->d3.host_stat =
10317 n_q_used = sg_queue_cnt + 1; 9075 QHSTA_D_QDONE_SG_LIST_CORRUPTED;
10318 AscPutVarDoneQTail(iop_base, sg_list_qp); 9076 goto FATAL_ERR_QDONE;
10319 } 9077 }
10320 if (asc_dvc->queue_full_or_busy & target_id) { 9078 AscWriteLramByte(iop_base,
10321 cur_target_qng = AscReadLramByte(iop_base, 9079 (ushort)(sg_q_addr + (ushort)
10322 (ushort) ((ushort) ASC_QADR_BEG + (ushort) scsiq->d2.target_ix)); 9080 ASC_SCSIQ_B_STATUS),
10323 if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) { 9081 QS_FREE);
10324 scsi_busy = AscReadLramByte(iop_base, 9082 }
10325 (ushort) ASCV_SCSIBUSY_B); 9083 n_q_used = sg_queue_cnt + 1;
10326 scsi_busy &= ~target_id; 9084 AscPutVarDoneQTail(iop_base, sg_list_qp);
10327 AscWriteLramByte(iop_base, 9085 }
10328 (ushort) ASCV_SCSIBUSY_B, scsi_busy); 9086 if (asc_dvc->queue_full_or_busy & target_id) {
10329 asc_dvc->queue_full_or_busy &= ~target_id; 9087 cur_target_qng = AscReadLramByte(iop_base,
10330 } 9088 (ushort)((ushort)
10331 } 9089 ASC_QADR_BEG
10332 if (asc_dvc->cur_total_qng >= n_q_used) { 9090 + (ushort)
10333 asc_dvc->cur_total_qng -= n_q_used; 9091 scsiq->d2.
10334 if (asc_dvc->cur_dvc_qng[tid_no] != 0) { 9092 target_ix));
10335 asc_dvc->cur_dvc_qng[tid_no]--; 9093 if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
10336 } 9094 scsi_busy = AscReadLramByte(iop_base, (ushort)
10337 } else { 9095 ASCV_SCSIBUSY_B);
10338 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG); 9096 scsi_busy &= ~target_id;
10339 scsiq->d3.done_stat = QD_WITH_ERROR; 9097 AscWriteLramByte(iop_base,
10340 goto FATAL_ERR_QDONE; 9098 (ushort)ASCV_SCSIBUSY_B,
10341 } 9099 scsi_busy);
10342 if ((scsiq->d2.srb_ptr == 0UL) || 9100 asc_dvc->queue_full_or_busy &= ~target_id;
10343 ((scsiq->q_status & QS_ABORTED) != 0)) { 9101 }
10344 return (0x11); 9102 }
10345 } else if (scsiq->q_status == QS_DONE) { 9103 if (asc_dvc->cur_total_qng >= n_q_used) {
10346 false_overrun = FALSE; 9104 asc_dvc->cur_total_qng -= n_q_used;
10347 if (scsiq->extra_bytes != 0) { 9105 if (asc_dvc->cur_dvc_qng[tid_no] != 0) {
10348 scsiq->remain_bytes += (ADV_DCNT) scsiq->extra_bytes; 9106 asc_dvc->cur_dvc_qng[tid_no]--;
10349 } 9107 }
10350 if (scsiq->d3.done_stat == QD_WITH_ERROR) { 9108 } else {
10351 if (scsiq->d3.host_stat == QHSTA_M_DATA_OVER_RUN) { 9109 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CUR_QNG);
10352 if ((scsiq->cntl & (QC_DATA_IN | QC_DATA_OUT)) == 0) { 9110 scsiq->d3.done_stat = QD_WITH_ERROR;
10353 scsiq->d3.done_stat = QD_NO_ERROR; 9111 goto FATAL_ERR_QDONE;
10354 scsiq->d3.host_stat = QHSTA_NO_ERROR; 9112 }
10355 } else if (false_overrun) { 9113 if ((scsiq->d2.srb_ptr == 0UL) ||
10356 scsiq->d3.done_stat = QD_NO_ERROR; 9114 ((scsiq->q_status & QS_ABORTED) != 0)) {
10357 scsiq->d3.host_stat = QHSTA_NO_ERROR; 9115 return (0x11);
10358 } 9116 } else if (scsiq->q_status == QS_DONE) {
10359 } else if (scsiq->d3.host_stat == 9117 false_overrun = FALSE;
10360 QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) { 9118 if (scsiq->extra_bytes != 0) {
10361 AscStopChip(iop_base); 9119 scsiq->remain_bytes +=
10362 AscSetChipControl(iop_base, 9120 (ADV_DCNT)scsiq->extra_bytes;
10363 (uchar) (CC_SCSI_RESET | CC_HALT)); 9121 }
10364 DvcDelayNanoSecond(asc_dvc, 60000); 9122 if (scsiq->d3.done_stat == QD_WITH_ERROR) {
10365 AscSetChipControl(iop_base, CC_HALT); 9123 if (scsiq->d3.host_stat ==
10366 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT); 9124 QHSTA_M_DATA_OVER_RUN) {
10367 AscSetChipStatus(iop_base, 0); 9125 if ((scsiq->
10368 AscSetChipControl(iop_base, 0); 9126 cntl & (QC_DATA_IN | QC_DATA_OUT))
10369 } 9127 == 0) {
10370 } 9128 scsiq->d3.done_stat =
10371 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) { 9129 QD_NO_ERROR;
10372 (*asc_isr_callback) (asc_dvc, scsiq); 9130 scsiq->d3.host_stat =
10373 } else { 9131 QHSTA_NO_ERROR;
10374 if ((AscReadLramByte(iop_base, 9132 } else if (false_overrun) {
10375 (ushort) (q_addr + (ushort) ASC_SCSIQ_CDB_BEG)) == 9133 scsiq->d3.done_stat =
10376 START_STOP)) { 9134 QD_NO_ERROR;
10377 asc_dvc->unit_not_ready &= ~target_id; 9135 scsiq->d3.host_stat =
10378 if (scsiq->d3.done_stat != QD_NO_ERROR) { 9136 QHSTA_NO_ERROR;
10379 asc_dvc->start_motor &= ~target_id; 9137 }
10380 } 9138 } else if (scsiq->d3.host_stat ==
10381 } 9139 QHSTA_M_HUNG_REQ_SCSI_BUS_RESET) {
10382 } 9140 AscStopChip(iop_base);
10383 return (1); 9141 AscSetChipControl(iop_base,
10384 } else { 9142 (uchar)(CC_SCSI_RESET
10385 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS); 9143 | CC_HALT));
10386 FATAL_ERR_QDONE: 9144 DvcDelayNanoSecond(asc_dvc, 60000);
10387 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) { 9145 AscSetChipControl(iop_base, CC_HALT);
10388 (*asc_isr_callback) (asc_dvc, scsiq); 9146 AscSetChipStatus(iop_base,
10389 } 9147 CIW_CLR_SCSI_RESET_INT);
10390 return (0x80); 9148 AscSetChipStatus(iop_base, 0);
10391 } 9149 AscSetChipControl(iop_base, 0);
10392 } 9150 }
10393 return (0); 9151 }
9152 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
9153 (*asc_isr_callback) (asc_dvc, scsiq);
9154 } else {
9155 if ((AscReadLramByte(iop_base,
9156 (ushort)(q_addr + (ushort)
9157 ASC_SCSIQ_CDB_BEG))
9158 == START_STOP)) {
9159 asc_dvc->unit_not_ready &= ~target_id;
9160 if (scsiq->d3.done_stat != QD_NO_ERROR) {
9161 asc_dvc->start_motor &=
9162 ~target_id;
9163 }
9164 }
9165 }
9166 return (1);
9167 } else {
9168 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_Q_STATUS);
9169 FATAL_ERR_QDONE:
9170 if ((scsiq->cntl & QC_NO_CALLBACK) == 0) {
9171 (*asc_isr_callback) (asc_dvc, scsiq);
9172 }
9173 return (0x80);
9174 }
9175 }
9176 return (0);
10394} 9177}
10395 9178
10396STATIC int 9179static int AscISR(ASC_DVC_VAR *asc_dvc)
10397AscISR(
10398 ASC_DVC_VAR *asc_dvc
10399)
10400{ 9180{
10401 ASC_CS_TYPE chipstat; 9181 ASC_CS_TYPE chipstat;
10402 PortAddr iop_base; 9182 PortAddr iop_base;
10403 ushort saved_ram_addr; 9183 ushort saved_ram_addr;
10404 uchar ctrl_reg; 9184 uchar ctrl_reg;
10405 uchar saved_ctrl_reg; 9185 uchar saved_ctrl_reg;
10406 int int_pending; 9186 int int_pending;
10407 int status; 9187 int status;
10408 uchar host_flag; 9188 uchar host_flag;
10409 9189
10410 iop_base = asc_dvc->iop_base; 9190 iop_base = asc_dvc->iop_base;
10411 int_pending = FALSE; 9191 int_pending = FALSE;
10412 9192
10413 if (AscIsIntPending(iop_base) == 0) 9193 if (AscIsIntPending(iop_base) == 0) {
10414 { 9194 return int_pending;
10415 return int_pending; 9195 }
10416 }
10417 9196
10418 if (((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0) 9197 if (((asc_dvc->init_state & ASC_INIT_STATE_END_LOAD_MC) == 0)
10419 || (asc_dvc->isr_callback == 0) 9198 || (asc_dvc->isr_callback == 0)
10420) { 9199 ) {
10421 return (ERR); 9200 return (ERR);
10422 } 9201 }
10423 if (asc_dvc->in_critical_cnt != 0) { 9202 if (asc_dvc->in_critical_cnt != 0) {
10424 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL); 9203 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_ON_CRITICAL);
10425 return (ERR); 9204 return (ERR);
10426 } 9205 }
10427 if (asc_dvc->is_in_int) { 9206 if (asc_dvc->is_in_int) {
10428 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY); 9207 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_ISR_RE_ENTRY);
10429 return (ERR); 9208 return (ERR);
10430 } 9209 }
10431 asc_dvc->is_in_int = TRUE; 9210 asc_dvc->is_in_int = TRUE;
10432 ctrl_reg = AscGetChipControl(iop_base); 9211 ctrl_reg = AscGetChipControl(iop_base);
10433 saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET | 9212 saved_ctrl_reg = ctrl_reg & (~(CC_SCSI_RESET | CC_CHIP_RESET |
10434 CC_SINGLE_STEP | CC_DIAG | CC_TEST)); 9213 CC_SINGLE_STEP | CC_DIAG | CC_TEST));
10435 chipstat = AscGetChipStatus(iop_base); 9214 chipstat = AscGetChipStatus(iop_base);
10436 if (chipstat & CSW_SCSI_RESET_LATCH) { 9215 if (chipstat & CSW_SCSI_RESET_LATCH) {
10437 if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) { 9216 if (!(asc_dvc->bus_type & (ASC_IS_VL | ASC_IS_EISA))) {
10438 int i = 10; 9217 int i = 10;
10439 int_pending = TRUE; 9218 int_pending = TRUE;
10440 asc_dvc->sdtr_done = 0; 9219 asc_dvc->sdtr_done = 0;
10441 saved_ctrl_reg &= (uchar) (~CC_HALT); 9220 saved_ctrl_reg &= (uchar)(~CC_HALT);
10442 while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE) && 9221 while ((AscGetChipStatus(iop_base) &
10443 (i-- > 0)) 9222 CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
10444 { 9223 DvcSleepMilliSecond(100);
10445 DvcSleepMilliSecond(100); 9224 }
10446 } 9225 AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT));
10447 AscSetChipControl(iop_base, (CC_CHIP_RESET | CC_HALT)); 9226 AscSetChipControl(iop_base, CC_HALT);
10448 AscSetChipControl(iop_base, CC_HALT); 9227 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
10449 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT); 9228 AscSetChipStatus(iop_base, 0);
10450 AscSetChipStatus(iop_base, 0); 9229 chipstat = AscGetChipStatus(iop_base);
10451 chipstat = AscGetChipStatus(iop_base); 9230 }
10452 } 9231 }
10453 } 9232 saved_ram_addr = AscGetChipLramAddr(iop_base);
10454 saved_ram_addr = AscGetChipLramAddr(iop_base); 9233 host_flag = AscReadLramByte(iop_base,
10455 host_flag = AscReadLramByte(iop_base, 9234 ASCV_HOST_FLAG_B) &
10456 ASCV_HOST_FLAG_B) & (uchar) (~ASC_HOST_FLAG_IN_ISR); 9235 (uchar)(~ASC_HOST_FLAG_IN_ISR);
10457 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, 9236 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
10458 (uchar) (host_flag | (uchar) ASC_HOST_FLAG_IN_ISR)); 9237 (uchar)(host_flag | (uchar)ASC_HOST_FLAG_IN_ISR));
10459 if ((chipstat & CSW_INT_PENDING) 9238 if ((chipstat & CSW_INT_PENDING)
10460 || (int_pending) 9239 || (int_pending)
10461) { 9240 ) {
10462 AscAckInterrupt(iop_base); 9241 AscAckInterrupt(iop_base);
10463 int_pending = TRUE; 9242 int_pending = TRUE;
10464 if ((chipstat & CSW_HALTED) && 9243 if ((chipstat & CSW_HALTED) && (ctrl_reg & CC_SINGLE_STEP)) {
10465 (ctrl_reg & CC_SINGLE_STEP)) { 9244 if (AscIsrChipHalted(asc_dvc) == ERR) {
10466 if (AscIsrChipHalted(asc_dvc) == ERR) { 9245 goto ISR_REPORT_QDONE_FATAL_ERROR;
10467 goto ISR_REPORT_QDONE_FATAL_ERROR; 9246 } else {
10468 } else { 9247 saved_ctrl_reg &= (uchar)(~CC_HALT);
10469 saved_ctrl_reg &= (uchar) (~CC_HALT); 9248 }
10470 } 9249 } else {
10471 } else { 9250 ISR_REPORT_QDONE_FATAL_ERROR:
10472 ISR_REPORT_QDONE_FATAL_ERROR: 9251 if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) {
10473 if ((asc_dvc->dvc_cntl & ASC_CNTL_INT_MULTI_Q) != 0) { 9252 while (((status =
10474 while (((status = AscIsrQDone(asc_dvc)) & 0x01) != 0) { 9253 AscIsrQDone(asc_dvc)) & 0x01) != 0) {
10475 } 9254 }
10476 } else { 9255 } else {
10477 do { 9256 do {
10478 if ((status = AscIsrQDone(asc_dvc)) == 1) { 9257 if ((status =
10479 break; 9258 AscIsrQDone(asc_dvc)) == 1) {
10480 } 9259 break;
10481 } while (status == 0x11); 9260 }
10482 } 9261 } while (status == 0x11);
10483 if ((status & 0x80) != 0) 9262 }
10484 int_pending = ERR; 9263 if ((status & 0x80) != 0)
10485 } 9264 int_pending = ERR;
10486 } 9265 }
10487 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag); 9266 }
10488 AscSetChipLramAddr(iop_base, saved_ram_addr); 9267 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
10489 AscSetChipControl(iop_base, saved_ctrl_reg); 9268 AscSetChipLramAddr(iop_base, saved_ram_addr);
10490 asc_dvc->is_in_int = FALSE; 9269 AscSetChipControl(iop_base, saved_ctrl_reg);
10491 return (int_pending); 9270 asc_dvc->is_in_int = FALSE;
9271 return (int_pending);
10492} 9272}
10493 9273
10494/* Microcode buffer is kept after initialization for error recovery. */ 9274/* Microcode buffer is kept after initialization for error recovery. */
10495STATIC uchar _asc_mcode_buf[] = 9275static uchar _asc_mcode_buf[] = {
10496{ 9276 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10497 0x01, 0x03, 0x01, 0x19, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9277 0x00, 0x00, 0x00, 0x00,
10498 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9278 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00,
10499 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9279 0x00, 0x00, 0x00, 0x00,
10500 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10501 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 9281 0x00, 0x00, 0x00, 0x00,
10502 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9282 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10503 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 9283 0x00, 0x00, 0x00, 0x00,
10504 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x88, 0x00, 0x00, 0x00, 0x00, 9284 0x00, 0x00, 0x00, 0x00, 0xC3, 0x12, 0x0D, 0x05, 0x01, 0x00, 0x00, 0x00,
10505 0x80, 0x73, 0x48, 0x04, 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73, 0x03, 0x23, 0x36, 0x40, 9285 0x00, 0xFF, 0x00, 0x00,
10506 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2, 0xC2, 0x00, 0x92, 0x80, 9286 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00,
10507 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xDF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 9287 0x00, 0x00, 0x00, 0x00,
10508 0x4F, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00, 0x92, 0x80, 0x80, 0x62, 9288 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0xFF,
10509 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8, 0xCD, 0x04, 0x4D, 0x00, 9289 0x00, 0x00, 0x00, 0x00,
10510 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23, 0x04, 0x61, 0x84, 0x01, 0xE6, 0x84, 0xD2, 0xC1, 9290 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x88,
10511 0x80, 0x73, 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97, 0xC6, 0x81, 0xC2, 0x88, 9291 0x00, 0x00, 0x00, 0x00,
10512 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00, 0x84, 0x97, 0x07, 0xA6, 9292 0x80, 0x73, 0x48, 0x04, 0x36, 0x00, 0x00, 0xA2, 0xC2, 0x00, 0x80, 0x73,
10513 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x01, 0xDE, 0xC2, 0x88, 0xCE, 0x00, 9293 0x03, 0x23, 0x36, 0x40,
10514 0x69, 0x60, 0xCE, 0x00, 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01, 0x80, 0x63, 0x07, 0xA6, 9294 0xB6, 0x00, 0x36, 0x00, 0x05, 0xD6, 0x0C, 0xD2, 0x12, 0xDA, 0x00, 0xA2,
10515 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6, 0x34, 0x01, 0x00, 0x33, 9295 0xC2, 0x00, 0x92, 0x80,
10516 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01, 0x04, 0xCA, 0x0D, 0x23, 0x68, 0x98, 0x4D, 0x04, 9296 0x1E, 0x98, 0x50, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xDF, 0x23, 0x36, 0x60,
10517 0x04, 0x85, 0x05, 0xD8, 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23, 0xF8, 0x88, 0xFB, 0x23, 9297 0xB6, 0x00, 0x92, 0x80,
10518 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01, 0x00, 0x33, 0x0A, 0x00, 9298 0x4F, 0x00, 0xF5, 0x00, 0x48, 0x98, 0xEF, 0x23, 0x36, 0x60, 0xB6, 0x00,
10519 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01, 0x00, 0x33, 0x0B, 0x00, 0xC2, 0x88, 0xCD, 0x04, 9299 0x92, 0x80, 0x80, 0x62,
10520 0x36, 0x2D, 0x00, 0x33, 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81, 0x06, 0xAB, 0x82, 0x01, 9300 0x92, 0x80, 0x00, 0x46, 0x15, 0xEE, 0x13, 0xEA, 0x02, 0x01, 0x09, 0xD8,
10521 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3, 0x3C, 0x01, 0x00, 0x05, 9301 0xCD, 0x04, 0x4D, 0x00,
10522 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6, 0x04, 0x23, 0xA0, 0x01, 0x15, 0x23, 0xA1, 0x01, 9302 0x00, 0xA3, 0xD6, 0x00, 0xA6, 0x97, 0x7F, 0x23, 0x04, 0x61, 0x84, 0x01,
10523 0xBE, 0x81, 0xFD, 0x23, 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0, 9303 0xE6, 0x84, 0xD2, 0xC1,
10524 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00, 0xC2, 0x88, 0x06, 0x23, 9304 0x80, 0x73, 0xCD, 0x04, 0x4D, 0x00, 0x00, 0xA3, 0xDA, 0x01, 0xA6, 0x97,
10525 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01, 0x00, 0xA2, 0xD4, 0x01, 0x57, 0x60, 0x00, 0xA0, 9305 0xC6, 0x81, 0xC2, 0x88,
10526 0xDA, 0x01, 0xE6, 0x84, 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73, 0x4B, 0x00, 0x06, 0x61, 9306 0x80, 0x73, 0x80, 0x77, 0x00, 0x01, 0x01, 0xA1, 0xFE, 0x00, 0x4F, 0x00,
10527 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC, 0x4F, 0x00, 0x84, 0x97, 9307 0x84, 0x97, 0x07, 0xA6,
10528 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01, 0x4F, 0x00, 0x62, 0x97, 0x48, 0x04, 0x84, 0x80, 9308 0x08, 0x01, 0x00, 0x33, 0x03, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x01, 0xDE,
10529 0xF0, 0x97, 0x00, 0x46, 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00, 0x81, 0x73, 0x06, 0x29, 9309 0xC2, 0x88, 0xCE, 0x00,
10530 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88, 0x04, 0x98, 0xF0, 0x80, 9310 0x69, 0x60, 0xCE, 0x00, 0x02, 0x03, 0x4A, 0x60, 0x00, 0xA2, 0x78, 0x01,
10531 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02, 0x7C, 0x95, 0x06, 0xA6, 0x34, 0x02, 0x03, 0xA6, 9311 0x80, 0x63, 0x07, 0xA6,
10532 0x4C, 0x04, 0x46, 0x82, 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96, 0x46, 0x82, 0xFE, 0x95, 9312 0x24, 0x01, 0x78, 0x81, 0x03, 0x03, 0x80, 0x63, 0xE2, 0x00, 0x07, 0xA6,
10533 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02, 0x07, 0xA6, 0x5A, 0x02, 9313 0x34, 0x01, 0x00, 0x33,
10534 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02, 0xC2, 0x88, 0x7C, 0x95, 0x48, 0x82, 0x60, 0x96, 9314 0x04, 0x00, 0xC2, 0x88, 0x03, 0x07, 0x02, 0x01, 0x04, 0xCA, 0x0D, 0x23,
10535 0x48, 0x82, 0x04, 0x23, 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84, 0x04, 0x01, 0x0C, 0xDC, 9315 0x68, 0x98, 0x4D, 0x04,
10536 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01, 0x6F, 0x00, 0xA5, 0x01, 9316 0x04, 0x85, 0x05, 0xD8, 0x0D, 0x23, 0x68, 0x98, 0xCD, 0x04, 0x15, 0x23,
10537 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01, 0x24, 0x2B, 0x1C, 0x01, 0x02, 0xA6, 0xAA, 0x02, 9317 0xF8, 0x88, 0xFB, 0x23,
10538 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04, 0x01, 0xA6, 0xB4, 0x02, 9318 0x02, 0x61, 0x82, 0x01, 0x80, 0x63, 0x02, 0x03, 0x06, 0xA3, 0x62, 0x01,
10539 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E, 0x80, 0x63, 0x00, 0x43, 9319 0x00, 0x33, 0x0A, 0x00,
10540 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01, 0x0B, 0xDC, 0xE7, 0x23, 0x04, 0x61, 0x84, 0x01, 9320 0xC2, 0x88, 0x4E, 0x00, 0x07, 0xA3, 0x6E, 0x01, 0x00, 0x33, 0x0B, 0x00,
10541 0x10, 0x31, 0x12, 0x35, 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0xEA, 0x82, 9321 0xC2, 0x88, 0xCD, 0x04,
10542 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8, 0x00, 0x33, 0x1F, 0x00, 9322 0x36, 0x2D, 0x00, 0x33, 0x1A, 0x00, 0xC2, 0x88, 0x50, 0x04, 0x88, 0x81,
10543 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39, 0x0E, 0x3D, 0x7E, 0x98, 0xB6, 0x2D, 0x01, 0xA6, 9323 0x06, 0xAB, 0x82, 0x01,
10544 0x14, 0x03, 0x00, 0xA6, 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6, 0x10, 0x03, 0x03, 0xA6, 9324 0x88, 0x81, 0x4E, 0x00, 0x07, 0xA3, 0x92, 0x01, 0x50, 0x00, 0x00, 0xA3,
10545 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xEE, 0x82, 9325 0x3C, 0x01, 0x00, 0x05,
10546 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42, 0x7E, 0x98, 0x64, 0xE4, 0x04, 0x01, 0x2D, 0xC8, 9326 0x7C, 0x81, 0x46, 0x97, 0x02, 0x01, 0x05, 0xC6, 0x04, 0x23, 0xA0, 0x01,
10547 0x31, 0x05, 0x07, 0x01, 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01, 0x05, 0x05, 0x86, 0x98, 9327 0x15, 0x23, 0xA1, 0x01,
10548 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6, 0x3C, 0x04, 0x06, 0xA6, 9328 0xBE, 0x81, 0xFD, 0x23, 0x02, 0x61, 0x82, 0x01, 0x0A, 0xDA, 0x4A, 0x00,
10549 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33, 0x25, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x32, 0x83, 9329 0x06, 0x61, 0x00, 0xA0,
10550 0x60, 0x96, 0x32, 0x83, 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05, 0xEB, 0x04, 0x00, 0x33, 9330 0xB4, 0x01, 0x80, 0x63, 0xCD, 0x04, 0x36, 0x2D, 0x00, 0x33, 0x1B, 0x00,
10551 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05, 0xFF, 0xA2, 0x7A, 0x03, 9331 0xC2, 0x88, 0x06, 0x23,
10552 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83, 0x05, 0x05, 0x15, 0x01, 0x00, 0xA2, 0x9A, 0x03, 9332 0x68, 0x98, 0xCD, 0x04, 0xE6, 0x84, 0x06, 0x01, 0x00, 0xA2, 0xD4, 0x01,
10553 0xEC, 0x00, 0x6E, 0x00, 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00, 0x01, 0xA6, 0x96, 0x03, 9333 0x57, 0x60, 0x00, 0xA0,
10554 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6, 0xA4, 0x03, 0x00, 0xA6, 9334 0xDA, 0x01, 0xE6, 0x84, 0x80, 0x23, 0xA0, 0x01, 0xE6, 0x84, 0x80, 0x73,
10555 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42, 0x01, 0xA6, 0xA4, 0x03, 0x07, 0xA6, 0xB2, 0x03, 9335 0x4B, 0x00, 0x06, 0x61,
10556 0xD4, 0x83, 0x7C, 0x95, 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88, 0xA8, 0x98, 0x80, 0x42, 9336 0x00, 0xA2, 0x00, 0x02, 0x04, 0x01, 0x0C, 0xDE, 0x02, 0x01, 0x03, 0xCC,
10557 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95, 0xC0, 0x83, 0x00, 0x33, 9337 0x4F, 0x00, 0x84, 0x97,
10558 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32, 0x80, 0x36, 0x04, 0x23, 0xA0, 0x01, 0x12, 0x23, 9338 0xFC, 0x81, 0x08, 0x23, 0x02, 0x41, 0x82, 0x01, 0x4F, 0x00, 0x62, 0x97,
10559 0xA1, 0x01, 0x10, 0x84, 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 9339 0x48, 0x04, 0x84, 0x80,
10560 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04, 0x06, 0xA6, 0x0A, 0x04, 9340 0xF0, 0x97, 0x00, 0x46, 0x56, 0x00, 0x03, 0xC0, 0x01, 0x23, 0xE8, 0x00,
10561 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xF4, 0x83, 0x60, 0x96, 0xF4, 0x83, 0x20, 0x84, 9341 0x81, 0x73, 0x06, 0x29,
10562 0x07, 0xF0, 0x06, 0xA4, 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23, 0x83, 0x03, 0x80, 0x63, 9342 0x03, 0x42, 0x06, 0xE2, 0x03, 0xEE, 0x6B, 0xEB, 0x11, 0x23, 0xF8, 0x88,
10563 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6, 0x38, 0x04, 0x00, 0x33, 9343 0x04, 0x98, 0xF0, 0x80,
10564 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84, 0x60, 0x96, 0x20, 0x84, 0x1D, 0x01, 0x06, 0xCC, 9344 0x80, 0x73, 0x80, 0x77, 0x07, 0xA4, 0x2A, 0x02, 0x7C, 0x95, 0x06, 0xA6,
10565 0x00, 0x33, 0x00, 0x84, 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62, 0xA2, 0x0D, 0x80, 0x63, 9345 0x34, 0x02, 0x03, 0xA6,
10566 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0xA3, 0x01, 9346 0x4C, 0x04, 0x46, 0x82, 0x04, 0x01, 0x03, 0xD8, 0xB4, 0x98, 0x6A, 0x96,
10567 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2, 0x86, 0x04, 0x0A, 0xA0, 0x76, 0x04, 0xE0, 0x00, 9347 0x46, 0x82, 0xFE, 0x95,
10568 0x00, 0x33, 0x1D, 0x00, 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00, 0x00, 0x33, 0x1E, 0x00, 9348 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0xB6, 0x2D, 0x02, 0xA6, 0x6C, 0x02,
10569 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04, 0x08, 0x23, 0x22, 0xA3, 9349 0x07, 0xA6, 0x5A, 0x02,
10570 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04, 0x02, 0x23, 0x22, 0xA3, 0xC4, 0x04, 0x42, 0x23, 9350 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x62, 0x02, 0xC2, 0x88, 0x7C, 0x95,
10571 0xF8, 0x88, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23, 0xF8, 0x88, 0x04, 0x98, 9351 0x48, 0x82, 0x60, 0x96,
10572 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20, 0x81, 0x62, 0xE8, 0x81, 9352 0x48, 0x82, 0x04, 0x23, 0xA0, 0x01, 0x14, 0x23, 0xA1, 0x01, 0x3C, 0x84,
10573 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE, 0x04, 0x98, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x81, 9353 0x04, 0x01, 0x0C, 0xDC,
10574 0xC0, 0x20, 0x81, 0x62, 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23, 0xF8, 0x88, 0x04, 0x23, 9354 0xE0, 0x23, 0x25, 0x61, 0xEF, 0x00, 0x14, 0x01, 0x4F, 0x04, 0xA8, 0x01,
10575 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3, 0xF4, 0x04, 0x00, 0x33, 9355 0x6F, 0x00, 0xA5, 0x01,
10576 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC, 0x02, 0x23, 0xA2, 0x01, 0x04, 0x23, 0xA0, 0x01, 9356 0x03, 0x23, 0xA4, 0x01, 0x06, 0x23, 0x9C, 0x01, 0x24, 0x2B, 0x1C, 0x01,
10577 0x04, 0x98, 0x26, 0x95, 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00, 0x00, 0xA3, 0x22, 0x05, 9357 0x02, 0xA6, 0xAA, 0x02,
10578 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85, 0x46, 0x97, 0xCD, 0x04, 9358 0x07, 0xA6, 0x5A, 0x02, 0x06, 0xA6, 0x5E, 0x02, 0x03, 0xA6, 0x20, 0x04,
10579 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01, 0x03, 0xDA, 0x80, 0x23, 0x82, 0x01, 0x34, 0x85, 9359 0x01, 0xA6, 0xB4, 0x02,
10580 0x02, 0x23, 0xA0, 0x01, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05, 0x1D, 0x01, 0x04, 0xD6, 9360 0x00, 0xA6, 0xB4, 0x02, 0x00, 0x33, 0x12, 0x00, 0xC2, 0x88, 0x00, 0x0E,
10581 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01, 0x49, 0x00, 0x81, 0x01, 9361 0x80, 0x63, 0x00, 0x43,
10582 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01, 0xF7, 0x04, 0x03, 0x01, 0x49, 0x04, 0x80, 0x01, 9362 0x00, 0xA0, 0x8C, 0x02, 0x4D, 0x04, 0x04, 0x01, 0x0B, 0xDC, 0xE7, 0x23,
10583 0xC9, 0x00, 0x00, 0x05, 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04, 0x01, 0x23, 0xEA, 0x00, 9363 0x04, 0x61, 0x84, 0x01,
10584 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63, 0x07, 0xA4, 0xF8, 0x05, 9364 0x10, 0x31, 0x12, 0x35, 0x14, 0x01, 0xEC, 0x00, 0x6C, 0x38, 0x00, 0x3F,
10585 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85, 0x00, 0x33, 0x2D, 0x00, 0xC2, 0x88, 0x04, 0xA0, 9365 0x00, 0x00, 0xEA, 0x82,
10586 0xB8, 0x05, 0x80, 0x63, 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0xA4, 0x05, 9366 0x18, 0x23, 0x04, 0x61, 0x18, 0xA0, 0xE2, 0x02, 0x04, 0x01, 0xA2, 0xC8,
10587 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00, 0x62, 0x97, 0x04, 0x85, 9367 0x00, 0x33, 0x1F, 0x00,
10588 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85, 0x08, 0xA0, 0xBE, 0x05, 0xF4, 0x85, 0x03, 0xA0, 9368 0xC2, 0x88, 0x08, 0x31, 0x0A, 0x35, 0x0C, 0x39, 0x0E, 0x3D, 0x7E, 0x98,
10589 0xC4, 0x05, 0xF4, 0x85, 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63, 0xCC, 0x86, 0x07, 0xA0, 9369 0xB6, 0x2D, 0x01, 0xA6,
10590 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05, 0x80, 0x67, 0x80, 0x63, 9370 0x14, 0x03, 0x00, 0xA6, 0x14, 0x03, 0x07, 0xA6, 0x0C, 0x03, 0x06, 0xA6,
10591 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23, 0x68, 0x98, 0x48, 0x23, 0xF8, 0x88, 0x07, 0x23, 9371 0x10, 0x03, 0x03, 0xA6,
10592 0x80, 0x00, 0x06, 0x87, 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x4A, 0x00, 9372 0x20, 0x04, 0x02, 0xA6, 0x6C, 0x02, 0x00, 0x33, 0x33, 0x00, 0xC2, 0x88,
10593 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23, 0x07, 0x41, 0x83, 0x03, 9373 0x7C, 0x95, 0xEE, 0x82,
10594 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33, 0x37, 0x00, 0xC2, 0x88, 0x1D, 0x01, 0x01, 0xD6, 9374 0x60, 0x96, 0xEE, 0x82, 0x82, 0x98, 0x80, 0x42, 0x7E, 0x98, 0x64, 0xE4,
10595 0x20, 0x23, 0x63, 0x60, 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00, 0x07, 0xA6, 0x7C, 0x05, 9375 0x04, 0x01, 0x2D, 0xC8,
10596 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00, 0x52, 0x00, 0x06, 0x61, 9376 0x31, 0x05, 0x07, 0x01, 0x00, 0xA2, 0x54, 0x03, 0x00, 0x43, 0x87, 0x01,
10597 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA, 0xC0, 0x23, 0x07, 0x41, 0x00, 0x63, 0x1D, 0x01, 9377 0x05, 0x05, 0x86, 0x98,
10598 0x04, 0xCC, 0x00, 0x33, 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23, 0x07, 0x41, 0x00, 0x63, 9378 0x7E, 0x98, 0x00, 0xA6, 0x16, 0x03, 0x07, 0xA6, 0x4C, 0x03, 0x03, 0xA6,
10599 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23, 0xDF, 0x00, 0x06, 0xA6, 9379 0x3C, 0x04, 0x06, 0xA6,
10600 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x80, 0x63, 0x00, 0x33, 0x00, 0x40, 0xC0, 0x20, 9380 0x50, 0x03, 0x01, 0xA6, 0x16, 0x03, 0x00, 0x33, 0x25, 0x00, 0xC2, 0x88,
10601 0x81, 0x62, 0x00, 0x63, 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 0x94, 0x06, 9381 0x7C, 0x95, 0x32, 0x83,
10602 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B, 0x40, 0x0E, 0x80, 0x63, 9382 0x60, 0x96, 0x32, 0x83, 0x04, 0x01, 0x10, 0xCE, 0x07, 0xC8, 0x05, 0x05,
10603 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x40, 0x0E, 0x80, 0x63, 0x00, 0x43, 9383 0xEB, 0x04, 0x00, 0x33,
10604 0x00, 0xA0, 0xA2, 0x06, 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x40, 0x0E, 9384 0x00, 0x20, 0xC0, 0x20, 0x81, 0x62, 0x72, 0x83, 0x00, 0x01, 0x05, 0x05,
10605 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63, 0x07, 0xA6, 0xD6, 0x06, 9385 0xFF, 0xA2, 0x7A, 0x03,
10606 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0x89, 0x00, 0x0A, 0x2B, 0x07, 0xA6, 9386 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x2E, 0x83, 0x05, 0x05, 0x15, 0x01,
10607 0xE8, 0x06, 0x00, 0x33, 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2, 0xF4, 0x06, 0xC0, 0x0E, 9387 0x00, 0xA2, 0x9A, 0x03,
10608 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20, 0x81, 0x62, 0x04, 0x01, 9388 0xEC, 0x00, 0x6E, 0x00, 0x95, 0x01, 0x6C, 0x38, 0x00, 0x3F, 0x00, 0x00,
10609 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x8C, 0x06, 0x00, 0x33, 9389 0x01, 0xA6, 0x96, 0x03,
10610 0x2C, 0x00, 0xC2, 0x88, 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63, 0x06, 0xA6, 9390 0x00, 0xA6, 0x96, 0x03, 0x10, 0x84, 0x80, 0x42, 0x7E, 0x98, 0x01, 0xA6,
10611 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88, 0x00, 0x00, 0x80, 0x67, 9391 0xA4, 0x03, 0x00, 0xA6,
10612 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0xBF, 0x23, 0x04, 0x61, 9392 0xBC, 0x03, 0x10, 0x84, 0xA8, 0x98, 0x80, 0x42, 0x01, 0xA6, 0xA4, 0x03,
10613 0x84, 0x01, 0xE6, 0x84, 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x00, 0x01, 0xF2, 0x00, 9393 0x07, 0xA6, 0xB2, 0x03,
10614 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04, 0x80, 0x05, 0x81, 0x05, 9394 0xD4, 0x83, 0x7C, 0x95, 0xA8, 0x83, 0x00, 0x33, 0x2F, 0x00, 0xC2, 0x88,
10615 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x01, 0x01, 0xF1, 0x00, 0x70, 0x00, 0x81, 0x01, 9395 0xA8, 0x98, 0x80, 0x42,
10616 0x70, 0x04, 0x71, 0x00, 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04, 0x70, 0x00, 0x80, 0x01, 9396 0x00, 0xA6, 0xBC, 0x03, 0x07, 0xA6, 0xCA, 0x03, 0xD4, 0x83, 0x7C, 0x95,
10617 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01, 0xF1, 0x00, 0x70, 0x00, 9397 0xC0, 0x83, 0x00, 0x33,
10618 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01, 0x72, 0x00, 0x81, 0x01, 0x71, 0x04, 0x70, 0x00, 9398 0x26, 0x00, 0xC2, 0x88, 0x38, 0x2B, 0x80, 0x32, 0x80, 0x36, 0x04, 0x23,
10619 0x81, 0x01, 0x70, 0x04, 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05, 0xA3, 0x01, 0xA2, 0x01, 9399 0xA0, 0x01, 0x12, 0x23,
10620 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1, 0xC4, 0x07, 0x00, 0x33, 9400 0xA1, 0x01, 0x10, 0x84, 0x07, 0xF0, 0x06, 0xA4, 0xF4, 0x03, 0x80, 0x6B,
10621 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05, 0x04, 0x01, 0x11, 0xC8, 0x48, 0x00, 0xB0, 0x01, 9401 0x80, 0x67, 0x05, 0x23,
10622 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43, 0x00, 0xA2, 0xE4, 0x07, 9402 0x83, 0x03, 0x80, 0x63, 0x03, 0xA6, 0x0E, 0x04, 0x07, 0xA6, 0x06, 0x04,
10623 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01, 0x05, 0x05, 0x00, 0x63, 9403 0x06, 0xA6, 0x0A, 0x04,
10624 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x80, 0x43, 0x76, 0x08, 0x80, 0x02, 9404 0x00, 0x33, 0x17, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0xF4, 0x83, 0x60, 0x96,
10625 0x77, 0x04, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x00, 0xA0, 9405 0xF4, 0x83, 0x20, 0x84,
10626 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04, 0x00, 0x63, 0xF3, 0x04, 9406 0x07, 0xF0, 0x06, 0xA4, 0x20, 0x04, 0x80, 0x6B, 0x80, 0x67, 0x05, 0x23,
10627 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43, 0xF4, 0x00, 0xCF, 0x40, 0x00, 0xA2, 0x44, 0x08, 9407 0x83, 0x03, 0x80, 0x63,
10628 0x74, 0x04, 0x02, 0x01, 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1, 0x24, 0x08, 0x04, 0x98, 9408 0xB6, 0x2D, 0x03, 0xA6, 0x3C, 0x04, 0x07, 0xA6, 0x34, 0x04, 0x06, 0xA6,
10629 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04, 0x5A, 0x88, 0x02, 0x01, 9409 0x38, 0x04, 0x00, 0x33,
10630 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95, 0x4A, 0x88, 0x75, 0x00, 0x00, 0xA3, 0x64, 0x08, 9410 0x30, 0x00, 0xC2, 0x88, 0x7C, 0x95, 0x20, 0x84, 0x60, 0x96, 0x20, 0x84,
10631 0x00, 0x05, 0x4E, 0x88, 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6, 0x76, 0x08, 9411 0x1D, 0x01, 0x06, 0xCC,
10632 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x38, 0x2B, 9412 0x00, 0x33, 0x00, 0x84, 0xC0, 0x20, 0x00, 0x23, 0xEA, 0x00, 0x81, 0x62,
10633 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09, 0x31, 0x05, 0x92, 0x98, 0x05, 0x05, 0xB2, 0x09, 9413 0xA2, 0x0D, 0x80, 0x63,
10634 0x00, 0x63, 0x00, 0x32, 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63, 0x80, 0x32, 0x80, 0x36, 9414 0x07, 0xA6, 0x5A, 0x04, 0x00, 0x33, 0x18, 0x00, 0xC2, 0x88, 0x03, 0x03,
10635 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32, 0x40, 0x36, 0x40, 0x3A, 9415 0x80, 0x63, 0xA3, 0x01,
10636 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40, 0x00, 0xA0, 0xB4, 0x08, 0x5D, 0x00, 0xFE, 0xC3, 9416 0x07, 0xA4, 0x64, 0x04, 0x23, 0x01, 0x00, 0xA2, 0x86, 0x04, 0x0A, 0xA0,
10637 0x00, 0x63, 0x80, 0x73, 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73, 0xFF, 0xFD, 0x80, 0x73, 9417 0x76, 0x04, 0xE0, 0x00,
10638 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01, 0xA1, 0x23, 0xA1, 0x01, 9418 0x00, 0x33, 0x1D, 0x00, 0xC2, 0x88, 0x0B, 0xA0, 0x82, 0x04, 0xE0, 0x00,
10639 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77, 0x68, 0x00, 0x00, 0xA2, 0x80, 0x00, 0x03, 0xC2, 9419 0x00, 0x33, 0x1E, 0x00,
10640 0xF1, 0xC7, 0x41, 0x23, 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23, 0xA0, 0x01, 0xE6, 0x84, 9420 0xC2, 0x88, 0x42, 0x23, 0xF8, 0x88, 0x00, 0x23, 0x22, 0xA3, 0xE6, 0x04,
9421 0x08, 0x23, 0x22, 0xA3,
9422 0xA2, 0x04, 0x28, 0x23, 0x22, 0xA3, 0xAE, 0x04, 0x02, 0x23, 0x22, 0xA3,
9423 0xC4, 0x04, 0x42, 0x23,
9424 0xF8, 0x88, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA0, 0xAE, 0x04, 0x45, 0x23,
9425 0xF8, 0x88, 0x04, 0x98,
9426 0x00, 0xA2, 0xC0, 0x04, 0xB4, 0x98, 0x00, 0x33, 0x00, 0x82, 0xC0, 0x20,
9427 0x81, 0x62, 0xE8, 0x81,
9428 0x47, 0x23, 0xF8, 0x88, 0x04, 0x01, 0x0B, 0xDE, 0x04, 0x98, 0xB4, 0x98,
9429 0x00, 0x33, 0x00, 0x81,
9430 0xC0, 0x20, 0x81, 0x62, 0x14, 0x01, 0x00, 0xA0, 0x00, 0x02, 0x43, 0x23,
9431 0xF8, 0x88, 0x04, 0x23,
9432 0xA0, 0x01, 0x44, 0x23, 0xA1, 0x01, 0x80, 0x73, 0x4D, 0x00, 0x03, 0xA3,
9433 0xF4, 0x04, 0x00, 0x33,
9434 0x27, 0x00, 0xC2, 0x88, 0x04, 0x01, 0x04, 0xDC, 0x02, 0x23, 0xA2, 0x01,
9435 0x04, 0x23, 0xA0, 0x01,
9436 0x04, 0x98, 0x26, 0x95, 0x4B, 0x00, 0xF6, 0x00, 0x4F, 0x04, 0x4F, 0x00,
9437 0x00, 0xA3, 0x22, 0x05,
9438 0x00, 0x05, 0x76, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x1C, 0x05, 0x0A, 0x85,
9439 0x46, 0x97, 0xCD, 0x04,
9440 0x24, 0x85, 0x48, 0x04, 0x84, 0x80, 0x02, 0x01, 0x03, 0xDA, 0x80, 0x23,
9441 0x82, 0x01, 0x34, 0x85,
9442 0x02, 0x23, 0xA0, 0x01, 0x4A, 0x00, 0x06, 0x61, 0x00, 0xA2, 0x40, 0x05,
9443 0x1D, 0x01, 0x04, 0xD6,
9444 0xFF, 0x23, 0x86, 0x41, 0x4B, 0x60, 0xCB, 0x00, 0xFF, 0x23, 0x80, 0x01,
9445 0x49, 0x00, 0x81, 0x01,
9446 0x04, 0x01, 0x02, 0xC8, 0x30, 0x01, 0x80, 0x01, 0xF7, 0x04, 0x03, 0x01,
9447 0x49, 0x04, 0x80, 0x01,
9448 0xC9, 0x00, 0x00, 0x05, 0x00, 0x01, 0xFF, 0xA0, 0x60, 0x05, 0x77, 0x04,
9449 0x01, 0x23, 0xEA, 0x00,
9450 0x5D, 0x00, 0xFE, 0xC7, 0x00, 0x62, 0x00, 0x23, 0xEA, 0x00, 0x00, 0x63,
9451 0x07, 0xA4, 0xF8, 0x05,
9452 0x03, 0x03, 0x02, 0xA0, 0x8E, 0x05, 0xF4, 0x85, 0x00, 0x33, 0x2D, 0x00,
9453 0xC2, 0x88, 0x04, 0xA0,
9454 0xB8, 0x05, 0x80, 0x63, 0x00, 0x23, 0xDF, 0x00, 0x4A, 0x00, 0x06, 0x61,
9455 0x00, 0xA2, 0xA4, 0x05,
9456 0x1D, 0x01, 0x06, 0xD6, 0x02, 0x23, 0x02, 0x41, 0x82, 0x01, 0x50, 0x00,
9457 0x62, 0x97, 0x04, 0x85,
9458 0x04, 0x23, 0x02, 0x41, 0x82, 0x01, 0x04, 0x85, 0x08, 0xA0, 0xBE, 0x05,
9459 0xF4, 0x85, 0x03, 0xA0,
9460 0xC4, 0x05, 0xF4, 0x85, 0x01, 0xA0, 0xCE, 0x05, 0x88, 0x00, 0x80, 0x63,
9461 0xCC, 0x86, 0x07, 0xA0,
9462 0xEE, 0x05, 0x5F, 0x00, 0x00, 0x2B, 0xDF, 0x08, 0x00, 0xA2, 0xE6, 0x05,
9463 0x80, 0x67, 0x80, 0x63,
9464 0x01, 0xA2, 0x7A, 0x06, 0x7C, 0x85, 0x06, 0x23, 0x68, 0x98, 0x48, 0x23,
9465 0xF8, 0x88, 0x07, 0x23,
9466 0x80, 0x00, 0x06, 0x87, 0x80, 0x63, 0x7C, 0x85, 0x00, 0x23, 0xDF, 0x00,
9467 0x00, 0x63, 0x4A, 0x00,
9468 0x06, 0x61, 0x00, 0xA2, 0x36, 0x06, 0x1D, 0x01, 0x16, 0xD4, 0xC0, 0x23,
9469 0x07, 0x41, 0x83, 0x03,
9470 0x80, 0x63, 0x06, 0xA6, 0x1C, 0x06, 0x00, 0x33, 0x37, 0x00, 0xC2, 0x88,
9471 0x1D, 0x01, 0x01, 0xD6,
9472 0x20, 0x23, 0x63, 0x60, 0x83, 0x03, 0x80, 0x63, 0x02, 0x23, 0xDF, 0x00,
9473 0x07, 0xA6, 0x7C, 0x05,
9474 0xEF, 0x04, 0x6F, 0x00, 0x00, 0x63, 0x4B, 0x00, 0x06, 0x41, 0xCB, 0x00,
9475 0x52, 0x00, 0x06, 0x61,
9476 0x00, 0xA2, 0x4E, 0x06, 0x1D, 0x01, 0x03, 0xCA, 0xC0, 0x23, 0x07, 0x41,
9477 0x00, 0x63, 0x1D, 0x01,
9478 0x04, 0xCC, 0x00, 0x33, 0x00, 0x83, 0xC0, 0x20, 0x81, 0x62, 0x80, 0x23,
9479 0x07, 0x41, 0x00, 0x63,
9480 0x80, 0x67, 0x08, 0x23, 0x83, 0x03, 0x80, 0x63, 0x00, 0x63, 0x01, 0x23,
9481 0xDF, 0x00, 0x06, 0xA6,
9482 0x84, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x80, 0x67, 0x80, 0x63, 0x00, 0x33,
9483 0x00, 0x40, 0xC0, 0x20,
9484 0x81, 0x62, 0x00, 0x63, 0x00, 0x00, 0xFE, 0x95, 0x83, 0x03, 0x80, 0x63,
9485 0x06, 0xA6, 0x94, 0x06,
9486 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x00, 0x01, 0xA0, 0x14, 0x07, 0x00, 0x2B,
9487 0x40, 0x0E, 0x80, 0x63,
9488 0x01, 0x00, 0x06, 0xA6, 0xAA, 0x06, 0x07, 0xA6, 0x7C, 0x05, 0x40, 0x0E,
9489 0x80, 0x63, 0x00, 0x43,
9490 0x00, 0xA0, 0xA2, 0x06, 0x06, 0xA6, 0xBC, 0x06, 0x07, 0xA6, 0x7C, 0x05,
9491 0x80, 0x67, 0x40, 0x0E,
9492 0x80, 0x63, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x23, 0xDF, 0x00, 0x00, 0x63,
9493 0x07, 0xA6, 0xD6, 0x06,
9494 0x00, 0x33, 0x2A, 0x00, 0xC2, 0x88, 0x03, 0x03, 0x80, 0x63, 0x89, 0x00,
9495 0x0A, 0x2B, 0x07, 0xA6,
9496 0xE8, 0x06, 0x00, 0x33, 0x29, 0x00, 0xC2, 0x88, 0x00, 0x43, 0x00, 0xA2,
9497 0xF4, 0x06, 0xC0, 0x0E,
9498 0x80, 0x63, 0xDE, 0x86, 0xC0, 0x0E, 0x00, 0x33, 0x00, 0x80, 0xC0, 0x20,
9499 0x81, 0x62, 0x04, 0x01,
9500 0x02, 0xDA, 0x80, 0x63, 0x7C, 0x85, 0x80, 0x7B, 0x80, 0x63, 0x06, 0xA6,
9501 0x8C, 0x06, 0x00, 0x33,
9502 0x2C, 0x00, 0xC2, 0x88, 0x0C, 0xA2, 0x2E, 0x07, 0xFE, 0x95, 0x83, 0x03,
9503 0x80, 0x63, 0x06, 0xA6,
9504 0x2C, 0x07, 0x07, 0xA6, 0x7C, 0x05, 0x00, 0x33, 0x3D, 0x00, 0xC2, 0x88,
9505 0x00, 0x00, 0x80, 0x67,
9506 0x83, 0x03, 0x80, 0x63, 0x0C, 0xA0, 0x44, 0x07, 0x07, 0xA6, 0x7C, 0x05,
9507 0xBF, 0x23, 0x04, 0x61,
9508 0x84, 0x01, 0xE6, 0x84, 0x00, 0x63, 0xF0, 0x04, 0x01, 0x01, 0xF1, 0x00,
9509 0x00, 0x01, 0xF2, 0x00,
9510 0x01, 0x05, 0x80, 0x01, 0x72, 0x04, 0x71, 0x00, 0x81, 0x01, 0x70, 0x04,
9511 0x80, 0x05, 0x81, 0x05,
9512 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x01, 0x01, 0xF1, 0x00,
9513 0x70, 0x00, 0x81, 0x01,
9514 0x70, 0x04, 0x71, 0x00, 0x81, 0x01, 0x72, 0x00, 0x80, 0x01, 0x71, 0x04,
9515 0x70, 0x00, 0x80, 0x01,
9516 0x70, 0x04, 0x00, 0x63, 0xF0, 0x04, 0xF2, 0x00, 0x72, 0x04, 0x00, 0x01,
9517 0xF1, 0x00, 0x70, 0x00,
9518 0x80, 0x01, 0x70, 0x04, 0x71, 0x00, 0x80, 0x01, 0x72, 0x00, 0x81, 0x01,
9519 0x71, 0x04, 0x70, 0x00,
9520 0x81, 0x01, 0x70, 0x04, 0x00, 0x63, 0x00, 0x23, 0xB3, 0x01, 0x83, 0x05,
9521 0xA3, 0x01, 0xA2, 0x01,
9522 0xA1, 0x01, 0x01, 0x23, 0xA0, 0x01, 0x00, 0x01, 0xC8, 0x00, 0x03, 0xA1,
9523 0xC4, 0x07, 0x00, 0x33,
9524 0x07, 0x00, 0xC2, 0x88, 0x80, 0x05, 0x81, 0x05, 0x04, 0x01, 0x11, 0xC8,
9525 0x48, 0x00, 0xB0, 0x01,
9526 0xB1, 0x01, 0x08, 0x23, 0xB2, 0x01, 0x05, 0x01, 0x48, 0x04, 0x00, 0x43,
9527 0x00, 0xA2, 0xE4, 0x07,
9528 0x00, 0x05, 0xDA, 0x87, 0x00, 0x01, 0xC8, 0x00, 0xFF, 0x23, 0x80, 0x01,
9529 0x05, 0x05, 0x00, 0x63,
9530 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04, 0x00, 0x02, 0x80, 0x43,
9531 0x76, 0x08, 0x80, 0x02,
9532 0x77, 0x04, 0x00, 0x63, 0xF7, 0x04, 0x1A, 0x09, 0xF6, 0x08, 0x6E, 0x04,
9533 0x00, 0x02, 0x00, 0xA0,
9534 0x14, 0x08, 0x16, 0x88, 0x00, 0x43, 0x76, 0x08, 0x80, 0x02, 0x77, 0x04,
9535 0x00, 0x63, 0xF3, 0x04,
9536 0x00, 0x23, 0xF4, 0x00, 0x74, 0x00, 0x80, 0x43, 0xF4, 0x00, 0xCF, 0x40,
9537 0x00, 0xA2, 0x44, 0x08,
9538 0x74, 0x04, 0x02, 0x01, 0xF7, 0xC9, 0xF6, 0xD9, 0x00, 0x01, 0x01, 0xA1,
9539 0x24, 0x08, 0x04, 0x98,
9540 0x26, 0x95, 0x24, 0x88, 0x73, 0x04, 0x00, 0x63, 0xF3, 0x04, 0x75, 0x04,
9541 0x5A, 0x88, 0x02, 0x01,
9542 0x04, 0xD8, 0x46, 0x97, 0x04, 0x98, 0x26, 0x95, 0x4A, 0x88, 0x75, 0x00,
9543 0x00, 0xA3, 0x64, 0x08,
9544 0x00, 0x05, 0x4E, 0x88, 0x73, 0x04, 0x00, 0x63, 0x80, 0x7B, 0x80, 0x63,
9545 0x06, 0xA6, 0x76, 0x08,
9546 0x00, 0x33, 0x3E, 0x00, 0xC2, 0x88, 0x80, 0x67, 0x83, 0x03, 0x80, 0x63,
9547 0x00, 0x63, 0x38, 0x2B,
9548 0x9C, 0x88, 0x38, 0x2B, 0x92, 0x88, 0x32, 0x09, 0x31, 0x05, 0x92, 0x98,
9549 0x05, 0x05, 0xB2, 0x09,
9550 0x00, 0x63, 0x00, 0x32, 0x00, 0x36, 0x00, 0x3A, 0x00, 0x3E, 0x00, 0x63,
9551 0x80, 0x32, 0x80, 0x36,
9552 0x80, 0x3A, 0x80, 0x3E, 0xB4, 0x3D, 0x00, 0x63, 0x38, 0x2B, 0x40, 0x32,
9553 0x40, 0x36, 0x40, 0x3A,
9554 0x40, 0x3E, 0x00, 0x63, 0x5A, 0x20, 0xC9, 0x40, 0x00, 0xA0, 0xB4, 0x08,
9555 0x5D, 0x00, 0xFE, 0xC3,
9556 0x00, 0x63, 0x80, 0x73, 0xE6, 0x20, 0x02, 0x23, 0xE8, 0x00, 0x82, 0x73,
9557 0xFF, 0xFD, 0x80, 0x73,
9558 0x13, 0x23, 0xF8, 0x88, 0x66, 0x20, 0xC0, 0x20, 0x04, 0x23, 0xA0, 0x01,
9559 0xA1, 0x23, 0xA1, 0x01,
9560 0x81, 0x62, 0xE2, 0x88, 0x80, 0x73, 0x80, 0x77, 0x68, 0x00, 0x00, 0xA2,
9561 0x80, 0x00, 0x03, 0xC2,
9562 0xF1, 0xC7, 0x41, 0x23, 0xF8, 0x88, 0x11, 0x23, 0xA1, 0x01, 0x04, 0x23,
9563 0xA0, 0x01, 0xE6, 0x84,
10641}; 9564};
10642 9565
10643STATIC ushort _asc_mcode_size = sizeof(_asc_mcode_buf); 9566static ushort _asc_mcode_size = sizeof(_asc_mcode_buf);
10644STATIC ADV_DCNT _asc_mcode_chksum = 0x012C453FUL; 9567static ADV_DCNT _asc_mcode_chksum = 0x012C453FUL;
10645 9568
10646#define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16 9569#define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
10647STATIC uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = 9570static uchar _syn_offset_one_disable_cmd[ASC_SYN_OFFSET_ONE_DISABLE_LIST] = {
10648{ 9571 INQUIRY,
10649 INQUIRY, 9572 REQUEST_SENSE,
10650 REQUEST_SENSE, 9573 READ_CAPACITY,
10651 READ_CAPACITY, 9574 READ_TOC,
10652 READ_TOC, 9575 MODE_SELECT,
10653 MODE_SELECT, 9576 MODE_SENSE,
10654 MODE_SENSE, 9577 MODE_SELECT_10,
10655 MODE_SELECT_10, 9578 MODE_SENSE_10,
10656 MODE_SENSE_10, 9579 0xFF,
10657 0xFF, 9580 0xFF,
10658 0xFF, 9581 0xFF,
10659 0xFF, 9582 0xFF,
10660 0xFF, 9583 0xFF,
10661 0xFF, 9584 0xFF,
10662 0xFF, 9585 0xFF,
10663 0xFF, 9586 0xFF
10664 0xFF
10665}; 9587};
10666 9588
10667STATIC int 9589static int AscExeScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq)
10668AscExeScsiQueue(
10669 ASC_DVC_VAR *asc_dvc,
10670 ASC_SCSI_Q *scsiq
10671)
10672{ 9590{
10673 PortAddr iop_base; 9591 PortAddr iop_base;
10674 ulong last_int_level; 9592 ulong last_int_level;
10675 int sta; 9593 int sta;
10676 int n_q_required; 9594 int n_q_required;
10677 int disable_syn_offset_one_fix; 9595 int disable_syn_offset_one_fix;
10678 int i; 9596 int i;
10679 ASC_PADDR addr; 9597 ASC_PADDR addr;
10680 ASC_EXE_CALLBACK asc_exe_callback; 9598 ASC_EXE_CALLBACK asc_exe_callback;
10681 ushort sg_entry_cnt = 0; 9599 ushort sg_entry_cnt = 0;
10682 ushort sg_entry_cnt_minus_one = 0; 9600 ushort sg_entry_cnt_minus_one = 0;
10683 uchar target_ix; 9601 uchar target_ix;
10684 uchar tid_no; 9602 uchar tid_no;
10685 uchar sdtr_data; 9603 uchar sdtr_data;
10686 uchar extra_bytes; 9604 uchar extra_bytes;
10687 uchar scsi_cmd; 9605 uchar scsi_cmd;
10688 uchar disable_cmd; 9606 uchar disable_cmd;
10689 ASC_SG_HEAD *sg_head; 9607 ASC_SG_HEAD *sg_head;
10690 ASC_DCNT data_cnt; 9608 ASC_DCNT data_cnt;
10691 9609
10692 iop_base = asc_dvc->iop_base; 9610 iop_base = asc_dvc->iop_base;
10693 sg_head = scsiq->sg_head; 9611 sg_head = scsiq->sg_head;
10694 asc_exe_callback = asc_dvc->exe_callback; 9612 asc_exe_callback = asc_dvc->exe_callback;
10695 if (asc_dvc->err_code != 0) 9613 if (asc_dvc->err_code != 0)
10696 return (ERR); 9614 return (ERR);
10697 if (scsiq == (ASC_SCSI_Q *) 0L) { 9615 if (scsiq == (ASC_SCSI_Q *)0L) {
10698 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SCSIQ_NULL_PTR); 9616 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_SCSIQ_NULL_PTR);
10699 return (ERR); 9617 return (ERR);
10700 } 9618 }
10701 scsiq->q1.q_no = 0; 9619 scsiq->q1.q_no = 0;
10702 if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) { 9620 if ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) == 0) {
10703 scsiq->q1.extra_bytes = 0; 9621 scsiq->q1.extra_bytes = 0;
10704 } 9622 }
10705 sta = 0; 9623 sta = 0;
10706 target_ix = scsiq->q2.target_ix; 9624 target_ix = scsiq->q2.target_ix;
10707 tid_no = ASC_TIX_TO_TID(target_ix); 9625 tid_no = ASC_TIX_TO_TID(target_ix);
10708 n_q_required = 1; 9626 n_q_required = 1;
10709 if (scsiq->cdbptr[0] == REQUEST_SENSE) { 9627 if (scsiq->cdbptr[0] == REQUEST_SENSE) {
10710 if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) { 9628 if ((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) {
10711 asc_dvc->sdtr_done &= ~scsiq->q1.target_id; 9629 asc_dvc->sdtr_done &= ~scsiq->q1.target_id;
10712 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no); 9630 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
10713 AscMsgOutSDTR(asc_dvc, 9631 AscMsgOutSDTR(asc_dvc,
10714 asc_dvc->sdtr_period_tbl[(sdtr_data >> 4) & 9632 asc_dvc->
10715 (uchar) (asc_dvc->max_sdtr_index - 1)], 9633 sdtr_period_tbl[(sdtr_data >> 4) &
10716 (uchar) (sdtr_data & (uchar) ASC_SYN_MAX_OFFSET)); 9634 (uchar)(asc_dvc->
10717 scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT); 9635 max_sdtr_index -
10718 } 9636 1)],
10719 } 9637 (uchar)(sdtr_data & (uchar)
10720 last_int_level = DvcEnterCritical(); 9638 ASC_SYN_MAX_OFFSET));
10721 if (asc_dvc->in_critical_cnt != 0) { 9639 scsiq->q1.cntl |= (QC_MSG_OUT | QC_URGENT);
10722 DvcLeaveCritical(last_int_level); 9640 }
10723 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY); 9641 }
10724 return (ERR); 9642 last_int_level = DvcEnterCritical();
10725 } 9643 if (asc_dvc->in_critical_cnt != 0) {
10726 asc_dvc->in_critical_cnt++; 9644 DvcLeaveCritical(last_int_level);
10727 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) { 9645 AscSetLibErrorCode(asc_dvc, ASCQ_ERR_CRITICAL_RE_ENTRY);
10728 if ((sg_entry_cnt = sg_head->entry_cnt) == 0) { 9646 return (ERR);
10729 asc_dvc->in_critical_cnt--; 9647 }
10730 DvcLeaveCritical(last_int_level); 9648 asc_dvc->in_critical_cnt++;
10731 return (ERR); 9649 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
10732 } 9650 if ((sg_entry_cnt = sg_head->entry_cnt) == 0) {
9651 asc_dvc->in_critical_cnt--;
9652 DvcLeaveCritical(last_int_level);
9653 return (ERR);
9654 }
10733#if !CC_VERY_LONG_SG_LIST 9655#if !CC_VERY_LONG_SG_LIST
10734 if (sg_entry_cnt > ASC_MAX_SG_LIST) 9656 if (sg_entry_cnt > ASC_MAX_SG_LIST) {
10735 { 9657 asc_dvc->in_critical_cnt--;
10736 asc_dvc->in_critical_cnt--; 9658 DvcLeaveCritical(last_int_level);
10737 DvcLeaveCritical(last_int_level); 9659 return (ERR);
10738 return(ERR); 9660 }
10739 }
10740#endif /* !CC_VERY_LONG_SG_LIST */ 9661#endif /* !CC_VERY_LONG_SG_LIST */
10741 if (sg_entry_cnt == 1) { 9662 if (sg_entry_cnt == 1) {
10742 scsiq->q1.data_addr = (ADV_PADDR) sg_head->sg_list[0].addr; 9663 scsiq->q1.data_addr =
10743 scsiq->q1.data_cnt = (ADV_DCNT) sg_head->sg_list[0].bytes; 9664 (ADV_PADDR)sg_head->sg_list[0].addr;
10744 scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE); 9665 scsiq->q1.data_cnt =
10745 } 9666 (ADV_DCNT)sg_head->sg_list[0].bytes;
10746 sg_entry_cnt_minus_one = sg_entry_cnt - 1; 9667 scsiq->q1.cntl &= ~(QC_SG_HEAD | QC_SG_SWAP_QUEUE);
10747 } 9668 }
10748 scsi_cmd = scsiq->cdbptr[0]; 9669 sg_entry_cnt_minus_one = sg_entry_cnt - 1;
10749 disable_syn_offset_one_fix = FALSE; 9670 }
10750 if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) && 9671 scsi_cmd = scsiq->cdbptr[0];
10751 !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) { 9672 disable_syn_offset_one_fix = FALSE;
10752 if (scsiq->q1.cntl & QC_SG_HEAD) { 9673 if ((asc_dvc->pci_fix_asyn_xfer & scsiq->q1.target_id) &&
10753 data_cnt = 0; 9674 !(asc_dvc->pci_fix_asyn_xfer_always & scsiq->q1.target_id)) {
10754 for (i = 0; i < sg_entry_cnt; i++) { 9675 if (scsiq->q1.cntl & QC_SG_HEAD) {
10755 data_cnt += (ADV_DCNT) le32_to_cpu(sg_head->sg_list[i].bytes); 9676 data_cnt = 0;
10756 } 9677 for (i = 0; i < sg_entry_cnt; i++) {
10757 } else { 9678 data_cnt +=
10758 data_cnt = le32_to_cpu(scsiq->q1.data_cnt); 9679 (ADV_DCNT)le32_to_cpu(sg_head->sg_list[i].
10759 } 9680 bytes);
10760 if (data_cnt != 0UL) { 9681 }
10761 if (data_cnt < 512UL) { 9682 } else {
10762 disable_syn_offset_one_fix = TRUE; 9683 data_cnt = le32_to_cpu(scsiq->q1.data_cnt);
10763 } else { 9684 }
10764 for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST; i++) { 9685 if (data_cnt != 0UL) {
10765 disable_cmd = _syn_offset_one_disable_cmd[i]; 9686 if (data_cnt < 512UL) {
10766 if (disable_cmd == 0xFF) { 9687 disable_syn_offset_one_fix = TRUE;
10767 break; 9688 } else {
10768 } 9689 for (i = 0; i < ASC_SYN_OFFSET_ONE_DISABLE_LIST;
10769 if (scsi_cmd == disable_cmd) { 9690 i++) {
10770 disable_syn_offset_one_fix = TRUE; 9691 disable_cmd =
10771 break; 9692 _syn_offset_one_disable_cmd[i];
10772 } 9693 if (disable_cmd == 0xFF) {
10773 } 9694 break;
10774 } 9695 }
10775 } 9696 if (scsi_cmd == disable_cmd) {
10776 } 9697 disable_syn_offset_one_fix =
10777 if (disable_syn_offset_one_fix) { 9698 TRUE;
10778 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG; 9699 break;
10779 scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX | 9700 }
10780 ASC_TAG_FLAG_DISABLE_DISCONNECT); 9701 }
10781 } else { 9702 }
10782 scsiq->q2.tag_code &= 0x27; 9703 }
10783 } 9704 }
10784 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) { 9705 if (disable_syn_offset_one_fix) {
10785 if (asc_dvc->bug_fix_cntl) { 9706 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
10786 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) { 9707 scsiq->q2.tag_code |= (ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX |
10787 if ((scsi_cmd == READ_6) || 9708 ASC_TAG_FLAG_DISABLE_DISCONNECT);
10788 (scsi_cmd == READ_10)) { 9709 } else {
10789 addr = 9710 scsiq->q2.tag_code &= 0x27;
10790 (ADV_PADDR) le32_to_cpu( 9711 }
10791 sg_head->sg_list[sg_entry_cnt_minus_one].addr) + 9712 if ((scsiq->q1.cntl & QC_SG_HEAD) != 0) {
10792 (ADV_DCNT) le32_to_cpu( 9713 if (asc_dvc->bug_fix_cntl) {
10793 sg_head->sg_list[sg_entry_cnt_minus_one].bytes); 9714 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
10794 extra_bytes = (uchar) ((ushort) addr & 0x0003); 9715 if ((scsi_cmd == READ_6) ||
10795 if ((extra_bytes != 0) && 9716 (scsi_cmd == READ_10)) {
10796 ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) 9717 addr =
10797 == 0)) { 9718 (ADV_PADDR)le32_to_cpu(sg_head->
10798 scsiq->q2.tag_code |= ASC_TAG_FLAG_EXTRA_BYTES; 9719 sg_list
10799 scsiq->q1.extra_bytes = extra_bytes; 9720 [sg_entry_cnt_minus_one].
10800 data_cnt = le32_to_cpu( 9721 addr) +
10801 sg_head->sg_list[sg_entry_cnt_minus_one].bytes); 9722 (ADV_DCNT)le32_to_cpu(sg_head->
10802 data_cnt -= (ASC_DCNT) extra_bytes; 9723 sg_list
10803 sg_head->sg_list[sg_entry_cnt_minus_one].bytes = 9724 [sg_entry_cnt_minus_one].
10804 cpu_to_le32(data_cnt); 9725 bytes);
10805 } 9726 extra_bytes =
10806 } 9727 (uchar)((ushort)addr & 0x0003);
10807 } 9728 if ((extra_bytes != 0)
10808 } 9729 &&
10809 sg_head->entry_to_copy = sg_head->entry_cnt; 9730 ((scsiq->q2.
9731 tag_code &
9732 ASC_TAG_FLAG_EXTRA_BYTES)
9733 == 0)) {
9734 scsiq->q2.tag_code |=
9735 ASC_TAG_FLAG_EXTRA_BYTES;
9736 scsiq->q1.extra_bytes =
9737 extra_bytes;
9738 data_cnt =
9739 le32_to_cpu(sg_head->
9740 sg_list
9741 [sg_entry_cnt_minus_one].
9742 bytes);
9743 data_cnt -=
9744 (ASC_DCNT) extra_bytes;
9745 sg_head->
9746 sg_list
9747 [sg_entry_cnt_minus_one].
9748 bytes =
9749 cpu_to_le32(data_cnt);
9750 }
9751 }
9752 }
9753 }
9754 sg_head->entry_to_copy = sg_head->entry_cnt;
10810#if CC_VERY_LONG_SG_LIST 9755#if CC_VERY_LONG_SG_LIST
10811 /* 9756 /*
10812 * Set the sg_entry_cnt to the maximum possible. The rest of 9757 * Set the sg_entry_cnt to the maximum possible. The rest of
10813 * the SG elements will be copied when the RISC completes the 9758 * the SG elements will be copied when the RISC completes the
10814 * SG elements that fit and halts. 9759 * SG elements that fit and halts.
10815 */ 9760 */
10816 if (sg_entry_cnt > ASC_MAX_SG_LIST) 9761 if (sg_entry_cnt > ASC_MAX_SG_LIST) {
10817 { 9762 sg_entry_cnt = ASC_MAX_SG_LIST;
10818 sg_entry_cnt = ASC_MAX_SG_LIST; 9763 }
10819 }
10820#endif /* CC_VERY_LONG_SG_LIST */ 9764#endif /* CC_VERY_LONG_SG_LIST */
10821 n_q_required = AscSgListToQueue(sg_entry_cnt); 9765 n_q_required = AscSgListToQueue(sg_entry_cnt);
10822 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >= 9766 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
10823 (uint) n_q_required) || ((scsiq->q1.cntl & QC_URGENT) != 0)) { 9767 (uint) n_q_required)
10824 if ((sta = AscSendScsiQueue(asc_dvc, scsiq, 9768 || ((scsiq->q1.cntl & QC_URGENT) != 0)) {
10825 n_q_required)) == 1) { 9769 if ((sta =
10826 asc_dvc->in_critical_cnt--; 9770 AscSendScsiQueue(asc_dvc, scsiq,
10827 if (asc_exe_callback != 0) { 9771 n_q_required)) == 1) {
10828 (*asc_exe_callback) (asc_dvc, scsiq); 9772 asc_dvc->in_critical_cnt--;
10829 } 9773 if (asc_exe_callback != 0) {
10830 DvcLeaveCritical(last_int_level); 9774 (*asc_exe_callback) (asc_dvc, scsiq);
10831 return (sta); 9775 }
10832 } 9776 DvcLeaveCritical(last_int_level);
10833 } 9777 return (sta);
10834 } else { 9778 }
10835 if (asc_dvc->bug_fix_cntl) { 9779 }
10836 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) { 9780 } else {
10837 if ((scsi_cmd == READ_6) || 9781 if (asc_dvc->bug_fix_cntl) {
10838 (scsi_cmd == READ_10)) { 9782 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_IF_NOT_DWB) {
10839 addr = le32_to_cpu(scsiq->q1.data_addr) + 9783 if ((scsi_cmd == READ_6) ||
10840 le32_to_cpu(scsiq->q1.data_cnt); 9784 (scsi_cmd == READ_10)) {
10841 extra_bytes = (uchar) ((ushort) addr & 0x0003); 9785 addr =
10842 if ((extra_bytes != 0) && 9786 le32_to_cpu(scsiq->q1.data_addr) +
10843 ((scsiq->q2.tag_code & ASC_TAG_FLAG_EXTRA_BYTES) 9787 le32_to_cpu(scsiq->q1.data_cnt);
10844 == 0)) { 9788 extra_bytes =
10845 data_cnt = le32_to_cpu(scsiq->q1.data_cnt); 9789 (uchar)((ushort)addr & 0x0003);
10846 if (((ushort) data_cnt & 0x01FF) == 0) { 9790 if ((extra_bytes != 0)
10847 scsiq->q2.tag_code |= ASC_TAG_FLAG_EXTRA_BYTES; 9791 &&
10848 data_cnt -= (ASC_DCNT) extra_bytes; 9792 ((scsiq->q2.
10849 scsiq->q1.data_cnt = cpu_to_le32(data_cnt); 9793 tag_code &
10850 scsiq->q1.extra_bytes = extra_bytes; 9794 ASC_TAG_FLAG_EXTRA_BYTES)
10851 } 9795 == 0)) {
10852 } 9796 data_cnt =
10853 } 9797 le32_to_cpu(scsiq->q1.
10854 } 9798 data_cnt);
10855 } 9799 if (((ushort)data_cnt & 0x01FF)
10856 n_q_required = 1; 9800 == 0) {
10857 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) || 9801 scsiq->q2.tag_code |=
10858 ((scsiq->q1.cntl & QC_URGENT) != 0)) { 9802 ASC_TAG_FLAG_EXTRA_BYTES;
10859 if ((sta = AscSendScsiQueue(asc_dvc, scsiq, 9803 data_cnt -= (ASC_DCNT)
10860 n_q_required)) == 1) { 9804 extra_bytes;
10861 asc_dvc->in_critical_cnt--; 9805 scsiq->q1.data_cnt =
10862 if (asc_exe_callback != 0) { 9806 cpu_to_le32
10863 (*asc_exe_callback) (asc_dvc, scsiq); 9807 (data_cnt);
10864 } 9808 scsiq->q1.extra_bytes =
10865 DvcLeaveCritical(last_int_level); 9809 extra_bytes;
10866 return (sta); 9810 }
10867 } 9811 }
10868 } 9812 }
10869 } 9813 }
10870 asc_dvc->in_critical_cnt--; 9814 }
10871 DvcLeaveCritical(last_int_level); 9815 n_q_required = 1;
10872 return (sta); 9816 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
9817 ((scsiq->q1.cntl & QC_URGENT) != 0)) {
9818 if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
9819 n_q_required)) == 1) {
9820 asc_dvc->in_critical_cnt--;
9821 if (asc_exe_callback != 0) {
9822 (*asc_exe_callback) (asc_dvc, scsiq);
9823 }
9824 DvcLeaveCritical(last_int_level);
9825 return (sta);
9826 }
9827 }
9828 }
9829 asc_dvc->in_critical_cnt--;
9830 DvcLeaveCritical(last_int_level);
9831 return (sta);
10873} 9832}
10874 9833
10875STATIC int 9834static int
10876AscSendScsiQueue( 9835AscSendScsiQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar n_q_required)
10877 ASC_DVC_VAR *asc_dvc,
10878 ASC_SCSI_Q *scsiq,
10879 uchar n_q_required
10880)
10881{ 9836{
10882 PortAddr iop_base; 9837 PortAddr iop_base;
10883 uchar free_q_head; 9838 uchar free_q_head;
10884 uchar next_qp; 9839 uchar next_qp;
10885 uchar tid_no; 9840 uchar tid_no;
10886 uchar target_ix; 9841 uchar target_ix;
10887 int sta; 9842 int sta;
10888 9843
10889 iop_base = asc_dvc->iop_base; 9844 iop_base = asc_dvc->iop_base;
10890 target_ix = scsiq->q2.target_ix; 9845 target_ix = scsiq->q2.target_ix;
10891 tid_no = ASC_TIX_TO_TID(target_ix); 9846 tid_no = ASC_TIX_TO_TID(target_ix);
10892 sta = 0; 9847 sta = 0;
10893 free_q_head = (uchar) AscGetVarFreeQHead(iop_base); 9848 free_q_head = (uchar)AscGetVarFreeQHead(iop_base);
10894 if (n_q_required > 1) { 9849 if (n_q_required > 1) {
10895 if ((next_qp = AscAllocMultipleFreeQueue(iop_base, 9850 if ((next_qp = AscAllocMultipleFreeQueue(iop_base,
10896 free_q_head, (uchar) (n_q_required))) 9851 free_q_head, (uchar)
10897 != (uchar) ASC_QLINK_END) { 9852 (n_q_required)))
10898 asc_dvc->last_q_shortage = 0; 9853 != (uchar)ASC_QLINK_END) {
10899 scsiq->sg_head->queue_cnt = n_q_required - 1; 9854 asc_dvc->last_q_shortage = 0;
10900 scsiq->q1.q_no = free_q_head; 9855 scsiq->sg_head->queue_cnt = n_q_required - 1;
10901 if ((sta = AscPutReadySgListQueue(asc_dvc, scsiq, 9856 scsiq->q1.q_no = free_q_head;
10902 free_q_head)) == 1) { 9857 if ((sta = AscPutReadySgListQueue(asc_dvc, scsiq,
10903 AscPutVarFreeQHead(iop_base, next_qp); 9858 free_q_head)) == 1) {
10904 asc_dvc->cur_total_qng += (uchar) (n_q_required); 9859 AscPutVarFreeQHead(iop_base, next_qp);
10905 asc_dvc->cur_dvc_qng[tid_no]++; 9860 asc_dvc->cur_total_qng += (uchar)(n_q_required);
10906 } 9861 asc_dvc->cur_dvc_qng[tid_no]++;
10907 return (sta); 9862 }
10908 } 9863 return (sta);
10909 } else if (n_q_required == 1) { 9864 }
10910 if ((next_qp = AscAllocFreeQueue(iop_base, 9865 } else if (n_q_required == 1) {
10911 free_q_head)) != ASC_QLINK_END) { 9866 if ((next_qp = AscAllocFreeQueue(iop_base,
10912 scsiq->q1.q_no = free_q_head; 9867 free_q_head)) !=
10913 if ((sta = AscPutReadyQueue(asc_dvc, scsiq, 9868 ASC_QLINK_END) {
10914 free_q_head)) == 1) { 9869 scsiq->q1.q_no = free_q_head;
10915 AscPutVarFreeQHead(iop_base, next_qp); 9870 if ((sta = AscPutReadyQueue(asc_dvc, scsiq,
10916 asc_dvc->cur_total_qng++; 9871 free_q_head)) == 1) {
10917 asc_dvc->cur_dvc_qng[tid_no]++; 9872 AscPutVarFreeQHead(iop_base, next_qp);
10918 } 9873 asc_dvc->cur_total_qng++;
10919 return (sta); 9874 asc_dvc->cur_dvc_qng[tid_no]++;
10920 } 9875 }
10921 } 9876 return (sta);
10922 return (sta); 9877 }
9878 }
9879 return (sta);
10923} 9880}
10924 9881
10925STATIC int 9882static int AscSgListToQueue(int sg_list)
10926AscSgListToQueue(
10927 int sg_list
10928)
10929{ 9883{
10930 int n_sg_list_qs; 9884 int n_sg_list_qs;
10931 9885
10932 n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q); 9886 n_sg_list_qs = ((sg_list - 1) / ASC_SG_LIST_PER_Q);
10933 if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0) 9887 if (((sg_list - 1) % ASC_SG_LIST_PER_Q) != 0)
10934 n_sg_list_qs++; 9888 n_sg_list_qs++;
10935 return (n_sg_list_qs + 1); 9889 return (n_sg_list_qs + 1);
10936} 9890}
10937 9891
10938 9892static uint
10939STATIC uint 9893AscGetNumOfFreeQueue(ASC_DVC_VAR *asc_dvc, uchar target_ix, uchar n_qs)
10940AscGetNumOfFreeQueue(
10941 ASC_DVC_VAR *asc_dvc,
10942 uchar target_ix,
10943 uchar n_qs
10944)
10945{ 9894{
10946 uint cur_used_qs; 9895 uint cur_used_qs;
10947 uint cur_free_qs; 9896 uint cur_free_qs;
10948 ASC_SCSI_BIT_ID_TYPE target_id; 9897 ASC_SCSI_BIT_ID_TYPE target_id;
10949 uchar tid_no; 9898 uchar tid_no;
10950 9899
10951 target_id = ASC_TIX_TO_TARGET_ID(target_ix); 9900 target_id = ASC_TIX_TO_TARGET_ID(target_ix);
10952 tid_no = ASC_TIX_TO_TID(target_ix); 9901 tid_no = ASC_TIX_TO_TID(target_ix);
10953 if ((asc_dvc->unit_not_ready & target_id) || 9902 if ((asc_dvc->unit_not_ready & target_id) ||
10954 (asc_dvc->queue_full_or_busy & target_id)) { 9903 (asc_dvc->queue_full_or_busy & target_id)) {
10955 return (0); 9904 return (0);
10956 } 9905 }
10957 if (n_qs == 1) { 9906 if (n_qs == 1) {
10958 cur_used_qs = (uint) asc_dvc->cur_total_qng + 9907 cur_used_qs = (uint) asc_dvc->cur_total_qng +
10959 (uint) asc_dvc->last_q_shortage + 9908 (uint) asc_dvc->last_q_shortage + (uint) ASC_MIN_FREE_Q;
10960 (uint) ASC_MIN_FREE_Q; 9909 } else {
10961 } else { 9910 cur_used_qs = (uint) asc_dvc->cur_total_qng +
10962 cur_used_qs = (uint) asc_dvc->cur_total_qng + 9911 (uint) ASC_MIN_FREE_Q;
10963 (uint) ASC_MIN_FREE_Q; 9912 }
10964 } 9913 if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) {
10965 if ((uint) (cur_used_qs + n_qs) <= (uint) asc_dvc->max_total_qng) { 9914 cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs;
10966 cur_free_qs = (uint) asc_dvc->max_total_qng - cur_used_qs; 9915 if (asc_dvc->cur_dvc_qng[tid_no] >=
10967 if (asc_dvc->cur_dvc_qng[tid_no] >= 9916 asc_dvc->max_dvc_qng[tid_no]) {
10968 asc_dvc->max_dvc_qng[tid_no]) { 9917 return (0);
10969 return (0); 9918 }
10970 } 9919 return (cur_free_qs);
10971 return (cur_free_qs); 9920 }
10972 } 9921 if (n_qs > 1) {
10973 if (n_qs > 1) { 9922 if ((n_qs > asc_dvc->last_q_shortage)
10974 if ((n_qs > asc_dvc->last_q_shortage) && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) { 9923 && (n_qs <= (asc_dvc->max_total_qng - ASC_MIN_FREE_Q))) {
10975 asc_dvc->last_q_shortage = n_qs; 9924 asc_dvc->last_q_shortage = n_qs;
10976 } 9925 }
10977 } 9926 }
10978 return (0); 9927 return (0);
10979} 9928}
10980 9929
10981STATIC int 9930static int AscPutReadyQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
10982AscPutReadyQueue(
10983 ASC_DVC_VAR *asc_dvc,
10984 ASC_SCSI_Q *scsiq,
10985 uchar q_no
10986)
10987{ 9931{
10988 ushort q_addr; 9932 ushort q_addr;
10989 uchar tid_no; 9933 uchar tid_no;
10990 uchar sdtr_data; 9934 uchar sdtr_data;
10991 uchar syn_period_ix; 9935 uchar syn_period_ix;
10992 uchar syn_offset; 9936 uchar syn_offset;
10993 PortAddr iop_base; 9937 PortAddr iop_base;
10994 9938
10995 iop_base = asc_dvc->iop_base; 9939 iop_base = asc_dvc->iop_base;
10996 if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) && 9940 if (((asc_dvc->init_sdtr & scsiq->q1.target_id) != 0) &&
10997 ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) { 9941 ((asc_dvc->sdtr_done & scsiq->q1.target_id) == 0)) {
10998 tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix); 9942 tid_no = ASC_TIX_TO_TID(scsiq->q2.target_ix);
10999 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no); 9943 sdtr_data = AscGetMCodeInitSDTRAtID(iop_base, tid_no);
11000 syn_period_ix = (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1); 9944 syn_period_ix =
11001 syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET; 9945 (sdtr_data >> 4) & (asc_dvc->max_sdtr_index - 1);
11002 AscMsgOutSDTR(asc_dvc, 9946 syn_offset = sdtr_data & ASC_SYN_MAX_OFFSET;
11003 asc_dvc->sdtr_period_tbl[syn_period_ix], 9947 AscMsgOutSDTR(asc_dvc,
11004 syn_offset); 9948 asc_dvc->sdtr_period_tbl[syn_period_ix],
11005 scsiq->q1.cntl |= QC_MSG_OUT; 9949 syn_offset);
11006 } 9950 scsiq->q1.cntl |= QC_MSG_OUT;
11007 q_addr = ASC_QNO_TO_QADDR(q_no); 9951 }
11008 if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) { 9952 q_addr = ASC_QNO_TO_QADDR(q_no);
11009 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG ; 9953 if ((scsiq->q1.target_id & asc_dvc->use_tagged_qng) == 0) {
11010 } 9954 scsiq->q2.tag_code &= ~MSG_SIMPLE_TAG;
11011 scsiq->q1.status = QS_FREE; 9955 }
11012 AscMemWordCopyPtrToLram(iop_base, 9956 scsiq->q1.status = QS_FREE;
11013 q_addr + ASC_SCSIQ_CDB_BEG, 9957 AscMemWordCopyPtrToLram(iop_base,
11014 (uchar *) scsiq->cdbptr, 9958 q_addr + ASC_SCSIQ_CDB_BEG,
11015 scsiq->q2.cdb_len >> 1); 9959 (uchar *)scsiq->cdbptr, scsiq->q2.cdb_len >> 1);
11016 9960
11017 DvcPutScsiQ(iop_base, 9961 DvcPutScsiQ(iop_base,
11018 q_addr + ASC_SCSIQ_CPY_BEG, 9962 q_addr + ASC_SCSIQ_CPY_BEG,
11019 (uchar *) &scsiq->q1.cntl, 9963 (uchar *)&scsiq->q1.cntl,
11020 ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1); 9964 ((sizeof(ASC_SCSIQ_1) + sizeof(ASC_SCSIQ_2)) / 2) - 1);
11021 AscWriteLramWord(iop_base, 9965 AscWriteLramWord(iop_base,
11022 (ushort) (q_addr + (ushort) ASC_SCSIQ_B_STATUS), 9966 (ushort)(q_addr + (ushort)ASC_SCSIQ_B_STATUS),
11023 (ushort) (((ushort) scsiq->q1.q_no << 8) | (ushort) QS_READY)); 9967 (ushort)(((ushort)scsiq->q1.
11024 return (1); 9968 q_no << 8) | (ushort)QS_READY));
9969 return (1);
11025} 9970}
11026 9971
11027STATIC int 9972static int
11028AscPutReadySgListQueue( 9973AscPutReadySgListQueue(ASC_DVC_VAR *asc_dvc, ASC_SCSI_Q *scsiq, uchar q_no)
11029 ASC_DVC_VAR *asc_dvc,
11030 ASC_SCSI_Q *scsiq,
11031 uchar q_no
11032)
11033{ 9974{
11034 int sta; 9975 int sta;
11035 int i; 9976 int i;
11036 ASC_SG_HEAD *sg_head; 9977 ASC_SG_HEAD *sg_head;
11037 ASC_SG_LIST_Q scsi_sg_q; 9978 ASC_SG_LIST_Q scsi_sg_q;
11038 ASC_DCNT saved_data_addr; 9979 ASC_DCNT saved_data_addr;
11039 ASC_DCNT saved_data_cnt; 9980 ASC_DCNT saved_data_cnt;
11040 PortAddr iop_base; 9981 PortAddr iop_base;
11041 ushort sg_list_dwords; 9982 ushort sg_list_dwords;
11042 ushort sg_index; 9983 ushort sg_index;
11043 ushort sg_entry_cnt; 9984 ushort sg_entry_cnt;
11044 ushort q_addr; 9985 ushort q_addr;
11045 uchar next_qp; 9986 uchar next_qp;
11046 9987
11047 iop_base = asc_dvc->iop_base; 9988 iop_base = asc_dvc->iop_base;
11048 sg_head = scsiq->sg_head; 9989 sg_head = scsiq->sg_head;
11049 saved_data_addr = scsiq->q1.data_addr; 9990 saved_data_addr = scsiq->q1.data_addr;
11050 saved_data_cnt = scsiq->q1.data_cnt; 9991 saved_data_cnt = scsiq->q1.data_cnt;
11051 scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr; 9992 scsiq->q1.data_addr = (ASC_PADDR) sg_head->sg_list[0].addr;
11052 scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes; 9993 scsiq->q1.data_cnt = (ASC_DCNT) sg_head->sg_list[0].bytes;
11053#if CC_VERY_LONG_SG_LIST 9994#if CC_VERY_LONG_SG_LIST
11054 /* 9995 /*
11055 * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST 9996 * If sg_head->entry_cnt is greater than ASC_MAX_SG_LIST
11056 * then not all SG elements will fit in the allocated queues. 9997 * then not all SG elements will fit in the allocated queues.
11057 * The rest of the SG elements will be copied when the RISC 9998 * The rest of the SG elements will be copied when the RISC
11058 * completes the SG elements that fit and halts. 9999 * completes the SG elements that fit and halts.
11059 */ 10000 */
11060 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) 10001 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
11061 { 10002 /*
11062 /* 10003 * Set sg_entry_cnt to be the number of SG elements that
11063 * Set sg_entry_cnt to be the number of SG elements that 10004 * will fit in the allocated SG queues. It is minus 1, because
11064 * will fit in the allocated SG queues. It is minus 1, because 10005 * the first SG element is handled above. ASC_MAX_SG_LIST is
11065 * the first SG element is handled above. ASC_MAX_SG_LIST is 10006 * already inflated by 1 to account for this. For example it
11066 * already inflated by 1 to account for this. For example it 10007 * may be 50 which is 1 + 7 queues * 7 SG elements.
11067 * may be 50 which is 1 + 7 queues * 7 SG elements. 10008 */
11068 */ 10009 sg_entry_cnt = ASC_MAX_SG_LIST - 1;
11069 sg_entry_cnt = ASC_MAX_SG_LIST - 1; 10010
11070 10011 /*
11071 /* 10012 * Keep track of remaining number of SG elements that will
11072 * Keep track of remaining number of SG elements that will 10013 * need to be handled from a_isr.c.
11073 * need to be handled from a_isr.c. 10014 */
11074 */ 10015 scsiq->remain_sg_entry_cnt =
11075 scsiq->remain_sg_entry_cnt = sg_head->entry_cnt - ASC_MAX_SG_LIST; 10016 sg_head->entry_cnt - ASC_MAX_SG_LIST;
11076 } else 10017 } else {
11077 {
11078#endif /* CC_VERY_LONG_SG_LIST */ 10018#endif /* CC_VERY_LONG_SG_LIST */
11079 /* 10019 /*
11080 * Set sg_entry_cnt to be the number of SG elements that 10020 * Set sg_entry_cnt to be the number of SG elements that
11081 * will fit in the allocated SG queues. It is minus 1, because 10021 * will fit in the allocated SG queues. It is minus 1, because
11082 * the first SG element is handled above. 10022 * the first SG element is handled above.
11083 */ 10023 */
11084 sg_entry_cnt = sg_head->entry_cnt - 1; 10024 sg_entry_cnt = sg_head->entry_cnt - 1;
11085#if CC_VERY_LONG_SG_LIST 10025#if CC_VERY_LONG_SG_LIST
11086 } 10026 }
11087#endif /* CC_VERY_LONG_SG_LIST */ 10027#endif /* CC_VERY_LONG_SG_LIST */
11088 if (sg_entry_cnt != 0) { 10028 if (sg_entry_cnt != 0) {
11089 scsiq->q1.cntl |= QC_SG_HEAD; 10029 scsiq->q1.cntl |= QC_SG_HEAD;
11090 q_addr = ASC_QNO_TO_QADDR(q_no); 10030 q_addr = ASC_QNO_TO_QADDR(q_no);
11091 sg_index = 1; 10031 sg_index = 1;
11092 scsiq->q1.sg_queue_cnt = sg_head->queue_cnt; 10032 scsiq->q1.sg_queue_cnt = sg_head->queue_cnt;
11093 scsi_sg_q.sg_head_qp = q_no; 10033 scsi_sg_q.sg_head_qp = q_no;
11094 scsi_sg_q.cntl = QCSG_SG_XFER_LIST; 10034 scsi_sg_q.cntl = QCSG_SG_XFER_LIST;
11095 for (i = 0; i < sg_head->queue_cnt; i++) { 10035 for (i = 0; i < sg_head->queue_cnt; i++) {
11096 scsi_sg_q.seq_no = i + 1; 10036 scsi_sg_q.seq_no = i + 1;
11097 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) { 10037 if (sg_entry_cnt > ASC_SG_LIST_PER_Q) {
11098 sg_list_dwords = (uchar) (ASC_SG_LIST_PER_Q * 2); 10038 sg_list_dwords = (uchar)(ASC_SG_LIST_PER_Q * 2);
11099 sg_entry_cnt -= ASC_SG_LIST_PER_Q; 10039 sg_entry_cnt -= ASC_SG_LIST_PER_Q;
11100 if (i == 0) { 10040 if (i == 0) {
11101 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q; 10041 scsi_sg_q.sg_list_cnt =
11102 scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q; 10042 ASC_SG_LIST_PER_Q;
11103 } else { 10043 scsi_sg_q.sg_cur_list_cnt =
11104 scsi_sg_q.sg_list_cnt = ASC_SG_LIST_PER_Q - 1; 10044 ASC_SG_LIST_PER_Q;
11105 scsi_sg_q.sg_cur_list_cnt = ASC_SG_LIST_PER_Q - 1; 10045 } else {
11106 } 10046 scsi_sg_q.sg_list_cnt =
11107 } else { 10047 ASC_SG_LIST_PER_Q - 1;
10048 scsi_sg_q.sg_cur_list_cnt =
10049 ASC_SG_LIST_PER_Q - 1;
10050 }
10051 } else {
11108#if CC_VERY_LONG_SG_LIST 10052#if CC_VERY_LONG_SG_LIST
11109 /* 10053 /*
11110 * This is the last SG queue in the list of 10054 * This is the last SG queue in the list of
11111 * allocated SG queues. If there are more 10055 * allocated SG queues. If there are more
11112 * SG elements than will fit in the allocated 10056 * SG elements than will fit in the allocated
11113 * queues, then set the QCSG_SG_XFER_MORE flag. 10057 * queues, then set the QCSG_SG_XFER_MORE flag.
11114 */ 10058 */
11115 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) 10059 if (sg_head->entry_cnt > ASC_MAX_SG_LIST) {
11116 { 10060 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE;
11117 scsi_sg_q.cntl |= QCSG_SG_XFER_MORE; 10061 } else {
11118 } else
11119 {
11120#endif /* CC_VERY_LONG_SG_LIST */ 10062#endif /* CC_VERY_LONG_SG_LIST */
11121 scsi_sg_q.cntl |= QCSG_SG_XFER_END; 10063 scsi_sg_q.cntl |= QCSG_SG_XFER_END;
11122#if CC_VERY_LONG_SG_LIST 10064#if CC_VERY_LONG_SG_LIST
11123 } 10065 }
11124#endif /* CC_VERY_LONG_SG_LIST */ 10066#endif /* CC_VERY_LONG_SG_LIST */
11125 sg_list_dwords = sg_entry_cnt << 1; 10067 sg_list_dwords = sg_entry_cnt << 1;
11126 if (i == 0) { 10068 if (i == 0) {
11127 scsi_sg_q.sg_list_cnt = sg_entry_cnt; 10069 scsi_sg_q.sg_list_cnt = sg_entry_cnt;
11128 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt; 10070 scsi_sg_q.sg_cur_list_cnt =
11129 } else { 10071 sg_entry_cnt;
11130 scsi_sg_q.sg_list_cnt = sg_entry_cnt - 1; 10072 } else {
11131 scsi_sg_q.sg_cur_list_cnt = sg_entry_cnt - 1; 10073 scsi_sg_q.sg_list_cnt =
11132 } 10074 sg_entry_cnt - 1;
11133 sg_entry_cnt = 0; 10075 scsi_sg_q.sg_cur_list_cnt =
11134 } 10076 sg_entry_cnt - 1;
11135 next_qp = AscReadLramByte(iop_base, 10077 }
11136 (ushort) (q_addr + ASC_SCSIQ_B_FWD)); 10078 sg_entry_cnt = 0;
11137 scsi_sg_q.q_no = next_qp; 10079 }
11138 q_addr = ASC_QNO_TO_QADDR(next_qp); 10080 next_qp = AscReadLramByte(iop_base,
11139 AscMemWordCopyPtrToLram(iop_base, 10081 (ushort)(q_addr +
11140 q_addr + ASC_SCSIQ_SGHD_CPY_BEG, 10082 ASC_SCSIQ_B_FWD));
11141 (uchar *) &scsi_sg_q, 10083 scsi_sg_q.q_no = next_qp;
11142 sizeof(ASC_SG_LIST_Q) >> 1); 10084 q_addr = ASC_QNO_TO_QADDR(next_qp);
11143 AscMemDWordCopyPtrToLram(iop_base, 10085 AscMemWordCopyPtrToLram(iop_base,
11144 q_addr + ASC_SGQ_LIST_BEG, 10086 q_addr + ASC_SCSIQ_SGHD_CPY_BEG,
11145 (uchar *) &sg_head->sg_list[sg_index], 10087 (uchar *)&scsi_sg_q,
11146 sg_list_dwords); 10088 sizeof(ASC_SG_LIST_Q) >> 1);
11147 sg_index += ASC_SG_LIST_PER_Q; 10089 AscMemDWordCopyPtrToLram(iop_base,
11148 scsiq->next_sg_index = sg_index; 10090 q_addr + ASC_SGQ_LIST_BEG,
11149 } 10091 (uchar *)&sg_head->
11150 } else { 10092 sg_list[sg_index],
11151 scsiq->q1.cntl &= ~QC_SG_HEAD; 10093 sg_list_dwords);
11152 } 10094 sg_index += ASC_SG_LIST_PER_Q;
11153 sta = AscPutReadyQueue(asc_dvc, scsiq, q_no); 10095 scsiq->next_sg_index = sg_index;
11154 scsiq->q1.data_addr = saved_data_addr; 10096 }
11155 scsiq->q1.data_cnt = saved_data_cnt; 10097 } else {
11156 return (sta); 10098 scsiq->q1.cntl &= ~QC_SG_HEAD;
10099 }
10100 sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
10101 scsiq->q1.data_addr = saved_data_addr;
10102 scsiq->q1.data_cnt = saved_data_cnt;
10103 return (sta);
11157} 10104}
11158 10105
11159STATIC int 10106static int
11160AscSetRunChipSynRegAtID( 10107AscSetRunChipSynRegAtID(PortAddr iop_base, uchar tid_no, uchar sdtr_data)
11161 PortAddr iop_base,
11162 uchar tid_no,
11163 uchar sdtr_data
11164)
11165{ 10108{
11166 int sta = FALSE; 10109 int sta = FALSE;
11167 10110
11168 if (AscHostReqRiscHalt(iop_base)) { 10111 if (AscHostReqRiscHalt(iop_base)) {
11169 sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data); 10112 sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
11170 AscStartChip(iop_base); 10113 AscStartChip(iop_base);
11171 return (sta); 10114 return (sta);
11172 } 10115 }
11173 return (sta); 10116 return (sta);
11174} 10117}
11175 10118
11176STATIC int 10119static int AscSetChipSynRegAtID(PortAddr iop_base, uchar id, uchar sdtr_data)
11177AscSetChipSynRegAtID(
11178 PortAddr iop_base,
11179 uchar id,
11180 uchar sdtr_data
11181)
11182{ 10120{
11183 ASC_SCSI_BIT_ID_TYPE org_id; 10121 ASC_SCSI_BIT_ID_TYPE org_id;
11184 int i; 10122 int i;
11185 int sta = TRUE; 10123 int sta = TRUE;
11186 10124
11187 AscSetBank(iop_base, 1); 10125 AscSetBank(iop_base, 1);
11188 org_id = AscReadChipDvcID(iop_base); 10126 org_id = AscReadChipDvcID(iop_base);
11189 for (i = 0; i <= ASC_MAX_TID; i++) { 10127 for (i = 0; i <= ASC_MAX_TID; i++) {
11190 if (org_id == (0x01 << i)) 10128 if (org_id == (0x01 << i))
11191 break; 10129 break;
11192 } 10130 }
11193 org_id = (ASC_SCSI_BIT_ID_TYPE) i; 10131 org_id = (ASC_SCSI_BIT_ID_TYPE) i;
11194 AscWriteChipDvcID(iop_base, id); 10132 AscWriteChipDvcID(iop_base, id);
11195 if (AscReadChipDvcID(iop_base) == (0x01 << id)) { 10133 if (AscReadChipDvcID(iop_base) == (0x01 << id)) {
11196 AscSetBank(iop_base, 0); 10134 AscSetBank(iop_base, 0);
11197 AscSetChipSyn(iop_base, sdtr_data); 10135 AscSetChipSyn(iop_base, sdtr_data);
11198 if (AscGetChipSyn(iop_base) != sdtr_data) { 10136 if (AscGetChipSyn(iop_base) != sdtr_data) {
11199 sta = FALSE; 10137 sta = FALSE;
11200 } 10138 }
11201 } else { 10139 } else {
11202 sta = FALSE; 10140 sta = FALSE;
11203 } 10141 }
11204 AscSetBank(iop_base, 1); 10142 AscSetBank(iop_base, 1);
11205 AscWriteChipDvcID(iop_base, org_id); 10143 AscWriteChipDvcID(iop_base, org_id);
11206 AscSetBank(iop_base, 0); 10144 AscSetBank(iop_base, 0);
11207 return (sta); 10145 return (sta);
11208} 10146}
11209 10147
11210STATIC ushort 10148static ushort AscInitLram(ASC_DVC_VAR *asc_dvc)
11211AscInitLram(
11212 ASC_DVC_VAR *asc_dvc
11213)
11214{ 10149{
11215 uchar i; 10150 uchar i;
11216 ushort s_addr; 10151 ushort s_addr;
11217 PortAddr iop_base; 10152 PortAddr iop_base;
11218 ushort warn_code; 10153 ushort warn_code;
11219 10154
11220 iop_base = asc_dvc->iop_base; 10155 iop_base = asc_dvc->iop_base;
11221 warn_code = 0; 10156 warn_code = 0;
11222 AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0, 10157 AscMemWordSetLram(iop_base, ASC_QADR_BEG, 0,
11223 (ushort) (((int) (asc_dvc->max_total_qng + 2 + 1) * 64) >> 1) 10158 (ushort)(((int)(asc_dvc->max_total_qng + 2 + 1) *
11224); 10159 64) >> 1)
11225 i = ASC_MIN_ACTIVE_QNO; 10160 );
11226 s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE; 10161 i = ASC_MIN_ACTIVE_QNO;
11227 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD), 10162 s_addr = ASC_QADR_BEG + ASC_QBLK_SIZE;
11228 (uchar) (i + 1)); 10163 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
11229 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD), 10164 (uchar)(i + 1));
11230 (uchar) (asc_dvc->max_total_qng)); 10165 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
11231 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO), 10166 (uchar)(asc_dvc->max_total_qng));
11232 (uchar) i); 10167 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
11233 i++; 10168 (uchar)i);
11234 s_addr += ASC_QBLK_SIZE; 10169 i++;
11235 for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) { 10170 s_addr += ASC_QBLK_SIZE;
11236 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD), 10171 for (; i < asc_dvc->max_total_qng; i++, s_addr += ASC_QBLK_SIZE) {
11237 (uchar) (i + 1)); 10172 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
11238 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD), 10173 (uchar)(i + 1));
11239 (uchar) (i - 1)); 10174 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
11240 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO), 10175 (uchar)(i - 1));
11241 (uchar) i); 10176 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
11242 } 10177 (uchar)i);
11243 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_FWD), 10178 }
11244 (uchar) ASC_QLINK_END); 10179 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_FWD),
11245 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_BWD), 10180 (uchar)ASC_QLINK_END);
11246 (uchar) (asc_dvc->max_total_qng - 1)); 10181 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_BWD),
11247 AscWriteLramByte(iop_base, (ushort) (s_addr + ASC_SCSIQ_B_QNO), 10182 (uchar)(asc_dvc->max_total_qng - 1));
11248 (uchar) asc_dvc->max_total_qng); 10183 AscWriteLramByte(iop_base, (ushort)(s_addr + ASC_SCSIQ_B_QNO),
11249 i++; 10184 (uchar)asc_dvc->max_total_qng);
11250 s_addr += ASC_QBLK_SIZE; 10185 i++;
11251 for (; i <= (uchar) (asc_dvc->max_total_qng + 3); 10186 s_addr += ASC_QBLK_SIZE;
11252 i++, s_addr += ASC_QBLK_SIZE) { 10187 for (; i <= (uchar)(asc_dvc->max_total_qng + 3);
11253 AscWriteLramByte(iop_base, 10188 i++, s_addr += ASC_QBLK_SIZE) {
11254 (ushort) (s_addr + (ushort) ASC_SCSIQ_B_FWD), i); 10189 AscWriteLramByte(iop_base,
11255 AscWriteLramByte(iop_base, 10190 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_FWD), i);
11256 (ushort) (s_addr + (ushort) ASC_SCSIQ_B_BWD), i); 10191 AscWriteLramByte(iop_base,
11257 AscWriteLramByte(iop_base, 10192 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_BWD), i);
11258 (ushort) (s_addr + (ushort) ASC_SCSIQ_B_QNO), i); 10193 AscWriteLramByte(iop_base,
11259 } 10194 (ushort)(s_addr + (ushort)ASC_SCSIQ_B_QNO), i);
11260 return (warn_code); 10195 }
10196 return (warn_code);
11261} 10197}
11262 10198
11263STATIC ushort 10199static ushort AscInitQLinkVar(ASC_DVC_VAR *asc_dvc)
11264AscInitQLinkVar(
11265 ASC_DVC_VAR *asc_dvc
11266)
11267{ 10200{
11268 PortAddr iop_base; 10201 PortAddr iop_base;
11269 int i; 10202 int i;
11270 ushort lram_addr; 10203 ushort lram_addr;
11271 10204
11272 iop_base = asc_dvc->iop_base; 10205 iop_base = asc_dvc->iop_base;
11273 AscPutRiscVarFreeQHead(iop_base, 1); 10206 AscPutRiscVarFreeQHead(iop_base, 1);
11274 AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng); 10207 AscPutRiscVarDoneQTail(iop_base, asc_dvc->max_total_qng);
11275 AscPutVarFreeQHead(iop_base, 1); 10208 AscPutVarFreeQHead(iop_base, 1);
11276 AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng); 10209 AscPutVarDoneQTail(iop_base, asc_dvc->max_total_qng);
11277 AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B, 10210 AscWriteLramByte(iop_base, ASCV_BUSY_QHEAD_B,
11278 (uchar) ((int) asc_dvc->max_total_qng + 1)); 10211 (uchar)((int)asc_dvc->max_total_qng + 1));
11279 AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B, 10212 AscWriteLramByte(iop_base, ASCV_DISC1_QHEAD_B,
11280 (uchar) ((int) asc_dvc->max_total_qng + 2)); 10213 (uchar)((int)asc_dvc->max_total_qng + 2));
11281 AscWriteLramByte(iop_base, (ushort) ASCV_TOTAL_READY_Q_B, 10214 AscWriteLramByte(iop_base, (ushort)ASCV_TOTAL_READY_Q_B,
11282 asc_dvc->max_total_qng); 10215 asc_dvc->max_total_qng);
11283 AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0); 10216 AscWriteLramWord(iop_base, ASCV_ASCDVC_ERR_CODE_W, 0);
11284 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0); 10217 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0);
11285 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0); 10218 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 0);
11286 AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0); 10219 AscWriteLramByte(iop_base, ASCV_SCSIBUSY_B, 0);
11287 AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0); 10220 AscWriteLramByte(iop_base, ASCV_WTM_FLAG_B, 0);
11288 AscPutQDoneInProgress(iop_base, 0); 10221 AscPutQDoneInProgress(iop_base, 0);
11289 lram_addr = ASC_QADR_BEG; 10222 lram_addr = ASC_QADR_BEG;
11290 for (i = 0; i < 32; i++, lram_addr += 2) { 10223 for (i = 0; i < 32; i++, lram_addr += 2) {
11291 AscWriteLramWord(iop_base, lram_addr, 0); 10224 AscWriteLramWord(iop_base, lram_addr, 0);
11292 } 10225 }
11293 return (0); 10226 return (0);
11294} 10227}
11295 10228
11296STATIC int 10229static int AscSetLibErrorCode(ASC_DVC_VAR *asc_dvc, ushort err_code)
11297AscSetLibErrorCode(
11298 ASC_DVC_VAR *asc_dvc,
11299 ushort err_code
11300)
11301{ 10230{
11302 if (asc_dvc->err_code == 0) { 10231 if (asc_dvc->err_code == 0) {
11303 asc_dvc->err_code = err_code; 10232 asc_dvc->err_code = err_code;
11304 AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W, 10233 AscWriteLramWord(asc_dvc->iop_base, ASCV_ASCDVC_ERR_CODE_W,
11305 err_code); 10234 err_code);
11306 } 10235 }
11307 return (err_code); 10236 return (err_code);
11308} 10237}
11309 10238
11310 10239static uchar
11311STATIC uchar 10240AscMsgOutSDTR(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar sdtr_offset)
11312AscMsgOutSDTR(
11313 ASC_DVC_VAR *asc_dvc,
11314 uchar sdtr_period,
11315 uchar sdtr_offset
11316)
11317{ 10241{
11318 EXT_MSG sdtr_buf; 10242 EXT_MSG sdtr_buf;
11319 uchar sdtr_period_index; 10243 uchar sdtr_period_index;
11320 PortAddr iop_base; 10244 PortAddr iop_base;
11321 10245
11322 iop_base = asc_dvc->iop_base; 10246 iop_base = asc_dvc->iop_base;
11323 sdtr_buf.msg_type = MS_EXTEND; 10247 sdtr_buf.msg_type = MS_EXTEND;
11324 sdtr_buf.msg_len = MS_SDTR_LEN; 10248 sdtr_buf.msg_len = MS_SDTR_LEN;
11325 sdtr_buf.msg_req = MS_SDTR_CODE; 10249 sdtr_buf.msg_req = MS_SDTR_CODE;
11326 sdtr_buf.xfer_period = sdtr_period; 10250 sdtr_buf.xfer_period = sdtr_period;
11327 sdtr_offset &= ASC_SYN_MAX_OFFSET; 10251 sdtr_offset &= ASC_SYN_MAX_OFFSET;
11328 sdtr_buf.req_ack_offset = sdtr_offset; 10252 sdtr_buf.req_ack_offset = sdtr_offset;
11329 if ((sdtr_period_index = 10253 if ((sdtr_period_index =
11330 AscGetSynPeriodIndex(asc_dvc, sdtr_period)) <= 10254 AscGetSynPeriodIndex(asc_dvc, sdtr_period)) <=
11331 asc_dvc->max_sdtr_index) { 10255 asc_dvc->max_sdtr_index) {
11332 AscMemWordCopyPtrToLram(iop_base, 10256 AscMemWordCopyPtrToLram(iop_base,
11333 ASCV_MSGOUT_BEG, 10257 ASCV_MSGOUT_BEG,
11334 (uchar *) &sdtr_buf, 10258 (uchar *)&sdtr_buf,
11335 sizeof (EXT_MSG) >> 1); 10259 sizeof(EXT_MSG) >> 1);
11336 return ((sdtr_period_index << 4) | sdtr_offset); 10260 return ((sdtr_period_index << 4) | sdtr_offset);
11337 } else { 10261 } else {
11338 10262
11339 sdtr_buf.req_ack_offset = 0; 10263 sdtr_buf.req_ack_offset = 0;
11340 AscMemWordCopyPtrToLram(iop_base, 10264 AscMemWordCopyPtrToLram(iop_base,
11341 ASCV_MSGOUT_BEG, 10265 ASCV_MSGOUT_BEG,
11342 (uchar *) &sdtr_buf, 10266 (uchar *)&sdtr_buf,
11343 sizeof (EXT_MSG) >> 1); 10267 sizeof(EXT_MSG) >> 1);
11344 return (0); 10268 return (0);
11345 } 10269 }
11346} 10270}
11347 10271
11348STATIC uchar 10272static uchar
11349AscCalSDTRData( 10273AscCalSDTRData(ASC_DVC_VAR *asc_dvc, uchar sdtr_period, uchar syn_offset)
11350 ASC_DVC_VAR *asc_dvc,
11351 uchar sdtr_period,
11352 uchar syn_offset
11353)
11354{ 10274{
11355 uchar byte; 10275 uchar byte;
11356 uchar sdtr_period_ix; 10276 uchar sdtr_period_ix;
11357 10277
11358 sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period); 10278 sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
11359 if ( 10279 if ((sdtr_period_ix > asc_dvc->max_sdtr_index)
11360 (sdtr_period_ix > asc_dvc->max_sdtr_index) 10280 ) {
11361) { 10281 return (0xFF);
11362 return (0xFF); 10282 }
11363 } 10283 byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
11364 byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET); 10284 return (byte);
11365 return (byte);
11366} 10285}
11367 10286
11368STATIC void 10287static void AscSetChipSDTR(PortAddr iop_base, uchar sdtr_data, uchar tid_no)
11369AscSetChipSDTR(
11370 PortAddr iop_base,
11371 uchar sdtr_data,
11372 uchar tid_no
11373)
11374{ 10288{
11375 AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data); 10289 AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
11376 AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data); 10290 AscPutMCodeSDTRDoneAtID(iop_base, tid_no, sdtr_data);
11377 return; 10291 return;
11378} 10292}
11379 10293
11380STATIC uchar 10294static uchar AscGetSynPeriodIndex(ASC_DVC_VAR *asc_dvc, uchar syn_time)
11381AscGetSynPeriodIndex(
11382 ASC_DVC_VAR *asc_dvc,
11383 uchar syn_time
11384)
11385{ 10295{
11386 uchar *period_table; 10296 uchar *period_table;
11387 int max_index; 10297 int max_index;
11388 int min_index; 10298 int min_index;
11389 int i; 10299 int i;
11390 10300
11391 period_table = asc_dvc->sdtr_period_tbl; 10301 period_table = asc_dvc->sdtr_period_tbl;
11392 max_index = (int) asc_dvc->max_sdtr_index; 10302 max_index = (int)asc_dvc->max_sdtr_index;
11393 min_index = (int)asc_dvc->host_init_sdtr_index; 10303 min_index = (int)asc_dvc->host_init_sdtr_index;
11394 if ((syn_time <= period_table[max_index])) { 10304 if ((syn_time <= period_table[max_index])) {
11395 for (i = min_index; i < (max_index - 1); i++) { 10305 for (i = min_index; i < (max_index - 1); i++) {
11396 if (syn_time <= period_table[i]) { 10306 if (syn_time <= period_table[i]) {
11397 return ((uchar) i); 10307 return ((uchar)i);
11398 } 10308 }
11399 } 10309 }
11400 return ((uchar) max_index); 10310 return ((uchar)max_index);
11401 } else { 10311 } else {
11402 return ((uchar) (max_index + 1)); 10312 return ((uchar)(max_index + 1));
11403 } 10313 }
11404} 10314}
11405 10315
11406STATIC uchar 10316static uchar AscAllocFreeQueue(PortAddr iop_base, uchar free_q_head)
11407AscAllocFreeQueue(
11408 PortAddr iop_base,
11409 uchar free_q_head
11410)
11411{ 10317{
11412 ushort q_addr; 10318 ushort q_addr;
11413 uchar next_qp; 10319 uchar next_qp;
11414 uchar q_status; 10320 uchar q_status;
11415 10321
11416 q_addr = ASC_QNO_TO_QADDR(free_q_head); 10322 q_addr = ASC_QNO_TO_QADDR(free_q_head);
11417 q_status = (uchar) AscReadLramByte(iop_base, 10323 q_status = (uchar)AscReadLramByte(iop_base,
11418 (ushort) (q_addr + ASC_SCSIQ_B_STATUS)); 10324 (ushort)(q_addr +
11419 next_qp = AscReadLramByte(iop_base, 10325 ASC_SCSIQ_B_STATUS));
11420 (ushort) (q_addr + ASC_SCSIQ_B_FWD)); 10326 next_qp = AscReadLramByte(iop_base, (ushort)(q_addr + ASC_SCSIQ_B_FWD));
11421 if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END)) { 10327 if (((q_status & QS_READY) == 0) && (next_qp != ASC_QLINK_END)) {
11422 return (next_qp); 10328 return (next_qp);
11423 } 10329 }
11424 return (ASC_QLINK_END); 10330 return (ASC_QLINK_END);
11425} 10331}
11426 10332
11427STATIC uchar 10333static uchar
11428AscAllocMultipleFreeQueue( 10334AscAllocMultipleFreeQueue(PortAddr iop_base, uchar free_q_head, uchar n_free_q)
11429 PortAddr iop_base,
11430 uchar free_q_head,
11431 uchar n_free_q
11432)
11433{ 10335{
11434 uchar i; 10336 uchar i;
11435 10337
11436 for (i = 0; i < n_free_q; i++) { 10338 for (i = 0; i < n_free_q; i++) {
11437 if ((free_q_head = AscAllocFreeQueue(iop_base, free_q_head)) 10339 if ((free_q_head = AscAllocFreeQueue(iop_base, free_q_head))
11438 == ASC_QLINK_END) { 10340 == ASC_QLINK_END) {
11439 return (ASC_QLINK_END); 10341 return (ASC_QLINK_END);
11440 } 10342 }
11441 } 10343 }
11442 return (free_q_head); 10344 return (free_q_head);
11443} 10345}
11444 10346
11445STATIC int 10347static int AscHostReqRiscHalt(PortAddr iop_base)
11446AscHostReqRiscHalt(
11447 PortAddr iop_base
11448)
11449{ 10348{
11450 int count = 0; 10349 int count = 0;
11451 int sta = 0; 10350 int sta = 0;
11452 uchar saved_stop_code; 10351 uchar saved_stop_code;
11453 10352
11454 if (AscIsChipHalted(iop_base)) 10353 if (AscIsChipHalted(iop_base))
11455 return (1); 10354 return (1);
11456 saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B); 10355 saved_stop_code = AscReadLramByte(iop_base, ASCV_STOP_CODE_B);
11457 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 10356 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
11458 ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP 10357 ASC_STOP_HOST_REQ_RISC_HALT | ASC_STOP_REQ_RISC_STOP);
11459); 10358 do {
11460 do { 10359 if (AscIsChipHalted(iop_base)) {
11461 if (AscIsChipHalted(iop_base)) { 10360 sta = 1;
11462 sta = 1; 10361 break;
11463 break; 10362 }
11464 } 10363 DvcSleepMilliSecond(100);
11465 DvcSleepMilliSecond(100); 10364 } while (count++ < 20);
11466 } while (count++ < 20); 10365 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code);
11467 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, saved_stop_code); 10366 return (sta);
11468 return (sta);
11469} 10367}
11470 10368
11471STATIC int 10369static int AscStopQueueExe(PortAddr iop_base)
11472AscStopQueueExe(
11473 PortAddr iop_base
11474)
11475{ 10370{
11476 int count = 0; 10371 int count = 0;
11477 10372
11478 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) { 10373 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) == 0) {
11479 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B, 10374 AscWriteLramByte(iop_base, ASCV_STOP_CODE_B,
11480 ASC_STOP_REQ_RISC_STOP); 10375 ASC_STOP_REQ_RISC_STOP);
11481 do { 10376 do {
11482 if ( 10377 if (AscReadLramByte(iop_base, ASCV_STOP_CODE_B) &
11483 AscReadLramByte(iop_base, ASCV_STOP_CODE_B) & 10378 ASC_STOP_ACK_RISC_STOP) {
11484 ASC_STOP_ACK_RISC_STOP) { 10379 return (1);
11485 return (1); 10380 }
11486 } 10381 DvcSleepMilliSecond(100);
11487 DvcSleepMilliSecond(100); 10382 } while (count++ < 20);
11488 } while (count++ < 20); 10383 }
11489 } 10384 return (0);
11490 return (0);
11491} 10385}
11492 10386
11493STATIC void 10387static void DvcDelayMicroSecond(ADV_DVC_VAR *asc_dvc, ushort micro_sec)
11494DvcDelayMicroSecond(ADV_DVC_VAR *asc_dvc, ushort micro_sec)
11495{ 10388{
11496 udelay(micro_sec); 10389 udelay(micro_sec);
11497} 10390}
11498 10391
11499STATIC void 10392static void DvcDelayNanoSecond(ASC_DVC_VAR *asc_dvc, ASC_DCNT nano_sec)
11500DvcDelayNanoSecond(ASC_DVC_VAR *asc_dvc, ASC_DCNT nano_sec)
11501{ 10393{
11502 udelay((nano_sec + 999)/1000); 10394 udelay((nano_sec + 999) / 1000);
11503} 10395}
11504 10396
11505#ifdef CONFIG_ISA 10397#ifdef CONFIG_ISA
11506STATIC ASC_DCNT __init 10398static ASC_DCNT __init AscGetEisaProductID(PortAddr iop_base)
11507AscGetEisaProductID(
11508 PortAddr iop_base)
11509{ 10399{
11510 PortAddr eisa_iop; 10400 PortAddr eisa_iop;
11511 ushort product_id_high, product_id_low; 10401 ushort product_id_high, product_id_low;
11512 ASC_DCNT product_id; 10402 ASC_DCNT product_id;
11513 10403
11514 eisa_iop = ASC_GET_EISA_SLOT(iop_base) | ASC_EISA_PID_IOP_MASK; 10404 eisa_iop = ASC_GET_EISA_SLOT(iop_base) | ASC_EISA_PID_IOP_MASK;
11515 product_id_low = inpw(eisa_iop); 10405 product_id_low = inpw(eisa_iop);
11516 product_id_high = inpw(eisa_iop + 2); 10406 product_id_high = inpw(eisa_iop + 2);
11517 product_id = ((ASC_DCNT) product_id_high << 16) | 10407 product_id = ((ASC_DCNT) product_id_high << 16) |
11518 (ASC_DCNT) product_id_low; 10408 (ASC_DCNT) product_id_low;
11519 return (product_id); 10409 return (product_id);
11520} 10410}
11521 10411
11522STATIC PortAddr __init 10412static PortAddr __init AscSearchIOPortAddrEISA(PortAddr iop_base)
11523AscSearchIOPortAddrEISA(
11524 PortAddr iop_base)
11525{ 10413{
11526 ASC_DCNT eisa_product_id; 10414 ASC_DCNT eisa_product_id;
11527 10415
11528 if (iop_base == 0) { 10416 if (iop_base == 0) {
11529 iop_base = ASC_EISA_MIN_IOP_ADDR; 10417 iop_base = ASC_EISA_MIN_IOP_ADDR;
11530 } else { 10418 } else {
11531 if (iop_base == ASC_EISA_MAX_IOP_ADDR) 10419 if (iop_base == ASC_EISA_MAX_IOP_ADDR)
11532 return (0); 10420 return (0);
11533 if ((iop_base & 0x0050) == 0x0050) { 10421 if ((iop_base & 0x0050) == 0x0050) {
11534 iop_base += ASC_EISA_BIG_IOP_GAP; 10422 iop_base += ASC_EISA_BIG_IOP_GAP;
11535 } else { 10423 } else {
11536 iop_base += ASC_EISA_SMALL_IOP_GAP; 10424 iop_base += ASC_EISA_SMALL_IOP_GAP;
11537 } 10425 }
11538 } 10426 }
11539 while (iop_base <= ASC_EISA_MAX_IOP_ADDR) { 10427 while (iop_base <= ASC_EISA_MAX_IOP_ADDR) {
11540 eisa_product_id = AscGetEisaProductID(iop_base); 10428 eisa_product_id = AscGetEisaProductID(iop_base);
11541 if ((eisa_product_id == ASC_EISA_ID_740) || 10429 if ((eisa_product_id == ASC_EISA_ID_740) ||
11542 (eisa_product_id == ASC_EISA_ID_750)) { 10430 (eisa_product_id == ASC_EISA_ID_750)) {
11543 if (AscFindSignature(iop_base)) { 10431 if (AscFindSignature(iop_base)) {
11544 inpw(iop_base + 4); 10432 inpw(iop_base + 4);
11545 return (iop_base); 10433 return (iop_base);
11546 } 10434 }
11547 } 10435 }
11548 if (iop_base == ASC_EISA_MAX_IOP_ADDR) 10436 if (iop_base == ASC_EISA_MAX_IOP_ADDR)
11549 return (0); 10437 return (0);
11550 if ((iop_base & 0x0050) == 0x0050) { 10438 if ((iop_base & 0x0050) == 0x0050) {
11551 iop_base += ASC_EISA_BIG_IOP_GAP; 10439 iop_base += ASC_EISA_BIG_IOP_GAP;
11552 } else { 10440 } else {
11553 iop_base += ASC_EISA_SMALL_IOP_GAP; 10441 iop_base += ASC_EISA_SMALL_IOP_GAP;
11554 } 10442 }
11555 } 10443 }
11556 return (0); 10444 return (0);
11557} 10445}
11558#endif /* CONFIG_ISA */ 10446#endif /* CONFIG_ISA */
11559 10447
11560STATIC int 10448static int AscStartChip(PortAddr iop_base)
11561AscStartChip(
11562 PortAddr iop_base
11563)
11564{ 10449{
11565 AscSetChipControl(iop_base, 0); 10450 AscSetChipControl(iop_base, 0);
11566 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) { 10451 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
11567 return (0); 10452 return (0);
11568 } 10453 }
11569 return (1); 10454 return (1);
11570} 10455}
11571 10456
11572STATIC int 10457static int AscStopChip(PortAddr iop_base)
11573AscStopChip(
11574 PortAddr iop_base
11575)
11576{ 10458{
11577 uchar cc_val; 10459 uchar cc_val;
11578 10460
11579 cc_val = AscGetChipControl(iop_base) & (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG)); 10461 cc_val =
11580 AscSetChipControl(iop_base, (uchar) (cc_val | CC_HALT)); 10462 AscGetChipControl(iop_base) &
11581 AscSetChipIH(iop_base, INS_HALT); 10463 (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG));
11582 AscSetChipIH(iop_base, INS_RFLAG_WTM); 10464 AscSetChipControl(iop_base, (uchar)(cc_val | CC_HALT));
11583 if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) { 10465 AscSetChipIH(iop_base, INS_HALT);
11584 return (0); 10466 AscSetChipIH(iop_base, INS_RFLAG_WTM);
11585 } 10467 if ((AscGetChipStatus(iop_base) & CSW_HALTED) == 0) {
11586 return (1); 10468 return (0);
10469 }
10470 return (1);
11587} 10471}
11588 10472
11589STATIC int 10473static int AscIsChipHalted(PortAddr iop_base)
11590AscIsChipHalted(
11591 PortAddr iop_base
11592)
11593{ 10474{
11594 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) { 10475 if ((AscGetChipStatus(iop_base) & CSW_HALTED) != 0) {
11595 if ((AscGetChipControl(iop_base) & CC_HALT) != 0) { 10476 if ((AscGetChipControl(iop_base) & CC_HALT) != 0) {
11596 return (1); 10477 return (1);
11597 } 10478 }
11598 } 10479 }
11599 return (0); 10480 return (0);
11600} 10481}
11601 10482
11602STATIC void 10483static void AscSetChipIH(PortAddr iop_base, ushort ins_code)
11603AscSetChipIH(
11604 PortAddr iop_base,
11605 ushort ins_code
11606)
11607{ 10484{
11608 AscSetBank(iop_base, 1); 10485 AscSetBank(iop_base, 1);
11609 AscWriteChipIH(iop_base, ins_code); 10486 AscWriteChipIH(iop_base, ins_code);
11610 AscSetBank(iop_base, 0); 10487 AscSetBank(iop_base, 0);
11611 return; 10488 return;
11612} 10489}
11613 10490
11614STATIC void 10491static void AscAckInterrupt(PortAddr iop_base)
11615AscAckInterrupt(
11616 PortAddr iop_base
11617)
11618{ 10492{
11619 uchar host_flag; 10493 uchar host_flag;
11620 uchar risc_flag; 10494 uchar risc_flag;
11621 ushort loop; 10495 ushort loop;
11622 10496
11623 loop = 0; 10497 loop = 0;
11624 do { 10498 do {
11625 risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B); 10499 risc_flag = AscReadLramByte(iop_base, ASCV_RISC_FLAG_B);
11626 if (loop++ > 0x7FFF) { 10500 if (loop++ > 0x7FFF) {
11627 break; 10501 break;
11628 } 10502 }
11629 } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0); 10503 } while ((risc_flag & ASC_RISC_FLAG_GEN_INT) != 0);
11630 host_flag = AscReadLramByte(iop_base, ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT); 10504 host_flag =
11631 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, 10505 AscReadLramByte(iop_base,
11632 (uchar) (host_flag | ASC_HOST_FLAG_ACK_INT)); 10506 ASCV_HOST_FLAG_B) & (~ASC_HOST_FLAG_ACK_INT);
11633 AscSetChipStatus(iop_base, CIW_INT_ACK); 10507 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B,
11634 loop = 0; 10508 (uchar)(host_flag | ASC_HOST_FLAG_ACK_INT));
11635 while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) { 10509 AscSetChipStatus(iop_base, CIW_INT_ACK);
11636 AscSetChipStatus(iop_base, CIW_INT_ACK); 10510 loop = 0;
11637 if (loop++ > 3) { 10511 while (AscGetChipStatus(iop_base) & CSW_INT_PENDING) {
11638 break; 10512 AscSetChipStatus(iop_base, CIW_INT_ACK);
11639 } 10513 if (loop++ > 3) {
11640 } 10514 break;
11641 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag); 10515 }
11642 return; 10516 }
10517 AscWriteLramByte(iop_base, ASCV_HOST_FLAG_B, host_flag);
10518 return;
11643} 10519}
11644 10520
11645STATIC void 10521static void AscDisableInterrupt(PortAddr iop_base)
11646AscDisableInterrupt(
11647 PortAddr iop_base
11648)
11649{ 10522{
11650 ushort cfg; 10523 ushort cfg;
11651 10524
11652 cfg = AscGetChipCfgLsw(iop_base); 10525 cfg = AscGetChipCfgLsw(iop_base);
11653 AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON)); 10526 AscSetChipCfgLsw(iop_base, cfg & (~ASC_CFG0_HOST_INT_ON));
11654 return; 10527 return;
11655} 10528}
11656 10529
11657STATIC void 10530static void AscEnableInterrupt(PortAddr iop_base)
11658AscEnableInterrupt(
11659 PortAddr iop_base
11660)
11661{ 10531{
11662 ushort cfg; 10532 ushort cfg;
11663 10533
11664 cfg = AscGetChipCfgLsw(iop_base); 10534 cfg = AscGetChipCfgLsw(iop_base);
11665 AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON); 10535 AscSetChipCfgLsw(iop_base, cfg | ASC_CFG0_HOST_INT_ON);
11666 return; 10536 return;
11667} 10537}
11668 10538
11669 10539static void AscSetBank(PortAddr iop_base, uchar bank)
11670
11671STATIC void
11672AscSetBank(
11673 PortAddr iop_base,
11674 uchar bank
11675)
11676{ 10540{
11677 uchar val; 10541 uchar val;
11678 10542
11679 val = AscGetChipControl(iop_base) & 10543 val = AscGetChipControl(iop_base) &
11680 (~(CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET | CC_CHIP_RESET)); 10544 (~
11681 if (bank == 1) { 10545 (CC_SINGLE_STEP | CC_TEST | CC_DIAG | CC_SCSI_RESET |
11682 val |= CC_BANK_ONE; 10546 CC_CHIP_RESET));
11683 } else if (bank == 2) { 10547 if (bank == 1) {
11684 val |= CC_DIAG | CC_BANK_ONE; 10548 val |= CC_BANK_ONE;
11685 } else { 10549 } else if (bank == 2) {
11686 val &= ~CC_BANK_ONE; 10550 val |= CC_DIAG | CC_BANK_ONE;
11687 } 10551 } else {
11688 AscSetChipControl(iop_base, val); 10552 val &= ~CC_BANK_ONE;
11689 return; 10553 }
10554 AscSetChipControl(iop_base, val);
10555 return;
11690} 10556}
11691 10557
11692STATIC int 10558static int AscResetChipAndScsiBus(ASC_DVC_VAR *asc_dvc)
11693AscResetChipAndScsiBus(
11694 ASC_DVC_VAR *asc_dvc
11695)
11696{ 10559{
11697 PortAddr iop_base; 10560 PortAddr iop_base;
11698 int i = 10; 10561 int i = 10;
11699 10562
11700 iop_base = asc_dvc->iop_base; 10563 iop_base = asc_dvc->iop_base;
11701 while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) 10564 while ((AscGetChipStatus(iop_base) & CSW_SCSI_RESET_ACTIVE)
11702 { 10565 && (i-- > 0)) {
11703 DvcSleepMilliSecond(100); 10566 DvcSleepMilliSecond(100);
11704 } 10567 }
11705 AscStopChip(iop_base); 10568 AscStopChip(iop_base);
11706 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT); 10569 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_SCSI_RESET | CC_HALT);
11707 DvcDelayNanoSecond(asc_dvc, 60000); 10570 DvcDelayNanoSecond(asc_dvc, 60000);
11708 AscSetChipIH(iop_base, INS_RFLAG_WTM); 10571 AscSetChipIH(iop_base, INS_RFLAG_WTM);
11709 AscSetChipIH(iop_base, INS_HALT); 10572 AscSetChipIH(iop_base, INS_HALT);
11710 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT); 10573 AscSetChipControl(iop_base, CC_CHIP_RESET | CC_HALT);
11711 AscSetChipControl(iop_base, CC_HALT); 10574 AscSetChipControl(iop_base, CC_HALT);
11712 DvcSleepMilliSecond(200); 10575 DvcSleepMilliSecond(200);
11713 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT); 10576 AscSetChipStatus(iop_base, CIW_CLR_SCSI_RESET_INT);
11714 AscSetChipStatus(iop_base, 0); 10577 AscSetChipStatus(iop_base, 0);
11715 return (AscIsChipHalted(iop_base)); 10578 return (AscIsChipHalted(iop_base));
11716} 10579}
11717 10580
11718STATIC ASC_DCNT __init 10581static ASC_DCNT __init AscGetMaxDmaCount(ushort bus_type)
11719AscGetMaxDmaCount(
11720 ushort bus_type)
11721{ 10582{
11722 if (bus_type & ASC_IS_ISA) 10583 if (bus_type & ASC_IS_ISA)
11723 return (ASC_MAX_ISA_DMA_COUNT); 10584 return (ASC_MAX_ISA_DMA_COUNT);
11724 else if (bus_type & (ASC_IS_EISA | ASC_IS_VL)) 10585 else if (bus_type & (ASC_IS_EISA | ASC_IS_VL))
11725 return (ASC_MAX_VL_DMA_COUNT); 10586 return (ASC_MAX_VL_DMA_COUNT);
11726 return (ASC_MAX_PCI_DMA_COUNT); 10587 return (ASC_MAX_PCI_DMA_COUNT);
11727} 10588}
11728 10589
11729#ifdef CONFIG_ISA 10590#ifdef CONFIG_ISA
11730STATIC ushort __init 10591static ushort __init AscGetIsaDmaChannel(PortAddr iop_base)
11731AscGetIsaDmaChannel(
11732 PortAddr iop_base)
11733{ 10592{
11734 ushort channel; 10593 ushort channel;
11735 10594
11736 channel = AscGetChipCfgLsw(iop_base) & 0x0003; 10595 channel = AscGetChipCfgLsw(iop_base) & 0x0003;
11737 if (channel == 0x03) 10596 if (channel == 0x03)
11738 return (0); 10597 return (0);
11739 else if (channel == 0x00) 10598 else if (channel == 0x00)
11740 return (7); 10599 return (7);
11741 return (channel + 4); 10600 return (channel + 4);
11742} 10601}
11743 10602
11744STATIC ushort __init 10603static ushort __init AscSetIsaDmaChannel(PortAddr iop_base, ushort dma_channel)
11745AscSetIsaDmaChannel(
11746 PortAddr iop_base,
11747 ushort dma_channel)
11748{ 10604{
11749 ushort cfg_lsw; 10605 ushort cfg_lsw;
11750 uchar value; 10606 uchar value;
11751 10607
11752 if ((dma_channel >= 5) && (dma_channel <= 7)) { 10608 if ((dma_channel >= 5) && (dma_channel <= 7)) {
11753 if (dma_channel == 7) 10609 if (dma_channel == 7)
11754 value = 0x00; 10610 value = 0x00;
11755 else 10611 else
11756 value = dma_channel - 4; 10612 value = dma_channel - 4;
11757 cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC; 10613 cfg_lsw = AscGetChipCfgLsw(iop_base) & 0xFFFC;
11758 cfg_lsw |= value; 10614 cfg_lsw |= value;
11759 AscSetChipCfgLsw(iop_base, cfg_lsw); 10615 AscSetChipCfgLsw(iop_base, cfg_lsw);
11760 return (AscGetIsaDmaChannel(iop_base)); 10616 return (AscGetIsaDmaChannel(iop_base));
11761 } 10617 }
11762 return (0); 10618 return (0);
11763} 10619}
11764 10620
11765STATIC uchar __init 10621static uchar __init AscSetIsaDmaSpeed(PortAddr iop_base, uchar speed_value)
11766AscSetIsaDmaSpeed(
11767 PortAddr iop_base,
11768 uchar speed_value)
11769{ 10622{
11770 speed_value &= 0x07; 10623 speed_value &= 0x07;
11771 AscSetBank(iop_base, 1); 10624 AscSetBank(iop_base, 1);
11772 AscWriteChipDmaSpeed(iop_base, speed_value); 10625 AscWriteChipDmaSpeed(iop_base, speed_value);
11773 AscSetBank(iop_base, 0); 10626 AscSetBank(iop_base, 0);
11774 return (AscGetIsaDmaSpeed(iop_base)); 10627 return (AscGetIsaDmaSpeed(iop_base));
11775} 10628}
11776 10629
11777STATIC uchar __init 10630static uchar __init AscGetIsaDmaSpeed(PortAddr iop_base)
11778AscGetIsaDmaSpeed(
11779 PortAddr iop_base
11780)
11781{ 10631{
11782 uchar speed_value; 10632 uchar speed_value;
11783 10633
11784 AscSetBank(iop_base, 1); 10634 AscSetBank(iop_base, 1);
11785 speed_value = AscReadChipDmaSpeed(iop_base); 10635 speed_value = AscReadChipDmaSpeed(iop_base);
11786 speed_value &= 0x07; 10636 speed_value &= 0x07;
11787 AscSetBank(iop_base, 0); 10637 AscSetBank(iop_base, 0);
11788 return (speed_value); 10638 return (speed_value);
11789} 10639}
11790#endif /* CONFIG_ISA */ 10640#endif /* CONFIG_ISA */
11791 10641
11792STATIC ushort __init 10642static ushort __init
11793AscReadPCIConfigWord( 10643AscReadPCIConfigWord(ASC_DVC_VAR *asc_dvc, ushort pci_config_offset)
11794 ASC_DVC_VAR *asc_dvc,
11795 ushort pci_config_offset)
11796{ 10644{
11797 uchar lsb, msb; 10645 uchar lsb, msb;
11798 10646
11799 lsb = DvcReadPCIConfigByte(asc_dvc, pci_config_offset); 10647 lsb = DvcReadPCIConfigByte(asc_dvc, pci_config_offset);
11800 msb = DvcReadPCIConfigByte(asc_dvc, pci_config_offset + 1); 10648 msb = DvcReadPCIConfigByte(asc_dvc, pci_config_offset + 1);
11801 return ((ushort) ((msb << 8) | lsb)); 10649 return ((ushort)((msb << 8) | lsb));
11802} 10650}
11803 10651
11804STATIC ushort __init 10652static ushort __init AscInitGetConfig(ASC_DVC_VAR *asc_dvc)
11805AscInitGetConfig(
11806 ASC_DVC_VAR *asc_dvc
11807)
11808{ 10653{
11809 ushort warn_code; 10654 ushort warn_code;
11810 PortAddr iop_base; 10655 PortAddr iop_base;
11811 ushort PCIDeviceID; 10656 ushort PCIDeviceID;
11812 ushort PCIVendorID; 10657 ushort PCIVendorID;
11813 uchar PCIRevisionID; 10658 uchar PCIRevisionID;
11814 uchar prevCmdRegBits; 10659 uchar prevCmdRegBits;
11815 10660
11816 warn_code = 0; 10661 warn_code = 0;
11817 iop_base = asc_dvc->iop_base; 10662 iop_base = asc_dvc->iop_base;
11818 asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG; 10663 asc_dvc->init_state = ASC_INIT_STATE_BEG_GET_CFG;
11819 if (asc_dvc->err_code != 0) { 10664 if (asc_dvc->err_code != 0) {
11820 return (UW_ERR); 10665 return (UW_ERR);
11821 } 10666 }
11822 if (asc_dvc->bus_type == ASC_IS_PCI) { 10667 if (asc_dvc->bus_type == ASC_IS_PCI) {
11823 PCIVendorID = AscReadPCIConfigWord(asc_dvc, 10668 PCIVendorID = AscReadPCIConfigWord(asc_dvc,
11824 AscPCIConfigVendorIDRegister); 10669 AscPCIConfigVendorIDRegister);
11825 10670
11826 PCIDeviceID = AscReadPCIConfigWord(asc_dvc, 10671 PCIDeviceID = AscReadPCIConfigWord(asc_dvc,
11827 AscPCIConfigDeviceIDRegister); 10672 AscPCIConfigDeviceIDRegister);
11828 10673
11829 PCIRevisionID = DvcReadPCIConfigByte(asc_dvc, 10674 PCIRevisionID = DvcReadPCIConfigByte(asc_dvc,
11830 AscPCIConfigRevisionIDRegister); 10675 AscPCIConfigRevisionIDRegister);
11831 10676
11832 if (PCIVendorID != PCI_VENDOR_ID_ASP) { 10677 if (PCIVendorID != PCI_VENDOR_ID_ASP) {
11833 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE; 10678 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
11834 } 10679 }
11835 prevCmdRegBits = DvcReadPCIConfigByte(asc_dvc, 10680 prevCmdRegBits = DvcReadPCIConfigByte(asc_dvc,
11836 AscPCIConfigCommandRegister); 10681 AscPCIConfigCommandRegister);
11837 10682
11838 if ((prevCmdRegBits & AscPCICmdRegBits_IOMemBusMaster) != 10683 if ((prevCmdRegBits & AscPCICmdRegBits_IOMemBusMaster) !=
11839 AscPCICmdRegBits_IOMemBusMaster) { 10684 AscPCICmdRegBits_IOMemBusMaster) {
11840 DvcWritePCIConfigByte(asc_dvc, 10685 DvcWritePCIConfigByte(asc_dvc,
11841 AscPCIConfigCommandRegister, 10686 AscPCIConfigCommandRegister,
11842 (prevCmdRegBits | 10687 (prevCmdRegBits |
11843 AscPCICmdRegBits_IOMemBusMaster)); 10688 AscPCICmdRegBits_IOMemBusMaster));
11844 10689
11845 if ((DvcReadPCIConfigByte(asc_dvc, 10690 if ((DvcReadPCIConfigByte(asc_dvc,
11846 AscPCIConfigCommandRegister) 10691 AscPCIConfigCommandRegister)
11847 & AscPCICmdRegBits_IOMemBusMaster) 10692 & AscPCICmdRegBits_IOMemBusMaster)
11848 != AscPCICmdRegBits_IOMemBusMaster) { 10693 != AscPCICmdRegBits_IOMemBusMaster) {
11849 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE; 10694 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
11850 } 10695 }
11851 } 10696 }
11852 if ((PCIDeviceID == PCI_DEVICE_ID_ASP_1200A) || 10697 if ((PCIDeviceID == PCI_DEVICE_ID_ASP_1200A) ||
11853 (PCIDeviceID == PCI_DEVICE_ID_ASP_ABP940)) { 10698 (PCIDeviceID == PCI_DEVICE_ID_ASP_ABP940)) {
11854 DvcWritePCIConfigByte(asc_dvc, 10699 DvcWritePCIConfigByte(asc_dvc,
11855 AscPCIConfigLatencyTimer, 0x00); 10700 AscPCIConfigLatencyTimer, 0x00);
11856 if (DvcReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) 10701 if (DvcReadPCIConfigByte
11857 != 0x00) { 10702 (asc_dvc, AscPCIConfigLatencyTimer)
11858 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE; 10703 != 0x00) {
11859 } 10704 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
11860 } else if (PCIDeviceID == PCI_DEVICE_ID_ASP_ABP940U) { 10705 }
11861 if (DvcReadPCIConfigByte(asc_dvc, 10706 } else if (PCIDeviceID == PCI_DEVICE_ID_ASP_ABP940U) {
11862 AscPCIConfigLatencyTimer) < 0x20) { 10707 if (DvcReadPCIConfigByte(asc_dvc,
11863 DvcWritePCIConfigByte(asc_dvc, 10708 AscPCIConfigLatencyTimer) <
11864 AscPCIConfigLatencyTimer, 0x20); 10709 0x20) {
11865 10710 DvcWritePCIConfigByte(asc_dvc,
11866 if (DvcReadPCIConfigByte(asc_dvc, 10711 AscPCIConfigLatencyTimer,
11867 AscPCIConfigLatencyTimer) < 0x20) { 10712 0x20);
11868 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE; 10713
11869 } 10714 if (DvcReadPCIConfigByte(asc_dvc,
11870 } 10715 AscPCIConfigLatencyTimer)
11871 } 10716 < 0x20) {
11872 } 10717 warn_code |=
10718 ASC_WARN_SET_PCI_CONFIG_SPACE;
10719 }
10720 }
10721 }
10722 }
11873 10723
11874 if (AscFindSignature(iop_base)) { 10724 if (AscFindSignature(iop_base)) {
11875 warn_code |= AscInitAscDvcVar(asc_dvc); 10725 warn_code |= AscInitAscDvcVar(asc_dvc);
11876 warn_code |= AscInitFromEEP(asc_dvc); 10726 warn_code |= AscInitFromEEP(asc_dvc);
11877 asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG; 10727 asc_dvc->init_state |= ASC_INIT_STATE_END_GET_CFG;
11878 if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT) { 10728 if (asc_dvc->scsi_reset_wait > ASC_MAX_SCSI_RESET_WAIT) {
11879 asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT; 10729 asc_dvc->scsi_reset_wait = ASC_MAX_SCSI_RESET_WAIT;
11880 } 10730 }
11881 } else { 10731 } else {
11882 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; 10732 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
11883 } 10733 }
11884 return(warn_code); 10734 return (warn_code);
11885} 10735}
11886 10736
11887STATIC ushort __init 10737static ushort __init AscInitSetConfig(ASC_DVC_VAR *asc_dvc)
11888AscInitSetConfig(
11889 ASC_DVC_VAR *asc_dvc
11890)
11891{ 10738{
11892 ushort warn_code = 0; 10739 ushort warn_code = 0;
11893 10740
11894 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG; 10741 asc_dvc->init_state |= ASC_INIT_STATE_BEG_SET_CFG;
11895 if (asc_dvc->err_code != 0) 10742 if (asc_dvc->err_code != 0)
11896 return (UW_ERR); 10743 return (UW_ERR);
11897 if (AscFindSignature(asc_dvc->iop_base)) { 10744 if (AscFindSignature(asc_dvc->iop_base)) {
11898 warn_code |= AscInitFromAscDvcVar(asc_dvc); 10745 warn_code |= AscInitFromAscDvcVar(asc_dvc);
11899 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG; 10746 asc_dvc->init_state |= ASC_INIT_STATE_END_SET_CFG;
11900 } else { 10747 } else {
11901 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; 10748 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
11902 } 10749 }
11903 return (warn_code); 10750 return (warn_code);
11904} 10751}
11905 10752
11906STATIC ushort __init 10753static ushort __init AscInitFromAscDvcVar(ASC_DVC_VAR *asc_dvc)
11907AscInitFromAscDvcVar(
11908 ASC_DVC_VAR *asc_dvc
11909)
11910{ 10754{
11911 PortAddr iop_base; 10755 PortAddr iop_base;
11912 ushort cfg_msw; 10756 ushort cfg_msw;
11913 ushort warn_code; 10757 ushort warn_code;
11914 ushort pci_device_id = 0; 10758 ushort pci_device_id = 0;
11915 10759
11916 iop_base = asc_dvc->iop_base; 10760 iop_base = asc_dvc->iop_base;
11917#ifdef CONFIG_PCI 10761#ifdef CONFIG_PCI
11918 if (asc_dvc->cfg->dev) 10762 if (asc_dvc->cfg->dev)
11919 pci_device_id = to_pci_dev(asc_dvc->cfg->dev)->device; 10763 pci_device_id = to_pci_dev(asc_dvc->cfg->dev)->device;
11920#endif 10764#endif
11921 warn_code = 0; 10765 warn_code = 0;
11922 cfg_msw = AscGetChipCfgMsw(iop_base); 10766 cfg_msw = AscGetChipCfgMsw(iop_base);
11923 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) { 10767 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
11924 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK)); 10768 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
11925 warn_code |= ASC_WARN_CFG_MSW_RECOVER; 10769 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
11926 AscSetChipCfgMsw(iop_base, cfg_msw); 10770 AscSetChipCfgMsw(iop_base, cfg_msw);
11927 } 10771 }
11928 if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) != 10772 if ((asc_dvc->cfg->cmd_qng_enabled & asc_dvc->cfg->disc_enable) !=
11929 asc_dvc->cfg->cmd_qng_enabled) { 10773 asc_dvc->cfg->cmd_qng_enabled) {
11930 asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled; 10774 asc_dvc->cfg->disc_enable = asc_dvc->cfg->cmd_qng_enabled;
11931 warn_code |= ASC_WARN_CMD_QNG_CONFLICT; 10775 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
11932 } 10776 }
11933 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) { 10777 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
11934 warn_code |= ASC_WARN_AUTO_CONFIG; 10778 warn_code |= ASC_WARN_AUTO_CONFIG;
11935 } 10779 }
11936 if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) { 10780 if ((asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL)) != 0) {
11937 if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type) 10781 if (AscSetChipIRQ(iop_base, asc_dvc->irq_no, asc_dvc->bus_type)
11938 != asc_dvc->irq_no) { 10782 != asc_dvc->irq_no) {
11939 asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO; 10783 asc_dvc->err_code |= ASC_IERR_SET_IRQ_NO;
11940 } 10784 }
11941 } 10785 }
11942 if (asc_dvc->bus_type & ASC_IS_PCI) { 10786 if (asc_dvc->bus_type & ASC_IS_PCI) {
11943 cfg_msw &= 0xFFC0; 10787 cfg_msw &= 0xFFC0;
11944 AscSetChipCfgMsw(iop_base, cfg_msw); 10788 AscSetChipCfgMsw(iop_base, cfg_msw);
11945 if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) { 10789 if ((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) {
11946 } else { 10790 } else {
11947 if ((pci_device_id == PCI_DEVICE_ID_ASP_1200A) || 10791 if ((pci_device_id == PCI_DEVICE_ID_ASP_1200A) ||
11948 (pci_device_id == PCI_DEVICE_ID_ASP_ABP940)) { 10792 (pci_device_id == PCI_DEVICE_ID_ASP_ABP940)) {
11949 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB; 10793 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_IF_NOT_DWB;
11950 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN; 10794 asc_dvc->bug_fix_cntl |=
11951 } 10795 ASC_BUG_FIX_ASYN_USE_SYN;
11952 } 10796 }
11953 } else if (asc_dvc->bus_type == ASC_IS_ISAPNP) { 10797 }
11954 if (AscGetChipVersion(iop_base, asc_dvc->bus_type) 10798 } else if (asc_dvc->bus_type == ASC_IS_ISAPNP) {
11955 == ASC_CHIP_VER_ASYN_BUG) { 10799 if (AscGetChipVersion(iop_base, asc_dvc->bus_type)
11956 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN; 10800 == ASC_CHIP_VER_ASYN_BUG) {
11957 } 10801 asc_dvc->bug_fix_cntl |= ASC_BUG_FIX_ASYN_USE_SYN;
11958 } 10802 }
11959 if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) != 10803 }
11960 asc_dvc->cfg->chip_scsi_id) { 10804 if (AscSetChipScsiID(iop_base, asc_dvc->cfg->chip_scsi_id) !=
11961 asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID; 10805 asc_dvc->cfg->chip_scsi_id) {
11962 } 10806 asc_dvc->err_code |= ASC_IERR_SET_SCSI_ID;
10807 }
11963#ifdef CONFIG_ISA 10808#ifdef CONFIG_ISA
11964 if (asc_dvc->bus_type & ASC_IS_ISA) { 10809 if (asc_dvc->bus_type & ASC_IS_ISA) {
11965 AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel); 10810 AscSetIsaDmaChannel(iop_base, asc_dvc->cfg->isa_dma_channel);
11966 AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed); 10811 AscSetIsaDmaSpeed(iop_base, asc_dvc->cfg->isa_dma_speed);
11967 } 10812 }
11968#endif /* CONFIG_ISA */ 10813#endif /* CONFIG_ISA */
11969 return (warn_code); 10814 return (warn_code);
11970} 10815}
11971 10816
11972STATIC ushort 10817static ushort AscInitAsc1000Driver(ASC_DVC_VAR *asc_dvc)
11973AscInitAsc1000Driver(
11974 ASC_DVC_VAR *asc_dvc
11975)
11976{ 10818{
11977 ushort warn_code; 10819 ushort warn_code;
11978 PortAddr iop_base; 10820 PortAddr iop_base;
11979 10821
11980 iop_base = asc_dvc->iop_base; 10822 iop_base = asc_dvc->iop_base;
11981 warn_code = 0; 10823 warn_code = 0;
11982 if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) && 10824 if ((asc_dvc->dvc_cntl & ASC_CNTL_RESET_SCSI) &&
11983 !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) { 10825 !(asc_dvc->init_state & ASC_INIT_RESET_SCSI_DONE)) {
11984 AscResetChipAndScsiBus(asc_dvc); 10826 AscResetChipAndScsiBus(asc_dvc);
11985 DvcSleepMilliSecond((ASC_DCNT) 10827 DvcSleepMilliSecond((ASC_DCNT)
11986 ((ushort) asc_dvc->scsi_reset_wait * 1000)); 10828 ((ushort)asc_dvc->scsi_reset_wait * 1000));
11987 } 10829 }
11988 asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC; 10830 asc_dvc->init_state |= ASC_INIT_STATE_BEG_LOAD_MC;
11989 if (asc_dvc->err_code != 0) 10831 if (asc_dvc->err_code != 0)
11990 return (UW_ERR); 10832 return (UW_ERR);
11991 if (!AscFindSignature(asc_dvc->iop_base)) { 10833 if (!AscFindSignature(asc_dvc->iop_base)) {
11992 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; 10834 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
11993 return (warn_code); 10835 return (warn_code);
11994 } 10836 }
11995 AscDisableInterrupt(iop_base); 10837 AscDisableInterrupt(iop_base);
11996 warn_code |= AscInitLram(asc_dvc); 10838 warn_code |= AscInitLram(asc_dvc);
11997 if (asc_dvc->err_code != 0) 10839 if (asc_dvc->err_code != 0)
11998 return (UW_ERR); 10840 return (UW_ERR);
11999 ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n", 10841 ASC_DBG1(1, "AscInitAsc1000Driver: _asc_mcode_chksum 0x%lx\n",
12000 (ulong) _asc_mcode_chksum); 10842 (ulong)_asc_mcode_chksum);
12001 if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf, 10843 if (AscLoadMicroCode(iop_base, 0, _asc_mcode_buf,
12002 _asc_mcode_size) != _asc_mcode_chksum) { 10844 _asc_mcode_size) != _asc_mcode_chksum) {
12003 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM; 10845 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
12004 return (warn_code); 10846 return (warn_code);
12005 } 10847 }
12006 warn_code |= AscInitMicroCodeVar(asc_dvc); 10848 warn_code |= AscInitMicroCodeVar(asc_dvc);
12007 asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC; 10849 asc_dvc->init_state |= ASC_INIT_STATE_END_LOAD_MC;
12008 AscEnableInterrupt(iop_base); 10850 AscEnableInterrupt(iop_base);
12009 return (warn_code); 10851 return (warn_code);
12010} 10852}
12011 10853
12012STATIC ushort __init 10854static ushort __init AscInitAscDvcVar(ASC_DVC_VAR *asc_dvc)
12013AscInitAscDvcVar(
12014 ASC_DVC_VAR *asc_dvc)
12015{ 10855{
12016 int i; 10856 int i;
12017 PortAddr iop_base; 10857 PortAddr iop_base;
12018 ushort warn_code; 10858 ushort warn_code;
12019 uchar chip_version; 10859 uchar chip_version;
12020 10860
12021 iop_base = asc_dvc->iop_base; 10861 iop_base = asc_dvc->iop_base;
12022 warn_code = 0; 10862 warn_code = 0;
12023 asc_dvc->err_code = 0; 10863 asc_dvc->err_code = 0;
12024 if ((asc_dvc->bus_type & 10864 if ((asc_dvc->bus_type &
12025 (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) { 10865 (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA | ASC_IS_VL)) == 0) {
12026 asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE; 10866 asc_dvc->err_code |= ASC_IERR_NO_BUS_TYPE;
12027 } 10867 }
12028 AscSetChipControl(iop_base, CC_HALT); 10868 AscSetChipControl(iop_base, CC_HALT);
12029 AscSetChipStatus(iop_base, 0); 10869 AscSetChipStatus(iop_base, 0);
12030 asc_dvc->bug_fix_cntl = 0; 10870 asc_dvc->bug_fix_cntl = 0;
12031 asc_dvc->pci_fix_asyn_xfer = 0; 10871 asc_dvc->pci_fix_asyn_xfer = 0;
12032 asc_dvc->pci_fix_asyn_xfer_always = 0; 10872 asc_dvc->pci_fix_asyn_xfer_always = 0;
12033 /* asc_dvc->init_state initalized in AscInitGetConfig(). */ 10873 /* asc_dvc->init_state initalized in AscInitGetConfig(). */
12034 asc_dvc->sdtr_done = 0; 10874 asc_dvc->sdtr_done = 0;
12035 asc_dvc->cur_total_qng = 0; 10875 asc_dvc->cur_total_qng = 0;
12036 asc_dvc->is_in_int = 0; 10876 asc_dvc->is_in_int = 0;
12037 asc_dvc->in_critical_cnt = 0; 10877 asc_dvc->in_critical_cnt = 0;
12038 asc_dvc->last_q_shortage = 0; 10878 asc_dvc->last_q_shortage = 0;
12039 asc_dvc->use_tagged_qng = 0; 10879 asc_dvc->use_tagged_qng = 0;
12040 asc_dvc->no_scam = 0; 10880 asc_dvc->no_scam = 0;
12041 asc_dvc->unit_not_ready = 0; 10881 asc_dvc->unit_not_ready = 0;
12042 asc_dvc->queue_full_or_busy = 0; 10882 asc_dvc->queue_full_or_busy = 0;
12043 asc_dvc->redo_scam = 0; 10883 asc_dvc->redo_scam = 0;
12044 asc_dvc->res2 = 0; 10884 asc_dvc->res2 = 0;
12045 asc_dvc->host_init_sdtr_index = 0; 10885 asc_dvc->host_init_sdtr_index = 0;
12046 asc_dvc->cfg->can_tagged_qng = 0; 10886 asc_dvc->cfg->can_tagged_qng = 0;
12047 asc_dvc->cfg->cmd_qng_enabled = 0; 10887 asc_dvc->cfg->cmd_qng_enabled = 0;
12048 asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL; 10888 asc_dvc->dvc_cntl = ASC_DEF_DVC_CNTL;
12049 asc_dvc->init_sdtr = 0; 10889 asc_dvc->init_sdtr = 0;
12050 asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG; 10890 asc_dvc->max_total_qng = ASC_DEF_MAX_TOTAL_QNG;
12051 asc_dvc->scsi_reset_wait = 3; 10891 asc_dvc->scsi_reset_wait = 3;
12052 asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET; 10892 asc_dvc->start_motor = ASC_SCSI_WIDTH_BIT_SET;
12053 asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type); 10893 asc_dvc->max_dma_count = AscGetMaxDmaCount(asc_dvc->bus_type);
12054 asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET; 10894 asc_dvc->cfg->sdtr_enable = ASC_SCSI_WIDTH_BIT_SET;
12055 asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET; 10895 asc_dvc->cfg->disc_enable = ASC_SCSI_WIDTH_BIT_SET;
12056 asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID; 10896 asc_dvc->cfg->chip_scsi_id = ASC_DEF_CHIP_SCSI_ID;
12057 asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER; 10897 asc_dvc->cfg->lib_serial_no = ASC_LIB_SERIAL_NUMBER;
12058 asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) | 10898 asc_dvc->cfg->lib_version = (ASC_LIB_VERSION_MAJOR << 8) |
12059 ASC_LIB_VERSION_MINOR; 10899 ASC_LIB_VERSION_MINOR;
12060 chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type); 10900 chip_version = AscGetChipVersion(iop_base, asc_dvc->bus_type);
12061 asc_dvc->cfg->chip_version = chip_version; 10901 asc_dvc->cfg->chip_version = chip_version;
12062 asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0; 10902 asc_dvc->sdtr_period_tbl[0] = SYN_XFER_NS_0;
12063 asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1; 10903 asc_dvc->sdtr_period_tbl[1] = SYN_XFER_NS_1;
12064 asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2; 10904 asc_dvc->sdtr_period_tbl[2] = SYN_XFER_NS_2;
12065 asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3; 10905 asc_dvc->sdtr_period_tbl[3] = SYN_XFER_NS_3;
12066 asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4; 10906 asc_dvc->sdtr_period_tbl[4] = SYN_XFER_NS_4;
12067 asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5; 10907 asc_dvc->sdtr_period_tbl[5] = SYN_XFER_NS_5;
12068 asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6; 10908 asc_dvc->sdtr_period_tbl[6] = SYN_XFER_NS_6;
12069 asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7; 10909 asc_dvc->sdtr_period_tbl[7] = SYN_XFER_NS_7;
12070 asc_dvc->max_sdtr_index = 7; 10910 asc_dvc->max_sdtr_index = 7;
12071 if ((asc_dvc->bus_type & ASC_IS_PCI) && 10911 if ((asc_dvc->bus_type & ASC_IS_PCI) &&
12072 (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) { 10912 (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3150)) {
12073 asc_dvc->bus_type = ASC_IS_PCI_ULTRA; 10913 asc_dvc->bus_type = ASC_IS_PCI_ULTRA;
12074 asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0; 10914 asc_dvc->sdtr_period_tbl[0] = SYN_ULTRA_XFER_NS_0;
12075 asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1; 10915 asc_dvc->sdtr_period_tbl[1] = SYN_ULTRA_XFER_NS_1;
12076 asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2; 10916 asc_dvc->sdtr_period_tbl[2] = SYN_ULTRA_XFER_NS_2;
12077 asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3; 10917 asc_dvc->sdtr_period_tbl[3] = SYN_ULTRA_XFER_NS_3;
12078 asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4; 10918 asc_dvc->sdtr_period_tbl[4] = SYN_ULTRA_XFER_NS_4;
12079 asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5; 10919 asc_dvc->sdtr_period_tbl[5] = SYN_ULTRA_XFER_NS_5;
12080 asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6; 10920 asc_dvc->sdtr_period_tbl[6] = SYN_ULTRA_XFER_NS_6;
12081 asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7; 10921 asc_dvc->sdtr_period_tbl[7] = SYN_ULTRA_XFER_NS_7;
12082 asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8; 10922 asc_dvc->sdtr_period_tbl[8] = SYN_ULTRA_XFER_NS_8;
12083 asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9; 10923 asc_dvc->sdtr_period_tbl[9] = SYN_ULTRA_XFER_NS_9;
12084 asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10; 10924 asc_dvc->sdtr_period_tbl[10] = SYN_ULTRA_XFER_NS_10;
12085 asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11; 10925 asc_dvc->sdtr_period_tbl[11] = SYN_ULTRA_XFER_NS_11;
12086 asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12; 10926 asc_dvc->sdtr_period_tbl[12] = SYN_ULTRA_XFER_NS_12;
12087 asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13; 10927 asc_dvc->sdtr_period_tbl[13] = SYN_ULTRA_XFER_NS_13;
12088 asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14; 10928 asc_dvc->sdtr_period_tbl[14] = SYN_ULTRA_XFER_NS_14;
12089 asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15; 10929 asc_dvc->sdtr_period_tbl[15] = SYN_ULTRA_XFER_NS_15;
12090 asc_dvc->max_sdtr_index = 15; 10930 asc_dvc->max_sdtr_index = 15;
12091 if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) 10931 if (chip_version == ASC_CHIP_VER_PCI_ULTRA_3150) {
12092 { 10932 AscSetExtraControl(iop_base,
12093 AscSetExtraControl(iop_base, 10933 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
12094 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE)); 10934 } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) {
12095 } else if (chip_version >= ASC_CHIP_VER_PCI_ULTRA_3050) { 10935 AscSetExtraControl(iop_base,
12096 AscSetExtraControl(iop_base, 10936 (SEC_ACTIVE_NEGATE |
12097 (SEC_ACTIVE_NEGATE | SEC_ENABLE_FILTER)); 10937 SEC_ENABLE_FILTER));
12098 } 10938 }
12099 } 10939 }
12100 if (asc_dvc->bus_type == ASC_IS_PCI) { 10940 if (asc_dvc->bus_type == ASC_IS_PCI) {
12101 AscSetExtraControl(iop_base, (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE)); 10941 AscSetExtraControl(iop_base,
12102 } 10942 (SEC_ACTIVE_NEGATE | SEC_SLEW_RATE));
10943 }
12103 10944
12104 asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED; 10945 asc_dvc->cfg->isa_dma_speed = ASC_DEF_ISA_DMA_SPEED;
12105 if (AscGetChipBusType(iop_base) == ASC_IS_ISAPNP) { 10946 if (AscGetChipBusType(iop_base) == ASC_IS_ISAPNP) {
12106 AscSetChipIFC(iop_base, IFC_INIT_DEFAULT); 10947 AscSetChipIFC(iop_base, IFC_INIT_DEFAULT);
12107 asc_dvc->bus_type = ASC_IS_ISAPNP; 10948 asc_dvc->bus_type = ASC_IS_ISAPNP;
12108 } 10949 }
12109#ifdef CONFIG_ISA 10950#ifdef CONFIG_ISA
12110 if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) { 10951 if ((asc_dvc->bus_type & ASC_IS_ISA) != 0) {
12111 asc_dvc->cfg->isa_dma_channel = (uchar) AscGetIsaDmaChannel(iop_base); 10952 asc_dvc->cfg->isa_dma_channel =
12112 } 10953 (uchar)AscGetIsaDmaChannel(iop_base);
10954 }
12113#endif /* CONFIG_ISA */ 10955#endif /* CONFIG_ISA */
12114 for (i = 0; i <= ASC_MAX_TID; i++) { 10956 for (i = 0; i <= ASC_MAX_TID; i++) {
12115 asc_dvc->cur_dvc_qng[i] = 0; 10957 asc_dvc->cur_dvc_qng[i] = 0;
12116 asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG; 10958 asc_dvc->max_dvc_qng[i] = ASC_MAX_SCSI1_QNG;
12117 asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *) 0L; 10959 asc_dvc->scsiq_busy_head[i] = (ASC_SCSI_Q *)0L;
12118 asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *) 0L; 10960 asc_dvc->scsiq_busy_tail[i] = (ASC_SCSI_Q *)0L;
12119 asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG; 10961 asc_dvc->cfg->max_tag_qng[i] = ASC_MAX_INRAM_TAG_QNG;
12120 } 10962 }
12121 return (warn_code); 10963 return (warn_code);
12122} 10964}
12123 10965
12124STATIC ushort __init 10966static ushort __init AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
12125AscInitFromEEP(ASC_DVC_VAR *asc_dvc)
12126{ 10967{
12127 ASCEEP_CONFIG eep_config_buf; 10968 ASCEEP_CONFIG eep_config_buf;
12128 ASCEEP_CONFIG *eep_config; 10969 ASCEEP_CONFIG *eep_config;
12129 PortAddr iop_base; 10970 PortAddr iop_base;
12130 ushort chksum; 10971 ushort chksum;
12131 ushort warn_code; 10972 ushort warn_code;
12132 ushort cfg_msw, cfg_lsw; 10973 ushort cfg_msw, cfg_lsw;
12133 int i; 10974 int i;
12134 int write_eep = 0; 10975 int write_eep = 0;
12135 10976
12136 iop_base = asc_dvc->iop_base; 10977 iop_base = asc_dvc->iop_base;
12137 warn_code = 0; 10978 warn_code = 0;
12138 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE); 10979 AscWriteLramWord(iop_base, ASCV_HALTCODE_W, 0x00FE);
12139 AscStopQueueExe(iop_base); 10980 AscStopQueueExe(iop_base);
12140 if ((AscStopChip(iop_base) == FALSE) || 10981 if ((AscStopChip(iop_base) == FALSE) ||
12141 (AscGetChipScsiCtrl(iop_base) != 0)) { 10982 (AscGetChipScsiCtrl(iop_base) != 0)) {
12142 asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE; 10983 asc_dvc->init_state |= ASC_INIT_RESET_SCSI_DONE;
12143 AscResetChipAndScsiBus(asc_dvc); 10984 AscResetChipAndScsiBus(asc_dvc);
12144 DvcSleepMilliSecond((ASC_DCNT) 10985 DvcSleepMilliSecond((ASC_DCNT)
12145 ((ushort) asc_dvc->scsi_reset_wait * 1000)); 10986 ((ushort)asc_dvc->scsi_reset_wait * 1000));
12146 } 10987 }
12147 if (AscIsChipHalted(iop_base) == FALSE) { 10988 if (AscIsChipHalted(iop_base) == FALSE) {
12148 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP; 10989 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
12149 return (warn_code); 10990 return (warn_code);
12150 } 10991 }
12151 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR); 10992 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
12152 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) { 10993 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
12153 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR; 10994 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
12154 return (warn_code); 10995 return (warn_code);
12155 } 10996 }
12156 eep_config = (ASCEEP_CONFIG *) &eep_config_buf; 10997 eep_config = (ASCEEP_CONFIG *)&eep_config_buf;
12157 cfg_msw = AscGetChipCfgMsw(iop_base); 10998 cfg_msw = AscGetChipCfgMsw(iop_base);
12158 cfg_lsw = AscGetChipCfgLsw(iop_base); 10999 cfg_lsw = AscGetChipCfgLsw(iop_base);
12159 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) { 11000 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
12160 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK)); 11001 cfg_msw &= (~(ASC_CFG_MSW_CLR_MASK));
12161 warn_code |= ASC_WARN_CFG_MSW_RECOVER; 11002 warn_code |= ASC_WARN_CFG_MSW_RECOVER;
12162 AscSetChipCfgMsw(iop_base, cfg_msw); 11003 AscSetChipCfgMsw(iop_base, cfg_msw);
12163 } 11004 }
12164 chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type); 11005 chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->bus_type);
12165 ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum); 11006 ASC_DBG1(1, "AscInitFromEEP: chksum 0x%x\n", chksum);
12166 if (chksum == 0) { 11007 if (chksum == 0) {
12167 chksum = 0xaa55; 11008 chksum = 0xaa55;
12168 } 11009 }
12169 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) { 11010 if (AscGetChipStatus(iop_base) & CSW_AUTO_CONFIG) {
12170 warn_code |= ASC_WARN_AUTO_CONFIG; 11011 warn_code |= ASC_WARN_AUTO_CONFIG;
12171 if (asc_dvc->cfg->chip_version == 3) { 11012 if (asc_dvc->cfg->chip_version == 3) {
12172 if (eep_config->cfg_lsw != cfg_lsw) { 11013 if (eep_config->cfg_lsw != cfg_lsw) {
12173 warn_code |= ASC_WARN_EEPROM_RECOVER; 11014 warn_code |= ASC_WARN_EEPROM_RECOVER;
12174 eep_config->cfg_lsw = AscGetChipCfgLsw(iop_base); 11015 eep_config->cfg_lsw =
12175 } 11016 AscGetChipCfgLsw(iop_base);
12176 if (eep_config->cfg_msw != cfg_msw) { 11017 }
12177 warn_code |= ASC_WARN_EEPROM_RECOVER; 11018 if (eep_config->cfg_msw != cfg_msw) {
12178 eep_config->cfg_msw = AscGetChipCfgMsw(iop_base); 11019 warn_code |= ASC_WARN_EEPROM_RECOVER;
12179 } 11020 eep_config->cfg_msw =
12180 } 11021 AscGetChipCfgMsw(iop_base);
12181 } 11022 }
12182 eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK; 11023 }
12183 eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON; 11024 }
12184 ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n", 11025 eep_config->cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
12185 eep_config->chksum); 11026 eep_config->cfg_lsw |= ASC_CFG0_HOST_INT_ON;
12186 if (chksum != eep_config->chksum) { 11027 ASC_DBG1(1, "AscInitFromEEP: eep_config->chksum 0x%x\n",
12187 if (AscGetChipVersion(iop_base, asc_dvc->bus_type) == 11028 eep_config->chksum);
12188 ASC_CHIP_VER_PCI_ULTRA_3050 ) 11029 if (chksum != eep_config->chksum) {
12189 { 11030 if (AscGetChipVersion(iop_base, asc_dvc->bus_type) ==
12190 ASC_DBG(1, 11031 ASC_CHIP_VER_PCI_ULTRA_3050) {
12191"AscInitFromEEP: chksum error ignored; EEPROM-less board\n"); 11032 ASC_DBG(1,
12192 eep_config->init_sdtr = 0xFF; 11033 "AscInitFromEEP: chksum error ignored; EEPROM-less board\n");
12193 eep_config->disc_enable = 0xFF; 11034 eep_config->init_sdtr = 0xFF;
12194 eep_config->start_motor = 0xFF; 11035 eep_config->disc_enable = 0xFF;
12195 eep_config->use_cmd_qng = 0; 11036 eep_config->start_motor = 0xFF;
12196 eep_config->max_total_qng = 0xF0; 11037 eep_config->use_cmd_qng = 0;
12197 eep_config->max_tag_qng = 0x20; 11038 eep_config->max_total_qng = 0xF0;
12198 eep_config->cntl = 0xBFFF; 11039 eep_config->max_tag_qng = 0x20;
12199 ASC_EEP_SET_CHIP_ID(eep_config, 7); 11040 eep_config->cntl = 0xBFFF;
12200 eep_config->no_scam = 0; 11041 ASC_EEP_SET_CHIP_ID(eep_config, 7);
12201 eep_config->adapter_info[0] = 0; 11042 eep_config->no_scam = 0;
12202 eep_config->adapter_info[1] = 0; 11043 eep_config->adapter_info[0] = 0;
12203 eep_config->adapter_info[2] = 0; 11044 eep_config->adapter_info[1] = 0;
12204 eep_config->adapter_info[3] = 0; 11045 eep_config->adapter_info[2] = 0;
12205 eep_config->adapter_info[4] = 0; 11046 eep_config->adapter_info[3] = 0;
12206 /* Indicate EEPROM-less board. */ 11047 eep_config->adapter_info[4] = 0;
12207 eep_config->adapter_info[5] = 0xBB; 11048 /* Indicate EEPROM-less board. */
12208 } else { 11049 eep_config->adapter_info[5] = 0xBB;
12209 ASC_PRINT( 11050 } else {
12210"AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n"); 11051 ASC_PRINT
12211 write_eep = 1; 11052 ("AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
12212 warn_code |= ASC_WARN_EEPROM_CHKSUM; 11053 write_eep = 1;
12213 } 11054 warn_code |= ASC_WARN_EEPROM_CHKSUM;
12214 } 11055 }
12215 asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr; 11056 }
12216 asc_dvc->cfg->disc_enable = eep_config->disc_enable; 11057 asc_dvc->cfg->sdtr_enable = eep_config->init_sdtr;
12217 asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng; 11058 asc_dvc->cfg->disc_enable = eep_config->disc_enable;
12218 asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config); 11059 asc_dvc->cfg->cmd_qng_enabled = eep_config->use_cmd_qng;
12219 asc_dvc->start_motor = eep_config->start_motor; 11060 asc_dvc->cfg->isa_dma_speed = ASC_EEP_GET_DMA_SPD(eep_config);
12220 asc_dvc->dvc_cntl = eep_config->cntl; 11061 asc_dvc->start_motor = eep_config->start_motor;
12221 asc_dvc->no_scam = eep_config->no_scam; 11062 asc_dvc->dvc_cntl = eep_config->cntl;
12222 asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0]; 11063 asc_dvc->no_scam = eep_config->no_scam;
12223 asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1]; 11064 asc_dvc->cfg->adapter_info[0] = eep_config->adapter_info[0];
12224 asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2]; 11065 asc_dvc->cfg->adapter_info[1] = eep_config->adapter_info[1];
12225 asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3]; 11066 asc_dvc->cfg->adapter_info[2] = eep_config->adapter_info[2];
12226 asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4]; 11067 asc_dvc->cfg->adapter_info[3] = eep_config->adapter_info[3];
12227 asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5]; 11068 asc_dvc->cfg->adapter_info[4] = eep_config->adapter_info[4];
12228 if (!AscTestExternalLram(asc_dvc)) { 11069 asc_dvc->cfg->adapter_info[5] = eep_config->adapter_info[5];
12229 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA)) { 11070 if (!AscTestExternalLram(asc_dvc)) {
12230 eep_config->max_total_qng = ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG; 11071 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) ==
12231 eep_config->max_tag_qng = ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG; 11072 ASC_IS_PCI_ULTRA)) {
12232 } else { 11073 eep_config->max_total_qng =
12233 eep_config->cfg_msw |= 0x0800; 11074 ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG;
12234 cfg_msw |= 0x0800; 11075 eep_config->max_tag_qng =
12235 AscSetChipCfgMsw(iop_base, cfg_msw); 11076 ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG;
12236 eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG; 11077 } else {
12237 eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG; 11078 eep_config->cfg_msw |= 0x0800;
12238 } 11079 cfg_msw |= 0x0800;
12239 } else { 11080 AscSetChipCfgMsw(iop_base, cfg_msw);
12240 } 11081 eep_config->max_total_qng = ASC_MAX_PCI_INRAM_TOTAL_QNG;
12241 if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) { 11082 eep_config->max_tag_qng = ASC_MAX_INRAM_TAG_QNG;
12242 eep_config->max_total_qng = ASC_MIN_TOTAL_QNG; 11083 }
12243 } 11084 } else {
12244 if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) { 11085 }
12245 eep_config->max_total_qng = ASC_MAX_TOTAL_QNG; 11086 if (eep_config->max_total_qng < ASC_MIN_TOTAL_QNG) {
12246 } 11087 eep_config->max_total_qng = ASC_MIN_TOTAL_QNG;
12247 if (eep_config->max_tag_qng > eep_config->max_total_qng) { 11088 }
12248 eep_config->max_tag_qng = eep_config->max_total_qng; 11089 if (eep_config->max_total_qng > ASC_MAX_TOTAL_QNG) {
12249 } 11090 eep_config->max_total_qng = ASC_MAX_TOTAL_QNG;
12250 if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) { 11091 }
12251 eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC; 11092 if (eep_config->max_tag_qng > eep_config->max_total_qng) {
12252 } 11093 eep_config->max_tag_qng = eep_config->max_total_qng;
12253 asc_dvc->max_total_qng = eep_config->max_total_qng; 11094 }
12254 if ((eep_config->use_cmd_qng & eep_config->disc_enable) != 11095 if (eep_config->max_tag_qng < ASC_MIN_TAG_Q_PER_DVC) {
12255 eep_config->use_cmd_qng) { 11096 eep_config->max_tag_qng = ASC_MIN_TAG_Q_PER_DVC;
12256 eep_config->disc_enable = eep_config->use_cmd_qng; 11097 }
12257 warn_code |= ASC_WARN_CMD_QNG_CONFLICT; 11098 asc_dvc->max_total_qng = eep_config->max_total_qng;
12258 } 11099 if ((eep_config->use_cmd_qng & eep_config->disc_enable) !=
12259 if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) { 11100 eep_config->use_cmd_qng) {
12260 asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type); 11101 eep_config->disc_enable = eep_config->use_cmd_qng;
12261 } 11102 warn_code |= ASC_WARN_CMD_QNG_CONFLICT;
12262 ASC_EEP_SET_CHIP_ID(eep_config, ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID); 11103 }
12263 asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config); 11104 if (asc_dvc->bus_type & (ASC_IS_ISA | ASC_IS_VL | ASC_IS_EISA)) {
12264 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) && 11105 asc_dvc->irq_no = AscGetChipIRQ(iop_base, asc_dvc->bus_type);
12265 !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) { 11106 }
12266 asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX; 11107 ASC_EEP_SET_CHIP_ID(eep_config,
12267 } 11108 ASC_EEP_GET_CHIP_ID(eep_config) & ASC_MAX_TID);
11109 asc_dvc->cfg->chip_scsi_id = ASC_EEP_GET_CHIP_ID(eep_config);
11110 if (((asc_dvc->bus_type & ASC_IS_PCI_ULTRA) == ASC_IS_PCI_ULTRA) &&
11111 !(asc_dvc->dvc_cntl & ASC_CNTL_SDTR_ENABLE_ULTRA)) {
11112 asc_dvc->host_init_sdtr_index = ASC_SDTR_ULTRA_PCI_10MB_INDEX;
11113 }
12268 11114
12269 for (i = 0; i <= ASC_MAX_TID; i++) { 11115 for (i = 0; i <= ASC_MAX_TID; i++) {
12270 asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i]; 11116 asc_dvc->dos_int13_table[i] = eep_config->dos_int13_table[i];
12271 asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng; 11117 asc_dvc->cfg->max_tag_qng[i] = eep_config->max_tag_qng;
12272 asc_dvc->cfg->sdtr_period_offset[i] = 11118 asc_dvc->cfg->sdtr_period_offset[i] =
12273 (uchar) (ASC_DEF_SDTR_OFFSET | 11119 (uchar)(ASC_DEF_SDTR_OFFSET |
12274 (asc_dvc->host_init_sdtr_index << 4)); 11120 (asc_dvc->host_init_sdtr_index << 4));
12275 } 11121 }
12276 eep_config->cfg_msw = AscGetChipCfgMsw(iop_base); 11122 eep_config->cfg_msw = AscGetChipCfgMsw(iop_base);
12277 if (write_eep) { 11123 if (write_eep) {
12278 if ((i = AscSetEEPConfig(iop_base, eep_config, asc_dvc->bus_type)) != 11124 if ((i =
12279 0) { 11125 AscSetEEPConfig(iop_base, eep_config,
12280 ASC_PRINT1( 11126 asc_dvc->bus_type)) != 0) {
12281"AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n", i); 11127 ASC_PRINT1
12282 } else { 11128 ("AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
12283 ASC_PRINT("AscInitFromEEP: Successfully re-wrote EEPROM.\n"); 11129 i);
12284 } 11130 } else {
12285 } 11131 ASC_PRINT
12286 return (warn_code); 11132 ("AscInitFromEEP: Successfully re-wrote EEPROM.\n");
11133 }
11134 }
11135 return (warn_code);
12287} 11136}
12288 11137
12289STATIC ushort 11138static ushort AscInitMicroCodeVar(ASC_DVC_VAR *asc_dvc)
12290AscInitMicroCodeVar(
12291 ASC_DVC_VAR *asc_dvc
12292)
12293{ 11139{
12294 int i; 11140 int i;
12295 ushort warn_code; 11141 ushort warn_code;
12296 PortAddr iop_base; 11142 PortAddr iop_base;
12297 ASC_PADDR phy_addr; 11143 ASC_PADDR phy_addr;
12298 ASC_DCNT phy_size; 11144 ASC_DCNT phy_size;
12299 11145
12300 iop_base = asc_dvc->iop_base; 11146 iop_base = asc_dvc->iop_base;
12301 warn_code = 0; 11147 warn_code = 0;
12302 for (i = 0; i <= ASC_MAX_TID; i++) { 11148 for (i = 0; i <= ASC_MAX_TID; i++) {
12303 AscPutMCodeInitSDTRAtID(iop_base, i, 11149 AscPutMCodeInitSDTRAtID(iop_base, i,
12304 asc_dvc->cfg->sdtr_period_offset[i] 11150 asc_dvc->cfg->sdtr_period_offset[i]
12305); 11151 );
12306 } 11152 }
12307 11153
12308 AscInitQLinkVar(asc_dvc); 11154 AscInitQLinkVar(asc_dvc);
12309 AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B, 11155 AscWriteLramByte(iop_base, ASCV_DISC_ENABLE_B,
12310 asc_dvc->cfg->disc_enable); 11156 asc_dvc->cfg->disc_enable);
12311 AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B, 11157 AscWriteLramByte(iop_base, ASCV_HOSTSCSI_ID_B,
12312 ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id)); 11158 ASC_TID_TO_TARGET_ID(asc_dvc->cfg->chip_scsi_id));
12313 11159
12314 /* Align overrun buffer on an 8 byte boundary. */ 11160 /* Align overrun buffer on an 8 byte boundary. */
12315 phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf); 11161 phy_addr = virt_to_bus(asc_dvc->cfg->overrun_buf);
12316 phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7); 11162 phy_addr = cpu_to_le32((phy_addr + 7) & ~0x7);
12317 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D, 11163 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_PADDR_D,
12318 (uchar *) &phy_addr, 1); 11164 (uchar *)&phy_addr, 1);
12319 phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8); 11165 phy_size = cpu_to_le32(ASC_OVERRUN_BSIZE - 8);
12320 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D, 11166 AscMemDWordCopyPtrToLram(iop_base, ASCV_OVERRUN_BSIZE_D,
12321 (uchar *) &phy_size, 1); 11167 (uchar *)&phy_size, 1);
12322 11168
12323 asc_dvc->cfg->mcode_date = 11169 asc_dvc->cfg->mcode_date =
12324 AscReadLramWord(iop_base, (ushort) ASCV_MC_DATE_W); 11170 AscReadLramWord(iop_base, (ushort)ASCV_MC_DATE_W);
12325 asc_dvc->cfg->mcode_version = 11171 asc_dvc->cfg->mcode_version =
12326 AscReadLramWord(iop_base, (ushort) ASCV_MC_VER_W); 11172 AscReadLramWord(iop_base, (ushort)ASCV_MC_VER_W);
12327 11173
12328 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR); 11174 AscSetPCAddr(iop_base, ASC_MCODE_START_ADDR);
12329 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) { 11175 if (AscGetPCAddr(iop_base) != ASC_MCODE_START_ADDR) {
12330 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR; 11176 asc_dvc->err_code |= ASC_IERR_SET_PC_ADDR;
12331 return (warn_code); 11177 return (warn_code);
12332 } 11178 }
12333 if (AscStartChip(iop_base) != 1) { 11179 if (AscStartChip(iop_base) != 1) {
12334 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP; 11180 asc_dvc->err_code |= ASC_IERR_START_STOP_CHIP;
12335 return (warn_code); 11181 return (warn_code);
12336 } 11182 }
12337 11183
12338 return (warn_code); 11184 return (warn_code);
12339} 11185}
12340 11186
12341STATIC int __init 11187static int __init AscTestExternalLram(ASC_DVC_VAR *asc_dvc)
12342AscTestExternalLram(
12343 ASC_DVC_VAR *asc_dvc)
12344{ 11188{
12345 PortAddr iop_base; 11189 PortAddr iop_base;
12346 ushort q_addr; 11190 ushort q_addr;
12347 ushort saved_word; 11191 ushort saved_word;
12348 int sta; 11192 int sta;
12349 11193
12350 iop_base = asc_dvc->iop_base; 11194 iop_base = asc_dvc->iop_base;
12351 sta = 0; 11195 sta = 0;
12352 q_addr = ASC_QNO_TO_QADDR(241); 11196 q_addr = ASC_QNO_TO_QADDR(241);
12353 saved_word = AscReadLramWord(iop_base, q_addr); 11197 saved_word = AscReadLramWord(iop_base, q_addr);
12354 AscSetChipLramAddr(iop_base, q_addr); 11198 AscSetChipLramAddr(iop_base, q_addr);
12355 AscSetChipLramData(iop_base, 0x55AA); 11199 AscSetChipLramData(iop_base, 0x55AA);
12356 DvcSleepMilliSecond(10); 11200 DvcSleepMilliSecond(10);
12357 AscSetChipLramAddr(iop_base, q_addr); 11201 AscSetChipLramAddr(iop_base, q_addr);
12358 if (AscGetChipLramData(iop_base) == 0x55AA) { 11202 if (AscGetChipLramData(iop_base) == 0x55AA) {
12359 sta = 1; 11203 sta = 1;
12360 AscWriteLramWord(iop_base, q_addr, saved_word); 11204 AscWriteLramWord(iop_base, q_addr, saved_word);
12361 } 11205 }
12362 return (sta); 11206 return (sta);
12363} 11207}
12364 11208
12365STATIC int __init 11209static int __init AscWriteEEPCmdReg(PortAddr iop_base, uchar cmd_reg)
12366AscWriteEEPCmdReg(
12367 PortAddr iop_base,
12368 uchar cmd_reg
12369)
12370{ 11210{
12371 uchar read_back; 11211 uchar read_back;
12372 int retry; 11212 int retry;
12373 11213
12374 retry = 0; 11214 retry = 0;
12375 while (TRUE) { 11215 while (TRUE) {
12376 AscSetChipEEPCmd(iop_base, cmd_reg); 11216 AscSetChipEEPCmd(iop_base, cmd_reg);
12377 DvcSleepMilliSecond(1); 11217 DvcSleepMilliSecond(1);
12378 read_back = AscGetChipEEPCmd(iop_base); 11218 read_back = AscGetChipEEPCmd(iop_base);
12379 if (read_back == cmd_reg) { 11219 if (read_back == cmd_reg) {
12380 return (1); 11220 return (1);
12381 } 11221 }
12382 if (retry++ > ASC_EEP_MAX_RETRY) { 11222 if (retry++ > ASC_EEP_MAX_RETRY) {
12383 return (0); 11223 return (0);
12384 } 11224 }
12385 } 11225 }
12386} 11226}
12387 11227
12388STATIC int __init 11228static int __init AscWriteEEPDataReg(PortAddr iop_base, ushort data_reg)
12389AscWriteEEPDataReg(
12390 PortAddr iop_base,
12391 ushort data_reg
12392)
12393{ 11229{
12394 ushort read_back; 11230 ushort read_back;
12395 int retry; 11231 int retry;
12396 11232
12397 retry = 0; 11233 retry = 0;
12398 while (TRUE) { 11234 while (TRUE) {
12399 AscSetChipEEPData(iop_base, data_reg); 11235 AscSetChipEEPData(iop_base, data_reg);
12400 DvcSleepMilliSecond(1); 11236 DvcSleepMilliSecond(1);
12401 read_back = AscGetChipEEPData(iop_base); 11237 read_back = AscGetChipEEPData(iop_base);
12402 if (read_back == data_reg) { 11238 if (read_back == data_reg) {
12403 return (1); 11239 return (1);
12404 } 11240 }
12405 if (retry++ > ASC_EEP_MAX_RETRY) { 11241 if (retry++ > ASC_EEP_MAX_RETRY) {
12406 return (0); 11242 return (0);
12407 } 11243 }
12408 } 11244 }
12409} 11245}
12410 11246
12411STATIC void __init 11247static void __init AscWaitEEPRead(void)
12412AscWaitEEPRead(void)
12413{ 11248{
12414 DvcSleepMilliSecond(1); 11249 DvcSleepMilliSecond(1);
12415 return; 11250 return;
12416} 11251}
12417 11252
12418STATIC void __init 11253static void __init AscWaitEEPWrite(void)
12419AscWaitEEPWrite(void)
12420{ 11254{
12421 DvcSleepMilliSecond(20); 11255 DvcSleepMilliSecond(20);
12422 return; 11256 return;
12423} 11257}
12424 11258
12425STATIC ushort __init 11259static ushort __init AscReadEEPWord(PortAddr iop_base, uchar addr)
12426AscReadEEPWord(
12427 PortAddr iop_base,
12428 uchar addr)
12429{ 11260{
12430 ushort read_wval; 11261 ushort read_wval;
12431 uchar cmd_reg; 11262 uchar cmd_reg;
12432 11263
12433 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE); 11264 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
12434 AscWaitEEPRead(); 11265 AscWaitEEPRead();
12435 cmd_reg = addr | ASC_EEP_CMD_READ; 11266 cmd_reg = addr | ASC_EEP_CMD_READ;
12436 AscWriteEEPCmdReg(iop_base, cmd_reg); 11267 AscWriteEEPCmdReg(iop_base, cmd_reg);
12437 AscWaitEEPRead(); 11268 AscWaitEEPRead();
12438 read_wval = AscGetChipEEPData(iop_base); 11269 read_wval = AscGetChipEEPData(iop_base);
12439 AscWaitEEPRead(); 11270 AscWaitEEPRead();
12440 return (read_wval); 11271 return (read_wval);
12441} 11272}
12442 11273
12443STATIC ushort __init 11274static ushort __init
12444AscWriteEEPWord( 11275AscWriteEEPWord(PortAddr iop_base, uchar addr, ushort word_val)
12445 PortAddr iop_base,
12446 uchar addr,
12447 ushort word_val)
12448{ 11276{
12449 ushort read_wval; 11277 ushort read_wval;
12450 11278
12451 read_wval = AscReadEEPWord(iop_base, addr); 11279 read_wval = AscReadEEPWord(iop_base, addr);
12452 if (read_wval != word_val) { 11280 if (read_wval != word_val) {
12453 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE); 11281 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_ABLE);
12454 AscWaitEEPRead(); 11282 AscWaitEEPRead();
12455 AscWriteEEPDataReg(iop_base, word_val); 11283 AscWriteEEPDataReg(iop_base, word_val);
12456 AscWaitEEPRead(); 11284 AscWaitEEPRead();
12457 AscWriteEEPCmdReg(iop_base, 11285 AscWriteEEPCmdReg(iop_base,
12458 (uchar) ((uchar) ASC_EEP_CMD_WRITE | addr)); 11286 (uchar)((uchar)ASC_EEP_CMD_WRITE | addr));
12459 AscWaitEEPWrite(); 11287 AscWaitEEPWrite();
12460 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE); 11288 AscWriteEEPCmdReg(iop_base, ASC_EEP_CMD_WRITE_DISABLE);
12461 AscWaitEEPRead(); 11289 AscWaitEEPRead();
12462 return (AscReadEEPWord(iop_base, addr)); 11290 return (AscReadEEPWord(iop_base, addr));
12463 } 11291 }
12464 return (read_wval); 11292 return (read_wval);
12465} 11293}
12466 11294
12467STATIC ushort __init 11295static ushort __init
12468AscGetEEPConfig( 11296AscGetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
12469 PortAddr iop_base,
12470 ASCEEP_CONFIG * cfg_buf, ushort bus_type)
12471{ 11297{
12472 ushort wval; 11298 ushort wval;
12473 ushort sum; 11299 ushort sum;
12474 ushort *wbuf; 11300 ushort *wbuf;
12475 int cfg_beg; 11301 int cfg_beg;
12476 int cfg_end; 11302 int cfg_end;
12477 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2; 11303 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
12478 int s_addr; 11304 int s_addr;
12479 11305
12480 wbuf = (ushort *) cfg_buf; 11306 wbuf = (ushort *)cfg_buf;
12481 sum = 0; 11307 sum = 0;
12482 /* Read two config words; Byte-swapping done by AscReadEEPWord(). */ 11308 /* Read two config words; Byte-swapping done by AscReadEEPWord(). */
12483 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) { 11309 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
12484 *wbuf = AscReadEEPWord(iop_base, (uchar) s_addr); 11310 *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
12485 sum += *wbuf; 11311 sum += *wbuf;
12486 } 11312 }
12487 if (bus_type & ASC_IS_VL) { 11313 if (bus_type & ASC_IS_VL) {
12488 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL; 11314 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
12489 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL; 11315 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
12490 } else { 11316 } else {
12491 cfg_beg = ASC_EEP_DVC_CFG_BEG; 11317 cfg_beg = ASC_EEP_DVC_CFG_BEG;
12492 cfg_end = ASC_EEP_MAX_DVC_ADDR; 11318 cfg_end = ASC_EEP_MAX_DVC_ADDR;
12493 } 11319 }
12494 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) { 11320 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
12495 wval = AscReadEEPWord( iop_base, ( uchar )s_addr ) ; 11321 wval = AscReadEEPWord(iop_base, (uchar)s_addr);
12496 if (s_addr <= uchar_end_in_config) { 11322 if (s_addr <= uchar_end_in_config) {
12497 /* 11323 /*
12498 * Swap all char fields - must unswap bytes already swapped 11324 * Swap all char fields - must unswap bytes already swapped
12499 * by AscReadEEPWord(). 11325 * by AscReadEEPWord().
12500 */ 11326 */
12501 *wbuf = le16_to_cpu(wval); 11327 *wbuf = le16_to_cpu(wval);
12502 } else { 11328 } else {
12503 /* Don't swap word field at the end - cntl field. */ 11329 /* Don't swap word field at the end - cntl field. */
12504 *wbuf = wval; 11330 *wbuf = wval;
12505 } 11331 }
12506 sum += wval; /* Checksum treats all EEPROM data as words. */ 11332 sum += wval; /* Checksum treats all EEPROM data as words. */
12507 } 11333 }
12508 /* 11334 /*
12509 * Read the checksum word which will be compared against 'sum' 11335 * Read the checksum word which will be compared against 'sum'
12510 * by the caller. Word field already swapped. 11336 * by the caller. Word field already swapped.
12511 */ 11337 */
12512 *wbuf = AscReadEEPWord(iop_base, (uchar) s_addr); 11338 *wbuf = AscReadEEPWord(iop_base, (uchar)s_addr);
12513 return (sum); 11339 return (sum);
12514} 11340}
12515 11341
12516STATIC int __init 11342static int __init
12517AscSetEEPConfigOnce( 11343AscSetEEPConfigOnce(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
12518 PortAddr iop_base,
12519 ASCEEP_CONFIG * cfg_buf, ushort bus_type)
12520{ 11344{
12521 int n_error; 11345 int n_error;
12522 ushort *wbuf; 11346 ushort *wbuf;
12523 ushort word; 11347 ushort word;
12524 ushort sum; 11348 ushort sum;
12525 int s_addr; 11349 int s_addr;
12526 int cfg_beg; 11350 int cfg_beg;
12527 int cfg_end; 11351 int cfg_end;
12528 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2; 11352 int uchar_end_in_config = ASC_EEP_MAX_DVC_ADDR - 2;
12529 11353
12530 11354 wbuf = (ushort *)cfg_buf;
12531 wbuf = (ushort *) cfg_buf; 11355 n_error = 0;
12532 n_error = 0; 11356 sum = 0;
12533 sum = 0; 11357 /* Write two config words; AscWriteEEPWord() will swap bytes. */
12534 /* Write two config words; AscWriteEEPWord() will swap bytes. */ 11358 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
12535 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) { 11359 sum += *wbuf;
12536 sum += *wbuf; 11360 if (*wbuf != AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
12537 if (*wbuf != AscWriteEEPWord(iop_base, (uchar) s_addr, *wbuf)) { 11361 n_error++;
12538 n_error++; 11362 }
12539 } 11363 }
12540 } 11364 if (bus_type & ASC_IS_VL) {
12541 if (bus_type & ASC_IS_VL) { 11365 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
12542 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL; 11366 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
12543 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL; 11367 } else {
12544 } else { 11368 cfg_beg = ASC_EEP_DVC_CFG_BEG;
12545 cfg_beg = ASC_EEP_DVC_CFG_BEG; 11369 cfg_end = ASC_EEP_MAX_DVC_ADDR;
12546 cfg_end = ASC_EEP_MAX_DVC_ADDR; 11370 }
12547 } 11371 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
12548 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) { 11372 if (s_addr <= uchar_end_in_config) {
12549 if (s_addr <= uchar_end_in_config) { 11373 /*
12550 /* 11374 * This is a char field. Swap char fields before they are
12551 * This is a char field. Swap char fields before they are 11375 * swapped again by AscWriteEEPWord().
12552 * swapped again by AscWriteEEPWord(). 11376 */
12553 */ 11377 word = cpu_to_le16(*wbuf);
12554 word = cpu_to_le16(*wbuf); 11378 if (word !=
12555 if (word != AscWriteEEPWord( iop_base, (uchar) s_addr, word)) { 11379 AscWriteEEPWord(iop_base, (uchar)s_addr, word)) {
12556 n_error++; 11380 n_error++;
12557 } 11381 }
12558 } else { 11382 } else {
12559 /* Don't swap word field at the end - cntl field. */ 11383 /* Don't swap word field at the end - cntl field. */
12560 if (*wbuf != AscWriteEEPWord(iop_base, (uchar) s_addr, *wbuf)) { 11384 if (*wbuf !=
12561 n_error++; 11385 AscWriteEEPWord(iop_base, (uchar)s_addr, *wbuf)) {
12562 } 11386 n_error++;
12563 } 11387 }
12564 sum += *wbuf; /* Checksum calculated from word values. */ 11388 }
12565 } 11389 sum += *wbuf; /* Checksum calculated from word values. */
12566 /* Write checksum word. It will be swapped by AscWriteEEPWord(). */ 11390 }
12567 *wbuf = sum; 11391 /* Write checksum word. It will be swapped by AscWriteEEPWord(). */
12568 if (sum != AscWriteEEPWord(iop_base, (uchar) s_addr, sum)) { 11392 *wbuf = sum;
12569 n_error++; 11393 if (sum != AscWriteEEPWord(iop_base, (uchar)s_addr, sum)) {
12570 } 11394 n_error++;
11395 }
12571 11396
12572 /* Read EEPROM back again. */ 11397 /* Read EEPROM back again. */
12573 wbuf = (ushort *) cfg_buf; 11398 wbuf = (ushort *)cfg_buf;
12574 /* 11399 /*
12575 * Read two config words; Byte-swapping done by AscReadEEPWord(). 11400 * Read two config words; Byte-swapping done by AscReadEEPWord().
12576 */ 11401 */
12577 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) { 11402 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
12578 if (*wbuf != AscReadEEPWord(iop_base, (uchar) s_addr)) { 11403 if (*wbuf != AscReadEEPWord(iop_base, (uchar)s_addr)) {
12579 n_error++; 11404 n_error++;
12580 } 11405 }
12581 } 11406 }
12582 if (bus_type & ASC_IS_VL) { 11407 if (bus_type & ASC_IS_VL) {
12583 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL; 11408 cfg_beg = ASC_EEP_DVC_CFG_BEG_VL;
12584 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL; 11409 cfg_end = ASC_EEP_MAX_DVC_ADDR_VL;
12585 } else { 11410 } else {
12586 cfg_beg = ASC_EEP_DVC_CFG_BEG; 11411 cfg_beg = ASC_EEP_DVC_CFG_BEG;
12587 cfg_end = ASC_EEP_MAX_DVC_ADDR; 11412 cfg_end = ASC_EEP_MAX_DVC_ADDR;
12588 } 11413 }
12589 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) { 11414 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
12590 if (s_addr <= uchar_end_in_config) { 11415 if (s_addr <= uchar_end_in_config) {
12591 /* 11416 /*
12592 * Swap all char fields. Must unswap bytes already swapped 11417 * Swap all char fields. Must unswap bytes already swapped
12593 * by AscReadEEPWord(). 11418 * by AscReadEEPWord().
12594 */ 11419 */
12595 word = le16_to_cpu(AscReadEEPWord(iop_base, (uchar) s_addr)); 11420 word =
12596 } else { 11421 le16_to_cpu(AscReadEEPWord
12597 /* Don't swap word field at the end - cntl field. */ 11422 (iop_base, (uchar)s_addr));
12598 word = AscReadEEPWord(iop_base, (uchar) s_addr); 11423 } else {
12599 } 11424 /* Don't swap word field at the end - cntl field. */
12600 if (*wbuf != word) { 11425 word = AscReadEEPWord(iop_base, (uchar)s_addr);
12601 n_error++; 11426 }
12602 } 11427 if (*wbuf != word) {
12603 } 11428 n_error++;
12604 /* Read checksum; Byte swapping not needed. */ 11429 }
12605 if (AscReadEEPWord(iop_base, (uchar) s_addr) != sum) { 11430 }
12606 n_error++; 11431 /* Read checksum; Byte swapping not needed. */
12607 } 11432 if (AscReadEEPWord(iop_base, (uchar)s_addr) != sum) {
12608 return (n_error); 11433 n_error++;
11434 }
11435 return (n_error);
12609} 11436}
12610 11437
12611STATIC int __init 11438static int __init
12612AscSetEEPConfig( 11439AscSetEEPConfig(PortAddr iop_base, ASCEEP_CONFIG *cfg_buf, ushort bus_type)
12613 PortAddr iop_base,
12614 ASCEEP_CONFIG * cfg_buf, ushort bus_type
12615)
12616{ 11440{
12617 int retry; 11441 int retry;
12618 int n_error; 11442 int n_error;
12619 11443
12620 retry = 0; 11444 retry = 0;
12621 while (TRUE) { 11445 while (TRUE) {
12622 if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf, 11446 if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
12623 bus_type)) == 0) { 11447 bus_type)) == 0) {
12624 break; 11448 break;
12625 } 11449 }
12626 if (++retry > ASC_EEP_MAX_RETRY) { 11450 if (++retry > ASC_EEP_MAX_RETRY) {
12627 break; 11451 break;
12628 } 11452 }
12629 } 11453 }
12630 return (n_error); 11454 return (n_error);
12631} 11455}
12632 11456
12633STATIC void 11457static void
12634AscAsyncFix( 11458AscAsyncFix(ASC_DVC_VAR *asc_dvc, uchar tid_no, ASC_SCSI_INQUIRY *inq)
12635 ASC_DVC_VAR *asc_dvc,
12636 uchar tid_no,
12637 ASC_SCSI_INQUIRY *inq)
12638{ 11459{
12639 uchar dvc_type; 11460 uchar dvc_type;
12640 ASC_SCSI_BIT_ID_TYPE tid_bits; 11461 ASC_SCSI_BIT_ID_TYPE tid_bits;
12641 11462
12642 dvc_type = ASC_INQ_DVC_TYPE(inq); 11463 dvc_type = ASC_INQ_DVC_TYPE(inq);
12643 tid_bits = ASC_TIX_TO_TARGET_ID(tid_no); 11464 tid_bits = ASC_TIX_TO_TARGET_ID(tid_no);
12644 11465
12645 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN) 11466 if (asc_dvc->bug_fix_cntl & ASC_BUG_FIX_ASYN_USE_SYN) {
12646 { 11467 if (!(asc_dvc->init_sdtr & tid_bits)) {
12647 if (!(asc_dvc->init_sdtr & tid_bits)) 11468 if ((dvc_type == TYPE_ROM) &&
12648 { 11469 (AscCompareString((uchar *)inq->vendor_id,
12649 if ((dvc_type == TYPE_ROM) && 11470 (uchar *)"HP ", 3) == 0)) {
12650 (AscCompareString((uchar *) inq->vendor_id, 11471 asc_dvc->pci_fix_asyn_xfer_always |= tid_bits;
12651 (uchar *) "HP ", 3) == 0)) 11472 }
12652 { 11473 asc_dvc->pci_fix_asyn_xfer |= tid_bits;
12653 asc_dvc->pci_fix_asyn_xfer_always |= tid_bits; 11474 if ((dvc_type == TYPE_PROCESSOR) ||
12654 } 11475 (dvc_type == TYPE_SCANNER) ||
12655 asc_dvc->pci_fix_asyn_xfer |= tid_bits; 11476 (dvc_type == TYPE_ROM) || (dvc_type == TYPE_TAPE)) {
12656 if ((dvc_type == TYPE_PROCESSOR) || 11477 asc_dvc->pci_fix_asyn_xfer &= ~tid_bits;
12657 (dvc_type == TYPE_SCANNER) || 11478 }
12658 (dvc_type == TYPE_ROM) || 11479
12659 (dvc_type == TYPE_TAPE)) 11480 if (asc_dvc->pci_fix_asyn_xfer & tid_bits) {
12660 { 11481 AscSetRunChipSynRegAtID(asc_dvc->iop_base,
12661 asc_dvc->pci_fix_asyn_xfer &= ~tid_bits; 11482 tid_no,
12662 } 11483 ASYN_SDTR_DATA_FIX_PCI_REV_AB);
12663 11484 }
12664 if (asc_dvc->pci_fix_asyn_xfer & tid_bits) 11485 }
12665 { 11486 }
12666 AscSetRunChipSynRegAtID(asc_dvc->iop_base, tid_no, 11487 return;
12667 ASYN_SDTR_DATA_FIX_PCI_REV_AB);
12668 }
12669 }
12670 }
12671 return;
12672} 11488}
12673 11489
12674STATIC int 11490static int AscTagQueuingSafe(ASC_SCSI_INQUIRY *inq)
12675AscTagQueuingSafe(ASC_SCSI_INQUIRY *inq)
12676{ 11491{
12677 if ((inq->add_len >= 32) && 11492 if ((inq->add_len >= 32) &&
12678 (AscCompareString((uchar *) inq->vendor_id, 11493 (AscCompareString((uchar *)inq->vendor_id,
12679 (uchar *) "QUANTUM XP34301", 15) == 0) && 11494 (uchar *)"QUANTUM XP34301", 15) == 0) &&
12680 (AscCompareString((uchar *) inq->product_rev_level, 11495 (AscCompareString((uchar *)inq->product_rev_level,
12681 (uchar *) "1071", 4) == 0)) 11496 (uchar *)"1071", 4) == 0)) {
12682 { 11497 return 0;
12683 return 0; 11498 }
12684 } 11499 return 1;
12685 return 1;
12686} 11500}
12687 11501
12688STATIC void 11502static void
12689AscInquiryHandling(ASC_DVC_VAR *asc_dvc, 11503AscInquiryHandling(ASC_DVC_VAR *asc_dvc, uchar tid_no, ASC_SCSI_INQUIRY *inq)
12690 uchar tid_no, ASC_SCSI_INQUIRY *inq)
12691{ 11504{
12692 ASC_SCSI_BIT_ID_TYPE tid_bit = ASC_TIX_TO_TARGET_ID(tid_no); 11505 ASC_SCSI_BIT_ID_TYPE tid_bit = ASC_TIX_TO_TARGET_ID(tid_no);
12693 ASC_SCSI_BIT_ID_TYPE orig_init_sdtr, orig_use_tagged_qng; 11506 ASC_SCSI_BIT_ID_TYPE orig_init_sdtr, orig_use_tagged_qng;
12694 11507
12695 orig_init_sdtr = asc_dvc->init_sdtr; 11508 orig_init_sdtr = asc_dvc->init_sdtr;
12696 orig_use_tagged_qng = asc_dvc->use_tagged_qng; 11509 orig_use_tagged_qng = asc_dvc->use_tagged_qng;
12697 11510
12698 asc_dvc->init_sdtr &= ~tid_bit; 11511 asc_dvc->init_sdtr &= ~tid_bit;
12699 asc_dvc->cfg->can_tagged_qng &= ~tid_bit; 11512 asc_dvc->cfg->can_tagged_qng &= ~tid_bit;
12700 asc_dvc->use_tagged_qng &= ~tid_bit; 11513 asc_dvc->use_tagged_qng &= ~tid_bit;
12701 11514
12702 if (ASC_INQ_RESPONSE_FMT(inq) >= 2 || ASC_INQ_ANSI_VER(inq) >= 2) { 11515 if (ASC_INQ_RESPONSE_FMT(inq) >= 2 || ASC_INQ_ANSI_VER(inq) >= 2) {
12703 if ((asc_dvc->cfg->sdtr_enable & tid_bit) && ASC_INQ_SYNC(inq)) { 11516 if ((asc_dvc->cfg->sdtr_enable & tid_bit) && ASC_INQ_SYNC(inq)) {
12704 asc_dvc->init_sdtr |= tid_bit; 11517 asc_dvc->init_sdtr |= tid_bit;
12705 } 11518 }
12706 if ((asc_dvc->cfg->cmd_qng_enabled & tid_bit) && 11519 if ((asc_dvc->cfg->cmd_qng_enabled & tid_bit) &&
12707 ASC_INQ_CMD_QUEUE(inq)) { 11520 ASC_INQ_CMD_QUEUE(inq)) {
12708 if (AscTagQueuingSafe(inq)) { 11521 if (AscTagQueuingSafe(inq)) {
12709 asc_dvc->use_tagged_qng |= tid_bit; 11522 asc_dvc->use_tagged_qng |= tid_bit;
12710 asc_dvc->cfg->can_tagged_qng |= tid_bit; 11523 asc_dvc->cfg->can_tagged_qng |= tid_bit;
12711 } 11524 }
12712 } 11525 }
12713 } 11526 }
12714 if (orig_use_tagged_qng != asc_dvc->use_tagged_qng) { 11527 if (orig_use_tagged_qng != asc_dvc->use_tagged_qng) {
12715 AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B, 11528 AscWriteLramByte(asc_dvc->iop_base, ASCV_DISC_ENABLE_B,
12716 asc_dvc->cfg->disc_enable); 11529 asc_dvc->cfg->disc_enable);
12717 AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B, 11530 AscWriteLramByte(asc_dvc->iop_base, ASCV_USE_TAGGED_QNG_B,
12718 asc_dvc->use_tagged_qng); 11531 asc_dvc->use_tagged_qng);
12719 AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B, 11532 AscWriteLramByte(asc_dvc->iop_base, ASCV_CAN_TAGGED_QNG_B,
12720 asc_dvc->cfg->can_tagged_qng); 11533 asc_dvc->cfg->can_tagged_qng);
12721 11534
12722 asc_dvc->max_dvc_qng[tid_no] = 11535 asc_dvc->max_dvc_qng[tid_no] =
12723 asc_dvc->cfg->max_tag_qng[tid_no]; 11536 asc_dvc->cfg->max_tag_qng[tid_no];
12724 AscWriteLramByte(asc_dvc->iop_base, 11537 AscWriteLramByte(asc_dvc->iop_base,
12725 (ushort) (ASCV_MAX_DVC_QNG_BEG + tid_no), 11538 (ushort)(ASCV_MAX_DVC_QNG_BEG + tid_no),
12726 asc_dvc->max_dvc_qng[tid_no]); 11539 asc_dvc->max_dvc_qng[tid_no]);
12727 } 11540 }
12728 if (orig_init_sdtr != asc_dvc->init_sdtr) { 11541 if (orig_init_sdtr != asc_dvc->init_sdtr) {
12729 AscAsyncFix(asc_dvc, tid_no, inq); 11542 AscAsyncFix(asc_dvc, tid_no, inq);
12730 } 11543 }
12731 return; 11544 return;
12732} 11545}
12733 11546
12734STATIC int 11547static int AscCompareString(uchar *str1, uchar *str2, int len)
12735AscCompareString(
12736 uchar *str1,
12737 uchar *str2,
12738 int len
12739)
12740{ 11548{
12741 int i; 11549 int i;
12742 int diff; 11550 int diff;
12743 11551
12744 for (i = 0; i < len; i++) { 11552 for (i = 0; i < len; i++) {
12745 diff = (int) (str1[i] - str2[i]); 11553 diff = (int)(str1[i] - str2[i]);
12746 if (diff != 0) 11554 if (diff != 0)
12747 return (diff); 11555 return (diff);
12748 } 11556 }
12749 return (0); 11557 return (0);
12750} 11558}
12751 11559
12752STATIC uchar 11560static uchar AscReadLramByte(PortAddr iop_base, ushort addr)
12753AscReadLramByte(
12754 PortAddr iop_base,
12755 ushort addr
12756)
12757{ 11561{
12758 uchar byte_data; 11562 uchar byte_data;
12759 ushort word_data; 11563 ushort word_data;
12760 11564
12761 if (isodd_word(addr)) { 11565 if (isodd_word(addr)) {
12762 AscSetChipLramAddr(iop_base, addr - 1); 11566 AscSetChipLramAddr(iop_base, addr - 1);
12763 word_data = AscGetChipLramData(iop_base); 11567 word_data = AscGetChipLramData(iop_base);
12764 byte_data = (uchar) ((word_data >> 8) & 0xFF); 11568 byte_data = (uchar)((word_data >> 8) & 0xFF);
12765 } else { 11569 } else {
12766 AscSetChipLramAddr(iop_base, addr); 11570 AscSetChipLramAddr(iop_base, addr);
12767 word_data = AscGetChipLramData(iop_base); 11571 word_data = AscGetChipLramData(iop_base);
12768 byte_data = (uchar) (word_data & 0xFF); 11572 byte_data = (uchar)(word_data & 0xFF);
12769 } 11573 }
12770 return (byte_data); 11574 return (byte_data);
12771} 11575}
12772STATIC ushort 11576
12773AscReadLramWord( 11577static ushort AscReadLramWord(PortAddr iop_base, ushort addr)
12774 PortAddr iop_base,
12775 ushort addr
12776)
12777{ 11578{
12778 ushort word_data; 11579 ushort word_data;
12779 11580
12780 AscSetChipLramAddr(iop_base, addr); 11581 AscSetChipLramAddr(iop_base, addr);
12781 word_data = AscGetChipLramData(iop_base); 11582 word_data = AscGetChipLramData(iop_base);
12782 return (word_data); 11583 return (word_data);
12783} 11584}
12784 11585
12785#if CC_VERY_LONG_SG_LIST 11586#if CC_VERY_LONG_SG_LIST
12786STATIC ASC_DCNT 11587static ASC_DCNT AscReadLramDWord(PortAddr iop_base, ushort addr)
12787AscReadLramDWord(
12788 PortAddr iop_base,
12789 ushort addr
12790)
12791{ 11588{
12792 ushort val_low, val_high; 11589 ushort val_low, val_high;
12793 ASC_DCNT dword_data; 11590 ASC_DCNT dword_data;
12794 11591
12795 AscSetChipLramAddr(iop_base, addr); 11592 AscSetChipLramAddr(iop_base, addr);
12796 val_low = AscGetChipLramData(iop_base); 11593 val_low = AscGetChipLramData(iop_base);
12797 val_high = AscGetChipLramData(iop_base); 11594 val_high = AscGetChipLramData(iop_base);
12798 dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low; 11595 dword_data = ((ASC_DCNT) val_high << 16) | (ASC_DCNT) val_low;
12799 return (dword_data); 11596 return (dword_data);
12800} 11597}
12801#endif /* CC_VERY_LONG_SG_LIST */ 11598#endif /* CC_VERY_LONG_SG_LIST */
12802 11599
12803STATIC void 11600static void AscWriteLramWord(PortAddr iop_base, ushort addr, ushort word_val)
12804AscWriteLramWord(
12805 PortAddr iop_base,
12806 ushort addr,
12807 ushort word_val
12808)
12809{ 11601{
12810 AscSetChipLramAddr(iop_base, addr); 11602 AscSetChipLramAddr(iop_base, addr);
12811 AscSetChipLramData(iop_base, word_val); 11603 AscSetChipLramData(iop_base, word_val);
12812 return; 11604 return;
12813} 11605}
12814 11606
12815STATIC void 11607static void AscWriteLramByte(PortAddr iop_base, ushort addr, uchar byte_val)
12816AscWriteLramByte(
12817 PortAddr iop_base,
12818 ushort addr,
12819 uchar byte_val
12820)
12821{ 11608{
12822 ushort word_data; 11609 ushort word_data;
12823 11610
12824 if (isodd_word(addr)) { 11611 if (isodd_word(addr)) {
12825 addr--; 11612 addr--;
12826 word_data = AscReadLramWord(iop_base, addr); 11613 word_data = AscReadLramWord(iop_base, addr);
12827 word_data &= 0x00FF; 11614 word_data &= 0x00FF;
12828 word_data |= (((ushort) byte_val << 8) & 0xFF00); 11615 word_data |= (((ushort)byte_val << 8) & 0xFF00);
12829 } else { 11616 } else {
12830 word_data = AscReadLramWord(iop_base, addr); 11617 word_data = AscReadLramWord(iop_base, addr);
12831 word_data &= 0xFF00; 11618 word_data &= 0xFF00;
12832 word_data |= ((ushort) byte_val & 0x00FF); 11619 word_data |= ((ushort)byte_val & 0x00FF);
12833 } 11620 }
12834 AscWriteLramWord(iop_base, addr, word_data); 11621 AscWriteLramWord(iop_base, addr, word_data);
12835 return; 11622 return;
12836} 11623}
12837 11624
12838/* 11625/*
@@ -12841,30 +11628,26 @@ AscWriteLramByte(
12841 * The source data is assumed to be in little-endian order in memory 11628 * The source data is assumed to be in little-endian order in memory
12842 * and is maintained in little-endian order when written to LRAM. 11629 * and is maintained in little-endian order when written to LRAM.
12843 */ 11630 */
12844STATIC void 11631static void
12845AscMemWordCopyPtrToLram( 11632AscMemWordCopyPtrToLram(PortAddr iop_base,
12846 PortAddr iop_base, 11633 ushort s_addr, uchar *s_buffer, int words)
12847 ushort s_addr,
12848 uchar *s_buffer,
12849 int words
12850)
12851{ 11634{
12852 int i; 11635 int i;
12853 11636
12854 AscSetChipLramAddr(iop_base, s_addr); 11637 AscSetChipLramAddr(iop_base, s_addr);
12855 for (i = 0; i < 2 * words; i += 2) { 11638 for (i = 0; i < 2 * words; i += 2) {
12856 /* 11639 /*
12857 * On a little-endian system the second argument below 11640 * On a little-endian system the second argument below
12858 * produces a little-endian ushort which is written to 11641 * produces a little-endian ushort which is written to
12859 * LRAM in little-endian order. On a big-endian system 11642 * LRAM in little-endian order. On a big-endian system
12860 * the second argument produces a big-endian ushort which 11643 * the second argument produces a big-endian ushort which
12861 * is "transparently" byte-swapped by outpw() and written 11644 * is "transparently" byte-swapped by outpw() and written
12862 * in little-endian order to LRAM. 11645 * in little-endian order to LRAM.
12863 */ 11646 */
12864 outpw(iop_base + IOP_RAM_DATA, 11647 outpw(iop_base + IOP_RAM_DATA,
12865 ((ushort) s_buffer[i + 1] << 8) | s_buffer[i]); 11648 ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
12866 } 11649 }
12867 return; 11650 return;
12868} 11651}
12869 11652
12870/* 11653/*
@@ -12873,24 +11656,18 @@ AscMemWordCopyPtrToLram(
12873 * The source data is assumed to be in little-endian order in memory 11656 * The source data is assumed to be in little-endian order in memory
12874 * and is maintained in little-endian order when writen to LRAM. 11657 * and is maintained in little-endian order when writen to LRAM.
12875 */ 11658 */
12876STATIC void 11659static void
12877AscMemDWordCopyPtrToLram( 11660AscMemDWordCopyPtrToLram(PortAddr iop_base,
12878 PortAddr iop_base, 11661 ushort s_addr, uchar *s_buffer, int dwords)
12879 ushort s_addr,
12880 uchar *s_buffer,
12881 int dwords
12882)
12883{ 11662{
12884 int i; 11663 int i;
12885 11664
12886 AscSetChipLramAddr(iop_base, s_addr); 11665 AscSetChipLramAddr(iop_base, s_addr);
12887 for (i = 0; i < 4 * dwords; i += 4) { 11666 for (i = 0; i < 4 * dwords; i += 4) {
12888 outpw(iop_base + IOP_RAM_DATA, 11667 outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */
12889 ((ushort) s_buffer[i + 1] << 8) | s_buffer[i]); /* LSW */ 11668 outpw(iop_base + IOP_RAM_DATA, ((ushort)s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */
12890 outpw(iop_base + IOP_RAM_DATA, 11669 }
12891 ((ushort) s_buffer[i + 3] << 8) | s_buffer[i + 2]); /* MSW */ 11670 return;
12892 }
12893 return;
12894} 11671}
12895 11672
12896/* 11673/*
@@ -12899,61 +11676,46 @@ AscMemDWordCopyPtrToLram(
12899 * The source data is assumed to be in little-endian order in LRAM 11676 * The source data is assumed to be in little-endian order in LRAM
12900 * and is maintained in little-endian order when written to memory. 11677 * and is maintained in little-endian order when written to memory.
12901 */ 11678 */
12902STATIC void 11679static void
12903AscMemWordCopyPtrFromLram( 11680AscMemWordCopyPtrFromLram(PortAddr iop_base,
12904 PortAddr iop_base, 11681 ushort s_addr, uchar *d_buffer, int words)
12905 ushort s_addr,
12906 uchar *d_buffer,
12907 int words
12908)
12909{ 11682{
12910 int i; 11683 int i;
12911 ushort word; 11684 ushort word;
12912 11685
12913 AscSetChipLramAddr(iop_base, s_addr); 11686 AscSetChipLramAddr(iop_base, s_addr);
12914 for (i = 0; i < 2 * words; i += 2) { 11687 for (i = 0; i < 2 * words; i += 2) {
12915 word = inpw(iop_base + IOP_RAM_DATA); 11688 word = inpw(iop_base + IOP_RAM_DATA);
12916 d_buffer[i] = word & 0xff; 11689 d_buffer[i] = word & 0xff;
12917 d_buffer[i + 1] = (word >> 8) & 0xff; 11690 d_buffer[i + 1] = (word >> 8) & 0xff;
12918 } 11691 }
12919 return; 11692 return;
12920} 11693}
12921 11694
12922STATIC ASC_DCNT 11695static ASC_DCNT AscMemSumLramWord(PortAddr iop_base, ushort s_addr, int words)
12923AscMemSumLramWord(
12924 PortAddr iop_base,
12925 ushort s_addr,
12926 int words
12927)
12928{ 11696{
12929 ASC_DCNT sum; 11697 ASC_DCNT sum;
12930 int i; 11698 int i;
12931 11699
12932 sum = 0L; 11700 sum = 0L;
12933 for (i = 0; i < words; i++, s_addr += 2) { 11701 for (i = 0; i < words; i++, s_addr += 2) {
12934 sum += AscReadLramWord(iop_base, s_addr); 11702 sum += AscReadLramWord(iop_base, s_addr);
12935 } 11703 }
12936 return (sum); 11704 return (sum);
12937} 11705}
12938 11706
12939STATIC void 11707static void
12940AscMemWordSetLram( 11708AscMemWordSetLram(PortAddr iop_base, ushort s_addr, ushort set_wval, int words)
12941 PortAddr iop_base,
12942 ushort s_addr,
12943 ushort set_wval,
12944 int words
12945)
12946{ 11709{
12947 int i; 11710 int i;
12948 11711
12949 AscSetChipLramAddr(iop_base, s_addr); 11712 AscSetChipLramAddr(iop_base, s_addr);
12950 for (i = 0; i < words; i++) { 11713 for (i = 0; i < words; i++) {
12951 AscSetChipLramData(iop_base, set_wval); 11714 AscSetChipLramData(iop_base, set_wval);
12952 } 11715 }
12953 return; 11716 return;
12954} 11717}
12955 11718
12956
12957/* 11719/*
12958 * --- Adv Library Functions 11720 * --- Adv Library Functions
12959 */ 11721 */
@@ -12961,1076 +11723,2112 @@ AscMemWordSetLram(
12961/* a_mcode.h */ 11723/* a_mcode.h */
12962 11724
12963/* Microcode buffer is kept after initialization for error recovery. */ 11725/* Microcode buffer is kept after initialization for error recovery. */
12964STATIC unsigned char _adv_asc3550_buf[] = { 11726static unsigned char _adv_asc3550_buf[] = {
12965 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc, 0x01, 0x00, 0x48, 0xe4, 11727 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0x16, 0x18, 0xe4, 0x00, 0xfc,
12966 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0x00, 0xfa, 0xff, 0xff, 0x28, 0x0e, 0x9e, 0xe7, 11728 0x01, 0x00, 0x48, 0xe4,
12967 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 0x01, 0xf6, 11729 0xbe, 0x18, 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0x00, 0xfa, 0xff, 0xff,
12968 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00, 0x00, 0xec, 0x85, 0xf0, 11730 0x28, 0x0e, 0x9e, 0xe7,
12969 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54, 0x00, 0xe6, 0x1e, 0xf0, 0x86, 0xf0, 0xb4, 0x00, 11731 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x00, 0xf6, 0x01, 0xe6, 0x09, 0xe7,
12970 0x98, 0x57, 0xd0, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00, 0xaa, 0x18, 0x02, 0x80, 11732 0x55, 0xf0, 0x01, 0xf6,
12971 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40, 0x00, 0x57, 0x01, 0xea, 11733 0x01, 0xfa, 0x08, 0x00, 0x03, 0x00, 0x04, 0x00, 0x18, 0xf4, 0x10, 0x00,
12972 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 11734 0x00, 0xec, 0x85, 0xf0,
12973 0xc0, 0x00, 0x01, 0x01, 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12, 0x02, 0x4a, 0xb9, 0x54, 11735 0xbc, 0x00, 0xd5, 0xf0, 0x8e, 0x0c, 0x38, 0x54, 0x00, 0xe6, 0x1e, 0xf0,
12974 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00, 0x3e, 0x00, 0x80, 0x00, 11736 0x86, 0xf0, 0xb4, 0x00,
12975 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 11737 0x98, 0x57, 0xd0, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x0c, 0x00, 0xbb, 0x00,
12976 0x78, 0x01, 0x62, 0x0a, 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13, 0x4c, 0x1c, 0xbb, 0x55, 11738 0xaa, 0x18, 0x02, 0x80,
12977 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0, 0x03, 0xf7, 0x06, 0xf7, 11739 0x32, 0xf0, 0x01, 0xfc, 0x88, 0x0c, 0xc6, 0x12, 0x02, 0x13, 0x18, 0x40,
12978 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00, 0x00, 0x01, 0xb0, 0x08, 0x30, 0x13, 0x64, 0x15, 11740 0x00, 0x57, 0x01, 0xea,
12979 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c, 0x04, 0xea, 0x5d, 0xf0, 11741 0x3c, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x3e, 0x57, 0x00, 0x80,
12980 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01, 11742 0x03, 0xe6, 0xb6, 0x00,
12981 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10, 0x0a, 0x12, 0x04, 0x13, 0x40, 0x13, 0x30, 0x1c, 11743 0xc0, 0x00, 0x01, 0x01, 0x3e, 0x01, 0xda, 0x0f, 0x22, 0x10, 0x08, 0x12,
12982 0x00, 0x4e, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xa7, 0xf0, 11744 0x02, 0x4a, 0xb9, 0x54,
12983 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00, 11745 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x20, 0x00, 0x32, 0x00,
12984 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xde, 0x03, 0x56, 0x0a, 0x14, 0x0e, 0x02, 0x10, 11746 0x3e, 0x00, 0x80, 0x00,
12985 0x04, 0x10, 0x0a, 0x10, 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13, 0x10, 0x15, 0x14, 0x15, 11747 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01,
12986 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 11748 0x74, 0x01, 0x76, 0x01,
12987 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 11749 0x78, 0x01, 0x62, 0x0a, 0x92, 0x0c, 0x2c, 0x10, 0x2e, 0x10, 0x06, 0x13,
12988 0x0b, 0xf0, 0x0c, 0xf0, 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 11750 0x4c, 0x1c, 0xbb, 0x55,
12989 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00, 0x9e, 0x00, 0xa8, 0x00, 11751 0x3c, 0x56, 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0xb1, 0xf0,
12990 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7a, 0x01, 0xc0, 0x01, 11752 0x03, 0xf7, 0x06, 0xf7,
12991 0xc2, 0x01, 0x7c, 0x02, 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08, 0x69, 0x08, 0xba, 0x08, 11753 0x03, 0xfc, 0x0f, 0x00, 0x40, 0x00, 0xbe, 0x00, 0x00, 0x01, 0xb0, 0x08,
12992 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 0x06, 0x12, 11754 0x30, 0x13, 0x64, 0x15,
12993 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13, 0x42, 0x14, 0xd6, 0x14, 0x8a, 0x15, 0xc6, 0x17, 11755 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44, 0x02, 0x48, 0x00, 0x4c,
12994 0xd2, 0x17, 0x6b, 0x18, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0x48, 0x47, 11756 0x04, 0xea, 0x5d, 0xf0,
12995 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55, 0x14, 0x56, 0x77, 0x57, 11757 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x34, 0x00, 0x36, 0x00, 0x98, 0x00,
12996 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90, 0x03, 0xa1, 0xfe, 0x9c, 0xf0, 0x29, 0x02, 0xfe, 11758 0xcc, 0x00, 0x20, 0x01,
12997 0xb8, 0x0c, 0xff, 0x10, 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf, 0xfe, 0x80, 0x01, 0xff, 11759 0x4e, 0x01, 0x4e, 0x0b, 0x1e, 0x0e, 0x0c, 0x10, 0x0a, 0x12, 0x04, 0x13,
12998 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24, 11760 0x40, 0x13, 0x30, 0x1c,
12999 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00, 0x00, 0x10, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 11761 0x00, 0x4e, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
13000 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x0f, 11762 0x59, 0xf0, 0xa7, 0xf0,
13001 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xcf, 11763 0xb8, 0xf0, 0x0e, 0xf7, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 0x9b, 0x00,
13002 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe, 0x04, 0xf7, 0xcf, 0x67, 0x0b, 0x3c, 0x2a, 0xfe, 11764 0xa4, 0x00, 0xb5, 0x00,
13003 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 11765 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xde, 0x03, 0x56, 0x0a,
13004 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b, 0x02, 0xfe, 0xd4, 0x0c, 11766 0x14, 0x0e, 0x02, 0x10,
13005 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x05, 0xfe, 0xa6, 11767 0x04, 0x10, 0x0a, 0x10, 0x36, 0x10, 0x0a, 0x13, 0x12, 0x13, 0x52, 0x13,
13006 0x00, 0xfe, 0xd3, 0x12, 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48, 0xf0, 0xfe, 0x86, 0x02, 11768 0x10, 0x15, 0x14, 0x15,
13007 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02, 0xfe, 0x46, 0xf0, 0xfe, 11769 0xac, 0x16, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 0x38, 0x44,
13008 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x44, 0x02, 0xfe, 0x44, 11770 0x91, 0x44, 0x0a, 0x45,
13009 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b, 0xa0, 0x17, 0x06, 0x18, 11771 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x83, 0x55, 0xb0, 0x57, 0x01, 0x58,
13010 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 11772 0x83, 0x59, 0x05, 0xe6,
13011 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xc7, 0x0a, 0x6b, 0x01, 0x9e, 11773 0x0b, 0xf0, 0x0c, 0xf0, 0x5c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 0x05, 0xf8,
13012 0x02, 0x29, 0x14, 0x4d, 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xbd, 11774 0x02, 0xfa, 0x03, 0xfa,
13013 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x17, 0x06, 11775 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0x0a, 0x00, 0x0d, 0x00, 0x1c, 0x00,
13014 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0x21, 0xfe, 0x94, 0x02, 0xfe, 11776 0x9e, 0x00, 0xa8, 0x00,
13015 0x5a, 0x1c, 0xea, 0xfe, 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97, 0x01, 0xfe, 0x54, 0x0f, 11777 0xaa, 0x00, 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01,
13016 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe, 0x69, 0x10, 0x17, 0x06, 11778 0x7a, 0x01, 0xc0, 0x01,
13017 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d, 0x12, 0x20, 0xfe, 0x05, 0xf6, 0xc7, 0x01, 0xfe, 11779 0xc2, 0x01, 0x7c, 0x02, 0x5a, 0x03, 0xea, 0x04, 0xe8, 0x07, 0x68, 0x08,
13018 0x52, 0x16, 0x09, 0x4a, 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6, 0x02, 0x29, 0x0a, 0x40, 11780 0x69, 0x08, 0xba, 0x08,
13019 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0x99, 0x01, 11781 0xe9, 0x09, 0x06, 0x0b, 0x3a, 0x0e, 0x00, 0x10, 0x1a, 0x10, 0xed, 0x10,
13020 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03, 0x01, 0xe6, 0x02, 0x29, 0x2a, 0x46, 0xfe, 0x02, 11782 0xf1, 0x10, 0x06, 0x12,
13021 0xe8, 0x27, 0xf8, 0xfe, 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc, 0x01, 0xfe, 0x07, 0x4b, 11783 0x0c, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x82, 0x13, 0x42, 0x14, 0xd6, 0x14,
13022 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0, 0xfe, 0x56, 0x03, 0xfe, 11784 0x8a, 0x15, 0xc6, 0x17,
13023 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0, 0x9c, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 11785 0xd2, 0x17, 0x6b, 0x18, 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40,
13024 0x64, 0x03, 0xeb, 0x0f, 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48, 0x1c, 0xeb, 0x09, 0x04, 11786 0x0e, 0x47, 0x48, 0x47,
13025 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40, 0x01, 0x0e, 0xac, 0x75, 11787 0x41, 0x48, 0x89, 0x48, 0x80, 0x4c, 0x00, 0x54, 0x44, 0x55, 0xe5, 0x55,
13026 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2, 0xfe, 0x01, 0xf0, 0xd2, 0xfe, 0x82, 0xf0, 0xfe, 11788 0x14, 0x56, 0x77, 0x57,
13027 0x92, 0x03, 0xec, 0x11, 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25, 0x32, 0x1f, 0xfe, 0xb4, 11789 0xbf, 0x57, 0x40, 0x5c, 0x06, 0x80, 0x08, 0x90, 0x03, 0xa1, 0xfe, 0x9c,
13028 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe, 0x0a, 0xf0, 0xfe, 0x7a, 11790 0xf0, 0x29, 0x02, 0xfe,
13029 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe, 0xf6, 0x04, 0x14, 0x2c, 0x01, 0x33, 0x8f, 0xfe, 11791 0xb8, 0x0c, 0xff, 0x10, 0x00, 0x00, 0xd0, 0xfe, 0xcc, 0x18, 0x00, 0xcf,
13030 0x66, 0x02, 0x02, 0xd1, 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8, 0xf7, 0xfe, 0x48, 0x1c, 11792 0xfe, 0x80, 0x01, 0xff,
13031 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3, 0x0a, 0xca, 0x01, 0x0e, 11793 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
13032 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28, 0xfe, 0x10, 0x12, 0x14, 0x2c, 0x01, 0x33, 0x8f, 11794 0x00, 0xfe, 0x57, 0x24,
13033 0xfe, 0x66, 0x02, 0x02, 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65, 0xfe, 0x3c, 0x04, 0x1f, 11795 0x00, 0xfe, 0x48, 0x00, 0x4f, 0xff, 0x04, 0x00, 0x00, 0x10, 0xff, 0x09,
13034 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2b, 0xff, 0x02, 11796 0x00, 0x00, 0xff, 0x08,
13035 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04, 0x2b, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd5, 11797 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10,
13036 0xfe, 0x4c, 0x44, 0xfe, 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64, 11798 0xff, 0xff, 0xff, 0x0f,
13037 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d, 0xfe, 0x2a, 0x13, 0x2f, 11799 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
13038 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64, 0xd3, 0xfa, 0xef, 0x86, 11800 0xfe, 0x04, 0xf7, 0xcf,
13039 0x09, 0x04, 0x1d, 0xfe, 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04, 0x1d, 0xfe, 0x1c, 0x12, 11801 0x2a, 0x67, 0x0b, 0x01, 0xfe, 0xce, 0x0e, 0xfe, 0x04, 0xf7, 0xcf, 0x67,
13040 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 11802 0x0b, 0x3c, 0x2a, 0xfe,
13041 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90, 0xf9, 0x03, 0x14, 0x92, 0x01, 0x33, 0x02, 0x29, 11803 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x91, 0xf0,
13042 0xfe, 0x42, 0x5b, 0x67, 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87, 0x80, 0xfe, 0x31, 0xe4, 11804 0xfe, 0xf0, 0x01, 0xfe,
13043 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a, 0xfe, 0x70, 0x12, 0x49, 11805 0x90, 0xf0, 0xfe, 0xf0, 0x01, 0xfe, 0x8f, 0xf0, 0x9c, 0x05, 0x51, 0x3b,
13044 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2, 0x00, 0x28, 0x16, 0xfe, 0x80, 0x05, 0xfe, 0x31, 11806 0x02, 0xfe, 0xd4, 0x0c,
13045 0xe4, 0x6a, 0x49, 0x04, 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 0x42, 0x12, 11807 0x01, 0xfe, 0x44, 0x0d, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28,
13046 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05, 0x11, 0xfe, 0xe3, 0x00, 11808 0x1c, 0x05, 0xfe, 0xa6,
13047 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0x64, 0x05, 0x83, 0x24, 11809 0x00, 0xfe, 0xd3, 0x12, 0x47, 0x18, 0xfe, 0xa6, 0x00, 0xb5, 0xfe, 0x48,
13048 0xfe, 0x21, 0x00, 0xa1, 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe, 0x09, 0x48, 0x01, 0x08, 11810 0xf0, 0xfe, 0x86, 0x02,
13049 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01, 0x86, 0x24, 0x06, 0x12, 11811 0xfe, 0x49, 0xf0, 0xfe, 0xa0, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xbe, 0x02,
13050 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d, 0xfe, 0x22, 0x12, 0x47, 0x01, 0xa7, 0x14, 0x92, 11812 0xfe, 0x46, 0xf0, 0xfe,
13051 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c, 0x02, 0x22, 0x05, 0xfe, 11813 0x50, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x56, 0x02, 0xfe, 0x43, 0xf0, 0xfe,
13052 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13, 0x47, 0x01, 0xa7, 0x26, 11814 0x44, 0x02, 0xfe, 0x44,
13053 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19, 0xfe, 0x02, 0x12, 0x5f, 0x01, 0xfe, 0xaa, 0x14, 11815 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x4c, 0x02, 0x17, 0x0b,
13054 0x1f, 0xfe, 0xfe, 0x05, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x50, 0xb4, 0x0c, 11816 0xa0, 0x17, 0x06, 0x18,
13055 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x14, 11817 0x96, 0x02, 0x29, 0xfe, 0x00, 0x1c, 0xde, 0xfe, 0x02, 0x1c, 0xdd, 0xfe,
13056 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48, 0xb7, 0x19, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 11818 0x1e, 0x1c, 0xfe, 0xe9,
13057 0x48, 0x8b, 0x1c, 0x3d, 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe, 0x72, 0x06, 0x49, 0x04, 11819 0x10, 0x01, 0xfe, 0x20, 0x17, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xc7,
13058 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68, 0x06, 0x11, 0x9a, 0x01, 11820 0x0a, 0x6b, 0x01, 0x9e,
13059 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4, 0x0c, 0x3f, 0x17, 0x06, 0x01, 0xa7, 0xec, 0x72, 11821 0x02, 0x29, 0x14, 0x4d, 0x37, 0x97, 0x01, 0xfe, 0x64, 0x0f, 0x0a, 0x6b,
13060 0x70, 0x01, 0x6e, 0x87, 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 11822 0x01, 0x82, 0xfe, 0xbd,
13061 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07, 0x8d, 0x81, 0x02, 0x22, 11823 0x10, 0x0a, 0x6b, 0x01, 0x82, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
13062 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 11824 0x58, 0x1c, 0x17, 0x06,
13063 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15, 0x00, 0x02, 0xfe, 0x32, 11825 0x18, 0x96, 0x2a, 0x25, 0x29, 0xfe, 0x3d, 0xf0, 0xfe, 0x02, 0x02, 0x21,
13064 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15, 0xfe, 0x1b, 0x00, 0x01, 11826 0xfe, 0x94, 0x02, 0xfe,
13065 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x06, 0x01, 11827 0x5a, 0x1c, 0xea, 0xfe, 0x14, 0x1c, 0x14, 0xfe, 0x30, 0x00, 0x37, 0x97,
13066 0x08, 0x15, 0x00, 0x02, 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe, 0x9a, 0x81, 0x4b, 0x1d, 11828 0x01, 0xfe, 0x54, 0x0f,
13067 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 11829 0x17, 0x06, 0x18, 0x96, 0x02, 0xd0, 0x1e, 0x20, 0x07, 0x10, 0x34, 0xfe,
13068 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0, 0xfe, 0x32, 0x07, 0x8d, 11830 0x69, 0x10, 0x17, 0x06,
13069 0x81, 0x8c, 0xfe, 0x5c, 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a, 0x06, 0x15, 0x19, 0x02, 11831 0x18, 0x96, 0xfe, 0x04, 0xec, 0x20, 0x46, 0x3d, 0x12, 0x20, 0xfe, 0x05,
13070 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x77, 0xfe, 0xca, 11832 0xf6, 0xc7, 0x01, 0xfe,
13071 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a, 0x35, 0x1e, 0x20, 0x07, 0x10, 0xfe, 0x0e, 0x12, 11833 0x52, 0x16, 0x09, 0x4a, 0x4c, 0x35, 0x11, 0x2d, 0x3c, 0x8a, 0x01, 0xe6,
13072 0x74, 0xfe, 0x80, 0x80, 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe, 0x83, 0xe7, 0xc4, 0xa1, 11834 0x02, 0x29, 0x0a, 0x40,
13073 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f, 0x40, 0x12, 0x58, 0x01, 11835 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x01, 0x6f, 0xfe, 0x18, 0x10, 0xfe, 0x41,
13074 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0x83, 0xfb, 0xfe, 11836 0x58, 0x0a, 0x99, 0x01,
13075 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 11837 0x0e, 0xfe, 0xc8, 0x54, 0x64, 0xfe, 0x0c, 0x03, 0x01, 0xe6, 0x02, 0x29,
13076 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a, 0xfe, 0x2a, 0x12, 0xfe, 11838 0x2a, 0x46, 0xfe, 0x02,
13077 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x04, 0x4f, 0x85, 0x01, 0xa8, 0xfe, 11839 0xe8, 0x27, 0xf8, 0xfe, 0x9e, 0x43, 0xf7, 0xfe, 0x27, 0xf0, 0xfe, 0xdc,
13078 0x1f, 0x80, 0x12, 0x58, 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56, 0x18, 0x57, 0xfb, 0xfe, 11840 0x01, 0xfe, 0x07, 0x4b,
13079 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x39, 0x18, 0x3a, 11841 0xfe, 0x20, 0xf0, 0x9c, 0xfe, 0x40, 0x1c, 0x25, 0xd2, 0xfe, 0x26, 0xf0,
13080 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35, 0x2a, 0x13, 0xfe, 0x4e, 0x11, 0x65, 0xfe, 0x48, 11842 0xfe, 0x56, 0x03, 0xfe,
13081 0x08, 0xfe, 0x9e, 0xf0, 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73, 0xdd, 0xb8, 0xfe, 0x80, 11843 0xa0, 0xf0, 0xfe, 0x44, 0x03, 0xfe, 0x11, 0xf0, 0x9c, 0xfe, 0xef, 0x10,
13082 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x7a, 0x08, 0x8d, 11844 0xfe, 0x9f, 0xf0, 0xfe,
13083 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10, 0x15, 0x19, 0xfe, 0xc9, 0x10, 0x61, 0x04, 0x06, 11845 0x64, 0x03, 0xeb, 0x0f, 0xfe, 0x11, 0x00, 0x02, 0x5a, 0x2a, 0xfe, 0x48,
13084 0xfe, 0x10, 0x12, 0x61, 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68, 0x12, 0xfe, 0x2e, 0x1c, 11846 0x1c, 0xeb, 0x09, 0x04,
13085 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe, 0x52, 0x12, 0xfe, 0x2c, 11847 0x1d, 0xfe, 0x18, 0x13, 0x23, 0x1e, 0x98, 0xac, 0x12, 0x98, 0x0a, 0x40,
13086 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0xbe, 0x08, 0xfe, 0x8a, 0x10, 11848 0x01, 0x0e, 0xac, 0x75,
13087 0xaa, 0xfe, 0xf3, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe, 0x24, 0x0a, 0xab, 0xfe, 11849 0x01, 0xfe, 0xbc, 0x15, 0x11, 0xca, 0x25, 0xd2, 0xfe, 0x01, 0xf0, 0xd2,
13088 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xb5, 0xfe, 11850 0xfe, 0x82, 0xf0, 0xfe,
13089 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x16, 0x9d, 0x05, 0xcb, 0x1c, 0x06, 0x16, 0x9d, 11851 0x92, 0x03, 0xec, 0x11, 0xfe, 0xe4, 0x00, 0x65, 0xfe, 0xa4, 0x03, 0x25,
13090 0xb8, 0x6d, 0xb9, 0x6d, 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b, 0x14, 0x92, 0x01, 0x33, 11852 0x32, 0x1f, 0xfe, 0xb4,
13091 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a, 0xfe, 0x74, 0x18, 0x1c, 11853 0x03, 0x01, 0x43, 0xfe, 0x06, 0xf0, 0xfe, 0xc4, 0x03, 0x8d, 0x81, 0xfe,
13092 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01, 0xfe, 0x44, 0x0d, 0x3b, 0x01, 0xe6, 0x1e, 0x27, 11854 0x0a, 0xf0, 0xfe, 0x7a,
13093 0x74, 0x67, 0x1a, 0x02, 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a, 0x09, 0x04, 0x6a, 0xfe, 11855 0x06, 0x02, 0x22, 0x05, 0x6b, 0x28, 0x16, 0xfe, 0xf6, 0x04, 0x14, 0x2c,
13094 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc, 0xfe, 0x83, 0x80, 0xfe, 11856 0x01, 0x33, 0x8f, 0xfe,
13095 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x63, 0x27, 0xfe, 0x40, 0x59, 11857 0x66, 0x02, 0x02, 0xd1, 0xeb, 0x2a, 0x67, 0x1a, 0xfe, 0x67, 0x1b, 0xf8,
13096 0xfe, 0xc1, 0x59, 0x77, 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18, 0x7c, 0xbe, 0x54, 0xbf, 11858 0xf7, 0xfe, 0x48, 0x1c,
13097 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e, 0x79, 0x56, 0x68, 0x57, 11859 0x70, 0x01, 0x6e, 0x87, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x16, 0xd3,
13098 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0x01, 0xa5, 0xa2, 0x23, 0x0c, 0x7b, 11860 0x0a, 0xca, 0x01, 0x0e,
13099 0x0c, 0x7c, 0x79, 0x56, 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x79, 0x39, 11861 0x74, 0x60, 0x59, 0x76, 0x27, 0x05, 0x6b, 0x28, 0xfe, 0x10, 0x12, 0x14,
13100 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x10, 0x58, 0xfe, 11862 0x2c, 0x01, 0x33, 0x8f,
13101 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x02, 0x6d, 0x09, 0x04, 0x19, 0x16, 0xd7, 0x09, 11863 0xfe, 0x66, 0x02, 0x02, 0xd1, 0xbc, 0x7d, 0xbd, 0x7f, 0x25, 0x22, 0x65,
13102 0x04, 0xfe, 0xf7, 0x00, 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f, 0xfe, 0x10, 0x90, 0xfe, 11864 0xfe, 0x3c, 0x04, 0x1f,
13103 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08, 0x11, 0x9b, 0x09, 0x04, 11865 0xfe, 0x38, 0x04, 0x68, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e,
13104 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a, 0x77, 0xfe, 0xc6, 0x08, 0xfe, 0x0c, 0x58, 0xfe, 11866 0x12, 0x2b, 0xff, 0x02,
13105 0x8d, 0x58, 0x02, 0x6d, 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04, 0x0b, 0xfe, 0x1a, 0x12, 11867 0x00, 0x10, 0x01, 0x08, 0x1f, 0xfe, 0xe0, 0x04, 0x2b, 0x01, 0x08, 0x1f,
13106 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9, 0x14, 0x7a, 0x01, 0x33, 11868 0x22, 0x30, 0x2e, 0xd5,
13107 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0xbe, 0x39, 0xfe, 0xed, 0x19, 0xbf, 11869 0xfe, 0x4c, 0x44, 0xfe, 0x4c, 0x12, 0x60, 0xfe, 0x44, 0x48, 0x13, 0x2c,
13108 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff, 0x34, 0xfe, 0x74, 0x10, 11870 0xfe, 0x4c, 0x54, 0x64,
13109 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x84, 0x05, 0xcb, 0x1c, 11871 0xd3, 0x46, 0x76, 0x27, 0xfa, 0xef, 0xfe, 0x62, 0x13, 0x09, 0x04, 0x1d,
13110 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00, 0x02, 0x5a, 0xfe, 0xd1, 0xf0, 0xfe, 0xc4, 0x0a, 11872 0xfe, 0x2a, 0x13, 0x2f,
13111 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 0xfe, 0xca, 11873 0x07, 0x7e, 0xa5, 0xfe, 0x20, 0x10, 0x13, 0x2c, 0xfe, 0x4c, 0x54, 0x64,
13112 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe, 0x22, 0x00, 0x02, 0x5a, 11874 0xd3, 0xfa, 0xef, 0x86,
13113 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe, 0x24, 0x00, 0x02, 0x5a, 0xfe, 0xd0, 0xf0, 0xfe, 11875 0x09, 0x04, 0x1d, 0xfe, 0x08, 0x13, 0x2f, 0x07, 0x7e, 0x6e, 0x09, 0x04,
13114 0xec, 0x0a, 0x0f, 0x93, 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f, 0x4c, 0xfe, 0x10, 0x10, 11876 0x1d, 0xfe, 0x1c, 0x12,
13115 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00, 0x2a, 0x13, 0xfe, 0x4e, 11877 0x14, 0x92, 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe,
13116 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0, 0xfe, 0x20, 0x0b, 0xb1, 0x16, 0x32, 0x2a, 0x73, 11878 0x70, 0x0c, 0x02, 0x22,
13117 0xdd, 0xb8, 0x22, 0xb9, 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25, 0x32, 0x8c, 0xfe, 0x48, 11879 0x2b, 0x11, 0xfe, 0xe6, 0x00, 0xfe, 0x1c, 0x90, 0xf9, 0x03, 0x14, 0x92,
13118 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xdb, 0x10, 0x11, 0xfe, 11880 0x01, 0x33, 0x02, 0x29,
13119 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd, 0x7f, 0xfe, 0x89, 0xf0, 0x22, 0x30, 0x2e, 0xd8, 11881 0xfe, 0x42, 0x5b, 0x67, 0x1a, 0xfe, 0x46, 0x59, 0xf8, 0xf7, 0xfe, 0x87,
13120 0xbc, 0x7d, 0xbd, 0x7f, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1, 0x45, 0x0f, 0xfe, 0x42, 11882 0x80, 0xfe, 0x31, 0xe4,
13121 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c, 0x09, 0x04, 0x0b, 0xfe, 11883 0x4f, 0x09, 0x04, 0x0b, 0xfe, 0x78, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x1a,
13122 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54, 0x12, 0x4b, 0xfe, 0x28, 0x00, 0x21, 0xfe, 0xa6, 11884 0xfe, 0x70, 0x12, 0x49,
13123 0x0c, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00, 0xfe, 0xe2, 0x10, 0x01, 11885 0x04, 0x06, 0xfe, 0x60, 0x13, 0x05, 0xfe, 0xa2, 0x00, 0x28, 0x16, 0xfe,
13124 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d, 0x01, 0x6f, 0x02, 0x29, 11886 0x80, 0x05, 0xfe, 0x31,
13125 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e, 0x0b, 0xfe, 0xb4, 0x10, 0x01, 0x86, 0x3e, 0x0b, 11887 0xe4, 0x6a, 0x49, 0x04, 0x0b, 0xfe, 0x4a, 0x13, 0x05, 0xfe, 0xa0, 0x00,
13126 0xfe, 0xaa, 0x10, 0x01, 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3, 0x3e, 0x0b, 0x0f, 0xfe, 11888 0x28, 0xfe, 0x42, 0x12,
13127 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01, 0xe8, 0x59, 0x11, 0x2d, 11889 0x5e, 0x01, 0x08, 0x25, 0x32, 0xf1, 0x01, 0x08, 0x26, 0xfe, 0x98, 0x05,
13128 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02, 0xfe, 0x2a, 0x03, 0x09, 0x04, 0x0b, 0x84, 0x3e, 11890 0x11, 0xfe, 0xe3, 0x00,
13129 0x0b, 0x0f, 0x00, 0xfe, 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12, 0x09, 0x04, 0x1b, 0xfe, 11891 0x23, 0x49, 0xfe, 0x4a, 0xf0, 0xfe, 0x6a, 0x05, 0xfe, 0x49, 0xf0, 0xfe,
13130 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 11892 0x64, 0x05, 0x83, 0x24,
13131 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35, 0xfe, 0xa9, 0x10, 0x0f, 0xfe, 0x15, 0x00, 0xfe, 11893 0xfe, 0x21, 0x00, 0xa1, 0x24, 0xfe, 0x22, 0x00, 0xa0, 0x24, 0x4c, 0xfe,
13132 0x04, 0xe6, 0x0b, 0x5f, 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x0f, 0xfe, 0x47, 0x00, 11894 0x09, 0x48, 0x01, 0x08,
13133 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa, 0xab, 0x70, 0x05, 0x6b, 11895 0x26, 0xfe, 0x98, 0x05, 0xfe, 0xe2, 0x08, 0x49, 0x04, 0xc5, 0x3b, 0x01,
13134 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x59, 0x01, 11896 0x86, 0x24, 0x06, 0x12,
13135 0xda, 0x02, 0x29, 0xea, 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31, 0x00, 0x37, 0x97, 0x01, 11897 0xcc, 0x37, 0xfe, 0x27, 0x01, 0x09, 0x04, 0x1d, 0xfe, 0x22, 0x12, 0x47,
13136 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e, 0x1d, 0xfe, 0xce, 0x45, 11898 0x01, 0xa7, 0x14, 0x92,
13137 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47, 0x4b, 0x89, 0xfe, 0x75, 0x57, 0x05, 0x51, 0xfe, 11899 0x09, 0x04, 0x06, 0x3b, 0x14, 0xc4, 0x01, 0x33, 0x8f, 0xfe, 0x70, 0x0c,
13138 0x98, 0x56, 0xfe, 0x38, 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48, 0x46, 0x09, 0x04, 0x1d, 11900 0x02, 0x22, 0x05, 0xfe,
13139 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a, 0x99, 0x01, 0x0e, 0xfe, 11901 0x9c, 0x00, 0x28, 0xfe, 0x3e, 0x12, 0x05, 0x50, 0x28, 0xfe, 0x36, 0x13,
13140 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe, 0x2a, 0x03, 0x0a, 0x51, 0xfe, 0xee, 0x14, 0xee, 11902 0x47, 0x01, 0xa7, 0x26,
13141 0x3e, 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x02, 0x29, 0x1e, 11903 0xfe, 0x08, 0x06, 0x0a, 0x06, 0x49, 0x04, 0x19, 0xfe, 0x02, 0x12, 0x5f,
13142 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12, 0xce, 0x1e, 0x2d, 0x47, 11904 0x01, 0xfe, 0xaa, 0x14,
13143 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe, 0xec, 0x0d, 0x13, 0x06, 0x12, 0x4d, 0x01, 0xfe, 11905 0x1f, 0xfe, 0xfe, 0x05, 0x11, 0x9a, 0x01, 0x43, 0x11, 0xfe, 0xe5, 0x00,
13144 0xe2, 0x15, 0x05, 0xfe, 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe, 0xf0, 0x0d, 0xfe, 0x02, 11906 0x05, 0x50, 0xb4, 0x0c,
13145 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 11907 0x50, 0x05, 0xc6, 0x28, 0xfe, 0x62, 0x12, 0x05, 0x3f, 0x28, 0xfe, 0x5a,
13146 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4, 0x0d, 0xfe, 0x18, 0x13, 0xaf, 0xfe, 0x02, 0xea, 11908 0x13, 0x01, 0xfe, 0x14,
13147 0xce, 0x62, 0x7a, 0xfe, 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c, 0x05, 0xfe, 0x38, 0x01, 11909 0x18, 0x01, 0xfe, 0x66, 0x18, 0xfe, 0x43, 0x48, 0xb7, 0x19, 0x13, 0x6c,
13148 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01, 11910 0xff, 0x02, 0x00, 0x57,
13149 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11, 0x2d, 0x8a, 0x13, 0x06, 0x03, 0x23, 0x03, 0x1e, 11911 0x48, 0x8b, 0x1c, 0x3d, 0x85, 0xb7, 0x69, 0x47, 0x01, 0xa7, 0x26, 0xfe,
13150 0x4d, 0xfe, 0xf7, 0x12, 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe, 0x71, 0x13, 0xfe, 0x24, 11912 0x72, 0x06, 0x49, 0x04,
13151 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 11913 0x1b, 0xdf, 0x89, 0x0a, 0x4d, 0x01, 0xfe, 0xd8, 0x14, 0x1f, 0xfe, 0x68,
13152 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x03, 0xfe, 11914 0x06, 0x11, 0x9a, 0x01,
13153 0x03, 0x57, 0xb6, 0x23, 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6, 0x75, 0x03, 0x09, 0x04, 11915 0x43, 0x11, 0xfe, 0xe5, 0x00, 0x05, 0x3f, 0xb4, 0x0c, 0x3f, 0x17, 0x06,
13154 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xe1, 11916 0x01, 0xa7, 0xec, 0x72,
13155 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe, 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xa3, 0xfe, 0x3c, 11917 0x70, 0x01, 0x6e, 0x87, 0x11, 0xfe, 0xe2, 0x00, 0x01, 0x08, 0x25, 0x32,
13156 0x90, 0xfe, 0x30, 0xf4, 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82, 0x16, 0x2f, 0x07, 0x2d, 11918 0xfe, 0x0a, 0xf0, 0xfe,
13157 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01, 0xe8, 0x11, 0xfe, 0xe9, 11919 0xa6, 0x06, 0x8c, 0xfe, 0x5c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 0x64, 0x07,
13158 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01, 0xfe, 0x14, 0x16, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 11920 0x8d, 0x81, 0x02, 0x22,
13159 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01, 0x09, 0x04, 0x4f, 0xfe, 11921 0x09, 0x04, 0x0b, 0xfe, 0x2e, 0x12, 0x15, 0x1a, 0x01, 0x08, 0x15, 0x00,
13160 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80, 0x40, 0x12, 0x20, 0x63, 11922 0x01, 0x08, 0x15, 0x00,
13161 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x03, 0xfe, 0x08, 0x1c, 0x05, 0xfe, 0xac, 11923 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x15,
13162 0x00, 0xfe, 0x06, 0x58, 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05, 0xfe, 0xb0, 0x00, 0xfe, 11924 0x00, 0x02, 0xfe, 0x32,
13163 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x24, 0x69, 0x12, 0xc9, 11925 0x08, 0x61, 0x04, 0x1b, 0xfe, 0x38, 0x12, 0x09, 0x04, 0x1b, 0x6e, 0x15,
13164 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48, 0x5f, 0x17, 0x1d, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 11926 0xfe, 0x1b, 0x00, 0x01,
13165 0x54, 0x21, 0xfe, 0x08, 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c, 0xfe, 0x90, 0x4d, 0xfe, 11927 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01, 0x08, 0x15, 0x00, 0x01,
13166 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c, 0x46, 0x1e, 0x20, 0xed, 11928 0x08, 0x15, 0x06, 0x01,
13167 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x32, 0x0f, 0xea, 0x70, 0xfe, 0x14, 0x1c, 11929 0x08, 0x15, 0x00, 0x02, 0xd9, 0x66, 0x4c, 0xfe, 0x3a, 0x55, 0x5f, 0xfe,
13168 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee, 0xfe, 0x07, 0xe6, 0x1d, 11930 0x9a, 0x81, 0x4b, 0x1d,
13169 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46, 0xfa, 0xef, 0xfe, 0x42, 11931 0xba, 0xfe, 0x32, 0x07, 0x0a, 0x1d, 0xfe, 0x09, 0x6f, 0xaf, 0xfe, 0xca,
13170 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a, 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x36, 0x12, 0xf0, 11932 0x45, 0xfe, 0x32, 0x12,
13171 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10, 11933 0x62, 0x2c, 0x85, 0x66, 0x7b, 0x01, 0x08, 0x25, 0x32, 0xfe, 0x0a, 0xf0,
13172 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e, 0x10, 0x07, 0x7e, 0x45, 11934 0xfe, 0x32, 0x07, 0x8d,
13173 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03, 0xfe, 0x44, 0x58, 0x74, 0xfe, 0x01, 0xec, 0x97, 11935 0x81, 0x8c, 0xfe, 0x5c, 0x07, 0x02, 0x22, 0x01, 0x43, 0x02, 0xfe, 0x8a,
13174 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76, 0x27, 0x01, 0xda, 0xfe, 11936 0x06, 0x15, 0x19, 0x02,
13175 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b, 0xfe, 0x48, 0x12, 0x07, 11937 0xfe, 0x8a, 0x06, 0xfe, 0x9c, 0xf7, 0xd4, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
13176 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30, 0x12, 0x07, 0xc2, 0x16, 0xfe, 0x3e, 0x11, 0x07, 11938 0x90, 0x77, 0xfe, 0xca,
13177 0xfe, 0x23, 0x00, 0x16, 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8, 0x11, 0x07, 0x19, 0xfe, 11939 0x07, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x4a, 0x6a, 0x35, 0x1e, 0x20, 0x07,
13178 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b, 0x01, 0x08, 0x8c, 0x43, 11940 0x10, 0xfe, 0x0e, 0x12,
13179 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01, 0xfe, 0x32, 0x0e, 0x11, 0x7e, 0x02, 0x29, 0x2b, 11941 0x74, 0xfe, 0x80, 0x80, 0x37, 0x20, 0x63, 0x27, 0xfe, 0x06, 0x10, 0xfe,
13180 0x2f, 0x07, 0x9b, 0xfe, 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe, 0xfc, 0x10, 0x09, 0x04, 11942 0x83, 0xe7, 0xc4, 0xa1,
13181 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe, 0xc6, 0x10, 0x1e, 0x58, 11943 0xfe, 0x03, 0x40, 0x09, 0x4a, 0x4f, 0x35, 0x01, 0xa8, 0xad, 0xfe, 0x1f,
13182 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77, 0xfe, 0x82, 0x0c, 0x0c, 0x54, 0x18, 0x55, 0x23, 11944 0x40, 0x12, 0x58, 0x01,
13183 0x0c, 0x7b, 0x0c, 0x7c, 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01, 0xa5, 0xc0, 0x38, 0xc1, 11945 0xa5, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6,
13184 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0xfe, 11946 0x51, 0x83, 0xfb, 0xfe,
13185 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x56, 0x18, 0x57, 11947 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x0c, 0x90, 0xfe, 0x8e, 0x90,
13186 0x83, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 11948 0xfe, 0x40, 0x50, 0xfe,
13187 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e, 0x58, 0xfe, 0x1f, 0x40, 11949 0xc2, 0x50, 0x0c, 0x39, 0x18, 0x3a, 0xfe, 0x4a, 0x10, 0x09, 0x04, 0x6a,
13188 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x44, 11950 0xfe, 0x2a, 0x12, 0xfe,
13189 0x50, 0xfe, 0xc6, 0x50, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x05, 0x39, 11951 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x54, 0x18, 0x55, 0x09, 0x04, 0x4f,
13190 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06, 0x12, 0xcd, 0x02, 0x5b, 11952 0x85, 0x01, 0xa8, 0xfe,
13191 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5, 0x07, 0x06, 0x21, 0x44, 0x2f, 0x07, 0x9b, 0x21, 11953 0x1f, 0x80, 0x12, 0x58, 0xfe, 0x44, 0x90, 0xfe, 0xc6, 0x90, 0x0c, 0x56,
13192 0x5b, 0x01, 0x6e, 0x1c, 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79, 0x39, 0x68, 0x3a, 0xfe, 11954 0x18, 0x57, 0xfb, 0xfe,
13193 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 11955 0x8a, 0x90, 0x0c, 0x52, 0x18, 0x53, 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90,
13194 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19, 0x41, 0x02, 0x5b, 0x2b, 0x01, 0x08, 0x25, 0x32, 11956 0x0c, 0x39, 0x18, 0x3a,
13195 0x1f, 0xa2, 0x30, 0x2e, 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b, 0x3b, 0x02, 0x44, 0x01, 11957 0x0c, 0x38, 0x18, 0x4e, 0x09, 0x4a, 0x19, 0x35, 0x2a, 0x13, 0xfe, 0x4e,
13196 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44, 0x01, 0x08, 0x1f, 0xa2, 11958 0x11, 0x65, 0xfe, 0x48,
13197 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x60, 0x05, 0xfe, 0x9c, 0x00, 0x28, 0x84, 0x49, 11959 0x08, 0xfe, 0x9e, 0xf0, 0xfe, 0x5c, 0x08, 0xb1, 0x16, 0x32, 0x2a, 0x73,
13198 0x04, 0x19, 0x34, 0x9f, 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06, 0x78, 0x3d, 0xfe, 0xda, 11960 0xdd, 0xb8, 0xfe, 0x80,
13199 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1, 0x05, 0xc6, 0x28, 0x84, 11961 0x08, 0xb9, 0xfe, 0x9e, 0x08, 0x8c, 0xfe, 0x74, 0x08, 0xfe, 0x06, 0xf0,
13200 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 11962 0xfe, 0x7a, 0x08, 0x8d,
13201 0x05, 0x50, 0xb4, 0x0c, 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xaa, 0x14, 0x02, 11963 0x81, 0x02, 0x22, 0x01, 0x43, 0xfe, 0xc9, 0x10, 0x15, 0x19, 0xfe, 0xc9,
13202 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06, 0x21, 0x44, 0x01, 0xfe, 11964 0x10, 0x61, 0x04, 0x06,
13203 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14, 0xfe, 0xa4, 0x14, 0x87, 0xfe, 0x4a, 0xf4, 0x0b, 11965 0xfe, 0x10, 0x12, 0x61, 0x04, 0x0b, 0x45, 0x09, 0x04, 0x0b, 0xfe, 0x68,
13204 0x16, 0x44, 0xfe, 0x4a, 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a, 0x85, 0x02, 0x5b, 0x05, 11966 0x12, 0xfe, 0x2e, 0x1c,
13205 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe, 0xd8, 0x14, 0x02, 0x5c, 11967 0x02, 0xfe, 0x24, 0x0a, 0x61, 0x04, 0x06, 0x45, 0x61, 0x04, 0x0b, 0xfe,
13206 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe, 0xe0, 0x12, 0x72, 0xf1, 0x01, 0x08, 0x23, 0x72, 11968 0x52, 0x12, 0xfe, 0x2c,
13207 0x03, 0x8f, 0xfe, 0xdc, 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca, 0x12, 0x5e, 0x2b, 0x01, 11969 0x1c, 0xfe, 0xaa, 0xf0, 0xfe, 0x1e, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0xbe,
13208 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 0xfe, 0xff, 0x7f, 11970 0x08, 0xfe, 0x8a, 0x10,
13209 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0x1c, 11971 0xaa, 0xfe, 0xf3, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0xca, 0x08, 0x02, 0xfe,
13210 0x3d, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 11972 0x24, 0x0a, 0xab, 0xfe,
13211 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58, 0x03, 0x0a, 0x50, 0x01, 11973 0xe7, 0x10, 0xfe, 0x2b, 0xf0, 0x9d, 0xe9, 0x1c, 0xfe, 0x00, 0xfe, 0xfe,
13212 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c, 0x10, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 11974 0x1c, 0x12, 0xb5, 0xfe,
13213 0x19, 0x48, 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x63, 0x27, 11975 0xd2, 0xf0, 0x9d, 0xfe, 0x76, 0x18, 0x1c, 0x1a, 0x16, 0x9d, 0x05, 0xcb,
13214 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 11976 0x1c, 0x06, 0x16, 0x9d,
13215 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01, 0xfe, 0x14, 0x18, 0xfe, 0x42, 0x48, 0x5f, 0x60, 11977 0xb8, 0x6d, 0xb9, 0x6d, 0xaa, 0xab, 0xfe, 0xb1, 0x10, 0x70, 0x5e, 0x2b,
13216 0x89, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14, 11978 0x14, 0x92, 0x01, 0x33,
13217 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe, 0xcc, 0x12, 0x49, 0x04, 11979 0x0f, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x5a, 0x0f, 0x7c, 0x02, 0x5a,
13218 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2, 0x4b, 0xc3, 0x64, 0xfe, 0xe8, 0x13, 0x3b, 0x13, 11980 0xfe, 0x74, 0x18, 0x1c,
13219 0x06, 0x17, 0xc3, 0x78, 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xa1, 0xff, 0x02, 0x83, 11981 0xfe, 0x00, 0xf8, 0x16, 0x6d, 0x67, 0x1b, 0x01, 0xfe, 0x44, 0x0d, 0x3b,
13220 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c, 0x13, 0x06, 0xfe, 0x56, 11982 0x01, 0xe6, 0x1e, 0x27,
13221 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00, 0x8e, 0xe4, 0x0a, 0xfe, 0x64, 0x00, 0x17, 0x93, 11983 0x74, 0x67, 0x1a, 0x02, 0x6d, 0x09, 0x04, 0x0b, 0x21, 0xfe, 0x06, 0x0a,
13222 0x13, 0x06, 0xfe, 0x28, 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe, 0xc8, 0x00, 0x8e, 0xe4, 11984 0x09, 0x04, 0x6a, 0xfe,
13223 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90, 0x01, 0xba, 0xfe, 0x4e, 11985 0x82, 0x12, 0x09, 0x04, 0x19, 0xfe, 0x66, 0x13, 0x1e, 0x58, 0xac, 0xfc,
13224 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4, 0x94, 0xfe, 0x56, 0xf0, 0xfe, 0x60, 0x14, 0xfe, 11986 0xfe, 0x83, 0x80, 0xfe,
13225 0x04, 0xf4, 0x6c, 0xfe, 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01, 0xfe, 0x22, 0x13, 0x1c, 11987 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x63,
13226 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 11988 0x27, 0xfe, 0x40, 0x59,
13227 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x19, 0xba, 0xfe, 0x9c, 0x14, 0xb7, 11989 0xfe, 0xc1, 0x59, 0x77, 0xd7, 0x05, 0x54, 0x31, 0x55, 0x0c, 0x7b, 0x18,
13228 0x19, 0x83, 0x60, 0x23, 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 11990 0x7c, 0xbe, 0x54, 0xbf,
13229 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26, 0xe5, 0x15, 0x0b, 0x01, 11991 0x55, 0x01, 0xa8, 0xad, 0x63, 0x27, 0x12, 0x58, 0xc0, 0x38, 0xc1, 0x4e,
13230 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xe5, 0x72, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x03, 11992 0x79, 0x56, 0x68, 0x57,
13231 0x15, 0x06, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x06, 0x01, 0x08, 11993 0xf4, 0xf5, 0xfe, 0x04, 0xfa, 0x38, 0xfe, 0x05, 0xfa, 0x4e, 0x01, 0xa5,
13232 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89, 0x4a, 0x01, 0x08, 0x03, 11994 0xa2, 0x23, 0x0c, 0x7b,
13233 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44, 0x13, 0xad, 0x12, 0xcc, 0xfe, 0x49, 0xf4, 0x00, 11995 0x0c, 0x7c, 0x79, 0x56, 0x68, 0x57, 0xfe, 0x12, 0x10, 0x09, 0x04, 0x19,
13234 0x3b, 0x72, 0x9f, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01, 0x08, 0x2f, 0x07, 0xfe, 11996 0x16, 0xd7, 0x79, 0x39,
13235 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd, 0x01, 0x43, 0x1e, 0xcd, 11997 0x68, 0x3a, 0x09, 0x04, 0xfe, 0xf7, 0x00, 0x35, 0x05, 0x52, 0x31, 0x53,
13236 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0xed, 0x88, 0x07, 0x10, 11998 0xfe, 0x10, 0x58, 0xfe,
13237 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x80, 0x01, 0x0e, 0x88, 11999 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x02, 0x6d, 0x09, 0x04,
13238 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3, 0x88, 0x03, 0x0a, 0x42, 12000 0x19, 0x16, 0xd7, 0x09,
13239 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xf2, 12001 0x04, 0xfe, 0xf7, 0x00, 0x35, 0xfe, 0x3a, 0x55, 0xfe, 0x19, 0x81, 0x5f,
13240 0xfe, 0x49, 0xe4, 0x10, 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51, 0x01, 0x82, 0x03, 0x17, 12002 0xfe, 0x10, 0x90, 0xfe,
13241 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 0x1c, 0xfe, 12003 0x92, 0x90, 0xfe, 0xd7, 0x10, 0x2f, 0x07, 0x9b, 0x16, 0xfe, 0xc6, 0x08,
13242 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01, 0xfe, 0xfc, 0x16, 0xe0, 0x91, 0x1d, 0x66, 0xfe, 12004 0x11, 0x9b, 0x09, 0x04,
13243 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe, 0xda, 0x10, 0x17, 0x10, 12005 0x0b, 0xfe, 0x14, 0x13, 0x05, 0x39, 0x31, 0x3a, 0x77, 0xfe, 0xc6, 0x08,
13244 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58, 0x05, 0xfe, 0x66, 0x01, 12006 0xfe, 0x0c, 0x58, 0xfe,
13245 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 0x50, 0x66, 12007 0x8d, 0x58, 0x02, 0x6d, 0x23, 0x47, 0xfe, 0x19, 0x80, 0xde, 0x09, 0x04,
13246 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe, 0x40, 0x16, 0xfe, 0xb6, 12008 0x0b, 0xfe, 0x1a, 0x12,
13247 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17, 0x10, 0x71, 0xfe, 0x83, 12009 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xe9, 0xb5, 0xfe, 0xd1, 0xf0, 0xd9,
13248 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x38, 0x90, 0xfe, 0x62, 0x16, 0xfe, 12010 0x14, 0x7a, 0x01, 0x33,
13249 0x94, 0x14, 0xfe, 0x10, 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 12011 0x0f, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0xbe, 0x39,
13250 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71, 0xfe, 0x30, 0xbc, 0xfe, 12012 0xfe, 0xed, 0x19, 0xbf,
13251 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0xc5, 0x90, 0xfe, 0x9a, 12013 0x3a, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xe9, 0x1c, 0xfe, 0x00, 0xff,
13252 0x16, 0xfe, 0x5c, 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe, 0x42, 0x10, 0xfe, 0x02, 12014 0x34, 0xfe, 0x74, 0x10,
13253 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc, 0xfe, 0x1d, 0xf7, 0x4f, 12015 0xb5, 0xfe, 0xd2, 0xf0, 0xfe, 0xb2, 0x0a, 0xfe, 0x76, 0x18, 0x1c, 0x1a,
13254 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x91, 0x4f, 0x47, 0xfe, 0x83, 0x58, 12016 0x84, 0x05, 0xcb, 0x1c,
13255 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11, 0xfe, 0xdd, 0x00, 0x63, 12017 0x06, 0xfe, 0x08, 0x13, 0x0f, 0xfe, 0x16, 0x00, 0x02, 0x5a, 0xfe, 0xd1,
13256 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14, 0x06, 0x37, 0x95, 0xa9, 12018 0xf0, 0xfe, 0xc4, 0x0a,
13257 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17, 0x23, 0x03, 0xfe, 0x7e, 0x18, 0x1c, 0x1a, 0x5d, 12019 0x14, 0x7a, 0x01, 0x33, 0x0f, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe,
13258 0x13, 0x0d, 0x03, 0x71, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x78, 0x2c, 12020 0xce, 0xf0, 0xfe, 0xca,
13259 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x3c, 0x8a, 0x0a, 12021 0x0a, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xd6, 0x0a, 0x0f, 0xfe,
13260 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 12022 0x22, 0x00, 0x02, 0x5a,
13261 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x01, 0x6f, 12023 0xfe, 0xcb, 0xf0, 0xfe, 0xe2, 0x0a, 0x0f, 0xfe, 0x24, 0x00, 0x02, 0x5a,
13262 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xf6, 0xfe, 0xd6, 0xf0, 12024 0xfe, 0xd0, 0xf0, 0xfe,
13263 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c, 0xe7, 0x0b, 0x0f, 0xfe, 0x15, 0x00, 0x59, 0x76, 12025 0xec, 0x0a, 0x0f, 0x93, 0xdc, 0xfe, 0xcf, 0xf0, 0xfe, 0xf6, 0x0a, 0x0f,
13264 0x27, 0x01, 0xda, 0x17, 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35, 0x11, 0x2d, 0x01, 0x6f, 12026 0x4c, 0xfe, 0x10, 0x10,
13265 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68, 0xc8, 0xfe, 0x48, 0x55, 12027 0xfe, 0xcc, 0xf0, 0xd9, 0x61, 0x04, 0x19, 0x3b, 0x0f, 0xfe, 0x12, 0x00,
13266 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73, 0x12, 0x98, 0x03, 0x0a, 0x99, 0x01, 0x0e, 0xf0, 12028 0x2a, 0x13, 0xfe, 0x4e,
13267 0x0a, 0x40, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73, 0x75, 0x03, 0x0a, 0x42, 12029 0x11, 0x65, 0xfe, 0x0c, 0x0b, 0xfe, 0x9e, 0xf0, 0xfe, 0x20, 0x0b, 0xb1,
13268 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01, 0x0e, 0x73, 0x75, 0x03, 12030 0x16, 0x32, 0x2a, 0x73,
13269 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18, 0x05, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0x5b, 12031 0xdd, 0xb8, 0x22, 0xb9, 0x22, 0x2a, 0xec, 0x65, 0xfe, 0x2c, 0x0b, 0x25,
13270 0xfe, 0x4e, 0xe4, 0xc2, 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1b, 12032 0x32, 0x8c, 0xfe, 0x48,
13271 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05, 0xfe, 0x94, 0x00, 0xfe, 12033 0x0b, 0x8d, 0x81, 0xb8, 0xd4, 0xb9, 0xd4, 0x02, 0x22, 0x01, 0x43, 0xfe,
13272 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe, 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x2c, 0xfe, 0x4e, 12034 0xdb, 0x10, 0x11, 0xfe,
13273 0x45, 0xfe, 0x0c, 0x12, 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69, 0x03, 0x07, 0x7a, 0xfe, 12035 0xe8, 0x00, 0xaa, 0xab, 0x70, 0xbc, 0x7d, 0xbd, 0x7f, 0xfe, 0x89, 0xf0,
13274 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1b, 0xfe, 0x5a, 12036 0x22, 0x30, 0x2e, 0xd8,
13275 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26, 0x10, 0x07, 0x1a, 0x5d, 0x24, 0x2c, 0xdc, 0x07, 12037 0xbc, 0x7d, 0xbd, 0x7f, 0x01, 0x08, 0x1f, 0x22, 0x30, 0x2e, 0xd6, 0xb1,
13276 0x0b, 0x5d, 0x24, 0x93, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d, 0x9f, 0xad, 0x03, 0x14, 12038 0x45, 0x0f, 0xfe, 0x42,
13277 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9, 0x03, 0x25, 0xfe, 0xca, 12039 0x00, 0x02, 0x5a, 0x78, 0x06, 0xfe, 0x81, 0x49, 0x16, 0xfe, 0x38, 0x0c,
13278 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6, 0x18, 0x03, 0xff, 0x1a, 0x00, 0x00, 12040 0x09, 0x04, 0x0b, 0xfe,
12041 0x44, 0x13, 0x0f, 0x00, 0x4b, 0x0b, 0xfe, 0x54, 0x12, 0x4b, 0xfe, 0x28,
12042 0x00, 0x21, 0xfe, 0xa6,
12043 0x0c, 0x0a, 0x40, 0x01, 0x0e, 0x07, 0x00, 0x5d, 0x3e, 0xfe, 0x28, 0x00,
12044 0xfe, 0xe2, 0x10, 0x01,
12045 0xe7, 0x01, 0xe8, 0x0a, 0x99, 0x01, 0xfe, 0x32, 0x0e, 0x59, 0x11, 0x2d,
12046 0x01, 0x6f, 0x02, 0x29,
12047 0x0f, 0xfe, 0x44, 0x00, 0x4b, 0x0b, 0xdf, 0x3e, 0x0b, 0xfe, 0xb4, 0x10,
12048 0x01, 0x86, 0x3e, 0x0b,
12049 0xfe, 0xaa, 0x10, 0x01, 0x86, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xa3,
12050 0x3e, 0x0b, 0x0f, 0xfe,
12051 0x43, 0x00, 0xfe, 0x96, 0x10, 0x09, 0x4a, 0x0b, 0x35, 0x01, 0xe7, 0x01,
12052 0xe8, 0x59, 0x11, 0x2d,
12053 0x01, 0x6f, 0x67, 0x0b, 0x59, 0x3c, 0x8a, 0x02, 0xfe, 0x2a, 0x03, 0x09,
12054 0x04, 0x0b, 0x84, 0x3e,
12055 0x0b, 0x0f, 0x00, 0xfe, 0x5c, 0x10, 0x61, 0x04, 0x1b, 0xfe, 0x58, 0x12,
12056 0x09, 0x04, 0x1b, 0xfe,
12057 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x5c, 0x0c, 0xfe,
12058 0x1c, 0x1c, 0xfe, 0x9d,
12059 0xf0, 0xfe, 0x62, 0x0c, 0x09, 0x4a, 0x1b, 0x35, 0xfe, 0xa9, 0x10, 0x0f,
12060 0xfe, 0x15, 0x00, 0xfe,
12061 0x04, 0xe6, 0x0b, 0x5f, 0x5c, 0x0f, 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10,
12062 0x0f, 0xfe, 0x47, 0x00,
12063 0xa1, 0x0f, 0xfe, 0x41, 0x00, 0xa0, 0x0f, 0xfe, 0x24, 0x00, 0x87, 0xaa,
12064 0xab, 0x70, 0x05, 0x6b,
12065 0x28, 0x21, 0xd1, 0x5f, 0xfe, 0x04, 0xe6, 0x1b, 0xfe, 0x9d, 0x41, 0xfe,
12066 0x1c, 0x42, 0x59, 0x01,
12067 0xda, 0x02, 0x29, 0xea, 0x14, 0x0b, 0x37, 0x95, 0xa9, 0x14, 0xfe, 0x31,
12068 0x00, 0x37, 0x97, 0x01,
12069 0xfe, 0x54, 0x0f, 0x02, 0xd0, 0x3c, 0xfe, 0x06, 0xec, 0xc9, 0xee, 0x3e,
12070 0x1d, 0xfe, 0xce, 0x45,
12071 0x34, 0x3c, 0xfe, 0x06, 0xea, 0xc9, 0xfe, 0x47, 0x4b, 0x89, 0xfe, 0x75,
12072 0x57, 0x05, 0x51, 0xfe,
12073 0x98, 0x56, 0xfe, 0x38, 0x12, 0x0a, 0x42, 0x01, 0x0e, 0xfe, 0x44, 0x48,
12074 0x46, 0x09, 0x04, 0x1d,
12075 0xfe, 0x1a, 0x13, 0x0a, 0x40, 0x01, 0x0e, 0x47, 0xfe, 0x41, 0x58, 0x0a,
12076 0x99, 0x01, 0x0e, 0xfe,
12077 0x49, 0x54, 0x8e, 0xfe, 0x2a, 0x0d, 0x02, 0xfe, 0x2a, 0x03, 0x0a, 0x51,
12078 0xfe, 0xee, 0x14, 0xee,
12079 0x3e, 0x1d, 0xfe, 0xce, 0x45, 0x34, 0x3c, 0xfe, 0xce, 0x47, 0xfe, 0xad,
12080 0x13, 0x02, 0x29, 0x1e,
12081 0x20, 0x07, 0x10, 0xfe, 0x9e, 0x12, 0x23, 0x12, 0x4d, 0x12, 0x94, 0x12,
12082 0xce, 0x1e, 0x2d, 0x47,
12083 0x37, 0x2d, 0xb1, 0xe0, 0xfe, 0xbc, 0xf0, 0xfe, 0xec, 0x0d, 0x13, 0x06,
12084 0x12, 0x4d, 0x01, 0xfe,
12085 0xe2, 0x15, 0x05, 0xfe, 0x38, 0x01, 0x31, 0xfe, 0x3a, 0x01, 0x77, 0xfe,
12086 0xf0, 0x0d, 0xfe, 0x02,
12087 0xec, 0xce, 0x62, 0x00, 0x5d, 0xfe, 0x04, 0xec, 0x20, 0x46, 0xfe, 0x05,
12088 0xf6, 0xfe, 0x34, 0x01,
12089 0x01, 0xfe, 0x52, 0x16, 0xfb, 0xfe, 0x48, 0xf4, 0x0d, 0xfe, 0x18, 0x13,
12090 0xaf, 0xfe, 0x02, 0xea,
12091 0xce, 0x62, 0x7a, 0xfe, 0xc5, 0x13, 0x14, 0x1b, 0x37, 0x95, 0xa9, 0x5c,
12092 0x05, 0xfe, 0x38, 0x01,
12093 0x1c, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 0x05, 0xfe, 0x3a, 0x01,
12094 0x0c, 0xfe, 0x62, 0x01,
12095 0x3d, 0x12, 0x20, 0x24, 0x06, 0x12, 0x2d, 0x11, 0x2d, 0x8a, 0x13, 0x06,
12096 0x03, 0x23, 0x03, 0x1e,
12097 0x4d, 0xfe, 0xf7, 0x12, 0x1e, 0x94, 0xac, 0x12, 0x94, 0x07, 0x7a, 0xfe,
12098 0x71, 0x13, 0xfe, 0x24,
12099 0x1c, 0x14, 0x1a, 0x37, 0x95, 0xa9, 0xfe, 0xd9, 0x10, 0xb6, 0xfe, 0x03,
12100 0xdc, 0xfe, 0x73, 0x57,
12101 0xfe, 0x80, 0x5d, 0x03, 0xb6, 0xfe, 0x03, 0xdc, 0xfe, 0x5b, 0x57, 0xfe,
12102 0x80, 0x5d, 0x03, 0xfe,
12103 0x03, 0x57, 0xb6, 0x23, 0xfe, 0x00, 0xcc, 0x03, 0xfe, 0x03, 0x57, 0xb6,
12104 0x75, 0x03, 0x09, 0x04,
12105 0x4c, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 0x06, 0xfe, 0x1a, 0x13,
12106 0xfe, 0x1e, 0x80, 0xe1,
12107 0xfe, 0x1d, 0x80, 0xa4, 0xfe, 0x0c, 0x90, 0xfe, 0x0e, 0x13, 0xfe, 0x0e,
12108 0x90, 0xa3, 0xfe, 0x3c,
12109 0x90, 0xfe, 0x30, 0xf4, 0x0b, 0xfe, 0x3c, 0x50, 0xa0, 0x01, 0xfe, 0x82,
12110 0x16, 0x2f, 0x07, 0x2d,
12111 0xe0, 0x01, 0xfe, 0xbc, 0x15, 0x09, 0x04, 0x1d, 0x45, 0x01, 0xe7, 0x01,
12112 0xe8, 0x11, 0xfe, 0xe9,
12113 0x00, 0x09, 0x04, 0x4c, 0xfe, 0x2c, 0x13, 0x01, 0xfe, 0x14, 0x16, 0xfe,
12114 0x1e, 0x1c, 0xfe, 0x14,
12115 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01, 0x18, 0xfe, 0x66, 0x01,
12116 0x09, 0x04, 0x4f, 0xfe,
12117 0x12, 0x12, 0xfe, 0x03, 0x80, 0x74, 0xfe, 0x01, 0xec, 0x20, 0xfe, 0x80,
12118 0x40, 0x12, 0x20, 0x63,
12119 0x27, 0x11, 0xc8, 0x59, 0x1e, 0x20, 0xed, 0x76, 0x20, 0x03, 0xfe, 0x08,
12120 0x1c, 0x05, 0xfe, 0xac,
12121 0x00, 0xfe, 0x06, 0x58, 0x05, 0xfe, 0xae, 0x00, 0xfe, 0x07, 0x58, 0x05,
12122 0xfe, 0xb0, 0x00, 0xfe,
12123 0x08, 0x58, 0x05, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c,
12124 0x24, 0x69, 0x12, 0xc9,
12125 0x23, 0x0c, 0x50, 0x0c, 0x3f, 0x13, 0x40, 0x48, 0x5f, 0x17, 0x1d, 0xfe,
12126 0x90, 0x4d, 0xfe, 0x91,
12127 0x54, 0x21, 0xfe, 0x08, 0x0f, 0x3e, 0x10, 0x13, 0x42, 0x48, 0x17, 0x4c,
12128 0xfe, 0x90, 0x4d, 0xfe,
12129 0x91, 0x54, 0x21, 0xfe, 0x1e, 0x0f, 0x24, 0x10, 0x12, 0x20, 0x78, 0x2c,
12130 0x46, 0x1e, 0x20, 0xed,
12131 0x76, 0x20, 0x11, 0xc8, 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x32, 0x0f, 0xea,
12132 0x70, 0xfe, 0x14, 0x1c,
12133 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x03, 0x3c, 0xfe, 0x0c, 0x14, 0xee,
12134 0xfe, 0x07, 0xe6, 0x1d,
12135 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x03, 0x01, 0x86, 0x78, 0x2c, 0x46,
12136 0xfa, 0xef, 0xfe, 0x42,
12137 0x13, 0x2f, 0x07, 0x2d, 0xfe, 0x34, 0x13, 0x0a, 0x42, 0x01, 0x0e, 0xb0,
12138 0xfe, 0x36, 0x12, 0xf0,
12139 0xfe, 0x45, 0x48, 0x01, 0xe3, 0xfe, 0x00, 0xcc, 0xb0, 0xfe, 0xf3, 0x13,
12140 0x3d, 0x75, 0x07, 0x10,
12141 0xa3, 0x0a, 0x80, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x6f, 0xfe, 0x0e,
12142 0x10, 0x07, 0x7e, 0x45,
12143 0xf6, 0xfe, 0xd6, 0xf0, 0xfe, 0x6c, 0x0f, 0x03, 0xfe, 0x44, 0x58, 0x74,
12144 0xfe, 0x01, 0xec, 0x97,
12145 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1b, 0x76,
12146 0x27, 0x01, 0xda, 0xfe,
12147 0xdd, 0x10, 0x2a, 0xbc, 0x7d, 0xbd, 0x7f, 0x30, 0x2e, 0xd5, 0x07, 0x1b,
12148 0xfe, 0x48, 0x12, 0x07,
12149 0x0b, 0xfe, 0x56, 0x12, 0x07, 0x1a, 0xfe, 0x30, 0x12, 0x07, 0xc2, 0x16,
12150 0xfe, 0x3e, 0x11, 0x07,
12151 0xfe, 0x23, 0x00, 0x16, 0xfe, 0x4a, 0x11, 0x07, 0x06, 0x16, 0xfe, 0xa8,
12152 0x11, 0x07, 0x19, 0xfe,
12153 0x12, 0x12, 0x07, 0x00, 0x16, 0x22, 0x14, 0xc2, 0x01, 0x33, 0x9f, 0x2b,
12154 0x01, 0x08, 0x8c, 0x43,
12155 0x03, 0x2b, 0xfe, 0x62, 0x08, 0x0a, 0xca, 0x01, 0xfe, 0x32, 0x0e, 0x11,
12156 0x7e, 0x02, 0x29, 0x2b,
12157 0x2f, 0x07, 0x9b, 0xfe, 0xd9, 0x13, 0x79, 0x39, 0x68, 0x3a, 0x77, 0xfe,
12158 0xfc, 0x10, 0x09, 0x04,
12159 0x6a, 0xfe, 0x72, 0x12, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x8e, 0xfe,
12160 0xc6, 0x10, 0x1e, 0x58,
12161 0xfe, 0x26, 0x13, 0x05, 0x7b, 0x31, 0x7c, 0x77, 0xfe, 0x82, 0x0c, 0x0c,
12162 0x54, 0x18, 0x55, 0x23,
12163 0x0c, 0x7b, 0x0c, 0x7c, 0x01, 0xa8, 0x24, 0x69, 0x73, 0x12, 0x58, 0x01,
12164 0xa5, 0xc0, 0x38, 0xc1,
12165 0x4e, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x38, 0xfe,
12166 0x05, 0xfa, 0x4e, 0xfe,
12167 0x91, 0x10, 0x05, 0x56, 0x31, 0x57, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56,
12168 0x0c, 0x56, 0x18, 0x57,
12169 0x83, 0xc0, 0x38, 0xc1, 0x4e, 0xf4, 0xf5, 0x05, 0x52, 0x31, 0x53, 0xfe,
12170 0x00, 0x56, 0xfe, 0xa1,
12171 0x56, 0x0c, 0x52, 0x18, 0x53, 0x09, 0x04, 0x6a, 0xfe, 0x1e, 0x12, 0x1e,
12172 0x58, 0xfe, 0x1f, 0x40,
12173 0x05, 0x54, 0x31, 0x55, 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x05, 0x56,
12174 0x31, 0x57, 0xfe, 0x44,
12175 0x50, 0xfe, 0xc6, 0x50, 0x05, 0x52, 0x31, 0x53, 0xfe, 0x08, 0x50, 0xfe,
12176 0x8a, 0x50, 0x05, 0x39,
12177 0x31, 0x3a, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x5c, 0x24, 0x06,
12178 0x12, 0xcd, 0x02, 0x5b,
12179 0x2b, 0x01, 0x08, 0x1f, 0x44, 0x30, 0x2e, 0xd5, 0x07, 0x06, 0x21, 0x44,
12180 0x2f, 0x07, 0x9b, 0x21,
12181 0x5b, 0x01, 0x6e, 0x1c, 0x3d, 0x16, 0x44, 0x09, 0x04, 0x0b, 0xe2, 0x79,
12182 0x39, 0x68, 0x3a, 0xfe,
12183 0x0a, 0x55, 0x34, 0xfe, 0x8b, 0x55, 0xbe, 0x39, 0xbf, 0x3a, 0xfe, 0x0c,
12184 0x51, 0xfe, 0x8e, 0x51,
12185 0x02, 0x5b, 0xfe, 0x19, 0x81, 0xaf, 0xfe, 0x19, 0x41, 0x02, 0x5b, 0x2b,
12186 0x01, 0x08, 0x25, 0x32,
12187 0x1f, 0xa2, 0x30, 0x2e, 0xd8, 0x4b, 0x1a, 0xfe, 0xa6, 0x12, 0x4b, 0x0b,
12188 0x3b, 0x02, 0x44, 0x01,
12189 0x08, 0x25, 0x32, 0x1f, 0xa2, 0x30, 0x2e, 0xd6, 0x07, 0x1a, 0x21, 0x44,
12190 0x01, 0x08, 0x1f, 0xa2,
12191 0x30, 0x2e, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x60, 0x05, 0xfe, 0x9c,
12192 0x00, 0x28, 0x84, 0x49,
12193 0x04, 0x19, 0x34, 0x9f, 0xfe, 0xbb, 0x45, 0x4b, 0x00, 0x45, 0x3e, 0x06,
12194 0x78, 0x3d, 0xfe, 0xda,
12195 0x14, 0x01, 0x6e, 0x87, 0xfe, 0x4b, 0x45, 0xe2, 0x2f, 0x07, 0x9a, 0xe1,
12196 0x05, 0xc6, 0x28, 0x84,
12197 0x05, 0x3f, 0x28, 0x34, 0x5e, 0x02, 0x5b, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8,
12198 0x14, 0xfe, 0x03, 0x17,
12199 0x05, 0x50, 0xb4, 0x0c, 0x50, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01,
12200 0xfe, 0xaa, 0x14, 0x02,
12201 0x5c, 0x01, 0x08, 0x25, 0x32, 0x1f, 0x44, 0x30, 0x2e, 0xd6, 0x07, 0x06,
12202 0x21, 0x44, 0x01, 0xfe,
12203 0x8e, 0x13, 0xfe, 0x42, 0x58, 0xfe, 0x82, 0x14, 0xfe, 0xa4, 0x14, 0x87,
12204 0xfe, 0x4a, 0xf4, 0x0b,
12205 0x16, 0x44, 0xfe, 0x4a, 0xf4, 0x06, 0xfe, 0x0c, 0x12, 0x2f, 0x07, 0x9a,
12206 0x85, 0x02, 0x5b, 0x05,
12207 0x3f, 0xb4, 0x0c, 0x3f, 0x5e, 0x2b, 0x01, 0x08, 0x26, 0x5c, 0x01, 0xfe,
12208 0xd8, 0x14, 0x02, 0x5c,
12209 0x13, 0x06, 0x65, 0xfe, 0xca, 0x12, 0x26, 0xfe, 0xe0, 0x12, 0x72, 0xf1,
12210 0x01, 0x08, 0x23, 0x72,
12211 0x03, 0x8f, 0xfe, 0xdc, 0x12, 0x25, 0xfe, 0xdc, 0x12, 0x1f, 0xfe, 0xca,
12212 0x12, 0x5e, 0x2b, 0x01,
12213 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b,
12214 0x1c, 0xfe, 0xff, 0x7f,
12215 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00,
12216 0x57, 0x48, 0x8b, 0x1c,
12217 0x3d, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x03, 0x13, 0x6c, 0xff, 0x02,
12218 0x00, 0x57, 0x48, 0x8b,
12219 0x03, 0x13, 0x6c, 0xff, 0x02, 0x00, 0x57, 0x48, 0x8b, 0xfe, 0x0b, 0x58,
12220 0x03, 0x0a, 0x50, 0x01,
12221 0x82, 0x0a, 0x3f, 0x01, 0x82, 0x03, 0xfc, 0x1c, 0x10, 0xff, 0x03, 0x00,
12222 0x54, 0xfe, 0x00, 0xf4,
12223 0x19, 0x48, 0xfe, 0x00, 0x7d, 0xfe, 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe,
12224 0x03, 0x7c, 0x63, 0x27,
12225 0x0c, 0x52, 0x18, 0x53, 0xbe, 0x56, 0xbf, 0x57, 0x03, 0xfe, 0x62, 0x08,
12226 0xfe, 0x82, 0x4a, 0xfe,
12227 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x74, 0x03, 0x01, 0xfe, 0x14, 0x18, 0xfe,
12228 0x42, 0x48, 0x5f, 0x60,
12229 0x89, 0x01, 0x08, 0x1f, 0xfe, 0xa2, 0x14, 0x30, 0x2e, 0xd8, 0x01, 0x08,
12230 0x1f, 0xfe, 0xa2, 0x14,
12231 0x30, 0x2e, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x05, 0xc6, 0x28, 0xfe,
12232 0xcc, 0x12, 0x49, 0x04,
12233 0x1b, 0xfe, 0xc4, 0x13, 0x23, 0x62, 0x1b, 0xe2, 0x4b, 0xc3, 0x64, 0xfe,
12234 0xe8, 0x13, 0x3b, 0x13,
12235 0x06, 0x17, 0xc3, 0x78, 0xdb, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55,
12236 0xa1, 0xff, 0x02, 0x83,
12237 0x55, 0x62, 0x1a, 0xa4, 0xbb, 0xfe, 0x30, 0x00, 0x8e, 0xe4, 0x17, 0x2c,
12238 0x13, 0x06, 0xfe, 0x56,
12239 0x10, 0x62, 0x0b, 0xe1, 0xbb, 0xfe, 0x64, 0x00, 0x8e, 0xe4, 0x0a, 0xfe,
12240 0x64, 0x00, 0x17, 0x93,
12241 0x13, 0x06, 0xfe, 0x28, 0x10, 0x62, 0x06, 0xfe, 0x60, 0x13, 0xbb, 0xfe,
12242 0xc8, 0x00, 0x8e, 0xe4,
12243 0x0a, 0xfe, 0xc8, 0x00, 0x17, 0x4d, 0x13, 0x06, 0x83, 0xbb, 0xfe, 0x90,
12244 0x01, 0xba, 0xfe, 0x4e,
12245 0x14, 0x89, 0xfe, 0x12, 0x10, 0xfe, 0x43, 0xf4, 0x94, 0xfe, 0x56, 0xf0,
12246 0xfe, 0x60, 0x14, 0xfe,
12247 0x04, 0xf4, 0x6c, 0xfe, 0x43, 0xf4, 0x93, 0xfe, 0xf3, 0x10, 0xf9, 0x01,
12248 0xfe, 0x22, 0x13, 0x1c,
12249 0x3d, 0xfe, 0x10, 0x13, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x69, 0xba,
12250 0xfe, 0x9c, 0x14, 0xb7,
12251 0x69, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 0x19, 0xba,
12252 0xfe, 0x9c, 0x14, 0xb7,
12253 0x19, 0x83, 0x60, 0x23, 0xfe, 0x4d, 0xf4, 0x00, 0xdf, 0x89, 0x13, 0x06,
12254 0xfe, 0xb4, 0x56, 0xfe,
12255 0xc3, 0x58, 0x03, 0x60, 0x13, 0x0b, 0x03, 0x15, 0x06, 0x01, 0x08, 0x26,
12256 0xe5, 0x15, 0x0b, 0x01,
12257 0x08, 0x26, 0xe5, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xe5, 0x72, 0xfe, 0x89,
12258 0x49, 0x01, 0x08, 0x03,
12259 0x15, 0x06, 0x01, 0x08, 0x26, 0xa6, 0x15, 0x1a, 0x01, 0x08, 0x26, 0xa6,
12260 0x15, 0x06, 0x01, 0x08,
12261 0x26, 0xa6, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x26, 0xa6, 0x72, 0xfe, 0x89,
12262 0x4a, 0x01, 0x08, 0x03,
12263 0x60, 0x03, 0x1e, 0xcc, 0x07, 0x06, 0xfe, 0x44, 0x13, 0xad, 0x12, 0xcc,
12264 0xfe, 0x49, 0xf4, 0x00,
12265 0x3b, 0x72, 0x9f, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xf1, 0x01,
12266 0x08, 0x2f, 0x07, 0xfe,
12267 0xe3, 0x00, 0xfe, 0x20, 0x13, 0x1f, 0xfe, 0x5a, 0x15, 0x23, 0x12, 0xcd,
12268 0x01, 0x43, 0x1e, 0xcd,
12269 0x07, 0x06, 0x45, 0x09, 0x4a, 0x06, 0x35, 0x03, 0x0a, 0x42, 0x01, 0x0e,
12270 0xed, 0x88, 0x07, 0x10,
12271 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a,
12272 0x80, 0x01, 0x0e, 0x88,
12273 0xfe, 0x80, 0xe7, 0x10, 0x07, 0x10, 0x84, 0xfe, 0x45, 0x58, 0x01, 0xe3,
12274 0x88, 0x03, 0x0a, 0x42,
12275 0x01, 0x0e, 0x88, 0x0a, 0x51, 0x01, 0x9e, 0x03, 0x0a, 0x42, 0x01, 0x0e,
12276 0xfe, 0x80, 0x80, 0xf2,
12277 0xfe, 0x49, 0xe4, 0x10, 0xa4, 0x0a, 0x80, 0x01, 0x0e, 0xf2, 0x0a, 0x51,
12278 0x01, 0x82, 0x03, 0x17,
12279 0x10, 0x71, 0x66, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde,
12280 0xfe, 0x24, 0x1c, 0xfe,
12281 0x1d, 0xf7, 0x1d, 0x90, 0xfe, 0xf6, 0x15, 0x01, 0xfe, 0xfc, 0x16, 0xe0,
12282 0x91, 0x1d, 0x66, 0xfe,
12283 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x03, 0xae, 0x21, 0xfe, 0xe6, 0x15, 0xfe,
12284 0xda, 0x10, 0x17, 0x10,
12285 0x71, 0x05, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x19, 0xfe, 0x18, 0x58,
12286 0x05, 0xfe, 0x66, 0x01,
12287 0xfe, 0x19, 0x58, 0x91, 0x19, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06,
12288 0xfe, 0x3c, 0x50, 0x66,
12289 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x19, 0x90, 0xfe,
12290 0x40, 0x16, 0xfe, 0xb6,
12291 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x18, 0x16, 0xfe, 0x9c, 0x10, 0x17,
12292 0x10, 0x71, 0xfe, 0x83,
12293 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x38, 0x90,
12294 0xfe, 0x62, 0x16, 0xfe,
12295 0x94, 0x14, 0xfe, 0x10, 0x13, 0x91, 0x38, 0x66, 0x1b, 0xfe, 0xaf, 0x19,
12296 0xfe, 0x98, 0xe7, 0x00,
12297 0x03, 0xae, 0x21, 0xfe, 0x56, 0x16, 0xfe, 0x6c, 0x10, 0x17, 0x10, 0x71,
12298 0xfe, 0x30, 0xbc, 0xfe,
12299 0xb2, 0xbc, 0x91, 0xc5, 0x66, 0x1b, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
12300 0xc5, 0x90, 0xfe, 0x9a,
12301 0x16, 0xfe, 0x5c, 0x14, 0x34, 0x03, 0xae, 0x21, 0xfe, 0x86, 0x16, 0xfe,
12302 0x42, 0x10, 0xfe, 0x02,
12303 0xf6, 0x10, 0x71, 0xfe, 0x18, 0xfe, 0x54, 0xfe, 0x19, 0xfe, 0x55, 0xfc,
12304 0xfe, 0x1d, 0xf7, 0x4f,
12305 0x90, 0xfe, 0xc0, 0x16, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x91, 0x4f,
12306 0x47, 0xfe, 0x83, 0x58,
12307 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x10, 0xfe, 0x81, 0xe7, 0x10, 0x11,
12308 0xfe, 0xdd, 0x00, 0x63,
12309 0x27, 0x03, 0x63, 0x27, 0xfe, 0x12, 0x45, 0x21, 0xfe, 0xb0, 0x16, 0x14,
12310 0x06, 0x37, 0x95, 0xa9,
12311 0x02, 0x29, 0xfe, 0x39, 0xf0, 0xfe, 0x04, 0x17, 0x23, 0x03, 0xfe, 0x7e,
12312 0x18, 0x1c, 0x1a, 0x5d,
12313 0x13, 0x0d, 0x03, 0x71, 0x05, 0xcb, 0x1c, 0x06, 0xfe, 0xef, 0x12, 0xfe,
12314 0xe1, 0x10, 0x78, 0x2c,
12315 0x46, 0x2f, 0x07, 0x2d, 0xfe, 0x3c, 0x13, 0xfe, 0x82, 0x14, 0xfe, 0x42,
12316 0x13, 0x3c, 0x8a, 0x0a,
12317 0x42, 0x01, 0x0e, 0xb0, 0xfe, 0x3e, 0x12, 0xf0, 0xfe, 0x45, 0x48, 0x01,
12318 0xe3, 0xfe, 0x00, 0xcc,
12319 0xb0, 0xfe, 0xf3, 0x13, 0x3d, 0x75, 0x07, 0x10, 0xa3, 0x0a, 0x80, 0x01,
12320 0x0e, 0xf2, 0x01, 0x6f,
12321 0xfe, 0x16, 0x10, 0x07, 0x7e, 0x85, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12,
12322 0xf6, 0xfe, 0xd6, 0xf0,
12323 0xfe, 0x24, 0x17, 0x17, 0x0b, 0x03, 0xfe, 0x9c, 0xe7, 0x0b, 0x0f, 0xfe,
12324 0x15, 0x00, 0x59, 0x76,
12325 0x27, 0x01, 0xda, 0x17, 0x06, 0x03, 0x3c, 0x8a, 0x09, 0x4a, 0x1d, 0x35,
12326 0x11, 0x2d, 0x01, 0x6f,
12327 0x17, 0x06, 0x03, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x79, 0xc7, 0x68,
12328 0xc8, 0xfe, 0x48, 0x55,
12329 0x34, 0xfe, 0xc9, 0x55, 0x03, 0x1e, 0x98, 0x73, 0x12, 0x98, 0x03, 0x0a,
12330 0x99, 0x01, 0x0e, 0xf0,
12331 0x0a, 0x40, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x16, 0xfe, 0xf0, 0x17, 0x73,
12332 0x75, 0x03, 0x0a, 0x42,
12333 0x01, 0x0e, 0x07, 0x10, 0x45, 0x0a, 0x51, 0x01, 0x9e, 0x0a, 0x40, 0x01,
12334 0x0e, 0x73, 0x75, 0x03,
12335 0xfe, 0x4e, 0xe4, 0x1a, 0x64, 0xfe, 0x24, 0x18, 0x05, 0xfe, 0x90, 0x00,
12336 0xfe, 0x3a, 0x45, 0x5b,
12337 0xfe, 0x4e, 0xe4, 0xc2, 0x64, 0xfe, 0x36, 0x18, 0x05, 0xfe, 0x92, 0x00,
12338 0xfe, 0x02, 0xe6, 0x1b,
12339 0xdc, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x64, 0xfe, 0x48, 0x18, 0x05,
12340 0xfe, 0x94, 0x00, 0xfe,
12341 0x02, 0xe6, 0x19, 0xfe, 0x08, 0x10, 0x05, 0xfe, 0x96, 0x00, 0xfe, 0x02,
12342 0xe6, 0x2c, 0xfe, 0x4e,
12343 0x45, 0xfe, 0x0c, 0x12, 0xaf, 0xff, 0x04, 0x68, 0x54, 0xde, 0x1c, 0x69,
12344 0x03, 0x07, 0x7a, 0xfe,
12345 0x5a, 0xf0, 0xfe, 0x74, 0x18, 0x24, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
12346 0x07, 0x1b, 0xfe, 0x5a,
12347 0xf0, 0xfe, 0x82, 0x18, 0x24, 0xc3, 0xfe, 0x26, 0x10, 0x07, 0x1a, 0x5d,
12348 0x24, 0x2c, 0xdc, 0x07,
12349 0x0b, 0x5d, 0x24, 0x93, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x5d, 0x24, 0x4d,
12350 0x9f, 0xad, 0x03, 0x14,
12351 0xfe, 0x09, 0x00, 0x01, 0x33, 0xfe, 0x04, 0xfe, 0x7d, 0x05, 0x7f, 0xf9,
12352 0x03, 0x25, 0xfe, 0xca,
12353 0x18, 0xfe, 0x14, 0xf0, 0x08, 0x65, 0xfe, 0xc6, 0x18, 0x03, 0xff, 0x1a,
12354 0x00, 0x00,
13279}; 12355};
13280 12356
13281STATIC unsigned short _adv_asc3550_size = 12357static unsigned short _adv_asc3550_size = sizeof(_adv_asc3550_buf); /* 0x13AD */
13282 sizeof(_adv_asc3550_buf); /* 0x13AD */ 12358static ADV_DCNT _adv_asc3550_chksum = 0x04D52DDDUL; /* Expanded little-endian checksum. */
13283STATIC ADV_DCNT _adv_asc3550_chksum =
13284 0x04D52DDDUL; /* Expanded little-endian checksum. */
13285 12359
13286/* Microcode buffer is kept after initialization for error recovery. */ 12360/* Microcode buffer is kept after initialization for error recovery. */
13287STATIC unsigned char _adv_asc38C0800_buf[] = { 12361static unsigned char _adv_asc38C0800_buf[] = {
13288 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4, 0x01, 0x00, 0x48, 0xe4, 12362 0x00, 0x00, 0x00, 0xf2, 0x00, 0xf0, 0x00, 0xfc, 0x00, 0x16, 0x18, 0xe4,
13289 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19, 0x00, 0xfa, 0xff, 0xff, 0x1c, 0x0f, 0x00, 0xf6, 12363 0x01, 0x00, 0x48, 0xe4,
13290 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6, 0x09, 0xe7, 0x55, 0xf0, 12364 0x18, 0x80, 0x03, 0xf6, 0x02, 0x00, 0xce, 0x19, 0x00, 0xfa, 0xff, 0xff,
13291 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0, 0x18, 0xf4, 0x08, 0x00, 12365 0x1c, 0x0f, 0x00, 0xf6,
13292 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0, 0x82, 0x0d, 0x00, 0xe6, 0x86, 0xf0, 0xb1, 0xf0, 12366 0x9e, 0xe7, 0xff, 0x00, 0x82, 0xe7, 0x00, 0xea, 0x01, 0xfa, 0x01, 0xe6,
13293 0x98, 0x57, 0x01, 0xfc, 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c, 0x3c, 0x00, 0xbb, 0x00, 12367 0x09, 0xe7, 0x55, 0xf0,
13294 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13, 0xba, 0x13, 0x18, 0x40, 12368 0x01, 0xf6, 0x03, 0x00, 0x04, 0x00, 0x10, 0x00, 0x1e, 0xf0, 0x85, 0xf0,
13295 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc, 0x3e, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x74, 0x01, 12369 0x18, 0xf4, 0x08, 0x00,
13296 0x76, 0x01, 0xb9, 0x54, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00, 0xc0, 0x00, 0x01, 0x01, 12370 0xbc, 0x00, 0x38, 0x54, 0x00, 0xec, 0xd5, 0xf0, 0x82, 0x0d, 0x00, 0xe6,
13297 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12, 0x08, 0x12, 0x02, 0x4a, 12371 0x86, 0xf0, 0xb1, 0xf0,
13298 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4, 0x5d, 0xf0, 0x02, 0xfa, 12372 0x98, 0x57, 0x01, 0xfc, 0xb4, 0x00, 0xd4, 0x01, 0x0c, 0x1c, 0x3e, 0x1c,
13299 0x20, 0x00, 0x32, 0x00, 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 0x68, 0x01, 0x6a, 0x01, 12373 0x3c, 0x00, 0xbb, 0x00,
13300 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d, 0x06, 0x13, 0x4c, 0x1c, 12374 0x00, 0x10, 0xba, 0x19, 0x02, 0x80, 0x32, 0xf0, 0x7c, 0x0d, 0x02, 0x13,
13301 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x0c, 0x00, 0x0f, 0x00, 0x47, 0x00, 12375 0xba, 0x13, 0x18, 0x40,
13302 0xbe, 0x00, 0x00, 0x01, 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c, 0x4e, 0x1c, 0x10, 0x44, 12376 0x00, 0x57, 0x01, 0xea, 0x02, 0xfc, 0x03, 0xfc, 0x3e, 0x00, 0x6c, 0x01,
13303 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa, 0x05, 0x00, 0x34, 0x00, 12377 0x6e, 0x01, 0x74, 0x01,
13304 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4a, 0x0b, 0x42, 0x0c, 0x12, 0x0f, 12378 0x76, 0x01, 0xb9, 0x54, 0x3e, 0x57, 0x00, 0x80, 0x03, 0xe6, 0xb6, 0x00,
13305 0x0c, 0x10, 0x22, 0x11, 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48, 0x00, 0x4e, 0x42, 0x54, 12379 0xc0, 0x00, 0x01, 0x01,
13306 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 0x59, 0xf0, 0xb8, 0xf0, 12380 0x3e, 0x01, 0x7a, 0x01, 0xca, 0x08, 0xce, 0x10, 0x16, 0x11, 0x04, 0x12,
13307 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc, 0x05, 0xfc, 0x06, 0x00, 0x19, 0x00, 0x33, 0x00, 12381 0x08, 0x12, 0x02, 0x4a,
13308 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00, 0xe7, 0x00, 0xe2, 0x03, 12382 0xbb, 0x55, 0x3c, 0x56, 0x03, 0x58, 0x1b, 0x80, 0x30, 0xe4, 0x4b, 0xe4,
13309 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13, 0x12, 0x13, 0x24, 0x14, 12383 0x5d, 0xf0, 0x02, 0xfa,
13310 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x08, 0x44, 12384 0x20, 0x00, 0x32, 0x00, 0x40, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01,
13311 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54, 0x3a, 0x55, 0x83, 0x55, 12385 0x68, 0x01, 0x6a, 0x01,
13312 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0, 0x0c, 0xf0, 0x04, 0xf8, 12386 0x70, 0x01, 0x72, 0x01, 0x78, 0x01, 0x7c, 0x01, 0x62, 0x0a, 0x86, 0x0d,
13313 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x9e, 0x00, 0xa8, 0x00, 0xaa, 0x00, 12387 0x06, 0x13, 0x4c, 0x1c,
13314 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01, 0xc4, 0x01, 0xc6, 0x01, 12388 0x04, 0x80, 0x4a, 0xe4, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x0c, 0x00,
13315 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08, 0x68, 0x08, 0x69, 0x08, 12389 0x0f, 0x00, 0x47, 0x00,
13316 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f, 0x12, 0x10, 0x1a, 0x10, 0xed, 0x10, 0xf1, 0x10, 12390 0xbe, 0x00, 0x00, 0x01, 0x20, 0x11, 0x5c, 0x16, 0x32, 0x1c, 0x38, 0x1c,
13317 0x2a, 0x11, 0x06, 0x12, 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13, 0x1e, 0x13, 0x46, 0x14, 12391 0x4e, 0x1c, 0x10, 0x44,
13318 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18, 0xca, 0x18, 0xe6, 0x19, 12392 0x00, 0x4c, 0x04, 0xea, 0x5c, 0xf0, 0xa7, 0xf0, 0x04, 0xf6, 0x03, 0xfa,
13319 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0xfe, 0x9c, 0xf0, 0x2b, 0x02, 0xfe, 12393 0x05, 0x00, 0x34, 0x00,
13320 0xac, 0x0d, 0xff, 0x10, 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6, 0xfe, 0x84, 0x01, 0xff, 12394 0x36, 0x00, 0x98, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x4a, 0x0b,
13321 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24, 12395 0x42, 0x0c, 0x12, 0x0f,
13322 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00, 0x00, 0x11, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 12396 0x0c, 0x10, 0x22, 0x11, 0x0a, 0x12, 0x04, 0x13, 0x30, 0x1c, 0x02, 0x48,
13323 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x11, 12397 0x00, 0x4e, 0x42, 0x54,
13324 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xd6, 12398 0x44, 0x55, 0xbd, 0x56, 0x06, 0x83, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0,
13325 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe, 0x04, 0xf7, 0xd6, 0x99, 0x0a, 0x42, 0x2c, 0xfe, 12399 0x59, 0xf0, 0xb8, 0xf0,
13326 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 12400 0x4b, 0xf4, 0x06, 0xf7, 0x0e, 0xf7, 0x04, 0xfc, 0x05, 0xfc, 0x06, 0x00,
13327 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d, 0x02, 0xfe, 0xc8, 0x0d, 12401 0x19, 0x00, 0x33, 0x00,
13328 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 0xa6, 12402 0x9b, 0x00, 0xa4, 0x00, 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe1, 0x00,
13329 0x00, 0xfe, 0xd3, 0x12, 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48, 0xf0, 0xfe, 0x8a, 0x02, 12403 0xe7, 0x00, 0xe2, 0x03,
13330 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02, 0xfe, 0x46, 0xf0, 0xfe, 12404 0x08, 0x0f, 0x02, 0x10, 0x04, 0x10, 0x0a, 0x10, 0x0a, 0x13, 0x0c, 0x13,
13331 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x48, 0x02, 0xfe, 0x44, 12405 0x12, 0x13, 0x24, 0x14,
13332 0xf0, 0xfe, 0x4c, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a, 0xaa, 0x18, 0x06, 0x14, 12406 0x34, 0x14, 0x04, 0x16, 0x08, 0x16, 0xa4, 0x17, 0x20, 0x1c, 0x34, 0x1c,
13333 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe, 0x1e, 0x1c, 0xfe, 0xe9, 12407 0x36, 0x1c, 0x08, 0x44,
13334 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xce, 0x09, 0x70, 0x01, 0xa8, 12408 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x01, 0x48, 0x68, 0x54,
13335 0x02, 0x2b, 0x15, 0x59, 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xbd, 12409 0x3a, 0x55, 0x83, 0x55,
13336 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x18, 0x06, 12410 0xe5, 0x55, 0xb0, 0x57, 0x01, 0x58, 0x83, 0x59, 0x05, 0xe6, 0x0b, 0xf0,
13337 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0x23, 0xfe, 0x98, 0x02, 0xfe, 12411 0x0c, 0xf0, 0x04, 0xf8,
13338 0x5a, 0x1c, 0xf8, 0xfe, 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 12412 0x05, 0xf8, 0x07, 0x00, 0x0a, 0x00, 0x1c, 0x00, 0x1e, 0x00, 0x9e, 0x00,
13339 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe, 0x69, 0x10, 0x18, 0x06, 12413 0xa8, 0x00, 0xaa, 0x00,
13340 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43, 0x13, 0x20, 0xfe, 0x05, 0xf6, 0xce, 0x01, 0xfe, 12414 0xb9, 0x00, 0xe0, 0x00, 0x22, 0x01, 0x26, 0x01, 0x79, 0x01, 0x7e, 0x01,
13341 0x4a, 0x17, 0x08, 0x54, 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 12415 0xc4, 0x01, 0xc6, 0x01,
13342 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x09, 12416 0x80, 0x02, 0x5e, 0x03, 0xee, 0x04, 0x9a, 0x06, 0xf8, 0x07, 0x62, 0x08,
13343 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe, 0x10, 0x03, 0x01, 0xfe, 0x82, 0x16, 0x02, 0x2b, 12417 0x68, 0x08, 0x69, 0x08,
13344 0x2c, 0x4f, 0xfe, 0x02, 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 12418 0xd6, 0x08, 0xe9, 0x09, 0xfa, 0x0b, 0x2e, 0x0f, 0x12, 0x10, 0x1a, 0x10,
13345 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x40, 0x1c, 0x1c, 12419 0xed, 0x10, 0xf1, 0x10,
13346 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x48, 0x03, 0xfe, 0x11, 0xf0, 12420 0x2a, 0x11, 0x06, 0x12, 0x0c, 0x12, 0x3e, 0x12, 0x10, 0x13, 0x16, 0x13,
13347 0xa7, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10, 0xfe, 0x11, 0x00, 0x02, 12421 0x1e, 0x13, 0x46, 0x14,
13348 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13, 0x21, 0x22, 0xa3, 0xb7, 12422 0x76, 0x14, 0x82, 0x14, 0x36, 0x15, 0xca, 0x15, 0x6b, 0x18, 0xbe, 0x18,
13349 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78, 0x01, 0xfe, 0xb4, 0x16, 0x12, 0xd1, 0x1c, 0xd9, 12423 0xca, 0x18, 0xe6, 0x19,
13350 0xfe, 0x01, 0xf0, 0xd9, 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12, 0xfe, 0xe4, 0x00, 0x27, 12424 0x12, 0x1c, 0x46, 0x1c, 0x9c, 0x32, 0x00, 0x40, 0x0e, 0x47, 0xfe, 0x9c,
13351 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe, 0x06, 0xf0, 0xfe, 0xc8, 12425 0xf0, 0x2b, 0x02, 0xfe,
13352 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a, 0x06, 0x02, 0x24, 0x03, 0x70, 0x28, 0x17, 0xfe, 12426 0xac, 0x0d, 0xff, 0x10, 0x00, 0x00, 0xd7, 0xfe, 0xe8, 0x19, 0x00, 0xd6,
13353 0xfa, 0x04, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8, 0xf9, 0x2c, 0x99, 0x19, 12427 0xfe, 0x84, 0x01, 0xff,
13354 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x74, 0x01, 0xaf, 0x8c, 12428 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
13355 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda, 0x09, 0xd1, 0x01, 0x0e, 0x8d, 0x51, 0x64, 0x79, 12429 0x00, 0xfe, 0x57, 0x24,
13356 0x2a, 0x03, 0x70, 0x28, 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 12430 0x00, 0xfe, 0x4c, 0x00, 0x5b, 0xff, 0x04, 0x00, 0x00, 0x11, 0xff, 0x09,
13357 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d, 0xfe, 0x3c, 0x04, 0x3b, 12431 0x00, 0x00, 0xff, 0x08,
13358 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2d, 0xff, 0x02, 0x00, 0x10, 0x01, 0x0b, 12432 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10,
13359 0x1d, 0xfe, 0xe4, 0x04, 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde, 0xfe, 0x4c, 0x44, 0xfe, 12433 0xff, 0xff, 0xff, 0x11,
13360 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0x4f, 0x79, 0x2a, 12434 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
13361 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x2a, 0x13, 0x32, 12435 0xfe, 0x04, 0xf7, 0xd6,
13362 0x07, 0x82, 0xfe, 0x52, 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b, 0xda, 0xfe, 12436 0x2c, 0x99, 0x0a, 0x01, 0xfe, 0xc2, 0x0f, 0xfe, 0x04, 0xf7, 0xd6, 0x99,
13363 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x08, 0x13, 0x32, 0x07, 12437 0x0a, 0x42, 0x2c, 0xfe,
13364 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x1c, 0x12, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 12438 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0xfe, 0x20, 0xf0, 0xa7, 0xfe, 0x91, 0xf0,
13365 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x2d, 0x12, 0xfe, 0xe6, 12439 0xfe, 0xf4, 0x01, 0xfe,
13366 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36, 0x02, 0x2b, 0xfe, 0x42, 12440 0x90, 0xf0, 0xfe, 0xf4, 0x01, 0xfe, 0x8f, 0xf0, 0xa7, 0x03, 0x5d, 0x4d,
13367 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x87, 0x80, 0xfe, 12441 0x02, 0xfe, 0xc8, 0x0d,
13368 0x31, 0xe4, 0x5b, 0x08, 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80, 0x07, 0x19, 0xfe, 0x7c, 12442 0x01, 0xfe, 0x38, 0x0e, 0xfe, 0xdd, 0x12, 0xfe, 0xfc, 0x10, 0xfe, 0x28,
13369 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28, 0x17, 0xfe, 0x90, 0x05, 12443 0x1c, 0x03, 0xfe, 0xa6,
13370 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe, 0x56, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x28, 0xfe, 12444 0x00, 0xfe, 0xd3, 0x12, 0x41, 0x14, 0xfe, 0xa6, 0x00, 0xc2, 0xfe, 0x48,
13371 0x4e, 0x12, 0x67, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c, 0x34, 0xfe, 0x89, 0x48, 12445 0xf0, 0xfe, 0x8a, 0x02,
13372 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0x12, 0xfe, 0xe3, 0x00, 12446 0xfe, 0x49, 0xf0, 0xfe, 0xa4, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc2, 0x02,
13373 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0x70, 0x05, 0x88, 0x25, 12447 0xfe, 0x46, 0xf0, 0xfe,
13374 0xfe, 0x21, 0x00, 0xab, 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe, 0x09, 0x48, 0xff, 0x02, 12448 0x54, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x5a, 0x02, 0xfe, 0x43, 0xf0, 0xfe,
13375 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2, 0x08, 0x53, 0x05, 0xcb, 12449 0x48, 0x02, 0xfe, 0x44,
13376 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39, 0xfe, 0x27, 0x01, 0x08, 0x05, 0x1b, 0xfe, 0x22, 12450 0xf0, 0xfe, 0x4c, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x50, 0x02, 0x18, 0x0a,
13377 0x12, 0x41, 0x01, 0xb2, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36, 12451 0xaa, 0x18, 0x06, 0x14,
13378 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb, 0x03, 0x5c, 0x28, 0xfe, 12452 0xa1, 0x02, 0x2b, 0xfe, 0x00, 0x1c, 0xe7, 0xfe, 0x02, 0x1c, 0xe6, 0xfe,
13379 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18, 0x06, 0x09, 0x06, 0x53, 0x05, 0x1f, 0xfe, 0x02, 12453 0x1e, 0x1c, 0xfe, 0xe9,
13380 0x12, 0x50, 0x01, 0xfe, 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe, 12454 0x10, 0x01, 0xfe, 0x18, 0x18, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xce,
13381 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62, 0x12, 0x03, 0x45, 0x28, 12455 0x09, 0x70, 0x01, 0xa8,
13382 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01, 0xfe, 0x76, 0x19, 0xfe, 0x43, 0x48, 0xc4, 0xcc, 12456 0x02, 0x2b, 0x15, 0x59, 0x39, 0xa2, 0x01, 0xfe, 0x58, 0x10, 0x09, 0x70,
13383 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4, 0x6e, 0x41, 0x01, 0xb2, 12457 0x01, 0x87, 0xfe, 0xbd,
13384 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01, 0xfe, 0xcc, 0x15, 0x1d, 12458 0x10, 0x09, 0x70, 0x01, 0x87, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe,
13385 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe, 0xe5, 0x00, 0x03, 0x45, 0xc1, 0x0c, 0x45, 12459 0x58, 0x1c, 0x18, 0x06,
13386 0x18, 0x06, 0x01, 0xb2, 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe, 0xe2, 0x00, 0x27, 0xdb, 12460 0x14, 0xa1, 0x2c, 0x1c, 0x2b, 0xfe, 0x3d, 0xf0, 0xfe, 0x06, 0x02, 0x23,
13387 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07, 0xfe, 0x06, 0xf0, 0xfe, 12461 0xfe, 0x98, 0x02, 0xfe,
13388 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05, 0x0a, 0xfe, 0x2e, 0x12, 0x16, 0x19, 0x01, 0x0b, 12462 0x5a, 0x1c, 0xf8, 0xfe, 0x14, 0x1c, 0x15, 0xfe, 0x30, 0x00, 0x39, 0xa2,
13389 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0xfe, 0x99, 0xa4, 0x01, 12463 0x01, 0xfe, 0x48, 0x10,
13390 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38, 0x12, 0x08, 0x05, 0x1a, 12464 0x18, 0x06, 0x14, 0xa1, 0x02, 0xd7, 0x22, 0x20, 0x07, 0x11, 0x35, 0xfe,
13391 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 12465 0x69, 0x10, 0x18, 0x06,
13392 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02, 0xe2, 0x6c, 0x58, 0xbe, 12466 0x14, 0xa1, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0x43, 0x13, 0x20, 0xfe, 0x05,
13393 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b, 0xfe, 0x09, 0x6f, 0xba, 12467 0xf6, 0xce, 0x01, 0xfe,
13394 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d, 0x8b, 0x6c, 0x7f, 0x27, 0xfe, 0x54, 0x07, 0x1c, 12468 0x4a, 0x17, 0x08, 0x54, 0x58, 0x37, 0x12, 0x2f, 0x42, 0x92, 0x01, 0xfe,
13395 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c, 0x07, 0x02, 0x24, 0x01, 12469 0x82, 0x16, 0x02, 0x2b,
13396 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 12470 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x01, 0x73, 0xfe, 0x18, 0x10,
13397 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x54, 0x5a, 0x37, 0x22, 0x20, 0x07, 12471 0xfe, 0x41, 0x58, 0x09,
13398 0x11, 0xfe, 0x0e, 0x12, 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a, 0xfe, 0x06, 0x10, 0xfe, 12472 0xa4, 0x01, 0x0e, 0xfe, 0xc8, 0x54, 0x6b, 0xfe, 0x10, 0x03, 0x01, 0xfe,
13399 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b, 0x37, 0x01, 0xb3, 0xb8, 12473 0x82, 0x16, 0x02, 0x2b,
13400 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 12474 0x2c, 0x4f, 0xfe, 0x02, 0xe8, 0x2a, 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43,
13401 0xfe, 0xc6, 0x51, 0x88, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 0xfe, 0x0c, 12475 0xfe, 0x77, 0x57, 0xfe,
13402 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d, 0x14, 0x3e, 0xfe, 0x4a, 12476 0x27, 0xf0, 0xfe, 0xe0, 0x01, 0xfe, 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xa7,
13403 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae, 0x90, 0x0c, 0x60, 0x14, 12477 0xfe, 0x40, 0x1c, 0x1c,
13404 0x61, 0x08, 0x05, 0x5b, 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62, 0xfe, 0x44, 0x90, 0xfe, 12478 0xd9, 0xfe, 0x26, 0xf0, 0xfe, 0x5a, 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x48,
13405 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e, 0x14, 0x5f, 12479 0x03, 0xfe, 0x11, 0xf0,
13406 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d, 0x14, 0x3e, 0x0c, 0x2e, 0x14, 0x3c, 0x21, 0x0c, 12480 0xa7, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 0xf0, 0xfe, 0x68, 0x03, 0xf9, 0x10,
13407 0x49, 0x0c, 0x63, 0x08, 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11, 0x27, 0xdd, 0xfe, 0x9e, 12481 0xfe, 0x11, 0x00, 0x02,
13408 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe, 0x9a, 0x08, 0xc6, 0xfe, 12482 0x65, 0x2c, 0xfe, 0x48, 0x1c, 0xf9, 0x08, 0x05, 0x1b, 0xfe, 0x18, 0x13,
13409 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x94, 0x08, 0x95, 0x86, 0x02, 0x24, 12483 0x21, 0x22, 0xa3, 0xb7,
13410 0x01, 0x4b, 0xfe, 0xc9, 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05, 0x06, 0xfe, 0x10, 0x12, 12484 0x13, 0xa3, 0x09, 0x46, 0x01, 0x0e, 0xb7, 0x78, 0x01, 0xfe, 0xb4, 0x16,
13411 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e, 0x1c, 0x02, 0xfe, 0x18, 12485 0x12, 0xd1, 0x1c, 0xd9,
13412 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a, 0xfe, 0x7a, 0x12, 0xfe, 0x2c, 0x1c, 0xfe, 0xaa, 12486 0xfe, 0x01, 0xf0, 0xd9, 0xfe, 0x82, 0xf0, 0xfe, 0x96, 0x03, 0xfa, 0x12,
13413 0xf0, 0xfe, 0xd2, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe, 0xde, 0x09, 0xfe, 0xb7, 12487 0xfe, 0xe4, 0x00, 0x27,
13414 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18, 0xfe, 0xf1, 0x18, 0xfe, 12488 0xfe, 0xa8, 0x03, 0x1c, 0x34, 0x1d, 0xfe, 0xb8, 0x03, 0x01, 0x4b, 0xfe,
13415 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe, 0x14, 0x59, 0xfe, 0x95, 12489 0x06, 0xf0, 0xfe, 0xc8,
13416 0x59, 0x1c, 0x85, 0xfe, 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0, 0xfe, 0xf0, 0x08, 0xb5, 12490 0x03, 0x95, 0x86, 0xfe, 0x0a, 0xf0, 0xfe, 0x8a, 0x06, 0x02, 0x24, 0x03,
13417 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18, 0x0b, 0xb6, 0xfe, 0xbf, 12491 0x70, 0x28, 0x17, 0xfe,
13418 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xc2, 0xfe, 0xd2, 12492 0xfa, 0x04, 0x15, 0x6d, 0x01, 0x36, 0x7b, 0xfe, 0x6a, 0x02, 0x02, 0xd8,
13419 0xf0, 0x85, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e, 0x06, 0x17, 0x85, 0xc5, 12493 0xf9, 0x2c, 0x99, 0x19,
13420 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15, 0x9d, 0x01, 0x36, 0x10, 12494 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c,
13421 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10, 0x80, 0x02, 0x65, 0xfe, 0x98, 0x80, 0xfe, 0x19, 12495 0x74, 0x01, 0xaf, 0x8c,
13422 0xe4, 0x0a, 0xfe, 0x1a, 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18, 0xfe, 0x44, 0x54, 0xbe, 12496 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x17, 0xda, 0x09, 0xd1, 0x01, 0x0e,
13423 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0x08, 0x05, 12497 0x8d, 0x51, 0x64, 0x79,
13424 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f, 0x14, 0x40, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x6c, 12498 0x2a, 0x03, 0x70, 0x28, 0xfe, 0x10, 0x12, 0x15, 0x6d, 0x01, 0x36, 0x7b,
13425 0x18, 0xfe, 0xed, 0x18, 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f, 0x3b, 0x40, 0x03, 0x49, 12499 0xfe, 0x6a, 0x02, 0x02,
13426 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18, 0x8f, 0xfe, 0xe3, 0x54, 12500 0xd8, 0xc7, 0x81, 0xc8, 0x83, 0x1c, 0x24, 0x27, 0xfe, 0x40, 0x04, 0x1d,
13427 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0xfe, 0x37, 0xf0, 0xfe, 0xda, 0x09, 0xfe, 0x8b, 12501 0xfe, 0x3c, 0x04, 0x3b,
13428 0xf0, 0xfe, 0x60, 0x09, 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa, 0x0a, 0x3a, 0x49, 0x3b, 12502 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x4e, 0x12, 0x2d, 0xff, 0x02,
13429 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00, 0xad, 0xfe, 0x01, 0x59, 12503 0x00, 0x10, 0x01, 0x0b,
13430 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a, 0xfe, 0x24, 0x0a, 0x3a, 0x49, 0x8f, 0xfe, 0xe3, 12504 0x1d, 0xfe, 0xe4, 0x04, 0x2d, 0x01, 0x0b, 0x1d, 0x24, 0x33, 0x31, 0xde,
13431 0x54, 0x57, 0x49, 0x7d, 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02, 0x4a, 0x3a, 0x49, 0x3b, 12505 0xfe, 0x4c, 0x44, 0xfe,
13432 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63, 0x02, 0x4a, 0x08, 0x05, 12506 0x4c, 0x12, 0x51, 0xfe, 0x44, 0x48, 0x0f, 0x6f, 0xfe, 0x4c, 0x54, 0x6b,
13433 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe, 0x66, 0x13, 0x22, 0x62, 0xb7, 0xfe, 0x03, 0xa1, 12507 0xda, 0x4f, 0x79, 0x2a,
13434 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91, 0xfe, 0x86, 0x91, 0x6a, 12508 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x62, 0x13, 0x08, 0x05, 0x1b,
13435 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29, 0x61, 0x0c, 0x7f, 0x14, 12509 0xfe, 0x2a, 0x13, 0x32,
13436 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8, 0x6a, 0x2a, 0x13, 0x62, 0x9b, 0x2e, 0x9c, 0x3c, 12510 0x07, 0x82, 0xfe, 0x52, 0x13, 0xfe, 0x20, 0x10, 0x0f, 0x6f, 0xfe, 0x4c,
13437 0x3a, 0x3f, 0x3b, 0x40, 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0x01, 0xef, 12511 0x54, 0x6b, 0xda, 0xfe,
13438 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40, 0xe4, 0x08, 0x05, 0x1f, 12512 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x40, 0x13, 0x08, 0x05, 0x1b, 0xfe,
13439 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0x03, 0x5e, 0x29, 0x5f, 12513 0x08, 0x13, 0x32, 0x07,
13440 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe, 0xf4, 0x09, 0x08, 0x05, 12514 0x82, 0xfe, 0x30, 0x13, 0x08, 0x05, 0x1b, 0xfe, 0x1c, 0x12, 0x15, 0x9d,
13441 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19, 0x81, 0x50, 0xfe, 0x10, 12515 0x08, 0x05, 0x06, 0x4d,
13442 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32, 0x07, 0xa6, 0x17, 0xfe, 0x08, 0x09, 0x12, 0xa6, 12516 0x15, 0xfe, 0x0d, 0x00, 0x01, 0x36, 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24,
13443 0x08, 0x05, 0x0a, 0xfe, 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe, 0x08, 0x09, 0xfe, 0x0c, 12517 0x2d, 0x12, 0xfe, 0xe6,
13444 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7, 0x08, 0x05, 0x0a, 0xfe, 12518 0x00, 0xfe, 0x1c, 0x90, 0xfe, 0x40, 0x5c, 0x04, 0x15, 0x9d, 0x01, 0x36,
13445 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xf4, 0xc2, 0xfe, 0xd1, 0xf0, 0xe2, 0x15, 0x7e, 12519 0x02, 0x2b, 0xfe, 0x42,
13446 0x01, 0x36, 0x10, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19, 0x57, 0x3d, 0xfe, 0xed, 12520 0x5b, 0x99, 0x19, 0xfe, 0x46, 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57,
13447 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe, 0x00, 0xff, 0x35, 0xfe, 12521 0xfe, 0x87, 0x80, 0xfe,
13448 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6, 0x0b, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x8a, 0x03, 12522 0x31, 0xe4, 0x5b, 0x08, 0x05, 0x0a, 0xfe, 0x84, 0x13, 0xfe, 0x20, 0x80,
13449 0xd2, 0x1e, 0x06, 0xfe, 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65, 0xfe, 0xd1, 0xf0, 0xfe, 12523 0x07, 0x19, 0xfe, 0x7c,
13450 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42, 0x10, 0xfe, 0xce, 0xf0, 12524 0x12, 0x53, 0x05, 0x06, 0xfe, 0x6c, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x28,
13451 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xca, 0x0b, 0x10, 0xfe, 0x22, 0x00, 12525 0x17, 0xfe, 0x90, 0x05,
13452 0x02, 0x65, 0xfe, 0xcb, 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00, 0x02, 0x65, 0xfe, 0xd0, 12526 0xfe, 0x31, 0xe4, 0x5a, 0x53, 0x05, 0x0a, 0xfe, 0x56, 0x13, 0x03, 0xfe,
13453 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea, 0x0b, 0x10, 0x58, 0xfe, 12527 0xa0, 0x00, 0x28, 0xfe,
13454 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05, 0x1f, 0x4d, 0x10, 0xfe, 0x12, 0x00, 0x2c, 0x0f, 12528 0x4e, 0x12, 0x67, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x48, 0x05, 0x1c,
13455 0xfe, 0x4e, 0x11, 0x27, 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14, 0x0c, 0xbc, 0x17, 0x34, 12529 0x34, 0xfe, 0x89, 0x48,
13456 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20, 0x0c, 0x1c, 0x34, 0x94, 12530 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x56, 0x05, 0x26, 0xfe, 0xa8, 0x05,
13457 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6, 0xdc, 0x02, 0x24, 0x01, 0x4b, 0xfe, 0xdb, 0x10, 12531 0x12, 0xfe, 0xe3, 0x00,
13458 0x12, 0xfe, 0xe8, 0x00, 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe, 0x89, 0xf0, 0x24, 0x33, 12532 0x21, 0x53, 0xfe, 0x4a, 0xf0, 0xfe, 0x76, 0x05, 0xfe, 0x49, 0xf0, 0xfe,
13459 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24, 0x33, 0x31, 0xdf, 0xbc, 12533 0x70, 0x05, 0x88, 0x25,
13460 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c, 0x06, 0xfe, 0x81, 0x49, 0x17, 0xfe, 0x2c, 0x0d, 12534 0xfe, 0x21, 0x00, 0xab, 0x25, 0xfe, 0x22, 0x00, 0xaa, 0x25, 0x58, 0xfe,
13461 0x08, 0x05, 0x0a, 0xfe, 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54, 0x12, 0x55, 0xfe, 0x28, 12535 0x09, 0x48, 0xff, 0x02,
13462 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66, 0x44, 0xfe, 0x28, 0x00, 12536 0x00, 0x10, 0x27, 0xfe, 0x86, 0x05, 0x26, 0xfe, 0xa8, 0x05, 0xfe, 0xe2,
13463 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09, 0xa4, 0x01, 0xfe, 0x26, 0x0f, 0x64, 0x12, 0x2f, 12537 0x08, 0x53, 0x05, 0xcb,
13464 0x01, 0x73, 0x02, 0x2b, 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44, 0x0a, 0xfe, 0xb4, 0x10, 12538 0x4d, 0x01, 0xb0, 0x25, 0x06, 0x13, 0xd3, 0x39, 0xfe, 0x27, 0x01, 0x08,
13465 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82, 0xfe, 0x34, 0x46, 0xac, 12539 0x05, 0x1b, 0xfe, 0x22,
13466 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96, 0x10, 0x08, 0x54, 0x0a, 0x37, 0x01, 0xf5, 0x01, 12540 0x12, 0x41, 0x01, 0xb2, 0x15, 0x9d, 0x08, 0x05, 0x06, 0x4d, 0x15, 0xfe,
13467 0xf6, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02, 0xfe, 0x2e, 0x03, 0x08, 12541 0x0d, 0x00, 0x01, 0x36,
13468 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05, 0x1a, 0xfe, 0x58, 0x12, 12542 0x7b, 0xfe, 0x64, 0x0d, 0x02, 0x24, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0xeb,
13469 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x50, 0x0d, 0xfe, 12543 0x03, 0x5c, 0x28, 0xfe,
13470 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37, 0xfe, 0xa9, 0x10, 0x10, 12544 0x36, 0x13, 0x41, 0x01, 0xb2, 0x26, 0xfe, 0x18, 0x06, 0x09, 0x06, 0x53,
13471 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10, 0xfe, 0x13, 0x00, 0xfe, 12545 0x05, 0x1f, 0xfe, 0x02,
13472 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41, 0x00, 0xaa, 0x10, 0xfe, 0x24, 0x00, 0x8c, 0xb5, 12546 0x12, 0x50, 0x01, 0xfe, 0x9e, 0x15, 0x1d, 0xfe, 0x0e, 0x06, 0x12, 0xa5,
13473 0xb6, 0x74, 0x03, 0x70, 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a, 0xfe, 0x9d, 0x41, 0xfe, 12547 0x01, 0x4b, 0x12, 0xfe,
13474 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0, 0xb4, 0x15, 0xfe, 0x31, 12548 0xe5, 0x00, 0x03, 0x5c, 0xc1, 0x0c, 0x5c, 0x03, 0xcd, 0x28, 0xfe, 0x62,
13475 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02, 0xd7, 0x42, 0xfe, 0x06, 0xec, 0xd0, 0xfc, 0x44, 12549 0x12, 0x03, 0x45, 0x28,
13476 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47, 0x4b, 0x91, 0xfe, 0x75, 12550 0xfe, 0x5a, 0x13, 0x01, 0xfe, 0x0c, 0x19, 0x01, 0xfe, 0x76, 0x19, 0xfe,
13477 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x44, 0x48, 12551 0x43, 0x48, 0xc4, 0xcc,
13478 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09, 0x46, 0x01, 0x0e, 0x41, 0xfe, 0x41, 0x58, 0x09, 12552 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0x8b, 0xc4,
13479 0xa4, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe, 0x2e, 0x03, 0x09, 0x5d, 12553 0x6e, 0x41, 0x01, 0xb2,
13480 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0xce, 0x47, 0xfe, 0xad, 12554 0x26, 0xfe, 0x82, 0x06, 0x53, 0x05, 0x1a, 0xe9, 0x91, 0x09, 0x59, 0x01,
13481 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x9e, 0x12, 0x21, 0x13, 0x59, 0x13, 0x9f, 0x13, 12555 0xfe, 0xcc, 0x15, 0x1d,
13482 0xd5, 0x22, 0x2f, 0x41, 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe, 0xe0, 0x0e, 0x0f, 0x06, 12556 0xfe, 0x78, 0x06, 0x12, 0xa5, 0x01, 0x4b, 0x12, 0xfe, 0xe5, 0x00, 0x03,
13483 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe, 0x3a, 0x01, 0x56, 0xfe, 12557 0x45, 0xc1, 0x0c, 0x45,
13484 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00, 0x66, 0xfe, 0x04, 0xec, 0x20, 0x4f, 0xfe, 0x05, 12558 0x18, 0x06, 0x01, 0xb2, 0xfa, 0x76, 0x74, 0x01, 0xaf, 0x8c, 0x12, 0xfe,
13485 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe, 0x48, 0xf4, 0x0d, 0xfe, 12559 0xe2, 0x00, 0x27, 0xdb,
13486 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13, 0x15, 0x1a, 0x39, 0xa0, 12560 0x1c, 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0xb6, 0x06, 0x94, 0xfe, 0x6c, 0x07,
13487 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x1e, 0xfe, 0xf0, 0xff, 0x0c, 0xfe, 0x60, 0x01, 12561 0xfe, 0x06, 0xf0, 0xfe,
13488 0x03, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25, 0x06, 0x13, 0x2f, 0x12, 12562 0x74, 0x07, 0x95, 0x86, 0x02, 0x24, 0x08, 0x05, 0x0a, 0xfe, 0x2e, 0x12,
13489 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12, 0x22, 0x9f, 0xb7, 0x13, 12563 0x16, 0x19, 0x01, 0x0b,
13490 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24, 0x1c, 0x15, 0x19, 0x39, 0xa0, 0xb4, 0xfe, 0xd9, 12564 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01, 0x0b,
13491 0x10, 0xc3, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xc3, 0xfe, 0x03, 0xdc, 12565 0xfe, 0x99, 0xa4, 0x01,
13492 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21, 0xfe, 0x00, 0xcc, 0x04, 12566 0x0b, 0x16, 0x00, 0x02, 0xfe, 0x42, 0x08, 0x68, 0x05, 0x1a, 0xfe, 0x38,
13493 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05, 0x58, 0xfe, 0x22, 0x13, 0xfe, 0x1c, 0x80, 0x07, 12567 0x12, 0x08, 0x05, 0x1a,
13494 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae, 0xfe, 0x0c, 0x90, 0xfe, 12568 0xfe, 0x30, 0x13, 0x16, 0xfe, 0x1b, 0x00, 0x01, 0x0b, 0x16, 0x00, 0x01,
13495 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x0a, 0xfe, 0x3c, 0x50, 12569 0x0b, 0x16, 0x00, 0x01,
13496 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f, 0xad, 0x01, 0xfe, 0xb4, 0x16, 0x08, 0x05, 0x1b, 12570 0x0b, 0x16, 0x00, 0x01, 0x0b, 0x16, 0x06, 0x01, 0x0b, 0x16, 0x00, 0x02,
13497 0x4e, 0x01, 0xf5, 0x01, 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58, 0xfe, 0x2c, 0x13, 0x01, 12571 0xe2, 0x6c, 0x58, 0xbe,
13498 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90, 0x0c, 0xfe, 0x64, 0x01, 12572 0x50, 0xfe, 0x9a, 0x81, 0x55, 0x1b, 0x7a, 0xfe, 0x42, 0x07, 0x09, 0x1b,
13499 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe, 0x12, 0x12, 0xfe, 0x03, 0x80, 0x8d, 0xfe, 0x01, 12573 0xfe, 0x09, 0x6f, 0xba,
13500 0xec, 0x20, 0xfe, 0x80, 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64, 0x22, 0x20, 0xfb, 0x79, 12574 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x69, 0x6d, 0x8b, 0x6c, 0x7f, 0x27,
13501 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 0xae, 0x00, 12575 0xfe, 0x54, 0x07, 0x1c,
13502 12576 0x34, 0xfe, 0x0a, 0xf0, 0xfe, 0x42, 0x07, 0x95, 0x86, 0x94, 0xfe, 0x6c,
13503 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 0xfe, 0x09, 12577 0x07, 0x02, 0x24, 0x01,
13504 0x58, 0xfe, 0x0a, 0x1c, 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c, 0x45, 0x0f, 0x46, 0x52, 12578 0x4b, 0x02, 0xdb, 0x16, 0x1f, 0x02, 0xdb, 0xfe, 0x9c, 0xf7, 0xdc, 0xfe,
13505 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc, 0x0f, 0x44, 0x11, 0x0f, 12579 0x2c, 0x90, 0xfe, 0xae,
13506 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xe4, 0x25, 0x11, 0x13, 0x20, 12580 0x90, 0x56, 0xfe, 0xda, 0x07, 0x0c, 0x60, 0x14, 0x61, 0x08, 0x54, 0x5a,
13507 0x7c, 0x6f, 0x4f, 0x22, 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 12581 0x37, 0x22, 0x20, 0x07,
13508 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x04, 0x42, 12582 0x11, 0xfe, 0x0e, 0x12, 0x8d, 0xfe, 0x80, 0x80, 0x39, 0x20, 0x6a, 0x2a,
13509 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x04, 0x01, 12583 0xfe, 0x06, 0x10, 0xfe,
13510 0xb0, 0x7c, 0x6f, 0x4f, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0x32, 0x07, 0x2f, 12584 0x83, 0xe7, 0xfe, 0x48, 0x00, 0xab, 0xfe, 0x03, 0x40, 0x08, 0x54, 0x5b,
13511 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 12585 0x37, 0x01, 0xb3, 0xb8,
13512 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 12586 0xfe, 0x1f, 0x40, 0x13, 0x62, 0x01, 0xef, 0xfe, 0x08, 0x50, 0xfe, 0x8a,
13513 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07, 0x82, 0x4e, 0xfe, 0x14, 12587 0x50, 0xfe, 0x44, 0x51,
13514 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d, 0xfe, 0x01, 0xec, 0xa2, 12588 0xfe, 0xc6, 0x51, 0x88, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90, 0x0c, 0x5e,
13515 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1a, 0x79, 0x2a, 0x01, 0xe3, 0xfe, 12589 0x14, 0x5f, 0xfe, 0x0c,
13516 0xdd, 0x10, 0x2c, 0xc7, 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a, 0xfe, 0x48, 0x12, 0x07, 12590 0x90, 0xfe, 0x8e, 0x90, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x0c, 0x3d,
13517 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17, 0xfe, 0x32, 0x12, 0x07, 12591 0x14, 0x3e, 0xfe, 0x4a,
13518 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17, 0xfe, 0x9c, 0x12, 0x07, 0x1f, 0xfe, 0x12, 0x12, 12592 0x10, 0x08, 0x05, 0x5a, 0xfe, 0x2a, 0x12, 0xfe, 0x2c, 0x90, 0xfe, 0xae,
13519 0x07, 0x00, 0x17, 0x24, 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b, 0x94, 0x4b, 0x04, 0x2d, 12593 0x90, 0x0c, 0x60, 0x14,
13520 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d, 0x32, 0x07, 0xa6, 0xfe, 12594 0x61, 0x08, 0x05, 0x5b, 0x8b, 0x01, 0xb3, 0xfe, 0x1f, 0x80, 0x13, 0x62,
13521 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe, 0xf0, 0x11, 0x08, 0x05, 0x5a, 0xfe, 0x72, 0x12, 12595 0xfe, 0x44, 0x90, 0xfe,
13522 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62, 0xfe, 0x26, 0x13, 0x03, 12596 0xc6, 0x90, 0x0c, 0x3f, 0x14, 0x40, 0xfe, 0x08, 0x90, 0xfe, 0x8a, 0x90,
13523 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 12597 0x0c, 0x5e, 0x14, 0x5f,
13524 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01, 0xef, 0x9b, 0x2e, 0x9c, 0x3c, 0xfe, 0x04, 0x55, 12598 0xfe, 0x40, 0x90, 0xfe, 0xc2, 0x90, 0x0c, 0x3d, 0x14, 0x3e, 0x0c, 0x2e,
13525 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe, 0x91, 0x10, 0x03, 0x3f, 12599 0x14, 0x3c, 0x21, 0x0c,
13526 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40, 0x88, 0x9b, 0x2e, 0x9c, 12600 0x49, 0x0c, 0x63, 0x08, 0x54, 0x1f, 0x37, 0x2c, 0x0f, 0xfe, 0x4e, 0x11,
13527 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x0c, 0x5e, 0x14, 12601 0x27, 0xdd, 0xfe, 0x9e,
13528 0x5f, 0x08, 0x05, 0x5a, 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40, 0x03, 0x60, 0x29, 0x61, 12602 0xf0, 0xfe, 0x76, 0x08, 0xbc, 0x17, 0x34, 0x2c, 0x77, 0xe6, 0xc5, 0xfe,
13529 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50, 12603 0x9a, 0x08, 0xc6, 0xfe,
13530 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x3d, 0x29, 0x3e, 0xfe, 0x40, 12604 0xb8, 0x08, 0x94, 0xfe, 0x8e, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x94, 0x08,
13531 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1d, 12605 0x95, 0x86, 0x02, 0x24,
13532 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23, 0x72, 0x01, 0xaf, 0x1e, 12606 0x01, 0x4b, 0xfe, 0xc9, 0x10, 0x16, 0x1f, 0xfe, 0xc9, 0x10, 0x68, 0x05,
13533 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a, 0x3d, 0x3b, 0x3e, 0xfe, 0x0a, 0x55, 0x35, 0xfe, 12607 0x06, 0xfe, 0x10, 0x12,
13534 0x8b, 0x55, 0x57, 0x3d, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x02, 0x72, 0xfe, 0x19, 12608 0x68, 0x05, 0x0a, 0x4e, 0x08, 0x05, 0x0a, 0xfe, 0x90, 0x12, 0xfe, 0x2e,
13535 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 0xe8, 0x33, 0x31, 12609 0x1c, 0x02, 0xfe, 0x18,
13536 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a, 0x4d, 0x02, 0x4c, 0x01, 0x0b, 0x1c, 0x34, 0x1d, 12610 0x0b, 0x68, 0x05, 0x06, 0x4e, 0x68, 0x05, 0x0a, 0xfe, 0x7a, 0x12, 0xfe,
13537 0xe8, 0x33, 0x31, 0xdf, 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8, 0x33, 0x31, 0xfe, 0xe8, 12611 0x2c, 0x1c, 0xfe, 0xaa,
13538 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53, 0x05, 0x1f, 0x35, 0xa9, 12612 0xf0, 0xfe, 0xd2, 0x09, 0xfe, 0xac, 0xf0, 0xfe, 0x00, 0x09, 0x02, 0xfe,
13539 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06, 0x7c, 0x43, 0xfe, 0xda, 0x14, 0x01, 0xaf, 0x8c, 12613 0xde, 0x09, 0xfe, 0xb7,
13540 0xfe, 0x4b, 0x45, 0xee, 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a, 0x03, 0x45, 0x28, 0x35, 12614 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0x02, 0xf6, 0x1a, 0x50, 0xfe, 0x70, 0x18,
13541 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17, 0x03, 0x5c, 0xc1, 0x0c, 12615 0xfe, 0xf1, 0x18, 0xfe,
13542 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0x9e, 0x15, 0x02, 0x89, 0x01, 0x0b, 0x1c, 12616 0x40, 0x55, 0xfe, 0xe1, 0x55, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0xfe,
13543 0x34, 0x1d, 0x4c, 0x33, 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1, 0xfe, 0x42, 0x58, 0xf1, 12617 0x14, 0x59, 0xfe, 0x95,
13544 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a, 0xf4, 0x06, 0xea, 0x32, 12618 0x59, 0x1c, 0x85, 0xfe, 0x8c, 0xf0, 0xfe, 0xfc, 0x08, 0xfe, 0xac, 0xf0,
13545 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 12619 0xfe, 0xf0, 0x08, 0xb5,
13546 0x01, 0xfe, 0xcc, 0x15, 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13, 0x26, 0xfe, 0xd4, 0x13, 12620 0xfe, 0xcb, 0x10, 0xfe, 0xad, 0xf0, 0xfe, 0x0c, 0x09, 0x02, 0xfe, 0x18,
13547 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0, 0x13, 0x1c, 0xfe, 0xd0, 12621 0x0b, 0xb6, 0xfe, 0xbf,
13548 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01, 0x0b, 0xfe, 0xd5, 0x10, 0x0f, 0x71, 0xff, 0x02, 12622 0x10, 0xfe, 0x2b, 0xf0, 0x85, 0xf4, 0x1e, 0xfe, 0x00, 0xfe, 0xfe, 0x1c,
13549 0x00, 0x57, 0x52, 0x93, 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 0x0f, 12623 0x12, 0xc2, 0xfe, 0xd2,
13550 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x04, 12624 0xf0, 0x85, 0xfe, 0x76, 0x18, 0x1e, 0x19, 0x17, 0x85, 0x03, 0xd2, 0x1e,
13551 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x04, 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 12625 0x06, 0x17, 0x85, 0xc5,
13552 0x93, 0xfe, 0x0b, 0x58, 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01, 0x87, 0x04, 0xfe, 0x03, 12626 0x4a, 0xc6, 0x4a, 0xb5, 0xb6, 0xfe, 0x89, 0x10, 0x74, 0x67, 0x2d, 0x15,
13553 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52, 0xfe, 0x00, 0x7d, 0xfe, 12627 0x9d, 0x01, 0x36, 0x10,
13554 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x6a, 0x2a, 0x0c, 0x5e, 0x14, 0x5f, 0x57, 0x3f, 12628 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x65, 0x10, 0x80, 0x02, 0x65, 0xfe,
13555 0x7d, 0x40, 0x04, 0xdd, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x8d, 0x04, 0x01, 12629 0x98, 0x80, 0xfe, 0x19,
13556 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33, 12630 0xe4, 0x0a, 0xfe, 0x1a, 0x12, 0x51, 0xfe, 0x19, 0x82, 0xfe, 0x6c, 0x18,
13557 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33, 0x31, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 12631 0xfe, 0x44, 0x54, 0xbe,
13558 0x03, 0xcd, 0x28, 0xfe, 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13, 0x21, 0x69, 0x1a, 0xee, 12632 0xfe, 0x19, 0x81, 0xfe, 0x74, 0x18, 0x8f, 0x90, 0x17, 0xfe, 0xce, 0x08,
13559 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c, 0x30, 0xfe, 0x78, 0x10, 12633 0x02, 0x4a, 0x08, 0x05,
13560 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83, 0x55, 0x69, 0x19, 0xae, 0x98, 0xfe, 0x30, 0x00, 12634 0x5a, 0xec, 0x03, 0x2e, 0x29, 0x3c, 0x0c, 0x3f, 0x14, 0x40, 0x9b, 0x2e,
13561 0x96, 0xf2, 0x18, 0x6d, 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed, 0x98, 0xfe, 0x64, 0x00, 12635 0x9c, 0x3c, 0xfe, 0x6c,
13562 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28, 0x10, 0x69, 0x06, 0xfe, 12636 0x18, 0xfe, 0xed, 0x18, 0xfe, 0x44, 0x54, 0xfe, 0xe5, 0x54, 0x3a, 0x3f,
13563 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2, 0x09, 0xfe, 0xc8, 0x00, 0x18, 0x59, 0x0f, 0x06, 12637 0x3b, 0x40, 0x03, 0x49,
13564 0x88, 0x98, 0xfe, 0x90, 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe, 0x43, 0xf4, 0x9f, 0xfe, 12638 0x29, 0x63, 0x8f, 0xfe, 0xe3, 0x54, 0xfe, 0x74, 0x18, 0xfe, 0xf5, 0x18,
13565 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4, 0x9e, 0xfe, 0xf3, 0x10, 12639 0x8f, 0xfe, 0xe3, 0x54,
13566 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e, 0x43, 0xec, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 12640 0x90, 0xc0, 0x56, 0xfe, 0xce, 0x08, 0x02, 0x4a, 0xfe, 0x37, 0xf0, 0xfe,
13567 0x6e, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00, 0x17, 0xfe, 0x4d, 0xe4, 12641 0xda, 0x09, 0xfe, 0x8b,
13568 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d, 0xf4, 0x00, 0xe9, 0x91, 12642 0xf0, 0xfe, 0x60, 0x09, 0x02, 0x4a, 0x08, 0x05, 0x0a, 0x23, 0xfe, 0xfa,
13569 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x04, 0x51, 0x0f, 0x0a, 0x04, 0x16, 0x06, 0x01, 12643 0x0a, 0x3a, 0x49, 0x3b,
13570 0x0b, 0x26, 0xf3, 0x16, 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01, 0x0b, 0x26, 0xf3, 0x76, 12644 0x63, 0x56, 0xfe, 0x3e, 0x0a, 0x0f, 0xfe, 0xc0, 0x07, 0x41, 0x98, 0x00,
13571 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0x16, 0x19, 0x01, 0x0b, 12645 0xad, 0xfe, 0x01, 0x59,
13572 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x26, 0xb1, 0x76, 12646 0xfe, 0x52, 0xf0, 0xfe, 0x0c, 0x0a, 0x8f, 0x7a, 0xfe, 0x24, 0x0a, 0x3a,
13573 0xfe, 0x89, 0x4a, 0x01, 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06, 0xfe, 0x48, 0x13, 0xb8, 12647 0x49, 0x8f, 0xfe, 0xe3,
13574 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 12648 0x54, 0x57, 0x49, 0x7d, 0x63, 0xfe, 0x14, 0x58, 0xfe, 0x95, 0x58, 0x02,
13575 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x2e, 0x16, 0x32, 0x07, 0xfe, 0xe3, 0x00, 12649 0x4a, 0x3a, 0x49, 0x3b,
13576 0xfe, 0x20, 0x13, 0x1d, 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b, 0x22, 0xd4, 0x07, 0x06, 12650 0x63, 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0xbe, 0x57, 0x49, 0x57, 0x63,
13577 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e, 0x07, 0x11, 0xae, 0x09, 12651 0x02, 0x4a, 0x08, 0x05,
13578 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x84, 0x01, 0x0e, 0x8e, 0xfe, 0x80, 12652 0x5a, 0xfe, 0x82, 0x12, 0x08, 0x05, 0x1f, 0xfe, 0x66, 0x13, 0x22, 0x62,
13579 0xe7, 0x11, 0x07, 0x11, 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04, 0x09, 0x48, 0x01, 0x0e, 12653 0xb7, 0xfe, 0x03, 0xa1,
13580 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x4c, 12654 0xfe, 0x83, 0x80, 0xfe, 0xc8, 0x44, 0xfe, 0x2e, 0x13, 0xfe, 0x04, 0x91,
13581 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 0x09, 0x5d, 0x01, 0x87, 12655 0xfe, 0x86, 0x91, 0x6a,
13582 0x04, 0x18, 0x11, 0x75, 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x24, 12656 0x2a, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x56, 0xe0, 0x03, 0x60, 0x29,
13583 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4, 0x17, 0xad, 0x9a, 0x1b, 12657 0x61, 0x0c, 0x7f, 0x14,
13584 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04, 0xb9, 0x23, 0xfe, 0xde, 0x16, 0xfe, 0xda, 0x10, 12658 0x80, 0x57, 0x60, 0x7d, 0x61, 0x01, 0xb3, 0xb8, 0x6a, 0x2a, 0x13, 0x62,
13585 0x18, 0x11, 0x75, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe, 0x18, 0x58, 0x03, 0xfe, 12659 0x9b, 0x2e, 0x9c, 0x3c,
13586 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4, 0x06, 0xfe, 0x3c, 12660 0x3a, 0x3f, 0x3b, 0x40, 0x90, 0xc0, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05,
13587 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x1f, 0x97, 0xfe, 0x38, 0x17, 12661 0xfa, 0x3c, 0x01, 0xef,
13588 0xfe, 0xb6, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c, 0x10, 0x18, 0x11, 0x75, 12662 0xfe, 0x36, 0x10, 0x21, 0x0c, 0x7f, 0x0c, 0x80, 0x3a, 0x3f, 0x3b, 0x40,
13589 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x2e, 0x97, 0xfe, 0x5a, 12663 0xe4, 0x08, 0x05, 0x1f,
13590 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c, 0x1a, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 0xe7, 0x00, 12664 0x17, 0xe0, 0x3a, 0x3d, 0x3b, 0x3e, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37,
13591 0x04, 0xb9, 0x23, 0xfe, 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75, 0xfe, 0x30, 0xbc, 0xfe, 12665 0x03, 0x5e, 0x29, 0x5f,
13592 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0xcb, 0x97, 0xfe, 0x92, 12666 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 0x57, 0x49, 0x7d, 0x63, 0x02, 0xfe,
13593 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x7e, 0x17, 0xfe, 0x42, 0x10, 0xfe, 0x02, 12667 0xf4, 0x09, 0x08, 0x05,
13594 0xf6, 0x11, 0x75, 0xfe, 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe, 0x03, 0xa1, 0xfe, 0x1d, 12668 0x1f, 0x17, 0xe0, 0x08, 0x05, 0xfe, 0xf7, 0x00, 0x37, 0xbe, 0xfe, 0x19,
13595 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13, 0x9a, 0x5b, 0x41, 0xfe, 12669 0x81, 0x50, 0xfe, 0x10,
13596 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x11, 0xfe, 0x81, 0xe7, 0x11, 0x12, 0xfe, 0xdd, 12670 0x90, 0xfe, 0x92, 0x90, 0xfe, 0xd3, 0x10, 0x32, 0x07, 0xa6, 0x17, 0xfe,
13597 0x00, 0x6a, 0x2a, 0x04, 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8, 0x17, 0x15, 0x06, 0x39, 12671 0x08, 0x09, 0x12, 0xa6,
13598 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04, 0xfe, 0x7e, 0x18, 0x1e, 12672 0x08, 0x05, 0x0a, 0xfe, 0x14, 0x13, 0x03, 0x3d, 0x29, 0x3e, 0x56, 0xfe,
13599 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2, 0x1e, 0x06, 0xfe, 0xef, 0x12, 0xfe, 0xe1, 0x10, 12673 0x08, 0x09, 0xfe, 0x0c,
13600 0x7c, 0x6f, 0x4f, 0x32, 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42, 0x13, 0x42, 0x92, 0x09, 12674 0x58, 0xfe, 0x8d, 0x58, 0x02, 0x4a, 0x21, 0x41, 0xfe, 0x19, 0x80, 0xe7,
13601 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 12675 0x08, 0x05, 0x0a, 0xfe,
13602 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c, 12676 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 0xf4, 0xc2, 0xfe, 0xd1,
13603 0x01, 0x73, 0xfe, 0x16, 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14, 12677 0xf0, 0xe2, 0x15, 0x7e,
13604 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c, 0xe7, 0x0a, 0x10, 0xfe, 12678 0x01, 0x36, 0x10, 0xfe, 0x44, 0x00, 0xfe, 0x8e, 0x10, 0xfe, 0x6c, 0x19,
13605 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18, 0x06, 0x04, 0x42, 0x92, 0x08, 0x54, 0x1b, 0x37, 12679 0x57, 0x3d, 0xfe, 0xed,
13606 0x12, 0x2f, 0x01, 0x73, 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 0x3a, 0xce, 0x3b, 12680 0x19, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0xf4, 0x1e, 0xfe,
13607 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77, 0x13, 0xa3, 0x04, 0x09, 12681 0x00, 0xff, 0x35, 0xfe,
13608 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46, 0x01, 0x0e, 0xfe, 0x49, 0x44, 0x17, 0xfe, 0xe8, 12682 0x74, 0x10, 0xc2, 0xfe, 0xd2, 0xf0, 0xfe, 0xa6, 0x0b, 0xfe, 0x76, 0x18,
13609 0x18, 0x77, 0x78, 0x04, 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09, 0x5d, 0x01, 0xa8, 0x09, 12683 0x1e, 0x19, 0x8a, 0x03,
13610 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe, 0x1c, 0x19, 0x03, 0xfe, 12684 0xd2, 0x1e, 0x06, 0xfe, 0x08, 0x13, 0x10, 0xfe, 0x16, 0x00, 0x02, 0x65,
13611 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xc9, 0x6b, 0xfe, 0x2e, 0x19, 12685 0xfe, 0xd1, 0xf0, 0xfe,
13612 0x03, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4, 0xfe, 0x0b, 0x00, 0x6b, 12686 0xb8, 0x0b, 0x15, 0x7e, 0x01, 0x36, 0x10, 0xfe, 0x17, 0x00, 0xfe, 0x42,
13613 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe, 0x08, 0x10, 0x03, 0xfe, 12687 0x10, 0xfe, 0xce, 0xf0,
13614 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e, 0x45, 0xea, 0xba, 0xff, 0x04, 0x68, 0x54, 0xe7, 12688 0xfe, 0xbe, 0x0b, 0xfe, 0x3c, 0x10, 0xfe, 0xcd, 0xf0, 0xfe, 0xca, 0x0b,
13615 0x1e, 0x6e, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 0x00, 12689 0x10, 0xfe, 0x22, 0x00,
13616 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19, 0x04, 0x07, 0x7e, 0xfe, 12690 0x02, 0x65, 0xfe, 0xcb, 0xf0, 0xfe, 0xd6, 0x0b, 0x10, 0xfe, 0x24, 0x00,
13617 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10, 0x07, 0x1a, 0xfe, 0x5a, 12691 0x02, 0x65, 0xfe, 0xd0,
13618 0xf0, 0xfe, 0x92, 0x19, 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66, 0x25, 0x6d, 0xe5, 0x07, 12692 0xf0, 0xfe, 0xe0, 0x0b, 0x10, 0x9e, 0xe5, 0xfe, 0xcf, 0xf0, 0xfe, 0xea,
13619 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59, 0xa9, 0xb8, 0x04, 0x15, 12693 0x0b, 0x10, 0x58, 0xfe,
13620 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe, 0x81, 0x03, 0x83, 0xfe, 0x40, 0x5c, 0x04, 0x1c, 12694 0x10, 0x10, 0xfe, 0xcc, 0xf0, 0xe2, 0x68, 0x05, 0x1f, 0x4d, 0x10, 0xfe,
13621 0xf7, 0xfe, 0x14, 0xf0, 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b, 0xf7, 0xfe, 0x82, 0xf0, 12695 0x12, 0x00, 0x2c, 0x0f,
13622 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00, 12696 0xfe, 0x4e, 0x11, 0x27, 0xfe, 0x00, 0x0c, 0xfe, 0x9e, 0xf0, 0xfe, 0x14,
12697 0x0c, 0xbc, 0x17, 0x34,
12698 0x2c, 0x77, 0xe6, 0xc5, 0x24, 0xc6, 0x24, 0x2c, 0xfa, 0x27, 0xfe, 0x20,
12699 0x0c, 0x1c, 0x34, 0x94,
12700 0xfe, 0x3c, 0x0c, 0x95, 0x86, 0xc5, 0xdc, 0xc6, 0xdc, 0x02, 0x24, 0x01,
12701 0x4b, 0xfe, 0xdb, 0x10,
12702 0x12, 0xfe, 0xe8, 0x00, 0xb5, 0xb6, 0x74, 0xc7, 0x81, 0xc8, 0x83, 0xfe,
12703 0x89, 0xf0, 0x24, 0x33,
12704 0x31, 0xe1, 0xc7, 0x81, 0xc8, 0x83, 0x27, 0xfe, 0x66, 0x0c, 0x1d, 0x24,
12705 0x33, 0x31, 0xdf, 0xbc,
12706 0x4e, 0x10, 0xfe, 0x42, 0x00, 0x02, 0x65, 0x7c, 0x06, 0xfe, 0x81, 0x49,
12707 0x17, 0xfe, 0x2c, 0x0d,
12708 0x08, 0x05, 0x0a, 0xfe, 0x44, 0x13, 0x10, 0x00, 0x55, 0x0a, 0xfe, 0x54,
12709 0x12, 0x55, 0xfe, 0x28,
12710 0x00, 0x23, 0xfe, 0x9a, 0x0d, 0x09, 0x46, 0x01, 0x0e, 0x07, 0x00, 0x66,
12711 0x44, 0xfe, 0x28, 0x00,
12712 0xfe, 0xe2, 0x10, 0x01, 0xf5, 0x01, 0xf6, 0x09, 0xa4, 0x01, 0xfe, 0x26,
12713 0x0f, 0x64, 0x12, 0x2f,
12714 0x01, 0x73, 0x02, 0x2b, 0x10, 0xfe, 0x44, 0x00, 0x55, 0x0a, 0xe9, 0x44,
12715 0x0a, 0xfe, 0xb4, 0x10,
12716 0x01, 0xb0, 0x44, 0x0a, 0xfe, 0xaa, 0x10, 0x01, 0xb0, 0xfe, 0x19, 0x82,
12717 0xfe, 0x34, 0x46, 0xac,
12718 0x44, 0x0a, 0x10, 0xfe, 0x43, 0x00, 0xfe, 0x96, 0x10, 0x08, 0x54, 0x0a,
12719 0x37, 0x01, 0xf5, 0x01,
12720 0xf6, 0x64, 0x12, 0x2f, 0x01, 0x73, 0x99, 0x0a, 0x64, 0x42, 0x92, 0x02,
12721 0xfe, 0x2e, 0x03, 0x08,
12722 0x05, 0x0a, 0x8a, 0x44, 0x0a, 0x10, 0x00, 0xfe, 0x5c, 0x10, 0x68, 0x05,
12723 0x1a, 0xfe, 0x58, 0x12,
12724 0x08, 0x05, 0x1a, 0xfe, 0x50, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0,
12725 0xfe, 0x50, 0x0d, 0xfe,
12726 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x56, 0x0d, 0x08, 0x54, 0x1a, 0x37,
12727 0xfe, 0xa9, 0x10, 0x10,
12728 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0a, 0x50, 0xfe, 0x2e, 0x10, 0x10,
12729 0xfe, 0x13, 0x00, 0xfe,
12730 0x10, 0x10, 0x10, 0x6f, 0xab, 0x10, 0xfe, 0x41, 0x00, 0xaa, 0x10, 0xfe,
12731 0x24, 0x00, 0x8c, 0xb5,
12732 0xb6, 0x74, 0x03, 0x70, 0x28, 0x23, 0xd8, 0x50, 0xfe, 0x04, 0xe6, 0x1a,
12733 0xfe, 0x9d, 0x41, 0xfe,
12734 0x1c, 0x42, 0x64, 0x01, 0xe3, 0x02, 0x2b, 0xf8, 0x15, 0x0a, 0x39, 0xa0,
12735 0xb4, 0x15, 0xfe, 0x31,
12736 0x00, 0x39, 0xa2, 0x01, 0xfe, 0x48, 0x10, 0x02, 0xd7, 0x42, 0xfe, 0x06,
12737 0xec, 0xd0, 0xfc, 0x44,
12738 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe, 0x06, 0xea, 0xd0, 0xfe, 0x47,
12739 0x4b, 0x91, 0xfe, 0x75,
12740 0x57, 0x03, 0x5d, 0xfe, 0x98, 0x56, 0xfe, 0x38, 0x12, 0x09, 0x48, 0x01,
12741 0x0e, 0xfe, 0x44, 0x48,
12742 0x4f, 0x08, 0x05, 0x1b, 0xfe, 0x1a, 0x13, 0x09, 0x46, 0x01, 0x0e, 0x41,
12743 0xfe, 0x41, 0x58, 0x09,
12744 0xa4, 0x01, 0x0e, 0xfe, 0x49, 0x54, 0x96, 0xfe, 0x1e, 0x0e, 0x02, 0xfe,
12745 0x2e, 0x03, 0x09, 0x5d,
12746 0xfe, 0xee, 0x14, 0xfc, 0x44, 0x1b, 0xfe, 0xce, 0x45, 0x35, 0x42, 0xfe,
12747 0xce, 0x47, 0xfe, 0xad,
12748 0x13, 0x02, 0x2b, 0x22, 0x20, 0x07, 0x11, 0xfe, 0x9e, 0x12, 0x21, 0x13,
12749 0x59, 0x13, 0x9f, 0x13,
12750 0xd5, 0x22, 0x2f, 0x41, 0x39, 0x2f, 0xbc, 0xad, 0xfe, 0xbc, 0xf0, 0xfe,
12751 0xe0, 0x0e, 0x0f, 0x06,
12752 0x13, 0x59, 0x01, 0xfe, 0xda, 0x16, 0x03, 0xfe, 0x38, 0x01, 0x29, 0xfe,
12753 0x3a, 0x01, 0x56, 0xfe,
12754 0xe4, 0x0e, 0xfe, 0x02, 0xec, 0xd5, 0x69, 0x00, 0x66, 0xfe, 0x04, 0xec,
12755 0x20, 0x4f, 0xfe, 0x05,
12756 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x4a, 0x17, 0xfe, 0x08, 0x90, 0xfe,
12757 0x48, 0xf4, 0x0d, 0xfe,
12758 0x18, 0x13, 0xba, 0xfe, 0x02, 0xea, 0xd5, 0x69, 0x7e, 0xfe, 0xc5, 0x13,
12759 0x15, 0x1a, 0x39, 0xa0,
12760 0xb4, 0xfe, 0x2e, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x1e, 0xfe, 0xf0, 0xff,
12761 0x0c, 0xfe, 0x60, 0x01,
12762 0x03, 0xfe, 0x3a, 0x01, 0x0c, 0xfe, 0x62, 0x01, 0x43, 0x13, 0x20, 0x25,
12763 0x06, 0x13, 0x2f, 0x12,
12764 0x2f, 0x92, 0x0f, 0x06, 0x04, 0x21, 0x04, 0x22, 0x59, 0xfe, 0xf7, 0x12,
12765 0x22, 0x9f, 0xb7, 0x13,
12766 0x9f, 0x07, 0x7e, 0xfe, 0x71, 0x13, 0xfe, 0x24, 0x1c, 0x15, 0x19, 0x39,
12767 0xa0, 0xb4, 0xfe, 0xd9,
12768 0x10, 0xc3, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x04,
12769 0xc3, 0xfe, 0x03, 0xdc,
12770 0xfe, 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x04, 0xfe, 0x03, 0x57, 0xc3, 0x21,
12771 0xfe, 0x00, 0xcc, 0x04,
12772 0xfe, 0x03, 0x57, 0xc3, 0x78, 0x04, 0x08, 0x05, 0x58, 0xfe, 0x22, 0x13,
12773 0xfe, 0x1c, 0x80, 0x07,
12774 0x06, 0xfe, 0x1a, 0x13, 0xfe, 0x1e, 0x80, 0xed, 0xfe, 0x1d, 0x80, 0xae,
12775 0xfe, 0x0c, 0x90, 0xfe,
12776 0x0e, 0x13, 0xfe, 0x0e, 0x90, 0xac, 0xfe, 0x3c, 0x90, 0xfe, 0x30, 0xf4,
12777 0x0a, 0xfe, 0x3c, 0x50,
12778 0xaa, 0x01, 0xfe, 0x7a, 0x17, 0x32, 0x07, 0x2f, 0xad, 0x01, 0xfe, 0xb4,
12779 0x16, 0x08, 0x05, 0x1b,
12780 0x4e, 0x01, 0xf5, 0x01, 0xf6, 0x12, 0xfe, 0xe9, 0x00, 0x08, 0x05, 0x58,
12781 0xfe, 0x2c, 0x13, 0x01,
12782 0xfe, 0x0c, 0x17, 0xfe, 0x1e, 0x1c, 0xfe, 0x14, 0x90, 0xfe, 0x96, 0x90,
12783 0x0c, 0xfe, 0x64, 0x01,
12784 0x14, 0xfe, 0x66, 0x01, 0x08, 0x05, 0x5b, 0xfe, 0x12, 0x12, 0xfe, 0x03,
12785 0x80, 0x8d, 0xfe, 0x01,
12786 0xec, 0x20, 0xfe, 0x80, 0x40, 0x13, 0x20, 0x6a, 0x2a, 0x12, 0xcf, 0x64,
12787 0x22, 0x20, 0xfb, 0x79,
12788 0x20, 0x04, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58,
12789 0x03, 0xfe, 0xae, 0x00,
12790
12791 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe,
12792 0xb2, 0x00, 0xfe, 0x09,
12793 0x58, 0xfe, 0x0a, 0x1c, 0x25, 0x6e, 0x13, 0xd0, 0x21, 0x0c, 0x5c, 0x0c,
12794 0x45, 0x0f, 0x46, 0x52,
12795 0x50, 0x18, 0x1b, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xfe, 0xfc,
12796 0x0f, 0x44, 0x11, 0x0f,
12797 0x48, 0x52, 0x18, 0x58, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x23, 0xe4,
12798 0x25, 0x11, 0x13, 0x20,
12799 0x7c, 0x6f, 0x4f, 0x22, 0x20, 0xfb, 0x79, 0x20, 0x12, 0xcf, 0xfe, 0x14,
12800 0x56, 0xfe, 0xd6, 0xf0,
12801 0xfe, 0x26, 0x10, 0xf8, 0x74, 0xfe, 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe,
12802 0x18, 0x1c, 0x04, 0x42,
12803 0xfe, 0x0c, 0x14, 0xfc, 0xfe, 0x07, 0xe6, 0x1b, 0xfe, 0xce, 0x47, 0xfe,
12804 0xf5, 0x13, 0x04, 0x01,
12805 0xb0, 0x7c, 0x6f, 0x4f, 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42,
12806 0x13, 0x32, 0x07, 0x2f,
12807 0xfe, 0x34, 0x13, 0x09, 0x48, 0x01, 0x0e, 0xbb, 0xfe, 0x36, 0x12, 0xfe,
12808 0x41, 0x48, 0xfe, 0x45,
12809 0x48, 0x01, 0xf0, 0xfe, 0x00, 0xcc, 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78,
12810 0x07, 0x11, 0xac, 0x09,
12811 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x5c, 0x01, 0x73, 0xfe, 0x0e, 0x10, 0x07,
12812 0x82, 0x4e, 0xfe, 0x14,
12813 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x60, 0x10, 0x04, 0xfe, 0x44, 0x58, 0x8d,
12814 0xfe, 0x01, 0xec, 0xa2,
12815 0xfe, 0x9e, 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x1a, 0x79,
12816 0x2a, 0x01, 0xe3, 0xfe,
12817 0xdd, 0x10, 0x2c, 0xc7, 0x81, 0xc8, 0x83, 0x33, 0x31, 0xde, 0x07, 0x1a,
12818 0xfe, 0x48, 0x12, 0x07,
12819 0x0a, 0xfe, 0x56, 0x12, 0x07, 0x19, 0xfe, 0x30, 0x12, 0x07, 0xc9, 0x17,
12820 0xfe, 0x32, 0x12, 0x07,
12821 0xfe, 0x23, 0x00, 0x17, 0xeb, 0x07, 0x06, 0x17, 0xfe, 0x9c, 0x12, 0x07,
12822 0x1f, 0xfe, 0x12, 0x12,
12823 0x07, 0x00, 0x17, 0x24, 0x15, 0xc9, 0x01, 0x36, 0xa9, 0x2d, 0x01, 0x0b,
12824 0x94, 0x4b, 0x04, 0x2d,
12825 0xdd, 0x09, 0xd1, 0x01, 0xfe, 0x26, 0x0f, 0x12, 0x82, 0x02, 0x2b, 0x2d,
12826 0x32, 0x07, 0xa6, 0xfe,
12827 0xd9, 0x13, 0x3a, 0x3d, 0x3b, 0x3e, 0x56, 0xfe, 0xf0, 0x11, 0x08, 0x05,
12828 0x5a, 0xfe, 0x72, 0x12,
12829 0x9b, 0x2e, 0x9c, 0x3c, 0x90, 0xc0, 0x96, 0xfe, 0xba, 0x11, 0x22, 0x62,
12830 0xfe, 0x26, 0x13, 0x03,
12831 0x7f, 0x29, 0x80, 0x56, 0xfe, 0x76, 0x0d, 0x0c, 0x60, 0x14, 0x61, 0x21,
12832 0x0c, 0x7f, 0x0c, 0x80,
12833 0x01, 0xb3, 0x25, 0x6e, 0x77, 0x13, 0x62, 0x01, 0xef, 0x9b, 0x2e, 0x9c,
12834 0x3c, 0xfe, 0x04, 0x55,
12835 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 0x2e, 0xfe, 0x05, 0xfa, 0x3c, 0xfe,
12836 0x91, 0x10, 0x03, 0x3f,
12837 0x29, 0x40, 0xfe, 0x40, 0x56, 0xfe, 0xe1, 0x56, 0x0c, 0x3f, 0x14, 0x40,
12838 0x88, 0x9b, 0x2e, 0x9c,
12839 0x3c, 0x90, 0xc0, 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x00, 0x56, 0xfe, 0xa1,
12840 0x56, 0x0c, 0x5e, 0x14,
12841 0x5f, 0x08, 0x05, 0x5a, 0xfe, 0x1e, 0x12, 0x22, 0x62, 0xfe, 0x1f, 0x40,
12842 0x03, 0x60, 0x29, 0x61,
12843 0xfe, 0x2c, 0x50, 0xfe, 0xae, 0x50, 0x03, 0x3f, 0x29, 0x40, 0xfe, 0x44,
12844 0x50, 0xfe, 0xc6, 0x50,
12845 0x03, 0x5e, 0x29, 0x5f, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x3d,
12846 0x29, 0x3e, 0xfe, 0x40,
12847 0x50, 0xfe, 0xc2, 0x50, 0x02, 0x89, 0x25, 0x06, 0x13, 0xd4, 0x02, 0x72,
12848 0x2d, 0x01, 0x0b, 0x1d,
12849 0x4c, 0x33, 0x31, 0xde, 0x07, 0x06, 0x23, 0x4c, 0x32, 0x07, 0xa6, 0x23,
12850 0x72, 0x01, 0xaf, 0x1e,
12851 0x43, 0x17, 0x4c, 0x08, 0x05, 0x0a, 0xee, 0x3a, 0x3d, 0x3b, 0x3e, 0xfe,
12852 0x0a, 0x55, 0x35, 0xfe,
12853 0x8b, 0x55, 0x57, 0x3d, 0x7d, 0x3e, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51,
12854 0x02, 0x72, 0xfe, 0x19,
12855 0x81, 0xba, 0xfe, 0x19, 0x41, 0x02, 0x72, 0x2d, 0x01, 0x0b, 0x1c, 0x34,
12856 0x1d, 0xe8, 0x33, 0x31,
12857 0xe1, 0x55, 0x19, 0xfe, 0xa6, 0x12, 0x55, 0x0a, 0x4d, 0x02, 0x4c, 0x01,
12858 0x0b, 0x1c, 0x34, 0x1d,
12859 0xe8, 0x33, 0x31, 0xdf, 0x07, 0x19, 0x23, 0x4c, 0x01, 0x0b, 0x1d, 0xe8,
12860 0x33, 0x31, 0xfe, 0xe8,
12861 0x09, 0xfe, 0xc2, 0x49, 0x51, 0x03, 0xfe, 0x9c, 0x00, 0x28, 0x8a, 0x53,
12862 0x05, 0x1f, 0x35, 0xa9,
12863 0xfe, 0xbb, 0x45, 0x55, 0x00, 0x4e, 0x44, 0x06, 0x7c, 0x43, 0xfe, 0xda,
12864 0x14, 0x01, 0xaf, 0x8c,
12865 0xfe, 0x4b, 0x45, 0xee, 0x32, 0x07, 0xa5, 0xed, 0x03, 0xcd, 0x28, 0x8a,
12866 0x03, 0x45, 0x28, 0x35,
12867 0x67, 0x02, 0x72, 0xfe, 0xc0, 0x5d, 0xfe, 0xf8, 0x14, 0xfe, 0x03, 0x17,
12868 0x03, 0x5c, 0xc1, 0x0c,
12869 0x5c, 0x67, 0x2d, 0x01, 0x0b, 0x26, 0x89, 0x01, 0xfe, 0x9e, 0x15, 0x02,
12870 0x89, 0x01, 0x0b, 0x1c,
12871 0x34, 0x1d, 0x4c, 0x33, 0x31, 0xdf, 0x07, 0x06, 0x23, 0x4c, 0x01, 0xf1,
12872 0xfe, 0x42, 0x58, 0xf1,
12873 0xfe, 0xa4, 0x14, 0x8c, 0xfe, 0x4a, 0xf4, 0x0a, 0x17, 0x4c, 0xfe, 0x4a,
12874 0xf4, 0x06, 0xea, 0x32,
12875 0x07, 0xa5, 0x8b, 0x02, 0x72, 0x03, 0x45, 0xc1, 0x0c, 0x45, 0x67, 0x2d,
12876 0x01, 0x0b, 0x26, 0x89,
12877 0x01, 0xfe, 0xcc, 0x15, 0x02, 0x89, 0x0f, 0x06, 0x27, 0xfe, 0xbe, 0x13,
12878 0x26, 0xfe, 0xd4, 0x13,
12879 0x76, 0xfe, 0x89, 0x48, 0x01, 0x0b, 0x21, 0x76, 0x04, 0x7b, 0xfe, 0xd0,
12880 0x13, 0x1c, 0xfe, 0xd0,
12881 0x13, 0x1d, 0xfe, 0xbe, 0x13, 0x67, 0x2d, 0x01, 0x0b, 0xfe, 0xd5, 0x10,
12882 0x0f, 0x71, 0xff, 0x02,
12883 0x00, 0x57, 0x52, 0x93, 0x1e, 0xfe, 0xff, 0x7f, 0xfe, 0x30, 0x56, 0xfe,
12884 0x00, 0x5c, 0x04, 0x0f,
12885 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x1e, 0x43, 0xfe, 0x30, 0x56,
12886 0xfe, 0x00, 0x5c, 0x04,
12887 0x0f, 0x71, 0xff, 0x02, 0x00, 0x57, 0x52, 0x93, 0x04, 0x0f, 0x71, 0xff,
12888 0x02, 0x00, 0x57, 0x52,
12889 0x93, 0xfe, 0x0b, 0x58, 0x04, 0x09, 0x5c, 0x01, 0x87, 0x09, 0x45, 0x01,
12890 0x87, 0x04, 0xfe, 0x03,
12891 0xa1, 0x1e, 0x11, 0xff, 0x03, 0x00, 0x54, 0xfe, 0x00, 0xf4, 0x1f, 0x52,
12892 0xfe, 0x00, 0x7d, 0xfe,
12893 0x01, 0x7d, 0xfe, 0x02, 0x7d, 0xfe, 0x03, 0x7c, 0x6a, 0x2a, 0x0c, 0x5e,
12894 0x14, 0x5f, 0x57, 0x3f,
12895 0x7d, 0x40, 0x04, 0xdd, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83,
12896 0x5a, 0x8d, 0x04, 0x01,
12897 0xfe, 0x0c, 0x19, 0xfe, 0x42, 0x48, 0x50, 0x51, 0x91, 0x01, 0x0b, 0x1d,
12898 0xfe, 0x96, 0x15, 0x33,
12899 0x31, 0xe1, 0x01, 0x0b, 0x1d, 0xfe, 0x96, 0x15, 0x33, 0x31, 0xfe, 0xe8,
12900 0x0a, 0xfe, 0xc1, 0x59,
12901 0x03, 0xcd, 0x28, 0xfe, 0xcc, 0x12, 0x53, 0x05, 0x1a, 0xfe, 0xc4, 0x13,
12902 0x21, 0x69, 0x1a, 0xee,
12903 0x55, 0xca, 0x6b, 0xfe, 0xdc, 0x14, 0x4d, 0x0f, 0x06, 0x18, 0xca, 0x7c,
12904 0x30, 0xfe, 0x78, 0x10,
12905 0xff, 0x02, 0x83, 0x55, 0xab, 0xff, 0x02, 0x83, 0x55, 0x69, 0x19, 0xae,
12906 0x98, 0xfe, 0x30, 0x00,
12907 0x96, 0xf2, 0x18, 0x6d, 0x0f, 0x06, 0xfe, 0x56, 0x10, 0x69, 0x0a, 0xed,
12908 0x98, 0xfe, 0x64, 0x00,
12909 0x96, 0xf2, 0x09, 0xfe, 0x64, 0x00, 0x18, 0x9e, 0x0f, 0x06, 0xfe, 0x28,
12910 0x10, 0x69, 0x06, 0xfe,
12911 0x60, 0x13, 0x98, 0xfe, 0xc8, 0x00, 0x96, 0xf2, 0x09, 0xfe, 0xc8, 0x00,
12912 0x18, 0x59, 0x0f, 0x06,
12913 0x88, 0x98, 0xfe, 0x90, 0x01, 0x7a, 0xfe, 0x42, 0x15, 0x91, 0xe4, 0xfe,
12914 0x43, 0xf4, 0x9f, 0xfe,
12915 0x56, 0xf0, 0xfe, 0x54, 0x15, 0xfe, 0x04, 0xf4, 0x71, 0xfe, 0x43, 0xf4,
12916 0x9e, 0xfe, 0xf3, 0x10,
12917 0xfe, 0x40, 0x5c, 0x01, 0xfe, 0x16, 0x14, 0x1e, 0x43, 0xec, 0xfe, 0x00,
12918 0x17, 0xfe, 0x4d, 0xe4,
12919 0x6e, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0x6e, 0xfe, 0x1c, 0x10, 0xfe, 0x00,
12920 0x17, 0xfe, 0x4d, 0xe4,
12921 0xcc, 0x7a, 0xfe, 0x90, 0x15, 0xc4, 0xcc, 0x88, 0x51, 0x21, 0xfe, 0x4d,
12922 0xf4, 0x00, 0xe9, 0x91,
12923 0x0f, 0x06, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x04, 0x51, 0x0f, 0x0a,
12924 0x04, 0x16, 0x06, 0x01,
12925 0x0b, 0x26, 0xf3, 0x16, 0x0a, 0x01, 0x0b, 0x26, 0xf3, 0x16, 0x19, 0x01,
12926 0x0b, 0x26, 0xf3, 0x76,
12927 0xfe, 0x89, 0x49, 0x01, 0x0b, 0x04, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1,
12928 0x16, 0x19, 0x01, 0x0b,
12929 0x26, 0xb1, 0x16, 0x06, 0x01, 0x0b, 0x26, 0xb1, 0xfe, 0x89, 0x49, 0x01,
12930 0x0b, 0x26, 0xb1, 0x76,
12931 0xfe, 0x89, 0x4a, 0x01, 0x0b, 0x04, 0x51, 0x04, 0x22, 0xd3, 0x07, 0x06,
12932 0xfe, 0x48, 0x13, 0xb8,
12933 0x13, 0xd3, 0xfe, 0x49, 0xf4, 0x00, 0x4d, 0x76, 0xa9, 0x67, 0xfe, 0x01,
12934 0xec, 0xfe, 0x27, 0x01,
12935 0xfe, 0x89, 0x48, 0xff, 0x02, 0x00, 0x10, 0x27, 0xfe, 0x2e, 0x16, 0x32,
12936 0x07, 0xfe, 0xe3, 0x00,
12937 0xfe, 0x20, 0x13, 0x1d, 0xfe, 0x52, 0x16, 0x21, 0x13, 0xd4, 0x01, 0x4b,
12938 0x22, 0xd4, 0x07, 0x06,
12939 0x4e, 0x08, 0x54, 0x06, 0x37, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfb, 0x8e,
12940 0x07, 0x11, 0xae, 0x09,
12941 0x84, 0x01, 0x0e, 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x84, 0x01,
12942 0x0e, 0x8e, 0xfe, 0x80,
12943 0xe7, 0x11, 0x07, 0x11, 0x8a, 0xfe, 0x45, 0x58, 0x01, 0xf0, 0x8e, 0x04,
12944 0x09, 0x48, 0x01, 0x0e,
12945 0x8e, 0x09, 0x5d, 0x01, 0xa8, 0x04, 0x09, 0x48, 0x01, 0x0e, 0xfe, 0x80,
12946 0x80, 0xfe, 0x80, 0x4c,
12947 0xfe, 0x49, 0xe4, 0x11, 0xae, 0x09, 0x84, 0x01, 0x0e, 0xfe, 0x80, 0x4c,
12948 0x09, 0x5d, 0x01, 0x87,
12949 0x04, 0x18, 0x11, 0x75, 0x6c, 0xfe, 0x60, 0x01, 0xfe, 0x18, 0xdf, 0xfe,
12950 0x19, 0xde, 0xfe, 0x24,
12951 0x1c, 0xfe, 0x1d, 0xf7, 0x1b, 0x97, 0xfe, 0xee, 0x16, 0x01, 0xfe, 0xf4,
12952 0x17, 0xad, 0x9a, 0x1b,
12953 0x6c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x04, 0xb9, 0x23, 0xfe, 0xde,
12954 0x16, 0xfe, 0xda, 0x10,
12955 0x18, 0x11, 0x75, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x1f, 0xfe,
12956 0x18, 0x58, 0x03, 0xfe,
12957 0x66, 0x01, 0xfe, 0x19, 0x58, 0x9a, 0x1f, 0xfe, 0x3c, 0x90, 0xfe, 0x30,
12958 0xf4, 0x06, 0xfe, 0x3c,
12959 0x50, 0x6c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x1f,
12960 0x97, 0xfe, 0x38, 0x17,
12961 0xfe, 0xb6, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x10, 0x17, 0xfe, 0x9c,
12962 0x10, 0x18, 0x11, 0x75,
12963 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7,
12964 0x2e, 0x97, 0xfe, 0x5a,
12965 0x17, 0xfe, 0x94, 0x14, 0xec, 0x9a, 0x2e, 0x6c, 0x1a, 0xfe, 0xaf, 0x19,
12966 0xfe, 0x98, 0xe7, 0x00,
12967 0x04, 0xb9, 0x23, 0xfe, 0x4e, 0x17, 0xfe, 0x6c, 0x10, 0x18, 0x11, 0x75,
12968 0xfe, 0x30, 0xbc, 0xfe,
12969 0xb2, 0xbc, 0x9a, 0xcb, 0x6c, 0x1a, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7,
12970 0xcb, 0x97, 0xfe, 0x92,
12971 0x17, 0xfe, 0x5c, 0x14, 0x35, 0x04, 0xb9, 0x23, 0xfe, 0x7e, 0x17, 0xfe,
12972 0x42, 0x10, 0xfe, 0x02,
12973 0xf6, 0x11, 0x75, 0xfe, 0x18, 0xfe, 0x60, 0xfe, 0x19, 0xfe, 0x61, 0xfe,
12974 0x03, 0xa1, 0xfe, 0x1d,
12975 0xf7, 0x5b, 0x97, 0xfe, 0xb8, 0x17, 0xfe, 0x36, 0x14, 0xfe, 0x1c, 0x13,
12976 0x9a, 0x5b, 0x41, 0xfe,
12977 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x11, 0xfe, 0x81, 0xe7,
12978 0x11, 0x12, 0xfe, 0xdd,
12979 0x00, 0x6a, 0x2a, 0x04, 0x6a, 0x2a, 0xfe, 0x12, 0x45, 0x23, 0xfe, 0xa8,
12980 0x17, 0x15, 0x06, 0x39,
12981 0xa0, 0xb4, 0x02, 0x2b, 0xfe, 0x39, 0xf0, 0xfe, 0xfc, 0x17, 0x21, 0x04,
12982 0xfe, 0x7e, 0x18, 0x1e,
12983 0x19, 0x66, 0x0f, 0x0d, 0x04, 0x75, 0x03, 0xd2, 0x1e, 0x06, 0xfe, 0xef,
12984 0x12, 0xfe, 0xe1, 0x10,
12985 0x7c, 0x6f, 0x4f, 0x32, 0x07, 0x2f, 0xfe, 0x3c, 0x13, 0xf1, 0xfe, 0x42,
12986 0x13, 0x42, 0x92, 0x09,
12987 0x48, 0x01, 0x0e, 0xbb, 0xeb, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01,
12988 0xf0, 0xfe, 0x00, 0xcc,
12989 0xbb, 0xfe, 0xf3, 0x13, 0x43, 0x78, 0x07, 0x11, 0xac, 0x09, 0x84, 0x01,
12990 0x0e, 0xfe, 0x80, 0x4c,
12991 0x01, 0x73, 0xfe, 0x16, 0x10, 0x07, 0x82, 0x8b, 0xfe, 0x40, 0x14, 0xfe,
12992 0x24, 0x12, 0xfe, 0x14,
12993 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0x1c, 0x18, 0x18, 0x0a, 0x04, 0xfe, 0x9c,
12994 0xe7, 0x0a, 0x10, 0xfe,
12995 0x15, 0x00, 0x64, 0x79, 0x2a, 0x01, 0xe3, 0x18, 0x06, 0x04, 0x42, 0x92,
12996 0x08, 0x54, 0x1b, 0x37,
12997 0x12, 0x2f, 0x01, 0x73, 0x18, 0x06, 0x04, 0xfe, 0x38, 0x90, 0xfe, 0xba,
12998 0x90, 0x3a, 0xce, 0x3b,
12999 0xcf, 0xfe, 0x48, 0x55, 0x35, 0xfe, 0xc9, 0x55, 0x04, 0x22, 0xa3, 0x77,
13000 0x13, 0xa3, 0x04, 0x09,
13001 0xa4, 0x01, 0x0e, 0xfe, 0x41, 0x48, 0x09, 0x46, 0x01, 0x0e, 0xfe, 0x49,
13002 0x44, 0x17, 0xfe, 0xe8,
13003 0x18, 0x77, 0x78, 0x04, 0x09, 0x48, 0x01, 0x0e, 0x07, 0x11, 0x4e, 0x09,
13004 0x5d, 0x01, 0xa8, 0x09,
13005 0x46, 0x01, 0x0e, 0x77, 0x78, 0x04, 0xfe, 0x4e, 0xe4, 0x19, 0x6b, 0xfe,
13006 0x1c, 0x19, 0x03, 0xfe,
13007 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xc9,
13008 0x6b, 0xfe, 0x2e, 0x19,
13009 0x03, 0xfe, 0x92, 0x00, 0xfe, 0x02, 0xe6, 0x1a, 0xe5, 0xfe, 0x4e, 0xe4,
13010 0xfe, 0x0b, 0x00, 0x6b,
13011 0xfe, 0x40, 0x19, 0x03, 0xfe, 0x94, 0x00, 0xfe, 0x02, 0xe6, 0x1f, 0xfe,
13012 0x08, 0x10, 0x03, 0xfe,
13013 0x96, 0x00, 0xfe, 0x02, 0xe6, 0x6d, 0xfe, 0x4e, 0x45, 0xea, 0xba, 0xff,
13014 0x04, 0x68, 0x54, 0xe7,
13015 0x1e, 0x6e, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe,
13016 0x1a, 0xf4, 0xfe, 0x00,
13017 0x04, 0xea, 0xfe, 0x48, 0xf4, 0x19, 0x7a, 0xfe, 0x74, 0x19, 0x0f, 0x19,
13018 0x04, 0x07, 0x7e, 0xfe,
13019 0x5a, 0xf0, 0xfe, 0x84, 0x19, 0x25, 0xfe, 0x09, 0x00, 0xfe, 0x34, 0x10,
13020 0x07, 0x1a, 0xfe, 0x5a,
13021 0xf0, 0xfe, 0x92, 0x19, 0x25, 0xca, 0xfe, 0x26, 0x10, 0x07, 0x19, 0x66,
13022 0x25, 0x6d, 0xe5, 0x07,
13023 0x0a, 0x66, 0x25, 0x9e, 0xfe, 0x0e, 0x10, 0x07, 0x06, 0x66, 0x25, 0x59,
13024 0xa9, 0xb8, 0x04, 0x15,
13025 0xfe, 0x09, 0x00, 0x01, 0x36, 0xfe, 0x04, 0xfe, 0x81, 0x03, 0x83, 0xfe,
13026 0x40, 0x5c, 0x04, 0x1c,
13027 0xf7, 0xfe, 0x14, 0xf0, 0x0b, 0x27, 0xfe, 0xd6, 0x19, 0x1c, 0xf7, 0x7b,
13028 0xf7, 0xfe, 0x82, 0xf0,
13029 0xfe, 0xda, 0x19, 0x04, 0xff, 0xcc, 0x00, 0x00,
13623}; 13030};
13624 13031
13625STATIC unsigned short _adv_asc38C0800_size = 13032static unsigned short _adv_asc38C0800_size = sizeof(_adv_asc38C0800_buf); /* 0x14E1 */
13626 sizeof(_adv_asc38C0800_buf); /* 0x14E1 */ 13033static ADV_DCNT _adv_asc38C0800_chksum = 0x050D3FD8UL; /* Expanded little-endian checksum. */
13627STATIC ADV_DCNT _adv_asc38C0800_chksum =
13628 0x050D3FD8UL; /* Expanded little-endian checksum. */
13629 13034
13630/* Microcode buffer is kept after initialization for error recovery. */ 13035/* Microcode buffer is kept after initialization for error recovery. */
13631STATIC unsigned char _adv_asc38C1600_buf[] = { 13036static unsigned char _adv_asc38C1600_buf[] = {
13632 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0, 0x18, 0xe4, 0x01, 0x00, 13037 0x00, 0x00, 0x00, 0xf2, 0x00, 0x16, 0x00, 0xfc, 0x00, 0x10, 0x00, 0xf0,
13633 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13, 0x2e, 0x1e, 0x02, 0x00, 0x07, 0x17, 0xc0, 0x5f, 13038 0x18, 0xe4, 0x01, 0x00,
13634 0x00, 0xfa, 0xff, 0xff, 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7, 0x85, 0xf0, 0x86, 0xf0, 13039 0x04, 0x1e, 0x48, 0xe4, 0x03, 0xf6, 0xf7, 0x13, 0x2e, 0x1e, 0x02, 0x00,
13635 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00, 0x98, 0x57, 0x01, 0xe6, 13040 0x07, 0x17, 0xc0, 0x5f,
13636 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4, 0x08, 0x00, 0xf0, 0x1d, 0x38, 0x54, 0x32, 0xf0, 13041 0x00, 0xfa, 0xff, 0xff, 0x04, 0x00, 0x00, 0xf6, 0x09, 0xe7, 0x82, 0xe7,
13637 0x10, 0x00, 0xc2, 0x0e, 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4, 0x00, 0xe6, 0xb1, 0xf0, 13042 0x85, 0xf0, 0x86, 0xf0,
13638 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01, 0x06, 0x13, 0x0c, 0x1c, 13043 0x4e, 0x10, 0x9e, 0xe7, 0xff, 0x00, 0x55, 0xf0, 0x01, 0xf6, 0x03, 0x00,
13639 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc, 0xbc, 0x0e, 0xa2, 0x12, 0xb9, 0x54, 0x00, 0x80, 13044 0x98, 0x57, 0x01, 0xe6,
13640 0x62, 0x0a, 0x5a, 0x12, 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56, 0x03, 0xe6, 0x01, 0xea, 13045 0x00, 0xea, 0x00, 0xec, 0x01, 0xfa, 0x18, 0xf4, 0x08, 0x00, 0xf0, 0x1d,
13641 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12, 0x04, 0x13, 0xbb, 0x55, 13046 0x38, 0x54, 0x32, 0xf0,
13642 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4, 0x40, 0x00, 0xb6, 0x00, 0xbb, 0x00, 0xc0, 0x00, 13047 0x10, 0x00, 0xc2, 0x0e, 0x1e, 0xf0, 0xd5, 0xf0, 0xbc, 0x00, 0x4b, 0xe4,
13643 0x00, 0x01, 0x01, 0x01, 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12, 0x4c, 0x1c, 0x4e, 0x1c, 13048 0x00, 0xe6, 0xb1, 0xf0,
13644 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00, 0x24, 0x01, 0x3c, 0x01, 13049 0xb4, 0x00, 0x02, 0x13, 0x3e, 0x1c, 0xc8, 0x47, 0x3e, 0x00, 0xd8, 0x01,
13645 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01, 0x78, 0x01, 0x7c, 0x01, 13050 0x06, 0x13, 0x0c, 0x1c,
13646 0xc6, 0x0e, 0x0c, 0x10, 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c, 0x6e, 0x1e, 0x02, 0x48, 13051 0x5e, 0x1e, 0x00, 0x57, 0xc8, 0x57, 0x01, 0xfc, 0xbc, 0x0e, 0xa2, 0x12,
13647 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7, 0x03, 0xfc, 0x06, 0x00, 13052 0xb9, 0x54, 0x00, 0x80,
13648 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12, 0x18, 0x1a, 0x70, 0x1a, 0x30, 0x1c, 0x38, 0x1c, 13053 0x62, 0x0a, 0x5a, 0x12, 0xc8, 0x15, 0x3e, 0x1e, 0x18, 0x40, 0xbd, 0x56,
13649 0x10, 0x44, 0x00, 0x4c, 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea, 0x5d, 0xf0, 0xa7, 0xf0, 13054 0x03, 0xe6, 0x01, 0xea,
13650 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00, 0x33, 0x00, 0x34, 0x00, 13055 0x5c, 0xf0, 0x0f, 0x00, 0x20, 0x00, 0x6c, 0x01, 0x6e, 0x01, 0x04, 0x12,
13651 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01, 0x79, 0x01, 0x3c, 0x09, 13056 0x04, 0x13, 0xbb, 0x55,
13652 0x68, 0x0d, 0x02, 0x10, 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13, 0x40, 0x16, 0x50, 0x16, 13057 0x3c, 0x56, 0x3e, 0x57, 0x03, 0x58, 0x4a, 0xe4, 0x40, 0x00, 0xb6, 0x00,
13653 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc, 0x05, 0xf0, 0x09, 0xf0, 13058 0xbb, 0x00, 0xc0, 0x00,
13654 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7, 0x0a, 0x00, 0x9b, 0x00, 0x9c, 0x00, 0xa4, 0x00, 13059 0x00, 0x01, 0x01, 0x01, 0x3e, 0x01, 0x58, 0x0a, 0x44, 0x10, 0x0a, 0x12,
13655 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08, 0xe9, 0x09, 0x5c, 0x0c, 13060 0x4c, 0x1c, 0x4e, 0x1c,
13656 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c, 0x42, 0x1d, 0x08, 0x44, 13061 0x02, 0x4a, 0x30, 0xe4, 0x05, 0xe6, 0x0c, 0x00, 0x3c, 0x00, 0x80, 0x00,
13657 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x89, 0x48, 0x68, 0x54, 0x83, 0x55, 0x83, 0x59, 13062 0x24, 0x01, 0x3c, 0x01,
13658 0x31, 0xe4, 0x02, 0xe6, 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0, 0x4b, 0xf4, 0x04, 0xf8, 13063 0x68, 0x01, 0x6a, 0x01, 0x70, 0x01, 0x72, 0x01, 0x74, 0x01, 0x76, 0x01,
13659 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00, 0xa8, 0x00, 0xaa, 0x00, 13064 0x78, 0x01, 0x7c, 0x01,
13660 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01, 0x26, 0x01, 0x60, 0x01, 0x7a, 0x01, 0x82, 0x01, 13065 0xc6, 0x0e, 0x0c, 0x10, 0xac, 0x12, 0xae, 0x12, 0x16, 0x1a, 0x32, 0x1c,
13661 0xc8, 0x01, 0xca, 0x01, 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07, 0x68, 0x08, 0x10, 0x0d, 13066 0x6e, 0x1e, 0x02, 0x48,
13662 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10, 0xf3, 0x10, 0x06, 0x12, 13067 0x3a, 0x55, 0xc9, 0x57, 0x02, 0xee, 0x5b, 0xf0, 0x03, 0xf7, 0x06, 0xf7,
13663 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13, 0x10, 0x13, 0xfe, 0x9c, 0xf0, 0x35, 0x05, 0xfe, 13068 0x03, 0xfc, 0x06, 0x00,
13664 0xec, 0x0e, 0xff, 0x10, 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8, 0xfe, 0x88, 0x01, 0xff, 13069 0x1e, 0x00, 0xbe, 0x00, 0xe1, 0x00, 0x0c, 0x12, 0x18, 0x1a, 0x70, 0x1a,
13665 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00, 0x00, 0xfe, 0x57, 0x24, 13070 0x30, 0x1c, 0x38, 0x1c,
13666 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00, 0x00, 0x1a, 0xff, 0x09, 0x00, 0x00, 0xff, 0x08, 13071 0x10, 0x44, 0x00, 0x4c, 0xb0, 0x57, 0x40, 0x5c, 0x4d, 0xe4, 0x04, 0xea,
13667 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10, 0xff, 0xff, 0xff, 0x13, 13072 0x5d, 0xf0, 0xa7, 0xf0,
13668 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00, 0xfe, 0x04, 0xf7, 0xe8, 13073 0x04, 0xf6, 0x02, 0xfc, 0x05, 0x00, 0x09, 0x00, 0x19, 0x00, 0x32, 0x00,
13669 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe, 0x04, 0xf7, 0xe8, 0x7d, 0x0d, 0x51, 0x37, 0xfe, 13074 0x33, 0x00, 0x34, 0x00,
13670 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 13075 0x36, 0x00, 0x98, 0x00, 0x9e, 0x00, 0xcc, 0x00, 0x20, 0x01, 0x4e, 0x01,
13671 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d, 0x05, 0xfe, 0x08, 0x0f, 13076 0x79, 0x01, 0x3c, 0x09,
13672 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05, 0xfe, 0x0e, 0x03, 0xfe, 0x28, 0x1c, 0x03, 0xfe, 13077 0x68, 0x0d, 0x02, 0x10, 0x04, 0x10, 0x3a, 0x10, 0x08, 0x12, 0x0a, 0x13,
13673 0xa6, 0x00, 0xfe, 0xd1, 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe, 0x48, 0xf0, 0xfe, 0x90, 13078 0x40, 0x16, 0x50, 0x16,
13674 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8, 0x02, 0xfe, 0x46, 0xf0, 13079 0x00, 0x17, 0x4a, 0x19, 0x00, 0x4e, 0x00, 0x54, 0x01, 0x58, 0x00, 0xdc,
13675 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60, 0x02, 0xfe, 0x43, 0xf0, 0xfe, 0x4e, 0x02, 0xfe, 13080 0x05, 0xf0, 0x09, 0xf0,
13676 0x44, 0xf0, 0xfe, 0x52, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c, 0x0d, 0xa2, 0x1c, 0x07, 13081 0x59, 0xf0, 0xb8, 0xf0, 0x48, 0xf4, 0x0e, 0xf7, 0x0a, 0x00, 0x9b, 0x00,
13677 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02, 0x1c, 0xf5, 0xfe, 0x1e, 13082 0x9c, 0x00, 0xa4, 0x00,
13678 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc, 0xde, 0x0a, 0x81, 0x01, 13083 0xb5, 0x00, 0xba, 0x00, 0xd0, 0x00, 0xe7, 0x00, 0xf0, 0x03, 0x69, 0x08,
13679 0xa3, 0x05, 0x35, 0x1f, 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 13084 0xe9, 0x09, 0x5c, 0x0c,
13680 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c, 0xfe, 0x58, 0x1c, 0x1c, 13085 0xb6, 0x12, 0xbc, 0x19, 0xd8, 0x1b, 0x20, 0x1c, 0x34, 0x1c, 0x36, 0x1c,
13681 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0x2b, 0xfe, 0x9e, 0x02, 13086 0x42, 0x1d, 0x08, 0x44,
13682 0xfe, 0x5a, 0x1c, 0xfe, 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30, 0x00, 0x47, 0xb8, 0x01, 13087 0x38, 0x44, 0x91, 0x44, 0x0a, 0x45, 0x48, 0x46, 0x89, 0x48, 0x68, 0x54,
13683 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09, 0x1a, 0x31, 0xfe, 0x69, 13088 0x83, 0x55, 0x83, 0x59,
13684 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0x01, 0xfe, 0x1e, 0x1e, 0x20, 0x2c, 13089 0x31, 0xe4, 0x02, 0xe6, 0x07, 0xf0, 0x08, 0xf0, 0x0b, 0xf0, 0x0c, 0xf0,
13685 0xfe, 0x05, 0xf6, 0xde, 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a, 0x44, 0x15, 0x56, 0x51, 13090 0x4b, 0xf4, 0x04, 0xf8,
13686 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 13091 0x05, 0xf8, 0x02, 0xfa, 0x03, 0xfa, 0x04, 0xfc, 0x05, 0xfc, 0x07, 0x00,
13687 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0xc8, 0x54, 13092 0xa8, 0x00, 0xaa, 0x00,
13688 0x7b, 0xfe, 0x1c, 0x03, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60, 0xfe, 0x02, 0xe8, 0x30, 13093 0xb9, 0x00, 0xe0, 0x00, 0xe5, 0x00, 0x22, 0x01, 0x26, 0x01, 0x60, 0x01,
13689 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0, 0xfe, 0xe4, 0x01, 0xfe, 13094 0x7a, 0x01, 0x82, 0x01,
13690 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40, 0x1c, 0x2a, 0xeb, 0xfe, 0x26, 0xf0, 0xfe, 0x66, 13095 0xc8, 0x01, 0xca, 0x01, 0x86, 0x02, 0x6a, 0x03, 0x18, 0x05, 0xb2, 0x07,
13691 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe, 0xef, 0x10, 0xfe, 0x9f, 13096 0x68, 0x08, 0x10, 0x0d,
13692 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05, 0x70, 0x37, 0xfe, 0x48, 13097 0x06, 0x10, 0x0a, 0x10, 0x0e, 0x10, 0x12, 0x10, 0x60, 0x10, 0xed, 0x10,
13693 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x26, 0x21, 0xb9, 0xc7, 0x20, 13098 0xf3, 0x10, 0x06, 0x12,
13694 0xb9, 0x0a, 0x57, 0x01, 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15, 0xe1, 0x2a, 0xeb, 0xfe, 13099 0x10, 0x12, 0x1e, 0x12, 0x0c, 0x13, 0x0e, 0x13, 0x10, 0x13, 0xfe, 0x9c,
13695 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32, 0x15, 0xfe, 0xe4, 0x00, 13100 0xf0, 0x35, 0x05, 0xfe,
13696 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe, 0xc6, 0x03, 0x01, 0x41, 0xfe, 0x06, 0xf0, 0xfe, 13101 0xec, 0x0e, 0xff, 0x10, 0x00, 0x00, 0xe9, 0xfe, 0x34, 0x1f, 0x00, 0xe8,
13697 0xd6, 0x03, 0xaf, 0xa0, 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29, 0x03, 0x81, 0x1e, 0x1b, 13102 0xfe, 0x88, 0x01, 0xff,
13698 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05, 0xea, 0xfe, 0x46, 0x1c, 13103 0x03, 0x00, 0x00, 0xfe, 0x93, 0x15, 0xfe, 0x0f, 0x05, 0xff, 0x38, 0x00,
13699 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0xfe, 0x48, 0x1c, 0x75, 13104 0x00, 0xfe, 0x57, 0x24,
13700 0x01, 0xa6, 0x86, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a, 0xe1, 0x01, 0x18, 0x77, 13105 0x00, 0xfe, 0x4c, 0x00, 0x65, 0xff, 0x04, 0x00, 0x00, 0x1a, 0xff, 0x09,
13701 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 13106 0x00, 0x00, 0xff, 0x08,
13702 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29, 0x2f, 0xfe, 0x4e, 0x04, 0x16, 0xfe, 0x4a, 0x04, 13107 0x01, 0x01, 0xff, 0x08, 0xff, 0xff, 0xff, 0x27, 0x00, 0x00, 0xff, 0x10,
13703 0x7e, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff, 0x02, 0x00, 0x10, 0x01, 13108 0xff, 0xff, 0xff, 0x13,
13704 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25, 0xee, 0xfe, 0x4c, 0x44, 13109 0x00, 0x00, 0xfe, 0x78, 0x56, 0xfe, 0x34, 0x12, 0xff, 0x21, 0x00, 0x00,
13705 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13, 0x34, 0xfe, 0x4c, 0x54, 0x7b, 0xec, 0x60, 0x8d, 13110 0xfe, 0x04, 0xf7, 0xe8,
13706 0x30, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xfe, 13111 0x37, 0x7d, 0x0d, 0x01, 0xfe, 0x4a, 0x11, 0xfe, 0x04, 0xf7, 0xe8, 0x7d,
13707 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10, 0x13, 0x34, 0xfe, 0x4c, 13112 0x0d, 0x51, 0x37, 0xfe,
13708 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x54, 0x13, 0x01, 0x0c, 0x06, 13113 0x3d, 0xf0, 0xfe, 0x0c, 0x02, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x91, 0xf0,
13709 0x28, 0xa5, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06, 0x28, 0xf9, 0x1f, 0x7f, 13114 0xfe, 0xf8, 0x01, 0xfe,
13710 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 13115 0x90, 0xf0, 0xfe, 0xf8, 0x01, 0xfe, 0x8f, 0xf0, 0xbc, 0x03, 0x67, 0x4d,
13711 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe, 0x1c, 0x90, 0x04, 0xfe, 0x9c, 0x93, 0x3a, 0x0b, 13116 0x05, 0xfe, 0x08, 0x0f,
13712 0x0e, 0x8b, 0x02, 0x1f, 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b, 0x7d, 0x1d, 0xfe, 0x46, 13117 0x01, 0xfe, 0x78, 0x0f, 0xfe, 0xdd, 0x12, 0x05, 0xfe, 0x0e, 0x03, 0xfe,
13713 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04, 0xfe, 0x87, 0x83, 0xfe, 13118 0x28, 0x1c, 0x03, 0xfe,
13714 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x98, 0x13, 0x0f, 0xfe, 0x20, 13119 0xa6, 0x00, 0xfe, 0xd1, 0x12, 0x3e, 0x22, 0xfe, 0xa6, 0x00, 0xac, 0xfe,
13715 0x80, 0x04, 0xfe, 0xa0, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84, 0x12, 0x01, 0x38, 0x06, 13120 0x48, 0xf0, 0xfe, 0x90,
13716 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda, 0x05, 0xd0, 0x54, 0x01, 13121 0x02, 0xfe, 0x49, 0xf0, 0xfe, 0xaa, 0x02, 0xfe, 0x4a, 0xf0, 0xfe, 0xc8,
13717 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x1e, 0xfe, 0x50, 0x12, 0x5e, 0xff, 13122 0x02, 0xfe, 0x46, 0xf0,
13718 0x02, 0x00, 0x10, 0x2f, 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 13123 0xfe, 0x5a, 0x02, 0xfe, 0x47, 0xf0, 0xfe, 0x60, 0x02, 0xfe, 0x43, 0xf0,
13719 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01, 0x38, 0xfe, 0x4a, 0xf0, 13124 0xfe, 0x4e, 0x02, 0xfe,
13720 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba, 0x05, 0x71, 0x2e, 0xfe, 0x21, 0x00, 0xf1, 0x2e, 13125 0x44, 0xf0, 0xfe, 0x52, 0x02, 0xfe, 0x45, 0xf0, 0xfe, 0x56, 0x02, 0x1c,
13721 0xfe, 0x22, 0x00, 0xa2, 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00, 0x10, 0x2f, 0xfe, 0xd0, 13126 0x0d, 0xa2, 0x1c, 0x07,
13722 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe, 0x1c, 0x00, 0x4d, 0x01, 13127 0x22, 0xb7, 0x05, 0x35, 0xfe, 0x00, 0x1c, 0xfe, 0xf1, 0x10, 0xfe, 0x02,
13723 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27, 0x01, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x24, 0x12, 13128 0x1c, 0xf5, 0xfe, 0x1e,
13724 0x3e, 0x01, 0x84, 0x1f, 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 13129 0x1c, 0xfe, 0xe9, 0x10, 0x01, 0x5f, 0xfe, 0xe7, 0x10, 0xfe, 0x06, 0xfc,
13725 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13, 0x03, 0xb6, 0x1e, 0xfe, 13130 0xde, 0x0a, 0x81, 0x01,
13726 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13, 0x3e, 0x01, 0x84, 0x17, 0xfe, 0x72, 0x06, 0x0a, 13131 0xa3, 0x05, 0x35, 0x1f, 0x95, 0x47, 0xb8, 0x01, 0xfe, 0xe4, 0x11, 0x0a,
13727 0x07, 0x01, 0x38, 0x06, 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56, 0x19, 0x16, 0xfe, 0x68, 13132 0x81, 0x01, 0x5c, 0xfe,
13728 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x03, 0x9a, 0x1e, 0xfe, 13133 0xbd, 0x10, 0x0a, 0x81, 0x01, 0x5c, 0xfe, 0xad, 0x10, 0xfe, 0x16, 0x1c,
13729 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13, 0x01, 0xc6, 0x09, 0x12, 0x48, 0xfe, 0x92, 0x06, 13134 0xfe, 0x58, 0x1c, 0x1c,
13730 0x2e, 0x12, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13, 0x58, 0xff, 0x02, 0x00, 13135 0x07, 0x22, 0xb7, 0x37, 0x2a, 0x35, 0xfe, 0x3d, 0xf0, 0xfe, 0x0c, 0x02,
13731 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17, 0xfe, 0xea, 0x06, 0x01, 13136 0x2b, 0xfe, 0x9e, 0x02,
13732 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01, 0xfe, 0x84, 0x19, 0x16, 0xfe, 0xe0, 0x06, 0x15, 13137 0xfe, 0x5a, 0x1c, 0xfe, 0x12, 0x1c, 0xfe, 0x14, 0x1c, 0x1f, 0xfe, 0x30,
13733 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0xae, 13138 0x00, 0x47, 0xb8, 0x01,
13734 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a, 0x1e, 0xfe, 0x1a, 0x12, 13139 0xfe, 0xd4, 0x11, 0x1c, 0x07, 0x22, 0xb7, 0x05, 0xe9, 0x21, 0x2c, 0x09,
13735 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 13140 0x1a, 0x31, 0xfe, 0x69,
13736 0xf0, 0x45, 0x0a, 0x95, 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24, 0x36, 0xfe, 0x02, 0xf6, 13141 0x10, 0x1c, 0x07, 0x22, 0xb7, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0x01, 0xfe,
13737 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x17, 0xfe, 13142 0x1e, 0x1e, 0x20, 0x2c,
13738 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe, 0x90, 0x07, 0x26, 0x20, 0x9e, 0x15, 0x82, 0x01, 13143 0xfe, 0x05, 0xf6, 0xde, 0x01, 0xfe, 0x62, 0x1b, 0x01, 0x0c, 0x61, 0x4a,
13739 0x41, 0x15, 0xe2, 0x21, 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58, 0x57, 0x10, 0xe6, 0x05, 13144 0x44, 0x15, 0x56, 0x51,
13740 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84, 0xfe, 0x9c, 0x32, 0x5f, 13145 0x01, 0xfe, 0x9e, 0x1e, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x0a, 0x57,
13741 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00, 0x2f, 0xed, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 13146 0x01, 0x18, 0x09, 0x00,
13742 0xce, 0x07, 0xae, 0xfe, 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08, 0xaf, 0xa0, 0x05, 0x29, 13147 0x36, 0x01, 0x85, 0xfe, 0x18, 0x10, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0x01,
13743 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 13148 0x18, 0xfe, 0xc8, 0x54,
13744 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08, 0x14, 0x00, 0x05, 0xfe, 13149 0x7b, 0xfe, 0x1c, 0x03, 0x01, 0xfe, 0x96, 0x1a, 0x05, 0x35, 0x37, 0x60,
13745 0xc6, 0x09, 0x01, 0x76, 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x30, 0x13, 13150 0xfe, 0x02, 0xe8, 0x30,
13746 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00, 13151 0xfe, 0xbf, 0x57, 0xfe, 0x9e, 0x43, 0xfe, 0x77, 0x57, 0xfe, 0x27, 0xf0,
13747 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00, 0x05, 0xef, 0x7c, 0x4a, 0x78, 0x4f, 0x0f, 0xfe, 13152 0xfe, 0xe4, 0x01, 0xfe,
13748 0x9a, 0x81, 0x04, 0xfe, 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d, 0x28, 0x48, 0xfe, 0x6c, 13153 0x07, 0x4b, 0xfe, 0x20, 0xf0, 0xbc, 0xfe, 0x40, 0x1c, 0x2a, 0xeb, 0xfe,
13749 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32, 0x12, 0x53, 0x63, 0x4e, 13154 0x26, 0xf0, 0xfe, 0x66,
13750 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe, 0x6c, 0x08, 0xaf, 0xa0, 13155 0x03, 0xfe, 0xa0, 0xf0, 0xfe, 0x54, 0x03, 0xfe, 0x11, 0xf0, 0xbc, 0xfe,
13751 0xae, 0xfe, 0x96, 0x08, 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24, 0x05, 0xed, 0xfe, 0x9c, 13156 0xef, 0x10, 0xfe, 0x9f,
13752 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe, 0x1e, 0xfe, 0x99, 0x58, 13157 0xf0, 0xfe, 0x74, 0x03, 0xfe, 0x46, 0x1c, 0x19, 0xfe, 0x11, 0x00, 0x05,
13753 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe, 0x16, 0x09, 0x10, 0x6a, 0x22, 0x6b, 0x01, 0x0c, 13158 0x70, 0x37, 0xfe, 0x48,
13754 0x61, 0x54, 0x44, 0x21, 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e, 0x1e, 0x47, 0x2c, 0x7a, 13159 0x1c, 0xfe, 0x46, 0x1c, 0x01, 0x0c, 0x06, 0x28, 0xfe, 0x18, 0x13, 0x26,
13755 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40, 0x01, 0x0c, 0x61, 0x65, 13160 0x21, 0xb9, 0xc7, 0x20,
13756 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20, 0x6e, 0x01, 0xfe, 0x6a, 0x16, 0xfe, 0x08, 0x50, 13161 0xb9, 0x0a, 0x57, 0x01, 0x18, 0xc7, 0x89, 0x01, 0xfe, 0xc8, 0x1a, 0x15,
13757 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10, 0x01, 0xfe, 0xce, 0x1e, 13162 0xe1, 0x2a, 0xeb, 0xfe,
13758 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e, 0x01, 0xfe, 0xfe, 0x1e, 13163 0x01, 0xf0, 0xeb, 0xfe, 0x82, 0xf0, 0xfe, 0xa4, 0x03, 0xfe, 0x9c, 0x32,
13759 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b, 0x22, 0x4c, 0xfe, 0x8a, 0x10, 0x01, 0x0c, 0x06, 13164 0x15, 0xfe, 0xe4, 0x00,
13760 0x54, 0xfe, 0x50, 0x12, 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e, 0x10, 0x6a, 0x22, 0x6b, 13165 0x2f, 0xfe, 0xb6, 0x03, 0x2a, 0x3c, 0x16, 0xfe, 0xc6, 0x03, 0x01, 0x41,
13761 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04, 0xfe, 0x9f, 0x83, 0x33, 13166 0xfe, 0x06, 0xf0, 0xfe,
13762 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90, 0x04, 0xfe, 0xc4, 0x93, 0x3a, 0x0b, 0xfe, 0xc6, 13167 0xd6, 0x03, 0xaf, 0xa0, 0xfe, 0x0a, 0xf0, 0xfe, 0xa2, 0x07, 0x05, 0x29,
13763 0x90, 0x04, 0xfe, 0xc6, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d, 0x01, 0xfe, 0xce, 0x1e, 13168 0x03, 0x81, 0x1e, 0x1b,
13764 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90, 0x04, 0xfe, 0xc0, 0x93, 13169 0xfe, 0x24, 0x05, 0x1f, 0x63, 0x01, 0x42, 0x8f, 0xfe, 0x70, 0x02, 0x05,
13765 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x4b, 0x22, 0x4c, 13170 0xea, 0xfe, 0x46, 0x1c,
13766 0x10, 0x64, 0x22, 0x34, 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 13171 0x37, 0x7d, 0x1d, 0xfe, 0x67, 0x1b, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57,
13767 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5, 13172 0xfe, 0x48, 0x1c, 0x75,
13768 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a, 0xd2, 0xfe, 0x1e, 0x0a, 0xd3, 0xfe, 0x42, 0x0a, 13173 0x01, 0xa6, 0x86, 0x0a, 0x57, 0x01, 0x18, 0x09, 0x00, 0x1b, 0xec, 0x0a,
13769 0xae, 0xfe, 0x12, 0x0a, 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0, 0x05, 0x29, 0x01, 0x41, 13174 0xe1, 0x01, 0x18, 0x77,
13770 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07, 0xfe, 0x14, 0x12, 0x01, 13175 0x50, 0x40, 0x8d, 0x30, 0x03, 0x81, 0x1e, 0xf8, 0x1f, 0x63, 0x01, 0x42,
13771 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x74, 0x12, 0xfe, 0x2e, 0x1c, 0x05, 0xfe, 13176 0x8f, 0xfe, 0x70, 0x02,
13772 0x1a, 0x0c, 0x01, 0x76, 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41, 0xfe, 0x2c, 0x1c, 0xfe, 13177 0x05, 0xea, 0xd7, 0x99, 0xd8, 0x9c, 0x2a, 0x29, 0x2f, 0xfe, 0x4e, 0x04,
13773 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe, 0x92, 0x10, 0xc4, 0xf6, 13178 0x16, 0xfe, 0x4a, 0x04,
13774 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe, 0x1a, 0x0c, 0xc5, 0xfe, 0xe7, 0x10, 0xfe, 0x2b, 13179 0x7e, 0xfe, 0xa0, 0x00, 0xfe, 0x9b, 0x57, 0xfe, 0x54, 0x12, 0x32, 0xff,
13775 0xf0, 0xbf, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12, 0xac, 0xfe, 0xd2, 0xf0, 13180 0x02, 0x00, 0x10, 0x01,
13776 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07, 0x1b, 0xbf, 0xd4, 0x5b, 13181 0x08, 0x16, 0xfe, 0x02, 0x05, 0x32, 0x01, 0x08, 0x16, 0x29, 0x27, 0x25,
13777 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5, 0xfe, 0xa9, 0x10, 0x75, 0x5e, 0x32, 0x1f, 0x7f, 13182 0xee, 0xfe, 0x4c, 0x44,
13778 0x01, 0x42, 0x19, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98, 0x05, 0x70, 0xfe, 0x74, 13183 0xfe, 0x58, 0x12, 0x50, 0xfe, 0x44, 0x48, 0x13, 0x34, 0xfe, 0x4c, 0x54,
13779 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78, 0x0f, 0x4d, 0x01, 0xfe, 13184 0x7b, 0xec, 0x60, 0x8d,
13780 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x0d, 0x2b, 0xfe, 0xe2, 13185 0x30, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x7c, 0x13, 0x01,
13781 0x0b, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24, 0xfe, 0x88, 0x13, 0x21, 13186 0x0c, 0x06, 0x28, 0xfe,
13782 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe, 0x83, 0x83, 0xfe, 0xc9, 13187 0x32, 0x13, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x68, 0x13, 0xfe, 0x26, 0x10,
13783 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42, 0x13, 0x0f, 0xfe, 0x04, 0x91, 0x04, 0xfe, 0x84, 13188 0x13, 0x34, 0xfe, 0x4c,
13784 0x93, 0xfe, 0xca, 0x57, 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93, 0xfe, 0xcb, 0x57, 0x0b, 13189 0x54, 0x7b, 0xec, 0x01, 0xfe, 0x4e, 0x1e, 0xfe, 0x48, 0x47, 0xfe, 0x54,
13785 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0x10, 13190 0x13, 0x01, 0x0c, 0x06,
13786 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01, 0xc2, 0xc8, 0x7a, 0x30, 0x20, 0x6e, 0xdb, 0x64, 13191 0x28, 0xa5, 0x01, 0x43, 0x09, 0x9b, 0xfe, 0x40, 0x13, 0x01, 0x0c, 0x06,
13787 0xdc, 0x34, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xfe, 0x04, 0xfa, 0x64, 13192 0x28, 0xf9, 0x1f, 0x7f,
13788 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97, 0x10, 0x98, 0x91, 0x6c, 13193 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe, 0x0d, 0x00, 0x01, 0x42, 0x8f,
13789 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x91, 0x4b, 0x7e, 0x4c, 0x01, 13194 0xfe, 0xa4, 0x0e, 0x05,
13790 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10, 0x58, 0xfe, 0x91, 0x58, 13195 0x29, 0x32, 0x15, 0xfe, 0xe6, 0x00, 0x0f, 0xfe, 0x1c, 0x90, 0x04, 0xfe,
13791 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x01, 0x0c, 13196 0x9c, 0x93, 0x3a, 0x0b,
13792 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe, 0x8e, 0x1e, 0x4f, 0x0f, 0xfe, 0x10, 0x90, 0x04, 13197 0x0e, 0x8b, 0x02, 0x1f, 0x7f, 0x01, 0x42, 0x05, 0x35, 0xfe, 0x42, 0x5b,
13793 0xfe, 0x90, 0x93, 0x3a, 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93, 0x79, 0x0b, 0x0e, 0xfe, 13198 0x7d, 0x1d, 0xfe, 0x46,
13794 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb, 0x01, 0x0c, 0x06, 0x0d, 13199 0x59, 0xfe, 0xbf, 0x57, 0xfe, 0x77, 0x57, 0x0f, 0xfe, 0x87, 0x80, 0x04,
13795 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e, 0xfe, 0x6e, 0x0a, 0xfe, 0x0c, 0x58, 0xfe, 0x8d, 13200 0xfe, 0x87, 0x83, 0xfe,
13796 0x58, 0x05, 0x5b, 0x26, 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99, 0x83, 0x33, 0x0b, 0x0e, 13201 0xc9, 0x47, 0x0b, 0x0e, 0xd0, 0x65, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x98,
13797 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c, 0x19, 0xfe, 0x19, 0x41, 13202 0x13, 0x0f, 0xfe, 0x20,
13798 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef, 0x1f, 0x92, 0x01, 0x42, 0x19, 0xfe, 0x44, 0x00, 13203 0x80, 0x04, 0xfe, 0xa0, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x1d, 0xfe, 0x84,
13799 0xfe, 0x90, 0x10, 0xfe, 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 13204 0x12, 0x01, 0x38, 0x06,
13800 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe, 0x76, 0x10, 0xac, 0xfe, 13205 0x07, 0xfe, 0x70, 0x13, 0x03, 0xfe, 0xa2, 0x00, 0x1e, 0x1b, 0xfe, 0xda,
13801 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x5d, 0x03, 0xe3, 0x23, 0x07, 0xfe, 13206 0x05, 0xd0, 0x54, 0x01,
13802 0x08, 0x13, 0x19, 0xfe, 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe, 0xcc, 0x0c, 0x1f, 0x92, 13207 0x38, 0x06, 0x0d, 0xfe, 0x58, 0x13, 0x03, 0xfe, 0xa0, 0x00, 0x1e, 0xfe,
13803 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2, 0x0c, 0xfe, 0x3e, 0x10, 13208 0x50, 0x12, 0x5e, 0xff,
13804 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe, 0x22, 0x00, 0x05, 0x70, 0xfe, 0xcb, 0xf0, 0xfe, 13209 0x02, 0x00, 0x10, 0x2f, 0xfe, 0x90, 0x05, 0x2a, 0x3c, 0xcc, 0xff, 0x02,
13805 0xea, 0x0c, 0x19, 0xfe, 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe, 0xf4, 0x0c, 0x19, 0x94, 13210 0x00, 0x10, 0x2f, 0xfe,
13806 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3, 0xfe, 0xcc, 0xf0, 0xef, 13211 0x9e, 0x05, 0x17, 0xfe, 0xf4, 0x05, 0x15, 0xfe, 0xe3, 0x00, 0x26, 0x01,
13807 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12, 0x00, 0x37, 0x13, 0xfe, 0x4e, 0x11, 0x2f, 0xfe, 13212 0x38, 0xfe, 0x4a, 0xf0,
13808 0x16, 0x0d, 0xfe, 0x9e, 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b, 0x3c, 0x37, 0x88, 0xf5, 13213 0xfe, 0xc0, 0x05, 0xfe, 0x49, 0xf0, 0xfe, 0xba, 0x05, 0x71, 0x2e, 0xfe,
13809 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32, 0x2f, 0xfe, 0x3e, 0x0d, 13214 0x21, 0x00, 0xf1, 0x2e,
13810 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0, 0xd4, 0x9f, 0xd5, 0x9f, 0xd2, 0x9f, 0xd3, 0x9f, 13215 0xfe, 0x22, 0x00, 0xa2, 0x2e, 0x4a, 0xfe, 0x09, 0x48, 0xff, 0x02, 0x00,
13811 0x05, 0x29, 0x01, 0x41, 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4, 0xc5, 0x75, 0xd7, 0x99, 13216 0x10, 0x2f, 0xfe, 0xd0,
13812 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8, 0x9c, 0x2f, 0xfe, 0x8c, 13217 0x05, 0x17, 0xfe, 0xf4, 0x05, 0xfe, 0xe2, 0x08, 0x01, 0x38, 0x06, 0xfe,
13813 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01, 0x48, 0xa4, 0x19, 0xfe, 0x42, 0x00, 0x05, 0x70, 13218 0x1c, 0x00, 0x4d, 0x01,
13814 0x90, 0x07, 0xfe, 0x81, 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x44, 0x13, 13219 0xa7, 0x2e, 0x07, 0x20, 0xe4, 0x47, 0xfe, 0x27, 0x01, 0x01, 0x0c, 0x06,
13815 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b, 0xfe, 0xda, 0x0e, 0x0a, 13220 0x28, 0xfe, 0x24, 0x12,
13816 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe, 0x28, 0x00, 0xfe, 0xfa, 0x10, 0x01, 0xfe, 0xf4, 13221 0x3e, 0x01, 0x84, 0x1f, 0x7f, 0x01, 0x0c, 0x06, 0x07, 0x4d, 0x1f, 0xfe,
13817 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40, 0x15, 0x56, 0x01, 0x85, 13222 0x0d, 0x00, 0x01, 0x42,
13818 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe, 0xcc, 0x10, 0x01, 0xa7, 13223 0x8f, 0xfe, 0xa4, 0x0e, 0x05, 0x29, 0x03, 0xe6, 0x1e, 0xfe, 0xca, 0x13,
13819 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f, 0xfe, 0x19, 0x82, 0x04, 0xfe, 0x99, 0x83, 0xfe, 13224 0x03, 0xb6, 0x1e, 0xfe,
13820 0xcc, 0x47, 0x0b, 0x0e, 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe, 0x43, 0x00, 0xfe, 0xa2, 13225 0x40, 0x12, 0x03, 0x66, 0x1e, 0xfe, 0x38, 0x13, 0x3e, 0x01, 0x84, 0x17,
13821 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x40, 0x15, 13226 0xfe, 0x72, 0x06, 0x0a,
13822 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01, 0xfe, 0x9e, 0x1e, 0x05, 0xfe, 0x3a, 0x03, 0x01, 13227 0x07, 0x01, 0x38, 0x06, 0x24, 0xfe, 0x02, 0x12, 0x4f, 0x01, 0xfe, 0x56,
13823 0x0c, 0x06, 0x0d, 0x5d, 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01, 0x76, 0x06, 0x12, 0xfe, 13228 0x19, 0x16, 0xfe, 0x68,
13824 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 13229 0x06, 0x15, 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x66, 0x8a, 0x10, 0x66,
13825 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x94, 0x0e, 0x01, 0x0c, 0x61, 0x12, 0x44, 13230 0x03, 0x9a, 0x1e, 0xfe,
13826 0xfe, 0x9f, 0x10, 0x19, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f, 0xfe, 0x2e, 0x10, 0x19, 13231 0x70, 0x12, 0x03, 0x55, 0x1e, 0xfe, 0x68, 0x13, 0x01, 0xc6, 0x09, 0x12,
13827 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19, 0xfe, 0x41, 0x00, 0xa2, 13232 0x48, 0xfe, 0x92, 0x06,
13828 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75, 0x03, 0x81, 0x1e, 0x2b, 0xea, 0x4f, 0xfe, 0x04, 13233 0x2e, 0x12, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 0x43, 0x48, 0x62, 0x80, 0x13,
13829 0xe6, 0x12, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05, 0x35, 0xfe, 0x12, 0x1c, 13234 0x58, 0xff, 0x02, 0x00,
13830 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01, 0xfe, 0xd4, 0x11, 0x05, 13235 0x57, 0x52, 0xad, 0x23, 0x3f, 0x4e, 0x62, 0x49, 0x3e, 0x01, 0x84, 0x17,
13831 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 13236 0xfe, 0xea, 0x06, 0x01,
13832 0xfe, 0x06, 0xea, 0xe0, 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03, 0x67, 0xfe, 0x98, 0x56, 13237 0x38, 0x06, 0x12, 0xf7, 0x45, 0x0a, 0x95, 0x01, 0xfe, 0x84, 0x19, 0x16,
13833 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01, 0x0c, 0x06, 0x28, 0xfe, 13238 0xfe, 0xe0, 0x06, 0x15,
13834 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe, 0x41, 0x58, 0x0a, 0xba, 0xfe, 0xfa, 0x14, 0xfe, 13239 0x82, 0x01, 0x41, 0x15, 0xe2, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x1c, 0x07,
13835 0x49, 0x54, 0xb0, 0xfe, 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67, 0xfe, 0xe0, 0x14, 0xfe, 13240 0x01, 0x84, 0xfe, 0xae,
13836 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47, 0xfe, 0xad, 0x13, 0x05, 13241 0x10, 0x03, 0x6f, 0x1e, 0xfe, 0x9e, 0x13, 0x3e, 0x01, 0x84, 0x03, 0x9a,
13837 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12, 0x26, 0x20, 0x96, 0x20, 0xe7, 0xfe, 0x08, 0x1c, 13242 0x1e, 0xfe, 0x1a, 0x12,
13838 0xfe, 0x7c, 0x19, 0xfe, 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe, 0x48, 0x55, 0xa5, 0x3b, 13243 0x01, 0x38, 0x06, 0x12, 0xfc, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe,
13839 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe, 0xf0, 0x1a, 0x03, 0xfe, 13244 0x43, 0x48, 0x62, 0x80,
13840 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe, 0x1e, 0x10, 0xfe, 0x02, 0xec, 0xe7, 0x53, 0x00, 13245 0xf0, 0x45, 0x0a, 0x95, 0x03, 0xb6, 0x1e, 0xf8, 0x01, 0x38, 0x06, 0x24,
13841 0x36, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01, 0x01, 0xfe, 0x62, 0x1b, 13246 0x36, 0xfe, 0x02, 0xf6,
13842 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02, 0xea, 0xe7, 0x53, 0x92, 13247 0x07, 0x71, 0x78, 0x8c, 0x00, 0x4d, 0x62, 0x49, 0x3e, 0x2d, 0x93, 0x4e,
13843 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3, 0xfe, 0x2a, 0x10, 0x03, 0xfe, 0x38, 0x01, 0x23, 13248 0xd0, 0x0d, 0x17, 0xfe,
13844 0xfe, 0xf0, 0xff, 0x10, 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62, 0x01, 0x01, 0xfe, 0x1e, 13249 0x9a, 0x07, 0x01, 0xfe, 0xc0, 0x19, 0x16, 0xfe, 0x90, 0x07, 0x26, 0x20,
13845 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02, 0x26, 0x02, 0x21, 0x96, 13250 0x9e, 0x15, 0x82, 0x01,
13846 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13, 0x1f, 0x1d, 0x47, 0xb5, 0xc3, 0xfe, 0xe1, 0x10, 13251 0x41, 0x15, 0xe2, 0x21, 0x9e, 0x09, 0x07, 0xfb, 0x03, 0xe6, 0xfe, 0x58,
13847 0xcf, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf, 0xfe, 0x03, 0xdc, 0xfe, 13252 0x57, 0x10, 0xe6, 0x05,
13848 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe, 0x00, 0xcc, 0x02, 0xfe, 13253 0xfe, 0x2a, 0x06, 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x1c, 0x07, 0x01, 0x84,
13849 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x0f, 0xfe, 0x1c, 0x80, 13254 0xfe, 0x9c, 0x32, 0x5f,
13850 0x04, 0xfe, 0x9c, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13, 0x0f, 0xfe, 0x1e, 0x80, 13255 0x75, 0x01, 0xa6, 0x86, 0x15, 0xfe, 0xe2, 0x00, 0x2f, 0xed, 0x2a, 0x3c,
13851 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe, 0x1d, 0x80, 0x04, 0xfe, 13256 0xfe, 0x0a, 0xf0, 0xfe,
13852 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c, 0x13, 0x01, 0xfe, 0xee, 0x1e, 0xac, 0xfe, 0x14, 13257 0xce, 0x07, 0xae, 0xfe, 0x96, 0x08, 0xfe, 0x06, 0xf0, 0xfe, 0x9e, 0x08,
13853 0x13, 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 13258 0xaf, 0xa0, 0x05, 0x29,
13854 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09, 0x56, 0xfb, 0x01, 0xfe, 13259 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x2e, 0x12, 0x14, 0x1d, 0x01, 0x08, 0x14,
13855 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x15, 13260 0x00, 0x01, 0x08, 0x14,
13856 0xfe, 0xe9, 0x00, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe, 0x22, 0x1b, 0xfe, 0x1e, 13261 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0xfe, 0x99, 0xa4, 0x01, 0x08,
13857 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe, 0x96, 0x90, 0x04, 0xfe, 13262 0x14, 0x00, 0x05, 0xfe,
13858 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64, 0x01, 0x22, 0xfe, 0x66, 0x01, 0x01, 0x0c, 0x06, 13263 0xc6, 0x09, 0x01, 0x76, 0x06, 0x12, 0xfe, 0x3a, 0x12, 0x01, 0x0c, 0x06,
13859 0x65, 0xf9, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b, 0x0e, 0x77, 0xfe, 0x01, 13264 0x12, 0xfe, 0x30, 0x13,
13860 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40, 0x21, 0x2c, 0xfe, 0x00, 13265 0x14, 0xfe, 0x1b, 0x00, 0x01, 0x08, 0x14, 0x00, 0x01, 0x08, 0x14, 0x00,
13861 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe, 0x06, 0x58, 0x03, 0xfe, 13266 0x01, 0x08, 0x14, 0x00,
13862 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58, 0x03, 0xfe, 0xb2, 0x00, 13267 0x01, 0x08, 0x14, 0x07, 0x01, 0x08, 0x14, 0x00, 0x05, 0xef, 0x7c, 0x4a,
13863 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10, 0x66, 0x10, 0x55, 0x10, 13268 0x78, 0x4f, 0x0f, 0xfe,
13864 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 0x88, 13269 0x9a, 0x81, 0x04, 0xfe, 0x9a, 0x83, 0xfe, 0xcb, 0x47, 0x0b, 0x0e, 0x2d,
13865 0x11, 0x46, 0x1a, 0x13, 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe, 0x91, 0x54, 0x2b, 0xfe, 13270 0x28, 0x48, 0xfe, 0x6c,
13866 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe, 0x00, 0x40, 0x8d, 0x2c, 13271 0x08, 0x0a, 0x28, 0xfe, 0x09, 0x6f, 0xca, 0xfe, 0xca, 0x45, 0xfe, 0x32,
13867 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xb2, 0x11, 0xfe, 0x12, 0x1c, 0x75, 0xfe, 13272 0x12, 0x53, 0x63, 0x4e,
13868 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c, 0x14, 0xfe, 0x0e, 0x47, 13273 0x7c, 0x97, 0x2f, 0xfe, 0x7e, 0x08, 0x2a, 0x3c, 0xfe, 0x0a, 0xf0, 0xfe,
13869 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01, 0xa7, 0x90, 0x34, 0x60, 13274 0x6c, 0x08, 0xaf, 0xa0,
13870 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x34, 13275 0xae, 0xfe, 0x96, 0x08, 0x05, 0x29, 0x01, 0x41, 0x05, 0xed, 0x14, 0x24,
13871 0x13, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 13276 0x05, 0xed, 0xfe, 0x9c,
13872 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a, 13277 0xf7, 0x9f, 0x01, 0xfe, 0xae, 0x1e, 0xfe, 0x18, 0x58, 0x01, 0xfe, 0xbe,
13873 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85, 0xf2, 0x09, 0x9b, 0xa4, 0xfe, 0x14, 0x56, 0xfe, 13278 0x1e, 0xfe, 0x99, 0x58,
13874 0xd6, 0xf0, 0xfe, 0xec, 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01, 0xec, 0xb8, 0xfe, 0x9e, 13279 0xfe, 0x78, 0x18, 0xfe, 0xf9, 0x18, 0x8e, 0xfe, 0x16, 0x09, 0x10, 0x6a,
13875 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01, 0xf4, 0xfe, 0xdd, 0x10, 13280 0x22, 0x6b, 0x01, 0x0c,
13876 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee, 0x09, 0x12, 0xfe, 0x48, 0x12, 0x09, 0x0d, 0xfe, 13281 0x61, 0x54, 0x44, 0x21, 0x2c, 0x09, 0x1a, 0xf8, 0x77, 0x01, 0xfe, 0x7e,
13877 0x56, 0x12, 0x09, 0x1d, 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4, 0x13, 0x09, 0xfe, 0x23, 13282 0x1e, 0x47, 0x2c, 0x7a,
13878 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09, 0x24, 0xfe, 0x12, 0x12, 13283 0x30, 0xf0, 0xfe, 0x83, 0xe7, 0xfe, 0x3f, 0x00, 0x71, 0xfe, 0x03, 0x40,
13879 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42, 0xa1, 0x32, 0x01, 0x08, 0xae, 0x41, 0x02, 0x32, 13284 0x01, 0x0c, 0x61, 0x65,
13880 0xfe, 0x62, 0x08, 0x0a, 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05, 0x35, 0x32, 0x01, 0x43, 13285 0x44, 0x01, 0xc2, 0xc8, 0xfe, 0x1f, 0x40, 0x20, 0x6e, 0x01, 0xfe, 0x6a,
13881 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80, 0x13, 0x01, 0x0c, 0x06, 13286 0x16, 0xfe, 0x08, 0x50,
13882 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55, 0xb0, 0xfe, 13287 0xfe, 0x8a, 0x50, 0xfe, 0x44, 0x51, 0xfe, 0xc6, 0x51, 0xfe, 0x10, 0x10,
13883 0x4a, 0x13, 0x21, 0x6e, 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e, 0xfe, 0xb6, 0x0e, 0x10, 13288 0x01, 0xfe, 0xce, 0x1e,
13884 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49, 0x88, 0x20, 0x6e, 0x01, 13289 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x01, 0xfe, 0xee, 0x1e,
13885 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x04, 0x55, 0xfe, 0xa5, 0x55, 0xfe, 0x04, 0xfa, 13290 0x01, 0xfe, 0xfe, 0x1e,
13886 0x64, 0xfe, 0x05, 0xfa, 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x40, 0x56, 0xfe, 13291 0xfe, 0x40, 0x50, 0xfe, 0xc2, 0x50, 0x10, 0x4b, 0x22, 0x4c, 0xfe, 0x8a,
13887 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 13292 0x10, 0x01, 0x0c, 0x06,
13888 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x10, 0x68, 0x22, 0x69, 0x01, 13293 0x54, 0xfe, 0x50, 0x12, 0x01, 0xfe, 0xae, 0x1e, 0x01, 0xfe, 0xbe, 0x1e,
13889 0x0c, 0x06, 0x54, 0xf9, 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b, 0x6b, 0xfe, 0x2c, 0x50, 13294 0x10, 0x6a, 0x22, 0x6b,
13890 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6, 0x50, 0x03, 0x68, 0x3b, 13295 0x01, 0x0c, 0x06, 0x65, 0x4e, 0x01, 0xc2, 0x0f, 0xfe, 0x1f, 0x80, 0x04,
13891 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x4b, 0x3b, 0x4c, 0xfe, 0x40, 0x50, 0xfe, 0xc2, 13296 0xfe, 0x9f, 0x83, 0x33,
13892 0x50, 0x05, 0x73, 0x2e, 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08, 0x16, 0x3d, 0x27, 0x25, 13297 0x0b, 0x0e, 0x20, 0x6e, 0x0f, 0xfe, 0x44, 0x90, 0x04, 0xfe, 0xc4, 0x93,
13893 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01, 0xa6, 0x23, 0x3f, 0x1b, 13298 0x3a, 0x0b, 0xfe, 0xc6,
13894 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0xfe, 0x0a, 0x55, 0x31, 13299 0x90, 0x04, 0xfe, 0xc6, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0x6c, 0x22, 0x6d,
13895 0xfe, 0x8b, 0x55, 0xd9, 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e, 0x51, 0x05, 0x72, 0x01, 13300 0x01, 0xfe, 0xce, 0x1e,
13896 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0, 13301 0x01, 0xfe, 0xde, 0x1e, 0x10, 0x68, 0x22, 0x69, 0x0f, 0xfe, 0x40, 0x90,
13897 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d, 0x83, 0x2d, 0x7f, 0x1b, 0xfe, 0x66, 0x15, 0x05, 13302 0x04, 0xfe, 0xc0, 0x93,
13898 0x3d, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d, 0x2b, 0x3d, 0x01, 0x08, 13303 0x3a, 0x0b, 0xfe, 0xc2, 0x90, 0x04, 0xfe, 0xc2, 0x93, 0x79, 0x0b, 0x0e,
13899 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03, 0xb6, 0x1e, 0x83, 0x01, 13304 0x10, 0x4b, 0x22, 0x4c,
13900 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45, 0x2d, 0x00, 0xa4, 0x46, 0x07, 0x90, 0x3f, 0x01, 13305 0x10, 0x64, 0x22, 0x34, 0x01, 0x0c, 0x61, 0x24, 0x44, 0x37, 0x13, 0xfe,
13901 0xfe, 0xf8, 0x15, 0x01, 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13, 0x01, 0x43, 0x09, 0x82, 13306 0x4e, 0x11, 0x2f, 0xfe,
13902 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e, 0x05, 0x72, 0xfe, 0xc0, 13307 0xde, 0x09, 0xfe, 0x9e, 0xf0, 0xfe, 0xf2, 0x09, 0xfe, 0x01, 0x48, 0x1b,
13903 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x5e, 0x32, 0x01, 0x08, 0x17, 13308 0x3c, 0x37, 0x88, 0xf5,
13904 0x73, 0x01, 0xfe, 0x56, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd, 13309 0xd4, 0xfe, 0x1e, 0x0a, 0xd5, 0xfe, 0x42, 0x0a, 0xd2, 0xfe, 0x1e, 0x0a,
13905 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe, 0xe8, 0x14, 0x01, 0xa6, 13310 0xd3, 0xfe, 0x42, 0x0a,
13906 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe, 0x4a, 0xf4, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 13311 0xae, 0xfe, 0x12, 0x0a, 0xfe, 0x06, 0xf0, 0xfe, 0x18, 0x0a, 0xaf, 0xa0,
13907 0x09, 0x82, 0x4e, 0x05, 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 13312 0x05, 0x29, 0x01, 0x41,
13908 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d, 0x27, 0x25, 0xbd, 0x09, 13313 0xfe, 0xc1, 0x10, 0x14, 0x24, 0xfe, 0xc1, 0x10, 0x01, 0x76, 0x06, 0x07,
13909 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b, 0xfe, 0xaa, 0x14, 0xfe, 0xb6, 0x14, 0x86, 0xa8, 13314 0xfe, 0x14, 0x12, 0x01,
13910 0xb2, 0x0d, 0x1b, 0x3d, 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09, 0x82, 0x4e, 0x05, 0x72, 13315 0x76, 0x06, 0x0d, 0x5d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x74, 0x12, 0xfe,
13911 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01, 0xfe, 0xc0, 0x19, 0x05, 13316 0x2e, 0x1c, 0x05, 0xfe,
13912 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17, 0xfe, 0xe2, 0x15, 0x5f, 0xcc, 0x01, 0x08, 0x26, 13317 0x1a, 0x0c, 0x01, 0x76, 0x06, 0x07, 0x5d, 0x01, 0x76, 0x06, 0x0d, 0x41,
13913 0x5f, 0x02, 0x8f, 0xfe, 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe, 0xcc, 0x15, 0x5e, 0x32, 13318 0xfe, 0x2c, 0x1c, 0xfe,
13914 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 0x23, 0xfe, 0xff, 13319 0xaa, 0xf0, 0xfe, 0xce, 0x0a, 0xfe, 0xac, 0xf0, 0xfe, 0x66, 0x0a, 0xfe,
13915 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xad, 13320 0x92, 0x10, 0xc4, 0xf6,
13916 0x23, 0x3f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 13321 0xfe, 0xad, 0xf0, 0xfe, 0x72, 0x0a, 0x05, 0xfe, 0x1a, 0x0c, 0xc5, 0xfe,
13917 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e, 0x02, 0x13, 0x58, 0xff, 13322 0xe7, 0x10, 0xfe, 0x2b,
13918 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58, 0x02, 0x0a, 0x66, 0x01, 0x5c, 0x0a, 0x55, 0x01, 13323 0xf0, 0xbf, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xfe, 0xfe, 0x1c, 0x12,
13919 0x5c, 0x0a, 0x6f, 0x01, 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a, 0xff, 0x03, 0x00, 0x54, 13324 0xac, 0xfe, 0xd2, 0xf0,
13920 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07, 0x7c, 0x3a, 0x0b, 0x0e, 13325 0xbf, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x1b, 0xbf, 0x03, 0xe3, 0x23, 0x07,
13921 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a, 0x19, 0xfe, 0xfb, 0x19, 0xfe, 0x1a, 0xf7, 0x00, 13326 0x1b, 0xbf, 0xd4, 0x5b,
13922 0xfe, 0x1b, 0xf7, 0x00, 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c, 0xda, 0x6d, 0x02, 0xfe, 13327 0xd5, 0x5b, 0xd2, 0x5b, 0xd3, 0x5b, 0xc4, 0xc5, 0xfe, 0xa9, 0x10, 0x75,
13923 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77, 0x02, 0x01, 0xc6, 0xfe, 13328 0x5e, 0x32, 0x1f, 0x7f,
13924 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xbe, 0x01, 0x08, 13329 0x01, 0x42, 0x19, 0xfe, 0x35, 0x00, 0xfe, 0x01, 0xf0, 0x70, 0x19, 0x98,
13925 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59, 0x03, 0x9a, 0x1e, 0xfe, 13330 0x05, 0x70, 0xfe, 0x74,
13926 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12, 0x48, 0xfe, 0x08, 0x17, 13331 0x18, 0x23, 0xfe, 0x00, 0xf8, 0x1b, 0x5b, 0x7d, 0x12, 0x01, 0xfe, 0x78,
13927 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d, 0xb4, 0x7b, 0xfe, 0x26, 0x17, 0x4d, 0x13, 0x07, 13332 0x0f, 0x4d, 0x01, 0xfe,
13928 0x1c, 0xb4, 0x90, 0x04, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1, 0xff, 0x02, 0x83, 0x55, 13333 0x96, 0x1a, 0x21, 0x30, 0x77, 0x7d, 0x1d, 0x05, 0x5b, 0x01, 0x0c, 0x06,
13929 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x1c, 0x63, 0x13, 13334 0x0d, 0x2b, 0xfe, 0xe2,
13930 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16, 0x13, 0xd6, 0xfe, 0x64, 0x00, 0xb0, 0xfe, 0x80, 13335 0x0b, 0x01, 0x0c, 0x06, 0x54, 0xfe, 0xa6, 0x12, 0x01, 0x0c, 0x06, 0x24,
13931 0x17, 0x0a, 0xfe, 0x64, 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10, 0x53, 0x07, 0xfe, 0x60, 13336 0xfe, 0x88, 0x13, 0x21,
13932 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8, 0x00, 0x1c, 0x95, 0x13, 13337 0x6e, 0xc7, 0x01, 0xfe, 0x1e, 0x1f, 0x0f, 0xfe, 0x83, 0x80, 0x04, 0xfe,
13933 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0x8c, 0x17, 0x45, 0xf3, 0xfe, 0x43, 0xf4, 0x96, 13338 0x83, 0x83, 0xfe, 0xc9,
13934 0xfe, 0x56, 0xf0, 0xfe, 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43, 0xf4, 0x94, 0xf6, 0x8b, 13339 0x47, 0x0b, 0x0e, 0xfe, 0xc8, 0x44, 0xfe, 0x42, 0x13, 0x0f, 0xfe, 0x04,
13935 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x49, 13340 0x91, 0x04, 0xfe, 0x84,
13936 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x80, 0x71, 0x50, 0x26, 0xfe, 13341 0x93, 0xfe, 0xca, 0x57, 0x0b, 0xfe, 0x86, 0x91, 0x04, 0xfe, 0x86, 0x93,
13937 0x4d, 0xf4, 0x00, 0xf7, 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3, 0x58, 0x02, 0x50, 0x13, 13342 0xfe, 0xcb, 0x57, 0x0b,
13938 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xbe, 0xfe, 0x03, 13343 0x0e, 0x7a, 0x30, 0xfe, 0x40, 0x59, 0xfe, 0xc1, 0x59, 0x8e, 0x40, 0x03,
13939 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0x01, 0x08, 0x16, 13344 0x6a, 0x3b, 0x6b, 0x10,
13940 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01, 0x01, 0x08, 0x16, 0xa9, 13345 0x97, 0x22, 0x98, 0xd9, 0x6a, 0xda, 0x6b, 0x01, 0xc2, 0xc8, 0x7a, 0x30,
13941 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27, 13346 0x20, 0x6e, 0xdb, 0x64,
13942 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01, 0x03, 0xb6, 0x1e, 0x83, 0x01, 0x38, 0x06, 0x24, 13347 0xdc, 0x34, 0x91, 0x6c, 0x7e, 0x6d, 0xfe, 0x44, 0x55, 0xfe, 0xe5, 0x55,
13943 0x31, 0xa2, 0x78, 0xf2, 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1, 0x78, 0x03, 0x9a, 0x1e, 13348 0xfe, 0x04, 0xfa, 0x64,
13944 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10, 0xfe, 0x40, 0x5a, 0x23, 13349 0xfe, 0x05, 0xfa, 0x34, 0x01, 0xfe, 0x6a, 0x16, 0xa3, 0x26, 0x10, 0x97,
13945 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x49, 0x71, 0x8c, 0x80, 0x48, 0xfe, 0xaa, 13350 0x10, 0x98, 0x91, 0x6c,
13946 0x18, 0x62, 0x80, 0xfe, 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01, 0xfe, 0xac, 0x1d, 0xfe, 13351 0x7e, 0x6d, 0xfe, 0x14, 0x10, 0x01, 0x0c, 0x06, 0x24, 0x1b, 0x40, 0x91,
13947 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe, 0x43, 0x48, 0x2d, 0x93, 13352 0x4b, 0x7e, 0x4c, 0x01,
13948 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe, 0x40, 0x10, 0x2d, 0xb4, 0x36, 0xfe, 0x34, 0xf4, 13353 0x0c, 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x10,
13949 0x04, 0xfe, 0x34, 0x10, 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe, 0x28, 0x10, 0xfe, 0xc0, 13354 0x58, 0xfe, 0x91, 0x58,
13950 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa, 0x18, 0x45, 0xfe, 0x1c, 13355 0xfe, 0x14, 0x59, 0xfe, 0x95, 0x59, 0x05, 0x5b, 0x01, 0x0c, 0x06, 0x24,
13951 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe, 0x0c, 0x19, 0xfe, 0x04, 0xf4, 13356 0x1b, 0x40, 0x01, 0x0c,
13952 0x58, 0xfe, 0x40, 0xf4, 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d, 0x21, 0xfe, 0x7f, 0x01, 13357 0x06, 0xfe, 0xf7, 0x00, 0x44, 0x78, 0x01, 0xfe, 0x8e, 0x1e, 0x4f, 0x0f,
13953 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe, 0x7e, 0x01, 0xfe, 0xc8, 13358 0xfe, 0x10, 0x90, 0x04,
13954 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01, 0xfe, 0x48, 0x45, 0xfa, 0x21, 0xfe, 0x81, 0x01, 13359 0xfe, 0x90, 0x93, 0x3a, 0x0b, 0xfe, 0x92, 0x90, 0x04, 0xfe, 0x92, 0x93,
13955 0xfe, 0xc8, 0x44, 0x4e, 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50, 0x13, 0x0d, 0x02, 0x14, 13360 0x79, 0x0b, 0x0e, 0xfe,
13956 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 13361 0xbd, 0x10, 0x01, 0x43, 0x09, 0xbb, 0x1b, 0xfe, 0x6e, 0x0a, 0x15, 0xbb,
13957 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x02, 0x14, 0x07, 13362 0x01, 0x0c, 0x06, 0x0d,
13958 0x01, 0x08, 0x17, 0xc1, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07, 0x01, 0x08, 0x17, 0xc1, 13363 0xfe, 0x14, 0x13, 0x03, 0x4b, 0x3b, 0x4c, 0x8e, 0xfe, 0x6e, 0x0a, 0xfe,
13959 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01, 0x08, 0x02, 0x50, 0x02, 13364 0x0c, 0x58, 0xfe, 0x8d,
13960 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f, 0x01, 0x08, 0x17, 0x74, 0x14, 0x12, 0x01, 0x08, 13365 0x58, 0x05, 0x5b, 0x26, 0x3e, 0x0f, 0xfe, 0x19, 0x80, 0x04, 0xfe, 0x99,
13961 0x17, 0x74, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01, 0x08, 0x17, 0x74, 0xfe, 13366 0x83, 0x33, 0x0b, 0x0e,
13962 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17, 0x74, 0x5f, 0xcc, 0x01, 13367 0xfe, 0xe5, 0x10, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1a, 0x12, 0xfe, 0x6c,
13963 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c, 0x13, 0xc8, 0x20, 0xe4, 0xfe, 0x49, 0xf4, 0x00, 13368 0x19, 0xfe, 0x19, 0x41,
13964 0x4d, 0x5f, 0xa1, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff, 0x02, 0x00, 0x10, 0x2f, 13369 0xfe, 0x6b, 0x18, 0xac, 0xfe, 0xd1, 0xf0, 0xef, 0x1f, 0x92, 0x01, 0x42,
13965 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13, 0x16, 0xfe, 0x64, 0x1a, 13370 0x19, 0xfe, 0x44, 0x00,
13966 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09, 0x07, 0x5d, 0x01, 0x0c, 0x61, 0x07, 0x44, 0x02, 13371 0xfe, 0x90, 0x10, 0xfe, 0x6c, 0x19, 0xd9, 0x4b, 0xfe, 0xed, 0x19, 0xda,
13967 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 13372 0x4c, 0xfe, 0x0c, 0x51,
13968 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa, 0xfe, 0x80, 0xe7, 0x1a, 13373 0xfe, 0x8e, 0x51, 0xfe, 0x6b, 0x18, 0x23, 0xfe, 0x00, 0xff, 0x31, 0xfe,
13969 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe, 0xb2, 0x16, 0xaa, 0x02, 0x0a, 0x5a, 0x01, 0x18, 13374 0x76, 0x10, 0xac, 0xfe,
13970 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe, 0x7e, 0x1e, 0xfe, 0x80, 13375 0xd2, 0xf0, 0xfe, 0xba, 0x0c, 0xfe, 0x76, 0x18, 0x23, 0x1d, 0x5d, 0x03,
13971 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x0a, 13376 0xe3, 0x23, 0x07, 0xfe,
13972 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c, 0xe5, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 13377 0x08, 0x13, 0x19, 0xfe, 0x16, 0x00, 0x05, 0x70, 0xfe, 0xd1, 0xf0, 0xfe,
13973 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe, 0x2a, 0x1c, 0xfa, 0xb3, 13378 0xcc, 0x0c, 0x1f, 0x92,
13974 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe, 0xf4, 0x1a, 0xfe, 0xfa, 13379 0x01, 0x42, 0x19, 0xfe, 0x17, 0x00, 0x5c, 0xfe, 0xce, 0xf0, 0xfe, 0xd2,
13975 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x24, 0xfe, 0x18, 0x58, 0x03, 13380 0x0c, 0xfe, 0x3e, 0x10,
13976 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f, 0xfe, 0x30, 0xf4, 0x07, 13381 0xfe, 0xcd, 0xf0, 0xfe, 0xde, 0x0c, 0x19, 0xfe, 0x22, 0x00, 0x05, 0x70,
13977 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c, 0xf7, 0x24, 0xb1, 0xfe, 13382 0xfe, 0xcb, 0xf0, 0xfe,
13978 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x26, 0x1b, 0xfe, 0xba, 0x10, 0x1c, 13383 0xea, 0x0c, 0x19, 0xfe, 0x24, 0x00, 0x05, 0x70, 0xfe, 0xd0, 0xf0, 0xfe,
13979 0x1a, 0x87, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe, 0x1d, 0xf7, 0x54, 0xb1, 13384 0xf4, 0x0c, 0x19, 0x94,
13980 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe, 0xaf, 0x19, 0xfe, 0x98, 13385 0xfe, 0x1c, 0x10, 0xfe, 0xcf, 0xf0, 0xfe, 0xfe, 0x0c, 0x19, 0x4a, 0xf3,
13981 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b, 0xfe, 0x8a, 0x10, 0x1c, 0x1a, 0x87, 0x8b, 0x0f, 13386 0xfe, 0xcc, 0xf0, 0xef,
13982 0xfe, 0x30, 0x90, 0x04, 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58, 0xfe, 0x32, 0x90, 0x04, 13387 0x01, 0x76, 0x06, 0x24, 0x4d, 0x19, 0xfe, 0x12, 0x00, 0x37, 0x13, 0xfe,
13983 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a, 0x7c, 0x12, 0xfe, 0x0f, 13388 0x4e, 0x11, 0x2f, 0xfe,
13984 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6, 0x1b, 0xfe, 0x5e, 0x14, 0x31, 0x02, 0xc9, 0x2b, 13389 0x16, 0x0d, 0xfe, 0x9e, 0xf0, 0xfe, 0x2a, 0x0d, 0xfe, 0x01, 0x48, 0x1b,
13985 0xfe, 0x96, 0x1b, 0x5c, 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe, 0x6a, 0xfe, 0x19, 0xfe, 13390 0x3c, 0x37, 0x88, 0xf5,
13986 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee, 0x1b, 0xfe, 0x36, 0x14, 13391 0xd4, 0x29, 0xd5, 0x29, 0xd2, 0x29, 0xd3, 0x29, 0x37, 0xfe, 0x9c, 0x32,
13987 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19, 0xfe, 0x80, 0xe7, 0x1a, 13392 0x2f, 0xfe, 0x3e, 0x0d,
13988 0xfe, 0x81, 0xe7, 0x1a, 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a, 0x30, 0xfe, 0x12, 0x45, 13393 0x2a, 0x3c, 0xae, 0xfe, 0x62, 0x0d, 0xaf, 0xa0, 0xd4, 0x9f, 0xd5, 0x9f,
13989 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe, 0x39, 0xf0, 0x75, 0x26, 13394 0xd2, 0x9f, 0xd3, 0x9f,
13990 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13, 0x11, 0x02, 0x87, 0x03, 0xe3, 0x23, 0x07, 0xfe, 13395 0x05, 0x29, 0x01, 0x41, 0xfe, 0xd3, 0x10, 0x15, 0xfe, 0xe8, 0x00, 0xc4,
13991 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09, 0x56, 0xfe, 0x3c, 0x13, 13396 0xc5, 0x75, 0xd7, 0x99,
13992 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe, 13397 0xd8, 0x9c, 0xfe, 0x89, 0xf0, 0x29, 0x27, 0x25, 0xbe, 0xd7, 0x99, 0xd8,
13993 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 13398 0x9c, 0x2f, 0xfe, 0x8c,
13994 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x4c, 0x01, 13399 0x0d, 0x16, 0x29, 0x27, 0x25, 0xbd, 0xfe, 0x01, 0x48, 0xa4, 0x19, 0xfe,
13995 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24, 0x12, 0xfe, 0x14, 0x56, 13400 0x42, 0x00, 0x05, 0x70,
13996 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d, 0x02, 0xfe, 0x9c, 0xe7, 0x0d, 0x19, 0xfe, 0x15, 13401 0x90, 0x07, 0xfe, 0x81, 0x49, 0x1b, 0xfe, 0x64, 0x0e, 0x01, 0x0c, 0x06,
13997 0x00, 0x40, 0x8d, 0x30, 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06, 0x83, 0xfe, 0x18, 0x80, 13402 0x0d, 0xfe, 0x44, 0x13,
13998 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38, 0x90, 0xfe, 0xba, 0x90, 13403 0x19, 0x00, 0x2d, 0x0d, 0xfe, 0x54, 0x12, 0x2d, 0xfe, 0x28, 0x00, 0x2b,
13999 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31, 0xfe, 0xc9, 0x55, 0x02, 0x21, 0xb9, 0x88, 0x20, 13404 0xfe, 0xda, 0x0e, 0x0a,
14000 0xb9, 0x02, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01, 0x18, 0xfe, 0x49, 0x44, 13405 0x57, 0x01, 0x18, 0x09, 0x00, 0x36, 0x46, 0xfe, 0x28, 0x00, 0xfe, 0xfa,
14001 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09, 0x1a, 0xa4, 0x0a, 0x67, 13406 0x10, 0x01, 0xfe, 0xf4,
14002 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89, 0x02, 0xfe, 0x4e, 0xe4, 0x1d, 0x7b, 0xfe, 0x52, 13407 0x1c, 0x01, 0xfe, 0x00, 0x1d, 0x0a, 0xba, 0x01, 0xfe, 0x58, 0x10, 0x40,
14003 0x1d, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe, 0x4e, 0xe4, 0xdd, 0x7b, 13408 0x15, 0x56, 0x01, 0x85,
14004 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10, 0xfe, 0x4e, 0xe4, 0xfe, 13409 0x05, 0x35, 0x19, 0xfe, 0x44, 0x00, 0x2d, 0x0d, 0xf7, 0x46, 0x0d, 0xfe,
14005 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe, 0x94, 0x00, 0xd1, 0x24, 0xfe, 0x08, 0x10, 0x03, 13410 0xcc, 0x10, 0x01, 0xa7,
14006 0xfe, 0x96, 0x00, 0xd1, 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04, 0x68, 0x54, 0xfe, 0xf1, 13411 0x46, 0x0d, 0xfe, 0xc2, 0x10, 0x01, 0xa7, 0x0f, 0xfe, 0x19, 0x82, 0x04,
14007 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c, 0xfe, 0x1a, 0xf4, 0xfe, 13412 0xfe, 0x99, 0x83, 0xfe,
14008 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa, 0x1d, 0x13, 0x1d, 0x02, 0x09, 0x92, 0xfe, 0x5a, 13413 0xcc, 0x47, 0x0b, 0x0e, 0xfe, 0x34, 0x46, 0xa5, 0x46, 0x0d, 0x19, 0xfe,
14009 0xf0, 0xfe, 0xba, 0x1d, 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe, 0x5a, 0xf0, 0xfe, 0xc8, 13414 0x43, 0x00, 0xfe, 0xa2,
14010 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe, 0x1a, 0x10, 0x09, 0x0d, 13415 0x10, 0x01, 0x0c, 0x61, 0x0d, 0x44, 0x01, 0xfe, 0xf4, 0x1c, 0x01, 0xfe,
14011 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e, 0x95, 0xa1, 0xc8, 0x02, 0x1f, 0x93, 0x01, 0x42, 13416 0x00, 0x1d, 0x40, 0x15,
14012 0xfe, 0x04, 0xfe, 0x99, 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e, 0xfe, 0x14, 0xf0, 0x08, 13417 0x56, 0x01, 0x85, 0x7d, 0x0d, 0x40, 0x51, 0x01, 0xfe, 0x9e, 0x1e, 0x05,
14013 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e, 0xfe, 0x82, 0xf0, 0xfe, 13418 0xfe, 0x3a, 0x03, 0x01,
14014 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x18, 13419 0x0c, 0x06, 0x0d, 0x5d, 0x46, 0x0d, 0x19, 0x00, 0xfe, 0x62, 0x10, 0x01,
14015 0x80, 0x04, 0xfe, 0x98, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02, 0x80, 0x04, 0xfe, 0x82, 13420 0x76, 0x06, 0x12, 0xfe,
14016 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86, 0x83, 0x33, 0x0b, 0x0e, 13421 0x5c, 0x12, 0x01, 0x0c, 0x06, 0x12, 0xfe, 0x52, 0x13, 0xfe, 0x1c, 0x1c,
14017 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x04, 13422 0xfe, 0x9d, 0xf0, 0xfe,
14018 0x80, 0x04, 0xfe, 0x84, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80, 0x80, 0x04, 0xfe, 0x80, 13423 0x8e, 0x0e, 0xfe, 0x1c, 0x1c, 0xfe, 0x9d, 0xf0, 0xfe, 0x94, 0x0e, 0x01,
14019 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04, 0xfe, 0x99, 0x83, 0xfe, 13424 0x0c, 0x61, 0x12, 0x44,
14020 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x83, 0x04, 0xfe, 0x86, 0x83, 0xfe, 0xce, 0x47, 13425 0xfe, 0x9f, 0x10, 0x19, 0xfe, 0x15, 0x00, 0xfe, 0x04, 0xe6, 0x0d, 0x4f,
14021 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f, 13426 0xfe, 0x2e, 0x10, 0x19,
14022 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x08, 0x90, 0x04, 13427 0xfe, 0x13, 0x00, 0xfe, 0x10, 0x10, 0x19, 0xfe, 0x47, 0x00, 0xf1, 0x19,
14023 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x8a, 0x90, 0x04, 0xfe, 0x8a, 0x93, 0x79, 13428 0xfe, 0x41, 0x00, 0xa2,
14024 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f, 13429 0x19, 0xfe, 0x24, 0x00, 0x86, 0xc4, 0xc5, 0x75, 0x03, 0x81, 0x1e, 0x2b,
14025 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x3c, 0x90, 0x04, 13430 0xea, 0x4f, 0xfe, 0x04,
14026 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 13431 0xe6, 0x12, 0xfe, 0x9d, 0x41, 0xfe, 0x1c, 0x42, 0x40, 0x01, 0xf4, 0x05,
14027 0x33, 0x0b, 0x77, 0x0e, 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00, 13432 0x35, 0xfe, 0x12, 0x1c,
13433 0x1f, 0x0d, 0x47, 0xb5, 0xc3, 0x1f, 0xfe, 0x31, 0x00, 0x47, 0xb8, 0x01,
13434 0xfe, 0xd4, 0x11, 0x05,
13435 0xe9, 0x51, 0xfe, 0x06, 0xec, 0xe0, 0xfe, 0x0e, 0x47, 0x46, 0x28, 0xfe,
13436 0xce, 0x45, 0x31, 0x51,
13437 0xfe, 0x06, 0xea, 0xe0, 0xfe, 0x47, 0x4b, 0x45, 0xfe, 0x75, 0x57, 0x03,
13438 0x67, 0xfe, 0x98, 0x56,
13439 0xfe, 0x38, 0x12, 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x44, 0x48, 0x60, 0x01,
13440 0x0c, 0x06, 0x28, 0xfe,
13441 0x18, 0x13, 0x0a, 0x57, 0x01, 0x18, 0x3e, 0xfe, 0x41, 0x58, 0x0a, 0xba,
13442 0xfe, 0xfa, 0x14, 0xfe,
13443 0x49, 0x54, 0xb0, 0xfe, 0x5e, 0x0f, 0x05, 0xfe, 0x3a, 0x03, 0x0a, 0x67,
13444 0xfe, 0xe0, 0x14, 0xfe,
13445 0x0e, 0x47, 0x46, 0x28, 0xfe, 0xce, 0x45, 0x31, 0x51, 0xfe, 0xce, 0x47,
13446 0xfe, 0xad, 0x13, 0x05,
13447 0x35, 0x21, 0x2c, 0x09, 0x1a, 0xfe, 0x98, 0x12, 0x26, 0x20, 0x96, 0x20,
13448 0xe7, 0xfe, 0x08, 0x1c,
13449 0xfe, 0x7c, 0x19, 0xfe, 0xfd, 0x19, 0xfe, 0x0a, 0x1c, 0x03, 0xe5, 0xfe,
13450 0x48, 0x55, 0xa5, 0x3b,
13451 0xfe, 0x62, 0x01, 0xfe, 0xc9, 0x55, 0x31, 0xfe, 0x74, 0x10, 0x01, 0xfe,
13452 0xf0, 0x1a, 0x03, 0xfe,
13453 0x38, 0x01, 0x3b, 0xfe, 0x3a, 0x01, 0x8e, 0xfe, 0x1e, 0x10, 0xfe, 0x02,
13454 0xec, 0xe7, 0x53, 0x00,
13455 0x36, 0xfe, 0x04, 0xec, 0x2c, 0x60, 0xfe, 0x05, 0xf6, 0xfe, 0x34, 0x01,
13456 0x01, 0xfe, 0x62, 0x1b,
13457 0x01, 0xfe, 0xce, 0x1e, 0xb2, 0x11, 0xfe, 0x18, 0x13, 0xca, 0xfe, 0x02,
13458 0xea, 0xe7, 0x53, 0x92,
13459 0xfe, 0xc3, 0x13, 0x1f, 0x12, 0x47, 0xb5, 0xc3, 0xfe, 0x2a, 0x10, 0x03,
13460 0xfe, 0x38, 0x01, 0x23,
13461 0xfe, 0xf0, 0xff, 0x10, 0xe5, 0x03, 0xfe, 0x3a, 0x01, 0x10, 0xfe, 0x62,
13462 0x01, 0x01, 0xfe, 0x1e,
13463 0x1e, 0x20, 0x2c, 0x15, 0x56, 0x01, 0xfe, 0x9e, 0x1e, 0x13, 0x07, 0x02,
13464 0x26, 0x02, 0x21, 0x96,
13465 0xc7, 0x20, 0x96, 0x09, 0x92, 0xfe, 0x79, 0x13, 0x1f, 0x1d, 0x47, 0xb5,
13466 0xc3, 0xfe, 0xe1, 0x10,
13467 0xcf, 0xfe, 0x03, 0xdc, 0xfe, 0x73, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xcf,
13468 0xfe, 0x03, 0xdc, 0xfe,
13469 0x5b, 0x57, 0xfe, 0x80, 0x5d, 0x02, 0xfe, 0x03, 0x57, 0xcf, 0x26, 0xfe,
13470 0x00, 0xcc, 0x02, 0xfe,
13471 0x03, 0x57, 0xcf, 0x89, 0x02, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13,
13472 0x0f, 0xfe, 0x1c, 0x80,
13473 0x04, 0xfe, 0x9c, 0x83, 0x33, 0x0b, 0x0e, 0x09, 0x07, 0xfe, 0x3a, 0x13,
13474 0x0f, 0xfe, 0x1e, 0x80,
13475 0x04, 0xfe, 0x9e, 0x83, 0x33, 0x0b, 0x0e, 0xfe, 0x2a, 0x13, 0x0f, 0xfe,
13476 0x1d, 0x80, 0x04, 0xfe,
13477 0x9d, 0x83, 0xfe, 0xf9, 0x13, 0x0e, 0xfe, 0x1c, 0x13, 0x01, 0xfe, 0xee,
13478 0x1e, 0xac, 0xfe, 0x14,
13479 0x13, 0x01, 0xfe, 0xfe, 0x1e, 0xfe, 0x81, 0x58, 0xfa, 0x01, 0xfe, 0x0e,
13480 0x1f, 0xfe, 0x30, 0xf4,
13481 0x0d, 0xfe, 0x3c, 0x50, 0xa2, 0x01, 0xfe, 0x92, 0x1b, 0x01, 0x43, 0x09,
13482 0x56, 0xfb, 0x01, 0xfe,
13483 0xc8, 0x1a, 0x01, 0x0c, 0x06, 0x28, 0xa4, 0x01, 0xfe, 0xf4, 0x1c, 0x01,
13484 0xfe, 0x00, 0x1d, 0x15,
13485 0xfe, 0xe9, 0x00, 0x01, 0x0c, 0x06, 0x4a, 0xfe, 0x4e, 0x13, 0x01, 0xfe,
13486 0x22, 0x1b, 0xfe, 0x1e,
13487 0x1c, 0x0f, 0xfe, 0x14, 0x90, 0x04, 0xfe, 0x94, 0x93, 0x3a, 0x0b, 0xfe,
13488 0x96, 0x90, 0x04, 0xfe,
13489 0x96, 0x93, 0x79, 0x0b, 0x0e, 0x10, 0xfe, 0x64, 0x01, 0x22, 0xfe, 0x66,
13490 0x01, 0x01, 0x0c, 0x06,
13491 0x65, 0xf9, 0x0f, 0xfe, 0x03, 0x80, 0x04, 0xfe, 0x83, 0x83, 0x33, 0x0b,
13492 0x0e, 0x77, 0xfe, 0x01,
13493 0xec, 0x2c, 0xfe, 0x80, 0x40, 0x20, 0x2c, 0x7a, 0x30, 0x15, 0xdf, 0x40,
13494 0x21, 0x2c, 0xfe, 0x00,
13495 0x40, 0x8d, 0x2c, 0x02, 0xfe, 0x08, 0x1c, 0x03, 0xfe, 0xac, 0x00, 0xfe,
13496 0x06, 0x58, 0x03, 0xfe,
13497 0xae, 0x00, 0xfe, 0x07, 0x58, 0x03, 0xfe, 0xb0, 0x00, 0xfe, 0x08, 0x58,
13498 0x03, 0xfe, 0xb2, 0x00,
13499 0xfe, 0x09, 0x58, 0xfe, 0x0a, 0x1c, 0x2e, 0x49, 0x20, 0xe0, 0x26, 0x10,
13500 0x66, 0x10, 0x55, 0x10,
13501 0x6f, 0x13, 0x57, 0x52, 0x4f, 0x1c, 0x28, 0xfe, 0x90, 0x4d, 0xfe, 0x91,
13502 0x54, 0x2b, 0xfe, 0x88,
13503 0x11, 0x46, 0x1a, 0x13, 0x5a, 0x52, 0x1c, 0x4a, 0xfe, 0x90, 0x4d, 0xfe,
13504 0x91, 0x54, 0x2b, 0xfe,
13505 0x9e, 0x11, 0x2e, 0x1a, 0x20, 0x2c, 0x90, 0x34, 0x60, 0x21, 0x2c, 0xfe,
13506 0x00, 0x40, 0x8d, 0x2c,
13507 0x15, 0xdf, 0xfe, 0x14, 0x56, 0xfe, 0xd6, 0xf0, 0xfe, 0xb2, 0x11, 0xfe,
13508 0x12, 0x1c, 0x75, 0xfe,
13509 0x14, 0x1c, 0xfe, 0x10, 0x1c, 0xfe, 0x18, 0x1c, 0x02, 0x51, 0xfe, 0x0c,
13510 0x14, 0xfe, 0x0e, 0x47,
13511 0xfe, 0x07, 0xe6, 0x28, 0xfe, 0xce, 0x47, 0xfe, 0xf5, 0x13, 0x02, 0x01,
13512 0xa7, 0x90, 0x34, 0x60,
13513 0xfe, 0x06, 0x80, 0xfe, 0x48, 0x47, 0xfe, 0x42, 0x13, 0xfe, 0x02, 0x80,
13514 0x09, 0x56, 0xfe, 0x34,
13515 0x13, 0x0a, 0x5a, 0x01, 0x18, 0xcb, 0xfe, 0x36, 0x12, 0xfe, 0x41, 0x48,
13516 0xfe, 0x45, 0x48, 0x01,
13517 0xfe, 0xb2, 0x16, 0xfe, 0x00, 0xcc, 0xcb, 0xfe, 0xf3, 0x13, 0x3f, 0x89,
13518 0x09, 0x1a, 0xa5, 0x0a,
13519 0x9d, 0x01, 0x18, 0xfe, 0x80, 0x5c, 0x01, 0x85, 0xf2, 0x09, 0x9b, 0xa4,
13520 0xfe, 0x14, 0x56, 0xfe,
13521 0xd6, 0xf0, 0xfe, 0xec, 0x11, 0x02, 0xfe, 0x44, 0x58, 0x77, 0xfe, 0x01,
13522 0xec, 0xb8, 0xfe, 0x9e,
13523 0x40, 0xfe, 0x9d, 0xe7, 0x00, 0xfe, 0x9c, 0xe7, 0x12, 0x8d, 0x30, 0x01,
13524 0xf4, 0xfe, 0xdd, 0x10,
13525 0x37, 0xd7, 0x99, 0xd8, 0x9c, 0x27, 0x25, 0xee, 0x09, 0x12, 0xfe, 0x48,
13526 0x12, 0x09, 0x0d, 0xfe,
13527 0x56, 0x12, 0x09, 0x1d, 0xfe, 0x30, 0x12, 0x09, 0xdd, 0x1b, 0xfe, 0xc4,
13528 0x13, 0x09, 0xfe, 0x23,
13529 0x00, 0x1b, 0xfe, 0xd0, 0x13, 0x09, 0x07, 0x1b, 0xfe, 0x34, 0x14, 0x09,
13530 0x24, 0xfe, 0x12, 0x12,
13531 0x09, 0x00, 0x1b, 0x29, 0x1f, 0xdd, 0x01, 0x42, 0xa1, 0x32, 0x01, 0x08,
13532 0xae, 0x41, 0x02, 0x32,
13533 0xfe, 0x62, 0x08, 0x0a, 0xe1, 0x01, 0xfe, 0x58, 0x10, 0x15, 0x9b, 0x05,
13534 0x35, 0x32, 0x01, 0x43,
13535 0x09, 0xbb, 0xfe, 0xd7, 0x13, 0x91, 0x4b, 0x7e, 0x4c, 0x8e, 0xfe, 0x80,
13536 0x13, 0x01, 0x0c, 0x06,
13537 0x54, 0xfe, 0x72, 0x12, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x44, 0x55, 0xfe,
13538 0xe5, 0x55, 0xb0, 0xfe,
13539 0x4a, 0x13, 0x21, 0x6e, 0xfe, 0x26, 0x13, 0x03, 0x97, 0x3b, 0x98, 0x8e,
13540 0xfe, 0xb6, 0x0e, 0x10,
13541 0x6a, 0x22, 0x6b, 0x26, 0x10, 0x97, 0x10, 0x98, 0x01, 0xc2, 0x2e, 0x49,
13542 0x88, 0x20, 0x6e, 0x01,
13543 0xfe, 0x6a, 0x16, 0xdb, 0x64, 0xdc, 0x34, 0xfe, 0x04, 0x55, 0xfe, 0xa5,
13544 0x55, 0xfe, 0x04, 0xfa,
13545 0x64, 0xfe, 0x05, 0xfa, 0x34, 0xfe, 0x8f, 0x10, 0x03, 0x6c, 0x3b, 0x6d,
13546 0xfe, 0x40, 0x56, 0xfe,
13547 0xe1, 0x56, 0x10, 0x6c, 0x22, 0x6d, 0x71, 0xdb, 0x64, 0xdc, 0x34, 0xfe,
13548 0x44, 0x55, 0xfe, 0xe5,
13549 0x55, 0x03, 0x68, 0x3b, 0x69, 0xfe, 0x00, 0x56, 0xfe, 0xa1, 0x56, 0x10,
13550 0x68, 0x22, 0x69, 0x01,
13551 0x0c, 0x06, 0x54, 0xf9, 0x21, 0x6e, 0xfe, 0x1f, 0x40, 0x03, 0x6a, 0x3b,
13552 0x6b, 0xfe, 0x2c, 0x50,
13553 0xfe, 0xae, 0x50, 0x03, 0x6c, 0x3b, 0x6d, 0xfe, 0x44, 0x50, 0xfe, 0xc6,
13554 0x50, 0x03, 0x68, 0x3b,
13555 0x69, 0xfe, 0x08, 0x50, 0xfe, 0x8a, 0x50, 0x03, 0x4b, 0x3b, 0x4c, 0xfe,
13556 0x40, 0x50, 0xfe, 0xc2,
13557 0x50, 0x05, 0x73, 0x2e, 0x07, 0x20, 0x9e, 0x05, 0x72, 0x32, 0x01, 0x08,
13558 0x16, 0x3d, 0x27, 0x25,
13559 0xee, 0x09, 0x07, 0x2b, 0x3d, 0x01, 0x43, 0x09, 0xbb, 0x2b, 0x72, 0x01,
13560 0xa6, 0x23, 0x3f, 0x1b,
13561 0x3d, 0x01, 0x0c, 0x06, 0x0d, 0xfe, 0x1e, 0x13, 0x91, 0x4b, 0x7e, 0x4c,
13562 0xfe, 0x0a, 0x55, 0x31,
13563 0xfe, 0x8b, 0x55, 0xd9, 0x4b, 0xda, 0x4c, 0xfe, 0x0c, 0x51, 0xfe, 0x8e,
13564 0x51, 0x05, 0x72, 0x01,
13565 0xfe, 0x8e, 0x1e, 0xca, 0xfe, 0x19, 0x41, 0x05, 0x72, 0x32, 0x01, 0x08,
13566 0x2a, 0x3c, 0x16, 0xc0,
13567 0x27, 0x25, 0xbe, 0x2d, 0x1d, 0xc0, 0x2d, 0x0d, 0x83, 0x2d, 0x7f, 0x1b,
13568 0xfe, 0x66, 0x15, 0x05,
13569 0x3d, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0xc0, 0x27, 0x25, 0xbd, 0x09, 0x1d,
13570 0x2b, 0x3d, 0x01, 0x08,
13571 0x16, 0xc0, 0x27, 0x25, 0xfe, 0xe8, 0x09, 0xfe, 0xc2, 0x49, 0x50, 0x03,
13572 0xb6, 0x1e, 0x83, 0x01,
13573 0x38, 0x06, 0x24, 0x31, 0xa1, 0xfe, 0xbb, 0x45, 0x2d, 0x00, 0xa4, 0x46,
13574 0x07, 0x90, 0x3f, 0x01,
13575 0xfe, 0xf8, 0x15, 0x01, 0xa6, 0x86, 0xfe, 0x4b, 0x45, 0xfe, 0x20, 0x13,
13576 0x01, 0x43, 0x09, 0x82,
13577 0xfe, 0x16, 0x13, 0x03, 0x9a, 0x1e, 0x5d, 0x03, 0x55, 0x1e, 0x31, 0x5e,
13578 0x05, 0x72, 0xfe, 0xc0,
13579 0x5d, 0x01, 0xa7, 0xfe, 0x03, 0x17, 0x03, 0x66, 0x8a, 0x10, 0x66, 0x5e,
13580 0x32, 0x01, 0x08, 0x17,
13581 0x73, 0x01, 0xfe, 0x56, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16,
13582 0x3d, 0x27, 0x25, 0xbd,
13583 0x09, 0x07, 0x2b, 0x3d, 0x01, 0xfe, 0xbe, 0x16, 0xfe, 0x42, 0x58, 0xfe,
13584 0xe8, 0x14, 0x01, 0xa6,
13585 0x86, 0xfe, 0x4a, 0xf4, 0x0d, 0x1b, 0x3d, 0xfe, 0x4a, 0xf4, 0x07, 0xfe,
13586 0x0e, 0x12, 0x01, 0x43,
13587 0x09, 0x82, 0x4e, 0x05, 0x72, 0x03, 0x55, 0x8a, 0x10, 0x55, 0x5e, 0x32,
13588 0x01, 0x08, 0x17, 0x73,
13589 0x01, 0xfe, 0x84, 0x19, 0x05, 0x73, 0x01, 0x08, 0x2a, 0x3c, 0x16, 0x3d,
13590 0x27, 0x25, 0xbd, 0x09,
13591 0x12, 0x2b, 0x3d, 0x01, 0xfe, 0xe8, 0x17, 0x8b, 0xfe, 0xaa, 0x14, 0xfe,
13592 0xb6, 0x14, 0x86, 0xa8,
13593 0xb2, 0x0d, 0x1b, 0x3d, 0xb2, 0x07, 0xfe, 0x0e, 0x12, 0x01, 0x43, 0x09,
13594 0x82, 0x4e, 0x05, 0x72,
13595 0x03, 0x6f, 0x8a, 0x10, 0x6f, 0x5e, 0x32, 0x01, 0x08, 0x17, 0x73, 0x01,
13596 0xfe, 0xc0, 0x19, 0x05,
13597 0x73, 0x13, 0x07, 0x2f, 0xfe, 0xcc, 0x15, 0x17, 0xfe, 0xe2, 0x15, 0x5f,
13598 0xcc, 0x01, 0x08, 0x26,
13599 0x5f, 0x02, 0x8f, 0xfe, 0xde, 0x15, 0x2a, 0xfe, 0xde, 0x15, 0x16, 0xfe,
13600 0xcc, 0x15, 0x5e, 0x32,
13601 0x01, 0x08, 0xfe, 0xd5, 0x10, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52,
13602 0xad, 0x23, 0xfe, 0xff,
13603 0x7f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff, 0x02,
13604 0x00, 0x57, 0x52, 0xad,
13605 0x23, 0x3f, 0xfe, 0x30, 0x56, 0xfe, 0x00, 0x5c, 0x02, 0x13, 0x58, 0xff,
13606 0x02, 0x00, 0x57, 0x52,
13607 0xad, 0x02, 0x13, 0x58, 0xff, 0x02, 0x00, 0x57, 0x52, 0xfe, 0x00, 0x5e,
13608 0x02, 0x13, 0x58, 0xff,
13609 0x02, 0x00, 0x57, 0x52, 0xad, 0xfe, 0x0b, 0x58, 0x02, 0x0a, 0x66, 0x01,
13610 0x5c, 0x0a, 0x55, 0x01,
13611 0x5c, 0x0a, 0x6f, 0x01, 0x5c, 0x02, 0x01, 0xfe, 0x1e, 0x1f, 0x23, 0x1a,
13612 0xff, 0x03, 0x00, 0x54,
13613 0xfe, 0x00, 0xf4, 0x24, 0x52, 0x0f, 0xfe, 0x00, 0x7c, 0x04, 0xfe, 0x07,
13614 0x7c, 0x3a, 0x0b, 0x0e,
13615 0xfe, 0x00, 0x71, 0xfe, 0xf9, 0x18, 0xfe, 0x7a, 0x19, 0xfe, 0xfb, 0x19,
13616 0xfe, 0x1a, 0xf7, 0x00,
13617 0xfe, 0x1b, 0xf7, 0x00, 0x7a, 0x30, 0x10, 0x68, 0x22, 0x69, 0xd9, 0x6c,
13618 0xda, 0x6d, 0x02, 0xfe,
13619 0x62, 0x08, 0xfe, 0x82, 0x4a, 0xfe, 0xe1, 0x1a, 0xfe, 0x83, 0x5a, 0x77,
13620 0x02, 0x01, 0xc6, 0xfe,
13621 0x42, 0x48, 0x4f, 0x50, 0x45, 0x01, 0x08, 0x16, 0xfe, 0xe0, 0x17, 0x27,
13622 0x25, 0xbe, 0x01, 0x08,
13623 0x16, 0xfe, 0xe0, 0x17, 0x27, 0x25, 0xfe, 0xe8, 0x0a, 0xfe, 0xc1, 0x59,
13624 0x03, 0x9a, 0x1e, 0xfe,
13625 0xda, 0x12, 0x01, 0x38, 0x06, 0x12, 0xfe, 0xd0, 0x13, 0x26, 0x53, 0x12,
13626 0x48, 0xfe, 0x08, 0x17,
13627 0xd1, 0x12, 0x53, 0x12, 0xfe, 0x1e, 0x13, 0x2d, 0xb4, 0x7b, 0xfe, 0x26,
13628 0x17, 0x4d, 0x13, 0x07,
13629 0x1c, 0xb4, 0x90, 0x04, 0xfe, 0x78, 0x10, 0xff, 0x02, 0x83, 0x55, 0xf1,
13630 0xff, 0x02, 0x83, 0x55,
13631 0x53, 0x1d, 0xfe, 0x12, 0x13, 0xd6, 0xfe, 0x30, 0x00, 0xb0, 0xfe, 0x80,
13632 0x17, 0x1c, 0x63, 0x13,
13633 0x07, 0xfe, 0x56, 0x10, 0x53, 0x0d, 0xfe, 0x16, 0x13, 0xd6, 0xfe, 0x64,
13634 0x00, 0xb0, 0xfe, 0x80,
13635 0x17, 0x0a, 0xfe, 0x64, 0x00, 0x1c, 0x94, 0x13, 0x07, 0xfe, 0x28, 0x10,
13636 0x53, 0x07, 0xfe, 0x60,
13637 0x13, 0xd6, 0xfe, 0xc8, 0x00, 0xb0, 0xfe, 0x80, 0x17, 0x0a, 0xfe, 0xc8,
13638 0x00, 0x1c, 0x95, 0x13,
13639 0x07, 0x71, 0xd6, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0x8c, 0x17, 0x45, 0xf3,
13640 0xfe, 0x43, 0xf4, 0x96,
13641 0xfe, 0x56, 0xf0, 0xfe, 0x9e, 0x17, 0xfe, 0x04, 0xf4, 0x58, 0xfe, 0x43,
13642 0xf4, 0x94, 0xf6, 0x8b,
13643 0x01, 0xfe, 0x24, 0x16, 0x23, 0x3f, 0xfc, 0xa8, 0x8c, 0x49, 0x48, 0xfe,
13644 0xda, 0x17, 0x62, 0x49,
13645 0xfe, 0x1c, 0x10, 0xa8, 0x8c, 0x80, 0x48, 0xfe, 0xda, 0x17, 0x62, 0x80,
13646 0x71, 0x50, 0x26, 0xfe,
13647 0x4d, 0xf4, 0x00, 0xf7, 0x45, 0x13, 0x07, 0xfe, 0xb4, 0x56, 0xfe, 0xc3,
13648 0x58, 0x02, 0x50, 0x13,
13649 0x0d, 0x02, 0x50, 0x3e, 0x78, 0x4f, 0x45, 0x01, 0x08, 0x16, 0xa9, 0x27,
13650 0x25, 0xbe, 0xfe, 0x03,
13651 0xea, 0xfe, 0x7e, 0x01, 0x01, 0x08, 0x16, 0xa9, 0x27, 0x25, 0xfe, 0xe9,
13652 0x0a, 0x01, 0x08, 0x16,
13653 0xa9, 0x27, 0x25, 0xfe, 0xe9, 0x0a, 0xfe, 0x05, 0xea, 0xfe, 0x7f, 0x01,
13654 0x01, 0x08, 0x16, 0xa9,
13655 0x27, 0x25, 0xfe, 0x69, 0x09, 0xfe, 0x02, 0xea, 0xfe, 0x80, 0x01, 0x01,
13656 0x08, 0x16, 0xa9, 0x27,
13657 0x25, 0xfe, 0xe8, 0x08, 0x47, 0xfe, 0x81, 0x01, 0x03, 0xb6, 0x1e, 0x83,
13658 0x01, 0x38, 0x06, 0x24,
13659 0x31, 0xa2, 0x78, 0xf2, 0x53, 0x07, 0x36, 0xfe, 0x34, 0xf4, 0x3f, 0xa1,
13660 0x78, 0x03, 0x9a, 0x1e,
13661 0x83, 0x01, 0x38, 0x06, 0x12, 0x31, 0xf0, 0x4f, 0x45, 0xfe, 0x90, 0x10,
13662 0xfe, 0x40, 0x5a, 0x23,
13663 0x3f, 0xfb, 0x8c, 0x49, 0x48, 0xfe, 0xaa, 0x18, 0x62, 0x49, 0x71, 0x8c,
13664 0x80, 0x48, 0xfe, 0xaa,
13665 0x18, 0x62, 0x80, 0xfe, 0xb4, 0x56, 0xfe, 0x40, 0x5d, 0x01, 0xc6, 0x01,
13666 0xfe, 0xac, 0x1d, 0xfe,
13667 0x02, 0x17, 0xfe, 0xc8, 0x45, 0xfe, 0x5a, 0xf0, 0xfe, 0xc0, 0x18, 0xfe,
13668 0x43, 0x48, 0x2d, 0x93,
13669 0x36, 0xfe, 0x34, 0xf4, 0xfe, 0x00, 0x11, 0xfe, 0x40, 0x10, 0x2d, 0xb4,
13670 0x36, 0xfe, 0x34, 0xf4,
13671 0x04, 0xfe, 0x34, 0x10, 0x2d, 0xfe, 0x0b, 0x00, 0x36, 0x46, 0x63, 0xfe,
13672 0x28, 0x10, 0xfe, 0xc0,
13673 0x49, 0xff, 0x02, 0x00, 0x54, 0xb2, 0xfe, 0x90, 0x01, 0x48, 0xfe, 0xfa,
13674 0x18, 0x45, 0xfe, 0x1c,
13675 0xf4, 0x3f, 0xf3, 0xfe, 0x40, 0xf4, 0x96, 0xfe, 0x56, 0xf0, 0xfe, 0x0c,
13676 0x19, 0xfe, 0x04, 0xf4,
13677 0x58, 0xfe, 0x40, 0xf4, 0x94, 0xf6, 0x3e, 0x2d, 0x93, 0x4e, 0xd0, 0x0d,
13678 0x21, 0xfe, 0x7f, 0x01,
13679 0xfe, 0xc8, 0x46, 0xfe, 0x24, 0x13, 0x8c, 0x00, 0x5d, 0x26, 0x21, 0xfe,
13680 0x7e, 0x01, 0xfe, 0xc8,
13681 0x45, 0xfe, 0x14, 0x13, 0x21, 0xfe, 0x80, 0x01, 0xfe, 0x48, 0x45, 0xfa,
13682 0x21, 0xfe, 0x81, 0x01,
13683 0xfe, 0xc8, 0x44, 0x4e, 0x26, 0x02, 0x13, 0x07, 0x02, 0x78, 0x45, 0x50,
13684 0x13, 0x0d, 0x02, 0x14,
13685 0x07, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x14, 0x0d, 0x01, 0x08, 0x17,
13686 0xfe, 0x82, 0x19, 0x14,
13687 0x1d, 0x01, 0x08, 0x17, 0xfe, 0x82, 0x19, 0x5f, 0xfe, 0x89, 0x49, 0x01,
13688 0x08, 0x02, 0x14, 0x07,
13689 0x01, 0x08, 0x17, 0xc1, 0x14, 0x1d, 0x01, 0x08, 0x17, 0xc1, 0x14, 0x07,
13690 0x01, 0x08, 0x17, 0xc1,
13691 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0xc1, 0x5f, 0xfe, 0x89, 0x4a, 0x01,
13692 0x08, 0x02, 0x50, 0x02,
13693 0x14, 0x07, 0x01, 0x08, 0x17, 0x74, 0x14, 0x7f, 0x01, 0x08, 0x17, 0x74,
13694 0x14, 0x12, 0x01, 0x08,
13695 0x17, 0x74, 0xfe, 0x89, 0x49, 0x01, 0x08, 0x17, 0x74, 0x14, 0x00, 0x01,
13696 0x08, 0x17, 0x74, 0xfe,
13697 0x89, 0x4a, 0x01, 0x08, 0x17, 0x74, 0xfe, 0x09, 0x49, 0x01, 0x08, 0x17,
13698 0x74, 0x5f, 0xcc, 0x01,
13699 0x08, 0x02, 0x21, 0xe4, 0x09, 0x07, 0xfe, 0x4c, 0x13, 0xc8, 0x20, 0xe4,
13700 0xfe, 0x49, 0xf4, 0x00,
13701 0x4d, 0x5f, 0xa1, 0x5e, 0xfe, 0x01, 0xec, 0xfe, 0x27, 0x01, 0xcc, 0xff,
13702 0x02, 0x00, 0x10, 0x2f,
13703 0xfe, 0x3e, 0x1a, 0x01, 0x43, 0x09, 0xfe, 0xe3, 0x00, 0xfe, 0x22, 0x13,
13704 0x16, 0xfe, 0x64, 0x1a,
13705 0x26, 0x20, 0x9e, 0x01, 0x41, 0x21, 0x9e, 0x09, 0x07, 0x5d, 0x01, 0x0c,
13706 0x61, 0x07, 0x44, 0x02,
13707 0x0a, 0x5a, 0x01, 0x18, 0xfe, 0x00, 0x40, 0xaa, 0x09, 0x1a, 0xfe, 0x12,
13708 0x13, 0x0a, 0x9d, 0x01,
13709 0x18, 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x9d, 0x01, 0x18, 0xaa,
13710 0xfe, 0x80, 0xe7, 0x1a,
13711 0x09, 0x1a, 0x5d, 0xfe, 0x45, 0x58, 0x01, 0xfe, 0xb2, 0x16, 0xaa, 0x02,
13712 0x0a, 0x5a, 0x01, 0x18,
13713 0xaa, 0x0a, 0x67, 0x01, 0xa3, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x01, 0xfe,
13714 0x7e, 0x1e, 0xfe, 0x80,
13715 0x4c, 0xfe, 0x49, 0xe4, 0x1a, 0xfe, 0x12, 0x13, 0x0a, 0x9d, 0x01, 0x18,
13716 0xfe, 0x80, 0x4c, 0x0a,
13717 0x67, 0x01, 0x5c, 0x02, 0x1c, 0x1a, 0x87, 0x7c, 0xe5, 0xfe, 0x18, 0xdf,
13718 0xfe, 0x19, 0xde, 0xfe,
13719 0x24, 0x1c, 0xfe, 0x1d, 0xf7, 0x28, 0xb1, 0xfe, 0x04, 0x1b, 0x01, 0xfe,
13720 0x2a, 0x1c, 0xfa, 0xb3,
13721 0x28, 0x7c, 0xfe, 0x2c, 0x01, 0xfe, 0x2f, 0x19, 0x02, 0xc9, 0x2b, 0xfe,
13722 0xf4, 0x1a, 0xfe, 0xfa,
13723 0x10, 0x1c, 0x1a, 0x87, 0x03, 0xfe, 0x64, 0x01, 0xfe, 0x00, 0xf4, 0x24,
13724 0xfe, 0x18, 0x58, 0x03,
13725 0xfe, 0x66, 0x01, 0xfe, 0x19, 0x58, 0xb3, 0x24, 0x01, 0xfe, 0x0e, 0x1f,
13726 0xfe, 0x30, 0xf4, 0x07,
13727 0xfe, 0x3c, 0x50, 0x7c, 0xfe, 0x38, 0x00, 0xfe, 0x0f, 0x79, 0xfe, 0x1c,
13728 0xf7, 0x24, 0xb1, 0xfe,
13729 0x50, 0x1b, 0xfe, 0xd4, 0x14, 0x31, 0x02, 0xc9, 0x2b, 0xfe, 0x26, 0x1b,
13730 0xfe, 0xba, 0x10, 0x1c,
13731 0x1a, 0x87, 0xfe, 0x83, 0x5a, 0xfe, 0x18, 0xdf, 0xfe, 0x19, 0xde, 0xfe,
13732 0x1d, 0xf7, 0x54, 0xb1,
13733 0xfe, 0x72, 0x1b, 0xfe, 0xb2, 0x14, 0xfc, 0xb3, 0x54, 0x7c, 0x12, 0xfe,
13734 0xaf, 0x19, 0xfe, 0x98,
13735 0xe7, 0x00, 0x02, 0xc9, 0x2b, 0xfe, 0x66, 0x1b, 0xfe, 0x8a, 0x10, 0x1c,
13736 0x1a, 0x87, 0x8b, 0x0f,
13737 0xfe, 0x30, 0x90, 0x04, 0xfe, 0xb0, 0x93, 0x3a, 0x0b, 0xfe, 0x18, 0x58,
13738 0xfe, 0x32, 0x90, 0x04,
13739 0xfe, 0xb2, 0x93, 0x3a, 0x0b, 0xfe, 0x19, 0x58, 0x0e, 0xa8, 0xb3, 0x4a,
13740 0x7c, 0x12, 0xfe, 0x0f,
13741 0x79, 0xfe, 0x1c, 0xf7, 0x4a, 0xb1, 0xfe, 0xc6, 0x1b, 0xfe, 0x5e, 0x14,
13742 0x31, 0x02, 0xc9, 0x2b,
13743 0xfe, 0x96, 0x1b, 0x5c, 0xfe, 0x02, 0xf6, 0x1a, 0x87, 0xfe, 0x18, 0xfe,
13744 0x6a, 0xfe, 0x19, 0xfe,
13745 0x6b, 0x01, 0xfe, 0x1e, 0x1f, 0xfe, 0x1d, 0xf7, 0x65, 0xb1, 0xfe, 0xee,
13746 0x1b, 0xfe, 0x36, 0x14,
13747 0xfe, 0x1c, 0x13, 0xb3, 0x65, 0x3e, 0xfe, 0x83, 0x58, 0xfe, 0xaf, 0x19,
13748 0xfe, 0x80, 0xe7, 0x1a,
13749 0xfe, 0x81, 0xe7, 0x1a, 0x15, 0xfe, 0xdd, 0x00, 0x7a, 0x30, 0x02, 0x7a,
13750 0x30, 0xfe, 0x12, 0x45,
13751 0x2b, 0xfe, 0xdc, 0x1b, 0x1f, 0x07, 0x47, 0xb5, 0xc3, 0x05, 0x35, 0xfe,
13752 0x39, 0xf0, 0x75, 0x26,
13753 0x02, 0xfe, 0x7e, 0x18, 0x23, 0x1d, 0x36, 0x13, 0x11, 0x02, 0x87, 0x03,
13754 0xe3, 0x23, 0x07, 0xfe,
13755 0xef, 0x12, 0xfe, 0xe1, 0x10, 0x90, 0x34, 0x60, 0xfe, 0x02, 0x80, 0x09,
13756 0x56, 0xfe, 0x3c, 0x13,
13757 0xfe, 0x82, 0x14, 0xfe, 0x42, 0x13, 0x51, 0xfe, 0x06, 0x83, 0x0a, 0x5a,
13758 0x01, 0x18, 0xcb, 0xfe,
13759 0x3e, 0x12, 0xfe, 0x41, 0x48, 0xfe, 0x45, 0x48, 0x01, 0xfe, 0xb2, 0x16,
13760 0xfe, 0x00, 0xcc, 0xcb,
13761 0xfe, 0xf3, 0x13, 0x3f, 0x89, 0x09, 0x1a, 0xa5, 0x0a, 0x9d, 0x01, 0x18,
13762 0xfe, 0x80, 0x4c, 0x01,
13763 0x85, 0xfe, 0x16, 0x10, 0x09, 0x9b, 0x4e, 0xfe, 0x40, 0x14, 0xfe, 0x24,
13764 0x12, 0xfe, 0x14, 0x56,
13765 0xfe, 0xd6, 0xf0, 0xfe, 0x52, 0x1c, 0x1c, 0x0d, 0x02, 0xfe, 0x9c, 0xe7,
13766 0x0d, 0x19, 0xfe, 0x15,
13767 0x00, 0x40, 0x8d, 0x30, 0x01, 0xf4, 0x1c, 0x07, 0x02, 0x51, 0xfe, 0x06,
13768 0x83, 0xfe, 0x18, 0x80,
13769 0x61, 0x28, 0x44, 0x15, 0x56, 0x01, 0x85, 0x1c, 0x07, 0x02, 0xfe, 0x38,
13770 0x90, 0xfe, 0xba, 0x90,
13771 0x91, 0xde, 0x7e, 0xdf, 0xfe, 0x48, 0x55, 0x31, 0xfe, 0xc9, 0x55, 0x02,
13772 0x21, 0xb9, 0x88, 0x20,
13773 0xb9, 0x02, 0x0a, 0xba, 0x01, 0x18, 0xfe, 0x41, 0x48, 0x0a, 0x57, 0x01,
13774 0x18, 0xfe, 0x49, 0x44,
13775 0x1b, 0xfe, 0x1e, 0x1d, 0x88, 0x89, 0x02, 0x0a, 0x5a, 0x01, 0x18, 0x09,
13776 0x1a, 0xa4, 0x0a, 0x67,
13777 0x01, 0xa3, 0x0a, 0x57, 0x01, 0x18, 0x88, 0x89, 0x02, 0xfe, 0x4e, 0xe4,
13778 0x1d, 0x7b, 0xfe, 0x52,
13779 0x1d, 0x03, 0xfe, 0x90, 0x00, 0xfe, 0x3a, 0x45, 0xfe, 0x2c, 0x10, 0xfe,
13780 0x4e, 0xe4, 0xdd, 0x7b,
13781 0xfe, 0x64, 0x1d, 0x03, 0xfe, 0x92, 0x00, 0xd1, 0x12, 0xfe, 0x1a, 0x10,
13782 0xfe, 0x4e, 0xe4, 0xfe,
13783 0x0b, 0x00, 0x7b, 0xfe, 0x76, 0x1d, 0x03, 0xfe, 0x94, 0x00, 0xd1, 0x24,
13784 0xfe, 0x08, 0x10, 0x03,
13785 0xfe, 0x96, 0x00, 0xd1, 0x63, 0xfe, 0x4e, 0x45, 0x83, 0xca, 0xff, 0x04,
13786 0x68, 0x54, 0xfe, 0xf1,
13787 0x10, 0x23, 0x49, 0xfe, 0x08, 0x1c, 0xfe, 0x67, 0x19, 0xfe, 0x0a, 0x1c,
13788 0xfe, 0x1a, 0xf4, 0xfe,
13789 0x00, 0x04, 0x83, 0xb2, 0x1d, 0x48, 0xfe, 0xaa, 0x1d, 0x13, 0x1d, 0x02,
13790 0x09, 0x92, 0xfe, 0x5a,
13791 0xf0, 0xfe, 0xba, 0x1d, 0x2e, 0x93, 0xfe, 0x34, 0x10, 0x09, 0x12, 0xfe,
13792 0x5a, 0xf0, 0xfe, 0xc8,
13793 0x1d, 0x2e, 0xb4, 0xfe, 0x26, 0x10, 0x09, 0x1d, 0x36, 0x2e, 0x63, 0xfe,
13794 0x1a, 0x10, 0x09, 0x0d,
13795 0x36, 0x2e, 0x94, 0xf2, 0x09, 0x07, 0x36, 0x2e, 0x95, 0xa1, 0xc8, 0x02,
13796 0x1f, 0x93, 0x01, 0x42,
13797 0xfe, 0x04, 0xfe, 0x99, 0x03, 0x9c, 0x8b, 0x02, 0x2a, 0xfe, 0x1c, 0x1e,
13798 0xfe, 0x14, 0xf0, 0x08,
13799 0x2f, 0xfe, 0x0c, 0x1e, 0x2a, 0xfe, 0x1c, 0x1e, 0x8f, 0xfe, 0x1c, 0x1e,
13800 0xfe, 0x82, 0xf0, 0xfe,
13801 0x10, 0x1e, 0x02, 0x0f, 0x3f, 0x04, 0xfe, 0x80, 0x83, 0x33, 0x0b, 0x0e,
13802 0x02, 0x0f, 0xfe, 0x18,
13803 0x80, 0x04, 0xfe, 0x98, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x02,
13804 0x80, 0x04, 0xfe, 0x82,
13805 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x80, 0x04, 0xfe, 0x86,
13806 0x83, 0x33, 0x0b, 0x0e,
13807 0x02, 0x0f, 0xfe, 0x1b, 0x80, 0x04, 0xfe, 0x9b, 0x83, 0x33, 0x0b, 0x0e,
13808 0x02, 0x0f, 0xfe, 0x04,
13809 0x80, 0x04, 0xfe, 0x84, 0x83, 0x33, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x80,
13810 0x80, 0x04, 0xfe, 0x80,
13811 0x83, 0xfe, 0xc9, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x19, 0x81, 0x04,
13812 0xfe, 0x99, 0x83, 0xfe,
13813 0xca, 0x47, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x06, 0x83, 0x04, 0xfe, 0x86,
13814 0x83, 0xfe, 0xce, 0x47,
13815 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x2c, 0x90, 0x04, 0xfe, 0xac, 0x93, 0x3a,
13816 0x0b, 0x0e, 0x02, 0x0f,
13817 0xfe, 0xae, 0x90, 0x04, 0xfe, 0xae, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
13818 0xfe, 0x08, 0x90, 0x04,
13819 0xfe, 0x88, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x8a, 0x90, 0x04,
13820 0xfe, 0x8a, 0x93, 0x79,
13821 0x0b, 0x0e, 0x02, 0x0f, 0xfe, 0x0c, 0x90, 0x04, 0xfe, 0x8c, 0x93, 0x3a,
13822 0x0b, 0x0e, 0x02, 0x0f,
13823 0xfe, 0x8e, 0x90, 0x04, 0xfe, 0x8e, 0x93, 0x79, 0x0b, 0x0e, 0x02, 0x0f,
13824 0xfe, 0x3c, 0x90, 0x04,
13825 0xfe, 0xbc, 0x93, 0x3a, 0x0b, 0x0e, 0x02, 0x8b, 0x0f, 0xfe, 0x03, 0x80,
13826 0x04, 0xfe, 0x83, 0x83,
13827 0x33, 0x0b, 0x77, 0x0e, 0xa8, 0x02, 0xff, 0x66, 0x00, 0x00,
14028}; 13828};
14029 13829
14030STATIC unsigned short _adv_asc38C1600_size = 13830static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
14031 sizeof(_adv_asc38C1600_buf); /* 0x1673 */ 13831static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
14032STATIC ADV_DCNT _adv_asc38C1600_chksum =
14033 0x0604EF77UL; /* Expanded little-endian checksum. */
14034 13832
14035/* a_init.c */ 13833/* a_init.c */
14036/* 13834/*
@@ -14049,340 +13847,340 @@ STATIC ADV_DCNT _adv_asc38C1600_chksum =
14049 * on big-endian platforms so char fields read as words are actually being 13847 * on big-endian platforms so char fields read as words are actually being
14050 * unswapped on big-endian platforms. 13848 * unswapped on big-endian platforms.
14051 */ 13849 */
14052STATIC ADVEEP_3550_CONFIG 13850static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config __initdata = {
14053Default_3550_EEPROM_Config __initdata = { 13851 ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */
14054 ADV_EEPROM_BIOS_ENABLE, /* cfg_lsw */ 13852 0x0000, /* cfg_msw */
14055 0x0000, /* cfg_msw */ 13853 0xFFFF, /* disc_enable */
14056 0xFFFF, /* disc_enable */ 13854 0xFFFF, /* wdtr_able */
14057 0xFFFF, /* wdtr_able */ 13855 0xFFFF, /* sdtr_able */
14058 0xFFFF, /* sdtr_able */ 13856 0xFFFF, /* start_motor */
14059 0xFFFF, /* start_motor */ 13857 0xFFFF, /* tagqng_able */
14060 0xFFFF, /* tagqng_able */ 13858 0xFFFF, /* bios_scan */
14061 0xFFFF, /* bios_scan */ 13859 0, /* scam_tolerant */
14062 0, /* scam_tolerant */ 13860 7, /* adapter_scsi_id */
14063 7, /* adapter_scsi_id */ 13861 0, /* bios_boot_delay */
14064 0, /* bios_boot_delay */ 13862 3, /* scsi_reset_delay */
14065 3, /* scsi_reset_delay */ 13863 0, /* bios_id_lun */
14066 0, /* bios_id_lun */ 13864 0, /* termination */
14067 0, /* termination */ 13865 0, /* reserved1 */
14068 0, /* reserved1 */ 13866 0xFFE7, /* bios_ctrl */
14069 0xFFE7, /* bios_ctrl */ 13867 0xFFFF, /* ultra_able */
14070 0xFFFF, /* ultra_able */ 13868 0, /* reserved2 */
14071 0, /* reserved2 */ 13869 ASC_DEF_MAX_HOST_QNG, /* max_host_qng */
14072 ASC_DEF_MAX_HOST_QNG, /* max_host_qng */ 13870 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
14073 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */ 13871 0, /* dvc_cntl */
14074 0, /* dvc_cntl */ 13872 0, /* bug_fix */
14075 0, /* bug_fix */ 13873 0, /* serial_number_word1 */
14076 0, /* serial_number_word1 */ 13874 0, /* serial_number_word2 */
14077 0, /* serial_number_word2 */ 13875 0, /* serial_number_word3 */
14078 0, /* serial_number_word3 */ 13876 0, /* check_sum */
14079 0, /* check_sum */ 13877 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
14080 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, /* oem_name[16] */ 13878 , /* oem_name[16] */
14081 0, /* dvc_err_code */ 13879 0, /* dvc_err_code */
14082 0, /* adv_err_code */ 13880 0, /* adv_err_code */
14083 0, /* adv_err_addr */ 13881 0, /* adv_err_addr */
14084 0, /* saved_dvc_err_code */ 13882 0, /* saved_dvc_err_code */
14085 0, /* saved_adv_err_code */ 13883 0, /* saved_adv_err_code */
14086 0, /* saved_adv_err_addr */ 13884 0, /* saved_adv_err_addr */
14087 0 /* num_of_err */ 13885 0 /* num_of_err */
14088}; 13886};
14089 13887
14090STATIC ADVEEP_3550_CONFIG 13888static ADVEEP_3550_CONFIG ADVEEP_3550_Config_Field_IsChar __initdata = {
14091ADVEEP_3550_Config_Field_IsChar __initdata = { 13889 0, /* cfg_lsw */
14092 0, /* cfg_lsw */ 13890 0, /* cfg_msw */
14093 0, /* cfg_msw */ 13891 0, /* -disc_enable */
14094 0, /* -disc_enable */ 13892 0, /* wdtr_able */
14095 0, /* wdtr_able */ 13893 0, /* sdtr_able */
14096 0, /* sdtr_able */ 13894 0, /* start_motor */
14097 0, /* start_motor */ 13895 0, /* tagqng_able */
14098 0, /* tagqng_able */ 13896 0, /* bios_scan */
14099 0, /* bios_scan */ 13897 0, /* scam_tolerant */
14100 0, /* scam_tolerant */ 13898 1, /* adapter_scsi_id */
14101 1, /* adapter_scsi_id */ 13899 1, /* bios_boot_delay */
14102 1, /* bios_boot_delay */ 13900 1, /* scsi_reset_delay */
14103 1, /* scsi_reset_delay */ 13901 1, /* bios_id_lun */
14104 1, /* bios_id_lun */ 13902 1, /* termination */
14105 1, /* termination */ 13903 1, /* reserved1 */
14106 1, /* reserved1 */ 13904 0, /* bios_ctrl */
14107 0, /* bios_ctrl */ 13905 0, /* ultra_able */
14108 0, /* ultra_able */ 13906 0, /* reserved2 */
14109 0, /* reserved2 */ 13907 1, /* max_host_qng */
14110 1, /* max_host_qng */ 13908 1, /* max_dvc_qng */
14111 1, /* max_dvc_qng */ 13909 0, /* dvc_cntl */
14112 0, /* dvc_cntl */ 13910 0, /* bug_fix */
14113 0, /* bug_fix */ 13911 0, /* serial_number_word1 */
14114 0, /* serial_number_word1 */ 13912 0, /* serial_number_word2 */
14115 0, /* serial_number_word2 */ 13913 0, /* serial_number_word3 */
14116 0, /* serial_number_word3 */ 13914 0, /* check_sum */
14117 0, /* check_sum */ 13915 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
14118 { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, /* oem_name[16] */ 13916 , /* oem_name[16] */
14119 0, /* dvc_err_code */ 13917 0, /* dvc_err_code */
14120 0, /* adv_err_code */ 13918 0, /* adv_err_code */
14121 0, /* adv_err_addr */ 13919 0, /* adv_err_addr */
14122 0, /* saved_dvc_err_code */ 13920 0, /* saved_dvc_err_code */
14123 0, /* saved_adv_err_code */ 13921 0, /* saved_adv_err_code */
14124 0, /* saved_adv_err_addr */ 13922 0, /* saved_adv_err_addr */
14125 0 /* num_of_err */ 13923 0 /* num_of_err */
14126}; 13924};
14127 13925
14128STATIC ADVEEP_38C0800_CONFIG 13926static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config __initdata = {
14129Default_38C0800_EEPROM_Config __initdata = { 13927 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
14130 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */ 13928 0x0000, /* 01 cfg_msw */
14131 0x0000, /* 01 cfg_msw */ 13929 0xFFFF, /* 02 disc_enable */
14132 0xFFFF, /* 02 disc_enable */ 13930 0xFFFF, /* 03 wdtr_able */
14133 0xFFFF, /* 03 wdtr_able */ 13931 0x4444, /* 04 sdtr_speed1 */
14134 0x4444, /* 04 sdtr_speed1 */ 13932 0xFFFF, /* 05 start_motor */
14135 0xFFFF, /* 05 start_motor */ 13933 0xFFFF, /* 06 tagqng_able */
14136 0xFFFF, /* 06 tagqng_able */ 13934 0xFFFF, /* 07 bios_scan */
14137 0xFFFF, /* 07 bios_scan */ 13935 0, /* 08 scam_tolerant */
14138 0, /* 08 scam_tolerant */ 13936 7, /* 09 adapter_scsi_id */
14139 7, /* 09 adapter_scsi_id */ 13937 0, /* bios_boot_delay */
14140 0, /* bios_boot_delay */ 13938 3, /* 10 scsi_reset_delay */
14141 3, /* 10 scsi_reset_delay */ 13939 0, /* bios_id_lun */
14142 0, /* bios_id_lun */ 13940 0, /* 11 termination_se */
14143 0, /* 11 termination_se */ 13941 0, /* termination_lvd */
14144 0, /* termination_lvd */ 13942 0xFFE7, /* 12 bios_ctrl */
14145 0xFFE7, /* 12 bios_ctrl */ 13943 0x4444, /* 13 sdtr_speed2 */
14146 0x4444, /* 13 sdtr_speed2 */ 13944 0x4444, /* 14 sdtr_speed3 */
14147 0x4444, /* 14 sdtr_speed3 */ 13945 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
14148 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */ 13946 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
14149 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */ 13947 0, /* 16 dvc_cntl */
14150 0, /* 16 dvc_cntl */ 13948 0x4444, /* 17 sdtr_speed4 */
14151 0x4444, /* 17 sdtr_speed4 */ 13949 0, /* 18 serial_number_word1 */
14152 0, /* 18 serial_number_word1 */ 13950 0, /* 19 serial_number_word2 */
14153 0, /* 19 serial_number_word2 */ 13951 0, /* 20 serial_number_word3 */
14154 0, /* 20 serial_number_word3 */ 13952 0, /* 21 check_sum */
14155 0, /* 21 check_sum */ 13953 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
14156 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, /* 22-29 oem_name[16] */ 13954 , /* 22-29 oem_name[16] */
14157 0, /* 30 dvc_err_code */ 13955 0, /* 30 dvc_err_code */
14158 0, /* 31 adv_err_code */ 13956 0, /* 31 adv_err_code */
14159 0, /* 32 adv_err_addr */ 13957 0, /* 32 adv_err_addr */
14160 0, /* 33 saved_dvc_err_code */ 13958 0, /* 33 saved_dvc_err_code */
14161 0, /* 34 saved_adv_err_code */ 13959 0, /* 34 saved_adv_err_code */
14162 0, /* 35 saved_adv_err_addr */ 13960 0, /* 35 saved_adv_err_addr */
14163 0, /* 36 reserved */ 13961 0, /* 36 reserved */
14164 0, /* 37 reserved */ 13962 0, /* 37 reserved */
14165 0, /* 38 reserved */ 13963 0, /* 38 reserved */
14166 0, /* 39 reserved */ 13964 0, /* 39 reserved */
14167 0, /* 40 reserved */ 13965 0, /* 40 reserved */
14168 0, /* 41 reserved */ 13966 0, /* 41 reserved */
14169 0, /* 42 reserved */ 13967 0, /* 42 reserved */
14170 0, /* 43 reserved */ 13968 0, /* 43 reserved */
14171 0, /* 44 reserved */ 13969 0, /* 44 reserved */
14172 0, /* 45 reserved */ 13970 0, /* 45 reserved */
14173 0, /* 46 reserved */ 13971 0, /* 46 reserved */
14174 0, /* 47 reserved */ 13972 0, /* 47 reserved */
14175 0, /* 48 reserved */ 13973 0, /* 48 reserved */
14176 0, /* 49 reserved */ 13974 0, /* 49 reserved */
14177 0, /* 50 reserved */ 13975 0, /* 50 reserved */
14178 0, /* 51 reserved */ 13976 0, /* 51 reserved */
14179 0, /* 52 reserved */ 13977 0, /* 52 reserved */
14180 0, /* 53 reserved */ 13978 0, /* 53 reserved */
14181 0, /* 54 reserved */ 13979 0, /* 54 reserved */
14182 0, /* 55 reserved */ 13980 0, /* 55 reserved */
14183 0, /* 56 cisptr_lsw */ 13981 0, /* 56 cisptr_lsw */
14184 0, /* 57 cisprt_msw */ 13982 0, /* 57 cisprt_msw */
14185 PCI_VENDOR_ID_ASP, /* 58 subsysvid */ 13983 PCI_VENDOR_ID_ASP, /* 58 subsysvid */
14186 PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */ 13984 PCI_DEVICE_ID_38C0800_REV1, /* 59 subsysid */
14187 0, /* 60 reserved */ 13985 0, /* 60 reserved */
14188 0, /* 61 reserved */ 13986 0, /* 61 reserved */
14189 0, /* 62 reserved */ 13987 0, /* 62 reserved */
14190 0 /* 63 reserved */ 13988 0 /* 63 reserved */
14191}; 13989};
14192 13990
14193STATIC ADVEEP_38C0800_CONFIG 13991static ADVEEP_38C0800_CONFIG ADVEEP_38C0800_Config_Field_IsChar __initdata = {
14194ADVEEP_38C0800_Config_Field_IsChar __initdata = { 13992 0, /* 00 cfg_lsw */
14195 0, /* 00 cfg_lsw */ 13993 0, /* 01 cfg_msw */
14196 0, /* 01 cfg_msw */ 13994 0, /* 02 disc_enable */
14197 0, /* 02 disc_enable */ 13995 0, /* 03 wdtr_able */
14198 0, /* 03 wdtr_able */ 13996 0, /* 04 sdtr_speed1 */
14199 0, /* 04 sdtr_speed1 */ 13997 0, /* 05 start_motor */
14200 0, /* 05 start_motor */ 13998 0, /* 06 tagqng_able */
14201 0, /* 06 tagqng_able */ 13999 0, /* 07 bios_scan */
14202 0, /* 07 bios_scan */ 14000 0, /* 08 scam_tolerant */
14203 0, /* 08 scam_tolerant */ 14001 1, /* 09 adapter_scsi_id */
14204 1, /* 09 adapter_scsi_id */ 14002 1, /* bios_boot_delay */
14205 1, /* bios_boot_delay */ 14003 1, /* 10 scsi_reset_delay */
14206 1, /* 10 scsi_reset_delay */ 14004 1, /* bios_id_lun */
14207 1, /* bios_id_lun */ 14005 1, /* 11 termination_se */
14208 1, /* 11 termination_se */ 14006 1, /* termination_lvd */
14209 1, /* termination_lvd */ 14007 0, /* 12 bios_ctrl */
14210 0, /* 12 bios_ctrl */ 14008 0, /* 13 sdtr_speed2 */
14211 0, /* 13 sdtr_speed2 */ 14009 0, /* 14 sdtr_speed3 */
14212 0, /* 14 sdtr_speed3 */ 14010 1, /* 15 max_host_qng */
14213 1, /* 15 max_host_qng */ 14011 1, /* max_dvc_qng */
14214 1, /* max_dvc_qng */ 14012 0, /* 16 dvc_cntl */
14215 0, /* 16 dvc_cntl */ 14013 0, /* 17 sdtr_speed4 */
14216 0, /* 17 sdtr_speed4 */ 14014 0, /* 18 serial_number_word1 */
14217 0, /* 18 serial_number_word1 */ 14015 0, /* 19 serial_number_word2 */
14218 0, /* 19 serial_number_word2 */ 14016 0, /* 20 serial_number_word3 */
14219 0, /* 20 serial_number_word3 */ 14017 0, /* 21 check_sum */
14220 0, /* 21 check_sum */ 14018 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
14221 { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, /* 22-29 oem_name[16] */ 14019 , /* 22-29 oem_name[16] */
14222 0, /* 30 dvc_err_code */ 14020 0, /* 30 dvc_err_code */
14223 0, /* 31 adv_err_code */ 14021 0, /* 31 adv_err_code */
14224 0, /* 32 adv_err_addr */ 14022 0, /* 32 adv_err_addr */
14225 0, /* 33 saved_dvc_err_code */ 14023 0, /* 33 saved_dvc_err_code */
14226 0, /* 34 saved_adv_err_code */ 14024 0, /* 34 saved_adv_err_code */
14227 0, /* 35 saved_adv_err_addr */ 14025 0, /* 35 saved_adv_err_addr */
14228 0, /* 36 reserved */ 14026 0, /* 36 reserved */
14229 0, /* 37 reserved */ 14027 0, /* 37 reserved */
14230 0, /* 38 reserved */ 14028 0, /* 38 reserved */
14231 0, /* 39 reserved */ 14029 0, /* 39 reserved */
14232 0, /* 40 reserved */ 14030 0, /* 40 reserved */
14233 0, /* 41 reserved */ 14031 0, /* 41 reserved */
14234 0, /* 42 reserved */ 14032 0, /* 42 reserved */
14235 0, /* 43 reserved */ 14033 0, /* 43 reserved */
14236 0, /* 44 reserved */ 14034 0, /* 44 reserved */
14237 0, /* 45 reserved */ 14035 0, /* 45 reserved */
14238 0, /* 46 reserved */ 14036 0, /* 46 reserved */
14239 0, /* 47 reserved */ 14037 0, /* 47 reserved */
14240 0, /* 48 reserved */ 14038 0, /* 48 reserved */
14241 0, /* 49 reserved */ 14039 0, /* 49 reserved */
14242 0, /* 50 reserved */ 14040 0, /* 50 reserved */
14243 0, /* 51 reserved */ 14041 0, /* 51 reserved */
14244 0, /* 52 reserved */ 14042 0, /* 52 reserved */
14245 0, /* 53 reserved */ 14043 0, /* 53 reserved */
14246 0, /* 54 reserved */ 14044 0, /* 54 reserved */
14247 0, /* 55 reserved */ 14045 0, /* 55 reserved */
14248 0, /* 56 cisptr_lsw */ 14046 0, /* 56 cisptr_lsw */
14249 0, /* 57 cisprt_msw */ 14047 0, /* 57 cisprt_msw */
14250 0, /* 58 subsysvid */ 14048 0, /* 58 subsysvid */
14251 0, /* 59 subsysid */ 14049 0, /* 59 subsysid */
14252 0, /* 60 reserved */ 14050 0, /* 60 reserved */
14253 0, /* 61 reserved */ 14051 0, /* 61 reserved */
14254 0, /* 62 reserved */ 14052 0, /* 62 reserved */
14255 0 /* 63 reserved */ 14053 0 /* 63 reserved */
14256}; 14054};
14257 14055
14258STATIC ADVEEP_38C1600_CONFIG 14056static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config __initdata = {
14259Default_38C1600_EEPROM_Config __initdata = { 14057 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */
14260 ADV_EEPROM_BIOS_ENABLE, /* 00 cfg_lsw */ 14058 0x0000, /* 01 cfg_msw */
14261 0x0000, /* 01 cfg_msw */ 14059 0xFFFF, /* 02 disc_enable */
14262 0xFFFF, /* 02 disc_enable */ 14060 0xFFFF, /* 03 wdtr_able */
14263 0xFFFF, /* 03 wdtr_able */ 14061 0x5555, /* 04 sdtr_speed1 */
14264 0x5555, /* 04 sdtr_speed1 */ 14062 0xFFFF, /* 05 start_motor */
14265 0xFFFF, /* 05 start_motor */ 14063 0xFFFF, /* 06 tagqng_able */
14266 0xFFFF, /* 06 tagqng_able */ 14064 0xFFFF, /* 07 bios_scan */
14267 0xFFFF, /* 07 bios_scan */ 14065 0, /* 08 scam_tolerant */
14268 0, /* 08 scam_tolerant */ 14066 7, /* 09 adapter_scsi_id */
14269 7, /* 09 adapter_scsi_id */ 14067 0, /* bios_boot_delay */
14270 0, /* bios_boot_delay */ 14068 3, /* 10 scsi_reset_delay */
14271 3, /* 10 scsi_reset_delay */ 14069 0, /* bios_id_lun */
14272 0, /* bios_id_lun */ 14070 0, /* 11 termination_se */
14273 0, /* 11 termination_se */ 14071 0, /* termination_lvd */
14274 0, /* termination_lvd */ 14072 0xFFE7, /* 12 bios_ctrl */
14275 0xFFE7, /* 12 bios_ctrl */ 14073 0x5555, /* 13 sdtr_speed2 */
14276 0x5555, /* 13 sdtr_speed2 */ 14074 0x5555, /* 14 sdtr_speed3 */
14277 0x5555, /* 14 sdtr_speed3 */ 14075 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */
14278 ASC_DEF_MAX_HOST_QNG, /* 15 max_host_qng */ 14076 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */
14279 ASC_DEF_MAX_DVC_QNG, /* max_dvc_qng */ 14077 0, /* 16 dvc_cntl */
14280 0, /* 16 dvc_cntl */ 14078 0x5555, /* 17 sdtr_speed4 */
14281 0x5555, /* 17 sdtr_speed4 */ 14079 0, /* 18 serial_number_word1 */
14282 0, /* 18 serial_number_word1 */ 14080 0, /* 19 serial_number_word2 */
14283 0, /* 19 serial_number_word2 */ 14081 0, /* 20 serial_number_word3 */
14284 0, /* 20 serial_number_word3 */ 14082 0, /* 21 check_sum */
14285 0, /* 21 check_sum */ 14083 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
14286 { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, /* 22-29 oem_name[16] */ 14084 , /* 22-29 oem_name[16] */
14287 0, /* 30 dvc_err_code */ 14085 0, /* 30 dvc_err_code */
14288 0, /* 31 adv_err_code */ 14086 0, /* 31 adv_err_code */
14289 0, /* 32 adv_err_addr */ 14087 0, /* 32 adv_err_addr */
14290 0, /* 33 saved_dvc_err_code */ 14088 0, /* 33 saved_dvc_err_code */
14291 0, /* 34 saved_adv_err_code */ 14089 0, /* 34 saved_adv_err_code */
14292 0, /* 35 saved_adv_err_addr */ 14090 0, /* 35 saved_adv_err_addr */
14293 0, /* 36 reserved */ 14091 0, /* 36 reserved */
14294 0, /* 37 reserved */ 14092 0, /* 37 reserved */
14295 0, /* 38 reserved */ 14093 0, /* 38 reserved */
14296 0, /* 39 reserved */ 14094 0, /* 39 reserved */
14297 0, /* 40 reserved */ 14095 0, /* 40 reserved */
14298 0, /* 41 reserved */ 14096 0, /* 41 reserved */
14299 0, /* 42 reserved */ 14097 0, /* 42 reserved */
14300 0, /* 43 reserved */ 14098 0, /* 43 reserved */
14301 0, /* 44 reserved */ 14099 0, /* 44 reserved */
14302 0, /* 45 reserved */ 14100 0, /* 45 reserved */
14303 0, /* 46 reserved */ 14101 0, /* 46 reserved */
14304 0, /* 47 reserved */ 14102 0, /* 47 reserved */
14305 0, /* 48 reserved */ 14103 0, /* 48 reserved */
14306 0, /* 49 reserved */ 14104 0, /* 49 reserved */
14307 0, /* 50 reserved */ 14105 0, /* 50 reserved */
14308 0, /* 51 reserved */ 14106 0, /* 51 reserved */
14309 0, /* 52 reserved */ 14107 0, /* 52 reserved */
14310 0, /* 53 reserved */ 14108 0, /* 53 reserved */
14311 0, /* 54 reserved */ 14109 0, /* 54 reserved */
14312 0, /* 55 reserved */ 14110 0, /* 55 reserved */
14313 0, /* 56 cisptr_lsw */ 14111 0, /* 56 cisptr_lsw */
14314 0, /* 57 cisprt_msw */ 14112 0, /* 57 cisprt_msw */
14315 PCI_VENDOR_ID_ASP, /* 58 subsysvid */ 14113 PCI_VENDOR_ID_ASP, /* 58 subsysvid */
14316 PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */ 14114 PCI_DEVICE_ID_38C1600_REV1, /* 59 subsysid */
14317 0, /* 60 reserved */ 14115 0, /* 60 reserved */
14318 0, /* 61 reserved */ 14116 0, /* 61 reserved */
14319 0, /* 62 reserved */ 14117 0, /* 62 reserved */
14320 0 /* 63 reserved */ 14118 0 /* 63 reserved */
14321}; 14119};
14322 14120
14323STATIC ADVEEP_38C1600_CONFIG 14121static ADVEEP_38C1600_CONFIG ADVEEP_38C1600_Config_Field_IsChar __initdata = {
14324ADVEEP_38C1600_Config_Field_IsChar __initdata = { 14122 0, /* 00 cfg_lsw */
14325 0, /* 00 cfg_lsw */ 14123 0, /* 01 cfg_msw */
14326 0, /* 01 cfg_msw */ 14124 0, /* 02 disc_enable */
14327 0, /* 02 disc_enable */ 14125 0, /* 03 wdtr_able */
14328 0, /* 03 wdtr_able */ 14126 0, /* 04 sdtr_speed1 */
14329 0, /* 04 sdtr_speed1 */ 14127 0, /* 05 start_motor */
14330 0, /* 05 start_motor */ 14128 0, /* 06 tagqng_able */
14331 0, /* 06 tagqng_able */ 14129 0, /* 07 bios_scan */
14332 0, /* 07 bios_scan */ 14130 0, /* 08 scam_tolerant */
14333 0, /* 08 scam_tolerant */ 14131 1, /* 09 adapter_scsi_id */
14334 1, /* 09 adapter_scsi_id */ 14132 1, /* bios_boot_delay */
14335 1, /* bios_boot_delay */ 14133 1, /* 10 scsi_reset_delay */
14336 1, /* 10 scsi_reset_delay */ 14134 1, /* bios_id_lun */
14337 1, /* bios_id_lun */ 14135 1, /* 11 termination_se */
14338 1, /* 11 termination_se */ 14136 1, /* termination_lvd */
14339 1, /* termination_lvd */ 14137 0, /* 12 bios_ctrl */
14340 0, /* 12 bios_ctrl */ 14138 0, /* 13 sdtr_speed2 */
14341 0, /* 13 sdtr_speed2 */ 14139 0, /* 14 sdtr_speed3 */
14342 0, /* 14 sdtr_speed3 */ 14140 1, /* 15 max_host_qng */
14343 1, /* 15 max_host_qng */ 14141 1, /* max_dvc_qng */
14344 1, /* max_dvc_qng */ 14142 0, /* 16 dvc_cntl */
14345 0, /* 16 dvc_cntl */ 14143 0, /* 17 sdtr_speed4 */
14346 0, /* 17 sdtr_speed4 */ 14144 0, /* 18 serial_number_word1 */
14347 0, /* 18 serial_number_word1 */ 14145 0, /* 19 serial_number_word2 */
14348 0, /* 19 serial_number_word2 */ 14146 0, /* 20 serial_number_word3 */
14349 0, /* 20 serial_number_word3 */ 14147 0, /* 21 check_sum */
14350 0, /* 21 check_sum */ 14148 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
14351 { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }, /* 22-29 oem_name[16] */ 14149 , /* 22-29 oem_name[16] */
14352 0, /* 30 dvc_err_code */ 14150 0, /* 30 dvc_err_code */
14353 0, /* 31 adv_err_code */ 14151 0, /* 31 adv_err_code */
14354 0, /* 32 adv_err_addr */ 14152 0, /* 32 adv_err_addr */
14355 0, /* 33 saved_dvc_err_code */ 14153 0, /* 33 saved_dvc_err_code */
14356 0, /* 34 saved_adv_err_code */ 14154 0, /* 34 saved_adv_err_code */
14357 0, /* 35 saved_adv_err_addr */ 14155 0, /* 35 saved_adv_err_addr */
14358 0, /* 36 reserved */ 14156 0, /* 36 reserved */
14359 0, /* 37 reserved */ 14157 0, /* 37 reserved */
14360 0, /* 38 reserved */ 14158 0, /* 38 reserved */
14361 0, /* 39 reserved */ 14159 0, /* 39 reserved */
14362 0, /* 40 reserved */ 14160 0, /* 40 reserved */
14363 0, /* 41 reserved */ 14161 0, /* 41 reserved */
14364 0, /* 42 reserved */ 14162 0, /* 42 reserved */
14365 0, /* 43 reserved */ 14163 0, /* 43 reserved */
14366 0, /* 44 reserved */ 14164 0, /* 44 reserved */
14367 0, /* 45 reserved */ 14165 0, /* 45 reserved */
14368 0, /* 46 reserved */ 14166 0, /* 46 reserved */
14369 0, /* 47 reserved */ 14167 0, /* 47 reserved */
14370 0, /* 48 reserved */ 14168 0, /* 48 reserved */
14371 0, /* 49 reserved */ 14169 0, /* 49 reserved */
14372 0, /* 50 reserved */ 14170 0, /* 50 reserved */
14373 0, /* 51 reserved */ 14171 0, /* 51 reserved */
14374 0, /* 52 reserved */ 14172 0, /* 52 reserved */
14375 0, /* 53 reserved */ 14173 0, /* 53 reserved */
14376 0, /* 54 reserved */ 14174 0, /* 54 reserved */
14377 0, /* 55 reserved */ 14175 0, /* 55 reserved */
14378 0, /* 56 cisptr_lsw */ 14176 0, /* 56 cisptr_lsw */
14379 0, /* 57 cisprt_msw */ 14177 0, /* 57 cisprt_msw */
14380 0, /* 58 subsysvid */ 14178 0, /* 58 subsysvid */
14381 0, /* 59 subsysid */ 14179 0, /* 59 subsysid */
14382 0, /* 60 reserved */ 14180 0, /* 60 reserved */
14383 0, /* 61 reserved */ 14181 0, /* 61 reserved */
14384 0, /* 62 reserved */ 14182 0, /* 62 reserved */
14385 0 /* 63 reserved */ 14183 0 /* 63 reserved */
14386}; 14184};
14387 14185
14388/* 14186/*
@@ -14393,136 +14191,128 @@ ADVEEP_38C1600_Config_Field_IsChar __initdata = {
14393 * For a non-fatal error return a warning code. If there are no warnings 14191 * For a non-fatal error return a warning code. If there are no warnings
14394 * then 0 is returned. 14192 * then 0 is returned.
14395 */ 14193 */
14396STATIC int __init 14194static int __init AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
14397AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
14398{ 14195{
14399 ushort warn_code; 14196 ushort warn_code;
14400 AdvPortAddr iop_base; 14197 AdvPortAddr iop_base;
14401 uchar pci_cmd_reg; 14198 uchar pci_cmd_reg;
14402 int status; 14199 int status;
14403 14200
14404 warn_code = 0; 14201 warn_code = 0;
14405 asc_dvc->err_code = 0; 14202 asc_dvc->err_code = 0;
14406 iop_base = asc_dvc->iop_base; 14203 iop_base = asc_dvc->iop_base;
14407 14204
14408 /* 14205 /*
14409 * PCI Command Register 14206 * PCI Command Register
14410 * 14207 *
14411 * Note: AscPCICmdRegBits_BusMastering definition (0x0007) includes 14208 * Note: AscPCICmdRegBits_BusMastering definition (0x0007) includes
14412 * I/O Space Control, Memory Space Control and Bus Master Control bits. 14209 * I/O Space Control, Memory Space Control and Bus Master Control bits.
14413 */ 14210 */
14414 14211
14415 if (((pci_cmd_reg = DvcAdvReadPCIConfigByte(asc_dvc, 14212 if (((pci_cmd_reg = DvcAdvReadPCIConfigByte(asc_dvc,
14416 AscPCIConfigCommandRegister)) 14213 AscPCIConfigCommandRegister))
14417 & AscPCICmdRegBits_BusMastering) 14214 & AscPCICmdRegBits_BusMastering)
14418 != AscPCICmdRegBits_BusMastering) 14215 != AscPCICmdRegBits_BusMastering) {
14419 { 14216 pci_cmd_reg |= AscPCICmdRegBits_BusMastering;
14420 pci_cmd_reg |= AscPCICmdRegBits_BusMastering; 14217
14421 14218 DvcAdvWritePCIConfigByte(asc_dvc,
14422 DvcAdvWritePCIConfigByte(asc_dvc, 14219 AscPCIConfigCommandRegister,
14423 AscPCIConfigCommandRegister, pci_cmd_reg); 14220 pci_cmd_reg);
14424 14221
14425 if (((DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigCommandRegister)) 14222 if (((DvcAdvReadPCIConfigByte
14426 & AscPCICmdRegBits_BusMastering) 14223 (asc_dvc, AscPCIConfigCommandRegister))
14427 != AscPCICmdRegBits_BusMastering) 14224 & AscPCICmdRegBits_BusMastering)
14428 { 14225 != AscPCICmdRegBits_BusMastering) {
14429 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE; 14226 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
14430 } 14227 }
14431 } 14228 }
14432
14433 /*
14434 * PCI Latency Timer
14435 *
14436 * If the "latency timer" register is 0x20 or above, then we don't need
14437 * to change it. Otherwise, set it to 0x20 (i.e. set it to 0x20 if it
14438 * comes up less than 0x20).
14439 */
14440 if (DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) < 0x20) {
14441 DvcAdvWritePCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer, 0x20);
14442 if (DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) < 0x20)
14443 {
14444 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
14445 }
14446 }
14447
14448 /*
14449 * Save the state of the PCI Configuration Command Register
14450 * "Parity Error Response Control" Bit. If the bit is clear (0),
14451 * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
14452 * DMA parity errors.
14453 */
14454 asc_dvc->cfg->control_flag = 0;
14455 if (((DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigCommandRegister)
14456 & AscPCICmdRegBits_ParErrRespCtrl)) == 0)
14457 {
14458 asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
14459 }
14460 14229
14461 asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) | 14230 /*
14462 ADV_LIB_VERSION_MINOR; 14231 * PCI Latency Timer
14463 asc_dvc->cfg->chip_version = 14232 *
14464 AdvGetChipVersion(iop_base, asc_dvc->bus_type); 14233 * If the "latency timer" register is 0x20 or above, then we don't need
14234 * to change it. Otherwise, set it to 0x20 (i.e. set it to 0x20 if it
14235 * comes up less than 0x20).
14236 */
14237 if (DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) < 0x20) {
14238 DvcAdvWritePCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer,
14239 0x20);
14240 if (DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigLatencyTimer) <
14241 0x20) {
14242 warn_code |= ASC_WARN_SET_PCI_CONFIG_SPACE;
14243 }
14244 }
14465 14245
14466 ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n", 14246 /*
14467 (ushort) AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1), 14247 * Save the state of the PCI Configuration Command Register
14468 (ushort) ADV_CHIP_ID_BYTE); 14248 * "Parity Error Response Control" Bit. If the bit is clear (0),
14249 * in AdvInitAsc3550/38C0800Driver() tell the microcode to ignore
14250 * DMA parity errors.
14251 */
14252 asc_dvc->cfg->control_flag = 0;
14253 if (((DvcAdvReadPCIConfigByte(asc_dvc, AscPCIConfigCommandRegister)
14254 & AscPCICmdRegBits_ParErrRespCtrl)) == 0) {
14255 asc_dvc->cfg->control_flag |= CONTROL_FLAG_IGNORE_PERR;
14256 }
14469 14257
14470 ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n", 14258 asc_dvc->cfg->lib_version = (ADV_LIB_VERSION_MAJOR << 8) |
14471 (ushort) AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0), 14259 ADV_LIB_VERSION_MINOR;
14472 (ushort) ADV_CHIP_ID_WORD); 14260 asc_dvc->cfg->chip_version =
14261 AdvGetChipVersion(iop_base, asc_dvc->bus_type);
14262
14263 ASC_DBG2(1, "AdvInitGetConfig: iopb_chip_id_1: 0x%x 0x%x\n",
14264 (ushort)AdvReadByteRegister(iop_base, IOPB_CHIP_ID_1),
14265 (ushort)ADV_CHIP_ID_BYTE);
14266
14267 ASC_DBG2(1, "AdvInitGetConfig: iopw_chip_id_0: 0x%x 0x%x\n",
14268 (ushort)AdvReadWordRegister(iop_base, IOPW_CHIP_ID_0),
14269 (ushort)ADV_CHIP_ID_WORD);
14270
14271 /*
14272 * Reset the chip to start and allow register writes.
14273 */
14274 if (AdvFindSignature(iop_base) == 0) {
14275 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE;
14276 return ADV_ERROR;
14277 } else {
14278 /*
14279 * The caller must set 'chip_type' to a valid setting.
14280 */
14281 if (asc_dvc->chip_type != ADV_CHIP_ASC3550 &&
14282 asc_dvc->chip_type != ADV_CHIP_ASC38C0800 &&
14283 asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
14284 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
14285 return ADV_ERROR;
14286 }
14473 14287
14474 /* 14288 /*
14475 * Reset the chip to start and allow register writes. 14289 * Reset Chip.
14476 */ 14290 */
14477 if (AdvFindSignature(iop_base) == 0) 14291 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
14478 { 14292 ADV_CTRL_REG_CMD_RESET);
14479 asc_dvc->err_code = ASC_IERR_BAD_SIGNATURE; 14293 DvcSleepMilliSecond(100);
14480 return ADV_ERROR; 14294 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
14481 } 14295 ADV_CTRL_REG_CMD_WR_IO_REG);
14482 else { 14296
14483 /* 14297 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
14484 * The caller must set 'chip_type' to a valid setting. 14298 if ((status =
14485 */ 14299 AdvInitFrom38C1600EEP(asc_dvc)) == ADV_ERROR) {
14486 if (asc_dvc->chip_type != ADV_CHIP_ASC3550 && 14300 return ADV_ERROR;
14487 asc_dvc->chip_type != ADV_CHIP_ASC38C0800 && 14301 }
14488 asc_dvc->chip_type != ADV_CHIP_ASC38C1600) 14302 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
14489 { 14303 if ((status =
14490 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE; 14304 AdvInitFrom38C0800EEP(asc_dvc)) == ADV_ERROR) {
14491 return ADV_ERROR; 14305 return ADV_ERROR;
14492 } 14306 }
14493 14307 } else {
14494 /* 14308 if ((status = AdvInitFrom3550EEP(asc_dvc)) == ADV_ERROR) {
14495 * Reset Chip. 14309 return ADV_ERROR;
14496 */ 14310 }
14497 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, 14311 }
14498 ADV_CTRL_REG_CMD_RESET); 14312 warn_code |= status;
14499 DvcSleepMilliSecond(100); 14313 }
14500 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
14501 ADV_CTRL_REG_CMD_WR_IO_REG);
14502
14503 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
14504 {
14505 if ((status = AdvInitFrom38C1600EEP(asc_dvc)) == ADV_ERROR)
14506 {
14507 return ADV_ERROR;
14508 }
14509 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
14510 {
14511 if ((status = AdvInitFrom38C0800EEP(asc_dvc)) == ADV_ERROR)
14512 {
14513 return ADV_ERROR;
14514 }
14515 } else
14516 {
14517 if ((status = AdvInitFrom3550EEP(asc_dvc)) == ADV_ERROR)
14518 {
14519 return ADV_ERROR;
14520 }
14521 }
14522 warn_code |= status;
14523 }
14524 14314
14525 return warn_code; 14315 return warn_code;
14526} 14316}
14527 14317
14528/* 14318/*
@@ -14535,574 +14325,563 @@ AdvInitGetConfig(ADV_DVC_VAR *asc_dvc)
14535 * 14325 *
14536 * Needed after initialization for error recovery. 14326 * Needed after initialization for error recovery.
14537 */ 14327 */
14538STATIC int 14328static int AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
14539AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
14540{ 14329{
14541 AdvPortAddr iop_base; 14330 AdvPortAddr iop_base;
14542 ushort warn_code; 14331 ushort warn_code;
14543 ADV_DCNT sum; 14332 ADV_DCNT sum;
14544 int begin_addr; 14333 int begin_addr;
14545 int end_addr; 14334 int end_addr;
14546 ushort code_sum; 14335 ushort code_sum;
14547 int word; 14336 int word;
14548 int j; 14337 int j;
14549 int adv_asc3550_expanded_size; 14338 int adv_asc3550_expanded_size;
14550 ADV_CARR_T *carrp; 14339 ADV_CARR_T *carrp;
14551 ADV_DCNT contig_len; 14340 ADV_DCNT contig_len;
14552 ADV_SDCNT buf_size; 14341 ADV_SDCNT buf_size;
14553 ADV_PADDR carr_paddr; 14342 ADV_PADDR carr_paddr;
14554 int i; 14343 int i;
14555 ushort scsi_cfg1; 14344 ushort scsi_cfg1;
14556 uchar tid; 14345 uchar tid;
14557 ushort bios_mem[ASC_MC_BIOSLEN/2]; /* BIOS RISC Memory 0x40-0x8F. */ 14346 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
14558 ushort wdtr_able = 0, sdtr_able, tagqng_able; 14347 ushort wdtr_able = 0, sdtr_able, tagqng_able;
14559 uchar max_cmd[ADV_MAX_TID + 1]; 14348 uchar max_cmd[ADV_MAX_TID + 1];
14560 14349
14561 /* If there is already an error, don't continue. */ 14350 /* If there is already an error, don't continue. */
14562 if (asc_dvc->err_code != 0) 14351 if (asc_dvc->err_code != 0) {
14563 { 14352 return ADV_ERROR;
14564 return ADV_ERROR; 14353 }
14565 }
14566
14567 /*
14568 * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
14569 */
14570 if (asc_dvc->chip_type != ADV_CHIP_ASC3550)
14571 {
14572 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
14573 return ADV_ERROR;
14574 }
14575
14576 warn_code = 0;
14577 iop_base = asc_dvc->iop_base;
14578
14579 /*
14580 * Save the RISC memory BIOS region before writing the microcode.
14581 * The BIOS may already be loaded and using its RISC LRAM region
14582 * so its region must be saved and restored.
14583 *
14584 * Note: This code makes the assumption, which is currently true,
14585 * that a chip reset does not clear RISC LRAM.
14586 */
14587 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
14588 {
14589 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
14590 }
14591
14592 /*
14593 * Save current per TID negotiated values.
14594 */
14595 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA)
14596 {
14597 ushort bios_version, major, minor;
14598
14599 bios_version = bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM)/2];
14600 major = (bios_version >> 12) & 0xF;
14601 minor = (bios_version >> 8) & 0xF;
14602 if (major < 3 || (major == 3 && minor == 1))
14603 {
14604 /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
14605 AdvReadWordLram(iop_base, 0x120, wdtr_able);
14606 } else
14607 {
14608 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
14609 }
14610 }
14611 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
14612 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
14613 for (tid = 0; tid <= ADV_MAX_TID; tid++)
14614 {
14615 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
14616 max_cmd[tid]);
14617 }
14618
14619 /*
14620 * Load the Microcode
14621 *
14622 * Write the microcode image to RISC memory starting at address 0.
14623 */
14624 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
14625 /* Assume the following compressed format of the microcode buffer:
14626 *
14627 * 254 word (508 byte) table indexed by byte code followed
14628 * by the following byte codes:
14629 *
14630 * 1-Byte Code:
14631 * 00: Emit word 0 in table.
14632 * 01: Emit word 1 in table.
14633 * .
14634 * FD: Emit word 253 in table.
14635 *
14636 * Multi-Byte Code:
14637 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
14638 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
14639 */
14640 word = 0;
14641 for (i = 253 * 2; i < _adv_asc3550_size; i++)
14642 {
14643 if (_adv_asc3550_buf[i] == 0xff)
14644 {
14645 for (j = 0; j < _adv_asc3550_buf[i + 1]; j++)
14646 {
14647 AdvWriteWordAutoIncLram(iop_base, (((ushort)
14648 _adv_asc3550_buf[i + 3] << 8) |
14649 _adv_asc3550_buf[i + 2]));
14650 word++;
14651 }
14652 i += 3;
14653 } else if (_adv_asc3550_buf[i] == 0xfe)
14654 {
14655 AdvWriteWordAutoIncLram(iop_base, (((ushort)
14656 _adv_asc3550_buf[i + 2] << 8) |
14657 _adv_asc3550_buf[i + 1]));
14658 i += 2;
14659 word++;
14660 } else
14661 {
14662 AdvWriteWordAutoIncLram(iop_base, (((ushort)
14663 _adv_asc3550_buf[(_adv_asc3550_buf[i] * 2) + 1] << 8) |
14664 _adv_asc3550_buf[_adv_asc3550_buf[i] * 2]));
14665 word++;
14666 }
14667 }
14668
14669 /*
14670 * Set 'word' for later use to clear the rest of memory and save
14671 * the expanded mcode size.
14672 */
14673 word *= 2;
14674 adv_asc3550_expanded_size = word;
14675
14676 /*
14677 * Clear the rest of ASC-3550 Internal RAM (8KB).
14678 */
14679 for (; word < ADV_3550_MEMSIZE; word += 2)
14680 {
14681 AdvWriteWordAutoIncLram(iop_base, 0);
14682 }
14683
14684 /*
14685 * Verify the microcode checksum.
14686 */
14687 sum = 0;
14688 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
14689
14690 for (word = 0; word < adv_asc3550_expanded_size; word += 2)
14691 {
14692 sum += AdvReadWordAutoIncLram(iop_base);
14693 }
14694
14695 if (sum != _adv_asc3550_chksum)
14696 {
14697 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
14698 return ADV_ERROR;
14699 }
14700
14701 /*
14702 * Restore the RISC memory BIOS region.
14703 */
14704 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
14705 {
14706 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
14707 }
14708
14709 /*
14710 * Calculate and write the microcode code checksum to the microcode
14711 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
14712 */
14713 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
14714 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
14715 code_sum = 0;
14716 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
14717 for (word = begin_addr; word < end_addr; word += 2)
14718 {
14719 code_sum += AdvReadWordAutoIncLram(iop_base);
14720 }
14721 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
14722
14723 /*
14724 * Read and save microcode version and date.
14725 */
14726 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
14727 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
14728
14729 /*
14730 * Set the chip type to indicate the ASC3550.
14731 */
14732 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
14733
14734 /*
14735 * If the PCI Configuration Command Register "Parity Error Response
14736 * Control" Bit was clear (0), then set the microcode variable
14737 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
14738 * to ignore DMA parity errors.
14739 */
14740 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
14741 {
14742 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
14743 word |= CONTROL_FLAG_IGNORE_PERR;
14744 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
14745 }
14746
14747 /*
14748 * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
14749 * threshold of 128 bytes. This register is only accessible to the host.
14750 */
14751 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
14752 START_CTL_EMFU | READ_CMD_MRM);
14753
14754 /*
14755 * Microcode operating variables for WDTR, SDTR, and command tag
14756 * queuing will be set in AdvInquiryHandling() based on what a
14757 * device reports it is capable of in Inquiry byte 7.
14758 *
14759 * If SCSI Bus Resets have been disabled, then directly set
14760 * SDTR and WDTR from the EEPROM configuration. This will allow
14761 * the BIOS and warm boot to work without a SCSI bus hang on
14762 * the Inquiry caused by host and target mismatched DTR values.
14763 * Without the SCSI Bus Reset, before an Inquiry a device can't
14764 * be assumed to be in Asynchronous, Narrow mode.
14765 */
14766 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
14767 {
14768 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
14769 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
14770 }
14771
14772 /*
14773 * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
14774 * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
14775 * bitmask. These values determine the maximum SDTR speed negotiated
14776 * with a device.
14777 *
14778 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
14779 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
14780 * without determining here whether the device supports SDTR.
14781 *
14782 * 4-bit speed SDTR speed name
14783 * =========== ===============
14784 * 0000b (0x0) SDTR disabled
14785 * 0001b (0x1) 5 Mhz
14786 * 0010b (0x2) 10 Mhz
14787 * 0011b (0x3) 20 Mhz (Ultra)
14788 * 0100b (0x4) 40 Mhz (LVD/Ultra2)
14789 * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
14790 * 0110b (0x6) Undefined
14791 * .
14792 * 1111b (0xF) Undefined
14793 */
14794 word = 0;
14795 for (tid = 0; tid <= ADV_MAX_TID; tid++)
14796 {
14797 if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able)
14798 {
14799 /* Set Ultra speed for TID 'tid'. */
14800 word |= (0x3 << (4 * (tid % 4)));
14801 } else
14802 {
14803 /* Set Fast speed for TID 'tid'. */
14804 word |= (0x2 << (4 * (tid % 4)));
14805 }
14806 if (tid == 3) /* Check if done with sdtr_speed1. */
14807 {
14808 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
14809 word = 0;
14810 } else if (tid == 7) /* Check if done with sdtr_speed2. */
14811 {
14812 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
14813 word = 0;
14814 } else if (tid == 11) /* Check if done with sdtr_speed3. */
14815 {
14816 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
14817 word = 0;
14818 } else if (tid == 15) /* Check if done with sdtr_speed4. */
14819 {
14820 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
14821 /* End of loop. */
14822 }
14823 }
14824
14825 /*
14826 * Set microcode operating variable for the disconnect per TID bitmask.
14827 */
14828 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
14829 14354
14830 /* 14355 /*
14831 * Set SCSI_CFG0 Microcode Default Value. 14356 * The caller must set 'chip_type' to ADV_CHIP_ASC3550.
14832 * 14357 */
14833 * The microcode will set the SCSI_CFG0 register using this value 14358 if (asc_dvc->chip_type != ADV_CHIP_ASC3550) {
14834 * after it is started below. 14359 asc_dvc->err_code |= ASC_IERR_BAD_CHIPTYPE;
14835 */ 14360 return ADV_ERROR;
14836 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0, 14361 }
14837 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
14838 asc_dvc->chip_scsi_id);
14839 14362
14840 /* 14363 warn_code = 0;
14841 * Determine SCSI_CFG1 Microcode Default Value. 14364 iop_base = asc_dvc->iop_base;
14842 * 14365
14843 * The microcode will set the SCSI_CFG1 register using this value 14366 /*
14844 * after it is started below. 14367 * Save the RISC memory BIOS region before writing the microcode.
14845 */ 14368 * The BIOS may already be loaded and using its RISC LRAM region
14369 * so its region must be saved and restored.
14370 *
14371 * Note: This code makes the assumption, which is currently true,
14372 * that a chip reset does not clear RISC LRAM.
14373 */
14374 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
14375 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
14376 bios_mem[i]);
14377 }
14846 14378
14847 /* Read current SCSI_CFG1 Register value. */ 14379 /*
14848 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1); 14380 * Save current per TID negotiated values.
14381 */
14382 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] == 0x55AA) {
14383 ushort bios_version, major, minor;
14384
14385 bios_version =
14386 bios_mem[(ASC_MC_BIOS_VERSION - ASC_MC_BIOSMEM) / 2];
14387 major = (bios_version >> 12) & 0xF;
14388 minor = (bios_version >> 8) & 0xF;
14389 if (major < 3 || (major == 3 && minor == 1)) {
14390 /* BIOS 3.1 and earlier location of 'wdtr_able' variable. */
14391 AdvReadWordLram(iop_base, 0x120, wdtr_able);
14392 } else {
14393 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
14394 }
14395 }
14396 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
14397 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
14398 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
14399 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
14400 max_cmd[tid]);
14401 }
14849 14402
14850 /* 14403 /*
14851 * If all three connectors are in use, return an error. 14404 * Load the Microcode
14852 */ 14405 *
14853 if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 || 14406 * Write the microcode image to RISC memory starting at address 0.
14854 (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) 14407 */
14855 { 14408 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
14856 asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION; 14409 /* Assume the following compressed format of the microcode buffer:
14857 return ADV_ERROR; 14410 *
14858 } 14411 * 254 word (508 byte) table indexed by byte code followed
14412 * by the following byte codes:
14413 *
14414 * 1-Byte Code:
14415 * 00: Emit word 0 in table.
14416 * 01: Emit word 1 in table.
14417 * .
14418 * FD: Emit word 253 in table.
14419 *
14420 * Multi-Byte Code:
14421 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
14422 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
14423 */
14424 word = 0;
14425 for (i = 253 * 2; i < _adv_asc3550_size; i++) {
14426 if (_adv_asc3550_buf[i] == 0xff) {
14427 for (j = 0; j < _adv_asc3550_buf[i + 1]; j++) {
14428 AdvWriteWordAutoIncLram(iop_base, (((ushort)
14429 _adv_asc3550_buf
14430 [i +
14431 3] << 8) |
14432 _adv_asc3550_buf
14433 [i + 2]));
14434 word++;
14435 }
14436 i += 3;
14437 } else if (_adv_asc3550_buf[i] == 0xfe) {
14438 AdvWriteWordAutoIncLram(iop_base, (((ushort)
14439 _adv_asc3550_buf[i +
14440 2]
14441 << 8) |
14442 _adv_asc3550_buf[i +
14443 1]));
14444 i += 2;
14445 word++;
14446 } else {
14447 AdvWriteWordAutoIncLram(iop_base, (((ushort)
14448 _adv_asc3550_buf[(_adv_asc3550_buf[i] * 2) + 1] << 8) | _adv_asc3550_buf[_adv_asc3550_buf[i] * 2]));
14449 word++;
14450 }
14451 }
14859 14452
14860 /* 14453 /*
14861 * If the internal narrow cable is reversed all of the SCSI_CTRL 14454 * Set 'word' for later use to clear the rest of memory and save
14862 * register signals will be set. Check for and return an error if 14455 * the expanded mcode size.
14863 * this condition is found. 14456 */
14864 */ 14457 word *= 2;
14865 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) 14458 adv_asc3550_expanded_size = word;
14866 { 14459
14867 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE; 14460 /*
14868 return ADV_ERROR; 14461 * Clear the rest of ASC-3550 Internal RAM (8KB).
14869 } 14462 */
14463 for (; word < ADV_3550_MEMSIZE; word += 2) {
14464 AdvWriteWordAutoIncLram(iop_base, 0);
14465 }
14870 14466
14871 /* 14467 /*
14872 * If this is a differential board and a single-ended device 14468 * Verify the microcode checksum.
14873 * is attached to one of the connectors, return an error. 14469 */
14874 */ 14470 sum = 0;
14875 if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) 14471 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
14876 {
14877 asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
14878 return ADV_ERROR;
14879 }
14880 14472
14881 /* 14473 for (word = 0; word < adv_asc3550_expanded_size; word += 2) {
14882 * If automatic termination control is enabled, then set the 14474 sum += AdvReadWordAutoIncLram(iop_base);
14883 * termination value based on a table listed in a_condor.h. 14475 }
14884 *
14885 * If manual termination was specified with an EEPROM setting
14886 * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
14887 * is ready to be 'ored' into SCSI_CFG1.
14888 */
14889 if (asc_dvc->cfg->termination == 0)
14890 {
14891 /*
14892 * The software always controls termination by setting TERM_CTL_SEL.
14893 * If TERM_CTL_SEL were set to 0, the hardware would set termination.
14894 */
14895 asc_dvc->cfg->termination |= TERM_CTL_SEL;
14896
14897 switch(scsi_cfg1 & CABLE_DETECT)
14898 {
14899 /* TERM_CTL_H: on, TERM_CTL_L: on */
14900 case 0x3: case 0x7: case 0xB: case 0xD: case 0xE: case 0xF:
14901 asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
14902 break;
14903
14904 /* TERM_CTL_H: on, TERM_CTL_L: off */
14905 case 0x1: case 0x5: case 0x9: case 0xA: case 0xC:
14906 asc_dvc->cfg->termination |= TERM_CTL_H;
14907 break;
14908
14909 /* TERM_CTL_H: off, TERM_CTL_L: off */
14910 case 0x2: case 0x6:
14911 break;
14912 }
14913 }
14914 14476
14915 /* 14477 if (sum != _adv_asc3550_chksum) {
14916 * Clear any set TERM_CTL_H and TERM_CTL_L bits. 14478 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
14917 */ 14479 return ADV_ERROR;
14918 scsi_cfg1 &= ~TERM_CTL; 14480 }
14919 14481
14920 /* 14482 /*
14921 * Invert the TERM_CTL_H and TERM_CTL_L bits and then 14483 * Restore the RISC memory BIOS region.
14922 * set 'scsi_cfg1'. The TERM_POL bit does not need to be 14484 */
14923 * referenced, because the hardware internally inverts 14485 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
14924 * the Termination High and Low bits if TERM_POL is set. 14486 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
14925 */ 14487 bios_mem[i]);
14926 scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL)); 14488 }
14927 14489
14928 /* 14490 /*
14929 * Set SCSI_CFG1 Microcode Default Value 14491 * Calculate and write the microcode code checksum to the microcode
14930 * 14492 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
14931 * Set filter value and possibly modified termination control 14493 */
14932 * bits in the Microcode SCSI_CFG1 Register Value. 14494 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
14933 * 14495 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
14934 * The microcode will set the SCSI_CFG1 register using this value 14496 code_sum = 0;
14935 * after it is started below. 14497 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
14936 */ 14498 for (word = begin_addr; word < end_addr; word += 2) {
14937 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, 14499 code_sum += AdvReadWordAutoIncLram(iop_base);
14938 FLTR_DISABLE | scsi_cfg1); 14500 }
14501 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
14502
14503 /*
14504 * Read and save microcode version and date.
14505 */
14506 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
14507 asc_dvc->cfg->mcode_date);
14508 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
14509 asc_dvc->cfg->mcode_version);
14510
14511 /*
14512 * Set the chip type to indicate the ASC3550.
14513 */
14514 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC3550);
14515
14516 /*
14517 * If the PCI Configuration Command Register "Parity Error Response
14518 * Control" Bit was clear (0), then set the microcode variable
14519 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
14520 * to ignore DMA parity errors.
14521 */
14522 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
14523 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
14524 word |= CONTROL_FLAG_IGNORE_PERR;
14525 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
14526 }
14939 14527
14940 /* 14528 /*
14941 * Set MEM_CFG Microcode Default Value 14529 * For ASC-3550, setting the START_CTL_EMFU [3:2] bits sets a FIFO
14942 * 14530 * threshold of 128 bytes. This register is only accessible to the host.
14943 * The microcode will set the MEM_CFG register using this value 14531 */
14944 * after it is started below. 14532 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
14945 * 14533 START_CTL_EMFU | READ_CMD_MRM);
14946 * MEM_CFG may be accessed as a word or byte, but only bits 0-7 14534
14947 * are defined. 14535 /*
14948 * 14536 * Microcode operating variables for WDTR, SDTR, and command tag
14949 * ASC-3550 has 8KB internal memory. 14537 * queuing will be set in AdvInquiryHandling() based on what a
14950 */ 14538 * device reports it is capable of in Inquiry byte 7.
14951 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG, 14539 *
14952 BIOS_EN | RAM_SZ_8KB); 14540 * If SCSI Bus Resets have been disabled, then directly set
14541 * SDTR and WDTR from the EEPROM configuration. This will allow
14542 * the BIOS and warm boot to work without a SCSI bus hang on
14543 * the Inquiry caused by host and target mismatched DTR values.
14544 * Without the SCSI Bus Reset, before an Inquiry a device can't
14545 * be assumed to be in Asynchronous, Narrow mode.
14546 */
14547 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
14548 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
14549 asc_dvc->wdtr_able);
14550 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
14551 asc_dvc->sdtr_able);
14552 }
14953 14553
14954 /* 14554 /*
14955 * Set SEL_MASK Microcode Default Value 14555 * Set microcode operating variables for SDTR_SPEED1, SDTR_SPEED2,
14956 * 14556 * SDTR_SPEED3, and SDTR_SPEED4 based on the ULTRA EEPROM per TID
14957 * The microcode will set the SEL_MASK register using this value 14557 * bitmask. These values determine the maximum SDTR speed negotiated
14958 * after it is started below. 14558 * with a device.
14959 */ 14559 *
14960 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK, 14560 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
14961 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id)); 14561 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
14562 * without determining here whether the device supports SDTR.
14563 *
14564 * 4-bit speed SDTR speed name
14565 * =========== ===============
14566 * 0000b (0x0) SDTR disabled
14567 * 0001b (0x1) 5 Mhz
14568 * 0010b (0x2) 10 Mhz
14569 * 0011b (0x3) 20 Mhz (Ultra)
14570 * 0100b (0x4) 40 Mhz (LVD/Ultra2)
14571 * 0101b (0x5) 80 Mhz (LVD2/Ultra3)
14572 * 0110b (0x6) Undefined
14573 * .
14574 * 1111b (0xF) Undefined
14575 */
14576 word = 0;
14577 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
14578 if (ADV_TID_TO_TIDMASK(tid) & asc_dvc->ultra_able) {
14579 /* Set Ultra speed for TID 'tid'. */
14580 word |= (0x3 << (4 * (tid % 4)));
14581 } else {
14582 /* Set Fast speed for TID 'tid'. */
14583 word |= (0x2 << (4 * (tid % 4)));
14584 }
14585 if (tid == 3) { /* Check if done with sdtr_speed1. */
14586 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, word);
14587 word = 0;
14588 } else if (tid == 7) { /* Check if done with sdtr_speed2. */
14589 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, word);
14590 word = 0;
14591 } else if (tid == 11) { /* Check if done with sdtr_speed3. */
14592 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, word);
14593 word = 0;
14594 } else if (tid == 15) { /* Check if done with sdtr_speed4. */
14595 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, word);
14596 /* End of loop. */
14597 }
14598 }
14962 14599
14963 /* 14600 /*
14964 * Build carrier freelist. 14601 * Set microcode operating variable for the disconnect per TID bitmask.
14965 * 14602 */
14966 * Driver must have already allocated memory and set 'carrier_buf'. 14603 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
14967 */ 14604 asc_dvc->cfg->disc_enable);
14968 ASC_ASSERT(asc_dvc->carrier_buf != NULL); 14605
14969 14606 /*
14970 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf); 14607 * Set SCSI_CFG0 Microcode Default Value.
14971 asc_dvc->carr_freelist = NULL; 14608 *
14972 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) 14609 * The microcode will set the SCSI_CFG0 register using this value
14973 { 14610 * after it is started below.
14974 buf_size = ADV_CARRIER_BUFSIZE; 14611 */
14975 } else 14612 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
14976 { 14613 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
14977 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T); 14614 asc_dvc->chip_scsi_id);
14978 } 14615
14616 /*
14617 * Determine SCSI_CFG1 Microcode Default Value.
14618 *
14619 * The microcode will set the SCSI_CFG1 register using this value
14620 * after it is started below.
14621 */
14622
14623 /* Read current SCSI_CFG1 Register value. */
14624 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
14625
14626 /*
14627 * If all three connectors are in use, return an error.
14628 */
14629 if ((scsi_cfg1 & CABLE_ILLEGAL_A) == 0 ||
14630 (scsi_cfg1 & CABLE_ILLEGAL_B) == 0) {
14631 asc_dvc->err_code |= ASC_IERR_ILLEGAL_CONNECTION;
14632 return ADV_ERROR;
14633 }
14979 14634
14980 do { 14635 /*
14981 /* 14636 * If the internal narrow cable is reversed all of the SCSI_CTRL
14982 * Get physical address of the carrier 'carrp'. 14637 * register signals will be set. Check for and return an error if
14983 */ 14638 * this condition is found.
14984 contig_len = sizeof(ADV_CARR_T); 14639 */
14985 carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp, 14640 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
14986 (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG)); 14641 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
14987 14642 return ADV_ERROR;
14988 buf_size -= sizeof(ADV_CARR_T); 14643 }
14989
14990 /*
14991 * If the current carrier is not physically contiguous, then
14992 * maybe there was a page crossing. Try the next carrier aligned
14993 * start address.
14994 */
14995 if (contig_len < sizeof(ADV_CARR_T))
14996 {
14997 carrp++;
14998 continue;
14999 }
15000
15001 carrp->carr_pa = carr_paddr;
15002 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
15003
15004 /*
15005 * Insert the carrier at the beginning of the freelist.
15006 */
15007 carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
15008 asc_dvc->carr_freelist = carrp;
15009
15010 carrp++;
15011 }
15012 while (buf_size > 0);
15013 14644
15014 /* 14645 /*
15015 * Set-up the Host->RISC Initiator Command Queue (ICQ). 14646 * If this is a differential board and a single-ended device
15016 */ 14647 * is attached to one of the connectors, return an error.
14648 */
14649 if ((scsi_cfg1 & DIFF_MODE) && (scsi_cfg1 & DIFF_SENSE) == 0) {
14650 asc_dvc->err_code |= ASC_IERR_SINGLE_END_DEVICE;
14651 return ADV_ERROR;
14652 }
15017 14653
15018 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) 14654 /*
15019 { 14655 * If automatic termination control is enabled, then set the
15020 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; 14656 * termination value based on a table listed in a_condor.h.
15021 return ADV_ERROR; 14657 *
15022 } 14658 * If manual termination was specified with an EEPROM setting
15023 asc_dvc->carr_freelist = (ADV_CARR_T *) 14659 * then 'termination' was set-up in AdvInitFrom3550EEPROM() and
15024 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa)); 14660 * is ready to be 'ored' into SCSI_CFG1.
14661 */
14662 if (asc_dvc->cfg->termination == 0) {
14663 /*
14664 * The software always controls termination by setting TERM_CTL_SEL.
14665 * If TERM_CTL_SEL were set to 0, the hardware would set termination.
14666 */
14667 asc_dvc->cfg->termination |= TERM_CTL_SEL;
14668
14669 switch (scsi_cfg1 & CABLE_DETECT) {
14670 /* TERM_CTL_H: on, TERM_CTL_L: on */
14671 case 0x3:
14672 case 0x7:
14673 case 0xB:
14674 case 0xD:
14675 case 0xE:
14676 case 0xF:
14677 asc_dvc->cfg->termination |= (TERM_CTL_H | TERM_CTL_L);
14678 break;
14679
14680 /* TERM_CTL_H: on, TERM_CTL_L: off */
14681 case 0x1:
14682 case 0x5:
14683 case 0x9:
14684 case 0xA:
14685 case 0xC:
14686 asc_dvc->cfg->termination |= TERM_CTL_H;
14687 break;
14688
14689 /* TERM_CTL_H: off, TERM_CTL_L: off */
14690 case 0x2:
14691 case 0x6:
14692 break;
14693 }
14694 }
15025 14695
15026 /* 14696 /*
15027 * The first command issued will be placed in the stopper carrier. 14697 * Clear any set TERM_CTL_H and TERM_CTL_L bits.
15028 */ 14698 */
15029 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER); 14699 scsi_cfg1 &= ~TERM_CTL;
14700
14701 /*
14702 * Invert the TERM_CTL_H and TERM_CTL_L bits and then
14703 * set 'scsi_cfg1'. The TERM_POL bit does not need to be
14704 * referenced, because the hardware internally inverts
14705 * the Termination High and Low bits if TERM_POL is set.
14706 */
14707 scsi_cfg1 |= (TERM_CTL_SEL | (~asc_dvc->cfg->termination & TERM_CTL));
14708
14709 /*
14710 * Set SCSI_CFG1 Microcode Default Value
14711 *
14712 * Set filter value and possibly modified termination control
14713 * bits in the Microcode SCSI_CFG1 Register Value.
14714 *
14715 * The microcode will set the SCSI_CFG1 register using this value
14716 * after it is started below.
14717 */
14718 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1,
14719 FLTR_DISABLE | scsi_cfg1);
14720
14721 /*
14722 * Set MEM_CFG Microcode Default Value
14723 *
14724 * The microcode will set the MEM_CFG register using this value
14725 * after it is started below.
14726 *
14727 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
14728 * are defined.
14729 *
14730 * ASC-3550 has 8KB internal memory.
14731 */
14732 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
14733 BIOS_EN | RAM_SZ_8KB);
14734
14735 /*
14736 * Set SEL_MASK Microcode Default Value
14737 *
14738 * The microcode will set the SEL_MASK register using this value
14739 * after it is started below.
14740 */
14741 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
14742 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
14743
14744 /*
14745 * Build carrier freelist.
14746 *
14747 * Driver must have already allocated memory and set 'carrier_buf'.
14748 */
14749 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
14750
14751 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
14752 asc_dvc->carr_freelist = NULL;
14753 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
14754 buf_size = ADV_CARRIER_BUFSIZE;
14755 } else {
14756 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
14757 }
15030 14758
15031 /* 14759 do {
15032 * Set RISC ICQ physical address start value. 14760 /*
15033 */ 14761 * Get physical address of the carrier 'carrp'.
15034 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa); 14762 */
14763 contig_len = sizeof(ADV_CARR_T);
14764 carr_paddr =
14765 cpu_to_le32(DvcGetPhyAddr
14766 (asc_dvc, NULL, (uchar *)carrp,
14767 (ADV_SDCNT *)&contig_len,
14768 ADV_IS_CARRIER_FLAG));
15035 14769
15036 /* 14770 buf_size -= sizeof(ADV_CARR_T);
15037 * Set-up the RISC->Host Initiator Response Queue (IRQ).
15038 */
15039 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL)
15040 {
15041 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
15042 return ADV_ERROR;
15043 }
15044 asc_dvc->carr_freelist = (ADV_CARR_T *)
15045 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
15046 14771
15047 /* 14772 /*
15048 * The first command completed by the RISC will be placed in 14773 * If the current carrier is not physically contiguous, then
15049 * the stopper. 14774 * maybe there was a page crossing. Try the next carrier aligned
15050 * 14775 * start address.
15051 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is 14776 */
15052 * completed the RISC will set the ASC_RQ_STOPPER bit. 14777 if (contig_len < sizeof(ADV_CARR_T)) {
15053 */ 14778 carrp++;
15054 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER); 14779 continue;
15055 14780 }
15056 /* 14781
15057 * Set RISC IRQ physical address start value. 14782 carrp->carr_pa = carr_paddr;
15058 */ 14783 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
15059 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
15060 asc_dvc->carr_pending_cnt = 0;
15061 14784
15062 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES, 14785 /*
15063 (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR)); 14786 * Insert the carrier at the beginning of the freelist.
14787 */
14788 carrp->next_vpa =
14789 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
14790 asc_dvc->carr_freelist = carrp;
15064 14791
15065 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word); 14792 carrp++;
15066 AdvWriteWordRegister(iop_base, IOPW_PC, word); 14793 }
14794 while (buf_size > 0);
15067 14795
15068 /* finally, finally, gentlemen, start your engine */ 14796 /*
15069 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN); 14797 * Set-up the Host->RISC Initiator Command Queue (ICQ).
14798 */
15070 14799
15071 /* 14800 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
15072 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus 14801 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
15073 * Resets should be performed. The RISC has to be running 14802 return ADV_ERROR;
15074 * to issue a SCSI Bus Reset. 14803 }
15075 */ 14804 asc_dvc->carr_freelist = (ADV_CARR_T *)
15076 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) 14805 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
15077 { 14806
15078 /* 14807 /*
15079 * If the BIOS Signature is present in memory, restore the 14808 * The first command issued will be placed in the stopper carrier.
15080 * BIOS Handshake Configuration Table and do not perform 14809 */
15081 * a SCSI Bus Reset. 14810 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
15082 */ 14811
15083 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA) 14812 /*
15084 { 14813 * Set RISC ICQ physical address start value.
15085 /* 14814 */
15086 * Restore per TID negotiated values. 14815 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
15087 */ 14816
15088 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able); 14817 /*
15089 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able); 14818 * Set-up the RISC->Host Initiator Response Queue (IRQ).
15090 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able); 14819 */
15091 for (tid = 0; tid <= ADV_MAX_TID; tid++) 14820 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
15092 { 14821 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
15093 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid, 14822 return ADV_ERROR;
15094 max_cmd[tid]); 14823 }
15095 } 14824 asc_dvc->carr_freelist = (ADV_CARR_T *)
15096 } else 14825 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
15097 { 14826
15098 if (AdvResetSB(asc_dvc) != ADV_TRUE) 14827 /*
15099 { 14828 * The first command completed by the RISC will be placed in
15100 warn_code = ASC_WARN_BUSRESET_ERROR; 14829 * the stopper.
15101 } 14830 *
15102 } 14831 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
15103 } 14832 * completed the RISC will set the ASC_RQ_STOPPER bit.
14833 */
14834 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
14835
14836 /*
14837 * Set RISC IRQ physical address start value.
14838 */
14839 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
14840 asc_dvc->carr_pending_cnt = 0;
14841
14842 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
14843 (ADV_INTR_ENABLE_HOST_INTR |
14844 ADV_INTR_ENABLE_GLOBAL_INTR));
14845
14846 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
14847 AdvWriteWordRegister(iop_base, IOPW_PC, word);
14848
14849 /* finally, finally, gentlemen, start your engine */
14850 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
14851
14852 /*
14853 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
14854 * Resets should be performed. The RISC has to be running
14855 * to issue a SCSI Bus Reset.
14856 */
14857 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
14858 /*
14859 * If the BIOS Signature is present in memory, restore the
14860 * BIOS Handshake Configuration Table and do not perform
14861 * a SCSI Bus Reset.
14862 */
14863 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
14864 0x55AA) {
14865 /*
14866 * Restore per TID negotiated values.
14867 */
14868 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
14869 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
14870 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
14871 tagqng_able);
14872 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
14873 AdvWriteByteLram(iop_base,
14874 ASC_MC_NUMBER_OF_MAX_CMD + tid,
14875 max_cmd[tid]);
14876 }
14877 } else {
14878 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
14879 warn_code = ASC_WARN_BUSRESET_ERROR;
14880 }
14881 }
14882 }
15104 14883
15105 return warn_code; 14884 return warn_code;
15106} 14885}
15107 14886
15108/* 14887/*
@@ -15115,619 +14894,610 @@ AdvInitAsc3550Driver(ADV_DVC_VAR *asc_dvc)
15115 * 14894 *
15116 * Needed after initialization for error recovery. 14895 * Needed after initialization for error recovery.
15117 */ 14896 */
15118STATIC int 14897static int AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
15119AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
15120{ 14898{
15121 AdvPortAddr iop_base; 14899 AdvPortAddr iop_base;
15122 ushort warn_code; 14900 ushort warn_code;
15123 ADV_DCNT sum; 14901 ADV_DCNT sum;
15124 int begin_addr; 14902 int begin_addr;
15125 int end_addr; 14903 int end_addr;
15126 ushort code_sum; 14904 ushort code_sum;
15127 int word; 14905 int word;
15128 int j; 14906 int j;
15129 int adv_asc38C0800_expanded_size; 14907 int adv_asc38C0800_expanded_size;
15130 ADV_CARR_T *carrp; 14908 ADV_CARR_T *carrp;
15131 ADV_DCNT contig_len; 14909 ADV_DCNT contig_len;
15132 ADV_SDCNT buf_size; 14910 ADV_SDCNT buf_size;
15133 ADV_PADDR carr_paddr; 14911 ADV_PADDR carr_paddr;
15134 int i; 14912 int i;
15135 ushort scsi_cfg1; 14913 ushort scsi_cfg1;
15136 uchar byte; 14914 uchar byte;
15137 uchar tid; 14915 uchar tid;
15138 ushort bios_mem[ASC_MC_BIOSLEN/2]; /* BIOS RISC Memory 0x40-0x8F. */ 14916 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
15139 ushort wdtr_able, sdtr_able, tagqng_able; 14917 ushort wdtr_able, sdtr_able, tagqng_able;
15140 uchar max_cmd[ADV_MAX_TID + 1]; 14918 uchar max_cmd[ADV_MAX_TID + 1];
15141 14919
15142 /* If there is already an error, don't continue. */ 14920 /* If there is already an error, don't continue. */
15143 if (asc_dvc->err_code != 0) 14921 if (asc_dvc->err_code != 0) {
15144 { 14922 return ADV_ERROR;
15145 return ADV_ERROR; 14923 }
15146 }
15147
15148 /*
15149 * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
15150 */
15151 if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800)
15152 {
15153 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
15154 return ADV_ERROR;
15155 }
15156
15157 warn_code = 0;
15158 iop_base = asc_dvc->iop_base;
15159
15160 /*
15161 * Save the RISC memory BIOS region before writing the microcode.
15162 * The BIOS may already be loaded and using its RISC LRAM region
15163 * so its region must be saved and restored.
15164 *
15165 * Note: This code makes the assumption, which is currently true,
15166 * that a chip reset does not clear RISC LRAM.
15167 */
15168 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
15169 {
15170 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
15171 }
15172
15173 /*
15174 * Save current per TID negotiated values.
15175 */
15176 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
15177 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
15178 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
15179 for (tid = 0; tid <= ADV_MAX_TID; tid++)
15180 {
15181 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
15182 max_cmd[tid]);
15183 }
15184
15185 /*
15186 * RAM BIST (RAM Built-In Self Test)
15187 *
15188 * Address : I/O base + offset 0x38h register (byte).
15189 * Function: Bit 7-6(RW) : RAM mode
15190 * Normal Mode : 0x00
15191 * Pre-test Mode : 0x40
15192 * RAM Test Mode : 0x80
15193 * Bit 5 : unused
15194 * Bit 4(RO) : Done bit
15195 * Bit 3-0(RO) : Status
15196 * Host Error : 0x08
15197 * Int_RAM Error : 0x04
15198 * RISC Error : 0x02
15199 * SCSI Error : 0x01
15200 * No Error : 0x00
15201 *
15202 * Note: RAM BIST code should be put right here, before loading the
15203 * microcode and after saving the RISC memory BIOS region.
15204 */
15205
15206 /*
15207 * LRAM Pre-test
15208 *
15209 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
15210 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
15211 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
15212 * to NORMAL_MODE, return an error too.
15213 */
15214 for (i = 0; i < 2; i++)
15215 {
15216 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
15217 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
15218 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
15219 if ((byte & RAM_TEST_DONE) == 0 || (byte & 0x0F) != PRE_TEST_VALUE)
15220 {
15221 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15222 return ADV_ERROR;
15223 }
15224
15225 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15226 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
15227 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
15228 != NORMAL_VALUE)
15229 {
15230 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15231 return ADV_ERROR;
15232 }
15233 }
15234
15235 /*
15236 * LRAM Test - It takes about 1.5 ms to run through the test.
15237 *
15238 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
15239 * If Done bit not set or Status not 0, save register byte, set the
15240 * err_code, and return an error.
15241 */
15242 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
15243 DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
15244
15245 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
15246 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0)
15247 {
15248 /* Get here if Done bit not set or Status not 0. */
15249 asc_dvc->bist_err_code = byte; /* for BIOS display message */
15250 asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
15251 return ADV_ERROR;
15252 }
15253
15254 /* We need to reset back to normal mode after LRAM test passes. */
15255 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15256
15257 /*
15258 * Load the Microcode
15259 *
15260 * Write the microcode image to RISC memory starting at address 0.
15261 *
15262 */
15263 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15264
15265 /* Assume the following compressed format of the microcode buffer:
15266 *
15267 * 254 word (508 byte) table indexed by byte code followed
15268 * by the following byte codes:
15269 *
15270 * 1-Byte Code:
15271 * 00: Emit word 0 in table.
15272 * 01: Emit word 1 in table.
15273 * .
15274 * FD: Emit word 253 in table.
15275 *
15276 * Multi-Byte Code:
15277 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
15278 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
15279 */
15280 word = 0;
15281 for (i = 253 * 2; i < _adv_asc38C0800_size; i++)
15282 {
15283 if (_adv_asc38C0800_buf[i] == 0xff)
15284 {
15285 for (j = 0; j < _adv_asc38C0800_buf[i + 1]; j++)
15286 {
15287 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15288 _adv_asc38C0800_buf[i + 3] << 8) |
15289 _adv_asc38C0800_buf[i + 2]));
15290 word++;
15291 }
15292 i += 3;
15293 } else if (_adv_asc38C0800_buf[i] == 0xfe)
15294 {
15295 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15296 _adv_asc38C0800_buf[i + 2] << 8) |
15297 _adv_asc38C0800_buf[i + 1]));
15298 i += 2;
15299 word++;
15300 } else
15301 {
15302 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15303 _adv_asc38C0800_buf[(_adv_asc38C0800_buf[i] * 2) + 1] << 8) |
15304 _adv_asc38C0800_buf[_adv_asc38C0800_buf[i] * 2]));
15305 word++;
15306 }
15307 }
15308
15309 /*
15310 * Set 'word' for later use to clear the rest of memory and save
15311 * the expanded mcode size.
15312 */
15313 word *= 2;
15314 adv_asc38C0800_expanded_size = word;
15315
15316 /*
15317 * Clear the rest of ASC-38C0800 Internal RAM (16KB).
15318 */
15319 for (; word < ADV_38C0800_MEMSIZE; word += 2)
15320 {
15321 AdvWriteWordAutoIncLram(iop_base, 0);
15322 }
15323
15324 /*
15325 * Verify the microcode checksum.
15326 */
15327 sum = 0;
15328 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15329
15330 for (word = 0; word < adv_asc38C0800_expanded_size; word += 2)
15331 {
15332 sum += AdvReadWordAutoIncLram(iop_base);
15333 }
15334 ASC_DBG2(1, "AdvInitAsc38C0800Driver: word %d, i %d\n", word, i);
15335
15336 ASC_DBG2(1,
15337 "AdvInitAsc38C0800Driver: sum 0x%lx, _adv_asc38C0800_chksum 0x%lx\n",
15338 (ulong) sum, (ulong) _adv_asc38C0800_chksum);
15339
15340 if (sum != _adv_asc38C0800_chksum)
15341 {
15342 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
15343 return ADV_ERROR;
15344 }
15345
15346 /*
15347 * Restore the RISC memory BIOS region.
15348 */
15349 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
15350 {
15351 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
15352 }
15353
15354 /*
15355 * Calculate and write the microcode code checksum to the microcode
15356 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
15357 */
15358 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
15359 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
15360 code_sum = 0;
15361 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
15362 for (word = begin_addr; word < end_addr; word += 2)
15363 {
15364 code_sum += AdvReadWordAutoIncLram(iop_base);
15365 }
15366 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
15367
15368 /*
15369 * Read microcode version and date.
15370 */
15371 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
15372 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
15373
15374 /*
15375 * Set the chip type to indicate the ASC38C0800.
15376 */
15377 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
15378
15379 /*
15380 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
15381 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
15382 * cable detection and then we are able to read C_DET[3:0].
15383 *
15384 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
15385 * Microcode Default Value' section below.
15386 */
15387 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
15388 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1, scsi_cfg1 | DIS_TERM_DRV);
15389
15390 /*
15391 * If the PCI Configuration Command Register "Parity Error Response
15392 * Control" Bit was clear (0), then set the microcode variable
15393 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
15394 * to ignore DMA parity errors.
15395 */
15396 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
15397 {
15398 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15399 word |= CONTROL_FLAG_IGNORE_PERR;
15400 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15401 }
15402
15403 /*
15404 * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
15405 * bits for the default FIFO threshold.
15406 *
15407 * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
15408 *
15409 * For DMA Errata #4 set the BC_THRESH_ENB bit.
15410 */
15411 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
15412 BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
15413
15414 /*
15415 * Microcode operating variables for WDTR, SDTR, and command tag
15416 * queuing will be set in AdvInquiryHandling() based on what a
15417 * device reports it is capable of in Inquiry byte 7.
15418 *
15419 * If SCSI Bus Resets have been disabled, then directly set
15420 * SDTR and WDTR from the EEPROM configuration. This will allow
15421 * the BIOS and warm boot to work without a SCSI bus hang on
15422 * the Inquiry caused by host and target mismatched DTR values.
15423 * Without the SCSI Bus Reset, before an Inquiry a device can't
15424 * be assumed to be in Asynchronous, Narrow mode.
15425 */
15426 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
15427 {
15428 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
15429 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
15430 }
15431
15432 /*
15433 * Set microcode operating variables for DISC and SDTR_SPEED1,
15434 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
15435 * configuration values.
15436 *
15437 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
15438 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
15439 * without determining here whether the device supports SDTR.
15440 */
15441 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
15442 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
15443 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
15444 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
15445 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
15446 14924
15447 /* 14925 /*
15448 * Set SCSI_CFG0 Microcode Default Value. 14926 * The caller must set 'chip_type' to ADV_CHIP_ASC38C0800.
15449 * 14927 */
15450 * The microcode will set the SCSI_CFG0 register using this value 14928 if (asc_dvc->chip_type != ADV_CHIP_ASC38C0800) {
15451 * after it is started below. 14929 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
15452 */ 14930 return ADV_ERROR;
15453 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0, 14931 }
15454 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
15455 asc_dvc->chip_scsi_id);
15456 14932
15457 /* 14933 warn_code = 0;
15458 * Determine SCSI_CFG1 Microcode Default Value. 14934 iop_base = asc_dvc->iop_base;
15459 * 14935
15460 * The microcode will set the SCSI_CFG1 register using this value 14936 /*
15461 * after it is started below. 14937 * Save the RISC memory BIOS region before writing the microcode.
15462 */ 14938 * The BIOS may already be loaded and using its RISC LRAM region
14939 * so its region must be saved and restored.
14940 *
14941 * Note: This code makes the assumption, which is currently true,
14942 * that a chip reset does not clear RISC LRAM.
14943 */
14944 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
14945 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
14946 bios_mem[i]);
14947 }
15463 14948
15464 /* Read current SCSI_CFG1 Register value. */ 14949 /*
15465 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1); 14950 * Save current per TID negotiated values.
14951 */
14952 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
14953 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
14954 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
14955 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
14956 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
14957 max_cmd[tid]);
14958 }
15466 14959
15467 /* 14960 /*
15468 * If the internal narrow cable is reversed all of the SCSI_CTRL 14961 * RAM BIST (RAM Built-In Self Test)
15469 * register signals will be set. Check for and return an error if 14962 *
15470 * this condition is found. 14963 * Address : I/O base + offset 0x38h register (byte).
15471 */ 14964 * Function: Bit 7-6(RW) : RAM mode
15472 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) 14965 * Normal Mode : 0x00
15473 { 14966 * Pre-test Mode : 0x40
15474 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE; 14967 * RAM Test Mode : 0x80
15475 return ADV_ERROR; 14968 * Bit 5 : unused
15476 } 14969 * Bit 4(RO) : Done bit
14970 * Bit 3-0(RO) : Status
14971 * Host Error : 0x08
14972 * Int_RAM Error : 0x04
14973 * RISC Error : 0x02
14974 * SCSI Error : 0x01
14975 * No Error : 0x00
14976 *
14977 * Note: RAM BIST code should be put right here, before loading the
14978 * microcode and after saving the RISC memory BIOS region.
14979 */
14980
14981 /*
14982 * LRAM Pre-test
14983 *
14984 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
14985 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
14986 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
14987 * to NORMAL_MODE, return an error too.
14988 */
14989 for (i = 0; i < 2; i++) {
14990 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
14991 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
14992 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
14993 if ((byte & RAM_TEST_DONE) == 0
14994 || (byte & 0x0F) != PRE_TEST_VALUE) {
14995 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
14996 return ADV_ERROR;
14997 }
14998
14999 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15000 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
15001 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
15002 != NORMAL_VALUE) {
15003 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15004 return ADV_ERROR;
15005 }
15006 }
15477 15007
15478 /* 15008 /*
15479 * All kind of combinations of devices attached to one of four connectors 15009 * LRAM Test - It takes about 1.5 ms to run through the test.
15480 * are acceptable except HVD device attached. For example, LVD device can 15010 *
15481 * be attached to SE connector while SE device attached to LVD connector. 15011 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
15482 * If LVD device attached to SE connector, it only runs up to Ultra speed. 15012 * If Done bit not set or Status not 0, save register byte, set the
15483 * 15013 * err_code, and return an error.
15484 * If an HVD device is attached to one of LVD connectors, return an error. 15014 */
15485 * However, there is no way to detect HVD device attached to SE connectors. 15015 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
15486 */ 15016 DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
15487 if (scsi_cfg1 & HVD) 15017
15488 { 15018 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
15489 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE; 15019 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
15490 return ADV_ERROR; 15020 /* Get here if Done bit not set or Status not 0. */
15491 } 15021 asc_dvc->bist_err_code = byte; /* for BIOS display message */
15022 asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
15023 return ADV_ERROR;
15024 }
15492 15025
15493 /* 15026 /* We need to reset back to normal mode after LRAM test passes. */
15494 * If either SE or LVD automatic termination control is enabled, then 15027 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15495 * set the termination value based on a table listed in a_condor.h. 15028
15496 * 15029 /*
15497 * If manual termination was specified with an EEPROM setting then 15030 * Load the Microcode
15498 * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready to 15031 *
15499 * be 'ored' into SCSI_CFG1. 15032 * Write the microcode image to RISC memory starting at address 0.
15500 */ 15033 *
15501 if ((asc_dvc->cfg->termination & TERM_SE) == 0) 15034 */
15502 { 15035 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15503 /* SE automatic termination control is enabled. */ 15036
15504 switch(scsi_cfg1 & C_DET_SE) 15037 /* Assume the following compressed format of the microcode buffer:
15505 { 15038 *
15506 /* TERM_SE_HI: on, TERM_SE_LO: on */ 15039 * 254 word (508 byte) table indexed by byte code followed
15507 case 0x1: case 0x2: case 0x3: 15040 * by the following byte codes:
15508 asc_dvc->cfg->termination |= TERM_SE; 15041 *
15509 break; 15042 * 1-Byte Code:
15510 15043 * 00: Emit word 0 in table.
15511 /* TERM_SE_HI: on, TERM_SE_LO: off */ 15044 * 01: Emit word 1 in table.
15512 case 0x0: 15045 * .
15513 asc_dvc->cfg->termination |= TERM_SE_HI; 15046 * FD: Emit word 253 in table.
15514 break; 15047 *
15515 } 15048 * Multi-Byte Code:
15516 } 15049 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
15050 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
15051 */
15052 word = 0;
15053 for (i = 253 * 2; i < _adv_asc38C0800_size; i++) {
15054 if (_adv_asc38C0800_buf[i] == 0xff) {
15055 for (j = 0; j < _adv_asc38C0800_buf[i + 1]; j++) {
15056 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15057 _adv_asc38C0800_buf
15058 [i +
15059 3] << 8) |
15060 _adv_asc38C0800_buf
15061 [i + 2]));
15062 word++;
15063 }
15064 i += 3;
15065 } else if (_adv_asc38C0800_buf[i] == 0xfe) {
15066 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15067 _adv_asc38C0800_buf
15068 [i +
15069 2] << 8) |
15070 _adv_asc38C0800_buf[i
15071 +
15072 1]));
15073 i += 2;
15074 word++;
15075 } else {
15076 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15077 _adv_asc38C0800_buf[(_adv_asc38C0800_buf[i] * 2) + 1] << 8) | _adv_asc38C0800_buf[_adv_asc38C0800_buf[i] * 2]));
15078 word++;
15079 }
15080 }
15517 15081
15518 if ((asc_dvc->cfg->termination & TERM_LVD) == 0) 15082 /*
15519 { 15083 * Set 'word' for later use to clear the rest of memory and save
15520 /* LVD automatic termination control is enabled. */ 15084 * the expanded mcode size.
15521 switch(scsi_cfg1 & C_DET_LVD) 15085 */
15522 { 15086 word *= 2;
15523 /* TERM_LVD_HI: on, TERM_LVD_LO: on */ 15087 adv_asc38C0800_expanded_size = word;
15524 case 0x4: case 0x8: case 0xC: 15088
15525 asc_dvc->cfg->termination |= TERM_LVD; 15089 /*
15526 break; 15090 * Clear the rest of ASC-38C0800 Internal RAM (16KB).
15527 15091 */
15528 /* TERM_LVD_HI: off, TERM_LVD_LO: off */ 15092 for (; word < ADV_38C0800_MEMSIZE; word += 2) {
15529 case 0x0: 15093 AdvWriteWordAutoIncLram(iop_base, 0);
15530 break; 15094 }
15531 }
15532 }
15533 15095
15534 /* 15096 /*
15535 * Clear any set TERM_SE and TERM_LVD bits. 15097 * Verify the microcode checksum.
15536 */ 15098 */
15537 scsi_cfg1 &= (~TERM_SE & ~TERM_LVD); 15099 sum = 0;
15100 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15538 15101
15539 /* 15102 for (word = 0; word < adv_asc38C0800_expanded_size; word += 2) {
15540 * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'. 15103 sum += AdvReadWordAutoIncLram(iop_base);
15541 */ 15104 }
15542 scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0); 15105 ASC_DBG2(1, "AdvInitAsc38C0800Driver: word %d, i %d\n", word, i);
15543 15106
15544 /* 15107 ASC_DBG2(1,
15545 * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE bits 15108 "AdvInitAsc38C0800Driver: sum 0x%lx, _adv_asc38C0800_chksum 0x%lx\n",
15546 * and set possibly modified termination control bits in the Microcode 15109 (ulong)sum, (ulong)_adv_asc38C0800_chksum);
15547 * SCSI_CFG1 Register Value.
15548 */
15549 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
15550 15110
15551 /* 15111 if (sum != _adv_asc38C0800_chksum) {
15552 * Set SCSI_CFG1 Microcode Default Value 15112 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
15553 * 15113 return ADV_ERROR;
15554 * Set possibly modified termination control and reset DIS_TERM_DRV 15114 }
15555 * bits in the Microcode SCSI_CFG1 Register Value.
15556 *
15557 * The microcode will set the SCSI_CFG1 register using this value
15558 * after it is started below.
15559 */
15560 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
15561 15115
15562 /* 15116 /*
15563 * Set MEM_CFG Microcode Default Value 15117 * Restore the RISC memory BIOS region.
15564 * 15118 */
15565 * The microcode will set the MEM_CFG register using this value 15119 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
15566 * after it is started below. 15120 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
15567 * 15121 bios_mem[i]);
15568 * MEM_CFG may be accessed as a word or byte, but only bits 0-7 15122 }
15569 * are defined.
15570 *
15571 * ASC-38C0800 has 16KB internal memory.
15572 */
15573 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
15574 BIOS_EN | RAM_SZ_16KB);
15575 15123
15576 /* 15124 /*
15577 * Set SEL_MASK Microcode Default Value 15125 * Calculate and write the microcode code checksum to the microcode
15578 * 15126 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
15579 * The microcode will set the SEL_MASK register using this value 15127 */
15580 * after it is started below. 15128 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
15581 */ 15129 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
15582 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK, 15130 code_sum = 0;
15583 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id)); 15131 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
15132 for (word = begin_addr; word < end_addr; word += 2) {
15133 code_sum += AdvReadWordAutoIncLram(iop_base);
15134 }
15135 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
15136
15137 /*
15138 * Read microcode version and date.
15139 */
15140 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
15141 asc_dvc->cfg->mcode_date);
15142 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
15143 asc_dvc->cfg->mcode_version);
15144
15145 /*
15146 * Set the chip type to indicate the ASC38C0800.
15147 */
15148 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C0800);
15149
15150 /*
15151 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
15152 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
15153 * cable detection and then we are able to read C_DET[3:0].
15154 *
15155 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
15156 * Microcode Default Value' section below.
15157 */
15158 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
15159 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
15160 scsi_cfg1 | DIS_TERM_DRV);
15161
15162 /*
15163 * If the PCI Configuration Command Register "Parity Error Response
15164 * Control" Bit was clear (0), then set the microcode variable
15165 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
15166 * to ignore DMA parity errors.
15167 */
15168 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
15169 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15170 word |= CONTROL_FLAG_IGNORE_PERR;
15171 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15172 }
15584 15173
15585 /* 15174 /*
15586 * Build the carrier freelist. 15175 * For ASC-38C0800, set FIFO_THRESH_80B [6:4] bits and START_CTL_TH [3:2]
15587 * 15176 * bits for the default FIFO threshold.
15588 * Driver must have already allocated memory and set 'carrier_buf'. 15177 *
15589 */ 15178 * Note: ASC-38C0800 FIFO threshold has been changed to 256 bytes.
15590 ASC_ASSERT(asc_dvc->carrier_buf != NULL); 15179 *
15591 15180 * For DMA Errata #4 set the BC_THRESH_ENB bit.
15592 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf); 15181 */
15593 asc_dvc->carr_freelist = NULL; 15182 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
15594 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) 15183 BC_THRESH_ENB | FIFO_THRESH_80B | START_CTL_TH |
15595 { 15184 READ_CMD_MRM);
15596 buf_size = ADV_CARRIER_BUFSIZE; 15185
15597 } else 15186 /*
15598 { 15187 * Microcode operating variables for WDTR, SDTR, and command tag
15599 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T); 15188 * queuing will be set in AdvInquiryHandling() based on what a
15600 } 15189 * device reports it is capable of in Inquiry byte 7.
15190 *
15191 * If SCSI Bus Resets have been disabled, then directly set
15192 * SDTR and WDTR from the EEPROM configuration. This will allow
15193 * the BIOS and warm boot to work without a SCSI bus hang on
15194 * the Inquiry caused by host and target mismatched DTR values.
15195 * Without the SCSI Bus Reset, before an Inquiry a device can't
15196 * be assumed to be in Asynchronous, Narrow mode.
15197 */
15198 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
15199 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
15200 asc_dvc->wdtr_able);
15201 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
15202 asc_dvc->sdtr_able);
15203 }
15601 15204
15602 do { 15205 /*
15603 /* 15206 * Set microcode operating variables for DISC and SDTR_SPEED1,
15604 * Get physical address for the carrier 'carrp'. 15207 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
15605 */ 15208 * configuration values.
15606 contig_len = sizeof(ADV_CARR_T); 15209 *
15607 carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp, 15210 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
15608 (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG)); 15211 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
15609 15212 * without determining here whether the device supports SDTR.
15610 buf_size -= sizeof(ADV_CARR_T); 15213 */
15611 15214 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
15612 /* 15215 asc_dvc->cfg->disc_enable);
15613 * If the current carrier is not physically contiguous, then 15216 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
15614 * maybe there was a page crossing. Try the next carrier aligned 15217 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
15615 * start address. 15218 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
15616 */ 15219 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
15617 if (contig_len < sizeof(ADV_CARR_T)) 15220
15618 { 15221 /*
15619 carrp++; 15222 * Set SCSI_CFG0 Microcode Default Value.
15620 continue; 15223 *
15621 } 15224 * The microcode will set the SCSI_CFG0 register using this value
15622 15225 * after it is started below.
15623 carrp->carr_pa = carr_paddr; 15226 */
15624 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp)); 15227 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
15625 15228 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
15626 /* 15229 asc_dvc->chip_scsi_id);
15627 * Insert the carrier at the beginning of the freelist. 15230
15628 */ 15231 /*
15629 carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist)); 15232 * Determine SCSI_CFG1 Microcode Default Value.
15630 asc_dvc->carr_freelist = carrp; 15233 *
15631 15234 * The microcode will set the SCSI_CFG1 register using this value
15632 carrp++; 15235 * after it is started below.
15633 } 15236 */
15634 while (buf_size > 0); 15237
15238 /* Read current SCSI_CFG1 Register value. */
15239 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
15240
15241 /*
15242 * If the internal narrow cable is reversed all of the SCSI_CTRL
15243 * register signals will be set. Check for and return an error if
15244 * this condition is found.
15245 */
15246 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
15247 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
15248 return ADV_ERROR;
15249 }
15635 15250
15636 /* 15251 /*
15637 * Set-up the Host->RISC Initiator Command Queue (ICQ). 15252 * All kind of combinations of devices attached to one of four connectors
15638 */ 15253 * are acceptable except HVD device attached. For example, LVD device can
15254 * be attached to SE connector while SE device attached to LVD connector.
15255 * If LVD device attached to SE connector, it only runs up to Ultra speed.
15256 *
15257 * If an HVD device is attached to one of LVD connectors, return an error.
15258 * However, there is no way to detect HVD device attached to SE connectors.
15259 */
15260 if (scsi_cfg1 & HVD) {
15261 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
15262 return ADV_ERROR;
15263 }
15639 15264
15640 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) 15265 /*
15641 { 15266 * If either SE or LVD automatic termination control is enabled, then
15642 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; 15267 * set the termination value based on a table listed in a_condor.h.
15643 return ADV_ERROR; 15268 *
15644 } 15269 * If manual termination was specified with an EEPROM setting then
15645 asc_dvc->carr_freelist = (ADV_CARR_T *) 15270 * 'termination' was set-up in AdvInitFrom38C0800EEPROM() and is ready to
15646 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa)); 15271 * be 'ored' into SCSI_CFG1.
15272 */
15273 if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
15274 /* SE automatic termination control is enabled. */
15275 switch (scsi_cfg1 & C_DET_SE) {
15276 /* TERM_SE_HI: on, TERM_SE_LO: on */
15277 case 0x1:
15278 case 0x2:
15279 case 0x3:
15280 asc_dvc->cfg->termination |= TERM_SE;
15281 break;
15282
15283 /* TERM_SE_HI: on, TERM_SE_LO: off */
15284 case 0x0:
15285 asc_dvc->cfg->termination |= TERM_SE_HI;
15286 break;
15287 }
15288 }
15647 15289
15648 /* 15290 if ((asc_dvc->cfg->termination & TERM_LVD) == 0) {
15649 * The first command issued will be placed in the stopper carrier. 15291 /* LVD automatic termination control is enabled. */
15650 */ 15292 switch (scsi_cfg1 & C_DET_LVD) {
15651 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER); 15293 /* TERM_LVD_HI: on, TERM_LVD_LO: on */
15294 case 0x4:
15295 case 0x8:
15296 case 0xC:
15297 asc_dvc->cfg->termination |= TERM_LVD;
15298 break;
15299
15300 /* TERM_LVD_HI: off, TERM_LVD_LO: off */
15301 case 0x0:
15302 break;
15303 }
15304 }
15652 15305
15653 /* 15306 /*
15654 * Set RISC ICQ physical address start value. 15307 * Clear any set TERM_SE and TERM_LVD bits.
15655 * carr_pa is LE, must be native before write 15308 */
15656 */ 15309 scsi_cfg1 &= (~TERM_SE & ~TERM_LVD);
15657 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa); 15310
15311 /*
15312 * Invert the TERM_SE and TERM_LVD bits and then set 'scsi_cfg1'.
15313 */
15314 scsi_cfg1 |= (~asc_dvc->cfg->termination & 0xF0);
15315
15316 /*
15317 * Clear BIG_ENDIAN, DIS_TERM_DRV, Terminator Polarity and HVD/LVD/SE bits
15318 * and set possibly modified termination control bits in the Microcode
15319 * SCSI_CFG1 Register Value.
15320 */
15321 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL & ~HVD_LVD_SE);
15322
15323 /*
15324 * Set SCSI_CFG1 Microcode Default Value
15325 *
15326 * Set possibly modified termination control and reset DIS_TERM_DRV
15327 * bits in the Microcode SCSI_CFG1 Register Value.
15328 *
15329 * The microcode will set the SCSI_CFG1 register using this value
15330 * after it is started below.
15331 */
15332 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
15333
15334 /*
15335 * Set MEM_CFG Microcode Default Value
15336 *
15337 * The microcode will set the MEM_CFG register using this value
15338 * after it is started below.
15339 *
15340 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
15341 * are defined.
15342 *
15343 * ASC-38C0800 has 16KB internal memory.
15344 */
15345 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
15346 BIOS_EN | RAM_SZ_16KB);
15347
15348 /*
15349 * Set SEL_MASK Microcode Default Value
15350 *
15351 * The microcode will set the SEL_MASK register using this value
15352 * after it is started below.
15353 */
15354 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
15355 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
15356
15357 /*
15358 * Build the carrier freelist.
15359 *
15360 * Driver must have already allocated memory and set 'carrier_buf'.
15361 */
15362 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
15363
15364 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
15365 asc_dvc->carr_freelist = NULL;
15366 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
15367 buf_size = ADV_CARRIER_BUFSIZE;
15368 } else {
15369 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
15370 }
15658 15371
15659 /* 15372 do {
15660 * Set-up the RISC->Host Initiator Response Queue (IRQ). 15373 /*
15661 */ 15374 * Get physical address for the carrier 'carrp'.
15662 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) 15375 */
15663 { 15376 contig_len = sizeof(ADV_CARR_T);
15664 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; 15377 carr_paddr =
15665 return ADV_ERROR; 15378 cpu_to_le32(DvcGetPhyAddr
15666 } 15379 (asc_dvc, NULL, (uchar *)carrp,
15667 asc_dvc->carr_freelist = (ADV_CARR_T *) 15380 (ADV_SDCNT *)&contig_len,
15668 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa)); 15381 ADV_IS_CARRIER_FLAG));
15669 15382
15670 /* 15383 buf_size -= sizeof(ADV_CARR_T);
15671 * The first command completed by the RISC will be placed in
15672 * the stopper.
15673 *
15674 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
15675 * completed the RISC will set the ASC_RQ_STOPPER bit.
15676 */
15677 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
15678 15384
15679 /* 15385 /*
15680 * Set RISC IRQ physical address start value. 15386 * If the current carrier is not physically contiguous, then
15681 * 15387 * maybe there was a page crossing. Try the next carrier aligned
15682 * carr_pa is LE, must be native before write * 15388 * start address.
15683 */ 15389 */
15684 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa); 15390 if (contig_len < sizeof(ADV_CARR_T)) {
15685 asc_dvc->carr_pending_cnt = 0; 15391 carrp++;
15392 continue;
15393 }
15394
15395 carrp->carr_pa = carr_paddr;
15396 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
15686 15397
15687 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES, 15398 /*
15688 (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR)); 15399 * Insert the carrier at the beginning of the freelist.
15400 */
15401 carrp->next_vpa =
15402 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
15403 asc_dvc->carr_freelist = carrp;
15689 15404
15690 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word); 15405 carrp++;
15691 AdvWriteWordRegister(iop_base, IOPW_PC, word); 15406 }
15407 while (buf_size > 0);
15692 15408
15693 /* finally, finally, gentlemen, start your engine */ 15409 /*
15694 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN); 15410 * Set-up the Host->RISC Initiator Command Queue (ICQ).
15411 */
15695 15412
15696 /* 15413 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
15697 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus 15414 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
15698 * Resets should be performed. The RISC has to be running 15415 return ADV_ERROR;
15699 * to issue a SCSI Bus Reset. 15416 }
15700 */ 15417 asc_dvc->carr_freelist = (ADV_CARR_T *)
15701 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) 15418 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
15702 { 15419
15703 /* 15420 /*
15704 * If the BIOS Signature is present in memory, restore the 15421 * The first command issued will be placed in the stopper carrier.
15705 * BIOS Handshake Configuration Table and do not perform 15422 */
15706 * a SCSI Bus Reset. 15423 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
15707 */ 15424
15708 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA) 15425 /*
15709 { 15426 * Set RISC ICQ physical address start value.
15710 /* 15427 * carr_pa is LE, must be native before write
15711 * Restore per TID negotiated values. 15428 */
15712 */ 15429 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
15713 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able); 15430
15714 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able); 15431 /*
15715 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able); 15432 * Set-up the RISC->Host Initiator Response Queue (IRQ).
15716 for (tid = 0; tid <= ADV_MAX_TID; tid++) 15433 */
15717 { 15434 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
15718 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid, 15435 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
15719 max_cmd[tid]); 15436 return ADV_ERROR;
15720 } 15437 }
15721 } else 15438 asc_dvc->carr_freelist = (ADV_CARR_T *)
15722 { 15439 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
15723 if (AdvResetSB(asc_dvc) != ADV_TRUE) 15440
15724 { 15441 /*
15725 warn_code = ASC_WARN_BUSRESET_ERROR; 15442 * The first command completed by the RISC will be placed in
15726 } 15443 * the stopper.
15727 } 15444 *
15728 } 15445 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
15446 * completed the RISC will set the ASC_RQ_STOPPER bit.
15447 */
15448 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
15449
15450 /*
15451 * Set RISC IRQ physical address start value.
15452 *
15453 * carr_pa is LE, must be native before write *
15454 */
15455 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
15456 asc_dvc->carr_pending_cnt = 0;
15457
15458 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
15459 (ADV_INTR_ENABLE_HOST_INTR |
15460 ADV_INTR_ENABLE_GLOBAL_INTR));
15461
15462 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
15463 AdvWriteWordRegister(iop_base, IOPW_PC, word);
15464
15465 /* finally, finally, gentlemen, start your engine */
15466 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
15467
15468 /*
15469 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
15470 * Resets should be performed. The RISC has to be running
15471 * to issue a SCSI Bus Reset.
15472 */
15473 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
15474 /*
15475 * If the BIOS Signature is present in memory, restore the
15476 * BIOS Handshake Configuration Table and do not perform
15477 * a SCSI Bus Reset.
15478 */
15479 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
15480 0x55AA) {
15481 /*
15482 * Restore per TID negotiated values.
15483 */
15484 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
15485 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
15486 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
15487 tagqng_able);
15488 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
15489 AdvWriteByteLram(iop_base,
15490 ASC_MC_NUMBER_OF_MAX_CMD + tid,
15491 max_cmd[tid]);
15492 }
15493 } else {
15494 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
15495 warn_code = ASC_WARN_BUSRESET_ERROR;
15496 }
15497 }
15498 }
15729 15499
15730 return warn_code; 15500 return warn_code;
15731} 15501}
15732 15502
15733/* 15503/*
@@ -15740,630 +15510,617 @@ AdvInitAsc38C0800Driver(ADV_DVC_VAR *asc_dvc)
15740 * 15510 *
15741 * Needed after initialization for error recovery. 15511 * Needed after initialization for error recovery.
15742 */ 15512 */
15743STATIC int 15513static int AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
15744AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
15745{ 15514{
15746 AdvPortAddr iop_base; 15515 AdvPortAddr iop_base;
15747 ushort warn_code; 15516 ushort warn_code;
15748 ADV_DCNT sum; 15517 ADV_DCNT sum;
15749 int begin_addr; 15518 int begin_addr;
15750 int end_addr; 15519 int end_addr;
15751 ushort code_sum; 15520 ushort code_sum;
15752 long word; 15521 long word;
15753 int j; 15522 int j;
15754 int adv_asc38C1600_expanded_size; 15523 int adv_asc38C1600_expanded_size;
15755 ADV_CARR_T *carrp; 15524 ADV_CARR_T *carrp;
15756 ADV_DCNT contig_len; 15525 ADV_DCNT contig_len;
15757 ADV_SDCNT buf_size; 15526 ADV_SDCNT buf_size;
15758 ADV_PADDR carr_paddr; 15527 ADV_PADDR carr_paddr;
15759 int i; 15528 int i;
15760 ushort scsi_cfg1; 15529 ushort scsi_cfg1;
15761 uchar byte; 15530 uchar byte;
15762 uchar tid; 15531 uchar tid;
15763 ushort bios_mem[ASC_MC_BIOSLEN/2]; /* BIOS RISC Memory 0x40-0x8F. */ 15532 ushort bios_mem[ASC_MC_BIOSLEN / 2]; /* BIOS RISC Memory 0x40-0x8F. */
15764 ushort wdtr_able, sdtr_able, ppr_able, tagqng_able; 15533 ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
15765 uchar max_cmd[ASC_MAX_TID + 1]; 15534 uchar max_cmd[ASC_MAX_TID + 1];
15766 15535
15767 /* If there is already an error, don't continue. */ 15536 /* If there is already an error, don't continue. */
15768 if (asc_dvc->err_code != 0) 15537 if (asc_dvc->err_code != 0) {
15769 { 15538 return ADV_ERROR;
15770 return ADV_ERROR; 15539 }
15771 }
15772
15773 /*
15774 * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
15775 */
15776 if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600)
15777 {
15778 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
15779 return ADV_ERROR;
15780 }
15781
15782 warn_code = 0;
15783 iop_base = asc_dvc->iop_base;
15784
15785 /*
15786 * Save the RISC memory BIOS region before writing the microcode.
15787 * The BIOS may already be loaded and using its RISC LRAM region
15788 * so its region must be saved and restored.
15789 *
15790 * Note: This code makes the assumption, which is currently true,
15791 * that a chip reset does not clear RISC LRAM.
15792 */
15793 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
15794 {
15795 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
15796 }
15797
15798 /*
15799 * Save current per TID negotiated values.
15800 */
15801 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
15802 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
15803 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
15804 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
15805 for (tid = 0; tid <= ASC_MAX_TID; tid++)
15806 {
15807 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
15808 max_cmd[tid]);
15809 }
15810
15811 /*
15812 * RAM BIST (Built-In Self Test)
15813 *
15814 * Address : I/O base + offset 0x38h register (byte).
15815 * Function: Bit 7-6(RW) : RAM mode
15816 * Normal Mode : 0x00
15817 * Pre-test Mode : 0x40
15818 * RAM Test Mode : 0x80
15819 * Bit 5 : unused
15820 * Bit 4(RO) : Done bit
15821 * Bit 3-0(RO) : Status
15822 * Host Error : 0x08
15823 * Int_RAM Error : 0x04
15824 * RISC Error : 0x02
15825 * SCSI Error : 0x01
15826 * No Error : 0x00
15827 *
15828 * Note: RAM BIST code should be put right here, before loading the
15829 * microcode and after saving the RISC memory BIOS region.
15830 */
15831
15832 /*
15833 * LRAM Pre-test
15834 *
15835 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
15836 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
15837 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
15838 * to NORMAL_MODE, return an error too.
15839 */
15840 for (i = 0; i < 2; i++)
15841 {
15842 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
15843 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
15844 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
15845 if ((byte & RAM_TEST_DONE) == 0 || (byte & 0x0F) != PRE_TEST_VALUE)
15846 {
15847 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15848 return ADV_ERROR;
15849 }
15850
15851 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15852 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
15853 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
15854 != NORMAL_VALUE)
15855 {
15856 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15857 return ADV_ERROR;
15858 }
15859 }
15860
15861 /*
15862 * LRAM Test - It takes about 1.5 ms to run through the test.
15863 *
15864 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
15865 * If Done bit not set or Status not 0, save register byte, set the
15866 * err_code, and return an error.
15867 */
15868 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
15869 DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
15870
15871 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
15872 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0)
15873 {
15874 /* Get here if Done bit not set or Status not 0. */
15875 asc_dvc->bist_err_code = byte; /* for BIOS display message */
15876 asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
15877 return ADV_ERROR;
15878 }
15879
15880 /* We need to reset back to normal mode after LRAM test passes. */
15881 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15882
15883 /*
15884 * Load the Microcode
15885 *
15886 * Write the microcode image to RISC memory starting at address 0.
15887 *
15888 */
15889 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15890
15891 /*
15892 * Assume the following compressed format of the microcode buffer:
15893 *
15894 * 254 word (508 byte) table indexed by byte code followed
15895 * by the following byte codes:
15896 *
15897 * 1-Byte Code:
15898 * 00: Emit word 0 in table.
15899 * 01: Emit word 1 in table.
15900 * .
15901 * FD: Emit word 253 in table.
15902 *
15903 * Multi-Byte Code:
15904 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
15905 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
15906 */
15907 word = 0;
15908 for (i = 253 * 2; i < _adv_asc38C1600_size; i++)
15909 {
15910 if (_adv_asc38C1600_buf[i] == 0xff)
15911 {
15912 for (j = 0; j < _adv_asc38C1600_buf[i + 1]; j++)
15913 {
15914 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15915 _adv_asc38C1600_buf[i + 3] << 8) |
15916 _adv_asc38C1600_buf[i + 2]));
15917 word++;
15918 }
15919 i += 3;
15920 } else if (_adv_asc38C1600_buf[i] == 0xfe)
15921 {
15922 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15923 _adv_asc38C1600_buf[i + 2] << 8) |
15924 _adv_asc38C1600_buf[i + 1]));
15925 i += 2;
15926 word++;
15927 } else
15928 {
15929 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15930 _adv_asc38C1600_buf[(_adv_asc38C1600_buf[i] * 2) + 1] << 8) |
15931 _adv_asc38C1600_buf[_adv_asc38C1600_buf[i] * 2]));
15932 word++;
15933 }
15934 }
15935
15936 /*
15937 * Set 'word' for later use to clear the rest of memory and save
15938 * the expanded mcode size.
15939 */
15940 word *= 2;
15941 adv_asc38C1600_expanded_size = word;
15942
15943 /*
15944 * Clear the rest of ASC-38C1600 Internal RAM (32KB).
15945 */
15946 for (; word < ADV_38C1600_MEMSIZE; word += 2)
15947 {
15948 AdvWriteWordAutoIncLram(iop_base, 0);
15949 }
15950
15951 /*
15952 * Verify the microcode checksum.
15953 */
15954 sum = 0;
15955 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
15956
15957 for (word = 0; word < adv_asc38C1600_expanded_size; word += 2)
15958 {
15959 sum += AdvReadWordAutoIncLram(iop_base);
15960 }
15961
15962 if (sum != _adv_asc38C1600_chksum)
15963 {
15964 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
15965 return ADV_ERROR;
15966 }
15967
15968 /*
15969 * Restore the RISC memory BIOS region.
15970 */
15971 for (i = 0; i < ASC_MC_BIOSLEN/2; i++)
15972 {
15973 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i), bios_mem[i]);
15974 }
15975
15976 /*
15977 * Calculate and write the microcode code checksum to the microcode
15978 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
15979 */
15980 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
15981 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
15982 code_sum = 0;
15983 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
15984 for (word = begin_addr; word < end_addr; word += 2)
15985 {
15986 code_sum += AdvReadWordAutoIncLram(iop_base);
15987 }
15988 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
15989
15990 /*
15991 * Read microcode version and date.
15992 */
15993 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE, asc_dvc->cfg->mcode_date);
15994 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM, asc_dvc->cfg->mcode_version);
15995
15996 /*
15997 * Set the chip type to indicate the ASC38C1600.
15998 */
15999 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
16000
16001 /*
16002 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
16003 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
16004 * cable detection and then we are able to read C_DET[3:0].
16005 *
16006 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
16007 * Microcode Default Value' section below.
16008 */
16009 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
16010 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1, scsi_cfg1 | DIS_TERM_DRV);
16011
16012 /*
16013 * If the PCI Configuration Command Register "Parity Error Response
16014 * Control" Bit was clear (0), then set the microcode variable
16015 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
16016 * to ignore DMA parity errors.
16017 */
16018 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR)
16019 {
16020 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
16021 word |= CONTROL_FLAG_IGNORE_PERR;
16022 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
16023 }
16024
16025 /*
16026 * If the BIOS control flag AIPP (Asynchronous Information
16027 * Phase Protection) disable bit is not set, then set the firmware
16028 * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
16029 * AIPP checking and encoding.
16030 */
16031 if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0)
16032 {
16033 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
16034 word |= CONTROL_FLAG_ENABLE_AIPP;
16035 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
16036 }
16037
16038 /*
16039 * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
16040 * and START_CTL_TH [3:2].
16041 */
16042 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
16043 FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
16044
16045 /*
16046 * Microcode operating variables for WDTR, SDTR, and command tag
16047 * queuing will be set in AdvInquiryHandling() based on what a
16048 * device reports it is capable of in Inquiry byte 7.
16049 *
16050 * If SCSI Bus Resets have been disabled, then directly set
16051 * SDTR and WDTR from the EEPROM configuration. This will allow
16052 * the BIOS and warm boot to work without a SCSI bus hang on
16053 * the Inquiry caused by host and target mismatched DTR values.
16054 * Without the SCSI Bus Reset, before an Inquiry a device can't
16055 * be assumed to be in Asynchronous, Narrow mode.
16056 */
16057 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0)
16058 {
16059 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, asc_dvc->wdtr_able);
16060 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, asc_dvc->sdtr_able);
16061 }
16062 15540
16063 /* 15541 /*
16064 * Set microcode operating variables for DISC and SDTR_SPEED1, 15542 * The caller must set 'chip_type' to ADV_CHIP_ASC38C1600.
16065 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM 15543 */
16066 * configuration values. 15544 if (asc_dvc->chip_type != ADV_CHIP_ASC38C1600) {
16067 * 15545 asc_dvc->err_code = ASC_IERR_BAD_CHIPTYPE;
16068 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2, 15546 return ADV_ERROR;
16069 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them 15547 }
16070 * without determining here whether the device supports SDTR.
16071 */
16072 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE, asc_dvc->cfg->disc_enable);
16073 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
16074 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
16075 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
16076 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
16077 15548
16078 /* 15549 warn_code = 0;
16079 * Set SCSI_CFG0 Microcode Default Value. 15550 iop_base = asc_dvc->iop_base;
16080 * 15551
16081 * The microcode will set the SCSI_CFG0 register using this value 15552 /*
16082 * after it is started below. 15553 * Save the RISC memory BIOS region before writing the microcode.
16083 */ 15554 * The BIOS may already be loaded and using its RISC LRAM region
16084 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0, 15555 * so its region must be saved and restored.
16085 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN | 15556 *
16086 asc_dvc->chip_scsi_id); 15557 * Note: This code makes the assumption, which is currently true,
15558 * that a chip reset does not clear RISC LRAM.
15559 */
15560 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
15561 AdvReadWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
15562 bios_mem[i]);
15563 }
16087 15564
16088 /* 15565 /*
16089 * Calculate SCSI_CFG1 Microcode Default Value. 15566 * Save current per TID negotiated values.
16090 * 15567 */
16091 * The microcode will set the SCSI_CFG1 register using this value 15568 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
16092 * after it is started below. 15569 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
16093 * 15570 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
16094 * Each ASC-38C1600 function has only two cable detect bits. 15571 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
16095 * The bus mode override bits are in IOPB_SOFT_OVER_WR. 15572 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
16096 */ 15573 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
16097 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1); 15574 max_cmd[tid]);
15575 }
16098 15576
16099 /* 15577 /*
16100 * If the cable is reversed all of the SCSI_CTRL register signals 15578 * RAM BIST (Built-In Self Test)
16101 * will be set. Check for and return an error if this condition is 15579 *
16102 * found. 15580 * Address : I/O base + offset 0x38h register (byte).
16103 */ 15581 * Function: Bit 7-6(RW) : RAM mode
16104 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) 15582 * Normal Mode : 0x00
16105 { 15583 * Pre-test Mode : 0x40
16106 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE; 15584 * RAM Test Mode : 0x80
16107 return ADV_ERROR; 15585 * Bit 5 : unused
16108 } 15586 * Bit 4(RO) : Done bit
15587 * Bit 3-0(RO) : Status
15588 * Host Error : 0x08
15589 * Int_RAM Error : 0x04
15590 * RISC Error : 0x02
15591 * SCSI Error : 0x01
15592 * No Error : 0x00
15593 *
15594 * Note: RAM BIST code should be put right here, before loading the
15595 * microcode and after saving the RISC memory BIOS region.
15596 */
15597
15598 /*
15599 * LRAM Pre-test
15600 *
15601 * Write PRE_TEST_MODE (0x40) to register and wait for 10 milliseconds.
15602 * If Done bit not set or low nibble not PRE_TEST_VALUE (0x05), return
15603 * an error. Reset to NORMAL_MODE (0x00) and do again. If cannot reset
15604 * to NORMAL_MODE, return an error too.
15605 */
15606 for (i = 0; i < 2; i++) {
15607 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, PRE_TEST_MODE);
15608 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
15609 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
15610 if ((byte & RAM_TEST_DONE) == 0
15611 || (byte & 0x0F) != PRE_TEST_VALUE) {
15612 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15613 return ADV_ERROR;
15614 }
15615
15616 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
15617 DvcSleepMilliSecond(10); /* Wait for 10ms before reading back. */
15618 if (AdvReadByteRegister(iop_base, IOPB_RAM_BIST)
15619 != NORMAL_VALUE) {
15620 asc_dvc->err_code |= ASC_IERR_BIST_PRE_TEST;
15621 return ADV_ERROR;
15622 }
15623 }
16109 15624
16110 /* 15625 /*
16111 * Each ASC-38C1600 function has two connectors. Only an HVD device 15626 * LRAM Test - It takes about 1.5 ms to run through the test.
16112 * can not be connected to either connector. An LVD device or SE device 15627 *
16113 * may be connected to either connecor. If an SE device is connected, 15628 * Write RAM_TEST_MODE (0x80) to register and wait for 10 milliseconds.
16114 * then at most Ultra speed (20 Mhz) can be used on both connectors. 15629 * If Done bit not set or Status not 0, save register byte, set the
16115 * 15630 * err_code, and return an error.
16116 * If an HVD device is attached, return an error. 15631 */
16117 */ 15632 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, RAM_TEST_MODE);
16118 if (scsi_cfg1 & HVD) 15633 DvcSleepMilliSecond(10); /* Wait for 10ms before checking status. */
16119 { 15634
16120 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE; 15635 byte = AdvReadByteRegister(iop_base, IOPB_RAM_BIST);
16121 return ADV_ERROR; 15636 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
16122 } 15637 /* Get here if Done bit not set or Status not 0. */
15638 asc_dvc->bist_err_code = byte; /* for BIOS display message */
15639 asc_dvc->err_code |= ASC_IERR_BIST_RAM_TEST;
15640 return ADV_ERROR;
15641 }
16123 15642
16124 /* 15643 /* We need to reset back to normal mode after LRAM test passes. */
16125 * Each function in the ASC-38C1600 uses only the SE cable detect and 15644 AdvWriteByteRegister(iop_base, IOPB_RAM_BIST, NORMAL_MODE);
16126 * termination because there are two connectors for each function. Each 15645
16127 * function may use either LVD or SE mode. Corresponding the SE automatic 15646 /*
16128 * termination control EEPROM bits are used for each function. Each 15647 * Load the Microcode
16129 * function has its own EEPROM. If SE automatic control is enabled for 15648 *
16130 * the function, then set the termination value based on a table listed 15649 * Write the microcode image to RISC memory starting at address 0.
16131 * in a_condor.h. 15650 *
16132 * 15651 */
16133 * If manual termination is specified in the EEPROM for the function, 15652 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
16134 * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is 15653
16135 * ready to be 'ored' into SCSI_CFG1. 15654 /*
16136 */ 15655 * Assume the following compressed format of the microcode buffer:
16137 if ((asc_dvc->cfg->termination & TERM_SE) == 0) 15656 *
16138 { 15657 * 254 word (508 byte) table indexed by byte code followed
16139 /* SE automatic termination control is enabled. */ 15658 * by the following byte codes:
16140 switch(scsi_cfg1 & C_DET_SE) 15659 *
16141 { 15660 * 1-Byte Code:
16142 /* TERM_SE_HI: on, TERM_SE_LO: on */ 15661 * 00: Emit word 0 in table.
16143 case 0x1: case 0x2: case 0x3: 15662 * 01: Emit word 1 in table.
16144 asc_dvc->cfg->termination |= TERM_SE; 15663 * .
16145 break; 15664 * FD: Emit word 253 in table.
16146 15665 *
16147 case 0x0: 15666 * Multi-Byte Code:
16148 if (ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) == 0) 15667 * FE WW WW: (3 byte code) Word to emit is the next word WW WW.
16149 { 15668 * FF BB WW WW: (4 byte code) Emit BB count times next word WW WW.
16150 /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */ 15669 */
16151 } 15670 word = 0;
16152 else 15671 for (i = 253 * 2; i < _adv_asc38C1600_size; i++) {
16153 { 15672 if (_adv_asc38C1600_buf[i] == 0xff) {
16154 /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */ 15673 for (j = 0; j < _adv_asc38C1600_buf[i + 1]; j++) {
16155 asc_dvc->cfg->termination |= TERM_SE_HI; 15674 AdvWriteWordAutoIncLram(iop_base, (((ushort)
16156 } 15675 _adv_asc38C1600_buf
16157 break; 15676 [i +
16158 } 15677 3] << 8) |
16159 } 15678 _adv_asc38C1600_buf
15679 [i + 2]));
15680 word++;
15681 }
15682 i += 3;
15683 } else if (_adv_asc38C1600_buf[i] == 0xfe) {
15684 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15685 _adv_asc38C1600_buf
15686 [i +
15687 2] << 8) |
15688 _adv_asc38C1600_buf[i
15689 +
15690 1]));
15691 i += 2;
15692 word++;
15693 } else {
15694 AdvWriteWordAutoIncLram(iop_base, (((ushort)
15695 _adv_asc38C1600_buf[(_adv_asc38C1600_buf[i] * 2) + 1] << 8) | _adv_asc38C1600_buf[_adv_asc38C1600_buf[i] * 2]));
15696 word++;
15697 }
15698 }
16160 15699
16161 /* 15700 /*
16162 * Clear any set TERM_SE bits. 15701 * Set 'word' for later use to clear the rest of memory and save
16163 */ 15702 * the expanded mcode size.
16164 scsi_cfg1 &= ~TERM_SE; 15703 */
15704 word *= 2;
15705 adv_asc38C1600_expanded_size = word;
15706
15707 /*
15708 * Clear the rest of ASC-38C1600 Internal RAM (32KB).
15709 */
15710 for (; word < ADV_38C1600_MEMSIZE; word += 2) {
15711 AdvWriteWordAutoIncLram(iop_base, 0);
15712 }
16165 15713
16166 /* 15714 /*
16167 * Invert the TERM_SE bits and then set 'scsi_cfg1'. 15715 * Verify the microcode checksum.
16168 */ 15716 */
16169 scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE); 15717 sum = 0;
15718 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, 0);
16170 15719
16171 /* 15720 for (word = 0; word < adv_asc38C1600_expanded_size; word += 2) {
16172 * Clear Big Endian and Terminator Polarity bits and set possibly 15721 sum += AdvReadWordAutoIncLram(iop_base);
16173 * modified termination control bits in the Microcode SCSI_CFG1 15722 }
16174 * Register Value.
16175 *
16176 * Big Endian bit is not used even on big endian machines.
16177 */
16178 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
16179 15723
16180 /* 15724 if (sum != _adv_asc38C1600_chksum) {
16181 * Set SCSI_CFG1 Microcode Default Value 15725 asc_dvc->err_code |= ASC_IERR_MCODE_CHKSUM;
16182 * 15726 return ADV_ERROR;
16183 * Set possibly modified termination control bits in the Microcode 15727 }
16184 * SCSI_CFG1 Register Value.
16185 *
16186 * The microcode will set the SCSI_CFG1 register using this value
16187 * after it is started below.
16188 */
16189 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
16190 15728
16191 /* 15729 /*
16192 * Set MEM_CFG Microcode Default Value 15730 * Restore the RISC memory BIOS region.
16193 * 15731 */
16194 * The microcode will set the MEM_CFG register using this value 15732 for (i = 0; i < ASC_MC_BIOSLEN / 2; i++) {
16195 * after it is started below. 15733 AdvWriteWordLram(iop_base, ASC_MC_BIOSMEM + (2 * i),
16196 * 15734 bios_mem[i]);
16197 * MEM_CFG may be accessed as a word or byte, but only bits 0-7 15735 }
16198 * are defined.
16199 *
16200 * ASC-38C1600 has 32KB internal memory.
16201 *
16202 * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
16203 * out a special 16K Adv Library and Microcode version. After the issue
16204 * resolved, we should turn back to the 32K support. Both a_condor.h and
16205 * mcode.sas files also need to be updated.
16206 *
16207 * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
16208 * BIOS_EN | RAM_SZ_32KB);
16209 */
16210 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG, BIOS_EN | RAM_SZ_16KB);
16211 15736
16212 /* 15737 /*
16213 * Set SEL_MASK Microcode Default Value 15738 * Calculate and write the microcode code checksum to the microcode
16214 * 15739 * code checksum location ASC_MC_CODE_CHK_SUM (0x2C).
16215 * The microcode will set the SEL_MASK register using this value 15740 */
16216 * after it is started below. 15741 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, begin_addr);
16217 */ 15742 AdvReadWordLram(iop_base, ASC_MC_CODE_END_ADDR, end_addr);
16218 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK, 15743 code_sum = 0;
16219 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id)); 15744 AdvWriteWordRegister(iop_base, IOPW_RAM_ADDR, begin_addr);
15745 for (word = begin_addr; word < end_addr; word += 2) {
15746 code_sum += AdvReadWordAutoIncLram(iop_base);
15747 }
15748 AdvWriteWordLram(iop_base, ASC_MC_CODE_CHK_SUM, code_sum);
15749
15750 /*
15751 * Read microcode version and date.
15752 */
15753 AdvReadWordLram(iop_base, ASC_MC_VERSION_DATE,
15754 asc_dvc->cfg->mcode_date);
15755 AdvReadWordLram(iop_base, ASC_MC_VERSION_NUM,
15756 asc_dvc->cfg->mcode_version);
15757
15758 /*
15759 * Set the chip type to indicate the ASC38C1600.
15760 */
15761 AdvWriteWordLram(iop_base, ASC_MC_CHIP_TYPE, ADV_CHIP_ASC38C1600);
15762
15763 /*
15764 * Write 1 to bit 14 'DIS_TERM_DRV' in the SCSI_CFG1 register.
15765 * When DIS_TERM_DRV set to 1, C_DET[3:0] will reflect current
15766 * cable detection and then we are able to read C_DET[3:0].
15767 *
15768 * Note: We will reset DIS_TERM_DRV to 0 in the 'Set SCSI_CFG1
15769 * Microcode Default Value' section below.
15770 */
15771 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
15772 AdvWriteWordRegister(iop_base, IOPW_SCSI_CFG1,
15773 scsi_cfg1 | DIS_TERM_DRV);
15774
15775 /*
15776 * If the PCI Configuration Command Register "Parity Error Response
15777 * Control" Bit was clear (0), then set the microcode variable
15778 * 'control_flag' CONTROL_FLAG_IGNORE_PERR flag to tell the microcode
15779 * to ignore DMA parity errors.
15780 */
15781 if (asc_dvc->cfg->control_flag & CONTROL_FLAG_IGNORE_PERR) {
15782 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15783 word |= CONTROL_FLAG_IGNORE_PERR;
15784 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
15785 }
16220 15786
16221 /* 15787 /*
16222 * Build the carrier freelist. 15788 * If the BIOS control flag AIPP (Asynchronous Information
16223 * 15789 * Phase Protection) disable bit is not set, then set the firmware
16224 * Driver must have already allocated memory and set 'carrier_buf'. 15790 * 'control_flag' CONTROL_FLAG_ENABLE_AIPP bit to enable
16225 */ 15791 * AIPP checking and encoding.
16226 15792 */
16227 ASC_ASSERT(asc_dvc->carrier_buf != NULL); 15793 if ((asc_dvc->bios_ctrl & BIOS_CTRL_AIPP_DIS) == 0) {
16228 15794 AdvReadWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
16229 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf); 15795 word |= CONTROL_FLAG_ENABLE_AIPP;
16230 asc_dvc->carr_freelist = NULL; 15796 AdvWriteWordLram(iop_base, ASC_MC_CONTROL_FLAG, word);
16231 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) 15797 }
16232 {
16233 buf_size = ADV_CARRIER_BUFSIZE;
16234 } else
16235 {
16236 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
16237 }
16238 15798
16239 do { 15799 /*
16240 /* 15800 * For ASC-38C1600 use DMA_CFG0 default values: FIFO_THRESH_80B [6:4],
16241 * Get physical address for the carrier 'carrp'. 15801 * and START_CTL_TH [3:2].
16242 */ 15802 */
16243 contig_len = sizeof(ADV_CARR_T); 15803 AdvWriteByteRegister(iop_base, IOPB_DMA_CFG0,
16244 carr_paddr = cpu_to_le32(DvcGetPhyAddr(asc_dvc, NULL, (uchar *) carrp, 15804 FIFO_THRESH_80B | START_CTL_TH | READ_CMD_MRM);
16245 (ADV_SDCNT *) &contig_len, ADV_IS_CARRIER_FLAG)); 15805
16246 15806 /*
16247 buf_size -= sizeof(ADV_CARR_T); 15807 * Microcode operating variables for WDTR, SDTR, and command tag
16248 15808 * queuing will be set in AdvInquiryHandling() based on what a
16249 /* 15809 * device reports it is capable of in Inquiry byte 7.
16250 * If the current carrier is not physically contiguous, then 15810 *
16251 * maybe there was a page crossing. Try the next carrier aligned 15811 * If SCSI Bus Resets have been disabled, then directly set
16252 * start address. 15812 * SDTR and WDTR from the EEPROM configuration. This will allow
16253 */ 15813 * the BIOS and warm boot to work without a SCSI bus hang on
16254 if (contig_len < sizeof(ADV_CARR_T)) 15814 * the Inquiry caused by host and target mismatched DTR values.
16255 { 15815 * Without the SCSI Bus Reset, before an Inquiry a device can't
16256 carrp++; 15816 * be assumed to be in Asynchronous, Narrow mode.
16257 continue; 15817 */
16258 } 15818 if ((asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) == 0) {
16259 15819 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
16260 carrp->carr_pa = carr_paddr; 15820 asc_dvc->wdtr_able);
16261 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp)); 15821 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
16262 15822 asc_dvc->sdtr_able);
16263 /* 15823 }
16264 * Insert the carrier at the beginning of the freelist.
16265 */
16266 carrp->next_vpa = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
16267 asc_dvc->carr_freelist = carrp;
16268
16269 carrp++;
16270 }
16271 while (buf_size > 0);
16272 15824
16273 /* 15825 /*
16274 * Set-up the Host->RISC Initiator Command Queue (ICQ). 15826 * Set microcode operating variables for DISC and SDTR_SPEED1,
16275 */ 15827 * SDTR_SPEED2, SDTR_SPEED3, and SDTR_SPEED4 based on the EEPROM
16276 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) 15828 * configuration values.
16277 { 15829 *
16278 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; 15830 * The SDTR per TID bitmask overrides the SDTR_SPEED1, SDTR_SPEED2,
16279 return ADV_ERROR; 15831 * SDTR_SPEED3, and SDTR_SPEED4 values so it is safe to set them
16280 } 15832 * without determining here whether the device supports SDTR.
16281 asc_dvc->carr_freelist = (ADV_CARR_T *) 15833 */
16282 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa)); 15834 AdvWriteWordLram(iop_base, ASC_MC_DISC_ENABLE,
15835 asc_dvc->cfg->disc_enable);
15836 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED1, asc_dvc->sdtr_speed1);
15837 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED2, asc_dvc->sdtr_speed2);
15838 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED3, asc_dvc->sdtr_speed3);
15839 AdvWriteWordLram(iop_base, ASC_MC_SDTR_SPEED4, asc_dvc->sdtr_speed4);
15840
15841 /*
15842 * Set SCSI_CFG0 Microcode Default Value.
15843 *
15844 * The microcode will set the SCSI_CFG0 register using this value
15845 * after it is started below.
15846 */
15847 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG0,
15848 PARITY_EN | QUEUE_128 | SEL_TMO_LONG | OUR_ID_EN |
15849 asc_dvc->chip_scsi_id);
15850
15851 /*
15852 * Calculate SCSI_CFG1 Microcode Default Value.
15853 *
15854 * The microcode will set the SCSI_CFG1 register using this value
15855 * after it is started below.
15856 *
15857 * Each ASC-38C1600 function has only two cable detect bits.
15858 * The bus mode override bits are in IOPB_SOFT_OVER_WR.
15859 */
15860 scsi_cfg1 = AdvReadWordRegister(iop_base, IOPW_SCSI_CFG1);
15861
15862 /*
15863 * If the cable is reversed all of the SCSI_CTRL register signals
15864 * will be set. Check for and return an error if this condition is
15865 * found.
15866 */
15867 if ((AdvReadWordRegister(iop_base, IOPW_SCSI_CTRL) & 0x3F07) == 0x3F07) {
15868 asc_dvc->err_code |= ASC_IERR_REVERSED_CABLE;
15869 return ADV_ERROR;
15870 }
16283 15871
16284 /* 15872 /*
16285 * The first command issued will be placed in the stopper carrier. 15873 * Each ASC-38C1600 function has two connectors. Only an HVD device
16286 */ 15874 * can not be connected to either connector. An LVD device or SE device
16287 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER); 15875 * may be connected to either connecor. If an SE device is connected,
15876 * then at most Ultra speed (20 Mhz) can be used on both connectors.
15877 *
15878 * If an HVD device is attached, return an error.
15879 */
15880 if (scsi_cfg1 & HVD) {
15881 asc_dvc->err_code |= ASC_IERR_HVD_DEVICE;
15882 return ADV_ERROR;
15883 }
16288 15884
16289 /* 15885 /*
16290 * Set RISC ICQ physical address start value. Initialize the 15886 * Each function in the ASC-38C1600 uses only the SE cable detect and
16291 * COMMA register to the same value otherwise the RISC will 15887 * termination because there are two connectors for each function. Each
16292 * prematurely detect a command is available. 15888 * function may use either LVD or SE mode. Corresponding the SE automatic
16293 */ 15889 * termination control EEPROM bits are used for each function. Each
16294 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa); 15890 * function has its own EEPROM. If SE automatic control is enabled for
16295 AdvWriteDWordRegister(iop_base, IOPDW_COMMA, 15891 * the function, then set the termination value based on a table listed
16296 le32_to_cpu(asc_dvc->icq_sp->carr_pa)); 15892 * in a_condor.h.
15893 *
15894 * If manual termination is specified in the EEPROM for the function,
15895 * then 'termination' was set-up in AscInitFrom38C1600EEPROM() and is
15896 * ready to be 'ored' into SCSI_CFG1.
15897 */
15898 if ((asc_dvc->cfg->termination & TERM_SE) == 0) {
15899 /* SE automatic termination control is enabled. */
15900 switch (scsi_cfg1 & C_DET_SE) {
15901 /* TERM_SE_HI: on, TERM_SE_LO: on */
15902 case 0x1:
15903 case 0x2:
15904 case 0x3:
15905 asc_dvc->cfg->termination |= TERM_SE;
15906 break;
15907
15908 case 0x0:
15909 if (ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) == 0) {
15910 /* Function 0 - TERM_SE_HI: off, TERM_SE_LO: off */
15911 } else {
15912 /* Function 1 - TERM_SE_HI: on, TERM_SE_LO: off */
15913 asc_dvc->cfg->termination |= TERM_SE_HI;
15914 }
15915 break;
15916 }
15917 }
16297 15918
16298 /* 15919 /*
16299 * Set-up the RISC->Host Initiator Response Queue (IRQ). 15920 * Clear any set TERM_SE bits.
16300 */ 15921 */
16301 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) 15922 scsi_cfg1 &= ~TERM_SE;
16302 { 15923
16303 asc_dvc->err_code |= ASC_IERR_NO_CARRIER; 15924 /*
16304 return ADV_ERROR; 15925 * Invert the TERM_SE bits and then set 'scsi_cfg1'.
16305 } 15926 */
16306 asc_dvc->carr_freelist = (ADV_CARR_T *) 15927 scsi_cfg1 |= (~asc_dvc->cfg->termination & TERM_SE);
16307 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa)); 15928
15929 /*
15930 * Clear Big Endian and Terminator Polarity bits and set possibly
15931 * modified termination control bits in the Microcode SCSI_CFG1
15932 * Register Value.
15933 *
15934 * Big Endian bit is not used even on big endian machines.
15935 */
15936 scsi_cfg1 &= (~BIG_ENDIAN & ~DIS_TERM_DRV & ~TERM_POL);
15937
15938 /*
15939 * Set SCSI_CFG1 Microcode Default Value
15940 *
15941 * Set possibly modified termination control bits in the Microcode
15942 * SCSI_CFG1 Register Value.
15943 *
15944 * The microcode will set the SCSI_CFG1 register using this value
15945 * after it is started below.
15946 */
15947 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SCSI_CFG1, scsi_cfg1);
15948
15949 /*
15950 * Set MEM_CFG Microcode Default Value
15951 *
15952 * The microcode will set the MEM_CFG register using this value
15953 * after it is started below.
15954 *
15955 * MEM_CFG may be accessed as a word or byte, but only bits 0-7
15956 * are defined.
15957 *
15958 * ASC-38C1600 has 32KB internal memory.
15959 *
15960 * XXX - Since ASC38C1600 Rev.3 has a Local RAM failure issue, we come
15961 * out a special 16K Adv Library and Microcode version. After the issue
15962 * resolved, we should turn back to the 32K support. Both a_condor.h and
15963 * mcode.sas files also need to be updated.
15964 *
15965 * AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
15966 * BIOS_EN | RAM_SZ_32KB);
15967 */
15968 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_MEM_CFG,
15969 BIOS_EN | RAM_SZ_16KB);
15970
15971 /*
15972 * Set SEL_MASK Microcode Default Value
15973 *
15974 * The microcode will set the SEL_MASK register using this value
15975 * after it is started below.
15976 */
15977 AdvWriteWordLram(iop_base, ASC_MC_DEFAULT_SEL_MASK,
15978 ADV_TID_TO_TIDMASK(asc_dvc->chip_scsi_id));
15979
15980 /*
15981 * Build the carrier freelist.
15982 *
15983 * Driver must have already allocated memory and set 'carrier_buf'.
15984 */
15985
15986 ASC_ASSERT(asc_dvc->carrier_buf != NULL);
15987
15988 carrp = (ADV_CARR_T *) ADV_16BALIGN(asc_dvc->carrier_buf);
15989 asc_dvc->carr_freelist = NULL;
15990 if (carrp == (ADV_CARR_T *) asc_dvc->carrier_buf) {
15991 buf_size = ADV_CARRIER_BUFSIZE;
15992 } else {
15993 buf_size = ADV_CARRIER_BUFSIZE - sizeof(ADV_CARR_T);
15994 }
16308 15995
16309 /* 15996 do {
16310 * The first command completed by the RISC will be placed in 15997 /*
16311 * the stopper. 15998 * Get physical address for the carrier 'carrp'.
16312 * 15999 */
16313 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is 16000 contig_len = sizeof(ADV_CARR_T);
16314 * completed the RISC will set the ASC_RQ_STOPPER bit. 16001 carr_paddr =
16315 */ 16002 cpu_to_le32(DvcGetPhyAddr
16316 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER); 16003 (asc_dvc, NULL, (uchar *)carrp,
16004 (ADV_SDCNT *)&contig_len,
16005 ADV_IS_CARRIER_FLAG));
16317 16006
16318 /* 16007 buf_size -= sizeof(ADV_CARR_T);
16319 * Set RISC IRQ physical address start value.
16320 */
16321 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
16322 asc_dvc->carr_pending_cnt = 0;
16323 16008
16324 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES, 16009 /*
16325 (ADV_INTR_ENABLE_HOST_INTR | ADV_INTR_ENABLE_GLOBAL_INTR)); 16010 * If the current carrier is not physically contiguous, then
16326 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word); 16011 * maybe there was a page crossing. Try the next carrier aligned
16327 AdvWriteWordRegister(iop_base, IOPW_PC, word); 16012 * start address.
16013 */
16014 if (contig_len < sizeof(ADV_CARR_T)) {
16015 carrp++;
16016 continue;
16017 }
16018
16019 carrp->carr_pa = carr_paddr;
16020 carrp->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(carrp));
16328 16021
16329 /* finally, finally, gentlemen, start your engine */ 16022 /*
16330 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN); 16023 * Insert the carrier at the beginning of the freelist.
16024 */
16025 carrp->next_vpa =
16026 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
16027 asc_dvc->carr_freelist = carrp;
16331 16028
16332 /* 16029 carrp++;
16333 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus 16030 }
16334 * Resets should be performed. The RISC has to be running 16031 while (buf_size > 0);
16335 * to issue a SCSI Bus Reset. 16032
16336 */ 16033 /*
16337 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) 16034 * Set-up the Host->RISC Initiator Command Queue (ICQ).
16338 { 16035 */
16339 /* 16036 if ((asc_dvc->icq_sp = asc_dvc->carr_freelist) == NULL) {
16340 * If the BIOS Signature is present in memory, restore the 16037 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
16341 * per TID microcode operating variables. 16038 return ADV_ERROR;
16342 */ 16039 }
16343 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM)/2] == 0x55AA) 16040 asc_dvc->carr_freelist = (ADV_CARR_T *)
16344 { 16041 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->icq_sp->next_vpa));
16345 /* 16042
16346 * Restore per TID negotiated values. 16043 /*
16347 */ 16044 * The first command issued will be placed in the stopper carrier.
16348 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able); 16045 */
16349 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able); 16046 asc_dvc->icq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
16350 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able); 16047
16351 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able); 16048 /*
16352 for (tid = 0; tid <= ASC_MAX_TID; tid++) 16049 * Set RISC ICQ physical address start value. Initialize the
16353 { 16050 * COMMA register to the same value otherwise the RISC will
16354 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid, 16051 * prematurely detect a command is available.
16355 max_cmd[tid]); 16052 */
16356 } 16053 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_ICQ, asc_dvc->icq_sp->carr_pa);
16357 } else 16054 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
16358 { 16055 le32_to_cpu(asc_dvc->icq_sp->carr_pa));
16359 if (AdvResetSB(asc_dvc) != ADV_TRUE) 16056
16360 { 16057 /*
16361 warn_code = ASC_WARN_BUSRESET_ERROR; 16058 * Set-up the RISC->Host Initiator Response Queue (IRQ).
16362 } 16059 */
16363 } 16060 if ((asc_dvc->irq_sp = asc_dvc->carr_freelist) == NULL) {
16364 } 16061 asc_dvc->err_code |= ASC_IERR_NO_CARRIER;
16062 return ADV_ERROR;
16063 }
16064 asc_dvc->carr_freelist = (ADV_CARR_T *)
16065 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->next_vpa));
16066
16067 /*
16068 * The first command completed by the RISC will be placed in
16069 * the stopper.
16070 *
16071 * Note: Set 'next_vpa' to ASC_CQ_STOPPER. When the request is
16072 * completed the RISC will set the ASC_RQ_STOPPER bit.
16073 */
16074 asc_dvc->irq_sp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
16075
16076 /*
16077 * Set RISC IRQ physical address start value.
16078 */
16079 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IRQ, asc_dvc->irq_sp->carr_pa);
16080 asc_dvc->carr_pending_cnt = 0;
16081
16082 AdvWriteByteRegister(iop_base, IOPB_INTR_ENABLES,
16083 (ADV_INTR_ENABLE_HOST_INTR |
16084 ADV_INTR_ENABLE_GLOBAL_INTR));
16085 AdvReadWordLram(iop_base, ASC_MC_CODE_BEGIN_ADDR, word);
16086 AdvWriteWordRegister(iop_base, IOPW_PC, word);
16087
16088 /* finally, finally, gentlemen, start your engine */
16089 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_RUN);
16090
16091 /*
16092 * Reset the SCSI Bus if the EEPROM indicates that SCSI Bus
16093 * Resets should be performed. The RISC has to be running
16094 * to issue a SCSI Bus Reset.
16095 */
16096 if (asc_dvc->bios_ctrl & BIOS_CTRL_RESET_SCSI_BUS) {
16097 /*
16098 * If the BIOS Signature is present in memory, restore the
16099 * per TID microcode operating variables.
16100 */
16101 if (bios_mem[(ASC_MC_BIOS_SIGNATURE - ASC_MC_BIOSMEM) / 2] ==
16102 0x55AA) {
16103 /*
16104 * Restore per TID negotiated values.
16105 */
16106 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
16107 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
16108 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
16109 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
16110 tagqng_able);
16111 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
16112 AdvWriteByteLram(iop_base,
16113 ASC_MC_NUMBER_OF_MAX_CMD + tid,
16114 max_cmd[tid]);
16115 }
16116 } else {
16117 if (AdvResetSB(asc_dvc) != ADV_TRUE) {
16118 warn_code = ASC_WARN_BUSRESET_ERROR;
16119 }
16120 }
16121 }
16365 16122
16366 return warn_code; 16123 return warn_code;
16367} 16124}
16368 16125
16369/* 16126/*
@@ -16378,164 +16135,146 @@ AdvInitAsc38C1600Driver(ADV_DVC_VAR *asc_dvc)
16378 * 16135 *
16379 * Note: Chip is stopped on entry. 16136 * Note: Chip is stopped on entry.
16380 */ 16137 */
16381STATIC int __init 16138static int __init AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
16382AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
16383{ 16139{
16384 AdvPortAddr iop_base; 16140 AdvPortAddr iop_base;
16385 ushort warn_code; 16141 ushort warn_code;
16386 ADVEEP_3550_CONFIG eep_config; 16142 ADVEEP_3550_CONFIG eep_config;
16387 int i; 16143 int i;
16388 16144
16389 iop_base = asc_dvc->iop_base; 16145 iop_base = asc_dvc->iop_base;
16390 16146
16391 warn_code = 0; 16147 warn_code = 0;
16392 16148
16393 /* 16149 /*
16394 * Read the board's EEPROM configuration. 16150 * Read the board's EEPROM configuration.
16395 * 16151 *
16396 * Set default values if a bad checksum is found. 16152 * Set default values if a bad checksum is found.
16397 */ 16153 */
16398 if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) 16154 if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.check_sum) {
16399 { 16155 warn_code |= ASC_WARN_EEPROM_CHKSUM;
16400 warn_code |= ASC_WARN_EEPROM_CHKSUM;
16401
16402 /*
16403 * Set EEPROM default values.
16404 */
16405 for (i = 0; i < sizeof(ADVEEP_3550_CONFIG); i++)
16406 {
16407 *((uchar *) &eep_config + i) =
16408 *((uchar *) &Default_3550_EEPROM_Config + i);
16409 }
16410
16411 /*
16412 * Assume the 6 byte board serial number that was read
16413 * from EEPROM is correct even if the EEPROM checksum
16414 * failed.
16415 */
16416 eep_config.serial_number_word3 =
16417 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
16418
16419 eep_config.serial_number_word2 =
16420 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
16421
16422 eep_config.serial_number_word1 =
16423 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
16424
16425 AdvSet3550EEPConfig(iop_base, &eep_config);
16426 }
16427 /*
16428 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
16429 * EEPROM configuration that was read.
16430 *
16431 * This is the mapping of EEPROM fields to Adv Library fields.
16432 */
16433 asc_dvc->wdtr_able = eep_config.wdtr_able;
16434 asc_dvc->sdtr_able = eep_config.sdtr_able;
16435 asc_dvc->ultra_able = eep_config.ultra_able;
16436 asc_dvc->tagqng_able = eep_config.tagqng_able;
16437 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
16438 asc_dvc->max_host_qng = eep_config.max_host_qng;
16439 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16440 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
16441 asc_dvc->start_motor = eep_config.start_motor;
16442 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
16443 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
16444 asc_dvc->no_scam = eep_config.scam_tolerant;
16445 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
16446 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
16447 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
16448 16156
16449 /* 16157 /*
16450 * Set the host maximum queuing (max. 253, min. 16) and the per device 16158 * Set EEPROM default values.
16451 * maximum queuing (max. 63, min. 4). 16159 */
16452 */ 16160 for (i = 0; i < sizeof(ADVEEP_3550_CONFIG); i++) {
16453 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) 16161 *((uchar *)&eep_config + i) =
16454 { 16162 *((uchar *)&Default_3550_EEPROM_Config + i);
16455 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG; 16163 }
16456 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG)
16457 {
16458 /* If the value is zero, assume it is uninitialized. */
16459 if (eep_config.max_host_qng == 0)
16460 {
16461 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16462 } else
16463 {
16464 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
16465 }
16466 }
16467 16164
16468 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) 16165 /*
16469 { 16166 * Assume the 6 byte board serial number that was read
16470 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG; 16167 * from EEPROM is correct even if the EEPROM checksum
16471 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) 16168 * failed.
16472 { 16169 */
16473 /* If the value is zero, assume it is uninitialized. */ 16170 eep_config.serial_number_word3 =
16474 if (eep_config.max_dvc_qng == 0) 16171 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
16475 {
16476 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
16477 } else
16478 {
16479 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
16480 }
16481 }
16482 16172
16483 /* 16173 eep_config.serial_number_word2 =
16484 * If 'max_dvc_qng' is greater than 'max_host_qng', then 16174 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
16485 * set 'max_dvc_qng' to 'max_host_qng'.
16486 */
16487 if (eep_config.max_dvc_qng > eep_config.max_host_qng)
16488 {
16489 eep_config.max_dvc_qng = eep_config.max_host_qng;
16490 }
16491 16175
16492 /* 16176 eep_config.serial_number_word1 =
16493 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng' 16177 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
16494 * values based on possibly adjusted EEPROM values. 16178
16495 */ 16179 AdvSet3550EEPConfig(iop_base, &eep_config);
16496 asc_dvc->max_host_qng = eep_config.max_host_qng; 16180 }
16497 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng; 16181 /*
16182 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
16183 * EEPROM configuration that was read.
16184 *
16185 * This is the mapping of EEPROM fields to Adv Library fields.
16186 */
16187 asc_dvc->wdtr_able = eep_config.wdtr_able;
16188 asc_dvc->sdtr_able = eep_config.sdtr_able;
16189 asc_dvc->ultra_able = eep_config.ultra_able;
16190 asc_dvc->tagqng_able = eep_config.tagqng_able;
16191 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
16192 asc_dvc->max_host_qng = eep_config.max_host_qng;
16193 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16194 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
16195 asc_dvc->start_motor = eep_config.start_motor;
16196 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
16197 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
16198 asc_dvc->no_scam = eep_config.scam_tolerant;
16199 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
16200 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
16201 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
16202
16203 /*
16204 * Set the host maximum queuing (max. 253, min. 16) and the per device
16205 * maximum queuing (max. 63, min. 4).
16206 */
16207 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
16208 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16209 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
16210 /* If the value is zero, assume it is uninitialized. */
16211 if (eep_config.max_host_qng == 0) {
16212 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16213 } else {
16214 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
16215 }
16216 }
16498 16217
16218 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
16219 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
16220 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
16221 /* If the value is zero, assume it is uninitialized. */
16222 if (eep_config.max_dvc_qng == 0) {
16223 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
16224 } else {
16225 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
16226 }
16227 }
16499 16228
16500 /* 16229 /*
16501 * If the EEPROM 'termination' field is set to automatic (0), then set 16230 * If 'max_dvc_qng' is greater than 'max_host_qng', then
16502 * the ADV_DVC_CFG 'termination' field to automatic also. 16231 * set 'max_dvc_qng' to 'max_host_qng'.
16503 * 16232 */
16504 * If the termination is specified with a non-zero 'termination' 16233 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
16505 * value check that a legal value is set and set the ADV_DVC_CFG 16234 eep_config.max_dvc_qng = eep_config.max_host_qng;
16506 * 'termination' field appropriately. 16235 }
16507 */
16508 if (eep_config.termination == 0)
16509 {
16510 asc_dvc->cfg->termination = 0; /* auto termination */
16511 } else
16512 {
16513 /* Enable manual control with low off / high off. */
16514 if (eep_config.termination == 1)
16515 {
16516 asc_dvc->cfg->termination = TERM_CTL_SEL;
16517
16518 /* Enable manual control with low off / high on. */
16519 } else if (eep_config.termination == 2)
16520 {
16521 asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
16522
16523 /* Enable manual control with low on / high on. */
16524 } else if (eep_config.termination == 3)
16525 {
16526 asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
16527 } else
16528 {
16529 /*
16530 * The EEPROM 'termination' field contains a bad value. Use
16531 * automatic termination instead.
16532 */
16533 asc_dvc->cfg->termination = 0;
16534 warn_code |= ASC_WARN_EEPROM_TERMINATION;
16535 }
16536 }
16537 16236
16538 return warn_code; 16237 /*
16238 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
16239 * values based on possibly adjusted EEPROM values.
16240 */
16241 asc_dvc->max_host_qng = eep_config.max_host_qng;
16242 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16243
16244 /*
16245 * If the EEPROM 'termination' field is set to automatic (0), then set
16246 * the ADV_DVC_CFG 'termination' field to automatic also.
16247 *
16248 * If the termination is specified with a non-zero 'termination'
16249 * value check that a legal value is set and set the ADV_DVC_CFG
16250 * 'termination' field appropriately.
16251 */
16252 if (eep_config.termination == 0) {
16253 asc_dvc->cfg->termination = 0; /* auto termination */
16254 } else {
16255 /* Enable manual control with low off / high off. */
16256 if (eep_config.termination == 1) {
16257 asc_dvc->cfg->termination = TERM_CTL_SEL;
16258
16259 /* Enable manual control with low off / high on. */
16260 } else if (eep_config.termination == 2) {
16261 asc_dvc->cfg->termination = TERM_CTL_SEL | TERM_CTL_H;
16262
16263 /* Enable manual control with low on / high on. */
16264 } else if (eep_config.termination == 3) {
16265 asc_dvc->cfg->termination =
16266 TERM_CTL_SEL | TERM_CTL_H | TERM_CTL_L;
16267 } else {
16268 /*
16269 * The EEPROM 'termination' field contains a bad value. Use
16270 * automatic termination instead.
16271 */
16272 asc_dvc->cfg->termination = 0;
16273 warn_code |= ASC_WARN_EEPROM_TERMINATION;
16274 }
16275 }
16276
16277 return warn_code;
16539} 16278}
16540 16279
16541/* 16280/*
@@ -16550,225 +16289,195 @@ AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
16550 * 16289 *
16551 * Note: Chip is stopped on entry. 16290 * Note: Chip is stopped on entry.
16552 */ 16291 */
16553STATIC int __init 16292static int __init AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
16554AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
16555{ 16293{
16556 AdvPortAddr iop_base; 16294 AdvPortAddr iop_base;
16557 ushort warn_code; 16295 ushort warn_code;
16558 ADVEEP_38C0800_CONFIG eep_config; 16296 ADVEEP_38C0800_CONFIG eep_config;
16559 int i; 16297 int i;
16560 uchar tid, termination; 16298 uchar tid, termination;
16561 ushort sdtr_speed = 0; 16299 ushort sdtr_speed = 0;
16300
16301 iop_base = asc_dvc->iop_base;
16302
16303 warn_code = 0;
16304
16305 /*
16306 * Read the board's EEPROM configuration.
16307 *
16308 * Set default values if a bad checksum is found.
16309 */
16310 if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
16311 eep_config.check_sum) {
16312 warn_code |= ASC_WARN_EEPROM_CHKSUM;
16562 16313
16563 iop_base = asc_dvc->iop_base; 16314 /*
16315 * Set EEPROM default values.
16316 */
16317 for (i = 0; i < sizeof(ADVEEP_38C0800_CONFIG); i++) {
16318 *((uchar *)&eep_config + i) =
16319 *((uchar *)&Default_38C0800_EEPROM_Config + i);
16320 }
16564 16321
16565 warn_code = 0; 16322 /*
16323 * Assume the 6 byte board serial number that was read
16324 * from EEPROM is correct even if the EEPROM checksum
16325 * failed.
16326 */
16327 eep_config.serial_number_word3 =
16328 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
16566 16329
16567 /* 16330 eep_config.serial_number_word2 =
16568 * Read the board's EEPROM configuration. 16331 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
16569 *
16570 * Set default values if a bad checksum is found.
16571 */
16572 if (AdvGet38C0800EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
16573 {
16574 warn_code |= ASC_WARN_EEPROM_CHKSUM;
16575
16576 /*
16577 * Set EEPROM default values.
16578 */
16579 for (i = 0; i < sizeof(ADVEEP_38C0800_CONFIG); i++)
16580 {
16581 *((uchar *) &eep_config + i) =
16582 *((uchar *) &Default_38C0800_EEPROM_Config + i);
16583 }
16584
16585 /*
16586 * Assume the 6 byte board serial number that was read
16587 * from EEPROM is correct even if the EEPROM checksum
16588 * failed.
16589 */
16590 eep_config.serial_number_word3 =
16591 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
16592
16593 eep_config.serial_number_word2 =
16594 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
16595
16596 eep_config.serial_number_word1 =
16597 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
16598
16599 AdvSet38C0800EEPConfig(iop_base, &eep_config);
16600 }
16601 /*
16602 * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
16603 * EEPROM configuration that was read.
16604 *
16605 * This is the mapping of EEPROM fields to Adv Library fields.
16606 */
16607 asc_dvc->wdtr_able = eep_config.wdtr_able;
16608 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
16609 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
16610 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
16611 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
16612 asc_dvc->tagqng_able = eep_config.tagqng_able;
16613 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
16614 asc_dvc->max_host_qng = eep_config.max_host_qng;
16615 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16616 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
16617 asc_dvc->start_motor = eep_config.start_motor;
16618 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
16619 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
16620 asc_dvc->no_scam = eep_config.scam_tolerant;
16621 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
16622 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
16623 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
16624 16332
16625 /* 16333 eep_config.serial_number_word1 =
16626 * For every Target ID if any of its 'sdtr_speed[1234]' bits 16334 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
16627 * are set, then set an 'sdtr_able' bit for it.
16628 */
16629 asc_dvc->sdtr_able = 0;
16630 for (tid = 0; tid <= ADV_MAX_TID; tid++)
16631 {
16632 if (tid == 0)
16633 {
16634 sdtr_speed = asc_dvc->sdtr_speed1;
16635 } else if (tid == 4)
16636 {
16637 sdtr_speed = asc_dvc->sdtr_speed2;
16638 } else if (tid == 8)
16639 {
16640 sdtr_speed = asc_dvc->sdtr_speed3;
16641 } else if (tid == 12)
16642 {
16643 sdtr_speed = asc_dvc->sdtr_speed4;
16644 }
16645 if (sdtr_speed & ADV_MAX_TID)
16646 {
16647 asc_dvc->sdtr_able |= (1 << tid);
16648 }
16649 sdtr_speed >>= 4;
16650 }
16651 16335
16652 /* 16336 AdvSet38C0800EEPConfig(iop_base, &eep_config);
16653 * Set the host maximum queuing (max. 253, min. 16) and the per device 16337 }
16654 * maximum queuing (max. 63, min. 4). 16338 /*
16655 */ 16339 * Set ADV_DVC_VAR and ADV_DVC_CFG variables from the
16656 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) 16340 * EEPROM configuration that was read.
16657 { 16341 *
16658 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG; 16342 * This is the mapping of EEPROM fields to Adv Library fields.
16659 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) 16343 */
16660 { 16344 asc_dvc->wdtr_able = eep_config.wdtr_able;
16661 /* If the value is zero, assume it is uninitialized. */ 16345 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
16662 if (eep_config.max_host_qng == 0) 16346 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
16663 { 16347 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
16664 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG; 16348 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
16665 } else 16349 asc_dvc->tagqng_able = eep_config.tagqng_able;
16666 { 16350 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
16667 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG; 16351 asc_dvc->max_host_qng = eep_config.max_host_qng;
16668 } 16352 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16669 } 16353 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ADV_MAX_TID);
16354 asc_dvc->start_motor = eep_config.start_motor;
16355 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
16356 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
16357 asc_dvc->no_scam = eep_config.scam_tolerant;
16358 asc_dvc->cfg->serial1 = eep_config.serial_number_word1;
16359 asc_dvc->cfg->serial2 = eep_config.serial_number_word2;
16360 asc_dvc->cfg->serial3 = eep_config.serial_number_word3;
16361
16362 /*
16363 * For every Target ID if any of its 'sdtr_speed[1234]' bits
16364 * are set, then set an 'sdtr_able' bit for it.
16365 */
16366 asc_dvc->sdtr_able = 0;
16367 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
16368 if (tid == 0) {
16369 sdtr_speed = asc_dvc->sdtr_speed1;
16370 } else if (tid == 4) {
16371 sdtr_speed = asc_dvc->sdtr_speed2;
16372 } else if (tid == 8) {
16373 sdtr_speed = asc_dvc->sdtr_speed3;
16374 } else if (tid == 12) {
16375 sdtr_speed = asc_dvc->sdtr_speed4;
16376 }
16377 if (sdtr_speed & ADV_MAX_TID) {
16378 asc_dvc->sdtr_able |= (1 << tid);
16379 }
16380 sdtr_speed >>= 4;
16381 }
16670 16382
16671 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) 16383 /*
16672 { 16384 * Set the host maximum queuing (max. 253, min. 16) and the per device
16673 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG; 16385 * maximum queuing (max. 63, min. 4).
16674 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) 16386 */
16675 { 16387 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
16676 /* If the value is zero, assume it is uninitialized. */ 16388 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16677 if (eep_config.max_dvc_qng == 0) 16389 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
16678 { 16390 /* If the value is zero, assume it is uninitialized. */
16679 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG; 16391 if (eep_config.max_host_qng == 0) {
16680 } else 16392 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16681 { 16393 } else {
16682 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG; 16394 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
16683 } 16395 }
16684 } 16396 }
16685 16397
16686 /* 16398 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
16687 * If 'max_dvc_qng' is greater than 'max_host_qng', then 16399 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
16688 * set 'max_dvc_qng' to 'max_host_qng'. 16400 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
16689 */ 16401 /* If the value is zero, assume it is uninitialized. */
16690 if (eep_config.max_dvc_qng > eep_config.max_host_qng) 16402 if (eep_config.max_dvc_qng == 0) {
16691 { 16403 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
16692 eep_config.max_dvc_qng = eep_config.max_host_qng; 16404 } else {
16693 } 16405 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
16406 }
16407 }
16694 16408
16695 /* 16409 /*
16696 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng' 16410 * If 'max_dvc_qng' is greater than 'max_host_qng', then
16697 * values based on possibly adjusted EEPROM values. 16411 * set 'max_dvc_qng' to 'max_host_qng'.
16698 */ 16412 */
16699 asc_dvc->max_host_qng = eep_config.max_host_qng; 16413 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
16700 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng; 16414 eep_config.max_dvc_qng = eep_config.max_host_qng;
16415 }
16701 16416
16702 /* 16417 /*
16703 * If the EEPROM 'termination' field is set to automatic (0), then set 16418 * Set ADV_DVC_VAR 'max_host_qng' and ADV_DVC_VAR 'max_dvc_qng'
16704 * the ADV_DVC_CFG 'termination' field to automatic also. 16419 * values based on possibly adjusted EEPROM values.
16705 * 16420 */
16706 * If the termination is specified with a non-zero 'termination' 16421 asc_dvc->max_host_qng = eep_config.max_host_qng;
16707 * value check that a legal value is set and set the ADV_DVC_CFG 16422 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16708 * 'termination' field appropriately. 16423
16709 */ 16424 /*
16710 if (eep_config.termination_se == 0) 16425 * If the EEPROM 'termination' field is set to automatic (0), then set
16711 { 16426 * the ADV_DVC_CFG 'termination' field to automatic also.
16712 termination = 0; /* auto termination for SE */ 16427 *
16713 } else 16428 * If the termination is specified with a non-zero 'termination'
16714 { 16429 * value check that a legal value is set and set the ADV_DVC_CFG
16715 /* Enable manual control with low off / high off. */ 16430 * 'termination' field appropriately.
16716 if (eep_config.termination_se == 1) 16431 */
16717 { 16432 if (eep_config.termination_se == 0) {
16718 termination = 0; 16433 termination = 0; /* auto termination for SE */
16719 16434 } else {
16720 /* Enable manual control with low off / high on. */ 16435 /* Enable manual control with low off / high off. */
16721 } else if (eep_config.termination_se == 2) 16436 if (eep_config.termination_se == 1) {
16722 { 16437 termination = 0;
16723 termination = TERM_SE_HI; 16438
16724 16439 /* Enable manual control with low off / high on. */
16725 /* Enable manual control with low on / high on. */ 16440 } else if (eep_config.termination_se == 2) {
16726 } else if (eep_config.termination_se == 3) 16441 termination = TERM_SE_HI;
16727 { 16442
16728 termination = TERM_SE; 16443 /* Enable manual control with low on / high on. */
16729 } else 16444 } else if (eep_config.termination_se == 3) {
16730 { 16445 termination = TERM_SE;
16731 /* 16446 } else {
16732 * The EEPROM 'termination_se' field contains a bad value. 16447 /*
16733 * Use automatic termination instead. 16448 * The EEPROM 'termination_se' field contains a bad value.
16734 */ 16449 * Use automatic termination instead.
16735 termination = 0; 16450 */
16736 warn_code |= ASC_WARN_EEPROM_TERMINATION; 16451 termination = 0;
16737 } 16452 warn_code |= ASC_WARN_EEPROM_TERMINATION;
16738 } 16453 }
16454 }
16739 16455
16740 if (eep_config.termination_lvd == 0) 16456 if (eep_config.termination_lvd == 0) {
16741 { 16457 asc_dvc->cfg->termination = termination; /* auto termination for LVD */
16742 asc_dvc->cfg->termination = termination; /* auto termination for LVD */ 16458 } else {
16743 } else 16459 /* Enable manual control with low off / high off. */
16744 { 16460 if (eep_config.termination_lvd == 1) {
16745 /* Enable manual control with low off / high off. */ 16461 asc_dvc->cfg->termination = termination;
16746 if (eep_config.termination_lvd == 1) 16462
16747 { 16463 /* Enable manual control with low off / high on. */
16748 asc_dvc->cfg->termination = termination; 16464 } else if (eep_config.termination_lvd == 2) {
16749 16465 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
16750 /* Enable manual control with low off / high on. */ 16466
16751 } else if (eep_config.termination_lvd == 2) 16467 /* Enable manual control with low on / high on. */
16752 { 16468 } else if (eep_config.termination_lvd == 3) {
16753 asc_dvc->cfg->termination = termination | TERM_LVD_HI; 16469 asc_dvc->cfg->termination = termination | TERM_LVD;
16754 16470 } else {
16755 /* Enable manual control with low on / high on. */ 16471 /*
16756 } else if (eep_config.termination_lvd == 3) 16472 * The EEPROM 'termination_lvd' field contains a bad value.
16757 { 16473 * Use automatic termination instead.
16758 asc_dvc->cfg->termination = 16474 */
16759 termination | TERM_LVD; 16475 asc_dvc->cfg->termination = termination;
16760 } else 16476 warn_code |= ASC_WARN_EEPROM_TERMINATION;
16761 { 16477 }
16762 /* 16478 }
16763 * The EEPROM 'termination_lvd' field contains a bad value.
16764 * Use automatic termination instead.
16765 */
16766 asc_dvc->cfg->termination = termination;
16767 warn_code |= ASC_WARN_EEPROM_TERMINATION;
16768 }
16769 }
16770 16479
16771 return warn_code; 16480 return warn_code;
16772} 16481}
16773 16482
16774/* 16483/*
@@ -16783,265 +16492,240 @@ AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
16783 * 16492 *
16784 * Note: Chip is stopped on entry. 16493 * Note: Chip is stopped on entry.
16785 */ 16494 */
16786STATIC int __init 16495static int __init AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
16787AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
16788{ 16496{
16789 AdvPortAddr iop_base; 16497 AdvPortAddr iop_base;
16790 ushort warn_code; 16498 ushort warn_code;
16791 ADVEEP_38C1600_CONFIG eep_config; 16499 ADVEEP_38C1600_CONFIG eep_config;
16792 int i; 16500 int i;
16793 uchar tid, termination; 16501 uchar tid, termination;
16794 ushort sdtr_speed = 0; 16502 ushort sdtr_speed = 0;
16503
16504 iop_base = asc_dvc->iop_base;
16505
16506 warn_code = 0;
16507
16508 /*
16509 * Read the board's EEPROM configuration.
16510 *
16511 * Set default values if a bad checksum is found.
16512 */
16513 if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
16514 eep_config.check_sum) {
16515 warn_code |= ASC_WARN_EEPROM_CHKSUM;
16795 16516
16796 iop_base = asc_dvc->iop_base; 16517 /*
16518 * Set EEPROM default values.
16519 */
16520 for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++) {
16521 if (i == 1
16522 && ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) !=
16523 0) {
16524 /*
16525 * Set Function 1 EEPROM Word 0 MSB
16526 *
16527 * Clear the BIOS_ENABLE (bit 14) and INTAB (bit 11)
16528 * EEPROM bits.
16529 *
16530 * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60 and
16531 * old Mac system booting problem. The Expansion ROM must
16532 * be disabled in Function 1 for these systems.
16533 *
16534 */
16535 *((uchar *)&eep_config + i) =
16536 ((*
16537 ((uchar *)&Default_38C1600_EEPROM_Config
16538 +
16539 i)) &
16540 (~
16541 (((ADV_EEPROM_BIOS_ENABLE |
16542 ADV_EEPROM_INTAB) >> 8) & 0xFF)));
16543
16544 /*
16545 * Set the INTAB (bit 11) if the GPIO 0 input indicates
16546 * the Function 1 interrupt line is wired to INTA.
16547 *
16548 * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
16549 * 1 - Function 1 interrupt line wired to INT A.
16550 * 0 - Function 1 interrupt line wired to INT B.
16551 *
16552 * Note: Adapter boards always have Function 0 wired to INTA.
16553 * Put all 5 GPIO bits in input mode and then read
16554 * their input values.
16555 */
16556 AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL,
16557 0);
16558 if (AdvReadByteRegister
16559 (iop_base, IOPB_GPIO_DATA) & 0x01) {
16560 /* Function 1 interrupt wired to INTA; Set EEPROM bit. */
16561 *((uchar *)&eep_config + i) |=
16562 ((ADV_EEPROM_INTAB >> 8) & 0xFF);
16563 }
16564 } else {
16565 *((uchar *)&eep_config + i) =
16566 *((uchar *)&Default_38C1600_EEPROM_Config
16567 + i);
16568 }
16569 }
16797 16570
16798 warn_code = 0; 16571 /*
16572 * Assume the 6 byte board serial number that was read
16573 * from EEPROM is correct even if the EEPROM checksum
16574 * failed.
16575 */
16576 eep_config.serial_number_word3 =
16577 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
16799 16578
16800 /* 16579 eep_config.serial_number_word2 =
16801 * Read the board's EEPROM configuration. 16580 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
16802 *
16803 * Set default values if a bad checksum is found.
16804 */
16805 if (AdvGet38C1600EEPConfig(iop_base, &eep_config) != eep_config.check_sum)
16806 {
16807 warn_code |= ASC_WARN_EEPROM_CHKSUM;
16808
16809 /*
16810 * Set EEPROM default values.
16811 */
16812 for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++)
16813 {
16814 if (i == 1 && ASC_PCI_ID2FUNC(asc_dvc->cfg->pci_slot_info) != 0)
16815 {
16816 /*
16817 * Set Function 1 EEPROM Word 0 MSB
16818 *
16819 * Clear the BIOS_ENABLE (bit 14) and INTAB (bit 11)
16820 * EEPROM bits.
16821 *
16822 * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60 and
16823 * old Mac system booting problem. The Expansion ROM must
16824 * be disabled in Function 1 for these systems.
16825 *
16826 */
16827 *((uchar *) &eep_config + i) =
16828 ((*((uchar *) &Default_38C1600_EEPROM_Config + i)) &
16829 (~(((ADV_EEPROM_BIOS_ENABLE | ADV_EEPROM_INTAB) >> 8) &
16830 0xFF)));
16831
16832 /*
16833 * Set the INTAB (bit 11) if the GPIO 0 input indicates
16834 * the Function 1 interrupt line is wired to INTA.
16835 *
16836 * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
16837 * 1 - Function 1 interrupt line wired to INT A.
16838 * 0 - Function 1 interrupt line wired to INT B.
16839 *
16840 * Note: Adapter boards always have Function 0 wired to INTA.
16841 * Put all 5 GPIO bits in input mode and then read
16842 * their input values.
16843 */
16844 AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
16845 if (AdvReadByteRegister(iop_base, IOPB_GPIO_DATA) & 0x01)
16846 {
16847 /* Function 1 interrupt wired to INTA; Set EEPROM bit. */
16848 *((uchar *) &eep_config + i) |=
16849 ((ADV_EEPROM_INTAB >> 8) & 0xFF);
16850 }
16851 }
16852 else
16853 {
16854 *((uchar *) &eep_config + i) =
16855 *((uchar *) &Default_38C1600_EEPROM_Config + i);
16856 }
16857 }
16858
16859 /*
16860 * Assume the 6 byte board serial number that was read
16861 * from EEPROM is correct even if the EEPROM checksum
16862 * failed.
16863 */
16864 eep_config.serial_number_word3 =
16865 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
16866
16867 eep_config.serial_number_word2 =
16868 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
16869
16870 eep_config.serial_number_word1 =
16871 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
16872
16873 AdvSet38C1600EEPConfig(iop_base, &eep_config);
16874 }
16875 16581
16876 /* 16582 eep_config.serial_number_word1 =
16877 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the 16583 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
16878 * EEPROM configuration that was read.
16879 *
16880 * This is the mapping of EEPROM fields to Adv Library fields.
16881 */
16882 asc_dvc->wdtr_able = eep_config.wdtr_able;
16883 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
16884 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
16885 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
16886 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
16887 asc_dvc->ppr_able = 0;
16888 asc_dvc->tagqng_able = eep_config.tagqng_able;
16889 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
16890 asc_dvc->max_host_qng = eep_config.max_host_qng;
16891 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16892 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
16893 asc_dvc->start_motor = eep_config.start_motor;
16894 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
16895 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
16896 asc_dvc->no_scam = eep_config.scam_tolerant;
16897 16584
16898 /* 16585 AdvSet38C1600EEPConfig(iop_base, &eep_config);
16899 * For every Target ID if any of its 'sdtr_speed[1234]' bits 16586 }
16900 * are set, then set an 'sdtr_able' bit for it.
16901 */
16902 asc_dvc->sdtr_able = 0;
16903 for (tid = 0; tid <= ASC_MAX_TID; tid++)
16904 {
16905 if (tid == 0)
16906 {
16907 sdtr_speed = asc_dvc->sdtr_speed1;
16908 } else if (tid == 4)
16909 {
16910 sdtr_speed = asc_dvc->sdtr_speed2;
16911 } else if (tid == 8)
16912 {
16913 sdtr_speed = asc_dvc->sdtr_speed3;
16914 } else if (tid == 12)
16915 {
16916 sdtr_speed = asc_dvc->sdtr_speed4;
16917 }
16918 if (sdtr_speed & ASC_MAX_TID)
16919 {
16920 asc_dvc->sdtr_able |= (1 << tid);
16921 }
16922 sdtr_speed >>= 4;
16923 }
16924 16587
16925 /* 16588 /*
16926 * Set the host maximum queuing (max. 253, min. 16) and the per device 16589 * Set ASC_DVC_VAR and ASC_DVC_CFG variables from the
16927 * maximum queuing (max. 63, min. 4). 16590 * EEPROM configuration that was read.
16928 */ 16591 *
16929 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) 16592 * This is the mapping of EEPROM fields to Adv Library fields.
16930 { 16593 */
16931 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG; 16594 asc_dvc->wdtr_able = eep_config.wdtr_able;
16932 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) 16595 asc_dvc->sdtr_speed1 = eep_config.sdtr_speed1;
16933 { 16596 asc_dvc->sdtr_speed2 = eep_config.sdtr_speed2;
16934 /* If the value is zero, assume it is uninitialized. */ 16597 asc_dvc->sdtr_speed3 = eep_config.sdtr_speed3;
16935 if (eep_config.max_host_qng == 0) 16598 asc_dvc->sdtr_speed4 = eep_config.sdtr_speed4;
16936 { 16599 asc_dvc->ppr_able = 0;
16937 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG; 16600 asc_dvc->tagqng_able = eep_config.tagqng_able;
16938 } else 16601 asc_dvc->cfg->disc_enable = eep_config.disc_enable;
16939 { 16602 asc_dvc->max_host_qng = eep_config.max_host_qng;
16940 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG; 16603 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16941 } 16604 asc_dvc->chip_scsi_id = (eep_config.adapter_scsi_id & ASC_MAX_TID);
16942 } 16605 asc_dvc->start_motor = eep_config.start_motor;
16606 asc_dvc->scsi_reset_wait = eep_config.scsi_reset_delay;
16607 asc_dvc->bios_ctrl = eep_config.bios_ctrl;
16608 asc_dvc->no_scam = eep_config.scam_tolerant;
16609
16610 /*
16611 * For every Target ID if any of its 'sdtr_speed[1234]' bits
16612 * are set, then set an 'sdtr_able' bit for it.
16613 */
16614 asc_dvc->sdtr_able = 0;
16615 for (tid = 0; tid <= ASC_MAX_TID; tid++) {
16616 if (tid == 0) {
16617 sdtr_speed = asc_dvc->sdtr_speed1;
16618 } else if (tid == 4) {
16619 sdtr_speed = asc_dvc->sdtr_speed2;
16620 } else if (tid == 8) {
16621 sdtr_speed = asc_dvc->sdtr_speed3;
16622 } else if (tid == 12) {
16623 sdtr_speed = asc_dvc->sdtr_speed4;
16624 }
16625 if (sdtr_speed & ASC_MAX_TID) {
16626 asc_dvc->sdtr_able |= (1 << tid);
16627 }
16628 sdtr_speed >>= 4;
16629 }
16943 16630
16944 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) 16631 /*
16945 { 16632 * Set the host maximum queuing (max. 253, min. 16) and the per device
16946 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG; 16633 * maximum queuing (max. 63, min. 4).
16947 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) 16634 */
16948 { 16635 if (eep_config.max_host_qng > ASC_DEF_MAX_HOST_QNG) {
16949 /* If the value is zero, assume it is uninitialized. */ 16636 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16950 if (eep_config.max_dvc_qng == 0) 16637 } else if (eep_config.max_host_qng < ASC_DEF_MIN_HOST_QNG) {
16951 { 16638 /* If the value is zero, assume it is uninitialized. */
16952 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG; 16639 if (eep_config.max_host_qng == 0) {
16953 } else 16640 eep_config.max_host_qng = ASC_DEF_MAX_HOST_QNG;
16954 { 16641 } else {
16955 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG; 16642 eep_config.max_host_qng = ASC_DEF_MIN_HOST_QNG;
16956 } 16643 }
16957 } 16644 }
16958 16645
16959 /* 16646 if (eep_config.max_dvc_qng > ASC_DEF_MAX_DVC_QNG) {
16960 * If 'max_dvc_qng' is greater than 'max_host_qng', then 16647 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
16961 * set 'max_dvc_qng' to 'max_host_qng'. 16648 } else if (eep_config.max_dvc_qng < ASC_DEF_MIN_DVC_QNG) {
16962 */ 16649 /* If the value is zero, assume it is uninitialized. */
16963 if (eep_config.max_dvc_qng > eep_config.max_host_qng) 16650 if (eep_config.max_dvc_qng == 0) {
16964 { 16651 eep_config.max_dvc_qng = ASC_DEF_MAX_DVC_QNG;
16965 eep_config.max_dvc_qng = eep_config.max_host_qng; 16652 } else {
16966 } 16653 eep_config.max_dvc_qng = ASC_DEF_MIN_DVC_QNG;
16654 }
16655 }
16967 16656
16968 /* 16657 /*
16969 * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng' 16658 * If 'max_dvc_qng' is greater than 'max_host_qng', then
16970 * values based on possibly adjusted EEPROM values. 16659 * set 'max_dvc_qng' to 'max_host_qng'.
16971 */ 16660 */
16972 asc_dvc->max_host_qng = eep_config.max_host_qng; 16661 if (eep_config.max_dvc_qng > eep_config.max_host_qng) {
16973 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng; 16662 eep_config.max_dvc_qng = eep_config.max_host_qng;
16663 }
16974 16664
16975 /* 16665 /*
16976 * If the EEPROM 'termination' field is set to automatic (0), then set 16666 * Set ASC_DVC_VAR 'max_host_qng' and ASC_DVC_VAR 'max_dvc_qng'
16977 * the ASC_DVC_CFG 'termination' field to automatic also. 16667 * values based on possibly adjusted EEPROM values.
16978 * 16668 */
16979 * If the termination is specified with a non-zero 'termination' 16669 asc_dvc->max_host_qng = eep_config.max_host_qng;
16980 * value check that a legal value is set and set the ASC_DVC_CFG 16670 asc_dvc->max_dvc_qng = eep_config.max_dvc_qng;
16981 * 'termination' field appropriately. 16671
16982 */ 16672 /*
16983 if (eep_config.termination_se == 0) 16673 * If the EEPROM 'termination' field is set to automatic (0), then set
16984 { 16674 * the ASC_DVC_CFG 'termination' field to automatic also.
16985 termination = 0; /* auto termination for SE */ 16675 *
16986 } else 16676 * If the termination is specified with a non-zero 'termination'
16987 { 16677 * value check that a legal value is set and set the ASC_DVC_CFG
16988 /* Enable manual control with low off / high off. */ 16678 * 'termination' field appropriately.
16989 if (eep_config.termination_se == 1) 16679 */
16990 { 16680 if (eep_config.termination_se == 0) {
16991 termination = 0; 16681 termination = 0; /* auto termination for SE */
16992 16682 } else {
16993 /* Enable manual control with low off / high on. */ 16683 /* Enable manual control with low off / high off. */
16994 } else if (eep_config.termination_se == 2) 16684 if (eep_config.termination_se == 1) {
16995 { 16685 termination = 0;
16996 termination = TERM_SE_HI; 16686
16997 16687 /* Enable manual control with low off / high on. */
16998 /* Enable manual control with low on / high on. */ 16688 } else if (eep_config.termination_se == 2) {
16999 } else if (eep_config.termination_se == 3) 16689 termination = TERM_SE_HI;
17000 { 16690
17001 termination = TERM_SE; 16691 /* Enable manual control with low on / high on. */
17002 } else 16692 } else if (eep_config.termination_se == 3) {
17003 { 16693 termination = TERM_SE;
17004 /* 16694 } else {
17005 * The EEPROM 'termination_se' field contains a bad value. 16695 /*
17006 * Use automatic termination instead. 16696 * The EEPROM 'termination_se' field contains a bad value.
17007 */ 16697 * Use automatic termination instead.
17008 termination = 0; 16698 */
17009 warn_code |= ASC_WARN_EEPROM_TERMINATION; 16699 termination = 0;
17010 } 16700 warn_code |= ASC_WARN_EEPROM_TERMINATION;
17011 } 16701 }
16702 }
17012 16703
17013 if (eep_config.termination_lvd == 0) 16704 if (eep_config.termination_lvd == 0) {
17014 { 16705 asc_dvc->cfg->termination = termination; /* auto termination for LVD */
17015 asc_dvc->cfg->termination = termination; /* auto termination for LVD */ 16706 } else {
17016 } else 16707 /* Enable manual control with low off / high off. */
17017 { 16708 if (eep_config.termination_lvd == 1) {
17018 /* Enable manual control with low off / high off. */ 16709 asc_dvc->cfg->termination = termination;
17019 if (eep_config.termination_lvd == 1) 16710
17020 { 16711 /* Enable manual control with low off / high on. */
17021 asc_dvc->cfg->termination = termination; 16712 } else if (eep_config.termination_lvd == 2) {
17022 16713 asc_dvc->cfg->termination = termination | TERM_LVD_HI;
17023 /* Enable manual control with low off / high on. */ 16714
17024 } else if (eep_config.termination_lvd == 2) 16715 /* Enable manual control with low on / high on. */
17025 { 16716 } else if (eep_config.termination_lvd == 3) {
17026 asc_dvc->cfg->termination = termination | TERM_LVD_HI; 16717 asc_dvc->cfg->termination = termination | TERM_LVD;
17027 16718 } else {
17028 /* Enable manual control with low on / high on. */ 16719 /*
17029 } else if (eep_config.termination_lvd == 3) 16720 * The EEPROM 'termination_lvd' field contains a bad value.
17030 { 16721 * Use automatic termination instead.
17031 asc_dvc->cfg->termination = 16722 */
17032 termination | TERM_LVD; 16723 asc_dvc->cfg->termination = termination;
17033 } else 16724 warn_code |= ASC_WARN_EEPROM_TERMINATION;
17034 { 16725 }
17035 /* 16726 }
17036 * The EEPROM 'termination_lvd' field contains a bad value.
17037 * Use automatic termination instead.
17038 */
17039 asc_dvc->cfg->termination = termination;
17040 warn_code |= ASC_WARN_EEPROM_TERMINATION;
17041 }
17042 }
17043 16727
17044 return warn_code; 16728 return warn_code;
17045} 16729}
17046 16730
17047/* 16731/*
@@ -17049,45 +16733,42 @@ AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
17049 * 16733 *
17050 * Return a checksum based on the EEPROM configuration read. 16734 * Return a checksum based on the EEPROM configuration read.
17051 */ 16735 */
17052STATIC ushort __init 16736static ushort __init
17053AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf) 16737AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
17054{ 16738{
17055 ushort wval, chksum; 16739 ushort wval, chksum;
17056 ushort *wbuf; 16740 ushort *wbuf;
17057 int eep_addr; 16741 int eep_addr;
17058 ushort *charfields; 16742 ushort *charfields;
17059 16743
17060 charfields = (ushort *) &ADVEEP_3550_Config_Field_IsChar; 16744 charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
17061 wbuf = (ushort *) cfg_buf; 16745 wbuf = (ushort *)cfg_buf;
17062 chksum = 0; 16746 chksum = 0;
17063 16747
17064 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN; 16748 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
17065 eep_addr < ADV_EEP_DVC_CFG_END; 16749 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
17066 eep_addr++, wbuf++) 16750 wval = AdvReadEEPWord(iop_base, eep_addr);
17067 { 16751 chksum += wval; /* Checksum is calculated from word values. */
17068 wval = AdvReadEEPWord(iop_base, eep_addr); 16752 if (*charfields++) {
17069 chksum += wval; /* Checksum is calculated from word values. */ 16753 *wbuf = le16_to_cpu(wval);
17070 if (*charfields++) { 16754 } else {
17071 *wbuf = le16_to_cpu(wval); 16755 *wbuf = wval;
17072 } else { 16756 }
17073 *wbuf = wval; 16757 }
17074 } 16758 /* Read checksum word. */
17075 } 16759 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17076 /* Read checksum word. */ 16760 wbuf++;
17077 *wbuf = AdvReadEEPWord(iop_base, eep_addr); 16761 charfields++;
17078 wbuf++; charfields++; 16762
17079 16763 /* Read rest of EEPROM not covered by the checksum. */
17080 /* Read rest of EEPROM not covered by the checksum. */ 16764 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
17081 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN; 16765 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
17082 eep_addr < ADV_EEP_MAX_WORD_ADDR; 16766 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17083 eep_addr++, wbuf++) 16767 if (*charfields++) {
17084 { 16768 *wbuf = le16_to_cpu(*wbuf);
17085 *wbuf = AdvReadEEPWord(iop_base, eep_addr); 16769 }
17086 if (*charfields++) { 16770 }
17087 *wbuf = le16_to_cpu(*wbuf); 16771 return chksum;
17088 }
17089 }
17090 return chksum;
17091} 16772}
17092 16773
17093/* 16774/*
@@ -17095,46 +16776,42 @@ AdvGet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
17095 * 16776 *
17096 * Return a checksum based on the EEPROM configuration read. 16777 * Return a checksum based on the EEPROM configuration read.
17097 */ 16778 */
17098STATIC ushort __init 16779static ushort __init
17099AdvGet38C0800EEPConfig(AdvPortAddr iop_base, 16780AdvGet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
17100 ADVEEP_38C0800_CONFIG *cfg_buf)
17101{ 16781{
17102 ushort wval, chksum; 16782 ushort wval, chksum;
17103 ushort *wbuf; 16783 ushort *wbuf;
17104 int eep_addr; 16784 int eep_addr;
17105 ushort *charfields; 16785 ushort *charfields;
17106 16786
17107 charfields = (ushort *) &ADVEEP_38C0800_Config_Field_IsChar; 16787 charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
17108 wbuf = (ushort *) cfg_buf; 16788 wbuf = (ushort *)cfg_buf;
17109 chksum = 0; 16789 chksum = 0;
17110 16790
17111 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN; 16791 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
17112 eep_addr < ADV_EEP_DVC_CFG_END; 16792 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
17113 eep_addr++, wbuf++) 16793 wval = AdvReadEEPWord(iop_base, eep_addr);
17114 { 16794 chksum += wval; /* Checksum is calculated from word values. */
17115 wval = AdvReadEEPWord(iop_base, eep_addr); 16795 if (*charfields++) {
17116 chksum += wval; /* Checksum is calculated from word values. */ 16796 *wbuf = le16_to_cpu(wval);
17117 if (*charfields++) { 16797 } else {
17118 *wbuf = le16_to_cpu(wval); 16798 *wbuf = wval;
17119 } else { 16799 }
17120 *wbuf = wval; 16800 }
17121 } 16801 /* Read checksum word. */
17122 } 16802 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17123 /* Read checksum word. */ 16803 wbuf++;
17124 *wbuf = AdvReadEEPWord(iop_base, eep_addr); 16804 charfields++;
17125 wbuf++; charfields++; 16805
17126 16806 /* Read rest of EEPROM not covered by the checksum. */
17127 /* Read rest of EEPROM not covered by the checksum. */ 16807 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
17128 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN; 16808 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
17129 eep_addr < ADV_EEP_MAX_WORD_ADDR; 16809 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17130 eep_addr++, wbuf++) 16810 if (*charfields++) {
17131 { 16811 *wbuf = le16_to_cpu(*wbuf);
17132 *wbuf = AdvReadEEPWord(iop_base, eep_addr); 16812 }
17133 if (*charfields++) { 16813 }
17134 *wbuf = le16_to_cpu(*wbuf); 16814 return chksum;
17135 }
17136 }
17137 return chksum;
17138} 16815}
17139 16816
17140/* 16817/*
@@ -17142,81 +16819,74 @@ AdvGet38C0800EEPConfig(AdvPortAddr iop_base,
17142 * 16819 *
17143 * Return a checksum based on the EEPROM configuration read. 16820 * Return a checksum based on the EEPROM configuration read.
17144 */ 16821 */
17145STATIC ushort __init 16822static ushort __init
17146AdvGet38C1600EEPConfig(AdvPortAddr iop_base, 16823AdvGet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
17147 ADVEEP_38C1600_CONFIG *cfg_buf)
17148{ 16824{
17149 ushort wval, chksum; 16825 ushort wval, chksum;
17150 ushort *wbuf; 16826 ushort *wbuf;
17151 int eep_addr; 16827 int eep_addr;
17152 ushort *charfields; 16828 ushort *charfields;
17153 16829
17154 charfields = (ushort*) &ADVEEP_38C1600_Config_Field_IsChar; 16830 charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
17155 wbuf = (ushort *) cfg_buf; 16831 wbuf = (ushort *)cfg_buf;
17156 chksum = 0; 16832 chksum = 0;
17157 16833
17158 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN; 16834 for (eep_addr = ADV_EEP_DVC_CFG_BEGIN;
17159 eep_addr < ADV_EEP_DVC_CFG_END; 16835 eep_addr < ADV_EEP_DVC_CFG_END; eep_addr++, wbuf++) {
17160 eep_addr++, wbuf++) 16836 wval = AdvReadEEPWord(iop_base, eep_addr);
17161 { 16837 chksum += wval; /* Checksum is calculated from word values. */
17162 wval = AdvReadEEPWord(iop_base, eep_addr); 16838 if (*charfields++) {
17163 chksum += wval; /* Checksum is calculated from word values. */ 16839 *wbuf = le16_to_cpu(wval);
17164 if (*charfields++) { 16840 } else {
17165 *wbuf = le16_to_cpu(wval); 16841 *wbuf = wval;
17166 } else { 16842 }
17167 *wbuf = wval; 16843 }
17168 } 16844 /* Read checksum word. */
17169 } 16845 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17170 /* Read checksum word. */ 16846 wbuf++;
17171 *wbuf = AdvReadEEPWord(iop_base, eep_addr); 16847 charfields++;
17172 wbuf++; charfields++; 16848
17173 16849 /* Read rest of EEPROM not covered by the checksum. */
17174 /* Read rest of EEPROM not covered by the checksum. */ 16850 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN;
17175 for (eep_addr = ADV_EEP_DVC_CTL_BEGIN; 16851 eep_addr < ADV_EEP_MAX_WORD_ADDR; eep_addr++, wbuf++) {
17176 eep_addr < ADV_EEP_MAX_WORD_ADDR; 16852 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
17177 eep_addr++, wbuf++) 16853 if (*charfields++) {
17178 { 16854 *wbuf = le16_to_cpu(*wbuf);
17179 *wbuf = AdvReadEEPWord(iop_base, eep_addr); 16855 }
17180 if (*charfields++) { 16856 }
17181 *wbuf = le16_to_cpu(*wbuf); 16857 return chksum;
17182 }
17183 }
17184 return chksum;
17185} 16858}
17186 16859
17187/* 16860/*
17188 * Read the EEPROM from specified location 16861 * Read the EEPROM from specified location
17189 */ 16862 */
17190STATIC ushort __init 16863static ushort __init AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
17191AdvReadEEPWord(AdvPortAddr iop_base, int eep_word_addr)
17192{ 16864{
17193 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, 16865 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
17194 ASC_EEP_CMD_READ | eep_word_addr); 16866 ASC_EEP_CMD_READ | eep_word_addr);
17195 AdvWaitEEPCmd(iop_base); 16867 AdvWaitEEPCmd(iop_base);
17196 return AdvReadWordRegister(iop_base, IOPW_EE_DATA); 16868 return AdvReadWordRegister(iop_base, IOPW_EE_DATA);
17197} 16869}
17198 16870
17199/* 16871/*
17200 * Wait for EEPROM command to complete 16872 * Wait for EEPROM command to complete
17201 */ 16873 */
17202STATIC void __init 16874static void __init AdvWaitEEPCmd(AdvPortAddr iop_base)
17203AdvWaitEEPCmd(AdvPortAddr iop_base)
17204{ 16875{
17205 int eep_delay_ms; 16876 int eep_delay_ms;
17206 16877
17207 for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) 16878 for (eep_delay_ms = 0; eep_delay_ms < ADV_EEP_DELAY_MS; eep_delay_ms++) {
17208 { 16879 if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) &
17209 if (AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) 16880 ASC_EEP_CMD_DONE) {
17210 { 16881 break;
17211 break; 16882 }
17212 } 16883 DvcSleepMilliSecond(1);
17213 DvcSleepMilliSecond(1); 16884 }
17214 } 16885 if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) ==
17215 if ((AdvReadWordRegister(iop_base, IOPW_EE_CMD) & ASC_EEP_CMD_DONE) == 0) 16886 0) {
17216 { 16887 ASC_ASSERT(0);
17217 ASC_ASSERT(0); 16888 }
17218 } 16889 return;
17219 return;
17220} 16890}
17221 16891
17222/* 16892/*
@@ -17225,201 +16895,202 @@ AdvWaitEEPCmd(AdvPortAddr iop_base)
17225void __init 16895void __init
17226AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf) 16896AdvSet3550EEPConfig(AdvPortAddr iop_base, ADVEEP_3550_CONFIG *cfg_buf)
17227{ 16897{
17228 ushort *wbuf; 16898 ushort *wbuf;
17229 ushort addr, chksum; 16899 ushort addr, chksum;
17230 ushort *charfields; 16900 ushort *charfields;
17231 16901
17232 wbuf = (ushort *) cfg_buf; 16902 wbuf = (ushort *)cfg_buf;
17233 charfields = (ushort *) &ADVEEP_3550_Config_Field_IsChar; 16903 charfields = (ushort *)&ADVEEP_3550_Config_Field_IsChar;
17234 chksum = 0; 16904 chksum = 0;
17235 16905
17236 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE); 16906 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
17237 AdvWaitEEPCmd(iop_base); 16907 AdvWaitEEPCmd(iop_base);
17238 16908
17239 /* 16909 /*
17240 * Write EEPROM from word 0 to word 20. 16910 * Write EEPROM from word 0 to word 20.
17241 */ 16911 */
17242 for (addr = ADV_EEP_DVC_CFG_BEGIN; 16912 for (addr = ADV_EEP_DVC_CFG_BEGIN;
17243 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) 16913 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
17244 { 16914 ushort word;
17245 ushort word; 16915
17246 16916 if (*charfields++) {
17247 if (*charfields++) { 16917 word = cpu_to_le16(*wbuf);
17248 word = cpu_to_le16(*wbuf); 16918 } else {
17249 } else { 16919 word = *wbuf;
17250 word = *wbuf; 16920 }
17251 } 16921 chksum += *wbuf; /* Checksum is calculated from word values. */
17252 chksum += *wbuf; /* Checksum is calculated from word values. */ 16922 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17253 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word); 16923 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
17254 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr); 16924 ASC_EEP_CMD_WRITE | addr);
17255 AdvWaitEEPCmd(iop_base); 16925 AdvWaitEEPCmd(iop_base);
17256 DvcSleepMilliSecond(ADV_EEP_DELAY_MS); 16926 DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
17257 } 16927 }
17258
17259 /*
17260 * Write EEPROM checksum at word 21.
17261 */
17262 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
17263 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17264 AdvWaitEEPCmd(iop_base);
17265 wbuf++; charfields++;
17266 16928
17267 /* 16929 /*
17268 * Write EEPROM OEM name at words 22 to 29. 16930 * Write EEPROM checksum at word 21.
17269 */ 16931 */
17270 for (addr = ADV_EEP_DVC_CTL_BEGIN; 16932 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
17271 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) 16933 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17272 { 16934 AdvWaitEEPCmd(iop_base);
17273 ushort word; 16935 wbuf++;
17274 16936 charfields++;
17275 if (*charfields++) { 16937
17276 word = cpu_to_le16(*wbuf); 16938 /*
17277 } else { 16939 * Write EEPROM OEM name at words 22 to 29.
17278 word = *wbuf; 16940 */
17279 } 16941 for (addr = ADV_EEP_DVC_CTL_BEGIN;
17280 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word); 16942 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
17281 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr); 16943 ushort word;
17282 AdvWaitEEPCmd(iop_base); 16944
17283 } 16945 if (*charfields++) {
17284 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE); 16946 word = cpu_to_le16(*wbuf);
17285 AdvWaitEEPCmd(iop_base); 16947 } else {
17286 return; 16948 word = *wbuf;
16949 }
16950 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
16951 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
16952 ASC_EEP_CMD_WRITE | addr);
16953 AdvWaitEEPCmd(iop_base);
16954 }
16955 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
16956 AdvWaitEEPCmd(iop_base);
16957 return;
17287} 16958}
17288 16959
17289/* 16960/*
17290 * Write the EEPROM from 'cfg_buf'. 16961 * Write the EEPROM from 'cfg_buf'.
17291 */ 16962 */
17292void __init 16963void __init
17293AdvSet38C0800EEPConfig(AdvPortAddr iop_base, 16964AdvSet38C0800EEPConfig(AdvPortAddr iop_base, ADVEEP_38C0800_CONFIG *cfg_buf)
17294 ADVEEP_38C0800_CONFIG *cfg_buf)
17295{ 16965{
17296 ushort *wbuf; 16966 ushort *wbuf;
17297 ushort *charfields; 16967 ushort *charfields;
17298 ushort addr, chksum; 16968 ushort addr, chksum;
17299 16969
17300 wbuf = (ushort *) cfg_buf; 16970 wbuf = (ushort *)cfg_buf;
17301 charfields = (ushort *) &ADVEEP_38C0800_Config_Field_IsChar; 16971 charfields = (ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
17302 chksum = 0; 16972 chksum = 0;
17303 16973
17304 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE); 16974 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
17305 AdvWaitEEPCmd(iop_base); 16975 AdvWaitEEPCmd(iop_base);
17306 16976
17307 /* 16977 /*
17308 * Write EEPROM from word 0 to word 20. 16978 * Write EEPROM from word 0 to word 20.
17309 */ 16979 */
17310 for (addr = ADV_EEP_DVC_CFG_BEGIN; 16980 for (addr = ADV_EEP_DVC_CFG_BEGIN;
17311 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) 16981 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
17312 { 16982 ushort word;
17313 ushort word; 16983
17314 16984 if (*charfields++) {
17315 if (*charfields++) { 16985 word = cpu_to_le16(*wbuf);
17316 word = cpu_to_le16(*wbuf); 16986 } else {
17317 } else { 16987 word = *wbuf;
17318 word = *wbuf; 16988 }
17319 } 16989 chksum += *wbuf; /* Checksum is calculated from word values. */
17320 chksum += *wbuf; /* Checksum is calculated from word values. */ 16990 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17321 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word); 16991 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
17322 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr); 16992 ASC_EEP_CMD_WRITE | addr);
17323 AdvWaitEEPCmd(iop_base); 16993 AdvWaitEEPCmd(iop_base);
17324 DvcSleepMilliSecond(ADV_EEP_DELAY_MS); 16994 DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
17325 } 16995 }
17326
17327 /*
17328 * Write EEPROM checksum at word 21.
17329 */
17330 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
17331 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17332 AdvWaitEEPCmd(iop_base);
17333 wbuf++; charfields++;
17334 16996
17335 /* 16997 /*
17336 * Write EEPROM OEM name at words 22 to 29. 16998 * Write EEPROM checksum at word 21.
17337 */ 16999 */
17338 for (addr = ADV_EEP_DVC_CTL_BEGIN; 17000 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
17339 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) 17001 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17340 { 17002 AdvWaitEEPCmd(iop_base);
17341 ushort word; 17003 wbuf++;
17342 17004 charfields++;
17343 if (*charfields++) { 17005
17344 word = cpu_to_le16(*wbuf); 17006 /*
17345 } else { 17007 * Write EEPROM OEM name at words 22 to 29.
17346 word = *wbuf; 17008 */
17347 } 17009 for (addr = ADV_EEP_DVC_CTL_BEGIN;
17348 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word); 17010 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
17349 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr); 17011 ushort word;
17350 AdvWaitEEPCmd(iop_base); 17012
17351 } 17013 if (*charfields++) {
17352 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE); 17014 word = cpu_to_le16(*wbuf);
17353 AdvWaitEEPCmd(iop_base); 17015 } else {
17354 return; 17016 word = *wbuf;
17017 }
17018 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17019 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
17020 ASC_EEP_CMD_WRITE | addr);
17021 AdvWaitEEPCmd(iop_base);
17022 }
17023 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
17024 AdvWaitEEPCmd(iop_base);
17025 return;
17355} 17026}
17356 17027
17357/* 17028/*
17358 * Write the EEPROM from 'cfg_buf'. 17029 * Write the EEPROM from 'cfg_buf'.
17359 */ 17030 */
17360void __init 17031void __init
17361AdvSet38C1600EEPConfig(AdvPortAddr iop_base, 17032AdvSet38C1600EEPConfig(AdvPortAddr iop_base, ADVEEP_38C1600_CONFIG *cfg_buf)
17362 ADVEEP_38C1600_CONFIG *cfg_buf)
17363{ 17033{
17364 ushort *wbuf; 17034 ushort *wbuf;
17365 ushort *charfields; 17035 ushort *charfields;
17366 ushort addr, chksum; 17036 ushort addr, chksum;
17367 17037
17368 wbuf = (ushort *) cfg_buf; 17038 wbuf = (ushort *)cfg_buf;
17369 charfields = (ushort *) &ADVEEP_38C1600_Config_Field_IsChar; 17039 charfields = (ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
17370 chksum = 0; 17040 chksum = 0;
17371 17041
17372 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE); 17042 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_ABLE);
17373 AdvWaitEEPCmd(iop_base); 17043 AdvWaitEEPCmd(iop_base);
17374 17044
17375 /* 17045 /*
17376 * Write EEPROM from word 0 to word 20. 17046 * Write EEPROM from word 0 to word 20.
17377 */ 17047 */
17378 for (addr = ADV_EEP_DVC_CFG_BEGIN; 17048 for (addr = ADV_EEP_DVC_CFG_BEGIN;
17379 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) 17049 addr < ADV_EEP_DVC_CFG_END; addr++, wbuf++) {
17380 { 17050 ushort word;
17381 ushort word; 17051
17382 17052 if (*charfields++) {
17383 if (*charfields++) { 17053 word = cpu_to_le16(*wbuf);
17384 word = cpu_to_le16(*wbuf); 17054 } else {
17385 } else { 17055 word = *wbuf;
17386 word = *wbuf; 17056 }
17387 } 17057 chksum += *wbuf; /* Checksum is calculated from word values. */
17388 chksum += *wbuf; /* Checksum is calculated from word values. */ 17058 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17389 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word); 17059 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
17390 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr); 17060 ASC_EEP_CMD_WRITE | addr);
17391 AdvWaitEEPCmd(iop_base); 17061 AdvWaitEEPCmd(iop_base);
17392 DvcSleepMilliSecond(ADV_EEP_DELAY_MS); 17062 DvcSleepMilliSecond(ADV_EEP_DELAY_MS);
17393 } 17063 }
17394
17395 /*
17396 * Write EEPROM checksum at word 21.
17397 */
17398 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
17399 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17400 AdvWaitEEPCmd(iop_base);
17401 wbuf++; charfields++;
17402 17064
17403 /* 17065 /*
17404 * Write EEPROM OEM name at words 22 to 29. 17066 * Write EEPROM checksum at word 21.
17405 */ 17067 */
17406 for (addr = ADV_EEP_DVC_CTL_BEGIN; 17068 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, chksum);
17407 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) 17069 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr);
17408 { 17070 AdvWaitEEPCmd(iop_base);
17409 ushort word; 17071 wbuf++;
17410 17072 charfields++;
17411 if (*charfields++) { 17073
17412 word = cpu_to_le16(*wbuf); 17074 /*
17413 } else { 17075 * Write EEPROM OEM name at words 22 to 29.
17414 word = *wbuf; 17076 */
17415 } 17077 for (addr = ADV_EEP_DVC_CTL_BEGIN;
17416 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word); 17078 addr < ADV_EEP_MAX_WORD_ADDR; addr++, wbuf++) {
17417 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE | addr); 17079 ushort word;
17418 AdvWaitEEPCmd(iop_base); 17080
17419 } 17081 if (*charfields++) {
17420 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE); 17082 word = cpu_to_le16(*wbuf);
17421 AdvWaitEEPCmd(iop_base); 17083 } else {
17422 return; 17084 word = *wbuf;
17085 }
17086 AdvWriteWordRegister(iop_base, IOPW_EE_DATA, word);
17087 AdvWriteWordRegister(iop_base, IOPW_EE_CMD,
17088 ASC_EEP_CMD_WRITE | addr);
17089 AdvWaitEEPCmd(iop_base);
17090 }
17091 AdvWriteWordRegister(iop_base, IOPW_EE_CMD, ASC_EEP_CMD_WRITE_DISABLE);
17092 AdvWaitEEPCmd(iop_base);
17093 return;
17423} 17094}
17424 17095
17425/* a_advlib.c */ 17096/* a_advlib.c */
@@ -17444,126 +17115,120 @@ AdvSet38C1600EEPConfig(AdvPortAddr iop_base,
17444 * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure 17115 * ADV_ERROR(-1) - Invalid ADV_SCSI_REQ_Q request structure
17445 * host IC error. 17116 * host IC error.
17446 */ 17117 */
17447STATIC int 17118static int AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
17448AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc,
17449 ADV_SCSI_REQ_Q *scsiq)
17450{ 17119{
17451 ulong last_int_level; 17120 ulong last_int_level;
17452 AdvPortAddr iop_base; 17121 AdvPortAddr iop_base;
17453 ADV_DCNT req_size; 17122 ADV_DCNT req_size;
17454 ADV_PADDR req_paddr; 17123 ADV_PADDR req_paddr;
17455 ADV_CARR_T *new_carrp; 17124 ADV_CARR_T *new_carrp;
17456 17125
17457 ASC_ASSERT(scsiq != NULL); /* 'scsiq' should never be NULL. */ 17126 ASC_ASSERT(scsiq != NULL); /* 'scsiq' should never be NULL. */
17458 17127
17459 /* 17128 /*
17460 * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID. 17129 * The ADV_SCSI_REQ_Q 'target_id' field should never exceed ADV_MAX_TID.
17461 */ 17130 */
17462 if (scsiq->target_id > ADV_MAX_TID) 17131 if (scsiq->target_id > ADV_MAX_TID) {
17463 { 17132 scsiq->host_status = QHSTA_M_INVALID_DEVICE;
17464 scsiq->host_status = QHSTA_M_INVALID_DEVICE; 17133 scsiq->done_status = QD_WITH_ERROR;
17465 scsiq->done_status = QD_WITH_ERROR; 17134 return ADV_ERROR;
17466 return ADV_ERROR; 17135 }
17467 }
17468
17469 iop_base = asc_dvc->iop_base;
17470
17471 last_int_level = DvcEnterCritical();
17472
17473 /*
17474 * Allocate a carrier ensuring at least one carrier always
17475 * remains on the freelist and initialize fields.
17476 */
17477 if ((new_carrp = asc_dvc->carr_freelist) == NULL)
17478 {
17479 DvcLeaveCritical(last_int_level);
17480 return ADV_BUSY;
17481 }
17482 asc_dvc->carr_freelist = (ADV_CARR_T *)
17483 ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
17484 asc_dvc->carr_pending_cnt++;
17485
17486 /*
17487 * Set the carrier to be a stopper by setting 'next_vpa'
17488 * to the stopper value. The current stopper will be changed
17489 * below to point to the new stopper.
17490 */
17491 new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
17492
17493 /*
17494 * Clear the ADV_SCSI_REQ_Q done flag.
17495 */
17496 scsiq->a_flag &= ~ADV_SCSIQ_DONE;
17497
17498 req_size = sizeof(ADV_SCSI_REQ_Q);
17499 req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *) scsiq,
17500 (ADV_SDCNT *) &req_size, ADV_IS_SCSIQ_FLAG);
17501
17502 ASC_ASSERT(ADV_32BALIGN(req_paddr) == req_paddr);
17503 ASC_ASSERT(req_size >= sizeof(ADV_SCSI_REQ_Q));
17504
17505 /* Wait for assertion before making little-endian */
17506 req_paddr = cpu_to_le32(req_paddr);
17507
17508 /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
17509 scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
17510 scsiq->scsiq_rptr = req_paddr;
17511 17136
17512 scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp)); 17137 iop_base = asc_dvc->iop_base;
17513 /*
17514 * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
17515 * order during initialization.
17516 */
17517 scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
17518
17519 /*
17520 * Use the current stopper to send the ADV_SCSI_REQ_Q command to
17521 * the microcode. The newly allocated stopper will become the new
17522 * stopper.
17523 */
17524 asc_dvc->icq_sp->areq_vpa = req_paddr;
17525 17138
17526 /* 17139 last_int_level = DvcEnterCritical();
17527 * Set the 'next_vpa' pointer for the old stopper to be the
17528 * physical address of the new stopper. The RISC can only
17529 * follow physical addresses.
17530 */
17531 asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
17532 17140
17533 /* 17141 /*
17534 * Set the host adapter stopper pointer to point to the new carrier. 17142 * Allocate a carrier ensuring at least one carrier always
17535 */ 17143 * remains on the freelist and initialize fields.
17536 asc_dvc->icq_sp = new_carrp; 17144 */
17537 17145 if ((new_carrp = asc_dvc->carr_freelist) == NULL) {
17538 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 || 17146 DvcLeaveCritical(last_int_level);
17539 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) 17147 return ADV_BUSY;
17540 { 17148 }
17541 /* 17149 asc_dvc->carr_freelist = (ADV_CARR_T *)
17542 * Tickle the RISC to tell it to read its Command Queue Head pointer. 17150 ADV_U32_TO_VADDR(le32_to_cpu(new_carrp->next_vpa));
17543 */ 17151 asc_dvc->carr_pending_cnt++;
17544 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A); 17152
17545 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) 17153 /*
17546 { 17154 * Set the carrier to be a stopper by setting 'next_vpa'
17547 /* 17155 * to the stopper value. The current stopper will be changed
17548 * Clear the tickle value. In the ASC-3550 the RISC flag 17156 * below to point to the new stopper.
17549 * command 'clr_tickle_a' does not work unless the host 17157 */
17550 * value is cleared. 17158 new_carrp->next_vpa = cpu_to_le32(ASC_CQ_STOPPER);
17551 */ 17159
17552 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP); 17160 /*
17553 } 17161 * Clear the ADV_SCSI_REQ_Q done flag.
17554 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) 17162 */
17555 { 17163 scsiq->a_flag &= ~ADV_SCSIQ_DONE;
17556 /* 17164
17557 * Notify the RISC a carrier is ready by writing the physical 17165 req_size = sizeof(ADV_SCSI_REQ_Q);
17558 * address of the new carrier stopper to the COMMA register. 17166 req_paddr = DvcGetPhyAddr(asc_dvc, scsiq, (uchar *)scsiq,
17559 */ 17167 (ADV_SDCNT *)&req_size, ADV_IS_SCSIQ_FLAG);
17560 AdvWriteDWordRegister(iop_base, IOPDW_COMMA, 17168
17561 le32_to_cpu(new_carrp->carr_pa)); 17169 ASC_ASSERT(ADV_32BALIGN(req_paddr) == req_paddr);
17562 } 17170 ASC_ASSERT(req_size >= sizeof(ADV_SCSI_REQ_Q));
17171
17172 /* Wait for assertion before making little-endian */
17173 req_paddr = cpu_to_le32(req_paddr);
17174
17175 /* Save virtual and physical address of ADV_SCSI_REQ_Q and carrier. */
17176 scsiq->scsiq_ptr = cpu_to_le32(ADV_VADDR_TO_U32(scsiq));
17177 scsiq->scsiq_rptr = req_paddr;
17178
17179 scsiq->carr_va = cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->icq_sp));
17180 /*
17181 * Every ADV_CARR_T.carr_pa is byte swapped to little-endian
17182 * order during initialization.
17183 */
17184 scsiq->carr_pa = asc_dvc->icq_sp->carr_pa;
17185
17186 /*
17187 * Use the current stopper to send the ADV_SCSI_REQ_Q command to
17188 * the microcode. The newly allocated stopper will become the new
17189 * stopper.
17190 */
17191 asc_dvc->icq_sp->areq_vpa = req_paddr;
17192
17193 /*
17194 * Set the 'next_vpa' pointer for the old stopper to be the
17195 * physical address of the new stopper. The RISC can only
17196 * follow physical addresses.
17197 */
17198 asc_dvc->icq_sp->next_vpa = new_carrp->carr_pa;
17199
17200 /*
17201 * Set the host adapter stopper pointer to point to the new carrier.
17202 */
17203 asc_dvc->icq_sp = new_carrp;
17204
17205 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
17206 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
17207 /*
17208 * Tickle the RISC to tell it to read its Command Queue Head pointer.
17209 */
17210 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
17211 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
17212 /*
17213 * Clear the tickle value. In the ASC-3550 the RISC flag
17214 * command 'clr_tickle_a' does not work unless the host
17215 * value is cleared.
17216 */
17217 AdvWriteByteRegister(iop_base, IOPB_TICKLE,
17218 ADV_TICKLE_NOP);
17219 }
17220 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
17221 /*
17222 * Notify the RISC a carrier is ready by writing the physical
17223 * address of the new carrier stopper to the COMMA register.
17224 */
17225 AdvWriteDWordRegister(iop_base, IOPDW_COMMA,
17226 le32_to_cpu(new_carrp->carr_pa));
17227 }
17563 17228
17564 DvcLeaveCritical(last_int_level); 17229 DvcLeaveCritical(last_int_level);
17565 17230
17566 return ADV_SUCCESS; 17231 return ADV_SUCCESS;
17567} 17232}
17568 17233
17569/* 17234/*
@@ -17575,42 +17240,39 @@ AdvExeScsiQueue(ADV_DVC_VAR *asc_dvc,
17575 * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC 17240 * ADV_ERROR(-1) - Microcode command timed-out. Microcode or IC
17576 * may be hung which requires driver recovery. 17241 * may be hung which requires driver recovery.
17577 */ 17242 */
17578STATIC int 17243static int AdvResetSB(ADV_DVC_VAR *asc_dvc)
17579AdvResetSB(ADV_DVC_VAR *asc_dvc)
17580{ 17244{
17581 int status; 17245 int status;
17582 17246
17583 /* 17247 /*
17584 * Send the SCSI Bus Reset idle start idle command which asserts 17248 * Send the SCSI Bus Reset idle start idle command which asserts
17585 * the SCSI Bus Reset signal. 17249 * the SCSI Bus Reset signal.
17586 */ 17250 */
17587 status = AdvSendIdleCmd(asc_dvc, (ushort) IDLE_CMD_SCSI_RESET_START, 0L); 17251 status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_START, 0L);
17588 if (status != ADV_TRUE) 17252 if (status != ADV_TRUE) {
17589 { 17253 return status;
17590 return status; 17254 }
17591 }
17592
17593 /*
17594 * Delay for the specified SCSI Bus Reset hold time.
17595 *
17596 * The hold time delay is done on the host because the RISC has no
17597 * microsecond accurate timer.
17598 */
17599 DvcDelayMicroSecond(asc_dvc, (ushort) ASC_SCSI_RESET_HOLD_TIME_US);
17600 17255
17601 /* 17256 /*
17602 * Send the SCSI Bus Reset end idle command which de-asserts 17257 * Delay for the specified SCSI Bus Reset hold time.
17603 * the SCSI Bus Reset signal and purges any pending requests. 17258 *
17604 */ 17259 * The hold time delay is done on the host because the RISC has no
17605 status = AdvSendIdleCmd(asc_dvc, (ushort) IDLE_CMD_SCSI_RESET_END, 0L); 17260 * microsecond accurate timer.
17606 if (status != ADV_TRUE) 17261 */
17607 { 17262 DvcDelayMicroSecond(asc_dvc, (ushort)ASC_SCSI_RESET_HOLD_TIME_US);
17608 return status; 17263
17609 } 17264 /*
17265 * Send the SCSI Bus Reset end idle command which de-asserts
17266 * the SCSI Bus Reset signal and purges any pending requests.
17267 */
17268 status = AdvSendIdleCmd(asc_dvc, (ushort)IDLE_CMD_SCSI_RESET_END, 0L);
17269 if (status != ADV_TRUE) {
17270 return status;
17271 }
17610 17272
17611 DvcSleepMilliSecond((ADV_DCNT) asc_dvc->scsi_reset_wait * 1000); 17273 DvcSleepMilliSecond((ADV_DCNT)asc_dvc->scsi_reset_wait * 1000);
17612 17274
17613 return status; 17275 return status;
17614} 17276}
17615 17277
17616/* 17278/*
@@ -17620,99 +17282,89 @@ AdvResetSB(ADV_DVC_VAR *asc_dvc)
17620 * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful. 17282 * ADV_TRUE(1) - Chip re-initialization and SCSI Bus Reset successful.
17621 * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure. 17283 * ADV_FALSE(0) - Chip re-initialization and SCSI Bus Reset failure.
17622 */ 17284 */
17623STATIC int 17285static int AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
17624AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
17625{ 17286{
17626 int status; 17287 int status;
17627 ushort wdtr_able, sdtr_able, tagqng_able; 17288 ushort wdtr_able, sdtr_able, tagqng_able;
17628 ushort ppr_able = 0; 17289 ushort ppr_able = 0;
17629 uchar tid, max_cmd[ADV_MAX_TID + 1]; 17290 uchar tid, max_cmd[ADV_MAX_TID + 1];
17630 AdvPortAddr iop_base; 17291 AdvPortAddr iop_base;
17631 ushort bios_sig; 17292 ushort bios_sig;
17632 17293
17633 iop_base = asc_dvc->iop_base; 17294 iop_base = asc_dvc->iop_base;
17634 17295
17635 /* 17296 /*
17636 * Save current per TID negotiated values. 17297 * Save current per TID negotiated values.
17637 */ 17298 */
17638 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able); 17299 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
17639 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able); 17300 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
17640 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) 17301 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
17641 { 17302 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
17642 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able); 17303 }
17643 } 17304 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
17644 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able); 17305 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
17645 for (tid = 0; tid <= ADV_MAX_TID; tid++) 17306 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
17646 { 17307 max_cmd[tid]);
17647 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid, 17308 }
17648 max_cmd[tid]);
17649 }
17650
17651 /*
17652 * Force the AdvInitAsc3550/38C0800Driver() function to
17653 * perform a SCSI Bus Reset by clearing the BIOS signature word.
17654 * The initialization functions assumes a SCSI Bus Reset is not
17655 * needed if the BIOS signature word is present.
17656 */
17657 AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
17658 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
17659
17660 /*
17661 * Stop chip and reset it.
17662 */
17663 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
17664 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
17665 DvcSleepMilliSecond(100);
17666 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_WR_IO_REG);
17667
17668 /*
17669 * Reset Adv Library error code, if any, and try
17670 * re-initializing the chip.
17671 */
17672 asc_dvc->err_code = 0;
17673 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600)
17674 {
17675 status = AdvInitAsc38C1600Driver(asc_dvc);
17676 }
17677 else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
17678 {
17679 status = AdvInitAsc38C0800Driver(asc_dvc);
17680 } else
17681 {
17682 status = AdvInitAsc3550Driver(asc_dvc);
17683 }
17684 17309
17685 /* Translate initialization return value to status value. */ 17310 /*
17686 if (status == 0) 17311 * Force the AdvInitAsc3550/38C0800Driver() function to
17687 { 17312 * perform a SCSI Bus Reset by clearing the BIOS signature word.
17688 status = ADV_TRUE; 17313 * The initialization functions assumes a SCSI Bus Reset is not
17689 } else 17314 * needed if the BIOS signature word is present.
17690 { 17315 */
17691 status = ADV_FALSE; 17316 AdvReadWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
17692 } 17317 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, 0);
17318
17319 /*
17320 * Stop chip and reset it.
17321 */
17322 AdvWriteWordRegister(iop_base, IOPW_RISC_CSR, ADV_RISC_CSR_STOP);
17323 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG, ADV_CTRL_REG_CMD_RESET);
17324 DvcSleepMilliSecond(100);
17325 AdvWriteWordRegister(iop_base, IOPW_CTRL_REG,
17326 ADV_CTRL_REG_CMD_WR_IO_REG);
17327
17328 /*
17329 * Reset Adv Library error code, if any, and try
17330 * re-initializing the chip.
17331 */
17332 asc_dvc->err_code = 0;
17333 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
17334 status = AdvInitAsc38C1600Driver(asc_dvc);
17335 } else if (asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
17336 status = AdvInitAsc38C0800Driver(asc_dvc);
17337 } else {
17338 status = AdvInitAsc3550Driver(asc_dvc);
17339 }
17693 17340
17694 /* 17341 /* Translate initialization return value to status value. */
17695 * Restore the BIOS signature word. 17342 if (status == 0) {
17696 */ 17343 status = ADV_TRUE;
17697 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig); 17344 } else {
17345 status = ADV_FALSE;
17346 }
17698 17347
17699 /* 17348 /*
17700 * Restore per TID negotiated values. 17349 * Restore the BIOS signature word.
17701 */ 17350 */
17702 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able); 17351 AdvWriteWordLram(iop_base, ASC_MC_BIOS_SIGNATURE, bios_sig);
17703 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able); 17352
17704 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) 17353 /*
17705 { 17354 * Restore per TID negotiated values.
17706 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able); 17355 */
17707 } 17356 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
17708 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able); 17357 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
17709 for (tid = 0; tid <= ADV_MAX_TID; tid++) 17358 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600) {
17710 { 17359 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, ppr_able);
17711 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid, 17360 }
17712 max_cmd[tid]); 17361 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
17713 } 17362 for (tid = 0; tid <= ADV_MAX_TID; tid++) {
17363 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
17364 max_cmd[tid]);
17365 }
17714 17366
17715 return status; 17367 return status;
17716} 17368}
17717 17369
17718/* 17370/*
@@ -17734,158 +17386,151 @@ AdvResetChipAndSB(ADV_DVC_VAR *asc_dvc)
17734 * ADV_TRUE(1) - interrupt was pending 17386 * ADV_TRUE(1) - interrupt was pending
17735 * ADV_FALSE(0) - no interrupt was pending 17387 * ADV_FALSE(0) - no interrupt was pending
17736 */ 17388 */
17737STATIC int 17389static int AdvISR(ADV_DVC_VAR *asc_dvc)
17738AdvISR(ADV_DVC_VAR *asc_dvc)
17739{ 17390{
17740 AdvPortAddr iop_base; 17391 AdvPortAddr iop_base;
17741 uchar int_stat; 17392 uchar int_stat;
17742 ushort target_bit; 17393 ushort target_bit;
17743 ADV_CARR_T *free_carrp; 17394 ADV_CARR_T *free_carrp;
17744 ADV_VADDR irq_next_vpa; 17395 ADV_VADDR irq_next_vpa;
17745 int flags; 17396 int flags;
17746 ADV_SCSI_REQ_Q *scsiq; 17397 ADV_SCSI_REQ_Q *scsiq;
17747
17748 flags = DvcEnterCritical();
17749
17750 iop_base = asc_dvc->iop_base;
17751
17752 /* Reading the register clears the interrupt. */
17753 int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
17754
17755 if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
17756 ADV_INTR_STATUS_INTRC)) == 0)
17757 {
17758 DvcLeaveCritical(flags);
17759 return ADV_FALSE;
17760 }
17761 17398
17762 /* 17399 flags = DvcEnterCritical();
17763 * Notify the driver of an asynchronous microcode condition by
17764 * calling the ADV_DVC_VAR.async_callback function. The function
17765 * is passed the microcode ASC_MC_INTRB_CODE byte value.
17766 */
17767 if (int_stat & ADV_INTR_STATUS_INTRB)
17768 {
17769 uchar intrb_code;
17770
17771 AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
17772
17773 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
17774 asc_dvc->chip_type == ADV_CHIP_ASC38C0800)
17775 {
17776 if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
17777 asc_dvc->carr_pending_cnt != 0)
17778 {
17779 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_A);
17780 if (asc_dvc->chip_type == ADV_CHIP_ASC3550)
17781 {
17782 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
17783 }
17784 }
17785 }
17786
17787 if (asc_dvc->async_callback != 0)
17788 {
17789 (*asc_dvc->async_callback)(asc_dvc, intrb_code);
17790 }
17791 }
17792 17400
17793 /* 17401 iop_base = asc_dvc->iop_base;
17794 * Check if the IRQ stopper carrier contains a completed request. 17402
17795 */ 17403 /* Reading the register clears the interrupt. */
17796 while (((irq_next_vpa = 17404 int_stat = AdvReadByteRegister(iop_base, IOPB_INTR_STATUS_REG);
17797 le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) 17405
17798 { 17406 if ((int_stat & (ADV_INTR_STATUS_INTRA | ADV_INTR_STATUS_INTRB |
17799 /* 17407 ADV_INTR_STATUS_INTRC)) == 0) {
17800 * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure. 17408 DvcLeaveCritical(flags);
17801 * The RISC will have set 'areq_vpa' to a virtual address. 17409 return ADV_FALSE;
17802 * 17410 }
17803 * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr 17411
17804 * field to the carrier ADV_CARR_T.areq_vpa field. The conversion 17412 /*
17805 * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr' 17413 * Notify the driver of an asynchronous microcode condition by
17806 * in AdvExeScsiQueue(). 17414 * calling the ADV_DVC_VAR.async_callback function. The function
17807 */ 17415 * is passed the microcode ASC_MC_INTRB_CODE byte value.
17808 scsiq = (ADV_SCSI_REQ_Q *) 17416 */
17809 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa)); 17417 if (int_stat & ADV_INTR_STATUS_INTRB) {
17810 17418 uchar intrb_code;
17811 /* 17419
17812 * Request finished with good status and the queue was not 17420 AdvReadByteLram(iop_base, ASC_MC_INTRB_CODE, intrb_code);
17813 * DMAed to host memory by the firmware. Set all status fields 17421
17814 * to indicate good status. 17422 if (asc_dvc->chip_type == ADV_CHIP_ASC3550 ||
17815 */ 17423 asc_dvc->chip_type == ADV_CHIP_ASC38C0800) {
17816 if ((irq_next_vpa & ASC_RQ_GOOD) != 0) 17424 if (intrb_code == ADV_ASYNC_CARRIER_READY_FAILURE &&
17817 { 17425 asc_dvc->carr_pending_cnt != 0) {
17818 scsiq->done_status = QD_NO_ERROR; 17426 AdvWriteByteRegister(iop_base, IOPB_TICKLE,
17819 scsiq->host_status = scsiq->scsi_status = 0; 17427 ADV_TICKLE_A);
17820 scsiq->data_cnt = 0L; 17428 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
17821 } 17429 AdvWriteByteRegister(iop_base,
17822 17430 IOPB_TICKLE,
17823 /* 17431 ADV_TICKLE_NOP);
17824 * Advance the stopper pointer to the next carrier 17432 }
17825 * ignoring the lower four bits. Free the previous 17433 }
17826 * stopper carrier. 17434 }
17827 */ 17435
17828 free_carrp = asc_dvc->irq_sp; 17436 if (asc_dvc->async_callback != 0) {
17829 asc_dvc->irq_sp = (ADV_CARR_T *) 17437 (*asc_dvc->async_callback) (asc_dvc, intrb_code);
17830 ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa)); 17438 }
17831 17439 }
17832 free_carrp->next_vpa = 17440
17833 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist)); 17441 /*
17834 asc_dvc->carr_freelist = free_carrp; 17442 * Check if the IRQ stopper carrier contains a completed request.
17835 asc_dvc->carr_pending_cnt--; 17443 */
17836 17444 while (((irq_next_vpa =
17837 ASC_ASSERT(scsiq != NULL); 17445 le32_to_cpu(asc_dvc->irq_sp->next_vpa)) & ASC_RQ_DONE) != 0) {
17838 target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id); 17446 /*
17839 17447 * Get a pointer to the newly completed ADV_SCSI_REQ_Q structure.
17840 /* 17448 * The RISC will have set 'areq_vpa' to a virtual address.
17841 * Clear request microcode control flag. 17449 *
17842 */ 17450 * The firmware will have copied the ASC_SCSI_REQ_Q.scsiq_ptr
17843 scsiq->cntl = 0; 17451 * field to the carrier ADV_CARR_T.areq_vpa field. The conversion
17844 17452 * below complements the conversion of ASC_SCSI_REQ_Q.scsiq_ptr'
17845 /* 17453 * in AdvExeScsiQueue().
17846 * If the command that completed was a SCSI INQUIRY and 17454 */
17847 * LUN 0 was sent the command, then process the INQUIRY 17455 scsiq = (ADV_SCSI_REQ_Q *)
17848 * command information for the device. 17456 ADV_U32_TO_VADDR(le32_to_cpu(asc_dvc->irq_sp->areq_vpa));
17849 * 17457
17850 * Note: If data returned were either VPD or CmdDt data, 17458 /*
17851 * don't process the INQUIRY command information for 17459 * Request finished with good status and the queue was not
17852 * the device, otherwise may erroneously set *_able bits. 17460 * DMAed to host memory by the firmware. Set all status fields
17853 */ 17461 * to indicate good status.
17854 if (scsiq->done_status == QD_NO_ERROR && 17462 */
17855 scsiq->cdb[0] == INQUIRY && 17463 if ((irq_next_vpa & ASC_RQ_GOOD) != 0) {
17856 scsiq->target_lun == 0 && 17464 scsiq->done_status = QD_NO_ERROR;
17857 (scsiq->cdb[1] & ADV_INQ_RTN_VPD_AND_CMDDT) 17465 scsiq->host_status = scsiq->scsi_status = 0;
17858 == ADV_INQ_RTN_STD_INQUIRY_DATA) 17466 scsiq->data_cnt = 0L;
17859 { 17467 }
17860 AdvInquiryHandling(asc_dvc, scsiq); 17468
17861 } 17469 /*
17862 17470 * Advance the stopper pointer to the next carrier
17863 /* 17471 * ignoring the lower four bits. Free the previous
17864 * Notify the driver of the completed request by passing 17472 * stopper carrier.
17865 * the ADV_SCSI_REQ_Q pointer to its callback function. 17473 */
17866 */ 17474 free_carrp = asc_dvc->irq_sp;
17867 scsiq->a_flag |= ADV_SCSIQ_DONE; 17475 asc_dvc->irq_sp = (ADV_CARR_T *)
17868 (*asc_dvc->isr_callback)(asc_dvc, scsiq); 17476 ADV_U32_TO_VADDR(ASC_GET_CARRP(irq_next_vpa));
17869 /* 17477
17870 * Note: After the driver callback function is called, 'scsiq' 17478 free_carrp->next_vpa =
17871 * can no longer be referenced. 17479 cpu_to_le32(ADV_VADDR_TO_U32(asc_dvc->carr_freelist));
17872 * 17480 asc_dvc->carr_freelist = free_carrp;
17873 * Fall through and continue processing other completed 17481 asc_dvc->carr_pending_cnt--;
17874 * requests... 17482
17875 */ 17483 ASC_ASSERT(scsiq != NULL);
17876 17484 target_bit = ADV_TID_TO_TIDMASK(scsiq->target_id);
17877 /* 17485
17878 * Disable interrupts again in case the driver inadvertently 17486 /*
17879 * enabled interrupts in its callback function. 17487 * Clear request microcode control flag.
17880 * 17488 */
17881 * The DvcEnterCritical() return value is ignored, because 17489 scsiq->cntl = 0;
17882 * the 'flags' saved when AdvISR() was first entered will be 17490
17883 * used to restore the interrupt flag on exit. 17491 /*
17884 */ 17492 * If the command that completed was a SCSI INQUIRY and
17885 (void) DvcEnterCritical(); 17493 * LUN 0 was sent the command, then process the INQUIRY
17886 } 17494 * command information for the device.
17887 DvcLeaveCritical(flags); 17495 *
17888 return ADV_TRUE; 17496 * Note: If data returned were either VPD or CmdDt data,
17497 * don't process the INQUIRY command information for
17498 * the device, otherwise may erroneously set *_able bits.
17499 */
17500 if (scsiq->done_status == QD_NO_ERROR &&
17501 scsiq->cdb[0] == INQUIRY &&
17502 scsiq->target_lun == 0 &&
17503 (scsiq->cdb[1] & ADV_INQ_RTN_VPD_AND_CMDDT)
17504 == ADV_INQ_RTN_STD_INQUIRY_DATA) {
17505 AdvInquiryHandling(asc_dvc, scsiq);
17506 }
17507
17508 /*
17509 * Notify the driver of the completed request by passing
17510 * the ADV_SCSI_REQ_Q pointer to its callback function.
17511 */
17512 scsiq->a_flag |= ADV_SCSIQ_DONE;
17513 (*asc_dvc->isr_callback) (asc_dvc, scsiq);
17514 /*
17515 * Note: After the driver callback function is called, 'scsiq'
17516 * can no longer be referenced.
17517 *
17518 * Fall through and continue processing other completed
17519 * requests...
17520 */
17521
17522 /*
17523 * Disable interrupts again in case the driver inadvertently
17524 * enabled interrupts in its callback function.
17525 *
17526 * The DvcEnterCritical() return value is ignored, because
17527 * the 'flags' saved when AdvISR() was first entered will be
17528 * used to restore the interrupt flag on exit.
17529 */
17530 (void)DvcEnterCritical();
17531 }
17532 DvcLeaveCritical(flags);
17533 return ADV_TRUE;
17889} 17534}
17890 17535
17891/* 17536/*
@@ -17902,71 +17547,67 @@ AdvISR(ADV_DVC_VAR *asc_dvc)
17902 * ADV_FALSE - command failed 17547 * ADV_FALSE - command failed
17903 * ADV_ERROR - command timed out 17548 * ADV_ERROR - command timed out
17904 */ 17549 */
17905STATIC int 17550static int
17906AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc, 17551AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
17907 ushort idle_cmd, 17552 ushort idle_cmd, ADV_DCNT idle_cmd_parameter)
17908 ADV_DCNT idle_cmd_parameter)
17909{ 17553{
17910 ulong last_int_level; 17554 ulong last_int_level;
17911 int result; 17555 int result;
17912 ADV_DCNT i, j; 17556 ADV_DCNT i, j;
17913 AdvPortAddr iop_base; 17557 AdvPortAddr iop_base;
17914 17558
17915 last_int_level = DvcEnterCritical(); 17559 last_int_level = DvcEnterCritical();
17916 17560
17917 iop_base = asc_dvc->iop_base; 17561 iop_base = asc_dvc->iop_base;
17918 17562
17919 /* 17563 /*
17920 * Clear the idle command status which is set by the microcode 17564 * Clear the idle command status which is set by the microcode
17921 * to a non-zero value to indicate when the command is completed. 17565 * to a non-zero value to indicate when the command is completed.
17922 * The non-zero result is one of the IDLE_CMD_STATUS_* values 17566 * The non-zero result is one of the IDLE_CMD_STATUS_* values
17923 * defined in a_advlib.h. 17567 * defined in a_advlib.h.
17924 */ 17568 */
17925 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort) 0); 17569 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, (ushort)0);
17926 17570
17927 /* 17571 /*
17928 * Write the idle command value after the idle command parameter 17572 * Write the idle command value after the idle command parameter
17929 * has been written to avoid a race condition. If the order is not 17573 * has been written to avoid a race condition. If the order is not
17930 * followed, the microcode may process the idle command before the 17574 * followed, the microcode may process the idle command before the
17931 * parameters have been written to LRAM. 17575 * parameters have been written to LRAM.
17932 */ 17576 */
17933 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER, 17577 AdvWriteDWordLramNoSwap(iop_base, ASC_MC_IDLE_CMD_PARAMETER,
17934 cpu_to_le32(idle_cmd_parameter)); 17578 cpu_to_le32(idle_cmd_parameter));
17935 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd); 17579 AdvWriteWordLram(iop_base, ASC_MC_IDLE_CMD, idle_cmd);
17936 17580
17937 /* 17581 /*
17938 * Tickle the RISC to tell it to process the idle command. 17582 * Tickle the RISC to tell it to process the idle command.
17939 */ 17583 */
17940 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B); 17584 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_B);
17941 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) 17585 if (asc_dvc->chip_type == ADV_CHIP_ASC3550) {
17942 { 17586 /*
17943 /* 17587 * Clear the tickle value. In the ASC-3550 the RISC flag
17944 * Clear the tickle value. In the ASC-3550 the RISC flag 17588 * command 'clr_tickle_b' does not work unless the host
17945 * command 'clr_tickle_b' does not work unless the host 17589 * value is cleared.
17946 * value is cleared. 17590 */
17947 */ 17591 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP);
17948 AdvWriteByteRegister(iop_base, IOPB_TICKLE, ADV_TICKLE_NOP); 17592 }
17949 }
17950 17593
17951 /* Wait for up to 100 millisecond for the idle command to timeout. */ 17594 /* Wait for up to 100 millisecond for the idle command to timeout. */
17952 for (i = 0; i < SCSI_WAIT_100_MSEC; i++) 17595 for (i = 0; i < SCSI_WAIT_100_MSEC; i++) {
17953 { 17596 /* Poll once each microsecond for command completion. */
17954 /* Poll once each microsecond for command completion. */ 17597 for (j = 0; j < SCSI_US_PER_MSEC; j++) {
17955 for (j = 0; j < SCSI_US_PER_MSEC; j++) 17598 AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS,
17956 { 17599 result);
17957 AdvReadWordLram(iop_base, ASC_MC_IDLE_CMD_STATUS, result); 17600 if (result != 0) {
17958 if (result != 0) 17601 DvcLeaveCritical(last_int_level);
17959 { 17602 return result;
17960 DvcLeaveCritical(last_int_level); 17603 }
17961 return result; 17604 DvcDelayMicroSecond(asc_dvc, (ushort)1);
17962 } 17605 }
17963 DvcDelayMicroSecond(asc_dvc, (ushort) 1); 17606 }
17964 }
17965 }
17966 17607
17967 ASC_ASSERT(0); /* The idle command should never timeout. */ 17608 ASC_ASSERT(0); /* The idle command should never timeout. */
17968 DvcLeaveCritical(last_int_level); 17609 DvcLeaveCritical(last_int_level);
17969 return ADV_ERROR; 17610 return ADV_ERROR;
17970} 17611}
17971 17612
17972/* 17613/*
@@ -17976,179 +17617,1415 @@ AdvSendIdleCmd(ADV_DVC_VAR *asc_dvc,
17976 * microcode operating variables that affect WDTR, SDTR, and Tag 17617 * microcode operating variables that affect WDTR, SDTR, and Tag
17977 * Queuing. 17618 * Queuing.
17978 */ 17619 */
17979STATIC void 17620static void AdvInquiryHandling(ADV_DVC_VAR *asc_dvc, ADV_SCSI_REQ_Q *scsiq)
17980AdvInquiryHandling(
17981 ADV_DVC_VAR *asc_dvc,
17982 ADV_SCSI_REQ_Q *scsiq)
17983{ 17621{
17984 AdvPortAddr iop_base; 17622 AdvPortAddr iop_base;
17985 uchar tid; 17623 uchar tid;
17986 ADV_SCSI_INQUIRY *inq; 17624 ADV_SCSI_INQUIRY *inq;
17987 ushort tidmask; 17625 ushort tidmask;
17988 ushort cfg_word; 17626 ushort cfg_word;
17627
17628 /*
17629 * AdvInquiryHandling() requires up to INQUIRY information Byte 7
17630 * to be available.
17631 *
17632 * If less than 8 bytes of INQUIRY information were requested or less
17633 * than 8 bytes were transferred, then return. cdb[4] is the request
17634 * length and the ADV_SCSI_REQ_Q 'data_cnt' field is set by the
17635 * microcode to the transfer residual count.
17636 */
17637
17638 if (scsiq->cdb[4] < 8 ||
17639 (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) < 8) {
17640 return;
17641 }
17989 17642
17990 /* 17643 iop_base = asc_dvc->iop_base;
17991 * AdvInquiryHandling() requires up to INQUIRY information Byte 7 17644 tid = scsiq->target_id;
17992 * to be available.
17993 *
17994 * If less than 8 bytes of INQUIRY information were requested or less
17995 * than 8 bytes were transferred, then return. cdb[4] is the request
17996 * length and the ADV_SCSI_REQ_Q 'data_cnt' field is set by the
17997 * microcode to the transfer residual count.
17998 */
17999
18000 if (scsiq->cdb[4] < 8 ||
18001 (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) < 8)
18002 {
18003 return;
18004 }
18005 17645
18006 iop_base = asc_dvc->iop_base; 17646 inq = (ADV_SCSI_INQUIRY *) scsiq->vdata_addr;
18007 tid = scsiq->target_id;
18008 17647
18009 inq = (ADV_SCSI_INQUIRY *) scsiq->vdata_addr; 17648 /*
17649 * WDTR, SDTR, and Tag Queuing cannot be enabled for old devices.
17650 */
17651 if (ADV_INQ_RESPONSE_FMT(inq) < 2 && ADV_INQ_ANSI_VER(inq) < 2) {
17652 return;
17653 } else {
17654 /*
17655 * INQUIRY Byte 7 Handling
17656 *
17657 * Use a device's INQUIRY byte 7 to determine whether it
17658 * supports WDTR, SDTR, and Tag Queuing. If the feature
17659 * is enabled in the EEPROM and the device supports the
17660 * feature, then enable it in the microcode.
17661 */
18010 17662
18011 /* 17663 tidmask = ADV_TID_TO_TIDMASK(tid);
18012 * WDTR, SDTR, and Tag Queuing cannot be enabled for old devices. 17664
18013 */ 17665 /*
18014 if (ADV_INQ_RESPONSE_FMT(inq) < 2 && ADV_INQ_ANSI_VER(inq) < 2) 17666 * Wide Transfers
18015 { 17667 *
18016 return; 17668 * If the EEPROM enabled WDTR for the device and the device
18017 } else 17669 * supports wide bus (16 bit) transfers, then turn on the
18018 { 17670 * device's 'wdtr_able' bit and write the new value to the
18019 /* 17671 * microcode.
18020 * INQUIRY Byte 7 Handling 17672 */
18021 * 17673 if ((asc_dvc->wdtr_able & tidmask) && ADV_INQ_WIDE16(inq)) {
18022 * Use a device's INQUIRY byte 7 to determine whether it 17674 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word);
18023 * supports WDTR, SDTR, and Tag Queuing. If the feature 17675 if ((cfg_word & tidmask) == 0) {
18024 * is enabled in the EEPROM and the device supports the 17676 cfg_word |= tidmask;
18025 * feature, then enable it in the microcode. 17677 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE,
18026 */ 17678 cfg_word);
18027 17679
18028 tidmask = ADV_TID_TO_TIDMASK(tid); 17680 /*
18029 17681 * Clear the microcode "SDTR negotiation" and "WDTR
18030 /* 17682 * negotiation" done indicators for the target to cause
18031 * Wide Transfers 17683 * it to negotiate with the new setting set above.
18032 * 17684 * WDTR when accepted causes the target to enter
18033 * If the EEPROM enabled WDTR for the device and the device 17685 * asynchronous mode, so SDTR must be negotiated.
18034 * supports wide bus (16 bit) transfers, then turn on the 17686 */
18035 * device's 'wdtr_able' bit and write the new value to the 17687 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE,
18036 * microcode. 17688 cfg_word);
18037 */ 17689 cfg_word &= ~tidmask;
18038 if ((asc_dvc->wdtr_able & tidmask) && ADV_INQ_WIDE16(inq)) 17690 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE,
18039 { 17691 cfg_word);
18040 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word); 17692 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE,
18041 if ((cfg_word & tidmask) == 0) 17693 cfg_word);
18042 { 17694 cfg_word &= ~tidmask;
18043 cfg_word |= tidmask; 17695 AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE,
18044 AdvWriteWordLram(iop_base, ASC_MC_WDTR_ABLE, cfg_word); 17696 cfg_word);
18045 17697 }
18046 /* 17698 }
18047 * Clear the microcode "SDTR negotiation" and "WDTR 17699
18048 * negotiation" done indicators for the target to cause 17700 /*
18049 * it to negotiate with the new setting set above. 17701 * Synchronous Transfers
18050 * WDTR when accepted causes the target to enter 17702 *
18051 * asynchronous mode, so SDTR must be negotiated. 17703 * If the EEPROM enabled SDTR for the device and the device
18052 */ 17704 * supports synchronous transfers, then turn on the device's
18053 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word); 17705 * 'sdtr_able' bit. Write the new value to the microcode.
18054 cfg_word &= ~tidmask; 17706 */
18055 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word); 17707 if ((asc_dvc->sdtr_able & tidmask) && ADV_INQ_SYNC(inq)) {
18056 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word); 17708 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word);
18057 cfg_word &= ~tidmask; 17709 if ((cfg_word & tidmask) == 0) {
18058 AdvWriteWordLram(iop_base, ASC_MC_WDTR_DONE, cfg_word); 17710 cfg_word |= tidmask;
18059 } 17711 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE,
18060 } 17712 cfg_word);
18061 17713
18062 /* 17714 /*
18063 * Synchronous Transfers 17715 * Clear the microcode "SDTR negotiation" done indicator
18064 * 17716 * for the target to cause it to negotiate with the new
18065 * If the EEPROM enabled SDTR for the device and the device 17717 * setting set above.
18066 * supports synchronous transfers, then turn on the device's 17718 */
18067 * 'sdtr_able' bit. Write the new value to the microcode. 17719 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE,
18068 */ 17720 cfg_word);
18069 if ((asc_dvc->sdtr_able & tidmask) && ADV_INQ_SYNC(inq)) 17721 cfg_word &= ~tidmask;
18070 { 17722 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE,
18071 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word); 17723 cfg_word);
18072 if ((cfg_word & tidmask) == 0) 17724 }
18073 { 17725 }
18074 cfg_word |= tidmask; 17726 /*
18075 AdvWriteWordLram(iop_base, ASC_MC_SDTR_ABLE, cfg_word); 17727 * If the Inquiry data included enough space for the SPI-3
18076 17728 * Clocking field, then check if DT mode is supported.
18077 /* 17729 */
18078 * Clear the microcode "SDTR negotiation" done indicator 17730 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600 &&
18079 * for the target to cause it to negotiate with the new 17731 (scsiq->cdb[4] >= 57 ||
18080 * setting set above. 17732 (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) >= 57)) {
18081 */ 17733 /*
18082 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word); 17734 * PPR (Parallel Protocol Request) Capable
18083 cfg_word &= ~tidmask; 17735 *
18084 AdvWriteWordLram(iop_base, ASC_MC_SDTR_DONE, cfg_word); 17736 * If the device supports DT mode, then it must be PPR capable.
18085 } 17737 * The PPR message will be used in place of the SDTR and WDTR
18086 } 17738 * messages to negotiate synchronous speed and offset, transfer
18087 /* 17739 * width, and protocol options.
18088 * If the Inquiry data included enough space for the SPI-3 17740 */
18089 * Clocking field, then check if DT mode is supported. 17741 if (ADV_INQ_CLOCKING(inq) & ADV_INQ_CLOCKING_DT_ONLY) {
18090 */ 17742 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE,
18091 if (asc_dvc->chip_type == ADV_CHIP_ASC38C1600 && 17743 asc_dvc->ppr_able);
18092 (scsiq->cdb[4] >= 57 || 17744 asc_dvc->ppr_able |= tidmask;
18093 (scsiq->cdb[4] - le32_to_cpu(scsiq->data_cnt)) >= 57)) 17745 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE,
18094 { 17746 asc_dvc->ppr_able);
18095 /* 17747 }
18096 * PPR (Parallel Protocol Request) Capable 17748 }
18097 * 17749
18098 * If the device supports DT mode, then it must be PPR capable. 17750 /*
18099 * The PPR message will be used in place of the SDTR and WDTR 17751 * If the EEPROM enabled Tag Queuing for the device and the
18100 * messages to negotiate synchronous speed and offset, transfer 17752 * device supports Tag Queueing, then turn on the device's
18101 * width, and protocol options. 17753 * 'tagqng_enable' bit in the microcode and set the microcode
18102 */ 17754 * maximum command count to the ADV_DVC_VAR 'max_dvc_qng'
18103 if (ADV_INQ_CLOCKING(inq) & ADV_INQ_CLOCKING_DT_ONLY) 17755 * value.
18104 { 17756 *
18105 AdvReadWordLram(iop_base, ASC_MC_PPR_ABLE, asc_dvc->ppr_able); 17757 * Tag Queuing is disabled for the BIOS which runs in polled
18106 asc_dvc->ppr_able |= tidmask; 17758 * mode and would see no benefit from Tag Queuing. Also by
18107 AdvWriteWordLram(iop_base, ASC_MC_PPR_ABLE, asc_dvc->ppr_able); 17759 * disabling Tag Queuing in the BIOS devices with Tag Queuing
18108 } 17760 * bugs will at least work with the BIOS.
18109 } 17761 */
18110 17762 if ((asc_dvc->tagqng_able & tidmask) && ADV_INQ_CMD_QUEUE(inq)) {
18111 /* 17763 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
18112 * If the EEPROM enabled Tag Queuing for the device and the 17764 cfg_word |= tidmask;
18113 * device supports Tag Queueing, then turn on the device's 17765 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE,
18114 * 'tagqng_enable' bit in the microcode and set the microcode 17766 cfg_word);
18115 * maximum command count to the ADV_DVC_VAR 'max_dvc_qng' 17767
18116 * value. 17768 AdvWriteByteLram(iop_base,
18117 * 17769 ASC_MC_NUMBER_OF_MAX_CMD + tid,
18118 * Tag Queuing is disabled for the BIOS which runs in polled 17770 asc_dvc->max_dvc_qng);
18119 * mode and would see no benefit from Tag Queuing. Also by 17771 }
18120 * disabling Tag Queuing in the BIOS devices with Tag Queuing 17772 }
18121 * bugs will at least work with the BIOS.
18122 */
18123 if ((asc_dvc->tagqng_able & tidmask) && ADV_INQ_CMD_QUEUE(inq))
18124 {
18125 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
18126 cfg_word |= tidmask;
18127 AdvWriteWordLram(iop_base, ASC_MC_TAGQNG_ABLE, cfg_word);
18128
18129 AdvWriteByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + tid,
18130 asc_dvc->max_dvc_qng);
18131 }
18132 }
18133} 17773}
17774
18134MODULE_LICENSE("Dual BSD/GPL"); 17775MODULE_LICENSE("Dual BSD/GPL");
18135 17776
17777static struct Scsi_Host *__devinit
17778advansys_board_found(int iop, struct device *dev, int bus_type)
17779{
17780 struct Scsi_Host *shost;
17781 struct pci_dev *pdev = bus_type == ASC_IS_PCI ? to_pci_dev(dev) : NULL;
17782 asc_board_t *boardp;
17783 ASC_DVC_VAR *asc_dvc_varp = NULL;
17784 ADV_DVC_VAR *adv_dvc_varp = NULL;
17785 adv_sgblk_t *sgp = NULL;
17786 int share_irq = FALSE;
17787 int iolen = 0;
17788 ADV_PADDR pci_memory_address;
17789 int warn_code, err_code;
17790 int ret;
17791
17792 /*
17793 * Adapter found.
17794 *
17795 * Register the adapter, get its configuration, and
17796 * initialize it.
17797 */
17798 ASC_DBG(2, "advansys_board_found: scsi_register()\n");
17799 shost = scsi_register(&driver_template, sizeof(asc_board_t));
17800
17801 if (!shost)
17802 return NULL;
17803
17804 /* Save a pointer to the Scsi_Host of each board found. */
17805 asc_host[asc_board_count++] = shost;
17806
17807 /* Initialize private per board data */
17808 boardp = ASC_BOARDP(shost);
17809 memset(boardp, 0, sizeof(asc_board_t));
17810 boardp->id = asc_board_count - 1;
17811
17812 /* Initialize spinlock. */
17813 spin_lock_init(&boardp->lock);
17814
17815 /*
17816 * Handle both narrow and wide boards.
17817 *
17818 * If a Wide board was detected, set the board structure
17819 * wide board flag. Set-up the board structure based on
17820 * the board type.
17821 */
17822#ifdef CONFIG_PCI
17823 if (bus_type == ASC_IS_PCI &&
17824 (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW ||
17825 pdev->device == PCI_DEVICE_ID_38C0800_REV1 ||
17826 pdev->device == PCI_DEVICE_ID_38C1600_REV1)) {
17827 boardp->flags |= ASC_IS_WIDE_BOARD;
17828 }
17829#endif /* CONFIG_PCI */
17830
17831 if (ASC_NARROW_BOARD(boardp)) {
17832 ASC_DBG(1, "advansys_board_found: narrow board\n");
17833 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
17834 asc_dvc_varp->bus_type = bus_type;
17835 asc_dvc_varp->drv_ptr = boardp;
17836 asc_dvc_varp->cfg = &boardp->dvc_cfg.asc_dvc_cfg;
17837 asc_dvc_varp->cfg->overrun_buf = &overrun_buf[0];
17838 asc_dvc_varp->iop_base = iop;
17839 asc_dvc_varp->isr_callback = asc_isr_callback;
17840 } else {
17841 ASC_DBG(1, "advansys_board_found: wide board\n");
17842 adv_dvc_varp = &boardp->dvc_var.adv_dvc_var;
17843 adv_dvc_varp->drv_ptr = boardp;
17844 adv_dvc_varp->cfg = &boardp->dvc_cfg.adv_dvc_cfg;
17845 adv_dvc_varp->isr_callback = adv_isr_callback;
17846 adv_dvc_varp->async_callback = adv_async_callback;
17847#ifdef CONFIG_PCI
17848 if (pdev->device == PCI_DEVICE_ID_ASP_ABP940UW) {
17849 ASC_DBG(1, "advansys_board_found: ASC-3550\n");
17850 adv_dvc_varp->chip_type = ADV_CHIP_ASC3550;
17851 } else if (pdev->device == PCI_DEVICE_ID_38C0800_REV1) {
17852 ASC_DBG(1, "advansys_board_found: ASC-38C0800\n");
17853 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C0800;
17854 } else {
17855 ASC_DBG(1, "advansys_board_found: ASC-38C1600\n");
17856 adv_dvc_varp->chip_type = ADV_CHIP_ASC38C1600;
17857 }
17858#endif /* CONFIG_PCI */
17859
17860 /*
17861 * Map the board's registers into virtual memory for
17862 * PCI slave access. Only memory accesses are used to
17863 * access the board's registers.
17864 *
17865 * Note: The PCI register base address is not always
17866 * page aligned, but the address passed to ioremap()
17867 * must be page aligned. It is guaranteed that the
17868 * PCI register base address will not cross a page
17869 * boundary.
17870 */
17871 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
17872 iolen = ADV_3550_IOLEN;
17873 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
17874 iolen = ADV_38C0800_IOLEN;
17875 } else {
17876 iolen = ADV_38C1600_IOLEN;
17877 }
17878#ifdef CONFIG_PCI
17879 pci_memory_address = pci_resource_start(pdev, 1);
17880 ASC_DBG1(1,
17881 "advansys_board_found: pci_memory_address: 0x%lx\n",
17882 (ulong)pci_memory_address);
17883 if ((boardp->ioremap_addr =
17884 ioremap(pci_memory_address & PAGE_MASK, PAGE_SIZE)) == 0) {
17885 ASC_PRINT3
17886 ("advansys_board_found: board %d: ioremap(%x, %d) returned NULL\n",
17887 boardp->id, pci_memory_address, iolen);
17888 scsi_unregister(shost);
17889 asc_board_count--;
17890 return NULL;
17891 }
17892 ASC_DBG1(1,
17893 "advansys_board_found: ioremap_addr: 0x%lx\n",
17894 (ulong)boardp->ioremap_addr);
17895 adv_dvc_varp->iop_base = (AdvPortAddr)
17896 (boardp->ioremap_addr +
17897 (pci_memory_address - (pci_memory_address & PAGE_MASK)));
17898 ASC_DBG1(1,
17899 "advansys_board_found: iop_base: 0x%lx\n",
17900 adv_dvc_varp->iop_base);
17901#endif /* CONFIG_PCI */
17902
17903 /*
17904 * Even though it isn't used to access wide boards, other
17905 * than for the debug line below, save I/O Port address so
17906 * that it can be reported.
17907 */
17908 boardp->ioport = iop;
17909
17910 ASC_DBG2(1,
17911 "advansys_board_found: iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
17912 (ushort)inp(iop + 1), (ushort)inpw(iop));
17913 }
17914
17915#ifdef CONFIG_PROC_FS
17916 /*
17917 * Allocate buffer for printing information from
17918 * /proc/scsi/advansys/[0...].
17919 */
17920 if ((boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_ATOMIC)) == NULL) {
17921 ASC_PRINT3
17922 ("advansys_board_found: board %d: kmalloc(%d, %d) returned NULL\n",
17923 boardp->id, ASC_PRTBUF_SIZE, GFP_ATOMIC);
17924 scsi_unregister(shost);
17925 asc_board_count--;
17926 return NULL;
17927 }
17928#endif /* CONFIG_PROC_FS */
17929
17930 if (ASC_NARROW_BOARD(boardp)) {
17931 asc_dvc_varp->cfg->dev = dev;
17932 /*
17933 * Set the board bus type and PCI IRQ before
17934 * calling AscInitGetConfig().
17935 */
17936 switch (asc_dvc_varp->bus_type) {
17937#ifdef CONFIG_ISA
17938 case ASC_IS_ISA:
17939 shost->unchecked_isa_dma = TRUE;
17940 share_irq = FALSE;
17941 break;
17942 case ASC_IS_VL:
17943 shost->unchecked_isa_dma = FALSE;
17944 share_irq = FALSE;
17945 break;
17946 case ASC_IS_EISA:
17947 shost->unchecked_isa_dma = FALSE;
17948 share_irq = TRUE;
17949 break;
17950#endif /* CONFIG_ISA */
17951#ifdef CONFIG_PCI
17952 case ASC_IS_PCI:
17953 shost->irq = asc_dvc_varp->irq_no = pdev->irq;
17954 asc_dvc_varp->cfg->pci_slot_info =
17955 ASC_PCI_MKID(pdev->bus->number,
17956 PCI_SLOT(pdev->devfn),
17957 PCI_FUNC(pdev->devfn));
17958 shost->unchecked_isa_dma = FALSE;
17959 share_irq = TRUE;
17960 break;
17961#endif /* CONFIG_PCI */
17962 default:
17963 ASC_PRINT2
17964 ("advansys_board_found: board %d: unknown adapter type: %d\n",
17965 boardp->id, asc_dvc_varp->bus_type);
17966 shost->unchecked_isa_dma = TRUE;
17967 share_irq = FALSE;
17968 break;
17969 }
17970 } else {
17971 adv_dvc_varp->cfg->dev = dev;
17972 /*
17973 * For Wide boards set PCI information before calling
17974 * AdvInitGetConfig().
17975 */
17976#ifdef CONFIG_PCI
17977 shost->irq = adv_dvc_varp->irq_no = pdev->irq;
17978 adv_dvc_varp->cfg->pci_slot_info =
17979 ASC_PCI_MKID(pdev->bus->number,
17980 PCI_SLOT(pdev->devfn),
17981 PCI_FUNC(pdev->devfn));
17982 shost->unchecked_isa_dma = FALSE;
17983 share_irq = TRUE;
17984#endif /* CONFIG_PCI */
17985 }
17986
17987 /*
17988 * Read the board configuration.
17989 */
17990 if (ASC_NARROW_BOARD(boardp)) {
17991 /*
17992 * NOTE: AscInitGetConfig() may change the board's
17993 * bus_type value. The bus_type value should no
17994 * longer be used. If the bus_type field must be
17995 * referenced only use the bit-wise AND operator "&".
17996 */
17997 ASC_DBG(2, "advansys_board_found: AscInitGetConfig()\n");
17998 switch (ret = AscInitGetConfig(asc_dvc_varp)) {
17999 case 0: /* No error */
18000 break;
18001 case ASC_WARN_IO_PORT_ROTATE:
18002 ASC_PRINT1
18003 ("AscInitGetConfig: board %d: I/O port address modified\n",
18004 boardp->id);
18005 break;
18006 case ASC_WARN_AUTO_CONFIG:
18007 ASC_PRINT1
18008 ("AscInitGetConfig: board %d: I/O port increment switch enabled\n",
18009 boardp->id);
18010 break;
18011 case ASC_WARN_EEPROM_CHKSUM:
18012 ASC_PRINT1
18013 ("AscInitGetConfig: board %d: EEPROM checksum error\n",
18014 boardp->id);
18015 break;
18016 case ASC_WARN_IRQ_MODIFIED:
18017 ASC_PRINT1
18018 ("AscInitGetConfig: board %d: IRQ modified\n",
18019 boardp->id);
18020 break;
18021 case ASC_WARN_CMD_QNG_CONFLICT:
18022 ASC_PRINT1
18023 ("AscInitGetConfig: board %d: tag queuing enabled w/o disconnects\n",
18024 boardp->id);
18025 break;
18026 default:
18027 ASC_PRINT2
18028 ("AscInitGetConfig: board %d: unknown warning: 0x%x\n",
18029 boardp->id, ret);
18030 break;
18031 }
18032 if ((err_code = asc_dvc_varp->err_code) != 0) {
18033 ASC_PRINT3
18034 ("AscInitGetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
18035 boardp->id,
18036 asc_dvc_varp->init_state, asc_dvc_varp->err_code);
18037 }
18038 } else {
18039 ASC_DBG(2, "advansys_board_found: AdvInitGetConfig()\n");
18040 if ((ret = AdvInitGetConfig(adv_dvc_varp)) != 0) {
18041 ASC_PRINT2
18042 ("AdvInitGetConfig: board %d: warning: 0x%x\n",
18043 boardp->id, ret);
18044 }
18045 if ((err_code = adv_dvc_varp->err_code) != 0) {
18046 ASC_PRINT2
18047 ("AdvInitGetConfig: board %d error: err_code 0x%x\n",
18048 boardp->id, adv_dvc_varp->err_code);
18049 }
18050 }
18051
18052 if (err_code != 0) {
18053#ifdef CONFIG_PROC_FS
18054 kfree(boardp->prtbuf);
18055#endif /* CONFIG_PROC_FS */
18056 scsi_unregister(shost);
18057 asc_board_count--;
18058 return NULL;
18059 }
18060
18061 /*
18062 * Save the EEPROM configuration so that it can be displayed
18063 * from /proc/scsi/advansys/[0...].
18064 */
18065 if (ASC_NARROW_BOARD(boardp)) {
18066
18067 ASCEEP_CONFIG *ep;
18068
18069 /*
18070 * Set the adapter's target id bit in the 'init_tidmask' field.
18071 */
18072 boardp->init_tidmask |=
18073 ADV_TID_TO_TIDMASK(asc_dvc_varp->cfg->chip_scsi_id);
18074
18075 /*
18076 * Save EEPROM settings for the board.
18077 */
18078 ep = &boardp->eep_config.asc_eep;
18079
18080 ep->init_sdtr = asc_dvc_varp->cfg->sdtr_enable;
18081 ep->disc_enable = asc_dvc_varp->cfg->disc_enable;
18082 ep->use_cmd_qng = asc_dvc_varp->cfg->cmd_qng_enabled;
18083 ASC_EEP_SET_DMA_SPD(ep, asc_dvc_varp->cfg->isa_dma_speed);
18084 ep->start_motor = asc_dvc_varp->start_motor;
18085 ep->cntl = asc_dvc_varp->dvc_cntl;
18086 ep->no_scam = asc_dvc_varp->no_scam;
18087 ep->max_total_qng = asc_dvc_varp->max_total_qng;
18088 ASC_EEP_SET_CHIP_ID(ep, asc_dvc_varp->cfg->chip_scsi_id);
18089 /* 'max_tag_qng' is set to the same value for every device. */
18090 ep->max_tag_qng = asc_dvc_varp->cfg->max_tag_qng[0];
18091 ep->adapter_info[0] = asc_dvc_varp->cfg->adapter_info[0];
18092 ep->adapter_info[1] = asc_dvc_varp->cfg->adapter_info[1];
18093 ep->adapter_info[2] = asc_dvc_varp->cfg->adapter_info[2];
18094 ep->adapter_info[3] = asc_dvc_varp->cfg->adapter_info[3];
18095 ep->adapter_info[4] = asc_dvc_varp->cfg->adapter_info[4];
18096 ep->adapter_info[5] = asc_dvc_varp->cfg->adapter_info[5];
18097
18098 /*
18099 * Modify board configuration.
18100 */
18101 ASC_DBG(2, "advansys_board_found: AscInitSetConfig()\n");
18102 switch (ret = AscInitSetConfig(asc_dvc_varp)) {
18103 case 0: /* No error. */
18104 break;
18105 case ASC_WARN_IO_PORT_ROTATE:
18106 ASC_PRINT1
18107 ("AscInitSetConfig: board %d: I/O port address modified\n",
18108 boardp->id);
18109 break;
18110 case ASC_WARN_AUTO_CONFIG:
18111 ASC_PRINT1
18112 ("AscInitSetConfig: board %d: I/O port increment switch enabled\n",
18113 boardp->id);
18114 break;
18115 case ASC_WARN_EEPROM_CHKSUM:
18116 ASC_PRINT1
18117 ("AscInitSetConfig: board %d: EEPROM checksum error\n",
18118 boardp->id);
18119 break;
18120 case ASC_WARN_IRQ_MODIFIED:
18121 ASC_PRINT1
18122 ("AscInitSetConfig: board %d: IRQ modified\n",
18123 boardp->id);
18124 break;
18125 case ASC_WARN_CMD_QNG_CONFLICT:
18126 ASC_PRINT1
18127 ("AscInitSetConfig: board %d: tag queuing w/o disconnects\n",
18128 boardp->id);
18129 break;
18130 default:
18131 ASC_PRINT2
18132 ("AscInitSetConfig: board %d: unknown warning: 0x%x\n",
18133 boardp->id, ret);
18134 break;
18135 }
18136 if (asc_dvc_varp->err_code != 0) {
18137 ASC_PRINT3
18138 ("AscInitSetConfig: board %d error: init_state 0x%x, err_code 0x%x\n",
18139 boardp->id,
18140 asc_dvc_varp->init_state, asc_dvc_varp->err_code);
18141#ifdef CONFIG_PROC_FS
18142 kfree(boardp->prtbuf);
18143#endif /* CONFIG_PROC_FS */
18144 scsi_unregister(shost);
18145 asc_board_count--;
18146 return NULL;
18147 }
18148
18149 /*
18150 * Finish initializing the 'Scsi_Host' structure.
18151 */
18152 /* AscInitSetConfig() will set the IRQ for non-PCI boards. */
18153 if ((asc_dvc_varp->bus_type & ASC_IS_PCI) == 0) {
18154 shost->irq = asc_dvc_varp->irq_no;
18155 }
18156 } else {
18157 ADVEEP_3550_CONFIG *ep_3550;
18158 ADVEEP_38C0800_CONFIG *ep_38C0800;
18159 ADVEEP_38C1600_CONFIG *ep_38C1600;
18160
18161 /*
18162 * Save Wide EEP Configuration Information.
18163 */
18164 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
18165 ep_3550 = &boardp->eep_config.adv_3550_eep;
18166
18167 ep_3550->adapter_scsi_id = adv_dvc_varp->chip_scsi_id;
18168 ep_3550->max_host_qng = adv_dvc_varp->max_host_qng;
18169 ep_3550->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
18170 ep_3550->termination = adv_dvc_varp->cfg->termination;
18171 ep_3550->disc_enable = adv_dvc_varp->cfg->disc_enable;
18172 ep_3550->bios_ctrl = adv_dvc_varp->bios_ctrl;
18173 ep_3550->wdtr_able = adv_dvc_varp->wdtr_able;
18174 ep_3550->sdtr_able = adv_dvc_varp->sdtr_able;
18175 ep_3550->ultra_able = adv_dvc_varp->ultra_able;
18176 ep_3550->tagqng_able = adv_dvc_varp->tagqng_able;
18177 ep_3550->start_motor = adv_dvc_varp->start_motor;
18178 ep_3550->scsi_reset_delay =
18179 adv_dvc_varp->scsi_reset_wait;
18180 ep_3550->serial_number_word1 =
18181 adv_dvc_varp->cfg->serial1;
18182 ep_3550->serial_number_word2 =
18183 adv_dvc_varp->cfg->serial2;
18184 ep_3550->serial_number_word3 =
18185 adv_dvc_varp->cfg->serial3;
18186 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
18187 ep_38C0800 = &boardp->eep_config.adv_38C0800_eep;
18188
18189 ep_38C0800->adapter_scsi_id =
18190 adv_dvc_varp->chip_scsi_id;
18191 ep_38C0800->max_host_qng = adv_dvc_varp->max_host_qng;
18192 ep_38C0800->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
18193 ep_38C0800->termination_lvd =
18194 adv_dvc_varp->cfg->termination;
18195 ep_38C0800->disc_enable =
18196 adv_dvc_varp->cfg->disc_enable;
18197 ep_38C0800->bios_ctrl = adv_dvc_varp->bios_ctrl;
18198 ep_38C0800->wdtr_able = adv_dvc_varp->wdtr_able;
18199 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
18200 ep_38C0800->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
18201 ep_38C0800->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
18202 ep_38C0800->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
18203 ep_38C0800->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
18204 ep_38C0800->tagqng_able = adv_dvc_varp->tagqng_able;
18205 ep_38C0800->start_motor = adv_dvc_varp->start_motor;
18206 ep_38C0800->scsi_reset_delay =
18207 adv_dvc_varp->scsi_reset_wait;
18208 ep_38C0800->serial_number_word1 =
18209 adv_dvc_varp->cfg->serial1;
18210 ep_38C0800->serial_number_word2 =
18211 adv_dvc_varp->cfg->serial2;
18212 ep_38C0800->serial_number_word3 =
18213 adv_dvc_varp->cfg->serial3;
18214 } else {
18215 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
18216
18217 ep_38C1600->adapter_scsi_id =
18218 adv_dvc_varp->chip_scsi_id;
18219 ep_38C1600->max_host_qng = adv_dvc_varp->max_host_qng;
18220 ep_38C1600->max_dvc_qng = adv_dvc_varp->max_dvc_qng;
18221 ep_38C1600->termination_lvd =
18222 adv_dvc_varp->cfg->termination;
18223 ep_38C1600->disc_enable =
18224 adv_dvc_varp->cfg->disc_enable;
18225 ep_38C1600->bios_ctrl = adv_dvc_varp->bios_ctrl;
18226 ep_38C1600->wdtr_able = adv_dvc_varp->wdtr_able;
18227 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
18228 ep_38C1600->sdtr_speed1 = adv_dvc_varp->sdtr_speed1;
18229 ep_38C1600->sdtr_speed2 = adv_dvc_varp->sdtr_speed2;
18230 ep_38C1600->sdtr_speed3 = adv_dvc_varp->sdtr_speed3;
18231 ep_38C1600->sdtr_speed4 = adv_dvc_varp->sdtr_speed4;
18232 ep_38C1600->tagqng_able = adv_dvc_varp->tagqng_able;
18233 ep_38C1600->start_motor = adv_dvc_varp->start_motor;
18234 ep_38C1600->scsi_reset_delay =
18235 adv_dvc_varp->scsi_reset_wait;
18236 ep_38C1600->serial_number_word1 =
18237 adv_dvc_varp->cfg->serial1;
18238 ep_38C1600->serial_number_word2 =
18239 adv_dvc_varp->cfg->serial2;
18240 ep_38C1600->serial_number_word3 =
18241 adv_dvc_varp->cfg->serial3;
18242 }
18243
18244 /*
18245 * Set the adapter's target id bit in the 'init_tidmask' field.
18246 */
18247 boardp->init_tidmask |=
18248 ADV_TID_TO_TIDMASK(adv_dvc_varp->chip_scsi_id);
18249
18250 /*
18251 * Finish initializing the 'Scsi_Host' structure.
18252 */
18253 shost->irq = adv_dvc_varp->irq_no;
18254 }
18255
18256 /*
18257 * Channels are numbered beginning with 0. For AdvanSys one host
18258 * structure supports one channel. Multi-channel boards have a
18259 * separate host structure for each channel.
18260 */
18261 shost->max_channel = 0;
18262 if (ASC_NARROW_BOARD(boardp)) {
18263 shost->max_id = ASC_MAX_TID + 1;
18264 shost->max_lun = ASC_MAX_LUN + 1;
18265
18266 shost->io_port = asc_dvc_varp->iop_base;
18267 boardp->asc_n_io_port = ASC_IOADR_GAP;
18268 shost->this_id = asc_dvc_varp->cfg->chip_scsi_id;
18269
18270 /* Set maximum number of queues the adapter can handle. */
18271 shost->can_queue = asc_dvc_varp->max_total_qng;
18272 } else {
18273 shost->max_id = ADV_MAX_TID + 1;
18274 shost->max_lun = ADV_MAX_LUN + 1;
18275
18276 /*
18277 * Save the I/O Port address and length even though
18278 * I/O ports are not used to access Wide boards.
18279 * Instead the Wide boards are accessed with
18280 * PCI Memory Mapped I/O.
18281 */
18282 shost->io_port = iop;
18283 boardp->asc_n_io_port = iolen;
18284
18285 shost->this_id = adv_dvc_varp->chip_scsi_id;
18286
18287 /* Set maximum number of queues the adapter can handle. */
18288 shost->can_queue = adv_dvc_varp->max_host_qng;
18289 }
18290
18291 /*
18292 * 'n_io_port' currently is one byte.
18293 *
18294 * Set a value to 'n_io_port', but never referenced it because
18295 * it may be truncated.
18296 */
18297 shost->n_io_port = boardp->asc_n_io_port <= 255 ?
18298 boardp->asc_n_io_port : 255;
18299
18300 /*
18301 * Following v1.3.89, 'cmd_per_lun' is no longer needed
18302 * and should be set to zero.
18303 *
18304 * But because of a bug introduced in v1.3.89 if the driver is
18305 * compiled as a module and 'cmd_per_lun' is zero, the Mid-Level
18306 * SCSI function 'allocate_device' will panic. To allow the driver
18307 * to work as a module in these kernels set 'cmd_per_lun' to 1.
18308 *
18309 * Note: This is wrong. cmd_per_lun should be set to the depth
18310 * you want on untagged devices always.
18311 #ifdef MODULE
18312 */
18313 shost->cmd_per_lun = 1;
18314/* #else
18315 shost->cmd_per_lun = 0;
18316#endif */
18317
18318 /*
18319 * Set the maximum number of scatter-gather elements the
18320 * adapter can handle.
18321 */
18322 if (ASC_NARROW_BOARD(boardp)) {
18323 /*
18324 * Allow two commands with 'sg_tablesize' scatter-gather
18325 * elements to be executed simultaneously. This value is
18326 * the theoretical hardware limit. It may be decreased
18327 * below.
18328 */
18329 shost->sg_tablesize =
18330 (((asc_dvc_varp->max_total_qng - 2) / 2) *
18331 ASC_SG_LIST_PER_Q) + 1;
18332 } else {
18333 shost->sg_tablesize = ADV_MAX_SG_LIST;
18334 }
18335
18336 /*
18337 * The value of 'sg_tablesize' can not exceed the SCSI
18338 * mid-level driver definition of SG_ALL. SG_ALL also
18339 * must not be exceeded, because it is used to define the
18340 * size of the scatter-gather table in 'struct asc_sg_head'.
18341 */
18342 if (shost->sg_tablesize > SG_ALL) {
18343 shost->sg_tablesize = SG_ALL;
18344 }
18345
18346 ASC_DBG1(1, "advansys_board_found: sg_tablesize: %d\n", shost->sg_tablesize);
18347
18348 /* BIOS start address. */
18349 if (ASC_NARROW_BOARD(boardp)) {
18350 shost->base = ((ulong)
18351 AscGetChipBiosAddress(asc_dvc_varp->
18352 iop_base,
18353 asc_dvc_varp->bus_type));
18354 } else {
18355 /*
18356 * Fill-in BIOS board variables. The Wide BIOS saves
18357 * information in LRAM that is used by the driver.
18358 */
18359 AdvReadWordLram(adv_dvc_varp->iop_base,
18360 BIOS_SIGNATURE, boardp->bios_signature);
18361 AdvReadWordLram(adv_dvc_varp->iop_base,
18362 BIOS_VERSION, boardp->bios_version);
18363 AdvReadWordLram(adv_dvc_varp->iop_base,
18364 BIOS_CODESEG, boardp->bios_codeseg);
18365 AdvReadWordLram(adv_dvc_varp->iop_base,
18366 BIOS_CODELEN, boardp->bios_codelen);
18367
18368 ASC_DBG2(1,
18369 "advansys_board_found: bios_signature 0x%x, bios_version 0x%x\n",
18370 boardp->bios_signature, boardp->bios_version);
18371
18372 ASC_DBG2(1,
18373 "advansys_board_found: bios_codeseg 0x%x, bios_codelen 0x%x\n",
18374 boardp->bios_codeseg, boardp->bios_codelen);
18375
18376 /*
18377 * If the BIOS saved a valid signature, then fill in
18378 * the BIOS code segment base address.
18379 */
18380 if (boardp->bios_signature == 0x55AA) {
18381 /*
18382 * Convert x86 realmode code segment to a linear
18383 * address by shifting left 4.
18384 */
18385 shost->base = ((ulong)boardp->bios_codeseg << 4);
18386 } else {
18387 shost->base = 0;
18388 }
18389 }
18390
18391 /*
18392 * Register Board Resources - I/O Port, DMA, IRQ
18393 */
18394
18395 /*
18396 * Register I/O port range.
18397 *
18398 * For Wide boards the I/O ports are not used to access
18399 * the board, but request the region anyway.
18400 *
18401 * 'shost->n_io_port' is not referenced, because it may be truncated.
18402 */
18403 ASC_DBG2(2,
18404 "advansys_board_found: request_region port 0x%lx, len 0x%x\n",
18405 (ulong)shost->io_port, boardp->asc_n_io_port);
18406 if (request_region(shost->io_port, boardp->asc_n_io_port,
18407 "advansys") == NULL) {
18408 ASC_PRINT3
18409 ("advansys_board_found: board %d: request_region() failed, port 0x%lx, len 0x%x\n",
18410 boardp->id, (ulong)shost->io_port, boardp->asc_n_io_port);
18411#ifdef CONFIG_PROC_FS
18412 kfree(boardp->prtbuf);
18413#endif /* CONFIG_PROC_FS */
18414 scsi_unregister(shost);
18415 asc_board_count--;
18416 return NULL;
18417 }
18418
18419 /* Register DMA Channel for Narrow boards. */
18420 shost->dma_channel = NO_ISA_DMA; /* Default to no ISA DMA. */
18421#ifdef CONFIG_ISA
18422 if (ASC_NARROW_BOARD(boardp)) {
18423 /* Register DMA channel for ISA bus. */
18424 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
18425 shost->dma_channel = asc_dvc_varp->cfg->isa_dma_channel;
18426 if ((ret =
18427 request_dma(shost->dma_channel, "advansys")) != 0) {
18428 ASC_PRINT3
18429 ("advansys_board_found: board %d: request_dma() %d failed %d\n",
18430 boardp->id, shost->dma_channel, ret);
18431 release_region(shost->io_port,
18432 boardp->asc_n_io_port);
18433#ifdef CONFIG_PROC_FS
18434 kfree(boardp->prtbuf);
18435#endif /* CONFIG_PROC_FS */
18436 scsi_unregister(shost);
18437 asc_board_count--;
18438 return NULL;
18439 }
18440 AscEnableIsaDma(shost->dma_channel);
18441 }
18442 }
18443#endif /* CONFIG_ISA */
18444
18445 /* Register IRQ Number. */
18446 ASC_DBG1(2, "advansys_board_found: request_irq() %d\n", shost->irq);
18447 /*
18448 * If request_irq() fails with the IRQF_DISABLED flag set,
18449 * then try again without the IRQF_DISABLED flag set. This
18450 * allows IRQ sharing to work even with other drivers that
18451 * do not set the IRQF_DISABLED flag.
18452 *
18453 * If IRQF_DISABLED is not set, then interrupts are enabled
18454 * before the driver interrupt function is called.
18455 */
18456 if (((ret = request_irq(shost->irq, advansys_interrupt,
18457 IRQF_DISABLED | (share_irq ==
18458 TRUE ?
18459 IRQF_SHARED :
18460 0), "advansys", boardp)) != 0)
18461 &&
18462 ((ret =
18463 request_irq(shost->irq, advansys_interrupt,
18464 (share_irq == TRUE ? IRQF_SHARED : 0),
18465 "advansys", boardp)) != 0)) {
18466 if (ret == -EBUSY) {
18467 ASC_PRINT2
18468 ("advansys_board_found: board %d: request_irq(): IRQ 0x%x already in use.\n",
18469 boardp->id, shost->irq);
18470 } else if (ret == -EINVAL) {
18471 ASC_PRINT2
18472 ("advansys_board_found: board %d: request_irq(): IRQ 0x%x not valid.\n",
18473 boardp->id, shost->irq);
18474 } else {
18475 ASC_PRINT3
18476 ("advansys_board_found: board %d: request_irq(): IRQ 0x%x failed with %d\n",
18477 boardp->id, shost->irq, ret);
18478 }
18479 release_region(shost->io_port, boardp->asc_n_io_port);
18480 iounmap(boardp->ioremap_addr);
18481 if (shost->dma_channel != NO_ISA_DMA) {
18482 free_dma(shost->dma_channel);
18483 }
18484#ifdef CONFIG_PROC_FS
18485 kfree(boardp->prtbuf);
18486#endif /* CONFIG_PROC_FS */
18487 scsi_unregister(shost);
18488 asc_board_count--;
18489 return NULL;
18490 }
18491
18492 /*
18493 * Initialize board RISC chip and enable interrupts.
18494 */
18495 if (ASC_NARROW_BOARD(boardp)) {
18496 ASC_DBG(2, "advansys_board_found: AscInitAsc1000Driver()\n");
18497 warn_code = AscInitAsc1000Driver(asc_dvc_varp);
18498 err_code = asc_dvc_varp->err_code;
18499
18500 if (warn_code || err_code) {
18501 ASC_PRINT4
18502 ("advansys_board_found: board %d error: init_state 0x%x, warn 0x%x, error 0x%x\n",
18503 boardp->id,
18504 asc_dvc_varp->init_state, warn_code, err_code);
18505 }
18506 } else {
18507 ADV_CARR_T *carrp;
18508 int req_cnt = 0;
18509 adv_req_t *reqp = NULL;
18510 int sg_cnt = 0;
18511
18512 /*
18513 * Allocate buffer carrier structures. The total size
18514 * is about 4 KB, so allocate all at once.
18515 */
18516 carrp = (ADV_CARR_T *) kmalloc(ADV_CARRIER_BUFSIZE, GFP_ATOMIC);
18517 ASC_DBG1(1, "advansys_board_found: carrp 0x%lx\n", (ulong)carrp);
18518
18519 if (carrp == NULL) {
18520 goto kmalloc_error;
18521 }
18522
18523 /*
18524 * Allocate up to 'max_host_qng' request structures for
18525 * the Wide board. The total size is about 16 KB, so
18526 * allocate all at once. If the allocation fails decrement
18527 * and try again.
18528 */
18529 for (req_cnt = adv_dvc_varp->max_host_qng;
18530 req_cnt > 0; req_cnt--) {
18531
18532 reqp = (adv_req_t *)
18533 kmalloc(sizeof(adv_req_t) * req_cnt, GFP_ATOMIC);
18534
18535 ASC_DBG3(1,
18536 "advansys_board_found: reqp 0x%lx, req_cnt %d, bytes %lu\n",
18537 (ulong)reqp, req_cnt,
18538 (ulong)sizeof(adv_req_t) * req_cnt);
18539
18540 if (reqp != NULL) {
18541 break;
18542 }
18543 }
18544 if (reqp == NULL) {
18545 goto kmalloc_error;
18546 }
18547
18548 /*
18549 * Allocate up to ADV_TOT_SG_BLOCK request structures for
18550 * the Wide board. Each structure is about 136 bytes.
18551 */
18552 boardp->adv_sgblkp = NULL;
18553 for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
18554
18555 sgp = (adv_sgblk_t *)
18556 kmalloc(sizeof(adv_sgblk_t), GFP_ATOMIC);
18557
18558 if (sgp == NULL) {
18559 break;
18560 }
18561
18562 sgp->next_sgblkp = boardp->adv_sgblkp;
18563 boardp->adv_sgblkp = sgp;
18564
18565 }
18566 ASC_DBG3(1,
18567 "advansys_board_found: sg_cnt %d * %u = %u bytes\n",
18568 sg_cnt, sizeof(adv_sgblk_t),
18569 (unsigned)(sizeof(adv_sgblk_t) * sg_cnt));
18570
18571 /*
18572 * If no request structures or scatter-gather structures could
18573 * be allocated, then return an error. Otherwise continue with
18574 * initialization.
18575 */
18576 kmalloc_error:
18577 if (carrp == NULL) {
18578 ASC_PRINT1
18579 ("advansys_board_found: board %d error: failed to kmalloc() carrier buffer.\n",
18580 boardp->id);
18581 err_code = ADV_ERROR;
18582 } else if (reqp == NULL) {
18583 kfree(carrp);
18584 ASC_PRINT1
18585 ("advansys_board_found: board %d error: failed to kmalloc() adv_req_t buffer.\n",
18586 boardp->id);
18587 err_code = ADV_ERROR;
18588 } else if (boardp->adv_sgblkp == NULL) {
18589 kfree(carrp);
18590 kfree(reqp);
18591 ASC_PRINT1
18592 ("advansys_board_found: board %d error: failed to kmalloc() adv_sgblk_t buffers.\n",
18593 boardp->id);
18594 err_code = ADV_ERROR;
18595 } else {
18596
18597 /* Save carrier buffer pointer. */
18598 boardp->orig_carrp = carrp;
18599
18600 /*
18601 * Save original pointer for kfree() in case the
18602 * driver is built as a module and can be unloaded.
18603 */
18604 boardp->orig_reqp = reqp;
18605
18606 adv_dvc_varp->carrier_buf = carrp;
18607
18608 /*
18609 * Point 'adv_reqp' to the request structures and
18610 * link them together.
18611 */
18612 req_cnt--;
18613 reqp[req_cnt].next_reqp = NULL;
18614 for (; req_cnt > 0; req_cnt--) {
18615 reqp[req_cnt - 1].next_reqp = &reqp[req_cnt];
18616 }
18617 boardp->adv_reqp = &reqp[0];
18618
18619 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
18620 ASC_DBG(2,
18621 "advansys_board_found: AdvInitAsc3550Driver()\n");
18622 warn_code = AdvInitAsc3550Driver(adv_dvc_varp);
18623 } else if (adv_dvc_varp->chip_type ==
18624 ADV_CHIP_ASC38C0800) {
18625 ASC_DBG(2,
18626 "advansys_board_found: AdvInitAsc38C0800Driver()\n");
18627 warn_code =
18628 AdvInitAsc38C0800Driver(adv_dvc_varp);
18629 } else {
18630 ASC_DBG(2,
18631 "advansys_board_found: AdvInitAsc38C1600Driver()\n");
18632 warn_code =
18633 AdvInitAsc38C1600Driver(adv_dvc_varp);
18634 }
18635 err_code = adv_dvc_varp->err_code;
18636
18637 if (warn_code || err_code) {
18638 ASC_PRINT3
18639 ("advansys_board_found: board %d error: warn 0x%x, error 0x%x\n",
18640 boardp->id, warn_code, err_code);
18641 }
18642 }
18643 }
18644
18645 if (err_code != 0) {
18646 release_region(shost->io_port, boardp->asc_n_io_port);
18647 if (ASC_WIDE_BOARD(boardp)) {
18648 iounmap(boardp->ioremap_addr);
18649 kfree(boardp->orig_carrp);
18650 boardp->orig_carrp = NULL;
18651 if (boardp->orig_reqp) {
18652 kfree(boardp->orig_reqp);
18653 boardp->orig_reqp = boardp->adv_reqp = NULL;
18654 }
18655 while ((sgp = boardp->adv_sgblkp) != NULL) {
18656 boardp->adv_sgblkp = sgp->next_sgblkp;
18657 kfree(sgp);
18658 }
18659 }
18660 if (shost->dma_channel != NO_ISA_DMA) {
18661 free_dma(shost->dma_channel);
18662 }
18663#ifdef CONFIG_PROC_FS
18664 kfree(boardp->prtbuf);
18665#endif /* CONFIG_PROC_FS */
18666 free_irq(shost->irq, boardp);
18667 scsi_unregister(shost);
18668 asc_board_count--;
18669 return NULL;
18670 }
18671 ASC_DBG_PRT_SCSI_HOST(2, shost);
18672
18673 return shost;
18674}
18675
18676/*
18677 * advansys_detect()
18678 *
18679 * Detect function for AdvanSys adapters.
18680 *
18681 * Argument is a pointer to the host driver's scsi_hosts entry.
18682 *
18683 * Return number of adapters found.
18684 *
18685 * Note: Because this function is called during system initialization
18686 * it must not call SCSI mid-level functions including scsi_malloc()
18687 * and scsi_free().
18688 */
18689static int __init advansys_detect(struct scsi_host_template *tpnt)
18690{
18691 static int detect_called = ASC_FALSE;
18692 int iop;
18693 int bus;
18694 int ioport = 0;
18695 struct device *dev = NULL;
18696#ifdef CONFIG_PCI
18697 int pci_init_search = 0;
18698 struct pci_dev *pci_devicep[ASC_NUM_BOARD_SUPPORTED];
18699 int pci_card_cnt_max = 0;
18700 int pci_card_cnt = 0;
18701 struct pci_dev *pdev = NULL;
18702 int pci_device_id_cnt = 0;
18703 unsigned int pci_device_id[ASC_PCI_DEVICE_ID_CNT] = {
18704 PCI_DEVICE_ID_ASP_1200A,
18705 PCI_DEVICE_ID_ASP_ABP940,
18706 PCI_DEVICE_ID_ASP_ABP940U,
18707 PCI_DEVICE_ID_ASP_ABP940UW,
18708 PCI_DEVICE_ID_38C0800_REV1,
18709 PCI_DEVICE_ID_38C1600_REV1
18710 };
18711#endif /* CONFIG_PCI */
18712
18713 if (detect_called == ASC_FALSE) {
18714 detect_called = ASC_TRUE;
18715 } else {
18716 printk
18717 ("AdvanSys SCSI: advansys_detect() multiple calls ignored\n");
18718 return 0;
18719 }
18720
18721 ASC_DBG(1, "advansys_detect: begin\n");
18722
18723 asc_board_count = 0;
18724
18725 /*
18726 * If I/O port probing has been modified, then verify and
18727 * clean-up the 'asc_ioport' list.
18728 */
18729 if (asc_iopflag == ASC_TRUE) {
18730 for (ioport = 0; ioport < ASC_NUM_IOPORT_PROBE; ioport++) {
18731 ASC_DBG2(1, "advansys_detect: asc_ioport[%d] 0x%x\n",
18732 ioport, asc_ioport[ioport]);
18733 if (asc_ioport[ioport] != 0) {
18734 for (iop = 0; iop < ASC_IOADR_TABLE_MAX_IX;
18735 iop++) {
18736 if (_asc_def_iop_base[iop] ==
18737 asc_ioport[ioport]) {
18738 break;
18739 }
18740 }
18741 if (iop == ASC_IOADR_TABLE_MAX_IX) {
18742 printk
18743 ("AdvanSys SCSI: specified I/O Port 0x%X is invalid\n",
18744 asc_ioport[ioport]);
18745 asc_ioport[ioport] = 0;
18746 }
18747 }
18748 }
18749 ioport = 0;
18750 }
18751
18752 for (bus = 0; bus < ASC_NUM_BUS; bus++) {
18753
18754 ASC_DBG2(1, "advansys_detect: bus search type %d (%s)\n",
18755 bus, asc_bus_name[bus]);
18756 iop = 0;
18757
18758 while (asc_board_count < ASC_NUM_BOARD_SUPPORTED) {
18759
18760 ASC_DBG1(2, "advansys_detect: asc_board_count %d\n",
18761 asc_board_count);
18762
18763 switch (asc_bus[bus]) {
18764 case ASC_IS_ISA:
18765 case ASC_IS_VL:
18766#ifdef CONFIG_ISA
18767 if (asc_iopflag == ASC_FALSE) {
18768 iop =
18769 AscSearchIOPortAddr(iop,
18770 asc_bus[bus]);
18771 } else {
18772 /*
18773 * ISA and VL I/O port scanning has either been
18774 * eliminated or limited to selected ports on
18775 * the LILO command line, /etc/lilo.conf, or
18776 * by setting variables when the module was loaded.
18777 */
18778 ASC_DBG(1,
18779 "advansys_detect: I/O port scanning modified\n");
18780 ioport_try_again:
18781 iop = 0;
18782 for (; ioport < ASC_NUM_IOPORT_PROBE;
18783 ioport++) {
18784 if ((iop =
18785 asc_ioport[ioport]) != 0) {
18786 break;
18787 }
18788 }
18789 if (iop) {
18790 ASC_DBG1(1,
18791 "advansys_detect: probing I/O port 0x%x...\n",
18792 iop);
18793 if (!request_region
18794 (iop, ASC_IOADR_GAP,
18795 "advansys")) {
18796 printk
18797 ("AdvanSys SCSI: specified I/O Port 0x%X is busy\n",
18798 iop);
18799 /* Don't try this I/O port twice. */
18800 asc_ioport[ioport] = 0;
18801 goto ioport_try_again;
18802 } else if (AscFindSignature(iop)
18803 == ASC_FALSE) {
18804 printk
18805 ("AdvanSys SCSI: specified I/O Port 0x%X has no adapter\n",
18806 iop);
18807 /* Don't try this I/O port twice. */
18808 release_region(iop,
18809 ASC_IOADR_GAP);
18810 asc_ioport[ioport] = 0;
18811 goto ioport_try_again;
18812 } else {
18813 /*
18814 * If this isn't an ISA board, then it must be
18815 * a VL board. If currently looking an ISA
18816 * board is being looked for then try for
18817 * another ISA board in 'asc_ioport'.
18818 */
18819 if (asc_bus[bus] ==
18820 ASC_IS_ISA
18821 &&
18822 (AscGetChipVersion
18823 (iop,
18824 ASC_IS_ISA) &
18825 ASC_CHIP_VER_ISA_BIT)
18826 == 0) {
18827 /*
18828 * Don't clear 'asc_ioport[ioport]'. Try
18829 * this board again for VL. Increment
18830 * 'ioport' past this board.
18831 */
18832 ioport++;
18833 release_region
18834 (iop,
18835 ASC_IOADR_GAP);
18836 goto ioport_try_again;
18837 }
18838 }
18839 /*
18840 * This board appears good, don't try the I/O port
18841 * again by clearing its value. Increment 'ioport'
18842 * for the next iteration.
18843 */
18844 asc_ioport[ioport++] = 0;
18845 }
18846 }
18847#endif /* CONFIG_ISA */
18848 break;
18849
18850 case ASC_IS_EISA:
18851#ifdef CONFIG_ISA
18852 iop = AscSearchIOPortAddr(iop, asc_bus[bus]);
18853#endif /* CONFIG_ISA */
18854 break;
18855
18856 case ASC_IS_PCI:
18857#ifdef CONFIG_PCI
18858 if (pci_init_search == 0) {
18859 int i, j;
18860
18861 pci_init_search = 1;
18862
18863 /* Find all PCI cards. */
18864 while (pci_device_id_cnt <
18865 ASC_PCI_DEVICE_ID_CNT) {
18866 if ((pdev =
18867 pci_find_device
18868 (PCI_VENDOR_ID_ASP,
18869 pci_device_id
18870 [pci_device_id_cnt],
18871 pdev)) == NULL) {
18872 pci_device_id_cnt++;
18873 } else {
18874 if (pci_enable_device
18875 (pdev) == 0) {
18876 pci_devicep
18877 [pci_card_cnt_max++]
18878 = pdev;
18879 }
18880 }
18881 }
18882
18883 /*
18884 * Sort PCI cards in ascending order by PCI Bus, Slot,
18885 * and Device Number.
18886 */
18887 for (i = 0; i < pci_card_cnt_max - 1;
18888 i++) {
18889 for (j = i + 1;
18890 j < pci_card_cnt_max;
18891 j++) {
18892 if ((pci_devicep[j]->
18893 bus->number <
18894 pci_devicep[i]->
18895 bus->number)
18896 ||
18897 ((pci_devicep[j]->
18898 bus->number ==
18899 pci_devicep[i]->
18900 bus->number)
18901 &&
18902 (pci_devicep[j]->
18903 devfn <
18904 pci_devicep[i]->
18905 devfn))) {
18906 pdev =
18907 pci_devicep
18908 [i];
18909 pci_devicep[i] =
18910 pci_devicep
18911 [j];
18912 pci_devicep[j] =
18913 pdev;
18914 }
18915 }
18916 }
18917
18918 pci_card_cnt = 0;
18919 } else {
18920 pci_card_cnt++;
18921 }
18922
18923 if (pci_card_cnt == pci_card_cnt_max) {
18924 iop = 0;
18925 } else {
18926 pdev = pci_devicep[pci_card_cnt];
18927
18928 ASC_DBG2(2,
18929 "advansys_detect: devfn %d, bus number %d\n",
18930 pdev->devfn,
18931 pdev->bus->number);
18932 iop = pci_resource_start(pdev, 0);
18933 ASC_DBG2(1,
18934 "advansys_detect: vendorID %X, deviceID %X\n",
18935 pdev->vendor,
18936 pdev->device);
18937 ASC_DBG2(2,
18938 "advansys_detect: iop %X, irqLine %d\n",
18939 iop, pdev->irq);
18940 }
18941 if (pdev)
18942 dev = &pdev->dev;
18943
18944#endif /* CONFIG_PCI */
18945 break;
18946
18947 default:
18948 ASC_PRINT1
18949 ("advansys_detect: unknown bus type: %d\n",
18950 asc_bus[bus]);
18951 break;
18952 }
18953 ASC_DBG1(1, "advansys_detect: iop 0x%x\n", iop);
18954
18955 /*
18956 * Adapter not found, try next bus type.
18957 */
18958 if (iop == 0) {
18959 break;
18960 }
18961
18962 advansys_board_found(iop, dev, asc_bus[bus]);
18963 }
18964 }
18965
18966 ASC_DBG1(1, "advansys_detect: done: asc_board_count %d\n",
18967 asc_board_count);
18968 return asc_board_count;
18969}
18970
18971/*
18972 * advansys_release()
18973 *
18974 * Release resources allocated for a single AdvanSys adapter.
18975 */
18976static int advansys_release(struct Scsi_Host *shost)
18977{
18978 asc_board_t *boardp;
18979
18980 ASC_DBG(1, "advansys_release: begin\n");
18981 boardp = ASC_BOARDP(shost);
18982 free_irq(shost->irq, boardp);
18983 if (shost->dma_channel != NO_ISA_DMA) {
18984 ASC_DBG(1, "advansys_release: free_dma()\n");
18985 free_dma(shost->dma_channel);
18986 }
18987 release_region(shost->io_port, boardp->asc_n_io_port);
18988 if (ASC_WIDE_BOARD(boardp)) {
18989 adv_sgblk_t *sgp = NULL;
18990
18991 iounmap(boardp->ioremap_addr);
18992 kfree(boardp->orig_carrp);
18993 boardp->orig_carrp = NULL;
18994 if (boardp->orig_reqp) {
18995 kfree(boardp->orig_reqp);
18996 boardp->orig_reqp = boardp->adv_reqp = NULL;
18997 }
18998 while ((sgp = boardp->adv_sgblkp) != NULL) {
18999 boardp->adv_sgblkp = sgp->next_sgblkp;
19000 kfree(sgp);
19001 }
19002 }
19003#ifdef CONFIG_PROC_FS
19004 ASC_ASSERT(boardp->prtbuf != NULL);
19005 kfree(boardp->prtbuf);
19006#endif /* CONFIG_PROC_FS */
19007 scsi_unregister(shost);
19008 ASC_DBG(1, "advansys_release: end\n");
19009 return 0;
19010}
19011
18136#ifdef CONFIG_PCI 19012#ifdef CONFIG_PCI
18137/* PCI Devices supported by this driver */ 19013/* PCI Devices supported by this driver */
18138static struct pci_device_id advansys_pci_tbl[] __devinitdata = { 19014static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
18139 { PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A, 19015 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_1200A,
18140 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 19016 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18141 { PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940, 19017 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940,
18142 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 19018 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18143 { PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U, 19019 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940U,
18144 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 19020 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18145 { PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW, 19021 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_ASP_ABP940UW,
18146 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 19022 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18147 { PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1, 19023 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C0800_REV1,
18148 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 19024 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18149 { PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1, 19025 {PCI_VENDOR_ID_ASP, PCI_DEVICE_ID_38C1600_REV1,
18150 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 19026 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
18151 { } 19027 {}
18152}; 19028};
19029
18153MODULE_DEVICE_TABLE(pci, advansys_pci_tbl); 19030MODULE_DEVICE_TABLE(pci, advansys_pci_tbl);
18154#endif /* CONFIG_PCI */ 19031#endif /* CONFIG_PCI */
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 286ab83116f9..a055a96e3ad3 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -2284,9 +2284,12 @@ static void ahd_linux_set_period(struct scsi_target *starget, int period)
2284 if (period < 8) 2284 if (period < 8)
2285 period = 8; 2285 period = 8;
2286 if (period < 10) { 2286 if (period < 10) {
2287 ppr_options |= MSG_EXT_PPR_DT_REQ; 2287 if (spi_max_width(starget)) {
2288 if (period == 8) 2288 ppr_options |= MSG_EXT_PPR_DT_REQ;
2289 ppr_options |= MSG_EXT_PPR_IU_REQ; 2289 if (period == 8)
2290 ppr_options |= MSG_EXT_PPR_IU_REQ;
2291 } else
2292 period = 10;
2290 } 2293 }
2291 2294
2292 dt = ppr_options & MSG_EXT_PPR_DT_REQ; 2295 dt = ppr_options & MSG_EXT_PPR_DT_REQ;
@@ -2365,7 +2368,7 @@ static void ahd_linux_set_dt(struct scsi_target *starget, int dt)
2365 printf("%s: %s DT\n", ahd_name(ahd), 2368 printf("%s: %s DT\n", ahd_name(ahd),
2366 dt ? "enabling" : "disabling"); 2369 dt ? "enabling" : "disabling");
2367#endif 2370#endif
2368 if (dt) { 2371 if (dt && spi_max_width(starget)) {
2369 ppr_options |= MSG_EXT_PPR_DT_REQ; 2372 ppr_options |= MSG_EXT_PPR_DT_REQ;
2370 if (!width) 2373 if (!width)
2371 ahd_linux_set_width(starget, 1); 2374 ahd_linux_set_width(starget, 1);
@@ -2447,7 +2450,7 @@ static void ahd_linux_set_iu(struct scsi_target *starget, int iu)
2447 iu ? "enabling" : "disabling"); 2450 iu ? "enabling" : "disabling");
2448#endif 2451#endif
2449 2452
2450 if (iu) { 2453 if (iu && spi_max_width(starget)) {
2451 ppr_options |= MSG_EXT_PPR_IU_REQ; 2454 ppr_options |= MSG_EXT_PPR_IU_REQ;
2452 ppr_options |= MSG_EXT_PPR_DT_REQ; /* IU requires DT */ 2455 ppr_options |= MSG_EXT_PPR_DT_REQ; /* IU requires DT */
2453 } 2456 }
@@ -2487,7 +2490,7 @@ static void ahd_linux_set_rd_strm(struct scsi_target *starget, int rdstrm)
2487 rdstrm ? "enabling" : "disabling"); 2490 rdstrm ? "enabling" : "disabling");
2488#endif 2491#endif
2489 2492
2490 if (rdstrm) 2493 if (rdstrm && spi_max_width(starget))
2491 ppr_options |= MSG_EXT_PPR_RD_STRM; 2494 ppr_options |= MSG_EXT_PPR_RD_STRM;
2492 2495
2493 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2496 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
@@ -2523,7 +2526,7 @@ static void ahd_linux_set_wr_flow(struct scsi_target *starget, int wrflow)
2523 wrflow ? "enabling" : "disabling"); 2526 wrflow ? "enabling" : "disabling");
2524#endif 2527#endif
2525 2528
2526 if (wrflow) 2529 if (wrflow && spi_max_width(starget))
2527 ppr_options |= MSG_EXT_PPR_WR_FLOW; 2530 ppr_options |= MSG_EXT_PPR_WR_FLOW;
2528 2531
2529 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2532 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
@@ -2567,7 +2570,7 @@ static void ahd_linux_set_rti(struct scsi_target *starget, int rti)
2567 rti ? "enabling" : "disabling"); 2570 rti ? "enabling" : "disabling");
2568#endif 2571#endif
2569 2572
2570 if (rti) 2573 if (rti && spi_max_width(starget))
2571 ppr_options |= MSG_EXT_PPR_RTI; 2574 ppr_options |= MSG_EXT_PPR_RTI;
2572 2575
2573 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2576 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
@@ -2603,7 +2606,7 @@ static void ahd_linux_set_pcomp_en(struct scsi_target *starget, int pcomp)
2603 pcomp ? "Enable" : "Disable"); 2606 pcomp ? "Enable" : "Disable");
2604#endif 2607#endif
2605 2608
2606 if (pcomp) { 2609 if (pcomp && spi_max_width(starget)) {
2607 uint8_t precomp; 2610 uint8_t precomp;
2608 2611
2609 if (ahd->unit < ARRAY_SIZE(aic79xx_iocell_info)) { 2612 if (ahd->unit < ARRAY_SIZE(aic79xx_iocell_info)) {
@@ -2647,7 +2650,7 @@ static void ahd_linux_set_hold_mcs(struct scsi_target *starget, int hold)
2647 unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ; 2650 unsigned int dt = ppr_options & MSG_EXT_PPR_DT_REQ;
2648 unsigned long flags; 2651 unsigned long flags;
2649 2652
2650 if (hold) 2653 if (hold && spi_max_width(starget))
2651 ppr_options |= MSG_EXT_PPR_HOLD_MCS; 2654 ppr_options |= MSG_EXT_PPR_HOLD_MCS;
2652 2655
2653 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2656 ahd_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 1803ab6fc21c..2e9c38f2e8a6 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -2317,8 +2317,13 @@ static void ahc_linux_set_period(struct scsi_target *starget, int period)
2317 2317
2318 if (period < 9) 2318 if (period < 9)
2319 period = 9; /* 12.5ns is our minimum */ 2319 period = 9; /* 12.5ns is our minimum */
2320 if (period == 9) 2320 if (period == 9) {
2321 ppr_options |= MSG_EXT_PPR_DT_REQ; 2321 if (spi_max_width(starget))
2322 ppr_options |= MSG_EXT_PPR_DT_REQ;
2323 else
2324 /* need wide for DT and need DT for 12.5 ns */
2325 period = 10;
2326 }
2322 2327
2323 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0, 2328 ahc_compile_devinfo(&devinfo, shost->this_id, starget->id, 0,
2324 starget->channel + 'A', ROLE_INITIATOR); 2329 starget->channel + 'A', ROLE_INITIATOR);
@@ -2381,7 +2386,7 @@ static void ahc_linux_set_dt(struct scsi_target *starget, int dt)
2381 unsigned long flags; 2386 unsigned long flags;
2382 struct ahc_syncrate *syncrate; 2387 struct ahc_syncrate *syncrate;
2383 2388
2384 if (dt) { 2389 if (dt && spi_max_width(starget)) {
2385 ppr_options |= MSG_EXT_PPR_DT_REQ; 2390 ppr_options |= MSG_EXT_PPR_DT_REQ;
2386 if (!width) 2391 if (!width)
2387 ahc_linux_set_width(starget, 1); 2392 ahc_linux_set_width(starget, 1);
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index ab00aecc5466..63bcde246447 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -586,7 +586,7 @@ static int __devinit asd_pci_probe(struct pci_dev *dev,
586 goto Err; 586 goto Err;
587 } 587 }
588 asd_ha->pcidev = dev; 588 asd_ha->pcidev = dev;
589 asd_ha->sas_ha.pcidev = asd_ha->pcidev; 589 asd_ha->sas_ha.dev = &asd_ha->pcidev->dev;
590 asd_ha->sas_ha.lldd_ha = asd_ha; 590 asd_ha->sas_ha.lldd_ha = asd_ha;
591 591
592 asd_ha->name = asd_dev->name; 592 asd_ha->name = asd_dev->name;
@@ -605,8 +605,6 @@ static int __devinit asd_pci_probe(struct pci_dev *dev,
605 goto Err_free; 605 goto Err_free;
606 } 606 }
607 607
608
609
610 err = asd_dev->setup(asd_ha); 608 err = asd_dev->setup(asd_ha);
611 if (err) 609 if (err)
612 goto Err_free; 610 goto Err_free;
diff --git a/drivers/scsi/arm/Kconfig b/drivers/scsi/arm/Kconfig
index d006a8cb4a74..7236143941f3 100644
--- a/drivers/scsi/arm/Kconfig
+++ b/drivers/scsi/arm/Kconfig
@@ -74,15 +74,6 @@ config SCSI_CUMANA_1
74 This enables support for the Cumana SCSI I card. If you have an 74 This enables support for the Cumana SCSI I card. If you have an
75 Acorn system with one of these, say Y. If unsure, say N. 75 Acorn system with one of these, say Y. If unsure, say N.
76 76
77config SCSI_ECOSCSI
78 tristate "EcoScsi support (EXPERIMENTAL)"
79 depends on ARCH_ACORN && EXPERIMENTAL && (ARCH_ARC || ARCH_A5K) && SCSI
80 select SCSI_SPI_ATTRS
81 help
82 This enables support for the EcoSCSI card -- a small card that sits
83 in the Econet socket. If you have an Acorn system with one of these,
84 say Y. If unsure, say N.
85
86config SCSI_OAK1 77config SCSI_OAK1
87 tristate "Oak SCSI support (EXPERIMENTAL)" 78 tristate "Oak SCSI support (EXPERIMENTAL)"
88 depends on ARCH_ACORN && EXPERIMENTAL && SCSI 79 depends on ARCH_ACORN && EXPERIMENTAL && SCSI
diff --git a/drivers/scsi/arm/Makefile b/drivers/scsi/arm/Makefile
index e8db17924c1d..16c3e86a6b1b 100644
--- a/drivers/scsi/arm/Makefile
+++ b/drivers/scsi/arm/Makefile
@@ -8,7 +8,6 @@ obj-$(CONFIG_SCSI_ACORNSCSI_3) += acornscsi_mod.o queue.o msgqueue.o
8obj-$(CONFIG_SCSI_ARXESCSI) += arxescsi.o fas216.o queue.o msgqueue.o 8obj-$(CONFIG_SCSI_ARXESCSI) += arxescsi.o fas216.o queue.o msgqueue.o
9obj-$(CONFIG_SCSI_CUMANA_1) += cumana_1.o 9obj-$(CONFIG_SCSI_CUMANA_1) += cumana_1.o
10obj-$(CONFIG_SCSI_CUMANA_2) += cumana_2.o fas216.o queue.o msgqueue.o 10obj-$(CONFIG_SCSI_CUMANA_2) += cumana_2.o fas216.o queue.o msgqueue.o
11obj-$(CONFIG_SCSI_ECOSCSI) += ecoscsi.o
12obj-$(CONFIG_SCSI_OAK1) += oak.o 11obj-$(CONFIG_SCSI_OAK1) += oak.o
13obj-$(CONFIG_SCSI_POWERTECSCSI) += powertec.o fas216.o queue.o msgqueue.o 12obj-$(CONFIG_SCSI_POWERTECSCSI) += powertec.o fas216.o queue.o msgqueue.o
14obj-$(CONFIG_SCSI_EESOXSCSI) += eesox.o fas216.o queue.o msgqueue.o 13obj-$(CONFIG_SCSI_EESOXSCSI) += eesox.o fas216.o queue.o msgqueue.o
diff --git a/drivers/scsi/arm/ecoscsi.c b/drivers/scsi/arm/ecoscsi.c
deleted file mode 100644
index 5265a9884338..000000000000
--- a/drivers/scsi/arm/ecoscsi.c
+++ /dev/null
@@ -1,166 +0,0 @@
1#define AUTOSENSE
2/* #define PSEUDO_DMA */
3
4/*
5 * EcoSCSI Generic NCR5380 driver
6 *
7 * Copyright 1995, Russell King
8 *
9 * ALPHA RELEASE 1.
10 *
11 * For more information, please consult
12 *
13 * NCR 5380 Family
14 * SCSI Protocol Controller
15 * Databook
16 *
17 * NCR Microelectronics
18 * 1635 Aeroplaza Drive
19 * Colorado Springs, CO 80916
20 * 1+ (719) 578-3400
21 * 1+ (800) 334-5454
22 */
23
24#include <linux/module.h>
25#include <linux/signal.h>
26#include <linux/ioport.h>
27#include <linux/delay.h>
28#include <linux/init.h>
29#include <linux/blkdev.h>
30
31#include <asm/io.h>
32#include <asm/system.h>
33
34#include "../scsi.h"
35#include <scsi/scsi_host.h>
36
37#define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
38
39#define NCR5380_local_declare() void __iomem *_base
40#define NCR5380_setup(host) _base = priv(host)->base
41
42#define NCR5380_read(reg) ({ writeb(reg | 8, _base); readb(_base + 4); })
43#define NCR5380_write(reg, value) ({ writeb(reg | 8, _base); writeb(value, _base + 4); })
44
45#define NCR5380_intr ecoscsi_intr
46#define NCR5380_queue_command ecoscsi_queue_command
47#define NCR5380_proc_info ecoscsi_proc_info
48
49#define NCR5380_implementation_fields \
50 void __iomem *base
51
52#include "../NCR5380.h"
53
54#define ECOSCSI_PUBLIC_RELEASE 1
55
56/*
57 * Function : ecoscsi_setup(char *str, int *ints)
58 *
59 * Purpose : LILO command line initialization of the overrides array,
60 *
61 * Inputs : str - unused, ints - array of integer parameters with ints[0]
62 * equal to the number of ints.
63 *
64 */
65
66void ecoscsi_setup(char *str, int *ints)
67{
68}
69
70const char * ecoscsi_info (struct Scsi_Host *spnt)
71{
72 return "";
73}
74
75#define BOARD_NORMAL 0
76#define BOARD_NCR53C400 1
77
78#include "../NCR5380.c"
79
80static struct scsi_host_template ecoscsi_template = {
81 .module = THIS_MODULE,
82 .name = "Serial Port EcoSCSI NCR5380",
83 .proc_name = "ecoscsi",
84 .info = ecoscsi_info,
85 .queuecommand = ecoscsi_queue_command,
86 .eh_abort_handler = NCR5380_abort,
87 .eh_bus_reset_handler = NCR5380_bus_reset,
88 .can_queue = 16,
89 .this_id = 7,
90 .sg_tablesize = SG_ALL,
91 .cmd_per_lun = 2,
92 .use_clustering = DISABLE_CLUSTERING
93};
94
95static struct Scsi_Host *host;
96
97static int __init ecoscsi_init(void)
98{
99 void __iomem *_base;
100 int ret;
101
102 if (!request_mem_region(0x33a0000, 4096, "ecoscsi")) {
103 ret = -EBUSY;
104 goto out;
105 }
106
107 _base = ioremap(0x33a0000, 4096);
108 if (!_base) {
109 ret = -ENOMEM;
110 goto out_release;
111 }
112
113 NCR5380_write(MODE_REG, 0x20); /* Is it really SCSI? */
114 if (NCR5380_read(MODE_REG) != 0x20) /* Write to a reg. */
115 goto out_unmap;
116
117 NCR5380_write(MODE_REG, 0x00); /* it back. */
118 if (NCR5380_read(MODE_REG) != 0x00)
119 goto out_unmap;
120
121 host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata));
122 if (!host) {
123 ret = -ENOMEM;
124 goto out_unmap;
125 }
126
127 priv(host)->base = _base;
128 host->irq = IRQ_NONE;
129
130 NCR5380_init(host, 0);
131
132 printk("scsi%d: at port 0x%08lx irqs disabled", host->host_no, host->io_port);
133 printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
134 host->can_queue, host->cmd_per_lun, ECOSCSI_PUBLIC_RELEASE);
135 printk("\nscsi%d:", host->host_no);
136 NCR5380_print_options(host);
137 printk("\n");
138
139 scsi_add_host(host, NULL); /* XXX handle failure */
140 scsi_scan_host(host);
141 return 0;
142
143 out_unmap:
144 iounmap(_base);
145 out_release:
146 release_mem_region(0x33a0000, 4096);
147 out:
148 return ret;
149}
150
151static void __exit ecoscsi_exit(void)
152{
153 scsi_remove_host(host);
154 NCR5380_exit(host);
155 scsi_host_put(host);
156 release_mem_region(0x33a0000, 4096);
157 return 0;
158}
159
160module_init(ecoscsi_init);
161module_exit(ecoscsi_exit);
162
163MODULE_AUTHOR("Russell King");
164MODULE_DESCRIPTION("Econet-SCSI driver for Acorn machines");
165MODULE_LICENSE("GPL");
166
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 7829ab1e2fb4..a21455d0274c 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -2216,11 +2216,13 @@ static void iscsi_tcp_session_destroy(struct iscsi_cls_session *cls_session)
2216 2216
2217static int iscsi_tcp_slave_configure(struct scsi_device *sdev) 2217static int iscsi_tcp_slave_configure(struct scsi_device *sdev)
2218{ 2218{
2219 blk_queue_bounce_limit(sdev->request_queue, BLK_BOUNCE_ANY);
2219 blk_queue_dma_alignment(sdev->request_queue, 0); 2220 blk_queue_dma_alignment(sdev->request_queue, 0);
2220 return 0; 2221 return 0;
2221} 2222}
2222 2223
2223static struct scsi_host_template iscsi_sht = { 2224static struct scsi_host_template iscsi_sht = {
2225 .module = THIS_MODULE,
2224 .name = "iSCSI Initiator over TCP/IP", 2226 .name = "iSCSI Initiator over TCP/IP",
2225 .queuecommand = iscsi_queuecommand, 2227 .queuecommand = iscsi_queuecommand,
2226 .change_queue_depth = iscsi_change_queue_depth, 2228 .change_queue_depth = iscsi_change_queue_depth,
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 4d85ce100192..5606d1e62978 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -596,9 +596,16 @@ static void iscsi_prep_mtask(struct iscsi_conn *conn,
596 nop->cmdsn = cpu_to_be32(session->cmdsn); 596 nop->cmdsn = cpu_to_be32(session->cmdsn);
597 if (hdr->itt != RESERVED_ITT) { 597 if (hdr->itt != RESERVED_ITT) {
598 hdr->itt = build_itt(mtask->itt, conn->id, session->age); 598 hdr->itt = build_itt(mtask->itt, conn->id, session->age);
599 /*
600 * TODO: We always use immediate, so we never hit this.
601 * If we start to send tmfs or nops as non-immediate then
602 * we should start checking the cmdsn numbers for mgmt tasks.
603 */
599 if (conn->c_stage == ISCSI_CONN_STARTED && 604 if (conn->c_stage == ISCSI_CONN_STARTED &&
600 !(hdr->opcode & ISCSI_OP_IMMEDIATE)) 605 !(hdr->opcode & ISCSI_OP_IMMEDIATE)) {
606 session->queued_cmdsn++;
601 session->cmdsn++; 607 session->cmdsn++;
608 }
602 } 609 }
603 610
604 if (session->tt->init_mgmt_task) 611 if (session->tt->init_mgmt_task)
@@ -641,9 +648,11 @@ static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn)
641 /* 648 /*
642 * Check for iSCSI window and take care of CmdSN wrap-around 649 * Check for iSCSI window and take care of CmdSN wrap-around
643 */ 650 */
644 if (!iscsi_sna_lte(session->cmdsn, session->max_cmdsn)) { 651 if (!iscsi_sna_lte(session->queued_cmdsn, session->max_cmdsn)) {
645 debug_scsi("iSCSI CmdSN closed. MaxCmdSN %u CmdSN %u\n", 652 debug_scsi("iSCSI CmdSN closed. ExpCmdSn %u MaxCmdSN %u "
646 session->max_cmdsn, session->cmdsn); 653 "CmdSN %u/%u\n", session->exp_cmdsn,
654 session->max_cmdsn, session->cmdsn,
655 session->queued_cmdsn);
647 return -ENOSPC; 656 return -ENOSPC;
648 } 657 }
649 return 0; 658 return 0;
@@ -722,11 +731,6 @@ check_mgmt:
722 731
723 /* process command queue */ 732 /* process command queue */
724 while (!list_empty(&conn->xmitqueue)) { 733 while (!list_empty(&conn->xmitqueue)) {
725 rc = iscsi_check_cmdsn_window_closed(conn);
726 if (rc) {
727 spin_unlock_bh(&conn->session->lock);
728 return rc;
729 }
730 /* 734 /*
731 * iscsi tcp may readd the task to the xmitqueue to send 735 * iscsi tcp may readd the task to the xmitqueue to send
732 * write data 736 * write data
@@ -834,12 +838,6 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
834 goto fault; 838 goto fault;
835 } 839 }
836 840
837 /*
838 * We check this here and in data xmit, because if we get to the point
839 * that this check is hitting the window then we have enough IO in
840 * flight and enough IO waiting to be transmitted it is better
841 * to let the scsi/block layer queue up.
842 */
843 if (iscsi_check_cmdsn_window_closed(conn)) { 841 if (iscsi_check_cmdsn_window_closed(conn)) {
844 reason = FAILURE_WINDOW_CLOSED; 842 reason = FAILURE_WINDOW_CLOSED;
845 goto reject; 843 goto reject;
@@ -850,6 +848,8 @@ int iscsi_queuecommand(struct scsi_cmnd *sc, void (*done)(struct scsi_cmnd *))
850 reason = FAILURE_OOM; 848 reason = FAILURE_OOM;
851 goto reject; 849 goto reject;
852 } 850 }
851 session->queued_cmdsn++;
852
853 sc->SCp.phase = session->age; 853 sc->SCp.phase = session->age;
854 sc->SCp.ptr = (char *)ctask; 854 sc->SCp.ptr = (char *)ctask;
855 855
@@ -1140,7 +1140,13 @@ static void fail_command(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask,
1140 if (!sc) 1140 if (!sc)
1141 return; 1141 return;
1142 1142
1143 if (ctask->state != ISCSI_TASK_PENDING) 1143 if (ctask->state == ISCSI_TASK_PENDING)
1144 /*
1145 * cmd never made it to the xmit thread, so we should not count
1146 * the cmd in the sequencing
1147 */
1148 conn->session->queued_cmdsn--;
1149 else
1144 conn->session->tt->cleanup_cmd_task(conn, ctask); 1150 conn->session->tt->cleanup_cmd_task(conn, ctask);
1145 iscsi_ctask_mtask_cleanup(ctask); 1151 iscsi_ctask_mtask_cleanup(ctask);
1146 1152
@@ -1392,7 +1398,7 @@ iscsi_session_setup(struct iscsi_transport *iscsit,
1392 session->state = ISCSI_STATE_FREE; 1398 session->state = ISCSI_STATE_FREE;
1393 session->mgmtpool_max = ISCSI_MGMT_CMDS_MAX; 1399 session->mgmtpool_max = ISCSI_MGMT_CMDS_MAX;
1394 session->cmds_max = cmds_max; 1400 session->cmds_max = cmds_max;
1395 session->cmdsn = initial_cmdsn; 1401 session->queued_cmdsn = session->cmdsn = initial_cmdsn;
1396 session->exp_cmdsn = initial_cmdsn + 1; 1402 session->exp_cmdsn = initial_cmdsn + 1;
1397 session->max_cmdsn = initial_cmdsn + 1; 1403 session->max_cmdsn = initial_cmdsn + 1;
1398 session->max_r2t = 1; 1404 session->max_r2t = 1;
@@ -1473,6 +1479,7 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
1473 struct iscsi_session *session = iscsi_hostdata(shost->hostdata); 1479 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
1474 struct module *owner = cls_session->transport->owner; 1480 struct module *owner = cls_session->transport->owner;
1475 1481
1482 iscsi_unblock_session(cls_session);
1476 scsi_remove_host(shost); 1483 scsi_remove_host(shost);
1477 1484
1478 iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds); 1485 iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);
@@ -1615,11 +1622,8 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
1615 kfree(conn->persistent_address); 1622 kfree(conn->persistent_address);
1616 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask, 1623 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,
1617 sizeof(void*)); 1624 sizeof(void*));
1618 if (session->leadconn == conn) { 1625 if (session->leadconn == conn)
1619 session->leadconn = NULL; 1626 session->leadconn = NULL;
1620 /* no connections exits.. reset sequencing */
1621 session->cmdsn = session->max_cmdsn = session->exp_cmdsn = 1;
1622 }
1623 spin_unlock_bh(&session->lock); 1627 spin_unlock_bh(&session->lock);
1624 1628
1625 kfifo_free(conn->mgmtqueue); 1629 kfifo_free(conn->mgmtqueue);
@@ -1649,6 +1653,7 @@ int iscsi_conn_start(struct iscsi_cls_conn *cls_conn)
1649 spin_lock_bh(&session->lock); 1653 spin_lock_bh(&session->lock);
1650 conn->c_stage = ISCSI_CONN_STARTED; 1654 conn->c_stage = ISCSI_CONN_STARTED;
1651 session->state = ISCSI_STATE_LOGGED_IN; 1655 session->state = ISCSI_STATE_LOGGED_IN;
1656 session->queued_cmdsn = session->cmdsn;
1652 1657
1653 switch(conn->stop_stage) { 1658 switch(conn->stop_stage) {
1654 case STOP_CONN_RECOVER: 1659 case STOP_CONN_RECOVER:
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index ced2de32c511..5e573efcf0a7 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -382,7 +382,7 @@ int sas_ata_init_host_and_port(struct domain_device *found_dev,
382 struct ata_port *ap; 382 struct ata_port *ap;
383 383
384 ata_host_init(&found_dev->sata_dev.ata_host, 384 ata_host_init(&found_dev->sata_dev.ata_host,
385 &ha->pcidev->dev, 385 ha->dev,
386 sata_port_info.flags, 386 sata_port_info.flags,
387 &sas_sata_ops); 387 &sas_sata_ops);
388 ap = ata_sas_port_alloc(&found_dev->sata_dev.ata_host, 388 ap = ata_sas_port_alloc(&found_dev->sata_dev.ata_host,
@@ -448,10 +448,10 @@ static void sas_disc_task_done(struct sas_task *task)
448 * @task: the task to be executed 448 * @task: the task to be executed
449 * @buffer: pointer to buffer to do I/O 449 * @buffer: pointer to buffer to do I/O
450 * @size: size of @buffer 450 * @size: size of @buffer
451 * @pci_dma_dir: PCI_DMA_... 451 * @dma_dir: DMA direction. DMA_xxx
452 */ 452 */
453static int sas_execute_task(struct sas_task *task, void *buffer, int size, 453static int sas_execute_task(struct sas_task *task, void *buffer, int size,
454 int pci_dma_dir) 454 enum dma_data_direction dma_dir)
455{ 455{
456 int res = 0; 456 int res = 0;
457 struct scatterlist *scatter = NULL; 457 struct scatterlist *scatter = NULL;
@@ -461,7 +461,7 @@ static int sas_execute_task(struct sas_task *task, void *buffer, int size,
461 struct sas_internal *i = 461 struct sas_internal *i =
462 to_sas_internal(task->dev->port->ha->core.shost->transportt); 462 to_sas_internal(task->dev->port->ha->core.shost->transportt);
463 463
464 if (pci_dma_dir != PCI_DMA_NONE) { 464 if (dma_dir != DMA_NONE) {
465 scatter = kzalloc(sizeof(*scatter), GFP_KERNEL); 465 scatter = kzalloc(sizeof(*scatter), GFP_KERNEL);
466 if (!scatter) 466 if (!scatter)
467 goto out; 467 goto out;
@@ -474,11 +474,11 @@ static int sas_execute_task(struct sas_task *task, void *buffer, int size,
474 task->scatter = scatter; 474 task->scatter = scatter;
475 task->num_scatter = num_scatter; 475 task->num_scatter = num_scatter;
476 task->total_xfer_len = size; 476 task->total_xfer_len = size;
477 task->data_dir = pci_dma_dir; 477 task->data_dir = dma_dir;
478 task->task_done = sas_disc_task_done; 478 task->task_done = sas_disc_task_done;
479 if (pci_dma_dir != PCI_DMA_NONE && 479 if (dma_dir != DMA_NONE &&
480 sas_protocol_ata(task->task_proto)) { 480 sas_protocol_ata(task->task_proto)) {
481 task->num_scatter = pci_map_sg(task->dev->port->ha->pcidev, 481 task->num_scatter = dma_map_sg(task->dev->port->ha->dev,
482 task->scatter, 482 task->scatter,
483 task->num_scatter, 483 task->num_scatter,
484 task->data_dir); 484 task->data_dir);
@@ -565,9 +565,9 @@ static int sas_execute_task(struct sas_task *task, void *buffer, int size,
565 } 565 }
566 } 566 }
567ex_err: 567ex_err:
568 if (pci_dma_dir != PCI_DMA_NONE) { 568 if (dma_dir != DMA_NONE) {
569 if (sas_protocol_ata(task->task_proto)) 569 if (sas_protocol_ata(task->task_proto))
570 pci_unmap_sg(task->dev->port->ha->pcidev, 570 dma_unmap_sg(task->dev->port->ha->dev,
571 task->scatter, task->num_scatter, 571 task->scatter, task->num_scatter,
572 task->data_dir); 572 task->data_dir);
573 kfree(scatter); 573 kfree(scatter);
@@ -628,11 +628,11 @@ static void sas_get_ata_command_set(struct domain_device *dev)
628 * @features: the features register 628 * @features: the features register
629 * @buffer: pointer to buffer to do I/O 629 * @buffer: pointer to buffer to do I/O
630 * @size: size of @buffer 630 * @size: size of @buffer
631 * @pci_dma_dir: PCI_DMA_... 631 * @dma_dir: DMA direction. DMA_xxx
632 */ 632 */
633static int sas_issue_ata_cmd(struct domain_device *dev, u8 command, 633static int sas_issue_ata_cmd(struct domain_device *dev, u8 command,
634 u8 features, void *buffer, int size, 634 u8 features, void *buffer, int size,
635 int pci_dma_dir) 635 enum dma_data_direction dma_dir)
636{ 636{
637 int res = 0; 637 int res = 0;
638 struct sas_task *task; 638 struct sas_task *task;
@@ -652,7 +652,7 @@ static int sas_issue_ata_cmd(struct domain_device *dev, u8 command,
652 task->ata_task.fis.device = d2h_fis->device; 652 task->ata_task.fis.device = d2h_fis->device;
653 task->ata_task.retry_count = 1; 653 task->ata_task.retry_count = 1;
654 654
655 res = sas_execute_task(task, buffer, size, pci_dma_dir); 655 res = sas_execute_task(task, buffer, size, dma_dir);
656 656
657 sas_free_task(task); 657 sas_free_task(task);
658out: 658out:
@@ -707,7 +707,7 @@ static int sas_discover_sata_dev(struct domain_device *dev)
707 } 707 }
708 708
709 res = sas_issue_ata_cmd(dev, command, 0, identify_x, 512, 709 res = sas_issue_ata_cmd(dev, command, 0, identify_x, 512,
710 PCI_DMA_FROMDEVICE); 710 DMA_FROM_DEVICE);
711 if (res) 711 if (res)
712 goto out_err; 712 goto out_err;
713 713
@@ -720,13 +720,13 @@ static int sas_discover_sata_dev(struct domain_device *dev)
720 goto cont1; 720 goto cont1;
721 res = sas_issue_ata_cmd(dev, ATA_SET_FEATURES, 721 res = sas_issue_ata_cmd(dev, ATA_SET_FEATURES,
722 ATA_FEATURE_PUP_STBY_SPIN_UP, 722 ATA_FEATURE_PUP_STBY_SPIN_UP,
723 NULL, 0, PCI_DMA_NONE); 723 NULL, 0, DMA_NONE);
724 if (res) 724 if (res)
725 goto cont1; 725 goto cont1;
726 726
727 schedule_timeout_interruptible(5*HZ); /* More time? */ 727 schedule_timeout_interruptible(5*HZ); /* More time? */
728 res = sas_issue_ata_cmd(dev, command, 0, identify_x, 512, 728 res = sas_issue_ata_cmd(dev, command, 0, identify_x, 512,
729 PCI_DMA_FROMDEVICE); 729 DMA_FROM_DEVICE);
730 if (res) 730 if (res)
731 goto out_err; 731 goto out_err;
732 } 732 }
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index 6ac9f61d006a..7ef0afc3cd68 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25#include <linux/pci.h>
26#include <linux/scatterlist.h> 25#include <linux/scatterlist.h>
27#include <scsi/scsi_host.h> 26#include <scsi/scsi_host.h>
28#include <scsi/scsi_eh.h> 27#include <scsi/scsi_eh.h>
@@ -170,7 +169,7 @@ int sas_notify_lldd_dev_found(struct domain_device *dev)
170 if (res) { 169 if (res) {
171 printk("sas: driver on pcidev %s cannot handle " 170 printk("sas: driver on pcidev %s cannot handle "
172 "device %llx, error:%d\n", 171 "device %llx, error:%d\n",
173 pci_name(sas_ha->pcidev), 172 sas_ha->dev->bus_id,
174 SAS_ADDR(dev->sas_addr), res); 173 SAS_ADDR(dev->sas_addr), res);
175 } 174 }
176 } 175 }
diff --git a/drivers/scsi/libsas/sas_dump.c b/drivers/scsi/libsas/sas_dump.c
index f1246d2c9bef..bf34a236f946 100644
--- a/drivers/scsi/libsas/sas_dump.c
+++ b/drivers/scsi/libsas/sas_dump.c
@@ -56,7 +56,7 @@ void sas_dprint_phye(int phyid, enum phy_event pe)
56 56
57void sas_dprint_hae(struct sas_ha_struct *sas_ha, enum ha_event he) 57void sas_dprint_hae(struct sas_ha_struct *sas_ha, enum ha_event he)
58{ 58{
59 SAS_DPRINTK("ha %s: %s event\n", pci_name(sas_ha->pcidev), 59 SAS_DPRINTK("ha %s: %s event\n", sas_ha->dev->bus_id,
60 sas_hae_str[he]); 60 sas_hae_str[he]);
61} 61}
62 62
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index b500f0c1449c..8727436b222d 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -507,14 +507,21 @@ static int sas_dev_present_in_domain(struct asd_sas_port *port,
507int sas_smp_get_phy_events(struct sas_phy *phy) 507int sas_smp_get_phy_events(struct sas_phy *phy)
508{ 508{
509 int res; 509 int res;
510 u8 *req;
511 u8 *resp;
510 struct sas_rphy *rphy = dev_to_rphy(phy->dev.parent); 512 struct sas_rphy *rphy = dev_to_rphy(phy->dev.parent);
511 struct domain_device *dev = sas_find_dev_by_rphy(rphy); 513 struct domain_device *dev = sas_find_dev_by_rphy(rphy);
512 u8 *req = alloc_smp_req(RPEL_REQ_SIZE);
513 u8 *resp = kzalloc(RPEL_RESP_SIZE, GFP_KERNEL);
514 514
515 if (!resp) 515 req = alloc_smp_req(RPEL_REQ_SIZE);
516 if (!req)
516 return -ENOMEM; 517 return -ENOMEM;
517 518
519 resp = alloc_smp_resp(RPEL_RESP_SIZE);
520 if (!resp) {
521 kfree(req);
522 return -ENOMEM;
523 }
524
518 req[1] = SMP_REPORT_PHY_ERR_LOG; 525 req[1] = SMP_REPORT_PHY_ERR_LOG;
519 req[9] = phy->number; 526 req[9] = phy->number;
520 527
@@ -1879,7 +1886,7 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1879 struct request *req) 1886 struct request *req)
1880{ 1887{
1881 struct domain_device *dev; 1888 struct domain_device *dev;
1882 int ret, type = rphy->identify.device_type; 1889 int ret, type;
1883 struct request *rsp = req->next_rq; 1890 struct request *rsp = req->next_rq;
1884 1891
1885 if (!rsp) { 1892 if (!rsp) {
@@ -1888,12 +1895,13 @@ int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1888 return -EINVAL; 1895 return -EINVAL;
1889 } 1896 }
1890 1897
1891 /* seems aic94xx doesn't support */ 1898 /* no rphy means no smp target support (ie aic94xx host) */
1892 if (!rphy) { 1899 if (!rphy) {
1893 printk("%s: can we send a smp request to a host?\n", 1900 printk("%s: can we send a smp request to a host?\n",
1894 __FUNCTION__); 1901 __FUNCTION__);
1895 return -EINVAL; 1902 return -EINVAL;
1896 } 1903 }
1904 type = rphy->identify.device_type;
1897 1905
1898 if (type != SAS_EDGE_EXPANDER_DEVICE && 1906 if (type != SAS_EDGE_EXPANDER_DEVICE &&
1899 type != SAS_FANOUT_EXPANDER_DEVICE) { 1907 type != SAS_FANOUT_EXPANDER_DEVICE) {
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 1612f9200a52..0f2a9f5d801c 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -91,18 +91,20 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj,
91{ 91{
92 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 92 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
93 struct device, kobj))); 93 struct device, kobj)));
94 unsigned long flags; 94 int size = ha->nvram_size;
95 char *nvram_cache = ha->nvram;
95 96
96 if (!capable(CAP_SYS_ADMIN) || off != 0) 97 if (!capable(CAP_SYS_ADMIN) || off > size || count == 0)
97 return 0; 98 return 0;
99 if (off + count > size) {
100 size -= off;
101 count = size;
102 }
98 103
99 /* Read NVRAM. */ 104 /* Read NVRAM data from cache. */
100 spin_lock_irqsave(&ha->hardware_lock, flags); 105 memcpy(buf, &nvram_cache[off], count);
101 ha->isp_ops->read_nvram(ha, (uint8_t *)buf, ha->nvram_base,
102 ha->nvram_size);
103 spin_unlock_irqrestore(&ha->hardware_lock, flags);
104 106
105 return ha->nvram_size; 107 return count;
106} 108}
107 109
108static ssize_t 110static ssize_t
@@ -144,6 +146,8 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj,
144 /* Write NVRAM. */ 146 /* Write NVRAM. */
145 spin_lock_irqsave(&ha->hardware_lock, flags); 147 spin_lock_irqsave(&ha->hardware_lock, flags);
146 ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count); 148 ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count);
149 ha->isp_ops->read_nvram(ha, (uint8_t *)&ha->nvram, ha->nvram_base,
150 count);
147 spin_unlock_irqrestore(&ha->hardware_lock, flags); 151 spin_unlock_irqrestore(&ha->hardware_lock, flags);
148 152
149 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 153 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
@@ -298,18 +302,20 @@ qla2x00_sysfs_read_vpd(struct kobject *kobj,
298{ 302{
299 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj, 303 struct scsi_qla_host *ha = to_qla_host(dev_to_shost(container_of(kobj,
300 struct device, kobj))); 304 struct device, kobj)));
301 unsigned long flags; 305 int size = ha->vpd_size;
306 char *vpd_cache = ha->vpd;
302 307
303 if (!capable(CAP_SYS_ADMIN) || off != 0) 308 if (!capable(CAP_SYS_ADMIN) || off > size || count == 0)
304 return 0; 309 return 0;
310 if (off + count > size) {
311 size -= off;
312 count = size;
313 }
305 314
306 /* Read NVRAM. */ 315 /* Read NVRAM data from cache. */
307 spin_lock_irqsave(&ha->hardware_lock, flags); 316 memcpy(buf, &vpd_cache[off], count);
308 ha->isp_ops->read_nvram(ha, (uint8_t *)buf, ha->vpd_base,
309 ha->vpd_size);
310 spin_unlock_irqrestore(&ha->hardware_lock, flags);
311 317
312 return ha->vpd_size; 318 return count;
313} 319}
314 320
315static ssize_t 321static ssize_t
@@ -327,6 +333,7 @@ qla2x00_sysfs_write_vpd(struct kobject *kobj,
327 /* Write NVRAM. */ 333 /* Write NVRAM. */
328 spin_lock_irqsave(&ha->hardware_lock, flags); 334 spin_lock_irqsave(&ha->hardware_lock, flags);
329 ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count); 335 ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count);
336 ha->isp_ops->read_nvram(ha, (uint8_t *)ha->vpd, ha->vpd_base, count);
330 spin_unlock_irqrestore(&ha->hardware_lock, flags); 337 spin_unlock_irqrestore(&ha->hardware_lock, flags);
331 338
332 return count; 339 return count;
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 0c9f36c8a248..27ae3a532a55 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2340,10 +2340,14 @@ typedef struct scsi_qla_host {
2340 uint8_t serial2; 2340 uint8_t serial2;
2341 2341
2342 /* NVRAM configuration data */ 2342 /* NVRAM configuration data */
2343#define MAX_NVRAM_SIZE 4096
2344#define VPD_OFFSET MAX_NVRAM_SIZE / 2
2343 uint16_t nvram_size; 2345 uint16_t nvram_size;
2344 uint16_t nvram_base; 2346 uint16_t nvram_base;
2347 void *nvram;
2345 uint16_t vpd_size; 2348 uint16_t vpd_size;
2346 uint16_t vpd_base; 2349 uint16_t vpd_base;
2350 void *vpd;
2347 2351
2348 uint16_t loop_reset_delay; 2352 uint16_t loop_reset_delay;
2349 uint8_t retry_count; 2353 uint8_t retry_count;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 5ec798c2bf13..374abe19b547 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1461,8 +1461,8 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1461 uint16_t cnt; 1461 uint16_t cnt;
1462 uint8_t *dptr1, *dptr2; 1462 uint8_t *dptr1, *dptr2;
1463 init_cb_t *icb = ha->init_cb; 1463 init_cb_t *icb = ha->init_cb;
1464 nvram_t *nv = (nvram_t *)ha->request_ring; 1464 nvram_t *nv = ha->nvram;
1465 uint8_t *ptr = (uint8_t *)ha->request_ring; 1465 uint8_t *ptr = ha->nvram;
1466 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 1466 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1467 1467
1468 rval = QLA_SUCCESS; 1468 rval = QLA_SUCCESS;
@@ -1480,8 +1480,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1480 chksum += *ptr++; 1480 chksum += *ptr++;
1481 1481
1482 DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no)); 1482 DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no));
1483 DEBUG5(qla2x00_dump_buffer((uint8_t *)ha->request_ring, 1483 DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size));
1484 ha->nvram_size));
1485 1484
1486 /* Bad NVRAM data, set defaults parameters. */ 1485 /* Bad NVRAM data, set defaults parameters. */
1487 if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || 1486 if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' ||
@@ -3500,7 +3499,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
3500 3499
3501 rval = QLA_SUCCESS; 3500 rval = QLA_SUCCESS;
3502 icb = (struct init_cb_24xx *)ha->init_cb; 3501 icb = (struct init_cb_24xx *)ha->init_cb;
3503 nv = (struct nvram_24xx *)ha->request_ring; 3502 nv = ha->nvram;
3504 3503
3505 /* Determine NVRAM starting address. */ 3504 /* Determine NVRAM starting address. */
3506 ha->nvram_size = sizeof(struct nvram_24xx); 3505 ha->nvram_size = sizeof(struct nvram_24xx);
@@ -3512,7 +3511,12 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
3512 ha->vpd_base = FA_NVRAM_VPD1_ADDR; 3511 ha->vpd_base = FA_NVRAM_VPD1_ADDR;
3513 } 3512 }
3514 3513
3515 /* Get NVRAM data and calculate checksum. */ 3514 /* Get VPD data into cache */
3515 ha->vpd = ha->nvram + VPD_OFFSET;
3516 ha->isp_ops->read_nvram(ha, (uint8_t *)ha->vpd,
3517 ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4);
3518
3519 /* Get NVRAM data into cache and calculate checksum. */
3516 dptr = (uint32_t *)nv; 3520 dptr = (uint32_t *)nv;
3517 ha->isp_ops->read_nvram(ha, (uint8_t *)dptr, ha->nvram_base, 3521 ha->isp_ops->read_nvram(ha, (uint8_t *)dptr, ha->nvram_base,
3518 ha->nvram_size); 3522 ha->nvram_size);
@@ -3520,8 +3524,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
3520 chksum += le32_to_cpu(*dptr++); 3524 chksum += le32_to_cpu(*dptr++);
3521 3525
3522 DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no)); 3526 DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no));
3523 DEBUG5(qla2x00_dump_buffer((uint8_t *)ha->request_ring, 3527 DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size));
3524 ha->nvram_size));
3525 3528
3526 /* Bad NVRAM data, set defaults parameters. */ 3529 /* Bad NVRAM data, set defaults parameters. */
3527 if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P' 3530 if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P'
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index b8f226ae2633..50539da467bf 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1068,7 +1068,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1068 * values. 1068 * values.
1069 */ 1069 */
1070 if (resid && 1070 if (resid &&
1071 ((unsigned)(cp->request_bufflen - resid) < 1071 ((unsigned)(scsi_bufflen(cp) - resid) <
1072 cp->underflow)) { 1072 cp->underflow)) {
1073 DEBUG2(qla_printk(KERN_INFO, ha, 1073 DEBUG2(qla_printk(KERN_INFO, ha,
1074 "scsi(%ld:%d:%d:%d): Mid-layer underflow " 1074 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
@@ -1076,7 +1076,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1076 "error status.\n", ha->host_no, 1076 "error status.\n", ha->host_no,
1077 cp->device->channel, cp->device->id, 1077 cp->device->channel, cp->device->id,
1078 cp->device->lun, resid, 1078 cp->device->lun, resid,
1079 cp->request_bufflen)); 1079 scsi_bufflen(cp)));
1080 1080
1081 cp->result = DID_ERROR << 16 | lscsi_status; 1081 cp->result = DID_ERROR << 16 | lscsi_status;
1082 } 1082 }
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index 19c44f0781fd..e2ea739e33df 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -154,6 +154,9 @@ static struct {
154 {"EMC", "Invista", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, 154 {"EMC", "Invista", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
155 {"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_FORCELUN}, 155 {"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_FORCELUN},
156 {"EMULEX", "MD21/S2 ESDI", NULL, BLIST_SINGLELUN}, 156 {"EMULEX", "MD21/S2 ESDI", NULL, BLIST_SINGLELUN},
157 {"easyRAID", "16P", NULL, BLIST_NOREPORTLUN},
158 {"easyRAID", "X6P", NULL, BLIST_NOREPORTLUN},
159 {"easyRAID", "F8", NULL, BLIST_NOREPORTLUN},
157 {"FSC", "CentricStor", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, 160 {"FSC", "CentricStor", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
158 {"Generic", "USB SD Reader", "1.00", BLIST_FORCELUN | BLIST_INQUIRY_36}, 161 {"Generic", "USB SD Reader", "1.00", BLIST_FORCELUN | BLIST_INQUIRY_36},
159 {"Generic", "USB Storage-SMC", "0180", BLIST_FORCELUN | BLIST_INQUIRY_36}, 162 {"Generic", "USB Storage-SMC", "0180", BLIST_FORCELUN | BLIST_INQUIRY_36},
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index da63c544919b..21c075d44db1 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -654,7 +654,7 @@ void scsi_run_host_queues(struct Scsi_Host *shost)
654static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate, 654static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate,
655 int bytes, int requeue) 655 int bytes, int requeue)
656{ 656{
657 request_queue_t *q = cmd->device->request_queue; 657 struct request_queue *q = cmd->device->request_queue;
658 struct request *req = cmd->request; 658 struct request *req = cmd->request;
659 unsigned long flags; 659 unsigned long flags;
660 660
@@ -818,7 +818,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
818{ 818{
819 int result = cmd->result; 819 int result = cmd->result;
820 int this_count = cmd->request_bufflen; 820 int this_count = cmd->request_bufflen;
821 request_queue_t *q = cmd->device->request_queue; 821 struct request_queue *q = cmd->device->request_queue;
822 struct request *req = cmd->request; 822 struct request *req = cmd->request;
823 int clear_errors = 1; 823 int clear_errors = 1;
824 struct scsi_sense_hdr sshdr; 824 struct scsi_sense_hdr sshdr;
@@ -1038,7 +1038,7 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
1038 return BLKPREP_KILL; 1038 return BLKPREP_KILL;
1039} 1039}
1040 1040
1041static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk, 1041static int scsi_issue_flush_fn(struct request_queue *q, struct gendisk *disk,
1042 sector_t *error_sector) 1042 sector_t *error_sector)
1043{ 1043{
1044 struct scsi_device *sdev = q->queuedata; 1044 struct scsi_device *sdev = q->queuedata;
@@ -1340,7 +1340,7 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
1340/* 1340/*
1341 * Kill a request for a dead device 1341 * Kill a request for a dead device
1342 */ 1342 */
1343static void scsi_kill_request(struct request *req, request_queue_t *q) 1343static void scsi_kill_request(struct request *req, struct request_queue *q)
1344{ 1344{
1345 struct scsi_cmnd *cmd = req->special; 1345 struct scsi_cmnd *cmd = req->special;
1346 struct scsi_device *sdev = cmd->device; 1346 struct scsi_device *sdev = cmd->device;
@@ -2119,7 +2119,7 @@ EXPORT_SYMBOL(scsi_target_resume);
2119int 2119int
2120scsi_internal_device_block(struct scsi_device *sdev) 2120scsi_internal_device_block(struct scsi_device *sdev)
2121{ 2121{
2122 request_queue_t *q = sdev->request_queue; 2122 struct request_queue *q = sdev->request_queue;
2123 unsigned long flags; 2123 unsigned long flags;
2124 int err = 0; 2124 int err = 0;
2125 2125
@@ -2159,7 +2159,7 @@ EXPORT_SYMBOL_GPL(scsi_internal_device_block);
2159int 2159int
2160scsi_internal_device_unblock(struct scsi_device *sdev) 2160scsi_internal_device_unblock(struct scsi_device *sdev)
2161{ 2161{
2162 request_queue_t *q = sdev->request_queue; 2162 struct request_queue *q = sdev->request_queue;
2163 int err; 2163 int err;
2164 unsigned long flags; 2164 unsigned long flags;
2165 2165
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 424d557284a9..e21c7142a3ea 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -814,7 +814,7 @@ static int sd_issue_flush(struct device *dev, sector_t *error_sector)
814 return ret; 814 return ret;
815} 815}
816 816
817static void sd_prepare_flush(request_queue_t *q, struct request *rq) 817static void sd_prepare_flush(struct request_queue *q, struct request *rq)
818{ 818{
819 memset(rq->cmd, 0, sizeof(rq->cmd)); 819 memset(rq->cmd, 0, sizeof(rq->cmd));
820 rq->cmd_type = REQ_TYPE_BLOCK_PC; 820 rq->cmd_type = REQ_TYPE_BLOCK_PC;
@@ -1285,7 +1285,7 @@ got_data:
1285 */ 1285 */
1286 int hard_sector = sector_size; 1286 int hard_sector = sector_size;
1287 sector_t sz = (sdkp->capacity/2) * (hard_sector/256); 1287 sector_t sz = (sdkp->capacity/2) * (hard_sector/256);
1288 request_queue_t *queue = sdp->request_queue; 1288 struct request_queue *queue = sdp->request_queue;
1289 sector_t mb = sz; 1289 sector_t mb = sz;
1290 1290
1291 blk_queue_hardsect_size(queue, hard_sector); 1291 blk_queue_hardsect_size(queue, hard_sector);
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index e7b6a7fde1cb..902eb11ffe8a 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -624,7 +624,7 @@ static void get_sectorsize(struct scsi_cd *cd)
624 unsigned char *buffer; 624 unsigned char *buffer;
625 int the_result, retries = 3; 625 int the_result, retries = 3;
626 int sector_size; 626 int sector_size;
627 request_queue_t *queue; 627 struct request_queue *queue;
628 628
629 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA); 629 buffer = kmalloc(512, GFP_KERNEL | GFP_DMA);
630 if (!buffer) 630 if (!buffer)
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 15a51459c81f..3db22325ea2c 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -2033,7 +2033,7 @@ static struct pci_device_id sym2_id_table[] __devinitdata = {
2033 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C875, 2033 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C875,
2034 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 2034 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
2035 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C1510, 2035 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_NCR_53C1510,
2036 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, /* new */ 2036 PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_SCSI<<8, 0xffff00, 0UL }, /* new */
2037 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C895A, 2037 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C895A,
2038 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 2038 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
2039 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C875A, 2039 { PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_53C875A,
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index cad426c9711e..aad4012bbb30 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -33,7 +33,6 @@
33#include <linux/keyboard.h> 33#include <linux/keyboard.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/pm.h> 35#include <linux/pm.h>
36#include <linux/pm_legacy.h>
37#include <linux/bitops.h> 36#include <linux/bitops.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39 38
@@ -401,9 +400,9 @@ irqreturn_t rs_interrupt(int irq, void *dev_id)
401 return IRQ_HANDLED; 400 return IRQ_HANDLED;
402} 401}
403 402
404static void do_softint(void *private) 403static void do_softint(struct work_struct *work)
405{ 404{
406 struct m68k_serial *info = (struct m68k_serial *) private; 405 struct m68k_serial *info = container_of(work, struct m68k_serial, tqueue);
407 struct tty_struct *tty; 406 struct tty_struct *tty;
408 407
409 tty = info->tty; 408 tty = info->tty;
@@ -425,9 +424,9 @@ static void do_softint(void *private)
425 * do_serial_hangup() -> tty->hangup() -> rs_hangup() 424 * do_serial_hangup() -> tty->hangup() -> rs_hangup()
426 * 425 *
427 */ 426 */
428static void do_serial_hangup(void *private) 427static void do_serial_hangup(struct work_struct *work)
429{ 428{
430 struct m68k_serial *info = (struct m68k_serial *) private; 429 struct m68k_serial *info = container_of(work, struct m68k_serial, tqueue_hangup);
431 struct tty_struct *tty; 430 struct tty_struct *tty;
432 431
433 tty = info->tty; 432 tty = info->tty;
@@ -1324,59 +1323,6 @@ static void show_serial_version(void)
1324 printk("MC68328 serial driver version 1.00\n"); 1323 printk("MC68328 serial driver version 1.00\n");
1325} 1324}
1326 1325
1327#ifdef CONFIG_PM_LEGACY
1328/* Serial Power management
1329 * The console (currently fixed at line 0) is a special case for power
1330 * management because the kernel is so chatty. The console will be
1331 * explicitly disabled my our power manager as the last minute, so we won't
1332 * mess with it here.
1333 */
1334static struct pm_dev *serial_pm[NR_PORTS];
1335
1336static int serial_pm_callback(struct pm_dev *dev, pm_request_t request, void *data)
1337{
1338 struct m68k_serial *info = (struct m68k_serial *)dev->data;
1339
1340 if(info == NULL)
1341 return -1;
1342
1343 /* special case for line 0 - pm restores it */
1344 if(info->line == 0)
1345 return 0;
1346
1347 switch (request) {
1348 case PM_SUSPEND:
1349 shutdown(info);
1350 break;
1351
1352 case PM_RESUME:
1353 startup(info);
1354 break;
1355 }
1356 return 0;
1357}
1358
1359void shutdown_console(void)
1360{
1361 struct m68k_serial *info = &m68k_soft[0];
1362
1363 /* HACK: wait a bit for any pending printk's to be dumped */
1364 {
1365 int i = 10000;
1366 while(i--);
1367 }
1368
1369 shutdown(info);
1370}
1371
1372void startup_console(void)
1373{
1374 struct m68k_serial *info = &m68k_soft[0];
1375 startup(info);
1376}
1377#endif /* CONFIG_PM_LEGACY */
1378
1379
1380static const struct tty_operations rs_ops = { 1326static const struct tty_operations rs_ops = {
1381 .open = rs_open, 1327 .open = rs_open,
1382 .close = rs_close, 1328 .close = rs_close,
@@ -1444,8 +1390,8 @@ rs68328_init(void)
1444 info->event = 0; 1390 info->event = 0;
1445 info->count = 0; 1391 info->count = 0;
1446 info->blocked_open = 0; 1392 info->blocked_open = 0;
1447 INIT_WORK(&info->tqueue, do_softint, info); 1393 INIT_WORK(&info->tqueue, do_softint);
1448 INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info); 1394 INIT_WORK(&info->tqueue_hangup, do_serial_hangup);
1449 init_waitqueue_head(&info->open_wait); 1395 init_waitqueue_head(&info->open_wait);
1450 init_waitqueue_head(&info->close_wait); 1396 init_waitqueue_head(&info->close_wait);
1451 info->line = i; 1397 info->line = i;
@@ -1467,11 +1413,6 @@ rs68328_init(void)
1467 IRQ_FLG_STD, 1413 IRQ_FLG_STD,
1468 "M68328_UART", NULL)) 1414 "M68328_UART", NULL))
1469 panic("Unable to attach 68328 serial interrupt\n"); 1415 panic("Unable to attach 68328 serial interrupt\n");
1470#ifdef CONFIG_PM_LEGACY
1471 serial_pm[i] = pm_register(PM_SYS_DEV, PM_SYS_COM, serial_pm_callback);
1472 if (serial_pm[i])
1473 serial_pm[i]->data = info;
1474#endif
1475 } 1416 }
1476 local_irq_restore(flags); 1417 local_irq_restore(flags);
1477 return 0; 1418 return 0;
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 0b3ec38ae614..2f5a5ac1b271 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2650,8 +2650,9 @@ static int __devinit serial8250_probe(struct platform_device *dev)
2650 ret = serial8250_register_port(&port); 2650 ret = serial8250_register_port(&port);
2651 if (ret < 0) { 2651 if (ret < 0) {
2652 dev_err(&dev->dev, "unable to register port at index %d " 2652 dev_err(&dev->dev, "unable to register port at index %d "
2653 "(IO%lx MEM%lx IRQ%d): %d\n", i, 2653 "(IO%lx MEM%llx IRQ%d): %d\n", i,
2654 p->iobase, p->mapbase, p->irq, ret); 2654 p->iobase, (unsigned long long)p->mapbase,
2655 p->irq, ret);
2655 } 2656 }
2656 } 2657 }
2657 return 0; 2658 return 0;
diff --git a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c
index 947c20507e1f..150cad5c2eba 100644
--- a/drivers/serial/8250_early.c
+++ b/drivers/serial/8250_early.c
@@ -151,8 +151,9 @@ static int __init parse_options(struct early_serial8250_device *device, char *op
151#else 151#else
152 port->membase = ioremap(port->mapbase, 64); 152 port->membase = ioremap(port->mapbase, 64);
153 if (!port->membase) { 153 if (!port->membase) {
154 printk(KERN_ERR "%s: Couldn't ioremap 0x%lx\n", 154 printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n",
155 __FUNCTION__, port->mapbase); 155 __FUNCTION__,
156 (unsigned long long)port->mapbase);
156 return -ENOMEM; 157 return -ENOMEM;
157 } 158 }
158#endif 159#endif
@@ -175,9 +176,10 @@ static int __init parse_options(struct early_serial8250_device *device, char *op
175 device->baud); 176 device->baud);
176 } 177 }
177 178
178 printk(KERN_INFO "Early serial console at %s 0x%lx (options '%s')\n", 179 printk(KERN_INFO "Early serial console at %s 0x%llx (options '%s')\n",
179 mmio ? "MMIO" : "I/O port", 180 mmio ? "MMIO" : "I/O port",
180 mmio ? port->mapbase : (unsigned long) port->iobase, 181 mmio ? (unsigned long long) port->mapbase
182 : (unsigned long long) port->iobase,
181 device->options); 183 device->options);
182 return 0; 184 return 0;
183} 185}
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 6d7d616e9ccd..5e485876f54c 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -976,7 +976,6 @@ enum pci_board_num_t {
976 pbn_oxsemi, 976 pbn_oxsemi,
977 pbn_intel_i960, 977 pbn_intel_i960,
978 pbn_sgi_ioc3, 978 pbn_sgi_ioc3,
979 pbn_nec_nile4,
980 pbn_computone_4, 979 pbn_computone_4,
981 pbn_computone_6, 980 pbn_computone_6,
982 pbn_computone_8, 981 pbn_computone_8,
@@ -1443,18 +1442,6 @@ static struct pciserial_board pci_boards[] __devinitdata = {
1443 }, 1442 },
1444 1443
1445 /* 1444 /*
1446 * NEC Vrc-5074 (Nile 4) builtin UART.
1447 */
1448 [pbn_nec_nile4] = {
1449 .flags = FL_BASE0,
1450 .num_ports = 1,
1451 .base_baud = 520833,
1452 .uart_offset = 8 << 3,
1453 .reg_shift = 3,
1454 .first_offset = 0x300,
1455 },
1456
1457 /*
1458 * Computone - uses IOMEM. 1445 * Computone - uses IOMEM.
1459 */ 1446 */
1460 [pbn_computone_4] = { 1447 [pbn_computone_4] = {
@@ -2345,13 +2332,6 @@ static struct pci_device_id serial_pci_tbl[] = {
2345 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2332 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2346 pbn_b2_1_115200 }, 2333 pbn_b2_1_115200 },
2347 2334
2348 /*
2349 * NEC Vrc-5074 (Nile 4) builtin UART.
2350 */
2351 { PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_NILE4,
2352 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2353 pbn_nec_nile4 },
2354
2355 { PCI_VENDOR_ID_DCI, PCI_DEVICE_ID_DCI_PCCOM2, 2335 { PCI_VENDOR_ID_DCI, PCI_DEVICE_ID_DCI_PCCOM2,
2356 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2336 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
2357 pbn_b3_2_115200 }, 2337 pbn_b3_2_115200 },
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 18f629706448..64ff6a5f6afd 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -88,21 +88,17 @@ config SERIAL_8250_PCI
88 depends on SERIAL_8250 && PCI 88 depends on SERIAL_8250 && PCI
89 default SERIAL_8250 89 default SERIAL_8250
90 help 90 help
91 Say Y here if you have PCI serial ports. 91 This builds standard PCI serial support. You may be able to
92 92 disable this feature if you only need legacy serial support.
93 To compile this driver as a module, choose M here: the module 93 Saves about 9K.
94 will be called 8250_pci.
95 94
96config SERIAL_8250_PNP 95config SERIAL_8250_PNP
97 tristate "8250/16550 PNP device support" if EMBEDDED 96 tristate "8250/16550 PNP device support" if EMBEDDED
98 depends on SERIAL_8250 && PNP 97 depends on SERIAL_8250 && PNP
99 default SERIAL_8250 98 default SERIAL_8250
100 help 99 help
101 Say Y here if you have serial ports described by PNPBIOS or ACPI. 100 This builds standard PNP serial support. You may be able to
102 These are typically ports built into the system board. 101 disable this feature if you only need legacy serial support.
103
104 To compile this driver as a module, choose M here: the module
105 will be called 8250_pnp.
106 102
107config SERIAL_8250_HP300 103config SERIAL_8250_HP300
108 tristate 104 tristate
@@ -1195,7 +1191,7 @@ config SERIAL_VR41XX
1195 1191
1196config SERIAL_VR41XX_CONSOLE 1192config SERIAL_VR41XX_CONSOLE
1197 bool "Enable NEC VR4100 series Serial Interface Unit console" 1193 bool "Enable NEC VR4100 series Serial Interface Unit console"
1198 depends on SERIAL_VR41XX 1194 depends on SERIAL_VR41XX=y
1199 select SERIAL_CORE_CONSOLE 1195 select SERIAL_CORE_CONSOLE
1200 help 1196 help
1201 If you have a NEC VR4100 series processor and you want to use 1197 If you have a NEC VR4100 series processor and you want to use
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index 00924feaf621..4d643c926657 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -74,10 +74,6 @@
74#include <asm/io.h> 74#include <asm/io.h>
75#include <asm/irq.h> 75#include <asm/irq.h>
76 76
77#if defined(CONFIG_SERIAL_MPSC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
78#define SUPPORT_SYSRQ
79#endif
80
81#define MPSC_NUM_CTLRS 2 77#define MPSC_NUM_CTLRS 2
82 78
83/* 79/*
@@ -97,9 +93,8 @@
97#define MPSC_TXBE_SIZE dma_get_cache_alignment() 93#define MPSC_TXBE_SIZE dma_get_cache_alignment()
98#define MPSC_TXB_SIZE (MPSC_TXR_ENTRIES * MPSC_TXBE_SIZE) 94#define MPSC_TXB_SIZE (MPSC_TXR_ENTRIES * MPSC_TXBE_SIZE)
99 95
100#define MPSC_DMA_ALLOC_SIZE (MPSC_RXR_SIZE + MPSC_RXB_SIZE + \ 96#define MPSC_DMA_ALLOC_SIZE (MPSC_RXR_SIZE + MPSC_RXB_SIZE + MPSC_TXR_SIZE \
101 MPSC_TXR_SIZE + MPSC_TXB_SIZE + \ 97 + MPSC_TXB_SIZE + dma_get_cache_alignment() /* for alignment */)
102 dma_get_cache_alignment() /* for alignment */)
103 98
104/* Rx and Tx Ring entry descriptors -- assume entry size is <= cacheline size */ 99/* Rx and Tx Ring entry descriptors -- assume entry size is <= cacheline size */
105struct mpsc_rx_desc { 100struct mpsc_rx_desc {
@@ -270,8 +265,8 @@ struct mpsc_port_info *mpsc_device_remove(int index);
270#define SDMA_DESC_CMDSTAT_EI (1<<23) 265#define SDMA_DESC_CMDSTAT_EI (1<<23)
271#define SDMA_DESC_CMDSTAT_O (1<<31) 266#define SDMA_DESC_CMDSTAT_O (1<<31)
272 267
273#define SDMA_DESC_DFLT (SDMA_DESC_CMDSTAT_O | \ 268#define SDMA_DESC_DFLT (SDMA_DESC_CMDSTAT_O \
274 SDMA_DESC_CMDSTAT_EI) 269 | SDMA_DESC_CMDSTAT_EI)
275 270
276#define SDMA_SDC_RFT (1<<0) 271#define SDMA_SDC_RFT (1<<0)
277#define SDMA_SDC_SFM (1<<1) 272#define SDMA_SDC_SFM (1<<1)
@@ -295,10 +290,10 @@ struct mpsc_port_info *mpsc_device_remove(int index);
295#define SDMA_1_CAUSE_TXBUF (1<<10) 290#define SDMA_1_CAUSE_TXBUF (1<<10)
296#define SDMA_1_CAUSE_TXEND (1<<11) 291#define SDMA_1_CAUSE_TXEND (1<<11)
297 292
298#define SDMA_CAUSE_RX_MASK (SDMA_0_CAUSE_RXBUF | SDMA_0_CAUSE_RXERR | \ 293#define SDMA_CAUSE_RX_MASK (SDMA_0_CAUSE_RXBUF | SDMA_0_CAUSE_RXERR \
299 SDMA_1_CAUSE_RXBUF | SDMA_1_CAUSE_RXERR) 294 | SDMA_1_CAUSE_RXBUF | SDMA_1_CAUSE_RXERR)
300#define SDMA_CAUSE_TX_MASK (SDMA_0_CAUSE_TXBUF | SDMA_0_CAUSE_TXEND | \ 295#define SDMA_CAUSE_TX_MASK (SDMA_0_CAUSE_TXBUF | SDMA_0_CAUSE_TXEND \
301 SDMA_1_CAUSE_TXBUF | SDMA_1_CAUSE_TXEND) 296 | SDMA_1_CAUSE_TXBUF | SDMA_1_CAUSE_TXEND)
302 297
303/* SDMA Interrupt registers */ 298/* SDMA Interrupt registers */
304#define SDMA_INTR_CAUSE 0x0000 299#define SDMA_INTR_CAUSE 0x0000
@@ -312,11 +307,11 @@ struct mpsc_port_info *mpsc_device_remove(int index);
312 * Define how this driver is known to the outside (we've been assigned a 307 * Define how this driver is known to the outside (we've been assigned a
313 * range on the "Low-density serial ports" major). 308 * range on the "Low-density serial ports" major).
314 */ 309 */
315#define MPSC_MAJOR 204 310#define MPSC_MAJOR 204
316#define MPSC_MINOR_START 44 311#define MPSC_MINOR_START 44
317#define MPSC_DRIVER_NAME "MPSC" 312#define MPSC_DRIVER_NAME "MPSC"
318#define MPSC_DEV_NAME "ttyMM" 313#define MPSC_DEV_NAME "ttyMM"
319#define MPSC_VERSION "1.00" 314#define MPSC_VERSION "1.00"
320 315
321static struct mpsc_port_info mpsc_ports[MPSC_NUM_CTLRS]; 316static struct mpsc_port_info mpsc_ports[MPSC_NUM_CTLRS];
322static struct mpsc_shared_regs mpsc_shared_regs; 317static struct mpsc_shared_regs mpsc_shared_regs;
@@ -332,8 +327,7 @@ static void mpsc_release_port(struct uart_port *port);
332 * 327 *
333 ****************************************************************************** 328 ******************************************************************************
334 */ 329 */
335static void 330static void mpsc_brg_init(struct mpsc_port_info *pi, u32 clk_src)
336mpsc_brg_init(struct mpsc_port_info *pi, u32 clk_src)
337{ 331{
338 u32 v; 332 u32 v;
339 333
@@ -349,11 +343,9 @@ mpsc_brg_init(struct mpsc_port_info *pi, u32 clk_src)
349 343
350 writel(readl(pi->brg_base + BRG_BTR) & 0xffff0000, 344 writel(readl(pi->brg_base + BRG_BTR) & 0xffff0000,
351 pi->brg_base + BRG_BTR); 345 pi->brg_base + BRG_BTR);
352 return;
353} 346}
354 347
355static void 348static void mpsc_brg_enable(struct mpsc_port_info *pi)
356mpsc_brg_enable(struct mpsc_port_info *pi)
357{ 349{
358 u32 v; 350 u32 v;
359 351
@@ -363,11 +355,9 @@ mpsc_brg_enable(struct mpsc_port_info *pi)
363 if (pi->mirror_regs) 355 if (pi->mirror_regs)
364 pi->BRG_BCR_m = v; 356 pi->BRG_BCR_m = v;
365 writel(v, pi->brg_base + BRG_BCR); 357 writel(v, pi->brg_base + BRG_BCR);
366 return;
367} 358}
368 359
369static void 360static void mpsc_brg_disable(struct mpsc_port_info *pi)
370mpsc_brg_disable(struct mpsc_port_info *pi)
371{ 361{
372 u32 v; 362 u32 v;
373 363
@@ -377,21 +367,19 @@ mpsc_brg_disable(struct mpsc_port_info *pi)
377 if (pi->mirror_regs) 367 if (pi->mirror_regs)
378 pi->BRG_BCR_m = v; 368 pi->BRG_BCR_m = v;
379 writel(v, pi->brg_base + BRG_BCR); 369 writel(v, pi->brg_base + BRG_BCR);
380 return;
381} 370}
382 371
383static inline void 372/*
384mpsc_set_baudrate(struct mpsc_port_info *pi, u32 baud) 373 * To set the baud, we adjust the CDV field in the BRG_BCR reg.
374 * From manual: Baud = clk / ((CDV+1)*2) ==> CDV = (clk / (baud*2)) - 1.
375 * However, the input clock is divided by 16 in the MPSC b/c of how
376 * 'MPSC_MMCRH' was set up so we have to divide the 'clk' used in our
377 * calculation by 16 to account for that. So the real calculation
378 * that accounts for the way the mpsc is set up is:
379 * CDV = (clk / (baud*2*16)) - 1 ==> CDV = (clk / (baud << 5)) - 1.
380 */
381static void mpsc_set_baudrate(struct mpsc_port_info *pi, u32 baud)
385{ 382{
386 /*
387 * To set the baud, we adjust the CDV field in the BRG_BCR reg.
388 * From manual: Baud = clk / ((CDV+1)*2) ==> CDV = (clk / (baud*2)) - 1.
389 * However, the input clock is divided by 16 in the MPSC b/c of how
390 * 'MPSC_MMCRH' was set up so we have to divide the 'clk' used in our
391 * calculation by 16 to account for that. So the real calculation
392 * that accounts for the way the mpsc is set up is:
393 * CDV = (clk / (baud*2*16)) - 1 ==> CDV = (clk / (baud << 5)) - 1.
394 */
395 u32 cdv = (pi->port.uartclk / (baud << 5)) - 1; 383 u32 cdv = (pi->port.uartclk / (baud << 5)) - 1;
396 u32 v; 384 u32 v;
397 385
@@ -403,8 +391,6 @@ mpsc_set_baudrate(struct mpsc_port_info *pi, u32 baud)
403 pi->BRG_BCR_m = v; 391 pi->BRG_BCR_m = v;
404 writel(v, pi->brg_base + BRG_BCR); 392 writel(v, pi->brg_base + BRG_BCR);
405 mpsc_brg_enable(pi); 393 mpsc_brg_enable(pi);
406
407 return;
408} 394}
409 395
410/* 396/*
@@ -415,13 +401,12 @@ mpsc_set_baudrate(struct mpsc_port_info *pi, u32 baud)
415 ****************************************************************************** 401 ******************************************************************************
416 */ 402 */
417 403
418static void 404static void mpsc_sdma_burstsize(struct mpsc_port_info *pi, u32 burst_size)
419mpsc_sdma_burstsize(struct mpsc_port_info *pi, u32 burst_size)
420{ 405{
421 u32 v; 406 u32 v;
422 407
423 pr_debug("mpsc_sdma_burstsize[%d]: burst_size: %d\n", 408 pr_debug("mpsc_sdma_burstsize[%d]: burst_size: %d\n",
424 pi->port.line, burst_size); 409 pi->port.line, burst_size);
425 410
426 burst_size >>= 3; /* Divide by 8 b/c reg values are 8-byte chunks */ 411 burst_size >>= 3; /* Divide by 8 b/c reg values are 8-byte chunks */
427 412
@@ -436,11 +421,9 @@ mpsc_sdma_burstsize(struct mpsc_port_info *pi, u32 burst_size)
436 421
437 writel((readl(pi->sdma_base + SDMA_SDC) & (0x3 << 12)) | (v << 12), 422 writel((readl(pi->sdma_base + SDMA_SDC) & (0x3 << 12)) | (v << 12),
438 pi->sdma_base + SDMA_SDC); 423 pi->sdma_base + SDMA_SDC);
439 return;
440} 424}
441 425
442static void 426static void mpsc_sdma_init(struct mpsc_port_info *pi, u32 burst_size)
443mpsc_sdma_init(struct mpsc_port_info *pi, u32 burst_size)
444{ 427{
445 pr_debug("mpsc_sdma_init[%d]: burst_size: %d\n", pi->port.line, 428 pr_debug("mpsc_sdma_init[%d]: burst_size: %d\n", pi->port.line,
446 burst_size); 429 burst_size);
@@ -448,11 +431,9 @@ mpsc_sdma_init(struct mpsc_port_info *pi, u32 burst_size)
448 writel((readl(pi->sdma_base + SDMA_SDC) & 0x3ff) | 0x03f, 431 writel((readl(pi->sdma_base + SDMA_SDC) & 0x3ff) | 0x03f,
449 pi->sdma_base + SDMA_SDC); 432 pi->sdma_base + SDMA_SDC);
450 mpsc_sdma_burstsize(pi, burst_size); 433 mpsc_sdma_burstsize(pi, burst_size);
451 return;
452} 434}
453 435
454static inline u32 436static u32 mpsc_sdma_intr_mask(struct mpsc_port_info *pi, u32 mask)
455mpsc_sdma_intr_mask(struct mpsc_port_info *pi, u32 mask)
456{ 437{
457 u32 old, v; 438 u32 old, v;
458 439
@@ -475,15 +456,14 @@ mpsc_sdma_intr_mask(struct mpsc_port_info *pi, u32 mask)
475 return old & 0xf; 456 return old & 0xf;
476} 457}
477 458
478static inline void 459static void mpsc_sdma_intr_unmask(struct mpsc_port_info *pi, u32 mask)
479mpsc_sdma_intr_unmask(struct mpsc_port_info *pi, u32 mask)
480{ 460{
481 u32 v; 461 u32 v;
482 462
483 pr_debug("mpsc_sdma_intr_unmask[%d]: mask: 0x%x\n", pi->port.line,mask); 463 pr_debug("mpsc_sdma_intr_unmask[%d]: mask: 0x%x\n", pi->port.line,mask);
484 464
485 v = (pi->mirror_regs) ? pi->shared_regs->SDMA_INTR_MASK_m : 465 v = (pi->mirror_regs) ? pi->shared_regs->SDMA_INTR_MASK_m
486 readl(pi->shared_regs->sdma_intr_base + SDMA_INTR_MASK); 466 : readl(pi->shared_regs->sdma_intr_base + SDMA_INTR_MASK);
487 467
488 mask &= 0xf; 468 mask &= 0xf;
489 if (pi->port.line) 469 if (pi->port.line)
@@ -493,41 +473,35 @@ mpsc_sdma_intr_unmask(struct mpsc_port_info *pi, u32 mask)
493 if (pi->mirror_regs) 473 if (pi->mirror_regs)
494 pi->shared_regs->SDMA_INTR_MASK_m = v; 474 pi->shared_regs->SDMA_INTR_MASK_m = v;
495 writel(v, pi->shared_regs->sdma_intr_base + SDMA_INTR_MASK); 475 writel(v, pi->shared_regs->sdma_intr_base + SDMA_INTR_MASK);
496 return;
497} 476}
498 477
499static inline void 478static void mpsc_sdma_intr_ack(struct mpsc_port_info *pi)
500mpsc_sdma_intr_ack(struct mpsc_port_info *pi)
501{ 479{
502 pr_debug("mpsc_sdma_intr_ack[%d]: Acknowledging IRQ\n", pi->port.line); 480 pr_debug("mpsc_sdma_intr_ack[%d]: Acknowledging IRQ\n", pi->port.line);
503 481
504 if (pi->mirror_regs) 482 if (pi->mirror_regs)
505 pi->shared_regs->SDMA_INTR_CAUSE_m = 0; 483 pi->shared_regs->SDMA_INTR_CAUSE_m = 0;
506 writeb(0x00, pi->shared_regs->sdma_intr_base + SDMA_INTR_CAUSE + 484 writeb(0x00, pi->shared_regs->sdma_intr_base + SDMA_INTR_CAUSE
507 pi->port.line); 485 + pi->port.line);
508 return;
509} 486}
510 487
511static inline void 488static void mpsc_sdma_set_rx_ring(struct mpsc_port_info *pi,
512mpsc_sdma_set_rx_ring(struct mpsc_port_info *pi, struct mpsc_rx_desc *rxre_p) 489 struct mpsc_rx_desc *rxre_p)
513{ 490{
514 pr_debug("mpsc_sdma_set_rx_ring[%d]: rxre_p: 0x%x\n", 491 pr_debug("mpsc_sdma_set_rx_ring[%d]: rxre_p: 0x%x\n",
515 pi->port.line, (u32) rxre_p); 492 pi->port.line, (u32)rxre_p);
516 493
517 writel((u32)rxre_p, pi->sdma_base + SDMA_SCRDP); 494 writel((u32)rxre_p, pi->sdma_base + SDMA_SCRDP);
518 return;
519} 495}
520 496
521static inline void 497static void mpsc_sdma_set_tx_ring(struct mpsc_port_info *pi,
522mpsc_sdma_set_tx_ring(struct mpsc_port_info *pi, struct mpsc_tx_desc *txre_p) 498 struct mpsc_tx_desc *txre_p)
523{ 499{
524 writel((u32)txre_p, pi->sdma_base + SDMA_SFTDP); 500 writel((u32)txre_p, pi->sdma_base + SDMA_SFTDP);
525 writel((u32)txre_p, pi->sdma_base + SDMA_SCTDP); 501 writel((u32)txre_p, pi->sdma_base + SDMA_SCTDP);
526 return;
527} 502}
528 503
529static inline void 504static void mpsc_sdma_cmd(struct mpsc_port_info *pi, u32 val)
530mpsc_sdma_cmd(struct mpsc_port_info *pi, u32 val)
531{ 505{
532 u32 v; 506 u32 v;
533 507
@@ -539,46 +513,40 @@ mpsc_sdma_cmd(struct mpsc_port_info *pi, u32 val)
539 wmb(); 513 wmb();
540 writel(v, pi->sdma_base + SDMA_SDCM); 514 writel(v, pi->sdma_base + SDMA_SDCM);
541 wmb(); 515 wmb();
542 return;
543} 516}
544 517
545static inline uint 518static uint mpsc_sdma_tx_active(struct mpsc_port_info *pi)
546mpsc_sdma_tx_active(struct mpsc_port_info *pi)
547{ 519{
548 return readl(pi->sdma_base + SDMA_SDCM) & SDMA_SDCM_TXD; 520 return readl(pi->sdma_base + SDMA_SDCM) & SDMA_SDCM_TXD;
549} 521}
550 522
551static inline void 523static void mpsc_sdma_start_tx(struct mpsc_port_info *pi)
552mpsc_sdma_start_tx(struct mpsc_port_info *pi)
553{ 524{
554 struct mpsc_tx_desc *txre, *txre_p; 525 struct mpsc_tx_desc *txre, *txre_p;
555 526
556 /* If tx isn't running & there's a desc ready to go, start it */ 527 /* If tx isn't running & there's a desc ready to go, start it */
557 if (!mpsc_sdma_tx_active(pi)) { 528 if (!mpsc_sdma_tx_active(pi)) {
558 txre = (struct mpsc_tx_desc *)(pi->txr + 529 txre = (struct mpsc_tx_desc *)(pi->txr
559 (pi->txr_tail * MPSC_TXRE_SIZE)); 530 + (pi->txr_tail * MPSC_TXRE_SIZE));
560 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE); 531 dma_cache_sync(pi->port.dev, (void *)txre, MPSC_TXRE_SIZE,
532 DMA_FROM_DEVICE);
561#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 533#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
562 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 534 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
563 invalidate_dcache_range((ulong)txre, 535 invalidate_dcache_range((ulong)txre,
564 (ulong)txre + MPSC_TXRE_SIZE); 536 (ulong)txre + MPSC_TXRE_SIZE);
565#endif 537#endif
566 538
567 if (be32_to_cpu(txre->cmdstat) & SDMA_DESC_CMDSTAT_O) { 539 if (be32_to_cpu(txre->cmdstat) & SDMA_DESC_CMDSTAT_O) {
568 txre_p = (struct mpsc_tx_desc *)(pi->txr_p + 540 txre_p = (struct mpsc_tx_desc *)
569 (pi->txr_tail * 541 (pi->txr_p + (pi->txr_tail * MPSC_TXRE_SIZE));
570 MPSC_TXRE_SIZE));
571 542
572 mpsc_sdma_set_tx_ring(pi, txre_p); 543 mpsc_sdma_set_tx_ring(pi, txre_p);
573 mpsc_sdma_cmd(pi, SDMA_SDCM_STD | SDMA_SDCM_TXD); 544 mpsc_sdma_cmd(pi, SDMA_SDCM_STD | SDMA_SDCM_TXD);
574 } 545 }
575 } 546 }
576
577 return;
578} 547}
579 548
580static inline void 549static void mpsc_sdma_stop(struct mpsc_port_info *pi)
581mpsc_sdma_stop(struct mpsc_port_info *pi)
582{ 550{
583 pr_debug("mpsc_sdma_stop[%d]: Stopping SDMA\n", pi->port.line); 551 pr_debug("mpsc_sdma_stop[%d]: Stopping SDMA\n", pi->port.line);
584 552
@@ -593,8 +561,6 @@ mpsc_sdma_stop(struct mpsc_port_info *pi)
593 /* Disable interrupts */ 561 /* Disable interrupts */
594 mpsc_sdma_intr_mask(pi, 0xf); 562 mpsc_sdma_intr_mask(pi, 0xf);
595 mpsc_sdma_intr_ack(pi); 563 mpsc_sdma_intr_ack(pi);
596
597 return;
598} 564}
599 565
600/* 566/*
@@ -605,8 +571,7 @@ mpsc_sdma_stop(struct mpsc_port_info *pi)
605 ****************************************************************************** 571 ******************************************************************************
606 */ 572 */
607 573
608static void 574static void mpsc_hw_init(struct mpsc_port_info *pi)
609mpsc_hw_init(struct mpsc_port_info *pi)
610{ 575{
611 u32 v; 576 u32 v;
612 577
@@ -628,8 +593,7 @@ mpsc_hw_init(struct mpsc_port_info *pi)
628 v = (v & ~0xf0f) | 0x100; 593 v = (v & ~0xf0f) | 0x100;
629 pi->shared_regs->MPSC_TCRR_m = v; 594 pi->shared_regs->MPSC_TCRR_m = v;
630 writel(v, pi->shared_regs->mpsc_routing_base + MPSC_TCRR); 595 writel(v, pi->shared_regs->mpsc_routing_base + MPSC_TCRR);
631 } 596 } else {
632 else {
633 v = readl(pi->shared_regs->mpsc_routing_base + MPSC_MRR); 597 v = readl(pi->shared_regs->mpsc_routing_base + MPSC_MRR);
634 v &= ~0x1c7; 598 v &= ~0x1c7;
635 writel(v, pi->shared_regs->mpsc_routing_base + MPSC_MRR); 599 writel(v, pi->shared_regs->mpsc_routing_base + MPSC_MRR);
@@ -646,7 +610,7 @@ mpsc_hw_init(struct mpsc_port_info *pi)
646 /* Put MPSC in UART mode & enabel Tx/Rx egines */ 610 /* Put MPSC in UART mode & enabel Tx/Rx egines */
647 writel(0x000004c4, pi->mpsc_base + MPSC_MMCRL); 611 writel(0x000004c4, pi->mpsc_base + MPSC_MMCRL);
648 612
649 /* No preamble, 16x divider, low-latency, */ 613 /* No preamble, 16x divider, low-latency, */
650 writel(0x04400400, pi->mpsc_base + MPSC_MMCRH); 614 writel(0x04400400, pi->mpsc_base + MPSC_MMCRH);
651 615
652 if (pi->mirror_regs) { 616 if (pi->mirror_regs) {
@@ -663,12 +627,9 @@ mpsc_hw_init(struct mpsc_port_info *pi)
663 writel(0, pi->mpsc_base + MPSC_CHR_8); 627 writel(0, pi->mpsc_base + MPSC_CHR_8);
664 writel(0, pi->mpsc_base + MPSC_CHR_9); 628 writel(0, pi->mpsc_base + MPSC_CHR_9);
665 writel(0, pi->mpsc_base + MPSC_CHR_10); 629 writel(0, pi->mpsc_base + MPSC_CHR_10);
666
667 return;
668} 630}
669 631
670static inline void 632static void mpsc_enter_hunt(struct mpsc_port_info *pi)
671mpsc_enter_hunt(struct mpsc_port_info *pi)
672{ 633{
673 pr_debug("mpsc_enter_hunt[%d]: Hunting...\n", pi->port.line); 634 pr_debug("mpsc_enter_hunt[%d]: Hunting...\n", pi->port.line);
674 635
@@ -677,20 +638,16 @@ mpsc_enter_hunt(struct mpsc_port_info *pi)
677 pi->mpsc_base + MPSC_CHR_2); 638 pi->mpsc_base + MPSC_CHR_2);
678 /* Erratum prevents reading CHR_2 so just delay for a while */ 639 /* Erratum prevents reading CHR_2 so just delay for a while */
679 udelay(100); 640 udelay(100);
680 } 641 } else {
681 else {
682 writel(readl(pi->mpsc_base + MPSC_CHR_2) | MPSC_CHR_2_EH, 642 writel(readl(pi->mpsc_base + MPSC_CHR_2) | MPSC_CHR_2_EH,
683 pi->mpsc_base + MPSC_CHR_2); 643 pi->mpsc_base + MPSC_CHR_2);
684 644
685 while (readl(pi->mpsc_base + MPSC_CHR_2) & MPSC_CHR_2_EH) 645 while (readl(pi->mpsc_base + MPSC_CHR_2) & MPSC_CHR_2_EH)
686 udelay(10); 646 udelay(10);
687 } 647 }
688
689 return;
690} 648}
691 649
692static inline void 650static void mpsc_freeze(struct mpsc_port_info *pi)
693mpsc_freeze(struct mpsc_port_info *pi)
694{ 651{
695 u32 v; 652 u32 v;
696 653
@@ -703,11 +660,9 @@ mpsc_freeze(struct mpsc_port_info *pi)
703 if (pi->mirror_regs) 660 if (pi->mirror_regs)
704 pi->MPSC_MPCR_m = v; 661 pi->MPSC_MPCR_m = v;
705 writel(v, pi->mpsc_base + MPSC_MPCR); 662 writel(v, pi->mpsc_base + MPSC_MPCR);
706 return;
707} 663}
708 664
709static inline void 665static void mpsc_unfreeze(struct mpsc_port_info *pi)
710mpsc_unfreeze(struct mpsc_port_info *pi)
711{ 666{
712 u32 v; 667 u32 v;
713 668
@@ -720,11 +675,9 @@ mpsc_unfreeze(struct mpsc_port_info *pi)
720 writel(v, pi->mpsc_base + MPSC_MPCR); 675 writel(v, pi->mpsc_base + MPSC_MPCR);
721 676
722 pr_debug("mpsc_unfreeze[%d]: Unfrozen\n", pi->port.line); 677 pr_debug("mpsc_unfreeze[%d]: Unfrozen\n", pi->port.line);
723 return;
724} 678}
725 679
726static inline void 680static void mpsc_set_char_length(struct mpsc_port_info *pi, u32 len)
727mpsc_set_char_length(struct mpsc_port_info *pi, u32 len)
728{ 681{
729 u32 v; 682 u32 v;
730 683
@@ -737,11 +690,9 @@ mpsc_set_char_length(struct mpsc_port_info *pi, u32 len)
737 if (pi->mirror_regs) 690 if (pi->mirror_regs)
738 pi->MPSC_MPCR_m = v; 691 pi->MPSC_MPCR_m = v;
739 writel(v, pi->mpsc_base + MPSC_MPCR); 692 writel(v, pi->mpsc_base + MPSC_MPCR);
740 return;
741} 693}
742 694
743static inline void 695static void mpsc_set_stop_bit_length(struct mpsc_port_info *pi, u32 len)
744mpsc_set_stop_bit_length(struct mpsc_port_info *pi, u32 len)
745{ 696{
746 u32 v; 697 u32 v;
747 698
@@ -756,11 +707,9 @@ mpsc_set_stop_bit_length(struct mpsc_port_info *pi, u32 len)
756 if (pi->mirror_regs) 707 if (pi->mirror_regs)
757 pi->MPSC_MPCR_m = v; 708 pi->MPSC_MPCR_m = v;
758 writel(v, pi->mpsc_base + MPSC_MPCR); 709 writel(v, pi->mpsc_base + MPSC_MPCR);
759 return;
760} 710}
761 711
762static inline void 712static void mpsc_set_parity(struct mpsc_port_info *pi, u32 p)
763mpsc_set_parity(struct mpsc_port_info *pi, u32 p)
764{ 713{
765 u32 v; 714 u32 v;
766 715
@@ -775,7 +724,6 @@ mpsc_set_parity(struct mpsc_port_info *pi, u32 p)
775 if (pi->mirror_regs) 724 if (pi->mirror_regs)
776 pi->MPSC_CHR_2_m = v; 725 pi->MPSC_CHR_2_m = v;
777 writel(v, pi->mpsc_base + MPSC_CHR_2); 726 writel(v, pi->mpsc_base + MPSC_CHR_2);
778 return;
779} 727}
780 728
781/* 729/*
@@ -786,8 +734,7 @@ mpsc_set_parity(struct mpsc_port_info *pi, u32 p)
786 ****************************************************************************** 734 ******************************************************************************
787 */ 735 */
788 736
789static void 737static void mpsc_init_hw(struct mpsc_port_info *pi)
790mpsc_init_hw(struct mpsc_port_info *pi)
791{ 738{
792 pr_debug("mpsc_init_hw[%d]: Initializing\n", pi->port.line); 739 pr_debug("mpsc_init_hw[%d]: Initializing\n", pi->port.line);
793 740
@@ -796,12 +743,9 @@ mpsc_init_hw(struct mpsc_port_info *pi)
796 mpsc_sdma_init(pi, dma_get_cache_alignment()); /* burst a cacheline */ 743 mpsc_sdma_init(pi, dma_get_cache_alignment()); /* burst a cacheline */
797 mpsc_sdma_stop(pi); 744 mpsc_sdma_stop(pi);
798 mpsc_hw_init(pi); 745 mpsc_hw_init(pi);
799
800 return;
801} 746}
802 747
803static int 748static int mpsc_alloc_ring_mem(struct mpsc_port_info *pi)
804mpsc_alloc_ring_mem(struct mpsc_port_info *pi)
805{ 749{
806 int rc = 0; 750 int rc = 0;
807 751
@@ -812,11 +756,10 @@ mpsc_alloc_ring_mem(struct mpsc_port_info *pi)
812 if (!dma_supported(pi->port.dev, 0xffffffff)) { 756 if (!dma_supported(pi->port.dev, 0xffffffff)) {
813 printk(KERN_ERR "MPSC: Inadequate DMA support\n"); 757 printk(KERN_ERR "MPSC: Inadequate DMA support\n");
814 rc = -ENXIO; 758 rc = -ENXIO;
815 } 759 } else if ((pi->dma_region = dma_alloc_noncoherent(pi->port.dev,
816 else if ((pi->dma_region = dma_alloc_noncoherent(pi->port.dev, 760 MPSC_DMA_ALLOC_SIZE,
817 MPSC_DMA_ALLOC_SIZE, &pi->dma_region_p, GFP_KERNEL)) 761 &pi->dma_region_p, GFP_KERNEL))
818 == NULL) { 762 == NULL) {
819
820 printk(KERN_ERR "MPSC: Can't alloc Desc region\n"); 763 printk(KERN_ERR "MPSC: Can't alloc Desc region\n");
821 rc = -ENOMEM; 764 rc = -ENOMEM;
822 } 765 }
@@ -825,23 +768,19 @@ mpsc_alloc_ring_mem(struct mpsc_port_info *pi)
825 return rc; 768 return rc;
826} 769}
827 770
828static void 771static void mpsc_free_ring_mem(struct mpsc_port_info *pi)
829mpsc_free_ring_mem(struct mpsc_port_info *pi)
830{ 772{
831 pr_debug("mpsc_free_ring_mem[%d]: Freeing ring mem\n", pi->port.line); 773 pr_debug("mpsc_free_ring_mem[%d]: Freeing ring mem\n", pi->port.line);
832 774
833 if (pi->dma_region) { 775 if (pi->dma_region) {
834 dma_free_noncoherent(pi->port.dev, MPSC_DMA_ALLOC_SIZE, 776 dma_free_noncoherent(pi->port.dev, MPSC_DMA_ALLOC_SIZE,
835 pi->dma_region, pi->dma_region_p); 777 pi->dma_region, pi->dma_region_p);
836 pi->dma_region = NULL; 778 pi->dma_region = NULL;
837 pi->dma_region_p = (dma_addr_t) NULL; 779 pi->dma_region_p = (dma_addr_t)NULL;
838 } 780 }
839
840 return;
841} 781}
842 782
843static void 783static void mpsc_init_rings(struct mpsc_port_info *pi)
844mpsc_init_rings(struct mpsc_port_info *pi)
845{ 784{
846 struct mpsc_rx_desc *rxre; 785 struct mpsc_rx_desc *rxre;
847 struct mpsc_tx_desc *txre; 786 struct mpsc_tx_desc *txre;
@@ -859,8 +798,8 @@ mpsc_init_rings(struct mpsc_port_info *pi)
859 * Descriptors & buffers are multiples of cacheline size and must be 798 * Descriptors & buffers are multiples of cacheline size and must be
860 * cacheline aligned. 799 * cacheline aligned.
861 */ 800 */
862 dp = ALIGN((u32) pi->dma_region, dma_get_cache_alignment()); 801 dp = ALIGN((u32)pi->dma_region, dma_get_cache_alignment());
863 dp_p = ALIGN((u32) pi->dma_region_p, dma_get_cache_alignment()); 802 dp_p = ALIGN((u32)pi->dma_region_p, dma_get_cache_alignment());
864 803
865 /* 804 /*
866 * Partition dma region into rx ring descriptor, rx buffers, 805 * Partition dma region into rx ring descriptor, rx buffers,
@@ -871,8 +810,8 @@ mpsc_init_rings(struct mpsc_port_info *pi)
871 dp += MPSC_RXR_SIZE; 810 dp += MPSC_RXR_SIZE;
872 dp_p += MPSC_RXR_SIZE; 811 dp_p += MPSC_RXR_SIZE;
873 812
874 pi->rxb = (u8 *) dp; 813 pi->rxb = (u8 *)dp;
875 pi->rxb_p = (u8 *) dp_p; 814 pi->rxb_p = (u8 *)dp_p;
876 dp += MPSC_RXB_SIZE; 815 dp += MPSC_RXB_SIZE;
877 dp_p += MPSC_RXB_SIZE; 816 dp_p += MPSC_RXB_SIZE;
878 817
@@ -883,8 +822,8 @@ mpsc_init_rings(struct mpsc_port_info *pi)
883 dp += MPSC_TXR_SIZE; 822 dp += MPSC_TXR_SIZE;
884 dp_p += MPSC_TXR_SIZE; 823 dp_p += MPSC_TXR_SIZE;
885 824
886 pi->txb = (u8 *) dp; 825 pi->txb = (u8 *)dp;
887 pi->txb_p = (u8 *) dp_p; 826 pi->txb_p = (u8 *)dp_p;
888 827
889 pi->txr_head = 0; 828 pi->txr_head = 0;
890 pi->txr_tail = 0; 829 pi->txr_tail = 0;
@@ -900,10 +839,9 @@ mpsc_init_rings(struct mpsc_port_info *pi)
900 839
901 rxre->bufsize = cpu_to_be16(MPSC_RXBE_SIZE); 840 rxre->bufsize = cpu_to_be16(MPSC_RXBE_SIZE);
902 rxre->bytecnt = cpu_to_be16(0); 841 rxre->bytecnt = cpu_to_be16(0);
903 rxre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O | 842 rxre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O
904 SDMA_DESC_CMDSTAT_EI | 843 | SDMA_DESC_CMDSTAT_EI | SDMA_DESC_CMDSTAT_F
905 SDMA_DESC_CMDSTAT_F | 844 | SDMA_DESC_CMDSTAT_L);
906 SDMA_DESC_CMDSTAT_L);
907 rxre->link = cpu_to_be32(dp_p + MPSC_RXRE_SIZE); 845 rxre->link = cpu_to_be32(dp_p + MPSC_RXRE_SIZE);
908 rxre->buf_ptr = cpu_to_be32(bp_p); 846 rxre->buf_ptr = cpu_to_be32(bp_p);
909 847
@@ -933,19 +871,19 @@ mpsc_init_rings(struct mpsc_port_info *pi)
933 } 871 }
934 txre->link = cpu_to_be32(pi->txr_p); /* Wrap last back to first */ 872 txre->link = cpu_to_be32(pi->txr_p); /* Wrap last back to first */
935 873
936 dma_cache_sync(pi->port.dev, (void *) pi->dma_region, MPSC_DMA_ALLOC_SIZE, 874 dma_cache_sync(pi->port.dev, (void *)pi->dma_region,
937 DMA_BIDIRECTIONAL); 875 MPSC_DMA_ALLOC_SIZE, DMA_BIDIRECTIONAL);
938#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 876#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
939 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 877 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
940 flush_dcache_range((ulong)pi->dma_region, 878 flush_dcache_range((ulong)pi->dma_region,
941 (ulong)pi->dma_region + MPSC_DMA_ALLOC_SIZE); 879 (ulong)pi->dma_region
880 + MPSC_DMA_ALLOC_SIZE);
942#endif 881#endif
943 882
944 return; 883 return;
945} 884}
946 885
947static void 886static void mpsc_uninit_rings(struct mpsc_port_info *pi)
948mpsc_uninit_rings(struct mpsc_port_info *pi)
949{ 887{
950 pr_debug("mpsc_uninit_rings[%d]: Uninitializing rings\n",pi->port.line); 888 pr_debug("mpsc_uninit_rings[%d]: Uninitializing rings\n",pi->port.line);
951 889
@@ -963,12 +901,9 @@ mpsc_uninit_rings(struct mpsc_port_info *pi)
963 pi->txb_p = NULL; 901 pi->txb_p = NULL;
964 pi->txr_head = 0; 902 pi->txr_head = 0;
965 pi->txr_tail = 0; 903 pi->txr_tail = 0;
966
967 return;
968} 904}
969 905
970static int 906static int mpsc_make_ready(struct mpsc_port_info *pi)
971mpsc_make_ready(struct mpsc_port_info *pi)
972{ 907{
973 int rc; 908 int rc;
974 909
@@ -993,8 +928,7 @@ mpsc_make_ready(struct mpsc_port_info *pi)
993 ****************************************************************************** 928 ******************************************************************************
994 */ 929 */
995 930
996static inline int 931static int mpsc_rx_intr(struct mpsc_port_info *pi)
997mpsc_rx_intr(struct mpsc_port_info *pi)
998{ 932{
999 struct mpsc_rx_desc *rxre; 933 struct mpsc_rx_desc *rxre;
1000 struct tty_struct *tty = pi->port.info->tty; 934 struct tty_struct *tty = pi->port.info->tty;
@@ -1007,21 +941,24 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1007 941
1008 rxre = (struct mpsc_rx_desc *)(pi->rxr + (pi->rxr_posn*MPSC_RXRE_SIZE)); 942 rxre = (struct mpsc_rx_desc *)(pi->rxr + (pi->rxr_posn*MPSC_RXRE_SIZE));
1009 943
1010 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE); 944 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE,
945 DMA_FROM_DEVICE);
1011#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 946#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1012 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 947 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1013 invalidate_dcache_range((ulong)rxre, 948 invalidate_dcache_range((ulong)rxre,
1014 (ulong)rxre + MPSC_RXRE_SIZE); 949 (ulong)rxre + MPSC_RXRE_SIZE);
1015#endif 950#endif
1016 951
1017 /* 952 /*
1018 * Loop through Rx descriptors handling ones that have been completed. 953 * Loop through Rx descriptors handling ones that have been completed.
1019 */ 954 */
1020 while (!((cmdstat = be32_to_cpu(rxre->cmdstat)) & SDMA_DESC_CMDSTAT_O)){ 955 while (!((cmdstat = be32_to_cpu(rxre->cmdstat))
956 & SDMA_DESC_CMDSTAT_O)) {
1021 bytes_in = be16_to_cpu(rxre->bytecnt); 957 bytes_in = be16_to_cpu(rxre->bytecnt);
1022 958
1023 /* Following use of tty struct directly is deprecated */ 959 /* Following use of tty struct directly is deprecated */
1024 if (unlikely(tty_buffer_request_room(tty, bytes_in) < bytes_in)) { 960 if (unlikely(tty_buffer_request_room(tty, bytes_in)
961 < bytes_in)) {
1025 if (tty->low_latency) 962 if (tty->low_latency)
1026 tty_flip_buffer_push(tty); 963 tty_flip_buffer_push(tty);
1027 /* 964 /*
@@ -1031,11 +968,12 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1031 } 968 }
1032 969
1033 bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE); 970 bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE);
1034 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_RXBE_SIZE, DMA_FROM_DEVICE); 971 dma_cache_sync(pi->port.dev, (void *)bp, MPSC_RXBE_SIZE,
972 DMA_FROM_DEVICE);
1035#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 973#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1036 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 974 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1037 invalidate_dcache_range((ulong)bp, 975 invalidate_dcache_range((ulong)bp,
1038 (ulong)bp + MPSC_RXBE_SIZE); 976 (ulong)bp + MPSC_RXBE_SIZE);
1039#endif 977#endif
1040 978
1041 /* 979 /*
@@ -1046,8 +984,9 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1046 * we'll assume there is no data in the buffer. 984 * we'll assume there is no data in the buffer.
1047 * If there is...it gets lost. 985 * If there is...it gets lost.
1048 */ 986 */
1049 if (unlikely(cmdstat & (SDMA_DESC_CMDSTAT_BR | 987 if (unlikely(cmdstat & (SDMA_DESC_CMDSTAT_BR
1050 SDMA_DESC_CMDSTAT_FR | SDMA_DESC_CMDSTAT_OR))) { 988 | SDMA_DESC_CMDSTAT_FR
989 | SDMA_DESC_CMDSTAT_OR))) {
1051 990
1052 pi->port.icount.rx++; 991 pi->port.icount.rx++;
1053 992
@@ -1056,11 +995,11 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1056 995
1057 if (uart_handle_break(&pi->port)) 996 if (uart_handle_break(&pi->port))
1058 goto next_frame; 997 goto next_frame;
1059 } 998 } else if (cmdstat & SDMA_DESC_CMDSTAT_FR) {
1060 else if (cmdstat & SDMA_DESC_CMDSTAT_FR)/* Framing */
1061 pi->port.icount.frame++; 999 pi->port.icount.frame++;
1062 else if (cmdstat & SDMA_DESC_CMDSTAT_OR) /* Overrun */ 1000 } else if (cmdstat & SDMA_DESC_CMDSTAT_OR) {
1063 pi->port.icount.overrun++; 1001 pi->port.icount.overrun++;
1002 }
1064 1003
1065 cmdstat &= pi->port.read_status_mask; 1004 cmdstat &= pi->port.read_status_mask;
1066 1005
@@ -1080,12 +1019,12 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1080 goto next_frame; 1019 goto next_frame;
1081 } 1020 }
1082 1021
1083 if ((unlikely(cmdstat & (SDMA_DESC_CMDSTAT_BR | 1022 if ((unlikely(cmdstat & (SDMA_DESC_CMDSTAT_BR
1084 SDMA_DESC_CMDSTAT_FR | SDMA_DESC_CMDSTAT_OR))) && 1023 | SDMA_DESC_CMDSTAT_FR
1085 !(cmdstat & pi->port.ignore_status_mask)) 1024 | SDMA_DESC_CMDSTAT_OR)))
1086 1025 && !(cmdstat & pi->port.ignore_status_mask)) {
1087 tty_insert_flip_char(tty, *bp, flag); 1026 tty_insert_flip_char(tty, *bp, flag);
1088 else { 1027 } else {
1089 for (i=0; i<bytes_in; i++) 1028 for (i=0; i<bytes_in; i++)
1090 tty_insert_flip_char(tty, *bp++, TTY_NORMAL); 1029 tty_insert_flip_char(tty, *bp++, TTY_NORMAL);
1091 1030
@@ -1095,29 +1034,29 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1095next_frame: 1034next_frame:
1096 rxre->bytecnt = cpu_to_be16(0); 1035 rxre->bytecnt = cpu_to_be16(0);
1097 wmb(); 1036 wmb();
1098 rxre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O | 1037 rxre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O
1099 SDMA_DESC_CMDSTAT_EI | 1038 | SDMA_DESC_CMDSTAT_EI | SDMA_DESC_CMDSTAT_F
1100 SDMA_DESC_CMDSTAT_F | 1039 | SDMA_DESC_CMDSTAT_L);
1101 SDMA_DESC_CMDSTAT_L);
1102 wmb(); 1040 wmb();
1103 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL); 1041 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE,
1042 DMA_BIDIRECTIONAL);
1104#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1043#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1105 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1044 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1106 flush_dcache_range((ulong)rxre, 1045 flush_dcache_range((ulong)rxre,
1107 (ulong)rxre + MPSC_RXRE_SIZE); 1046 (ulong)rxre + MPSC_RXRE_SIZE);
1108#endif 1047#endif
1109 1048
1110 /* Advance to next descriptor */ 1049 /* Advance to next descriptor */
1111 pi->rxr_posn = (pi->rxr_posn + 1) & (MPSC_RXR_ENTRIES - 1); 1050 pi->rxr_posn = (pi->rxr_posn + 1) & (MPSC_RXR_ENTRIES - 1);
1112 rxre = (struct mpsc_rx_desc *)(pi->rxr + 1051 rxre = (struct mpsc_rx_desc *)
1113 (pi->rxr_posn * MPSC_RXRE_SIZE)); 1052 (pi->rxr + (pi->rxr_posn * MPSC_RXRE_SIZE));
1114 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE); 1053 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE,
1054 DMA_FROM_DEVICE);
1115#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1055#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1116 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1056 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1117 invalidate_dcache_range((ulong)rxre, 1057 invalidate_dcache_range((ulong)rxre,
1118 (ulong)rxre + MPSC_RXRE_SIZE); 1058 (ulong)rxre + MPSC_RXRE_SIZE);
1119#endif 1059#endif
1120
1121 rc = 1; 1060 rc = 1;
1122 } 1061 }
1123 1062
@@ -1129,42 +1068,38 @@ next_frame:
1129 return rc; 1068 return rc;
1130} 1069}
1131 1070
1132static inline void 1071static void mpsc_setup_tx_desc(struct mpsc_port_info *pi, u32 count, u32 intr)
1133mpsc_setup_tx_desc(struct mpsc_port_info *pi, u32 count, u32 intr)
1134{ 1072{
1135 struct mpsc_tx_desc *txre; 1073 struct mpsc_tx_desc *txre;
1136 1074
1137 txre = (struct mpsc_tx_desc *)(pi->txr + 1075 txre = (struct mpsc_tx_desc *)(pi->txr
1138 (pi->txr_head * MPSC_TXRE_SIZE)); 1076 + (pi->txr_head * MPSC_TXRE_SIZE));
1139 1077
1140 txre->bytecnt = cpu_to_be16(count); 1078 txre->bytecnt = cpu_to_be16(count);
1141 txre->shadow = txre->bytecnt; 1079 txre->shadow = txre->bytecnt;
1142 wmb(); /* ensure cmdstat is last field updated */ 1080 wmb(); /* ensure cmdstat is last field updated */
1143 txre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O | SDMA_DESC_CMDSTAT_F | 1081 txre->cmdstat = cpu_to_be32(SDMA_DESC_CMDSTAT_O | SDMA_DESC_CMDSTAT_F
1144 SDMA_DESC_CMDSTAT_L | ((intr) ? 1082 | SDMA_DESC_CMDSTAT_L
1145 SDMA_DESC_CMDSTAT_EI 1083 | ((intr) ? SDMA_DESC_CMDSTAT_EI : 0));
1146 : 0));
1147 wmb(); 1084 wmb();
1148 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_BIDIRECTIONAL); 1085 dma_cache_sync(pi->port.dev, (void *)txre, MPSC_TXRE_SIZE,
1086 DMA_BIDIRECTIONAL);
1149#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1087#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1150 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1088 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1151 flush_dcache_range((ulong)txre, 1089 flush_dcache_range((ulong)txre,
1152 (ulong)txre + MPSC_TXRE_SIZE); 1090 (ulong)txre + MPSC_TXRE_SIZE);
1153#endif 1091#endif
1154
1155 return;
1156} 1092}
1157 1093
1158static inline void 1094static void mpsc_copy_tx_data(struct mpsc_port_info *pi)
1159mpsc_copy_tx_data(struct mpsc_port_info *pi)
1160{ 1095{
1161 struct circ_buf *xmit = &pi->port.info->xmit; 1096 struct circ_buf *xmit = &pi->port.info->xmit;
1162 u8 *bp; 1097 u8 *bp;
1163 u32 i; 1098 u32 i;
1164 1099
1165 /* Make sure the desc ring isn't full */ 1100 /* Make sure the desc ring isn't full */
1166 while (CIRC_CNT(pi->txr_head, pi->txr_tail, MPSC_TXR_ENTRIES) < 1101 while (CIRC_CNT(pi->txr_head, pi->txr_tail, MPSC_TXR_ENTRIES)
1167 (MPSC_TXR_ENTRIES - 1)) { 1102 < (MPSC_TXR_ENTRIES - 1)) {
1168 if (pi->port.x_char) { 1103 if (pi->port.x_char) {
1169 /* 1104 /*
1170 * Ideally, we should use the TCS field in 1105 * Ideally, we should use the TCS field in
@@ -1178,11 +1113,11 @@ mpsc_copy_tx_data(struct mpsc_port_info *pi)
1178 *bp = pi->port.x_char; 1113 *bp = pi->port.x_char;
1179 pi->port.x_char = 0; 1114 pi->port.x_char = 0;
1180 i = 1; 1115 i = 1;
1181 } 1116 } else if (!uart_circ_empty(xmit)
1182 else if (!uart_circ_empty(xmit) && !uart_tx_stopped(&pi->port)){ 1117 && !uart_tx_stopped(&pi->port)) {
1183 i = min((u32) MPSC_TXBE_SIZE, 1118 i = min((u32)MPSC_TXBE_SIZE,
1184 (u32) uart_circ_chars_pending(xmit)); 1119 (u32)uart_circ_chars_pending(xmit));
1185 i = min(i, (u32) CIRC_CNT_TO_END(xmit->head, xmit->tail, 1120 i = min(i, (u32)CIRC_CNT_TO_END(xmit->head, xmit->tail,
1186 UART_XMIT_SIZE)); 1121 UART_XMIT_SIZE));
1187 bp = pi->txb + (pi->txr_head * MPSC_TXBE_SIZE); 1122 bp = pi->txb + (pi->txr_head * MPSC_TXBE_SIZE);
1188 memcpy(bp, &xmit->buf[xmit->tail], i); 1123 memcpy(bp, &xmit->buf[xmit->tail], i);
@@ -1190,27 +1125,25 @@ mpsc_copy_tx_data(struct mpsc_port_info *pi)
1190 1125
1191 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 1126 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
1192 uart_write_wakeup(&pi->port); 1127 uart_write_wakeup(&pi->port);
1193 } 1128 } else { /* All tx data copied into ring bufs */
1194 else /* All tx data copied into ring bufs */
1195 return; 1129 return;
1130 }
1196 1131
1197 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL); 1132 dma_cache_sync(pi->port.dev, (void *)bp, MPSC_TXBE_SIZE,
1133 DMA_BIDIRECTIONAL);
1198#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1134#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1199 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1135 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1200 flush_dcache_range((ulong)bp, 1136 flush_dcache_range((ulong)bp,
1201 (ulong)bp + MPSC_TXBE_SIZE); 1137 (ulong)bp + MPSC_TXBE_SIZE);
1202#endif 1138#endif
1203 mpsc_setup_tx_desc(pi, i, 1); 1139 mpsc_setup_tx_desc(pi, i, 1);
1204 1140
1205 /* Advance to next descriptor */ 1141 /* Advance to next descriptor */
1206 pi->txr_head = (pi->txr_head + 1) & (MPSC_TXR_ENTRIES - 1); 1142 pi->txr_head = (pi->txr_head + 1) & (MPSC_TXR_ENTRIES - 1);
1207 } 1143 }
1208
1209 return;
1210} 1144}
1211 1145
1212static inline int 1146static int mpsc_tx_intr(struct mpsc_port_info *pi)
1213mpsc_tx_intr(struct mpsc_port_info *pi)
1214{ 1147{
1215 struct mpsc_tx_desc *txre; 1148 struct mpsc_tx_desc *txre;
1216 int rc = 0; 1149 int rc = 0;
@@ -1219,14 +1152,15 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
1219 spin_lock_irqsave(&pi->tx_lock, iflags); 1152 spin_lock_irqsave(&pi->tx_lock, iflags);
1220 1153
1221 if (!mpsc_sdma_tx_active(pi)) { 1154 if (!mpsc_sdma_tx_active(pi)) {
1222 txre = (struct mpsc_tx_desc *)(pi->txr + 1155 txre = (struct mpsc_tx_desc *)(pi->txr
1223 (pi->txr_tail * MPSC_TXRE_SIZE)); 1156 + (pi->txr_tail * MPSC_TXRE_SIZE));
1224 1157
1225 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE); 1158 dma_cache_sync(pi->port.dev, (void *)txre, MPSC_TXRE_SIZE,
1159 DMA_FROM_DEVICE);
1226#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1160#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1227 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1161 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1228 invalidate_dcache_range((ulong)txre, 1162 invalidate_dcache_range((ulong)txre,
1229 (ulong)txre + MPSC_TXRE_SIZE); 1163 (ulong)txre + MPSC_TXRE_SIZE);
1230#endif 1164#endif
1231 1165
1232 while (!(be32_to_cpu(txre->cmdstat) & SDMA_DESC_CMDSTAT_O)) { 1166 while (!(be32_to_cpu(txre->cmdstat) & SDMA_DESC_CMDSTAT_O)) {
@@ -1238,14 +1172,14 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
1238 if (pi->txr_head == pi->txr_tail) 1172 if (pi->txr_head == pi->txr_tail)
1239 break; 1173 break;
1240 1174
1241 txre = (struct mpsc_tx_desc *)(pi->txr + 1175 txre = (struct mpsc_tx_desc *)(pi->txr
1242 (pi->txr_tail * MPSC_TXRE_SIZE)); 1176 + (pi->txr_tail * MPSC_TXRE_SIZE));
1243 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, 1177 dma_cache_sync(pi->port.dev, (void *)txre,
1244 DMA_FROM_DEVICE); 1178 MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
1245#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1179#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1246 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1180 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1247 invalidate_dcache_range((ulong)txre, 1181 invalidate_dcache_range((ulong)txre,
1248 (ulong)txre + MPSC_TXRE_SIZE); 1182 (ulong)txre + MPSC_TXRE_SIZE);
1249#endif 1183#endif
1250 } 1184 }
1251 1185
@@ -1262,8 +1196,7 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
1262 * the interrupt, then handle any completed Rx/Tx descriptors. When done 1196 * the interrupt, then handle any completed Rx/Tx descriptors. When done
1263 * handling those descriptors, we restart the Rx/Tx engines if they're stopped. 1197 * handling those descriptors, we restart the Rx/Tx engines if they're stopped.
1264 */ 1198 */
1265static irqreturn_t 1199static irqreturn_t mpsc_sdma_intr(int irq, void *dev_id)
1266mpsc_sdma_intr(int irq, void *dev_id)
1267{ 1200{
1268 struct mpsc_port_info *pi = dev_id; 1201 struct mpsc_port_info *pi = dev_id;
1269 ulong iflags; 1202 ulong iflags;
@@ -1290,8 +1223,7 @@ mpsc_sdma_intr(int irq, void *dev_id)
1290 * 1223 *
1291 ****************************************************************************** 1224 ******************************************************************************
1292 */ 1225 */
1293static uint 1226static uint mpsc_tx_empty(struct uart_port *port)
1294mpsc_tx_empty(struct uart_port *port)
1295{ 1227{
1296 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1228 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1297 ulong iflags; 1229 ulong iflags;
@@ -1304,21 +1236,18 @@ mpsc_tx_empty(struct uart_port *port)
1304 return rc; 1236 return rc;
1305} 1237}
1306 1238
1307static void 1239static void mpsc_set_mctrl(struct uart_port *port, uint mctrl)
1308mpsc_set_mctrl(struct uart_port *port, uint mctrl)
1309{ 1240{
1310 /* Have no way to set modem control lines AFAICT */ 1241 /* Have no way to set modem control lines AFAICT */
1311 return;
1312} 1242}
1313 1243
1314static uint 1244static uint mpsc_get_mctrl(struct uart_port *port)
1315mpsc_get_mctrl(struct uart_port *port)
1316{ 1245{
1317 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1246 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1318 u32 mflags, status; 1247 u32 mflags, status;
1319 1248
1320 status = (pi->mirror_regs) ? pi->MPSC_CHR_10_m : 1249 status = (pi->mirror_regs) ? pi->MPSC_CHR_10_m
1321 readl(pi->mpsc_base + MPSC_CHR_10); 1250 : readl(pi->mpsc_base + MPSC_CHR_10);
1322 1251
1323 mflags = 0; 1252 mflags = 0;
1324 if (status & 0x1) 1253 if (status & 0x1)
@@ -1329,19 +1258,16 @@ mpsc_get_mctrl(struct uart_port *port)
1329 return mflags | TIOCM_DSR; /* No way to tell if DSR asserted */ 1258 return mflags | TIOCM_DSR; /* No way to tell if DSR asserted */
1330} 1259}
1331 1260
1332static void 1261static void mpsc_stop_tx(struct uart_port *port)
1333mpsc_stop_tx(struct uart_port *port)
1334{ 1262{
1335 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1263 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1336 1264
1337 pr_debug("mpsc_stop_tx[%d]\n", port->line); 1265 pr_debug("mpsc_stop_tx[%d]\n", port->line);
1338 1266
1339 mpsc_freeze(pi); 1267 mpsc_freeze(pi);
1340 return;
1341} 1268}
1342 1269
1343static void 1270static void mpsc_start_tx(struct uart_port *port)
1344mpsc_start_tx(struct uart_port *port)
1345{ 1271{
1346 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1272 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1347 unsigned long iflags; 1273 unsigned long iflags;
@@ -1355,42 +1281,45 @@ mpsc_start_tx(struct uart_port *port)
1355 spin_unlock_irqrestore(&pi->tx_lock, iflags); 1281 spin_unlock_irqrestore(&pi->tx_lock, iflags);
1356 1282
1357 pr_debug("mpsc_start_tx[%d]\n", port->line); 1283 pr_debug("mpsc_start_tx[%d]\n", port->line);
1358 return;
1359} 1284}
1360 1285
1361static void 1286static void mpsc_start_rx(struct mpsc_port_info *pi)
1362mpsc_start_rx(struct mpsc_port_info *pi)
1363{ 1287{
1364 pr_debug("mpsc_start_rx[%d]: Starting...\n", pi->port.line); 1288 pr_debug("mpsc_start_rx[%d]: Starting...\n", pi->port.line);
1365 1289
1366 /* Issue a Receive Abort to clear any receive errors */
1367 writel(MPSC_CHR_2_RA, pi->mpsc_base + MPSC_CHR_2);
1368 if (pi->rcv_data) { 1290 if (pi->rcv_data) {
1369 mpsc_enter_hunt(pi); 1291 mpsc_enter_hunt(pi);
1370 mpsc_sdma_cmd(pi, SDMA_SDCM_ERD); 1292 mpsc_sdma_cmd(pi, SDMA_SDCM_ERD);
1371 } 1293 }
1372 return;
1373} 1294}
1374 1295
1375static void 1296static void mpsc_stop_rx(struct uart_port *port)
1376mpsc_stop_rx(struct uart_port *port)
1377{ 1297{
1378 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1298 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1379 1299
1380 pr_debug("mpsc_stop_rx[%d]: Stopping...\n", port->line); 1300 pr_debug("mpsc_stop_rx[%d]: Stopping...\n", port->line);
1381 1301
1302 if (pi->mirror_regs) {
1303 writel(pi->MPSC_CHR_2_m | MPSC_CHR_2_RA,
1304 pi->mpsc_base + MPSC_CHR_2);
1305 /* Erratum prevents reading CHR_2 so just delay for a while */
1306 udelay(100);
1307 } else {
1308 writel(readl(pi->mpsc_base + MPSC_CHR_2) | MPSC_CHR_2_RA,
1309 pi->mpsc_base + MPSC_CHR_2);
1310
1311 while (readl(pi->mpsc_base + MPSC_CHR_2) & MPSC_CHR_2_RA)
1312 udelay(10);
1313 }
1314
1382 mpsc_sdma_cmd(pi, SDMA_SDCM_AR); 1315 mpsc_sdma_cmd(pi, SDMA_SDCM_AR);
1383 return;
1384} 1316}
1385 1317
1386static void 1318static void mpsc_enable_ms(struct uart_port *port)
1387mpsc_enable_ms(struct uart_port *port)
1388{ 1319{
1389 return; /* Not supported */
1390} 1320}
1391 1321
1392static void 1322static void mpsc_break_ctl(struct uart_port *port, int ctl)
1393mpsc_break_ctl(struct uart_port *port, int ctl)
1394{ 1323{
1395 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1324 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1396 ulong flags; 1325 ulong flags;
@@ -1403,12 +1332,9 @@ mpsc_break_ctl(struct uart_port *port, int ctl)
1403 pi->MPSC_CHR_1_m = v; 1332 pi->MPSC_CHR_1_m = v;
1404 writel(v, pi->mpsc_base + MPSC_CHR_1); 1333 writel(v, pi->mpsc_base + MPSC_CHR_1);
1405 spin_unlock_irqrestore(&pi->port.lock, flags); 1334 spin_unlock_irqrestore(&pi->port.lock, flags);
1406
1407 return;
1408} 1335}
1409 1336
1410static int 1337static int mpsc_startup(struct uart_port *port)
1411mpsc_startup(struct uart_port *port)
1412{ 1338{
1413 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1339 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1414 u32 flag = 0; 1340 u32 flag = 0;
@@ -1426,20 +1352,19 @@ mpsc_startup(struct uart_port *port)
1426 flag = IRQF_SHARED; 1352 flag = IRQF_SHARED;
1427 1353
1428 if (request_irq(pi->port.irq, mpsc_sdma_intr, flag, 1354 if (request_irq(pi->port.irq, mpsc_sdma_intr, flag,
1429 "mpsc-sdma", pi)) 1355 "mpsc-sdma", pi))
1430 printk(KERN_ERR "MPSC: Can't get SDMA IRQ %d\n", 1356 printk(KERN_ERR "MPSC: Can't get SDMA IRQ %d\n",
1431 pi->port.irq); 1357 pi->port.irq);
1432 1358
1433 mpsc_sdma_intr_unmask(pi, 0xf); 1359 mpsc_sdma_intr_unmask(pi, 0xf);
1434 mpsc_sdma_set_rx_ring(pi, (struct mpsc_rx_desc *)(pi->rxr_p + 1360 mpsc_sdma_set_rx_ring(pi, (struct mpsc_rx_desc *)(pi->rxr_p
1435 (pi->rxr_posn * MPSC_RXRE_SIZE))); 1361 + (pi->rxr_posn * MPSC_RXRE_SIZE)));
1436 } 1362 }
1437 1363
1438 return rc; 1364 return rc;
1439} 1365}
1440 1366
1441static void 1367static void mpsc_shutdown(struct uart_port *port)
1442mpsc_shutdown(struct uart_port *port)
1443{ 1368{
1444 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1369 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1445 1370
@@ -1447,11 +1372,9 @@ mpsc_shutdown(struct uart_port *port)
1447 1372
1448 mpsc_sdma_stop(pi); 1373 mpsc_sdma_stop(pi);
1449 free_irq(pi->port.irq, pi); 1374 free_irq(pi->port.irq, pi);
1450 return;
1451} 1375}
1452 1376
1453static void 1377static void mpsc_set_termios(struct uart_port *port, struct ktermios *termios,
1454mpsc_set_termios(struct uart_port *port, struct ktermios *termios,
1455 struct ktermios *old) 1378 struct ktermios *old)
1456{ 1379{
1457 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1380 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
@@ -1508,12 +1431,11 @@ mpsc_set_termios(struct uart_port *port, struct ktermios *termios,
1508 mpsc_set_baudrate(pi, baud); 1431 mpsc_set_baudrate(pi, baud);
1509 1432
1510 /* Characters/events to read */ 1433 /* Characters/events to read */
1511 pi->rcv_data = 1;
1512 pi->port.read_status_mask = SDMA_DESC_CMDSTAT_OR; 1434 pi->port.read_status_mask = SDMA_DESC_CMDSTAT_OR;
1513 1435
1514 if (termios->c_iflag & INPCK) 1436 if (termios->c_iflag & INPCK)
1515 pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_PE | 1437 pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_PE
1516 SDMA_DESC_CMDSTAT_FR; 1438 | SDMA_DESC_CMDSTAT_FR;
1517 1439
1518 if (termios->c_iflag & (BRKINT | PARMRK)) 1440 if (termios->c_iflag & (BRKINT | PARMRK))
1519 pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_BR; 1441 pi->port.read_status_mask |= SDMA_DESC_CMDSTAT_BR;
@@ -1522,8 +1444,8 @@ mpsc_set_termios(struct uart_port *port, struct ktermios *termios,
1522 pi->port.ignore_status_mask = 0; 1444 pi->port.ignore_status_mask = 0;
1523 1445
1524 if (termios->c_iflag & IGNPAR) 1446 if (termios->c_iflag & IGNPAR)
1525 pi->port.ignore_status_mask |= SDMA_DESC_CMDSTAT_PE | 1447 pi->port.ignore_status_mask |= SDMA_DESC_CMDSTAT_PE
1526 SDMA_DESC_CMDSTAT_FR; 1448 | SDMA_DESC_CMDSTAT_FR;
1527 1449
1528 if (termios->c_iflag & IGNBRK) { 1450 if (termios->c_iflag & IGNBRK) {
1529 pi->port.ignore_status_mask |= SDMA_DESC_CMDSTAT_BR; 1451 pi->port.ignore_status_mask |= SDMA_DESC_CMDSTAT_BR;
@@ -1532,32 +1454,32 @@ mpsc_set_termios(struct uart_port *port, struct ktermios *termios,
1532 pi->port.ignore_status_mask |= SDMA_DESC_CMDSTAT_OR; 1454 pi->port.ignore_status_mask |= SDMA_DESC_CMDSTAT_OR;
1533 } 1455 }
1534 1456
1535 /* Ignore all chars if CREAD not set */ 1457 if ((termios->c_cflag & CREAD)) {
1536 if (!(termios->c_cflag & CREAD)) 1458 if (!pi->rcv_data) {
1459 pi->rcv_data = 1;
1460 mpsc_start_rx(pi);
1461 }
1462 } else if (pi->rcv_data) {
1463 mpsc_stop_rx(port);
1537 pi->rcv_data = 0; 1464 pi->rcv_data = 0;
1538 else 1465 }
1539 mpsc_start_rx(pi);
1540 1466
1541 spin_unlock_irqrestore(&pi->port.lock, flags); 1467 spin_unlock_irqrestore(&pi->port.lock, flags);
1542 return;
1543} 1468}
1544 1469
1545static const char * 1470static const char *mpsc_type(struct uart_port *port)
1546mpsc_type(struct uart_port *port)
1547{ 1471{
1548 pr_debug("mpsc_type[%d]: port type: %s\n", port->line,MPSC_DRIVER_NAME); 1472 pr_debug("mpsc_type[%d]: port type: %s\n", port->line,MPSC_DRIVER_NAME);
1549 return MPSC_DRIVER_NAME; 1473 return MPSC_DRIVER_NAME;
1550} 1474}
1551 1475
1552static int 1476static int mpsc_request_port(struct uart_port *port)
1553mpsc_request_port(struct uart_port *port)
1554{ 1477{
1555 /* Should make chip/platform specific call */ 1478 /* Should make chip/platform specific call */
1556 return 0; 1479 return 0;
1557} 1480}
1558 1481
1559static void 1482static void mpsc_release_port(struct uart_port *port)
1560mpsc_release_port(struct uart_port *port)
1561{ 1483{
1562 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1484 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1563 1485
@@ -1566,18 +1488,13 @@ mpsc_release_port(struct uart_port *port)
1566 mpsc_free_ring_mem(pi); 1488 mpsc_free_ring_mem(pi);
1567 pi->ready = 0; 1489 pi->ready = 0;
1568 } 1490 }
1569
1570 return;
1571} 1491}
1572 1492
1573static void 1493static void mpsc_config_port(struct uart_port *port, int flags)
1574mpsc_config_port(struct uart_port *port, int flags)
1575{ 1494{
1576 return;
1577} 1495}
1578 1496
1579static int 1497static int mpsc_verify_port(struct uart_port *port, struct serial_struct *ser)
1580mpsc_verify_port(struct uart_port *port, struct serial_struct *ser)
1581{ 1498{
1582 struct mpsc_port_info *pi = (struct mpsc_port_info *)port; 1499 struct mpsc_port_info *pi = (struct mpsc_port_info *)port;
1583 int rc = 0; 1500 int rc = 0;
@@ -1603,22 +1520,22 @@ mpsc_verify_port(struct uart_port *port, struct serial_struct *ser)
1603} 1520}
1604 1521
1605static struct uart_ops mpsc_pops = { 1522static struct uart_ops mpsc_pops = {
1606 .tx_empty = mpsc_tx_empty, 1523 .tx_empty = mpsc_tx_empty,
1607 .set_mctrl = mpsc_set_mctrl, 1524 .set_mctrl = mpsc_set_mctrl,
1608 .get_mctrl = mpsc_get_mctrl, 1525 .get_mctrl = mpsc_get_mctrl,
1609 .stop_tx = mpsc_stop_tx, 1526 .stop_tx = mpsc_stop_tx,
1610 .start_tx = mpsc_start_tx, 1527 .start_tx = mpsc_start_tx,
1611 .stop_rx = mpsc_stop_rx, 1528 .stop_rx = mpsc_stop_rx,
1612 .enable_ms = mpsc_enable_ms, 1529 .enable_ms = mpsc_enable_ms,
1613 .break_ctl = mpsc_break_ctl, 1530 .break_ctl = mpsc_break_ctl,
1614 .startup = mpsc_startup, 1531 .startup = mpsc_startup,
1615 .shutdown = mpsc_shutdown, 1532 .shutdown = mpsc_shutdown,
1616 .set_termios = mpsc_set_termios, 1533 .set_termios = mpsc_set_termios,
1617 .type = mpsc_type, 1534 .type = mpsc_type,
1618 .release_port = mpsc_release_port, 1535 .release_port = mpsc_release_port,
1619 .request_port = mpsc_request_port, 1536 .request_port = mpsc_request_port,
1620 .config_port = mpsc_config_port, 1537 .config_port = mpsc_config_port,
1621 .verify_port = mpsc_verify_port, 1538 .verify_port = mpsc_verify_port,
1622}; 1539};
1623 1540
1624/* 1541/*
@@ -1630,8 +1547,7 @@ static struct uart_ops mpsc_pops = {
1630 */ 1547 */
1631 1548
1632#ifdef CONFIG_SERIAL_MPSC_CONSOLE 1549#ifdef CONFIG_SERIAL_MPSC_CONSOLE
1633static void 1550static void mpsc_console_write(struct console *co, const char *s, uint count)
1634mpsc_console_write(struct console *co, const char *s, uint count)
1635{ 1551{
1636 struct mpsc_port_info *pi = &mpsc_ports[co->index]; 1552 struct mpsc_port_info *pi = &mpsc_ports[co->index];
1637 u8 *bp, *dp, add_cr = 0; 1553 u8 *bp, *dp, add_cr = 0;
@@ -1660,8 +1576,7 @@ mpsc_console_write(struct console *co, const char *s, uint count)
1660 if (add_cr) { 1576 if (add_cr) {
1661 *(dp++) = '\r'; 1577 *(dp++) = '\r';
1662 add_cr = 0; 1578 add_cr = 0;
1663 } 1579 } else {
1664 else {
1665 *(dp++) = *s; 1580 *(dp++) = *s;
1666 1581
1667 if (*(s++) == '\n') { /* add '\r' after '\n' */ 1582 if (*(s++) == '\n') { /* add '\r' after '\n' */
@@ -1673,11 +1588,12 @@ mpsc_console_write(struct console *co, const char *s, uint count)
1673 count--; 1588 count--;
1674 } 1589 }
1675 1590
1676 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL); 1591 dma_cache_sync(pi->port.dev, (void *)bp, MPSC_TXBE_SIZE,
1592 DMA_BIDIRECTIONAL);
1677#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1593#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1678 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1594 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1679 flush_dcache_range((ulong)bp, 1595 flush_dcache_range((ulong)bp,
1680 (ulong)bp + MPSC_TXBE_SIZE); 1596 (ulong)bp + MPSC_TXBE_SIZE);
1681#endif 1597#endif
1682 mpsc_setup_tx_desc(pi, i, 0); 1598 mpsc_setup_tx_desc(pi, i, 0);
1683 pi->txr_head = (pi->txr_head + 1) & (MPSC_TXR_ENTRIES - 1); 1599 pi->txr_head = (pi->txr_head + 1) & (MPSC_TXR_ENTRIES - 1);
@@ -1690,11 +1606,9 @@ mpsc_console_write(struct console *co, const char *s, uint count)
1690 } 1606 }
1691 1607
1692 spin_unlock_irqrestore(&pi->tx_lock, iflags); 1608 spin_unlock_irqrestore(&pi->tx_lock, iflags);
1693 return;
1694} 1609}
1695 1610
1696static int __init 1611static int __init mpsc_console_setup(struct console *co, char *options)
1697mpsc_console_setup(struct console *co, char *options)
1698{ 1612{
1699 struct mpsc_port_info *pi; 1613 struct mpsc_port_info *pi;
1700 int baud, bits, parity, flow; 1614 int baud, bits, parity, flow;
@@ -1723,17 +1637,16 @@ mpsc_console_setup(struct console *co, char *options)
1723} 1637}
1724 1638
1725static struct console mpsc_console = { 1639static struct console mpsc_console = {
1726 .name = MPSC_DEV_NAME, 1640 .name = MPSC_DEV_NAME,
1727 .write = mpsc_console_write, 1641 .write = mpsc_console_write,
1728 .device = uart_console_device, 1642 .device = uart_console_device,
1729 .setup = mpsc_console_setup, 1643 .setup = mpsc_console_setup,
1730 .flags = CON_PRINTBUFFER, 1644 .flags = CON_PRINTBUFFER,
1731 .index = -1, 1645 .index = -1,
1732 .data = &mpsc_reg, 1646 .data = &mpsc_reg,
1733}; 1647};
1734 1648
1735static int __init 1649static int __init mpsc_late_console_init(void)
1736mpsc_late_console_init(void)
1737{ 1650{
1738 pr_debug("mpsc_late_console_init: Enter\n"); 1651 pr_debug("mpsc_late_console_init: Enter\n");
1739 1652
@@ -1755,43 +1668,40 @@ late_initcall(mpsc_late_console_init);
1755 * 1668 *
1756 ****************************************************************************** 1669 ******************************************************************************
1757 */ 1670 */
1758static void 1671static void mpsc_resource_err(char *s)
1759mpsc_resource_err(char *s)
1760{ 1672{
1761 printk(KERN_WARNING "MPSC: Platform device resource error in %s\n", s); 1673 printk(KERN_WARNING "MPSC: Platform device resource error in %s\n", s);
1762 return;
1763} 1674}
1764 1675
1765static int 1676static int mpsc_shared_map_regs(struct platform_device *pd)
1766mpsc_shared_map_regs(struct platform_device *pd)
1767{ 1677{
1768 struct resource *r; 1678 struct resource *r;
1769 1679
1770 if ((r = platform_get_resource(pd, IORESOURCE_MEM, 1680 if ((r = platform_get_resource(pd, IORESOURCE_MEM,
1771 MPSC_ROUTING_BASE_ORDER)) && request_mem_region(r->start, 1681 MPSC_ROUTING_BASE_ORDER))
1772 MPSC_ROUTING_REG_BLOCK_SIZE, "mpsc_routing_regs")) { 1682 && request_mem_region(r->start,
1773 1683 MPSC_ROUTING_REG_BLOCK_SIZE,
1684 "mpsc_routing_regs")) {
1774 mpsc_shared_regs.mpsc_routing_base = ioremap(r->start, 1685 mpsc_shared_regs.mpsc_routing_base = ioremap(r->start,
1775 MPSC_ROUTING_REG_BLOCK_SIZE); 1686 MPSC_ROUTING_REG_BLOCK_SIZE);
1776 mpsc_shared_regs.mpsc_routing_base_p = r->start; 1687 mpsc_shared_regs.mpsc_routing_base_p = r->start;
1777 } 1688 } else {
1778 else {
1779 mpsc_resource_err("MPSC routing base"); 1689 mpsc_resource_err("MPSC routing base");
1780 return -ENOMEM; 1690 return -ENOMEM;
1781 } 1691 }
1782 1692
1783 if ((r = platform_get_resource(pd, IORESOURCE_MEM, 1693 if ((r = platform_get_resource(pd, IORESOURCE_MEM,
1784 MPSC_SDMA_INTR_BASE_ORDER)) && request_mem_region(r->start, 1694 MPSC_SDMA_INTR_BASE_ORDER))
1785 MPSC_SDMA_INTR_REG_BLOCK_SIZE, "sdma_intr_regs")) { 1695 && request_mem_region(r->start,
1786 1696 MPSC_SDMA_INTR_REG_BLOCK_SIZE,
1697 "sdma_intr_regs")) {
1787 mpsc_shared_regs.sdma_intr_base = ioremap(r->start, 1698 mpsc_shared_regs.sdma_intr_base = ioremap(r->start,
1788 MPSC_SDMA_INTR_REG_BLOCK_SIZE); 1699 MPSC_SDMA_INTR_REG_BLOCK_SIZE);
1789 mpsc_shared_regs.sdma_intr_base_p = r->start; 1700 mpsc_shared_regs.sdma_intr_base_p = r->start;
1790 } 1701 } else {
1791 else {
1792 iounmap(mpsc_shared_regs.mpsc_routing_base); 1702 iounmap(mpsc_shared_regs.mpsc_routing_base);
1793 release_mem_region(mpsc_shared_regs.mpsc_routing_base_p, 1703 release_mem_region(mpsc_shared_regs.mpsc_routing_base_p,
1794 MPSC_ROUTING_REG_BLOCK_SIZE); 1704 MPSC_ROUTING_REG_BLOCK_SIZE);
1795 mpsc_resource_err("SDMA intr base"); 1705 mpsc_resource_err("SDMA intr base");
1796 return -ENOMEM; 1706 return -ENOMEM;
1797 } 1707 }
@@ -1799,18 +1709,17 @@ mpsc_shared_map_regs(struct platform_device *pd)
1799 return 0; 1709 return 0;
1800} 1710}
1801 1711
1802static void 1712static void mpsc_shared_unmap_regs(void)
1803mpsc_shared_unmap_regs(void)
1804{ 1713{
1805 if (!mpsc_shared_regs.mpsc_routing_base) { 1714 if (!mpsc_shared_regs.mpsc_routing_base) {
1806 iounmap(mpsc_shared_regs.mpsc_routing_base); 1715 iounmap(mpsc_shared_regs.mpsc_routing_base);
1807 release_mem_region(mpsc_shared_regs.mpsc_routing_base_p, 1716 release_mem_region(mpsc_shared_regs.mpsc_routing_base_p,
1808 MPSC_ROUTING_REG_BLOCK_SIZE); 1717 MPSC_ROUTING_REG_BLOCK_SIZE);
1809 } 1718 }
1810 if (!mpsc_shared_regs.sdma_intr_base) { 1719 if (!mpsc_shared_regs.sdma_intr_base) {
1811 iounmap(mpsc_shared_regs.sdma_intr_base); 1720 iounmap(mpsc_shared_regs.sdma_intr_base);
1812 release_mem_region(mpsc_shared_regs.sdma_intr_base_p, 1721 release_mem_region(mpsc_shared_regs.sdma_intr_base_p,
1813 MPSC_SDMA_INTR_REG_BLOCK_SIZE); 1722 MPSC_SDMA_INTR_REG_BLOCK_SIZE);
1814 } 1723 }
1815 1724
1816 mpsc_shared_regs.mpsc_routing_base = NULL; 1725 mpsc_shared_regs.mpsc_routing_base = NULL;
@@ -1818,19 +1727,17 @@ mpsc_shared_unmap_regs(void)
1818 1727
1819 mpsc_shared_regs.mpsc_routing_base_p = 0; 1728 mpsc_shared_regs.mpsc_routing_base_p = 0;
1820 mpsc_shared_regs.sdma_intr_base_p = 0; 1729 mpsc_shared_regs.sdma_intr_base_p = 0;
1821
1822 return;
1823} 1730}
1824 1731
1825static int 1732static int mpsc_shared_drv_probe(struct platform_device *dev)
1826mpsc_shared_drv_probe(struct platform_device *dev)
1827{ 1733{
1828 struct mpsc_shared_pdata *pdata; 1734 struct mpsc_shared_pdata *pdata;
1829 int rc = -ENODEV; 1735 int rc = -ENODEV;
1830 1736
1831 if (dev->id == 0) { 1737 if (dev->id == 0) {
1832 if (!(rc = mpsc_shared_map_regs(dev))) { 1738 if (!(rc = mpsc_shared_map_regs(dev))) {
1833 pdata = (struct mpsc_shared_pdata *)dev->dev.platform_data; 1739 pdata = (struct mpsc_shared_pdata *)
1740 dev->dev.platform_data;
1834 1741
1835 mpsc_shared_regs.MPSC_MRR_m = pdata->mrr_val; 1742 mpsc_shared_regs.MPSC_MRR_m = pdata->mrr_val;
1836 mpsc_shared_regs.MPSC_RCRR_m= pdata->rcrr_val; 1743 mpsc_shared_regs.MPSC_RCRR_m= pdata->rcrr_val;
@@ -1847,8 +1754,7 @@ mpsc_shared_drv_probe(struct platform_device *dev)
1847 return rc; 1754 return rc;
1848} 1755}
1849 1756
1850static int 1757static int mpsc_shared_drv_remove(struct platform_device *dev)
1851mpsc_shared_drv_remove(struct platform_device *dev)
1852{ 1758{
1853 int rc = -ENODEV; 1759 int rc = -ENODEV;
1854 1760
@@ -1869,7 +1775,7 @@ static struct platform_driver mpsc_shared_driver = {
1869 .probe = mpsc_shared_drv_probe, 1775 .probe = mpsc_shared_drv_probe,
1870 .remove = mpsc_shared_drv_remove, 1776 .remove = mpsc_shared_drv_remove,
1871 .driver = { 1777 .driver = {
1872 .name = MPSC_SHARED_NAME, 1778 .name = MPSC_SHARED_NAME,
1873 }, 1779 },
1874}; 1780};
1875 1781
@@ -1881,55 +1787,51 @@ static struct platform_driver mpsc_shared_driver = {
1881 ****************************************************************************** 1787 ******************************************************************************
1882 */ 1788 */
1883static struct uart_driver mpsc_reg = { 1789static struct uart_driver mpsc_reg = {
1884 .owner = THIS_MODULE, 1790 .owner = THIS_MODULE,
1885 .driver_name = MPSC_DRIVER_NAME, 1791 .driver_name = MPSC_DRIVER_NAME,
1886 .dev_name = MPSC_DEV_NAME, 1792 .dev_name = MPSC_DEV_NAME,
1887 .major = MPSC_MAJOR, 1793 .major = MPSC_MAJOR,
1888 .minor = MPSC_MINOR_START, 1794 .minor = MPSC_MINOR_START,
1889 .nr = MPSC_NUM_CTLRS, 1795 .nr = MPSC_NUM_CTLRS,
1890 .cons = MPSC_CONSOLE, 1796 .cons = MPSC_CONSOLE,
1891}; 1797};
1892 1798
1893static int 1799static int mpsc_drv_map_regs(struct mpsc_port_info *pi,
1894mpsc_drv_map_regs(struct mpsc_port_info *pi, struct platform_device *pd) 1800 struct platform_device *pd)
1895{ 1801{
1896 struct resource *r; 1802 struct resource *r;
1897 1803
1898 if ((r = platform_get_resource(pd, IORESOURCE_MEM, MPSC_BASE_ORDER)) && 1804 if ((r = platform_get_resource(pd, IORESOURCE_MEM, MPSC_BASE_ORDER))
1899 request_mem_region(r->start, MPSC_REG_BLOCK_SIZE, "mpsc_regs")){ 1805 && request_mem_region(r->start, MPSC_REG_BLOCK_SIZE,
1900 1806 "mpsc_regs")) {
1901 pi->mpsc_base = ioremap(r->start, MPSC_REG_BLOCK_SIZE); 1807 pi->mpsc_base = ioremap(r->start, MPSC_REG_BLOCK_SIZE);
1902 pi->mpsc_base_p = r->start; 1808 pi->mpsc_base_p = r->start;
1903 } 1809 } else {
1904 else {
1905 mpsc_resource_err("MPSC base"); 1810 mpsc_resource_err("MPSC base");
1906 return -ENOMEM; 1811 goto err;
1907 } 1812 }
1908 1813
1909 if ((r = platform_get_resource(pd, IORESOURCE_MEM, 1814 if ((r = platform_get_resource(pd, IORESOURCE_MEM,
1910 MPSC_SDMA_BASE_ORDER)) && request_mem_region(r->start, 1815 MPSC_SDMA_BASE_ORDER))
1911 MPSC_SDMA_REG_BLOCK_SIZE, "sdma_regs")) { 1816 && request_mem_region(r->start,
1912 1817 MPSC_SDMA_REG_BLOCK_SIZE, "sdma_regs")) {
1913 pi->sdma_base = ioremap(r->start,MPSC_SDMA_REG_BLOCK_SIZE); 1818 pi->sdma_base = ioremap(r->start,MPSC_SDMA_REG_BLOCK_SIZE);
1914 pi->sdma_base_p = r->start; 1819 pi->sdma_base_p = r->start;
1915 } 1820 } else {
1916 else {
1917 mpsc_resource_err("SDMA base"); 1821 mpsc_resource_err("SDMA base");
1918 if (pi->mpsc_base) { 1822 if (pi->mpsc_base) {
1919 iounmap(pi->mpsc_base); 1823 iounmap(pi->mpsc_base);
1920 pi->mpsc_base = NULL; 1824 pi->mpsc_base = NULL;
1921 } 1825 }
1922 return -ENOMEM; 1826 goto err;
1923 } 1827 }
1924 1828
1925 if ((r = platform_get_resource(pd,IORESOURCE_MEM,MPSC_BRG_BASE_ORDER)) 1829 if ((r = platform_get_resource(pd,IORESOURCE_MEM,MPSC_BRG_BASE_ORDER))
1926 && request_mem_region(r->start, MPSC_BRG_REG_BLOCK_SIZE, 1830 && request_mem_region(r->start,
1927 "brg_regs")) { 1831 MPSC_BRG_REG_BLOCK_SIZE, "brg_regs")) {
1928
1929 pi->brg_base = ioremap(r->start, MPSC_BRG_REG_BLOCK_SIZE); 1832 pi->brg_base = ioremap(r->start, MPSC_BRG_REG_BLOCK_SIZE);
1930 pi->brg_base_p = r->start; 1833 pi->brg_base_p = r->start;
1931 } 1834 } else {
1932 else {
1933 mpsc_resource_err("BRG base"); 1835 mpsc_resource_err("BRG base");
1934 if (pi->mpsc_base) { 1836 if (pi->mpsc_base) {
1935 iounmap(pi->mpsc_base); 1837 iounmap(pi->mpsc_base);
@@ -1939,14 +1841,15 @@ mpsc_drv_map_regs(struct mpsc_port_info *pi, struct platform_device *pd)
1939 iounmap(pi->sdma_base); 1841 iounmap(pi->sdma_base);
1940 pi->sdma_base = NULL; 1842 pi->sdma_base = NULL;
1941 } 1843 }
1942 return -ENOMEM; 1844 goto err;
1943 } 1845 }
1944
1945 return 0; 1846 return 0;
1847
1848err:
1849 return -ENOMEM;
1946} 1850}
1947 1851
1948static void 1852static void mpsc_drv_unmap_regs(struct mpsc_port_info *pi)
1949mpsc_drv_unmap_regs(struct mpsc_port_info *pi)
1950{ 1853{
1951 if (!pi->mpsc_base) { 1854 if (!pi->mpsc_base) {
1952 iounmap(pi->mpsc_base); 1855 iounmap(pi->mpsc_base);
@@ -1968,13 +1871,10 @@ mpsc_drv_unmap_regs(struct mpsc_port_info *pi)
1968 pi->mpsc_base_p = 0; 1871 pi->mpsc_base_p = 0;
1969 pi->sdma_base_p = 0; 1872 pi->sdma_base_p = 0;
1970 pi->brg_base_p = 0; 1873 pi->brg_base_p = 0;
1971
1972 return;
1973} 1874}
1974 1875
1975static void 1876static void mpsc_drv_get_platform_data(struct mpsc_port_info *pi,
1976mpsc_drv_get_platform_data(struct mpsc_port_info *pi, 1877 struct platform_device *pd, int num)
1977 struct platform_device *pd, int num)
1978{ 1878{
1979 struct mpsc_pdata *pdata; 1879 struct mpsc_pdata *pdata;
1980 1880
@@ -2009,12 +1909,9 @@ mpsc_drv_get_platform_data(struct mpsc_port_info *pi,
2009 pi->shared_regs = &mpsc_shared_regs; 1909 pi->shared_regs = &mpsc_shared_regs;
2010 1910
2011 pi->port.irq = platform_get_irq(pd, 0); 1911 pi->port.irq = platform_get_irq(pd, 0);
2012
2013 return;
2014} 1912}
2015 1913
2016static int 1914static int mpsc_drv_probe(struct platform_device *dev)
2017mpsc_drv_probe(struct platform_device *dev)
2018{ 1915{
2019 struct mpsc_port_info *pi; 1916 struct mpsc_port_info *pi;
2020 int rc = -ENODEV; 1917 int rc = -ENODEV;
@@ -2030,47 +1927,46 @@ mpsc_drv_probe(struct platform_device *dev)
2030 if (!(rc = mpsc_make_ready(pi))) { 1927 if (!(rc = mpsc_make_ready(pi))) {
2031 spin_lock_init(&pi->tx_lock); 1928 spin_lock_init(&pi->tx_lock);
2032 if (!(rc = uart_add_one_port(&mpsc_reg, 1929 if (!(rc = uart_add_one_port(&mpsc_reg,
2033 &pi->port))) 1930 &pi->port))) {
2034 rc = 0; 1931 rc = 0;
2035 else { 1932 } else {
2036 mpsc_release_port( 1933 mpsc_release_port((struct uart_port *)
2037 (struct uart_port *)pi); 1934 pi);
2038 mpsc_drv_unmap_regs(pi); 1935 mpsc_drv_unmap_regs(pi);
2039 } 1936 }
2040 } 1937 } else {
2041 else
2042 mpsc_drv_unmap_regs(pi); 1938 mpsc_drv_unmap_regs(pi);
1939 }
2043 } 1940 }
2044 } 1941 }
2045 1942
2046 return rc; 1943 return rc;
2047} 1944}
2048 1945
2049static int 1946static int mpsc_drv_remove(struct platform_device *dev)
2050mpsc_drv_remove(struct platform_device *dev)
2051{ 1947{
2052 pr_debug("mpsc_drv_exit: Removing MPSC %d\n", dev->id); 1948 pr_debug("mpsc_drv_exit: Removing MPSC %d\n", dev->id);
2053 1949
2054 if (dev->id < MPSC_NUM_CTLRS) { 1950 if (dev->id < MPSC_NUM_CTLRS) {
2055 uart_remove_one_port(&mpsc_reg, &mpsc_ports[dev->id].port); 1951 uart_remove_one_port(&mpsc_reg, &mpsc_ports[dev->id].port);
2056 mpsc_release_port((struct uart_port *)&mpsc_ports[dev->id].port); 1952 mpsc_release_port((struct uart_port *)
1953 &mpsc_ports[dev->id].port);
2057 mpsc_drv_unmap_regs(&mpsc_ports[dev->id]); 1954 mpsc_drv_unmap_regs(&mpsc_ports[dev->id]);
2058 return 0; 1955 return 0;
2059 } 1956 } else {
2060 else
2061 return -ENODEV; 1957 return -ENODEV;
1958 }
2062} 1959}
2063 1960
2064static struct platform_driver mpsc_driver = { 1961static struct platform_driver mpsc_driver = {
2065 .probe = mpsc_drv_probe, 1962 .probe = mpsc_drv_probe,
2066 .remove = mpsc_drv_remove, 1963 .remove = mpsc_drv_remove,
2067 .driver = { 1964 .driver = {
2068 .name = MPSC_CTLR_NAME, 1965 .name = MPSC_CTLR_NAME,
2069 }, 1966 },
2070}; 1967};
2071 1968
2072static int __init 1969static int __init mpsc_drv_init(void)
2073mpsc_drv_init(void)
2074{ 1970{
2075 int rc; 1971 int rc;
2076 1972
@@ -2085,24 +1981,21 @@ mpsc_drv_init(void)
2085 platform_driver_unregister(&mpsc_shared_driver); 1981 platform_driver_unregister(&mpsc_shared_driver);
2086 uart_unregister_driver(&mpsc_reg); 1982 uart_unregister_driver(&mpsc_reg);
2087 } 1983 }
2088 } 1984 } else {
2089 else
2090 uart_unregister_driver(&mpsc_reg); 1985 uart_unregister_driver(&mpsc_reg);
1986 }
2091 } 1987 }
2092 1988
2093 return rc; 1989 return rc;
2094
2095} 1990}
2096 1991
2097static void __exit 1992static void __exit mpsc_drv_exit(void)
2098mpsc_drv_exit(void)
2099{ 1993{
2100 platform_driver_unregister(&mpsc_driver); 1994 platform_driver_unregister(&mpsc_driver);
2101 platform_driver_unregister(&mpsc_shared_driver); 1995 platform_driver_unregister(&mpsc_shared_driver);
2102 uart_unregister_driver(&mpsc_reg); 1996 uart_unregister_driver(&mpsc_reg);
2103 memset(mpsc_ports, 0, sizeof(mpsc_ports)); 1997 memset(mpsc_ports, 0, sizeof(mpsc_ports));
2104 memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs)); 1998 memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs));
2105 return;
2106} 1999}
2107 2000
2108module_init(mpsc_drv_init); 2001module_init(mpsc_drv_init);
diff --git a/drivers/serial/sb1250-duart.c b/drivers/serial/sb1250-duart.c
index 1d9d7285172a..201253755011 100644
--- a/drivers/serial/sb1250-duart.c
+++ b/drivers/serial/sb1250-duart.c
@@ -25,6 +25,7 @@
25#define SUPPORT_SYSRQ 25#define SUPPORT_SYSRQ
26#endif 26#endif
27 27
28#include <linux/compiler.h>
28#include <linux/console.h> 29#include <linux/console.h>
29#include <linux/delay.h> 30#include <linux/delay.h>
30#include <linux/errno.h> 31#include <linux/errno.h>
@@ -103,8 +104,6 @@ struct sbd_duart {
103 104
104static struct sbd_duart sbd_duarts[DUART_MAX_CHIP]; 105static struct sbd_duart sbd_duarts[DUART_MAX_CHIP];
105 106
106#define __unused __attribute__((__unused__))
107
108 107
109/* 108/*
110 * Reading and writing SB1250 DUART registers. 109 * Reading and writing SB1250 DUART registers.
@@ -204,12 +203,12 @@ static int sbd_receive_drain(struct sbd_port *sport)
204 return loops; 203 return loops;
205} 204}
206 205
207static int __unused sbd_transmit_ready(struct sbd_port *sport) 206static int __maybe_unused sbd_transmit_ready(struct sbd_port *sport)
208{ 207{
209 return read_sbdchn(sport, R_DUART_STATUS) & M_DUART_TX_RDY; 208 return read_sbdchn(sport, R_DUART_STATUS) & M_DUART_TX_RDY;
210} 209}
211 210
212static int __unused sbd_transmit_drain(struct sbd_port *sport) 211static int __maybe_unused sbd_transmit_drain(struct sbd_port *sport)
213{ 212{
214 int loops = 10000; 213 int loops = 10000;
215 214
@@ -664,7 +663,7 @@ static void sbd_release_port(struct uart_port *uport)
664 663
665static int sbd_map_port(struct uart_port *uport) 664static int sbd_map_port(struct uart_port *uport)
666{ 665{
667 static const char *err = KERN_ERR "sbd: Cannot map MMIO\n"; 666 const char *err = KERN_ERR "sbd: Cannot map MMIO\n";
668 struct sbd_port *sport = to_sport(uport); 667 struct sbd_port *sport = to_sport(uport);
669 struct sbd_duart *duart = sport->duart; 668 struct sbd_duart *duart = sport->duart;
670 669
@@ -691,8 +690,7 @@ static int sbd_map_port(struct uart_port *uport)
691 690
692static int sbd_request_port(struct uart_port *uport) 691static int sbd_request_port(struct uart_port *uport)
693{ 692{
694 static const char *err = KERN_ERR 693 const char *err = KERN_ERR "sbd: Unable to reserve MMIO resource\n";
695 "sbd: Unable to reserve MMIO resource\n";
696 struct sbd_duart *duart = to_sport(uport)->duart; 694 struct sbd_duart *duart = to_sport(uport)->duart;
697 int map_guard; 695 int map_guard;
698 int ret = 0; 696 int ret = 0;
@@ -755,7 +753,7 @@ static int sbd_verify_port(struct uart_port *uport, struct serial_struct *ser)
755} 753}
756 754
757 755
758static struct uart_ops sbd_ops = { 756static const struct uart_ops sbd_ops = {
759 .tx_empty = sbd_tx_empty, 757 .tx_empty = sbd_tx_empty,
760 .set_mctrl = sbd_set_mctrl, 758 .set_mctrl = sbd_set_mctrl,
761 .get_mctrl = sbd_get_mctrl, 759 .get_mctrl = sbd_get_mctrl,
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 9c57486c2e7f..030a6063541d 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -626,7 +626,7 @@ static int uart_get_info(struct uart_state *state,
626 tmp.hub6 = port->hub6; 626 tmp.hub6 = port->hub6;
627 tmp.io_type = port->iotype; 627 tmp.io_type = port->iotype;
628 tmp.iomem_reg_shift = port->regshift; 628 tmp.iomem_reg_shift = port->regshift;
629 tmp.iomem_base = (void *)port->mapbase; 629 tmp.iomem_base = (void *)(unsigned long)port->mapbase;
630 630
631 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 631 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
632 return -EFAULT; 632 return -EFAULT;
@@ -1666,10 +1666,11 @@ static int uart_line_info(char *buf, struct uart_driver *drv, int i)
1666 return 0; 1666 return 0;
1667 1667
1668 mmio = port->iotype >= UPIO_MEM; 1668 mmio = port->iotype >= UPIO_MEM;
1669 ret = sprintf(buf, "%d: uart:%s %s%08lX irq:%d", 1669 ret = sprintf(buf, "%d: uart:%s %s%08llX irq:%d",
1670 port->line, uart_type(port), 1670 port->line, uart_type(port),
1671 mmio ? "mmio:0x" : "port:", 1671 mmio ? "mmio:0x" : "port:",
1672 mmio ? port->mapbase : (unsigned long) port->iobase, 1672 mmio ? (unsigned long long)port->mapbase
1673 : (unsigned long long) port->iobase,
1673 port->irq); 1674 port->irq);
1674 1675
1675 if (port->type == PORT_UNKNOWN) { 1676 if (port->type == PORT_UNKNOWN) {
@@ -2069,7 +2070,7 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port)
2069 case UPIO_TSI: 2070 case UPIO_TSI:
2070 case UPIO_DWAPB: 2071 case UPIO_DWAPB:
2071 snprintf(address, sizeof(address), 2072 snprintf(address, sizeof(address),
2072 "MMIO 0x%lx", port->mapbase); 2073 "MMIO 0x%llx", (unsigned long long)port->mapbase);
2073 break; 2074 break;
2074 default: 2075 default:
2075 strlcpy(address, "*unknown*", sizeof(address)); 2076 strlcpy(address, "*unknown*", sizeof(address));
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index 1deb5764326d..b8f91e018b21 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -1043,8 +1043,9 @@ static int __devinit serial_txx9_probe(struct platform_device *dev)
1043 ret = serial_txx9_register_port(&port); 1043 ret = serial_txx9_register_port(&port);
1044 if (ret < 0) { 1044 if (ret < 0) {
1045 dev_err(&dev->dev, "unable to register port at index %d " 1045 dev_err(&dev->dev, "unable to register port at index %d "
1046 "(IO%x MEM%lx IRQ%d): %d\n", i, 1046 "(IO%x MEM%llx IRQ%d): %d\n", i,
1047 p->iobase, p->mapbase, p->irq, ret); 1047 p->iobase, (unsigned long long)p->mapbase,
1048 p->irq, ret);
1048 } 1049 }
1049 } 1050 }
1050 return 0; 1051 return 0;
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 672cd1042539..053fca41b08a 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -12,6 +12,7 @@
12 * Modified to support multiple serial ports. Stuart Menefy (May 2000). 12 * Modified to support multiple serial ports. Stuart Menefy (May 2000).
13 * Modified to support SecureEdge. David McCullough (2002) 13 * Modified to support SecureEdge. David McCullough (2002)
14 * Modified to support SH7300 SCIF. Takashi Kusuda (Jun 2003). 14 * Modified to support SH7300 SCIF. Takashi Kusuda (Jun 2003).
15 * Removed SH7300 support (Jul 2007).
15 * 16 *
16 * This file is subject to the terms and conditions of the GNU General Public 17 * This file is subject to the terms and conditions of the GNU General Public
17 * License. See the file "COPYING" in the main directory of this archive 18 * License. See the file "COPYING" in the main directory of this archive
@@ -289,13 +290,7 @@ static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag)
289#endif 290#endif
290 291
291#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF) 292#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF)
292#if defined(CONFIG_CPU_SUBTYPE_SH7300) 293#if defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
293/* SH7300 doesn't use RTS/CTS */
294static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
295{
296 sci_out(port, SCFCR, 0);
297}
298#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
299static void sci_init_pins_scif(struct uart_port* port, unsigned int cflag) 294static void sci_init_pins_scif(struct uart_port* port, unsigned int cflag)
300{ 295{
301 unsigned int fcr_val = 0; 296 unsigned int fcr_val = 0;
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 247fb66bf0f4..cf75466ebf57 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -9,6 +9,7 @@
9 * Modified to support multiple serial ports. Stuart Menefy (May 2000). 9 * Modified to support multiple serial ports. Stuart Menefy (May 2000).
10 * Modified to support SH7300(SH-Mobile) SCIF. Takashi Kusuda (Jun 2003). 10 * Modified to support SH7300(SH-Mobile) SCIF. Takashi Kusuda (Jun 2003).
11 * Modified to support H8/300 Series Yoshinori Sato (Feb 2004). 11 * Modified to support H8/300 Series Yoshinori Sato (Feb 2004).
12 * Removed SH7300 support (Jul 2007).
12 */ 13 */
13#include <linux/serial_core.h> 14#include <linux/serial_core.h>
14#include <asm/io.h> 15#include <asm/io.h>
@@ -23,13 +24,10 @@
23#endif 24#endif
24#endif 25#endif
25 26
26#if defined(CONFIG_CPU_SUBTYPE_SH7708) 27#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
27# define SCSPTR 0xffffff7c /* 8 bit */ 28 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
28# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 29 defined(CONFIG_CPU_SUBTYPE_SH7708) || \
29# define SCI_ONLY 30 defined(CONFIG_CPU_SUBTYPE_SH7709)
30#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || \
31 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
32 defined(CONFIG_CPU_SUBTYPE_SH7706)
33# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */ 31# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */
34# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */ 32# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */
35# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 33# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
@@ -73,11 +71,6 @@
73# define SCIF_ORER 0x0001 /* overrun error bit */ 71# define SCIF_ORER 0x0001 /* overrun error bit */
74# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 72# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
75# define SCIF_ONLY 73# define SCIF_ONLY
76#elif defined(CONFIG_CPU_SUBTYPE_SH7300)
77# define SCPCR 0xA4050116 /* 16 bit SCIF */
78# define SCPDR 0xA4050136 /* 16 bit SCIF */
79# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
80# define SCIF_ONLY
81#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712) 74#elif defined(CONFIG_CPU_SUBTYPE_SH7710) || defined(CONFIG_CPU_SUBTYPE_SH7712)
82# define SCSPTR0 0xA4400000 /* 16 bit SCIF */ 75# define SCSPTR0 0xA4400000 /* 16 bit SCIF */
83# define SCI_NPORTS 2 76# define SCI_NPORTS 2
@@ -86,12 +79,6 @@
86# define PBCR 0xa4050102 79# define PBCR 0xa4050102
87# define SCSCR_INIT(port) 0x3B 80# define SCSCR_INIT(port) 0x3B
88# define SCIF_ONLY 81# define SCIF_ONLY
89#elif defined(CONFIG_CPU_SUBTYPE_SH73180)
90# define SCPDR 0xA4050138 /* 16 bit SCIF */
91# define SCSPTR2 SCPDR
92# define SCIF_ORER 0x0001 /* overrun error bit */
93# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */
94# define SCIF_ONLY
95#elif defined(CONFIG_CPU_SUBTYPE_SH7343) 82#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
96# define SCSPTR0 0xffe00010 /* 16 bit SCIF */ 83# define SCSPTR0 0xffe00010 /* 16 bit SCIF */
97# define SCSPTR1 0xffe10010 /* 16 bit SCIF */ 84# define SCSPTR1 0xffe10010 /* 16 bit SCIF */
@@ -230,7 +217,7 @@
230#define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ 217#define SCIF_RDF 0x0002 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
231#define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */ 218#define SCIF_DR 0x0001 /* 7705 SCIF, 7707 SCIF, 7709 SCIF, 7750 SCIF */
232 219
233#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 220#if defined(CONFIG_CPU_SUBTYPE_SH7705)
234#define SCIF_ORER 0x0200 221#define SCIF_ORER 0x0200
235#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER) 222#define SCIF_ERRORS ( SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK | SCIF_ORER)
236#define SCIF_RFDC_MASK 0x007f 223#define SCIF_RFDC_MASK 0x007f
@@ -259,7 +246,7 @@
259# define SCxSR_ERRORS(port) SCIF_ERRORS 246# define SCxSR_ERRORS(port) SCIF_ERRORS
260# define SCxSR_RDxF(port) SCIF_RDF 247# define SCxSR_RDxF(port) SCIF_RDF
261# define SCxSR_TDxE(port) SCIF_TDFE 248# define SCxSR_TDxE(port) SCIF_TDFE
262#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 249#if defined(CONFIG_CPU_SUBTYPE_SH7705)
263# define SCxSR_ORER(port) SCIF_ORER 250# define SCxSR_ORER(port) SCIF_ORER
264#else 251#else
265# define SCxSR_ORER(port) 0x0000 252# define SCxSR_ORER(port) 0x0000
@@ -267,13 +254,13 @@
267# define SCxSR_FER(port) SCIF_FER 254# define SCxSR_FER(port) SCIF_FER
268# define SCxSR_PER(port) SCIF_PER 255# define SCxSR_PER(port) SCIF_PER
269# define SCxSR_BRK(port) SCIF_BRK 256# define SCxSR_BRK(port) SCIF_BRK
270#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 257#if defined(CONFIG_CPU_SUBTYPE_SH7705)
271# define SCxSR_RDxF_CLEAR(port) (sci_in(port,SCxSR)&0xfffc) 258# define SCxSR_RDxF_CLEAR(port) (sci_in(port,SCxSR)&0xfffc)
272# define SCxSR_ERROR_CLEAR(port) (sci_in(port,SCxSR)&0xfd73) 259# define SCxSR_ERROR_CLEAR(port) (sci_in(port,SCxSR)&0xfd73)
273# define SCxSR_TDxE_CLEAR(port) (sci_in(port,SCxSR)&0xffdf) 260# define SCxSR_TDxE_CLEAR(port) (sci_in(port,SCxSR)&0xffdf)
274# define SCxSR_BREAK_CLEAR(port) (sci_in(port,SCxSR)&0xffe3) 261# define SCxSR_BREAK_CLEAR(port) (sci_in(port,SCxSR)&0xffe3)
275#else 262#else
276/* SH7705 can also use this, clearing is same between 7705 and 7709 and 7300 */ 263/* SH7705 can also use this, clearing is same between 7705 and 7709 */
277# define SCxSR_RDxF_CLEAR(port) 0x00fc 264# define SCxSR_RDxF_CLEAR(port) 0x00fc
278# define SCxSR_ERROR_CLEAR(port) 0x0073 265# define SCxSR_ERROR_CLEAR(port) 0x0073
279# define SCxSR_TDxE_CLEAR(port) 0x00df 266# define SCxSR_TDxE_CLEAR(port) 0x00df
@@ -375,8 +362,7 @@
375 CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size) 362 CPU_SCIx_FNS(name, sh4_sci_offset, sh4_sci_size, sh4_scif_offset, sh4_scif_size)
376#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \ 363#define SCIF_FNS(name, sh3_scif_offset, sh3_scif_size, sh4_scif_offset, sh4_scif_size) \
377 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) 364 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
378#elif defined(CONFIG_CPU_SUBTYPE_SH7300) || \ 365#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
379 defined(CONFIG_CPU_SUBTYPE_SH7705)
380#define SCIF_FNS(name, scif_offset, scif_size) \ 366#define SCIF_FNS(name, scif_offset, scif_size) \
381 CPU_SCIF_FNS(name, scif_offset, scif_size) 367 CPU_SCIF_FNS(name, scif_offset, scif_size)
382#else 368#else
@@ -402,8 +388,7 @@
402 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) 388 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
403#endif 389#endif
404 390
405#if defined(CONFIG_CPU_SUBTYPE_SH7300) || \ 391#if defined(CONFIG_CPU_SUBTYPE_SH7705)
406 defined(CONFIG_CPU_SUBTYPE_SH7705)
407 392
408SCIF_FNS(SCSMR, 0x00, 16) 393SCIF_FNS(SCSMR, 0x00, 16)
409SCIF_FNS(SCBRR, 0x04, 8) 394SCIF_FNS(SCBRR, 0x04, 8)
@@ -485,16 +470,10 @@ static const struct __attribute__((packed)) {
485}; 470};
486#endif 471#endif
487 472
488#if defined(CONFIG_CPU_SUBTYPE_SH7708) 473#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
489static inline int sci_rxd_in(struct uart_port *port) 474 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
490{ 475 defined(CONFIG_CPU_SUBTYPE_SH7708) || \
491 if (port->mapbase == 0xfffffe80) 476 defined(CONFIG_CPU_SUBTYPE_SH7709)
492 return ctrl_inb(SCSPTR)&0x01 ? 1 : 0; /* SCI */
493 return 1;
494}
495#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || \
496 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
497 defined(CONFIG_CPU_SUBTYPE_SH7706)
498static inline int sci_rxd_in(struct uart_port *port) 477static inline int sci_rxd_in(struct uart_port *port)
499{ 478{
500 if (port->mapbase == 0xfffffe80) 479 if (port->mapbase == 0xfffffe80)
@@ -562,18 +541,6 @@ static inline int sci_rxd_in(struct uart_port *port)
562 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */ 541 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
563 return 1; 542 return 1;
564} 543}
565#elif defined(CONFIG_CPU_SUBTYPE_SH7300)
566static inline int sci_rxd_in(struct uart_port *port)
567{
568 if (port->mapbase == 0xa4430000)
569 return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCIF0 */
570 return 1;
571}
572#elif defined(CONFIG_CPU_SUBTYPE_SH73180)
573static inline int sci_rxd_in(struct uart_port *port)
574{
575 return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCIF0 */
576}
577#elif defined(CONFIG_CPU_SUBTYPE_SH7343) 544#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
578static inline int sci_rxd_in(struct uart_port *port) 545static inline int sci_rxd_in(struct uart_port *port)
579{ 546{
@@ -721,8 +688,7 @@ static inline int sci_rxd_in(struct uart_port *port)
721 * -- Mitch Davis - 15 Jul 2000 688 * -- Mitch Davis - 15 Jul 2000
722 */ 689 */
723 690
724#if defined(CONFIG_CPU_SUBTYPE_SH7300) || \ 691#if defined(CONFIG_CPU_SUBTYPE_SH7780) || \
725 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
726 defined(CONFIG_CPU_SUBTYPE_SH7785) 692 defined(CONFIG_CPU_SUBTYPE_SH7785)
727#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1) 693#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(16*bps)-1)
728#elif defined(CONFIG_CPU_SUBTYPE_SH7705) 694#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index 85309acb75f6..6fd51b0022ca 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -65,7 +65,9 @@ static struct uart_port siu_uart_ports[SIU_PORTS_MAX] = {
65 }, 65 },
66}; 66};
67 67
68#ifdef CONFIG_SERIAL_VR41XX_CONSOLE
68static uint8_t lsr_break_flag[SIU_PORTS_MAX]; 69static uint8_t lsr_break_flag[SIU_PORTS_MAX];
70#endif
69 71
70#define siu_read(port, offset) readb((port)->membase + (offset)) 72#define siu_read(port, offset) readb((port)->membase + (offset))
71#define siu_write(port, offset, value) writeb((value), (port)->membase + (offset)) 73#define siu_write(port, offset, value) writeb((value), (port)->membase + (offset))
@@ -782,7 +784,7 @@ static void siu_console_write(struct console *con, const char *s, unsigned count
782 siu_write(port, UART_IER, ier); 784 siu_write(port, UART_IER, ier);
783} 785}
784 786
785static int siu_console_setup(struct console *con, char *options) 787static int __init siu_console_setup(struct console *con, char *options)
786{ 788{
787 struct uart_port *port; 789 struct uart_port *port;
788 int baud = 9600; 790 int baud = 9600;
@@ -800,7 +802,8 @@ static int siu_console_setup(struct console *con, char *options)
800 port->membase = ioremap(port->mapbase, siu_port_size(port)); 802 port->membase = ioremap(port->mapbase, siu_port_size(port));
801 } 803 }
802 804
803 vr41xx_select_siu_interface(SIU_INTERFACE_RS232C); 805 if (port->type == PORT_VR41XX_SIU)
806 vr41xx_select_siu_interface(SIU_INTERFACE_RS232C);
804 807
805 if (options != NULL) 808 if (options != NULL)
806 uart_parse_options(options, &baud, &parity, &bits, &flow); 809 uart_parse_options(options, &baud, &parity, &bits, &flow);
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index b05de30b5d9b..e84d21597943 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -200,6 +200,8 @@ static DEFINE_MUTEX(board_lock);
200 * platforms may not be able to use spi_register_board_info though, and 200 * platforms may not be able to use spi_register_board_info though, and
201 * this is exported so that for example a USB or parport based adapter 201 * this is exported so that for example a USB or parport based adapter
202 * driver could add devices (which it would learn about out-of-band). 202 * driver could add devices (which it would learn about out-of-band).
203 *
204 * Returns the new device, or NULL.
203 */ 205 */
204struct spi_device *spi_new_device(struct spi_master *master, 206struct spi_device *spi_new_device(struct spi_master *master,
205 struct spi_board_info *chip) 207 struct spi_board_info *chip)
@@ -208,7 +210,20 @@ struct spi_device *spi_new_device(struct spi_master *master,
208 struct device *dev = master->cdev.dev; 210 struct device *dev = master->cdev.dev;
209 int status; 211 int status;
210 212
211 /* NOTE: caller did any chip->bus_num checks necessary */ 213 /* NOTE: caller did any chip->bus_num checks necessary.
214 *
215 * Also, unless we change the return value convention to use
216 * error-or-pointer (not NULL-or-pointer), troubleshootability
217 * suggests syslogged diagnostics are best here (ugh).
218 */
219
220 /* Chipselects are numbered 0..max; validate. */
221 if (chip->chip_select >= master->num_chipselect) {
222 dev_err(dev, "cs%d > max %d\n",
223 chip->chip_select,
224 master->num_chipselect);
225 return NULL;
226 }
212 227
213 if (!spi_master_get(master)) 228 if (!spi_master_get(master))
214 return NULL; 229 return NULL;
@@ -236,10 +251,10 @@ struct spi_device *spi_new_device(struct spi_master *master,
236 proxy->controller_state = NULL; 251 proxy->controller_state = NULL;
237 proxy->dev.release = spidev_release; 252 proxy->dev.release = spidev_release;
238 253
239 /* drivers may modify this default i/o setup */ 254 /* drivers may modify this initial i/o setup */
240 status = master->setup(proxy); 255 status = master->setup(proxy);
241 if (status < 0) { 256 if (status < 0) {
242 dev_dbg(dev, "can't %s %s, status %d\n", 257 dev_err(dev, "can't %s %s, status %d\n",
243 "setup", proxy->dev.bus_id, status); 258 "setup", proxy->dev.bus_id, status);
244 goto fail; 259 goto fail;
245 } 260 }
@@ -249,7 +264,7 @@ struct spi_device *spi_new_device(struct spi_master *master,
249 */ 264 */
250 status = device_register(&proxy->dev); 265 status = device_register(&proxy->dev);
251 if (status < 0) { 266 if (status < 0) {
252 dev_dbg(dev, "can't %s %s, status %d\n", 267 dev_err(dev, "can't %s %s, status %d\n",
253 "add", proxy->dev.bus_id, status); 268 "add", proxy->dev.bus_id, status);
254 goto fail; 269 goto fail;
255 } 270 }
@@ -306,7 +321,6 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
306static void scan_boardinfo(struct spi_master *master) 321static void scan_boardinfo(struct spi_master *master)
307{ 322{
308 struct boardinfo *bi; 323 struct boardinfo *bi;
309 struct device *dev = master->cdev.dev;
310 324
311 mutex_lock(&board_lock); 325 mutex_lock(&board_lock);
312 list_for_each_entry(bi, &board_list, list) { 326 list_for_each_entry(bi, &board_list, list) {
@@ -316,17 +330,9 @@ static void scan_boardinfo(struct spi_master *master)
316 for (n = bi->n_board_info; n > 0; n--, chip++) { 330 for (n = bi->n_board_info; n > 0; n--, chip++) {
317 if (chip->bus_num != master->bus_num) 331 if (chip->bus_num != master->bus_num)
318 continue; 332 continue;
319 /* some controllers only have one chip, so they 333 /* NOTE: this relies on spi_new_device to
320 * might not use chipselects. otherwise, the 334 * issue diagnostics when given bogus inputs
321 * chipselects are numbered 0..max.
322 */ 335 */
323 if (chip->chip_select >= master->num_chipselect
324 && master->num_chipselect) {
325 dev_dbg(dev, "cs%d > max %d\n",
326 chip->chip_select,
327 master->num_chipselect);
328 continue;
329 }
330 (void) spi_new_device(master, chip); 336 (void) spi_new_device(master, chip);
331 } 337 }
332 } 338 }
@@ -419,8 +425,17 @@ int spi_register_master(struct spi_master *master)
419 if (!dev) 425 if (!dev)
420 return -ENODEV; 426 return -ENODEV;
421 427
428 /* even if it's just one always-selected device, there must
429 * be at least one chipselect
430 */
431 if (master->num_chipselect == 0)
432 return -EINVAL;
433
422 /* convention: dynamically assigned bus IDs count down from the max */ 434 /* convention: dynamically assigned bus IDs count down from the max */
423 if (master->bus_num < 0) { 435 if (master->bus_num < 0) {
436 /* FIXME switch to an IDR based scheme, something like
437 * I2C now uses, so we can't run out of "dynamic" IDs
438 */
424 master->bus_num = atomic_dec_return(&dyn_bus_id); 439 master->bus_num = atomic_dec_return(&dyn_bus_id);
425 dynamic = 1; 440 dynamic = 1;
426 } 441 }
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index 3295cfcc9f20..0c16a2b39b41 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -39,6 +39,7 @@ struct mpc83xx_spi_reg {
39}; 39};
40 40
41/* SPI Controller mode register definitions */ 41/* SPI Controller mode register definitions */
42#define SPMODE_LOOP (1 << 30)
42#define SPMODE_CI_INACTIVEHIGH (1 << 29) 43#define SPMODE_CI_INACTIVEHIGH (1 << 29)
43#define SPMODE_CP_BEGIN_EDGECLK (1 << 28) 44#define SPMODE_CP_BEGIN_EDGECLK (1 << 28)
44#define SPMODE_DIV16 (1 << 27) 45#define SPMODE_DIV16 (1 << 27)
@@ -153,12 +154,18 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
153 len = len - 1; 154 len = len - 1;
154 155
155 /* mask out bits we are going to set */ 156 /* mask out bits we are going to set */
156 regval &= ~0x38ff0000; 157 regval &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH
158 | SPMODE_LEN(0xF) | SPMODE_DIV16
159 | SPMODE_PM(0xF) | SPMODE_REV | SPMODE_LOOP);
157 160
158 if (spi->mode & SPI_CPHA) 161 if (spi->mode & SPI_CPHA)
159 regval |= SPMODE_CP_BEGIN_EDGECLK; 162 regval |= SPMODE_CP_BEGIN_EDGECLK;
160 if (spi->mode & SPI_CPOL) 163 if (spi->mode & SPI_CPOL)
161 regval |= SPMODE_CI_INACTIVEHIGH; 164 regval |= SPMODE_CI_INACTIVEHIGH;
165 if (!(spi->mode & SPI_LSB_FIRST))
166 regval |= SPMODE_REV;
167 if (spi->mode & SPI_LOOP)
168 regval |= SPMODE_LOOP;
162 169
163 regval |= SPMODE_LEN(len); 170 regval |= SPMODE_LEN(len);
164 171
@@ -176,6 +183,8 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
176 regval |= SPMODE_PM(pm); 183 regval |= SPMODE_PM(pm);
177 } 184 }
178 185
186 /* Turn off SPI unit prior changing mode */
187 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0);
179 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); 188 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
180 if (mpc83xx_spi->activate_cs) 189 if (mpc83xx_spi->activate_cs)
181 mpc83xx_spi->activate_cs(spi->chip_select, pol); 190 mpc83xx_spi->activate_cs(spi->chip_select, pol);
@@ -231,6 +240,14 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
231 } else 240 } else
232 return -EINVAL; 241 return -EINVAL;
233 242
243 if (mpc83xx_spi->qe_mode && spi->mode & SPI_LSB_FIRST) {
244 mpc83xx_spi->tx_shift = 0;
245 if (bits_per_word <= 8)
246 mpc83xx_spi->rx_shift = 8;
247 else
248 mpc83xx_spi->rx_shift = 0;
249 }
250
234 /* nsecs = (clock period)/2 */ 251 /* nsecs = (clock period)/2 */
235 if (!hz) 252 if (!hz)
236 hz = spi->max_speed_hz; 253 hz = spi->max_speed_hz;
@@ -245,17 +262,22 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
245 262
246 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); 263 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
247 264
248 /* Mask out bits_per_wordgth */ 265 /* mask out bits we are going to set */
249 regval &= 0xff0fffff; 266 regval &= ~(SPMODE_LEN(0xF) | SPMODE_REV);
250 regval |= SPMODE_LEN(bits_per_word); 267 regval |= SPMODE_LEN(bits_per_word);
268 if (!(spi->mode & SPI_LSB_FIRST))
269 regval |= SPMODE_REV;
251 270
271 /* Turn off SPI unit prior changing mode */
272 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0);
252 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); 273 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
253 274
254 return 0; 275 return 0;
255} 276}
256 277
257/* the spi->mode bits understood by this driver: */ 278/* the spi->mode bits understood by this driver: */
258#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH) 279#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \
280 | SPI_LSB_FIRST | SPI_LOOP)
259 281
260static int mpc83xx_spi_setup(struct spi_device *spi) 282static int mpc83xx_spi_setup(struct spi_device *spi)
261{ 283{
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index 7071ff8da63e..5cf48123e0ef 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -28,7 +28,7 @@
28#include <asm/hardware.h> 28#include <asm/hardware.h>
29 29
30#include <asm/arch/regs-gpio.h> 30#include <asm/arch/regs-gpio.h>
31#include <asm/arch/regs-spi.h> 31#include <asm/plat-s3c24xx/regs-spi.h>
32#include <asm/arch/spi.h> 32#include <asm/arch/spi.h>
33 33
34struct s3c24xx_spi { 34struct s3c24xx_spi {
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 38b60ad0eda0..630f781aeb19 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -55,9 +55,16 @@
55static unsigned long minors[N_SPI_MINORS / BITS_PER_LONG]; 55static unsigned long minors[N_SPI_MINORS / BITS_PER_LONG];
56 56
57 57
58/* Bit masks for spi_device.mode management */ 58/* Bit masks for spi_device.mode management. Note that incorrect
59#define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL) 59 * settings for CS_HIGH and 3WIRE can cause *lots* of trouble for other
60 60 * devices on a shared bus: CS_HIGH, because this device will be
61 * active when it shouldn't be; 3WIRE, because when active it won't
62 * behave as it should.
63 *
64 * REVISIT should changing those two modes be privileged?
65 */
66#define SPI_MODE_MASK (SPI_CPHA | SPI_CPOL | SPI_CS_HIGH \
67 | SPI_LSB_FIRST | SPI_3WIRE | SPI_LOOP)
61 68
62struct spidev_data { 69struct spidev_data {
63 struct device dev; 70 struct device dev;
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index befff5f9d58c..ac49b15fa768 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_USB_SISUSBVGA) += misc/
48obj-$(CONFIG_USB_TEST) += misc/ 48obj-$(CONFIG_USB_TEST) += misc/
49obj-$(CONFIG_USB_TRANCEVIBRATOR)+= misc/ 49obj-$(CONFIG_USB_TRANCEVIBRATOR)+= misc/
50obj-$(CONFIG_USB_USS720) += misc/ 50obj-$(CONFIG_USB_USS720) += misc/
51obj-$(CONFIG_USB_IOWARRIOR) += misc/
51 52
52obj-$(CONFIG_USB_ATM) += atm/ 53obj-$(CONFIG_USB_ATM) += atm/
53obj-$(CONFIG_USB_SPEEDTOUCH) += atm/ 54obj-$(CONFIG_USB_SPEEDTOUCH) += atm/
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 25f63f1096b4..b6bd05e3d439 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -18,9 +18,17 @@
18#include "hcd.h" /* for usbcore internals */ 18#include "hcd.h" /* for usbcore internals */
19#include "usb.h" 19#include "usb.h"
20 20
21struct api_context {
22 struct completion done;
23 int status;
24};
25
21static void usb_api_blocking_completion(struct urb *urb) 26static void usb_api_blocking_completion(struct urb *urb)
22{ 27{
23 complete((struct completion *)urb->context); 28 struct api_context *ctx = urb->context;
29
30 ctx->status = urb->status;
31 complete(&ctx->done);
24} 32}
25 33
26 34
@@ -32,20 +40,21 @@ static void usb_api_blocking_completion(struct urb *urb)
32 */ 40 */
33static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) 41static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
34{ 42{
35 struct completion done; 43 struct api_context ctx;
36 unsigned long expire; 44 unsigned long expire;
37 int retval; 45 int retval;
38 int status = urb->status;
39 46
40 init_completion(&done); 47 init_completion(&ctx.done);
41 urb->context = &done; 48 urb->context = &ctx;
42 urb->actual_length = 0; 49 urb->actual_length = 0;
43 retval = usb_submit_urb(urb, GFP_NOIO); 50 retval = usb_submit_urb(urb, GFP_NOIO);
44 if (unlikely(retval)) 51 if (unlikely(retval))
45 goto out; 52 goto out;
46 53
47 expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT; 54 expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT;
48 if (!wait_for_completion_timeout(&done, expire)) { 55 if (!wait_for_completion_timeout(&ctx.done, expire)) {
56 usb_kill_urb(urb);
57 retval = (ctx.status == -ENOENT ? -ETIMEDOUT : ctx.status);
49 58
50 dev_dbg(&urb->dev->dev, 59 dev_dbg(&urb->dev->dev,
51 "%s timed out on ep%d%s len=%d/%d\n", 60 "%s timed out on ep%d%s len=%d/%d\n",
@@ -54,11 +63,8 @@ static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
54 usb_pipein(urb->pipe) ? "in" : "out", 63 usb_pipein(urb->pipe) ? "in" : "out",
55 urb->actual_length, 64 urb->actual_length,
56 urb->transfer_buffer_length); 65 urb->transfer_buffer_length);
57
58 usb_kill_urb(urb);
59 retval = status == -ENOENT ? -ETIMEDOUT : status;
60 } else 66 } else
61 retval = status; 67 retval = ctx.status;
62out: 68out:
63 if (actual_length) 69 if (actual_length)
64 *actual_length = urb->actual_length; 70 *actual_length = urb->actual_length;
@@ -411,15 +417,22 @@ int usb_sg_init (
411 * Some systems need to revert to PIO when DMA is temporarily 417 * Some systems need to revert to PIO when DMA is temporarily
412 * unavailable. For their sakes, both transfer_buffer and 418 * unavailable. For their sakes, both transfer_buffer and
413 * transfer_dma are set when possible. However this can only 419 * transfer_dma are set when possible. However this can only
414 * work on systems without HIGHMEM, since DMA buffers located 420 * work on systems without:
415 * in high memory are not directly addressable by the CPU for 421 *
416 * PIO ... so when HIGHMEM is in use, transfer_buffer is NULL 422 * - HIGHMEM, since DMA buffers located in high memory are
423 * not directly addressable by the CPU for PIO;
424 *
425 * - IOMMU, since dma_map_sg() is allowed to use an IOMMU to
426 * make virtually discontiguous buffers be "dma-contiguous"
427 * so that PIO and DMA need diferent numbers of URBs.
428 *
429 * So when HIGHMEM or IOMMU are in use, transfer_buffer is NULL
417 * to prevent stale pointers and to help spot bugs. 430 * to prevent stale pointers and to help spot bugs.
418 */ 431 */
419 if (dma) { 432 if (dma) {
420 io->urbs [i]->transfer_dma = sg_dma_address (sg + i); 433 io->urbs [i]->transfer_dma = sg_dma_address (sg + i);
421 len = sg_dma_len (sg + i); 434 len = sg_dma_len (sg + i);
422#ifdef CONFIG_HIGHMEM 435#if defined(CONFIG_HIGHMEM) || defined(CONFIG_IOMMU)
423 io->urbs[i]->transfer_buffer = NULL; 436 io->urbs[i]->transfer_buffer = NULL;
424#else 437#else
425 io->urbs[i]->transfer_buffer = 438 io->urbs[i]->transfer_buffer =
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index aa21b38a31ce..b7917c5a3c6f 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -30,18 +30,40 @@
30static const struct usb_device_id usb_quirk_list[] = { 30static const struct usb_device_id usb_quirk_list[] = {
31 /* HP 5300/5370C scanner */ 31 /* HP 5300/5370C scanner */
32 { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 }, 32 { USB_DEVICE(0x03f0, 0x0701), .driver_info = USB_QUIRK_STRING_FETCH_255 },
33 /* Acer Peripherals Inc. (now BenQ Corp.) Prisa 640BU */
34 { USB_DEVICE(0x04a5, 0x207e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
33 /* Benq S2W 3300U */ 35 /* Benq S2W 3300U */
34 { USB_DEVICE(0x04a5, 0x20b0), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 36 { USB_DEVICE(0x04a5, 0x20b0), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
37 /* Canon, Inc. CanoScan N1240U/LiDE30 */
38 { USB_DEVICE(0x04a9, 0x220e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
39 /* Canon, Inc. CanoScan N650U/N656U */
40 { USB_DEVICE(0x04a9, 0x2206), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
41 /* Canon, Inc. CanoScan 1220U */
42 { USB_DEVICE(0x04a9, 0x2207), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
43 /* Canon, Inc. CanoScan N670U/N676U/LiDE 20 */
44 { USB_DEVICE(0x04a9, 0x220d), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
45 /* old Cannon scanner */
46 { USB_DEVICE(0x04a9, 0x2220), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
35 /* Seiko Epson Corp. Perfection 1200 */ 47 /* Seiko Epson Corp. Perfection 1200 */
36 { USB_DEVICE(0x04b8, 0x0104), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 48 { USB_DEVICE(0x04b8, 0x0104), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
49 /* Seiko Epson Corp. Perfection 660 */
50 { USB_DEVICE(0x04b8, 0x0114), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
51 /* Epson Perfection 1260 Photo */
52 { USB_DEVICE(0x04b8, 0x011d), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
37 /* Seiko Epson Corp - Perfection 1670 */ 53 /* Seiko Epson Corp - Perfection 1670 */
38 { USB_DEVICE(0x04b8, 0x011f), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 54 { USB_DEVICE(0x04b8, 0x011f), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
55 /* EPSON Perfection 2480 */
56 { USB_DEVICE(0x04b8, 0x0121), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
57 /* Seiko Epson Corp.*/
58 { USB_DEVICE(0x04b8, 0x0122), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
39 /* Samsung ML-2510 Series printer */ 59 /* Samsung ML-2510 Series printer */
40 { USB_DEVICE(0x04e8, 0x327e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 60 { USB_DEVICE(0x04e8, 0x327e), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
41 /* Elsa MicroLink 56k (V.250) */ 61 /* Elsa MicroLink 56k (V.250) */
42 { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 62 { USB_DEVICE(0x05cc, 0x2267), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
43 /* Ultima Electronics Corp.*/ 63 /* Ultima Electronics Corp.*/
44 { USB_DEVICE(0x05d8, 0x4005), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 64 { USB_DEVICE(0x05d8, 0x4005), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
65 /* Agfa Snapscan1212u */
66 { USB_DEVICE(0x06bd, 0x2061), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
45 /* Umax [hex] Astra 3400U */ 67 /* Umax [hex] Astra 3400U */
46 { USB_DEVICE(0x1606, 0x0060), .driver_info = USB_QUIRK_NO_AUTOSUSPEND }, 68 { USB_DEVICE(0x1606, 0x0060), .driver_info = USB_QUIRK_NO_AUTOSUSPEND },
47 69
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
index d18901b92cda..c6760aee1e5c 100644
--- a/drivers/usb/gadget/config.c
+++ b/drivers/usb/gadget/config.c
@@ -50,7 +50,7 @@ usb_descriptor_fillbuf(void *buf, unsigned buflen,
50 return -EINVAL; 50 return -EINVAL;
51 51
52 /* fill buffer from src[] until null descriptor ptr */ 52 /* fill buffer from src[] until null descriptor ptr */
53 for (; 0 != *src; src++) { 53 for (; NULL != *src; src++) {
54 unsigned len = (*src)->bLength; 54 unsigned len = (*src)->bLength;
55 55
56 if (len > buflen) 56 if (len > buflen)
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
index 6042364402b8..3aa46cfa66ba 100644
--- a/drivers/usb/gadget/epautoconf.c
+++ b/drivers/usb/gadget/epautoconf.c
@@ -71,7 +71,7 @@ ep_matches (
71 u16 max; 71 u16 max;
72 72
73 /* endpoint already claimed? */ 73 /* endpoint already claimed? */
74 if (0 != ep->driver_data) 74 if (NULL != ep->driver_data)
75 return 0; 75 return 0;
76 76
77 /* only support ep0 for portable CONTROL traffic */ 77 /* only support ep0 for portable CONTROL traffic */
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index a3376739a81b..593e23507b1a 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1723,7 +1723,8 @@ rx_submit (struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags)
1723 size += sizeof (struct rndis_packet_msg_type); 1723 size += sizeof (struct rndis_packet_msg_type);
1724 size -= size % dev->out_ep->maxpacket; 1724 size -= size % dev->out_ep->maxpacket;
1725 1725
1726 if ((skb = alloc_skb (size + NET_IP_ALIGN, gfp_flags)) == 0) { 1726 skb = alloc_skb(size + NET_IP_ALIGN, gfp_flags);
1727 if (skb == NULL) {
1727 DEBUG (dev, "no rx skb\n"); 1728 DEBUG (dev, "no rx skb\n");
1728 goto enomem; 1729 goto enomem;
1729 } 1730 }
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index e60745ffaf8e..173004f60fea 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -964,7 +964,7 @@ static int setup_req (struct usb_ep *ep, struct usb_request *req, u16 len)
964 } 964 }
965 if (len > sizeof (dev->rbuf)) 965 if (len > sizeof (dev->rbuf))
966 req->buf = kmalloc(len, GFP_ATOMIC); 966 req->buf = kmalloc(len, GFP_ATOMIC);
967 if (req->buf == 0) { 967 if (req->buf == NULL) {
968 req->buf = dev->rbuf; 968 req->buf = dev->rbuf;
969 return -ENOMEM; 969 return -ENOMEM;
970 } 970 }
@@ -1394,7 +1394,7 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1394 dev->setup_abort = 0; 1394 dev->setup_abort = 0;
1395 if (dev->state == STATE_DEV_UNCONNECTED) { 1395 if (dev->state == STATE_DEV_UNCONNECTED) {
1396#ifdef CONFIG_USB_GADGET_DUALSPEED 1396#ifdef CONFIG_USB_GADGET_DUALSPEED
1397 if (gadget->speed == USB_SPEED_HIGH && dev->hs_config == 0) { 1397 if (gadget->speed == USB_SPEED_HIGH && dev->hs_config == NULL) {
1398 spin_unlock(&dev->lock); 1398 spin_unlock(&dev->lock);
1399 ERROR (dev, "no high speed config??\n"); 1399 ERROR (dev, "no high speed config??\n");
1400 return -EINVAL; 1400 return -EINVAL;
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index 700dda8a9157..4b27d12f049d 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -1299,7 +1299,7 @@ static int m66592_queue(struct usb_ep *_ep, struct usb_request *_req,
1299 req->req.actual = 0; 1299 req->req.actual = 0;
1300 req->req.status = -EINPROGRESS; 1300 req->req.status = -EINPROGRESS;
1301 1301
1302 if (ep->desc == 0) /* control */ 1302 if (ep->desc == NULL) /* control */
1303 start_ep0(ep, req); 1303 start_ep0(ep, req);
1304 else { 1304 else {
1305 if (request && !ep->busy) 1305 if (request && !ep->busy)
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 63b9521c1322..72b4ebbf132d 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -93,8 +93,6 @@ static const char driver_name [] = "pxa2xx_udc";
93static const char ep0name [] = "ep0"; 93static const char ep0name [] = "ep0";
94 94
95 95
96// #define DISABLE_TEST_MODE
97
98#ifdef CONFIG_ARCH_IXP4XX 96#ifdef CONFIG_ARCH_IXP4XX
99 97
100/* cpu-specific register addresses are compiled in to this code */ 98/* cpu-specific register addresses are compiled in to this code */
@@ -113,17 +111,6 @@ static const char ep0name [] = "ep0";
113#define SIZE_STR "" 111#define SIZE_STR ""
114#endif 112#endif
115 113
116#ifdef DISABLE_TEST_MODE
117/* (mode == 0) == no undocumented chip tweaks
118 * (mode & 1) == double buffer bulk IN
119 * (mode & 2) == double buffer bulk OUT
120 * ... so mode = 3 (or 7, 15, etc) does it for both
121 */
122static ushort fifo_mode = 0;
123module_param(fifo_mode, ushort, 0);
124MODULE_PARM_DESC (fifo_mode, "pxa2xx udc fifo mode");
125#endif
126
127/* --------------------------------------------------------------------------- 114/* ---------------------------------------------------------------------------
128 * endpoint related parts of the api to the usb controller hardware, 115 * endpoint related parts of the api to the usb controller hardware,
129 * used by gadget driver; and the inner talker-to-hardware core. 116 * used by gadget driver; and the inner talker-to-hardware core.
@@ -1252,23 +1239,6 @@ static void udc_enable (struct pxa2xx_udc *dev)
1252 UDC_RES2 = 0x00; 1239 UDC_RES2 = 0x00;
1253 } 1240 }
1254 1241
1255#ifdef DISABLE_TEST_MODE
1256 /* "test mode" seems to have become the default in later chip
1257 * revs, preventing double buffering (and invalidating docs).
1258 * this EXPERIMENT enables it for bulk endpoints by tweaking
1259 * undefined/reserved register bits (that other drivers clear).
1260 * Belcarra code comments noted this usage.
1261 */
1262 if (fifo_mode & 1) { /* IN endpoints */
1263 UDC_RES1 |= USIR0_IR1|USIR0_IR6;
1264 UDC_RES2 |= USIR1_IR11;
1265 }
1266 if (fifo_mode & 2) { /* OUT endpoints */
1267 UDC_RES1 |= USIR0_IR2|USIR0_IR7;
1268 UDC_RES2 |= USIR1_IR12;
1269 }
1270#endif
1271
1272 /* enable suspend/resume and reset irqs */ 1242 /* enable suspend/resume and reset irqs */
1273 udc_clear_mask_UDCCR(UDCCR_SRM | UDCCR_REM); 1243 udc_clear_mask_UDCCR(UDCCR_SRM | UDCCR_REM);
1274 1244
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index a2e6e3fc8c8d..fcfe869acb94 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -653,7 +653,8 @@ set_source_sink_config (struct zero_dev *dev, gfp_t gfp_flags)
653 result = usb_ep_enable (ep, d); 653 result = usb_ep_enable (ep, d);
654 if (result == 0) { 654 if (result == 0) {
655 ep->driver_data = dev; 655 ep->driver_data = dev;
656 if (source_sink_start_ep (ep, gfp_flags) != 0) { 656 if (source_sink_start_ep(ep, gfp_flags)
657 != NULL) {
657 dev->in_ep = ep; 658 dev->in_ep = ep;
658 continue; 659 continue;
659 } 660 }
@@ -667,7 +668,8 @@ set_source_sink_config (struct zero_dev *dev, gfp_t gfp_flags)
667 result = usb_ep_enable (ep, d); 668 result = usb_ep_enable (ep, d);
668 if (result == 0) { 669 if (result == 0) {
669 ep->driver_data = dev; 670 ep->driver_data = dev;
670 if (source_sink_start_ep (ep, gfp_flags) != 0) { 671 if (source_sink_start_ep(ep, gfp_flags)
672 != NULL) {
671 dev->out_ep = ep; 673 dev->out_ep = ep;
672 continue; 674 continue;
673 } 675 }
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index e831cb7f64fd..33f6ee50b8d3 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -356,7 +356,7 @@ static void cp2101_get_termios (struct usb_serial_port *port)
356 356
357 dbg("%s - port %d", __FUNCTION__, port->number); 357 dbg("%s - port %d", __FUNCTION__, port->number);
358 358
359 if ((!port->tty) || (!port->tty->termios)) { 359 if (!port->tty || !port->tty->termios) {
360 dbg("%s - no tty structures", __FUNCTION__); 360 dbg("%s - no tty structures", __FUNCTION__);
361 return; 361 return;
362 } 362 }
@@ -526,50 +526,35 @@ static void cp2101_set_termios (struct usb_serial_port *port,
526 return; 526 return;
527 } 527 }
528 cflag = port->tty->termios->c_cflag; 528 cflag = port->tty->termios->c_cflag;
529 529 old_cflag = old_termios->c_cflag;
530 /* Check that they really want us to change something */ 530 baud = tty_get_baud_rate(port->tty);
531 if (old_termios) {
532 if ((cflag == old_termios->c_cflag) &&
533 (RELEVANT_IFLAG(port->tty->termios->c_iflag)
534 == RELEVANT_IFLAG(old_termios->c_iflag))) {
535 dbg("%s - nothing to change...", __FUNCTION__);
536 return;
537 }
538
539 old_cflag = old_termios->c_cflag;
540 }
541 531
542 /* If the baud rate is to be updated*/ 532 /* If the baud rate is to be updated*/
543 if ((cflag & CBAUD) != (old_cflag & CBAUD)) { 533 if (baud != tty_termios_baud_rate(old_termios)) {
544 switch (cflag & CBAUD) { 534 switch (baud) {
545 /* 535 case 0:
546 * The baud rates which are commented out below 536 case 600:
547 * appear to be supported by the device 537 case 1200:
548 * but are non-standard 538 case 1800:
549 */ 539 case 2400:
550 case B0: baud = 0; break; 540 case 4800:
551 case B600: baud = 600; break; 541 case 7200:
552 case B1200: baud = 1200; break; 542 case 9600:
553 case B1800: baud = 1800; break; 543 case 14400:
554 case B2400: baud = 2400; break; 544 case 19200:
555 case B4800: baud = 4800; break; 545 case 28800:
556 /*case B7200: baud = 7200; break;*/ 546 case 38400:
557 case B9600: baud = 9600; break; 547 case 55854:
558 /*ase B14400: baud = 14400; break;*/ 548 case 57600:
559 case B19200: baud = 19200; break; 549 case 115200:
560 /*case B28800: baud = 28800; break;*/ 550 case 127117:
561 case B38400: baud = 38400; break; 551 case 230400:
562 /*case B55854: baud = 55054; break;*/ 552 case 460800:
563 case B57600: baud = 57600; break; 553 case 921600:
564 case B115200: baud = 115200; break; 554 case 3686400:
565 /*case B127117: baud = 127117; break;*/ 555 break;
566 case B230400: baud = 230400; break;
567 case B460800: baud = 460800; break;
568 case B921600: baud = 921600; break;
569 /*case B3686400: baud = 3686400; break;*/
570 default: 556 default:
571 dev_err(&port->dev, "cp2101 driver does not " 557 baud = 9600;
572 "support the baudrate requested\n");
573 break; 558 break;
574 } 559 }
575 560
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 976f54ec26e6..dab2e66d111d 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -433,38 +433,38 @@ struct digi_port {
433 433
434/* Local Function Declarations */ 434/* Local Function Declarations */
435 435
436static void digi_wakeup_write( struct usb_serial_port *port ); 436static void digi_wakeup_write(struct usb_serial_port *port);
437static void digi_wakeup_write_lock(struct work_struct *work); 437static void digi_wakeup_write_lock(struct work_struct *work);
438static int digi_write_oob_command( struct usb_serial_port *port, 438static int digi_write_oob_command(struct usb_serial_port *port,
439 unsigned char *buf, int count, int interruptible ); 439 unsigned char *buf, int count, int interruptible);
440static int digi_write_inb_command( struct usb_serial_port *port, 440static int digi_write_inb_command(struct usb_serial_port *port,
441 unsigned char *buf, int count, unsigned long timeout ); 441 unsigned char *buf, int count, unsigned long timeout);
442static int digi_set_modem_signals( struct usb_serial_port *port, 442static int digi_set_modem_signals(struct usb_serial_port *port,
443 unsigned int modem_signals, int interruptible ); 443 unsigned int modem_signals, int interruptible);
444static int digi_transmit_idle( struct usb_serial_port *port, 444static int digi_transmit_idle(struct usb_serial_port *port,
445 unsigned long timeout ); 445 unsigned long timeout);
446static void digi_rx_throttle (struct usb_serial_port *port); 446static void digi_rx_throttle (struct usb_serial_port *port);
447static void digi_rx_unthrottle (struct usb_serial_port *port); 447static void digi_rx_unthrottle (struct usb_serial_port *port);
448static void digi_set_termios( struct usb_serial_port *port, 448static void digi_set_termios(struct usb_serial_port *port,
449 struct ktermios *old_termios ); 449 struct ktermios *old_termios);
450static void digi_break_ctl( struct usb_serial_port *port, int break_state ); 450static void digi_break_ctl(struct usb_serial_port *port, int break_state);
451static int digi_ioctl( struct usb_serial_port *port, struct file *file, 451static int digi_ioctl(struct usb_serial_port *port, struct file *file,
452 unsigned int cmd, unsigned long arg ); 452 unsigned int cmd, unsigned long arg);
453static int digi_tiocmget( struct usb_serial_port *port, struct file *file ); 453static int digi_tiocmget(struct usb_serial_port *port, struct file *file);
454static int digi_tiocmset( struct usb_serial_port *port, struct file *file, 454static int digi_tiocmset(struct usb_serial_port *port, struct file *file,
455 unsigned int set, unsigned int clear ); 455 unsigned int set, unsigned int clear);
456static int digi_write( struct usb_serial_port *port, const unsigned char *buf, int count ); 456static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count);
457static void digi_write_bulk_callback( struct urb *urb ); 457static void digi_write_bulk_callback(struct urb *urb);
458static int digi_write_room( struct usb_serial_port *port ); 458static int digi_write_room(struct usb_serial_port *port);
459static int digi_chars_in_buffer( struct usb_serial_port *port ); 459static int digi_chars_in_buffer(struct usb_serial_port *port);
460static int digi_open( struct usb_serial_port *port, struct file *filp ); 460static int digi_open(struct usb_serial_port *port, struct file *filp);
461static void digi_close( struct usb_serial_port *port, struct file *filp ); 461static void digi_close(struct usb_serial_port *port, struct file *filp);
462static int digi_startup_device( struct usb_serial *serial ); 462static int digi_startup_device(struct usb_serial *serial);
463static int digi_startup( struct usb_serial *serial ); 463static int digi_startup(struct usb_serial *serial);
464static void digi_shutdown( struct usb_serial *serial ); 464static void digi_shutdown(struct usb_serial *serial);
465static void digi_read_bulk_callback( struct urb *urb ); 465static void digi_read_bulk_callback(struct urb *urb);
466static int digi_read_inb_callback( struct urb *urb ); 466static int digi_read_inb_callback(struct urb *urb);
467static int digi_read_oob_callback( struct urb *urb ); 467static int digi_read_oob_callback(struct urb *urb);
468 468
469 469
470/* Statics */ 470/* Statics */
@@ -576,9 +576,9 @@ static struct usb_serial_driver digi_acceleport_4_device = {
576* with the equivalent code. 576* with the equivalent code.
577*/ 577*/
578 578
579static inline long cond_wait_interruptible_timeout_irqrestore( 579static long cond_wait_interruptible_timeout_irqrestore(
580 wait_queue_head_t *q, long timeout, 580 wait_queue_head_t *q, long timeout,
581 spinlock_t *lock, unsigned long flags ) 581 spinlock_t *lock, unsigned long flags)
582{ 582{
583 DEFINE_WAIT(wait); 583 DEFINE_WAIT(wait);
584 584
@@ -600,18 +600,16 @@ static inline long cond_wait_interruptible_timeout_irqrestore(
600 600
601static void digi_wakeup_write_lock(struct work_struct *work) 601static void digi_wakeup_write_lock(struct work_struct *work)
602{ 602{
603 struct digi_port *priv = 603 struct digi_port *priv = container_of(work, struct digi_port, dp_wakeup_work);
604 container_of(work, struct digi_port, dp_wakeup_work);
605 struct usb_serial_port *port = priv->dp_port; 604 struct usb_serial_port *port = priv->dp_port;
606 unsigned long flags; 605 unsigned long flags;
607 606
608 607 spin_lock_irqsave(&priv->dp_port_lock, flags);
609 spin_lock_irqsave( &priv->dp_port_lock, flags ); 608 digi_wakeup_write(port);
610 digi_wakeup_write( port ); 609 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
611 spin_unlock_irqrestore( &priv->dp_port_lock, flags );
612} 610}
613 611
614static void digi_wakeup_write( struct usb_serial_port *port ) 612static void digi_wakeup_write(struct usb_serial_port *port)
615{ 613{
616 tty_wakeup(port->tty); 614 tty_wakeup(port->tty);
617} 615}
@@ -628,8 +626,8 @@ static void digi_wakeup_write( struct usb_serial_port *port )
628* returned by usb_submit_urb. 626* returned by usb_submit_urb.
629*/ 627*/
630 628
631static int digi_write_oob_command( struct usb_serial_port *port, 629static int digi_write_oob_command(struct usb_serial_port *port,
632 unsigned char *buf, int count, int interruptible ) 630 unsigned char *buf, int count, int interruptible)
633{ 631{
634 632
635 int ret = 0; 633 int ret = 0;
@@ -638,49 +636,37 @@ static int digi_write_oob_command( struct usb_serial_port *port,
638 struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); 636 struct digi_port *oob_priv = usb_get_serial_port_data(oob_port);
639 unsigned long flags = 0; 637 unsigned long flags = 0;
640 638
639 dbg("digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, count);
641 640
642dbg( "digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, count ); 641 spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
643 642 while(count > 0) {
644 spin_lock_irqsave( &oob_priv->dp_port_lock, flags ); 643 while(oob_port->write_urb->status == -EINPROGRESS
645 644 || oob_priv->dp_write_urb_in_use) {
646 while( count > 0 ) {
647
648 while( oob_port->write_urb->status == -EINPROGRESS
649 || oob_priv->dp_write_urb_in_use ) {
650 cond_wait_interruptible_timeout_irqrestore( 645 cond_wait_interruptible_timeout_irqrestore(
651 &oob_port->write_wait, DIGI_RETRY_TIMEOUT, 646 &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
652 &oob_priv->dp_port_lock, flags ); 647 &oob_priv->dp_port_lock, flags);
653 if( interruptible && signal_pending(current) ) { 648 if (interruptible && signal_pending(current))
654 return( -EINTR ); 649 return -EINTR;
655 } 650 spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
656 spin_lock_irqsave( &oob_priv->dp_port_lock, flags );
657 } 651 }
658 652
659 /* len must be a multiple of 4, so commands are not split */ 653 /* len must be a multiple of 4, so commands are not split */
660 len = min(count, oob_port->bulk_out_size ); 654 len = min(count, oob_port->bulk_out_size);
661 if( len > 4 ) 655 if (len > 4)
662 len &= ~3; 656 len &= ~3;
663 657 memcpy(oob_port->write_urb->transfer_buffer, buf, len);
664 memcpy( oob_port->write_urb->transfer_buffer, buf, len );
665 oob_port->write_urb->transfer_buffer_length = len; 658 oob_port->write_urb->transfer_buffer_length = len;
666 oob_port->write_urb->dev = port->serial->dev; 659 oob_port->write_urb->dev = port->serial->dev;
667 660 if ((ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0) {
668 if( (ret=usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0 ) {
669 oob_priv->dp_write_urb_in_use = 1; 661 oob_priv->dp_write_urb_in_use = 1;
670 count -= len; 662 count -= len;
671 buf += len; 663 buf += len;
672 } 664 }
673
674 }
675
676 spin_unlock_irqrestore( &oob_priv->dp_port_lock, flags );
677
678 if( ret ) {
679 err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__,
680 ret );
681 } 665 }
682 666 spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags);
683 return( ret ); 667 if (ret)
668 err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__, ret);
669 return ret;
684 670
685} 671}
686 672
@@ -697,63 +683,58 @@ dbg( "digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, co
697* error returned by digi_write. 683* error returned by digi_write.
698*/ 684*/
699 685
700static int digi_write_inb_command( struct usb_serial_port *port, 686static int digi_write_inb_command(struct usb_serial_port *port,
701 unsigned char *buf, int count, unsigned long timeout ) 687 unsigned char *buf, int count, unsigned long timeout)
702{ 688{
703
704 int ret = 0; 689 int ret = 0;
705 int len; 690 int len;
706 struct digi_port *priv = usb_get_serial_port_data(port); 691 struct digi_port *priv = usb_get_serial_port_data(port);
707 unsigned char *data = port->write_urb->transfer_buffer; 692 unsigned char *data = port->write_urb->transfer_buffer;
708 unsigned long flags = 0; 693 unsigned long flags = 0;
709 694
695 dbg("digi_write_inb_command: TOP: port=%d, count=%d",
696 priv->dp_port_num, count);
710 697
711dbg( "digi_write_inb_command: TOP: port=%d, count=%d", priv->dp_port_num, 698 if (timeout)
712count );
713
714 if( timeout )
715 timeout += jiffies; 699 timeout += jiffies;
716 else 700 else
717 timeout = ULONG_MAX; 701 timeout = ULONG_MAX;
718 702
719 spin_lock_irqsave( &priv->dp_port_lock, flags ); 703 spin_lock_irqsave(&priv->dp_port_lock, flags);
720 704 while(count > 0 && ret == 0) {
721 while( count > 0 && ret == 0 ) { 705 while((port->write_urb->status == -EINPROGRESS
722 706 || priv->dp_write_urb_in_use) && time_before(jiffies, timeout)) {
723 while( (port->write_urb->status == -EINPROGRESS
724 || priv->dp_write_urb_in_use) && time_before(jiffies, timeout)) {
725 cond_wait_interruptible_timeout_irqrestore( 707 cond_wait_interruptible_timeout_irqrestore(
726 &port->write_wait, DIGI_RETRY_TIMEOUT, 708 &port->write_wait, DIGI_RETRY_TIMEOUT,
727 &priv->dp_port_lock, flags ); 709 &priv->dp_port_lock, flags);
728 if( signal_pending(current) ) { 710 if (signal_pending(current))
729 return( -EINTR ); 711 return -EINTR;
730 } 712 spin_lock_irqsave(&priv->dp_port_lock, flags);
731 spin_lock_irqsave( &priv->dp_port_lock, flags );
732 } 713 }
733 714
734 /* len must be a multiple of 4 and small enough to */ 715 /* len must be a multiple of 4 and small enough to */
735 /* guarantee the write will send buffered data first, */ 716 /* guarantee the write will send buffered data first, */
736 /* so commands are in order with data and not split */ 717 /* so commands are in order with data and not split */
737 len = min(count, port->bulk_out_size-2-priv->dp_out_buf_len ); 718 len = min(count, port->bulk_out_size-2-priv->dp_out_buf_len);
738 if( len > 4 ) 719 if (len > 4)
739 len &= ~3; 720 len &= ~3;
740 721
741 /* write any buffered data first */ 722 /* write any buffered data first */
742 if( priv->dp_out_buf_len > 0 ) { 723 if (priv->dp_out_buf_len > 0) {
743 data[0] = DIGI_CMD_SEND_DATA; 724 data[0] = DIGI_CMD_SEND_DATA;
744 data[1] = priv->dp_out_buf_len; 725 data[1] = priv->dp_out_buf_len;
745 memcpy( data+2, priv->dp_out_buf, 726 memcpy(data + 2, priv->dp_out_buf,
746 priv->dp_out_buf_len ); 727 priv->dp_out_buf_len);
747 memcpy( data+2+priv->dp_out_buf_len, buf, len ); 728 memcpy(data + 2 + priv->dp_out_buf_len, buf, len);
748 port->write_urb->transfer_buffer_length 729 port->write_urb->transfer_buffer_length
749 = priv->dp_out_buf_len+2+len; 730 = priv->dp_out_buf_len + 2 + len;
750 } else { 731 } else {
751 memcpy( data, buf, len ); 732 memcpy(data, buf, len);
752 port->write_urb->transfer_buffer_length = len; 733 port->write_urb->transfer_buffer_length = len;
753 } 734 }
754 port->write_urb->dev = port->serial->dev; 735 port->write_urb->dev = port->serial->dev;
755 736
756 if( (ret=usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0 ) { 737 if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) {
757 priv->dp_write_urb_in_use = 1; 738 priv->dp_write_urb_in_use = 1;
758 priv->dp_out_buf_len = 0; 739 priv->dp_out_buf_len = 0;
759 count -= len; 740 count -= len;
@@ -761,16 +742,12 @@ count );
761 } 742 }
762 743
763 } 744 }
745 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
764 746
765 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 747 if (ret)
766 748 err("%s: usb_submit_urb failed, ret=%d, port=%d",
767 if( ret ) { 749 __FUNCTION__, ret, priv->dp_port_num);
768 err("%s: usb_submit_urb failed, ret=%d, port=%d", __FUNCTION__, 750 return ret;
769 ret, priv->dp_port_num );
770 }
771
772 return( ret );
773
774} 751}
775 752
776 753
@@ -784,8 +761,8 @@ count );
784* returned by usb_submit_urb. 761* returned by usb_submit_urb.
785*/ 762*/
786 763
787static int digi_set_modem_signals( struct usb_serial_port *port, 764static int digi_set_modem_signals(struct usb_serial_port *port,
788 unsigned int modem_signals, int interruptible ) 765 unsigned int modem_signals, int interruptible)
789{ 766{
790 767
791 int ret; 768 int ret;
@@ -796,60 +773,47 @@ static int digi_set_modem_signals( struct usb_serial_port *port,
796 unsigned long flags = 0; 773 unsigned long flags = 0;
797 774
798 775
799dbg( "digi_set_modem_signals: TOP: port=%d, modem_signals=0x%x", 776 dbg("digi_set_modem_signals: TOP: port=%d, modem_signals=0x%x",
800port_priv->dp_port_num, modem_signals ); 777 port_priv->dp_port_num, modem_signals);
801 778
802 spin_lock_irqsave( &oob_priv->dp_port_lock, flags ); 779 spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
803 spin_lock( &port_priv->dp_port_lock ); 780 spin_lock(&port_priv->dp_port_lock);
804 781
805 while( oob_port->write_urb->status == -EINPROGRESS 782 while(oob_port->write_urb->status == -EINPROGRESS || oob_priv->dp_write_urb_in_use) {
806 || oob_priv->dp_write_urb_in_use ) { 783 spin_unlock(&port_priv->dp_port_lock);
807 spin_unlock( &port_priv->dp_port_lock );
808 cond_wait_interruptible_timeout_irqrestore( 784 cond_wait_interruptible_timeout_irqrestore(
809 &oob_port->write_wait, DIGI_RETRY_TIMEOUT, 785 &oob_port->write_wait, DIGI_RETRY_TIMEOUT,
810 &oob_priv->dp_port_lock, flags ); 786 &oob_priv->dp_port_lock, flags);
811 if( interruptible && signal_pending(current) ) { 787 if (interruptible && signal_pending(current))
812 return( -EINTR ); 788 return -EINTR;
813 } 789 spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
814 spin_lock_irqsave( &oob_priv->dp_port_lock, flags ); 790 spin_lock(&port_priv->dp_port_lock);
815 spin_lock( &port_priv->dp_port_lock );
816 } 791 }
817
818 data[0] = DIGI_CMD_SET_DTR_SIGNAL; 792 data[0] = DIGI_CMD_SET_DTR_SIGNAL;
819 data[1] = port_priv->dp_port_num; 793 data[1] = port_priv->dp_port_num;
820 data[2] = (modem_signals&TIOCM_DTR) ? 794 data[2] = (modem_signals&TIOCM_DTR) ? DIGI_DTR_ACTIVE : DIGI_DTR_INACTIVE;
821 DIGI_DTR_ACTIVE : DIGI_DTR_INACTIVE;
822 data[3] = 0; 795 data[3] = 0;
823
824 data[4] = DIGI_CMD_SET_RTS_SIGNAL; 796 data[4] = DIGI_CMD_SET_RTS_SIGNAL;
825 data[5] = port_priv->dp_port_num; 797 data[5] = port_priv->dp_port_num;
826 data[6] = (modem_signals&TIOCM_RTS) ? 798 data[6] = (modem_signals&TIOCM_RTS) ? DIGI_RTS_ACTIVE : DIGI_RTS_INACTIVE;
827 DIGI_RTS_ACTIVE : DIGI_RTS_INACTIVE;
828 data[7] = 0; 799 data[7] = 0;
829 800
830 oob_port->write_urb->transfer_buffer_length = 8; 801 oob_port->write_urb->transfer_buffer_length = 8;
831 oob_port->write_urb->dev = port->serial->dev; 802 oob_port->write_urb->dev = port->serial->dev;
832 803
833 if( (ret=usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0 ) { 804 if ((ret = usb_submit_urb(oob_port->write_urb, GFP_ATOMIC)) == 0) {
834 oob_priv->dp_write_urb_in_use = 1; 805 oob_priv->dp_write_urb_in_use = 1;
835 port_priv->dp_modem_signals = 806 port_priv->dp_modem_signals =
836 (port_priv->dp_modem_signals&~(TIOCM_DTR|TIOCM_RTS)) 807 (port_priv->dp_modem_signals&~(TIOCM_DTR|TIOCM_RTS))
837 | (modem_signals&(TIOCM_DTR|TIOCM_RTS)); 808 | (modem_signals&(TIOCM_DTR|TIOCM_RTS));
838 } 809 }
839 810 spin_unlock(&port_priv->dp_port_lock);
840 spin_unlock( &port_priv->dp_port_lock ); 811 spin_unlock_irqrestore(&oob_priv->dp_port_lock, flags);
841 spin_unlock_irqrestore( &oob_priv->dp_port_lock, flags ); 812 if (ret)
842 813 err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__, ret);
843 if( ret ) { 814 return ret;
844 err("%s: usb_submit_urb failed, ret=%d", __FUNCTION__,
845 ret );
846 }
847
848 return( ret );
849
850} 815}
851 816
852
853/* 817/*
854* Digi Transmit Idle 818* Digi Transmit Idle
855* 819*
@@ -862,203 +826,182 @@ port_priv->dp_port_num, modem_signals );
862* port at a time, so its ok. 826* port at a time, so its ok.
863*/ 827*/
864 828
865static int digi_transmit_idle( struct usb_serial_port *port, 829static int digi_transmit_idle(struct usb_serial_port *port,
866 unsigned long timeout ) 830 unsigned long timeout)
867{ 831{
868
869 int ret; 832 int ret;
870 unsigned char buf[2]; 833 unsigned char buf[2];
871 struct digi_port *priv = usb_get_serial_port_data(port); 834 struct digi_port *priv = usb_get_serial_port_data(port);
872 unsigned long flags = 0; 835 unsigned long flags = 0;
873 836
874 837 spin_lock_irqsave(&priv->dp_port_lock, flags);
875 spin_lock_irqsave( &priv->dp_port_lock, flags );
876 priv->dp_transmit_idle = 0; 838 priv->dp_transmit_idle = 0;
877 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 839 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
878 840
879 buf[0] = DIGI_CMD_TRANSMIT_IDLE; 841 buf[0] = DIGI_CMD_TRANSMIT_IDLE;
880 buf[1] = 0; 842 buf[1] = 0;
881 843
882 timeout += jiffies; 844 timeout += jiffies;
883 845
884 if( (ret=digi_write_inb_command( port, buf, 2, timeout-jiffies )) != 0 ) 846 if ((ret = digi_write_inb_command(port, buf, 2, timeout - jiffies)) != 0)
885 return( ret ); 847 return ret;
886 848
887 spin_lock_irqsave( &priv->dp_port_lock, flags ); 849 spin_lock_irqsave(&priv->dp_port_lock, flags);
888 850
889 while( time_before(jiffies, timeout) && !priv->dp_transmit_idle ) { 851 while(time_before(jiffies, timeout) && !priv->dp_transmit_idle) {
890 cond_wait_interruptible_timeout_irqrestore( 852 cond_wait_interruptible_timeout_irqrestore(
891 &priv->dp_transmit_idle_wait, DIGI_RETRY_TIMEOUT, 853 &priv->dp_transmit_idle_wait, DIGI_RETRY_TIMEOUT,
892 &priv->dp_port_lock, flags ); 854 &priv->dp_port_lock, flags);
893 if( signal_pending(current) ) { 855 if (signal_pending(current))
894 return( -EINTR ); 856 return -EINTR;
895 } 857 spin_lock_irqsave(&priv->dp_port_lock, flags);
896 spin_lock_irqsave( &priv->dp_port_lock, flags );
897 } 858 }
898
899 priv->dp_transmit_idle = 0; 859 priv->dp_transmit_idle = 0;
900 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 860 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
901 861 return 0;
902 return( 0 );
903 862
904} 863}
905 864
906 865
907static void digi_rx_throttle( struct usb_serial_port *port ) 866static void digi_rx_throttle(struct usb_serial_port *port)
908{ 867{
909
910 unsigned long flags; 868 unsigned long flags;
911 struct digi_port *priv = usb_get_serial_port_data(port); 869 struct digi_port *priv = usb_get_serial_port_data(port);
912 870
913 871
914dbg( "digi_rx_throttle: TOP: port=%d", priv->dp_port_num ); 872 dbg("digi_rx_throttle: TOP: port=%d", priv->dp_port_num);
915 873
916 /* stop receiving characters by not resubmitting the read urb */ 874 /* stop receiving characters by not resubmitting the read urb */
917 spin_lock_irqsave( &priv->dp_port_lock, flags ); 875 spin_lock_irqsave(&priv->dp_port_lock, flags);
918 priv->dp_throttled = 1; 876 priv->dp_throttled = 1;
919 priv->dp_throttle_restart = 0; 877 priv->dp_throttle_restart = 0;
920 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 878 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
921
922} 879}
923 880
924 881
925static void digi_rx_unthrottle( struct usb_serial_port *port ) 882static void digi_rx_unthrottle(struct usb_serial_port *port)
926{ 883{
927
928 int ret = 0; 884 int ret = 0;
929 unsigned long flags; 885 unsigned long flags;
930 struct digi_port *priv = usb_get_serial_port_data(port); 886 struct digi_port *priv = usb_get_serial_port_data(port);
931 887
932dbg( "digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num ); 888 dbg("digi_rx_unthrottle: TOP: port=%d", priv->dp_port_num);
933 889
934 spin_lock_irqsave( &priv->dp_port_lock, flags ); 890 spin_lock_irqsave(&priv->dp_port_lock, flags);
935 891
936 /* turn throttle off */ 892 /* turn throttle off */
937 priv->dp_throttled = 0; 893 priv->dp_throttled = 0;
938 priv->dp_throttle_restart = 0; 894 priv->dp_throttle_restart = 0;
939 895
940 /* restart read chain */ 896 /* restart read chain */
941 if( priv->dp_throttle_restart ) { 897 if (priv->dp_throttle_restart) {
942 port->read_urb->dev = port->serial->dev; 898 port->read_urb->dev = port->serial->dev;
943 ret = usb_submit_urb( port->read_urb, GFP_ATOMIC ); 899 ret = usb_submit_urb(port->read_urb, GFP_ATOMIC);
944 } 900 }
945 901
946 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 902 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
947
948 if( ret ) {
949 err("%s: usb_submit_urb failed, ret=%d, port=%d", __FUNCTION__,
950 ret, priv->dp_port_num );
951 }
952 903
904 if (ret)
905 err("%s: usb_submit_urb failed, ret=%d, port=%d",
906 __FUNCTION__, ret, priv->dp_port_num);
953} 907}
954 908
955 909
956static void digi_set_termios( struct usb_serial_port *port, 910static void digi_set_termios(struct usb_serial_port *port,
957 struct ktermios *old_termios ) 911 struct ktermios *old_termios)
958{ 912{
959 913
960 struct digi_port *priv = usb_get_serial_port_data(port); 914 struct digi_port *priv = usb_get_serial_port_data(port);
961 unsigned int iflag = port->tty->termios->c_iflag; 915 struct tty_struct *tty = port->tty;
962 unsigned int cflag = port->tty->termios->c_cflag; 916 unsigned int iflag = tty->termios->c_iflag;
917 unsigned int cflag = tty->termios->c_cflag;
963 unsigned int old_iflag = old_termios->c_iflag; 918 unsigned int old_iflag = old_termios->c_iflag;
964 unsigned int old_cflag = old_termios->c_cflag; 919 unsigned int old_cflag = old_termios->c_cflag;
965 unsigned char buf[32]; 920 unsigned char buf[32];
966 unsigned int modem_signals; 921 unsigned int modem_signals;
967 int arg,ret; 922 int arg,ret;
968 int i = 0; 923 int i = 0;
924 speed_t baud;
969 925
970 926 dbg("digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x", priv->dp_port_num, iflag, old_iflag, cflag, old_cflag);
971dbg( "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x", priv->dp_port_num, iflag, old_iflag, cflag, old_cflag );
972 927
973 /* set baud rate */ 928 /* set baud rate */
974 if( (cflag&CBAUD) != (old_cflag&CBAUD) ) { 929 if ((baud = tty_get_baud_rate(tty)) != tty_termios_baud_rate(old_termios)) {
975
976 arg = -1; 930 arg = -1;
977 931
978 /* reassert DTR and (maybe) RTS on transition from B0 */ 932 /* reassert DTR and (maybe) RTS on transition from B0 */
979 if( (old_cflag&CBAUD) == B0 ) { 933 if ((old_cflag&CBAUD) == B0) {
980 /* don't set RTS if using hardware flow control */ 934 /* don't set RTS if using hardware flow control */
981 /* and throttling input */ 935 /* and throttling input */
982 modem_signals = TIOCM_DTR; 936 modem_signals = TIOCM_DTR;
983 if( !(port->tty->termios->c_cflag & CRTSCTS) || 937 if (!(tty->termios->c_cflag & CRTSCTS) ||
984 !test_bit(TTY_THROTTLED, &port->tty->flags) ) { 938 !test_bit(TTY_THROTTLED, &tty->flags))
985 modem_signals |= TIOCM_RTS; 939 modem_signals |= TIOCM_RTS;
986 } 940 digi_set_modem_signals(port, modem_signals, 1);
987 digi_set_modem_signals( port, modem_signals, 1 );
988 } 941 }
989 942 switch (baud) {
990 switch( (cflag&CBAUD) ) {
991 /* drop DTR and RTS on transition to B0 */ 943 /* drop DTR and RTS on transition to B0 */
992 case B0: digi_set_modem_signals( port, 0, 1 ); break; 944 case 0: digi_set_modem_signals(port, 0, 1); break;
993 case B50: arg = DIGI_BAUD_50; break; 945 case 50: arg = DIGI_BAUD_50; break;
994 case B75: arg = DIGI_BAUD_75; break; 946 case 75: arg = DIGI_BAUD_75; break;
995 case B110: arg = DIGI_BAUD_110; break; 947 case 110: arg = DIGI_BAUD_110; break;
996 case B150: arg = DIGI_BAUD_150; break; 948 case 150: arg = DIGI_BAUD_150; break;
997 case B200: arg = DIGI_BAUD_200; break; 949 case 200: arg = DIGI_BAUD_200; break;
998 case B300: arg = DIGI_BAUD_300; break; 950 case 300: arg = DIGI_BAUD_300; break;
999 case B600: arg = DIGI_BAUD_600; break; 951 case 600: arg = DIGI_BAUD_600; break;
1000 case B1200: arg = DIGI_BAUD_1200; break; 952 case 1200: arg = DIGI_BAUD_1200; break;
1001 case B1800: arg = DIGI_BAUD_1800; break; 953 case 1800: arg = DIGI_BAUD_1800; break;
1002 case B2400: arg = DIGI_BAUD_2400; break; 954 case 2400: arg = DIGI_BAUD_2400; break;
1003 case B4800: arg = DIGI_BAUD_4800; break; 955 case 4800: arg = DIGI_BAUD_4800; break;
1004 case B9600: arg = DIGI_BAUD_9600; break; 956 case 9600: arg = DIGI_BAUD_9600; break;
1005 case B19200: arg = DIGI_BAUD_19200; break; 957 case 19200: arg = DIGI_BAUD_19200; break;
1006 case B38400: arg = DIGI_BAUD_38400; break; 958 case 38400: arg = DIGI_BAUD_38400; break;
1007 case B57600: arg = DIGI_BAUD_57600; break; 959 case 57600: arg = DIGI_BAUD_57600; break;
1008 case B115200: arg = DIGI_BAUD_115200; break; 960 case 115200: arg = DIGI_BAUD_115200; break;
1009 case B230400: arg = DIGI_BAUD_230400; break; 961 case 230400: arg = DIGI_BAUD_230400; break;
1010 case B460800: arg = DIGI_BAUD_460800; break; 962 case 460800: arg = DIGI_BAUD_460800; break;
1011 default: 963 default:
1012 dbg( "digi_set_termios: can't handle baud rate 0x%x", 964 arg = DIGI_BAUD_9600;
1013 (cflag&CBAUD) ); 965 baud = 9600;
1014 break; 966 break;
1015 } 967 }
1016 968 if (arg != -1) {
1017 if( arg != -1 ) {
1018 buf[i++] = DIGI_CMD_SET_BAUD_RATE; 969 buf[i++] = DIGI_CMD_SET_BAUD_RATE;
1019 buf[i++] = priv->dp_port_num; 970 buf[i++] = priv->dp_port_num;
1020 buf[i++] = arg; 971 buf[i++] = arg;
1021 buf[i++] = 0; 972 buf[i++] = 0;
1022 } 973 }
1023
1024 } 974 }
1025
1026 /* set parity */ 975 /* set parity */
1027 if( (cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD)) ) { 976 if ((cflag&(PARENB|PARODD)) != (old_cflag&(PARENB|PARODD))) {
1028 977 if (cflag&PARENB) {
1029 if( (cflag&PARENB) ) { 978 if (cflag&PARODD)
1030 if( (cflag&PARODD) )
1031 arg = DIGI_PARITY_ODD; 979 arg = DIGI_PARITY_ODD;
1032 else 980 else
1033 arg = DIGI_PARITY_EVEN; 981 arg = DIGI_PARITY_EVEN;
1034 } else { 982 } else {
1035 arg = DIGI_PARITY_NONE; 983 arg = DIGI_PARITY_NONE;
1036 } 984 }
1037
1038 buf[i++] = DIGI_CMD_SET_PARITY; 985 buf[i++] = DIGI_CMD_SET_PARITY;
1039 buf[i++] = priv->dp_port_num; 986 buf[i++] = priv->dp_port_num;
1040 buf[i++] = arg; 987 buf[i++] = arg;
1041 buf[i++] = 0; 988 buf[i++] = 0;
1042
1043 } 989 }
1044
1045 /* set word size */ 990 /* set word size */
1046 if( (cflag&CSIZE) != (old_cflag&CSIZE) ) { 991 if ((cflag&CSIZE) != (old_cflag&CSIZE)) {
1047
1048 arg = -1; 992 arg = -1;
1049 993 switch (cflag&CSIZE) {
1050 switch( (cflag&CSIZE) ) {
1051 case CS5: arg = DIGI_WORD_SIZE_5; break; 994 case CS5: arg = DIGI_WORD_SIZE_5; break;
1052 case CS6: arg = DIGI_WORD_SIZE_6; break; 995 case CS6: arg = DIGI_WORD_SIZE_6; break;
1053 case CS7: arg = DIGI_WORD_SIZE_7; break; 996 case CS7: arg = DIGI_WORD_SIZE_7; break;
1054 case CS8: arg = DIGI_WORD_SIZE_8; break; 997 case CS8: arg = DIGI_WORD_SIZE_8; break;
1055 default: 998 default:
1056 dbg( "digi_set_termios: can't handle word size %d", 999 dbg("digi_set_termios: can't handle word size %d",
1057 (cflag&CSIZE) ); 1000 (cflag&CSIZE));
1058 break; 1001 break;
1059 } 1002 }
1060 1003
1061 if( arg != -1 ) { 1004 if (arg != -1) {
1062 buf[i++] = DIGI_CMD_SET_WORD_SIZE; 1005 buf[i++] = DIGI_CMD_SET_WORD_SIZE;
1063 buf[i++] = priv->dp_port_num; 1006 buf[i++] = priv->dp_port_num;
1064 buf[i++] = arg; 1007 buf[i++] = arg;
@@ -1068,9 +1011,9 @@ dbg( "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, ol
1068 } 1011 }
1069 1012
1070 /* set stop bits */ 1013 /* set stop bits */
1071 if( (cflag&CSTOPB) != (old_cflag&CSTOPB) ) { 1014 if ((cflag&CSTOPB) != (old_cflag&CSTOPB)) {
1072 1015
1073 if( (cflag&CSTOPB) ) 1016 if ((cflag&CSTOPB))
1074 arg = DIGI_STOP_BITS_2; 1017 arg = DIGI_STOP_BITS_2;
1075 else 1018 else
1076 arg = DIGI_STOP_BITS_1; 1019 arg = DIGI_STOP_BITS_1;
@@ -1083,18 +1026,15 @@ dbg( "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, ol
1083 } 1026 }
1084 1027
1085 /* set input flow control */ 1028 /* set input flow control */
1086 if( (iflag&IXOFF) != (old_iflag&IXOFF) 1029 if ((iflag&IXOFF) != (old_iflag&IXOFF)
1087 || (cflag&CRTSCTS) != (old_cflag&CRTSCTS) ) { 1030 || (cflag&CRTSCTS) != (old_cflag&CRTSCTS)) {
1088
1089 arg = 0; 1031 arg = 0;
1090 1032 if (iflag&IXOFF)
1091 if( (iflag&IXOFF) )
1092 arg |= DIGI_INPUT_FLOW_CONTROL_XON_XOFF; 1033 arg |= DIGI_INPUT_FLOW_CONTROL_XON_XOFF;
1093 else 1034 else
1094 arg &= ~DIGI_INPUT_FLOW_CONTROL_XON_XOFF; 1035 arg &= ~DIGI_INPUT_FLOW_CONTROL_XON_XOFF;
1095 1036
1096 if( (cflag&CRTSCTS) ) { 1037 if (cflag&CRTSCTS) {
1097
1098 arg |= DIGI_INPUT_FLOW_CONTROL_RTS; 1038 arg |= DIGI_INPUT_FLOW_CONTROL_RTS;
1099 1039
1100 /* On USB-4 it is necessary to assert RTS prior */ 1040 /* On USB-4 it is necessary to assert RTS prior */
@@ -1107,43 +1047,37 @@ dbg( "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, ol
1107 } else { 1047 } else {
1108 arg &= ~DIGI_INPUT_FLOW_CONTROL_RTS; 1048 arg &= ~DIGI_INPUT_FLOW_CONTROL_RTS;
1109 } 1049 }
1110
1111 buf[i++] = DIGI_CMD_SET_INPUT_FLOW_CONTROL; 1050 buf[i++] = DIGI_CMD_SET_INPUT_FLOW_CONTROL;
1112 buf[i++] = priv->dp_port_num; 1051 buf[i++] = priv->dp_port_num;
1113 buf[i++] = arg; 1052 buf[i++] = arg;
1114 buf[i++] = 0; 1053 buf[i++] = 0;
1115
1116 } 1054 }
1117 1055
1118 /* set output flow control */ 1056 /* set output flow control */
1119 if( (iflag&IXON) != (old_iflag&IXON) 1057 if ((iflag&IXON) != (old_iflag&IXON)
1120 || (cflag&CRTSCTS) != (old_cflag&CRTSCTS) ) { 1058 || (cflag&CRTSCTS) != (old_cflag&CRTSCTS)) {
1121
1122 arg = 0; 1059 arg = 0;
1123 1060 if (iflag&IXON)
1124 if( (iflag&IXON) )
1125 arg |= DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; 1061 arg |= DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF;
1126 else 1062 else
1127 arg &= ~DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF; 1063 arg &= ~DIGI_OUTPUT_FLOW_CONTROL_XON_XOFF;
1128 1064
1129 if( (cflag&CRTSCTS) ) { 1065 if (cflag&CRTSCTS) {
1130 arg |= DIGI_OUTPUT_FLOW_CONTROL_CTS; 1066 arg |= DIGI_OUTPUT_FLOW_CONTROL_CTS;
1131 } else { 1067 } else {
1132 arg &= ~DIGI_OUTPUT_FLOW_CONTROL_CTS; 1068 arg &= ~DIGI_OUTPUT_FLOW_CONTROL_CTS;
1133 port->tty->hw_stopped = 0; 1069 tty->hw_stopped = 0;
1134 } 1070 }
1135 1071
1136 buf[i++] = DIGI_CMD_SET_OUTPUT_FLOW_CONTROL; 1072 buf[i++] = DIGI_CMD_SET_OUTPUT_FLOW_CONTROL;
1137 buf[i++] = priv->dp_port_num; 1073 buf[i++] = priv->dp_port_num;
1138 buf[i++] = arg; 1074 buf[i++] = arg;
1139 buf[i++] = 0; 1075 buf[i++] = 0;
1140
1141 } 1076 }
1142 1077
1143 /* set receive enable/disable */ 1078 /* set receive enable/disable */
1144 if( (cflag&CREAD) != (old_cflag&CREAD) ) { 1079 if ((cflag&CREAD) != (old_cflag&CREAD)) {
1145 1080 if (cflag&CREAD)
1146 if( (cflag&CREAD) )
1147 arg = DIGI_ENABLE; 1081 arg = DIGI_ENABLE;
1148 else 1082 else
1149 arg = DIGI_DISABLE; 1083 arg = DIGI_DISABLE;
@@ -1152,32 +1086,26 @@ dbg( "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, ol
1152 buf[i++] = priv->dp_port_num; 1086 buf[i++] = priv->dp_port_num;
1153 buf[i++] = arg; 1087 buf[i++] = arg;
1154 buf[i++] = 0; 1088 buf[i++] = 0;
1155
1156 } 1089 }
1157 1090 if ((ret = digi_write_oob_command(port, buf, i, 1)) != 0)
1158 if( (ret=digi_write_oob_command( port, buf, i, 1 )) != 0 ) 1091 dbg("digi_set_termios: write oob failed, ret=%d", ret);
1159 dbg( "digi_set_termios: write oob failed, ret=%d", ret );
1160 1092
1161} 1093}
1162 1094
1163 1095
1164static void digi_break_ctl( struct usb_serial_port *port, int break_state ) 1096static void digi_break_ctl(struct usb_serial_port *port, int break_state)
1165{ 1097{
1166
1167 unsigned char buf[4]; 1098 unsigned char buf[4];
1168 1099
1169
1170 buf[0] = DIGI_CMD_BREAK_CONTROL; 1100 buf[0] = DIGI_CMD_BREAK_CONTROL;
1171 buf[1] = 2; /* length */ 1101 buf[1] = 2; /* length */
1172 buf[2] = break_state ? 1 : 0; 1102 buf[2] = break_state ? 1 : 0;
1173 buf[3] = 0; /* pad */ 1103 buf[3] = 0; /* pad */
1174 1104 digi_write_inb_command(port, buf, 4, 0);
1175 digi_write_inb_command( port, buf, 4, 0 );
1176
1177} 1105}
1178 1106
1179 1107
1180static int digi_tiocmget( struct usb_serial_port *port, struct file *file ) 1108static int digi_tiocmget(struct usb_serial_port *port, struct file *file)
1181{ 1109{
1182 struct digi_port *priv = usb_get_serial_port_data(port); 1110 struct digi_port *priv = usb_get_serial_port_data(port);
1183 unsigned int val; 1111 unsigned int val;
@@ -1185,15 +1113,15 @@ static int digi_tiocmget( struct usb_serial_port *port, struct file *file )
1185 1113
1186 dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num); 1114 dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num);
1187 1115
1188 spin_lock_irqsave( &priv->dp_port_lock, flags ); 1116 spin_lock_irqsave(&priv->dp_port_lock, flags);
1189 val = priv->dp_modem_signals; 1117 val = priv->dp_modem_signals;
1190 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 1118 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1191 return val; 1119 return val;
1192} 1120}
1193 1121
1194 1122
1195static int digi_tiocmset( struct usb_serial_port *port, struct file *file, 1123static int digi_tiocmset(struct usb_serial_port *port, struct file *file,
1196 unsigned int set, unsigned int clear ) 1124 unsigned int set, unsigned int clear)
1197{ 1125{
1198 struct digi_port *priv = usb_get_serial_port_data(port); 1126 struct digi_port *priv = usb_get_serial_port_data(port);
1199 unsigned int val; 1127 unsigned int val;
@@ -1201,41 +1129,34 @@ static int digi_tiocmset( struct usb_serial_port *port, struct file *file,
1201 1129
1202 dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num); 1130 dbg("%s: TOP: port=%d", __FUNCTION__, priv->dp_port_num);
1203 1131
1204 spin_lock_irqsave( &priv->dp_port_lock, flags ); 1132 spin_lock_irqsave(&priv->dp_port_lock, flags);
1205 val = (priv->dp_modem_signals & ~clear) | set; 1133 val = (priv->dp_modem_signals & ~clear) | set;
1206 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 1134 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1207 return digi_set_modem_signals( port, val, 1 ); 1135 return digi_set_modem_signals(port, val, 1);
1208} 1136}
1209 1137
1210 1138
1211static int digi_ioctl( struct usb_serial_port *port, struct file *file, 1139static int digi_ioctl(struct usb_serial_port *port, struct file *file,
1212 unsigned int cmd, unsigned long arg ) 1140 unsigned int cmd, unsigned long arg)
1213{ 1141{
1214
1215 struct digi_port *priv = usb_get_serial_port_data(port); 1142 struct digi_port *priv = usb_get_serial_port_data(port);
1216 1143 dbg("digi_ioctl: TOP: port=%d, cmd=0x%x", priv->dp_port_num, cmd);
1217dbg( "digi_ioctl: TOP: port=%d, cmd=0x%x", priv->dp_port_num, cmd );
1218 1144
1219 switch (cmd) { 1145 switch (cmd) {
1220
1221 case TIOCMIWAIT: 1146 case TIOCMIWAIT:
1222 /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/ 1147 /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
1223 /* TODO */ 1148 /* TODO */
1224 return( 0 ); 1149 return 0;
1225
1226 case TIOCGICOUNT: 1150 case TIOCGICOUNT:
1227 /* return count of modemline transitions */ 1151 /* return count of modemline transitions */
1228 /* TODO */ 1152 /* TODO */
1229 return 0; 1153 return 0;
1230
1231 } 1154 }
1232 1155 return -ENOIOCTLCMD;
1233 return( -ENOIOCTLCMD );
1234 1156
1235} 1157}
1236 1158
1237 1159static int digi_write(struct usb_serial_port *port, const unsigned char *buf, int count)
1238static int digi_write( struct usb_serial_port *port, const unsigned char *buf, int count )
1239{ 1160{
1240 1161
1241 int ret,data_len,new_len; 1162 int ret,data_len,new_len;
@@ -1243,35 +1164,29 @@ static int digi_write( struct usb_serial_port *port, const unsigned char *buf, i
1243 unsigned char *data = port->write_urb->transfer_buffer; 1164 unsigned char *data = port->write_urb->transfer_buffer;
1244 unsigned long flags = 0; 1165 unsigned long flags = 0;
1245 1166
1246 1167 dbg("digi_write: TOP: port=%d, count=%d, in_interrupt=%ld",
1247dbg( "digi_write: TOP: port=%d, count=%d, in_interrupt=%ld", 1168 priv->dp_port_num, count, in_interrupt());
1248priv->dp_port_num, count, in_interrupt() );
1249 1169
1250 /* copy user data (which can sleep) before getting spin lock */ 1170 /* copy user data (which can sleep) before getting spin lock */
1251 count = min( count, port->bulk_out_size-2 ); 1171 count = min(count, port->bulk_out_size-2);
1252 count = min( 64, count); 1172 count = min(64, count);
1253 1173
1254 /* be sure only one write proceeds at a time */ 1174 /* be sure only one write proceeds at a time */
1255 /* there are races on the port private buffer */ 1175 /* there are races on the port private buffer */
1256 /* and races to check write_urb->status */ 1176 /* and races to check write_urb->status */
1257 spin_lock_irqsave( &priv->dp_port_lock, flags ); 1177 spin_lock_irqsave(&priv->dp_port_lock, flags);
1258 1178
1259 /* wait for urb status clear to submit another urb */ 1179 /* wait for urb status clear to submit another urb */
1260 if( port->write_urb->status == -EINPROGRESS 1180 if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use) {
1261 || priv->dp_write_urb_in_use ) {
1262
1263 /* buffer data if count is 1 (probably put_char) if possible */ 1181 /* buffer data if count is 1 (probably put_char) if possible */
1264 if( count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE ) { 1182 if (count == 1 && priv->dp_out_buf_len < DIGI_OUT_BUF_SIZE) {
1265 priv->dp_out_buf[priv->dp_out_buf_len++] = *buf; 1183 priv->dp_out_buf[priv->dp_out_buf_len++] = *buf;
1266 new_len = 1; 1184 new_len = 1;
1267 } else { 1185 } else {
1268 new_len = 0; 1186 new_len = 0;
1269 } 1187 }
1270 1188 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1271 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 1189 return new_len;
1272
1273 return( new_len );
1274
1275 } 1190 }
1276 1191
1277 /* allow space for any buffered data and for new data, up to */ 1192 /* allow space for any buffered data and for new data, up to */
@@ -1279,9 +1194,9 @@ priv->dp_port_num, count, in_interrupt() );
1279 new_len = min(count, port->bulk_out_size-2-priv->dp_out_buf_len); 1194 new_len = min(count, port->bulk_out_size-2-priv->dp_out_buf_len);
1280 data_len = new_len + priv->dp_out_buf_len; 1195 data_len = new_len + priv->dp_out_buf_len;
1281 1196
1282 if( data_len == 0 ) { 1197 if (data_len == 0) {
1283 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 1198 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1284 return( 0 ); 1199 return 0;
1285 } 1200 }
1286 1201
1287 port->write_urb->transfer_buffer_length = data_len+2; 1202 port->write_urb->transfer_buffer_length = data_len+2;
@@ -1291,32 +1206,29 @@ priv->dp_port_num, count, in_interrupt() );
1291 *data++ = data_len; 1206 *data++ = data_len;
1292 1207
1293 /* copy in buffered data first */ 1208 /* copy in buffered data first */
1294 memcpy( data, priv->dp_out_buf, priv->dp_out_buf_len ); 1209 memcpy(data, priv->dp_out_buf, priv->dp_out_buf_len);
1295 data += priv->dp_out_buf_len; 1210 data += priv->dp_out_buf_len;
1296 1211
1297 /* copy in new data */ 1212 /* copy in new data */
1298 memcpy( data, buf, new_len ); 1213 memcpy(data, buf, new_len);
1299 1214
1300 if( (ret=usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0 ) { 1215 if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) {
1301 priv->dp_write_urb_in_use = 1; 1216 priv->dp_write_urb_in_use = 1;
1302 ret = new_len; 1217 ret = new_len;
1303 priv->dp_out_buf_len = 0; 1218 priv->dp_out_buf_len = 0;
1304 } 1219 }
1305 1220
1306 /* return length of new data written, or error */ 1221 /* return length of new data written, or error */
1307 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 1222 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1308 if( ret < 0 ) { 1223 if (ret < 0)
1309 err("%s: usb_submit_urb failed, ret=%d, port=%d", __FUNCTION__, 1224 err("%s: usb_submit_urb failed, ret=%d, port=%d",
1310 ret, priv->dp_port_num ); 1225 __FUNCTION__, ret, priv->dp_port_num);
1311 } 1226 dbg("digi_write: returning %d", ret);
1312 1227 return ret;
1313dbg( "digi_write: returning %d", ret );
1314 return( ret );
1315 1228
1316} 1229}
1317 1230
1318 1231static void digi_write_bulk_callback(struct urb *urb)
1319static void digi_write_bulk_callback( struct urb *urb )
1320{ 1232{
1321 1233
1322 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1234 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
@@ -1326,153 +1238,136 @@ static void digi_write_bulk_callback( struct urb *urb )
1326 int ret = 0; 1238 int ret = 0;
1327 int status = urb->status; 1239 int status = urb->status;
1328 1240
1329 1241 dbg("digi_write_bulk_callback: TOP, urb->status=%d", status);
1330 dbg("digi_write_bulk_callback: TOP, urb status=%d", status);
1331 1242
1332 /* port and serial sanity check */ 1243 /* port and serial sanity check */
1333 if( port == NULL || (priv=usb_get_serial_port_data(port)) == NULL ) { 1244 if (port == NULL || (priv=usb_get_serial_port_data(port)) == NULL) {
1334 err("%s: port or port->private is NULL, status=%d", 1245 err("%s: port or port->private is NULL, status=%d",
1335 __FUNCTION__, status); 1246 __FUNCTION__, status);
1336 return; 1247 return;
1337 } 1248 }
1338 serial = port->serial; 1249 serial = port->serial;
1339 if( serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL ) { 1250 if (serial == NULL || (serial_priv=usb_get_serial_data(serial)) == NULL) {
1340 err("%s: serial or serial->private is NULL, status=%d", 1251 err("%s: serial or serial->private is NULL, status=%d",
1341 __FUNCTION__, status); 1252 __FUNCTION__, status);
1342 return; 1253 return;
1343 } 1254 }
1344 1255
1345 /* handle oob callback */ 1256 /* handle oob callback */
1346 if( priv->dp_port_num == serial_priv->ds_oob_port_num ) { 1257 if (priv->dp_port_num == serial_priv->ds_oob_port_num) {
1347 dbg( "digi_write_bulk_callback: oob callback" ); 1258 dbg("digi_write_bulk_callback: oob callback");
1348 spin_lock( &priv->dp_port_lock ); 1259 spin_lock(&priv->dp_port_lock);
1349 priv->dp_write_urb_in_use = 0; 1260 priv->dp_write_urb_in_use = 0;
1350 wake_up_interruptible( &port->write_wait ); 1261 wake_up_interruptible(&port->write_wait);
1351 spin_unlock( &priv->dp_port_lock ); 1262 spin_unlock(&priv->dp_port_lock);
1352 return; 1263 return;
1353 } 1264 }
1354 1265
1355 /* try to send any buffered data on this port, if it is open */ 1266 /* try to send any buffered data on this port, if it is open */
1356 spin_lock( &priv->dp_port_lock ); 1267 spin_lock(&priv->dp_port_lock);
1357 priv->dp_write_urb_in_use = 0; 1268 priv->dp_write_urb_in_use = 0;
1358 if( port->open_count && port->write_urb->status != -EINPROGRESS 1269 if (port->open_count && port->write_urb->status != -EINPROGRESS
1359 && priv->dp_out_buf_len > 0 ) { 1270 && priv->dp_out_buf_len > 0) {
1360
1361 *((unsigned char *)(port->write_urb->transfer_buffer)) 1271 *((unsigned char *)(port->write_urb->transfer_buffer))
1362 = (unsigned char)DIGI_CMD_SEND_DATA; 1272 = (unsigned char)DIGI_CMD_SEND_DATA;
1363 *((unsigned char *)(port->write_urb->transfer_buffer)+1) 1273 *((unsigned char *)(port->write_urb->transfer_buffer)+1)
1364 = (unsigned char)priv->dp_out_buf_len; 1274 = (unsigned char)priv->dp_out_buf_len;
1365 1275 port->write_urb->transfer_buffer_length = priv->dp_out_buf_len+2;
1366 port->write_urb->transfer_buffer_length
1367 = priv->dp_out_buf_len+2;
1368 port->write_urb->dev = serial->dev; 1276 port->write_urb->dev = serial->dev;
1369 1277 memcpy(port->write_urb->transfer_buffer+2, priv->dp_out_buf,
1370 memcpy( port->write_urb->transfer_buffer+2, priv->dp_out_buf, 1278 priv->dp_out_buf_len);
1371 priv->dp_out_buf_len ); 1279 if ((ret = usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0) {
1372
1373 if( (ret=usb_submit_urb(port->write_urb, GFP_ATOMIC)) == 0 ) {
1374 priv->dp_write_urb_in_use = 1; 1280 priv->dp_write_urb_in_use = 1;
1375 priv->dp_out_buf_len = 0; 1281 priv->dp_out_buf_len = 0;
1376 } 1282 }
1377
1378 } 1283 }
1379
1380 /* wake up processes sleeping on writes immediately */ 1284 /* wake up processes sleeping on writes immediately */
1381 digi_wakeup_write( port ); 1285 digi_wakeup_write(port);
1382
1383 /* also queue up a wakeup at scheduler time, in case we */ 1286 /* also queue up a wakeup at scheduler time, in case we */
1384 /* lost the race in write_chan(). */ 1287 /* lost the race in write_chan(). */
1385 schedule_work(&priv->dp_wakeup_work); 1288 schedule_work(&priv->dp_wakeup_work);
1386 1289
1387 spin_unlock( &priv->dp_port_lock ); 1290 spin_unlock(&priv->dp_port_lock);
1388 1291 if (ret)
1389 if( ret ) { 1292 err("%s: usb_submit_urb failed, ret=%d, port=%d",
1390 err("%s: usb_submit_urb failed, ret=%d, port=%d", __FUNCTION__, 1293 __FUNCTION__, ret, priv->dp_port_num);
1391 ret, priv->dp_port_num );
1392 }
1393
1394} 1294}
1395 1295
1396 1296static int digi_write_room(struct usb_serial_port *port)
1397static int digi_write_room( struct usb_serial_port *port )
1398{ 1297{
1399 1298
1400 int room; 1299 int room;
1401 struct digi_port *priv = usb_get_serial_port_data(port); 1300 struct digi_port *priv = usb_get_serial_port_data(port);
1402 unsigned long flags = 0; 1301 unsigned long flags = 0;
1403 1302
1303 spin_lock_irqsave(&priv->dp_port_lock, flags);
1404 1304
1405 spin_lock_irqsave( &priv->dp_port_lock, flags ); 1305 if (port->write_urb->status == -EINPROGRESS || priv->dp_write_urb_in_use)
1406
1407 if( port->write_urb->status == -EINPROGRESS
1408 || priv->dp_write_urb_in_use )
1409 room = 0; 1306 room = 0;
1410 else 1307 else
1411 room = port->bulk_out_size - 2 - priv->dp_out_buf_len; 1308 room = port->bulk_out_size - 2 - priv->dp_out_buf_len;
1412 1309
1413 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 1310 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1414 1311 dbg("digi_write_room: port=%d, room=%d", priv->dp_port_num, room);
1415dbg( "digi_write_room: port=%d, room=%d", priv->dp_port_num, room ); 1312 return room;
1416 return( room );
1417 1313
1418} 1314}
1419 1315
1420 1316static int digi_chars_in_buffer(struct usb_serial_port *port)
1421static int digi_chars_in_buffer( struct usb_serial_port *port )
1422{ 1317{
1423 1318
1424 struct digi_port *priv = usb_get_serial_port_data(port); 1319 struct digi_port *priv = usb_get_serial_port_data(port);
1425 1320
1426 1321
1427 if( port->write_urb->status == -EINPROGRESS 1322 if (port->write_urb->status == -EINPROGRESS
1428 || priv->dp_write_urb_in_use ) { 1323 || priv->dp_write_urb_in_use) {
1429dbg( "digi_chars_in_buffer: port=%d, chars=%d", priv->dp_port_num, port->bulk_out_size - 2 ); 1324 dbg("digi_chars_in_buffer: port=%d, chars=%d",
1430 /* return( port->bulk_out_size - 2 ); */ 1325 priv->dp_port_num, port->bulk_out_size - 2);
1431 return( 256 ); 1326 /* return(port->bulk_out_size - 2); */
1327 return 256;
1432 } else { 1328 } else {
1433dbg( "digi_chars_in_buffer: port=%d, chars=%d", priv->dp_port_num, priv->dp_out_buf_len ); 1329 dbg("digi_chars_in_buffer: port=%d, chars=%d",
1434 return( priv->dp_out_buf_len ); 1330 priv->dp_port_num, priv->dp_out_buf_len);
1331 return priv->dp_out_buf_len;
1435 } 1332 }
1436 1333
1437} 1334}
1438 1335
1439 1336
1440static int digi_open( struct usb_serial_port *port, struct file *filp ) 1337static int digi_open(struct usb_serial_port *port, struct file *filp)
1441{ 1338{
1442
1443 int ret; 1339 int ret;
1444 unsigned char buf[32]; 1340 unsigned char buf[32];
1445 struct digi_port *priv = usb_get_serial_port_data(port); 1341 struct digi_port *priv = usb_get_serial_port_data(port);
1446 struct ktermios not_termios; 1342 struct ktermios not_termios;
1447 unsigned long flags = 0; 1343 unsigned long flags = 0;
1448 1344
1449 1345 dbg("digi_open: TOP: port=%d, open_count=%d",
1450dbg( "digi_open: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_count ); 1346 priv->dp_port_num, port->open_count);
1451 1347
1452 /* be sure the device is started up */ 1348 /* be sure the device is started up */
1453 if( digi_startup_device( port->serial ) != 0 ) 1349 if (digi_startup_device(port->serial) != 0)
1454 return( -ENXIO ); 1350 return -ENXIO;
1455 1351
1456 spin_lock_irqsave( &priv->dp_port_lock, flags ); 1352 spin_lock_irqsave(&priv->dp_port_lock, flags);
1457 1353
1458 /* don't wait on a close in progress for non-blocking opens */ 1354 /* don't wait on a close in progress for non-blocking opens */
1459 if( priv->dp_in_close && (filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0 ) { 1355 if (priv->dp_in_close && (filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0) {
1460 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 1356 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1461 return( -EAGAIN ); 1357 return -EAGAIN;
1462 } 1358 }
1463 1359
1464 /* wait for a close in progress to finish */ 1360 /* wait for a close in progress to finish */
1465 while( priv->dp_in_close ) { 1361 while(priv->dp_in_close) {
1466 cond_wait_interruptible_timeout_irqrestore( 1362 cond_wait_interruptible_timeout_irqrestore(
1467 &priv->dp_close_wait, DIGI_RETRY_TIMEOUT, 1363 &priv->dp_close_wait, DIGI_RETRY_TIMEOUT,
1468 &priv->dp_port_lock, flags ); 1364 &priv->dp_port_lock, flags);
1469 if( signal_pending(current) ) { 1365 if (signal_pending(current))
1470 return( -EINTR ); 1366 return -EINTR;
1471 } 1367 spin_lock_irqsave(&priv->dp_port_lock, flags);
1472 spin_lock_irqsave( &priv->dp_port_lock, flags );
1473 } 1368 }
1474 1369
1475 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 1370 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1476 1371
1477 /* read modem signals automatically whenever they change */ 1372 /* read modem signals automatically whenever they change */
1478 buf[0] = DIGI_CMD_READ_INPUT_SIGNALS; 1373 buf[0] = DIGI_CMD_READ_INPUT_SIGNALS;
@@ -1486,23 +1381,22 @@ dbg( "digi_open: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_cou
1486 buf[6] = DIGI_FLUSH_TX | DIGI_FLUSH_RX; 1381 buf[6] = DIGI_FLUSH_TX | DIGI_FLUSH_RX;
1487 buf[7] = 0; 1382 buf[7] = 0;
1488 1383
1489 if( (ret=digi_write_oob_command( port, buf, 8, 1 )) != 0 ) 1384 if ((ret = digi_write_oob_command(port, buf, 8, 1)) != 0)
1490 dbg( "digi_open: write oob failed, ret=%d", ret ); 1385 dbg("digi_open: write oob failed, ret=%d", ret);
1491 1386
1492 /* set termios settings */ 1387 /* set termios settings */
1493 not_termios.c_cflag = ~port->tty->termios->c_cflag; 1388 not_termios.c_cflag = ~port->tty->termios->c_cflag;
1494 not_termios.c_iflag = ~port->tty->termios->c_iflag; 1389 not_termios.c_iflag = ~port->tty->termios->c_iflag;
1495 digi_set_termios( port, &not_termios ); 1390 digi_set_termios(port, &not_termios);
1496 1391
1497 /* set DTR and RTS */ 1392 /* set DTR and RTS */
1498 digi_set_modem_signals( port, TIOCM_DTR|TIOCM_RTS, 1 ); 1393 digi_set_modem_signals(port, TIOCM_DTR|TIOCM_RTS, 1);
1499
1500 return( 0 );
1501 1394
1395 return 0;
1502} 1396}
1503 1397
1504 1398
1505static void digi_close( struct usb_serial_port *port, struct file *filp ) 1399static void digi_close(struct usb_serial_port *port, struct file *filp)
1506{ 1400{
1507 DEFINE_WAIT(wait); 1401 DEFINE_WAIT(wait);
1508 int ret; 1402 int ret;
@@ -1511,40 +1405,37 @@ static void digi_close( struct usb_serial_port *port, struct file *filp )
1511 struct digi_port *priv = usb_get_serial_port_data(port); 1405 struct digi_port *priv = usb_get_serial_port_data(port);
1512 unsigned long flags = 0; 1406 unsigned long flags = 0;
1513 1407
1514 1408 dbg("digi_close: TOP: port=%d, open_count=%d",
1515dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_count ); 1409 priv->dp_port_num, port->open_count);
1516
1517 1410
1518 /* if disconnected, just clear flags */ 1411 /* if disconnected, just clear flags */
1519 if (!usb_get_intfdata(port->serial->interface)) 1412 if (!usb_get_intfdata(port->serial->interface))
1520 goto exit; 1413 goto exit;
1521 1414
1522 /* do cleanup only after final close on this port */ 1415 /* do cleanup only after final close on this port */
1523 spin_lock_irqsave( &priv->dp_port_lock, flags ); 1416 spin_lock_irqsave(&priv->dp_port_lock, flags);
1524 priv->dp_in_close = 1; 1417 priv->dp_in_close = 1;
1525 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 1418 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1526 1419
1527 /* tell line discipline to process only XON/XOFF */ 1420 /* tell line discipline to process only XON/XOFF */
1528 tty->closing = 1; 1421 tty->closing = 1;
1529 1422
1530 /* wait for output to drain */ 1423 /* wait for output to drain */
1531 if( (filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0 ) { 1424 if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0)
1532 tty_wait_until_sent( tty, DIGI_CLOSE_TIMEOUT ); 1425 tty_wait_until_sent(tty, DIGI_CLOSE_TIMEOUT);
1533 }
1534 1426
1535 /* flush driver and line discipline buffers */ 1427 /* flush driver and line discipline buffers */
1536 if( tty->driver->flush_buffer ) 1428 if (tty->driver->flush_buffer)
1537 tty->driver->flush_buffer( tty ); 1429 tty->driver->flush_buffer(tty);
1538 tty_ldisc_flush(tty); 1430 tty_ldisc_flush(tty);
1539 1431
1540 if (port->serial->dev) { 1432 if (port->serial->dev) {
1541 /* wait for transmit idle */ 1433 /* wait for transmit idle */
1542 if( (filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0 ) { 1434 if ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) == 0) {
1543 digi_transmit_idle( port, DIGI_CLOSE_TIMEOUT ); 1435 digi_transmit_idle(port, DIGI_CLOSE_TIMEOUT);
1544 } 1436 }
1545
1546 /* drop DTR and RTS */ 1437 /* drop DTR and RTS */
1547 digi_set_modem_signals( port, 0, 0 ); 1438 digi_set_modem_signals(port, 0, 0);
1548 1439
1549 /* disable input flow control */ 1440 /* disable input flow control */
1550 buf[0] = DIGI_CMD_SET_INPUT_FLOW_CONTROL; 1441 buf[0] = DIGI_CMD_SET_INPUT_FLOW_CONTROL;
@@ -1576,8 +1467,8 @@ dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_co
1576 buf[18] = DIGI_FLUSH_TX | DIGI_FLUSH_RX; 1467 buf[18] = DIGI_FLUSH_TX | DIGI_FLUSH_RX;
1577 buf[19] = 0; 1468 buf[19] = 0;
1578 1469
1579 if( (ret=digi_write_oob_command( port, buf, 20, 0 )) != 0 ) 1470 if ((ret = digi_write_oob_command(port, buf, 20, 0)) != 0)
1580 dbg( "digi_close: write oob failed, ret=%d", ret ); 1471 dbg("digi_close: write oob failed, ret=%d", ret);
1581 1472
1582 /* wait for final commands on oob port to complete */ 1473 /* wait for final commands on oob port to complete */
1583 prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_INTERRUPTIBLE); 1474 prepare_to_wait(&priv->dp_flush_wait, &wait, TASK_INTERRUPTIBLE);
@@ -1587,17 +1478,14 @@ dbg( "digi_close: TOP: port=%d, open_count=%d", priv->dp_port_num, port->open_co
1587 /* shutdown any outstanding bulk writes */ 1478 /* shutdown any outstanding bulk writes */
1588 usb_kill_urb(port->write_urb); 1479 usb_kill_urb(port->write_urb);
1589 } 1480 }
1590
1591 tty->closing = 0; 1481 tty->closing = 0;
1592
1593exit: 1482exit:
1594 spin_lock_irqsave( &priv->dp_port_lock, flags ); 1483 spin_lock_irqsave(&priv->dp_port_lock, flags);
1595 priv->dp_write_urb_in_use = 0; 1484 priv->dp_write_urb_in_use = 0;
1596 priv->dp_in_close = 0; 1485 priv->dp_in_close = 0;
1597 wake_up_interruptible( &priv->dp_close_wait ); 1486 wake_up_interruptible(&priv->dp_close_wait);
1598 spin_unlock_irqrestore( &priv->dp_port_lock, flags ); 1487 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1599 1488 dbg("digi_close: done");
1600dbg( "digi_close: done" );
1601} 1489}
1602 1490
1603 1491
@@ -1608,155 +1496,136 @@ dbg( "digi_close: done" );
1608* urbs initialized. Returns 0 if successful, non-zero error otherwise. 1496* urbs initialized. Returns 0 if successful, non-zero error otherwise.
1609*/ 1497*/
1610 1498
1611static int digi_startup_device( struct usb_serial *serial ) 1499static int digi_startup_device(struct usb_serial *serial)
1612{ 1500{
1613
1614 int i,ret = 0; 1501 int i,ret = 0;
1615 struct digi_serial *serial_priv = usb_get_serial_data(serial); 1502 struct digi_serial *serial_priv = usb_get_serial_data(serial);
1616 struct usb_serial_port *port; 1503 struct usb_serial_port *port;
1617 1504
1618
1619 /* be sure this happens exactly once */ 1505 /* be sure this happens exactly once */
1620 spin_lock( &serial_priv->ds_serial_lock ); 1506 spin_lock(&serial_priv->ds_serial_lock);
1621 if( serial_priv->ds_device_started ) { 1507 if (serial_priv->ds_device_started) {
1622 spin_unlock( &serial_priv->ds_serial_lock ); 1508 spin_unlock(&serial_priv->ds_serial_lock);
1623 return( 0 ); 1509 return 0;
1624 } 1510 }
1625 serial_priv->ds_device_started = 1; 1511 serial_priv->ds_device_started = 1;
1626 spin_unlock( &serial_priv->ds_serial_lock ); 1512 spin_unlock(&serial_priv->ds_serial_lock);
1627 1513
1628 /* start reading from each bulk in endpoint for the device */ 1514 /* start reading from each bulk in endpoint for the device */
1629 /* set USB_DISABLE_SPD flag for write bulk urbs */ 1515 /* set USB_DISABLE_SPD flag for write bulk urbs */
1630 for( i=0; i<serial->type->num_ports+1; i++ ) { 1516 for (i = 0; i < serial->type->num_ports + 1; i++) {
1631
1632 port = serial->port[i]; 1517 port = serial->port[i];
1633
1634 port->write_urb->dev = port->serial->dev; 1518 port->write_urb->dev = port->serial->dev;
1635 1519 if ((ret = usb_submit_urb(port->read_urb, GFP_KERNEL)) != 0) {
1636 if( (ret=usb_submit_urb(port->read_urb, GFP_KERNEL)) != 0 ) { 1520 err("%s: usb_submit_urb failed, ret=%d, port=%d",
1637 err("%s: usb_submit_urb failed, ret=%d, port=%d", __FUNCTION__, 1521 __FUNCTION__, ret, i);
1638 ret, i );
1639 break; 1522 break;
1640 } 1523 }
1641
1642 } 1524 }
1643 1525 return ret;
1644 return( ret );
1645
1646} 1526}
1647 1527
1648 1528
1649static int digi_startup( struct usb_serial *serial ) 1529static int digi_startup(struct usb_serial *serial)
1650{ 1530{
1651 1531
1652 int i; 1532 int i;
1653 struct digi_port *priv; 1533 struct digi_port *priv;
1654 struct digi_serial *serial_priv; 1534 struct digi_serial *serial_priv;
1655 1535
1656 1536 dbg("digi_startup: TOP");
1657dbg( "digi_startup: TOP" );
1658 1537
1659 /* allocate the private data structures for all ports */ 1538 /* allocate the private data structures for all ports */
1660 /* number of regular ports + 1 for the out-of-band port */ 1539 /* number of regular ports + 1 for the out-of-band port */
1661 for( i=0; i<serial->type->num_ports+1; i++ ) { 1540 for(i = 0; i < serial->type->num_ports + 1; i++) {
1662
1663 /* allocate port private structure */ 1541 /* allocate port private structure */
1664 priv = kmalloc( sizeof(struct digi_port), 1542 priv = kmalloc(sizeof(struct digi_port), GFP_KERNEL);
1665 GFP_KERNEL ); 1543 if (priv == NULL) {
1666 if( priv == (struct digi_port *)0 ) { 1544 while (--i >= 0)
1667 while( --i >= 0 ) 1545 kfree(usb_get_serial_port_data(serial->port[i]));
1668 kfree( usb_get_serial_port_data(serial->port[i]) ); 1546 return 1; /* error */
1669 return( 1 ); /* error */
1670 } 1547 }
1671 1548
1672 /* initialize port private structure */ 1549 /* initialize port private structure */
1673 spin_lock_init( &priv->dp_port_lock ); 1550 spin_lock_init(&priv->dp_port_lock);
1674 priv->dp_port_num = i; 1551 priv->dp_port_num = i;
1675 priv->dp_out_buf_len = 0; 1552 priv->dp_out_buf_len = 0;
1676 priv->dp_write_urb_in_use = 0; 1553 priv->dp_write_urb_in_use = 0;
1677 priv->dp_modem_signals = 0; 1554 priv->dp_modem_signals = 0;
1678 init_waitqueue_head( &priv->dp_modem_change_wait ); 1555 init_waitqueue_head(&priv->dp_modem_change_wait);
1679 priv->dp_transmit_idle = 0; 1556 priv->dp_transmit_idle = 0;
1680 init_waitqueue_head( &priv->dp_transmit_idle_wait ); 1557 init_waitqueue_head(&priv->dp_transmit_idle_wait);
1681 priv->dp_throttled = 0; 1558 priv->dp_throttled = 0;
1682 priv->dp_throttle_restart = 0; 1559 priv->dp_throttle_restart = 0;
1683 init_waitqueue_head( &priv->dp_flush_wait ); 1560 init_waitqueue_head(&priv->dp_flush_wait);
1684 priv->dp_in_close = 0; 1561 priv->dp_in_close = 0;
1685 init_waitqueue_head( &priv->dp_close_wait ); 1562 init_waitqueue_head(&priv->dp_close_wait);
1686 INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock); 1563 INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock);
1687 priv->dp_port = serial->port[i]; 1564 priv->dp_port = serial->port[i];
1688
1689 /* initialize write wait queue for this port */ 1565 /* initialize write wait queue for this port */
1690 init_waitqueue_head( &serial->port[i]->write_wait ); 1566 init_waitqueue_head(&serial->port[i]->write_wait);
1691 1567
1692 usb_set_serial_port_data(serial->port[i], priv); 1568 usb_set_serial_port_data(serial->port[i], priv);
1693 } 1569 }
1694 1570
1695 /* allocate serial private structure */ 1571 /* allocate serial private structure */
1696 serial_priv = kmalloc( sizeof(struct digi_serial), 1572 serial_priv = kmalloc(sizeof(struct digi_serial), GFP_KERNEL);
1697 GFP_KERNEL ); 1573 if (serial_priv == NULL) {
1698 if( serial_priv == (struct digi_serial *)0 ) { 1574 for (i = 0; i < serial->type->num_ports + 1; i++)
1699 for( i=0; i<serial->type->num_ports+1; i++ ) 1575 kfree(usb_get_serial_port_data(serial->port[i]));
1700 kfree( usb_get_serial_port_data(serial->port[i]) ); 1576 return 1; /* error */
1701 return( 1 ); /* error */
1702 } 1577 }
1703 1578
1704 /* initialize serial private structure */ 1579 /* initialize serial private structure */
1705 spin_lock_init( &serial_priv->ds_serial_lock ); 1580 spin_lock_init(&serial_priv->ds_serial_lock);
1706 serial_priv->ds_oob_port_num = serial->type->num_ports; 1581 serial_priv->ds_oob_port_num = serial->type->num_ports;
1707 serial_priv->ds_oob_port = serial->port[serial_priv->ds_oob_port_num]; 1582 serial_priv->ds_oob_port = serial->port[serial_priv->ds_oob_port_num];
1708 serial_priv->ds_device_started = 0; 1583 serial_priv->ds_device_started = 0;
1709 usb_set_serial_data(serial, serial_priv); 1584 usb_set_serial_data(serial, serial_priv);
1710 1585
1711 return( 0 ); 1586 return 0;
1712
1713} 1587}
1714 1588
1715 1589
1716static void digi_shutdown( struct usb_serial *serial ) 1590static void digi_shutdown(struct usb_serial *serial)
1717{ 1591{
1718
1719 int i; 1592 int i;
1720 1593 dbg("digi_shutdown: TOP, in_interrupt()=%ld", in_interrupt());
1721
1722dbg( "digi_shutdown: TOP, in_interrupt()=%ld", in_interrupt() );
1723 1594
1724 /* stop reads and writes on all ports */ 1595 /* stop reads and writes on all ports */
1725 for( i=0; i<serial->type->num_ports+1; i++ ) { 1596 for (i = 0; i < serial->type->num_ports + 1; i++) {
1726 usb_kill_urb(serial->port[i]->read_urb); 1597 usb_kill_urb(serial->port[i]->read_urb);
1727 usb_kill_urb(serial->port[i]->write_urb); 1598 usb_kill_urb(serial->port[i]->write_urb);
1728 } 1599 }
1729 1600
1730 /* free the private data structures for all ports */ 1601 /* free the private data structures for all ports */
1731 /* number of regular ports + 1 for the out-of-band port */ 1602 /* number of regular ports + 1 for the out-of-band port */
1732 for( i=0; i<serial->type->num_ports+1; i++ ) 1603 for(i = 0; i < serial->type->num_ports + 1; i++)
1733 kfree( usb_get_serial_port_data(serial->port[i]) ); 1604 kfree(usb_get_serial_port_data(serial->port[i]));
1734 kfree( usb_get_serial_data(serial) ); 1605 kfree(usb_get_serial_data(serial));
1735} 1606}
1736 1607
1737 1608
1738static void digi_read_bulk_callback( struct urb *urb ) 1609static void digi_read_bulk_callback(struct urb *urb)
1739{ 1610{
1740
1741 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1611 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1742 struct digi_port *priv; 1612 struct digi_port *priv;
1743 struct digi_serial *serial_priv; 1613 struct digi_serial *serial_priv;
1744 int ret; 1614 int ret;
1745 int status = urb->status; 1615 int status = urb->status;
1746 1616
1747 1617 dbg("digi_read_bulk_callback: TOP");
1748dbg( "digi_read_bulk_callback: TOP" );
1749 1618
1750 /* port sanity check, do not resubmit if port is not valid */ 1619 /* port sanity check, do not resubmit if port is not valid */
1751 if( port == NULL || (priv=usb_get_serial_port_data(port)) == NULL ) { 1620 if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
1752 err("%s: port or port->private is NULL, status=%d", 1621 err("%s: port or port->private is NULL, status=%d",
1753 __FUNCTION__, status); 1622 __FUNCTION__, status);
1754 return; 1623 return;
1755 } 1624 }
1756 if( port->serial == NULL 1625 if (port->serial == NULL ||
1757 || (serial_priv=usb_get_serial_data(port->serial)) == NULL ) { 1626 (serial_priv=usb_get_serial_data(port->serial)) == NULL) {
1758 err("%s: serial is bad or serial->private is NULL, status=%d", 1627 err("%s: serial is bad or serial->private is NULL, status=%d",
1759 __FUNCTION__, status); 1628 __FUNCTION__, status);
1760 return; 1629 return;
1761 } 1630 }
1762 1631
@@ -1768,24 +1637,23 @@ dbg( "digi_read_bulk_callback: TOP" );
1768 } 1637 }
1769 1638
1770 /* handle oob or inb callback, do not resubmit if error */ 1639 /* handle oob or inb callback, do not resubmit if error */
1771 if( priv->dp_port_num == serial_priv->ds_oob_port_num ) { 1640 if (priv->dp_port_num == serial_priv->ds_oob_port_num) {
1772 if( digi_read_oob_callback( urb ) != 0 ) 1641 if (digi_read_oob_callback(urb) != 0)
1773 return; 1642 return;
1774 } else { 1643 } else {
1775 if( digi_read_inb_callback( urb ) != 0 ) 1644 if (digi_read_inb_callback(urb) != 0)
1776 return; 1645 return;
1777 } 1646 }
1778 1647
1779 /* continue read */ 1648 /* continue read */
1780 urb->dev = port->serial->dev; 1649 urb->dev = port->serial->dev;
1781 if( (ret=usb_submit_urb(urb, GFP_ATOMIC)) != 0 ) { 1650 if ((ret = usb_submit_urb(urb, GFP_ATOMIC)) != 0) {
1782 err("%s: failed resubmitting urb, ret=%d, port=%d", __FUNCTION__, 1651 err("%s: failed resubmitting urb, ret=%d, port=%d",
1783 ret, priv->dp_port_num ); 1652 __FUNCTION__, ret, priv->dp_port_num);
1784 } 1653 }
1785 1654
1786} 1655}
1787 1656
1788
1789/* 1657/*
1790* Digi Read INB Callback 1658* Digi Read INB Callback
1791* 1659*
@@ -1796,7 +1664,7 @@ dbg( "digi_read_bulk_callback: TOP" );
1796* throttled, and -1 if the sanity checks failed. 1664* throttled, and -1 if the sanity checks failed.
1797*/ 1665*/
1798 1666
1799static int digi_read_inb_callback( struct urb *urb ) 1667static int digi_read_inb_callback(struct urb *urb)
1800{ 1668{
1801 1669
1802 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1670 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
@@ -1812,72 +1680,67 @@ static int digi_read_inb_callback( struct urb *urb )
1812 1680
1813 /* do not process callbacks on closed ports */ 1681 /* do not process callbacks on closed ports */
1814 /* but do continue the read chain */ 1682 /* but do continue the read chain */
1815 if( port->open_count == 0 ) 1683 if (port->open_count == 0)
1816 return( 0 ); 1684 return 0;
1817 1685
1818 /* short/multiple packet check */ 1686 /* short/multiple packet check */
1819 if( urb->actual_length != len + 2 ) { 1687 if (urb->actual_length != len + 2) {
1820 err("%s: INCOMPLETE OR MULTIPLE PACKET, urb status=%d, " 1688 err("%s: INCOMPLETE OR MULTIPLE PACKET, urb->status=%d, "
1821 "port=%d, opcode=%d, len=%d, actual_length=%d, " 1689 "port=%d, opcode=%d, len=%d, actual_length=%d, "
1822 "port_status=%d", __FUNCTION__, status, priv->dp_port_num, 1690 "status=%d", __FUNCTION__, status, priv->dp_port_num,
1823 opcode, len, urb->actual_length, port_status); 1691 opcode, len, urb->actual_length, port_status);
1824 return( -1 ); 1692 return -1;
1825 } 1693 }
1826 1694
1827 spin_lock( &priv->dp_port_lock ); 1695 spin_lock(&priv->dp_port_lock);
1828 1696
1829 /* check for throttle; if set, do not resubmit read urb */ 1697 /* check for throttle; if set, do not resubmit read urb */
1830 /* indicate the read chain needs to be restarted on unthrottle */ 1698 /* indicate the read chain needs to be restarted on unthrottle */
1831 throttled = priv->dp_throttled; 1699 throttled = priv->dp_throttled;
1832 if( throttled ) 1700 if (throttled)
1833 priv->dp_throttle_restart = 1; 1701 priv->dp_throttle_restart = 1;
1834 1702
1835 /* receive data */ 1703 /* receive data */
1836 if( opcode == DIGI_CMD_RECEIVE_DATA ) { 1704 if (opcode == DIGI_CMD_RECEIVE_DATA) {
1837
1838 /* get flag from port_status */ 1705 /* get flag from port_status */
1839 flag = 0; 1706 flag = 0;
1840 1707
1841 /* overrun is special, not associated with a char */ 1708 /* overrun is special, not associated with a char */
1842 if (port_status & DIGI_OVERRUN_ERROR) { 1709 if (port_status & DIGI_OVERRUN_ERROR)
1843 tty_insert_flip_char( tty, 0, TTY_OVERRUN ); 1710 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
1844 }
1845 1711
1846 /* break takes precedence over parity, */ 1712 /* break takes precedence over parity, */
1847 /* which takes precedence over framing errors */ 1713 /* which takes precedence over framing errors */
1848 if (port_status & DIGI_BREAK_ERROR) { 1714 if (port_status & DIGI_BREAK_ERROR)
1849 flag = TTY_BREAK; 1715 flag = TTY_BREAK;
1850 } else if (port_status & DIGI_PARITY_ERROR) { 1716 else if (port_status & DIGI_PARITY_ERROR)
1851 flag = TTY_PARITY; 1717 flag = TTY_PARITY;
1852 } else if (port_status & DIGI_FRAMING_ERROR) { 1718 else if (port_status & DIGI_FRAMING_ERROR)
1853 flag = TTY_FRAME; 1719 flag = TTY_FRAME;
1854 }
1855 1720
1856 /* data length is len-1 (one byte of len is port_status) */ 1721 /* data length is len-1 (one byte of len is port_status) */
1857 --len; 1722 --len;
1858 1723
1859 len = tty_buffer_request_room(tty, len); 1724 len = tty_buffer_request_room(tty, len);
1860 if( len > 0 ) { 1725 if (len > 0) {
1861 /* Hot path */ 1726 /* Hot path */
1862 if(flag == TTY_NORMAL) 1727 if (flag == TTY_NORMAL)
1863 tty_insert_flip_string(tty, data, len); 1728 tty_insert_flip_string(tty, data, len);
1864 else { 1729 else {
1865 for(i = 0; i < len; i++) 1730 for(i = 0; i < len; i++)
1866 tty_insert_flip_char(tty, data[i], flag); 1731 tty_insert_flip_char(tty, data[i], flag);
1867 } 1732 }
1868 tty_flip_buffer_push( tty ); 1733 tty_flip_buffer_push(tty);
1869 } 1734 }
1870 } 1735 }
1736 spin_unlock(&priv->dp_port_lock);
1871 1737
1872 spin_unlock( &priv->dp_port_lock ); 1738 if (opcode == DIGI_CMD_RECEIVE_DISABLE)
1873 1739 dbg("%s: got RECEIVE_DISABLE", __FUNCTION__);
1874 if( opcode == DIGI_CMD_RECEIVE_DISABLE ) { 1740 else if (opcode != DIGI_CMD_RECEIVE_DATA)
1875 dbg("%s: got RECEIVE_DISABLE", __FUNCTION__ ); 1741 dbg("%s: unknown opcode: %d", __FUNCTION__, opcode);
1876 } else if( opcode != DIGI_CMD_RECEIVE_DATA ) {
1877 dbg("%s: unknown opcode: %d", __FUNCTION__, opcode );
1878 }
1879 1742
1880 return( throttled ? 1 : 0 ); 1743 return(throttled ? 1 : 0);
1881 1744
1882} 1745}
1883 1746
@@ -1891,7 +1754,7 @@ static int digi_read_inb_callback( struct urb *urb )
1891* -1 if the sanity checks failed. 1754* -1 if the sanity checks failed.
1892*/ 1755*/
1893 1756
1894static int digi_read_oob_callback( struct urb *urb ) 1757static int digi_read_oob_callback(struct urb *urb)
1895{ 1758{
1896 1759
1897 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1760 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
@@ -1900,87 +1763,75 @@ static int digi_read_oob_callback( struct urb *urb )
1900 int opcode, line, status, val; 1763 int opcode, line, status, val;
1901 int i; 1764 int i;
1902 1765
1903 1766 dbg("digi_read_oob_callback: port=%d, len=%d",
1904dbg( "digi_read_oob_callback: port=%d, len=%d", priv->dp_port_num, 1767 priv->dp_port_num, urb->actual_length);
1905urb->actual_length );
1906 1768
1907 /* handle each oob command */ 1769 /* handle each oob command */
1908 for( i=0; i<urb->actual_length-3; ) { 1770 for(i = 0; i < urb->actual_length - 3;) {
1909
1910 opcode = ((unsigned char *)urb->transfer_buffer)[i++]; 1771 opcode = ((unsigned char *)urb->transfer_buffer)[i++];
1911 line = ((unsigned char *)urb->transfer_buffer)[i++]; 1772 line = ((unsigned char *)urb->transfer_buffer)[i++];
1912 status = ((unsigned char *)urb->transfer_buffer)[i++]; 1773 status = ((unsigned char *)urb->transfer_buffer)[i++];
1913 val = ((unsigned char *)urb->transfer_buffer)[i++]; 1774 val = ((unsigned char *)urb->transfer_buffer)[i++];
1914 1775
1915dbg( "digi_read_oob_callback: opcode=%d, line=%d, status=%d, val=%d", 1776 dbg("digi_read_oob_callback: opcode=%d, line=%d, status=%d, val=%d",
1916opcode, line, status, val ); 1777 opcode, line, status, val);
1917 1778
1918 if( status != 0 || line >= serial->type->num_ports ) 1779 if (status != 0 || line >= serial->type->num_ports)
1919 continue; 1780 continue;
1920 1781
1921 port = serial->port[line]; 1782 port = serial->port[line];
1922 1783
1923 if ((priv=usb_get_serial_port_data(port)) == NULL ) 1784 if ((priv=usb_get_serial_port_data(port)) == NULL)
1924 return -1; 1785 return -1;
1925 1786
1926 if( opcode == DIGI_CMD_READ_INPUT_SIGNALS ) { 1787 if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) {
1927 1788 spin_lock(&priv->dp_port_lock);
1928 spin_lock( &priv->dp_port_lock );
1929
1930 /* convert from digi flags to termiox flags */ 1789 /* convert from digi flags to termiox flags */
1931 if( val & DIGI_READ_INPUT_SIGNALS_CTS ) { 1790 if (val & DIGI_READ_INPUT_SIGNALS_CTS) {
1932 priv->dp_modem_signals |= TIOCM_CTS; 1791 priv->dp_modem_signals |= TIOCM_CTS;
1933 /* port must be open to use tty struct */ 1792 /* port must be open to use tty struct */
1934 if( port->open_count 1793 if (port->open_count
1935 && port->tty->termios->c_cflag & CRTSCTS ) { 1794 && port->tty->termios->c_cflag & CRTSCTS) {
1936 port->tty->hw_stopped = 0; 1795 port->tty->hw_stopped = 0;
1937 digi_wakeup_write( port ); 1796 digi_wakeup_write(port);
1938 } 1797 }
1939 } else { 1798 } else {
1940 priv->dp_modem_signals &= ~TIOCM_CTS; 1799 priv->dp_modem_signals &= ~TIOCM_CTS;
1941 /* port must be open to use tty struct */ 1800 /* port must be open to use tty struct */
1942 if( port->open_count 1801 if (port->open_count
1943 && port->tty->termios->c_cflag & CRTSCTS ) { 1802 && port->tty->termios->c_cflag & CRTSCTS) {
1944 port->tty->hw_stopped = 1; 1803 port->tty->hw_stopped = 1;
1945 } 1804 }
1946 } 1805 }
1947 if( val & DIGI_READ_INPUT_SIGNALS_DSR ) 1806 if (val & DIGI_READ_INPUT_SIGNALS_DSR)
1948 priv->dp_modem_signals |= TIOCM_DSR; 1807 priv->dp_modem_signals |= TIOCM_DSR;
1949 else 1808 else
1950 priv->dp_modem_signals &= ~TIOCM_DSR; 1809 priv->dp_modem_signals &= ~TIOCM_DSR;
1951 if( val & DIGI_READ_INPUT_SIGNALS_RI ) 1810 if (val & DIGI_READ_INPUT_SIGNALS_RI)
1952 priv->dp_modem_signals |= TIOCM_RI; 1811 priv->dp_modem_signals |= TIOCM_RI;
1953 else 1812 else
1954 priv->dp_modem_signals &= ~TIOCM_RI; 1813 priv->dp_modem_signals &= ~TIOCM_RI;
1955 if( val & DIGI_READ_INPUT_SIGNALS_DCD ) 1814 if (val & DIGI_READ_INPUT_SIGNALS_DCD)
1956 priv->dp_modem_signals |= TIOCM_CD; 1815 priv->dp_modem_signals |= TIOCM_CD;
1957 else 1816 else
1958 priv->dp_modem_signals &= ~TIOCM_CD; 1817 priv->dp_modem_signals &= ~TIOCM_CD;
1959 1818
1960 wake_up_interruptible( &priv->dp_modem_change_wait ); 1819 wake_up_interruptible(&priv->dp_modem_change_wait);
1961 spin_unlock( &priv->dp_port_lock ); 1820 spin_unlock(&priv->dp_port_lock);
1962 1821 } else if (opcode == DIGI_CMD_TRANSMIT_IDLE) {
1963 } else if( opcode == DIGI_CMD_TRANSMIT_IDLE ) { 1822 spin_lock(&priv->dp_port_lock);
1964
1965 spin_lock( &priv->dp_port_lock );
1966 priv->dp_transmit_idle = 1; 1823 priv->dp_transmit_idle = 1;
1967 wake_up_interruptible( &priv->dp_transmit_idle_wait ); 1824 wake_up_interruptible(&priv->dp_transmit_idle_wait);
1968 spin_unlock( &priv->dp_port_lock ); 1825 spin_unlock(&priv->dp_port_lock);
1969 1826 } else if (opcode == DIGI_CMD_IFLUSH_FIFO) {
1970 } else if( opcode == DIGI_CMD_IFLUSH_FIFO ) { 1827 wake_up_interruptible(&priv->dp_flush_wait);
1971
1972 wake_up_interruptible( &priv->dp_flush_wait );
1973
1974 } 1828 }
1975
1976 } 1829 }
1977 1830 return 0;
1978 return( 0 );
1979 1831
1980} 1832}
1981 1833
1982 1834static int __init digi_init(void)
1983static int __init digi_init (void)
1984{ 1835{
1985 int retval; 1836 int retval;
1986 retval = usb_serial_register(&digi_acceleport_2_device); 1837 retval = usb_serial_register(&digi_acceleport_2_device);
@@ -2002,12 +1853,11 @@ failed_acceleport_2_device:
2002 return retval; 1853 return retval;
2003} 1854}
2004 1855
2005
2006static void __exit digi_exit (void) 1856static void __exit digi_exit (void)
2007{ 1857{
2008 usb_deregister (&digi_driver); 1858 usb_deregister(&digi_driver);
2009 usb_serial_deregister (&digi_acceleport_2_device); 1859 usb_serial_deregister(&digi_acceleport_2_device);
2010 usb_serial_deregister (&digi_acceleport_4_device); 1860 usb_serial_deregister(&digi_acceleport_4_device);
2011} 1861}
2012 1862
2013 1863
@@ -2015,8 +1865,8 @@ module_init(digi_init);
2015module_exit(digi_exit); 1865module_exit(digi_exit);
2016 1866
2017 1867
2018MODULE_AUTHOR( DRIVER_AUTHOR ); 1868MODULE_AUTHOR(DRIVER_AUTHOR);
2019MODULE_DESCRIPTION( DRIVER_DESC ); 1869MODULE_DESCRIPTION(DRIVER_DESC);
2020MODULE_LICENSE("GPL"); 1870MODULE_LICENSE("GPL");
2021 1871
2022module_param(debug, bool, S_IRUGO | S_IWUSR); 1872module_param(debug, bool, S_IRUGO | S_IWUSR);
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index dd42f57089ff..2ecb1d2a034d 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -2366,9 +2366,8 @@ static int send_cmd_write_baud_rate (struct edgeport_port *edge_port, int baudRa
2366 int status; 2366 int status;
2367 unsigned char number = edge_port->port->number - edge_port->port->serial->minor; 2367 unsigned char number = edge_port->port->number - edge_port->port->serial->minor;
2368 2368
2369 if ((!edge_serial->is_epic) || 2369 if (edge_serial->is_epic &&
2370 ((edge_serial->is_epic) && 2370 !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) {
2371 (!edge_serial->epic_descriptor.Supports.IOSPSetBaudRate))) {
2372 dbg("SendCmdWriteBaudRate - NOT Setting baud rate for port = %d, baud = %d", 2371 dbg("SendCmdWriteBaudRate - NOT Setting baud rate for port = %d, baud = %d",
2373 edge_port->port->number, baudRate); 2372 edge_port->port->number, baudRate);
2374 return 0; 2373 return 0;
@@ -2461,18 +2460,16 @@ static int send_cmd_write_uart_register (struct edgeport_port *edge_port, __u8 r
2461 2460
2462 dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __FUNCTION__, regValue); 2461 dbg("%s - write to %s register 0x%02x", (regNum == MCR) ? "MCR" : "LCR", __FUNCTION__, regValue);
2463 2462
2464 if ((!edge_serial->is_epic) || 2463 if (edge_serial->is_epic &&
2465 ((edge_serial->is_epic) && 2464 !edge_serial->epic_descriptor.Supports.IOSPWriteMCR &&
2466 (!edge_serial->epic_descriptor.Supports.IOSPWriteMCR) && 2465 regNum == MCR) {
2467 (regNum == MCR))) {
2468 dbg("SendCmdWriteUartReg - Not writing to MCR Register"); 2466 dbg("SendCmdWriteUartReg - Not writing to MCR Register");
2469 return 0; 2467 return 0;
2470 } 2468 }
2471 2469
2472 if ((!edge_serial->is_epic) || 2470 if (edge_serial->is_epic &&
2473 ((edge_serial->is_epic) && 2471 !edge_serial->epic_descriptor.Supports.IOSPWriteLCR &&
2474 (!edge_serial->epic_descriptor.Supports.IOSPWriteLCR) && 2472 regNum == LCR) {
2475 (regNum == LCR))) {
2476 dbg ("SendCmdWriteUartReg - Not writing to LCR Register"); 2473 dbg ("SendCmdWriteUartReg - Not writing to LCR Register");
2477 return 0; 2474 return 0;
2478 } 2475 }
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index 2a3fabcf5186..e08c9bb403d8 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -184,21 +184,21 @@ struct mct_u232_private {
184 * we do not know how to support. We ignore them for the moment. 184 * we do not know how to support. We ignore them for the moment.
185 * XXX Rate-limit the error message, it's user triggerable. 185 * XXX Rate-limit the error message, it's user triggerable.
186 */ 186 */
187static int mct_u232_calculate_baud_rate(struct usb_serial *serial, int value) 187static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value)
188{ 188{
189 if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID 189 if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID
190 || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { 190 || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) {
191 switch (value) { 191 switch (value) {
192 case B300: return 0x01; 192 case 300: return 0x01;
193 case B600: return 0x02; /* this one not tested */ 193 case 600: return 0x02; /* this one not tested */
194 case B1200: return 0x03; 194 case 1200: return 0x03;
195 case B2400: return 0x04; 195 case 2400: return 0x04;
196 case B4800: return 0x06; 196 case 4800: return 0x06;
197 case B9600: return 0x08; 197 case 9600: return 0x08;
198 case B19200: return 0x09; 198 case 19200: return 0x09;
199 case B38400: return 0x0a; 199 case 38400: return 0x0a;
200 case B57600: return 0x0b; 200 case 57600: return 0x0b;
201 case B115200: return 0x0c; 201 case 115200: return 0x0c;
202 default: 202 default:
203 err("MCT USB-RS232: unsupported baudrate request 0x%x," 203 err("MCT USB-RS232: unsupported baudrate request 0x%x,"
204 " using default of B9600", value); 204 " using default of B9600", value);
@@ -206,27 +206,27 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, int value)
206 } 206 }
207 } else { 207 } else {
208 switch (value) { 208 switch (value) {
209 case B300: value = 300; break; 209 case 300: break;
210 case B600: value = 600; break; 210 case 600: break;
211 case B1200: value = 1200; break; 211 case 1200: break;
212 case B2400: value = 2400; break; 212 case 2400: break;
213 case B4800: value = 4800; break; 213 case 4800: break;
214 case B9600: value = 9600; break; 214 case 9600: break;
215 case B19200: value = 19200; break; 215 case 19200: break;
216 case B38400: value = 38400; break; 216 case 38400: break;
217 case B57600: value = 57600; break; 217 case 57600: break;
218 case B115200: value = 115200; break; 218 case 115200: break;
219 default: 219 default:
220 err("MCT USB-RS232: unsupported baudrate request 0x%x," 220 err("MCT USB-RS232: unsupported baudrate request 0x%x,"
221 " using default of B9600", value); 221 " using default of B9600", value);
222 value = 9600; 222 value = 9600;
223 } 223 }
224 return 115200/value; 224 return 115200/value;
225 } 225 }
226} 226}
227 227
228static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_port *port, 228static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_port *port,
229 int value) 229 speed_t value)
230{ 230{
231 __le32 divisor; 231 __le32 divisor;
232 int rc; 232 int rc;
@@ -634,7 +634,7 @@ static void mct_u232_set_termios (struct usb_serial_port *port,
634 mct_u232_set_modem_ctrl(serial, control_state); 634 mct_u232_set_modem_ctrl(serial, control_state);
635 } 635 }
636 636
637 mct_u232_set_baud_rate(serial, port, cflag & CBAUD); 637 mct_u232_set_baud_rate(serial, port, tty_get_baud_rate(port->tty));
638 638
639 if ((cflag & CBAUD) == B0 ) { 639 if ((cflag & CBAUD) == B0 ) {
640 dbg("%s: baud is B0", __FUNCTION__); 640 dbg("%s: baud is B0", __FUNCTION__);
diff --git a/drivers/usb/serial/mct_u232.h b/drivers/usb/serial/mct_u232.h
index a61bac8f224a..aae10c8174d6 100644
--- a/drivers/usb/serial/mct_u232.h
+++ b/drivers/usb/serial/mct_u232.h
@@ -79,7 +79,7 @@
79 * and "Intel solution". They are the regular MCT and "Sitecom" for us. 79 * and "Intel solution". They are the regular MCT and "Sitecom" for us.
80 * This is pointless to document in the header, see the code for the bits. 80 * This is pointless to document in the header, see the code for the bits.
81 */ 81 */
82static int mct_u232_calculate_baud_rate(struct usb_serial *serial, int value); 82static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value);
83 83
84/* 84/*
85 * Line Control Register (LCR) 85 * Line Control Register (LCR)
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 0794ccdebfd4..0bb8de4cc524 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -45,7 +45,7 @@ enum devicetype {
45 DEVICE_INSTALLER = 2, 45 DEVICE_INSTALLER = 2,
46}; 46};
47 47
48int sierra_set_power_state(struct usb_device *udev, __u16 swiState) 48static int sierra_set_power_state(struct usb_device *udev, __u16 swiState)
49{ 49{
50 int result; 50 int result;
51 dev_dbg(&udev->dev, "%s", "SET POWER STATE"); 51 dev_dbg(&udev->dev, "%s", "SET POWER STATE");
@@ -60,7 +60,7 @@ int sierra_set_power_state(struct usb_device *udev, __u16 swiState)
60 return result; 60 return result;
61} 61}
62 62
63int sierra_set_ms_mode(struct usb_device *udev, __u16 eSocMode) 63static int sierra_set_ms_mode(struct usb_device *udev, __u16 eSocMode)
64{ 64{
65 int result; 65 int result;
66 dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH"); 66 dev_dbg(&udev->dev, "%s", "DEVICE MODE SWITCH");
@@ -75,7 +75,8 @@ int sierra_set_ms_mode(struct usb_device *udev, __u16 eSocMode)
75 return result; 75 return result;
76} 76}
77 77
78int sierra_probe(struct usb_interface *iface, const struct usb_device_id *id) 78static int sierra_probe(struct usb_interface *iface,
79 const struct usb_device_id *id)
79{ 80{
80 int result; 81 int result;
81 struct usb_device *udev; 82 struct usb_device *udev;
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a3665659d13b..9bf01a5efc84 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -60,19 +60,19 @@ static struct usb_driver usb_serial_driver = {
60 60
61static int debug; 61static int debug;
62static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */ 62static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */
63static spinlock_t table_lock; 63static DEFINE_MUTEX(table_lock);
64static LIST_HEAD(usb_serial_driver_list); 64static LIST_HEAD(usb_serial_driver_list);
65 65
66struct usb_serial *usb_serial_get_by_index(unsigned index) 66struct usb_serial *usb_serial_get_by_index(unsigned index)
67{ 67{
68 struct usb_serial *serial; 68 struct usb_serial *serial;
69 69
70 spin_lock(&table_lock); 70 mutex_lock(&table_lock);
71 serial = serial_table[index]; 71 serial = serial_table[index];
72 72
73 if (serial) 73 if (serial)
74 kref_get(&serial->kref); 74 kref_get(&serial->kref);
75 spin_unlock(&table_lock); 75 mutex_unlock(&table_lock);
76 return serial; 76 return serial;
77} 77}
78 78
@@ -84,7 +84,7 @@ static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_po
84 dbg("%s %d", __FUNCTION__, num_ports); 84 dbg("%s %d", __FUNCTION__, num_ports);
85 85
86 *minor = 0; 86 *minor = 0;
87 spin_lock(&table_lock); 87 mutex_lock(&table_lock);
88 for (i = 0; i < SERIAL_TTY_MINORS; ++i) { 88 for (i = 0; i < SERIAL_TTY_MINORS; ++i) {
89 if (serial_table[i]) 89 if (serial_table[i])
90 continue; 90 continue;
@@ -106,10 +106,10 @@ static struct usb_serial *get_free_serial (struct usb_serial *serial, int num_po
106 serial_table[i] = serial; 106 serial_table[i] = serial;
107 serial->port[j++]->number = i; 107 serial->port[j++]->number = i;
108 } 108 }
109 spin_unlock(&table_lock); 109 mutex_unlock(&table_lock);
110 return serial; 110 return serial;
111 } 111 }
112 spin_unlock(&table_lock); 112 mutex_unlock(&table_lock);
113 return NULL; 113 return NULL;
114} 114}
115 115
@@ -172,9 +172,9 @@ static void destroy_serial(struct kref *kref)
172 172
173void usb_serial_put(struct usb_serial *serial) 173void usb_serial_put(struct usb_serial *serial)
174{ 174{
175 spin_lock(&table_lock); 175 mutex_lock(&table_lock);
176 kref_put(&serial->kref, destroy_serial); 176 kref_put(&serial->kref, destroy_serial);
177 spin_unlock(&table_lock); 177 mutex_unlock(&table_lock);
178} 178}
179 179
180/***************************************************************************** 180/*****************************************************************************
@@ -1077,16 +1077,17 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
1077 struct usb_serial_port *port; 1077 struct usb_serial_port *port;
1078 int i, r = 0; 1078 int i, r = 0;
1079 1079
1080 if (serial) { 1080 if (!serial) /* device has been disconnected */
1081 for (i = 0; i < serial->num_ports; ++i) { 1081 return 0;
1082 port = serial->port[i]; 1082
1083 if (port) 1083 for (i = 0; i < serial->num_ports; ++i) {
1084 kill_traffic(port); 1084 port = serial->port[i];
1085 } 1085 if (port)
1086 kill_traffic(port);
1086 } 1087 }
1087 1088
1088 if (serial->type->suspend) 1089 if (serial->type->suspend)
1089 serial->type->suspend(serial, message); 1090 r = serial->type->suspend(serial, message);
1090 1091
1091 return r; 1092 return r;
1092} 1093}
@@ -1128,7 +1129,6 @@ static int __init usb_serial_init(void)
1128 return -ENOMEM; 1129 return -ENOMEM;
1129 1130
1130 /* Initialize our global data */ 1131 /* Initialize our global data */
1131 spin_lock_init(&table_lock);
1132 for (i = 0; i < SERIAL_TTY_MINORS; ++i) { 1132 for (i = 0; i < SERIAL_TTY_MINORS; ++i) {
1133 serial_table[i] = NULL; 1133 serial_table[i] = NULL;
1134 } 1134 }
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index a624e72f81dc..d8d008d42946 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -320,6 +320,13 @@ UNUSUAL_DEV( 0x04b0, 0x0401, 0x0200, 0x0200,
320 US_SC_DEVICE, US_PR_DEVICE, NULL, 320 US_SC_DEVICE, US_PR_DEVICE, NULL,
321 US_FL_FIX_CAPACITY), 321 US_FL_FIX_CAPACITY),
322 322
323/* Reported by Milinevsky Dmitry <niam.niam@gmail.com> */
324UNUSUAL_DEV( 0x04b0, 0x0409, 0x0100, 0x0100,
325 "NIKON",
326 "NIKON DSC D50",
327 US_SC_DEVICE, US_PR_DEVICE, NULL,
328 US_FL_FIX_CAPACITY),
329
323/* Reported by Andreas Bockhold <andreas@bockionline.de> */ 330/* Reported by Andreas Bockhold <andreas@bockionline.de> */
324UNUSUAL_DEV( 0x04b0, 0x0405, 0x0100, 0x0100, 331UNUSUAL_DEV( 0x04b0, 0x0405, 0x0100, 0x0100,
325 "NIKON", 332 "NIKON",
@@ -1357,6 +1364,20 @@ UNUSUAL_DEV( 0x0f19, 0x0105, 0x0100, 0x0100,
1357 US_SC_DEVICE, US_PR_DEVICE, NULL, 1364 US_SC_DEVICE, US_PR_DEVICE, NULL,
1358 US_FL_IGNORE_RESIDUE ), 1365 US_FL_IGNORE_RESIDUE ),
1359 1366
1367/* Jeremy Katz <katzj@redhat.com>:
1368 * The Blackberry Pearl can run in two modes; a usb-storage only mode
1369 * and a mode that allows access via mass storage and to its database.
1370 * The berry_charge module will set the device to dual mode and thus we
1371 * should ignore its native mode if that module is built
1372 */
1373#ifdef CONFIG_USB_BERRY_CHARGE
1374UNUSUAL_DEV( 0x0fca, 0x0006, 0x0001, 0x0001,
1375 "RIM",
1376 "Blackberry Pearl",
1377 US_SC_DEVICE, US_PR_DEVICE, NULL,
1378 US_FL_IGNORE_DEVICE ),
1379#endif
1380
1360/* Reported by Michael Stattmann <michael@stattmann.com> */ 1381/* Reported by Michael Stattmann <michael@stattmann.com> */
1361UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000, 1382UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000,
1362 "Sony Ericsson", 1383 "Sony Ericsson",
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 564cc9b51822..5216c11d4dec 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1571,7 +1571,14 @@ config FB_PM3
1571 1571
1572config FB_AU1100 1572config FB_AU1100
1573 bool "Au1100 LCD Driver" 1573 bool "Au1100 LCD Driver"
1574 depends on (FB = y) && EXPERIMENTAL && PCI && MIPS && MIPS_PB1100=y 1574 depends on (FB = y) && MIPS && SOC_AU1100
1575 select FB_CFB_FILLRECT
1576 select FB_CFB_COPYAREA
1577 select FB_CFB_IMAGEBLIT
1578 help
1579 This is the framebuffer driver for the AMD Au1100 SOC. It can drive
1580 various panels and CRTs by passing in kernel cmd line option
1581 au1100fb:panel=<name>.
1575 1582
1576config FB_AU1200 1583config FB_AU1200
1577 bool "Au1200 LCD Driver" 1584 bool "Au1200 LCD Driver"
@@ -1638,18 +1645,6 @@ config FB_MAXINE
1638 DECstation series (Personal DECstation 5000/20, /25, /33, /50, 1645 DECstation series (Personal DECstation 5000/20, /25, /33, /50,
1639 Codename "Maxine"). 1646 Codename "Maxine").
1640 1647
1641config FB_TX3912
1642 bool "TMPTX3912/PR31700 frame buffer support"
1643 depends on (FB = y) && NINO
1644 select FB_CFB_FILLRECT
1645 select FB_CFB_COPYAREA
1646 select FB_CFB_IMAGEBLIT
1647 help
1648 The TX3912 is a Toshiba RISC processor based on the MIPS 3900 core
1649 see <http://www.toshiba.com/taec/components/Generic/risc/tx3912.htm>.
1650
1651 Say Y here to enable kernel support for the on-board framebuffer.
1652
1653config FB_G364 1648config FB_G364
1654 bool "G364 frame buffer support" 1649 bool "G364 frame buffer support"
1655 depends on (FB = y) && (MIPS_MAGNUM_4000 || OLIVETTI_M700) 1650 depends on (FB = y) && (MIPS_MAGNUM_4000 || OLIVETTI_M700)
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 518933d4905f..06eec7b182b7 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -103,7 +103,6 @@ obj-$(CONFIG_FB_PMAG_AA) += pmag-aa-fb.o
103obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o 103obj-$(CONFIG_FB_PMAG_BA) += pmag-ba-fb.o
104obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o 104obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o
105obj-$(CONFIG_FB_MAXINE) += maxinefb.o 105obj-$(CONFIG_FB_MAXINE) += maxinefb.o
106obj-$(CONFIG_FB_TX3912) += tx3912fb.o
107obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o 106obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o
108obj-$(CONFIG_FB_IMX) += imxfb.o 107obj-$(CONFIG_FB_IMX) += imxfb.o
109obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o 108obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o
diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c
index 61a8bf159cb0..eedb8285e32f 100644
--- a/drivers/video/acornfb.c
+++ b/drivers/video/acornfb.c
@@ -138,17 +138,6 @@ static struct pixclock arc_clocks[] = {
138 { 41250, 42083, VIDC_CTRL_DIV1, VID_CTL_24MHz }, /* 24.000MHz */ 138 { 41250, 42083, VIDC_CTRL_DIV1, VID_CTL_24MHz }, /* 24.000MHz */
139}; 139};
140 140
141#ifdef CONFIG_ARCH_A5K
142static struct pixclock a5k_clocks[] = {
143 { 117974, 120357, VIDC_CTRL_DIV3, VID_CTL_25MHz }, /* 8.392MHz */
144 { 78649, 80238, VIDC_CTRL_DIV2, VID_CTL_25MHz }, /* 12.588MHz */
145 { 58987, 60178, VIDC_CTRL_DIV1_5, VID_CTL_25MHz }, /* 16.588MHz */
146 { 55000, 56111, VIDC_CTRL_DIV2, VID_CTL_36MHz }, /* 18.000MHz */
147 { 39325, 40119, VIDC_CTRL_DIV1, VID_CTL_25MHz }, /* 25.175MHz */
148 { 27500, 28055, VIDC_CTRL_DIV1, VID_CTL_36MHz }, /* 36.000MHz */
149};
150#endif
151
152static struct pixclock * 141static struct pixclock *
153acornfb_valid_pixrate(struct fb_var_screeninfo *var) 142acornfb_valid_pixrate(struct fb_var_screeninfo *var)
154{ 143{
@@ -163,15 +152,6 @@ acornfb_valid_pixrate(struct fb_var_screeninfo *var)
163 pixclock < arc_clocks[i].max_clock) 152 pixclock < arc_clocks[i].max_clock)
164 return arc_clocks + i; 153 return arc_clocks + i;
165 154
166#ifdef CONFIG_ARCH_A5K
167 if (machine_is_a5k()) {
168 for (i = 0; i < ARRAY_SIZE(a5k_clocks); i++)
169 if (pixclock > a5k_clocks[i].min_clock &&
170 pixclock < a5k_clocks[i].max_clock)
171 return a5k_clocks + i;
172 }
173#endif
174
175 return NULL; 155 return NULL;
176} 156}
177 157
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index b0b2e40bbd9f..718b9f83736e 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -279,90 +279,91 @@ static void __devinit bw2_do_default_mode(struct bw2_par *par,
279 } 279 }
280} 280}
281 281
282struct all_info { 282static int __devinit bw2_probe(struct of_device *op, const struct of_device_id *match)
283 struct fb_info info;
284 struct bw2_par par;
285};
286
287static int __devinit bw2_init_one(struct of_device *op)
288{ 283{
289 struct device_node *dp = op->node; 284 struct device_node *dp = op->node;
290 struct all_info *all; 285 struct fb_info *info;
286 struct bw2_par *par;
291 int linebytes, err; 287 int linebytes, err;
292 288
293 all = kzalloc(sizeof(*all), GFP_KERNEL); 289 info = framebuffer_alloc(sizeof(struct bw2_par), &op->dev);
294 if (!all)
295 return -ENOMEM;
296 290
297 spin_lock_init(&all->par.lock); 291 err = -ENOMEM;
292 if (!info)
293 goto out_err;
294 par = info->par;
298 295
299 all->par.physbase = op->resource[0].start; 296 spin_lock_init(&par->lock);
300 all->par.which_io = op->resource[0].flags & IORESOURCE_BITS;
301 297
302 sbusfb_fill_var(&all->info.var, dp->node, 1); 298 par->physbase = op->resource[0].start;
299 par->which_io = op->resource[0].flags & IORESOURCE_BITS;
300
301 sbusfb_fill_var(&info->var, dp->node, 1);
303 linebytes = of_getintprop_default(dp, "linebytes", 302 linebytes = of_getintprop_default(dp, "linebytes",
304 all->info.var.xres); 303 info->var.xres);
305 304
306 all->info.var.red.length = all->info.var.green.length = 305 info->var.red.length = info->var.green.length =
307 all->info.var.blue.length = all->info.var.bits_per_pixel; 306 info->var.blue.length = info->var.bits_per_pixel;
308 all->info.var.red.offset = all->info.var.green.offset = 307 info->var.red.offset = info->var.green.offset =
309 all->info.var.blue.offset = 0; 308 info->var.blue.offset = 0;
310 309
311 all->par.regs = of_ioremap(&op->resource[0], BWTWO_REGISTER_OFFSET, 310 par->regs = of_ioremap(&op->resource[0], BWTWO_REGISTER_OFFSET,
312 sizeof(struct bw2_regs), "bw2 regs"); 311 sizeof(struct bw2_regs), "bw2 regs");
312 if (!par->regs)
313 goto out_release_fb;
313 314
314 if (!of_find_property(dp, "width", NULL)) 315 if (!of_find_property(dp, "width", NULL))
315 bw2_do_default_mode(&all->par, &all->info, &linebytes); 316 bw2_do_default_mode(par, info, &linebytes);
316 317
317 all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres); 318 par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
318 319
319 all->info.flags = FBINFO_DEFAULT; 320 info->flags = FBINFO_DEFAULT;
320 all->info.fbops = &bw2_ops; 321 info->fbops = &bw2_ops;
321 322
322 all->info.screen_base = 323 info->screen_base = of_ioremap(&op->resource[0], 0,
323 of_ioremap(&op->resource[0], 0, all->par.fbsize, "bw2 ram"); 324 par->fbsize, "bw2 ram");
324 all->info.par = &all->par; 325 if (!info->screen_base)
326 goto out_unmap_regs;
325 327
326 bw2_blank(0, &all->info); 328 bw2_blank(0, info);
327 329
328 bw2_init_fix(&all->info, linebytes); 330 bw2_init_fix(info, linebytes);
329 331
330 err= register_framebuffer(&all->info); 332 err = register_framebuffer(info);
331 if (err < 0) { 333 if (err < 0)
332 of_iounmap(&op->resource[0], 334 goto out_unmap_screen;
333 all->par.regs, sizeof(struct bw2_regs));
334 of_iounmap(&op->resource[0],
335 all->info.screen_base, all->par.fbsize);
336 kfree(all);
337 return err;
338 }
339 335
340 dev_set_drvdata(&op->dev, all); 336 dev_set_drvdata(&op->dev, info);
341 337
342 printk("%s: bwtwo at %lx:%lx\n", 338 printk("%s: bwtwo at %lx:%lx\n",
343 dp->full_name, 339 dp->full_name, par->which_io, par->physbase);
344 all->par.which_io, all->par.physbase);
345 340
346 return 0; 341 return 0;
347}
348 342
349static int __devinit bw2_probe(struct of_device *dev, const struct of_device_id *match) 343out_unmap_screen:
350{ 344 of_iounmap(&op->resource[0], info->screen_base, par->fbsize);
351 struct of_device *op = to_of_device(&dev->dev); 345
346out_unmap_regs:
347 of_iounmap(&op->resource[0], par->regs, sizeof(struct bw2_regs));
348
349out_release_fb:
350 framebuffer_release(info);
352 351
353 return bw2_init_one(op); 352out_err:
353 return err;
354} 354}
355 355
356static int __devexit bw2_remove(struct of_device *op) 356static int __devexit bw2_remove(struct of_device *op)
357{ 357{
358 struct all_info *all = dev_get_drvdata(&op->dev); 358 struct fb_info *info = dev_get_drvdata(&op->dev);
359 struct bw2_par *par = info->par;
359 360
360 unregister_framebuffer(&all->info); 361 unregister_framebuffer(info);
361 362
362 of_iounmap(&op->resource[0], all->par.regs, sizeof(struct bw2_regs)); 363 of_iounmap(&op->resource[0], par->regs, sizeof(struct bw2_regs));
363 of_iounmap(&op->resource[0], all->info.screen_base, all->par.fbsize); 364 of_iounmap(&op->resource[0], info->screen_base, par->fbsize);
364 365
365 kfree(all); 366 framebuffer_release(info);
366 367
367 dev_set_drvdata(&op->dev, NULL); 368 dev_set_drvdata(&op->dev, NULL);
368 369
diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c
index b071bb632b97..41f6dbf61be7 100644
--- a/drivers/video/cg14.c
+++ b/drivers/video/cg14.c
@@ -448,81 +448,79 @@ static struct sbus_mmap_map __cg14_mmap_map[CG14_MMAP_ENTRIES] __devinitdata = {
448 { .size = 0 } 448 { .size = 0 }
449}; 449};
450 450
451struct all_info { 451static void cg14_unmap_regs(struct of_device *op, struct fb_info *info,
452 struct fb_info info; 452 struct cg14_par *par)
453 struct cg14_par par;
454};
455
456static void cg14_unmap_regs(struct of_device *op, struct all_info *all)
457{ 453{
458 if (all->par.regs) 454 if (par->regs)
459 of_iounmap(&op->resource[0], 455 of_iounmap(&op->resource[0],
460 all->par.regs, sizeof(struct cg14_regs)); 456 par->regs, sizeof(struct cg14_regs));
461 if (all->par.clut) 457 if (par->clut)
462 of_iounmap(&op->resource[0], 458 of_iounmap(&op->resource[0],
463 all->par.clut, sizeof(struct cg14_clut)); 459 par->clut, sizeof(struct cg14_clut));
464 if (all->par.cursor) 460 if (par->cursor)
465 of_iounmap(&op->resource[0], 461 of_iounmap(&op->resource[0],
466 all->par.cursor, sizeof(struct cg14_cursor)); 462 par->cursor, sizeof(struct cg14_cursor));
467 if (all->info.screen_base) 463 if (info->screen_base)
468 of_iounmap(&op->resource[1], 464 of_iounmap(&op->resource[1],
469 all->info.screen_base, all->par.fbsize); 465 info->screen_base, par->fbsize);
470} 466}
471 467
472static int __devinit cg14_init_one(struct of_device *op) 468static int __devinit cg14_probe(struct of_device *op, const struct of_device_id *match)
473{ 469{
474 struct device_node *dp = op->node; 470 struct device_node *dp = op->node;
475 struct all_info *all; 471 struct fb_info *info;
472 struct cg14_par *par;
476 int is_8mb, linebytes, i, err; 473 int is_8mb, linebytes, i, err;
477 474
478 all = kzalloc(sizeof(*all), GFP_KERNEL); 475 info = framebuffer_alloc(sizeof(struct cg14_par), &op->dev);
479 if (!all) 476
480 return -ENOMEM; 477 err = -ENOMEM;
478 if (!info)
479 goto out_err;
480 par = info->par;
481 481
482 spin_lock_init(&all->par.lock); 482 spin_lock_init(&par->lock);
483 483
484 sbusfb_fill_var(&all->info.var, dp->node, 8); 484 sbusfb_fill_var(&info->var, dp->node, 8);
485 all->info.var.red.length = 8; 485 info->var.red.length = 8;
486 all->info.var.green.length = 8; 486 info->var.green.length = 8;
487 all->info.var.blue.length = 8; 487 info->var.blue.length = 8;
488 488
489 linebytes = of_getintprop_default(dp, "linebytes", 489 linebytes = of_getintprop_default(dp, "linebytes",
490 all->info.var.xres); 490 info->var.xres);
491 all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres); 491 par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
492 492
493 if (!strcmp(dp->parent->name, "sbus") || 493 if (!strcmp(dp->parent->name, "sbus") ||
494 !strcmp(dp->parent->name, "sbi")) { 494 !strcmp(dp->parent->name, "sbi")) {
495 all->par.physbase = op->resource[0].start; 495 par->physbase = op->resource[0].start;
496 all->par.iospace = op->resource[0].flags & IORESOURCE_BITS; 496 par->iospace = op->resource[0].flags & IORESOURCE_BITS;
497 } else { 497 } else {
498 all->par.physbase = op->resource[1].start; 498 par->physbase = op->resource[1].start;
499 all->par.iospace = op->resource[0].flags & IORESOURCE_BITS; 499 par->iospace = op->resource[0].flags & IORESOURCE_BITS;
500 } 500 }
501 501
502 all->par.regs = of_ioremap(&op->resource[0], 0, 502 par->regs = of_ioremap(&op->resource[0], 0,
503 sizeof(struct cg14_regs), "cg14 regs"); 503 sizeof(struct cg14_regs), "cg14 regs");
504 all->par.clut = of_ioremap(&op->resource[0], CG14_CLUT1, 504 par->clut = of_ioremap(&op->resource[0], CG14_CLUT1,
505 sizeof(struct cg14_clut), "cg14 clut"); 505 sizeof(struct cg14_clut), "cg14 clut");
506 all->par.cursor = of_ioremap(&op->resource[0], CG14_CURSORREGS, 506 par->cursor = of_ioremap(&op->resource[0], CG14_CURSORREGS,
507 sizeof(struct cg14_cursor), "cg14 cursor"); 507 sizeof(struct cg14_cursor), "cg14 cursor");
508 508
509 all->info.screen_base = of_ioremap(&op->resource[1], 0, 509 info->screen_base = of_ioremap(&op->resource[1], 0,
510 all->par.fbsize, "cg14 ram"); 510 par->fbsize, "cg14 ram");
511 511
512 if (!all->par.regs || !all->par.clut || !all->par.cursor || 512 if (!par->regs || !par->clut || !par->cursor || !info->screen_base)
513 !all->info.screen_base) 513 goto out_unmap_regs;
514 cg14_unmap_regs(op, all);
515 514
516 is_8mb = (((op->resource[1].end - op->resource[1].start) + 1) == 515 is_8mb = (((op->resource[1].end - op->resource[1].start) + 1) ==
517 (8 * 1024 * 1024)); 516 (8 * 1024 * 1024));
518 517
519 BUILD_BUG_ON(sizeof(all->par.mmap_map) != sizeof(__cg14_mmap_map)); 518 BUILD_BUG_ON(sizeof(par->mmap_map) != sizeof(__cg14_mmap_map));
520 519
521 memcpy(&all->par.mmap_map, &__cg14_mmap_map, 520 memcpy(&par->mmap_map, &__cg14_mmap_map, sizeof(par->mmap_map));
522 sizeof(all->par.mmap_map));
523 521
524 for (i = 0; i < CG14_MMAP_ENTRIES; i++) { 522 for (i = 0; i < CG14_MMAP_ENTRIES; i++) {
525 struct sbus_mmap_map *map = &all->par.mmap_map[i]; 523 struct sbus_mmap_map *map = &par->mmap_map[i];
526 524
527 if (!map->size) 525 if (!map->size)
528 break; 526 break;
@@ -536,59 +534,55 @@ static int __devinit cg14_init_one(struct of_device *op)
536 map->size *= 2; 534 map->size *= 2;
537 } 535 }
538 536
539 all->par.mode = MDI_8_PIX; 537 par->mode = MDI_8_PIX;
540 all->par.ramsize = (is_8mb ? 0x800000 : 0x400000); 538 par->ramsize = (is_8mb ? 0x800000 : 0x400000);
541 539
542 all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; 540 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
543 all->info.fbops = &cg14_ops; 541 info->fbops = &cg14_ops;
544 all->info.par = &all->par;
545 542
546 __cg14_reset(&all->par); 543 __cg14_reset(par);
547 544
548 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 545 if (fb_alloc_cmap(&info->cmap, 256, 0))
549 cg14_unmap_regs(op, all); 546 goto out_unmap_regs;
550 kfree(all);
551 return -ENOMEM;
552 }
553 fb_set_cmap(&all->info.cmap, &all->info);
554 547
555 cg14_init_fix(&all->info, linebytes, dp); 548 fb_set_cmap(&info->cmap, info);
556 549
557 err = register_framebuffer(&all->info); 550 cg14_init_fix(info, linebytes, dp);
558 if (err < 0) { 551
559 fb_dealloc_cmap(&all->info.cmap); 552 err = register_framebuffer(info);
560 cg14_unmap_regs(op, all); 553 if (err < 0)
561 kfree(all); 554 goto out_dealloc_cmap;
562 return err;
563 }
564 555
565 dev_set_drvdata(&op->dev, all); 556 dev_set_drvdata(&op->dev, info);
566 557
567 printk("%s: cgfourteen at %lx:%lx, %dMB\n", 558 printk("%s: cgfourteen at %lx:%lx, %dMB\n",
568 dp->full_name, 559 dp->full_name,
569 all->par.iospace, all->par.physbase, 560 par->iospace, par->physbase,
570 all->par.ramsize >> 20); 561 par->ramsize >> 20);
571 562
572 return 0; 563 return 0;
573}
574 564
575static int __devinit cg14_probe(struct of_device *dev, const struct of_device_id *match) 565out_dealloc_cmap:
576{ 566 fb_dealloc_cmap(&info->cmap);
577 struct of_device *op = to_of_device(&dev->dev); 567
568out_unmap_regs:
569 cg14_unmap_regs(op, info, par);
578 570
579 return cg14_init_one(op); 571out_err:
572 return err;
580} 573}
581 574
582static int __devexit cg14_remove(struct of_device *op) 575static int __devexit cg14_remove(struct of_device *op)
583{ 576{
584 struct all_info *all = dev_get_drvdata(&op->dev); 577 struct fb_info *info = dev_get_drvdata(&op->dev);
578 struct cg14_par *par = info->par;
585 579
586 unregister_framebuffer(&all->info); 580 unregister_framebuffer(info);
587 fb_dealloc_cmap(&all->info.cmap); 581 fb_dealloc_cmap(&info->cmap);
588 582
589 cg14_unmap_regs(op, all); 583 cg14_unmap_regs(op, info, par);
590 584
591 kfree(all); 585 framebuffer_release(info);
592 586
593 dev_set_drvdata(&op->dev, NULL); 587 dev_set_drvdata(&op->dev, NULL);
594 588
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c
index f042428a84f4..5741b46ade1b 100644
--- a/drivers/video/cg3.c
+++ b/drivers/video/cg3.c
@@ -353,104 +353,102 @@ static void __devinit cg3_do_default_mode(struct cg3_par *par)
353 } 353 }
354} 354}
355 355
356struct all_info { 356static int __devinit cg3_probe(struct of_device *op,
357 struct fb_info info; 357 const struct of_device_id *match)
358 struct cg3_par par;
359};
360
361static int __devinit cg3_init_one(struct of_device *op)
362{ 358{
363 struct device_node *dp = op->node; 359 struct device_node *dp = op->node;
364 struct all_info *all; 360 struct fb_info *info;
361 struct cg3_par *par;
365 int linebytes, err; 362 int linebytes, err;
366 363
367 all = kzalloc(sizeof(*all), GFP_KERNEL); 364 info = framebuffer_alloc(sizeof(struct cg3_par), &op->dev);
368 if (!all)
369 return -ENOMEM;
370 365
371 spin_lock_init(&all->par.lock); 366 err = -ENOMEM;
367 if (!info)
368 goto out_err;
369 par = info->par;
372 370
373 all->par.physbase = op->resource[0].start; 371 spin_lock_init(&par->lock);
374 all->par.which_io = op->resource[0].flags & IORESOURCE_BITS;
375 372
376 sbusfb_fill_var(&all->info.var, dp->node, 8); 373 par->physbase = op->resource[0].start;
377 all->info.var.red.length = 8; 374 par->which_io = op->resource[0].flags & IORESOURCE_BITS;
378 all->info.var.green.length = 8; 375
379 all->info.var.blue.length = 8; 376 sbusfb_fill_var(&info->var, dp->node, 8);
377 info->var.red.length = 8;
378 info->var.green.length = 8;
379 info->var.blue.length = 8;
380 if (!strcmp(dp->name, "cgRDI")) 380 if (!strcmp(dp->name, "cgRDI"))
381 all->par.flags |= CG3_FLAG_RDI; 381 par->flags |= CG3_FLAG_RDI;
382 if (all->par.flags & CG3_FLAG_RDI) 382 if (par->flags & CG3_FLAG_RDI)
383 cg3_rdi_maybe_fixup_var(&all->info.var, dp); 383 cg3_rdi_maybe_fixup_var(&info->var, dp);
384 384
385 linebytes = of_getintprop_default(dp, "linebytes", 385 linebytes = of_getintprop_default(dp, "linebytes",
386 all->info.var.xres); 386 info->var.xres);
387 all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres); 387 par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
388 388
389 all->par.regs = of_ioremap(&op->resource[0], CG3_REGS_OFFSET, 389 par->regs = of_ioremap(&op->resource[0], CG3_REGS_OFFSET,
390 sizeof(struct cg3_regs), "cg3 regs"); 390 sizeof(struct cg3_regs), "cg3 regs");
391 if (!par->regs)
392 goto out_release_fb;
391 393
392 all->info.flags = FBINFO_DEFAULT; 394 info->flags = FBINFO_DEFAULT;
393 all->info.fbops = &cg3_ops; 395 info->fbops = &cg3_ops;
394 all->info.screen_base = 396 info->screen_base = of_ioremap(&op->resource[0], CG3_RAM_OFFSET,
395 of_ioremap(&op->resource[0], CG3_RAM_OFFSET, 397 par->fbsize, "cg3 ram");
396 all->par.fbsize, "cg3 ram"); 398 if (!info->screen_base)
397 all->info.par = &all->par; 399 goto out_unmap_regs;
398 400
399 cg3_blank(0, &all->info); 401 cg3_blank(0, info);
400 402
401 if (!of_find_property(dp, "width", NULL)) 403 if (!of_find_property(dp, "width", NULL))
402 cg3_do_default_mode(&all->par); 404 cg3_do_default_mode(par);
403 405
404 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 406 if (fb_alloc_cmap(&info->cmap, 256, 0))
405 of_iounmap(&op->resource[0], 407 goto out_unmap_screen;
406 all->par.regs, sizeof(struct cg3_regs)); 408
407 of_iounmap(&op->resource[0], 409 fb_set_cmap(&info->cmap, info);
408 all->info.screen_base, all->par.fbsize);
409 kfree(all);
410 return -ENOMEM;
411 }
412 fb_set_cmap(&all->info.cmap, &all->info);
413
414 cg3_init_fix(&all->info, linebytes, dp);
415
416 err = register_framebuffer(&all->info);
417 if (err < 0) {
418 fb_dealloc_cmap(&all->info.cmap);
419 of_iounmap(&op->resource[0],
420 all->par.regs, sizeof(struct cg3_regs));
421 of_iounmap(&op->resource[0],
422 all->info.screen_base, all->par.fbsize);
423 kfree(all);
424 return err;
425 }
426 410
427 dev_set_drvdata(&op->dev, all); 411 cg3_init_fix(info, linebytes, dp);
412
413 err = register_framebuffer(info);
414 if (err < 0)
415 goto out_dealloc_cmap;
416
417 dev_set_drvdata(&op->dev, info);
428 418
429 printk("%s: cg3 at %lx:%lx\n", 419 printk("%s: cg3 at %lx:%lx\n",
430 dp->full_name, all->par.which_io, all->par.physbase); 420 dp->full_name, par->which_io, par->physbase);
431 421
432 return 0; 422 return 0;
433}
434 423
435static int __devinit cg3_probe(struct of_device *dev, 424out_dealloc_cmap:
436 const struct of_device_id *match) 425 fb_dealloc_cmap(&info->cmap);
437{ 426
438 struct of_device *op = to_of_device(&dev->dev); 427out_unmap_screen:
428 of_iounmap(&op->resource[0], info->screen_base, par->fbsize);
429
430out_unmap_regs:
431 of_iounmap(&op->resource[0], par->regs, sizeof(struct cg3_regs));
432
433out_release_fb:
434 framebuffer_release(info);
439 435
440 return cg3_init_one(op); 436out_err:
437 return err;
441} 438}
442 439
443static int __devexit cg3_remove(struct of_device *op) 440static int __devexit cg3_remove(struct of_device *op)
444{ 441{
445 struct all_info *all = dev_get_drvdata(&op->dev); 442 struct fb_info *info = dev_get_drvdata(&op->dev);
443 struct cg3_par *par = info->par;
446 444
447 unregister_framebuffer(&all->info); 445 unregister_framebuffer(info);
448 fb_dealloc_cmap(&all->info.cmap); 446 fb_dealloc_cmap(&info->cmap);
449 447
450 of_iounmap(&op->resource[0], all->par.regs, sizeof(struct cg3_regs)); 448 of_iounmap(&op->resource[0], par->regs, sizeof(struct cg3_regs));
451 of_iounmap(&op->resource[0], all->info.screen_base, all->par.fbsize); 449 of_iounmap(&op->resource[0], info->screen_base, par->fbsize);
452 450
453 kfree(all); 451 framebuffer_release(info);
454 452
455 dev_set_drvdata(&op->dev, NULL); 453 dev_set_drvdata(&op->dev, NULL);
456 454
diff --git a/drivers/video/cg6.c b/drivers/video/cg6.c
index 4dad23a28f58..87c747123538 100644
--- a/drivers/video/cg6.c
+++ b/drivers/video/cg6.c
@@ -653,135 +653,120 @@ static void cg6_chip_init(struct fb_info *info)
653 sbus_writel(info->var.yres - 1, &fbc->clipmaxy); 653 sbus_writel(info->var.yres - 1, &fbc->clipmaxy);
654} 654}
655 655
656struct all_info { 656static void cg6_unmap_regs(struct of_device *op, struct fb_info *info,
657 struct fb_info info; 657 struct cg6_par *par)
658 struct cg6_par par;
659};
660
661static void cg6_unmap_regs(struct of_device *op, struct all_info *all)
662{ 658{
663 if (all->par.fbc) 659 if (par->fbc)
664 of_iounmap(&op->resource[0], all->par.fbc, 4096); 660 of_iounmap(&op->resource[0], par->fbc, 4096);
665 if (all->par.tec) 661 if (par->tec)
666 of_iounmap(&op->resource[0], 662 of_iounmap(&op->resource[0], par->tec, sizeof(struct cg6_tec));
667 all->par.tec, sizeof(struct cg6_tec)); 663 if (par->thc)
668 if (all->par.thc) 664 of_iounmap(&op->resource[0], par->thc, sizeof(struct cg6_thc));
669 of_iounmap(&op->resource[0], 665 if (par->bt)
670 all->par.thc, sizeof(struct cg6_thc)); 666 of_iounmap(&op->resource[0], par->bt, sizeof(struct bt_regs));
671 if (all->par.bt) 667 if (par->fhc)
672 of_iounmap(&op->resource[0], 668 of_iounmap(&op->resource[0], par->fhc, sizeof(u32));
673 all->par.bt, sizeof(struct bt_regs)); 669
674 if (all->par.fhc) 670 if (info->screen_base)
675 of_iounmap(&op->resource[0], 671 of_iounmap(&op->resource[0], info->screen_base, par->fbsize);
676 all->par.fhc, sizeof(u32));
677
678 if (all->info.screen_base)
679 of_iounmap(&op->resource[0],
680 all->info.screen_base, all->par.fbsize);
681} 672}
682 673
683static int __devinit cg6_init_one(struct of_device *op) 674static int __devinit cg6_probe(struct of_device *op, const struct of_device_id *match)
684{ 675{
685 struct device_node *dp = op->node; 676 struct device_node *dp = op->node;
686 struct all_info *all; 677 struct fb_info *info;
678 struct cg6_par *par;
687 int linebytes, err; 679 int linebytes, err;
688 680
689 all = kzalloc(sizeof(*all), GFP_KERNEL); 681 info = framebuffer_alloc(sizeof(struct cg6_par), &op->dev);
690 if (!all) 682
691 return -ENOMEM; 683 err = -ENOMEM;
684 if (!info)
685 goto out_err;
686 par = info->par;
692 687
693 spin_lock_init(&all->par.lock); 688 spin_lock_init(&par->lock);
694 689
695 all->par.physbase = op->resource[0].start; 690 par->physbase = op->resource[0].start;
696 all->par.which_io = op->resource[0].flags & IORESOURCE_BITS; 691 par->which_io = op->resource[0].flags & IORESOURCE_BITS;
697 692
698 sbusfb_fill_var(&all->info.var, dp->node, 8); 693 sbusfb_fill_var(&info->var, dp->node, 8);
699 all->info.var.red.length = 8; 694 info->var.red.length = 8;
700 all->info.var.green.length = 8; 695 info->var.green.length = 8;
701 all->info.var.blue.length = 8; 696 info->var.blue.length = 8;
702 697
703 linebytes = of_getintprop_default(dp, "linebytes", 698 linebytes = of_getintprop_default(dp, "linebytes",
704 all->info.var.xres); 699 info->var.xres);
705 all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres); 700 par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
706 if (of_find_property(dp, "dblbuf", NULL)) 701 if (of_find_property(dp, "dblbuf", NULL))
707 all->par.fbsize *= 4; 702 par->fbsize *= 4;
708 703
709 all->par.fbc = of_ioremap(&op->resource[0], CG6_FBC_OFFSET, 704 par->fbc = of_ioremap(&op->resource[0], CG6_FBC_OFFSET,
710 4096, "cgsix fbc"); 705 4096, "cgsix fbc");
711 all->par.tec = of_ioremap(&op->resource[0], CG6_TEC_OFFSET, 706 par->tec = of_ioremap(&op->resource[0], CG6_TEC_OFFSET,
712 sizeof(struct cg6_tec), "cgsix tec"); 707 sizeof(struct cg6_tec), "cgsix tec");
713 all->par.thc = of_ioremap(&op->resource[0], CG6_THC_OFFSET, 708 par->thc = of_ioremap(&op->resource[0], CG6_THC_OFFSET,
714 sizeof(struct cg6_thc), "cgsix thc"); 709 sizeof(struct cg6_thc), "cgsix thc");
715 all->par.bt = of_ioremap(&op->resource[0], CG6_BROOKTREE_OFFSET, 710 par->bt = of_ioremap(&op->resource[0], CG6_BROOKTREE_OFFSET,
716 sizeof(struct bt_regs), "cgsix dac"); 711 sizeof(struct bt_regs), "cgsix dac");
717 all->par.fhc = of_ioremap(&op->resource[0], CG6_FHC_OFFSET, 712 par->fhc = of_ioremap(&op->resource[0], CG6_FHC_OFFSET,
718 sizeof(u32), "cgsix fhc"); 713 sizeof(u32), "cgsix fhc");
719 714
720 all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_IMAGEBLIT | 715 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_IMAGEBLIT |
721 FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT; 716 FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT;
722 all->info.fbops = &cg6_ops; 717 info->fbops = &cg6_ops;
723
724 all->info.screen_base = of_ioremap(&op->resource[0], CG6_RAM_OFFSET,
725 all->par.fbsize, "cgsix ram");
726 if (!all->par.fbc || !all->par.tec || !all->par.thc ||
727 !all->par.bt || !all->par.fhc || !all->info.screen_base) {
728 cg6_unmap_regs(op, all);
729 kfree(all);
730 return -ENOMEM;
731 }
732 718
733 all->info.par = &all->par; 719 info->screen_base = of_ioremap(&op->resource[0], CG6_RAM_OFFSET,
720 par->fbsize, "cgsix ram");
721 if (!par->fbc || !par->tec || !par->thc ||
722 !par->bt || !par->fhc || !info->screen_base)
723 goto out_unmap_regs;
734 724
735 all->info.var.accel_flags = FB_ACCELF_TEXT; 725 info->var.accel_flags = FB_ACCELF_TEXT;
736 726
737 cg6_bt_init(&all->par); 727 cg6_bt_init(par);
738 cg6_chip_init(&all->info); 728 cg6_chip_init(info);
739 cg6_blank(0, &all->info); 729 cg6_blank(0, info);
740 730
741 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 731 if (fb_alloc_cmap(&info->cmap, 256, 0))
742 cg6_unmap_regs(op, all); 732 goto out_unmap_regs;
743 kfree(all);
744 return -ENOMEM;
745 }
746 733
747 fb_set_cmap(&all->info.cmap, &all->info); 734 fb_set_cmap(&info->cmap, info);
748 cg6_init_fix(&all->info, linebytes); 735 cg6_init_fix(info, linebytes);
749 736
750 err = register_framebuffer(&all->info); 737 err = register_framebuffer(info);
751 if (err < 0) { 738 if (err < 0)
752 cg6_unmap_regs(op, all); 739 goto out_dealloc_cmap;
753 fb_dealloc_cmap(&all->info.cmap);
754 kfree(all);
755 return err;
756 }
757 740
758 dev_set_drvdata(&op->dev, all); 741 dev_set_drvdata(&op->dev, info);
759 742
760 printk("%s: CGsix [%s] at %lx:%lx\n", 743 printk("%s: CGsix [%s] at %lx:%lx\n",
761 dp->full_name, 744 dp->full_name, info->fix.id,
762 all->info.fix.id, 745 par->which_io, par->physbase);
763 all->par.which_io, all->par.physbase);
764 746
765 return 0; 747 return 0;
766}
767 748
768static int __devinit cg6_probe(struct of_device *dev, const struct of_device_id *match) 749out_dealloc_cmap:
769{ 750 fb_dealloc_cmap(&info->cmap);
770 struct of_device *op = to_of_device(&dev->dev); 751
752out_unmap_regs:
753 cg6_unmap_regs(op, info, par);
771 754
772 return cg6_init_one(op); 755out_err:
756 return err;
773} 757}
774 758
775static int __devexit cg6_remove(struct of_device *op) 759static int __devexit cg6_remove(struct of_device *op)
776{ 760{
777 struct all_info *all = dev_get_drvdata(&op->dev); 761 struct fb_info *info = dev_get_drvdata(&op->dev);
762 struct cg6_par *par = info->par;
778 763
779 unregister_framebuffer(&all->info); 764 unregister_framebuffer(info);
780 fb_dealloc_cmap(&all->info.cmap); 765 fb_dealloc_cmap(&info->cmap);
781 766
782 cg6_unmap_regs(op, all); 767 cg6_unmap_regs(op, info, par);
783 768
784 kfree(all); 769 framebuffer_release(info);
785 770
786 dev_set_drvdata(&op->dev, NULL); 771 dev_set_drvdata(&op->dev, NULL);
787 772
diff --git a/drivers/video/chipsfb.c b/drivers/video/chipsfb.c
index f48e8c534c87..6796ba62c3c6 100644
--- a/drivers/video/chipsfb.c
+++ b/drivers/video/chipsfb.c
@@ -24,6 +24,7 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/fb.h> 26#include <linux/fb.h>
27#include <linux/pm.h>
27#include <linux/init.h> 28#include <linux/init.h>
28#include <linux/pci.h> 29#include <linux/pci.h>
29#include <linux/console.h> 30#include <linux/console.h>
@@ -458,7 +459,7 @@ static int chipsfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
458 459
459 if (state.event == pdev->dev.power.power_state.event) 460 if (state.event == pdev->dev.power.power_state.event)
460 return 0; 461 return 0;
461 if (state.event != PM_SUSPEND_MEM) 462 if (state.event != PM_EVENT_SUSPEND)
462 goto done; 463 goto done;
463 464
464 acquire_console_sem(); 465 acquire_console_sem();
diff --git a/drivers/video/console/fonts.c b/drivers/video/console/fonts.c
index a6828d0a4c56..96979c377518 100644
--- a/drivers/video/console/fonts.c
+++ b/drivers/video/console/fonts.c
@@ -133,8 +133,8 @@ const struct font_desc *get_default_font(int xres, int yres, u32 font_w,
133 if ((yres < 400) == (f->height <= 8)) 133 if ((yres < 400) == (f->height <= 8))
134 c += 1000; 134 c += 1000;
135 135
136 if (!(font_w & (1 << (f->width - 1))) || 136 if ((font_w & (1 << (f->width - 1))) &&
137 !(font_w & (1 << (f->height - 1)))) 137 (font_h & (1 << (f->height - 1))))
138 c += 1000; 138 c += 1000;
139 139
140 if (c > cc) { 140 if (c > cc) {
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 215ac579f901..074027204702 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -244,8 +244,17 @@ static void fb_set_logo(struct fb_info *info,
244 u8 xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0; 244 u8 xor = (info->fix.visual == FB_VISUAL_MONO01) ? 0xff : 0;
245 u8 fg = 1, d; 245 u8 fg = 1, d;
246 246
247 if (fb_get_color_depth(&info->var, &info->fix) == 3) 247 switch (fb_get_color_depth(&info->var, &info->fix)) {
248 case 1:
249 fg = 1;
250 break;
251 case 2:
252 fg = 3;
253 break;
254 default:
248 fg = 7; 255 fg = 7;
256 break;
257 }
249 258
250 if (info->fix.visual == FB_VISUAL_MONO01 || 259 if (info->fix.visual == FB_VISUAL_MONO01 ||
251 info->fix.visual == FB_VISUAL_MONO10) 260 info->fix.visual == FB_VISUAL_MONO10)
@@ -564,21 +573,6 @@ int fb_prepare_logo(struct fb_info *info, int rotate)
564 depth = 4; 573 depth = 4;
565 } 574 }
566 575
567 if (depth >= 8) {
568 switch (info->fix.visual) {
569 case FB_VISUAL_TRUECOLOR:
570 fb_logo.needs_truepalette = 1;
571 break;
572 case FB_VISUAL_DIRECTCOLOR:
573 fb_logo.needs_directpalette = 1;
574 fb_logo.needs_cmapreset = 1;
575 break;
576 case FB_VISUAL_PSEUDOCOLOR:
577 fb_logo.needs_cmapreset = 1;
578 break;
579 }
580 }
581
582 /* Return if no suitable logo was found */ 576 /* Return if no suitable logo was found */
583 fb_logo.logo = fb_find_logo(depth); 577 fb_logo.logo = fb_find_logo(depth);
584 578
@@ -604,6 +598,22 @@ int fb_prepare_logo(struct fb_info *info, int rotate)
604 else 598 else
605 fb_logo.depth = 1; 599 fb_logo.depth = 1;
606 600
601
602 if (fb_logo.depth > 4 && depth > 4) {
603 switch (info->fix.visual) {
604 case FB_VISUAL_TRUECOLOR:
605 fb_logo.needs_truepalette = 1;
606 break;
607 case FB_VISUAL_DIRECTCOLOR:
608 fb_logo.needs_directpalette = 1;
609 fb_logo.needs_cmapreset = 1;
610 break;
611 case FB_VISUAL_PSEUDOCOLOR:
612 fb_logo.needs_cmapreset = 1;
613 break;
614 }
615 }
616
607 return fb_prepare_extra_logos(info, fb_logo.logo->height, yres); 617 return fb_prepare_extra_logos(info, fb_logo.logo->height, yres);
608} 618}
609 619
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index 3f6c98fad437..4b520b573911 100644
--- a/drivers/video/ffb.c
+++ b/drivers/video/ffb.c
@@ -371,6 +371,8 @@ struct ffb_par {
371 unsigned long fbsize; 371 unsigned long fbsize;
372 372
373 int board_type; 373 int board_type;
374
375 u32 pseudo_palette[16];
374}; 376};
375 377
376static void FFBFifo(struct ffb_par *par, int n) 378static void FFBFifo(struct ffb_par *par, int n)
@@ -900,75 +902,67 @@ ffb_init_fix(struct fb_info *info)
900 info->fix.accel = FB_ACCEL_SUN_CREATOR; 902 info->fix.accel = FB_ACCEL_SUN_CREATOR;
901} 903}
902 904
903struct all_info { 905static int __devinit ffb_probe(struct of_device *op, const struct of_device_id *match)
904 struct fb_info info;
905 struct ffb_par par;
906 u32 pseudo_palette[16];
907};
908
909static int ffb_init_one(struct of_device *op)
910{ 906{
911 struct device_node *dp = op->node; 907 struct device_node *dp = op->node;
912 struct ffb_fbc __iomem *fbc; 908 struct ffb_fbc __iomem *fbc;
913 struct ffb_dac __iomem *dac; 909 struct ffb_dac __iomem *dac;
914 struct all_info *all; 910 struct fb_info *info;
915 int err; 911 struct ffb_par *par;
916 u32 dac_pnum, dac_rev, dac_mrev; 912 u32 dac_pnum, dac_rev, dac_mrev;
913 int err;
917 914
918 all = kzalloc(sizeof(*all), GFP_KERNEL); 915 info = framebuffer_alloc(sizeof(struct ffb_par), &op->dev);
919 if (!all)
920 return -ENOMEM;
921 916
922 spin_lock_init(&all->par.lock); 917 err = -ENOMEM;
923 all->par.fbc = of_ioremap(&op->resource[2], 0, 918 if (!info)
924 sizeof(struct ffb_fbc), "ffb fbc"); 919 goto out_err;
925 if (!all->par.fbc) {
926 kfree(all);
927 return -ENOMEM;
928 }
929 920
930 all->par.dac = of_ioremap(&op->resource[1], 0, 921 par = info->par;
931 sizeof(struct ffb_dac), "ffb dac"); 922
932 if (!all->par.dac) { 923 spin_lock_init(&par->lock);
933 of_iounmap(&op->resource[2], 924 par->fbc = of_ioremap(&op->resource[2], 0,
934 all->par.fbc, sizeof(struct ffb_fbc)); 925 sizeof(struct ffb_fbc), "ffb fbc");
935 kfree(all); 926 if (!par->fbc)
936 return -ENOMEM; 927 goto out_release_fb;
937 } 928
929 par->dac = of_ioremap(&op->resource[1], 0,
930 sizeof(struct ffb_dac), "ffb dac");
931 if (!par->dac)
932 goto out_unmap_fbc;
938 933
939 all->par.rop_cache = FFB_ROP_NEW; 934 par->rop_cache = FFB_ROP_NEW;
940 all->par.physbase = op->resource[0].start; 935 par->physbase = op->resource[0].start;
941 936
942 /* Don't mention copyarea, so SCROLL_REDRAW is always 937 /* Don't mention copyarea, so SCROLL_REDRAW is always
943 * used. It is the fastest on this chip. 938 * used. It is the fastest on this chip.
944 */ 939 */
945 all->info.flags = (FBINFO_DEFAULT | 940 info->flags = (FBINFO_DEFAULT |
946 /* FBINFO_HWACCEL_COPYAREA | */ 941 /* FBINFO_HWACCEL_COPYAREA | */
947 FBINFO_HWACCEL_FILLRECT | 942 FBINFO_HWACCEL_FILLRECT |
948 FBINFO_HWACCEL_IMAGEBLIT); 943 FBINFO_HWACCEL_IMAGEBLIT);
949 all->info.fbops = &ffb_ops; 944
950 all->info.screen_base = (char *) all->par.physbase + FFB_DFB24_POFF; 945 info->fbops = &ffb_ops;
951 all->info.par = &all->par; 946
952 all->info.pseudo_palette = all->pseudo_palette; 947 info->screen_base = (char *) par->physbase + FFB_DFB24_POFF;
953 948 info->pseudo_palette = par->pseudo_palette;
954 sbusfb_fill_var(&all->info.var, dp->node, 32); 949
955 all->par.fbsize = PAGE_ALIGN(all->info.var.xres * 950 sbusfb_fill_var(&info->var, dp->node, 32);
956 all->info.var.yres * 951 par->fbsize = PAGE_ALIGN(info->var.xres * info->var.yres * 4);
957 4); 952 ffb_fixup_var_rgb(&info->var);
958 ffb_fixup_var_rgb(&all->info.var); 953
959 954 info->var.accel_flags = FB_ACCELF_TEXT;
960 all->info.var.accel_flags = FB_ACCELF_TEXT;
961 955
962 if (!strcmp(dp->name, "SUNW,afb")) 956 if (!strcmp(dp->name, "SUNW,afb"))
963 all->par.flags |= FFB_FLAG_AFB; 957 par->flags |= FFB_FLAG_AFB;
964 958
965 all->par.board_type = of_getintprop_default(dp, "board_type", 0); 959 par->board_type = of_getintprop_default(dp, "board_type", 0);
966 960
967 fbc = all->par.fbc; 961 fbc = par->fbc;
968 if ((upa_readl(&fbc->ucsr) & FFB_UCSR_ALL_ERRORS) != 0) 962 if ((upa_readl(&fbc->ucsr) & FFB_UCSR_ALL_ERRORS) != 0)
969 upa_writel(FFB_UCSR_ALL_ERRORS, &fbc->ucsr); 963 upa_writel(FFB_UCSR_ALL_ERRORS, &fbc->ucsr);
970 964
971 dac = all->par.dac; 965 dac = par->dac;
972 upa_writel(FFB_DAC_DID, &dac->type); 966 upa_writel(FFB_DAC_DID, &dac->type);
973 dac_pnum = upa_readl(&dac->value); 967 dac_pnum = upa_readl(&dac->value);
974 dac_rev = (dac_pnum & FFB_DAC_DID_REV) >> FFB_DAC_DID_REV_SHIFT; 968 dac_rev = (dac_pnum & FFB_DAC_DID_REV) >> FFB_DAC_DID_REV_SHIFT;
@@ -985,76 +979,70 @@ static int ffb_init_one(struct of_device *op)
985 * cursor logic. We identify Pacifica 1 as not Pacifica 2, the 979 * cursor logic. We identify Pacifica 1 as not Pacifica 2, the
986 * latter having a part number value of 0x236e. 980 * latter having a part number value of 0x236e.
987 */ 981 */
988 if ((all->par.flags & FFB_FLAG_AFB) || dac_pnum == 0x236e) { 982 if ((par->flags & FFB_FLAG_AFB) || dac_pnum == 0x236e) {
989 all->par.flags &= ~FFB_FLAG_INVCURSOR; 983 par->flags &= ~FFB_FLAG_INVCURSOR;
990 } else { 984 } else {
991 if (dac_mrev < 3) 985 if (dac_mrev < 3)
992 all->par.flags |= FFB_FLAG_INVCURSOR; 986 par->flags |= FFB_FLAG_INVCURSOR;
993 } 987 }
994 988
995 ffb_switch_from_graph(&all->par); 989 ffb_switch_from_graph(par);
996 990
997 /* Unblank it just to be sure. When there are multiple 991 /* Unblank it just to be sure. When there are multiple
998 * FFB/AFB cards in the system, or it is not the OBP 992 * FFB/AFB cards in the system, or it is not the OBP
999 * chosen console, it will have video outputs off in 993 * chosen console, it will have video outputs off in
1000 * the DAC. 994 * the DAC.
1001 */ 995 */
1002 ffb_blank(0, &all->info); 996 ffb_blank(0, info);
1003
1004 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
1005 printk(KERN_ERR "ffb: Could not allocate color map.\n");
1006 of_iounmap(&op->resource[2],
1007 all->par.fbc, sizeof(struct ffb_fbc));
1008 of_iounmap(&op->resource[1],
1009 all->par.dac, sizeof(struct ffb_dac));
1010 kfree(all);
1011 return -ENOMEM;
1012 }
1013 997
1014 ffb_init_fix(&all->info); 998 if (fb_alloc_cmap(&info->cmap, 256, 0))
1015 999 goto out_unmap_dac;
1016 err = register_framebuffer(&all->info); 1000
1017 if (err < 0) { 1001 ffb_init_fix(info);
1018 printk(KERN_ERR "ffb: Could not register framebuffer.\n");
1019 fb_dealloc_cmap(&all->info.cmap);
1020 of_iounmap(&op->resource[2],
1021 all->par.fbc, sizeof(struct ffb_fbc));
1022 of_iounmap(&op->resource[1],
1023 all->par.dac, sizeof(struct ffb_dac));
1024 kfree(all);
1025 return err;
1026 }
1027 1002
1028 dev_set_drvdata(&op->dev, all); 1003 err = register_framebuffer(info);
1004 if (err < 0)
1005 goto out_dealloc_cmap;
1006
1007 dev_set_drvdata(&op->dev, info);
1029 1008
1030 printk("%s: %s at %016lx, type %d, " 1009 printk("%s: %s at %016lx, type %d, "
1031 "DAC pnum[%x] rev[%d] manuf_rev[%d]\n", 1010 "DAC pnum[%x] rev[%d] manuf_rev[%d]\n",
1032 dp->full_name, 1011 dp->full_name,
1033 ((all->par.flags & FFB_FLAG_AFB) ? "AFB" : "FFB"), 1012 ((par->flags & FFB_FLAG_AFB) ? "AFB" : "FFB"),
1034 all->par.physbase, all->par.board_type, 1013 par->physbase, par->board_type,
1035 dac_pnum, dac_rev, dac_mrev); 1014 dac_pnum, dac_rev, dac_mrev);
1036 1015
1037 return 0; 1016 return 0;
1038}
1039 1017
1040static int __devinit ffb_probe(struct of_device *dev, const struct of_device_id *match) 1018out_dealloc_cmap:
1041{ 1019 fb_dealloc_cmap(&info->cmap);
1042 struct of_device *op = to_of_device(&dev->dev); 1020
1021out_unmap_dac:
1022 of_iounmap(&op->resource[2], par->fbc, sizeof(struct ffb_fbc));
1023
1024out_unmap_fbc:
1025 of_iounmap(&op->resource[2], par->fbc, sizeof(struct ffb_fbc));
1026
1027out_release_fb:
1028 framebuffer_release(info);
1043 1029
1044 return ffb_init_one(op); 1030out_err:
1031 return err;
1045} 1032}
1046 1033
1047static int __devexit ffb_remove(struct of_device *op) 1034static int __devexit ffb_remove(struct of_device *op)
1048{ 1035{
1049 struct all_info *all = dev_get_drvdata(&op->dev); 1036 struct fb_info *info = dev_get_drvdata(&op->dev);
1037 struct ffb_par *par = info->par;
1050 1038
1051 unregister_framebuffer(&all->info); 1039 unregister_framebuffer(info);
1052 fb_dealloc_cmap(&all->info.cmap); 1040 fb_dealloc_cmap(&info->cmap);
1053 1041
1054 of_iounmap(&op->resource[2], all->par.fbc, sizeof(struct ffb_fbc)); 1042 of_iounmap(&op->resource[2], par->fbc, sizeof(struct ffb_fbc));
1055 of_iounmap(&op->resource[1], all->par.dac, sizeof(struct ffb_dac)); 1043 of_iounmap(&op->resource[1], par->dac, sizeof(struct ffb_dac));
1056 1044
1057 kfree(all); 1045 framebuffer_release(info);
1058 1046
1059 dev_set_drvdata(&op->dev, NULL); 1047 dev_set_drvdata(&op->dev, NULL);
1060 1048
diff --git a/drivers/video/geode/Kconfig b/drivers/video/geode/Kconfig
index a814b6c2605c..7608429b3943 100644
--- a/drivers/video/geode/Kconfig
+++ b/drivers/video/geode/Kconfig
@@ -8,6 +8,21 @@ config FB_GEODE
8 Say 'Y' here to allow you to select framebuffer drivers for 8 Say 'Y' here to allow you to select framebuffer drivers for
9 the AMD Geode family of processors. 9 the AMD Geode family of processors.
10 10
11config FB_GEODE_LX
12 tristate "AMD Geode LX framebuffer support (EXPERIMENTAL)"
13 depends on FB && FB_GEODE
14 select FB_CFB_FILLRECT
15 select FB_CFB_COPYAREA
16 select FB_CFB_IMAGEBLIT
17 ---help---
18 Framebuffer driver for the display controller integrated into the
19 AMD Geode LX processors.
20
21 To compile this driver as a module, choose M here: the module will
22 be called lxfb.
23
24 If unsure, say N.
25
11config FB_GEODE_GX 26config FB_GEODE_GX
12 tristate "AMD Geode GX framebuffer support (EXPERIMENTAL)" 27 tristate "AMD Geode GX framebuffer support (EXPERIMENTAL)"
13 depends on FB && FB_GEODE && EXPERIMENTAL 28 depends on FB && FB_GEODE && EXPERIMENTAL
diff --git a/drivers/video/geode/Makefile b/drivers/video/geode/Makefile
index f896565bc312..957304b45fba 100644
--- a/drivers/video/geode/Makefile
+++ b/drivers/video/geode/Makefile
@@ -2,6 +2,8 @@
2 2
3obj-$(CONFIG_FB_GEODE_GX1) += gx1fb.o 3obj-$(CONFIG_FB_GEODE_GX1) += gx1fb.o
4obj-$(CONFIG_FB_GEODE_GX) += gxfb.o 4obj-$(CONFIG_FB_GEODE_GX) += gxfb.o
5obj-$(CONFIG_FB_GEODE_LX) += lxfb.o
5 6
6gx1fb-objs := gx1fb_core.o display_gx1.o video_cs5530.o 7gx1fb-objs := gx1fb_core.o display_gx1.o video_cs5530.o
7gxfb-objs := gxfb_core.o display_gx.o video_gx.o 8gxfb-objs := gxfb_core.o display_gx.o video_gx.o
9lxfb-objs := lxfb_core.o lxfb_ops.o
diff --git a/drivers/video/geode/lxfb.h b/drivers/video/geode/lxfb.h
new file mode 100644
index 000000000000..6c227f9592a5
--- /dev/null
+++ b/drivers/video/geode/lxfb.h
@@ -0,0 +1,199 @@
1#ifndef _LXFB_H_
2#define _LXFB_H_
3
4#include <linux/fb.h>
5
6#define OUTPUT_CRT 0x01
7#define OUTPUT_PANEL 0x02
8
9struct lxfb_par {
10 int output;
11 int panel_width;
12 int panel_height;
13
14 void __iomem *gp_regs;
15 void __iomem *dc_regs;
16 void __iomem *df_regs;
17};
18
19static inline unsigned int lx_get_pitch(unsigned int xres, int bpp)
20{
21 return (((xres * (bpp >> 3)) + 7) & ~7);
22}
23
24void lx_set_mode(struct fb_info *);
25void lx_get_gamma(struct fb_info *, unsigned int *, int);
26void lx_set_gamma(struct fb_info *, unsigned int *, int);
27unsigned int lx_framebuffer_size(void);
28int lx_blank_display(struct fb_info *, int);
29void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int,
30 unsigned int, unsigned int);
31
32/* MSRS */
33
34#define MSR_LX_GLD_CONFIG 0x48002001
35#define MSR_LX_GLCP_DOTPLL 0x4c000015
36#define MSR_LX_DF_PADSEL 0x48000011
37#define MSR_LX_DC_SPARE 0x80000011
38#define MSR_LX_DF_GLCONFIG 0x48002001
39
40#define MSR_LX_GLIU0_P2D_RO0 0x10000029
41
42#define GLCP_DOTPLL_RESET (1 << 0)
43#define GLCP_DOTPLL_BYPASS (1 << 15)
44#define GLCP_DOTPLL_HALFPIX (1 << 24)
45#define GLCP_DOTPLL_LOCK (1 << 25)
46
47#define DF_CONFIG_OUTPUT_MASK 0x38
48#define DF_OUTPUT_PANEL 0x08
49#define DF_OUTPUT_CRT 0x00
50#define DF_SIMULTANEOUS_CRT_AND_FP (1 << 15)
51
52#define DF_DEFAULT_TFT_PAD_SEL_LOW 0xDFFFFFFF
53#define DF_DEFAULT_TFT_PAD_SEL_HIGH 0x0000003F
54
55#define DC_SPARE_DISABLE_CFIFO_HGO 0x00000800
56#define DC_SPARE_VFIFO_ARB_SELECT 0x00000400
57#define DC_SPARE_WM_LPEN_OVRD 0x00000200
58#define DC_SPARE_LOAD_WM_LPEN_MASK 0x00000100
59#define DC_SPARE_DISABLE_INIT_VID_PRI 0x00000080
60#define DC_SPARE_DISABLE_VFIFO_WM 0x00000040
61#define DC_SPARE_DISABLE_CWD_CHECK 0x00000020
62#define DC_SPARE_PIX8_PAN_FIX 0x00000010
63#define DC_SPARE_FIRST_REQ_MASK 0x00000002
64
65/* Registers */
66
67#define DC_UNLOCK 0x00
68#define DC_UNLOCK_CODE 0x4758
69
70#define DC_GENERAL_CFG 0x04
71#define DC_GCFG_DFLE (1 << 0)
72#define DC_GCFG_VIDE (1 << 3)
73#define DC_GCFG_VGAE (1 << 7)
74#define DC_GCFG_CMPE (1 << 5)
75#define DC_GCFG_DECE (1 << 6)
76#define DC_GCFG_FDTY (1 << 17)
77
78#define DC_DISPLAY_CFG 0x08
79#define DC_DCFG_TGEN (1 << 0)
80#define DC_DCFG_GDEN (1 << 3)
81#define DC_DCFG_VDEN (1 << 4)
82#define DC_DCFG_TRUP (1 << 6)
83#define DC_DCFG_DCEN (1 << 24)
84#define DC_DCFG_PALB (1 << 25)
85#define DC_DCFG_VISL (1 << 27)
86
87#define DC_DCFG_16BPP 0x0
88
89#define DC_DCFG_DISP_MODE_MASK 0x00000300
90#define DC_DCFG_DISP_MODE_8BPP 0x00000000
91#define DC_DCFG_DISP_MODE_16BPP 0x00000100
92#define DC_DCFG_DISP_MODE_24BPP 0x00000200
93#define DC_DCFG_DISP_MODE_32BPP 0x00000300
94
95
96#define DC_ARB_CFG 0x0C
97
98#define DC_FB_START 0x10
99#define DC_CB_START 0x14
100#define DC_CURSOR_START 0x18
101
102#define DC_DV_TOP 0x2C
103#define DC_DV_TOP_ENABLE (1 << 0)
104
105#define DC_LINE_SIZE 0x30
106#define DC_GRAPHICS_PITCH 0x34
107#define DC_H_ACTIVE_TIMING 0x40
108#define DC_H_BLANK_TIMING 0x44
109#define DC_H_SYNC_TIMING 0x48
110#define DC_V_ACTIVE_TIMING 0x50
111#define DC_V_BLANK_TIMING 0x54
112#define DC_V_SYNC_TIMING 0x58
113#define DC_FB_ACTIVE 0x5C
114
115#define DC_PAL_ADDRESS 0x70
116#define DC_PAL_DATA 0x74
117
118#define DC_PHY_MEM_OFFSET 0x84
119
120#define DC_DV_CTL 0x88
121#define DC_DV_LINE_SIZE_MASK 0x00000C00
122#define DC_DV_LINE_SIZE_1024 0x00000000
123#define DC_DV_LINE_SIZE_2048 0x00000400
124#define DC_DV_LINE_SIZE_4096 0x00000800
125#define DC_DV_LINE_SIZE_8192 0x00000C00
126
127
128#define DC_GFX_SCALE 0x90
129#define DC_IRQ_FILT_CTL 0x94
130
131
132#define DC_IRQ 0xC8
133#define DC_IRQ_MASK (1 << 0)
134#define DC_VSYNC_IRQ_MASK (1 << 1)
135#define DC_IRQ_STATUS (1 << 20)
136#define DC_VSYNC_IRQ_STATUS (1 << 21)
137
138#define DC_GENLCK_CTRL 0xD4
139#define DC_GENLCK_ENABLE (1 << 18)
140#define DC_GC_ALPHA_FLICK_ENABLE (1 << 25)
141#define DC_GC_FLICKER_FILTER_ENABLE (1 << 24)
142#define DC_GC_FLICKER_FILTER_MASK (0x0F << 28)
143
144#define DC_COLOR_KEY 0xB8
145#define DC_CLR_KEY_ENABLE (1 << 24)
146
147
148#define DC3_DV_LINE_SIZE_MASK 0x00000C00
149#define DC3_DV_LINE_SIZE_1024 0x00000000
150#define DC3_DV_LINE_SIZE_2048 0x00000400
151#define DC3_DV_LINE_SIZE_4096 0x00000800
152#define DC3_DV_LINE_SIZE_8192 0x00000C00
153
154#define DF_VIDEO_CFG 0x0
155#define DF_VCFG_VID_EN (1 << 0)
156
157#define DF_DISPLAY_CFG 0x08
158
159#define DF_DCFG_CRT_EN (1 << 0)
160#define DF_DCFG_HSYNC_EN (1 << 1)
161#define DF_DCFG_VSYNC_EN (1 << 2)
162#define DF_DCFG_DAC_BL_EN (1 << 3)
163#define DF_DCFG_CRT_HSYNC_POL (1 << 8)
164#define DF_DCFG_CRT_VSYNC_POL (1 << 9)
165#define DF_DCFG_GV_PAL_BYP (1 << 21)
166
167#define DF_DCFG_CRT_SYNC_SKW_INIT 0x10000
168#define DF_DCFG_CRT_SYNC_SKW_MASK 0x1c000
169
170#define DF_DCFG_PWR_SEQ_DLY_INIT 0x80000
171#define DF_DCFG_PWR_SEQ_DLY_MASK 0xe0000
172
173#define DF_MISC 0x50
174
175#define DF_MISC_GAM_BYPASS (1 << 0)
176#define DF_MISC_DAC_PWRDN (1 << 10)
177#define DF_MISC_A_PWRDN (1 << 11)
178
179#define DF_PAR 0x38
180#define DF_PDR 0x40
181#define DF_ALPHA_CONTROL_1 0xD8
182#define DF_VIDEO_REQUEST 0x120
183
184#define DF_PANEL_TIM1 0x400
185#define DF_DEFAULT_TFT_PMTIM1 0x0
186
187#define DF_PANEL_TIM2 0x408
188#define DF_DEFAULT_TFT_PMTIM2 0x08000000
189
190#define DF_FP_PM 0x410
191#define DF_FP_PM_P (1 << 24)
192
193#define DF_DITHER_CONTROL 0x418
194#define DF_DEFAULT_TFT_DITHCTL 0x00000070
195#define GP_BLT_STATUS 0x44
196#define GP_BS_BLT_BUSY (1 << 0)
197#define GP_BS_CB_EMPTY (1 << 4)
198
199#endif
diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
new file mode 100644
index 000000000000..5e30b40c8c0f
--- /dev/null
+++ b/drivers/video/geode/lxfb_core.c
@@ -0,0 +1,621 @@
1/*
2 * Geode LX framebuffer driver.
3 *
4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
5 * Built from gxfb (which is Copyright (C) 2006 Arcom Control Systems Ltd.)
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/errno.h>
16#include <linux/string.h>
17#include <linux/console.h>
18#include <linux/mm.h>
19#include <linux/slab.h>
20#include <linux/delay.h>
21#include <linux/fb.h>
22#include <linux/init.h>
23#include <linux/pci.h>
24#include <linux/uaccess.h>
25
26#include "lxfb.h"
27
28static char *mode_option;
29static int noclear, nopanel, nocrt;
30static int fbsize;
31
32/* Most of these modes are sorted in ascending order, but
33 * since the first entry in this table is the "default" mode,
34 * we try to make it something sane - 640x480-60 is sane
35 */
36
37const struct fb_videomode geode_modedb[] __initdata = {
38 /* 640x480-60 */
39 { NULL, 60, 640, 480, 39682, 48, 8, 25, 2, 88, 2,
40 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
41 FB_VMODE_NONINTERLACED, 0 },
42 /* 640x400-70 */
43 { NULL, 70, 640, 400, 39770, 40, 8, 28, 5, 96, 2,
44 FB_SYNC_HOR_HIGH_ACT,
45 FB_VMODE_NONINTERLACED, 0 },
46 /* 640x480-70 */
47 { NULL, 70, 640, 480, 35014, 88, 24, 15, 2, 64, 3,
48 0, FB_VMODE_NONINTERLACED, 0 },
49 /* 640x480-72 */
50 { NULL, 72, 640, 480, 32102, 120, 16, 20, 1, 40, 3,
51 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
52 FB_VMODE_NONINTERLACED, 0 },
53 /* 640x480-75 */
54 { NULL, 75, 640, 480, 31746, 120, 16, 16, 1, 64, 3,
55 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
56 FB_VMODE_NONINTERLACED, 0 },
57 /* 640x480-85 */
58 { NULL, 85, 640, 480, 27780, 80, 56, 25, 1, 56, 3,
59 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
60 FB_VMODE_NONINTERLACED, 0 },
61 /* 640x480-90 */
62 { NULL, 90, 640, 480, 26392, 96, 32, 22, 1, 64, 3,
63 0, FB_VMODE_NONINTERLACED, 0 },
64 /* 640x480-100 */
65 { NULL, 100, 640, 480, 23167, 104, 40, 25, 1, 64, 3,
66 0, FB_VMODE_NONINTERLACED, 0 },
67 /* 640x480-60 */
68 { NULL, 60, 640, 480, 39682, 48, 16, 25, 10, 88, 2,
69 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
70 FB_VMODE_NONINTERLACED, 0 },
71 /* 800x600-56 */
72 { NULL, 56, 800, 600, 27901, 128, 24, 22, 1, 72, 2,
73 0, FB_VMODE_NONINTERLACED, 0 },
74 /* 800x600-60 */
75 { NULL, 60, 800, 600, 25131, 72, 32, 23, 1, 136, 4,
76 0, FB_VMODE_NONINTERLACED, 0 },
77 /* 800x600-70 */
78 { NULL, 70, 800, 600, 21873, 120, 40, 21, 4, 80, 3,
79 0, FB_VMODE_NONINTERLACED, 0 },
80 /* 800x600-72 */
81 { NULL, 72, 800, 600, 20052, 64, 56, 23, 37, 120, 6,
82 0, FB_VMODE_NONINTERLACED, 0 },
83 /* 800x600-75 */
84 { NULL, 75, 800, 600, 20202, 160, 16, 21, 1, 80, 3,
85 0, FB_VMODE_NONINTERLACED, 0 },
86 /* 800x600-85 */
87 { NULL, 85, 800, 600, 17790, 152, 32, 27, 1, 64, 3,
88 0, FB_VMODE_NONINTERLACED, 0 },
89 /* 800x600-90 */
90 { NULL, 90, 800, 600, 16648, 128, 40, 28, 1, 88, 3,
91 0, FB_VMODE_NONINTERLACED, 0 },
92 /* 800x600-100 */
93 { NULL, 100, 800, 600, 14667, 136, 48, 27, 1, 88, 3,
94 0, FB_VMODE_NONINTERLACED, 0 },
95 /* 800x600-60 */
96 { NULL, 60, 800, 600, 25131, 88, 40, 23, 1, 128, 4,
97 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
98 FB_VMODE_NONINTERLACED, 0 },
99 /* 1024x768-60 */
100 { NULL, 60, 1024, 768, 15385, 160, 24, 29, 3, 136, 6,
101 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
102 FB_VMODE_NONINTERLACED, 0 },
103 /* 1024x768-70 */
104 { NULL, 70, 1024, 768, 13346, 144, 24, 29, 3, 136, 6,
105 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
106 FB_VMODE_NONINTERLACED, 0 },
107 /* 1024x768-72 */
108 { NULL, 72, 1024, 768, 12702, 168, 56, 29, 4, 112, 3,
109 0, FB_VMODE_NONINTERLACED, 0 },
110 /* 1024x768-75 */
111 { NULL, 75, 1024, 768, 12703, 176, 16, 28, 1, 96, 3,
112 0, FB_VMODE_NONINTERLACED, 0 },
113 /* 1024x768-85 */
114 { NULL, 85, 1024, 768, 10581, 208, 48, 36, 1, 96, 3,
115 0, FB_VMODE_NONINTERLACED, 0 },
116 /* 1024x768-90 */
117 { NULL, 90, 1024, 768, 9981, 176, 64, 37, 1, 112, 3,
118 0, FB_VMODE_NONINTERLACED, 0 },
119 /* 1024x768-100 */
120 { NULL, 100, 1024, 768, 8825, 184, 72, 42, 1, 112, 3,
121 0, FB_VMODE_NONINTERLACED, 0 },
122 /* 1024x768-60 */
123 { NULL, 60, 1024, 768, 15385, 160, 24, 29, 3, 136, 6,
124 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
125 FB_VMODE_NONINTERLACED, 0 },
126 /* 1152x864-60 */
127 { NULL, 60, 1152, 864, 12251, 184, 64, 27, 1, 120, 3,
128 0, FB_VMODE_NONINTERLACED, 0 },
129 /* 1152x864-70 */
130 { NULL, 70, 1152, 864, 10254, 192, 72, 32, 8, 120, 3,
131 0, FB_VMODE_NONINTERLACED, 0 },
132 /* 1152x864-72 */
133 { NULL, 72, 1152, 864, 9866, 200, 72, 33, 7, 128, 3,
134 0, FB_VMODE_NONINTERLACED, 0 },
135 /* 1152x864-75 */
136 { NULL, 75, 1152, 864, 9259, 256, 64, 32, 1, 128, 3,
137 0, FB_VMODE_NONINTERLACED, 0 },
138 /* 1152x864-85 */
139 { NULL, 85, 1152, 864, 8357, 200, 72, 37, 3, 128, 3,
140 0, FB_VMODE_NONINTERLACED, 0 },
141 /* 1152x864-90 */
142 { NULL, 90, 1152, 864, 7719, 208, 80, 42, 9, 128, 3,
143 0, FB_VMODE_NONINTERLACED, 0 },
144 /* 1152x864-100 */
145 { NULL, 100, 1152, 864, 6947, 208, 80, 48, 3, 128, 3,
146 0, FB_VMODE_NONINTERLACED, 0 },
147 /* 1152x864-60 */
148 { NULL, 60, 1152, 864, 12251, 184, 64, 27, 1, 120, 3,
149 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
150 FB_VMODE_NONINTERLACED, 0 },
151 /* 1280x1024-60 */
152 { NULL, 60, 1280, 1024, 9262, 248, 48, 38, 1, 112, 3,
153 0, FB_VMODE_NONINTERLACED, 0 },
154 /* 1280x1024-70 */
155 { NULL, 70, 1280, 1024, 7719, 224, 88, 38, 6, 136, 3,
156 0, FB_VMODE_NONINTERLACED, 0 },
157 /* 1280x1024-72 */
158 { NULL, 72, 1280, 1024, 7490, 224, 88, 39, 7, 136, 3,
159 0, FB_VMODE_NONINTERLACED, 0 },
160 /* 1280x1024-75 */
161 { NULL, 75, 1280, 1024, 7409, 248, 16, 38, 1, 144, 3,
162 0, FB_VMODE_NONINTERLACED, 0 },
163 /* 1280x1024-85 */
164 { NULL, 85, 1280, 1024, 6351, 224, 64, 44, 1, 160, 3,
165 0, FB_VMODE_NONINTERLACED, 0 },
166 /* 1280x1024-90 */
167 { NULL, 90, 1280, 1024, 5791, 240, 96, 51, 12, 144, 3,
168 0, FB_VMODE_NONINTERLACED, 0 },
169 /* 1280x1024-100 */
170 { NULL, 100, 1280, 1024, 5212, 240, 96, 57, 6, 144, 3,
171 0, FB_VMODE_NONINTERLACED, 0 },
172 /* 1280x1024-60 */
173 { NULL, 60, 1280, 1024, 9262, 248, 48, 38, 1, 112, 3,
174 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
175 FB_VMODE_NONINTERLACED, 0 },
176 /* 1600x1200-60 */
177 { NULL, 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3,
178 0, FB_VMODE_NONINTERLACED, 0 },
179 /* 1600x1200-70 */
180 { NULL, 70, 1600, 1200, 5291, 304, 64, 46, 1, 192, 3,
181 0, FB_VMODE_NONINTERLACED, 0 },
182 /* 1600x1200-72 */
183 { NULL, 72, 1600, 1200, 5053, 288, 112, 47, 13, 176, 3,
184 0, FB_VMODE_NONINTERLACED, 0 },
185 /* 1600x1200-75 */
186 { NULL, 75, 1600, 1200, 4938, 304, 64, 46, 1, 192, 3,
187 0, FB_VMODE_NONINTERLACED, 0 },
188 /* 1600x1200-85 */
189 { NULL, 85, 1600, 1200, 4357, 304, 64, 46, 1, 192, 3,
190 0, FB_VMODE_NONINTERLACED, 0 },
191 /* 1600x1200-90 */
192 { NULL, 90, 1600, 1200, 3981, 304, 128, 60, 1, 176, 3,
193 0, FB_VMODE_NONINTERLACED, 0 },
194 /* 1600x1200-100 */
195 { NULL, 100, 1600, 1200, 3563, 304, 128, 67, 1, 176, 3,
196 0, FB_VMODE_NONINTERLACED, 0 },
197 /* 1600x1200-60 */
198 { NULL, 60, 1600, 1200, 6172, 304, 64, 46, 1, 192, 3,
199 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
200 FB_VMODE_NONINTERLACED, 0 },
201 /* 1920x1440-60 */
202 { NULL, 60, 1920, 1440, 4273, 344, 128, 56, 1, 208, 3,
203 0, FB_VMODE_NONINTERLACED, 0 },
204 /* 1920x1440-70 */
205 { NULL, 70, 1920, 1440, 3593, 360, 152, 55, 8, 208, 3,
206 0, FB_VMODE_NONINTERLACED, 0 },
207 /* 1920x1440-72 */
208 { NULL, 72, 1920, 1440, 3472, 360, 152, 68, 4, 208, 3,
209 0, FB_VMODE_NONINTERLACED, 0 },
210 /* 1920x1440-75 */
211 { NULL, 75, 1920, 1440, 3367, 352, 144, 56, 1, 224, 3,
212 0, FB_VMODE_NONINTERLACED, 0 },
213 /* 1920x1440-85 */
214 { NULL, 85, 1920, 1440, 2929, 368, 152, 68, 1, 216, 3,
215 0, FB_VMODE_NONINTERLACED, 0 },
216};
217
218static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
219{
220 if (var->xres > 1920 || var->yres > 1440)
221 return -EINVAL;
222
223 if (var->bits_per_pixel == 32) {
224 var->red.offset = 16; var->red.length = 8;
225 var->green.offset = 8; var->green.length = 8;
226 var->blue.offset = 0; var->blue.length = 8;
227 } else if (var->bits_per_pixel == 16) {
228 var->red.offset = 11; var->red.length = 5;
229 var->green.offset = 5; var->green.length = 6;
230 var->blue.offset = 0; var->blue.length = 5;
231 } else if (var->bits_per_pixel == 8) {
232 var->red.offset = 0; var->red.length = 8;
233 var->green.offset = 0; var->green.length = 8;
234 var->blue.offset = 0; var->blue.length = 8;
235 } else
236 return -EINVAL;
237
238 var->transp.offset = 0; var->transp.length = 0;
239
240 /* Enough video memory? */
241 if ((lx_get_pitch(var->xres, var->bits_per_pixel) * var->yres)
242 > info->fix.smem_len)
243 return -EINVAL;
244
245 return 0;
246}
247
248static int lxfb_set_par(struct fb_info *info)
249{
250 if (info->var.bits_per_pixel > 8) {
251 info->fix.visual = FB_VISUAL_TRUECOLOR;
252 fb_dealloc_cmap(&info->cmap);
253 } else {
254 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
255 fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
256 }
257
258 info->fix.line_length = lx_get_pitch(info->var.xres,
259 info->var.bits_per_pixel);
260
261 lx_set_mode(info);
262 return 0;
263}
264
265static inline u_int chan_to_field(u_int chan, struct fb_bitfield *bf)
266{
267 chan &= 0xffff;
268 chan >>= 16 - bf->length;
269 return chan << bf->offset;
270}
271
272static int lxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
273 unsigned blue, unsigned transp,
274 struct fb_info *info)
275{
276 if (info->var.grayscale) {
277 /* grayscale = 0.30*R + 0.59*G + 0.11*B */
278 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
279 }
280
281 /* Truecolor has hardware independent palette */
282 if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
283 u32 *pal = info->pseudo_palette;
284 u32 v;
285
286 if (regno >= 16)
287 return -EINVAL;
288
289 v = chan_to_field(red, &info->var.red);
290 v |= chan_to_field(green, &info->var.green);
291 v |= chan_to_field(blue, &info->var.blue);
292
293 pal[regno] = v;
294 } else {
295 if (regno >= 256)
296 return -EINVAL;
297
298 lx_set_palette_reg(info, regno, red, green, blue);
299 }
300
301 return 0;
302}
303
304static int lxfb_blank(int blank_mode, struct fb_info *info)
305{
306 return lx_blank_display(info, blank_mode);
307}
308
309
310static int __init lxfb_map_video_memory(struct fb_info *info,
311 struct pci_dev *dev)
312{
313 struct lxfb_par *par = info->par;
314 int ret;
315
316 ret = pci_enable_device(dev);
317
318 if (ret)
319 return ret;
320
321 ret = pci_request_region(dev, 0, "lxfb-framebuffer");
322
323 if (ret)
324 return ret;
325
326 ret = pci_request_region(dev, 1, "lxfb-gp");
327
328 if (ret)
329 return ret;
330
331 ret = pci_request_region(dev, 2, "lxfb-vg");
332
333 if (ret)
334 return ret;
335
336 ret = pci_request_region(dev, 3, "lxfb-vip");
337
338 if (ret)
339 return ret;
340
341 info->fix.smem_start = pci_resource_start(dev, 0);
342 info->fix.smem_len = fbsize ? fbsize : lx_framebuffer_size();
343
344 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
345
346 ret = -ENOMEM;
347
348 if (info->screen_base == NULL)
349 return ret;
350
351 par->gp_regs = ioremap(pci_resource_start(dev, 1),
352 pci_resource_len(dev, 1));
353
354 if (par->gp_regs == NULL)
355 return ret;
356
357 par->dc_regs = ioremap(pci_resource_start(dev, 2),
358 pci_resource_len(dev, 2));
359
360 if (par->dc_regs == NULL)
361 return ret;
362
363 par->df_regs = ioremap(pci_resource_start(dev, 3),
364 pci_resource_len(dev, 3));
365
366 if (par->df_regs == NULL)
367 return ret;
368
369 writel(DC_UNLOCK_CODE, par->dc_regs + DC_UNLOCK);
370
371 writel(info->fix.smem_start & 0xFF000000,
372 par->dc_regs + DC_PHY_MEM_OFFSET);
373
374 writel(0, par->dc_regs + DC_UNLOCK);
375
376 dev_info(&dev->dev, "%d KB of video memory at 0x%lx\n",
377 info->fix.smem_len / 1024, info->fix.smem_start);
378
379 return 0;
380}
381
382static struct fb_ops lxfb_ops = {
383 .owner = THIS_MODULE,
384 .fb_check_var = lxfb_check_var,
385 .fb_set_par = lxfb_set_par,
386 .fb_setcolreg = lxfb_setcolreg,
387 .fb_blank = lxfb_blank,
388 /* No HW acceleration for now. */
389 .fb_fillrect = cfb_fillrect,
390 .fb_copyarea = cfb_copyarea,
391 .fb_imageblit = cfb_imageblit,
392};
393
394static struct fb_info * __init lxfb_init_fbinfo(struct device *dev)
395{
396 struct lxfb_par *par;
397 struct fb_info *info;
398
399 /* Alloc enough space for the pseudo palette. */
400 info = framebuffer_alloc(sizeof(struct lxfb_par) + sizeof(u32) * 16,
401 dev);
402 if (!info)
403 return NULL;
404
405 par = info->par;
406
407 strcpy(info->fix.id, "Geode LX");
408
409 info->fix.type = FB_TYPE_PACKED_PIXELS;
410 info->fix.type_aux = 0;
411 info->fix.xpanstep = 0;
412 info->fix.ypanstep = 0;
413 info->fix.ywrapstep = 0;
414 info->fix.accel = FB_ACCEL_NONE;
415
416 info->var.nonstd = 0;
417 info->var.activate = FB_ACTIVATE_NOW;
418 info->var.height = -1;
419 info->var.width = -1;
420 info->var.accel_flags = 0;
421 info->var.vmode = FB_VMODE_NONINTERLACED;
422
423 info->fbops = &lxfb_ops;
424 info->flags = FBINFO_DEFAULT;
425 info->node = -1;
426
427 info->pseudo_palette = (void *)par + sizeof(struct lxfb_par);
428
429 info->var.grayscale = 0;
430
431 return info;
432}
433
434static int __init lxfb_probe(struct pci_dev *pdev,
435 const struct pci_device_id *id)
436{
437 struct lxfb_par *par;
438 struct fb_info *info;
439 int ret;
440
441 struct fb_videomode *modedb_ptr;
442 int modedb_size;
443
444 info = lxfb_init_fbinfo(&pdev->dev);
445
446 if (info == NULL)
447 return -ENOMEM;
448
449 par = info->par;
450
451 ret = lxfb_map_video_memory(info, pdev);
452
453 if (ret < 0) {
454 dev_err(&pdev->dev,
455 "failed to map frame buffer or controller registers\n");
456 goto err;
457 }
458
459 /* Set up the desired outputs */
460
461 par->output = 0;
462 par->output |= (nopanel) ? 0 : OUTPUT_PANEL;
463 par->output |= (nocrt) ? 0 : OUTPUT_CRT;
464
465 /* Set up the mode database */
466
467 modedb_ptr = (struct fb_videomode *) geode_modedb;
468 modedb_size = ARRAY_SIZE(geode_modedb);
469
470 ret = fb_find_mode(&info->var, info, mode_option,
471 modedb_ptr, modedb_size, NULL, 16);
472
473 if (ret == 0 || ret == 4) {
474 dev_err(&pdev->dev, "could not find valid video mode\n");
475 ret = -EINVAL;
476 goto err;
477 }
478
479 /* Clear the screen of garbage, unless noclear was specified,
480 * in which case we assume the user knows what he is doing */
481
482 if (!noclear)
483 memset_io(info->screen_base, 0, info->fix.smem_len);
484
485 /* Set the mode */
486
487 lxfb_check_var(&info->var, info);
488 lxfb_set_par(info);
489
490 if (register_framebuffer(info) < 0) {
491 ret = -EINVAL;
492 goto err;
493 }
494 pci_set_drvdata(pdev, info);
495 printk(KERN_INFO "fb%d: %s frame buffer device\n",
496 info->node, info->fix.id);
497
498 return 0;
499
500err:
501 if (info->screen_base) {
502 iounmap(info->screen_base);
503 pci_release_region(pdev, 0);
504 }
505 if (par->gp_regs) {
506 iounmap(par->gp_regs);
507 pci_release_region(pdev, 1);
508 }
509 if (par->dc_regs) {
510 iounmap(par->dc_regs);
511 pci_release_region(pdev, 2);
512 }
513 if (par->df_regs) {
514 iounmap(par->df_regs);
515 pci_release_region(pdev, 3);
516 }
517
518 if (info)
519 framebuffer_release(info);
520
521 return ret;
522}
523
524static void lxfb_remove(struct pci_dev *pdev)
525{
526 struct fb_info *info = pci_get_drvdata(pdev);
527 struct lxfb_par *par = info->par;
528
529 unregister_framebuffer(info);
530
531 iounmap(info->screen_base);
532 pci_release_region(pdev, 0);
533
534 iounmap(par->gp_regs);
535 pci_release_region(pdev, 1);
536
537 iounmap(par->dc_regs);
538 pci_release_region(pdev, 2);
539
540 iounmap(par->df_regs);
541 pci_release_region(pdev, 3);
542
543 pci_set_drvdata(pdev, NULL);
544 framebuffer_release(info);
545}
546
547static struct pci_device_id lxfb_id_table[] = {
548 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_VIDEO) },
549 { 0, }
550};
551
552MODULE_DEVICE_TABLE(pci, lxfb_id_table);
553
554static struct pci_driver lxfb_driver = {
555 .name = "lxfb",
556 .id_table = lxfb_id_table,
557 .probe = lxfb_probe,
558 .remove = lxfb_remove,
559};
560
561#ifndef MODULE
562static int __init lxfb_setup(char *options)
563{
564 char *opt;
565
566 if (!options || !*options)
567 return 0;
568
569 while (1) {
570 char *opt = strsep(&options, ",");
571
572 if (opt == NULL)
573 break;
574
575 if (!*opt)
576 continue;
577
578 if (!strncmp(opt, "fbsize:", 7))
579 fbsize = simple_strtoul(opt+7, NULL, 0);
580 else if (!strcmp(opt, "noclear"))
581 noclear = 1;
582 else if (!strcmp(opt, "nopanel"))
583 nopanel = 1;
584 else if (!strcmp(opt, "nocrt"))
585 nocrt = 1;
586 else
587 mode_option = opt;
588 }
589
590 return 0;
591}
592#endif
593
594static int __init lxfb_init(void)
595{
596#ifndef MODULE
597 char *option = NULL;
598
599 if (fb_get_options("lxfb", &option))
600 return -ENODEV;
601
602 lxfb_setup(option);
603#endif
604 return pci_register_driver(&lxfb_driver);
605}
606static void __exit lxfb_cleanup(void)
607{
608 pci_unregister_driver(&lxfb_driver);
609}
610
611module_init(lxfb_init);
612module_exit(lxfb_cleanup);
613
614module_param(mode_option, charp, 0);
615MODULE_PARM_DESC(mode_option, "video mode (<x>x<y>[-<bpp>][@<refr>])");
616
617module_param(fbsize, int, 0);
618MODULE_PARM_DESC(fbsize, "video memory size");
619
620MODULE_DESCRIPTION("Framebuffer driver for the AMD Geode LX");
621MODULE_LICENSE("GPL");
diff --git a/drivers/video/geode/lxfb_ops.c b/drivers/video/geode/lxfb_ops.c
new file mode 100644
index 000000000000..4fbc99be96ef
--- /dev/null
+++ b/drivers/video/geode/lxfb_ops.c
@@ -0,0 +1,536 @@
1/* Geode LX framebuffer driver
2 *
3 * Copyright (C) 2006-2007, Advanced Micro Devices,Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
10
11#include <linux/kernel.h>
12#include <linux/errno.h>
13#include <linux/fb.h>
14#include <linux/uaccess.h>
15#include <linux/delay.h>
16
17#include "lxfb.h"
18
19/* TODO
20 * Support panel scaling
21 * Add acceleration
22 * Add support for interlacing (TV out)
23 * Support compression
24 */
25
26/* This is the complete list of PLL frequencies that we can set -
27 * we will choose the closest match to the incoming clock.
28 * freq is the frequency of the dotclock * 1000 (for example,
29 * 24823 = 24.983 Mhz).
30 * pllval is the corresponding PLL value
31*/
32
33static const struct {
34 unsigned int pllval;
35 unsigned int freq;
36} pll_table[] = {
37 { 0x000031AC, 24923 },
38 { 0x0000215D, 25175 },
39 { 0x00001087, 27000 },
40 { 0x0000216C, 28322 },
41 { 0x0000218D, 28560 },
42 { 0x000010C9, 31200 },
43 { 0x00003147, 31500 },
44 { 0x000010A7, 33032 },
45 { 0x00002159, 35112 },
46 { 0x00004249, 35500 },
47 { 0x00000057, 36000 },
48 { 0x0000219A, 37889 },
49 { 0x00002158, 39168 },
50 { 0x00000045, 40000 },
51 { 0x00000089, 43163 },
52 { 0x000010E7, 44900 },
53 { 0x00002136, 45720 },
54 { 0x00003207, 49500 },
55 { 0x00002187, 50000 },
56 { 0x00004286, 56250 },
57 { 0x000010E5, 60065 },
58 { 0x00004214, 65000 },
59 { 0x00001105, 68179 },
60 { 0x000031E4, 74250 },
61 { 0x00003183, 75000 },
62 { 0x00004284, 78750 },
63 { 0x00001104, 81600 },
64 { 0x00006363, 94500 },
65 { 0x00005303, 97520 },
66 { 0x00002183, 100187 },
67 { 0x00002122, 101420 },
68 { 0x00001081, 108000 },
69 { 0x00006201, 113310 },
70 { 0x00000041, 119650 },
71 { 0x000041A1, 129600 },
72 { 0x00002182, 133500 },
73 { 0x000041B1, 135000 },
74 { 0x00000051, 144000 },
75 { 0x000041E1, 148500 },
76 { 0x000062D1, 157500 },
77 { 0x000031A1, 162000 },
78 { 0x00000061, 169203 },
79 { 0x00004231, 172800 },
80 { 0x00002151, 175500 },
81 { 0x000052E1, 189000 },
82 { 0x00000071, 192000 },
83 { 0x00003201, 198000 },
84 { 0x00004291, 202500 },
85 { 0x00001101, 204750 },
86 { 0x00007481, 218250 },
87 { 0x00004170, 229500 },
88 { 0x00006210, 234000 },
89 { 0x00003140, 251182 },
90 { 0x00006250, 261000 },
91 { 0x000041C0, 278400 },
92 { 0x00005220, 280640 },
93 { 0x00000050, 288000 },
94 { 0x000041E0, 297000 },
95 { 0x00002130, 320207 }
96};
97
98
99static void lx_set_dotpll(u32 pllval)
100{
101 u32 dotpll_lo, dotpll_hi;
102 int i;
103
104 rdmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi);
105
106 if ((dotpll_lo & GLCP_DOTPLL_LOCK) && (dotpll_hi == pllval))
107 return;
108
109 dotpll_hi = pllval;
110 dotpll_lo &= ~(GLCP_DOTPLL_BYPASS | GLCP_DOTPLL_HALFPIX);
111 dotpll_lo |= GLCP_DOTPLL_RESET;
112
113 wrmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi);
114
115 /* Wait 100us for the PLL to lock */
116
117 udelay(100);
118
119 /* Now, loop for the lock bit */
120
121 for (i = 0; i < 1000; i++) {
122 rdmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi);
123 if (dotpll_lo & GLCP_DOTPLL_LOCK)
124 break;
125 }
126
127 /* Clear the reset bit */
128
129 dotpll_lo &= ~GLCP_DOTPLL_RESET;
130 wrmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi);
131}
132
133/* Set the clock based on the frequency specified by the current mode */
134
135static void lx_set_clock(struct fb_info *info)
136{
137 unsigned int diff, min, best = 0;
138 unsigned int freq, i;
139
140 freq = (unsigned int) (0x3b9aca00 / info->var.pixclock);
141
142 min = abs(pll_table[0].freq - freq);
143
144 for (i = 0; i < ARRAY_SIZE(pll_table); i++) {
145 diff = abs(pll_table[i].freq - freq);
146 if (diff < min) {
147 min = diff;
148 best = i;
149 }
150 }
151
152 lx_set_dotpll(pll_table[best].pllval & 0x7FFF);
153}
154
155static void lx_graphics_disable(struct fb_info *info)
156{
157 struct lxfb_par *par = info->par;
158 unsigned int val, gcfg;
159
160 /* Note: This assumes that the video is in a quitet state */
161
162 writel(0, par->df_regs + DF_ALPHA_CONTROL_1);
163 writel(0, par->df_regs + DF_ALPHA_CONTROL_1 + 32);
164 writel(0, par->df_regs + DF_ALPHA_CONTROL_1 + 64);
165
166 /* Turn off the VGA and video enable */
167 val = readl (par->dc_regs + DC_GENERAL_CFG) &
168 ~(DC_GCFG_VGAE | DC_GCFG_VIDE);
169
170 writel(val, par->dc_regs + DC_GENERAL_CFG);
171
172 val = readl(par->df_regs + DF_VIDEO_CFG) & ~DF_VCFG_VID_EN;
173 writel(val, par->df_regs + DF_VIDEO_CFG);
174
175 writel( DC_IRQ_MASK | DC_VSYNC_IRQ_MASK |
176 DC_IRQ_STATUS | DC_VSYNC_IRQ_STATUS,
177 par->dc_regs + DC_IRQ);
178
179 val = readl(par->dc_regs + DC_GENLCK_CTRL) & ~DC_GENLCK_ENABLE;
180 writel(val, par->dc_regs + DC_GENLCK_CTRL);
181
182 val = readl(par->dc_regs + DC_COLOR_KEY) & ~DC_CLR_KEY_ENABLE;
183 writel(val & ~DC_CLR_KEY_ENABLE, par->dc_regs + DC_COLOR_KEY);
184
185 /* We don't actually blank the panel, due to the long latency
186 involved with bringing it back */
187
188 val = readl(par->df_regs + DF_MISC) | DF_MISC_DAC_PWRDN;
189 writel(val, par->df_regs + DF_MISC);
190
191 /* Turn off the display */
192
193 val = readl(par->df_regs + DF_DISPLAY_CFG);
194 writel(val & ~(DF_DCFG_CRT_EN | DF_DCFG_HSYNC_EN | DF_DCFG_VSYNC_EN |
195 DF_DCFG_DAC_BL_EN), par->df_regs + DF_DISPLAY_CFG);
196
197 gcfg = readl(par->dc_regs + DC_GENERAL_CFG);
198 gcfg &= ~(DC_GCFG_CMPE | DC_GCFG_DECE);
199 writel(gcfg, par->dc_regs + DC_GENERAL_CFG);
200
201 /* Turn off the TGEN */
202 val = readl(par->dc_regs + DC_DISPLAY_CFG);
203 val &= ~DC_DCFG_TGEN;
204 writel(val, par->dc_regs + DC_DISPLAY_CFG);
205
206 /* Wait 1000 usecs to ensure that the TGEN is clear */
207 udelay(1000);
208
209 /* Turn off the FIFO loader */
210
211 gcfg &= ~DC_GCFG_DFLE;
212 writel(gcfg, par->dc_regs + DC_GENERAL_CFG);
213
214 /* Lastly, wait for the GP to go idle */
215
216 do {
217 val = readl(par->gp_regs + GP_BLT_STATUS);
218 } while ((val & GP_BS_BLT_BUSY) || !(val & GP_BS_CB_EMPTY));
219}
220
221static void lx_graphics_enable(struct fb_info *info)
222{
223 struct lxfb_par *par = info->par;
224 u32 temp, config;
225
226 /* Set the video request register */
227 writel(0, par->df_regs + DF_VIDEO_REQUEST);
228
229 /* Set up the polarities */
230
231 config = readl(par->df_regs + DF_DISPLAY_CFG);
232
233 config &= ~(DF_DCFG_CRT_SYNC_SKW_MASK | DF_DCFG_PWR_SEQ_DLY_MASK |
234 DF_DCFG_CRT_HSYNC_POL | DF_DCFG_CRT_VSYNC_POL);
235
236 config |= (DF_DCFG_CRT_SYNC_SKW_INIT | DF_DCFG_PWR_SEQ_DLY_INIT |
237 DF_DCFG_GV_PAL_BYP);
238
239 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
240 config |= DF_DCFG_CRT_HSYNC_POL;
241
242 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
243 config |= DF_DCFG_CRT_VSYNC_POL;
244
245 if (par->output & OUTPUT_PANEL) {
246 u32 msrlo, msrhi;
247
248 writel(DF_DEFAULT_TFT_PMTIM1,
249 par->df_regs + DF_PANEL_TIM1);
250 writel(DF_DEFAULT_TFT_PMTIM2,
251 par->df_regs + DF_PANEL_TIM2);
252 writel(DF_DEFAULT_TFT_DITHCTL,
253 par->df_regs + DF_DITHER_CONTROL);
254
255 msrlo = DF_DEFAULT_TFT_PAD_SEL_LOW;
256 msrhi = DF_DEFAULT_TFT_PAD_SEL_HIGH;
257
258 wrmsr(MSR_LX_DF_PADSEL, msrlo, msrhi);
259 }
260
261 if (par->output & OUTPUT_CRT) {
262 config |= DF_DCFG_CRT_EN | DF_DCFG_HSYNC_EN |
263 DF_DCFG_VSYNC_EN | DF_DCFG_DAC_BL_EN;
264 }
265
266 writel(config, par->df_regs + DF_DISPLAY_CFG);
267
268 /* Turn the CRT dacs back on */
269
270 if (par->output & OUTPUT_CRT) {
271 temp = readl(par->df_regs + DF_MISC);
272 temp &= ~(DF_MISC_DAC_PWRDN | DF_MISC_A_PWRDN);
273 writel(temp, par->df_regs + DF_MISC);
274 }
275
276 /* Turn the panel on (if it isn't already) */
277
278 if (par->output & OUTPUT_PANEL) {
279 temp = readl(par->df_regs + DF_FP_PM);
280
281 if (!(temp & 0x09))
282 writel(temp | DF_FP_PM_P, par->df_regs + DF_FP_PM);
283 }
284
285 temp = readl(par->df_regs + DF_MISC);
286 temp = readl(par->df_regs + DF_DISPLAY_CFG);
287}
288
289unsigned int lx_framebuffer_size(void)
290{
291 unsigned int val;
292
293 /* The frame buffer size is reported by a VSM in VSA II */
294 /* Virtual Register Class = 0x02 */
295 /* VG_MEM_SIZE (1MB units) = 0x00 */
296
297 outw(0xFC53, 0xAC1C);
298 outw(0x0200, 0xAC1C);
299
300 val = (unsigned int)(inw(0xAC1E)) & 0xFE;
301 return (val << 20);
302}
303
304void lx_set_mode(struct fb_info *info)
305{
306 struct lxfb_par *par = info->par;
307 u64 msrval;
308
309 unsigned int max, dv, val, size;
310
311 unsigned int gcfg, dcfg;
312 int hactive, hblankstart, hsyncstart, hsyncend, hblankend, htotal;
313 int vactive, vblankstart, vsyncstart, vsyncend, vblankend, vtotal;
314
315 /* Unlock the DC registers */
316 writel(DC_UNLOCK_CODE, par->dc_regs + DC_UNLOCK);
317
318 lx_graphics_disable(info);
319
320 lx_set_clock(info);
321
322 /* Set output mode */
323
324 rdmsrl(MSR_LX_DF_GLCONFIG, msrval);
325 msrval &= ~DF_CONFIG_OUTPUT_MASK;
326
327 if (par->output & OUTPUT_PANEL) {
328 msrval |= DF_OUTPUT_PANEL;
329
330 if (par->output & OUTPUT_CRT)
331 msrval |= DF_SIMULTANEOUS_CRT_AND_FP;
332 else
333 msrval &= ~DF_SIMULTANEOUS_CRT_AND_FP;
334 } else {
335 msrval |= DF_OUTPUT_CRT;
336 }
337
338 wrmsrl(MSR_LX_DF_GLCONFIG, msrval);
339
340 /* Clear the various buffers */
341 /* FIXME: Adjust for panning here */
342
343 writel(0, par->dc_regs + DC_FB_START);
344 writel(0, par->dc_regs + DC_CB_START);
345 writel(0, par->dc_regs + DC_CURSOR_START);
346
347 /* FIXME: Add support for interlacing */
348 /* FIXME: Add support for scaling */
349
350 val = readl(par->dc_regs + DC_GENLCK_CTRL);
351 val &= ~(DC_GC_ALPHA_FLICK_ENABLE |
352 DC_GC_FLICKER_FILTER_ENABLE | DC_GC_FLICKER_FILTER_MASK);
353
354 /* Default scaling params */
355
356 writel((0x4000 << 16) | 0x4000, par->dc_regs + DC_GFX_SCALE);
357 writel(0, par->dc_regs + DC_IRQ_FILT_CTL);
358 writel(val, par->dc_regs + DC_GENLCK_CTRL);
359
360 /* FIXME: Support compression */
361
362 if (info->fix.line_length > 4096)
363 dv = DC_DV_LINE_SIZE_8192;
364 else if (info->fix.line_length > 2048)
365 dv = DC_DV_LINE_SIZE_4096;
366 else if (info->fix.line_length > 1024)
367 dv = DC_DV_LINE_SIZE_2048;
368 else
369 dv = DC_DV_LINE_SIZE_1024;
370
371 max = info->fix.line_length * info->var.yres;
372 max = (max + 0x3FF) & 0xFFFFFC00;
373
374 writel(max | DC_DV_TOP_ENABLE, par->dc_regs + DC_DV_TOP);
375
376 val = readl(par->dc_regs + DC_DV_CTL) & ~DC_DV_LINE_SIZE_MASK;
377 writel(val | dv, par->dc_regs + DC_DV_CTL);
378
379 size = info->var.xres * (info->var.bits_per_pixel >> 3);
380
381 writel(info->fix.line_length >> 3, par->dc_regs + DC_GRAPHICS_PITCH);
382 writel((size + 7) >> 3, par->dc_regs + DC_LINE_SIZE);
383
384 /* Set default watermark values */
385
386 rdmsrl(MSR_LX_DC_SPARE, msrval);
387
388 msrval &= ~(DC_SPARE_DISABLE_CFIFO_HGO | DC_SPARE_VFIFO_ARB_SELECT |
389 DC_SPARE_LOAD_WM_LPEN_MASK | DC_SPARE_WM_LPEN_OVRD |
390 DC_SPARE_DISABLE_INIT_VID_PRI | DC_SPARE_DISABLE_VFIFO_WM);
391 msrval |= DC_SPARE_DISABLE_VFIFO_WM | DC_SPARE_DISABLE_INIT_VID_PRI;
392 wrmsrl(MSR_LX_DC_SPARE, msrval);
393
394 gcfg = DC_GCFG_DFLE; /* Display fifo enable */
395 gcfg |= 0xB600; /* Set default priority */
396 gcfg |= DC_GCFG_FDTY; /* Set the frame dirty mode */
397
398 dcfg = DC_DCFG_VDEN; /* Enable video data */
399 dcfg |= DC_DCFG_GDEN; /* Enable graphics */
400 dcfg |= DC_DCFG_TGEN; /* Turn on the timing generator */
401 dcfg |= DC_DCFG_TRUP; /* Update timings immediately */
402 dcfg |= DC_DCFG_PALB; /* Palette bypass in > 8 bpp modes */
403 dcfg |= DC_DCFG_VISL;
404 dcfg |= DC_DCFG_DCEN; /* Always center the display */
405
406 /* Set the current BPP mode */
407
408 switch (info->var.bits_per_pixel) {
409 case 8:
410 dcfg |= DC_DCFG_DISP_MODE_8BPP;
411 break;
412
413 case 16:
414 dcfg |= DC_DCFG_DISP_MODE_16BPP | DC_DCFG_16BPP;
415 break;
416
417 case 32:
418 case 24:
419 dcfg |= DC_DCFG_DISP_MODE_24BPP;
420 break;
421 }
422
423 /* Now - set up the timings */
424
425 hactive = info->var.xres;
426 hblankstart = hactive;
427 hsyncstart = hblankstart + info->var.right_margin;
428 hsyncend = hsyncstart + info->var.hsync_len;
429 hblankend = hsyncend + info->var.left_margin;
430 htotal = hblankend;
431
432 vactive = info->var.yres;
433 vblankstart = vactive;
434 vsyncstart = vblankstart + info->var.lower_margin;
435 vsyncend = vsyncstart + info->var.vsync_len;
436 vblankend = vsyncend + info->var.upper_margin;
437 vtotal = vblankend;
438
439 writel((hactive - 1) | ((htotal - 1) << 16),
440 par->dc_regs + DC_H_ACTIVE_TIMING);
441 writel((hblankstart - 1) | ((hblankend - 1) << 16),
442 par->dc_regs + DC_H_BLANK_TIMING);
443 writel((hsyncstart - 1) | ((hsyncend - 1) << 16),
444 par->dc_regs + DC_H_SYNC_TIMING);
445
446 writel((vactive - 1) | ((vtotal - 1) << 16),
447 par->dc_regs + DC_V_ACTIVE_TIMING);
448
449 writel((vblankstart - 1) | ((vblankend - 1) << 16),
450 par->dc_regs + DC_V_BLANK_TIMING);
451
452 writel((vsyncstart - 1) | ((vsyncend - 1) << 16),
453 par->dc_regs + DC_V_SYNC_TIMING);
454
455 writel( (info->var.xres - 1) << 16 | (info->var.yres - 1),
456 par->dc_regs + DC_FB_ACTIVE);
457
458 /* And re-enable the graphics output */
459 lx_graphics_enable(info);
460
461 /* Write the two main configuration registers */
462 writel(dcfg, par->dc_regs + DC_DISPLAY_CFG);
463 writel(0, par->dc_regs + DC_ARB_CFG);
464 writel(gcfg, par->dc_regs + DC_GENERAL_CFG);
465
466 /* Lock the DC registers */
467 writel(0, par->dc_regs + DC_UNLOCK);
468}
469
470void lx_set_palette_reg(struct fb_info *info, unsigned regno,
471 unsigned red, unsigned green, unsigned blue)
472{
473 struct lxfb_par *par = info->par;
474 int val;
475
476 /* Hardware palette is in RGB 8-8-8 format. */
477
478 val = (red << 8) & 0xff0000;
479 val |= (green) & 0x00ff00;
480 val |= (blue >> 8) & 0x0000ff;
481
482 writel(regno, par->dc_regs + DC_PAL_ADDRESS);
483 writel(val, par->dc_regs + DC_PAL_DATA);
484}
485
486int lx_blank_display(struct fb_info *info, int blank_mode)
487{
488 struct lxfb_par *par = info->par;
489 u32 dcfg, fp_pm;
490 int blank, hsync, vsync;
491
492 /* CRT power saving modes. */
493 switch (blank_mode) {
494 case FB_BLANK_UNBLANK:
495 blank = 0; hsync = 1; vsync = 1;
496 break;
497 case FB_BLANK_NORMAL:
498 blank = 1; hsync = 1; vsync = 1;
499 break;
500 case FB_BLANK_VSYNC_SUSPEND:
501 blank = 1; hsync = 1; vsync = 0;
502 break;
503 case FB_BLANK_HSYNC_SUSPEND:
504 blank = 1; hsync = 0; vsync = 1;
505 break;
506 case FB_BLANK_POWERDOWN:
507 blank = 1; hsync = 0; vsync = 0;
508 break;
509 default:
510 return -EINVAL;
511 }
512
513 dcfg = readl(par->df_regs + DF_DISPLAY_CFG);
514 dcfg &= ~(DF_DCFG_DAC_BL_EN
515 | DF_DCFG_HSYNC_EN | DF_DCFG_VSYNC_EN);
516 if (!blank)
517 dcfg |= DF_DCFG_DAC_BL_EN;
518 if (hsync)
519 dcfg |= DF_DCFG_HSYNC_EN;
520 if (vsync)
521 dcfg |= DF_DCFG_VSYNC_EN;
522 writel(dcfg, par->df_regs + DF_DISPLAY_CFG);
523
524 /* Power on/off flat panel */
525
526 if (par->output & OUTPUT_PANEL) {
527 fp_pm = readl(par->df_regs + DF_FP_PM);
528 if (blank_mode == FB_BLANK_POWERDOWN)
529 fp_pm &= ~DF_FP_PM_P;
530 else
531 fp_pm |= DF_FP_PM_P;
532 writel(fp_pm, par->df_regs + DF_FP_PM);
533 }
534
535 return 0;
536}
diff --git a/drivers/video/leo.c b/drivers/video/leo.c
index a038aa5a9e1c..45b9a5d55dec 100644
--- a/drivers/video/leo.c
+++ b/drivers/video/leo.c
@@ -525,130 +525,123 @@ static void leo_fixup_var_rgb(struct fb_var_screeninfo *var)
525 var->transp.length = 0; 525 var->transp.length = 0;
526} 526}
527 527
528struct all_info { 528static void leo_unmap_regs(struct of_device *op, struct fb_info *info,
529 struct fb_info info; 529 struct leo_par *par)
530 struct leo_par par;
531};
532
533static void leo_unmap_regs(struct of_device *op, struct all_info *all)
534{ 530{
535 if (all->par.lc_ss0_usr) 531 if (par->lc_ss0_usr)
536 of_iounmap(&op->resource[0], all->par.lc_ss0_usr, 0x1000); 532 of_iounmap(&op->resource[0], par->lc_ss0_usr, 0x1000);
537 if (all->par.ld_ss0) 533 if (par->ld_ss0)
538 of_iounmap(&op->resource[0], all->par.ld_ss0, 0x1000); 534 of_iounmap(&op->resource[0], par->ld_ss0, 0x1000);
539 if (all->par.ld_ss1) 535 if (par->ld_ss1)
540 of_iounmap(&op->resource[0], all->par.ld_ss1, 0x1000); 536 of_iounmap(&op->resource[0], par->ld_ss1, 0x1000);
541 if (all->par.lx_krn) 537 if (par->lx_krn)
542 of_iounmap(&op->resource[0], all->par.lx_krn, 0x1000); 538 of_iounmap(&op->resource[0], par->lx_krn, 0x1000);
543 if (all->par.cursor) 539 if (par->cursor)
544 of_iounmap(&op->resource[0], 540 of_iounmap(&op->resource[0],
545 all->par.cursor, sizeof(struct leo_cursor)); 541 par->cursor, sizeof(struct leo_cursor));
546 if (all->info.screen_base) 542 if (info->screen_base)
547 of_iounmap(&op->resource[0], all->info.screen_base, 0x800000); 543 of_iounmap(&op->resource[0], info->screen_base, 0x800000);
548} 544}
549 545
550static int __devinit leo_init_one(struct of_device *op) 546static int __devinit leo_probe(struct of_device *op, const struct of_device_id *match)
551{ 547{
552 struct device_node *dp = op->node; 548 struct device_node *dp = op->node;
553 struct all_info *all; 549 struct fb_info *info;
550 struct leo_par *par;
554 int linebytes, err; 551 int linebytes, err;
555 552
556 all = kzalloc(sizeof(*all), GFP_KERNEL); 553 info = framebuffer_alloc(sizeof(struct leo_par), &op->dev);
557 if (!all) 554
558 return -ENOMEM; 555 err = -ENOMEM;
556 if (!info)
557 goto out_err;
558 par = info->par;
559 559
560 spin_lock_init(&all->par.lock); 560 spin_lock_init(&par->lock);
561 561
562 all->par.physbase = op->resource[0].start; 562 par->physbase = op->resource[0].start;
563 all->par.which_io = op->resource[0].flags & IORESOURCE_BITS; 563 par->which_io = op->resource[0].flags & IORESOURCE_BITS;
564 564
565 sbusfb_fill_var(&all->info.var, dp->node, 32); 565 sbusfb_fill_var(&info->var, dp->node, 32);
566 leo_fixup_var_rgb(&all->info.var); 566 leo_fixup_var_rgb(&info->var);
567 567
568 linebytes = of_getintprop_default(dp, "linebytes", 568 linebytes = of_getintprop_default(dp, "linebytes",
569 all->info.var.xres); 569 info->var.xres);
570 all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres); 570 par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
571 571
572 all->par.lc_ss0_usr = 572 par->lc_ss0_usr =
573 of_ioremap(&op->resource[0], LEO_OFF_LC_SS0_USR, 573 of_ioremap(&op->resource[0], LEO_OFF_LC_SS0_USR,
574 0x1000, "leolc ss0usr"); 574 0x1000, "leolc ss0usr");
575 all->par.ld_ss0 = 575 par->ld_ss0 =
576 of_ioremap(&op->resource[0], LEO_OFF_LD_SS0, 576 of_ioremap(&op->resource[0], LEO_OFF_LD_SS0,
577 0x1000, "leold ss0"); 577 0x1000, "leold ss0");
578 all->par.ld_ss1 = 578 par->ld_ss1 =
579 of_ioremap(&op->resource[0], LEO_OFF_LD_SS1, 579 of_ioremap(&op->resource[0], LEO_OFF_LD_SS1,
580 0x1000, "leold ss1"); 580 0x1000, "leold ss1");
581 all->par.lx_krn = 581 par->lx_krn =
582 of_ioremap(&op->resource[0], LEO_OFF_LX_KRN, 582 of_ioremap(&op->resource[0], LEO_OFF_LX_KRN,
583 0x1000, "leolx krn"); 583 0x1000, "leolx krn");
584 all->par.cursor = 584 par->cursor =
585 of_ioremap(&op->resource[0], LEO_OFF_LX_CURSOR, 585 of_ioremap(&op->resource[0], LEO_OFF_LX_CURSOR,
586 sizeof(struct leo_cursor), "leolx cursor"); 586 sizeof(struct leo_cursor), "leolx cursor");
587 all->info.screen_base = 587 info->screen_base =
588 of_ioremap(&op->resource[0], LEO_OFF_SS0, 588 of_ioremap(&op->resource[0], LEO_OFF_SS0,
589 0x800000, "leo ram"); 589 0x800000, "leo ram");
590 if (!all->par.lc_ss0_usr || 590 if (!par->lc_ss0_usr ||
591 !all->par.ld_ss0 || 591 !par->ld_ss0 ||
592 !all->par.ld_ss1 || 592 !par->ld_ss1 ||
593 !all->par.lx_krn || 593 !par->lx_krn ||
594 !all->par.cursor || 594 !par->cursor ||
595 !all->info.screen_base) { 595 !info->screen_base)
596 leo_unmap_regs(op, all); 596 goto out_unmap_regs;
597 kfree(all);
598 return -ENOMEM;
599 }
600 597
601 all->info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN; 598 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
602 all->info.fbops = &leo_ops; 599 info->fbops = &leo_ops;
603 all->info.par = &all->par;
604 600
605 leo_init_wids(&all->info); 601 leo_init_wids(info);
606 leo_init_hw(&all->info); 602 leo_init_hw(info);
607 603
608 leo_blank(0, &all->info); 604 leo_blank(0, info);
609 605
610 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 606 if (fb_alloc_cmap(&info->cmap, 256, 0))
611 leo_unmap_regs(op, all); 607 goto out_unmap_regs;
612 kfree(all);
613 return -ENOMEM;;
614 }
615 608
616 leo_init_fix(&all->info, dp); 609 leo_init_fix(info, dp);
617 610
618 err = register_framebuffer(&all->info); 611 err = register_framebuffer(info);
619 if (err < 0) { 612 if (err < 0)
620 fb_dealloc_cmap(&all->info.cmap); 613 goto out_dealloc_cmap;
621 leo_unmap_regs(op, all);
622 kfree(all);
623 return err;
624 }
625 614
626 dev_set_drvdata(&op->dev, all); 615 dev_set_drvdata(&op->dev, info);
627 616
628 printk("%s: leo at %lx:%lx\n", 617 printk("%s: leo at %lx:%lx\n",
629 dp->full_name, 618 dp->full_name,
630 all->par.which_io, all->par.physbase); 619 par->which_io, par->physbase);
631 620
632 return 0; 621 return 0;
633}
634 622
635static int __devinit leo_probe(struct of_device *dev, const struct of_device_id *match) 623out_dealloc_cmap:
636{ 624 fb_dealloc_cmap(&info->cmap);
637 struct of_device *op = to_of_device(&dev->dev); 625
626out_unmap_regs:
627 leo_unmap_regs(op, info, par);
628 framebuffer_release(info);
638 629
639 return leo_init_one(op); 630out_err:
631 return err;
640} 632}
641 633
642static int __devexit leo_remove(struct of_device *op) 634static int __devexit leo_remove(struct of_device *op)
643{ 635{
644 struct all_info *all = dev_get_drvdata(&op->dev); 636 struct fb_info *info = dev_get_drvdata(&op->dev);
637 struct leo_par *par = info->par;
645 638
646 unregister_framebuffer(&all->info); 639 unregister_framebuffer(info);
647 fb_dealloc_cmap(&all->info.cmap); 640 fb_dealloc_cmap(&info->cmap);
648 641
649 leo_unmap_regs(op, all); 642 leo_unmap_regs(op, info, par);
650 643
651 kfree(all); 644 framebuffer_release(info);
652 645
653 dev_set_drvdata(&op->dev, NULL); 646 dev_set_drvdata(&op->dev, NULL);
654 647
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c
index 637b78bb4bf7..58496061142d 100644
--- a/drivers/video/p9100.c
+++ b/drivers/video/p9100.c
@@ -255,107 +255,95 @@ static void p9100_init_fix(struct fb_info *info, int linebytes, struct device_no
255 info->fix.accel = FB_ACCEL_SUN_CGTHREE; 255 info->fix.accel = FB_ACCEL_SUN_CGTHREE;
256} 256}
257 257
258struct all_info { 258static int __devinit p9100_probe(struct of_device *op, const struct of_device_id *match)
259 struct fb_info info;
260 struct p9100_par par;
261};
262
263static int __devinit p9100_init_one(struct of_device *op)
264{ 259{
265 struct device_node *dp = op->node; 260 struct device_node *dp = op->node;
266 struct all_info *all; 261 struct fb_info *info;
262 struct p9100_par *par;
267 int linebytes, err; 263 int linebytes, err;
268 264
269 all = kzalloc(sizeof(*all), GFP_KERNEL); 265 info = framebuffer_alloc(sizeof(struct p9100_par), &op->dev);
270 if (!all) 266
271 return -ENOMEM; 267 err = -ENOMEM;
268 if (!info)
269 goto out_err;
270 par = info->par;
272 271
273 spin_lock_init(&all->par.lock); 272 spin_lock_init(&par->lock);
274 273
275 /* This is the framebuffer and the only resource apps can mmap. */ 274 /* This is the framebuffer and the only resource apps can mmap. */
276 all->par.physbase = op->resource[2].start; 275 par->physbase = op->resource[2].start;
277 all->par.which_io = op->resource[2].flags & IORESOURCE_BITS; 276 par->which_io = op->resource[2].flags & IORESOURCE_BITS;
278
279 sbusfb_fill_var(&all->info.var, dp->node, 8);
280 all->info.var.red.length = 8;
281 all->info.var.green.length = 8;
282 all->info.var.blue.length = 8;
283
284 linebytes = of_getintprop_default(dp, "linebytes",
285 all->info.var.xres);
286 all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres);
287
288 all->par.regs = of_ioremap(&op->resource[0], 0,
289 sizeof(struct p9100_regs), "p9100 regs");
290 if (!all->par.regs) {
291 kfree(all);
292 return -ENOMEM;
293 }
294 277
295 all->info.flags = FBINFO_DEFAULT; 278 sbusfb_fill_var(&info->var, dp->node, 8);
296 all->info.fbops = &p9100_ops; 279 info->var.red.length = 8;
297 all->info.screen_base = of_ioremap(&op->resource[2], 0, 280 info->var.green.length = 8;
298 all->par.fbsize, "p9100 ram"); 281 info->var.blue.length = 8;
299 if (!all->info.screen_base) {
300 of_iounmap(&op->resource[0],
301 all->par.regs, sizeof(struct p9100_regs));
302 kfree(all);
303 return -ENOMEM;
304 }
305 all->info.par = &all->par;
306 282
307 p9100_blank(0, &all->info); 283 linebytes = of_getintprop_default(dp, "linebytes", info->var.xres);
284 par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
308 285
309 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 286 par->regs = of_ioremap(&op->resource[0], 0,
310 of_iounmap(&op->resource[0], 287 sizeof(struct p9100_regs), "p9100 regs");
311 all->par.regs, sizeof(struct p9100_regs)); 288 if (!par->regs)
312 of_iounmap(&op->resource[2], 289 goto out_release_fb;
313 all->info.screen_base, all->par.fbsize);
314 kfree(all);
315 return -ENOMEM;
316 }
317 290
318 p9100_init_fix(&all->info, linebytes, dp); 291 info->flags = FBINFO_DEFAULT;
319 292 info->fbops = &p9100_ops;
320 err = register_framebuffer(&all->info); 293 info->screen_base = of_ioremap(&op->resource[2], 0,
321 if (err < 0) { 294 par->fbsize, "p9100 ram");
322 fb_dealloc_cmap(&all->info.cmap); 295 if (!info->screen_base)
323 of_iounmap(&op->resource[0], 296 goto out_unmap_regs;
324 all->par.regs, sizeof(struct p9100_regs)); 297
325 of_iounmap(&op->resource[2], 298 p9100_blank(0, info);
326 all->info.screen_base, all->par.fbsize); 299
327 kfree(all); 300 if (fb_alloc_cmap(&info->cmap, 256, 0))
328 return err; 301 goto out_unmap_screen;
329 }
330 fb_set_cmap(&all->info.cmap, &all->info);
331 302
332 dev_set_drvdata(&op->dev, all); 303 p9100_init_fix(info, linebytes, dp);
304
305 err = register_framebuffer(info);
306 if (err < 0)
307 goto out_dealloc_cmap;
308
309 fb_set_cmap(&info->cmap, info);
310
311 dev_set_drvdata(&op->dev, info);
333 312
334 printk("%s: p9100 at %lx:%lx\n", 313 printk("%s: p9100 at %lx:%lx\n",
335 dp->full_name, 314 dp->full_name,
336 all->par.which_io, all->par.physbase); 315 par->which_io, par->physbase);
337 316
338 return 0; 317 return 0;
339}
340 318
341static int __devinit p9100_probe(struct of_device *dev, const struct of_device_id *match) 319out_dealloc_cmap:
342{ 320 fb_dealloc_cmap(&info->cmap);
343 struct of_device *op = to_of_device(&dev->dev); 321
322out_unmap_screen:
323 of_iounmap(&op->resource[2], info->screen_base, par->fbsize);
324
325out_unmap_regs:
326 of_iounmap(&op->resource[0], par->regs, sizeof(struct p9100_regs));
327
328out_release_fb:
329 framebuffer_release(info);
344 330
345 return p9100_init_one(op); 331out_err:
332 return err;
346} 333}
347 334
348static int __devexit p9100_remove(struct of_device *op) 335static int __devexit p9100_remove(struct of_device *op)
349{ 336{
350 struct all_info *all = dev_get_drvdata(&op->dev); 337 struct fb_info *info = dev_get_drvdata(&op->dev);
338 struct p9100_par *par = info->par;
351 339
352 unregister_framebuffer(&all->info); 340 unregister_framebuffer(info);
353 fb_dealloc_cmap(&all->info.cmap); 341 fb_dealloc_cmap(&info->cmap);
354 342
355 of_iounmap(&op->resource[0], all->par.regs, sizeof(struct p9100_regs)); 343 of_iounmap(&op->resource[0], par->regs, sizeof(struct p9100_regs));
356 of_iounmap(&op->resource[2], all->info.screen_base, all->par.fbsize); 344 of_iounmap(&op->resource[2], info->screen_base, par->fbsize);
357 345
358 kfree(all); 346 framebuffer_release(info);
359 347
360 dev_set_drvdata(&op->dev, NULL); 348 dev_set_drvdata(&op->dev, NULL);
361 349
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
index ed3426062a8b..8a4c6470d799 100644
--- a/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -474,6 +474,7 @@ static void schedule_palette_update(struct s3c2410fb_info *fbi,
474{ 474{
475 unsigned long flags; 475 unsigned long flags;
476 unsigned long irqen; 476 unsigned long irqen;
477 void __iomem *regs = fbi->io;
477 478
478 local_irq_save(flags); 479 local_irq_save(flags);
479 480
@@ -483,9 +484,9 @@ static void schedule_palette_update(struct s3c2410fb_info *fbi,
483 fbi->palette_ready = 1; 484 fbi->palette_ready = 1;
484 485
485 /* enable IRQ */ 486 /* enable IRQ */
486 irqen = readl(S3C2410_LCDINTMSK); 487 irqen = readl(regs + S3C2410_LCDINTMSK);
487 irqen &= ~S3C2410_LCDINT_FRSYNC; 488 irqen &= ~S3C2410_LCDINT_FRSYNC;
488 writel(irqen, S3C2410_LCDINTMSK); 489 writel(irqen, regs + S3C2410_LCDINTMSK);
489 } 490 }
490 491
491 local_irq_restore(flags); 492 local_irq_restore(flags);
@@ -680,6 +681,7 @@ static inline void modify_gpio(void __iomem *reg,
680static int s3c2410fb_init_registers(struct s3c2410fb_info *fbi) 681static int s3c2410fb_init_registers(struct s3c2410fb_info *fbi)
681{ 682{
682 unsigned long flags; 683 unsigned long flags;
684 void __iomem *regs = fbi->io;
683 685
684 /* Initialise LCD with values from haret */ 686 /* Initialise LCD with values from haret */
685 687
@@ -694,25 +696,25 @@ static int s3c2410fb_init_registers(struct s3c2410fb_info *fbi)
694 696
695 local_irq_restore(flags); 697 local_irq_restore(flags);
696 698
697 writel(fbi->regs.lcdcon1, S3C2410_LCDCON1); 699 writel(fbi->regs.lcdcon1, regs + S3C2410_LCDCON1);
698 writel(fbi->regs.lcdcon2, S3C2410_LCDCON2); 700 writel(fbi->regs.lcdcon2, regs + S3C2410_LCDCON2);
699 writel(fbi->regs.lcdcon3, S3C2410_LCDCON3); 701 writel(fbi->regs.lcdcon3, regs + S3C2410_LCDCON3);
700 writel(fbi->regs.lcdcon4, S3C2410_LCDCON4); 702 writel(fbi->regs.lcdcon4, regs + S3C2410_LCDCON4);
701 writel(fbi->regs.lcdcon5, S3C2410_LCDCON5); 703 writel(fbi->regs.lcdcon5, regs + S3C2410_LCDCON5);
702 704
703 s3c2410fb_set_lcdaddr(fbi); 705 s3c2410fb_set_lcdaddr(fbi);
704 706
705 dprintk("LPCSEL = 0x%08lx\n", mach_info->lpcsel); 707 dprintk("LPCSEL = 0x%08lx\n", mach_info->lpcsel);
706 writel(mach_info->lpcsel, S3C2410_LPCSEL); 708 writel(mach_info->lpcsel, regs + S3C2410_LPCSEL);
707 709
708 dprintk("replacing TPAL %08x\n", readl(S3C2410_TPAL)); 710 dprintk("replacing TPAL %08x\n", readl(regs + S3C2410_TPAL));
709 711
710 /* ensure temporary palette disabled */ 712 /* ensure temporary palette disabled */
711 writel(0x00, S3C2410_TPAL); 713 writel(0x00, regs + S3C2410_TPAL);
712 714
713 /* Enable video by setting the ENVID bit to 1 */ 715 /* Enable video by setting the ENVID bit to 1 */
714 fbi->regs.lcdcon1 |= S3C2410_LCDCON1_ENVID; 716 fbi->regs.lcdcon1 |= S3C2410_LCDCON1_ENVID;
715 writel(fbi->regs.lcdcon1, S3C2410_LCDCON1); 717 writel(fbi->regs.lcdcon1, regs + S3C2410_LCDCON1);
716 return 0; 718 return 0;
717} 719}
718 720
@@ -720,6 +722,7 @@ static void s3c2410fb_write_palette(struct s3c2410fb_info *fbi)
720{ 722{
721 unsigned int i; 723 unsigned int i;
722 unsigned long ent; 724 unsigned long ent;
725 void __iomem *regs = fbi->io;
723 726
724 fbi->palette_ready = 0; 727 fbi->palette_ready = 0;
725 728
@@ -727,14 +730,14 @@ static void s3c2410fb_write_palette(struct s3c2410fb_info *fbi)
727 if ((ent = fbi->palette_buffer[i]) == PALETTE_BUFF_CLEAR) 730 if ((ent = fbi->palette_buffer[i]) == PALETTE_BUFF_CLEAR)
728 continue; 731 continue;
729 732
730 writel(ent, S3C2410_TFTPAL(i)); 733 writel(ent, regs + S3C2410_TFTPAL(i));
731 734
732 /* it seems the only way to know exactly 735 /* it seems the only way to know exactly
733 * if the palette wrote ok, is to check 736 * if the palette wrote ok, is to check
734 * to see if the value verifies ok 737 * to see if the value verifies ok
735 */ 738 */
736 739
737 if (readw(S3C2410_TFTPAL(i)) == ent) 740 if (readw(regs + S3C2410_TFTPAL(i)) == ent)
738 fbi->palette_buffer[i] = PALETTE_BUFF_CLEAR; 741 fbi->palette_buffer[i] = PALETTE_BUFF_CLEAR;
739 else 742 else
740 fbi->palette_ready = 1; /* retry */ 743 fbi->palette_ready = 1; /* retry */
@@ -744,14 +747,15 @@ static void s3c2410fb_write_palette(struct s3c2410fb_info *fbi)
744static irqreturn_t s3c2410fb_irq(int irq, void *dev_id) 747static irqreturn_t s3c2410fb_irq(int irq, void *dev_id)
745{ 748{
746 struct s3c2410fb_info *fbi = dev_id; 749 struct s3c2410fb_info *fbi = dev_id;
747 unsigned long lcdirq = readl(S3C2410_LCDINTPND); 750 void __iomem *regs = fbi->io;
751 unsigned long lcdirq = readl(regs + S3C2410_LCDINTPND);
748 752
749 if (lcdirq & S3C2410_LCDINT_FRSYNC) { 753 if (lcdirq & S3C2410_LCDINT_FRSYNC) {
750 if (fbi->palette_ready) 754 if (fbi->palette_ready)
751 s3c2410fb_write_palette(fbi); 755 s3c2410fb_write_palette(fbi);
752 756
753 writel(S3C2410_LCDINT_FRSYNC, S3C2410_LCDINTPND); 757 writel(S3C2410_LCDINT_FRSYNC, regs + S3C2410_LCDINTPND);
754 writel(S3C2410_LCDINT_FRSYNC, S3C2410_LCDSRCPND); 758 writel(S3C2410_LCDINT_FRSYNC, regs + S3C2410_LCDSRCPND);
755 } 759 }
756 760
757 return IRQ_HANDLED; 761 return IRQ_HANDLED;
@@ -764,9 +768,11 @@ static int __init s3c2410fb_probe(struct platform_device *pdev)
764 struct s3c2410fb_info *info; 768 struct s3c2410fb_info *info;
765 struct fb_info *fbinfo; 769 struct fb_info *fbinfo;
766 struct s3c2410fb_hw *mregs; 770 struct s3c2410fb_hw *mregs;
771 struct resource *res;
767 int ret; 772 int ret;
768 int irq; 773 int irq;
769 int i; 774 int i;
775 int size;
770 u32 lcdcon1; 776 u32 lcdcon1;
771 777
772 mach_info = pdev->dev.platform_data; 778 mach_info = pdev->dev.platform_data;
@@ -788,11 +794,32 @@ static int __init s3c2410fb_probe(struct platform_device *pdev)
788 return -ENOMEM; 794 return -ENOMEM;
789 } 795 }
790 796
791
792 info = fbinfo->par; 797 info = fbinfo->par;
793 info->fb = fbinfo; 798 info->fb = fbinfo;
794 info->dev = &pdev->dev; 799 info->dev = &pdev->dev;
795 800
801 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
802 if (res == NULL) {
803 dev_err(&pdev->dev, "failed to get memory registersn");
804 ret = -ENXIO;
805 goto dealloc_fb;
806 }
807
808 size = (res->end - res->start)+1;
809 info->mem = request_mem_region(res->start, size, pdev->name);
810 if (info->mem == NULL) {
811 dev_err(&pdev->dev, "failed to get memory region\n");
812 ret = -ENOENT;
813 goto dealloc_fb;
814 }
815
816 info->io = ioremap(res->start, size);
817 if (info->io == NULL) {
818 dev_err(&pdev->dev, "ioremap() of registers failed\n");
819 ret = -ENXIO;
820 goto release_mem;
821 }
822
796 platform_set_drvdata(pdev, fbinfo); 823 platform_set_drvdata(pdev, fbinfo);
797 824
798 dprintk("devinit\n"); 825 dprintk("devinit\n");
@@ -803,8 +830,8 @@ static int __init s3c2410fb_probe(struct platform_device *pdev)
803 830
804 /* Stop the video and unset ENVID if set */ 831 /* Stop the video and unset ENVID if set */
805 info->regs.lcdcon1 &= ~S3C2410_LCDCON1_ENVID; 832 info->regs.lcdcon1 &= ~S3C2410_LCDCON1_ENVID;
806 lcdcon1 = readl(S3C2410_LCDCON1); 833 lcdcon1 = readl(info->io + S3C2410_LCDCON1);
807 writel(lcdcon1 & ~S3C2410_LCDCON1_ENVID, S3C2410_LCDCON1); 834 writel(lcdcon1 & ~S3C2410_LCDCON1_ENVID, info->io + S3C2410_LCDCON1);
808 835
809 info->mach_info = pdev->dev.platform_data; 836 info->mach_info = pdev->dev.platform_data;
810 837
@@ -855,19 +882,11 @@ static int __init s3c2410fb_probe(struct platform_device *pdev)
855 for (i = 0; i < 256; i++) 882 for (i = 0; i < 256; i++)
856 info->palette_buffer[i] = PALETTE_BUFF_CLEAR; 883 info->palette_buffer[i] = PALETTE_BUFF_CLEAR;
857 884
858 if (!request_mem_region((unsigned long)S3C24XX_VA_LCD, SZ_1M, "s3c2410-lcd")) {
859 ret = -EBUSY;
860 goto dealloc_fb;
861 }
862
863
864 dprintk("got LCD region\n");
865
866 ret = request_irq(irq, s3c2410fb_irq, IRQF_DISABLED, pdev->name, info); 885 ret = request_irq(irq, s3c2410fb_irq, IRQF_DISABLED, pdev->name, info);
867 if (ret) { 886 if (ret) {
868 dev_err(&pdev->dev, "cannot get irq %d - err %d\n", irq, ret); 887 dev_err(&pdev->dev, "cannot get irq %d - err %d\n", irq, ret);
869 ret = -EBUSY; 888 ret = -EBUSY;
870 goto release_mem; 889 goto release_regs;
871 } 890 }
872 891
873 info->clk = clk_get(NULL, "lcd"); 892 info->clk = clk_get(NULL, "lcd");
@@ -889,6 +908,7 @@ static int __init s3c2410fb_probe(struct platform_device *pdev)
889 ret = -ENOMEM; 908 ret = -ENOMEM;
890 goto release_clock; 909 goto release_clock;
891 } 910 }
911
892 dprintk("got video memory\n"); 912 dprintk("got video memory\n");
893 913
894 ret = s3c2410fb_init_registers(info); 914 ret = s3c2410fb_init_registers(info);
@@ -916,8 +936,11 @@ release_clock:
916 clk_put(info->clk); 936 clk_put(info->clk);
917release_irq: 937release_irq:
918 free_irq(irq,info); 938 free_irq(irq,info);
939release_regs:
940 iounmap(info->io);
919release_mem: 941release_mem:
920 release_mem_region((unsigned long)S3C24XX_VA_LCD, S3C24XX_SZ_LCD); 942 release_resource(info->mem);
943 kfree(info->mem);
921dealloc_fb: 944dealloc_fb:
922 framebuffer_release(fbinfo); 945 framebuffer_release(fbinfo);
923 return ret; 946 return ret;
@@ -935,7 +958,7 @@ static void s3c2410fb_stop_lcd(struct s3c2410fb_info *fbi)
935 local_irq_save(flags); 958 local_irq_save(flags);
936 959
937 fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_ENVID; 960 fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_ENVID;
938 writel(fbi->regs.lcdcon1, S3C2410_LCDCON1); 961 writel(fbi->regs.lcdcon1, fbi->io + S3C2410_LCDCON1);
939 962
940 local_irq_restore(flags); 963 local_irq_restore(flags);
941} 964}
@@ -962,7 +985,10 @@ static int s3c2410fb_remove(struct platform_device *pdev)
962 985
963 irq = platform_get_irq(pdev, 0); 986 irq = platform_get_irq(pdev, 0);
964 free_irq(irq,info); 987 free_irq(irq,info);
965 release_mem_region((unsigned long)S3C24XX_VA_LCD, S3C24XX_SZ_LCD); 988
989 release_resource(info->mem);
990 kfree(info->mem);
991 iounmap(info->io);
966 unregister_framebuffer(fbinfo); 992 unregister_framebuffer(fbinfo);
967 993
968 return 0; 994 return 0;
diff --git a/drivers/video/s3c2410fb.h b/drivers/video/s3c2410fb.h
index f3f8a8e15012..17c7915b7acd 100644
--- a/drivers/video/s3c2410fb.h
+++ b/drivers/video/s3c2410fb.h
@@ -30,6 +30,9 @@ struct s3c2410fb_info {
30 struct device *dev; 30 struct device *dev;
31 struct clk *clk; 31 struct clk *clk;
32 32
33 struct resource *mem;
34 void __iomem *io;
35
33 struct s3c2410fb_mach_info *mach_info; 36 struct s3c2410fb_mach_info *mach_info;
34 37
35 /* raw memory addresses */ 38 /* raw memory addresses */
diff --git a/drivers/video/sbuslib.c b/drivers/video/sbuslib.c
index 34ef859ee414..963a454b7074 100644
--- a/drivers/video/sbuslib.c
+++ b/drivers/video/sbuslib.c
@@ -190,17 +190,6 @@ int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
190EXPORT_SYMBOL(sbusfb_ioctl_helper); 190EXPORT_SYMBOL(sbusfb_ioctl_helper);
191 191
192#ifdef CONFIG_COMPAT 192#ifdef CONFIG_COMPAT
193struct fbcmap32 {
194 int index; /* first element (0 origin) */
195 int count;
196 u32 red;
197 u32 green;
198 u32 blue;
199};
200
201#define FBIOPUTCMAP32 _IOW('F', 3, struct fbcmap32)
202#define FBIOGETCMAP32 _IOW('F', 4, struct fbcmap32)
203
204static int fbiogetputcmap(struct fb_info *info, unsigned int cmd, unsigned long arg) 193static int fbiogetputcmap(struct fb_info *info, unsigned int cmd, unsigned long arg)
205{ 194{
206 struct fbcmap32 __user *argp = (void __user *)arg; 195 struct fbcmap32 __user *argp = (void __user *)arg;
@@ -223,20 +212,6 @@ static int fbiogetputcmap(struct fb_info *info, unsigned int cmd, unsigned long
223 (unsigned long)p); 212 (unsigned long)p);
224} 213}
225 214
226struct fbcursor32 {
227 short set; /* what to set, choose from the list above */
228 short enable; /* cursor on/off */
229 struct fbcurpos pos; /* cursor position */
230 struct fbcurpos hot; /* cursor hot spot */
231 struct fbcmap32 cmap; /* color map info */
232 struct fbcurpos size; /* cursor bit map size */
233 u32 image; /* cursor image bits */
234 u32 mask; /* cursor mask bits */
235};
236
237#define FBIOSCURSOR32 _IOW('F', 24, struct fbcursor32)
238#define FBIOGCURSOR32 _IOW('F', 25, struct fbcursor32)
239
240static int fbiogscursor(struct fb_info *info, unsigned long arg) 215static int fbiogscursor(struct fb_info *info, unsigned long arg)
241{ 216{
242 struct fbcursor __user *p = compat_alloc_user_space(sizeof(*p)); 217 struct fbcursor __user *p = compat_alloc_user_space(sizeof(*p));
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c
index 5a99669232ce..e5a9ddb3c8be 100644
--- a/drivers/video/tcx.c
+++ b/drivers/video/tcx.c
@@ -345,88 +345,82 @@ tcx_init_fix(struct fb_info *info, int linebytes)
345 info->fix.accel = FB_ACCEL_SUN_TCX; 345 info->fix.accel = FB_ACCEL_SUN_TCX;
346} 346}
347 347
348struct all_info { 348static void tcx_unmap_regs(struct of_device *op, struct fb_info *info,
349 struct fb_info info; 349 struct tcx_par *par)
350 struct tcx_par par;
351};
352
353static void tcx_unmap_regs(struct of_device *op, struct all_info *all)
354{ 350{
355 if (all->par.tec) 351 if (par->tec)
356 of_iounmap(&op->resource[7], 352 of_iounmap(&op->resource[7],
357 all->par.tec, sizeof(struct tcx_tec)); 353 par->tec, sizeof(struct tcx_tec));
358 if (all->par.thc) 354 if (par->thc)
359 of_iounmap(&op->resource[9], 355 of_iounmap(&op->resource[9],
360 all->par.thc, sizeof(struct tcx_thc)); 356 par->thc, sizeof(struct tcx_thc));
361 if (all->par.bt) 357 if (par->bt)
362 of_iounmap(&op->resource[8], 358 of_iounmap(&op->resource[8],
363 all->par.bt, sizeof(struct bt_regs)); 359 par->bt, sizeof(struct bt_regs));
364 if (all->par.cplane) 360 if (par->cplane)
365 of_iounmap(&op->resource[4], 361 of_iounmap(&op->resource[4],
366 all->par.cplane, all->par.fbsize * sizeof(u32)); 362 par->cplane, par->fbsize * sizeof(u32));
367 if (all->info.screen_base) 363 if (info->screen_base)
368 of_iounmap(&op->resource[0], 364 of_iounmap(&op->resource[0],
369 all->info.screen_base, all->par.fbsize); 365 info->screen_base, par->fbsize);
370} 366}
371 367
372static int __devinit tcx_init_one(struct of_device *op) 368static int __devinit tcx_init_one(struct of_device *op)
373{ 369{
374 struct device_node *dp = op->node; 370 struct device_node *dp = op->node;
375 struct all_info *all; 371 struct fb_info *info;
372 struct tcx_par *par;
376 int linebytes, i, err; 373 int linebytes, i, err;
377 374
378 all = kzalloc(sizeof(*all), GFP_KERNEL); 375 info = framebuffer_alloc(sizeof(struct tcx_par), &op->dev);
379 if (!all)
380 return -ENOMEM;
381 376
382 spin_lock_init(&all->par.lock); 377 err = -ENOMEM;
378 if (!info)
379 goto out_err;
380 par = info->par;
383 381
384 all->par.lowdepth = 382 spin_lock_init(&par->lock);
383
384 par->lowdepth =
385 (of_find_property(dp, "tcx-8-bit", NULL) != NULL); 385 (of_find_property(dp, "tcx-8-bit", NULL) != NULL);
386 386
387 sbusfb_fill_var(&all->info.var, dp->node, 8); 387 sbusfb_fill_var(&info->var, dp->node, 8);
388 all->info.var.red.length = 8; 388 info->var.red.length = 8;
389 all->info.var.green.length = 8; 389 info->var.green.length = 8;
390 all->info.var.blue.length = 8; 390 info->var.blue.length = 8;
391 391
392 linebytes = of_getintprop_default(dp, "linebytes", 392 linebytes = of_getintprop_default(dp, "linebytes",
393 all->info.var.xres); 393 info->var.xres);
394 all->par.fbsize = PAGE_ALIGN(linebytes * all->info.var.yres); 394 par->fbsize = PAGE_ALIGN(linebytes * info->var.yres);
395 395
396 all->par.tec = of_ioremap(&op->resource[7], 0, 396 par->tec = of_ioremap(&op->resource[7], 0,
397 sizeof(struct tcx_tec), "tcx tec"); 397 sizeof(struct tcx_tec), "tcx tec");
398 all->par.thc = of_ioremap(&op->resource[9], 0, 398 par->thc = of_ioremap(&op->resource[9], 0,
399 sizeof(struct tcx_thc), "tcx thc"); 399 sizeof(struct tcx_thc), "tcx thc");
400 all->par.bt = of_ioremap(&op->resource[8], 0, 400 par->bt = of_ioremap(&op->resource[8], 0,
401 sizeof(struct bt_regs), "tcx dac"); 401 sizeof(struct bt_regs), "tcx dac");
402 all->info.screen_base = of_ioremap(&op->resource[0], 0, 402 info->screen_base = of_ioremap(&op->resource[0], 0,
403 all->par.fbsize, "tcx ram"); 403 par->fbsize, "tcx ram");
404 if (!all->par.tec || !all->par.thc || 404 if (!par->tec || !par->thc ||
405 !all->par.bt || !all->info.screen_base) { 405 !par->bt || !info->screen_base)
406 tcx_unmap_regs(op, all); 406 goto out_unmap_regs;
407 kfree(all); 407
408 return -ENOMEM; 408 memcpy(&par->mmap_map, &__tcx_mmap_map, sizeof(par->mmap_map));
409 } 409 if (!par->lowdepth) {
410 410 par->cplane = of_ioremap(&op->resource[4], 0,
411 memcpy(&all->par.mmap_map, &__tcx_mmap_map, sizeof(all->par.mmap_map)); 411 par->fbsize * sizeof(u32),
412 if (!all->par.lowdepth) {
413 all->par.cplane = of_ioremap(&op->resource[4], 0,
414 all->par.fbsize * sizeof(u32),
415 "tcx cplane"); 412 "tcx cplane");
416 if (!all->par.cplane) { 413 if (!par->cplane)
417 tcx_unmap_regs(op, all); 414 goto out_unmap_regs;
418 kfree(all);
419 return -ENOMEM;
420 }
421 } else { 415 } else {
422 all->par.mmap_map[1].size = SBUS_MMAP_EMPTY; 416 par->mmap_map[1].size = SBUS_MMAP_EMPTY;
423 all->par.mmap_map[4].size = SBUS_MMAP_EMPTY; 417 par->mmap_map[4].size = SBUS_MMAP_EMPTY;
424 all->par.mmap_map[5].size = SBUS_MMAP_EMPTY; 418 par->mmap_map[5].size = SBUS_MMAP_EMPTY;
425 all->par.mmap_map[6].size = SBUS_MMAP_EMPTY; 419 par->mmap_map[6].size = SBUS_MMAP_EMPTY;
426 } 420 }
427 421
428 all->par.physbase = 0; 422 par->physbase = 0;
429 all->par.which_io = op->resource[0].flags & IORESOURCE_BITS; 423 par->which_io = op->resource[0].flags & IORESOURCE_BITS;
430 424
431 for (i = 0; i < TCX_MMAP_ENTRIES; i++) { 425 for (i = 0; i < TCX_MMAP_ENTRIES; i++) {
432 int j; 426 int j;
@@ -444,53 +438,54 @@ static int __devinit tcx_init_one(struct of_device *op)
444 j = i; 438 j = i;
445 break; 439 break;
446 }; 440 };
447 all->par.mmap_map[i].poff = op->resource[j].start; 441 par->mmap_map[i].poff = op->resource[j].start;
448 } 442 }
449 443
450 all->info.flags = FBINFO_DEFAULT; 444 info->flags = FBINFO_DEFAULT;
451 all->info.fbops = &tcx_ops; 445 info->fbops = &tcx_ops;
452 all->info.par = &all->par;
453 446
454 /* Initialize brooktree DAC. */ 447 /* Initialize brooktree DAC. */
455 sbus_writel(0x04 << 24, &all->par.bt->addr); /* color planes */ 448 sbus_writel(0x04 << 24, &par->bt->addr); /* color planes */
456 sbus_writel(0xff << 24, &all->par.bt->control); 449 sbus_writel(0xff << 24, &par->bt->control);
457 sbus_writel(0x05 << 24, &all->par.bt->addr); 450 sbus_writel(0x05 << 24, &par->bt->addr);
458 sbus_writel(0x00 << 24, &all->par.bt->control); 451 sbus_writel(0x00 << 24, &par->bt->control);
459 sbus_writel(0x06 << 24, &all->par.bt->addr); /* overlay plane */ 452 sbus_writel(0x06 << 24, &par->bt->addr); /* overlay plane */
460 sbus_writel(0x73 << 24, &all->par.bt->control); 453 sbus_writel(0x73 << 24, &par->bt->control);
461 sbus_writel(0x07 << 24, &all->par.bt->addr); 454 sbus_writel(0x07 << 24, &par->bt->addr);
462 sbus_writel(0x00 << 24, &all->par.bt->control); 455 sbus_writel(0x00 << 24, &par->bt->control);
463 456
464 tcx_reset(&all->info); 457 tcx_reset(info);
465
466 tcx_blank(FB_BLANK_UNBLANK, &all->info);
467
468 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
469 tcx_unmap_regs(op, all);
470 kfree(all);
471 return -ENOMEM;
472 }
473 458
474 fb_set_cmap(&all->info.cmap, &all->info); 459 tcx_blank(FB_BLANK_UNBLANK, info);
475 tcx_init_fix(&all->info, linebytes);
476 460
477 err = register_framebuffer(&all->info); 461 if (fb_alloc_cmap(&info->cmap, 256, 0))
478 if (err < 0) { 462 goto out_unmap_regs;
479 fb_dealloc_cmap(&all->info.cmap); 463
480 tcx_unmap_regs(op, all); 464 fb_set_cmap(&info->cmap, info);
481 kfree(all); 465 tcx_init_fix(info, linebytes);
482 return err; 466
483 } 467 err = register_framebuffer(info);
468 if (err < 0)
469 goto out_dealloc_cmap;
484 470
485 dev_set_drvdata(&op->dev, all); 471 dev_set_drvdata(&op->dev, info);
486 472
487 printk("%s: TCX at %lx:%lx, %s\n", 473 printk("%s: TCX at %lx:%lx, %s\n",
488 dp->full_name, 474 dp->full_name,
489 all->par.which_io, 475 par->which_io,
490 op->resource[0].start, 476 op->resource[0].start,
491 all->par.lowdepth ? "8-bit only" : "24-bit depth"); 477 par->lowdepth ? "8-bit only" : "24-bit depth");
492 478
493 return 0; 479 return 0;
480
481out_dealloc_cmap:
482 fb_dealloc_cmap(&info->cmap);
483
484out_unmap_regs:
485 tcx_unmap_regs(op, info, par);
486
487out_err:
488 return err;
494} 489}
495 490
496static int __devinit tcx_probe(struct of_device *dev, const struct of_device_id *match) 491static int __devinit tcx_probe(struct of_device *dev, const struct of_device_id *match)
@@ -502,14 +497,15 @@ static int __devinit tcx_probe(struct of_device *dev, const struct of_device_id
502 497
503static int __devexit tcx_remove(struct of_device *op) 498static int __devexit tcx_remove(struct of_device *op)
504{ 499{
505 struct all_info *all = dev_get_drvdata(&op->dev); 500 struct fb_info *info = dev_get_drvdata(&op->dev);
501 struct tcx_par *par = info->par;
506 502
507 unregister_framebuffer(&all->info); 503 unregister_framebuffer(info);
508 fb_dealloc_cmap(&all->info.cmap); 504 fb_dealloc_cmap(&info->cmap);
509 505
510 tcx_unmap_regs(op, all); 506 tcx_unmap_regs(op, info, par);
511 507
512 kfree(all); 508 framebuffer_release(info);
513 509
514 dev_set_drvdata(&op->dev, NULL); 510 dev_set_drvdata(&op->dev, NULL);
515 511
diff --git a/drivers/video/tgafb.c b/drivers/video/tgafb.c
index 89facb73edfc..d292a37ec7d6 100644
--- a/drivers/video/tgafb.c
+++ b/drivers/video/tgafb.c
@@ -849,7 +849,7 @@ tgafb_clut_imageblit(struct fb_info *info, const struct fb_image *image)
849 u32 *palette = ((u32 *)info->pseudo_palette); 849 u32 *palette = ((u32 *)info->pseudo_palette);
850 unsigned long pos, line_length, i, j; 850 unsigned long pos, line_length, i, j;
851 const unsigned char *data; 851 const unsigned char *data;
852 void *regs_base, *fb_base; 852 void __iomem *regs_base, *fb_base;
853 853
854 dx = image->dx; 854 dx = image->dx;
855 dy = image->dy; 855 dy = image->dy;
diff --git a/drivers/video/tx3912fb.c b/drivers/video/tx3912fb.c
deleted file mode 100644
index e6f7c78da68b..000000000000
--- a/drivers/video/tx3912fb.c
+++ /dev/null
@@ -1,326 +0,0 @@
1/*
2 * drivers/video/tx3912fb.c
3 *
4 * Copyright (C) 1999 Harald Koerfgen
5 * Copyright (C) 2001 Steven Hill (sjhill@realitydiluted.com)
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive for
9 * more details.
10 *
11 * Framebuffer for LCD controller in TMPR3912/05 and PR31700 processors
12 */
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/errno.h>
16#include <linux/string.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/init.h>
20#include <linux/pm.h>
21#include <linux/fb.h>
22#include <asm/io.h>
23#include <asm/bootinfo.h>
24#include <asm/uaccess.h>
25#include <asm/tx3912.h>
26#include <video/tx3912.h>
27
28/*
29 * Frame buffer, palette and console structures
30 */
31static struct fb_info fb_info;
32static u32 cfb8[16];
33
34static struct fb_fix_screeninfo tx3912fb_fix __initdata = {
35 .id = "tx3912fb",
36 .smem_len = ((240 * 320)/2),
37 .type = FB_TYPE_PACKED_PIXELS,
38 .visual = FB_VISUAL_TRUECOLOR,
39 .xpanstep = 1,
40 .ypanstep = 1,
41 .ywrapstep = 1,
42 .accel = FB_ACCEL_NONE,
43};
44
45static struct fb_var_screeninfo tx3912fb_var = {
46 .xres = 240,
47 .yres = 320,
48 .xres_virtual = 240,
49 .yres_virtual = 320,
50 .bits_per_pixel =4,
51 .red = { 0, 4, 0 }, /* ??? */
52 .green = { 0, 4, 0 },
53 .blue = { 0, 4, 0 },
54 .activate = FB_ACTIVATE_NOW,
55 .width = -1,
56 .height = -1,
57 .pixclock = 20000,
58 .left_margin = 64,
59 .right_margin = 64,
60 .upper_margin = 32,
61 .lower_margin = 32,
62 .hsync_len = 64,
63 .vsync_len = 2,
64 .vmode = FB_VMODE_NONINTERLACED,
65};
66
67/*
68 * Interface used by the world
69 */
70int tx3912fb_init(void);
71
72static int tx3912fb_setcolreg(u_int regno, u_int red, u_int green,
73 u_int blue, u_int transp,
74 struct fb_info *info);
75
76/*
77 * Macros
78 */
79#define get_line_length(xres_virtual, bpp) \
80 (u_long) (((int) xres_virtual * (int) bpp + 7) >> 3)
81
82/*
83 * Frame buffer operations structure used by console driver
84 */
85static struct fb_ops tx3912fb_ops = {
86 .owner = THIS_MODULE,
87 .fb_setcolreg = tx3912fb_setcolreg,
88 .fb_fillrect = cfb_fillrect,
89 .fb_copyarea = cfb_copyarea,
90 .fb_imageblit = cfb_imageblit,
91};
92
93static int tx3912fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
94{
95 /*
96 * Memory limit
97 */
98 line_length =
99 get_line_length(var->xres_virtual, var->bits_per_pixel);
100 if ((line_length * var->yres_virtual) > info->fix.smem_len)
101 return -ENOMEM;
102
103 return 0;
104}
105
106static int tx3912fb_set_par(struct fb_info *info)
107{
108 u_long tx3912fb_paddr = 0;
109
110 /* Disable the video logic */
111 outl(inl(TX3912_VIDEO_CTRL1) &
112 ~(TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON),
113 TX3912_VIDEO_CTRL1);
114 udelay(200);
115
116 /* Set start address for DMA transfer */
117 outl(tx3912fb_paddr, TX3912_VIDEO_CTRL3);
118
119 /* Set end address for DMA transfer */
120 outl((tx3912fb_paddr + tx3912fb_fix.smem_len + 1), TX3912_VIDEO_CTRL4);
121
122 /* Set the pixel depth */
123 switch (info->var.bits_per_pixel) {
124 case 1:
125 /* Monochrome */
126 outl(inl(TX3912_VIDEO_CTRL1) &
127 ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
128 info->fix.visual = FB_VISUAL_MONO10;
129 break;
130 case 4:
131 /* 4-bit gray */
132 outl(inl(TX3912_VIDEO_CTRL1) &
133 ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
134 outl(inl(TX3912_VIDEO_CTRL1) |
135 TX3912_VIDEO_CTRL1_BITSEL_4BIT_GRAY,
136 TX3912_VIDEO_CTRL1);
137 info->fix.visual = FB_VISUAL_TRUECOLOR;
138 break;
139 case 8:
140 /* 8-bit color */
141 outl(inl(TX3912_VIDEO_CTRL1) &
142 ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
143 outl(inl(TX3912_VIDEO_CTRL1) |
144 TX3912_VIDEO_CTRL1_BITSEL_8BIT_COLOR,
145 TX3912_VIDEO_CTRL1);
146 info->fix.visual = FB_VISUAL_TRUECOLOR;
147 break;
148 case 2:
149 default:
150 /* 2-bit gray */
151 outl(inl(TX3912_VIDEO_CTRL1) &
152 ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
153 outl(inl(TX3912_VIDEO_CTRL1) |
154 TX3912_VIDEO_CTRL1_BITSEL_2BIT_GRAY,
155 TX3912_VIDEO_CTRL1);
156 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
157 break;
158 }
159
160 /* Enable the video clock */
161 outl(inl(TX3912_CLK_CTRL) | TX3912_CLK_CTRL_ENVIDCLK,
162 TX3912_CLK_CTRL);
163
164 /* Unfreeze video logic and enable DF toggle */
165 outl(inl(TX3912_VIDEO_CTRL1) &
166 ~(TX3912_VIDEO_CTRL1_ENFREEZEFRAME |
167 TX3912_VIDEO_CTRL1_DFMODE)
168 , TX3912_VIDEO_CTRL1);
169 udelay(200);
170
171 /* Enable the video logic */
172 outl(inl(TX3912_VIDEO_CTRL1) |
173 (TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON),
174 TX3912_VIDEO_CTRL1);
175
176 info->fix.line_length = get_line_length(var->xres_virtual,
177 var->bits_per_pixel);
178}
179
180/*
181 * Set a single color register
182 */
183static int tx3912fb_setcolreg(u_int regno, u_int red, u_int green,
184 u_int blue, u_int transp,
185 struct fb_info *info)
186{
187 if (regno > 255)
188 return 1;
189
190 if (regno < 16)
191 ((u32 *)(info->pseudo_palette))[regno] = ((red & 0xe000) >> 8)
192 | ((green & 0xe000) >> 11)
193 | ((blue & 0xc000) >> 14);
194 return 0;
195}
196
197int __init tx3912fb_setup(char *options);
198
199/*
200 * Initialization of the framebuffer
201 */
202int __init tx3912fb_init(void)
203{
204 u_long tx3912fb_paddr = 0;
205 int size = (info->var.bits_per_pixel == 8) ? 256 : 16;
206 char *option = NULL;
207
208 if (fb_get_options("tx3912fb", &option))
209 return -ENODEV;
210 tx3912fb_setup(option);
211
212 /* Disable the video logic */
213 outl(inl(TX3912_VIDEO_CTRL1) &
214 ~(TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON),
215 TX3912_VIDEO_CTRL1);
216 udelay(200);
217
218 /* Set start address for DMA transfer */
219 outl(tx3912fb_paddr, TX3912_VIDEO_CTRL3);
220
221 /* Set end address for DMA transfer */
222 outl((tx3912fb_paddr + tx3912fb_fix.smem_len + 1), TX3912_VIDEO_CTRL4);
223
224 /* Set the pixel depth */
225 switch (tx3912fb_var.bits_per_pixel) {
226 case 1:
227 /* Monochrome */
228 outl(inl(TX3912_VIDEO_CTRL1) &
229 ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
230 tx3912fb_fix.visual = FB_VISUAL_MONO10;
231 break;
232 case 4:
233 /* 4-bit gray */
234 outl(inl(TX3912_VIDEO_CTRL1) &
235 ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
236 outl(inl(TX3912_VIDEO_CTRL1) |
237 TX3912_VIDEO_CTRL1_BITSEL_4BIT_GRAY,
238 TX3912_VIDEO_CTRL1);
239 tx3912fb_fix.visual = FB_VISUAL_TRUECOLOR;
240 tx3912fb_fix.grayscale = 1;
241 break;
242 case 8:
243 /* 8-bit color */
244 outl(inl(TX3912_VIDEO_CTRL1) &
245 ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
246 outl(inl(TX3912_VIDEO_CTRL1) |
247 TX3912_VIDEO_CTRL1_BITSEL_8BIT_COLOR,
248 TX3912_VIDEO_CTRL1);
249 tx3912fb_fix.visual = FB_VISUAL_TRUECOLOR;
250 break;
251 case 2:
252 default:
253 /* 2-bit gray */
254 outl(inl(TX3912_VIDEO_CTRL1) &
255 ~TX3912_VIDEO_CTRL1_BITSEL_MASK, TX3912_VIDEO_CTRL1);
256 outl(inl(TX3912_VIDEO_CTRL1) |
257 TX3912_VIDEO_CTRL1_BITSEL_2BIT_GRAY,
258 TX3912_VIDEO_CTRL1);
259 tx3912fb_fix.visual = FB_VISUAL_PSEUDOCOLOR;
260 tx3912fb_fix.grayscale = 1;
261 break;
262 }
263
264 /* Enable the video clock */
265 outl(inl(TX3912_CLK_CTRL) | TX3912_CLK_CTRL_ENVIDCLK,
266 TX3912_CLK_CTRL);
267
268 /* Unfreeze video logic and enable DF toggle */
269 outl(inl(TX3912_VIDEO_CTRL1) &
270 ~(TX3912_VIDEO_CTRL1_ENFREEZEFRAME | TX3912_VIDEO_CTRL1_DFMODE),
271 TX3912_VIDEO_CTRL1);
272 udelay(200);
273
274 /* Clear the framebuffer */
275 memset((void *) tx3912fb_fix.smem_start, 0xff, tx3912fb_fix.smem_len);
276 udelay(200);
277
278 /* Enable the video logic */
279 outl(inl(TX3912_VIDEO_CTRL1) |
280 (TX3912_VIDEO_CTRL1_ENVID | TX3912_VIDEO_CTRL1_DISPON),
281 TX3912_VIDEO_CTRL1);
282
283 /*
284 * Memory limit
285 */
286 tx3912fb_fix.line_length =
287 get_line_length(tx3912fb_var.xres_virtual, tx3912fb_var.bits_per_pixel);
288 if ((tx3912fb_fix.line_length * tx3912fb_var.yres_virtual) > tx3912fb_fix.smem_len)
289 return -ENOMEM;
290
291 fb_info.fbops = &tx3912fb_ops;
292 fb_info.var = tx3912fb_var;
293 fb_info.fix = tx3912fb_fix;
294 fb_info.pseudo_palette = cfb8;
295 fb_info.flags = FBINFO_DEFAULT;
296
297 /* Clear the framebuffer */
298 memset((void *) fb_info.fix.smem_start, 0xff, fb_info.fix.smem_len);
299 udelay(200);
300
301 fb_alloc_cmap(&info->cmap, size, 0);
302
303 if (register_framebuffer(&fb_info) < 0)
304 return -1;
305
306 printk(KERN_INFO "fb%d: TX3912 frame buffer using %uKB.\n",
307 fb_info.node, (u_int) (fb_info.fix.smem_len >> 10));
308 return 0;
309}
310
311int __init tx3912fb_setup(char *options)
312{
313 char *this_opt;
314
315 if (!options || !*options)
316 return 0;
317
318 while ((this_opt = strsep(&options, ","))) {
319 if (!strncmp(options, "bpp:", 4))
320 tx3912fb_var.bits_per_pixel = simple_strtoul(options+4, NULL, 0);
321 }
322 return 0;
323}
324
325module_init(tx3912fb_init);
326MODULE_LICENSE("GPL");
diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
index 1d29a89a86b4..6ef9733a18d4 100644
--- a/drivers/video/xilinxfb.c
+++ b/drivers/video/xilinxfb.c
@@ -79,7 +79,7 @@
79/* 79/*
80 * Here are the default fb_fix_screeninfo and fb_var_screeninfo structures 80 * Here are the default fb_fix_screeninfo and fb_var_screeninfo structures
81 */ 81 */
82static struct fb_fix_screeninfo xilinx_fb_fix __initdata = { 82static struct fb_fix_screeninfo xilinx_fb_fix = {
83 .id = "Xilinx", 83 .id = "Xilinx",
84 .type = FB_TYPE_PACKED_PIXELS, 84 .type = FB_TYPE_PACKED_PIXELS,
85 .visual = FB_VISUAL_TRUECOLOR, 85 .visual = FB_VISUAL_TRUECOLOR,
@@ -88,7 +88,7 @@ static struct fb_fix_screeninfo xilinx_fb_fix __initdata = {
88 .accel = FB_ACCEL_NONE 88 .accel = FB_ACCEL_NONE
89}; 89};
90 90
91static struct fb_var_screeninfo xilinx_fb_var __initdata = { 91static struct fb_var_screeninfo xilinx_fb_var = {
92 .xres = XRES, 92 .xres = XRES,
93 .yres = YRES, 93 .yres = YRES,
94 .xres_virtual = XRES_VIRTUAL, 94 .xres_virtual = XRES_VIRTUAL,
@@ -212,11 +212,6 @@ xilinxfb_drv_probe(struct device *dev)
212 pdev = to_platform_device(dev); 212 pdev = to_platform_device(dev);
213 pdata = pdev->dev.platform_data; 213 pdata = pdev->dev.platform_data;
214 214
215 if (pdata == NULL) {
216 printk(KERN_ERR "Couldn't find platform data.\n");
217 return -EFAULT;
218 }
219
220 drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL); 215 drvdata = kzalloc(sizeof(*drvdata), GFP_KERNEL);
221 if (!drvdata) { 216 if (!drvdata) {
222 printk(KERN_ERR "Couldn't allocate device private record\n"); 217 printk(KERN_ERR "Couldn't allocate device private record\n");
@@ -258,11 +253,9 @@ xilinxfb_drv_probe(struct device *dev)
258 xilinx_fb_out_be32(drvdata, REG_FB_ADDR, drvdata->fb_phys); 253 xilinx_fb_out_be32(drvdata, REG_FB_ADDR, drvdata->fb_phys);
259 254
260 /* Turn on the display */ 255 /* Turn on the display */
261 if (pdata->rotate_screen) { 256 drvdata->reg_ctrl_default = REG_CTRL_ENABLE;
262 drvdata->reg_ctrl_default = REG_CTRL_ENABLE | REG_CTRL_ROTATE; 257 if (pdata && pdata->rotate_screen)
263 } else { 258 drvdata->reg_ctrl_default |= REG_CTRL_ROTATE;
264 drvdata->reg_ctrl_default = REG_CTRL_ENABLE;
265 }
266 xilinx_fb_out_be32(drvdata, REG_CTRL, drvdata->reg_ctrl_default); 259 xilinx_fb_out_be32(drvdata, REG_CTRL, drvdata->reg_ctrl_default);
267 260
268 /* Fill struct fb_info */ 261 /* Fill struct fb_info */
@@ -281,8 +274,10 @@ xilinxfb_drv_probe(struct device *dev)
281 } 274 }
282 275
283 drvdata->info.flags = FBINFO_DEFAULT; 276 drvdata->info.flags = FBINFO_DEFAULT;
284 xilinx_fb_var.height = pdata->screen_height_mm; 277 if (pdata) {
285 xilinx_fb_var.width = pdata->screen_width_mm; 278 xilinx_fb_var.height = pdata->screen_height_mm;
279 xilinx_fb_var.width = pdata->screen_width_mm;
280 }
286 drvdata->info.var = xilinx_fb_var; 281 drvdata->info.var = xilinx_fb_var;
287 282
288 /* Register new frame buffer */ 283 /* Register new frame buffer */
diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c
index 763bc73e5070..4b696641ce33 100644
--- a/drivers/w1/masters/ds1wm.c
+++ b/drivers/w1/masters/ds1wm.c
@@ -85,7 +85,7 @@ static struct {
85}; 85};
86 86
87struct ds1wm_data { 87struct ds1wm_data {
88 void *map; 88 void __iomem *map;
89 int bus_shift; /* # of shifts to calc register offsets */ 89 int bus_shift; /* # of shifts to calc register offsets */
90 struct platform_device *pdev; 90 struct platform_device *pdev;
91 struct ds1wm_platform_data *pdata; 91 struct ds1wm_platform_data *pdata;
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index 9e943fbce81b..227d53b12a5c 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -782,8 +782,8 @@ static int process_msg(void)
782 msg->u.watch.vec = split(body, msg->hdr.len, 782 msg->u.watch.vec = split(body, msg->hdr.len,
783 &msg->u.watch.vec_size); 783 &msg->u.watch.vec_size);
784 if (IS_ERR(msg->u.watch.vec)) { 784 if (IS_ERR(msg->u.watch.vec)) {
785 kfree(msg);
786 err = PTR_ERR(msg->u.watch.vec); 785 err = PTR_ERR(msg->u.watch.vec);
786 kfree(msg);
787 goto out; 787 goto out;
788 } 788 }
789 789
diff --git a/fs/afs/flock.c b/fs/afs/flock.c
index 4f77f3caee97..af6952e39a18 100644
--- a/fs/afs/flock.c
+++ b/fs/afs/flock.c
@@ -19,6 +19,7 @@ static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl);
19static void afs_fl_release_private(struct file_lock *fl); 19static void afs_fl_release_private(struct file_lock *fl);
20 20
21static struct workqueue_struct *afs_lock_manager; 21static struct workqueue_struct *afs_lock_manager;
22static DEFINE_MUTEX(afs_lock_manager_mutex);
22 23
23static struct file_lock_operations afs_lock_ops = { 24static struct file_lock_operations afs_lock_ops = {
24 .fl_copy_lock = afs_fl_copy_lock, 25 .fl_copy_lock = afs_fl_copy_lock,
@@ -30,12 +31,20 @@ static struct file_lock_operations afs_lock_ops = {
30 */ 31 */
31static int afs_init_lock_manager(void) 32static int afs_init_lock_manager(void)
32{ 33{
34 int ret;
35
36 ret = 0;
33 if (!afs_lock_manager) { 37 if (!afs_lock_manager) {
34 afs_lock_manager = create_singlethread_workqueue("kafs_lockd"); 38 mutex_lock(&afs_lock_manager_mutex);
35 if (!afs_lock_manager) 39 if (!afs_lock_manager) {
36 return -ENOMEM; 40 afs_lock_manager =
41 create_singlethread_workqueue("kafs_lockd");
42 if (!afs_lock_manager)
43 ret = -ENOMEM;
44 }
45 mutex_unlock(&afs_lock_manager_mutex);
37 } 46 }
38 return 0; 47 return ret;
39} 48}
40 49
41/* 50/*
@@ -68,6 +77,29 @@ static void afs_schedule_lock_extension(struct afs_vnode *vnode)
68} 77}
69 78
70/* 79/*
80 * grant one or more locks (readlocks are allowed to jump the queue if the
81 * first lock in the queue is itself a readlock)
82 * - the caller must hold the vnode lock
83 */
84static void afs_grant_locks(struct afs_vnode *vnode, struct file_lock *fl)
85{
86 struct file_lock *p, *_p;
87
88 list_move_tail(&fl->fl_u.afs.link, &vnode->granted_locks);
89 if (fl->fl_type == F_RDLCK) {
90 list_for_each_entry_safe(p, _p, &vnode->pending_locks,
91 fl_u.afs.link) {
92 if (p->fl_type == F_RDLCK) {
93 p->fl_u.afs.state = AFS_LOCK_GRANTED;
94 list_move_tail(&p->fl_u.afs.link,
95 &vnode->granted_locks);
96 wake_up(&p->fl_wait);
97 }
98 }
99 }
100}
101
102/*
71 * do work for a lock, including: 103 * do work for a lock, including:
72 * - probing for a lock we're waiting on but didn't get immediately 104 * - probing for a lock we're waiting on but didn't get immediately
73 * - extending a lock that's close to timing out 105 * - extending a lock that's close to timing out
@@ -172,8 +204,7 @@ void afs_lock_work(struct work_struct *work)
172 struct file_lock, fl_u.afs.link) == fl) { 204 struct file_lock, fl_u.afs.link) == fl) {
173 fl->fl_u.afs.state = ret; 205 fl->fl_u.afs.state = ret;
174 if (ret == AFS_LOCK_GRANTED) 206 if (ret == AFS_LOCK_GRANTED)
175 list_move_tail(&fl->fl_u.afs.link, 207 afs_grant_locks(vnode, fl);
176 &vnode->granted_locks);
177 else 208 else
178 list_del_init(&fl->fl_u.afs.link); 209 list_del_init(&fl->fl_u.afs.link);
179 wake_up(&fl->fl_wait); 210 wake_up(&fl->fl_wait);
@@ -258,49 +289,50 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl)
258 289
259 spin_lock(&vnode->lock); 290 spin_lock(&vnode->lock);
260 291
261 if (list_empty(&vnode->pending_locks)) { 292 /* if we've already got a readlock on the server then we can instantly
262 /* if there's no-one else with a lock on this vnode, then we 293 * grant another readlock, irrespective of whether there are any
263 * need to ask the server for a lock */ 294 * pending writelocks */
264 if (list_empty(&vnode->granted_locks)) { 295 if (type == AFS_LOCK_READ &&
265 _debug("not locked"); 296 vnode->flags & (1 << AFS_VNODE_READLOCKED)) {
266 ASSERTCMP(vnode->flags & 297 _debug("instant readlock");
267 ((1 << AFS_VNODE_LOCKING) | 298 ASSERTCMP(vnode->flags &
268 (1 << AFS_VNODE_READLOCKED) | 299 ((1 << AFS_VNODE_LOCKING) |
269 (1 << AFS_VNODE_WRITELOCKED)), ==, 0); 300 (1 << AFS_VNODE_WRITELOCKED)), ==, 0);
270 list_add_tail(&fl->fl_u.afs.link, &vnode->pending_locks); 301 ASSERT(!list_empty(&vnode->granted_locks));
271 set_bit(AFS_VNODE_LOCKING, &vnode->flags); 302 goto sharing_existing_lock;
272 spin_unlock(&vnode->lock); 303 }
273 304
274 ret = afs_vnode_set_lock(vnode, key, type); 305 /* if there's no-one else with a lock on this vnode, then we need to
275 clear_bit(AFS_VNODE_LOCKING, &vnode->flags); 306 * ask the server for a lock */
276 switch (ret) { 307 if (list_empty(&vnode->pending_locks) &&
277 case 0: 308 list_empty(&vnode->granted_locks)) {
278 goto acquired_server_lock; 309 _debug("not locked");
279 case -EWOULDBLOCK: 310 ASSERTCMP(vnode->flags &
280 spin_lock(&vnode->lock); 311 ((1 << AFS_VNODE_LOCKING) |
281 ASSERT(list_empty(&vnode->granted_locks)); 312 (1 << AFS_VNODE_READLOCKED) |
282 ASSERTCMP(vnode->pending_locks.next, ==, 313 (1 << AFS_VNODE_WRITELOCKED)), ==, 0);
283 &fl->fl_u.afs.link); 314 list_add_tail(&fl->fl_u.afs.link, &vnode->pending_locks);
284 goto wait; 315 set_bit(AFS_VNODE_LOCKING, &vnode->flags);
285 default: 316 spin_unlock(&vnode->lock);
286 spin_lock(&vnode->lock);
287 list_del_init(&fl->fl_u.afs.link);
288 spin_unlock(&vnode->lock);
289 goto error;
290 }
291 }
292 317
293 /* if we've already got a readlock on the server and no waiting 318 ret = afs_vnode_set_lock(vnode, key, type);
294 * writelocks, then we might be able to instantly grant another 319 clear_bit(AFS_VNODE_LOCKING, &vnode->flags);
295 * readlock */ 320 switch (ret) {
296 if (type == AFS_LOCK_READ && 321 case 0:
297 vnode->flags & (1 << AFS_VNODE_READLOCKED)) { 322 _debug("acquired");
298 _debug("instant readlock"); 323 goto acquired_server_lock;
299 ASSERTCMP(vnode->flags & 324 case -EWOULDBLOCK:
300 ((1 << AFS_VNODE_LOCKING) | 325 _debug("would block");
301 (1 << AFS_VNODE_WRITELOCKED)), ==, 0); 326 spin_lock(&vnode->lock);
302 ASSERT(!list_empty(&vnode->granted_locks)); 327 ASSERT(list_empty(&vnode->granted_locks));
303 goto sharing_existing_lock; 328 ASSERTCMP(vnode->pending_locks.next, ==,
329 &fl->fl_u.afs.link);
330 goto wait;
331 default:
332 spin_lock(&vnode->lock);
333 list_del_init(&fl->fl_u.afs.link);
334 spin_unlock(&vnode->lock);
335 goto error;
304 } 336 }
305 } 337 }
306 338
diff --git a/fs/bio.c b/fs/bio.c
index 0d2c2d38b7ba..29a44c1b64c6 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -230,7 +230,7 @@ void bio_put(struct bio *bio)
230 } 230 }
231} 231}
232 232
233inline int bio_phys_segments(request_queue_t *q, struct bio *bio) 233inline int bio_phys_segments(struct request_queue *q, struct bio *bio)
234{ 234{
235 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID))) 235 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID)))
236 blk_recount_segments(q, bio); 236 blk_recount_segments(q, bio);
@@ -238,7 +238,7 @@ inline int bio_phys_segments(request_queue_t *q, struct bio *bio)
238 return bio->bi_phys_segments; 238 return bio->bi_phys_segments;
239} 239}
240 240
241inline int bio_hw_segments(request_queue_t *q, struct bio *bio) 241inline int bio_hw_segments(struct request_queue *q, struct bio *bio)
242{ 242{
243 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID))) 243 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID)))
244 blk_recount_segments(q, bio); 244 blk_recount_segments(q, bio);
@@ -257,7 +257,7 @@ inline int bio_hw_segments(request_queue_t *q, struct bio *bio)
257 */ 257 */
258void __bio_clone(struct bio *bio, struct bio *bio_src) 258void __bio_clone(struct bio *bio, struct bio *bio_src)
259{ 259{
260 request_queue_t *q = bdev_get_queue(bio_src->bi_bdev); 260 struct request_queue *q = bdev_get_queue(bio_src->bi_bdev);
261 261
262 memcpy(bio->bi_io_vec, bio_src->bi_io_vec, 262 memcpy(bio->bi_io_vec, bio_src->bi_io_vec,
263 bio_src->bi_max_vecs * sizeof(struct bio_vec)); 263 bio_src->bi_max_vecs * sizeof(struct bio_vec));
@@ -303,7 +303,7 @@ struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask)
303 */ 303 */
304int bio_get_nr_vecs(struct block_device *bdev) 304int bio_get_nr_vecs(struct block_device *bdev)
305{ 305{
306 request_queue_t *q = bdev_get_queue(bdev); 306 struct request_queue *q = bdev_get_queue(bdev);
307 int nr_pages; 307 int nr_pages;
308 308
309 nr_pages = ((q->max_sectors << 9) + PAGE_SIZE - 1) >> PAGE_SHIFT; 309 nr_pages = ((q->max_sectors << 9) + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -315,7 +315,7 @@ int bio_get_nr_vecs(struct block_device *bdev)
315 return nr_pages; 315 return nr_pages;
316} 316}
317 317
318static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page 318static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page
319 *page, unsigned int len, unsigned int offset, 319 *page, unsigned int len, unsigned int offset,
320 unsigned short max_sectors) 320 unsigned short max_sectors)
321{ 321{
@@ -425,7 +425,7 @@ static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page
425 * smaller than PAGE_SIZE, so it is always possible to add a single 425 * smaller than PAGE_SIZE, so it is always possible to add a single
426 * page to an empty bio. This should only be used by REQ_PC bios. 426 * page to an empty bio. This should only be used by REQ_PC bios.
427 */ 427 */
428int bio_add_pc_page(request_queue_t *q, struct bio *bio, struct page *page, 428int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page *page,
429 unsigned int len, unsigned int offset) 429 unsigned int len, unsigned int offset)
430{ 430{
431 return __bio_add_page(q, bio, page, len, offset, q->max_hw_sectors); 431 return __bio_add_page(q, bio, page, len, offset, q->max_hw_sectors);
@@ -523,7 +523,7 @@ int bio_uncopy_user(struct bio *bio)
523 * to/from kernel pages as necessary. Must be paired with 523 * to/from kernel pages as necessary. Must be paired with
524 * call bio_uncopy_user() on io completion. 524 * call bio_uncopy_user() on io completion.
525 */ 525 */
526struct bio *bio_copy_user(request_queue_t *q, unsigned long uaddr, 526struct bio *bio_copy_user(struct request_queue *q, unsigned long uaddr,
527 unsigned int len, int write_to_vm) 527 unsigned int len, int write_to_vm)
528{ 528{
529 unsigned long end = (uaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; 529 unsigned long end = (uaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
@@ -600,7 +600,7 @@ out_bmd:
600 return ERR_PTR(ret); 600 return ERR_PTR(ret);
601} 601}
602 602
603static struct bio *__bio_map_user_iov(request_queue_t *q, 603static struct bio *__bio_map_user_iov(struct request_queue *q,
604 struct block_device *bdev, 604 struct block_device *bdev,
605 struct sg_iovec *iov, int iov_count, 605 struct sg_iovec *iov, int iov_count,
606 int write_to_vm) 606 int write_to_vm)
@@ -712,7 +712,7 @@ static struct bio *__bio_map_user_iov(request_queue_t *q,
712 712
713/** 713/**
714 * bio_map_user - map user address into bio 714 * bio_map_user - map user address into bio
715 * @q: the request_queue_t for the bio 715 * @q: the struct request_queue for the bio
716 * @bdev: destination block device 716 * @bdev: destination block device
717 * @uaddr: start of user address 717 * @uaddr: start of user address
718 * @len: length in bytes 718 * @len: length in bytes
@@ -721,7 +721,7 @@ static struct bio *__bio_map_user_iov(request_queue_t *q,
721 * Map the user space address into a bio suitable for io to a block 721 * Map the user space address into a bio suitable for io to a block
722 * device. Returns an error pointer in case of error. 722 * device. Returns an error pointer in case of error.
723 */ 723 */
724struct bio *bio_map_user(request_queue_t *q, struct block_device *bdev, 724struct bio *bio_map_user(struct request_queue *q, struct block_device *bdev,
725 unsigned long uaddr, unsigned int len, int write_to_vm) 725 unsigned long uaddr, unsigned int len, int write_to_vm)
726{ 726{
727 struct sg_iovec iov; 727 struct sg_iovec iov;
@@ -734,7 +734,7 @@ struct bio *bio_map_user(request_queue_t *q, struct block_device *bdev,
734 734
735/** 735/**
736 * bio_map_user_iov - map user sg_iovec table into bio 736 * bio_map_user_iov - map user sg_iovec table into bio
737 * @q: the request_queue_t for the bio 737 * @q: the struct request_queue for the bio
738 * @bdev: destination block device 738 * @bdev: destination block device
739 * @iov: the iovec. 739 * @iov: the iovec.
740 * @iov_count: number of elements in the iovec 740 * @iov_count: number of elements in the iovec
@@ -743,7 +743,7 @@ struct bio *bio_map_user(request_queue_t *q, struct block_device *bdev,
743 * Map the user space address into a bio suitable for io to a block 743 * Map the user space address into a bio suitable for io to a block
744 * device. Returns an error pointer in case of error. 744 * device. Returns an error pointer in case of error.
745 */ 745 */
746struct bio *bio_map_user_iov(request_queue_t *q, struct block_device *bdev, 746struct bio *bio_map_user_iov(struct request_queue *q, struct block_device *bdev,
747 struct sg_iovec *iov, int iov_count, 747 struct sg_iovec *iov, int iov_count,
748 int write_to_vm) 748 int write_to_vm)
749{ 749{
@@ -808,7 +808,7 @@ static int bio_map_kern_endio(struct bio *bio, unsigned int bytes_done, int err)
808} 808}
809 809
810 810
811static struct bio *__bio_map_kern(request_queue_t *q, void *data, 811static struct bio *__bio_map_kern(struct request_queue *q, void *data,
812 unsigned int len, gfp_t gfp_mask) 812 unsigned int len, gfp_t gfp_mask)
813{ 813{
814 unsigned long kaddr = (unsigned long)data; 814 unsigned long kaddr = (unsigned long)data;
@@ -847,7 +847,7 @@ static struct bio *__bio_map_kern(request_queue_t *q, void *data,
847 847
848/** 848/**
849 * bio_map_kern - map kernel address into bio 849 * bio_map_kern - map kernel address into bio
850 * @q: the request_queue_t for the bio 850 * @q: the struct request_queue for the bio
851 * @data: pointer to buffer to map 851 * @data: pointer to buffer to map
852 * @len: length in bytes 852 * @len: length in bytes
853 * @gfp_mask: allocation flags for bio allocation 853 * @gfp_mask: allocation flags for bio allocation
@@ -855,7 +855,7 @@ static struct bio *__bio_map_kern(request_queue_t *q, void *data,
855 * Map the kernel address into a bio suitable for io to a block 855 * Map the kernel address into a bio suitable for io to a block
856 * device. Returns an error pointer in case of error. 856 * device. Returns an error pointer in case of error.
857 */ 857 */
858struct bio *bio_map_kern(request_queue_t *q, void *data, unsigned int len, 858struct bio *bio_map_kern(struct request_queue *q, void *data, unsigned int len,
859 gfp_t gfp_mask) 859 gfp_t gfp_mask)
860{ 860{
861 struct bio *bio; 861 struct bio *bio;
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index e440a7b95d02..2bc1428d621c 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -115,6 +115,10 @@
115#include <linux/dvb/video.h> 115#include <linux/dvb/video.h>
116#include <linux/lp.h> 116#include <linux/lp.h>
117 117
118#ifdef CONFIG_SPARC
119#include <asm/fbio.h>
120#endif
121
118static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, 122static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
119 unsigned long arg, struct file *f) 123 unsigned long arg, struct file *f)
120{ 124{
@@ -3493,6 +3497,22 @@ IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
3493 3497
3494/* loop */ 3498/* loop */
3495IGNORE_IOCTL(LOOP_CLR_FD) 3499IGNORE_IOCTL(LOOP_CLR_FD)
3500
3501#ifdef CONFIG_SPARC
3502/* Sparc framebuffers, handled in sbusfb_compat_ioctl() */
3503IGNORE_IOCTL(FBIOGTYPE)
3504IGNORE_IOCTL(FBIOSATTR)
3505IGNORE_IOCTL(FBIOGATTR)
3506IGNORE_IOCTL(FBIOSVIDEO)
3507IGNORE_IOCTL(FBIOGVIDEO)
3508IGNORE_IOCTL(FBIOSCURPOS)
3509IGNORE_IOCTL(FBIOGCURPOS)
3510IGNORE_IOCTL(FBIOGCURMAX)
3511IGNORE_IOCTL(FBIOPUTCMAP32)
3512IGNORE_IOCTL(FBIOGETCMAP32)
3513IGNORE_IOCTL(FBIOSCURSOR32)
3514IGNORE_IOCTL(FBIOGCURSOR32)
3515#endif
3496}; 3516};
3497 3517
3498#define IOCTL_HASHSIZE 256 3518#define IOCTL_HASHSIZE 256
diff --git a/fs/dcookies.c b/fs/dcookies.c
index c1208f53bd74..792cbf55fa95 100644
--- a/fs/dcookies.c
+++ b/fs/dcookies.c
@@ -20,6 +20,7 @@
20#include <linux/capability.h> 20#include <linux/capability.h>
21#include <linux/dcache.h> 21#include <linux/dcache.h>
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/err.h>
23#include <linux/errno.h> 24#include <linux/errno.h>
24#include <linux/dcookies.h> 25#include <linux/dcookies.h>
25#include <linux/mutex.h> 26#include <linux/mutex.h>
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 68579a0ed3f0..639a32c3c9c1 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -580,7 +580,7 @@ static int ext2_check_descriptors (struct super_block * sb)
580 return 0; 580 return 0;
581 } 581 }
582 if (le32_to_cpu(gdp->bg_inode_table) < first_block || 582 if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
583 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group > 583 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group - 1 >
584 last_block) 584 last_block)
585 { 585 {
586 ext2_error (sb, "ext2_check_descriptors", 586 ext2_error (sb, "ext2_check_descriptors",
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index f0614e3f1fe8..22cfdd61c060 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -1221,7 +1221,7 @@ static int ext3_check_descriptors (struct super_block * sb)
1221 return 0; 1221 return 0;
1222 } 1222 }
1223 if (le32_to_cpu(gdp->bg_inode_table) < first_block || 1223 if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
1224 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group > 1224 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group - 1 >
1225 last_block) 1225 last_block)
1226 { 1226 {
1227 ext3_error (sb, "ext3_check_descriptors", 1227 ext3_error (sb, "ext3_check_descriptors",
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 750c46f7d893..78beb096f57d 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -1544,7 +1544,7 @@ int ext4_ext_walk_space(struct inode *inode, unsigned long block,
1544 1544
1545static void 1545static void
1546ext4_ext_put_in_cache(struct inode *inode, __u32 block, 1546ext4_ext_put_in_cache(struct inode *inode, __u32 block,
1547 __u32 len, __u32 start, int type) 1547 __u32 len, ext4_fsblk_t start, int type)
1548{ 1548{
1549 struct ext4_ext_cache *cex; 1549 struct ext4_ext_cache *cex;
1550 BUG_ON(len == 0); 1550 BUG_ON(len == 0);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 75adbb64e028..4550b83ab1c9 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1283,7 +1283,7 @@ static int ext4_check_descriptors (struct super_block * sb)
1283 } 1283 }
1284 inode_table = ext4_inode_table(sb, gdp); 1284 inode_table = ext4_inode_table(sb, gdp);
1285 if (inode_table < first_block || 1285 if (inode_table < first_block ||
1286 inode_table + sbi->s_itb_per_group > last_block) 1286 inode_table + sbi->s_itb_per_group - 1 > last_block)
1287 { 1287 {
1288 ext4_error (sb, "ext4_check_descriptors", 1288 ext4_error (sb, "ext4_check_descriptors",
1289 "Inode table for group %d" 1289 "Inode table for group %d"
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 1a5e8e893d75..773421130116 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -508,7 +508,7 @@ static int gfs2_setlease(struct file *file, long arg, struct file_lock **fl)
508 */ 508 */
509 if (!sdp->sd_args.ar_localflocks) 509 if (!sdp->sd_args.ar_localflocks)
510 return -EINVAL; 510 return -EINVAL;
511 return setlease(file, arg, fl); 511 return generic_setlease(file, arg, fl);
512} 512}
513 513
514/** 514/**
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 95c72aa81867..043b470fd3b6 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -846,6 +846,15 @@ root_found:
846 goto out_no_root; 846 goto out_no_root;
847 if (!inode->i_op) 847 if (!inode->i_op)
848 goto out_bad_root; 848 goto out_bad_root;
849
850 /* Make sure the root inode is a directory */
851 if (!S_ISDIR(inode->i_mode)) {
852 printk(KERN_WARNING
853 "isofs_fill_super: root inode is not a directory. "
854 "Corrupted media?\n");
855 goto out_iput;
856 }
857
849 /* get the root dentry */ 858 /* get the root dentry */
850 s->s_root = d_alloc_root(inode); 859 s->s_root = d_alloc_root(inode);
851 if (!(s->s_root)) 860 if (!(s->s_root))
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index b3efa4536cc5..a21e4bc5444b 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -335,10 +335,10 @@ static void nlmsvc_freegrantargs(struct nlm_rqst *call)
335/* 335/*
336 * Deferred lock request handling for non-blocking lock 336 * Deferred lock request handling for non-blocking lock
337 */ 337 */
338static u32 338static __be32
339nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block) 339nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block)
340{ 340{
341 u32 status = nlm_lck_denied_nolocks; 341 __be32 status = nlm_lck_denied_nolocks;
342 342
343 block->b_flags |= B_QUEUED; 343 block->b_flags |= B_QUEUED;
344 344
@@ -352,7 +352,7 @@ nlmsvc_defer_lock_rqst(struct svc_rqst *rqstp, struct nlm_block *block)
352 status = nlm_drop_reply; 352 status = nlm_drop_reply;
353 } 353 }
354 dprintk("lockd: nlmsvc_defer_lock_rqst block %p flags %d status %d\n", 354 dprintk("lockd: nlmsvc_defer_lock_rqst block %p flags %d status %d\n",
355 block, block->b_flags, status); 355 block, block->b_flags, ntohl(status));
356 356
357 return status; 357 return status;
358} 358}
diff --git a/fs/locks.c b/fs/locks.c
index 310510637247..50857d2d3404 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1324,7 +1324,7 @@ int fcntl_getlease(struct file *filp)
1324} 1324}
1325 1325
1326/** 1326/**
1327 * setlease - sets a lease on an open file 1327 * generic_setlease - sets a lease on an open file
1328 * @filp: file pointer 1328 * @filp: file pointer
1329 * @arg: type of lease to obtain 1329 * @arg: type of lease to obtain
1330 * @flp: input - file_lock to use, output - file_lock inserted 1330 * @flp: input - file_lock to use, output - file_lock inserted
@@ -1334,7 +1334,7 @@ int fcntl_getlease(struct file *filp)
1334 * 1334 *
1335 * Called with kernel lock held. 1335 * Called with kernel lock held.
1336 */ 1336 */
1337int setlease(struct file *filp, long arg, struct file_lock **flp) 1337int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
1338{ 1338{
1339 struct file_lock *fl, **before, **my_before = NULL, *lease; 1339 struct file_lock *fl, **before, **my_before = NULL, *lease;
1340 struct dentry *dentry = filp->f_path.dentry; 1340 struct dentry *dentry = filp->f_path.dentry;
@@ -1419,7 +1419,7 @@ int setlease(struct file *filp, long arg, struct file_lock **flp)
1419out: 1419out:
1420 return error; 1420 return error;
1421} 1421}
1422EXPORT_SYMBOL(setlease); 1422EXPORT_SYMBOL(generic_setlease);
1423 1423
1424 /** 1424 /**
1425 * vfs_setlease - sets a lease on an open file 1425 * vfs_setlease - sets a lease on an open file
@@ -1456,7 +1456,7 @@ int vfs_setlease(struct file *filp, long arg, struct file_lock **lease)
1456 if (filp->f_op && filp->f_op->setlease) 1456 if (filp->f_op && filp->f_op->setlease)
1457 error = filp->f_op->setlease(filp, arg, lease); 1457 error = filp->f_op->setlease(filp, arg, lease);
1458 else 1458 else
1459 error = setlease(filp, arg, lease); 1459 error = generic_setlease(filp, arg, lease);
1460 unlock_kernel(); 1460 unlock_kernel();
1461 1461
1462 return error; 1462 return error;
diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c
index 551e0bac7aac..df6d60bdfcd3 100644
--- a/fs/ncpfs/ncplib_kernel.c
+++ b/fs/ncpfs/ncplib_kernel.c
@@ -726,9 +726,6 @@ ncp_del_file_or_subdir2(struct ncp_server *server,
726 __le32 dirent; 726 __le32 dirent;
727 727
728 if (!inode) { 728 if (!inode) {
729#ifdef CONFIG_NCPFS_DEBUGDENTRY
730 PRINTK("ncpfs: ncpdel2: dentry->d_inode == NULL\n");
731#endif
732 return 0xFF; /* Any error */ 729 return 0xFF; /* Any error */
733 } 730 }
734 volnum = NCP_FINFO(inode)->volNumber; 731 volnum = NCP_FINFO(inode)->volNumber;
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 2d295dda4c1d..cba899a3494e 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -564,9 +564,10 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
564 564
565 /* flags */ 565 /* flags */
566 err = get_int(&mesg, &an_int); 566 err = get_int(&mesg, &an_int);
567 if (err == -ENOENT) 567 if (err == -ENOENT) {
568 err = 0;
568 set_bit(CACHE_NEGATIVE, &exp.h.flags); 569 set_bit(CACHE_NEGATIVE, &exp.h.flags);
569 else { 570 } else {
570 if (err || an_int < 0) goto out; 571 if (err || an_int < 0) goto out;
571 exp.ex_flags= an_int; 572 exp.ex_flags= an_int;
572 573
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index 2cf9a9a2d89c..2ccffde81b84 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -138,7 +138,7 @@ idtoname_request(struct cache_detail *cd, struct cache_head *ch, char **bpp,
138 char idstr[11]; 138 char idstr[11];
139 139
140 qword_add(bpp, blen, ent->authname); 140 qword_add(bpp, blen, ent->authname);
141 snprintf(idstr, sizeof(idstr), "%d", ent->id); 141 snprintf(idstr, sizeof(idstr), "%u", ent->id);
142 qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user"); 142 qword_add(bpp, blen, ent->type == IDMAP_TYPE_GROUP ? "group" : "user");
143 qword_add(bpp, blen, idstr); 143 qword_add(bpp, blen, idstr);
144 144
@@ -165,7 +165,7 @@ idtoname_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)
165 return 0; 165 return 0;
166 } 166 }
167 ent = container_of(h, struct ent, h); 167 ent = container_of(h, struct ent, h);
168 seq_printf(m, "%s %s %d", ent->authname, 168 seq_printf(m, "%s %s %u", ent->authname,
169 ent->type == IDMAP_TYPE_GROUP ? "group" : "user", 169 ent->type == IDMAP_TYPE_GROUP ? "group" : "user",
170 ent->id); 170 ent->id);
171 if (test_bit(CACHE_VALID, &h->flags)) 171 if (test_bit(CACHE_VALID, &h->flags))
@@ -349,7 +349,7 @@ nametoid_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h)
349 ent->type == IDMAP_TYPE_GROUP ? "group" : "user", 349 ent->type == IDMAP_TYPE_GROUP ? "group" : "user",
350 ent->name); 350 ent->name);
351 if (test_bit(CACHE_VALID, &h->flags)) 351 if (test_bit(CACHE_VALID, &h->flags))
352 seq_printf(m, " %d", ent->id); 352 seq_printf(m, " %u", ent->id);
353 seq_printf(m, "\n"); 353 seq_printf(m, "\n");
354 return 0; 354 return 0;
355} 355}
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 3c627128e205..29b7e63cb32c 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -100,7 +100,15 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
100 status = nfsd_create_v3(rqstp, current_fh, open->op_fname.data, 100 status = nfsd_create_v3(rqstp, current_fh, open->op_fname.data,
101 open->op_fname.len, &open->op_iattr, 101 open->op_fname.len, &open->op_iattr,
102 &resfh, open->op_createmode, 102 &resfh, open->op_createmode,
103 (u32 *)open->op_verf.data, &open->op_truncate, &created); 103 (u32 *)open->op_verf.data,
104 &open->op_truncate, &created);
105
106 /* If we ever decide to use different attrs to store the
107 * verifier in nfsd_create_v3, then we'll need to change this
108 */
109 if (open->op_createmode == NFS4_CREATE_EXCLUSIVE && status == 0)
110 open->op_bmval[1] |= (FATTR4_WORD1_TIME_ACCESS |
111 FATTR4_WORD1_TIME_MODIFY);
104 } else { 112 } else {
105 status = nfsd_lookup(rqstp, current_fh, 113 status = nfsd_lookup(rqstp, current_fh,
106 open->op_fname.data, open->op_fname.len, &resfh); 114 open->op_fname.data, open->op_fname.len, &resfh);
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index b3d55c6747fd..8ef0964179bc 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2450,7 +2450,7 @@ nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_
2450} 2450}
2451 2451
2452static void 2452static void
2453nfsd4_encode_secinfo(struct nfsd4_compoundres *resp, int nfserr, 2453nfsd4_encode_secinfo(struct nfsd4_compoundres *resp, __be32 nfserr,
2454 struct nfsd4_secinfo *secinfo) 2454 struct nfsd4_secinfo *secinfo)
2455{ 2455{
2456 int i = 0; 2456 int i = 0;
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index ee96a897a29e..a0c2b253818b 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1309,7 +1309,10 @@ nfsd_create_v3(struct svc_rqst *rqstp, struct svc_fh *fhp,
1309 1309
1310 if (createmode == NFS3_CREATE_EXCLUSIVE) { 1310 if (createmode == NFS3_CREATE_EXCLUSIVE) {
1311 /* solaris7 gets confused (bugid 4218508) if these have 1311 /* solaris7 gets confused (bugid 4218508) if these have
1312 * the high bit set, so just clear the high bits. 1312 * the high bit set, so just clear the high bits. If this is
1313 * ever changed to use different attrs for storing the
1314 * verifier, then do_open_lookup() will also need to be fixed
1315 * accordingly.
1313 */ 1316 */
1314 v_mtime = verifier[0]&0x7fffffff; 1317 v_mtime = verifier[0]&0x7fffffff;
1315 v_atime = verifier[1]&0x7fffffff; 1318 v_atime = verifier[1]&0x7fffffff;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 5727cd18302a..c4034f693e7b 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2153,7 +2153,7 @@ static int ocfs2_splice_write_actor(struct pipe_inode_info *pipe,
2153 src = buf->ops->map(pipe, buf, 1); 2153 src = buf->ops->map(pipe, buf, 1);
2154 dst = kmap_atomic(page, KM_USER1); 2154 dst = kmap_atomic(page, KM_USER1);
2155 memcpy(dst + offset, src + buf->offset, count); 2155 memcpy(dst + offset, src + buf->offset, count);
2156 kunmap_atomic(page, KM_USER1); 2156 kunmap_atomic(dst, KM_USER1);
2157 buf->ops->unmap(pipe, buf, src); 2157 buf->ops->unmap(pipe, buf, src);
2158 2158
2159 copied = ocfs2_write_end(file, file->f_mapping, sd->pos, count, count, 2159 copied = ocfs2_write_end(file, file->f_mapping, sd->pos, count, count,
diff --git a/fs/open.c b/fs/open.c
index a6b054edacba..1d9e5e98bf4e 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -256,24 +256,26 @@ static long do_sys_truncate(const char __user * path, loff_t length)
256 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 256 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
257 goto dput_and_out; 257 goto dput_and_out;
258 258
259 /* 259 error = get_write_access(inode);
260 * Make sure that there are no leases.
261 */
262 error = break_lease(inode, FMODE_WRITE);
263 if (error) 260 if (error)
264 goto dput_and_out; 261 goto dput_and_out;
265 262
266 error = get_write_access(inode); 263 /*
264 * Make sure that there are no leases. get_write_access() protects
265 * against the truncate racing with a lease-granting setlease().
266 */
267 error = break_lease(inode, FMODE_WRITE);
267 if (error) 268 if (error)
268 goto dput_and_out; 269 goto put_write_and_out;
269 270
270 error = locks_verify_truncate(inode, NULL, length); 271 error = locks_verify_truncate(inode, NULL, length);
271 if (!error) { 272 if (!error) {
272 DQUOT_INIT(inode); 273 DQUOT_INIT(inode);
273 error = do_truncate(nd.dentry, length, 0, NULL); 274 error = do_truncate(nd.dentry, length, 0, NULL);
274 } 275 }
275 put_write_access(inode);
276 276
277put_write_and_out:
278 put_write_access(inode);
277dput_and_out: 279dput_and_out:
278 path_release(&nd); 280 path_release(&nd);
279out: 281out:
@@ -403,7 +405,7 @@ asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len)
403 if (inode->i_op && inode->i_op->fallocate) 405 if (inode->i_op && inode->i_op->fallocate)
404 ret = inode->i_op->fallocate(inode, mode, offset, len); 406 ret = inode->i_op->fallocate(inode, mode, offset, len);
405 else 407 else
406 ret = -ENOSYS; 408 ret = -EOPNOTSUPP;
407 409
408out_fput: 410out_fput:
409 fput(file); 411 fput(file);
diff --git a/fs/partitions/msdos.c b/fs/partitions/msdos.c
index 4ccec4cd1367..5567ec0d03a3 100644
--- a/fs/partitions/msdos.c
+++ b/fs/partitions/msdos.c
@@ -203,6 +203,7 @@ parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev,
203 Sector sect; 203 Sector sect;
204 struct solaris_x86_vtoc *v; 204 struct solaris_x86_vtoc *v;
205 int i; 205 int i;
206 short max_nparts;
206 207
207 v = (struct solaris_x86_vtoc *)read_dev_sector(bdev, offset+1, &sect); 208 v = (struct solaris_x86_vtoc *)read_dev_sector(bdev, offset+1, &sect);
208 if (!v) 209 if (!v)
@@ -218,7 +219,9 @@ parse_solaris_x86(struct parsed_partitions *state, struct block_device *bdev,
218 put_dev_sector(sect); 219 put_dev_sector(sect);
219 return; 220 return;
220 } 221 }
221 for (i=0; i<SOLARIS_X86_NUMSLICE && state->next<state->limit; i++) { 222 /* Ensure we can handle previous case of VTOC with 8 entries gracefully */
223 max_nparts = le16_to_cpu (v->v_nparts) > 8 ? SOLARIS_X86_NUMSLICE : 8;
224 for (i=0; i<max_nparts && state->next<state->limit; i++) {
222 struct solaris_x86_slice *s = &v->v_slice[i]; 225 struct solaris_x86_slice *s = &v->v_slice[i];
223 if (s->s_size == 0) 226 if (s->s_size == 0)
224 continue; 227 continue;
diff --git a/fs/partitions/sun.c b/fs/partitions/sun.c
index 123f8b46c8ba..794118da4ef3 100644
--- a/fs/partitions/sun.c
+++ b/fs/partitions/sun.c
@@ -19,34 +19,47 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev)
19 Sector sect; 19 Sector sect;
20 struct sun_disklabel { 20 struct sun_disklabel {
21 unsigned char info[128]; /* Informative text string */ 21 unsigned char info[128]; /* Informative text string */
22 unsigned char spare0[14]; 22 struct sun_vtoc {
23 struct sun_info { 23 __be32 version; /* Layout version */
24 unsigned char spare1; 24 char volume[8]; /* Volume name */
25 unsigned char id; 25 __be16 nparts; /* Number of partitions */
26 unsigned char spare2; 26 struct sun_info { /* Partition hdrs, sec 2 */
27 unsigned char flags; 27 __be16 id;
28 } infos[8]; 28 __be16 flags;
29 unsigned char spare[246]; /* Boot information etc. */ 29 } infos[8];
30 __be16 padding; /* Alignment padding */
31 __be32 bootinfo[3]; /* Info needed by mboot */
32 __be32 sanity; /* To verify vtoc sanity */
33 __be32 reserved[10]; /* Free space */
34 __be32 timestamp[8]; /* Partition timestamp */
35 } vtoc;
36 __be32 write_reinstruct; /* sectors to skip, writes */
37 __be32 read_reinstruct; /* sectors to skip, reads */
38 unsigned char spare[148]; /* Padding */
30 __be16 rspeed; /* Disk rotational speed */ 39 __be16 rspeed; /* Disk rotational speed */
31 __be16 pcylcount; /* Physical cylinder count */ 40 __be16 pcylcount; /* Physical cylinder count */
32 __be16 sparecyl; /* extra sects per cylinder */ 41 __be16 sparecyl; /* extra sects per cylinder */
33 unsigned char spare2[4]; /* More magic... */ 42 __be16 obs1; /* gap1 */
43 __be16 obs2; /* gap2 */
34 __be16 ilfact; /* Interleave factor */ 44 __be16 ilfact; /* Interleave factor */
35 __be16 ncyl; /* Data cylinder count */ 45 __be16 ncyl; /* Data cylinder count */
36 __be16 nacyl; /* Alt. cylinder count */ 46 __be16 nacyl; /* Alt. cylinder count */
37 __be16 ntrks; /* Tracks per cylinder */ 47 __be16 ntrks; /* Tracks per cylinder */
38 __be16 nsect; /* Sectors per track */ 48 __be16 nsect; /* Sectors per track */
39 unsigned char spare3[4]; /* Even more magic... */ 49 __be16 obs3; /* bhead - Label head offset */
50 __be16 obs4; /* ppart - Physical Partition */
40 struct sun_partition { 51 struct sun_partition {
41 __be32 start_cylinder; 52 __be32 start_cylinder;
42 __be32 num_sectors; 53 __be32 num_sectors;
43 } partitions[8]; 54 } partitions[8];
44 __be16 magic; /* Magic number */ 55 __be16 magic; /* Magic number */
45 __be16 csum; /* Label xor'd checksum */ 56 __be16 csum; /* Label xor'd checksum */
46 } * label; 57 } * label;
47 struct sun_partition *p; 58 struct sun_partition *p;
48 unsigned long spc; 59 unsigned long spc;
49 char b[BDEVNAME_SIZE]; 60 char b[BDEVNAME_SIZE];
61 int use_vtoc;
62 int nparts;
50 63
51 label = (struct sun_disklabel *)read_dev_sector(bdev, 0, &sect); 64 label = (struct sun_disklabel *)read_dev_sector(bdev, 0, &sect);
52 if (!label) 65 if (!label)
@@ -70,9 +83,22 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev)
70 return 0; 83 return 0;
71 } 84 }
72 85
73 /* All Sun disks have 8 partition entries */ 86 /* Check to see if we can use the VTOC table */
87 use_vtoc = ((be32_to_cpu(label->vtoc.sanity) == SUN_VTOC_SANITY) &&
88 (be32_to_cpu(label->vtoc.version) == 1) &&
89 (be16_to_cpu(label->vtoc.nparts) <= 8));
90
91 /* Use 8 partition entries if not specified in validated VTOC */
92 nparts = (use_vtoc) ? be16_to_cpu(label->vtoc.nparts) : 8;
93
94 /*
95 * So that old Linux-Sun partitions continue to work,
96 * alow the VTOC to be used under the additional condition ...
97 */
98 use_vtoc = use_vtoc || !(label->vtoc.sanity |
99 label->vtoc.version | label->vtoc.nparts);
74 spc = be16_to_cpu(label->ntrks) * be16_to_cpu(label->nsect); 100 spc = be16_to_cpu(label->ntrks) * be16_to_cpu(label->nsect);
75 for (i = 0; i < 8; i++, p++) { 101 for (i = 0; i < nparts; i++, p++) {
76 unsigned long st_sector; 102 unsigned long st_sector;
77 unsigned int num_sectors; 103 unsigned int num_sectors;
78 104
@@ -81,10 +107,12 @@ int sun_partition(struct parsed_partitions *state, struct block_device *bdev)
81 if (num_sectors) { 107 if (num_sectors) {
82 put_partition(state, slot, st_sector, num_sectors); 108 put_partition(state, slot, st_sector, num_sectors);
83 state->parts[slot].flags = 0; 109 state->parts[slot].flags = 0;
84 if (label->infos[i].id == LINUX_RAID_PARTITION) 110 if (use_vtoc) {
85 state->parts[slot].flags |= ADDPART_FLAG_RAID; 111 if (be16_to_cpu(label->vtoc.infos[i].id) == LINUX_RAID_PARTITION)
86 if (label->infos[i].id == SUN_WHOLE_DISK) 112 state->parts[slot].flags |= ADDPART_FLAG_RAID;
87 state->parts[slot].flags |= ADDPART_FLAG_WHOLEDISK; 113 else if (be16_to_cpu(label->vtoc.infos[i].id) == SUN_WHOLE_DISK)
114 state->parts[slot].flags |= ADDPART_FLAG_WHOLEDISK;
115 }
88 } 116 }
89 slot++; 117 slot++;
90 } 118 }
diff --git a/fs/partitions/sun.h b/fs/partitions/sun.h
index b1b19fda7b22..7f864d1f86d4 100644
--- a/fs/partitions/sun.h
+++ b/fs/partitions/sun.h
@@ -3,5 +3,6 @@
3 */ 3 */
4 4
5#define SUN_LABEL_MAGIC 0xDABE 5#define SUN_LABEL_MAGIC 0xDABE
6#define SUN_VTOC_SANITY 0x600DDEEE
6 7
7int sun_partition(struct parsed_partitions *state, struct block_device *bdev); 8int sun_partition(struct parsed_partitions *state, struct block_device *bdev);
diff --git a/fs/pipe.c b/fs/pipe.c
index d007830d9c87..6b3d91a691bf 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -255,7 +255,7 @@ void generic_pipe_buf_get(struct pipe_inode_info *pipe, struct pipe_buffer *buf)
255 255
256/** 256/**
257 * generic_pipe_buf_confirm - verify contents of the pipe buffer 257 * generic_pipe_buf_confirm - verify contents of the pipe buffer
258 * @pipe: the pipe that the buffer belongs to 258 * @info: the pipe that the buffer belongs to
259 * @buf: the buffer to confirm 259 * @buf: the buffer to confirm
260 * 260 *
261 * Description: 261 * Description:
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 3c77d5a64e7c..19489b0d5554 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -927,7 +927,7 @@ static const struct file_operations proc_pid_sched_operations = {
927 .read = seq_read, 927 .read = seq_read,
928 .write = sched_write, 928 .write = sched_write,
929 .llseek = seq_lseek, 929 .llseek = seq_lseek,
930 .release = seq_release, 930 .release = single_release,
931}; 931};
932 932
933#endif 933#endif
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 94e2c1adf184..a5b0dfd89a17 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -386,6 +386,19 @@ static const struct file_operations proc_reg_file_ops = {
386 .release = proc_reg_release, 386 .release = proc_reg_release,
387}; 387};
388 388
389#ifdef CONFIG_COMPAT
390static const struct file_operations proc_reg_file_ops_no_compat = {
391 .llseek = proc_reg_llseek,
392 .read = proc_reg_read,
393 .write = proc_reg_write,
394 .poll = proc_reg_poll,
395 .unlocked_ioctl = proc_reg_unlocked_ioctl,
396 .mmap = proc_reg_mmap,
397 .open = proc_reg_open,
398 .release = proc_reg_release,
399};
400#endif
401
389struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, 402struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
390 struct proc_dir_entry *de) 403 struct proc_dir_entry *de)
391{ 404{
@@ -413,8 +426,15 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
413 if (de->proc_iops) 426 if (de->proc_iops)
414 inode->i_op = de->proc_iops; 427 inode->i_op = de->proc_iops;
415 if (de->proc_fops) { 428 if (de->proc_fops) {
416 if (S_ISREG(inode->i_mode)) 429 if (S_ISREG(inode->i_mode)) {
417 inode->i_fop = &proc_reg_file_ops; 430#ifdef CONFIG_COMPAT
431 if (!de->proc_fops->compat_ioctl)
432 inode->i_fop =
433 &proc_reg_file_ops_no_compat;
434 else
435#endif
436 inode->i_fop = &proc_reg_file_ops;
437 }
418 else 438 else
419 inode->i_fop = de->proc_fops; 439 inode->i_fop = de->proc_fops;
420 } 440 }
diff --git a/fs/quota.c b/fs/quota.c
index e6577ac15a6c..99b24b52bfc8 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -387,7 +387,7 @@ asmlinkage long sys_quotactl(unsigned int cmd, const char __user *special, qid_t
387 return ret; 387 return ret;
388} 388}
389 389
390#if defined(CONFIG_X86_64) || defined(CONFIG_IA64) 390#if defined(CONFIG_COMPAT_FOR_U64_ALIGNMENT)
391/* 391/*
392 * This code works only for 32 bit quota tools over 64 bit OS (x86_64, ia64) 392 * This code works only for 32 bit quota tools over 64 bit OS (x86_64, ia64)
393 * and is necessary due to alignment problems. 393 * and is necessary due to alignment problems.
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index cad2b7ace630..237fe8b8e819 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -295,5 +295,10 @@ unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
295 */ 295 */
296int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma) 296int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma)
297{ 297{
298 return vma->vm_flags & VM_SHARED ? 0 : -ENOSYS; 298 if (!(vma->vm_flags & VM_SHARED))
299 return -ENOSYS;
300
301 file_accessed(file);
302 vma->vm_ops = &generic_file_vm_ops;
303 return 0;
299} 304}
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index b6f12593c39d..981027d1187b 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -1042,7 +1042,8 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st
1042 pos = I_UNFM_NUM(&s_ih); 1042 pos = I_UNFM_NUM(&s_ih);
1043 1043
1044 while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > n_new_file_length) { 1044 while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > n_new_file_length) {
1045 __u32 *unfm, block; 1045 __le32 *unfm;
1046 __u32 block;
1046 1047
1047 /* Each unformatted block deletion may involve one additional 1048 /* Each unformatted block deletion may involve one additional
1048 * bitmap block into the transaction, thereby the initial 1049 * bitmap block into the transaction, thereby the initial
@@ -1052,7 +1053,7 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st
1052 break; 1053 break;
1053 } 1054 }
1054 1055
1055 unfm = (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + pos - 1; 1056 unfm = (__le32 *)B_I_PITEM(p_s_bh, &s_ih) + pos - 1;
1056 block = get_block_num(unfm, 0); 1057 block = get_block_num(unfm, 0);
1057 1058
1058 if (block != 0) { 1059 if (block != 0) {
diff --git a/fs/signalfd.c b/fs/signalfd.c
index 3b07f26d984d..7b941abbcde0 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -320,7 +320,7 @@ asmlinkage long sys_signalfd(int ufd, sigset_t __user *user_mask, size_t sizemas
320 320
321 if (sizemask != sizeof(sigset_t) || 321 if (sizemask != sizeof(sigset_t) ||
322 copy_from_user(&sigmask, user_mask, sizeof(sigmask))) 322 copy_from_user(&sigmask, user_mask, sizeof(sigmask)))
323 return error = -EINVAL; 323 return -EINVAL;
324 sigdelsetmask(&sigmask, sigmask(SIGKILL) | sigmask(SIGSTOP)); 324 sigdelsetmask(&sigmask, sigmask(SIGKILL) | sigmask(SIGSTOP));
325 signotset(&sigmask); 325 signotset(&sigmask);
326 326
diff --git a/fs/splice.c b/fs/splice.c
index 0a0973218084..c010a72ca2d2 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -164,7 +164,7 @@ static const struct pipe_buf_operations user_page_pipe_buf_ops = {
164 * @spd: data to fill 164 * @spd: data to fill
165 * 165 *
166 * Description: 166 * Description:
167 * @spd contains a map of pages and len/offset tupples, a long with 167 * @spd contains a map of pages and len/offset tuples, along with
168 * the struct pipe_buf_operations associated with these pages. This 168 * the struct pipe_buf_operations associated with these pages. This
169 * function will link that data to the pipe. 169 * function will link that data to the pipe.
170 * 170 *
@@ -1000,7 +1000,7 @@ static long do_splice_to(struct file *in, loff_t *ppos,
1000 * Description: 1000 * Description:
1001 * This is a special case helper to splice directly between two 1001 * This is a special case helper to splice directly between two
1002 * points, without requiring an explicit pipe. Internally an allocated 1002 * points, without requiring an explicit pipe. Internally an allocated
1003 * pipe is cached in the process, and reused during the life time of 1003 * pipe is cached in the process, and reused during the lifetime of
1004 * that process. 1004 * that process.
1005 * 1005 *
1006 */ 1006 */
diff --git a/fs/timerfd.c b/fs/timerfd.c
index af9eca5c0230..61983f3b107c 100644
--- a/fs/timerfd.c
+++ b/fs/timerfd.c
@@ -95,7 +95,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
95{ 95{
96 struct timerfd_ctx *ctx = file->private_data; 96 struct timerfd_ctx *ctx = file->private_data;
97 ssize_t res; 97 ssize_t res;
98 u32 ticks = 0; 98 u64 ticks = 0;
99 DECLARE_WAITQUEUE(wait, current); 99 DECLARE_WAITQUEUE(wait, current);
100 100
101 if (count < sizeof(ticks)) 101 if (count < sizeof(ticks))
@@ -130,7 +130,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
130 * callback to avoid DoS attacks specifying a very 130 * callback to avoid DoS attacks specifying a very
131 * short timer period. 131 * short timer period.
132 */ 132 */
133 ticks = (u32) 133 ticks = (u64)
134 hrtimer_forward(&ctx->tmr, 134 hrtimer_forward(&ctx->tmr,
135 hrtimer_cb_get_time(&ctx->tmr), 135 hrtimer_cb_get_time(&ctx->tmr),
136 ctx->tintv); 136 ctx->tintv);
@@ -140,7 +140,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count,
140 } 140 }
141 spin_unlock_irq(&ctx->wqh.lock); 141 spin_unlock_irq(&ctx->wqh.lock);
142 if (ticks) 142 if (ticks)
143 res = put_user(ticks, buf) ? -EFAULT: sizeof(ticks); 143 res = put_user(ticks, (u64 __user *) buf) ? -EFAULT: sizeof(ticks);
144 return res; 144 return res;
145} 145}
146 146
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 0d2c41666cd2..1652b2c665bb 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1127,13 +1127,15 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1127 } 1127 }
1128 1128
1129 inode->i_uid = le32_to_cpu(fe->uid); 1129 inode->i_uid = le32_to_cpu(fe->uid);
1130 if (inode->i_uid == -1 || UDF_QUERY_FLAG(inode->i_sb, 1130 if (inode->i_uid == -1 ||
1131 UDF_FLAG_UID_IGNORE)) 1131 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_IGNORE) ||
1132 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_SET))
1132 inode->i_uid = UDF_SB(inode->i_sb)->s_uid; 1133 inode->i_uid = UDF_SB(inode->i_sb)->s_uid;
1133 1134
1134 inode->i_gid = le32_to_cpu(fe->gid); 1135 inode->i_gid = le32_to_cpu(fe->gid);
1135 if (inode->i_gid == -1 || UDF_QUERY_FLAG(inode->i_sb, 1136 if (inode->i_gid == -1 ||
1136 UDF_FLAG_GID_IGNORE)) 1137 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_IGNORE) ||
1138 UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_SET))
1137 inode->i_gid = UDF_SB(inode->i_sb)->s_gid; 1139 inode->i_gid = UDF_SB(inode->i_sb)->s_gid;
1138 1140
1139 inode->i_nlink = le16_to_cpu(fe->fileLinkCount); 1141 inode->i_nlink = le16_to_cpu(fe->fileLinkCount);
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 7b30964665db..382be7be5ae3 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -366,11 +366,13 @@ static int udf_parse_options(char *options, struct udf_options *uopt)
366 if (match_int(args, &option)) 366 if (match_int(args, &option))
367 return 0; 367 return 0;
368 uopt->gid = option; 368 uopt->gid = option;
369 uopt->flags |= (1 << UDF_FLAG_GID_SET);
369 break; 370 break;
370 case Opt_uid: 371 case Opt_uid:
371 if (match_int(args, &option)) 372 if (match_int(args, &option))
372 return 0; 373 return 0;
373 uopt->uid = option; 374 uopt->uid = option;
375 uopt->flags |= (1 << UDF_FLAG_UID_SET);
374 break; 376 break;
375 case Opt_umask: 377 case Opt_umask:
376 if (match_octal(args, &option)) 378 if (match_octal(args, &option))
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 3e937d3fb8f9..3c2982017c6d 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -24,6 +24,8 @@
24#define UDF_FLAG_UID_IGNORE 12 /* use sb uid instead of on disk uid */ 24#define UDF_FLAG_UID_IGNORE 12 /* use sb uid instead of on disk uid */
25#define UDF_FLAG_GID_FORGET 13 25#define UDF_FLAG_GID_FORGET 13
26#define UDF_FLAG_GID_IGNORE 14 26#define UDF_FLAG_GID_IGNORE 14
27#define UDF_FLAG_UID_SET 15
28#define UDF_FLAG_GID_SET 16
27 29
28#define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001 30#define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001
29#define UDF_PART_FLAG_UNALLOC_TABLE 0x0002 31#define UDF_PART_FLAG_UNALLOC_TABLE 0x0002
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c
index 141cf15067c2..42319d75aaab 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -139,7 +139,7 @@ STATIC int xfs_inumbers_fmt_compat(
139 long count, 139 long count,
140 long *written) 140 long *written)
141{ 141{
142 compat_xfs_inogrp_t *p32 = ubuffer; 142 compat_xfs_inogrp_t __user *p32 = ubuffer;
143 long i; 143 long i;
144 144
145 for (i = 0; i < count; i++) { 145 for (i = 0; i < count; i++) {
@@ -444,7 +444,7 @@ xfs_compat_ioctl(
444 case XFS_IOC_FSINUMBERS_32: 444 case XFS_IOC_FSINUMBERS_32:
445 cmd = _NATIVE_IOC(cmd, struct xfs_fsop_bulkreq); 445 cmd = _NATIVE_IOC(cmd, struct xfs_fsop_bulkreq);
446 return xfs_ioc_bulkstat_compat(XFS_BHVTOI(VNHEAD(vp))->i_mount, 446 return xfs_ioc_bulkstat_compat(XFS_BHVTOI(VNHEAD(vp))->i_mount,
447 cmd, (void*)arg); 447 cmd, (void __user*)arg);
448 case XFS_IOC_FD_TO_HANDLE_32: 448 case XFS_IOC_FD_TO_HANDLE_32:
449 case XFS_IOC_PATH_TO_HANDLE_32: 449 case XFS_IOC_PATH_TO_HANDLE_32:
450 case XFS_IOC_PATH_TO_FSHANDLE_32: 450 case XFS_IOC_PATH_TO_FSHANDLE_32:
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 5e3dcf3299bf..3d0fea235bf3 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -131,7 +131,7 @@ struct acpi_device_ops {
131struct acpi_driver { 131struct acpi_driver {
132 char name[80]; 132 char name[80];
133 char class[80]; 133 char class[80];
134 char *ids; /* Supported Hardware IDs */ 134 const struct acpi_device_id *ids; /* Supported Hardware IDs */
135 struct acpi_device_ops ops; 135 struct acpi_device_ops ops;
136 struct device_driver drv; 136 struct device_driver drv;
137 struct module *owner; 137 struct module *owner;
@@ -341,7 +341,8 @@ int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent,
341int acpi_bus_trim(struct acpi_device *start, int rmdevice); 341int acpi_bus_trim(struct acpi_device *start, int rmdevice);
342int acpi_bus_start(struct acpi_device *device); 342int acpi_bus_start(struct acpi_device *device);
343acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd); 343acpi_status acpi_bus_get_ejd(acpi_handle handle, acpi_handle * ejd);
344int acpi_match_ids(struct acpi_device *device, char *ids); 344int acpi_match_device_ids(struct acpi_device *device,
345 const struct acpi_device_id *ids);
345int acpi_create_dir(struct acpi_device *); 346int acpi_create_dir(struct acpi_device *);
346void acpi_remove_dir(struct acpi_device *); 347void acpi_remove_dir(struct acpi_device *);
347 348
@@ -365,6 +366,17 @@ acpi_handle acpi_get_child(acpi_handle, acpi_integer);
365acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int); 366acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
366#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle)) 367#define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
367 368
369#ifdef CONFIG_PM_SLEEP
370int acpi_pm_device_sleep_state(struct device *, int, int *);
371#else /* !CONFIG_PM_SLEEP */
372static inline int acpi_pm_device_sleep_state(struct device *d, int w, int *p)
373{
374 if (p)
375 *p = ACPI_STATE_D0;
376 return ACPI_STATE_D3;
377}
378#endif /* !CONFIG_PM_SLEEP */
379
368#endif /* CONFIG_ACPI */ 380#endif /* CONFIG_ACPI */
369 381
370#endif /*__ACPI_BUS_H__*/ 382#endif /*__ACPI_BUS_H__*/
diff --git a/include/acpi/acpi_drivers.h b/include/acpi/acpi_drivers.h
index 553515912c0b..202acb9ff4d0 100644
--- a/include/acpi/acpi_drivers.h
+++ b/include/acpi/acpi_drivers.h
@@ -34,16 +34,21 @@
34#define ACPI_BUS_COMPONENT 0x00010000 34#define ACPI_BUS_COMPONENT 0x00010000
35#define ACPI_SYSTEM_COMPONENT 0x02000000 35#define ACPI_SYSTEM_COMPONENT 0x02000000
36 36
37/* _HID definitions */ 37/*
38 * _HID definitions
39 * HIDs must conform to ACPI spec(6.1.4)
40 * Linux specific HIDs do not apply to this and begin with LNX:
41 */
38 42
39#define ACPI_POWER_HID "power_resource" 43#define ACPI_POWER_HID "LNXPOWER"
40#define ACPI_PROCESSOR_HID "ACPI0007" 44#define ACPI_PROCESSOR_HID "ACPI0007"
41#define ACPI_SYSTEM_HID "acpi_system" 45#define ACPI_SYSTEM_HID "LNXSYSTM"
42#define ACPI_THERMAL_HID "thermal" 46#define ACPI_THERMAL_HID "LNXTHERM"
43#define ACPI_BUTTON_HID_POWERF "button_power" 47#define ACPI_BUTTON_HID_POWERF "LNXPWRBN"
44#define ACPI_BUTTON_HID_SLEEPF "button_sleep" 48#define ACPI_BUTTON_HID_SLEEPF "LNXSLPBN"
45#define ACPI_VIDEO_HID "video" 49#define ACPI_VIDEO_HID "LNXVIDEO"
46#define ACPI_BAY_HID "bay" 50#define ACPI_BAY_HID "LNXIOBAY"
51
47/* -------------------------------------------------------------------------- 52/* --------------------------------------------------------------------------
48 PCI 53 PCI
49 -------------------------------------------------------------------------- */ 54 -------------------------------------------------------------------------- */
@@ -145,7 +150,7 @@ static inline void unregister_hotplug_dock_device(acpi_handle handle)
145#ifdef CONFIG_ACPI_SLEEP 150#ifdef CONFIG_ACPI_SLEEP
146extern int acpi_sleep_init(void); 151extern int acpi_sleep_init(void);
147#else 152#else
148#define acpi_sleep_init() do {} while (0) 153static inline int acpi_sleep_init(void) { return 0; }
149#endif 154#endif
150 155
151#endif /*__ACPI_DRIVERS_H__*/ 156#endif /*__ACPI_DRIVERS_H__*/
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index fe8abc276437..e73a38939120 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -809,7 +809,7 @@ acpi_status(*acpi_walk_callback) (acpi_handle obj_handle,
809 809
810/* Common string version of device HIDs and UIDs */ 810/* Common string version of device HIDs and UIDs */
811 811
812struct acpi_device_id { 812struct acpica_device_id {
813 char value[ACPI_DEVICE_ID_LENGTH]; 813 char value[ACPI_DEVICE_ID_LENGTH];
814}; 814};
815 815
@@ -859,8 +859,8 @@ struct acpi_device_info {
859 u32 valid; /* Indicates which fields below are valid */ 859 u32 valid; /* Indicates which fields below are valid */
860 u32 current_status; /* _STA value */ 860 u32 current_status; /* _STA value */
861 acpi_integer address; /* _ADR value if any */ 861 acpi_integer address; /* _ADR value if any */
862 struct acpi_device_id hardware_id; /* _HID value if any */ 862 struct acpica_device_id hardware_id; /* _HID value if any */
863 struct acpi_device_id unique_id; /* _UID value if any */ 863 struct acpica_device_id unique_id; /* _UID value if any */
864 u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */ 864 u8 highest_dstates[4]; /* _sx_d values: 0xFF indicates not valid */
865 struct acpi_compatible_id_list compatibility_id; /* List of _CIDs if any */ 865 struct acpi_compatible_id_list compatibility_id; /* List of _CIDs if any */
866}; 866};
diff --git a/include/acpi/acutils.h b/include/acpi/acutils.h
index a87ef1c8d46b..a2918547c73f 100644
--- a/include/acpi/acutils.h
+++ b/include/acpi/acutils.h
@@ -354,7 +354,7 @@ acpi_ut_evaluate_numeric_object(char *object_name,
354 354
355acpi_status 355acpi_status
356acpi_ut_execute_HID(struct acpi_namespace_node *device_node, 356acpi_ut_execute_HID(struct acpi_namespace_node *device_node,
357 struct acpi_device_id *hid); 357 struct acpica_device_id *hid);
358 358
359acpi_status 359acpi_status
360acpi_ut_execute_CID(struct acpi_namespace_node *device_node, 360acpi_ut_execute_CID(struct acpi_namespace_node *device_node,
@@ -366,7 +366,7 @@ acpi_ut_execute_STA(struct acpi_namespace_node *device_node,
366 366
367acpi_status 367acpi_status
368acpi_ut_execute_UID(struct acpi_namespace_node *device_node, 368acpi_ut_execute_UID(struct acpi_namespace_node *device_node,
369 struct acpi_device_id *uid); 369 struct acpica_device_id *uid);
370 370
371acpi_status 371acpi_status
372acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest); 372acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest);
diff --git a/include/asm-alpha/bitops.h b/include/asm-alpha/bitops.h
index 3a0cbeb03fa1..9e71201000d5 100644
--- a/include/asm-alpha/bitops.h
+++ b/include/asm-alpha/bitops.h
@@ -324,7 +324,7 @@ static inline int fls64(unsigned long x)
324{ 324{
325 unsigned long t, a, r; 325 unsigned long t, a, r;
326 326
327 t = __kernel_cmpbge (x, 0x0101010101010101); 327 t = __kernel_cmpbge (x, 0x0101010101010101UL);
328 a = __flsm1_tab[t]; 328 a = __flsm1_tab[t];
329 t = __kernel_extbl (x, a); 329 t = __kernel_extbl (x, a);
330 r = a*8 + __flsm1_tab[t] + (x != 0); 330 r = a*8 + __flsm1_tab[t] + (x != 0);
diff --git a/include/asm-alpha/thread_info.h b/include/asm-alpha/thread_info.h
index 48a22e3e6f32..fb3185196298 100644
--- a/include/asm-alpha/thread_info.h
+++ b/include/asm-alpha/thread_info.h
@@ -67,28 +67,24 @@ register struct thread_info *__current_thread_info __asm__("$8");
67 * TIF_SYSCALL_TRACE is known to be 0 via blbs. 67 * TIF_SYSCALL_TRACE is known to be 0 via blbs.
68 */ 68 */
69#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 69#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
70#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 70#define TIF_SIGPENDING 1 /* signal pending */
71#define TIF_SIGPENDING 2 /* signal pending */ 71#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
72#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 72#define TIF_POLLING_NRFLAG 3 /* poll_idle is polling NEED_RESCHED */
73#define TIF_POLLING_NRFLAG 4 /* poll_idle is polling NEED_RESCHED */ 73#define TIF_DIE_IF_KERNEL 4 /* dik recursion lock */
74#define TIF_DIE_IF_KERNEL 5 /* dik recursion lock */ 74#define TIF_UAC_NOPRINT 5 /* see sysinfo.h */
75#define TIF_UAC_NOPRINT 6 /* see sysinfo.h */ 75#define TIF_UAC_NOFIX 6
76#define TIF_UAC_NOFIX 7 76#define TIF_UAC_SIGBUS 7
77#define TIF_UAC_SIGBUS 8 77#define TIF_MEMDIE 8
78#define TIF_MEMDIE 9 78#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */
79#define TIF_RESTORE_SIGMASK 10 /* restore signal mask in do_signal */
80 79
81#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 80#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
82#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
83#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 81#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
84#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 82#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
85#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 83#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
86#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 84#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
87 85
88/* Work to do on interrupt/exception return. */ 86/* Work to do on interrupt/exception return. */
89#define _TIF_WORK_MASK (_TIF_NOTIFY_RESUME \ 87#define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED)
90 | _TIF_SIGPENDING \
91 | _TIF_NEED_RESCHED)
92 88
93/* Work to do on any return to userspace. */ 89/* Work to do on any return to userspace. */
94#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \ 90#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \
diff --git a/include/asm-arm/arch-mxc/uncompress.h b/include/asm-arm/arch-mxc/uncompress.h
index ec5787d0e78c..42cc0cb3fefd 100644
--- a/include/asm-arm/arch-mxc/uncompress.h
+++ b/include/asm-arm/arch-mxc/uncompress.h
@@ -26,7 +26,6 @@
26#define __MXC_BOOT_UNCOMPRESS 26#define __MXC_BOOT_UNCOMPRESS
27 27
28#include <asm/hardware.h> 28#include <asm/hardware.h>
29#include <asm/processor.h>
30 29
31#define UART(x) (*(volatile unsigned long *)(serial_port + (x))) 30#define UART(x) (*(volatile unsigned long *)(serial_port + (x)))
32 31
@@ -62,7 +61,7 @@ static void putc(int ch)
62 } 61 }
63 62
64 while (!(UART(USR2) & USR2_TXFE)) 63 while (!(UART(USR2) & USR2_TXFE))
65 cpu_relax(); 64 barrier();
66 65
67 UART(TXR) = ch; 66 UART(TXR) = ch;
68} 67}
diff --git a/include/asm-arm/arch-omap/mailbox.h b/include/asm-arm/arch-omap/mailbox.h
index 4bf0909461f2..7cbed9332e16 100644
--- a/include/asm-arm/arch-omap/mailbox.h
+++ b/include/asm-arm/arch-omap/mailbox.h
@@ -37,7 +37,7 @@ struct omap_mbox_ops {
37 37
38struct omap_mbox_queue { 38struct omap_mbox_queue {
39 spinlock_t lock; 39 spinlock_t lock;
40 request_queue_t *queue; 40 struct request_queue *queue;
41 struct work_struct work; 41 struct work_struct work;
42 int (*callback)(void *); 42 int (*callback)(void *);
43 struct omap_mbox *mbox; 43 struct omap_mbox *mbox;
diff --git a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
index 69c65d56a6ac..41784357a204 100644
--- a/include/asm-arm/thread_info.h
+++ b/include/asm-arm/thread_info.h
@@ -134,22 +134,19 @@ extern void iwmmxt_task_switch(struct thread_info *);
134/* 134/*
135 * thread information flags: 135 * thread information flags:
136 * TIF_SYSCALL_TRACE - syscall trace active 136 * TIF_SYSCALL_TRACE - syscall trace active
137 * TIF_NOTIFY_RESUME - resumption notification requested
138 * TIF_SIGPENDING - signal pending 137 * TIF_SIGPENDING - signal pending
139 * TIF_NEED_RESCHED - rescheduling necessary 138 * TIF_NEED_RESCHED - rescheduling necessary
140 * TIF_USEDFPU - FPU was used by this task this quantum (SMP) 139 * TIF_USEDFPU - FPU was used by this task this quantum (SMP)
141 * TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED 140 * TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED
142 */ 141 */
143#define TIF_NOTIFY_RESUME 0 142#define TIF_SIGPENDING 0
144#define TIF_SIGPENDING 1 143#define TIF_NEED_RESCHED 1
145#define TIF_NEED_RESCHED 2
146#define TIF_SYSCALL_TRACE 8 144#define TIF_SYSCALL_TRACE 8
147#define TIF_POLLING_NRFLAG 16 145#define TIF_POLLING_NRFLAG 16
148#define TIF_USING_IWMMXT 17 146#define TIF_USING_IWMMXT 17
149#define TIF_MEMDIE 18 147#define TIF_MEMDIE 18
150#define TIF_FREEZE 19 148#define TIF_FREEZE 19
151 149
152#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
153#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 150#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
154#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 151#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
155#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 152#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
diff --git a/include/asm-arm/unaligned.h b/include/asm-arm/unaligned.h
index 795b9e5b9e6a..8431f6eed5c6 100644
--- a/include/asm-arm/unaligned.h
+++ b/include/asm-arm/unaligned.h
@@ -60,24 +60,24 @@ extern int __bug_unaligned_x(const void *ptr);
60 __get_unaligned_4_be((__p+4))) 60 __get_unaligned_4_be((__p+4)))
61 61
62#define __get_unaligned_le(ptr) \ 62#define __get_unaligned_le(ptr) \
63 ({ \ 63 ((__force typeof(*(ptr)))({ \
64 const __u8 *__p = (const __u8 *)(ptr); \ 64 const __u8 *__p = (const __u8 *)(ptr); \
65 __builtin_choose_expr(sizeof(*(ptr)) == 1, *__p, \ 65 __builtin_choose_expr(sizeof(*(ptr)) == 1, *__p, \
66 __builtin_choose_expr(sizeof(*(ptr)) == 2, __get_unaligned_2_le(__p), \ 66 __builtin_choose_expr(sizeof(*(ptr)) == 2, __get_unaligned_2_le(__p), \
67 __builtin_choose_expr(sizeof(*(ptr)) == 4, __get_unaligned_4_le(__p), \ 67 __builtin_choose_expr(sizeof(*(ptr)) == 4, __get_unaligned_4_le(__p), \
68 __builtin_choose_expr(sizeof(*(ptr)) == 8, __get_unaligned_8_le(__p), \ 68 __builtin_choose_expr(sizeof(*(ptr)) == 8, __get_unaligned_8_le(__p), \
69 (void)__bug_unaligned_x(__p))))); \ 69 (void)__bug_unaligned_x(__p))))); \
70 }) 70 }))
71 71
72#define __get_unaligned_be(ptr) \ 72#define __get_unaligned_be(ptr) \
73 ({ \ 73 ((__force typeof(*(ptr)))({ \
74 const __u8 *__p = (const __u8 *)(ptr); \ 74 const __u8 *__p = (const __u8 *)(ptr); \
75 __builtin_choose_expr(sizeof(*(ptr)) == 1, *__p, \ 75 __builtin_choose_expr(sizeof(*(ptr)) == 1, *__p, \
76 __builtin_choose_expr(sizeof(*(ptr)) == 2, __get_unaligned_2_be(__p), \ 76 __builtin_choose_expr(sizeof(*(ptr)) == 2, __get_unaligned_2_be(__p), \
77 __builtin_choose_expr(sizeof(*(ptr)) == 4, __get_unaligned_4_be(__p), \ 77 __builtin_choose_expr(sizeof(*(ptr)) == 4, __get_unaligned_4_be(__p), \
78 __builtin_choose_expr(sizeof(*(ptr)) == 8, __get_unaligned_8_be(__p), \ 78 __builtin_choose_expr(sizeof(*(ptr)) == 8, __get_unaligned_8_be(__p), \
79 (void)__bug_unaligned_x(__p))))); \ 79 (void)__bug_unaligned_x(__p))))); \
80 }) 80 }))
81 81
82 82
83static inline void __put_unaligned_2_le(__u32 __v, register __u8 *__p) 83static inline void __put_unaligned_2_le(__u32 __v, register __u8 *__p)
@@ -131,15 +131,16 @@ static inline void __put_unaligned_8_be(const unsigned long long __v, register _
131 */ 131 */
132#define __put_unaligned_le(val,ptr) \ 132#define __put_unaligned_le(val,ptr) \
133 ({ \ 133 ({ \
134 (void)sizeof(*(ptr) = (val)); \
134 switch (sizeof(*(ptr))) { \ 135 switch (sizeof(*(ptr))) { \
135 case 1: \ 136 case 1: \
136 *(ptr) = (val); \ 137 *(ptr) = (val); \
137 break; \ 138 break; \
138 case 2: __put_unaligned_2_le((val),(__u8 *)(ptr)); \ 139 case 2: __put_unaligned_2_le((__force u16)(val),(__u8 *)(ptr)); \
139 break; \ 140 break; \
140 case 4: __put_unaligned_4_le((val),(__u8 *)(ptr)); \ 141 case 4: __put_unaligned_4_le((__force u32)(val),(__u8 *)(ptr)); \
141 break; \ 142 break; \
142 case 8: __put_unaligned_8_le((val),(__u8 *)(ptr)); \ 143 case 8: __put_unaligned_8_le((__force u64)(val),(__u8 *)(ptr)); \
143 break; \ 144 break; \
144 default: __bug_unaligned_x(ptr); \ 145 default: __bug_unaligned_x(ptr); \
145 break; \ 146 break; \
@@ -149,15 +150,16 @@ static inline void __put_unaligned_8_be(const unsigned long long __v, register _
149 150
150#define __put_unaligned_be(val,ptr) \ 151#define __put_unaligned_be(val,ptr) \
151 ({ \ 152 ({ \
153 (void)sizeof(*(ptr) = (val)); \
152 switch (sizeof(*(ptr))) { \ 154 switch (sizeof(*(ptr))) { \
153 case 1: \ 155 case 1: \
154 *(ptr) = (val); \ 156 *(ptr) = (val); \
155 break; \ 157 break; \
156 case 2: __put_unaligned_2_be((val),(__u8 *)(ptr)); \ 158 case 2: __put_unaligned_2_be((__force u16)(val),(__u8 *)(ptr)); \
157 break; \ 159 break; \
158 case 4: __put_unaligned_4_be((val),(__u8 *)(ptr)); \ 160 case 4: __put_unaligned_4_be((__force u32)(val),(__u8 *)(ptr)); \
159 break; \ 161 break; \
160 case 8: __put_unaligned_8_be((val),(__u8 *)(ptr)); \ 162 case 8: __put_unaligned_8_be((__force u64)(val),(__u8 *)(ptr)); \
161 break; \ 163 break; \
162 default: __bug_unaligned_x(ptr); \ 164 default: __bug_unaligned_x(ptr); \
163 break; \ 165 break; \
diff --git a/include/asm-arm26/a.out.h b/include/asm-arm26/a.out.h
deleted file mode 100644
index 7167f54ae3fc..000000000000
--- a/include/asm-arm26/a.out.h
+++ /dev/null
@@ -1,39 +0,0 @@
1#ifndef __ARM_A_OUT_H__
2#define __ARM_A_OUT_H__
3
4#include <linux/personality.h>
5#include <asm/types.h>
6
7struct exec
8{
9 __u32 a_info; /* Use macros N_MAGIC, etc for access */
10 __u32 a_text; /* length of text, in bytes */
11 __u32 a_data; /* length of data, in bytes */
12 __u32 a_bss; /* length of uninitialized data area for file, in bytes */
13 __u32 a_syms; /* length of symbol table data in file, in bytes */
14 __u32 a_entry; /* start address */
15 __u32 a_trsize; /* length of relocation info for text, in bytes */
16 __u32 a_drsize; /* length of relocation info for data, in bytes */
17};
18
19/*
20 * This is always the same
21 */
22#define N_TXTADDR(a) (0x00008000)
23
24#define N_TRSIZE(a) ((a).a_trsize)
25#define N_DRSIZE(a) ((a).a_drsize)
26#define N_SYMSIZE(a) ((a).a_syms)
27
28#define M_ARM 103
29
30#ifdef __KERNEL__
31#define STACK_TOP TASK_SIZE
32#define STACK_TOP_MAX STACK_TOP
33#endif
34
35#ifndef LIBRARY_START_TEXT
36#define LIBRARY_START_TEXT (0x00c00000)
37#endif
38
39#endif /* __A_OUT_GNU_H__ */
diff --git a/include/asm-arm26/assembler.h b/include/asm-arm26/assembler.h
deleted file mode 100644
index bb507a9a4a55..000000000000
--- a/include/asm-arm26/assembler.h
+++ /dev/null
@@ -1,106 +0,0 @@
1/*
2 * linux/include/asm-arm26/assembler.h
3 *
4 * This file contains arm architecture specific defines
5 * for the different processors.
6 *
7 * Do not include any C declarations in this file - it is included by
8 * assembler source.
9 */
10#ifndef __ASSEMBLY__
11#error "Only include this from assembly code"
12#endif
13
14/*
15 * Endian independent macros for shifting bytes within registers.
16 */
17#define pull lsr
18#define push lsl
19#define byte(x) (x*8)
20
21#ifdef __STDC__
22#define LOADREGS(cond, base, reglist...)\
23 ldm##cond base,reglist^
24
25#define RETINSTR(instr, regs...)\
26 instr##s regs
27#else
28#define LOADREGS(cond, base, reglist...)\
29 ldm/**/cond base,reglist^
30
31#define RETINSTR(instr, regs...)\
32 instr/**/s regs
33#endif
34
35#define MODENOP\
36 mov r0, r0
37
38#define MODE(savereg,tmpreg,mode) \
39 mov savereg, pc; \
40 bic tmpreg, savereg, $0x0c000003; \
41 orr tmpreg, tmpreg, $mode; \
42 teqp tmpreg, $0
43
44#define RESTOREMODE(savereg) \
45 teqp savereg, $0
46
47#define SAVEIRQS(tmpreg)
48
49#define RESTOREIRQS(tmpreg)
50
51#define DISABLEIRQS(tmpreg)\
52 teqp pc, $0x08000003
53
54#define ENABLEIRQS(tmpreg)\
55 teqp pc, $0x00000003
56
57#define USERMODE(tmpreg)\
58 teqp pc, $0x00000000;\
59 mov r0, r0
60
61#define SVCMODE(tmpreg)\
62 teqp pc, $0x00000003;\
63 mov r0, r0
64
65
66/*
67 * Save the current IRQ state and disable IRQs
68 * Note that this macro assumes FIQs are enabled, and
69 * that the processor is in SVC mode.
70 */
71 .macro save_and_disable_irqs, oldcpsr, temp
72 mov \oldcpsr, pc
73 orr \temp, \oldcpsr, #0x08000000
74 teqp \temp, #0
75 .endm
76
77/*
78 * Restore interrupt state previously stored in
79 * a register
80 * ** Actually do nothing on Arc - hope that the caller uses a MOVS PC soon
81 * after!
82 */
83 .macro restore_irqs, oldcpsr
84 @ This be restore_irqs
85 .endm
86
87/*
88 * These two are used to save LR/restore PC over a user-based access.
89 * The old 26-bit architecture requires that we save lr (R14)
90 */
91 .macro save_lr
92 str lr, [sp, #-4]!
93 .endm
94
95 .macro restore_pc
96 ldmfd sp!, {pc}^
97 .endm
98
99#define USER(x...) \
1009999: x; \
101 .section __ex_table,"a"; \
102 .align 3; \
103 .long 9999b,9001f; \
104 .previous
105
106
diff --git a/include/asm-arm26/atomic.h b/include/asm-arm26/atomic.h
deleted file mode 100644
index d6dd42374cf3..000000000000
--- a/include/asm-arm26/atomic.h
+++ /dev/null
@@ -1,123 +0,0 @@
1/*
2 * linux/include/asm-arm26/atomic.h
3 *
4 * Copyright (c) 1996 Russell King.
5 * Modified for arm26 by Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Changelog:
12 * 25-11-2004 IM Updated for 2.6.9
13 * 27-06-1996 RMK Created
14 * 13-04-1997 RMK Made functions atomic!
15 * 07-12-1997 RMK Upgraded for v2.1.
16 * 26-08-1998 PJB Added #ifdef __KERNEL__
17 *
18 * FIXME - its probably worth seeing what these compile into...
19 */
20#ifndef __ASM_ARM_ATOMIC_H
21#define __ASM_ARM_ATOMIC_H
22
23#ifdef CONFIG_SMP
24#error SMP is NOT supported
25#endif
26
27typedef struct { volatile int counter; } atomic_t;
28
29#define ATOMIC_INIT(i) { (i) }
30
31#ifdef __KERNEL__
32#include <asm/system.h>
33
34#define atomic_read(v) ((v)->counter)
35#define atomic_set(v,i) (((v)->counter) = (i))
36
37static inline int atomic_add_return(int i, atomic_t *v)
38{
39 unsigned long flags;
40 int val;
41
42 local_irq_save(flags);
43 val = v->counter;
44 v->counter = val += i;
45 local_irq_restore(flags);
46
47 return val;
48}
49
50static inline int atomic_sub_return(int i, atomic_t *v)
51{
52 unsigned long flags;
53 int val;
54
55 local_irq_save(flags);
56 val = v->counter;
57 v->counter = val -= i;
58 local_irq_restore(flags);
59
60 return val;
61}
62
63static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
64{
65 int ret;
66 unsigned long flags;
67
68 local_irq_save(flags);
69 ret = v->counter;
70 if (likely(ret == old))
71 v->counter = new;
72 local_irq_restore(flags);
73
74 return ret;
75}
76
77#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
78
79static inline int atomic_add_unless(atomic_t *v, int a, int u)
80{
81 int ret;
82 unsigned long flags;
83
84 local_irq_save(flags);
85 ret = v->counter;
86 if (ret != u)
87 v->counter += a;
88 local_irq_restore(flags);
89
90 return ret != u;
91}
92#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
93
94static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
95{
96 unsigned long flags;
97
98 local_irq_save(flags);
99 *addr &= ~mask;
100 local_irq_restore(flags);
101}
102
103#define atomic_add(i, v) (void) atomic_add_return(i, v)
104#define atomic_inc(v) (void) atomic_add_return(1, v)
105#define atomic_sub(i, v) (void) atomic_sub_return(i, v)
106#define atomic_dec(v) (void) atomic_sub_return(1, v)
107
108#define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
109#define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
110#define atomic_inc_return(v) (atomic_add_return(1, v))
111#define atomic_dec_return(v) (atomic_sub_return(1, v))
112
113#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
114
115/* Atomic operations are already serializing on ARM26 */
116#define smp_mb__before_atomic_dec() barrier()
117#define smp_mb__after_atomic_dec() barrier()
118#define smp_mb__before_atomic_inc() barrier()
119#define smp_mb__after_atomic_inc() barrier()
120
121#include <asm-generic/atomic.h>
122#endif
123#endif
diff --git a/include/asm-arm26/auxvec.h b/include/asm-arm26/auxvec.h
deleted file mode 100644
index c0536f6b29a7..000000000000
--- a/include/asm-arm26/auxvec.h
+++ /dev/null
@@ -1,4 +0,0 @@
1#ifndef __ASMARM_AUXVEC_H
2#define __ASMARM_AUXVEC_H
3
4#endif
diff --git a/include/asm-arm26/bitops.h b/include/asm-arm26/bitops.h
deleted file mode 100644
index 19a69573a654..000000000000
--- a/include/asm-arm26/bitops.h
+++ /dev/null
@@ -1,207 +0,0 @@
1/*
2 * Copyright 1995, Russell King.
3 *
4 * Based on the arm32 version by RMK (and others). Their copyrights apply to
5 * Those parts.
6 * Modified for arm26 by Ian Molton on 25/11/04
7 *
8 * bit 0 is the LSB of an "unsigned long" quantity.
9 *
10 * Please note that the code in this file should never be included
11 * from user space. Many of these are not implemented in assembler
12 * since they would be too costly. Also, they require privileged
13 * instructions (which are not available from user mode) to ensure
14 * that they are atomic.
15 */
16
17#ifndef __ASM_ARM_BITOPS_H
18#define __ASM_ARM_BITOPS_H
19
20#ifdef __KERNEL__
21
22#include <linux/compiler.h>
23#include <asm/system.h>
24
25#define smp_mb__before_clear_bit() do { } while (0)
26#define smp_mb__after_clear_bit() do { } while (0)
27
28/*
29 * These functions are the basis of our bit ops.
30 *
31 * First, the atomic bitops. These use native endian.
32 */
33static inline void ____atomic_set_bit(unsigned int bit, volatile unsigned long *p)
34{
35 unsigned long flags;
36 unsigned long mask = 1UL << (bit & 31);
37
38 p += bit >> 5;
39
40 local_irq_save(flags);
41 *p |= mask;
42 local_irq_restore(flags);
43}
44
45static inline void ____atomic_clear_bit(unsigned int bit, volatile unsigned long *p)
46{
47 unsigned long flags;
48 unsigned long mask = 1UL << (bit & 31);
49
50 p += bit >> 5;
51
52 local_irq_save(flags);
53 *p &= ~mask;
54 local_irq_restore(flags);
55}
56
57static inline void ____atomic_change_bit(unsigned int bit, volatile unsigned long *p)
58{
59 unsigned long flags;
60 unsigned long mask = 1UL << (bit & 31);
61
62 p += bit >> 5;
63
64 local_irq_save(flags);
65 *p ^= mask;
66 local_irq_restore(flags);
67}
68
69static inline int
70____atomic_test_and_set_bit(unsigned int bit, volatile unsigned long *p)
71{
72 unsigned long flags;
73 unsigned int res;
74 unsigned long mask = 1UL << (bit & 31);
75
76 p += bit >> 5;
77
78 local_irq_save(flags);
79 res = *p;
80 *p = res | mask;
81 local_irq_restore(flags);
82
83 return res & mask;
84}
85
86static inline int
87____atomic_test_and_clear_bit(unsigned int bit, volatile unsigned long *p)
88{
89 unsigned long flags;
90 unsigned int res;
91 unsigned long mask = 1UL << (bit & 31);
92
93 p += bit >> 5;
94
95 local_irq_save(flags);
96 res = *p;
97 *p = res & ~mask;
98 local_irq_restore(flags);
99
100 return res & mask;
101}
102
103static inline int
104____atomic_test_and_change_bit(unsigned int bit, volatile unsigned long *p)
105{
106 unsigned long flags;
107 unsigned int res;
108 unsigned long mask = 1UL << (bit & 31);
109
110 p += bit >> 5;
111
112 local_irq_save(flags);
113 res = *p;
114 *p = res ^ mask;
115 local_irq_restore(flags);
116
117 return res & mask;
118}
119
120#include <asm-generic/bitops/non-atomic.h>
121
122/*
123 * Little endian assembly bitops. nr = 0 -> byte 0 bit 0.
124 */
125extern void _set_bit_le(int nr, volatile unsigned long * p);
126extern void _clear_bit_le(int nr, volatile unsigned long * p);
127extern void _change_bit_le(int nr, volatile unsigned long * p);
128extern int _test_and_set_bit_le(int nr, volatile unsigned long * p);
129extern int _test_and_clear_bit_le(int nr, volatile unsigned long * p);
130extern int _test_and_change_bit_le(int nr, volatile unsigned long * p);
131extern int _find_first_zero_bit_le(const unsigned long * p, unsigned size);
132extern int _find_next_zero_bit_le(void * p, int size, int offset);
133extern int _find_first_bit_le(const unsigned long *p, unsigned size);
134extern int _find_next_bit_le(const unsigned long *p, int size, int offset);
135
136/*
137 * The __* form of bitops are non-atomic and may be reordered.
138 */
139#define ATOMIC_BITOP_LE(name,nr,p) \
140 (__builtin_constant_p(nr) ? \
141 ____atomic_##name(nr, p) : \
142 _##name##_le(nr,p))
143
144#define NONATOMIC_BITOP(name,nr,p) \
145 (____nonatomic_##name(nr, p))
146
147/*
148 * These are the little endian, atomic definitions.
149 */
150#define set_bit(nr,p) ATOMIC_BITOP_LE(set_bit,nr,p)
151#define clear_bit(nr,p) ATOMIC_BITOP_LE(clear_bit,nr,p)
152#define change_bit(nr,p) ATOMIC_BITOP_LE(change_bit,nr,p)
153#define test_and_set_bit(nr,p) ATOMIC_BITOP_LE(test_and_set_bit,nr,p)
154#define test_and_clear_bit(nr,p) ATOMIC_BITOP_LE(test_and_clear_bit,nr,p)
155#define test_and_change_bit(nr,p) ATOMIC_BITOP_LE(test_and_change_bit,nr,p)
156#define find_first_zero_bit(p,sz) _find_first_zero_bit_le(p,sz)
157#define find_next_zero_bit(p,sz,off) _find_next_zero_bit_le(p,sz,off)
158#define find_first_bit(p,sz) _find_first_bit_le(p,sz)
159#define find_next_bit(p,sz,off) _find_next_bit_le(p,sz,off)
160
161#define WORD_BITOFF_TO_LE(x) ((x))
162
163#include <asm-generic/bitops/ffz.h>
164#include <asm-generic/bitops/__ffs.h>
165#include <asm-generic/bitops/fls.h>
166#include <asm-generic/bitops/fls64.h>
167#include <asm-generic/bitops/ffs.h>
168#include <asm-generic/bitops/sched.h>
169#include <asm-generic/bitops/hweight.h>
170
171/*
172 * Ext2 is defined to use little-endian byte ordering.
173 * These do not need to be atomic.
174 */
175#define ext2_set_bit(nr,p) \
176 __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
177#define ext2_set_bit_atomic(lock,nr,p) \
178 test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
179#define ext2_clear_bit(nr,p) \
180 __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
181#define ext2_clear_bit_atomic(lock,nr,p) \
182 test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
183#define ext2_test_bit(nr,p) \
184 test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
185#define ext2_find_first_zero_bit(p,sz) \
186 _find_first_zero_bit_le(p,sz)
187#define ext2_find_next_zero_bit(p,sz,off) \
188 _find_next_zero_bit_le(p,sz,off)
189
190/*
191 * Minix is defined to use little-endian byte ordering.
192 * These do not need to be atomic.
193 */
194#define minix_set_bit(nr,p) \
195 __set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
196#define minix_test_bit(nr,p) \
197 test_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
198#define minix_test_and_set_bit(nr,p) \
199 __test_and_set_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
200#define minix_test_and_clear_bit(nr,p) \
201 __test_and_clear_bit(WORD_BITOFF_TO_LE(nr), (unsigned long *)(p))
202#define minix_find_first_zero_bit(p,sz) \
203 _find_first_zero_bit_le((unsigned long *)(p),sz)
204
205#endif /* __KERNEL__ */
206
207#endif /* _ARM_BITOPS_H */
diff --git a/include/asm-arm26/bug.h b/include/asm-arm26/bug.h
deleted file mode 100644
index 8545d58b0475..000000000000
--- a/include/asm-arm26/bug.h
+++ /dev/null
@@ -1,19 +0,0 @@
1#ifndef _ASMARM_BUG_H
2#define _ASMARM_BUG_H
3
4
5#ifdef CONFIG_BUG
6#ifdef CONFIG_DEBUG_BUGVERBOSE
7extern volatile void __bug(const char *file, int line, void *data);
8/* give file/line information */
9#define BUG() __bug(__FILE__, __LINE__, NULL)
10#else
11#define BUG() (*(int *)0 = 0)
12#endif
13
14#define HAVE_ARCH_BUG
15#endif
16
17#include <asm-generic/bug.h>
18
19#endif
diff --git a/include/asm-arm26/bugs.h b/include/asm-arm26/bugs.h
deleted file mode 100644
index e99ac2e46d7f..000000000000
--- a/include/asm-arm26/bugs.h
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * linux/include/asm-arm26/bugs.h
3 *
4 * Copyright (C) 1995 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __ASM_BUGS_H
11#define __ASM_BUGS_H
12
13#define check_bugs() cpu_check_bugs()
14
15#endif
diff --git a/include/asm-arm26/byteorder.h b/include/asm-arm26/byteorder.h
deleted file mode 100644
index 0b4af9ac76e9..000000000000
--- a/include/asm-arm26/byteorder.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * linux/include/asm-arm/byteorder.h
3 *
4 * ARM Endian-ness. In little endian mode, the data bus is connected such
5 * that byte accesses appear as:
6 * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31
7 * and word accesses (data or instruction) appear as:
8 * d0...d31
9 *
10 */
11#ifndef __ASM_ARM_BYTEORDER_H
12#define __ASM_ARM_BYTEORDER_H
13
14#include <asm/types.h>
15
16#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
17# define __BYTEORDER_HAS_U64__
18# define __SWAB_64_THRU_32__
19#endif
20
21#include <linux/byteorder/little_endian.h>
22
23#endif
24
diff --git a/include/asm-arm26/cache.h b/include/asm-arm26/cache.h
deleted file mode 100644
index 8c3abcf728fe..000000000000
--- a/include/asm-arm26/cache.h
+++ /dev/null
@@ -1,12 +0,0 @@
1/*
2 * linux/include/asm-arm26/cache.h
3 */
4#ifndef __ASMARM_CACHE_H
5#define __ASMARM_CACHE_H
6
7#define L1_CACHE_SHIFT 5
8#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1))
10#define SMP_CACHE_BYTES L1_CACHE_BYTES
11
12#endif
diff --git a/include/asm-arm26/cacheflush.h b/include/asm-arm26/cacheflush.h
deleted file mode 100644
index 14ae15b6faab..000000000000
--- a/include/asm-arm26/cacheflush.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * linux/include/asm-arm/cacheflush.h
3 *
4 * Copyright (C) 2000-2002 Russell King
5 * Copyright (C) 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * ARM26 cache 'functions'
12 *
13 */
14
15#ifndef _ASMARM_CACHEFLUSH_H
16#define _ASMARM_CACHEFLUSH_H
17
18#if 1 //FIXME - BAD INCLUDES!!!
19#include <linux/sched.h>
20#include <linux/mm.h>
21#endif
22
23#define flush_cache_all() do { } while (0)
24#define flush_cache_mm(mm) do { } while (0)
25#define flush_cache_dup_mm(mm) do { } while (0)
26#define flush_cache_range(vma,start,end) do { } while (0)
27#define flush_cache_page(vma,vmaddr,pfn) do { } while (0)
28#define flush_cache_vmap(start, end) do { } while (0)
29#define flush_cache_vunmap(start, end) do { } while (0)
30
31#define invalidate_dcache_range(start,end) do { } while (0)
32#define clean_dcache_range(start,end) do { } while (0)
33#define flush_dcache_range(start,end) do { } while (0)
34#define flush_dcache_page(page) do { } while (0)
35#define flush_dcache_mmap_lock(mapping) do { } while (0)
36#define flush_dcache_mmap_unlock(mapping) do { } while (0)
37#define clean_dcache_entry(_s) do { } while (0)
38#define clean_cache_entry(_start) do { } while (0)
39
40#define flush_icache_user_range(start,end, bob, fred) do { } while (0)
41#define flush_icache_range(start,end) do { } while (0)
42#define flush_icache_page(vma,page) do { } while (0)
43
44#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
45 memcpy(dst, src, len)
46#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
47 memcpy(dst, src, len)
48
49/* DAG: ARM3 will flush cache on MEMC updates anyway? so don't bother */
50/* IM : Yes, it will, but only if setup to do so (we do this). */
51#define clean_cache_area(_start,_size) do { } while (0)
52
53#endif
diff --git a/include/asm-arm26/checksum.h b/include/asm-arm26/checksum.h
deleted file mode 100644
index f2b4b0a403bd..000000000000
--- a/include/asm-arm26/checksum.h
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2 * linux/include/asm-arm/checksum.h
3 *
4 * IP checksum routines
5 *
6 * Copyright (C) Original authors of ../asm-i386/checksum.h
7 * Copyright (C) 1996-1999 Russell King
8 */
9#ifndef __ASM_ARM_CHECKSUM_H
10#define __ASM_ARM_CHECKSUM_H
11
12#include <linux/in6.h>
13
14/*
15 * computes the checksum of a memory block at buff, length len,
16 * and adds in "sum" (32-bit)
17 *
18 * returns a 32-bit number suitable for feeding into itself
19 * or csum_tcpudp_magic
20 *
21 * this function must be called with even lengths, except
22 * for the last fragment, which may be odd
23 *
24 * it's best to have buff aligned on a 32-bit boundary
25 */
26__wsum csum_partial(const void *buff, int len, __wsum sum);
27
28/*
29 * the same as csum_partial, but copies from src while it
30 * checksums, and handles user-space pointer exceptions correctly, when needed.
31 *
32 * here even more important to align src and dst on a 32-bit (or even
33 * better 64-bit) boundary
34 */
35
36__wsum
37csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
38
39__wsum
40csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
41
42/*
43 * This is a version of ip_compute_csum() optimized for IP headers,
44 * which always checksum on 4 octet boundaries.
45 */
46static inline __sum16
47ip_fast_csum(const void *iph, unsigned int ihl)
48{
49 unsigned int sum, tmp1;
50
51 __asm__ __volatile__(
52 "ldr %0, [%1], #4 @ ip_fast_csum \n\
53 ldr %3, [%1], #4 \n\
54 sub %2, %2, #5 \n\
55 adds %0, %0, %3 \n\
56 ldr %3, [%1], #4 \n\
57 adcs %0, %0, %3 \n\
58 ldr %3, [%1], #4 \n\
591: adcs %0, %0, %3 \n\
60 ldr %3, [%1], #4 \n\
61 tst %2, #15 @ do this carefully \n\
62 subne %2, %2, #1 @ without destroying \n\
63 bne 1b @ the carry flag \n\
64 adcs %0, %0, %3 \n\
65 adc %0, %0, #0 \n\
66 adds %0, %0, %0, lsl #16 \n\
67 addcs %0, %0, #0x10000 \n\
68 mvn %0, %0 \n\
69 mov %0, %0, lsr #16"
70 : "=r" (sum), "=r" (iph), "=r" (ihl), "=r" (tmp1)
71 : "1" (iph), "2" (ihl)
72 : "cc");
73 return (__force __sum16)sum;
74}
75
76/*
77 * Fold a partial checksum without adding pseudo headers
78 */
79static inline __sum16 csum_fold(__wsum sum)
80{
81 __asm__(
82 "adds %0, %1, %1, lsl #16 @ csum_fold \n\
83 addcs %0, %0, #0x10000"
84 : "=r" (sum)
85 : "r" (sum)
86 : "cc");
87 return (__force __sum16)(~(__force u32)sum >> 16);
88}
89
90static inline __wsum
91csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
92 unsigned short proto, __wsum sum)
93{
94 __asm__(
95 "adds %0, %1, %2 @ csum_tcpudp_nofold \n\
96 adcs %0, %0, %3 \n\
97 adcs %0, %0, %4 \n\
98 adcs %0, %0, %5 \n\
99 adc %0, %0, #0"
100 : "=&r"(sum)
101 : "r" (sum), "r" (daddr), "r" (saddr), "r" (htons(len)), "Ir" (htons(proto))
102 : "cc");
103 return sum;
104}
105/*
106 * computes the checksum of the TCP/UDP pseudo-header
107 * returns a 16-bit checksum, already complemented
108 */
109static inline __sum16
110csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
111 unsigned short proto, __wsum sum)
112{
113 __asm__(
114 "adds %0, %1, %2 @ csum_tcpudp_magic \n\
115 adcs %0, %0, %3 \n\
116 adcs %0, %0, %4 \n\
117 adcs %0, %0, %5 \n\
118 adc %0, %0, #0 \n\
119 adds %0, %0, %0, lsl #16 \n\
120 addcs %0, %0, #0x10000 \n\
121 mvn %0, %0"
122 : "=&r"(sum)
123 : "r" (sum), "r" (daddr), "r" (saddr), "r" (htons(len)), "Ir" (htons(proto))
124 : "cc");
125 return (__force __sum16)((__force u32)sum >> 16);
126}
127
128
129/*
130 * this routine is used for miscellaneous IP-like checksums, mainly
131 * in icmp.c
132 */
133static inline __sum16
134ip_compute_csum(const void *buff, int len)
135{
136 return csum_fold(csum_partial(buff, len, 0));
137}
138
139#define _HAVE_ARCH_IPV6_CSUM
140extern __wsum
141__csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __be32 len,
142 __be32 proto, __wsum sum);
143
144static inline __sum16
145csum_ipv6_magic(const struct in6_addr *saddr, const struct in6_addr *daddr, __u32 len,
146 unsigned short proto, __wsum sum)
147{
148 return csum_fold(__csum_ipv6_magic(saddr, daddr, htonl(len),
149 htonl(proto), sum));
150}
151#endif
diff --git a/include/asm-arm26/constants.h b/include/asm-arm26/constants.h
deleted file mode 100644
index 0d0b14415563..000000000000
--- a/include/asm-arm26/constants.h
+++ /dev/null
@@ -1,28 +0,0 @@
1#ifndef __ASM_OFFSETS_H__
2#define __ASM_OFFSETS_H__
3/*
4 * DO NOT MODIFY.
5 *
6 * This file was generated by arch/arm26/Makefile
7 *
8 */
9
10#define TSK_ACTIVE_MM 96 /* offsetof(struct task_struct, active_mm) */
11
12#define VMA_VM_MM 0 /* offsetof(struct vm_area_struct, vm_mm) */
13#define VMA_VM_FLAGS 20 /* offsetof(struct vm_area_struct, vm_flags) */
14
15#define VM_EXEC 4 /* VM_EXEC */
16
17
18#define PAGE_PRESENT 1 /* L_PTE_PRESENT */
19#define PAGE_READONLY 95 /* PAGE_READONLY */
20#define PAGE_NOT_USER 3 /* PAGE_NONE */
21#define PAGE_OLD 3 /* PAGE_NONE */
22#define PAGE_CLEAN 128 /* L_PTE_DIRTY */
23
24#define PAGE_SZ 32768 /* PAGE_SIZE */
25
26#define SYS_ERROR0 10420224 /* 0x9f0000 */
27
28#endif
diff --git a/include/asm-arm26/cputime.h b/include/asm-arm26/cputime.h
deleted file mode 100644
index d2783a9e47b3..000000000000
--- a/include/asm-arm26/cputime.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ARM26_CPUTIME_H
2#define __ARM26_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* __ARM26_CPUTIME_H */
diff --git a/include/asm-arm26/current.h b/include/asm-arm26/current.h
deleted file mode 100644
index 75d21e2a3ff7..000000000000
--- a/include/asm-arm26/current.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef _ASMARM_CURRENT_H
2#define _ASMARM_CURRENT_H
3
4#include <linux/thread_info.h>
5
6static inline struct task_struct *get_current(void) __attribute_const__;
7
8static inline struct task_struct *get_current(void)
9{
10 return current_thread_info()->task;
11}
12
13#define current (get_current())
14
15#endif /* _ASMARM_CURRENT_H */
diff --git a/include/asm-arm26/delay.h b/include/asm-arm26/delay.h
deleted file mode 100644
index 40fbf7bbe6c2..000000000000
--- a/include/asm-arm26/delay.h
+++ /dev/null
@@ -1,34 +0,0 @@
1#ifndef __ASM_ARM_DELAY_H
2#define __ASM_ARM_DELAY_H
3
4/*
5 * Copyright (C) 1995 Russell King
6 *
7 * Delay routines, using a pre-computed "loops_per_second" value.
8 */
9
10extern void __delay(int loops);
11
12/*
13 * division by multiplication: you don't have to worry about
14 * loss of precision.
15 *
16 * Use only for very small delays ( < 1 msec). Should probably use a
17 * lookup table, really, as the multiplications take much too long with
18 * short delays. This is a "reasonable" implementation, though (and the
19 * first constant multiplications gets optimized away if the delay is
20 * a constant)
21 *
22 * FIXME - lets improve it then...
23 */
24extern void udelay(unsigned long usecs);
25
26static inline unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
27{
28 return a * b / c;
29}
30
31
32
33#endif /* defined(_ARM_DELAY_H) */
34
diff --git a/include/asm-arm26/device.h b/include/asm-arm26/device.h
deleted file mode 100644
index d8f9872b0e2d..000000000000
--- a/include/asm-arm26/device.h
+++ /dev/null
@@ -1,7 +0,0 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-arm26/div64.h b/include/asm-arm26/div64.h
deleted file mode 100644
index 6cd978cefb28..000000000000
--- a/include/asm-arm26/div64.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/div64.h>
diff --git a/include/asm-arm26/dma.h b/include/asm-arm26/dma.h
deleted file mode 100644
index 4326ba85eb72..000000000000
--- a/include/asm-arm26/dma.h
+++ /dev/null
@@ -1,183 +0,0 @@
1#ifndef __ASM_ARM_DMA_H
2#define __ASM_ARM_DMA_H
3
4typedef unsigned int dmach_t;
5
6#include <linux/spinlock.h>
7#include <asm/system.h>
8#include <asm/memory.h>
9#include <asm/scatterlist.h>
10
11// FIXME - do we really need this? arm26 cant do 'proper' DMA
12
13typedef struct dma_struct dma_t;
14typedef unsigned int dmamode_t;
15
16struct dma_ops {
17 int (*request)(dmach_t, dma_t *); /* optional */
18 void (*free)(dmach_t, dma_t *); /* optional */
19 void (*enable)(dmach_t, dma_t *); /* mandatory */
20 void (*disable)(dmach_t, dma_t *); /* mandatory */
21 int (*residue)(dmach_t, dma_t *); /* optional */
22 int (*setspeed)(dmach_t, dma_t *, int); /* optional */
23 char *type;
24};
25
26struct dma_struct {
27 struct scatterlist buf; /* single DMA */
28 int sgcount; /* number of DMA SG */
29 struct scatterlist *sg; /* DMA Scatter-Gather List */
30
31 unsigned int active:1; /* Transfer active */
32 unsigned int invalid:1; /* Address/Count changed */
33 unsigned int using_sg:1; /* using scatter list? */
34 dmamode_t dma_mode; /* DMA mode */
35 int speed; /* DMA speed */
36
37 unsigned int lock; /* Device is allocated */
38 const char *device_id; /* Device name */
39
40 unsigned int dma_base; /* Controller base address */
41 int dma_irq; /* Controller IRQ */
42 int state; /* Controller state */
43 struct scatterlist cur_sg; /* Current controller buffer */
44
45 struct dma_ops *d_ops;
46};
47
48/* Prototype: void arch_dma_init(dma)
49 * Purpose : Initialise architecture specific DMA
50 * Params : dma - pointer to array of DMA structures
51 */
52extern void arch_dma_init(dma_t *dma);
53
54extern void isa_init_dma(dma_t *dma);
55
56
57#define MAX_DMA_ADDRESS 0x03000000
58#define MAX_DMA_CHANNELS 3
59
60/* ARC */
61#define DMA_VIRTUAL_FLOPPY0 0
62#define DMA_VIRTUAL_FLOPPY1 1
63#define DMA_VIRTUAL_SOUND 2
64
65/* A5K */
66#define DMA_FLOPPY 0
67
68/*
69 * DMA modes
70 */
71#define DMA_MODE_MASK 3
72
73#define DMA_MODE_READ 0
74#define DMA_MODE_WRITE 1
75#define DMA_MODE_CASCADE 2
76#define DMA_AUTOINIT 4
77
78extern spinlock_t dma_spin_lock;
79
80static inline unsigned long claim_dma_lock(void)
81{
82 unsigned long flags;
83 spin_lock_irqsave(&dma_spin_lock, flags);
84 return flags;
85}
86
87static inline void release_dma_lock(unsigned long flags)
88{
89 spin_unlock_irqrestore(&dma_spin_lock, flags);
90}
91
92/* Clear the 'DMA Pointer Flip Flop'.
93 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
94 */
95#define clear_dma_ff(channel)
96
97/* Set only the page register bits of the transfer address.
98 *
99 * NOTE: This is an architecture specific function, and should
100 * be hidden from the drivers
101 */
102extern void set_dma_page(dmach_t channel, char pagenr);
103
104/* Request a DMA channel
105 *
106 * Some architectures may need to do allocate an interrupt
107 */
108extern int request_dma(dmach_t channel, const char * device_id);
109
110/* Free a DMA channel
111 *
112 * Some architectures may need to do free an interrupt
113 */
114extern void free_dma(dmach_t channel);
115
116/* Enable DMA for this channel
117 *
118 * On some architectures, this may have other side effects like
119 * enabling an interrupt and setting the DMA registers.
120 */
121extern void enable_dma(dmach_t channel);
122
123/* Disable DMA for this channel
124 *
125 * On some architectures, this may have other side effects like
126 * disabling an interrupt or whatever.
127 */
128extern void disable_dma(dmach_t channel);
129
130/* Test whether the specified channel has an active DMA transfer
131 */
132extern int dma_channel_active(dmach_t channel);
133
134/* Set the DMA scatter gather list for this channel
135 *
136 * This should not be called if a DMA channel is enabled,
137 * especially since some DMA architectures don't update the
138 * DMA address immediately, but defer it to the enable_dma().
139 */
140extern void set_dma_sg(dmach_t channel, struct scatterlist *sg, int nr_sg);
141
142/* Set the DMA address for this channel
143 *
144 * This should not be called if a DMA channel is enabled,
145 * especially since some DMA architectures don't update the
146 * DMA address immediately, but defer it to the enable_dma().
147 */
148extern void set_dma_addr(dmach_t channel, unsigned long physaddr);
149
150/* Set the DMA byte count for this channel
151 *
152 * This should not be called if a DMA channel is enabled,
153 * especially since some DMA architectures don't update the
154 * DMA count immediately, but defer it to the enable_dma().
155 */
156extern void set_dma_count(dmach_t channel, unsigned long count);
157
158/* Set the transfer direction for this channel
159 *
160 * This should not be called if a DMA channel is enabled,
161 * especially since some DMA architectures don't update the
162 * DMA transfer direction immediately, but defer it to the
163 * enable_dma().
164 */
165extern void set_dma_mode(dmach_t channel, dmamode_t mode);
166
167/* Set the transfer speed for this channel
168 */
169extern void set_dma_speed(dmach_t channel, int cycle_ns);
170
171/* Get DMA residue count. After a DMA transfer, this
172 * should return zero. Reading this while a DMA transfer is
173 * still in progress will return unpredictable results.
174 * If called before the channel has been used, it may return 1.
175 * Otherwise, it returns the number of _bytes_ left to transfer.
176 */
177extern int get_dma_residue(dmach_t channel);
178
179#ifndef NO_DMA
180#define NO_DMA 255
181#endif
182
183#endif /* _ARM_DMA_H */
diff --git a/include/asm-arm26/ecard.h b/include/asm-arm26/ecard.h
deleted file mode 100644
index 66691939c3c1..000000000000
--- a/include/asm-arm26/ecard.h
+++ /dev/null
@@ -1,294 +0,0 @@
1/*
2 * linux/include/asm-arm26/ecard.h
3 *
4 * definitions for expansion cards
5 *
6 * This is a new system as from Linux 1.2.3
7 *
8 * Changelog:
9 * 11-12-1996 RMK Further minor improvements
10 * 12-09-1997 RMK Added interrupt enable/disable for card level
11 * 18-05-2003 IM Adjusted for ARM26
12 *
13 * Reference: Acorns Risc OS 3 Programmers Reference Manuals.
14 */
15
16#ifndef __ASM_ECARD_H
17#define __ASM_ECARD_H
18
19/*
20 * Currently understood cards (but not necessarily
21 * supported):
22 * Manufacturer Product ID
23 */
24#define MANU_ACORN 0x0000
25#define PROD_ACORN_SCSI 0x0002
26#define PROD_ACORN_ETHER1 0x0003
27#define PROD_ACORN_MFM 0x000b
28
29#define MANU_CCONCEPTS 0x0009
30#define PROD_CCONCEPTS_COLOURCARD 0x0050
31
32#define MANU_ANT2 0x0011
33#define PROD_ANT_ETHER3 0x00a4
34
35#define MANU_ATOMWIDE 0x0017
36#define PROD_ATOMWIDE_3PSERIAL 0x0090
37
38#define MANU_IRLAM_INSTRUMENTS 0x001f
39#define MANU_IRLAM_INSTRUMENTS_ETHERN 0x5678
40
41#define MANU_OAK 0x0021
42#define PROD_OAK_SCSI 0x0058
43
44#define MANU_MORLEY 0x002b
45#define PROD_MORLEY_SCSI_UNCACHED 0x0067
46
47#define MANU_CUMANA 0x003a
48#define PROD_CUMANA_SCSI_2 0x003a
49#define PROD_CUMANA_SCSI_1 0x00a0
50
51#define MANU_ICS 0x003c
52#define PROD_ICS_IDE 0x00ae
53
54#define MANU_ICS2 0x003d
55#define PROD_ICS2_IDE 0x00ae
56
57#define MANU_SERPORT 0x003f
58#define PROD_SERPORT_DSPORT 0x00b9
59
60#define MANU_ARXE 0x0041
61#define PROD_ARXE_SCSI 0x00be
62
63#define MANU_I3 0x0046
64#define PROD_I3_ETHERLAN500 0x00d4
65#define PROD_I3_ETHERLAN600 0x00ec
66#define PROD_I3_ETHERLAN600A 0x011e
67
68#define MANU_ANT 0x0053
69#define PROD_ANT_ETHERM 0x00d8
70#define PROD_ANT_ETHERB 0x00e4
71
72#define MANU_ALSYSTEMS 0x005b
73#define PROD_ALSYS_SCSIATAPI 0x0107
74
75#define MANU_MCS 0x0063
76#define PROD_MCS_CONNECT32 0x0125
77
78#define MANU_EESOX 0x0064
79#define PROD_EESOX_SCSI2 0x008c
80
81#define MANU_YELLOWSTONE 0x0096
82#define PROD_YELLOWSTONE_RAPIDE32 0x0120
83
84#define MANU_SIMTEC 0x005f
85#define PROD_SIMTEC_IDE8 0x0130
86#define PROD_SIMTEC_IDE16 0x0131
87
88
89#ifdef ECARD_C
90#define CONST
91#else
92#define CONST const
93#endif
94
95#define MAX_ECARDS 4
96
97typedef enum { /* Cards address space */
98 ECARD_IOC,
99 ECARD_MEMC,
100 ECARD_EASI
101} card_type_t;
102
103typedef enum { /* Speed for ECARD_IOC space */
104 ECARD_SLOW = 0,
105 ECARD_MEDIUM = 1,
106 ECARD_FAST = 2,
107 ECARD_SYNC = 3
108} card_speed_t;
109
110struct ecard_id { /* Card ID structure */
111 unsigned short manufacturer;
112 unsigned short product;
113 void *data;
114};
115
116struct in_ecid { /* Packed card ID information */
117 unsigned short product; /* Product code */
118 unsigned short manufacturer; /* Manufacturer code */
119 unsigned char id:4; /* Simple ID */
120 unsigned char cd:1; /* Chunk dir present */
121 unsigned char is:1; /* Interrupt status pointers */
122 unsigned char w:2; /* Width */
123 unsigned char country; /* Country */
124 unsigned char irqmask; /* IRQ mask */
125 unsigned char fiqmask; /* FIQ mask */
126 unsigned long irqoff; /* IRQ offset */
127 unsigned long fiqoff; /* FIQ offset */
128};
129
130typedef struct expansion_card ecard_t;
131typedef unsigned long *loader_t;
132
133typedef struct { /* Card handler routines */
134 void (*irqenable)(ecard_t *ec, int irqnr);
135 void (*irqdisable)(ecard_t *ec, int irqnr);
136 int (*irqpending)(ecard_t *ec);
137 void (*fiqenable)(ecard_t *ec, int fiqnr);
138 void (*fiqdisable)(ecard_t *ec, int fiqnr);
139 int (*fiqpending)(ecard_t *ec);
140} expansioncard_ops_t;
141
142#define ECARD_NUM_RESOURCES (6)
143
144#define ECARD_RES_IOCSLOW (0)
145#define ECARD_RES_IOCMEDIUM (1)
146#define ECARD_RES_IOCFAST (2)
147#define ECARD_RES_IOCSYNC (3)
148#define ECARD_RES_MEMC (4)
149#define ECARD_RES_EASI (5)
150
151#define ecard_resource_start(ec,nr) ((ec)->resource[nr].start)
152#define ecard_resource_end(ec,nr) ((ec)->resource[nr].end)
153#define ecard_resource_len(ec,nr) ((ec)->resource[nr].end - \
154 (ec)->resource[nr].start + 1)
155
156/*
157 * This contains all the info needed on an expansion card
158 */
159struct expansion_card {
160 struct expansion_card *next;
161
162 struct device dev;
163 struct resource resource[ECARD_NUM_RESOURCES];
164
165 /* Public data */
166 volatile unsigned char *irqaddr; /* address of IRQ register */
167 volatile unsigned char *fiqaddr; /* address of FIQ register */
168 unsigned char irqmask; /* IRQ mask */
169 unsigned char fiqmask; /* FIQ mask */
170 unsigned char claimed; /* Card claimed? */
171
172 void *irq_data; /* Data for use for IRQ by card */
173 void *fiq_data; /* Data for use for FIQ by card */
174 const expansioncard_ops_t *ops; /* Enable/Disable Ops for card */
175
176 CONST unsigned int slot_no; /* Slot number */
177 CONST unsigned int dma; /* DMA number (for request_dma) */
178 CONST unsigned int irq; /* IRQ number (for request_irq) */
179 CONST unsigned int fiq; /* FIQ number (for request_irq) */
180 CONST card_type_t type; /* Type of card */
181 CONST struct in_ecid cid; /* Card Identification */
182
183 /* Private internal data */
184 const char *card_desc; /* Card description */
185 CONST unsigned int podaddr; /* Base Linux address for card */
186 CONST loader_t loader; /* loader program */
187 u64 dma_mask;
188};
189
190struct in_chunk_dir {
191 unsigned int start_offset;
192 union {
193 unsigned char string[256];
194 unsigned char data[1];
195 } d;
196};
197
198/*
199 * ecard_claim: claim an expansion card entry
200 * FIXME - are these atomic / called with interrupts off ?
201 */
202#define ecard_claim(ec) ((ec)->claimed = 1)
203
204/*
205 * ecard_release: release an expansion card entry
206 */
207#define ecard_release(ec) ((ec)->claimed = 0)
208
209/*
210 * Read a chunk from an expansion card
211 * cd : where to put read data
212 * ec : expansion card info struct
213 * id : id number to find
214 * num: (n+1)'th id to find.
215 */
216extern int ecard_readchunk (struct in_chunk_dir *cd, struct expansion_card *ec, int id, int num);
217
218/*
219 * Obtain the address of a card
220 */
221extern unsigned int ecard_address (struct expansion_card *ec, card_type_t card_type, card_speed_t speed);
222
223#ifdef ECARD_C
224/* Definitions internal to ecard.c - for it's use only!!
225 *
226 * External expansion card header as read from the card
227 */
228struct ex_ecid {
229 unsigned char r_irq:1;
230 unsigned char r_zero:1;
231 unsigned char r_fiq:1;
232 unsigned char r_id:4;
233 unsigned char r_a:1;
234
235 unsigned char r_cd:1;
236 unsigned char r_is:1;
237 unsigned char r_w:2;
238 unsigned char r_r1:4;
239
240 unsigned char r_r2:8;
241
242 unsigned char r_prod[2];
243
244 unsigned char r_manu[2];
245
246 unsigned char r_country;
247
248 unsigned char r_irqmask;
249 unsigned char r_irqoff[3];
250
251 unsigned char r_fiqmask;
252 unsigned char r_fiqoff[3];
253};
254
255/*
256 * Chunk directory entry as read from the card
257 */
258struct ex_chunk_dir {
259 unsigned char r_id;
260 unsigned char r_len[3];
261 unsigned long r_start;
262 union {
263 char string[256];
264 char data[1];
265 } d;
266#define c_id(x) ((x)->r_id)
267#define c_len(x) ((x)->r_len[0]|((x)->r_len[1]<<8)|((x)->r_len[2]<<16))
268#define c_start(x) ((x)->r_start)
269};
270
271#endif
272
273extern struct bus_type ecard_bus_type;
274
275#define ECARD_DEV(_d) container_of((_d), struct expansion_card, dev)
276
277struct ecard_driver {
278 int (*probe)(struct expansion_card *, const struct ecard_id *id);
279 void (*remove)(struct expansion_card *);
280 void (*shutdown)(struct expansion_card *);
281 const struct ecard_id *id_table;
282 unsigned int id;
283 struct device_driver drv;
284};
285
286#define ECARD_DRV(_d) container_of((_d), struct ecard_driver, drv)
287
288#define ecard_set_drvdata(ec,data) dev_set_drvdata(&(ec)->dev, (data))
289#define ecard_get_drvdata(ec) dev_get_drvdata(&(ec)->dev)
290
291int ecard_register_driver(struct ecard_driver *);
292void ecard_remove_driver(struct ecard_driver *);
293
294#endif
diff --git a/include/asm-arm26/elf.h b/include/asm-arm26/elf.h
deleted file mode 100644
index 5a47fdb3015d..000000000000
--- a/include/asm-arm26/elf.h
+++ /dev/null
@@ -1,77 +0,0 @@
1#ifndef __ASMARM_ELF_H
2#define __ASMARM_ELF_H
3
4/*
5 * ELF register definitions..
6 */
7
8#include <asm/ptrace.h>
9#include <asm/procinfo.h>
10
11//FIXME - is it always 32K ?
12
13#define ELF_EXEC_PAGESIZE 32768
14#define SET_PERSONALITY(ex,ibcs2) set_personality(PER_LINUX)
15
16typedef unsigned long elf_greg_t;
17typedef unsigned long elf_freg_t[3];
18
19#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
20typedef elf_greg_t elf_gregset_t[ELF_NGREG];
21
22typedef struct { void *null; } elf_fpregset_t;
23
24/*
25 * This is used to ensure we don't load something for the wrong architecture.
26 * We can only execute 26-bit code.
27 */
28
29#define EM_ARM 40
30#define EF_ARM_APCS26 0x08
31
32//#define elf_check_arch(x) ( ((x)->e_machine == EM_ARM) && ((x)->e_flags & EF_ARM_APCS26) ) FIXME!!!!! - this looks OK, but the flags seem to be wrong.
33#define elf_check_arch(x) (1)
34
35/*
36 * These are used to set parameters in the core dumps.
37 */
38#define ELF_CLASS ELFCLASS32
39#define ELF_DATA ELFDATA2LSB
40#define ELF_ARCH EM_ARM
41
42#define USE_ELF_CORE_DUMP
43
44/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
45 use of this is to invoke "./ld.so someprog" to test out a new version of
46 the loader. We need to make sure that it is out of the way of the program
47 that it will "exec", and that there is sufficient room for the brk. */
48
49#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
50
51/* When the program starts, a1 contains a pointer to a function to be
52 registered with atexit, as per the SVR4 ABI. A value of 0 means we
53 have no such handler. */
54#define ELF_PLAT_INIT(_r, load_addr) (_r)->ARM_r0 = 0
55
56/* This yields a mask that user programs can use to figure out what
57 instruction set this cpu supports. */
58
59extern unsigned int elf_hwcap;
60#define ELF_HWCAP (elf_hwcap)
61
62/* This yields a string that ld.so will use to load implementation
63 specific libraries for optimization. This is more specific in
64 intent than poking at uname or /proc/cpuinfo. */
65
66/* For now we just provide a fairly general string that describes the
67 processor family. This could be made more specific later if someone
68 implemented optimisations that require it. 26-bit CPUs give you
69 "v1l" for ARM2 (no SWP) and "v2l" for anything else (ARM1 isn't
70 supported).
71 */
72
73#define ELF_PLATFORM_SIZE 8
74extern char elf_platform[];
75#define ELF_PLATFORM (elf_platform)
76
77#endif
diff --git a/include/asm-arm26/emergency-restart.h b/include/asm-arm26/emergency-restart.h
deleted file mode 100644
index 108d8c48e42e..000000000000
--- a/include/asm-arm26/emergency-restart.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_EMERGENCY_RESTART_H
2#define _ASM_EMERGENCY_RESTART_H
3
4#include <asm-generic/emergency-restart.h>
5
6#endif /* _ASM_EMERGENCY_RESTART_H */
diff --git a/include/asm-arm26/errno.h b/include/asm-arm26/errno.h
deleted file mode 100644
index 6e60f0612bb6..000000000000
--- a/include/asm-arm26/errno.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ARM_ERRNO_H
2#define _ARM_ERRNO_H
3
4#include <asm-generic/errno.h>
5
6#endif
diff --git a/include/asm-arm26/fb.h b/include/asm-arm26/fb.h
deleted file mode 100644
index c7df38030992..000000000000
--- a/include/asm-arm26/fb.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#ifndef _ASM_FB_H_
2#define _ASM_FB_H_
3#include <linux/fb.h>
4
5#define fb_pgprotect(...) do {} while (0)
6
7static inline int fb_is_primary_device(struct fb_info *info)
8{
9 return 0;
10}
11
12#endif /* _ASM_FB_H_ */
diff --git a/include/asm-arm26/fcntl.h b/include/asm-arm26/fcntl.h
deleted file mode 100644
index d85995e7459e..000000000000
--- a/include/asm-arm26/fcntl.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#ifndef _ARM_FCNTL_H
2#define _ARM_FCNTL_H
3
4/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
5 located on an ext2 file system */
6#define O_DIRECTORY 040000 /* must be a directory */
7#define O_NOFOLLOW 0100000 /* don't follow links */
8#define O_DIRECT 0200000 /* direct disk access hint - currently ignored */
9#define O_LARGEFILE 0400000
10
11#include <asm-generic/fcntl.h>
12
13#endif
diff --git a/include/asm-arm26/fiq.h b/include/asm-arm26/fiq.h
deleted file mode 100644
index a3bad09e825c..000000000000
--- a/include/asm-arm26/fiq.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * linux/include/asm-arm/fiq.h
3 *
4 * Support for FIQ on ARM architectures.
5 * Written by Philip Blundell <philb@gnu.org>, 1998
6 * Re-written by Russell King
7 */
8
9#ifndef __ASM_FIQ_H
10#define __ASM_FIQ_H
11
12#include <asm/ptrace.h>
13
14struct fiq_handler {
15 struct fiq_handler *next;
16 /* Name
17 */
18 const char *name;
19 /* Called to ask driver to relinquish/
20 * reacquire FIQ
21 * return zero to accept, or -<errno>
22 */
23 int (*fiq_op)(void *, int relinquish);
24 /* data for the relinquish/reacquire functions
25 */
26 void *dev_id;
27};
28
29extern int claim_fiq(struct fiq_handler *f);
30extern void release_fiq(struct fiq_handler *f);
31extern void set_fiq_handler(void *start, unsigned int length);
32extern void set_fiq_regs(struct pt_regs *regs);
33extern void get_fiq_regs(struct pt_regs *regs);
34extern void enable_fiq(int fiq);
35extern void disable_fiq(int fiq);
36
37#endif
diff --git a/include/asm-arm26/floppy.h b/include/asm-arm26/floppy.h
deleted file mode 100644
index efb732165a4f..000000000000
--- a/include/asm-arm26/floppy.h
+++ /dev/null
@@ -1,141 +0,0 @@
1/*
2 * linux/include/asm-arm/floppy.h
3 *
4 * Copyright (C) 1996-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Note that we don't touch FLOPPY_DMA nor FLOPPY_IRQ here
11 */
12#ifndef __ASM_ARM_FLOPPY_H
13#define __ASM_ARM_FLOPPY_H
14
15#define fd_outb(val,port) \
16 do { \
17 if ((port) == FD_DOR) \
18 fd_setdor((val)); \
19 else \
20 outb((val),(port)); \
21 } while(0)
22
23#define fd_inb(port) inb((port))
24#define fd_request_irq() request_irq(IRQ_FLOPPYDISK,floppy_interrupt,\
25 IRQF_DISABLED,"floppy",NULL)
26#define fd_free_irq() free_irq(IRQ_FLOPPYDISK,NULL)
27#define fd_disable_irq() disable_irq(IRQ_FLOPPYDISK)
28#define fd_enable_irq() enable_irq(IRQ_FLOPPYDISK)
29
30#define fd_request_dma() request_dma(DMA_FLOPPY,"floppy")
31#define fd_free_dma() free_dma(DMA_FLOPPY)
32#define fd_disable_dma() disable_dma(DMA_FLOPPY)
33#define fd_enable_dma() enable_dma(DMA_FLOPPY)
34#define fd_clear_dma_ff() clear_dma_ff(DMA_FLOPPY)
35#define fd_set_dma_mode(mode) set_dma_mode(DMA_FLOPPY, (mode))
36#define fd_set_dma_addr(addr) set_dma_addr(DMA_FLOPPY, virt_to_bus((addr)))
37#define fd_set_dma_count(len) set_dma_count(DMA_FLOPPY, (len))
38#define fd_cacheflush(addr,sz)
39
40/* need to clean up dma.h */
41#define DMA_FLOPPYDISK DMA_FLOPPY
42
43/* Floppy_selects is the list of DOR's to select drive fd
44 *
45 * On initialisation, the floppy list is scanned, and the drives allocated
46 * in the order that they are found. This is done by seeking the drive
47 * to a non-zero track, and then restoring it to track 0. If an error occurs,
48 * then there is no floppy drive present. [to be put back in again]
49 */
50static unsigned char floppy_selects[2][4] =
51{
52 { 0x10, 0x21, 0x23, 0x33 },
53 { 0x10, 0x21, 0x23, 0x33 }
54};
55
56#define fd_setdor(dor) \
57do { \
58 int new_dor = (dor); \
59 if (new_dor & 0xf0) \
60 new_dor = (new_dor & 0x0c) | floppy_selects[fdc][new_dor & 3]; \
61 else \
62 new_dor &= 0x0c; \
63 outb(new_dor, FD_DOR); \
64} while (0)
65
66/*
67 * Someday, we'll automatically detect which drives are present...
68 */
69static inline void fd_scandrives (void)
70{
71#if 0
72 int floppy, drive_count;
73
74 fd_disable_irq();
75 raw_cmd = &default_raw_cmd;
76 raw_cmd->flags = FD_RAW_SPIN | FD_RAW_NEED_SEEK;
77 raw_cmd->track = 0;
78 raw_cmd->rate = ?;
79 drive_count = 0;
80 for (floppy = 0; floppy < 4; floppy ++) {
81 current_drive = drive_count;
82 /*
83 * Turn on floppy motor
84 */
85 if (start_motor(redo_fd_request))
86 continue;
87 /*
88 * Set up FDC
89 */
90 fdc_specify();
91 /*
92 * Tell FDC to recalibrate
93 */
94 output_byte(FD_RECALIBRATE);
95 LAST_OUT(UNIT(floppy));
96 /* wait for command to complete */
97 if (!successful) {
98 int i;
99 for (i = drive_count; i < 3; i--)
100 floppy_selects[fdc][i] = floppy_selects[fdc][i + 1];
101 floppy_selects[fdc][3] = 0;
102 floppy -= 1;
103 } else
104 drive_count++;
105 }
106#else
107 floppy_selects[0][0] = 0x10;
108 floppy_selects[0][1] = 0x21;
109 floppy_selects[0][2] = 0x23;
110 floppy_selects[0][3] = 0x33;
111#endif
112}
113
114#define FDC1 (0x3f0)
115
116#define FLOPPY0_TYPE 4
117#define FLOPPY1_TYPE 4
118
119#define N_FDC 1
120#define N_DRIVE 4
121
122#define FLOPPY_MOTOR_MASK 0xf0
123
124#define CROSS_64KB(a,s) (0)
125
126/*
127 * This allows people to reverse the order of
128 * fd0 and fd1, in case their hardware is
129 * strangely connected (as some RiscPCs
130 * and A5000s seem to be).
131 */
132static void driveswap(int *ints, int dummy, int dummy2)
133{
134 floppy_selects[0][0] ^= floppy_selects[0][1];
135 floppy_selects[0][1] ^= floppy_selects[0][0];
136 floppy_selects[0][0] ^= floppy_selects[0][1];
137}
138
139#define EXTRA_FLOPPY_PARAMS ,{ "driveswap", &driveswap, NULL, 0, 0 }
140
141#endif
diff --git a/include/asm-arm26/fpstate.h b/include/asm-arm26/fpstate.h
deleted file mode 100644
index 785749b3c5ab..000000000000
--- a/include/asm-arm26/fpstate.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * linux/include/asm-arm/fpstate.h
3 *
4 * Copyright (C) 1995 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARM_FPSTATE_H
12#define __ASM_ARM_FPSTATE_H
13
14#define FP_SIZE 35
15
16struct fp_hard_struct {
17 unsigned int save[FP_SIZE]; /* as yet undefined */
18};
19
20struct fp_soft_struct {
21 unsigned int save[FP_SIZE]; /* undefined information */
22};
23
24union fp_state {
25 struct fp_hard_struct hard;
26 struct fp_soft_struct soft;
27};
28
29#endif
diff --git a/include/asm-arm26/futex.h b/include/asm-arm26/futex.h
deleted file mode 100644
index 6a332a9f099c..000000000000
--- a/include/asm-arm26/futex.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_FUTEX_H
2#define _ASM_FUTEX_H
3
4#include <asm-generic/futex.h>
5
6#endif
diff --git a/include/asm-arm26/hardirq.h b/include/asm-arm26/hardirq.h
deleted file mode 100644
index e717742ffce0..000000000000
--- a/include/asm-arm26/hardirq.h
+++ /dev/null
@@ -1,32 +0,0 @@
1#ifndef __ASM_HARDIRQ_H
2#define __ASM_HARDIRQ_H
3
4#include <linux/cache.h>
5#include <linux/threads.h>
6#include <asm/irq.h>
7
8typedef struct {
9 unsigned int __softirq_pending;
10} ____cacheline_aligned irq_cpustat_t;
11
12#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
13
14#define HARDIRQ_BITS 8
15
16/*
17 * The hardirq mask has to be large enough to have space
18 * for potentially all IRQ sources in the system nesting
19 * on a single CPU:
20 */
21#if (1 << HARDIRQ_BITS) < NR_IRQS
22# error HARDIRQ_BITS is too low!
23#endif
24
25#ifndef CONFIG_SMP
26
27extern asmlinkage void __do_softirq(void);
28
29#endif
30
31
32#endif /* __ASM_HARDIRQ_H */
diff --git a/include/asm-arm26/hardware.h b/include/asm-arm26/hardware.h
deleted file mode 100644
index 801df0bde8b7..000000000000
--- a/include/asm-arm26/hardware.h
+++ /dev/null
@@ -1,109 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-arc/hardware.h
3 *
4 * Copyright (C) 1996-1999 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This file contains the hardware definitions of the
11 * Acorn Archimedes/A5000 machines.
12 *
13 * Modifications:
14 * 04-04-1998 PJB/RMK Merged arc and a5k versions
15 */
16#ifndef __ASM_HARDWARE_H
17#define __ASM_HARDWARE_H
18
19
20
21/*
22 * What hardware must be present - these can be tested by the kernel
23 * source.
24 */
25#define HAS_IOC
26#define HAS_MEMC
27#define HAS_VIDC
28
29#define VDMA_ALIGNMENT PAGE_SIZE
30#define VDMA_XFERSIZE 16
31#define VDMA_INIT 0
32#define VDMA_START 1
33#define VDMA_END 2
34
35#ifndef __ASSEMBLY__
36extern void memc_write(unsigned int reg, unsigned long val);
37
38#define video_set_dma(start,end,offset) \
39do { \
40 memc_write (VDMA_START, (start >> 2)); \
41 memc_write (VDMA_END, (end - VDMA_XFERSIZE) >> 2); \
42 memc_write (VDMA_INIT, (offset >> 2)); \
43} while (0)
44#endif
45
46
47/* Hardware addresses of major areas.
48 * *_START is the physical address
49 * *_SIZE is the size of the region
50 * *_BASE is the virtual address
51 */
52#define IO_START 0x03000000
53#define IO_SIZE 0x01000000
54#define IO_BASE 0x03000000
55
56/*
57 * Screen mapping information
58 */
59#define SCREEN_START 0x02000000
60#define SCREEN_END 0x02078000
61#define SCREEN_SIZE 0x00078000
62#define SCREEN_BASE 0x02000000
63
64
65#define EXPMASK_BASE 0x03360000
66#define IOEB_BASE 0x03350000
67#define VIDC_BASE 0x03400000
68#define LATCHA_BASE 0x03250040
69#define LATCHB_BASE 0x03250018
70#define IOC_BASE 0x03200000
71#define FLOPPYDMA_BASE 0x0302a000
72#define PCIO_BASE 0x03010000
73
74// FIXME - are the below correct?
75#define PODSLOT_IOC0_BASE 0x03240000
76#define PODSLOT_IOC_SIZE (1 << 14)
77#define PODSLOT_MEMC_BASE 0x03000000
78#define PODSLOT_MEMC_SIZE (1 << 14)
79
80#define vidc_writel(val) __raw_writel(val, VIDC_BASE)
81
82#ifndef __ASSEMBLY__
83
84/*
85 * for use with inb/outb
86 */
87#define IOEB_VID_CTL (IOEB_BASE + 0x48)
88#define IOEB_PRESENT (IOEB_BASE + 0x50)
89#define IOEB_PSCLR (IOEB_BASE + 0x58)
90#define IOEB_MONTYPE (IOEB_BASE + 0x70)
91
92//FIXME - These adresses are weird - ISTR some weirdo address shifting stuff was going on here...
93#define IO_EC_IOC_BASE 0x80090000
94#define IO_EC_MEMC_BASE 0x80000000
95
96#ifdef CONFIG_ARCH_ARC
97/* A680 hardware */
98#define WD1973_BASE 0x03290000
99#define WD1973_LATCH 0x03350000
100#define Z8530_BASE 0x032b0008
101#define SCSI_BASE 0x03100000
102#endif
103
104#endif
105
106#define EXPMASK_STATUS (EXPMASK_BASE + 0x00)
107#define EXPMASK_ENABLE (EXPMASK_BASE + 0x04)
108
109#endif
diff --git a/include/asm-arm26/ide.h b/include/asm-arm26/ide.h
deleted file mode 100644
index db804d751df9..000000000000
--- a/include/asm-arm26/ide.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * linux/include/asm-arm/ide.h
3 *
4 * Copyright (C) 1994-1996 Linus Torvalds & authors
5 */
6
7/*
8 * This file contains the i386 architecture specific IDE code.
9 */
10
11#ifndef __ASMARM_IDE_H
12#define __ASMARM_IDE_H
13
14#ifdef __KERNEL__
15
16#ifndef MAX_HWIFS
17#define MAX_HWIFS 4
18#endif
19
20#include <asm/irq.h>
21#include <asm/mach-types.h>
22
23/* JMA 18.05.03 these will never be needed, but the kernel needs them to compile */
24#define __ide_mm_insw(port,addr,len) readsw(port,addr,len)
25#define __ide_mm_insl(port,addr,len) readsl(port,addr,len)
26#define __ide_mm_outsw(port,addr,len) writesw(port,addr,len)
27#define __ide_mm_outsl(port,addr,len) writesl(port,addr,len)
28
29#define IDE_ARCH_OBSOLETE_INIT
30#define ide_default_io_ctl(base) (0)
31
32#endif /* __KERNEL__ */
33
34#endif /* __ASMARM_IDE_H */
diff --git a/include/asm-arm26/io.h b/include/asm-arm26/io.h
deleted file mode 100644
index a5a7a4d5e09c..000000000000
--- a/include/asm-arm26/io.h
+++ /dev/null
@@ -1,434 +0,0 @@
1/*
2 * linux/include/asm-arm/io.h
3 *
4 * Copyright (C) 1996-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Modifications:
11 * 16-Sep-1996 RMK Inlined the inx/outx functions & optimised for both
12 * constant addresses and variable addresses.
13 * 04-Dec-1997 RMK Moved a lot of this stuff to the new architecture
14 * specific IO header files.
15 * 27-Mar-1999 PJB Second parameter of memcpy_toio is const..
16 * 04-Apr-1999 PJB Added check_signature.
17 * 12-Dec-1999 RMK More cleanups
18 * 18-Jun-2000 RMK Removed virt_to_* and friends definitions
19 */
20#ifndef __ASM_ARM_IO_H
21#define __ASM_ARM_IO_H
22
23#ifdef __KERNEL__
24
25#include <linux/types.h>
26#include <asm/byteorder.h>
27#include <asm/memory.h>
28#include <asm/hardware.h>
29
30/*
31 * Generic IO read/write. These perform native-endian accesses. Note
32 * that some architectures will want to re-define __raw_{read,write}w.
33 */
34extern void __raw_writesb(unsigned int addr, const void *data, int bytelen);
35extern void __raw_writesw(unsigned int addr, const void *data, int wordlen);
36extern void __raw_writesl(unsigned int addr, const void *data, int longlen);
37
38extern void __raw_readsb(unsigned int addr, void *data, int bytelen);
39extern void __raw_readsw(unsigned int addr, void *data, int wordlen);
40extern void __raw_readsl(unsigned int addr, void *data, int longlen);
41
42#define __raw_writeb(v,a) (*(volatile unsigned char *)(a) = (v))
43#define __raw_writew(v,a) (*(volatile unsigned short *)(a) = (v))
44#define __raw_writel(v,a) (*(volatile unsigned int *)(a) = (v))
45
46#define __raw_readb(a) (*(volatile unsigned char *)(a))
47#define __raw_readw(a) (*(volatile unsigned short *)(a))
48#define __raw_readl(a) (*(volatile unsigned int *)(a))
49
50
51/*
52 * Bad read/write accesses...
53 */
54extern void __readwrite_bug(const char *fn);
55
56/*
57 * Now, pick up the machine-defined IO definitions
58 */
59
60#define IO_SPACE_LIMIT 0xffffffff
61
62/*
63 * GCC is totally crap at loading/storing data. We try to persuade it
64 * to do the right thing by using these whereever possible instead of
65 * the above.
66 */
67#define __arch_base_getb(b,o) \
68 ({ \
69 unsigned int v, r = (b); \
70 __asm__ __volatile__( \
71 "ldrb %0, [%1, %2]" \
72 : "=r" (v) \
73 : "r" (r), "Ir" (o)); \
74 v; \
75 })
76
77#define __arch_base_getl(b,o) \
78 ({ \
79 unsigned int v, r = (b); \
80 __asm__ __volatile__( \
81 "ldr %0, [%1, %2]" \
82 : "=r" (v) \
83 : "r" (r), "Ir" (o)); \
84 v; \
85 })
86
87#define __arch_base_putb(v,b,o) \
88 ({ \
89 unsigned int r = (b); \
90 __asm__ __volatile__( \
91 "strb %0, [%1, %2]" \
92 : \
93 : "r" (v), "r" (r), "Ir" (o)); \
94 })
95
96#define __arch_base_putl(v,b,o) \
97 ({ \
98 unsigned int r = (b); \
99 __asm__ __volatile__( \
100 "str %0, [%1, %2]" \
101 : \
102 : "r" (v), "r" (r), "Ir" (o)); \
103 })
104
105/*
106 * We use two different types of addressing - PC style addresses, and ARM
107 * addresses. PC style accesses the PC hardware with the normal PC IO
108 * addresses, eg 0x3f8 for serial#1. ARM addresses are 0x80000000+
109 * and are translated to the start of IO. Note that all addresses are
110 * shifted left!
111 */
112#define __PORT_PCIO(x) (!((x) & 0x80000000))
113
114/*
115 * Dynamic IO functions - let the compiler
116 * optimize the expressions
117 */
118static inline void __outb (unsigned int value, unsigned int port)
119{
120 unsigned long temp;
121 __asm__ __volatile__(
122 "tst %2, #0x80000000\n\t"
123 "mov %0, %4\n\t"
124 "addeq %0, %0, %3\n\t"
125 "strb %1, [%0, %2, lsl #2] @ outb"
126 : "=&r" (temp)
127 : "r" (value), "r" (port), "Ir" (PCIO_BASE - IO_BASE), "Ir" (IO_BASE)
128 : "cc");
129}
130
131static inline void __outw (unsigned int value, unsigned int port)
132{
133 unsigned long temp;
134 __asm__ __volatile__(
135 "tst %2, #0x80000000\n\t"
136 "mov %0, %4\n\t"
137 "addeq %0, %0, %3\n\t"
138 "str %1, [%0, %2, lsl #2] @ outw"
139 : "=&r" (temp)
140 : "r" (value|value<<16), "r" (port), "Ir" (PCIO_BASE - IO_BASE), "Ir" (IO_BASE)
141 : "cc");
142}
143
144static inline void __outl (unsigned int value, unsigned int port)
145{
146 unsigned long temp;
147 __asm__ __volatile__(
148 "tst %2, #0x80000000\n\t"
149 "mov %0, %4\n\t"
150 "addeq %0, %0, %3\n\t"
151 "str %1, [%0, %2, lsl #2] @ outl"
152 : "=&r" (temp)
153 : "r" (value), "r" (port), "Ir" (PCIO_BASE - IO_BASE), "Ir" (IO_BASE)
154 : "cc");
155}
156
157#define DECLARE_DYN_IN(sz,fnsuffix,instr) \
158static inline unsigned sz __in##fnsuffix (unsigned int port) \
159{ \
160 unsigned long temp, value; \
161 __asm__ __volatile__( \
162 "tst %2, #0x80000000\n\t" \
163 "mov %0, %4\n\t" \
164 "addeq %0, %0, %3\n\t" \
165 "ldr" instr " %1, [%0, %2, lsl #2] @ in" #fnsuffix \
166 : "=&r" (temp), "=r" (value) \
167 : "r" (port), "Ir" (PCIO_BASE - IO_BASE), "Ir" (IO_BASE) \
168 : "cc"); \
169 return (unsigned sz)value; \
170}
171
172static inline unsigned int __ioaddr (unsigned int port) \
173{ \
174 if (__PORT_PCIO(port)) \
175 return (unsigned int)(PCIO_BASE + (port << 2)); \
176 else \
177 return (unsigned int)(IO_BASE + (port << 2)); \
178}
179
180#define DECLARE_IO(sz,fnsuffix,instr) \
181 DECLARE_DYN_IN(sz,fnsuffix,instr)
182
183DECLARE_IO(char,b,"b")
184DECLARE_IO(short,w,"")
185DECLARE_IO(int,l,"")
186
187#undef DECLARE_IO
188#undef DECLARE_DYN_IN
189
190/*
191 * Constant address IO functions
192 *
193 * These have to be macros for the 'J' constraint to work -
194 * +/-4096 immediate operand.
195 */
196#define __outbc(value,port) \
197({ \
198 if (__PORT_PCIO((port))) \
199 __asm__ __volatile__( \
200 "strb %0, [%1, %2] @ outbc" \
201 : : "r" (value), "r" (PCIO_BASE), "Jr" ((port) << 2)); \
202 else \
203 __asm__ __volatile__( \
204 "strb %0, [%1, %2] @ outbc" \
205 : : "r" (value), "r" (IO_BASE), "r" ((port) << 2)); \
206})
207
208#define __inbc(port) \
209({ \
210 unsigned char result; \
211 if (__PORT_PCIO((port))) \
212 __asm__ __volatile__( \
213 "ldrb %0, [%1, %2] @ inbc" \
214 : "=r" (result) : "r" (PCIO_BASE), "Jr" ((port) << 2)); \
215 else \
216 __asm__ __volatile__( \
217 "ldrb %0, [%1, %2] @ inbc" \
218 : "=r" (result) : "r" (IO_BASE), "r" ((port) << 2)); \
219 result; \
220})
221
222#define __outwc(value,port) \
223({ \
224 unsigned long v = value; \
225 if (__PORT_PCIO((port))) \
226 __asm__ __volatile__( \
227 "str %0, [%1, %2] @ outwc" \
228 : : "r" (v|v<<16), "r" (PCIO_BASE), "Jr" ((port) << 2)); \
229 else \
230 __asm__ __volatile__( \
231 "str %0, [%1, %2] @ outwc" \
232 : : "r" (v|v<<16), "r" (IO_BASE), "r" ((port) << 2)); \
233})
234
235#define __inwc(port) \
236({ \
237 unsigned short result; \
238 if (__PORT_PCIO((port))) \
239 __asm__ __volatile__( \
240 "ldr %0, [%1, %2] @ inwc" \
241 : "=r" (result) : "r" (PCIO_BASE), "Jr" ((port) << 2)); \
242 else \
243 __asm__ __volatile__( \
244 "ldr %0, [%1, %2] @ inwc" \
245 : "=r" (result) : "r" (IO_BASE), "r" ((port) << 2)); \
246 result & 0xffff; \
247})
248
249#define __outlc(value,port) \
250({ \
251 unsigned long v = value; \
252 if (__PORT_PCIO((port))) \
253 __asm__ __volatile__( \
254 "str %0, [%1, %2] @ outlc" \
255 : : "r" (v), "r" (PCIO_BASE), "Jr" ((port) << 2)); \
256 else \
257 __asm__ __volatile__( \
258 "str %0, [%1, %2] @ outlc" \
259 : : "r" (v), "r" (IO_BASE), "r" ((port) << 2)); \
260})
261
262#define __inlc(port) \
263({ \
264 unsigned long result; \
265 if (__PORT_PCIO((port))) \
266 __asm__ __volatile__( \
267 "ldr %0, [%1, %2] @ inlc" \
268 : "=r" (result) : "r" (PCIO_BASE), "Jr" ((port) << 2)); \
269 else \
270 __asm__ __volatile__( \
271 "ldr %0, [%1, %2] @ inlc" \
272 : "=r" (result) : "r" (IO_BASE), "r" ((port) << 2)); \
273 result; \
274})
275
276#define __ioaddrc(port) \
277({ \
278 unsigned long addr; \
279 if (__PORT_PCIO((port))) \
280 addr = PCIO_BASE + ((port) << 2); \
281 else \
282 addr = IO_BASE + ((port) << 2); \
283 addr; \
284})
285
286#define inb(p) (__builtin_constant_p((p)) ? __inbc(p) : __inb(p))
287#define inw(p) (__builtin_constant_p((p)) ? __inwc(p) : __inw(p))
288#define inl(p) (__builtin_constant_p((p)) ? __inlc(p) : __inl(p))
289#define outb(v,p) (__builtin_constant_p((p)) ? __outbc(v,p) : __outb(v,p))
290#define outw(v,p) (__builtin_constant_p((p)) ? __outwc(v,p) : __outw(v,p))
291#define outl(v,p) (__builtin_constant_p((p)) ? __outlc(v,p) : __outl(v,p))
292#define __ioaddr(p) (__builtin_constant_p((p)) ? __ioaddr(p) : __ioaddrc(p))
293
294/* JMA 18.02.03 added sb,sl from arm/io.h, changing io to ioaddr */
295
296#define outsb(p,d,l) __raw_writesb(__ioaddr(p),d,l)
297#define outsw(p,d,l) __raw_writesw(__ioaddr(p),d,l)
298#define outsl(p,d,l) __raw_writesl(__ioaddr(p),d,l)
299
300#define insb(p,d,l) __raw_readsb(__ioaddr(p),d,l)
301#define insw(p,d,l) __raw_readsw(__ioaddr(p),d,l)
302#define insl(p,d,l) __raw_readsl(__ioaddr(p),d,l)
303
304#define insw(p,d,l) __raw_readsw(__ioaddr(p),d,l)
305#define outsw(p,d,l) __raw_writesw(__ioaddr(p),d,l)
306
307#define readb(c) (__readwrite_bug("readb"),0)
308#define readw(c) (__readwrite_bug("readw"),0)
309#define readl(c) (__readwrite_bug("readl"),0)
310#define readb_relaxed(addr) readb(addr)
311#define readw_relaxed(addr) readw(addr)
312#define readl_relaxed(addr) readl(addr)
313#define writeb(v,c) __readwrite_bug("writeb")
314#define writew(v,c) __readwrite_bug("writew")
315#define writel(v,c) __readwrite_bug("writel")
316
317#define readsw(p,d,l) (__readwrite_bug("readsw"),0)
318#define readsl(p,d,l) (__readwrite_bug("readsl"),0)
319#define writesw(p,d,l) __readwrite_bug("writesw")
320#define writesl(p,d,l) __readwrite_bug("writesl")
321
322#define mmiowb()
323
324/* the following macro is deprecated */
325#define ioaddr(port) __ioaddr((port))
326
327/*
328 * No ioremap support here.
329 */
330#define __arch_ioremap(c,s,f,a) ((void *)(c))
331#define __arch_iounmap(c) do { } while (0)
332
333
334#if defined(__arch_putb) || defined(__arch_putw) || defined(__arch_putl) || \
335 defined(__arch_getb) || defined(__arch_getw) || defined(__arch_getl)
336#warning machine class uses old __arch_putw or __arch_getw
337#endif
338
339/*
340 * IO port access primitives
341 * -------------------------
342 *
343 * The ARM doesn't have special IO access instructions; all IO is memory
344 * mapped. Note that these are defined to perform little endian accesses
345 * only. Their primary purpose is to access PCI and ISA peripherals.
346 *
347 * Note that for a big endian machine, this implies that the following
348 * big endian mode connectivity is in place, as described by numerious
349 * ARM documents:
350 *
351 * PCI: D0-D7 D8-D15 D16-D23 D24-D31
352 * ARM: D24-D31 D16-D23 D8-D15 D0-D7
353 *
354 * The machine specific io.h include defines __io to translate an "IO"
355 * address to a memory address.
356 *
357 * Note that we prevent GCC re-ordering or caching values in expressions
358 * by introducing sequence points into the in*() definitions. Note that
359 * __raw_* do not guarantee this behaviour.
360 */
361/*
362#define outsb(p,d,l) __raw_writesb(__io(p),d,l)
363#define outsw(p,d,l) __raw_writesw(__io(p),d,l)
364
365#define insb(p,d,l) __raw_readsb(__io(p),d,l)
366#define insw(p,d,l) __raw_readsw(__io(p),d,l)
367*/
368#define outb_p(val,port) outb((val),(port))
369#define outw_p(val,port) outw((val),(port))
370#define inb_p(port) inb((port))
371#define inw_p(port) inw((port))
372#define inl_p(port) inl((port))
373
374#define outsb_p(port,from,len) outsb(port,from,len)
375#define outsw_p(port,from,len) outsw(port,from,len)
376#define insb_p(port,to,len) insb(port,to,len)
377#define insw_p(port,to,len) insw(port,to,len)
378
379/*
380 * String version of IO memory access ops:
381 */
382extern void _memcpy_fromio(void *, unsigned long, size_t);
383extern void _memcpy_toio(unsigned long, const void *, size_t);
384extern void _memset_io(unsigned long, int, size_t);
385
386/*
387 * ioremap and friends.
388 *
389 * ioremap takes a PCI memory address, as specified in
390 * Documentation/IO-mapping.txt.
391 */
392extern void * __ioremap(unsigned long, size_t, unsigned long, unsigned long);
393extern void __iounmap(void *addr);
394
395#ifndef __arch_ioremap
396#define ioremap(cookie,size) __ioremap(cookie,size,0,1)
397#define ioremap_nocache(cookie,size) __ioremap(cookie,size,0,1)
398#define iounmap(cookie) __iounmap(cookie)
399#else
400#define ioremap(cookie,size) __arch_ioremap((cookie),(size),0,1)
401#define ioremap_nocache(cookie,size) __arch_ioremap((cookie),(size),0,1)
402#define iounmap(cookie) __arch_iounmap(cookie)
403#endif
404
405/*
406 * DMA-consistent mapping functions. These allocate/free a region of
407 * uncached, unwrite-buffered mapped memory space for use with DMA
408 * devices. This is the "generic" version. The PCI specific version
409 * is in pci.h
410 */
411extern void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle);
412extern void consistent_free(void *vaddr, size_t size, dma_addr_t handle);
413extern void consistent_sync(void *vaddr, size_t size, int rw);
414
415/*
416 * can the hardware map this into one segment or not, given no other
417 * constraints.
418 */
419#define BIOVEC_MERGEABLE(vec1, vec2) \
420 ((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
421
422/*
423 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
424 * access
425 */
426#define xlate_dev_mem_ptr(p) __va(p)
427
428/*
429 * Convert a virtual cached pointer to an uncached pointer
430 */
431#define xlate_dev_kmem_ptr(p) p
432
433#endif /* __KERNEL__ */
434#endif /* __ASM_ARM_IO_H */
diff --git a/include/asm-arm26/ioc.h b/include/asm-arm26/ioc.h
deleted file mode 100644
index b3b46ef65943..000000000000
--- a/include/asm-arm26/ioc.h
+++ /dev/null
@@ -1,72 +0,0 @@
1/*
2 * linux/include/asm-arm/hardware/ioc.h
3 *
4 * Copyright (C) Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Use these macros to read/write the IOC. All it does is perform the actual
11 * read/write.
12 */
13#ifndef __ASMARM_HARDWARE_IOC_H
14#define __ASMARM_HARDWARE_IOC_H
15
16#ifndef __ASSEMBLY__
17
18/*
19 * We use __raw_base variants here so that we give the compiler the
20 * chance to keep IOC_BASE in a register.
21 */
22#define ioc_readb(off) __raw_readb(IOC_BASE + (off))
23#define ioc_writeb(val,off) __raw_writeb(val, IOC_BASE + (off))
24
25#endif
26
27#define IOC_CONTROL (0x00)
28#define IOC_KARTTX (0x04)
29#define IOC_KARTRX (0x04)
30
31#define IOC_IRQSTATA (0x10)
32#define IOC_IRQREQA (0x14)
33#define IOC_IRQCLRA (0x14)
34#define IOC_IRQMASKA (0x18)
35
36#define IOC_IRQSTATB (0x20)
37#define IOC_IRQREQB (0x24)
38#define IOC_IRQMASKB (0x28)
39
40#define IOC_FIQSTAT (0x30)
41#define IOC_FIQREQ (0x34)
42#define IOC_FIQMASK (0x38)
43
44#define IOC_T0CNTL (0x40)
45#define IOC_T0LTCHL (0x40)
46#define IOC_T0CNTH (0x44)
47#define IOC_T0LTCHH (0x44)
48#define IOC_T0GO (0x48)
49#define IOC_T0LATCH (0x4c)
50
51#define IOC_T1CNTL (0x50)
52#define IOC_T1LTCHL (0x50)
53#define IOC_T1CNTH (0x54)
54#define IOC_T1LTCHH (0x54)
55#define IOC_T1GO (0x58)
56#define IOC_T1LATCH (0x5c)
57
58#define IOC_T2CNTL (0x60)
59#define IOC_T2LTCHL (0x60)
60#define IOC_T2CNTH (0x64)
61#define IOC_T2LTCHH (0x64)
62#define IOC_T2GO (0x68)
63#define IOC_T2LATCH (0x6c)
64
65#define IOC_T3CNTL (0x70)
66#define IOC_T3LTCHL (0x70)
67#define IOC_T3CNTH (0x74)
68#define IOC_T3LTCHH (0x74)
69#define IOC_T3GO (0x78)
70#define IOC_T3LATCH (0x7c)
71
72#endif
diff --git a/include/asm-arm26/ioctl.h b/include/asm-arm26/ioctl.h
deleted file mode 100644
index b279fe06dfe5..000000000000
--- a/include/asm-arm26/ioctl.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/ioctl.h>
diff --git a/include/asm-arm26/ioctls.h b/include/asm-arm26/ioctls.h
deleted file mode 100644
index 8a3296200be1..000000000000
--- a/include/asm-arm26/ioctls.h
+++ /dev/null
@@ -1,85 +0,0 @@
1#ifndef __ASM_ARM_IOCTLS_H
2#define __ASM_ARM_IOCTLS_H
3
4#include <asm/ioctl.h>
5
6/* 0x54 is just a magic number to make these relatively unique ('T') */
7
8#define TCGETS 0x5401
9#define TCSETS 0x5402
10#define TCSETSW 0x5403
11#define TCSETSF 0x5404
12#define TCGETA 0x5405
13#define TCSETA 0x5406
14#define TCSETAW 0x5407
15#define TCSETAF 0x5408
16#define TCSBRK 0x5409
17#define TCXONC 0x540A
18#define TCFLSH 0x540B
19#define TIOCEXCL 0x540C
20#define TIOCNXCL 0x540D
21#define TIOCSCTTY 0x540E
22#define TIOCGPGRP 0x540F
23#define TIOCSPGRP 0x5410
24#define TIOCOUTQ 0x5411
25#define TIOCSTI 0x5412
26#define TIOCGWINSZ 0x5413
27#define TIOCSWINSZ 0x5414
28#define TIOCMGET 0x5415
29#define TIOCMBIS 0x5416
30#define TIOCMBIC 0x5417
31#define TIOCMSET 0x5418
32#define TIOCGSOFTCAR 0x5419
33#define TIOCSSOFTCAR 0x541A
34#define FIONREAD 0x541B
35#define TIOCINQ FIONREAD
36#define TIOCLINUX 0x541C
37#define TIOCCONS 0x541D
38#define TIOCGSERIAL 0x541E
39#define TIOCSSERIAL 0x541F
40#define TIOCPKT 0x5420
41#define FIONBIO 0x5421
42#define TIOCNOTTY 0x5422
43#define TIOCSETD 0x5423
44#define TIOCGETD 0x5424
45#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
46#define TIOCTTYGSTRUCT 0x5426 /* For debugging only */
47#define TIOCSBRK 0x5427 /* BSD compatibility */
48#define TIOCCBRK 0x5428 /* BSD compatibility */
49#define TIOCGSID 0x5429 /* Return the session ID of FD */
50#define TCGETS2 _IOR('T',0x2A, struct termios2)
51#define TCSETS2 _IOW('T',0x2B, struct termios2)
52#define TCSETSW2 _IOW('T',0x2C, struct termios2)
53#define TCSETSF2 _IOW('T',0x2D, struct termios2)
54#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
55#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
56
57#define FIONCLEX 0x5450 /* these numbers need to be adjusted. */
58#define FIOCLEX 0x5451
59#define FIOASYNC 0x5452
60#define TIOCSERCONFIG 0x5453
61#define TIOCSERGWILD 0x5454
62#define TIOCSERSWILD 0x5455
63#define TIOCGLCKTRMIOS 0x5456
64#define TIOCSLCKTRMIOS 0x5457
65#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
66#define TIOCSERGETLSR 0x5459 /* Get line status register */
67#define TIOCSERGETMULTI 0x545A /* Get multiport config */
68#define TIOCSERSETMULTI 0x545B /* Set multiport config */
69
70#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
71#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
72#define FIOQSIZE 0x545E
73
74/* Used for packet mode */
75#define TIOCPKT_DATA 0
76#define TIOCPKT_FLUSHREAD 1
77#define TIOCPKT_FLUSHWRITE 2
78#define TIOCPKT_STOP 4
79#define TIOCPKT_START 8
80#define TIOCPKT_NOSTOP 16
81#define TIOCPKT_DOSTOP 32
82
83#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
84
85#endif
diff --git a/include/asm-arm26/ipc.h b/include/asm-arm26/ipc.h
deleted file mode 100644
index a46e3d9c2a3f..000000000000
--- a/include/asm-arm26/ipc.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/ipc.h>
diff --git a/include/asm-arm26/ipcbuf.h b/include/asm-arm26/ipcbuf.h
deleted file mode 100644
index 97683975f7df..000000000000
--- a/include/asm-arm26/ipcbuf.h
+++ /dev/null
@@ -1,29 +0,0 @@
1#ifndef __ASMARM_IPCBUF_H
2#define __ASMARM_IPCBUF_H
3
4/*
5 * The ipc64_perm structure for arm architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 32-bit mode_t and seq
11 * - 2 miscellaneous 32-bit values
12 */
13
14struct ipc64_perm
15{
16 __kernel_key_t key;
17 __kernel_uid32_t uid;
18 __kernel_gid32_t gid;
19 __kernel_uid32_t cuid;
20 __kernel_gid32_t cgid;
21 __kernel_mode_t mode;
22 unsigned short __pad1;
23 unsigned short seq;
24 unsigned short __pad2;
25 unsigned long __unused1;
26 unsigned long __unused2;
27};
28
29#endif /* __ASMARM_IPCBUF_H */
diff --git a/include/asm-arm26/irq.h b/include/asm-arm26/irq.h
deleted file mode 100644
index 52971b49ed3b..000000000000
--- a/include/asm-arm26/irq.h
+++ /dev/null
@@ -1,43 +0,0 @@
1#ifndef __ASM_ARM_IRQ_H
2#define __ASM_ARM_IRQ_H
3
4#include <asm/sysirq.h>
5
6#ifndef NR_IRQS
7#define NR_IRQS 128
8#endif
9
10
11/* JMA 18.05.02 Copied off arch/arm/irq.h */
12#ifndef irq_canonicalize
13#define irq_canonicalize(i) (i)
14#endif
15
16
17/*
18 * Use this value to indicate lack of interrupt
19 * capability
20 */
21#ifndef NO_IRQ
22#define NO_IRQ ((unsigned int)(-1))
23#endif
24
25struct irqaction;
26
27#define __IRQT_FALEDGE (1 << 0)
28#define __IRQT_RISEDGE (1 << 1)
29#define __IRQT_LOWLVL (1 << 2)
30#define __IRQT_HIGHLVL (1 << 3)
31
32#define IRQT_NOEDGE (0)
33#define IRQT_RISING (__IRQT_RISEDGE)
34#define IRQT_FALLING (__IRQT_FALEDGE)
35#define IRQT_BOTHEDGE (__IRQT_RISEDGE|__IRQT_FALEDGE)
36#define IRQT_LOW (__IRQT_LOWLVL)
37#define IRQT_HIGH (__IRQT_HIGHLVL)
38#define IRQT_PROBE (1 << 4)
39
40int set_irq_type(unsigned int irq, unsigned int type);
41
42#endif
43
diff --git a/include/asm-arm26/irqchip.h b/include/asm-arm26/irqchip.h
deleted file mode 100644
index 6a007a954098..000000000000
--- a/include/asm-arm26/irqchip.h
+++ /dev/null
@@ -1,101 +0,0 @@
1/*
2 * linux/include/asm-arm/mach/irq.h
3 *
4 * Copyright (C) 1995-2000 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __ASM_ARM_MACH_IRQ_H
11#define __ASM_ARM_MACH_IRQ_H
12
13struct irqdesc;
14struct pt_regs;
15struct seq_file;
16
17typedef void (*irq_handler_t)(unsigned int, struct irqdesc *, struct pt_regs *);
18typedef void (*irq_control_t)(unsigned int);
19
20struct irqchip {
21 /*
22 * Acknowledge the IRQ.
23 * If this is a level-based IRQ, then it is expected to mask the IRQ
24 * as well.
25 */
26 void (*ack)(unsigned int);
27 /*
28 * Mask the IRQ in hardware.
29 */
30 void (*mask)(unsigned int);
31 /*
32 * Unmask the IRQ in hardware.
33 */
34 void (*unmask)(unsigned int);
35 /*
36 * Re-run the IRQ
37 */
38 void (*rerun)(unsigned int);
39 /*
40 * Set the type of the IRQ.
41 */
42 int (*type)(unsigned int, unsigned int);
43};
44
45struct irqdesc {
46 irq_handler_t handle;
47 struct irqchip *chip;
48 struct irqaction *action;
49
50 unsigned int enabled : 1; /* IRQ is currently enabled */
51 unsigned int triggered: 1; /* IRQ has occurred */
52 unsigned int running : 1; /* IRQ is running */
53 unsigned int pending : 1; /* IRQ is pending */
54 unsigned int probing : 1; /* IRQ in use for a probe */
55 unsigned int probe_ok : 1; /* IRQ can be used for probe */
56 unsigned int valid : 1; /* IRQ claimable */
57 unsigned int noautoenable : 1; /* don't automatically enable IRQ */
58 unsigned int unused :23;
59 unsigned int depth; /* disable depth */
60
61 /*
62 * IRQ lock detection
63 */
64 unsigned int lck_cnt;
65 unsigned int lck_pc;
66 unsigned int lck_jif;
67};
68
69extern struct irqdesc irq_desc[];
70
71/*
72 * This is internal. Do not use it.
73 */
74extern void (*init_arch_irq)(void);
75extern void init_FIQ(void);
76extern int show_fiq_list(struct seq_file *, void *);
77void __set_irq_handler(unsigned int irq, irq_handler_t, int);
78
79/*
80 * External stuff.
81 */
82#define set_irq_handler(irq,handler) __set_irq_handler(irq,handler,0)
83#define set_irq_chained_handler(irq,handler) __set_irq_handler(irq,handler,1)
84
85void set_irq_chip(unsigned int irq, struct irqchip *);
86void set_irq_flags(unsigned int irq, unsigned int flags);
87
88#define IRQF_VALID (1 << 0)
89#define IRQF_PROBE (1 << 1)
90#define IRQF_NOAUTOEN (1 << 2)
91
92/*
93 * Built-in IRQ handlers.
94 */
95void do_level_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs);
96void do_edge_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs);
97void do_simple_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs);
98void do_bad_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs);
99void dummy_mask_unmask_irq(unsigned int irq);
100
101#endif
diff --git a/include/asm-arm26/kdebug.h b/include/asm-arm26/kdebug.h
deleted file mode 100644
index 6ece1b037665..000000000000
--- a/include/asm-arm26/kdebug.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kdebug.h>
diff --git a/include/asm-arm26/kmap_types.h b/include/asm-arm26/kmap_types.h
deleted file mode 100644
index d5da712b723c..000000000000
--- a/include/asm-arm26/kmap_types.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#ifndef __ARM_KMAP_TYPES_H
2#define __ARM_KMAP_TYPES_H
3
4/*
5 * This is the "bare minimum". AIO seems to require this.
6 */
7enum km_type {
8 KM_IRQ0,
9 KM_USER1
10};
11
12#endif
diff --git a/include/asm-arm26/leds.h b/include/asm-arm26/leds.h
deleted file mode 100644
index 12290ea55801..000000000000
--- a/include/asm-arm26/leds.h
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * linux/include/asm-arm/leds.h
3 *
4 * Copyright (C) 1998 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Event-driven interface for LEDs on machines
11 * Added led_start and led_stop- Alex Holden, 28th Dec 1998.
12 */
13#ifndef ASM_ARM_LEDS_H
14#define ASM_ARM_LEDS_H
15
16
17typedef enum {
18 led_idle_start,
19 led_idle_end,
20 led_timer,
21 led_start,
22 led_stop,
23 led_claim, /* override idle & timer leds */
24 led_release, /* restore idle & timer leds */
25 led_start_timer_mode,
26 led_stop_timer_mode,
27 led_green_on,
28 led_green_off,
29 led_amber_on,
30 led_amber_off,
31 led_red_on,
32 led_red_off,
33 led_blue_on,
34 led_blue_off,
35 /*
36 * I want this between led_timer and led_start, but
37 * someone has decided to export this to user space
38 */
39 led_halted
40} led_event_t;
41
42/* Use this routine to handle LEDs */
43
44#ifdef CONFIG_LEDS
45extern void (*leds_event)(led_event_t);
46#else
47#define leds_event(e)
48#endif
49
50#endif
diff --git a/include/asm-arm26/limits.h b/include/asm-arm26/limits.h
deleted file mode 100644
index 08d8c6600804..000000000000
--- a/include/asm-arm26/limits.h
+++ /dev/null
@@ -1,11 +0,0 @@
1#ifndef __ASM_PIPE_H
2#define __ASM_PIPE_H
3
4#ifndef PAGE_SIZE
5#include <asm/page.h>
6#endif
7
8#define PIPE_BUF PAGE_SIZE
9
10#endif
11
diff --git a/include/asm-arm26/linkage.h b/include/asm-arm26/linkage.h
deleted file mode 100644
index dbe4b4e31a5b..000000000000
--- a/include/asm-arm26/linkage.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4#define __ALIGN .align 0
5#define __ALIGN_STR ".align 0"
6
7#endif
diff --git a/include/asm-arm26/local.h b/include/asm-arm26/local.h
deleted file mode 100644
index 6759e9183cef..000000000000
--- a/include/asm-arm26/local.h
+++ /dev/null
@@ -1,2 +0,0 @@
1//FIXME - nicked from arm32 - check it is correct...
2#include <asm-generic/local.h>
diff --git a/include/asm-arm26/locks.h b/include/asm-arm26/locks.h
deleted file mode 100644
index 81b3bda2ed00..000000000000
--- a/include/asm-arm26/locks.h
+++ /dev/null
@@ -1,161 +0,0 @@
1/*
2 * linux/include/asm-arm/proc-armo/locks.h
3 *
4 * Copyright (C) 2000 Russell King
5 * Fixes for 26 bit machines, (C) 2000 Dave Gilbert
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Interrupt safe locking assembler.
12 */
13#ifndef __ASM_PROC_LOCKS_H
14#define __ASM_PROC_LOCKS_H
15
16/* Decrements by 1, fails if value < 0 */
17#define __down_op(ptr,fail) \
18 ({ \
19 __asm__ __volatile__ ( \
20 "@ atomic down operation\n" \
21" mov ip, pc\n" \
22" orr lr, ip, #0x08000000\n" \
23" teqp lr, #0\n" \
24" ldr lr, [%0]\n" \
25" and ip, ip, #0x0c000003\n" \
26" subs lr, lr, #1\n" \
27" str lr, [%0]\n" \
28" orrmi ip, ip, #0x80000000 @ set N\n" \
29" teqp ip, #0\n" \
30" movmi ip, %0\n" \
31" blmi " #fail \
32 : \
33 : "r" (ptr) \
34 : "ip", "lr", "cc"); \
35 })
36
37#define __down_op_ret(ptr,fail) \
38 ({ \
39 unsigned int result; \
40 __asm__ __volatile__ ( \
41" @ down_op_ret\n" \
42" mov ip, pc\n" \
43" orr lr, ip, #0x08000000\n" \
44" teqp lr, #0\n" \
45" ldr lr, [%1]\n" \
46" and ip, ip, #0x0c000003\n" \
47" subs lr, lr, #1\n" \
48" str lr, [%1]\n" \
49" orrmi ip, ip, #0x80000000 @ set N\n" \
50" teqp ip, #0\n" \
51" movmi ip, %1\n" \
52" movpl ip, #0\n" \
53" blmi " #fail "\n" \
54" mov %0, ip" \
55 : "=&r" (result) \
56 : "r" (ptr) \
57 : "ip", "lr", "cc"); \
58 result; \
59 })
60
61#define __up_op(ptr,wake) \
62 ({ \
63 __asm__ __volatile__ ( \
64 "@ up_op\n" \
65" mov ip, pc\n" \
66" orr lr, ip, #0x08000000\n" \
67" teqp lr, #0\n" \
68" ldr lr, [%0]\n" \
69" and ip, ip, #0x0c000003\n" \
70" adds lr, lr, #1\n" \
71" str lr, [%0]\n" \
72" orrle ip, ip, #0x80000000 @ set N - should this be mi ??? DAG ! \n" \
73" teqp ip, #0\n" \
74" movmi ip, %0\n" \
75" blmi " #wake \
76 : \
77 : "r" (ptr) \
78 : "ip", "lr", "cc"); \
79 })
80
81/*
82 * The value 0x01000000 supports up to 128 processors and
83 * lots of processes. BIAS must be chosen such that sub'ing
84 * BIAS once per CPU will result in the long remaining
85 * negative.
86 */
87#define RW_LOCK_BIAS 0x01000000
88#define RW_LOCK_BIAS_STR "0x01000000"
89
90/* Decrements by RW_LOCK_BIAS rather than 1, fails if value != 0 */
91#define __down_op_write(ptr,fail) \
92 ({ \
93 __asm__ __volatile__( \
94 "@ down_op_write\n" \
95" mov ip, pc\n" \
96" orr lr, ip, #0x08000000\n" \
97" teqp lr, #0\n" \
98" and ip, ip, #0x0c000003\n" \
99\
100" ldr lr, [%0]\n" \
101" subs lr, lr, %1\n" \
102" str lr, [%0]\n" \
103\
104" orreq ip, ip, #0x40000000 @ set Z \n"\
105" teqp ip, #0\n" \
106" movne ip, %0\n" \
107" blne " #fail \
108 : \
109 : "r" (ptr), "I" (RW_LOCK_BIAS) \
110 : "ip", "lr", "cc"); \
111 })
112
113/* Increments by RW_LOCK_BIAS, wakes if value >= 0 */
114#define __up_op_write(ptr,wake) \
115 ({ \
116 __asm__ __volatile__( \
117 "@ up_op_read\n" \
118" mov ip, pc\n" \
119" orr lr, ip, #0x08000000\n" \
120" teqp lr, #0\n" \
121\
122" ldr lr, [%0]\n" \
123" and ip, ip, #0x0c000003\n" \
124" adds lr, lr, %1\n" \
125" str lr, [%0]\n" \
126\
127" orrcs ip, ip, #0x20000000 @ set C\n" \
128" teqp ip, #0\n" \
129" movcs ip, %0\n" \
130" blcs " #wake \
131 : \
132 : "r" (ptr), "I" (RW_LOCK_BIAS) \
133 : "ip", "lr", "cc"); \
134 })
135
136#define __down_op_read(ptr,fail) \
137 __down_op(ptr, fail)
138
139#define __up_op_read(ptr,wake) \
140 ({ \
141 __asm__ __volatile__( \
142 "@ up_op_read\n" \
143" mov ip, pc\n" \
144" orr lr, ip, #0x08000000\n" \
145" teqp lr, #0\n" \
146\
147" ldr lr, [%0]\n" \
148" and ip, ip, #0x0c000003\n" \
149" adds lr, lr, %1\n" \
150" str lr, [%0]\n" \
151\
152" orreq ip, ip, #0x40000000 @ Set Z \n" \
153" teqp ip, #0\n" \
154" moveq ip, %0\n" \
155" bleq " #wake \
156 : \
157 : "r" (ptr), "I" (1) \
158 : "ip", "lr", "cc"); \
159 })
160
161#endif
diff --git a/include/asm-arm26/mach-types.h b/include/asm-arm26/mach-types.h
deleted file mode 100644
index 0aeaedcbac96..000000000000
--- a/include/asm-arm26/mach-types.h
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * Unlike ARM32 this is NOT automatically generated. DONT delete it
3 * Instead, consider FIXME-ing it so its auto-detected.
4 */
5
6#ifndef __ASM_ARM_MACH_TYPE_H
7#define __ASM_ARM_MACH_TYPE_H
8
9
10#ifndef __ASSEMBLY__
11extern unsigned int __machine_arch_type;
12#endif
13
14#define MACH_TYPE_ARCHIMEDES 10
15#define MACH_TYPE_A5K 11
16
17#ifdef CONFIG_ARCH_ARC
18# define machine_arch_type MACH_TYPE_ARCHIMEDES
19# define machine_is_archimedes() (machine_arch_type == MACH_TYPE_ARCHIMEDES)
20#else
21# define machine_is_archimedes() (0)
22#endif
23
24#ifdef CONFIG_ARCH_A5K
25# define machine_arch_type MACH_TYPE_A5K
26# define machine_is_a5k() (machine_arch_type == MACH_TYPE_A5K)
27#else
28# define machine_is_a5k() (0)
29#endif
30
31#ifndef machine_arch_type
32#error Unknown machine type
33#define machine_arch_type __machine_arch_type
34#endif
35
36#endif
diff --git a/include/asm-arm26/map.h b/include/asm-arm26/map.h
deleted file mode 100644
index 6e12a7fa5c5d..000000000000
--- a/include/asm-arm26/map.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * linux/include/asm-arm/map.h
3 *
4 * Copyright (C) 1999-2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Page table mapping constructs and function prototypes
11 */
12struct map_desc {
13 unsigned long virtual;
14 unsigned long physical;
15 unsigned long length;
16 unsigned int type;
17};
18
19struct meminfo;
20
21extern void create_memmap_holes(struct meminfo *);
22extern void memtable_init(struct meminfo *);
23extern void iotable_init(struct map_desc *);
24extern void setup_io_desc(void);
diff --git a/include/asm-arm26/mc146818rtc.h b/include/asm-arm26/mc146818rtc.h
deleted file mode 100644
index a234130db8f1..000000000000
--- a/include/asm-arm26/mc146818rtc.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * Machine dependent access functions for RTC registers.
3 */
4#ifndef _ASM_MC146818RTC_H
5#define _ASM_MC146818RTC_H
6
7#include <asm/irq.h>
8#include <asm/io.h>
9
10#ifndef RTC_PORT
11#define RTC_PORT(x) (0x70 + (x))
12#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */
13#endif
14
15/*
16 * The yet supported machines all access the RTC index register via
17 * an ISA port access but the way to access the date register differs ...
18 */
19#define CMOS_READ(addr) ({ \
20outb_p((addr),RTC_PORT(0)); \
21inb_p(RTC_PORT(1)); \
22})
23#define CMOS_WRITE(val, addr) ({ \
24outb_p((addr),RTC_PORT(0)); \
25outb_p((val),RTC_PORT(1)); \
26})
27
28#endif /* _ASM_MC146818RTC_H */
diff --git a/include/asm-arm26/memory.h b/include/asm-arm26/memory.h
deleted file mode 100644
index 7c1e5be39060..000000000000
--- a/include/asm-arm26/memory.h
+++ /dev/null
@@ -1,101 +0,0 @@
1/*
2 * linux/include/asm-arm26/memory.h
3 *
4 * Copyright (C) 2000-2002 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Note: this file should not be included by non-asm/.h files
11 */
12#ifndef __ASM_ARM_MEMORY_H
13#define __ASM_ARM_MEMORY_H
14
15/*
16 * User space: 26MB
17 */
18#define TASK_SIZE (0x01a00000UL)
19
20/*
21 * This decides where the kernel will search for a free chunk of vm
22 * space during mmap's.
23 */
24#define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
25
26/*
27 * Page offset: 32MB
28 */
29#define PAGE_OFFSET (0x02000000UL)
30#define PHYS_OFFSET (0x02000000UL)
31
32#define PHYS_TO_NID(addr) (0)
33
34/*
35 * PFNs are used to describe any physical page; this means
36 * PFN 0 == physical address 0.
37 *
38 * This is the PFN of the first RAM page in the kernel
39 * direct-mapped view. We assume this is the first page
40 * of RAM in the mem_map as well.
41 */
42#define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT)
43
44/*
45 * These are *only* valid on the kernel direct mapped RAM memory.
46 */
47static inline unsigned long virt_to_phys(void *x)
48{
49 return (unsigned long)x;
50}
51
52static inline void *phys_to_virt(unsigned long x)
53{
54 return (void *)((unsigned long)x);
55}
56
57#define __pa(x) (unsigned long)(x)
58#define __va(x) ((void *)(unsigned long)(x))
59
60/*
61 * Virtual <-> DMA view memory address translations
62 * Again, these are *only* valid on the kernel direct mapped RAM
63 * memory. Use of these is *deprecated*.
64 */
65#define virt_to_bus(x) ((unsigned long)(x))
66#define bus_to_virt(x) ((void *)((unsigned long)(x)))
67
68/*
69 * Conversion between a struct page and a physical address.
70 *
71 * Note: when converting an unknown physical address to a
72 * struct page, the resulting pointer must be validated
73 * using VALID_PAGE(). It must return an invalid struct page
74 * for any physical address not corresponding to a system
75 * RAM address.
76 *
77 * page_to_pfn(page) convert a struct page * to a PFN number
78 * pfn_to_page(pfn) convert a _valid_ PFN number to struct page *
79 * pfn_valid(pfn) indicates whether a PFN number is valid
80 *
81 * virt_to_page(k) convert a _valid_ virtual address to struct page *
82 * virt_addr_valid(k) indicates whether a virtual address is valid
83 */
84#define ARCH_PFN_OFFSET (PHYS_PFN_OFFSET)
85#define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
86
87#define virt_to_page(kaddr) (pfn_to_page(__pa(kaddr) >> PAGE_SHIFT))
88#define virt_addr_valid(kaddr) ((int)(kaddr) >= PAGE_OFFSET && (int)(kaddr) < (unsigned long)high_memory)
89
90/*
91 * For BIO. "will die". Kill me when bio_to_phys() and bvec_to_phys() die.
92 */
93#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
94
95/*
96 * We should really eliminate virt_to_bus() here - it's deprecated.
97 */
98#define page_to_bus(page) (page_address(page))
99
100#include <asm-generic/memory_model.h>
101#endif
diff --git a/include/asm-arm26/mman.h b/include/asm-arm26/mman.h
deleted file mode 100644
index 4000a6c1b76b..000000000000
--- a/include/asm-arm26/mman.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef __ARM_MMAN_H__
2#define __ARM_MMAN_H__
3
4#include <asm-generic/mman.h>
5
6#define MAP_GROWSDOWN 0x0100 /* stack-like segment */
7#define MAP_DENYWRITE 0x0800 /* ETXTBSY */
8#define MAP_EXECUTABLE 0x1000 /* mark it as an executable */
9#define MAP_LOCKED 0x2000 /* pages are locked */
10#define MAP_NORESERVE 0x4000 /* don't check for reservations */
11#define MAP_POPULATE 0x8000 /* populate (prefault) page tables */
12#define MAP_NONBLOCK 0x10000 /* do not block on IO */
13
14#define MCL_CURRENT 1 /* lock all current mappings */
15#define MCL_FUTURE 2 /* lock all future mappings */
16
17#endif /* __ARM_MMAN_H__ */
diff --git a/include/asm-arm26/mmu.h b/include/asm-arm26/mmu.h
deleted file mode 100644
index 9b8d3d781a1e..000000000000
--- a/include/asm-arm26/mmu.h
+++ /dev/null
@@ -1,9 +0,0 @@
1#ifndef __ARM_MMU_H
2#define __ARM_MMU_H
3
4/*
5 * The ARM doesn't have a mmu context
6 */
7typedef struct { } mm_context_t;
8
9#endif
diff --git a/include/asm-arm26/mmu_context.h b/include/asm-arm26/mmu_context.h
deleted file mode 100644
index 16c821f81b8d..000000000000
--- a/include/asm-arm26/mmu_context.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * linux/include/asm-arm/mmu_context.h
3 *
4 * Copyright (C) 1996 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Changelog:
11 * 27-06-1996 RMK Created
12 */
13#ifndef __ASM_ARM_MMU_CONTEXT_H
14#define __ASM_ARM_MMU_CONTEXT_H
15
16#include <asm-generic/mm_hooks.h>
17
18#define init_new_context(tsk,mm) 0
19#define destroy_context(mm) do { } while(0)
20
21/*
22 * This is called when "tsk" is about to enter lazy TLB mode.
23 *
24 * mm: describes the currently active mm context
25 * tsk: task which is entering lazy tlb
26 * cpu: cpu number which is entering lazy tlb
27 *
28 * tsk->mm will be NULL
29 */
30static inline void
31enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
32{
33}
34
35/*
36 * This is the actual mm switch as far as the scheduler
37 * is concerned. No registers are touched.
38 */
39static inline void
40switch_mm(struct mm_struct *prev, struct mm_struct *next,
41 struct task_struct *tsk)
42{
43 cpu_switch_mm(next->pgd, next);
44}
45
46#define deactivate_mm(tsk,mm) do { } while (0)
47
48static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
49{
50 cpu_switch_mm(next->pgd, next);
51}
52
53#endif
diff --git a/include/asm-arm26/module.h b/include/asm-arm26/module.h
deleted file mode 100644
index 1157f178daec..000000000000
--- a/include/asm-arm26/module.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef _ASM_ARM_MODULE_H
2#define _ASM_ARM_MODULE_H
3/*
4 * This file contains the arm architecture specific module code.
5 */
6
7#endif /* _ASM_ARM_MODULE_H */
diff --git a/include/asm-arm26/msgbuf.h b/include/asm-arm26/msgbuf.h
deleted file mode 100644
index 33b35b946eaa..000000000000
--- a/include/asm-arm26/msgbuf.h
+++ /dev/null
@@ -1,31 +0,0 @@
1#ifndef _ASMARM_MSGBUF_H
2#define _ASMARM_MSGBUF_H
3
4/*
5 * The msqid64_ds structure for arm architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 64-bit time_t to solve y2038 problem
11 * - 2 miscellaneous 32-bit values
12 */
13
14struct msqid64_ds {
15 struct ipc64_perm msg_perm;
16 __kernel_time_t msg_stime; /* last msgsnd time */
17 unsigned long __unused1;
18 __kernel_time_t msg_rtime; /* last msgrcv time */
19 unsigned long __unused2;
20 __kernel_time_t msg_ctime; /* last change time */
21 unsigned long __unused3;
22 unsigned long msg_cbytes; /* current number of bytes on queue */
23 unsigned long msg_qnum; /* number of messages in queue */
24 unsigned long msg_qbytes; /* max number of bytes on queue */
25 __kernel_pid_t msg_lspid; /* pid of last msgsnd */
26 __kernel_pid_t msg_lrpid; /* last receive pid */
27 unsigned long __unused4;
28 unsigned long __unused5;
29};
30
31#endif /* _ASMARM_MSGBUF_H */
diff --git a/include/asm-arm26/namei.h b/include/asm-arm26/namei.h
deleted file mode 100644
index 3f5d340110eb..000000000000
--- a/include/asm-arm26/namei.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * linux/include/asm-arm26/namei.h
3 *
4 * Routines to handle famous /usr/gnemul
5 * Derived from the Sparc version of this file
6 *
7 * Included from linux/fs/namei.c
8 */
9
10#ifndef __ASMARM_NAMEI_H
11#define __ASMARM_NAMEI_H
12
13#define ARM_BSD_EMUL "usr/gnemul/bsd/"
14
15static inline char *__emul_prefix(void)
16{
17 switch (current->personality) {
18 case PER_BSD:
19 return ARM_BSD_EMUL;
20 default:
21 return NULL;
22 }
23}
24
25#endif /* __ASMARM_NAMEI_H */
diff --git a/include/asm-arm26/oldlatches.h b/include/asm-arm26/oldlatches.h
deleted file mode 100644
index bc87089b2152..000000000000
--- a/include/asm-arm26/oldlatches.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-arc/oldlatches.h
3 *
4 * Copyright (C) 1996 Russell King, Dave Gilbert
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Modifications:
11 * 04-04-1998 PJB/RMK Merged arc and a5k versions
12 */
13#ifndef _ASM_ARCH_OLDLATCH_H
14#define _ASM_ARCH_OLDLATCH_H
15
16#define LATCHA_FDSEL0 (1<<0)
17#define LATCHA_FDSEL1 (1<<1)
18#define LATCHA_FDSEL2 (1<<2)
19#define LATCHA_FDSEL3 (1<<3)
20#define LATCHA_FDSELALL (0xf)
21#define LATCHA_SIDESEL (1<<4)
22#define LATCHA_MOTOR (1<<5)
23#define LATCHA_INUSE (1<<6)
24#define LATCHA_CHANGERST (1<<7)
25
26#define LATCHB_FDCDENSITY (1<<1)
27#define LATCHB_FDCRESET (1<<3)
28#define LATCHB_PRINTSTROBE (1<<4)
29
30/* newval=(oldval & mask)|newdata */
31void oldlatch_bupdate(unsigned char mask,unsigned char newdata);
32
33/* newval=(oldval & mask)|newdata */
34void oldlatch_aupdate(unsigned char mask,unsigned char newdata);
35
36#endif
37
diff --git a/include/asm-arm26/page.h b/include/asm-arm26/page.h
deleted file mode 100644
index fa19de28fda0..000000000000
--- a/include/asm-arm26/page.h
+++ /dev/null
@@ -1,102 +0,0 @@
1#ifndef _ASMARM_PAGE_H
2#define _ASMARM_PAGE_H
3
4
5#ifdef __KERNEL__
6#ifndef __ASSEMBLY__
7
8extern void __clear_user_page(void *p, unsigned long user);
9extern void __copy_user_page(void *to, const void *from, unsigned long user);
10extern void copy_page(void *to, const void *from);
11
12//FIXME these may be wrong on ARM26
13#define clear_user_page(addr,vaddr,pg) \
14 do { \
15 preempt_disable(); \
16 __clear_user_page(addr, vaddr); \
17 preempt_enable(); \
18 } while (0)
19
20#define copy_user_page(to,from,vaddr,pg) \
21 do { \
22 preempt_disable(); \
23 __copy_user_page(to, from, vaddr); \
24 preempt_enable(); \
25 } while (0)
26
27#define clear_page(page) memzero((void *)(page), PAGE_SIZE)
28#define copy_page(to, from) __copy_user_page(to, from, 0);
29
30#undef STRICT_MM_TYPECHECKS
31
32#ifdef STRICT_MM_TYPECHECKS
33/*
34 * These are used to make use of C type-checking..
35 */
36typedef struct { unsigned long pgd; } pgd_t;
37typedef struct { unsigned long pte; } pte_t;
38typedef struct { unsigned long pmd; } pmd_t;
39typedef struct { unsigned long pgprot; } pgprot_t;
40
41#define pgd_val(x) ((x).pgd)
42#define pte_val(x) ((x).pte)
43#define pmd_val(x) ((x).pmd)
44#define pgprot_val(x) ((x).pgprot)
45
46#define __pte(x) ((pte_t) { (x) } )
47#define __pmd(x) ((pmd_t) { (x) } )
48#define __pgprot(x) ((pgprot_t) { (x) } )
49
50#else
51/*
52 * .. while these make it easier on the compiler
53 */
54typedef unsigned long pgd_t;
55typedef unsigned long pte_t;
56typedef unsigned long pmd_t;
57typedef unsigned long pgprot_t;
58
59//FIXME - should these cast to unsigned long?
60#define pgd_val(x) (x)
61#define pte_val(x) (x)
62#define pmd_val(x) (x)
63#define pgprot_val(x) (x)
64
65#define __pte(x) (x)
66#define __pmd(x) (x)
67#define __pgprot(x) (x)
68
69#endif /* STRICT_MM_TYPECHECKS */
70#endif /* !__ASSEMBLY__ */
71#endif /* __KERNEL__ */
72
73/* PAGE_SHIFT determines the page size. This is configurable. */
74#if defined(CONFIG_PAGESIZE_16)
75#define PAGE_SHIFT 14 /* 16K */
76#else /* default */
77#define PAGE_SHIFT 15 /* 32K */
78#endif
79
80#define EXEC_PAGESIZE 32768
81
82#define PAGE_SIZE (1UL << PAGE_SHIFT)
83#define PAGE_MASK (~(PAGE_SIZE-1))
84
85/* to align the pointer to the (next) page boundary */
86#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
87
88#ifdef __KERNEL__
89#ifndef __ASSEMBLY__
90
91#include <asm/memory.h>
92
93#endif /* !__ASSEMBLY__ */
94
95#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
96 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
97
98#endif /* __KERNEL__ */
99
100#include <asm-generic/page.h>
101
102#endif
diff --git a/include/asm-arm26/param.h b/include/asm-arm26/param.h
deleted file mode 100644
index 6b1e52df542e..000000000000
--- a/include/asm-arm26/param.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * linux/include/asm-arm/param.h
3 *
4 * Copyright (C) 1995-1999 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __ASM_PARAM_H
11#define __ASM_PARAM_H
12
13#ifndef __KERNEL_HZ
14#define __KERNEL_HZ 100
15#endif
16
17#ifdef __KERNEL__
18# define HZ __KERNEL_HZ /* Internal kernel timer frequency */
19# define USER_HZ 100 /* User interfaces are in "ticks" */
20# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
21#else
22# define HZ 100
23#endif
24
25#ifndef NOGROUP
26#define NOGROUP (-1)
27#endif
28
29/* max length of hostname */
30#define MAXHOSTNAMELEN 64
31
32#endif
33
diff --git a/include/asm-arm26/parport.h b/include/asm-arm26/parport.h
deleted file mode 100644
index f2f90c76ddd1..000000000000
--- a/include/asm-arm26/parport.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 * linux/include/asm-arm/parport.h: ARM-specific parport initialisation
3 *
4 * Copyright (C) 1999, 2000 Tim Waugh <tim@cyberelk.demon.co.uk>
5 *
6 * This file should only be included by drivers/parport/parport_pc.c.
7 */
8
9#ifndef __ASMARM_PARPORT_H
10#define __ASMARM_PARPORT_H
11
12static int __devinit parport_pc_find_isa_ports (int autoirq, int autodma);
13static int __devinit parport_pc_find_nonpci_ports (int autoirq, int autodma)
14{
15 return parport_pc_find_isa_ports (autoirq, autodma);
16}
17
18#endif /* !(_ASMARM_PARPORT_H) */
diff --git a/include/asm-arm26/pci.h b/include/asm-arm26/pci.h
deleted file mode 100644
index 6ac67ed7718c..000000000000
--- a/include/asm-arm26/pci.h
+++ /dev/null
@@ -1,6 +0,0 @@
1/* Should not be needed. IDE stupidity */
2/* JMA 18.05.03 - is kinda needed, if only to tell it we don't have a PCI bus */
3
4#define PCI_DMA_BUS_IS_PHYS 0
5#define pcibios_scan_all_fns(a, b) 0
6
diff --git a/include/asm-arm26/percpu.h b/include/asm-arm26/percpu.h
deleted file mode 100644
index b4e32d8ec072..000000000000
--- a/include/asm-arm26/percpu.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ARM_PERCPU
2#define __ARM_PERCPU
3
4#include <asm-generic/percpu.h>
5
6#endif
diff --git a/include/asm-arm26/pgalloc.h b/include/asm-arm26/pgalloc.h
deleted file mode 100644
index 7725af3ddb4d..000000000000
--- a/include/asm-arm26/pgalloc.h
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * linux/include/asm-arm/pgalloc.h
3 *
4 * Copyright (C) 2000-2001 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef _ASMARM_PGALLOC_H
11#define _ASMARM_PGALLOC_H
12
13#include <asm/processor.h>
14#include <asm/cacheflush.h>
15#include <asm/tlbflush.h>
16#include <linux/slab.h>
17
18extern struct kmem_cache *pte_cache;
19
20static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr){
21 return kmem_cache_alloc(pte_cache, GFP_KERNEL);
22}
23
24static inline void pte_free_kernel(pte_t *pte){
25 if (pte)
26 kmem_cache_free(pte_cache, pte);
27}
28
29/*
30 * Populate the pmdp entry with a pointer to the pte. This pmd is part
31 * of the mm address space.
32 *
33 * If 'mm' is the init tasks mm, then we are doing a vmalloc, and we
34 * need to set stuff up correctly for it.
35 */
36static inline void
37pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
38{
39//FIXME - is this doing the right thing?
40 set_pmd(pmdp, (unsigned long)ptep | 1/*FIXME _PMD_PRESENT*/);
41}
42
43/*
44 * FIXME - We use the old 2.5.5-rmk1 hack for this.
45 * This is not truly correct, but should be functional.
46 */
47#define pte_alloc_one(mm,addr) ((struct page *)pte_alloc_one_kernel(mm,addr))
48#define pte_free(pte) pte_free_kernel((pte_t *)pte)
49#define pmd_populate(mm,pmdp,ptep) pmd_populate_kernel(mm,pmdp,(pte_t *)ptep)
50
51/*
52 * Since we have only two-level page tables, these are trivial
53 *
54 * trick __pmd_alloc into optimising away. The actual value is irrelevant though as it
55 * is thrown away. It just cant be zero. -IM
56 */
57
58#define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
59#define pmd_free(pmd) do { } while (0)
60#define pgd_populate(mm,pmd,pte) BUG()
61
62extern pgd_t *get_pgd_slow(struct mm_struct *mm);
63extern void free_pgd_slow(pgd_t *pgd);
64
65#define pgd_alloc(mm) get_pgd_slow(mm)
66#define pgd_free(pgd) free_pgd_slow(pgd)
67
68#define check_pgt_cache() do { } while (0)
69
70#endif
diff --git a/include/asm-arm26/pgtable.h b/include/asm-arm26/pgtable.h
deleted file mode 100644
index 55a1a697d12b..000000000000
--- a/include/asm-arm26/pgtable.h
+++ /dev/null
@@ -1,298 +0,0 @@
1/*
2 * linux/include/asm-arm26/pgtable.h
3 *
4 * Copyright (C) 2000-2002 Russell King
5 * Copyright (C) 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASMARM_PGTABLE_H
12#define _ASMARM_PGTABLE_H
13
14#include <asm-generic/4level-fixup.h>
15
16#include <asm/memory.h>
17
18/*
19 * The table below defines the page protection levels that we insert into our
20 * Linux page table version. These get translated into the best that the
21 * architecture can perform. Note that on most ARM hardware:
22 * 1) We cannot do execute protection
23 * 2) If we could do execute protection, then read is implied
24 * 3) write implies read permissions
25 */
26#define __P000 PAGE_NONE
27#define __P001 PAGE_READONLY
28#define __P010 PAGE_COPY
29#define __P011 PAGE_COPY
30#define __P100 PAGE_READONLY
31#define __P101 PAGE_READONLY
32#define __P110 PAGE_COPY
33#define __P111 PAGE_COPY
34
35#define __S000 PAGE_NONE
36#define __S001 PAGE_READONLY
37#define __S010 PAGE_SHARED
38#define __S011 PAGE_SHARED
39#define __S100 PAGE_READONLY
40#define __S101 PAGE_READONLY
41#define __S110 PAGE_SHARED
42#define __S111 PAGE_SHARED
43
44/*
45 * PMD_SHIFT determines the size of the area a second-level page table can map
46 * PGDIR_SHIFT determines what a third-level page table entry can map
47 */
48#define PGD_SHIFT 25
49#define PMD_SHIFT 20
50
51#define PGD_SIZE (1UL << PGD_SHIFT)
52#define PGD_MASK (~(PGD_SIZE-1))
53#define PMD_SIZE (1UL << PMD_SHIFT)
54#define PMD_MASK (~(PMD_SIZE-1))
55
56/* The kernel likes to use these names for the above (ick) */
57#define PGDIR_SIZE PGD_SIZE
58#define PGDIR_MASK PGD_MASK
59
60#define PTRS_PER_PGD 32
61#define PTRS_PER_PMD 1
62#define PTRS_PER_PTE 32
63
64/*
65 * This is the lowest virtual address we can permit any user space
66 * mapping to be mapped at. This is particularly important for
67 * non-high vector CPUs.
68 */
69#define FIRST_USER_ADDRESS PAGE_SIZE
70
71#define FIRST_USER_PGD_NR 1
72#define USER_PTRS_PER_PGD ((TASK_SIZE/PGD_SIZE) - FIRST_USER_PGD_NR)
73
74// FIXME - WTF?
75#define LIBRARY_TEXT_START 0x0c000000
76
77
78
79#ifndef __ASSEMBLY__
80extern void __pte_error(const char *file, int line, unsigned long val);
81extern void __pmd_error(const char *file, int line, unsigned long val);
82extern void __pgd_error(const char *file, int line, unsigned long val);
83
84#define pte_ERROR(pte) __pte_error(__FILE__, __LINE__, pte_val(pte))
85#define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd_val(pmd))
86#define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd_val(pgd))
87
88/*
89 * ZERO_PAGE is a global shared page that is always zero: used
90 * for zero-mapped memory areas etc..
91 */
92extern struct page *empty_zero_page;
93#define ZERO_PAGE(vaddr) (empty_zero_page)
94
95#define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT)
96#define pte_page(pte) (pfn_to_page(pte_pfn(pte)))
97#define pfn_pte(pfn,prot) (__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)))
98#define pages_to_mb(x) ((x) >> (20 - PAGE_SHIFT))
99#define mk_pte(page,prot) pfn_pte(page_to_pfn(page),prot)
100
101/*
102 * Terminology: PGD = Page Directory, PMD = Page Middle Directory,
103 * PTE = Page Table Entry
104 *
105 * on arm26 we have no 2nd level page table. we simulate this by removing the
106 * PMD.
107 *
108 * pgd_none is 0 to prevernt pmd_alloc() calling __pmd_alloc(). This causes it
109 * to return pmd_offset(pgd,addr) which is a pointer to the pgd (IOW, a no-op).
110 *
111 * however, to work this way, whilst we are allocating 32 pgds, containing 32
112 * PTEs, the actual work is done on the PMDs, thus:
113 *
114 * instead of mm->pgd->pmd->pte
115 * we have mm->pgdpmd->pte
116 *
117 * IOW, think of PGD operations and PMD ones as being the same thing, just
118 * that PGD stuff deals with the mm_struct side of things, wheras PMD stuff
119 * deals with the pte side of things.
120 *
121 * additionally, we store some bits in the PGD and PTE pointers:
122 * PGDs:
123 * o The lowest (1) bit of the PGD is to determine if it is present or swap.
124 * o The 2nd bit of the PGD is unused and must be zero.
125 * o The top 6 bits of the PGD must be zero.
126 * PTEs:
127 * o The lower 5 bits of a pte are flags. bit 1 is the 'present' flag. The
128 * others determine the pages attributes.
129 *
130 * the pgd_val, pmd_val, and pte_val macros seem to be private to our code.
131 * They get the RAW value of the PGD/PMD/PTE entry, including our flags
132 * encoded into the pointers.
133 *
134 * The pgd_offset, pmd_offset, and pte_offset macros are used by the kernel,
135 * so they shouldnt have our flags attached.
136 *
137 * If you understood that, feel free to explain it to me...
138 *
139 */
140
141#define _PMD_PRESENT (0x01)
142
143/* These definitions allow us to optimise out stuff like pmd_alloc() */
144#define pgd_none(pgd) (0)
145#define pgd_bad(pgd) (0)
146#define pgd_present(pgd) (1)
147#define pgd_clear(pgdp) do { } while (0)
148
149/* Whilst these handle our actual 'page directory' (the agglomeration of pgd and pmd)
150 */
151#define pmd_none(pmd) (!pmd_val(pmd))
152#define pmd_bad(pmd) ((pmd_val(pmd) & 0xfc000002))
153#define pmd_present(pmd) (pmd_val(pmd) & _PMD_PRESENT)
154#define set_pmd(pmd_ptr, pmd) ((*(pmd_ptr)) = (pmd))
155#define pmd_clear(pmdp) set_pmd(pmdp, __pmd(0))
156
157/* and these handle our pte tables */
158#define pte_none(pte) (!pte_val(pte))
159#define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
160#define set_pte(pte_ptr, pte) ((*(pte_ptr)) = (pte))
161#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
162#define pte_clear(mm,addr,ptep) set_pte_at((mm),(addr),(ptep), __pte(0))
163
164/* macros to ease the getting of pointers to stuff... */
165#define pgd_offset(mm, addr) ((pgd_t *)(mm)->pgd + __pgd_index(addr))
166#define pmd_offset(pgd, addr) ((pmd_t *)(pgd))
167#define pte_offset(pmd, addr) ((pte_t *)pmd_page(*(pmd)) + __pte_index(addr))
168
169/* there is no __pmd_index as we dont use pmds */
170#define __pgd_index(addr) ((addr) >> PGD_SHIFT)
171#define __pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
172
173
174/* Keep the kernel happy */
175#define pgd_index(addr) __pgd_index(addr)
176#define pgd_offset_k(addr) (pgd_offset(&init_mm, addr))
177
178/*
179 * The vmalloc() routines leaves a hole of 4kB between each vmalloced
180 * area for the same reason. ;) FIXME: surely 1 page not 4k ?
181 */
182#define VMALLOC_START 0x01a00000
183#define VMALLOC_END 0x01c00000
184
185/* Is pmd_page supposed to return a pointer to a page in some arches? ours seems to
186 * return a pointer to memory (no special alignment)
187 */
188#define pmd_page(pmd) ((struct page *)(pmd_val((pmd)) & ~_PMD_PRESENT))
189#define pmd_page_vaddr(pmd) ((pte_t *)(pmd_val((pmd)) & ~_PMD_PRESENT))
190
191#define pte_offset_kernel(dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr))
192
193#define pte_offset_map(dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr))
194#define pte_offset_map_nested(dir,addr) (pmd_page_vaddr(*(dir)) + __pte_index(addr))
195#define pte_unmap(pte) do { } while (0)
196#define pte_unmap_nested(pte) do { } while (0)
197
198
199#define _PAGE_PRESENT 0x01
200#define _PAGE_READONLY 0x02
201#define _PAGE_NOT_USER 0x04
202#define _PAGE_OLD 0x08
203#define _PAGE_CLEAN 0x10
204
205// an old page has never been read.
206// a clean page has never been written.
207
208/* -- present -- -- !dirty -- --- !write --- ---- !user --- */
209#define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY | _PAGE_NOT_USER)
210#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_CLEAN )
211#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY )
212#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY )
213#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_NOT_USER)
214
215#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_OLD | _PAGE_CLEAN)
216
217/*
218 * The following only work if pte_present() is true.
219 * Undefined behaviour if not..
220 */
221#define pte_write(pte) (!(pte_val(pte) & _PAGE_READONLY))
222#define pte_dirty(pte) (!(pte_val(pte) & _PAGE_CLEAN))
223#define pte_young(pte) (!(pte_val(pte) & _PAGE_OLD))
224//ONLY when !pte_present() I think. nicked from arm32 (FIXME!)
225#define pte_file(pte) (!(pte_val(pte) & _PAGE_OLD))
226
227#define PTE_BIT_FUNC(fn,op) \
228static inline pte_t pte_##fn(pte_t pte) { pte_val(pte) op; return pte; }
229
230PTE_BIT_FUNC(wrprotect, |= _PAGE_READONLY);
231PTE_BIT_FUNC(mkwrite, &= ~_PAGE_READONLY);
232PTE_BIT_FUNC(mkclean, |= _PAGE_CLEAN);
233PTE_BIT_FUNC(mkdirty, &= ~_PAGE_CLEAN);
234PTE_BIT_FUNC(mkold, |= _PAGE_OLD);
235PTE_BIT_FUNC(mkyoung, &= ~_PAGE_OLD);
236
237/*
238 * We don't store cache state bits in the page table here. FIXME - or do we?
239 */
240#define pgprot_noncached(prot) (prot)
241#define pgprot_writecombine(prot) (prot) //FIXME - is a no-op?
242
243extern void pgtable_cache_init(void);
244
245//FIXME - nicked from arm32 and brutally hacked. probably wrong.
246#define pte_to_pgoff(x) (pte_val(x) >> 2)
247#define pgoff_to_pte(x) __pte(((x) << 2) & ~_PAGE_OLD)
248
249//FIXME - next line borrowed from arm32. is it right?
250#define PTE_FILE_MAX_BITS 30
251
252
253static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
254{
255 pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot);
256 return pte;
257}
258
259extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
260
261/* Encode and decode a swap entry.
262 *
263 * We support up to 32GB of swap on 4k machines
264 */
265#define __swp_type(x) (((x).val >> 2) & 0x7f)
266#define __swp_offset(x) ((x).val >> 9)
267#define __swp_entry(type,offset) ((swp_entry_t) { ((type) << 2) | ((offset) << 9) })
268#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
269#define __swp_entry_to_pte(swp) ((pte_t) { (swp).val })
270
271/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
272/* FIXME: this is not correct */
273#define kern_addr_valid(addr) (1)
274
275/*
276 * Conversion functions: convert a page and protection to a page entry,
277 * and a page entry and page directory to the page they refer to.
278 */
279static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot)
280{
281 pte_t pte;
282 pte_val(pte) = physpage | pgprot_val(pgprot);
283 return pte;
284}
285
286
287#include <asm-generic/pgtable.h>
288
289/*
290 * remap a physical page `pfn' of size `size' with page protection `prot'
291 * into virtual address `from'
292 */
293#define io_remap_pfn_range(vma,from,pfn,size,prot) \
294 remap_pfn_range(vma, from, pfn, size, prot)
295
296#endif /* !__ASSEMBLY__ */
297
298#endif /* _ASMARM_PGTABLE_H */
diff --git a/include/asm-arm26/poll.h b/include/asm-arm26/poll.h
deleted file mode 100644
index 1170e7065f6a..000000000000
--- a/include/asm-arm26/poll.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __ASMARM_POLL_H
2#define __ASMARM_POLL_H
3
4#include <asm-generic/poll.h>
5
6#undef POLLREMOVE
7
8#endif
diff --git a/include/asm-arm26/posix_types.h b/include/asm-arm26/posix_types.h
deleted file mode 100644
index f8d1eb4f4cb1..000000000000
--- a/include/asm-arm26/posix_types.h
+++ /dev/null
@@ -1,81 +0,0 @@
1/*
2 * linux/include/asm-arm/posix_types.h
3 *
4 * Copyright (C) 1996-1998 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Changelog:
11 * 27-06-1996 RMK Created
12 */
13#ifndef __ARCH_ARM_POSIX_TYPES_H
14#define __ARCH_ARM_POSIX_TYPES_H
15
16/*
17 * This file is generally used by user-level software, so you need to
18 * be a little careful about namespace pollution etc. Also, we cannot
19 * assume GCC is being used.
20 */
21
22typedef unsigned long __kernel_ino_t;
23typedef unsigned short __kernel_mode_t;
24typedef unsigned short __kernel_nlink_t;
25typedef long __kernel_off_t;
26typedef int __kernel_pid_t;
27typedef unsigned short __kernel_ipc_pid_t;
28typedef unsigned short __kernel_uid_t;
29typedef unsigned short __kernel_gid_t;
30typedef unsigned int __kernel_size_t;
31typedef int __kernel_ssize_t;
32typedef int __kernel_ptrdiff_t;
33typedef long __kernel_time_t;
34typedef long __kernel_suseconds_t;
35typedef long __kernel_clock_t;
36typedef int __kernel_timer_t;
37typedef int __kernel_clockid_t;
38typedef int __kernel_daddr_t;
39typedef char * __kernel_caddr_t;
40typedef unsigned short __kernel_uid16_t;
41typedef unsigned short __kernel_gid16_t;
42typedef unsigned int __kernel_uid32_t;
43typedef unsigned int __kernel_gid32_t;
44
45typedef unsigned short __kernel_old_uid_t;
46typedef unsigned short __kernel_old_gid_t;
47typedef unsigned short __kernel_old_dev_t;
48
49#ifdef __GNUC__
50typedef long long __kernel_loff_t;
51#endif
52
53typedef struct {
54#if defined(__KERNEL__) || defined(__USE_ALL)
55 int val[2];
56#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
57 int __val[2];
58#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
59} __kernel_fsid_t;
60
61#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
62
63#undef __FD_SET
64#define __FD_SET(fd, fdsetp) \
65 (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] |= (1<<((fd) & 31)))
66
67#undef __FD_CLR
68#define __FD_CLR(fd, fdsetp) \
69 (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] &= ~(1<<((fd) & 31)))
70
71#undef __FD_ISSET
72#define __FD_ISSET(fd, fdsetp) \
73 ((((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] & (1<<((fd) & 31))) != 0)
74
75#undef __FD_ZERO
76#define __FD_ZERO(fdsetp) \
77 (memset ((fdsetp), 0, sizeof (*(fd_set *)(fdsetp))))
78
79#endif
80
81#endif
diff --git a/include/asm-arm26/proc-fns.h b/include/asm-arm26/proc-fns.h
deleted file mode 100644
index a83100454055..000000000000
--- a/include/asm-arm26/proc-fns.h
+++ /dev/null
@@ -1,49 +0,0 @@
1/*
2 * linux/include/asm-arm26/proc-fns.h
3 *
4 * Copyright (C) 2000 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __ASSEMBLY__
11
12#include <asm/page.h>
13
14/*
15 * Don't change this structure - ASM code
16 * relies on it.
17 */
18extern struct processor {
19 /* check for any bugs */
20 void (*_check_bugs)(void);
21 /* Set up any processor specifics */
22 void (*_proc_init)(void);
23 /* Disable any processor specifics */
24 void (*_proc_fin)(void);
25 /* set the MEMC hardware mappings */
26 void (*_set_pgd)(pgd_t *pgd);
27 /* XCHG */
28 unsigned long (*_xchg_1)(unsigned long x, volatile void *ptr);
29 unsigned long (*_xchg_4)(unsigned long x, volatile void *ptr);
30} processor;
31
32extern const struct processor arm2_processor_functions;
33extern const struct processor arm250_processor_functions;
34extern const struct processor arm3_processor_functions;
35
36#define cpu_check_bugs() processor._check_bugs()
37#define cpu_proc_init() processor._proc_init()
38#define cpu_proc_fin() processor._proc_fin()
39#define cpu_do_idle() do { } while (0)
40#define cpu_switch_mm(pgd,mm) processor._set_pgd(pgd)
41#define cpu_xchg_1(x,ptr) processor._xchg_1(x,ptr)
42#define cpu_xchg_4(x,ptr) processor._xchg_4(x,ptr)
43
44
45//FIXME - these shouldnt be in proc-fn.h
46extern void cpu_memc_update_all(pgd_t *pgd);
47extern void cpu_memc_update_entry(pgd_t *pgd, unsigned long phys_pte, unsigned long log_addr);
48
49#endif
diff --git a/include/asm-arm26/processor.h b/include/asm-arm26/processor.h
deleted file mode 100644
index 1d2d5f7b467b..000000000000
--- a/include/asm-arm26/processor.h
+++ /dev/null
@@ -1,113 +0,0 @@
1/*
2 * linux/include/asm-arm26/processor.h
3 *
4 * Copyright (C) 1995 Russell King
5 * Copyright (C) 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef __ASM_ARM_PROCESSOR_H
13#define __ASM_ARM_PROCESSOR_H
14
15/*
16 * Default implementation of macro that returns current
17 * instruction pointer ("program counter").
18 */
19#define current_text_addr() ({ __label__ _l; _l: &&_l;})
20
21#ifdef __KERNEL__
22
23#include <asm/atomic.h>
24#include <asm/ptrace.h>
25#include <linux/string.h>
26
27#define KERNEL_STACK_SIZE 4096
28
29typedef struct {
30 void (*put_byte)(void); /* Special calling convention */
31 void (*get_byte)(void); /* Special calling convention */
32 void (*put_half)(void); /* Special calling convention */
33 void (*get_half)(void); /* Special calling convention */
34 void (*put_word)(void); /* Special calling convention */
35 void (*get_word)(void); /* Special calling convention */
36 void (*put_dword)(void); /* Special calling convention */
37 unsigned long (*copy_from_user)(void *to, const void *from, unsigned long sz);
38 unsigned long (*copy_to_user)(void *to, const void *from, unsigned long sz);
39 unsigned long (*clear_user)(void *addr, unsigned long sz);
40 unsigned long (*strncpy_from_user)(char *to, const char *from, unsigned long sz);
41 unsigned long (*strnlen_user)(const char *s, long n);
42} uaccess_t;
43
44extern uaccess_t uaccess_user, uaccess_kernel;
45
46#define EXTRA_THREAD_STRUCT \
47 uaccess_t *uaccess; /* User access functions*/
48
49#define EXTRA_THREAD_STRUCT_INIT \
50 .uaccess = &uaccess_kernel,
51
52// FIXME?!!
53
54#define start_thread(regs,pc,sp) \
55({ \
56 unsigned long *stack = (unsigned long *)sp; \
57 set_fs(USER_DS); \
58 memzero(regs->uregs, sizeof (regs->uregs)); \
59 regs->ARM_pc = pc | ~0xfc000003; /* pc */ \
60 regs->ARM_sp = sp; /* sp */ \
61 regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
62 regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
63 regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
64})
65
66#define KSTK_EIP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1020])
67#define KSTK_ESP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1018])
68
69struct debug_entry {
70 u32 address;
71 u32 insn;
72};
73
74struct debug_info {
75 int nsaved;
76 struct debug_entry bp[2];
77};
78
79struct thread_struct {
80 /* fault info */
81 unsigned long address;
82 unsigned long trap_no;
83 unsigned long error_code;
84 /* debugging */
85 struct debug_info debug;
86 EXTRA_THREAD_STRUCT
87};
88
89#define INIT_THREAD { \
90EXTRA_THREAD_STRUCT_INIT \
91}
92
93/* Forward declaration, a strange C thing */
94struct task_struct;
95
96/* Free all resources held by a thread. */
97extern void release_thread(struct task_struct *);
98
99unsigned long get_wchan(struct task_struct *p);
100
101#define cpu_relax() barrier()
102
103/* Prepare to copy thread state - unlazy all lazy status */
104#define prepare_to_copy(tsk) do { } while (0)
105
106/*
107 * Create a new kernel thread
108 */
109extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
110
111#endif
112
113#endif /* __ASM_ARM_PROCESSOR_H */
diff --git a/include/asm-arm26/procinfo.h b/include/asm-arm26/procinfo.h
deleted file mode 100644
index b28624db69ff..000000000000
--- a/include/asm-arm26/procinfo.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * linux/include/asm-arm/procinfo.h
3 *
4 * Copyright (C) 1996-1999 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __ASM_PROCINFO_H
11#define __ASM_PROCINFO_H
12
13#ifndef __ASSEMBLY__
14
15//struct processor;
16//struct cpu_user_fns;
17
18struct proc_info_item {
19 const char *manufacturer;
20 const char *cpu_name;
21};
22
23/*
24 * Note! struct processor is always defined if we're
25 * using MULTI_CPU, otherwise this entry is unused,
26 * but still exists.
27 *
28 * NOTE! The following structure is defined by assembly
29 * language, NOT C code. For more information, check:
30 * arch/arm/mm/proc-*.S and arch/arm/kernel/head-armv.S
31 */
32struct proc_info_list {
33 unsigned int cpu_val;
34 unsigned int cpu_mask;
35 const char *arch_name;
36 const char *elf_name;
37 unsigned int elf_hwcap;
38 struct proc_info_item *info;
39 struct processor *proc;
40};
41
42#endif /* __ASSEMBLY__ */
43
44#define PROC_INFO_SZ 48
45
46#define HWCAP_SWP 1
47#define HWCAP_HALF 2
48#define HWCAP_THUMB 4
49#define HWCAP_26BIT 8 /* Play it safe */
50#define HWCAP_FAST_MULT 16
51#define HWCAP_FPA 32
52#define HWCAP_VFP 64
53#define HWCAP_EDSP 128
54#define HWCAP_JAVA 256
55
56#endif
diff --git a/include/asm-arm26/ptrace.h b/include/asm-arm26/ptrace.h
deleted file mode 100644
index 6a46b5ae1156..000000000000
--- a/include/asm-arm26/ptrace.h
+++ /dev/null
@@ -1,104 +0,0 @@
1#ifndef __ASM_ARM_PTRACE_H
2#define __ASM_ARM_PTRACE_H
3
4#define PTRACE_GETREGS 12
5#define PTRACE_SETREGS 13
6#define PTRACE_GETFPREGS 14
7#define PTRACE_SETFPREGS 15
8#define PTRACE_OLDSETOPTIONS 21
9
10/* options set using PTRACE_SETOPTIONS */
11#define PTRACE_O_TRACESYSGOOD 0x00000001
12
13#define MODE_USR26 0x00000000
14#define MODE_FIQ26 0x00000001
15#define MODE_IRQ26 0x00000002
16#define MODE_SVC26 0x00000003
17#define MODE_MASK 0x00000003
18
19#define PSR_F_BIT 0x04000000
20#define PSR_I_BIT 0x08000000
21#define PSR_V_BIT 0x10000000
22#define PSR_C_BIT 0x20000000
23#define PSR_Z_BIT 0x40000000
24#define PSR_N_BIT 0x80000000
25
26#define PCMASK 0xfc000003
27
28
29#ifndef __ASSEMBLY__
30
31#define pc_pointer(v) ((v) & ~PCMASK) /* convert v to pc type address */
32#define instruction_pointer(regs) (pc_pointer((regs)->ARM_pc)) /* get pc */
33#define profile_pc(regs) instruction_pointer(regs)
34
35/* this struct defines the way the registers are stored on the
36 stack during a system call. */
37
38struct pt_regs {
39 long uregs[17];
40};
41
42#define ARM_pc uregs[15]
43#define ARM_lr uregs[14]
44#define ARM_sp uregs[13]
45#define ARM_ip uregs[12]
46#define ARM_fp uregs[11]
47#define ARM_r10 uregs[10]
48#define ARM_r9 uregs[9]
49#define ARM_r8 uregs[8]
50#define ARM_r7 uregs[7]
51#define ARM_r6 uregs[6]
52#define ARM_r5 uregs[5]
53#define ARM_r4 uregs[4]
54#define ARM_r3 uregs[3]
55#define ARM_r2 uregs[2]
56#define ARM_r1 uregs[1]
57#define ARM_r0 uregs[0]
58#define ARM_ORIG_r0 uregs[16]
59
60#ifdef __KERNEL__
61
62#define processor_mode(regs) \
63 ((regs)->ARM_pc & MODE_MASK)
64
65#define user_mode(regs) \
66 (processor_mode(regs) == MODE_USR26)
67
68#define interrupts_enabled(regs) \
69 (!((regs)->ARM_pc & PSR_I_BIT))
70
71#define fast_interrupts_enabled(regs) \
72 (!((regs)->ARM_pc & PSR_F_BIT))
73
74#define condition_codes(regs) \
75 ((regs)->ARM_pc & (PSR_V_BIT|PSR_C_BIT|PSR_Z_BIT|PSR_N_BIT))
76
77/* Are the current registers suitable for user mode?
78 * (used to maintain security in signal handlers)
79 */
80static inline int valid_user_regs(struct pt_regs *regs)
81{
82 if (user_mode(regs) &&
83 (regs->ARM_pc & (PSR_F_BIT | PSR_I_BIT)) == 0)
84 return 1;
85
86 /*
87 * force it to be something sensible
88 */
89 regs->ARM_pc &= ~(MODE_MASK | PSR_F_BIT | PSR_I_BIT);
90
91 return 0;
92}
93
94extern void show_regs(struct pt_regs *);
95
96#define predicate(x) (x & 0xf0000000)
97#define PREDICATE_ALWAYS 0xe0000000
98
99#endif /* __KERNEL__ */
100
101#endif /* __ASSEMBLY__ */
102
103#endif
104
diff --git a/include/asm-arm26/resource.h b/include/asm-arm26/resource.h
deleted file mode 100644
index 734b581b5b6a..000000000000
--- a/include/asm-arm26/resource.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ARM_RESOURCE_H
2#define _ARM_RESOURCE_H
3
4#include <asm-generic/resource.h>
5
6#endif
diff --git a/include/asm-arm26/scatterlist.h b/include/asm-arm26/scatterlist.h
deleted file mode 100644
index d9c056c7784e..000000000000
--- a/include/asm-arm26/scatterlist.h
+++ /dev/null
@@ -1,26 +0,0 @@
1#ifndef _ASMARM_SCATTERLIST_H
2#define _ASMARM_SCATTERLIST_H
3
4#include <asm/types.h>
5
6struct scatterlist {
7 struct page *page; /* buffer page */
8 unsigned int offset; /* buffer offset */
9 dma_addr_t dma_address; /* dma address */
10 unsigned int length; /* length */
11 char *__address; /* for set_dma_addr */
12};
13
14/*
15 * These macros should be used after a pci_map_sg call has been done
16 * to get bus addresses of each of the SG entries and their lengths.
17 * You should only work with the number of sg entries pci_map_sg
18 * returns, or alternatively stop on the first sg_dma_len(sg) which
19 * is 0.
20 */
21#define sg_dma_address(sg) ((sg)->dma_address)
22#define sg_dma_len(sg) ((sg)->length)
23
24#define ISA_DMA_THRESHOLD (0xffffffff)
25
26#endif /* _ASMARM_SCATTERLIST_H */
diff --git a/include/asm-arm26/sections.h b/include/asm-arm26/sections.h
deleted file mode 100644
index 10b6370efad0..000000000000
--- a/include/asm-arm26/sections.h
+++ /dev/null
@@ -1,2 +0,0 @@
1//FIXME - nicked from arm32 - check its correct.
2#include <asm-generic/sections.h>
diff --git a/include/asm-arm26/segment.h b/include/asm-arm26/segment.h
deleted file mode 100644
index 9e24c21f6304..000000000000
--- a/include/asm-arm26/segment.h
+++ /dev/null
@@ -1,11 +0,0 @@
1#ifndef __ASM_ARM_SEGMENT_H
2#define __ASM_ARM_SEGMENT_H
3
4#define __KERNEL_CS 0x0
5#define __KERNEL_DS 0x0
6
7#define __USER_CS 0x1
8#define __USER_DS 0x1
9
10#endif /* __ASM_ARM_SEGMENT_H */
11
diff --git a/include/asm-arm26/semaphore-helper.h b/include/asm-arm26/semaphore-helper.h
deleted file mode 100644
index 1d7f1987edb9..000000000000
--- a/include/asm-arm26/semaphore-helper.h
+++ /dev/null
@@ -1,84 +0,0 @@
1#ifndef ASMARM_SEMAPHORE_HELPER_H
2#define ASMARM_SEMAPHORE_HELPER_H
3
4/*
5 * These two _must_ execute atomically wrt each other.
6 */
7static inline void wake_one_more(struct semaphore * sem)
8{
9 unsigned long flags;
10
11 spin_lock_irqsave(&semaphore_wake_lock, flags);
12 if (atomic_read(&sem->count) <= 0)
13 sem->waking++;
14 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
15}
16
17static inline int waking_non_zero(struct semaphore *sem)
18{
19 unsigned long flags;
20 int ret = 0;
21
22 spin_lock_irqsave(&semaphore_wake_lock, flags);
23 if (sem->waking > 0) {
24 sem->waking--;
25 ret = 1;
26 }
27 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
28 return ret;
29}
30
31/*
32 * waking non zero interruptible
33 * 1 got the lock
34 * 0 go to sleep
35 * -EINTR interrupted
36 *
37 * We must undo the sem->count down_interruptible() increment while we are
38 * protected by the spinlock in order to make this atomic_inc() with the
39 * atomic_read() in wake_one_more(), otherwise we can race. -arca
40 */
41static inline int waking_non_zero_interruptible(struct semaphore *sem,
42 struct task_struct *tsk)
43{
44 unsigned long flags;
45 int ret = 0;
46
47 spin_lock_irqsave(&semaphore_wake_lock, flags);
48 if (sem->waking > 0) {
49 sem->waking--;
50 ret = 1;
51 } else if (signal_pending(tsk)) {
52 atomic_inc(&sem->count);
53 ret = -EINTR;
54 }
55 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
56 return ret;
57}
58
59/*
60 * waking_non_zero_try_lock:
61 * 1 failed to lock
62 * 0 got the lock
63 *
64 * We must undo the sem->count down_interruptible() increment while we are
65 * protected by the spinlock in order to make this atomic_inc() with the
66 * atomic_read() in wake_one_more(), otherwise we can race. -arca
67 */
68static inline int waking_non_zero_trylock(struct semaphore *sem)
69{
70 unsigned long flags;
71 int ret = 1;
72
73 spin_lock_irqsave(&semaphore_wake_lock, flags);
74 if (sem->waking <= 0)
75 atomic_inc(&sem->count);
76 else {
77 sem->waking--;
78 ret = 0;
79 }
80 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
81 return ret;
82}
83
84#endif
diff --git a/include/asm-arm26/semaphore.h b/include/asm-arm26/semaphore.h
deleted file mode 100644
index 1fda54375ed8..000000000000
--- a/include/asm-arm26/semaphore.h
+++ /dev/null
@@ -1,100 +0,0 @@
1/*
2 * linux/include/asm-arm26/semaphore.h
3 */
4#ifndef __ASM_ARM_SEMAPHORE_H
5#define __ASM_ARM_SEMAPHORE_H
6
7#include <linux/linkage.h>
8#include <linux/spinlock.h>
9#include <linux/wait.h>
10#include <linux/rwsem.h>
11
12#include <asm/atomic.h>
13#include <asm/locks.h>
14
15struct semaphore {
16 atomic_t count;
17 int sleepers;
18 wait_queue_head_t wait;
19};
20
21#define __SEMAPHORE_INIT(name, n) \
22{ \
23 .count = ATOMIC_INIT(n), \
24 .sleepers = 0, \
25 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait), \
26}
27
28#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
29 struct semaphore name = __SEMAPHORE_INIT(name,count)
30
31#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
32#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
33
34static inline void sema_init(struct semaphore *sem, int val)
35{
36 atomic_set(&sem->count, val);
37 sem->sleepers = 0;
38 init_waitqueue_head(&sem->wait);
39}
40
41static inline void init_MUTEX(struct semaphore *sem)
42{
43 sema_init(sem, 1);
44}
45
46static inline void init_MUTEX_LOCKED(struct semaphore *sem)
47{
48 sema_init(sem, 0);
49}
50
51/*
52 * special register calling convention
53 */
54asmlinkage void __down_failed(void);
55asmlinkage int __down_interruptible_failed(void);
56asmlinkage int __down_trylock_failed(void);
57asmlinkage void __up_wakeup(void);
58
59extern void __down(struct semaphore * sem);
60extern int __down_interruptible(struct semaphore * sem);
61extern int __down_trylock(struct semaphore * sem);
62extern void __up(struct semaphore * sem);
63
64/*
65 * This is ugly, but we want the default case to fall through.
66 * "__down" is the actual routine that waits...
67 */
68static inline void down(struct semaphore * sem)
69{
70 might_sleep();
71 __down_op(sem, __down_failed);
72}
73
74/*
75 * This is ugly, but we want the default case to fall through.
76 * "__down_interruptible" is the actual routine that waits...
77 */
78static inline int down_interruptible (struct semaphore * sem)
79{
80 might_sleep();
81 return __down_op_ret(sem, __down_interruptible_failed);
82}
83
84static inline int down_trylock(struct semaphore *sem)
85{
86 return __down_op_ret(sem, __down_trylock_failed);
87}
88
89/*
90 * Note! This is subtle. We jump to wake people up only if
91 * the semaphore was negative (== somebody was waiting on it).
92 * The default case (no contention) will result in NO
93 * jumps for both down() and up().
94 */
95static inline void up(struct semaphore * sem)
96{
97 __up_op(sem, __up_wakeup);
98}
99
100#endif
diff --git a/include/asm-arm26/sembuf.h b/include/asm-arm26/sembuf.h
deleted file mode 100644
index 1c0283954289..000000000000
--- a/include/asm-arm26/sembuf.h
+++ /dev/null
@@ -1,25 +0,0 @@
1#ifndef _ASMARM_SEMBUF_H
2#define _ASMARM_SEMBUF_H
3
4/*
5 * The semid64_ds structure for arm architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 64-bit time_t to solve y2038 problem
11 * - 2 miscellaneous 32-bit values
12 */
13
14struct semid64_ds {
15 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
16 __kernel_time_t sem_otime; /* last semop time */
17 unsigned long __unused1;
18 __kernel_time_t sem_ctime; /* last change time */
19 unsigned long __unused2;
20 unsigned long sem_nsems; /* no. of semaphores in array */
21 unsigned long __unused3;
22 unsigned long __unused4;
23};
24
25#endif /* _ASMARM_SEMBUF_H */
diff --git a/include/asm-arm26/serial.h b/include/asm-arm26/serial.h
deleted file mode 100644
index dd86a716cb0b..000000000000
--- a/include/asm-arm26/serial.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 * linux/include/asm-arm/serial.h
3 *
4 * Copyright (C) 1996 Russell King.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Changelog:
11 * 15-10-1996 RMK Created
12 */
13
14#ifndef __ASM_SERIAL_H
15#define __ASM_SERIAL_H
16
17
18/*
19 * This assumes you have a 1.8432 MHz clock for your UART.
20 *
21 * It'd be nice if someone built a serial card with a 24.576 MHz
22 * clock, since the 16550A is capable of handling a top speed of 1.5
23 * megabits/second; but this requires the faster clock.
24 */
25#define BASE_BAUD (1843200 / 16)
26
27#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
28
29#if defined(CONFIG_ARCH_A5K)
30 /* UART CLK PORT IRQ FLAGS */
31
32#define SERIAL_PORT_DFNS \
33 { 0, BASE_BAUD, 0x3F8, 10, STD_COM_FLAGS }, /* ttyS0 */ \
34 { 0, BASE_BAUD, 0x2F8, 10, STD_COM_FLAGS }, /* ttyS1 */
35
36#else
37
38#define SERIAL_PORT_DFNS \
39 { 0, BASE_BAUD, 0 , 0, STD_COM_FLAGS }, /* ttyS0 */ \
40 { 0, BASE_BAUD, 0 , 0, STD_COM_FLAGS }, /* ttyS1 */
41
42#endif
43
44#endif
diff --git a/include/asm-arm26/setup.h b/include/asm-arm26/setup.h
deleted file mode 100644
index e82562306475..000000000000
--- a/include/asm-arm26/setup.h
+++ /dev/null
@@ -1,209 +0,0 @@
1/*
2 * linux/include/asm/setup.h
3 *
4 * Copyright (C) 1997-1999 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Structure passed to kernel to tell it about the
11 * hardware it's running on. See Documentation/arm/Setup
12 * for more info.
13 */
14#ifndef __ASMARM_SETUP_H
15#define __ASMARM_SETUP_H
16
17#define COMMAND_LINE_SIZE 1024
18
19#ifdef __KERNEL__
20
21/* The list ends with an ATAG_NONE node. */
22#define ATAG_NONE 0x00000000
23
24struct tag_header {
25 u32 size;
26 u32 tag;
27};
28
29/* The list must start with an ATAG_CORE node */
30#define ATAG_CORE 0x54410001
31
32struct tag_core {
33 u32 flags; /* bit 0 = read-only */
34 u32 pagesize;
35 u32 rootdev;
36};
37
38/* it is allowed to have multiple ATAG_MEM nodes */
39#define ATAG_MEM 0x54410002
40
41struct tag_mem32 {
42 u32 size;
43 u32 start; /* physical start address */
44};
45
46/* VGA text type displays */
47#define ATAG_VIDEOTEXT 0x54410003
48
49struct tag_videotext {
50 u8 x;
51 u8 y;
52 u16 video_page;
53 u8 video_mode;
54 u8 video_cols;
55 u16 video_ega_bx;
56 u8 video_lines;
57 u8 video_isvga;
58 u16 video_points;
59};
60
61/* describes how the ramdisk will be used in kernel */
62#define ATAG_RAMDISK 0x54410004
63
64struct tag_ramdisk {
65 u32 flags; /* bit 0 = load, bit 1 = prompt */
66 u32 size; /* decompressed ramdisk size in _kilo_ bytes */
67 u32 start; /* starting block of floppy-based RAM disk image */
68};
69
70/* describes where the compressed ramdisk image lives */
71/*
72 * this one accidentally used virtual addresses - as such,
73 * it's deprecated.
74 */
75#define ATAG_INITRD 0x54410005
76
77/* describes where the compressed ramdisk image lives */
78#define ATAG_INITRD2 0x54420005
79
80struct tag_initrd {
81 u32 start; /* physical start address */
82 u32 size; /* size of compressed ramdisk image in bytes */
83};
84
85/* board serial number. "64 bits should be enough for everybody" */
86#define ATAG_SERIAL 0x54410006
87
88struct tag_serialnr {
89 u32 low;
90 u32 high;
91};
92
93/* board revision */
94#define ATAG_REVISION 0x54410007
95
96struct tag_revision {
97 u32 rev;
98};
99
100/* initial values for vesafb-type framebuffers. see struct screen_info
101 * in include/linux/tty.h
102 */
103#define ATAG_VIDEOLFB 0x54410008
104
105struct tag_videolfb {
106 u16 lfb_width;
107 u16 lfb_height;
108 u16 lfb_depth;
109 u16 lfb_linelength;
110 u32 lfb_base;
111 u32 lfb_size;
112 u8 red_size;
113 u8 red_pos;
114 u8 green_size;
115 u8 green_pos;
116 u8 blue_size;
117 u8 blue_pos;
118 u8 rsvd_size;
119 u8 rsvd_pos;
120};
121
122/* command line: \0 terminated string */
123#define ATAG_CMDLINE 0x54410009
124
125struct tag_cmdline {
126 char cmdline[1]; /* this is the minimum size */
127};
128
129/* acorn RiscPC specific information */
130#define ATAG_ACORN 0x41000101
131
132struct tag_acorn {
133 u32 memc_control_reg;
134 u32 vram_pages;
135 u8 sounddefault;
136 u8 adfsdrives;
137};
138
139/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */
140#define ATAG_MEMCLK 0x41000402
141
142struct tag_memclk {
143 u32 fmemclk;
144};
145
146struct tag {
147 struct tag_header hdr;
148 union {
149 struct tag_core core;
150 struct tag_mem32 mem;
151 struct tag_videotext videotext;
152 struct tag_ramdisk ramdisk;
153 struct tag_initrd initrd;
154 struct tag_serialnr serialnr;
155 struct tag_revision revision;
156 struct tag_videolfb videolfb;
157 struct tag_cmdline cmdline;
158
159 /*
160 * Acorn specific
161 */
162 struct tag_acorn acorn;
163
164 /*
165 * DC21285 specific
166 */
167 struct tag_memclk memclk;
168 } u;
169};
170
171struct tagtable {
172 u32 tag;
173 int (*parse)(const struct tag *);
174};
175
176#define __tag __used __attribute__((__section__(".taglist")))
177#define __tagtable(tag, fn) \
178static struct tagtable __tagtable_##fn __tag = { tag, fn }
179
180#define tag_member_present(tag,member) \
181 ((unsigned long)(&((struct tag *)0L)->member + 1) \
182 <= (tag)->hdr.size * 4)
183
184#define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size))
185#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
186
187#define for_each_tag(t,base) \
188 for (t = base; t->hdr.size; t = tag_next(t))
189
190/*
191 * Memory map description
192 */
193#define NR_BANKS 8
194
195struct meminfo {
196 int nr_banks;
197 unsigned long end;
198 struct {
199 unsigned long start;
200 unsigned long size;
201 int node;
202 } bank[NR_BANKS];
203};
204
205extern struct meminfo meminfo;
206
207#endif /* __KERNEL__ */
208
209#endif
diff --git a/include/asm-arm26/shmbuf.h b/include/asm-arm26/shmbuf.h
deleted file mode 100644
index 2e5c67ba1c97..000000000000
--- a/include/asm-arm26/shmbuf.h
+++ /dev/null
@@ -1,42 +0,0 @@
1#ifndef _ASMARM_SHMBUF_H
2#define _ASMARM_SHMBUF_H
3
4/*
5 * The shmid64_ds structure for arm architecture.
6 * Note extra padding because this structure is passed back and forth
7 * between kernel and user space.
8 *
9 * Pad space is left for:
10 * - 64-bit time_t to solve y2038 problem
11 * - 2 miscellaneous 32-bit values
12 */
13
14struct shmid64_ds {
15 struct ipc64_perm shm_perm; /* operation perms */
16 size_t shm_segsz; /* size of segment (bytes) */
17 __kernel_time_t shm_atime; /* last attach time */
18 unsigned long __unused1;
19 __kernel_time_t shm_dtime; /* last detach time */
20 unsigned long __unused2;
21 __kernel_time_t shm_ctime; /* last change time */
22 unsigned long __unused3;
23 __kernel_pid_t shm_cpid; /* pid of creator */
24 __kernel_pid_t shm_lpid; /* pid of last operator */
25 unsigned long shm_nattch; /* no. of current attaches */
26 unsigned long __unused4;
27 unsigned long __unused5;
28};
29
30struct shminfo64 {
31 unsigned long shmmax;
32 unsigned long shmmin;
33 unsigned long shmmni;
34 unsigned long shmseg;
35 unsigned long shmall;
36 unsigned long __unused1;
37 unsigned long __unused2;
38 unsigned long __unused3;
39 unsigned long __unused4;
40};
41
42#endif /* _ASMARM_SHMBUF_H */
diff --git a/include/asm-arm26/shmparam.h b/include/asm-arm26/shmparam.h
deleted file mode 100644
index d3748686631e..000000000000
--- a/include/asm-arm26/shmparam.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef _ASMARM_SHMPARAM_H
2#define _ASMARM_SHMPARAM_H
3
4#ifndef SHMMAX
5#define SHMMAX 0x003fa000
6#endif
7
8/*
9 * This should be the size of the virtually indexed cache/ways,
10 * or page size, whichever is greater since the cache aliases
11 * every size/ways bytes.
12 */
13#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
14
15#endif /* _ASMARM_SHMPARAM_H */
diff --git a/include/asm-arm26/sigcontext.h b/include/asm-arm26/sigcontext.h
deleted file mode 100644
index 013ad2074fc7..000000000000
--- a/include/asm-arm26/sigcontext.h
+++ /dev/null
@@ -1,33 +0,0 @@
1#ifndef _ASMARM_SIGCONTEXT_H
2#define _ASMARM_SIGCONTEXT_H
3
4/*
5 * Signal context structure - contains all info to do with the state
6 * before the signal handler was invoked. Note: only add new entries
7 * to the end of the structure.
8 */
9struct sigcontext {
10 unsigned long trap_no;
11 unsigned long error_code;
12 unsigned long oldmask;
13 unsigned long arm_r0;
14 unsigned long arm_r1;
15 unsigned long arm_r2;
16 unsigned long arm_r3;
17 unsigned long arm_r4;
18 unsigned long arm_r5;
19 unsigned long arm_r6;
20 unsigned long arm_r7;
21 unsigned long arm_r8;
22 unsigned long arm_r9;
23 unsigned long arm_r10;
24 unsigned long arm_fp;
25 unsigned long arm_ip;
26 unsigned long arm_sp;
27 unsigned long arm_lr;
28 unsigned long arm_pc;
29 unsigned long fault_address;
30};
31
32
33#endif
diff --git a/include/asm-arm26/siginfo.h b/include/asm-arm26/siginfo.h
deleted file mode 100644
index 5e21852e6039..000000000000
--- a/include/asm-arm26/siginfo.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASMARM_SIGINFO_H
2#define _ASMARM_SIGINFO_H
3
4#include <asm-generic/siginfo.h>
5
6#endif
diff --git a/include/asm-arm26/signal.h b/include/asm-arm26/signal.h
deleted file mode 100644
index 967ba4947e40..000000000000
--- a/include/asm-arm26/signal.h
+++ /dev/null
@@ -1,176 +0,0 @@
1#ifndef _ASMARM_SIGNAL_H
2#define _ASMARM_SIGNAL_H
3
4#include <linux/types.h>
5
6/* Avoid too many header ordering problems. */
7struct siginfo;
8
9#ifdef __KERNEL__
10/* Most things should be clean enough to redefine this at will, if care
11 is taken to make libc match. */
12
13#define _NSIG 64
14#define _NSIG_BPW 32
15#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
16
17typedef unsigned long old_sigset_t; /* at least 32 bits */
18
19typedef struct {
20 unsigned long sig[_NSIG_WORDS];
21} sigset_t;
22
23#else
24/* Here we must cater to libcs that poke about in kernel headers. */
25
26#define NSIG 32
27typedef unsigned long sigset_t;
28
29#endif /* __KERNEL__ */
30
31#define SIGHUP 1
32#define SIGINT 2
33#define SIGQUIT 3
34#define SIGILL 4
35#define SIGTRAP 5
36#define SIGABRT 6
37#define SIGIOT 6
38#define SIGBUS 7
39#define SIGFPE 8
40#define SIGKILL 9
41#define SIGUSR1 10
42#define SIGSEGV 11
43#define SIGUSR2 12
44#define SIGPIPE 13
45#define SIGALRM 14
46#define SIGTERM 15
47#define SIGSTKFLT 16
48#define SIGCHLD 17
49#define SIGCONT 18
50#define SIGSTOP 19
51#define SIGTSTP 20
52#define SIGTTIN 21
53#define SIGTTOU 22
54#define SIGURG 23
55#define SIGXCPU 24
56#define SIGXFSZ 25
57#define SIGVTALRM 26
58#define SIGPROF 27
59#define SIGWINCH 28
60#define SIGIO 29
61#define SIGPOLL SIGIO
62/*
63#define SIGLOST 29
64*/
65#define SIGPWR 30
66#define SIGSYS 31
67#define SIGUNUSED 31
68
69/* These should not be considered constants from userland. */
70#define SIGRTMIN 32
71#define SIGRTMAX _NSIG
72
73#define SIGSWI 32
74
75/*
76 * SA_FLAGS values:
77 *
78 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
79 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
80 * SA_SIGINFO deliver the signal with SIGINFO structs
81 * SA_THIRTYTWO delivers the signal in 32-bit mode, even if the task
82 * is running in 26-bit.
83 * SA_ONSTACK allows alternate signal stacks (see sigaltstack(2)).
84 * SA_RESTART flag to get restarting signals (which were the default long ago)
85 * SA_NODEFER prevents the current signal from being masked in the handler.
86 * SA_RESETHAND clears the handler when the signal is delivered.
87 *
88 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
89 * Unix names RESETHAND and NODEFER respectively.
90 */
91#define SA_NOCLDSTOP 0x00000001
92#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
93#define SA_SIGINFO 0x00000004
94#define SA_THIRTYTWO 0x02000000
95#define SA_RESTORER 0x04000000
96#define SA_ONSTACK 0x08000000
97#define SA_RESTART 0x10000000
98#define SA_NODEFER 0x40000000
99#define SA_RESETHAND 0x80000000
100
101#define SA_NOMASK SA_NODEFER
102#define SA_ONESHOT SA_RESETHAND
103
104
105/*
106 * sigaltstack controls
107 */
108#define SS_ONSTACK 1
109#define SS_DISABLE 2
110
111#define MINSIGSTKSZ 2048
112#define SIGSTKSZ 8192
113
114#ifdef __KERNEL__
115#define SA_IRQNOMASK 0x08000000
116#endif
117
118#include <asm-generic/signal.h>
119
120#ifdef __KERNEL__
121struct old_sigaction {
122 __sighandler_t sa_handler;
123 old_sigset_t sa_mask;
124 unsigned long sa_flags;
125 void (*sa_restorer)(void);
126};
127
128struct sigaction {
129 __sighandler_t sa_handler;
130 unsigned long sa_flags;
131 void (*sa_restorer)(void);
132 sigset_t sa_mask; /* mask last for extensibility */
133};
134
135struct k_sigaction {
136 struct sigaction sa;
137};
138
139#else
140/* Here we must cater to libcs that poke about in kernel headers. */
141
142struct sigaction {
143 union {
144 __sighandler_t _sa_handler;
145 void (*_sa_sigaction)(int, struct siginfo *, void *);
146 } _u;
147 sigset_t sa_mask;
148 unsigned long sa_flags;
149 void (*sa_restorer)(void);
150};
151
152#define sa_handler _u._sa_handler
153#define sa_sigaction _u._sa_sigaction
154
155#endif /* __KERNEL__ */
156
157typedef struct sigaltstack {
158 void *ss_sp;
159 int ss_flags;
160 size_t ss_size;
161} stack_t;
162
163#ifdef __KERNEL__
164#include <asm/sigcontext.h>
165
166#define sigmask(sig) (1UL << ((sig) - 1))
167#endif
168
169
170#ifdef __KERNEL__
171#include <asm/sigcontext.h>
172#define ptrace_signal_deliver(regs, cookie) do { } while (0)
173#endif
174
175
176#endif
diff --git a/include/asm-arm26/sizes.h b/include/asm-arm26/sizes.h
deleted file mode 100644
index f8d92ca12040..000000000000
--- a/include/asm-arm26/sizes.h
+++ /dev/null
@@ -1,52 +0,0 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 */
16/* DO NOT EDIT!! - this file automatically generated
17 * from .s file by awk -f s2h.awk
18 */
19/* Size defintions
20 * Copyright (C) ARM Limited 1998. All rights reserved.
21 */
22
23#ifndef __sizes_h
24#define __sizes_h 1
25
26/* handy sizes */
27#define SZ_1K 0x00000400
28#define SZ_4K 0x00001000
29#define SZ_8K 0x00002000
30#define SZ_16K 0x00004000
31#define SZ_64K 0x00010000
32#define SZ_128K 0x00020000
33#define SZ_256K 0x00040000
34#define SZ_512K 0x00080000
35
36#define SZ_1M 0x00100000
37#define SZ_2M 0x00200000
38#define SZ_4M 0x00400000
39#define SZ_8M 0x00800000
40#define SZ_16M 0x01000000
41#define SZ_32M 0x02000000
42#define SZ_64M 0x04000000
43#define SZ_128M 0x08000000
44#define SZ_256M 0x10000000
45#define SZ_512M 0x20000000
46
47#define SZ_1G 0x40000000
48#define SZ_2G 0x80000000
49
50#endif
51
52/* END */
diff --git a/include/asm-arm26/smp.h b/include/asm-arm26/smp.h
deleted file mode 100644
index 38349ec8b61b..000000000000
--- a/include/asm-arm26/smp.h
+++ /dev/null
@@ -1,9 +0,0 @@
1#ifndef __ASM_SMP_H
2#define __ASM_SMP_H
3
4
5#ifdef CONFIG_SMP
6#error SMP not supported
7#endif
8
9#endif
diff --git a/include/asm-arm26/socket.h b/include/asm-arm26/socket.h
deleted file mode 100644
index 65a1a64bf934..000000000000
--- a/include/asm-arm26/socket.h
+++ /dev/null
@@ -1,55 +0,0 @@
1#ifndef _ASMARM_SOCKET_H
2#define _ASMARM_SOCKET_H
3
4#include <asm/sockios.h>
5
6/* For setsockopt(2) */
7#define SOL_SOCKET 1
8
9#define SO_DEBUG 1
10#define SO_REUSEADDR 2
11#define SO_TYPE 3
12#define SO_ERROR 4
13#define SO_DONTROUTE 5
14#define SO_BROADCAST 6
15#define SO_SNDBUF 7
16#define SO_RCVBUF 8
17#define SO_SNDBUFFORCE 32
18#define SO_RCVBUFFORCE 33
19#define SO_KEEPALIVE 9
20#define SO_OOBINLINE 10
21#define SO_NO_CHECK 11
22#define SO_PRIORITY 12
23#define SO_LINGER 13
24#define SO_BSDCOMPAT 14
25/* To add :#define SO_REUSEPORT 15 */
26#define SO_PASSCRED 16
27#define SO_PEERCRED 17
28#define SO_RCVLOWAT 18
29#define SO_SNDLOWAT 19
30#define SO_RCVTIMEO 20
31#define SO_SNDTIMEO 21
32
33/* Security levels - as per NRL IPv6 - don't actually do anything */
34#define SO_SECURITY_AUTHENTICATION 22
35#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
36#define SO_SECURITY_ENCRYPTION_NETWORK 24
37
38#define SO_BINDTODEVICE 25
39
40/* Socket filtering */
41#define SO_ATTACH_FILTER 26
42#define SO_DETACH_FILTER 27
43
44#define SO_PEERNAME 28
45#define SO_TIMESTAMP 29
46#define SCM_TIMESTAMP SO_TIMESTAMP
47
48#define SO_ACCEPTCONN 30
49
50#define SO_PEERSEC 31
51#define SO_PASSSEC 34
52#define SO_TIMESTAMPNS 35
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54
55#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-arm26/sockios.h b/include/asm-arm26/sockios.h
deleted file mode 100644
index a2588a2512df..000000000000
--- a/include/asm-arm26/sockios.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#ifndef __ARCH_ARM_SOCKIOS_H
2#define __ARCH_ARM_SOCKIOS_H
3
4/* Socket-level I/O control calls. */
5#define FIOSETOWN 0x8901
6#define SIOCSPGRP 0x8902
7#define FIOGETOWN 0x8903
8#define SIOCGPGRP 0x8904
9#define SIOCATMARK 0x8905
10#define SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
11#define SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
12
13#endif
diff --git a/include/asm-arm26/spinlock.h b/include/asm-arm26/spinlock.h
deleted file mode 100644
index e92e81deb4fd..000000000000
--- a/include/asm-arm26/spinlock.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SPINLOCK_H
2#define __ASM_SPINLOCK_H
3
4#error ARM architecture does not support SMP spin locks
5
6#endif /* __ASM_SPINLOCK_H */
diff --git a/include/asm-arm26/stat.h b/include/asm-arm26/stat.h
deleted file mode 100644
index e4abc4fa0850..000000000000
--- a/include/asm-arm26/stat.h
+++ /dev/null
@@ -1,77 +0,0 @@
1#ifndef _ASMARM_STAT_H
2#define _ASMARM_STAT_H
3
4struct __old_kernel_stat {
5 unsigned short st_dev;
6 unsigned short st_ino;
7 unsigned short st_mode;
8 unsigned short st_nlink;
9 unsigned short st_uid;
10 unsigned short st_gid;
11 unsigned short st_rdev;
12 unsigned long st_size;
13 unsigned long st_atime;
14 unsigned long st_mtime;
15 unsigned long st_ctime;
16};
17
18struct stat {
19 unsigned short st_dev;
20 unsigned short __pad1;
21 unsigned long st_ino;
22 unsigned short st_mode;
23 unsigned short st_nlink;
24 unsigned short st_uid;
25 unsigned short st_gid;
26 unsigned short st_rdev;
27 unsigned short __pad2;
28 unsigned long st_size;
29 unsigned long st_blksize;
30 unsigned long st_blocks;
31 unsigned long st_atime;
32 unsigned long st_atime_nsec;
33 unsigned long st_mtime;
34 unsigned long st_mtime_nsec;
35 unsigned long st_ctime;
36 unsigned long st_ctime_nsec;
37 unsigned long __unused4;
38 unsigned long __unused5;
39};
40
41/* This matches struct stat64 in glibc2.1, hence the absolutely
42 * insane amounts of padding around dev_t's.
43 */
44struct stat64 {
45 unsigned long long st_dev;
46 unsigned char __pad0[4];
47
48#define STAT64_HAS_BROKEN_ST_INO 1
49 unsigned long __st_ino;
50 unsigned int st_mode;
51 unsigned int st_nlink;
52
53 unsigned long st_uid;
54 unsigned long st_gid;
55
56 unsigned long long st_rdev;
57 unsigned char __pad3[4];
58
59 long long st_size;
60 unsigned long st_blksize;
61
62 unsigned long st_blocks; /* Number 512-byte blocks allocated. */
63 unsigned long __pad4; /* Future possible st_blocks hi bits */
64
65 unsigned long st_atime;
66 unsigned long st_atime_nsec;
67
68 unsigned long st_mtime;
69 unsigned long st_mtime_nsec;
70
71 unsigned long st_ctime;
72 unsigned long st_ctime_nsec;
73
74 unsigned long long st_ino;
75};
76
77#endif
diff --git a/include/asm-arm26/statfs.h b/include/asm-arm26/statfs.h
deleted file mode 100644
index 776dbc8f7623..000000000000
--- a/include/asm-arm26/statfs.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef _ASMARM_STATFS_H
2#define _ASMARM_STATFS_H
3
4//FIXME - this may not be appropriate for arm26. check it out.
5
6#include <asm-generic/statfs.h>
7
8#endif
diff --git a/include/asm-arm26/string.h b/include/asm-arm26/string.h
deleted file mode 100644
index 2a8ab162412f..000000000000
--- a/include/asm-arm26/string.h
+++ /dev/null
@@ -1,43 +0,0 @@
1#ifndef __ASM_ARM_STRING_H
2#define __ASM_ARM_STRING_H
3
4/*
5 * We don't do inline string functions, since the
6 * optimised inline asm versions are not small.
7 */
8
9#define __HAVE_ARCH_STRRCHR
10extern char * strrchr(const char * s, int c);
11
12#define __HAVE_ARCH_STRCHR
13extern char * strchr(const char * s, int c);
14
15#define __HAVE_ARCH_MEMCPY
16extern void * memcpy(void *, const void *, __kernel_size_t);
17
18#define __HAVE_ARCH_MEMMOVE
19extern void * memmove(void *, const void *, __kernel_size_t);
20
21#define __HAVE_ARCH_MEMCHR
22extern void * memchr(const void *, int, __kernel_size_t);
23
24#define __HAVE_ARCH_MEMZERO
25#define __HAVE_ARCH_MEMSET
26extern void * memset(void *, int, __kernel_size_t);
27
28extern void __memzero(void *ptr, __kernel_size_t n);
29
30#define memset(p,v,n) \
31 ({ \
32 if ((n) != 0) { \
33 if (__builtin_constant_p((v)) && (v) == 0) \
34 __memzero((p),(n)); \
35 else \
36 memset((p),(v),(n)); \
37 } \
38 (p); \
39 })
40
41#define memzero(p,n) ({ if ((n) != 0) __memzero((p),(n)); (p); })
42
43#endif
diff --git a/include/asm-arm26/suspend.h b/include/asm-arm26/suspend.h
deleted file mode 100644
index 5e4c1cc0c19d..000000000000
--- a/include/asm-arm26/suspend.h
+++ /dev/null
@@ -1,4 +0,0 @@
1#ifdef _ASMARM_SUSPEND_H
2#define _ASMARM_SUSPEND_H
3
4#endif
diff --git a/include/asm-arm26/sysirq.h b/include/asm-arm26/sysirq.h
deleted file mode 100644
index 81dca90d9a3f..000000000000
--- a/include/asm-arm26/sysirq.h
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-arc/irqs.h
3 *
4 * Copyright (C) 1996 Russell King, Dave Gilbert
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Modifications:
11 * 04-04-1998 PJB Merged arc and a5k versions
12 */
13
14
15#if defined(CONFIG_ARCH_A5K)
16#define IRQ_PRINTER 0
17#define IRQ_BATLOW 1
18#define IRQ_FLOPPYINDEX 2
19#define IRQ_FLOPPYDISK 12
20#elif defined(CONFIG_ARCH_ARC)
21#define IRQ_PRINTERBUSY 0
22#define IRQ_SERIALRING 1
23#define IRQ_PRINTERACK 2
24#define IRQ_FLOPPYCHANGED 12
25#endif
26
27#define IRQ_VSYNCPULSE 3
28#define IRQ_POWERON 4
29#define IRQ_TIMER0 5
30#define IRQ_TIMER1 6
31#define IRQ_IMMEDIATE 7
32#define IRQ_EXPCARDFIQ 8
33#define IRQ_SOUNDCHANGE 9
34#define IRQ_SERIALPORT 10
35#define IRQ_HARDDISK 11
36#define IRQ_EXPANSIONCARD 13
37#define IRQ_KEYBOARDTX 14
38#define IRQ_KEYBOARDRX 15
39
40#if defined(CONFIG_ARCH_A5K)
41#define FIQ_SERIALPORT 4
42#elif defined(CONFIG_ARCH_ARC)
43#define FIQ_FLOPPYIRQ 1
44#define FIQ_FD1772 FIQ_FLOPPYIRQ
45#endif
46
47#define FIQ_FLOPPYDATA 0
48#define FIQ_ECONET 2
49#define FIQ_EXPANSIONCARD 6
50#define FIQ_FORCE 7
51
52#define IRQ_TIMER IRQ_TIMER0
53
54/*
55 * This is the offset of the FIQ "IRQ" numbers
56 */
57#define FIQ_START 64
58
59#define irq_cannonicalize(i) (i)
60
diff --git a/include/asm-arm26/system.h b/include/asm-arm26/system.h
deleted file mode 100644
index e09da5ff1f54..000000000000
--- a/include/asm-arm26/system.h
+++ /dev/null
@@ -1,247 +0,0 @@
1#ifndef __ASM_ARM_SYSTEM_H
2#define __ASM_ARM_SYSTEM_H
3
4#ifdef __KERNEL__
5
6
7/*
8 * This is used to ensure the compiler did actually allocate the register we
9 * asked it for some inline assembly sequences. Apparently we can't trust
10 * the compiler from one version to another so a bit of paranoia won't hurt.
11 * This string is meant to be concatenated with the inline asm string and
12 * will cause compilation to stop on mismatch. (From ARM32 - may come in handy)
13 */
14#define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t"
15
16#ifndef __ASSEMBLY__
17
18#include <linux/linkage.h>
19
20struct thread_info;
21struct task_struct;
22
23#if 0
24/* information about the system we're running on */
25extern unsigned int system_rev;
26extern unsigned int system_serial_low;
27extern unsigned int system_serial_high;
28extern unsigned int mem_fclk_21285;
29
30FIXME - sort this
31/*
32 * We need to turn the caches off before calling the reset vector - RiscOS
33 * messes up if we don't
34 */
35#define proc_hard_reset() cpu_proc_fin()
36
37#endif
38
39struct pt_regs;
40
41void die(const char *msg, struct pt_regs *regs, int err)
42 __attribute__((noreturn));
43
44void die_if_kernel(const char *str, struct pt_regs *regs, int err);
45
46void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
47 struct pt_regs *),
48 int sig, const char *name);
49
50#include <asm/proc-fns.h>
51
52#define xchg(ptr,x) \
53 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
54
55extern asmlinkage void __backtrace(void);
56
57#define set_cr(x) \
58 __asm__ __volatile__( \
59 "mcr p15, 0, %0, c1, c0, 0 @ set CR" \
60 : : "r" (x) : "cc")
61
62#define get_cr() \
63 ({ \
64 unsigned int __val; \
65 __asm__ __volatile__( \
66 "mrc p15, 0, %0, c1, c0, 0 @ get CR" \
67 : "=r" (__val) : : "cc"); \
68 __val; \
69 })
70
71extern unsigned long cr_no_alignment; /* defined in entry-armv.S */
72extern unsigned long cr_alignment; /* defined in entry-armv.S */
73
74#define UDBG_UNDEFINED (1 << 0)
75#define UDBG_SYSCALL (1 << 1)
76#define UDBG_BADABORT (1 << 2)
77#define UDBG_SEGV (1 << 3)
78#define UDBG_BUS (1 << 4)
79
80extern unsigned int user_debug;
81
82#define vectors_base() (0)
83
84#define mb() __asm__ __volatile__ ("" : : : "memory")
85#define rmb() mb()
86#define wmb() mb()
87#define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
88
89#define read_barrier_depends() do { } while(0)
90#define set_mb(var, value) do { var = value; mb(); } while (0)
91
92/*
93 * We assume knowledge of how
94 * spin_unlock_irq() and friends are implemented. This avoids
95 * us needlessly decrementing and incrementing the preempt count.
96 */
97#define prepare_arch_switch(next) local_irq_enable()
98#define finish_arch_switch(prev) spin_unlock(&(rq)->lock)
99
100/*
101 * switch_to(prev, next) should switch from task `prev' to `next'
102 * `prev' will never be the same as `next'. schedule() itself
103 * contains the memory barrier to tell GCC not to cache `current'.
104 */
105extern struct task_struct *__switch_to(struct task_struct *, struct thread_info *, struct thread_info *);
106
107#define switch_to(prev,next,last) \
108do { \
109 last = __switch_to(prev,task_thread_info(prev),task_thread_info(next)); \
110} while (0)
111
112/*
113 * Save the current interrupt enable state & disable IRQs
114 */
115#define local_irq_save(x) \
116 do { \
117 unsigned long temp; \
118 __asm__ __volatile__( \
119" mov %0, pc @ save_flags_cli\n" \
120" orr %1, %0, #0x08000000\n" \
121" and %0, %0, #0x0c000000\n" \
122" teqp %1, #0\n" \
123 : "=r" (x), "=r" (temp) \
124 : \
125 : "memory"); \
126 } while (0)
127
128/*
129 * Enable IRQs (sti)
130 */
131#define local_irq_enable() \
132 do { \
133 unsigned long temp; \
134 __asm__ __volatile__( \
135" mov %0, pc @ sti\n" \
136" bic %0, %0, #0x08000000\n" \
137" teqp %0, #0\n" \
138 : "=r" (temp) \
139 : \
140 : "memory"); \
141 } while(0)
142
143/*
144 * Disable IRQs (cli)
145 */
146#define local_irq_disable() \
147 do { \
148 unsigned long temp; \
149 __asm__ __volatile__( \
150" mov %0, pc @ cli\n" \
151" orr %0, %0, #0x08000000\n" \
152" teqp %0, #0\n" \
153 : "=r" (temp) \
154 : \
155 : "memory"); \
156 } while(0)
157
158/* Enable FIQs (stf) */
159
160#define __stf() do { \
161 unsigned long temp; \
162 __asm__ __volatile__( \
163" mov %0, pc @ stf\n" \
164" bic %0, %0, #0x04000000\n" \
165" teqp %0, #0\n" \
166 : "=r" (temp)); \
167 } while(0)
168
169/* Disable FIQs (clf) */
170
171#define __clf() do { \
172 unsigned long temp; \
173 __asm__ __volatile__( \
174" mov %0, pc @ clf\n" \
175" orr %0, %0, #0x04000000\n" \
176" teqp %0, #0\n" \
177 : "=r" (temp)); \
178 } while(0)
179
180
181/*
182 * Save the current interrupt enable state.
183 */
184#define local_save_flags(x) \
185 do { \
186 __asm__ __volatile__( \
187" mov %0, pc @ save_flags\n" \
188" and %0, %0, #0x0c000000\n" \
189 : "=r" (x)); \
190 } while (0)
191
192
193/*
194 * restore saved IRQ & FIQ state
195 */
196#define local_irq_restore(x) \
197 do { \
198 unsigned long temp; \
199 __asm__ __volatile__( \
200" mov %0, pc @ restore_flags\n" \
201" bic %0, %0, #0x0c000000\n" \
202" orr %0, %0, %1\n" \
203" teqp %0, #0\n" \
204 : "=&r" (temp) \
205 : "r" (x) \
206 : "memory"); \
207 } while (0)
208
209
210#ifdef CONFIG_SMP
211#error SMP not supported
212#endif
213
214#define smp_mb() barrier()
215#define smp_rmb() barrier()
216#define smp_wmb() barrier()
217#define smp_read_barrier_depends() do { } while(0)
218
219#define clf() __clf()
220#define stf() __stf()
221
222#define irqs_disabled() \
223({ \
224 unsigned long flags; \
225 local_save_flags(flags); \
226 flags & PSR_I_BIT; \
227})
228
229static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
230{
231 extern void __bad_xchg(volatile void *, int);
232
233 switch (size) {
234 case 1: return cpu_xchg_1(x, ptr);
235 case 4: return cpu_xchg_4(x, ptr);
236 default: __bad_xchg(ptr, size);
237 }
238 return 0;
239}
240
241#endif /* __ASSEMBLY__ */
242
243#define arch_align_stack(x) (x)
244
245#endif /* __KERNEL__ */
246
247#endif
diff --git a/include/asm-arm26/termbits.h b/include/asm-arm26/termbits.h
deleted file mode 100644
index 48d2f5c7bcb8..000000000000
--- a/include/asm-arm26/termbits.h
+++ /dev/null
@@ -1,196 +0,0 @@
1#ifndef __ASM_ARM_TERMBITS_H
2#define __ASM_ARM_TERMBITS_H
3
4typedef unsigned char cc_t;
5typedef unsigned int speed_t;
6typedef unsigned int tcflag_t;
7
8#define NCCS 19
9struct termios {
10 tcflag_t c_iflag; /* input mode flags */
11 tcflag_t c_oflag; /* output mode flags */
12 tcflag_t c_cflag; /* control mode flags */
13 tcflag_t c_lflag; /* local mode flags */
14 cc_t c_line; /* line discipline */
15 cc_t c_cc[NCCS]; /* control characters */
16};
17
18struct termios2 {
19 tcflag_t c_iflag; /* input mode flags */
20 tcflag_t c_oflag; /* output mode flags */
21 tcflag_t c_cflag; /* control mode flags */
22 tcflag_t c_lflag; /* local mode flags */
23 cc_t c_line; /* line discipline */
24 cc_t c_cc[NCCS]; /* control characters */
25 speed_t c_ispeed; /* input speed */
26 speed_t c_ospeed; /* output speed */
27};
28
29struct ktermios {
30 tcflag_t c_iflag; /* input mode flags */
31 tcflag_t c_oflag; /* output mode flags */
32 tcflag_t c_cflag; /* control mode flags */
33 tcflag_t c_lflag; /* local mode flags */
34 cc_t c_line; /* line discipline */
35 cc_t c_cc[NCCS]; /* control characters */
36 speed_t c_ispeed; /* input speed */
37 speed_t c_ospeed; /* output speed */
38};
39
40/* c_cc characters */
41#define VINTR 0
42#define VQUIT 1
43#define VERASE 2
44#define VKILL 3
45#define VEOF 4
46#define VTIME 5
47#define VMIN 6
48#define VSWTC 7
49#define VSTART 8
50#define VSTOP 9
51#define VSUSP 10
52#define VEOL 11
53#define VREPRINT 12
54#define VDISCARD 13
55#define VWERASE 14
56#define VLNEXT 15
57#define VEOL2 16
58
59/* c_iflag bits */
60#define IGNBRK 0000001
61#define BRKINT 0000002
62#define IGNPAR 0000004
63#define PARMRK 0000010
64#define INPCK 0000020
65#define ISTRIP 0000040
66#define INLCR 0000100
67#define IGNCR 0000200
68#define ICRNL 0000400
69#define IUCLC 0001000
70#define IXON 0002000
71#define IXANY 0004000
72#define IXOFF 0010000
73#define IMAXBEL 0020000
74#define IUTF8 0040000
75
76/* c_oflag bits */
77#define OPOST 0000001
78#define OLCUC 0000002
79#define ONLCR 0000004
80#define OCRNL 0000010
81#define ONOCR 0000020
82#define ONLRET 0000040
83#define OFILL 0000100
84#define OFDEL 0000200
85#define NLDLY 0000400
86#define NL0 0000000
87#define NL1 0000400
88#define CRDLY 0003000
89#define CR0 0000000
90#define CR1 0001000
91#define CR2 0002000
92#define CR3 0003000
93#define TABDLY 0014000
94#define TAB0 0000000
95#define TAB1 0004000
96#define TAB2 0010000
97#define TAB3 0014000
98#define XTABS 0014000
99#define BSDLY 0020000
100#define BS0 0000000
101#define BS1 0020000
102#define VTDLY 0040000
103#define VT0 0000000
104#define VT1 0040000
105#define FFDLY 0100000
106#define FF0 0000000
107#define FF1 0100000
108
109/* c_cflag bit meaning */
110#define CBAUD 0010017
111#define B0 0000000 /* hang up */
112#define B50 0000001
113#define B75 0000002
114#define B110 0000003
115#define B134 0000004
116#define B150 0000005
117#define B200 0000006
118#define B300 0000007
119#define B600 0000010
120#define B1200 0000011
121#define B1800 0000012
122#define B2400 0000013
123#define B4800 0000014
124#define B9600 0000015
125#define B19200 0000016
126#define B38400 0000017
127#define EXTA B19200
128#define EXTB B38400
129#define CSIZE 0000060
130#define CS5 0000000
131#define CS6 0000020
132#define CS7 0000040
133#define CS8 0000060
134#define CSTOPB 0000100
135#define CREAD 0000200
136#define PARENB 0000400
137#define PARODD 0001000
138#define HUPCL 0002000
139#define CLOCAL 0004000
140#define CBAUDEX 0010000
141#define BOTHER 0010000
142#define B57600 0010001
143#define B115200 0010002
144#define B230400 0010003
145#define B460800 0010004
146#define B500000 0010005
147#define B576000 0010006
148#define B921600 0010007
149#define B1000000 0010010
150#define B1152000 0010011
151#define B1500000 0010012
152#define B2000000 0010013
153#define B2500000 0010014
154#define B3000000 0010015
155#define B3500000 0010016
156#define B4000000 0010017
157#define CIBAUD 002003600000 /* input baud rate */
158#define CMSPAR 010000000000 /* mark or space (stick) parity */
159#define CRTSCTS 020000000000 /* flow control */
160
161#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
162
163/* c_lflag bits */
164#define ISIG 0000001
165#define ICANON 0000002
166#define XCASE 0000004
167#define ECHO 0000010
168#define ECHOE 0000020
169#define ECHOK 0000040
170#define ECHONL 0000100
171#define NOFLSH 0000200
172#define TOSTOP 0000400
173#define ECHOCTL 0001000
174#define ECHOPRT 0002000
175#define ECHOKE 0004000
176#define FLUSHO 0010000
177#define PENDIN 0040000
178#define IEXTEN 0100000
179
180/* tcflow() and TCXONC use these */
181#define TCOOFF 0
182#define TCOON 1
183#define TCIOFF 2
184#define TCION 3
185
186/* tcflush() and TCFLSH use these */
187#define TCIFLUSH 0
188#define TCOFLUSH 1
189#define TCIOFLUSH 2
190
191/* tcsetattr uses these */
192#define TCSANOW 0
193#define TCSADRAIN 1
194#define TCSAFLUSH 2
195
196#endif /* __ASM_ARM_TERMBITS_H */
diff --git a/include/asm-arm26/termios.h b/include/asm-arm26/termios.h
deleted file mode 100644
index 293e3f1bc3f2..000000000000
--- a/include/asm-arm26/termios.h
+++ /dev/null
@@ -1,92 +0,0 @@
1#ifndef __ASM_ARM_TERMIOS_H
2#define __ASM_ARM_TERMIOS_H
3
4#include <asm/termbits.h>
5#include <asm/ioctls.h>
6
7struct winsize {
8 unsigned short ws_row;
9 unsigned short ws_col;
10 unsigned short ws_xpixel;
11 unsigned short ws_ypixel;
12};
13
14#define NCC 8
15struct termio {
16 unsigned short c_iflag; /* input mode flags */
17 unsigned short c_oflag; /* output mode flags */
18 unsigned short c_cflag; /* control mode flags */
19 unsigned short c_lflag; /* local mode flags */
20 unsigned char c_line; /* line discipline */
21 unsigned char c_cc[NCC]; /* control characters */
22};
23
24#ifdef __KERNEL__
25/* intr=^C quit=^| erase=del kill=^U
26 eof=^D vtime=\0 vmin=\1 sxtc=\0
27 start=^Q stop=^S susp=^Z eol=\0
28 reprint=^R discard=^U werase=^W lnext=^V
29 eol2=\0
30*/
31#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
32#endif
33
34/* modem lines */
35#define TIOCM_LE 0x001
36#define TIOCM_DTR 0x002
37#define TIOCM_RTS 0x004
38#define TIOCM_ST 0x008
39#define TIOCM_SR 0x010
40#define TIOCM_CTS 0x020
41#define TIOCM_CAR 0x040
42#define TIOCM_RNG 0x080
43#define TIOCM_DSR 0x100
44#define TIOCM_CD TIOCM_CAR
45#define TIOCM_RI TIOCM_RNG
46#define TIOCM_OUT1 0x2000
47#define TIOCM_OUT2 0x4000
48#define TIOCM_LOOP 0x8000
49
50/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
51
52#ifdef __KERNEL__
53
54/*
55 * Translate a "termio" structure into a "termios". Ugh.
56 */
57#define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
58 unsigned short __tmp; \
59 get_user(__tmp,&(termio)->x); \
60 *(unsigned short *) &(termios)->x = __tmp; \
61}
62
63#define user_termio_to_kernel_termios(termios, termio) \
64({ \
65 SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
66 SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
67 SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
68 SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
69 copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
70})
71
72/*
73 * Translate a "termios" structure into a "termio". Ugh.
74 */
75#define kernel_termios_to_user_termio(termio, termios) \
76({ \
77 put_user((termios)->c_iflag, &(termio)->c_iflag); \
78 put_user((termios)->c_oflag, &(termio)->c_oflag); \
79 put_user((termios)->c_cflag, &(termio)->c_cflag); \
80 put_user((termios)->c_lflag, &(termio)->c_lflag); \
81 put_user((termios)->c_line, &(termio)->c_line); \
82 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
83})
84
85#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2))
86#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2))
87#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
88#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
89
90#endif /* __KERNEL__ */
91
92#endif /* __ASM_ARM_TERMIOS_H */
diff --git a/include/asm-arm26/thread_info.h b/include/asm-arm26/thread_info.h
deleted file mode 100644
index 9b367ebe515d..000000000000
--- a/include/asm-arm26/thread_info.h
+++ /dev/null
@@ -1,140 +0,0 @@
1/*
2 * linux/include/asm-arm26/thread_info.h
3 *
4 * Copyright (C) 2002 Russell King.
5 * Copyright (C) 2003 Ian Molton.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef __ASM_ARM_THREAD_INFO_H
12#define __ASM_ARM_THREAD_INFO_H
13
14#ifdef __KERNEL__
15
16#ifndef __ASSEMBLY__
17
18struct task_struct;
19struct exec_domain;
20
21#include <linux/compiler.h>
22#include <asm/fpstate.h>
23#include <asm/ptrace.h>
24#include <asm/types.h>
25
26typedef unsigned long mm_segment_t;
27
28struct cpu_context_save {
29 __u32 r4;
30 __u32 r5;
31 __u32 r6;
32 __u32 r7;
33 __u32 r8;
34 __u32 r9;
35 __u32 sl;
36 __u32 fp;
37 __u32 sp;
38 __u32 pc;
39};
40
41/*
42 * low level task data that entry.S needs immediate access to.
43 * We assume cpu_context follows immedately after cpu_domain.
44 */
45struct thread_info {
46 unsigned long flags; /* low level flags */
47 int preempt_count; /* 0 => preemptable, <0 => bug */
48 mm_segment_t addr_limit; /* address limit */
49 struct task_struct *task; /* main task structure */
50 struct exec_domain *exec_domain; /* execution domain */
51 __u32 cpu; /* cpu */
52 struct cpu_context_save cpu_context; /* cpu context */
53 struct restart_block restart_block;
54 union fp_state fpstate;
55};
56
57#define INIT_THREAD_INFO(tsk) \
58{ \
59 .task &tsk, \
60 .exec_domain &default_exec_domain, \
61 .flags 0, \
62 .preempt_count 0, \
63 .addr_limit KERNEL_DS, \
64 .restart_block = { \
65 .fn = do_no_restart_syscall, \
66 }, \
67}
68
69#define init_thread_info (init_thread_union.thread_info)
70#define init_stack (init_thread_union.stack)
71
72/*
73 * how to get the thread information struct from C
74 */
75static inline struct thread_info *current_thread_info(void) __attribute_const__;
76
77static inline struct thread_info *current_thread_info(void)
78{
79 register unsigned long sp asm ("sp");
80 return (struct thread_info *)(sp & ~0x1fff);
81}
82
83#define THREAD_SIZE PAGE_SIZE
84#define task_pt_regs(task) ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE - 8) - 1)
85
86extern struct thread_info *alloc_thread_info(struct task_struct *task);
87extern void free_thread_info(struct thread_info *);
88
89#define thread_saved_pc(tsk) \
90 ((unsigned long)(pc_pointer(task_thread_info(tsk)->cpu_context.pc)))
91#define thread_saved_fp(tsk) \
92 ((unsigned long)(task_thread_info(tsk)->cpu_context.fp))
93
94#else /* !__ASSEMBLY__ */
95
96#define TI_FLAGS 0
97#define TI_PREEMPT 4
98#define TI_ADDR_LIMIT 8
99#define TI_TASK 12
100#define TI_EXEC_DOMAIN 16
101#define TI_CPU 20
102#define TI_CPU_SAVE 24
103#define TI_RESTART_BLOCK 28
104#define TI_FPSTATE 68
105
106#endif
107
108#define PREEMPT_ACTIVE 0x04000000
109
110/*
111 * thread information flags:
112 * TIF_SYSCALL_TRACE - syscall trace active
113 * TIF_NOTIFY_RESUME - resumption notification requested
114 * TIF_SIGPENDING - signal pending
115 * TIF_NEED_RESCHED - rescheduling necessary
116 * TIF_USEDFPU - FPU was used by this task this quantum (SMP)
117 * TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED
118 */
119#define TIF_NOTIFY_RESUME 0
120#define TIF_SIGPENDING 1
121#define TIF_NEED_RESCHED 2
122#define TIF_SYSCALL_TRACE 8
123#define TIF_USED_FPU 16
124#define TIF_POLLING_NRFLAG 17
125#define TIF_MEMDIE 18
126
127#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
128#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
129#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
130#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
131#define _TIF_USED_FPU (1 << TIF_USED_FPU)
132#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
133
134/*
135 * Change these and you break ASM code in entry-common.S
136 */
137#define _TIF_WORK_MASK 0x000000ff
138
139#endif /* __KERNEL__ */
140#endif /* __ASM_ARM_THREAD_INFO_H */
diff --git a/include/asm-arm26/timex.h b/include/asm-arm26/timex.h
deleted file mode 100644
index 68322fbc1aed..000000000000
--- a/include/asm-arm26/timex.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * linux/include/asm-arm/timex.h
3 *
4 * Copyright (C) 1997,1998 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Architecture Specific TIME specifications
11 */
12#ifndef _ASMARM_TIMEX_H
13#define _ASMARM_TIMEX_H
14
15/*
16 * On the RiscPC, the clock ticks at 2MHz.
17 */
18#define CLOCK_TICK_RATE 2000000
19
20/* IS THAT RIGHT ON A5000? FIXME */
21
22typedef unsigned long cycles_t;
23
24static inline cycles_t get_cycles (void)
25{
26 return 0;
27}
28
29#endif
diff --git a/include/asm-arm26/tlb.h b/include/asm-arm26/tlb.h
deleted file mode 100644
index 08ddd85b8d35..000000000000
--- a/include/asm-arm26/tlb.h
+++ /dev/null
@@ -1,63 +0,0 @@
1#ifndef __ASMARM_TLB_H
2#define __ASMARM_TLB_H
3
4#include <asm/pgalloc.h>
5#include <asm/tlbflush.h>
6
7/*
8 * TLB handling. This allows us to remove pages from the page
9 * tables, and efficiently handle the TLB issues.
10 */
11struct mmu_gather {
12 struct mm_struct *mm;
13 unsigned int need_flush;
14 unsigned int fullmm;
15};
16
17DECLARE_PER_CPU(struct mmu_gather, mmu_gathers);
18
19static inline struct mmu_gather *
20tlb_gather_mmu(struct mm_struct *mm, unsigned int full_mm_flush)
21{
22 struct mmu_gather *tlb = &get_cpu_var(mmu_gathers);
23
24 tlb->mm = mm;
25 tlb->need_flush = 0;
26 tlb->fullmm = full_mm_flush;
27
28 return tlb;
29}
30
31static inline void
32tlb_finish_mmu(struct mmu_gather *tlb, unsigned long start, unsigned long end)
33{
34 if (tlb->need_flush)
35 flush_tlb_mm(tlb->mm);
36
37 /* keep the page table cache within bounds */
38 check_pgt_cache();
39
40 put_cpu_var(mmu_gathers);
41}
42
43#define tlb_remove_tlb_entry(tlb,ptep,address) do { } while (0)
44//#define tlb_start_vma(tlb,vma) do { } while (0)
45//FIXME - ARM32 uses this now that things changed in the kernel. seems like it may be pointless on arm26, however to get things compiling...
46#define tlb_start_vma(tlb,vma) \
47 do { \
48 if (!tlb->fullmm) \
49 flush_cache_range(vma, vma->vm_start, vma->vm_end); \
50 } while (0)
51#define tlb_end_vma(tlb,vma) do { } while (0)
52
53static inline void
54tlb_remove_page(struct mmu_gather *tlb, struct page *page)
55{
56 tlb->need_flush = 1;
57 free_page_and_swap_cache(page);
58}
59
60#define pte_free_tlb(tlb,ptep) pte_free(ptep)
61#define pmd_free_tlb(tlb,pmdp) pmd_free(pmdp)
62
63#endif
diff --git a/include/asm-arm26/tlbflush.h b/include/asm-arm26/tlbflush.h
deleted file mode 100644
index f79c1cbf4f69..000000000000
--- a/include/asm-arm26/tlbflush.h
+++ /dev/null
@@ -1,70 +0,0 @@
1#ifndef __ASMARM_TLBFLUSH_H
2#define __ASMARM_TLBFLUSH_H
3
4/*
5 * TLB flushing:
6 *
7 * - flush_tlb_all() flushes all processes TLBs
8 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
9 * - flush_tlb_page(vma, vmaddr) flushes one page
10 * - flush_tlb_range(vma, start, end) flushes a range of pages
11 */
12
13#define flush_tlb_all() memc_update_all()
14#define flush_tlb_mm(mm) memc_update_mm(mm)
15#define flush_tlb_page(vma, vmaddr) do { printk("flush_tlb_page\n");} while (0) // IS THIS RIGHT?
16#define flush_tlb_range(vma,start,end) \
17 do { memc_update_mm(vma->vm_mm); (void)(start); (void)(end); } while (0)
18#define flush_tlb_pgtables(mm,start,end) do { printk("flush_tlb_pgtables\n");} while (0)
19#define flush_tlb_kernel_range(s,e) do { printk("flush_tlb_range\n");} while (0)
20
21/*
22 * The following handle the weird MEMC chip
23 */
24static inline void memc_update_all(void)
25{
26 struct task_struct *p;
27 cpu_memc_update_all(init_mm.pgd);
28 for_each_process(p) {
29 if (!p->mm)
30 continue;
31 cpu_memc_update_all(p->mm->pgd);
32 }
33 processor._set_pgd(current->active_mm->pgd);
34}
35
36static inline void memc_update_mm(struct mm_struct *mm)
37{
38 cpu_memc_update_all(mm->pgd);
39
40 if (mm == current->active_mm)
41 processor._set_pgd(mm->pgd);
42}
43
44static inline void
45memc_clear(struct mm_struct *mm, struct page *page)
46{
47 cpu_memc_update_entry(mm->pgd, (unsigned long) page_address(page), 0);
48
49 if (mm == current->active_mm)
50 processor._set_pgd(mm->pgd);
51}
52
53static inline void
54memc_update_addr(struct mm_struct *mm, pte_t pte, unsigned long vaddr)
55{
56 cpu_memc_update_entry(mm->pgd, pte_val(pte), vaddr);
57
58 if (mm == current->active_mm)
59 processor._set_pgd(mm->pgd);
60}
61
62static inline void
63update_mmu_cache(struct vm_area_struct *vma, unsigned long addr, pte_t pte)
64{
65 struct mm_struct *mm = vma->vm_mm;
66printk("update_mmu_cache\n");
67 memc_update_addr(mm, pte, addr);
68}
69
70#endif
diff --git a/include/asm-arm26/topology.h b/include/asm-arm26/topology.h
deleted file mode 100644
index accbd7cad9b5..000000000000
--- a/include/asm-arm26/topology.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_ARM_TOPOLOGY_H
2#define _ASM_ARM_TOPOLOGY_H
3
4#include <asm-generic/topology.h>
5
6#endif /* _ASM_ARM_TOPOLOGY_H */
diff --git a/include/asm-arm26/types.h b/include/asm-arm26/types.h
deleted file mode 100644
index 81bd357ada02..000000000000
--- a/include/asm-arm26/types.h
+++ /dev/null
@@ -1,59 +0,0 @@
1#ifndef __ASM_ARM_TYPES_H
2#define __ASM_ARM_TYPES_H
3
4#ifndef __ASSEMBLY__
5
6typedef unsigned short umode_t;
7
8/*
9 * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
10 * header files exported to user space
11 */
12
13typedef __signed__ char __s8;
14typedef unsigned char __u8;
15
16typedef __signed__ short __s16;
17typedef unsigned short __u16;
18
19typedef __signed__ int __s32;
20typedef unsigned int __u32;
21
22#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
23typedef __signed__ long long __s64;
24typedef unsigned long long __u64;
25#endif
26
27#endif /* __ASSEMBLY__ */
28
29/*
30 * These aren't exported outside the kernel to avoid name space clashes
31 */
32#ifdef __KERNEL__
33
34#define BITS_PER_LONG 32
35
36#ifndef __ASSEMBLY__
37
38typedef signed char s8;
39typedef unsigned char u8;
40
41typedef signed short s16;
42typedef unsigned short u16;
43
44typedef signed int s32;
45typedef unsigned int u32;
46
47typedef signed long long s64;
48typedef unsigned long long u64;
49
50/* Dma addresses are 32-bits wide. */
51
52typedef u32 dma_addr_t;
53typedef u32 dma64_addr_t;
54
55#endif /* __ASSEMBLY__ */
56
57#endif /* __KERNEL__ */
58
59#endif
diff --git a/include/asm-arm26/uaccess-asm.h b/include/asm-arm26/uaccess-asm.h
deleted file mode 100644
index ade76ec02995..000000000000
--- a/include/asm-arm26/uaccess-asm.h
+++ /dev/null
@@ -1,153 +0,0 @@
1/*
2 * linux/include/asm-arm/proc-armo/uaccess.h
3 *
4 * Copyright (C) 1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11/*
12 * The fs functions are implemented on the ARM2 and ARM3 architectures
13 * manually.
14 * Use *_user functions to access user memory with faulting behaving
15 * as though the user is accessing the memory.
16 * Use set_fs(get_ds()) and then the *_user functions to allow them to
17 * access kernel memory.
18 */
19
20/*
21 * These are the values used to represent the user `fs' and the kernel `ds'
22 * FIXME - the KERNEL_DS should end at 0x03000000 but we want to access ROM at
23 * 0x03400000. ideally we want to forbid access to the IO space inbetween.
24 */
25#define KERNEL_DS 0x03FFFFFF
26#define USER_DS 0x02000000
27
28extern uaccess_t uaccess_user, uaccess_kernel;
29
30static inline void set_fs (mm_segment_t fs)
31{
32 current_thread_info()->addr_limit = fs;
33 current->thread.uaccess = (fs == USER_DS ? &uaccess_user : &uaccess_kernel);
34}
35
36#define __range_ok(addr,size) ({ \
37 unsigned long flag, roksum; \
38 __asm__ __volatile__("subs %1, %0, %3; cmpcs %1, %2; movcs %0, #0" \
39 : "=&r" (flag), "=&r" (roksum) \
40 : "r" (addr), "Ir" (size), "0" (current_thread_info()->addr_limit) \
41 : "cc"); \
42 flag; })
43
44#define __addr_ok(addr) ({ \
45 unsigned long flag; \
46 __asm__ __volatile__("cmp %2, %0; movlo %0, #0" \
47 : "=&r" (flag) \
48 : "0" (current_thread_info()->addr_limit), "r" (addr) \
49 : "cc"); \
50 (flag == 0); })
51
52#define __put_user_asm_byte(x,addr,err) \
53 __asm__ __volatile__( \
54 " mov r0, %1\n" \
55 " mov r1, %2\n" \
56 " mov r2, %0\n" \
57 " mov lr, pc\n" \
58 " mov pc, %3\n" \
59 " mov %0, r2\n" \
60 : "=r" (err) \
61 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_byte), \
62 "0" (err) \
63 : "r0", "r1", "r2", "lr")
64
65#define __put_user_asm_half(x,addr,err) \
66 __asm__ __volatile__( \
67 " mov r0, %1\n" \
68 " mov r1, %2\n" \
69 " mov r2, %0\n" \
70 " mov lr, pc\n" \
71 " mov pc, %3\n" \
72 " mov %0, r2\n" \
73 : "=r" (err) \
74 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_half), \
75 "0" (err) \
76 : "r0", "r1", "r2", "lr")
77
78#define __put_user_asm_word(x,addr,err) \
79 __asm__ __volatile__( \
80 " mov r0, %1\n" \
81 " mov r1, %2\n" \
82 " mov r2, %0\n" \
83 " mov lr, pc\n" \
84 " mov pc, %3\n" \
85 " mov %0, r2\n" \
86 : "=r" (err) \
87 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_word), \
88 "0" (err) \
89 : "r0", "r1", "r2", "lr")
90
91#define __put_user_asm_dword(x,addr,err) \
92 __asm__ __volatile__( \
93 " mov r0, %1\n" \
94 " mov r1, %2\n" \
95 " mov r2, %0\n" \
96 " mov lr, pc\n" \
97 " mov pc, %3\n" \
98 " mov %0, r2\n" \
99 : "=r" (err) \
100 : "r" (x), "r" (addr), "r" (current->thread.uaccess->put_dword), \
101 "0" (err) \
102 : "r0", "r1", "r2", "lr")
103
104#define __get_user_asm_byte(x,addr,err) \
105 __asm__ __volatile__( \
106 " mov r0, %2\n" \
107 " mov r1, %0\n" \
108 " mov lr, pc\n" \
109 " mov pc, %3\n" \
110 " mov %0, r1\n" \
111 " mov %1, r0\n" \
112 : "=r" (err), "=r" (x) \
113 : "r" (addr), "r" (current->thread.uaccess->get_byte), "0" (err) \
114 : "r0", "r1", "r2", "lr")
115
116#define __get_user_asm_half(x,addr,err) \
117 __asm__ __volatile__( \
118 " mov r0, %2\n" \
119 " mov r1, %0\n" \
120 " mov lr, pc\n" \
121 " mov pc, %3\n" \
122 " mov %0, r1\n" \
123 " mov %1, r0\n" \
124 : "=r" (err), "=r" (x) \
125 : "r" (addr), "r" (current->thread.uaccess->get_half), "0" (err) \
126 : "r0", "r1", "r2", "lr")
127
128#define __get_user_asm_word(x,addr,err) \
129 __asm__ __volatile__( \
130 " mov r0, %2\n" \
131 " mov r1, %0\n" \
132 " mov lr, pc\n" \
133 " mov pc, %3\n" \
134 " mov %0, r1\n" \
135 " mov %1, r0\n" \
136 : "=r" (err), "=r" (x) \
137 : "r" (addr), "r" (current->thread.uaccess->get_word), "0" (err) \
138 : "r0", "r1", "r2", "lr")
139
140#define __do_copy_from_user(to,from,n) \
141 (n) = current->thread.uaccess->copy_from_user((to),(from),(n))
142
143#define __do_copy_to_user(to,from,n) \
144 (n) = current->thread.uaccess->copy_to_user((to),(from),(n))
145
146#define __do_clear_user(addr,sz) \
147 (sz) = current->thread.uaccess->clear_user((addr),(sz))
148
149#define __do_strncpy_from_user(dst,src,count,res) \
150 (res) = current->thread.uaccess->strncpy_from_user(dst,src,count)
151
152#define __do_strnlen_user(s,n,res) \
153 (res) = current->thread.uaccess->strnlen_user(s,n)
diff --git a/include/asm-arm26/uaccess.h b/include/asm-arm26/uaccess.h
deleted file mode 100644
index d64ed84cb2d3..000000000000
--- a/include/asm-arm26/uaccess.h
+++ /dev/null
@@ -1,293 +0,0 @@
1#ifndef _ASMARM_UACCESS_H
2#define _ASMARM_UACCESS_H
3
4/*
5 * User space memory access functions
6 */
7#include <linux/sched.h>
8#include <asm/errno.h>
9
10#define VERIFY_READ 0
11#define VERIFY_WRITE 1
12
13/*
14 * The exception table consists of pairs of addresses: the first is the
15 * address of an instruction that is allowed to fault, and the second is
16 * the address at which the program should continue. No registers are
17 * modified, so it is entirely up to the continuation code to figure out
18 * what to do.
19 *
20 * All the routines below use bits of fixup code that are out of line
21 * with the main instruction path. This means when everything is well,
22 * we don't even have to jump over them. Further, they do not intrude
23 * on our cache or tlb entries.
24 */
25
26struct exception_table_entry
27{
28 unsigned long insn, fixup;
29};
30
31/* Returns 0 if exception not found and fixup otherwise. */
32extern unsigned long search_exception_table(unsigned long);
33extern int fixup_exception(struct pt_regs *regs);
34
35#define get_ds() (KERNEL_DS)
36#define get_fs() (current_thread_info()->addr_limit)
37#define segment_eq(a,b) ((a) == (b))
38
39#include <asm/uaccess-asm.h>
40
41#define access_ok(type,addr,size) (__range_ok(addr,size) == 0)
42
43/*
44 * Single-value transfer routines. They automatically use the right
45 * size if we just have the right pointer type. Note that the functions
46 * which read from user space (*get_*) need to take care not to leak
47 * kernel data even if the calling code is buggy and fails to check
48 * the return value. This means zeroing out the destination variable
49 * or buffer on error. Normally this is done out of line by the
50 * fixup code, but there are a few places where it intrudes on the
51 * main code path. When we only write to user space, there is no
52 * problem.
53 *
54 * The "__xxx" versions of the user access functions do not verify the
55 * address space - it must have been done previously with a separate
56 * "access_ok()" call.
57 *
58 * The "xxx_error" versions set the third argument to EFAULT if an
59 * error occurs, and leave it unchanged on success. Note that these
60 * versions are void (ie, don't return a value as such).
61 */
62
63extern int __get_user_1(void *);
64extern int __get_user_2(void *);
65extern int __get_user_4(void *);
66extern int __get_user_8(void *);
67extern int __get_user_bad(void);
68
69#define __get_user_x(__r1,__p,__e,__s,__i...) \
70 __asm__ __volatile__ ("bl __get_user_" #__s \
71 : "=&r" (__e), "=r" (__r1) \
72 : "0" (__p) \
73 : __i)
74
75#define get_user(x,p) \
76 ({ \
77 register const typeof(*(p)) *__p asm("r0") = (p); \
78 register typeof(*(p)) __r1 asm("r1"); \
79 register int __e asm("r0"); \
80 switch (sizeof(*(p))) { \
81 case 1: \
82 __get_user_x(__r1, __p, __e, 1, "lr"); \
83 break; \
84 case 2: \
85 __get_user_x(__r1, __p, __e, 2, "r2", "lr"); \
86 break; \
87 case 4: \
88 __get_user_x(__r1, __p, __e, 4, "lr"); \
89 break; \
90 case 8: \
91 __get_user_x(__r1, __p, __e, 8, "lr"); \
92 break; \
93 default: __e = __get_user_bad(); break; \
94 } \
95 x = __r1; \
96 __e; \
97 })
98
99
100#define __get_user(x,ptr) \
101({ \
102 long __gu_err = 0; \
103 __get_user_err((x),(ptr),__gu_err); \
104 __gu_err; \
105})
106
107#define __get_user_error(x,ptr,err) \
108({ \
109 __get_user_err((x),(ptr),err); \
110 (void) 0; \
111})
112
113#define __get_user_err(x,ptr,err) \
114do { \
115 unsigned long __gu_addr = (unsigned long)(ptr); \
116 unsigned long __gu_val; \
117 switch (sizeof(*(ptr))) { \
118 case 1: __get_user_asm_byte(__gu_val,__gu_addr,err); break; \
119 case 2: __get_user_asm_half(__gu_val,__gu_addr,err); break; \
120 case 4: __get_user_asm_word(__gu_val,__gu_addr,err); break; \
121 default: (__gu_val) = __get_user_bad(); \
122 } \
123 (x) = (__typeof__(*(ptr)))__gu_val; \
124} while (0)
125
126extern int __put_user_1(void *, unsigned int);
127extern int __put_user_2(void *, unsigned int);
128extern int __put_user_4(void *, unsigned int);
129extern int __put_user_8(void *, unsigned long long);
130extern int __put_user_bad(void);
131
132#define __put_user_x(__r1,__p,__e,__s) \
133 __asm__ __volatile__ ( \
134 __asmeq("%0", "r0") __asmeq("%2", "r1") \
135 "bl __put_user_" #__s \
136 : "=&r" (__e) \
137 : "0" (__p), "r" (__r1) \
138 : "ip", "lr", "cc")
139
140#define put_user(x,p) \
141 ({ \
142 register const typeof(*(p)) __r1 asm("r1") = (x); \
143 register const typeof(*(p)) *__p asm("r0") = (p); \
144 register int __e asm("r0"); \
145 switch (sizeof(*(__p))) { \
146 case 1: \
147 __put_user_x(__r1, __p, __e, 1); \
148 break; \
149 case 2: \
150 __put_user_x(__r1, __p, __e, 2); \
151 break; \
152 case 4: \
153 __put_user_x(__r1, __p, __e, 4); \
154 break; \
155 case 8: \
156 __put_user_x(__r1, __p, __e, 8); \
157 break; \
158 default: __e = __put_user_bad(); break; \
159 } \
160 __e; \
161 })
162
163#if 0
164/********************* OLD METHOD *******************/
165#define __put_user_x(__r1,__p,__e,__s,__i...) \
166 __asm__ __volatile__ ("bl __put_user_" #__s \
167 : "=&r" (__e) \
168 : "0" (__p), "r" (__r1) \
169 : __i)
170
171#define put_user(x,p) \
172 ({ \
173 register const typeof(*(p)) __r1 asm("r1") = (x); \
174 register const typeof(*(p)) *__p asm("r0") = (p); \
175 register int __e asm("r0"); \
176 switch (sizeof(*(p))) { \
177 case 1: \
178 __put_user_x(__r1, __p, __e, 1, "r2", "lr"); \
179 break; \
180 case 2: \
181 __put_user_x(__r1, __p, __e, 2, "r2", "lr"); \
182 break; \
183 case 4: \
184 __put_user_x(__r1, __p, __e, 4, "r2", "lr"); \
185 break; \
186 case 8: \
187 __put_user_x(__r1, __p, __e, 8, "r2", "ip", "lr"); \
188 break; \
189 default: __e = __put_user_bad(); break; \
190 } \
191 __e; \
192 })
193/*************************************************/
194#endif
195
196#define __put_user(x,ptr) \
197({ \
198 long __pu_err = 0; \
199 __put_user_err((x),(ptr),__pu_err); \
200 __pu_err; \
201})
202
203#define __put_user_error(x,ptr,err) \
204({ \
205 __put_user_err((x),(ptr),err); \
206 (void) 0; \
207})
208
209#define __put_user_err(x,ptr,err) \
210do { \
211 unsigned long __pu_addr = (unsigned long)(ptr); \
212 __typeof__(*(ptr)) __pu_val = (x); \
213 switch (sizeof(*(ptr))) { \
214 case 1: __put_user_asm_byte(__pu_val,__pu_addr,err); break; \
215 case 2: __put_user_asm_half(__pu_val,__pu_addr,err); break; \
216 case 4: __put_user_asm_word(__pu_val,__pu_addr,err); break; \
217 case 8: __put_user_asm_dword(__pu_val,__pu_addr,err); break; \
218 default: __put_user_bad(); \
219 } \
220} while (0)
221
222static __inline__ unsigned long copy_from_user(void *to, const void *from, unsigned long n)
223{
224 if (access_ok(VERIFY_READ, from, n))
225 __do_copy_from_user(to, from, n);
226 else /* security hole - plug it */
227 memzero(to, n);
228 return n;
229}
230
231static __inline__ unsigned long __copy_from_user(void *to, const void *from, unsigned long n)
232{
233 __do_copy_from_user(to, from, n);
234 return n;
235}
236
237static __inline__ unsigned long copy_to_user(void *to, const void *from, unsigned long n)
238{
239 if (access_ok(VERIFY_WRITE, to, n))
240 __do_copy_to_user(to, from, n);
241 return n;
242}
243
244static __inline__ unsigned long __copy_to_user(void *to, const void *from, unsigned long n)
245{
246 __do_copy_to_user(to, from, n);
247 return n;
248}
249
250#define __copy_to_user_inatomic __copy_to_user
251#define __copy_from_user_inatomic __copy_from_user
252
253static __inline__ unsigned long clear_user (void *to, unsigned long n)
254{
255 if (access_ok(VERIFY_WRITE, to, n))
256 __do_clear_user(to, n);
257 return n;
258}
259
260static __inline__ unsigned long __clear_user (void *to, unsigned long n)
261{
262 __do_clear_user(to, n);
263 return n;
264}
265
266static __inline__ long strncpy_from_user (char *dst, const char *src, long count)
267{
268 long res = -EFAULT;
269 if (access_ok(VERIFY_READ, src, 1))
270 __do_strncpy_from_user(dst, src, count, res);
271 return res;
272}
273
274static __inline__ long __strncpy_from_user (char *dst, const char *src, long count)
275{
276 long res;
277 __do_strncpy_from_user(dst, src, count, res);
278 return res;
279}
280
281#define strlen_user(s) strnlen_user(s, ~0UL >> 1)
282
283static inline long strnlen_user(const char *s, long n)
284{
285 unsigned long res = 0;
286
287 if (__addr_ok(s))
288 __do_strnlen_user(s, n, res);
289
290 return res;
291}
292
293#endif /* _ASMARM_UACCESS_H */
diff --git a/include/asm-arm26/ucontext.h b/include/asm-arm26/ucontext.h
deleted file mode 100644
index f853130137cc..000000000000
--- a/include/asm-arm26/ucontext.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#ifndef _ASMARM_UCONTEXT_H
2#define _ASMARM_UCONTEXT_H
3
4struct ucontext {
5 unsigned long uc_flags;
6 struct ucontext *uc_link;
7 stack_t uc_stack;
8 struct sigcontext uc_mcontext;
9 sigset_t uc_sigmask; /* mask last for extensibility */
10};
11
12#endif /* !_ASMARM_UCONTEXT_H */
diff --git a/include/asm-arm26/unaligned.h b/include/asm-arm26/unaligned.h
deleted file mode 100644
index d992782089fd..000000000000
--- a/include/asm-arm26/unaligned.h
+++ /dev/null
@@ -1,118 +0,0 @@
1#ifndef __ASM_ARM_UNALIGNED_H
2#define __ASM_ARM_UNALIGNED_H
3
4#include <asm/types.h>
5
6extern int __bug_unaligned_x(void *ptr);
7
8/*
9 * What is the most efficient way of loading/storing an unaligned value?
10 *
11 * That is the subject of this file. Efficiency here is defined as
12 * minimum code size with minimum register usage for the common cases.
13 * It is currently not believed that long longs are common, so we
14 * trade efficiency for the chars, shorts and longs against the long
15 * longs.
16 *
17 * Current stats with gcc 2.7.2.2 for these functions:
18 *
19 * ptrsize get: code regs put: code regs
20 * 1 1 1 1 2
21 * 2 3 2 3 2
22 * 4 7 3 7 3
23 * 8 20 6 16 6
24 *
25 * gcc 2.95.1 seems to code differently:
26 *
27 * ptrsize get: code regs put: code regs
28 * 1 1 1 1 2
29 * 2 3 2 3 2
30 * 4 7 4 7 4
31 * 8 19 8 15 6
32 *
33 * which may or may not be more efficient (depending upon whether
34 * you can afford the extra registers). Hopefully the gcc 2.95
35 * is inteligent enough to decide if it is better to use the
36 * extra register, but evidence so far seems to suggest otherwise.
37 *
38 * Unfortunately, gcc is not able to optimise the high word
39 * out of long long >> 32, or the low word from long long << 32
40 */
41
42#define __get_unaligned_2_le(__p) \
43 (__p[0] | __p[1] << 8)
44
45#define __get_unaligned_4_le(__p) \
46 (__p[0] | __p[1] << 8 | __p[2] << 16 | __p[3] << 24)
47
48#define __get_unaligned_le(ptr) \
49 ({ \
50 __typeof__(*(ptr)) __v; \
51 __u8 *__p = (__u8 *)(ptr); \
52 switch (sizeof(*(ptr))) { \
53 case 1: __v = *(ptr); break; \
54 case 2: __v = __get_unaligned_2_le(__p); break; \
55 case 4: __v = __get_unaligned_4_le(__p); break; \
56 case 8: { \
57 unsigned int __v1, __v2; \
58 __v2 = __get_unaligned_4_le((__p+4)); \
59 __v1 = __get_unaligned_4_le(__p); \
60 __v = ((unsigned long long)__v2 << 32 | __v1); \
61 } \
62 break; \
63 default: __v = __bug_unaligned_x(__p); break; \
64 } \
65 __v; \
66 })
67
68static inline void __put_unaligned_2_le(__u32 __v, register __u8 *__p)
69{
70 *__p++ = __v;
71 *__p++ = __v >> 8;
72}
73
74static inline void __put_unaligned_4_le(__u32 __v, register __u8 *__p)
75{
76 __put_unaligned_2_le(__v >> 16, __p + 2);
77 __put_unaligned_2_le(__v, __p);
78}
79
80static inline void __put_unaligned_8_le(const unsigned long long __v, register __u8 *__p)
81{
82 /*
83 * tradeoff: 8 bytes of stack for all unaligned puts (2
84 * instructions), or an extra register in the long long
85 * case - go for the extra register.
86 */
87 __put_unaligned_4_le(__v >> 32, __p+4);
88 __put_unaligned_4_le(__v, __p);
89}
90
91/*
92 * Try to store an unaligned value as efficiently as possible.
93 */
94#define __put_unaligned_le(val,ptr) \
95 ({ \
96 switch (sizeof(*(ptr))) { \
97 case 1: \
98 *(ptr) = (val); \
99 break; \
100 case 2: __put_unaligned_2_le((val),(__u8 *)(ptr)); \
101 break; \
102 case 4: __put_unaligned_4_le((val),(__u8 *)(ptr)); \
103 break; \
104 case 8: __put_unaligned_8_le((val),(__u8 *)(ptr)); \
105 break; \
106 default: __bug_unaligned_x(ptr); \
107 break; \
108 } \
109 (void) 0; \
110 })
111
112/*
113 * Select endianness
114 */
115#define get_unaligned __get_unaligned_le
116#define put_unaligned __put_unaligned_le
117
118#endif
diff --git a/include/asm-arm26/uncompress.h b/include/asm-arm26/uncompress.h
deleted file mode 100644
index df2cba816a4e..000000000000
--- a/include/asm-arm26/uncompress.h
+++ /dev/null
@@ -1,111 +0,0 @@
1/*
2 * linux/include/asm-arm/arch-arc/uncompress.h
3 *
4 * Copyright (C) 1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#define VIDMEM ((char *)0x02000000)
11
12int video_num_columns, video_num_lines, video_size_row;
13int white, bytes_per_char_h;
14extern unsigned long con_charconvtable[256];
15
16struct param_struct {
17 unsigned long page_size;
18 unsigned long nr_pages;
19 unsigned long ramdisk_size;
20 unsigned long mountrootrdonly;
21 unsigned long rootdev;
22 unsigned long video_num_cols;
23 unsigned long video_num_rows;
24 unsigned long video_x;
25 unsigned long video_y;
26 unsigned long memc_control_reg;
27 unsigned char sounddefault;
28 unsigned char adfsdrives;
29 unsigned char bytes_per_char_h;
30 unsigned char bytes_per_char_v;
31 unsigned long unused[256/4-11];
32};
33
34static struct param_struct *params = (struct param_struct *)0x0207c000;
35
36/*
37 * This does not append a newline
38 */
39static void puts(const char *s)
40{
41 extern void ll_write_char(char *, unsigned long);
42 int x,y;
43 unsigned char c;
44 char *ptr;
45
46 x = params->video_x;
47 y = params->video_y;
48
49 while ( ( c = *(unsigned char *)s++ ) != '\0' ) {
50 if ( c == '\n' ) {
51 x = 0;
52 if ( ++y >= video_num_lines ) {
53 y--;
54 }
55 } else {
56 ptr = VIDMEM + ((y*video_num_columns*params->bytes_per_char_v+x)*bytes_per_char_h);
57 ll_write_char(ptr, c|(white<<16));
58 if ( ++x >= video_num_columns ) {
59 x = 0;
60 if ( ++y >= video_num_lines ) {
61 y--;
62 }
63 }
64 }
65 }
66
67 params->video_x = x;
68 params->video_y = y;
69}
70
71static void error(char *x);
72
73/*
74 * Setup for decompression
75 */
76static void arch_decomp_setup(void)
77{
78 int i;
79
80 video_num_lines = params->video_num_rows;
81 video_num_columns = params->video_num_cols;
82 bytes_per_char_h = params->bytes_per_char_h;
83 video_size_row = video_num_columns * bytes_per_char_h;
84 if (bytes_per_char_h == 4)
85 for (i = 0; i < 256; i++)
86 con_charconvtable[i] =
87 (i & 128 ? 1 << 0 : 0) |
88 (i & 64 ? 1 << 4 : 0) |
89 (i & 32 ? 1 << 8 : 0) |
90 (i & 16 ? 1 << 12 : 0) |
91 (i & 8 ? 1 << 16 : 0) |
92 (i & 4 ? 1 << 20 : 0) |
93 (i & 2 ? 1 << 24 : 0) |
94 (i & 1 ? 1 << 28 : 0);
95 else
96 for (i = 0; i < 16; i++)
97 con_charconvtable[i] =
98 (i & 8 ? 1 << 0 : 0) |
99 (i & 4 ? 1 << 8 : 0) |
100 (i & 2 ? 1 << 16 : 0) |
101 (i & 1 ? 1 << 24 : 0);
102
103 white = bytes_per_char_h == 8 ? 0xfc : 7;
104
105 if (params->nr_pages * params->page_size < 4096*1024) error("<4M of mem\n");
106}
107
108/*
109 * nothing to do
110 */
111#define arch_decomp_wdog()
diff --git a/include/asm-arm26/unistd.h b/include/asm-arm26/unistd.h
deleted file mode 100644
index 4c3b919177e5..000000000000
--- a/include/asm-arm26/unistd.h
+++ /dev/null
@@ -1,343 +0,0 @@
1/*
2 * linux/include/asm-arm/unistd.h
3 *
4 * Copyright (C) 2001-2003 Russell King
5 * Modified 25/11/04 Ian Molton for arm26.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Please forward _all_ changes to this file to spyro@f2s.com
12 * no matter what the change is. Thanks!
13 */
14#ifndef __ASM_ARM_UNISTD_H
15#define __ASM_ARM_UNISTD_H
16
17#define __NR_SYSCALL_BASE 0x900000
18
19/*
20 * This file contains the system call numbers.
21 */
22
23#define __NR_restart_syscall (__NR_SYSCALL_BASE+ 0)
24#define __NR_exit (__NR_SYSCALL_BASE+ 1)
25#define __NR_fork (__NR_SYSCALL_BASE+ 2)
26#define __NR_read (__NR_SYSCALL_BASE+ 3)
27#define __NR_write (__NR_SYSCALL_BASE+ 4)
28#define __NR_open (__NR_SYSCALL_BASE+ 5)
29#define __NR_close (__NR_SYSCALL_BASE+ 6)
30 /* 7 was sys_waitpid */
31#define __NR_creat (__NR_SYSCALL_BASE+ 8)
32#define __NR_link (__NR_SYSCALL_BASE+ 9)
33#define __NR_unlink (__NR_SYSCALL_BASE+ 10)
34#define __NR_execve (__NR_SYSCALL_BASE+ 11)
35#define __NR_chdir (__NR_SYSCALL_BASE+ 12)
36#define __NR_time (__NR_SYSCALL_BASE+ 13)
37#define __NR_mknod (__NR_SYSCALL_BASE+ 14)
38#define __NR_chmod (__NR_SYSCALL_BASE+ 15)
39#define __NR_lchown (__NR_SYSCALL_BASE+ 16)
40 /* 17 was sys_break */
41 /* 18 was sys_stat */
42#define __NR_lseek (__NR_SYSCALL_BASE+ 19)
43#define __NR_getpid (__NR_SYSCALL_BASE+ 20)
44#define __NR_mount (__NR_SYSCALL_BASE+ 21)
45#define __NR_umount (__NR_SYSCALL_BASE+ 22)
46#define __NR_setuid (__NR_SYSCALL_BASE+ 23)
47#define __NR_getuid (__NR_SYSCALL_BASE+ 24)
48#define __NR_stime (__NR_SYSCALL_BASE+ 25)
49#define __NR_ptrace (__NR_SYSCALL_BASE+ 26)
50#define __NR_alarm (__NR_SYSCALL_BASE+ 27)
51 /* 28 was sys_fstat */
52#define __NR_pause (__NR_SYSCALL_BASE+ 29)
53#define __NR_utime (__NR_SYSCALL_BASE+ 30)
54 /* 31 was sys_stty */
55 /* 32 was sys_gtty */
56#define __NR_access (__NR_SYSCALL_BASE+ 33)
57#define __NR_nice (__NR_SYSCALL_BASE+ 34)
58 /* 35 was sys_ftime */
59#define __NR_sync (__NR_SYSCALL_BASE+ 36)
60#define __NR_kill (__NR_SYSCALL_BASE+ 37)
61#define __NR_rename (__NR_SYSCALL_BASE+ 38)
62#define __NR_mkdir (__NR_SYSCALL_BASE+ 39)
63#define __NR_rmdir (__NR_SYSCALL_BASE+ 40)
64#define __NR_dup (__NR_SYSCALL_BASE+ 41)
65#define __NR_pipe (__NR_SYSCALL_BASE+ 42)
66#define __NR_times (__NR_SYSCALL_BASE+ 43)
67 /* 44 was sys_prof */
68#define __NR_brk (__NR_SYSCALL_BASE+ 45)
69#define __NR_setgid (__NR_SYSCALL_BASE+ 46)
70#define __NR_getgid (__NR_SYSCALL_BASE+ 47)
71 /* 48 was sys_signal */
72#define __NR_geteuid (__NR_SYSCALL_BASE+ 49)
73#define __NR_getegid (__NR_SYSCALL_BASE+ 50)
74#define __NR_acct (__NR_SYSCALL_BASE+ 51)
75#define __NR_umount2 (__NR_SYSCALL_BASE+ 52)
76 /* 53 was sys_lock */
77#define __NR_ioctl (__NR_SYSCALL_BASE+ 54)
78#define __NR_fcntl (__NR_SYSCALL_BASE+ 55)
79 /* 56 was sys_mpx */
80#define __NR_setpgid (__NR_SYSCALL_BASE+ 57)
81 /* 58 was sys_ulimit */
82 /* 59 was sys_olduname */
83#define __NR_umask (__NR_SYSCALL_BASE+ 60)
84#define __NR_chroot (__NR_SYSCALL_BASE+ 61)
85#define __NR_ustat (__NR_SYSCALL_BASE+ 62)
86#define __NR_dup2 (__NR_SYSCALL_BASE+ 63)
87#define __NR_getppid (__NR_SYSCALL_BASE+ 64)
88#define __NR_getpgrp (__NR_SYSCALL_BASE+ 65)
89#define __NR_setsid (__NR_SYSCALL_BASE+ 66)
90#define __NR_sigaction (__NR_SYSCALL_BASE+ 67)
91 /* 68 was sys_sgetmask */
92 /* 69 was sys_ssetmask */
93#define __NR_setreuid (__NR_SYSCALL_BASE+ 70)
94#define __NR_setregid (__NR_SYSCALL_BASE+ 71)
95#define __NR_sigsuspend (__NR_SYSCALL_BASE+ 72)
96#define __NR_sigpending (__NR_SYSCALL_BASE+ 73)
97#define __NR_sethostname (__NR_SYSCALL_BASE+ 74)
98#define __NR_setrlimit (__NR_SYSCALL_BASE+ 75)
99#define __NR_getrlimit (__NR_SYSCALL_BASE+ 76) /* Back compat 2GB limited rlimit */
100#define __NR_getrusage (__NR_SYSCALL_BASE+ 77)
101#define __NR_gettimeofday (__NR_SYSCALL_BASE+ 78)
102#define __NR_settimeofday (__NR_SYSCALL_BASE+ 79)
103#define __NR_getgroups (__NR_SYSCALL_BASE+ 80)
104#define __NR_setgroups (__NR_SYSCALL_BASE+ 81)
105#define __NR_select (__NR_SYSCALL_BASE+ 82)
106#define __NR_symlink (__NR_SYSCALL_BASE+ 83)
107 /* 84 was sys_lstat */
108#define __NR_readlink (__NR_SYSCALL_BASE+ 85)
109#define __NR_uselib (__NR_SYSCALL_BASE+ 86)
110#define __NR_swapon (__NR_SYSCALL_BASE+ 87)
111#define __NR_reboot (__NR_SYSCALL_BASE+ 88)
112#define __NR_readdir (__NR_SYSCALL_BASE+ 89)
113#define __NR_mmap (__NR_SYSCALL_BASE+ 90)
114#define __NR_munmap (__NR_SYSCALL_BASE+ 91)
115#define __NR_truncate (__NR_SYSCALL_BASE+ 92)
116#define __NR_ftruncate (__NR_SYSCALL_BASE+ 93)
117#define __NR_fchmod (__NR_SYSCALL_BASE+ 94)
118#define __NR_fchown (__NR_SYSCALL_BASE+ 95)
119#define __NR_getpriority (__NR_SYSCALL_BASE+ 96)
120#define __NR_setpriority (__NR_SYSCALL_BASE+ 97)
121 /* 98 was sys_profil */
122#define __NR_statfs (__NR_SYSCALL_BASE+ 99)
123#define __NR_fstatfs (__NR_SYSCALL_BASE+100)
124 /* 101 was sys_ioperm */
125#define __NR_socketcall (__NR_SYSCALL_BASE+102)
126#define __NR_syslog (__NR_SYSCALL_BASE+103)
127#define __NR_setitimer (__NR_SYSCALL_BASE+104)
128#define __NR_getitimer (__NR_SYSCALL_BASE+105)
129#define __NR_stat (__NR_SYSCALL_BASE+106)
130#define __NR_lstat (__NR_SYSCALL_BASE+107)
131#define __NR_fstat (__NR_SYSCALL_BASE+108)
132 /* 109 was sys_uname */
133 /* 110 was sys_iopl */
134#define __NR_vhangup (__NR_SYSCALL_BASE+111)
135 /* 112 was sys_idle */
136#define __NR_syscall (__NR_SYSCALL_BASE+113) /* syscall to call a syscall! */
137#define __NR_wait4 (__NR_SYSCALL_BASE+114)
138#define __NR_swapoff (__NR_SYSCALL_BASE+115)
139#define __NR_sysinfo (__NR_SYSCALL_BASE+116)
140#define __NR_ipc (__NR_SYSCALL_BASE+117)
141#define __NR_fsync (__NR_SYSCALL_BASE+118)
142#define __NR_sigreturn (__NR_SYSCALL_BASE+119)
143#define __NR_clone (__NR_SYSCALL_BASE+120)
144#define __NR_setdomainname (__NR_SYSCALL_BASE+121)
145#define __NR_uname (__NR_SYSCALL_BASE+122)
146 /* 123 was sys_modify_ldt */
147#define __NR_adjtimex (__NR_SYSCALL_BASE+124)
148#define __NR_mprotect (__NR_SYSCALL_BASE+125)
149#define __NR_sigprocmask (__NR_SYSCALL_BASE+126)
150 /* 127 was sys_create_module */
151#define __NR_init_module (__NR_SYSCALL_BASE+128)
152#define __NR_delete_module (__NR_SYSCALL_BASE+129)
153 /* 130 was sys_get_kernel_syms */
154#define __NR_quotactl (__NR_SYSCALL_BASE+131)
155#define __NR_getpgid (__NR_SYSCALL_BASE+132)
156#define __NR_fchdir (__NR_SYSCALL_BASE+133)
157#define __NR_bdflush (__NR_SYSCALL_BASE+134)
158#define __NR_sysfs (__NR_SYSCALL_BASE+135)
159#define __NR_personality (__NR_SYSCALL_BASE+136)
160 /* 137 was sys_afs_syscall */
161#define __NR_setfsuid (__NR_SYSCALL_BASE+138)
162#define __NR_setfsgid (__NR_SYSCALL_BASE+139)
163#define __NR__llseek (__NR_SYSCALL_BASE+140)
164#define __NR_getdents (__NR_SYSCALL_BASE+141)
165#define __NR__newselect (__NR_SYSCALL_BASE+142)
166#define __NR_flock (__NR_SYSCALL_BASE+143)
167#define __NR_msync (__NR_SYSCALL_BASE+144)
168#define __NR_readv (__NR_SYSCALL_BASE+145)
169#define __NR_writev (__NR_SYSCALL_BASE+146)
170#define __NR_getsid (__NR_SYSCALL_BASE+147)
171#define __NR_fdatasync (__NR_SYSCALL_BASE+148)
172#define __NR__sysctl (__NR_SYSCALL_BASE+149)
173#define __NR_mlock (__NR_SYSCALL_BASE+150)
174#define __NR_munlock (__NR_SYSCALL_BASE+151)
175#define __NR_mlockall (__NR_SYSCALL_BASE+152)
176#define __NR_munlockall (__NR_SYSCALL_BASE+153)
177#define __NR_sched_setparam (__NR_SYSCALL_BASE+154)
178#define __NR_sched_getparam (__NR_SYSCALL_BASE+155)
179#define __NR_sched_setscheduler (__NR_SYSCALL_BASE+156)
180#define __NR_sched_getscheduler (__NR_SYSCALL_BASE+157)
181#define __NR_sched_yield (__NR_SYSCALL_BASE+158)
182#define __NR_sched_get_priority_max (__NR_SYSCALL_BASE+159)
183#define __NR_sched_get_priority_min (__NR_SYSCALL_BASE+160)
184#define __NR_sched_rr_get_interval (__NR_SYSCALL_BASE+161)
185#define __NR_nanosleep (__NR_SYSCALL_BASE+162)
186#define __NR_mremap (__NR_SYSCALL_BASE+163)
187#define __NR_setresuid (__NR_SYSCALL_BASE+164)
188#define __NR_getresuid (__NR_SYSCALL_BASE+165)
189 /* 166 was sys_vm86 */
190 /* 167 was sys_query_module */
191#define __NR_poll (__NR_SYSCALL_BASE+168)
192#define __NR_nfsservctl (__NR_SYSCALL_BASE+169)
193#define __NR_setresgid (__NR_SYSCALL_BASE+170)
194#define __NR_getresgid (__NR_SYSCALL_BASE+171)
195#define __NR_prctl (__NR_SYSCALL_BASE+172)
196#define __NR_rt_sigreturn (__NR_SYSCALL_BASE+173)
197#define __NR_rt_sigaction (__NR_SYSCALL_BASE+174)
198#define __NR_rt_sigprocmask (__NR_SYSCALL_BASE+175)
199#define __NR_rt_sigpending (__NR_SYSCALL_BASE+176)
200#define __NR_rt_sigtimedwait (__NR_SYSCALL_BASE+177)
201#define __NR_rt_sigqueueinfo (__NR_SYSCALL_BASE+178)
202#define __NR_rt_sigsuspend (__NR_SYSCALL_BASE+179)
203#define __NR_pread64 (__NR_SYSCALL_BASE+180)
204#define __NR_pwrite64 (__NR_SYSCALL_BASE+181)
205#define __NR_chown (__NR_SYSCALL_BASE+182)
206#define __NR_getcwd (__NR_SYSCALL_BASE+183)
207#define __NR_capget (__NR_SYSCALL_BASE+184)
208#define __NR_capset (__NR_SYSCALL_BASE+185)
209#define __NR_sigaltstack (__NR_SYSCALL_BASE+186)
210#define __NR_sendfile (__NR_SYSCALL_BASE+187)
211 /* 188 reserved */
212 /* 189 reserved */
213#define __NR_vfork (__NR_SYSCALL_BASE+190)
214#define __NR_ugetrlimit (__NR_SYSCALL_BASE+191) /* SuS compliant getrlimit */
215#define __NR_mmap2 (__NR_SYSCALL_BASE+192)
216#define __NR_truncate64 (__NR_SYSCALL_BASE+193)
217#define __NR_ftruncate64 (__NR_SYSCALL_BASE+194)
218#define __NR_stat64 (__NR_SYSCALL_BASE+195)
219#define __NR_lstat64 (__NR_SYSCALL_BASE+196)
220#define __NR_fstat64 (__NR_SYSCALL_BASE+197)
221#define __NR_lchown32 (__NR_SYSCALL_BASE+198)
222#define __NR_getuid32 (__NR_SYSCALL_BASE+199)
223#define __NR_getgid32 (__NR_SYSCALL_BASE+200)
224#define __NR_geteuid32 (__NR_SYSCALL_BASE+201)
225#define __NR_getegid32 (__NR_SYSCALL_BASE+202)
226#define __NR_setreuid32 (__NR_SYSCALL_BASE+203)
227#define __NR_setregid32 (__NR_SYSCALL_BASE+204)
228#define __NR_getgroups32 (__NR_SYSCALL_BASE+205)
229#define __NR_setgroups32 (__NR_SYSCALL_BASE+206)
230#define __NR_fchown32 (__NR_SYSCALL_BASE+207)
231#define __NR_setresuid32 (__NR_SYSCALL_BASE+208)
232#define __NR_getresuid32 (__NR_SYSCALL_BASE+209)
233#define __NR_setresgid32 (__NR_SYSCALL_BASE+210)
234#define __NR_getresgid32 (__NR_SYSCALL_BASE+211)
235#define __NR_chown32 (__NR_SYSCALL_BASE+212)
236#define __NR_setuid32 (__NR_SYSCALL_BASE+213)
237#define __NR_setgid32 (__NR_SYSCALL_BASE+214)
238#define __NR_setfsuid32 (__NR_SYSCALL_BASE+215)
239#define __NR_setfsgid32 (__NR_SYSCALL_BASE+216)
240#define __NR_getdents64 (__NR_SYSCALL_BASE+217)
241#define __NR_pivot_root (__NR_SYSCALL_BASE+218)
242#define __NR_mincore (__NR_SYSCALL_BASE+219)
243#define __NR_madvise (__NR_SYSCALL_BASE+220)
244#define __NR_fcntl64 (__NR_SYSCALL_BASE+221)
245 /* 222 for tux */
246 /* 223 is unused */
247#define __NR_gettid (__NR_SYSCALL_BASE+224)
248#define __NR_readahead (__NR_SYSCALL_BASE+225)
249#define __NR_setxattr (__NR_SYSCALL_BASE+226)
250#define __NR_lsetxattr (__NR_SYSCALL_BASE+227)
251#define __NR_fsetxattr (__NR_SYSCALL_BASE+228)
252#define __NR_getxattr (__NR_SYSCALL_BASE+229)
253#define __NR_lgetxattr (__NR_SYSCALL_BASE+230)
254#define __NR_fgetxattr (__NR_SYSCALL_BASE+231)
255#define __NR_listxattr (__NR_SYSCALL_BASE+232)
256#define __NR_llistxattr (__NR_SYSCALL_BASE+233)
257#define __NR_flistxattr (__NR_SYSCALL_BASE+234)
258#define __NR_removexattr (__NR_SYSCALL_BASE+235)
259#define __NR_lremovexattr (__NR_SYSCALL_BASE+236)
260#define __NR_fremovexattr (__NR_SYSCALL_BASE+237)
261#define __NR_tkill (__NR_SYSCALL_BASE+238)
262#define __NR_sendfile64 (__NR_SYSCALL_BASE+239)
263#define __NR_futex (__NR_SYSCALL_BASE+240)
264#define __NR_sched_setaffinity (__NR_SYSCALL_BASE+241)
265#define __NR_sched_getaffinity (__NR_SYSCALL_BASE+242)
266#define __NR_io_setup (__NR_SYSCALL_BASE+243)
267#define __NR_io_destroy (__NR_SYSCALL_BASE+244)
268#define __NR_io_getevents (__NR_SYSCALL_BASE+245)
269#define __NR_io_submit (__NR_SYSCALL_BASE+246)
270#define __NR_io_cancel (__NR_SYSCALL_BASE+247)
271#define __NR_exit_group (__NR_SYSCALL_BASE+248)
272#define __NR_lookup_dcookie (__NR_SYSCALL_BASE+249)
273#define __NR_epoll_create (__NR_SYSCALL_BASE+250)
274#define __NR_epoll_ctl (__NR_SYSCALL_BASE+251)
275#define __NR_epoll_wait (__NR_SYSCALL_BASE+252)
276#define __NR_remap_file_pages (__NR_SYSCALL_BASE+253)
277 /* 254 for set_thread_area */
278 /* 255 for get_thread_area */
279 /* 256 for set_tid_address */
280#define __NR_timer_create (__NR_SYSCALL_BASE+257)
281#define __NR_timer_settime (__NR_SYSCALL_BASE+258)
282#define __NR_timer_gettime (__NR_SYSCALL_BASE+259)
283#define __NR_timer_getoverrun (__NR_SYSCALL_BASE+260)
284#define __NR_timer_delete (__NR_SYSCALL_BASE+261)
285#define __NR_clock_settime (__NR_SYSCALL_BASE+262)
286#define __NR_clock_gettime (__NR_SYSCALL_BASE+263)
287#define __NR_clock_getres (__NR_SYSCALL_BASE+264)
288#define __NR_clock_nanosleep (__NR_SYSCALL_BASE+265)
289#define __NR_statfs64 (__NR_SYSCALL_BASE+266)
290#define __NR_fstatfs64 (__NR_SYSCALL_BASE+267)
291#define __NR_tgkill (__NR_SYSCALL_BASE+268)
292#define __NR_utimes (__NR_SYSCALL_BASE+269)
293#define __NR_fadvise64_64 (__NR_SYSCALL_BASE+270)
294#define __NR_pciconfig_iobase (__NR_SYSCALL_BASE+271)
295#define __NR_pciconfig_read (__NR_SYSCALL_BASE+272)
296#define __NR_pciconfig_write (__NR_SYSCALL_BASE+273)
297#define __NR_mq_open (__NR_SYSCALL_BASE+274)
298#define __NR_mq_unlink (__NR_SYSCALL_BASE+275)
299#define __NR_mq_timedsend (__NR_SYSCALL_BASE+276)
300#define __NR_mq_timedreceive (__NR_SYSCALL_BASE+277)
301#define __NR_mq_notify (__NR_SYSCALL_BASE+278)
302#define __NR_mq_getsetattr (__NR_SYSCALL_BASE+279)
303#define __NR_waitid (__NR_SYSCALL_BASE+280)
304
305/*
306 * The following SWIs are ARM private. FIXME - make appropriate for arm26
307 */
308#define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
309#define __ARM_NR_breakpoint (__ARM_NR_BASE+1)
310#define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
311#define __ARM_NR_usr26 (__ARM_NR_BASE+3)
312
313#ifdef __KERNEL__
314
315#define __ARCH_WANT_IPC_PARSE_VERSION
316#define __ARCH_WANT_OLD_READDIR
317#define __ARCH_WANT_STAT64
318#define __ARCH_WANT_SYS_ALARM
319#define __ARCH_WANT_SYS_GETHOSTNAME
320#define __ARCH_WANT_SYS_PAUSE
321#define __ARCH_WANT_SYS_TIME
322#define __ARCH_WANT_SYS_UTIME
323#define __ARCH_WANT_SYS_SOCKETCALL
324#define __ARCH_WANT_SYS_FADVISE64
325#define __ARCH_WANT_SYS_GETPGRP
326#define __ARCH_WANT_SYS_LLSEEK
327#define __ARCH_WANT_SYS_NICE
328#define __ARCH_WANT_SYS_OLD_GETRLIMIT
329#define __ARCH_WANT_SYS_OLDUMOUNT
330#define __ARCH_WANT_SYS_SIGPENDING
331#define __ARCH_WANT_SYS_SIGPROCMASK
332#define __ARCH_WANT_SYS_RT_SIGACTION
333
334/*
335 * "Conditional" syscalls
336 *
337 * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
338 * but it doesn't work on all toolchains, so we just do it by hand
339 */
340#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
341
342#endif /* __KERNEL__ */
343#endif /* __ASM_ARM_UNISTD_H */
diff --git a/include/asm-arm26/user.h b/include/asm-arm26/user.h
deleted file mode 100644
index 3e8b0f879159..000000000000
--- a/include/asm-arm26/user.h
+++ /dev/null
@@ -1,84 +0,0 @@
1#ifndef _ARM_USER_H
2#define _ARM_USER_H
3
4#include <asm/page.h>
5#include <asm/ptrace.h>
6/* Core file format: The core file is written in such a way that gdb
7 can understand it and provide useful information to the user (under
8 linux we use the 'trad-core' bfd). There are quite a number of
9 obstacles to being able to view the contents of the floating point
10 registers, and until these are solved you will not be able to view the
11 contents of them. Actually, you can read in the core file and look at
12 the contents of the user struct to find out what the floating point
13 registers contain.
14 The actual file contents are as follows:
15 UPAGE: 1 page consisting of a user struct that tells gdb what is present
16 in the file. Directly after this is a copy of the task_struct, which
17 is currently not used by gdb, but it may come in useful at some point.
18 All of the registers are stored as part of the upage. The upage should
19 always be only one page.
20 DATA: The data area is stored. We use current->end_text to
21 current->brk to pick up all of the user variables, plus any memory
22 that may have been malloced. No attempt is made to determine if a page
23 is demand-zero or if a page is totally unused, we just cover the entire
24 range. All of the addresses are rounded in such a way that an integral
25 number of pages is written.
26 STACK: We need the stack information in order to get a meaningful
27 backtrace. We need to write the data from (esp) to
28 current->start_stack, so we round each of these off in order to be able
29 to write an integer number of pages.
30 The minimum core file size is 3 pages, or 12288 bytes.
31*/
32
33struct user_fp {
34 struct fp_reg {
35 unsigned int sign1:1;
36 unsigned int unused:15;
37 unsigned int sign2:1;
38 unsigned int exponent:14;
39 unsigned int j:1;
40 unsigned int mantissa1:31;
41 unsigned int mantissa0:32;
42 } fpregs[8];
43 unsigned int fpsr:32;
44 unsigned int fpcr:32;
45 unsigned char ftype[8];
46 unsigned int init_flag;
47};
48
49/* When the kernel dumps core, it starts by dumping the user struct -
50 this will be used by gdb to figure out where the data and stack segments
51 are within the file, and what virtual addresses to use. */
52struct user{
53/* We start with the registers, to mimic the way that "memory" is returned
54 from the ptrace(3,...) function. */
55 struct pt_regs regs; /* Where the registers are actually stored */
56/* ptrace does not yet supply these. Someday.... */
57 int u_fpvalid; /* True if math co-processor being used. */
58 /* for this mess. Not yet used. */
59/* The rest of this junk is to help gdb figure out what goes where */
60 unsigned long int u_tsize; /* Text segment size (pages). */
61 unsigned long int u_dsize; /* Data segment size (pages). */
62 unsigned long int u_ssize; /* Stack segment size (pages). */
63 unsigned long start_code; /* Starting virtual address of text. */
64 unsigned long start_stack; /* Starting virtual address of stack area.
65 This is actually the bottom of the stack,
66 the top of the stack is always found in the
67 esp register. */
68 long int signal; /* Signal that caused the core dump. */
69 int reserved; /* No longer used */
70 struct pt_regs * u_ar0; /* Used by gdb to help find the values for */
71 /* the registers. */
72 unsigned long magic; /* To uniquely identify a core file */
73 char u_comm[32]; /* User command that was responsible */
74 int u_debugreg[8];
75 struct user_fp u_fp; /* FP state */
76 struct user_fp_struct * u_fp0;/* Used by gdb to help find the values for */
77 /* the FP registers. */
78};
79#define NBPG PAGE_SIZE
80#define UPAGES 1
81#define HOST_TEXT_START_ADDR (u.start_code)
82#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
83
84#endif /* _ARM_USER_H */
diff --git a/include/asm-arm26/xor.h b/include/asm-arm26/xor.h
deleted file mode 100644
index e7c4cf58bed1..000000000000
--- a/include/asm-arm26/xor.h
+++ /dev/null
@@ -1,141 +0,0 @@
1/*
2 * linux/include/asm-arm/xor.h
3 *
4 * Copyright (C) 2001 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <asm-generic/xor.h>
11
12#define __XOR(a1, a2) a1 ^= a2
13
14#define GET_BLOCK_2(dst) \
15 __asm__("ldmia %0, {%1, %2}" \
16 : "=r" (dst), "=r" (a1), "=r" (a2) \
17 : "0" (dst))
18
19#define GET_BLOCK_4(dst) \
20 __asm__("ldmia %0, {%1, %2, %3, %4}" \
21 : "=r" (dst), "=r" (a1), "=r" (a2), "=r" (a3), "=r" (a4) \
22 : "0" (dst))
23
24#define XOR_BLOCK_2(src) \
25 __asm__("ldmia %0!, {%1, %2}" \
26 : "=r" (src), "=r" (b1), "=r" (b2) \
27 : "0" (src)); \
28 __XOR(a1, b1); __XOR(a2, b2);
29
30#define XOR_BLOCK_4(src) \
31 __asm__("ldmia %0!, {%1, %2, %3, %4}" \
32 : "=r" (src), "=r" (b1), "=r" (b2), "=r" (b3), "=r" (b4) \
33 : "0" (src)); \
34 __XOR(a1, b1); __XOR(a2, b2); __XOR(a3, b3); __XOR(a4, b4)
35
36#define PUT_BLOCK_2(dst) \
37 __asm__ __volatile__("stmia %0!, {%2, %3}" \
38 : "=r" (dst) \
39 : "0" (dst), "r" (a1), "r" (a2))
40
41#define PUT_BLOCK_4(dst) \
42 __asm__ __volatile__("stmia %0!, {%2, %3, %4, %5}" \
43 : "=r" (dst) \
44 : "0" (dst), "r" (a1), "r" (a2), "r" (a3), "r" (a4))
45
46static void
47xor_arm4regs_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
48{
49 unsigned int lines = bytes / sizeof(unsigned long) / 4;
50 register unsigned int a1 __asm__("r4");
51 register unsigned int a2 __asm__("r5");
52 register unsigned int a3 __asm__("r6");
53 register unsigned int a4 __asm__("r7");
54 register unsigned int b1 __asm__("r8");
55 register unsigned int b2 __asm__("r9");
56 register unsigned int b3 __asm__("ip");
57 register unsigned int b4 __asm__("lr");
58
59 do {
60 GET_BLOCK_4(p1);
61 XOR_BLOCK_4(p2);
62 PUT_BLOCK_4(p1);
63 } while (--lines);
64}
65
66static void
67xor_arm4regs_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
68 unsigned long *p3)
69{
70 unsigned int lines = bytes / sizeof(unsigned long) / 4;
71 register unsigned int a1 __asm__("r4");
72 register unsigned int a2 __asm__("r5");
73 register unsigned int a3 __asm__("r6");
74 register unsigned int a4 __asm__("r7");
75 register unsigned int b1 __asm__("r8");
76 register unsigned int b2 __asm__("r9");
77 register unsigned int b3 __asm__("ip");
78 register unsigned int b4 __asm__("lr");
79
80 do {
81 GET_BLOCK_4(p1);
82 XOR_BLOCK_4(p2);
83 XOR_BLOCK_4(p3);
84 PUT_BLOCK_4(p1);
85 } while (--lines);
86}
87
88static void
89xor_arm4regs_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
90 unsigned long *p3, unsigned long *p4)
91{
92 unsigned int lines = bytes / sizeof(unsigned long) / 2;
93 register unsigned int a1 __asm__("r8");
94 register unsigned int a2 __asm__("r9");
95 register unsigned int b1 __asm__("ip");
96 register unsigned int b2 __asm__("lr");
97
98 do {
99 GET_BLOCK_2(p1);
100 XOR_BLOCK_2(p2);
101 XOR_BLOCK_2(p3);
102 XOR_BLOCK_2(p4);
103 PUT_BLOCK_2(p1);
104 } while (--lines);
105}
106
107static void
108xor_arm4regs_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
109 unsigned long *p3, unsigned long *p4, unsigned long *p5)
110{
111 unsigned int lines = bytes / sizeof(unsigned long) / 2;
112 register unsigned int a1 __asm__("r8");
113 register unsigned int a2 __asm__("r9");
114 register unsigned int b1 __asm__("ip");
115 register unsigned int b2 __asm__("lr");
116
117 do {
118 GET_BLOCK_2(p1);
119 XOR_BLOCK_2(p2);
120 XOR_BLOCK_2(p3);
121 XOR_BLOCK_2(p4);
122 XOR_BLOCK_2(p5);
123 PUT_BLOCK_2(p1);
124 } while (--lines);
125}
126
127static struct xor_block_template xor_block_arm4regs = {
128 .name = "arm4regs",
129 .do_2 = xor_arm4regs_2,
130 .do_3 = xor_arm4regs_3,
131 .do_4 = xor_arm4regs_4,
132 .do_5 = xor_arm4regs_5,
133};
134
135#undef XOR_TRY_TEMPLATES
136#define XOR_TRY_TEMPLATES \
137 do { \
138 xor_speed(&xor_block_arm4regs); \
139 xor_speed(&xor_block_8regs); \
140 xor_speed(&xor_block_32regs); \
141 } while (0)
diff --git a/include/asm-avr32/thread_info.h b/include/asm-avr32/thread_info.h
index a2e606dd4f4a..17dacf3f36d3 100644
--- a/include/asm-avr32/thread_info.h
+++ b/include/asm-avr32/thread_info.h
@@ -74,20 +74,18 @@ static inline struct thread_info *current_thread_info(void)
74 * - other flags in MSW 74 * - other flags in MSW
75 */ 75 */
76#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 76#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
77#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 77#define TIF_SIGPENDING 1 /* signal pending */
78#define TIF_SIGPENDING 2 /* signal pending */ 78#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
79#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 79#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
80#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
81 TIF_NEED_RESCHED */ 80 TIF_NEED_RESCHED */
82#define TIF_BREAKPOINT 5 /* true if we should break after return */ 81#define TIF_BREAKPOINT 4 /* true if we should break after return */
83#define TIF_SINGLE_STEP 6 /* single step after next break */ 82#define TIF_SINGLE_STEP 5 /* single step after next break */
84#define TIF_MEMDIE 7 83#define TIF_MEMDIE 6
85#define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal */ 84#define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */
86#define TIF_CPU_GOING_TO_SLEEP 9 /* CPU is entering sleep 0 mode */ 85#define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */
87#define TIF_USERSPACE 31 /* true if FS sets userspace */ 86#define TIF_USERSPACE 31 /* true if FS sets userspace */
88 87
89#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 88#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
90#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
91#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 89#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
92#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 90#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
93#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 91#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
diff --git a/include/asm-blackfin/bfin-global.h b/include/asm-blackfin/bfin-global.h
index c4d6cbbf96d4..a970781a0f98 100644
--- a/include/asm-blackfin/bfin-global.h
+++ b/include/asm-blackfin/bfin-global.h
@@ -61,6 +61,7 @@ extern void bfin_dcache_init(void);
61extern int read_iloc(void); 61extern int read_iloc(void);
62extern int bfin_console_init(void); 62extern int bfin_console_init(void);
63extern asmlinkage void lower_to_irq14(void); 63extern asmlinkage void lower_to_irq14(void);
64extern void init_exception_vectors(void);
64extern void init_dma(void); 65extern void init_dma(void);
65extern void program_IAR(void); 66extern void program_IAR(void);
66extern void evt14_softirq(void); 67extern void evt14_softirq(void);
diff --git a/include/asm-blackfin/mach-bf548/cdefBF54x_base.h b/include/asm-blackfin/mach-bf548/cdefBF54x_base.h
index 98d35a929116..cdf29e75ea59 100644
--- a/include/asm-blackfin/mach-bf548/cdefBF54x_base.h
+++ b/include/asm-blackfin/mach-bf548/cdefBF54x_base.h
@@ -242,6 +242,39 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
242#define bfin_read_TWI0_RCV_DATA16() bfin_read16(TWI0_RCV_DATA16) 242#define bfin_read_TWI0_RCV_DATA16() bfin_read16(TWI0_RCV_DATA16)
243#define bfin_write_TWI0_RCV_DATA16(val) bfin_write16(TWI0_RCV_DATA16, val) 243#define bfin_write_TWI0_RCV_DATA16(val) bfin_write16(TWI0_RCV_DATA16, val)
244 244
245#define bfin_read_TWI_CLKDIV() bfin_read16(TWI0_CLKDIV)
246#define bfin_write_TWI_CLKDIV(val) bfin_write16(TWI0_CLKDIV, val)
247#define bfin_read_TWI_CONTROL() bfin_read16(TWI0_CONTROL)
248#define bfin_write_TWI_CONTROL(val) bfin_write16(TWI0_CONTROL, val)
249#define bfin_read_TWI_SLAVE_CTRL() bfin_read16(TWI0_SLAVE_CTRL)
250#define bfin_write_TWI_SLAVE_CTRL(val) bfin_write16(TWI0_SLAVE_CTRL, val)
251#define bfin_read_TWI_SLAVE_STAT() bfin_read16(TWI0_SLAVE_STAT)
252#define bfin_write_TWI_SLAVE_STAT(val) bfin_write16(TWI0_SLAVE_STAT, val)
253#define bfin_read_TWI_SLAVE_ADDR() bfin_read16(TWI0_SLAVE_ADDR)
254#define bfin_write_TWI_SLAVE_ADDR(val) bfin_write16(TWI0_SLAVE_ADDR, val)
255#define bfin_read_TWI_MASTER_CTL() bfin_read16(TWI0_MASTER_CTRL)
256#define bfin_write_TWI_MASTER_CTL(val) bfin_write16(TWI0_MASTER_CTRL, val)
257#define bfin_read_TWI_MASTER_STAT() bfin_read16(TWI0_MASTER_STAT)
258#define bfin_write_TWI_MASTER_STAT(val) bfin_write16(TWI0_MASTER_STAT, val)
259#define bfin_read_TWI_MASTER_ADDR() bfin_read16(TWI0_MASTER_ADDR)
260#define bfin_write_TWI_MASTER_ADDR(val) bfin_write16(TWI0_MASTER_ADDR, val)
261#define bfin_read_TWI_INT_STAT() bfin_read16(TWI0_INT_STAT)
262#define bfin_write_TWI_INT_STAT(val) bfin_write16(TWI0_INT_STAT, val)
263#define bfin_read_TWI_INT_MASK() bfin_read16(TWI0_INT_MASK)
264#define bfin_write_TWI_INT_MASK(val) bfin_write16(TWI0_INT_MASK, val)
265#define bfin_read_TWI_FIFO_CTL() bfin_read16(TWI0_FIFO_CTRL)
266#define bfin_write_TWI_FIFO_CTL(val) bfin_write16(TWI0_FIFO_CTRL, val)
267#define bfin_read_TWI_FIFO_STAT() bfin_read16(TWI0_FIFO_STAT)
268#define bfin_write_TWI_FIFO_STAT(val) bfin_write16(TWI0_FIFO_STAT, val)
269#define bfin_read_TWI_XMT_DATA8() bfin_read16(TWI0_XMT_DATA8)
270#define bfin_write_TWI_XMT_DATA8(val) bfin_write16(TWI0_XMT_DATA8, val)
271#define bfin_read_TWI_XMT_DATA16() bfin_read16(TWI0_XMT_DATA16)
272#define bfin_write_TWI_XMT_DATA16(val) bfin_write16(TWI0_XMT_DATA16, val)
273#define bfin_read_TWI_RCV_DATA8() bfin_read16(TWI0_RCV_DATA8)
274#define bfin_write_TWI_RCV_DATA8(val) bfin_write16(TWI0_RCV_DATA8, val)
275#define bfin_read_TWI_RCV_DATA16() bfin_read16(TWI0_RCV_DATA16)
276#define bfin_write_TWI_RCV_DATA16(val) bfin_write16(TWI0_RCV_DATA16, val)
277
245/* SPORT0 is not defined in the shared file because it is not available on the ADSP-BF542 and ADSP-BF544 bfin_read_()rocessors */ 278/* SPORT0 is not defined in the shared file because it is not available on the ADSP-BF542 and ADSP-BF544 bfin_read_()rocessors */
246 279
247/* SPORT1 Registers */ 280/* SPORT1 Registers */
diff --git a/include/asm-blackfin/mach-bf548/irq.h b/include/asm-blackfin/mach-bf548/irq.h
index 0b3325bb1fff..e548d3cd81e3 100644
--- a/include/asm-blackfin/mach-bf548/irq.h
+++ b/include/asm-blackfin/mach-bf548/irq.h
@@ -112,6 +112,7 @@ Events (highest priority) EMU 0
112#define IRQ_ATAPI_TX BFIN_IRQ(44) /* ATAPI TX (DMA11) Interrupt */ 112#define IRQ_ATAPI_TX BFIN_IRQ(44) /* ATAPI TX (DMA11) Interrupt */
113#define IRQ_TWI0 BFIN_IRQ(45) /* TWI0 Interrupt */ 113#define IRQ_TWI0 BFIN_IRQ(45) /* TWI0 Interrupt */
114#define IRQ_TWI1 BFIN_IRQ(46) /* TWI1 Interrupt */ 114#define IRQ_TWI1 BFIN_IRQ(46) /* TWI1 Interrupt */
115#define IRQ_TWI IRQ_TWI0 /* TWI Interrupt */
115#define IRQ_CAN0_RX BFIN_IRQ(47) /* CAN0 Receive Interrupt */ 116#define IRQ_CAN0_RX BFIN_IRQ(47) /* CAN0 Receive Interrupt */
116#define IRQ_CAN0_TX BFIN_IRQ(48) /* CAN0 Transmit Interrupt */ 117#define IRQ_CAN0_TX BFIN_IRQ(48) /* CAN0 Transmit Interrupt */
117#define IRQ_MDMAS2 BFIN_IRQ(49) /* MDMA Stream 2 Interrupt */ 118#define IRQ_MDMAS2 BFIN_IRQ(49) /* MDMA Stream 2 Interrupt */
diff --git a/include/asm-blackfin/mach-bf561/cdefBF561.h b/include/asm-blackfin/mach-bf561/cdefBF561.h
index 1a8ec9e46922..6e87ab269ffe 100644
--- a/include/asm-blackfin/mach-bf561/cdefBF561.h
+++ b/include/asm-blackfin/mach-bf561/cdefBF561.h
@@ -81,6 +81,12 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
81#define bfin_write_PLL_LOCKCNT(val) bfin_write16(PLL_LOCKCNT,val) 81#define bfin_write_PLL_LOCKCNT(val) bfin_write16(PLL_LOCKCNT,val)
82#define bfin_read_CHIPID() bfin_read32(CHIPID) 82#define bfin_read_CHIPID() bfin_read32(CHIPID)
83 83
84/* For MMR's that are reserved on Core B, set up defines to better integrate with other ports */
85#define bfin_read_SWRST() bfin_read_SICA_SWRST()
86#define bfin_write_SWRST() bfin_write_SICA_SWRST()
87#define bfin_read_SYSCR() bfin_read_SICA_SYSCR()
88#define bfin_write_SYSCR() bfin_write_SICA_SYSCR()
89
84/* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */ 90/* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */
85#define bfin_read_SICA_SWRST() bfin_read16(SICA_SWRST) 91#define bfin_read_SICA_SWRST() bfin_read16(SICA_SWRST)
86#define bfin_write_SICA_SWRST(val) bfin_write16(SICA_SWRST,val) 92#define bfin_write_SICA_SWRST(val) bfin_write16(SICA_SWRST,val)
diff --git a/include/asm-blackfin/mach-bf561/defBF561.h b/include/asm-blackfin/mach-bf561/defBF561.h
index 89150ecb909d..0f2dc6e6335b 100644
--- a/include/asm-blackfin/mach-bf561/defBF561.h
+++ b/include/asm-blackfin/mach-bf561/defBF561.h
@@ -52,6 +52,10 @@
52#define PLL_LOCKCNT 0xFFC00010 /* PLL Lock Count register (16-bit) */ 52#define PLL_LOCKCNT 0xFFC00010 /* PLL Lock Count register (16-bit) */
53#define CHIPID 0xFFC00014 /* Chip ID Register */ 53#define CHIPID 0xFFC00014 /* Chip ID Register */
54 54
55/* For MMR's that are reserved on Core B, set up defines to better integrate with other ports */
56#define SWRST SICA_SWRST
57#define SYSCR SICA_SYSCR
58
55/* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */ 59/* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */
56#define SICA_SWRST 0xFFC00100 /* Software Reset register */ 60#define SICA_SWRST 0xFFC00100 /* Software Reset register */
57#define SICA_SYSCR 0xFFC00104 /* System Reset Configuration register */ 61#define SICA_SYSCR 0xFFC00104 /* System Reset Configuration register */
diff --git a/include/asm-blackfin/thread_info.h b/include/asm-blackfin/thread_info.h
index fa8f08cf283e..15b99cf4f50b 100644
--- a/include/asm-blackfin/thread_info.h
+++ b/include/asm-blackfin/thread_info.h
@@ -39,6 +39,11 @@
39 */ 39 */
40#define ALIGN_PAGE_MASK 0xffffe000 40#define ALIGN_PAGE_MASK 0xffffe000
41 41
42/*
43 * Size of kernel stack for each process. This must be a power of 2...
44 */
45#define THREAD_SIZE 8192 /* 2 pages */
46
42#ifndef __ASSEMBLY__ 47#ifndef __ASSEMBLY__
43 48
44typedef unsigned long mm_segment_t; 49typedef unsigned long mm_segment_t;
@@ -76,11 +81,6 @@ struct thread_info {
76#define init_thread_info (init_thread_union.thread_info) 81#define init_thread_info (init_thread_union.thread_info)
77#define init_stack (init_thread_union.stack) 82#define init_stack (init_thread_union.stack)
78 83
79/*
80 * Size of kernel stack for each process. This must be a power of 2...
81 */
82#define THREAD_SIZE 8192 /* 2 pages */
83
84/* How to get the thread information struct from C */ 84/* How to get the thread information struct from C */
85 85
86static inline struct thread_info *current_thread_info(void) 86static inline struct thread_info *current_thread_info(void)
@@ -94,7 +94,7 @@ static inline struct thread_info *current_thread_info(void)
94 struct thread_info *ti; 94 struct thread_info *ti;
95 __asm__("%0 = sp;": "=&d"(ti): 95 __asm__("%0 = sp;": "=&d"(ti):
96 ); 96 );
97 return (struct thread_info *)((long)ti & ~8191UL); 97 return (struct thread_info *)((long)ti & ~((long)THREAD_SIZE-1));
98} 98}
99 99
100/* thread information allocation */ 100/* thread information allocation */
@@ -118,18 +118,16 @@ static inline struct thread_info *current_thread_info(void)
118 * thread information flag bit numbers 118 * thread information flag bit numbers
119 */ 119 */
120#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 120#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
121#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 121#define TIF_SIGPENDING 1 /* signal pending */
122#define TIF_SIGPENDING 2 /* signal pending */ 122#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
123#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 123#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
124#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
125 TIF_NEED_RESCHED */ 124 TIF_NEED_RESCHED */
126#define TIF_MEMDIE 5 125#define TIF_MEMDIE 4
127#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */ 126#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
128#define TIF_FREEZE 7 /* is freezing for suspend */ 127#define TIF_FREEZE 6 /* is freezing for suspend */
129 128
130/* as above, but as bit values */ 129/* as above, but as bit values */
131#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 130#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
132#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
133#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 131#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
134#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 132#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
135#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 133#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
diff --git a/include/asm-cris/thread_info.h b/include/asm-cris/thread_info.h
index 7ad853c3f74e..fde39f6c49c7 100644
--- a/include/asm-cris/thread_info.h
+++ b/include/asm-cris/thread_info.h
@@ -79,14 +79,12 @@ struct thread_info {
79 * - other flags in MSW 79 * - other flags in MSW
80 */ 80 */
81#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 81#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
82#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 82#define TIF_SIGPENDING 1 /* signal pending */
83#define TIF_SIGPENDING 2 /* signal pending */ 83#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
84#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
85#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 84#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
86#define TIF_MEMDIE 17 85#define TIF_MEMDIE 17
87 86
88#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 87#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
89#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
90#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 88#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
91#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 89#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
92#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 90#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
diff --git a/include/asm-frv/thread_info.h b/include/asm-frv/thread_info.h
index d881f518e6a9..cc5433e78b52 100644
--- a/include/asm-frv/thread_info.h
+++ b/include/asm-frv/thread_info.h
@@ -108,18 +108,16 @@ register struct thread_info *__current_thread_info asm("gr15");
108 * - other flags in MSW 108 * - other flags in MSW
109 */ 109 */
110#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 110#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
111#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 111#define TIF_SIGPENDING 1 /* signal pending */
112#define TIF_SIGPENDING 2 /* signal pending */ 112#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
113#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 113#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
114#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */ 114#define TIF_IRET 4 /* return with iret */
115#define TIF_IRET 5 /* return with iret */ 115#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
116#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
117#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 116#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
118#define TIF_MEMDIE 17 /* OOM killer killed process */ 117#define TIF_MEMDIE 17 /* OOM killer killed process */
119#define TIF_FREEZE 18 /* freezing for suspend */ 118#define TIF_FREEZE 18 /* freezing for suspend */
120 119
121#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 120#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
122#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
123#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 121#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
124#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 122#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
125#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) 123#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 344e3091af24..d56fedbb457a 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -33,7 +33,7 @@ struct bug_entry {
33 33
34#ifndef HAVE_ARCH_WARN_ON 34#ifndef HAVE_ARCH_WARN_ON
35#define WARN_ON(condition) ({ \ 35#define WARN_ON(condition) ({ \
36 typeof(condition) __ret_warn_on = (condition); \ 36 int __ret_warn_on = !!(condition); \
37 if (unlikely(__ret_warn_on)) { \ 37 if (unlikely(__ret_warn_on)) { \
38 printk("WARNING: at %s:%d %s()\n", __FILE__, \ 38 printk("WARNING: at %s:%d %s()\n", __FILE__, \
39 __LINE__, __FUNCTION__); \ 39 __LINE__, __FUNCTION__); \
@@ -54,7 +54,7 @@ struct bug_entry {
54 54
55#ifndef HAVE_ARCH_WARN_ON 55#ifndef HAVE_ARCH_WARN_ON
56#define WARN_ON(condition) ({ \ 56#define WARN_ON(condition) ({ \
57 typeof(condition) __ret_warn_on = (condition); \ 57 int __ret_warn_on = !!(condition); \
58 unlikely(__ret_warn_on); \ 58 unlikely(__ret_warn_on); \
59}) 59})
60#endif 60#endif
@@ -62,7 +62,7 @@ struct bug_entry {
62 62
63#define WARN_ON_ONCE(condition) ({ \ 63#define WARN_ON_ONCE(condition) ({ \
64 static int __warned; \ 64 static int __warned; \
65 typeof(condition) __ret_warn_once = (condition); \ 65 int __ret_warn_once = !!(condition); \
66 \ 66 \
67 if (unlikely(__ret_warn_once)) \ 67 if (unlikely(__ret_warn_once)) \
68 if (WARN_ON(!__warned)) \ 68 if (WARN_ON(!__warned)) \
diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h
index 16a466e50681..2fe1b2e67f01 100644
--- a/include/asm-generic/unaligned.h
+++ b/include/asm-generic/unaligned.h
@@ -79,24 +79,24 @@ static inline void __ustw(__u16 val, __u16 *addr)
79 79
80#define __get_unaligned(ptr, size) ({ \ 80#define __get_unaligned(ptr, size) ({ \
81 const void *__gu_p = ptr; \ 81 const void *__gu_p = ptr; \
82 __u64 val; \ 82 __u64 __val; \
83 switch (size) { \ 83 switch (size) { \
84 case 1: \ 84 case 1: \
85 val = *(const __u8 *)__gu_p; \ 85 __val = *(const __u8 *)__gu_p; \
86 break; \ 86 break; \
87 case 2: \ 87 case 2: \
88 val = __uldw(__gu_p); \ 88 __val = __uldw(__gu_p); \
89 break; \ 89 break; \
90 case 4: \ 90 case 4: \
91 val = __uldl(__gu_p); \ 91 __val = __uldl(__gu_p); \
92 break; \ 92 break; \
93 case 8: \ 93 case 8: \
94 val = __uldq(__gu_p); \ 94 __val = __uldq(__gu_p); \
95 break; \ 95 break; \
96 default: \ 96 default: \
97 bad_unaligned_access_length(); \ 97 bad_unaligned_access_length(); \
98 }; \ 98 }; \
99 (__force __typeof__(*(ptr)))val; \ 99 (__force __typeof__(*(ptr)))__val; \
100}) 100})
101 101
102#define __put_unaligned(val, ptr, size) \ 102#define __put_unaligned(val, ptr, size) \
diff --git a/include/asm-h8300/thread_info.h b/include/asm-h8300/thread_info.h
index aee4009a498e..27bb95e2944c 100644
--- a/include/asm-h8300/thread_info.h
+++ b/include/asm-h8300/thread_info.h
@@ -86,17 +86,15 @@ static inline struct thread_info *current_thread_info(void)
86 * thread information flag bit numbers 86 * thread information flag bit numbers
87 */ 87 */
88#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 88#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
89#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 89#define TIF_SIGPENDING 1 /* signal pending */
90#define TIF_SIGPENDING 2 /* signal pending */ 90#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
91#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 91#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
92#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
93 TIF_NEED_RESCHED */ 92 TIF_NEED_RESCHED */
94#define TIF_MEMDIE 5 93#define TIF_MEMDIE 4
95#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */ 94#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
96 95
97/* as above, but as bit values */ 96/* as above, but as bit values */
98#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 97#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
99#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
100#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 98#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
101#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 99#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
102#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 100#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
diff --git a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h
index 449f3f272e07..125179adf044 100644
--- a/include/asm-i386/acpi.h
+++ b/include/asm-i386/acpi.h
@@ -121,19 +121,6 @@ static inline void acpi_disable_pci(void)
121} 121}
122extern int acpi_irq_balance_set(char *str); 122extern int acpi_irq_balance_set(char *str);
123 123
124#else /* !CONFIG_ACPI */
125
126#define acpi_lapic 0
127#define acpi_ioapic 0
128static inline void acpi_noirq_set(void) { }
129static inline void acpi_disable_pci(void) { }
130static inline void disable_acpi(void) { }
131
132#endif /* !CONFIG_ACPI */
133
134
135#ifdef CONFIG_ACPI_SLEEP
136
137/* routines for saving/restoring kernel state */ 124/* routines for saving/restoring kernel state */
138extern int acpi_save_state_mem(void); 125extern int acpi_save_state_mem(void);
139extern void acpi_restore_state_mem(void); 126extern void acpi_restore_state_mem(void);
@@ -143,7 +130,15 @@ extern unsigned long acpi_wakeup_address;
143/* early initialization routine */ 130/* early initialization routine */
144extern void acpi_reserve_bootmem(void); 131extern void acpi_reserve_bootmem(void);
145 132
146#endif /*CONFIG_ACPI_SLEEP*/ 133#else /* !CONFIG_ACPI */
134
135#define acpi_lapic 0
136#define acpi_ioapic 0
137static inline void acpi_noirq_set(void) { }
138static inline void acpi_disable_pci(void) { }
139static inline void disable_acpi(void) { }
140
141#endif /* !CONFIG_ACPI */
147 142
148#define ARCH_HAS_POWER_INIT 1 143#define ARCH_HAS_POWER_INIT 1
149 144
diff --git a/include/asm-i386/bootparam.h b/include/asm-i386/bootparam.h
index 427d8652bfde..b91b01783e4b 100644
--- a/include/asm-i386/bootparam.h
+++ b/include/asm-i386/bootparam.h
@@ -4,8 +4,9 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/screen_info.h> 5#include <linux/screen_info.h>
6#include <linux/apm_bios.h> 6#include <linux/apm_bios.h>
7#include <asm/e820.h>
8#include <linux/edd.h> 7#include <linux/edd.h>
8#include <asm/e820.h>
9#include <asm/ist.h>
9#include <video/edid.h> 10#include <video/edid.h>
10 11
11struct setup_header { 12struct setup_header {
@@ -48,9 +49,9 @@ struct efi_info {
48 u32 _pad1; 49 u32 _pad1;
49 u32 efi_systab; 50 u32 efi_systab;
50 u32 efi_memdesc_size; 51 u32 efi_memdesc_size;
51 u32 efi_memdec_version; 52 u32 efi_memdesc_version;
52 u32 efi_memmap; 53 u32 efi_memmap;
53 u32 fi_memmap_size; 54 u32 efi_memmap_size;
54 u32 _pad2[2]; 55 u32 _pad2[2];
55}; 56};
56 57
@@ -59,7 +60,7 @@ struct boot_params {
59 struct screen_info screen_info; /* 0x000 */ 60 struct screen_info screen_info; /* 0x000 */
60 struct apm_bios_info apm_bios_info; /* 0x040 */ 61 struct apm_bios_info apm_bios_info; /* 0x040 */
61 u8 _pad2[12]; /* 0x054 */ 62 u8 _pad2[12]; /* 0x054 */
62 u32 speedstep_info[4]; /* 0x060 */ 63 struct ist_info ist_info; /* 0x060 */
63 u8 _pad3[16]; /* 0x070 */ 64 u8 _pad3[16]; /* 0x070 */
64 u8 hd0_info[16]; /* obsolete! */ /* 0x080 */ 65 u8 hd0_info[16]; /* obsolete! */ /* 0x080 */
65 u8 hd1_info[16]; /* obsolete! */ /* 0x090 */ 66 u8 hd1_info[16]; /* obsolete! */ /* 0x090 */
diff --git a/include/asm-i386/e820.h b/include/asm-i386/e820.h
index 43114c824608..cf67dbb1db79 100644
--- a/include/asm-i386/e820.h
+++ b/include/asm-i386/e820.h
@@ -47,7 +47,7 @@ extern void e820_register_memory(void);
47extern void limit_regions(unsigned long long size); 47extern void limit_regions(unsigned long long size);
48extern void print_memory_map(char *who); 48extern void print_memory_map(char *who);
49 49
50#if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND) 50#if defined(CONFIG_PM) && defined(CONFIG_HIBERNATION)
51extern void e820_mark_nosave_regions(void); 51extern void e820_mark_nosave_regions(void);
52#else 52#else
53static inline void e820_mark_nosave_regions(void) 53static inline void e820_mark_nosave_regions(void)
diff --git a/include/asm-i386/ist.h b/include/asm-i386/ist.h
index d13d1e68afa9..ef2003ebc6f9 100644
--- a/include/asm-i386/ist.h
+++ b/include/asm-i386/ist.h
@@ -19,11 +19,13 @@
19 19
20#ifdef __KERNEL__ 20#ifdef __KERNEL__
21 21
22#include <linux/types.h>
23
22struct ist_info { 24struct ist_info {
23 unsigned long signature; 25 u32 signature;
24 unsigned long command; 26 u32 command;
25 unsigned long event; 27 u32 event;
26 unsigned long perf_level; 28 u32 perf_level;
27}; 29};
28 30
29extern struct ist_info ist_info; 31extern struct ist_info ist_info;
diff --git a/include/asm-i386/serial.h b/include/asm-i386/serial.h
index 57a4306cdf63..bd67480ca109 100644
--- a/include/asm-i386/serial.h
+++ b/include/asm-i386/serial.h
@@ -11,3 +11,19 @@
11 * megabits/second; but this requires the faster clock. 11 * megabits/second; but this requires the faster clock.
12 */ 12 */
13#define BASE_BAUD ( 1843200 / 16 ) 13#define BASE_BAUD ( 1843200 / 16 )
14
15/* Standard COM flags (except for COM4, because of the 8514 problem) */
16#ifdef CONFIG_SERIAL_DETECT_IRQ
17#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ)
18#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
19#else
20#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
21#define STD_COM4_FLAGS ASYNC_BOOT_AUTOCONF
22#endif
23
24#define SERIAL_PORT_DFNS \
25 /* UART CLK PORT IRQ FLAGS */ \
26 { 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */ \
27 { 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS }, /* ttyS1 */ \
28 { 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS }, /* ttyS2 */ \
29 { 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS }, /* ttyS3 */
diff --git a/include/asm-i386/suspend.h b/include/asm-i386/suspend.h
index 8dbaafe611ff..a2520732ffd6 100644
--- a/include/asm-i386/suspend.h
+++ b/include/asm-i386/suspend.h
@@ -21,7 +21,7 @@ struct saved_context {
21 unsigned long return_address; 21 unsigned long return_address;
22} __attribute__((packed)); 22} __attribute__((packed));
23 23
24#ifdef CONFIG_ACPI_SLEEP 24#ifdef CONFIG_ACPI
25extern unsigned long saved_eip; 25extern unsigned long saved_eip;
26extern unsigned long saved_esp; 26extern unsigned long saved_esp;
27extern unsigned long saved_ebp; 27extern unsigned long saved_ebp;
diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
index 54424e045e01..22a8cbcd35e2 100644
--- a/include/asm-i386/thread_info.h
+++ b/include/asm-i386/thread_info.h
@@ -124,15 +124,14 @@ static inline struct thread_info *current_thread_info(void)
124 * - other flags in MSW 124 * - other flags in MSW
125 */ 125 */
126#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 126#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
127#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 127#define TIF_SIGPENDING 1 /* signal pending */
128#define TIF_SIGPENDING 2 /* signal pending */ 128#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
129#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 129#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
130#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */ 130#define TIF_IRET 4 /* return with iret */
131#define TIF_IRET 5 /* return with iret */ 131#define TIF_SYSCALL_EMU 5 /* syscall emulation active */
132#define TIF_SYSCALL_EMU 6 /* syscall emulation active */ 132#define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */
133#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 133#define TIF_SECCOMP 7 /* secure computing */
134#define TIF_SECCOMP 8 /* secure computing */ 134#define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */
135#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
136#define TIF_MEMDIE 16 135#define TIF_MEMDIE 16
137#define TIF_DEBUG 17 /* uses debug registers */ 136#define TIF_DEBUG 17 /* uses debug registers */
138#define TIF_IO_BITMAP 18 /* uses I/O bitmap */ 137#define TIF_IO_BITMAP 18 /* uses I/O bitmap */
@@ -140,7 +139,6 @@ static inline struct thread_info *current_thread_info(void)
140#define TIF_NOTSC 20 /* TSC is not accessible in userland */ 139#define TIF_NOTSC 20 /* TSC is not accessible in userland */
141 140
142#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 141#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
143#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
144#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 142#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
145#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 143#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
146#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 144#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
diff --git a/include/asm-ia64/acpi.h b/include/asm-ia64/acpi.h
index 5b526357d178..49730ffbbae4 100644
--- a/include/asm-ia64/acpi.h
+++ b/include/asm-ia64/acpi.h
@@ -100,6 +100,11 @@ const char *acpi_get_sysname (void);
100int acpi_request_vector (u32 int_type); 100int acpi_request_vector (u32 int_type);
101int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); 101int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
102 102
103/* routines for saving/restoring kernel state */
104extern int acpi_save_state_mem(void);
105extern void acpi_restore_state_mem(void);
106extern unsigned long acpi_wakeup_address;
107
103/* 108/*
104 * Record the cpei override flag and current logical cpu. This is 109 * Record the cpei override flag and current logical cpu. This is
105 * useful for CPU removal. 110 * useful for CPU removal.
diff --git a/include/asm-ia64/ia32.h b/include/asm-ia64/ia32.h
index 5ff8d74c3e00..2390ee145aa1 100644
--- a/include/asm-ia64/ia32.h
+++ b/include/asm-ia64/ia32.h
@@ -27,11 +27,12 @@ extern int ia32_clone_tls (struct task_struct *child, struct pt_regs *childregs)
27extern int ia32_setup_frame1 (int sig, struct k_sigaction *ka, siginfo_t *info, 27extern int ia32_setup_frame1 (int sig, struct k_sigaction *ka, siginfo_t *info,
28 sigset_t *set, struct pt_regs *regs); 28 sigset_t *set, struct pt_regs *regs);
29#if PAGE_SHIFT > IA32_PAGE_SHIFT 29#if PAGE_SHIFT > IA32_PAGE_SHIFT
30extern int ia32_copy_partial_page_list (struct task_struct *, unsigned long); 30extern int ia32_copy_ia64_partial_page_list(struct task_struct *,
31extern void ia32_drop_partial_page_list (struct task_struct *); 31 unsigned long);
32extern void ia32_drop_ia64_partial_page_list(struct task_struct *);
32#else 33#else
33# define ia32_copy_partial_page_list(a1, a2) 0 34# define ia32_copy_ia64_partial_page_list(a1, a2) 0
34# define ia32_drop_partial_page_list(a1) do { ; } while (0) 35# define ia32_drop_ia64_partial_page_list(a1) do { ; } while (0)
35#endif 36#endif
36 37
37#endif /* !__ASSEMBLY__ */ 38#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-ia64/machvec.h b/include/asm-ia64/machvec.h
index ca33eb181ff2..5cf8bf1e805e 100644
--- a/include/asm-ia64/machvec.h
+++ b/include/asm-ia64/machvec.h
@@ -275,6 +275,7 @@ struct ia64_machine_vector {
275 275
276extern struct ia64_machine_vector ia64_mv; 276extern struct ia64_machine_vector ia64_mv;
277extern void machvec_init (const char *name); 277extern void machvec_init (const char *name);
278extern void machvec_init_from_cmdline(const char *cmdline);
278 279
279# else 280# else
280# error Unknown configuration. Update asm-ia64/machvec.h. 281# error Unknown configuration. Update asm-ia64/machvec.h.
diff --git a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h
index 6251c76437d2..be3b0ae43270 100644
--- a/include/asm-ia64/processor.h
+++ b/include/asm-ia64/processor.h
@@ -220,7 +220,7 @@ struct desc_struct {
220 220
221#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8) 221#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
222 222
223struct partial_page_list; 223struct ia64_partial_page_list;
224#endif 224#endif
225 225
226struct thread_struct { 226struct thread_struct {
@@ -242,7 +242,7 @@ struct thread_struct {
242 __u64 fdr; /* IA32 fp except. data reg */ 242 __u64 fdr; /* IA32 fp except. data reg */
243 __u64 old_k1; /* old value of ar.k1 */ 243 __u64 old_k1; /* old value of ar.k1 */
244 __u64 old_iob; /* old IOBase value */ 244 __u64 old_iob; /* old IOBase value */
245 struct partial_page_list *ppl; /* partial page list for 4K page size issue */ 245 struct ia64_partial_page_list *ppl; /* partial page list for 4K page size issue */
246 /* cached TLS descriptors. */ 246 /* cached TLS descriptors. */
247 struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES]; 247 struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
248 248
diff --git a/include/asm-ia64/smp.h b/include/asm-ia64/smp.h
index c60024989ebd..6314b29e8c4d 100644
--- a/include/asm-ia64/smp.h
+++ b/include/asm-ia64/smp.h
@@ -116,7 +116,6 @@ max_xtp (void)
116extern int __cpu_disable (void); 116extern int __cpu_disable (void);
117extern void __cpu_die (unsigned int cpu); 117extern void __cpu_die (unsigned int cpu);
118extern void cpu_die (void) __attribute__ ((noreturn)); 118extern void cpu_die (void) __attribute__ ((noreturn));
119extern int __cpu_up (unsigned int cpu);
120extern void __init smp_build_cpu_map(void); 119extern void __init smp_build_cpu_map(void);
121 120
122extern void __init init_smp_config (void); 121extern void __init init_smp_config (void);
diff --git a/include/asm-ia64/thread_info.h b/include/asm-ia64/thread_info.h
index 7d0241db622b..d16031e72efa 100644
--- a/include/asm-ia64/thread_info.h
+++ b/include/asm-ia64/thread_info.h
@@ -79,13 +79,13 @@ struct thread_info {
79 * - pending work-to-be-done flags are in least-significant 16 bits, other flags 79 * - pending work-to-be-done flags are in least-significant 16 bits, other flags
80 * in top 16 bits 80 * in top 16 bits
81 */ 81 */
82#define TIF_NOTIFY_RESUME 0 /* resumption notification requested */ 82#define TIF_SIGPENDING 0 /* signal pending */
83#define TIF_SIGPENDING 1 /* signal pending */ 83#define TIF_NEED_RESCHED 1 /* rescheduling necessary */
84#define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 84#define TIF_SYSCALL_TRACE 2 /* syscall trace active */
85#define TIF_SYSCALL_TRACE 3 /* syscall trace active */ 85#define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */
86#define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */ 86#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
87#define TIF_SINGLESTEP 5 /* restore singlestep on return to user mode */ 87#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
88#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */ 88#define TIF_PERFMON_WORK 6 /* work for pfm_handle_work() */
89#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 89#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
90#define TIF_MEMDIE 17 90#define TIF_MEMDIE 17
91#define TIF_MCA_INIT 18 /* this task is processing MCA or INIT */ 91#define TIF_MCA_INIT 18 /* this task is processing MCA or INIT */
@@ -96,8 +96,8 @@ struct thread_info {
96#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 96#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
97#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) 97#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
98#define _TIF_SYSCALL_TRACEAUDIT (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP) 98#define _TIF_SYSCALL_TRACEAUDIT (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP)
99#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
100#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 99#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
100#define _TIF_PERFMON_WORK (1 << TIF_PERFMON_WORK)
101#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 101#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
102#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 102#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
103#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 103#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
@@ -106,7 +106,9 @@ struct thread_info {
106#define _TIF_FREEZE (1 << TIF_FREEZE) 106#define _TIF_FREEZE (1 << TIF_FREEZE)
107 107
108/* "work to do on user-return" bits */ 108/* "work to do on user-return" bits */
109#define TIF_ALLWORK_MASK (_TIF_NOTIFY_RESUME|_TIF_SIGPENDING|_TIF_NEED_RESCHED|_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_RESTORE_SIGMASK) 109#define TIF_ALLWORK_MASK (_TIF_SIGPENDING|_TIF_PERFMON_WORK|_TIF_SYSCALL_AUDIT|\
110 _TIF_NEED_RESCHED| _TIF_SYSCALL_TRACE|\
111 _TIF_RESTORE_SIGMASK)
110/* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT */ 112/* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT */
111#define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)) 113#define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT))
112 114
diff --git a/include/asm-m32r/thread_info.h b/include/asm-m32r/thread_info.h
index 22aff3222d22..b7ccc3e68604 100644
--- a/include/asm-m32r/thread_info.h
+++ b/include/asm-m32r/thread_info.h
@@ -146,17 +146,15 @@ static inline unsigned int get_thread_fault_code(void)
146 * - other flags in MSW 146 * - other flags in MSW
147 */ 147 */
148#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 148#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
149#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 149#define TIF_SIGPENDING 1 /* signal pending */
150#define TIF_SIGPENDING 2 /* signal pending */ 150#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
151#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 151#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
152#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */ 152#define TIF_IRET 4 /* return with iret */
153#define TIF_IRET 5 /* return with iret */
154#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 153#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
155 /* 31..28 fault code */ 154 /* 31..28 fault code */
156#define TIF_MEMDIE 17 155#define TIF_MEMDIE 17
157 156
158#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 157#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
159#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
160#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 158#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
161#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 159#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
162#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 160#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
diff --git a/include/asm-m68k/raw_io.h b/include/asm-m68k/raw_io.h
index 91c623f0994c..d9eb9834ccc8 100644
--- a/include/asm-m68k/raw_io.h
+++ b/include/asm-m68k/raw_io.h
@@ -36,15 +36,15 @@ extern void __iounmap(void *addr, unsigned long size);
36#define in_be32(addr) \ 36#define in_be32(addr) \
37 ({ u32 __v = (*(__force volatile u32 *) (addr)); __v; }) 37 ({ u32 __v = (*(__force volatile u32 *) (addr)); __v; })
38#define in_le16(addr) \ 38#define in_le16(addr) \
39 ({ u16 __v = le16_to_cpu(*(__force volatile u16 *) (addr)); __v; }) 39 ({ u16 __v = le16_to_cpu(*(__force volatile __le16 *) (addr)); __v; })
40#define in_le32(addr) \ 40#define in_le32(addr) \
41 ({ u32 __v = le32_to_cpu(*(__force volatile u32 *) (addr)); __v; }) 41 ({ u32 __v = le32_to_cpu(*(__force volatile __le32 *) (addr)); __v; })
42 42
43#define out_8(addr,b) (void)((*(__force volatile u8 *) (addr)) = (b)) 43#define out_8(addr,b) (void)((*(__force volatile u8 *) (addr)) = (b))
44#define out_be16(addr,w) (void)((*(__force volatile u16 *) (addr)) = (w)) 44#define out_be16(addr,w) (void)((*(__force volatile u16 *) (addr)) = (w))
45#define out_be32(addr,l) (void)((*(__force volatile u32 *) (addr)) = (l)) 45#define out_be32(addr,l) (void)((*(__force volatile u32 *) (addr)) = (l))
46#define out_le16(addr,w) (void)((*(__force volatile u16 *) (addr)) = cpu_to_le16(w)) 46#define out_le16(addr,w) (void)((*(__force volatile __le16 *) (addr)) = cpu_to_le16(w))
47#define out_le32(addr,l) (void)((*(__force volatile u32 *) (addr)) = cpu_to_le32(l)) 47#define out_le32(addr,l) (void)((*(__force volatile __le32 *) (addr)) = cpu_to_le32(l))
48 48
49#define raw_inb in_8 49#define raw_inb in_8
50#define raw_inw in_be16 50#define raw_inw in_be16
diff --git a/include/asm-m68k/system.h b/include/asm-m68k/system.h
index 198878b53a61..caa9b1663e45 100644
--- a/include/asm-m68k/system.h
+++ b/include/asm-m68k/system.h
@@ -46,6 +46,22 @@ asmlinkage void resume(void);
46} while (0) 46} while (0)
47 47
48 48
49/*
50 * Force strict CPU ordering.
51 * Not really required on m68k...
52 */
53#define nop() do { asm volatile ("nop"); barrier(); } while (0)
54#define mb() barrier()
55#define rmb() barrier()
56#define wmb() barrier()
57#define read_barrier_depends() ((void)0)
58#define set_mb(var, value) ({ (var) = (value); wmb(); })
59
60#define smp_mb() barrier()
61#define smp_rmb() barrier()
62#define smp_wmb() barrier()
63#define smp_read_barrier_depends() ((void)0)
64
49/* interrupt control.. */ 65/* interrupt control.. */
50#if 0 66#if 0
51#define local_irq_enable() asm volatile ("andiw %0,%%sr": : "i" (ALLOWINT) : "memory") 67#define local_irq_enable() asm volatile ("andiw %0,%%sr": : "i" (ALLOWINT) : "memory")
@@ -70,23 +86,6 @@ static inline int irqs_disabled(void)
70/* For spinlocks etc */ 86/* For spinlocks etc */
71#define local_irq_save(x) ({ local_save_flags(x); local_irq_disable(); }) 87#define local_irq_save(x) ({ local_save_flags(x); local_irq_disable(); })
72 88
73/*
74 * Force strict CPU ordering.
75 * Not really required on m68k...
76 */
77#define nop() do { asm volatile ("nop"); barrier(); } while (0)
78#define mb() barrier()
79#define rmb() barrier()
80#define wmb() barrier()
81#define read_barrier_depends() ((void)0)
82#define set_mb(var, value) ({ (var) = (value); wmb(); })
83
84#define smp_mb() barrier()
85#define smp_rmb() barrier()
86#define smp_wmb() barrier()
87#define smp_read_barrier_depends() ((void)0)
88
89
90#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) 89#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
91 90
92struct __xchg_dummy { unsigned long a[100]; }; 91struct __xchg_dummy { unsigned long a[100]; };
diff --git a/include/asm-m68knommu/hardirq.h b/include/asm-m68knommu/hardirq.h
index 980075bab792..bfad28149a49 100644
--- a/include/asm-m68knommu/hardirq.h
+++ b/include/asm-m68knommu/hardirq.h
@@ -22,4 +22,6 @@ typedef struct {
22# error HARDIRQ_BITS is too low! 22# error HARDIRQ_BITS is too low!
23#endif 23#endif
24 24
25void ack_bad_irq(unsigned int irq);
26
25#endif /* __M68K_HARDIRQ_H */ 27#endif /* __M68K_HARDIRQ_H */
diff --git a/include/asm-m68knommu/hw_irq.h b/include/asm-m68knommu/hw_irq.h
new file mode 100644
index 000000000000..f3ec9e5ae049
--- /dev/null
+++ b/include/asm-m68knommu/hw_irq.h
@@ -0,0 +1,4 @@
1#ifndef __M68KNOMMU_HW_IRQ_H__
2#define __M68KNOMMU_HW_IRQ_H__
3
4#endif /* __M68KNOMMU_HW_IRQ_H__ */
diff --git a/include/asm-m68knommu/machdep.h b/include/asm-m68knommu/machdep.h
index 6ce28f8e0ead..708d7863ba68 100644
--- a/include/asm-m68knommu/machdep.h
+++ b/include/asm-m68knommu/machdep.h
@@ -1,53 +1,21 @@
1#ifndef _M68KNOMMU_MACHDEP_H 1#ifndef _M68KNOMMU_MACHDEP_H
2#define _M68KNOMMU_MACHDEP_H 2#define _M68KNOMMU_MACHDEP_H
3 3
4#include <linux/seq_file.h>
5#include <linux/interrupt.h> 4#include <linux/interrupt.h>
6 5
7struct pt_regs; 6extern void (*mach_sched_init) (irq_handler_t handler);
8struct kbd_repeat;
9struct mktime;
10struct hwclk_time;
11struct gendisk;
12struct buffer_head;
13
14extern void (*mach_sched_init) (irqreturn_t (*handler)(int, void *, struct pt_regs *));
15/* machine dependent keyboard functions */
16extern int (*mach_keyb_init) (void);
17extern int (*mach_kbdrate) (struct kbd_repeat *);
18extern void (*mach_kbd_leds) (unsigned int);
19/* machine dependent irq functions */
20extern void (*mach_init_IRQ) (void);
21extern irq_handler_t mach_default_handler;
22extern int (*mach_request_irq) (unsigned int irq, void (*handler)(int, void *, struct pt_regs *),
23 unsigned long flags, const char *devname, void *dev_id);
24extern void (*mach_free_irq) (unsigned int irq, void *dev_id);
25extern void (*mach_get_model) (char *model);
26extern int (*mach_get_hardware_list) (char *buffer);
27extern int (*mach_get_irq_list) (struct seq_file *p, void *v);
28extern void (*mach_process_int) (int irq, struct pt_regs *fp);
29/* machine dependent timer functions */ 7/* machine dependent timer functions */
30extern unsigned long (*mach_gettimeoffset)(void); 8extern unsigned long (*mach_gettimeoffset)(void);
31extern void (*mach_gettod)(int *year, int *mon, int *day, int *hour, 9extern void (*mach_gettod)(int *year, int *mon, int *day, int *hour,
32 int *min, int *sec); 10 int *min, int *sec);
33extern int (*mach_hwclk)(int, struct hwclk_time*);
34extern int (*mach_set_clock_mmss)(unsigned long); 11extern int (*mach_set_clock_mmss)(unsigned long);
12
13/* machine dependent power off functions */
35extern void (*mach_reset)( void ); 14extern void (*mach_reset)( void );
36extern void (*mach_halt)( void ); 15extern void (*mach_halt)( void );
37extern void (*mach_power_off)( void ); 16extern void (*mach_power_off)( void );
38extern unsigned long (*mach_hd_init) (unsigned long, unsigned long);
39extern void (*mach_hd_setup)(char *, int *);
40extern long mach_max_dma_address;
41extern void (*mach_floppy_eject)(void);
42extern void (*mach_heartbeat) (int);
43extern void (*mach_l2_flush) (int);
44extern int mach_sysrq_key;
45extern int mach_sysrq_shift_state;
46extern int mach_sysrq_shift_mask;
47extern char *mach_sysrq_xlate;
48 17
49extern void config_BSP(char *command, int len); 18extern void config_BSP(char *command, int len);
50extern void (*mach_tick)(void); 19extern void (*mach_tick)(void);
51extern void (*mach_trap_init)(void);
52 20
53#endif /* _M68KNOMMU_MACHDEP_H */ 21#endif /* _M68KNOMMU_MACHDEP_H */
diff --git a/include/asm-m68knommu/mcfdma.h b/include/asm-m68knommu/mcfdma.h
index ea729e81a6be..705c52c79cd8 100644
--- a/include/asm-m68knommu/mcfdma.h
+++ b/include/asm-m68knommu/mcfdma.h
@@ -133,7 +133,7 @@
133#define MCFDMA_DIR_ASCEN 0x0800 /* Address Sequence Complete (Completion) interrupt enable */ 133#define MCFDMA_DIR_ASCEN 0x0800 /* Address Sequence Complete (Completion) interrupt enable */
134#define MCFDMA_DIR_TEEN 0x0200 /* Transfer Error interrupt enable */ 134#define MCFDMA_DIR_TEEN 0x0200 /* Transfer Error interrupt enable */
135#define MCFDMA_DIR_TCEN 0x0100 /* Transfer Complete (a bus transfer, that is) interrupt enable */ 135#define MCFDMA_DIR_TCEN 0x0100 /* Transfer Complete (a bus transfer, that is) interrupt enable */
136#define MCFDMA_DIR_INV 0x1000 /* Invalid Combination */ 136#define MCFDMA_DIR_INV 0x0010 /* Invalid Combination */
137#define MCFDMA_DIR_ASC 0x0008 /* Address Sequence Complete (DMA Completion) */ 137#define MCFDMA_DIR_ASC 0x0008 /* Address Sequence Complete (DMA Completion) */
138#define MCFDMA_DIR_TE 0x0002 /* Transfer Error */ 138#define MCFDMA_DIR_TE 0x0002 /* Transfer Error */
139#define MCFDMA_DIR_TC 0x0001 /* Transfer Complete */ 139#define MCFDMA_DIR_TC 0x0001 /* Transfer Complete */
diff --git a/include/asm-m68knommu/system.h b/include/asm-m68knommu/system.h
index 5e5ed18bb78f..5da43a5d12a3 100644
--- a/include/asm-m68knommu/system.h
+++ b/include/asm-m68knommu/system.h
@@ -296,7 +296,7 @@ cmpxchg(volatile int *p, int old, int new)
296({ \ 296({ \
297 unsigned char volatile *reset; \ 297 unsigned char volatile *reset; \
298 asm("move.w #0x2700, %sr"); \ 298 asm("move.w #0x2700, %sr"); \
299 reset = ((volatile unsigned short *)(MCF_IPSBAR + 0x110000)); \ 299 reset = ((volatile unsigned char *)(MCF_IPSBAR + 0x110000)); \
300 while(1) \ 300 while(1) \
301 *reset |= (0x01 << 7);\ 301 *reset |= (0x01 << 7);\
302}) 302})
@@ -318,7 +318,7 @@ cmpxchg(volatile int *p, int old, int new)
318({ \ 318({ \
319 unsigned char volatile *reset; \ 319 unsigned char volatile *reset; \
320 asm("move.w #0x2700, %sr"); \ 320 asm("move.w #0x2700, %sr"); \
321 reset = ((volatile unsigned short *)(MCF_IPSBAR + 0xA0000)); \ 321 reset = ((volatile unsigned char *)(MCF_IPSBAR + 0xA0000)); \
322 while(1) \ 322 while(1) \
323 *reset |= 0x80; \ 323 *reset |= 0x80; \
324}) 324})
diff --git a/include/asm-m68knommu/thread_info.h b/include/asm-m68knommu/thread_info.h
index b8f009edf2b2..95996d978bed 100644
--- a/include/asm-m68knommu/thread_info.h
+++ b/include/asm-m68knommu/thread_info.h
@@ -83,16 +83,14 @@ static inline struct thread_info *current_thread_info(void)
83 * thread information flag bit numbers 83 * thread information flag bit numbers
84 */ 84 */
85#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 85#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
86#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 86#define TIF_SIGPENDING 1 /* signal pending */
87#define TIF_SIGPENDING 2 /* signal pending */ 87#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
88#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 88#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
89#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
90 TIF_NEED_RESCHED */ 89 TIF_NEED_RESCHED */
91#define TIF_MEMDIE 5 90#define TIF_MEMDIE 4
92 91
93/* as above, but as bit values */ 92/* as above, but as bit values */
94#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 93#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
95#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
96#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 94#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
97#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 95#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
98#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 96#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
diff --git a/include/asm-m68knommu/timex.h b/include/asm-m68knommu/timex.h
index 85069998db52..109050f3fe91 100644
--- a/include/asm-m68knommu/timex.h
+++ b/include/asm-m68knommu/timex.h
@@ -1 +1,23 @@
1#include <asm-m68k/timex.h> 1/*
2 * linux/include/asm-m68knommu/timex.h
3 *
4 * m68knommu architecture timex specifications
5 */
6#ifndef _ASM_M68KNOMMU_TIMEX_H
7#define _ASM_M68KNOMMU_TIMEX_H
8
9#ifdef CONFIG_COLDFIRE
10#include <asm/coldfire.h>
11#define CLOCK_TICK_RATE MCF_CLK
12#else
13#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
14#endif
15
16typedef unsigned long cycles_t;
17
18static inline cycles_t get_cycles(void)
19{
20 return 0;
21}
22
23#endif
diff --git a/include/asm-mips/a.out.h b/include/asm-mips/a.out.h
index 1ad60ba186d0..bf55a5b34bef 100644
--- a/include/asm-mips/a.out.h
+++ b/include/asm-mips/a.out.h
@@ -38,7 +38,8 @@ struct exec
38#define STACK_TOP TASK_SIZE 38#define STACK_TOP TASK_SIZE
39#endif 39#endif
40#ifdef CONFIG_64BIT 40#ifdef CONFIG_64BIT
41#define STACK_TOP (current->thread.mflags & MF_32BIT_ADDR ? TASK_SIZE32 : TASK_SIZE) 41#define STACK_TOP \
42 (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE)
42#endif 43#endif
43#define STACK_TOP_MAX TASK_SIZE 44#define STACK_TOP_MAX TASK_SIZE
44 45
diff --git a/include/asm-mips/bootinfo.h b/include/asm-mips/bootinfo.h
index 087126a5faf9..c0f052b37b9e 100644
--- a/include/asm-mips/bootinfo.h
+++ b/include/asm-mips/bootinfo.h
@@ -86,16 +86,6 @@
86#define MACH_COBALT_27 0 /* Proto "27" hardware */ 86#define MACH_COBALT_27 0 /* Proto "27" hardware */
87 87
88/* 88/*
89 * Valid machtype for group NEC DDB
90 */
91#define MACH_GROUP_NEC_DDB 8 /* NEC DDB */
92#define MACH_NEC_DDB5074 0 /* NEC DDB Vrc-5074 */
93#define MACH_NEC_DDB5476 1 /* NEC DDB Vrc-5476 */
94#define MACH_NEC_DDB5477 2 /* NEC DDB Vrc-5477 */
95#define MACH_NEC_ROCKHOPPER 3 /* Rockhopper base board */
96#define MACH_NEC_ROCKHOPPERII 4 /* Rockhopper II base board */
97
98/*
99 * Valid machtype for group BAGET 89 * Valid machtype for group BAGET
100 */ 90 */
101#define MACH_GROUP_BAGET 9 /* Baget */ 91#define MACH_GROUP_BAGET 9 /* Baget */
@@ -145,9 +135,6 @@
145#define MACH_TOSHIBA_RBTX4937 5 135#define MACH_TOSHIBA_RBTX4937 5
146#define MACH_TOSHIBA_RBTX4938 6 136#define MACH_TOSHIBA_RBTX4938 6
147 137
148#define GROUP_TOSHIBA_NAMES { "Pallas", "TopasCE", "JMR", "JMR TX3927", \
149 "RBTX4927", "RBTX4937" }
150
151/* 138/*
152 * Valid machtype for group Alchemy 139 * Valid machtype for group Alchemy
153 */ 140 */
diff --git a/include/asm-mips/ddb5xxx/ddb5477.h b/include/asm-mips/ddb5xxx/ddb5477.h
deleted file mode 100644
index 6cf177caf6d5..000000000000
--- a/include/asm-mips/ddb5xxx/ddb5477.h
+++ /dev/null
@@ -1,342 +0,0 @@
1/***********************************************************************
2 *
3 * Copyright 2001 MontaVista Software Inc.
4 * Author: jsun@mvista.com or jsun@junsun.net
5 *
6 * include/asm-mips/ddb5xxx/ddb5477.h
7 * DDB 5477 specific definitions and macros.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 ***********************************************************************
15 */
16
17#ifndef __ASM_DDB5XXX_DDB5477_H
18#define __ASM_DDB5XXX_DDB5477_H
19
20#include <irq.h>
21
22/*
23 * This contains macros that are specific to DDB5477 or renamed from
24 * DDB5476.
25 */
26
27/*
28 * renamed PADRs
29 */
30#define DDB_LCS0 DDB_DCS2
31#define DDB_LCS1 DDB_DCS3
32#define DDB_LCS2 DDB_DCS4
33#define DDB_VRC5477 DDB_INTCS
34
35/*
36 * New CPU interface registers
37 */
38#define DDB_INTCTRL0 0x0400 /* Interrupt Control 0 */
39#define DDB_INTCTRL1 0x0404 /* Interrupt Control 1 */
40#define DDB_INTCTRL2 0x0408 /* Interrupt Control 2 */
41#define DDB_INTCTRL3 0x040c /* Interrupt Control 3 */
42
43#define DDB_INT0STAT 0x0420 /* INT0 Status [R] */
44#define DDB_INT1STAT 0x0428 /* INT1 Status [R] */
45#define DDB_INT2STAT 0x0430 /* INT2 Status [R] */
46#define DDB_INT3STAT 0x0438 /* INT3 Status [R] */
47#define DDB_INT4STAT 0x0440 /* INT4 Status [R] */
48#define DDB_NMISTAT 0x0450 /* NMI Status [R] */
49
50#define DDB_INTCLR32 0x0468 /* Interrupt Clear */
51
52#define DDB_INTPPES0 0x0470 /* PCI0 Interrupt Control */
53#define DDB_INTPPES1 0x0478 /* PCI1 Interrupt Control */
54
55#undef DDB_CPUSTAT /* duplicate in Vrc-5477 */
56#define DDB_CPUSTAT 0x0480 /* CPU Status [R] */
57#define DDB_BUSCTRL 0x0488 /* Internal Bus Control */
58
59
60/*
61 * Timer registers
62 */
63#define DDB_REFCTRL_L DDB_T0CTRL
64#define DDB_REFCTRL_H (DDB_T0CTRL+4)
65#define DDB_REFCNTR DDB_T0CNTR
66#define DDB_SPT0CTRL_L DDB_T1CTRL
67#define DDB_SPT0CTRL_H (DDB_T1CTRL+4)
68#define DDB_SPT1CTRL_L DDB_T2CTRL
69#define DDB_SPT1CTRL_H (DDB_T2CTRL+4)
70#define DDB_SPT1CNTR DDB_T1CTRL
71#define DDB_WDTCTRL_L DDB_T3CTRL
72#define DDB_WDTCTRL_H (DDB_T3CTRL+4)
73#define DDB_WDTCNTR DDB_T3CNTR
74
75/*
76 * DMA registers are moved. We don't care about it for now. TODO.
77 */
78
79/*
80 * BARs for ext PCI (PCI0)
81 */
82#undef DDB_BARC
83#undef DDB_BARB
84
85#define DDB_BARC0 0x0210 /* PCI0 Control */
86#define DDB_BARM010 0x0218 /* PCI0 SDRAM bank01 */
87#define DDB_BARM230 0x0220 /* PCI0 SDRAM bank23 */
88#define DDB_BAR00 0x0240 /* PCI0 LDCS0 */
89#define DDB_BAR10 0x0248 /* PCI0 LDCS1 */
90#define DDB_BAR20 0x0250 /* PCI0 LDCS2 */
91#define DDB_BAR30 0x0258 /* PCI0 LDCS3 */
92#define DDB_BAR40 0x0260 /* PCI0 LDCS4 */
93#define DDB_BAR50 0x0268 /* PCI0 LDCS5 */
94#define DDB_BARB0 0x0280 /* PCI0 BOOT */
95#define DDB_BARP00 0x0290 /* PCI0 for IOPCI Window0 */
96#define DDB_BARP10 0x0298 /* PCI0 for IOPCI Window1 */
97
98/*
99 * BARs for IOPIC (PCI1)
100 */
101#define DDB_BARC1 0x0610 /* PCI1 Control */
102#define DDB_BARM011 0x0618 /* PCI1 SDRAM bank01 */
103#define DDB_BARM231 0x0620 /* PCI1 SDRAM bank23 */
104#define DDB_BAR01 0x0640 /* PCI1 LDCS0 */
105#define DDB_BAR11 0x0648 /* PCI1 LDCS1 */
106#define DDB_BAR21 0x0650 /* PCI1 LDCS2 */
107#define DDB_BAR31 0x0658 /* PCI1 LDCS3 */
108#define DDB_BAR41 0x0660 /* PCI1 LDCS4 */
109#define DDB_BAR51 0x0668 /* PCI1 LDCS5 */
110#define DDB_BARB1 0x0680 /* PCI1 BOOT */
111#define DDB_BARP01 0x0690 /* PCI1 for ext PCI Window0 */
112#define DDB_BARP11 0x0698 /* PCI1 for ext PCI Window1 */
113
114/*
115 * Other registers for ext PCI (PCI0)
116 */
117#define DDB_PCIINIT00 0x02f0 /* PCI0 Initiator 0 */
118#define DDB_PCIINIT10 0x02f8 /* PCI0 Initiator 1 */
119
120#define DDB_PCISWP0 0x02b0 /* PCI0 Swap */
121#define DDB_PCIERR0 0x02b8 /* PCI0 Error */
122
123#define DDB_PCICTL0_L 0x02e0 /* PCI0 Control-L */
124#define DDB_PCICTL0_H 0x02e4 /* PCI0 Control-H */
125#define DDB_PCIARB0_L 0x02e8 /* PCI0 Arbitration-L */
126#define DDB_PCIARB0_H 0x02ec /* PCI0 Arbitration-H */
127
128/*
129 * Other registers for IOPCI (PCI1)
130 */
131#define DDB_IOPCIW0 0x00d0 /* PCI Address Window 0 [R/W] */
132#define DDB_IOPCIW1 0x00d8 /* PCI Address Window 1 [R/W] */
133
134#define DDB_PCIINIT01 0x06f0 /* PCI1 Initiator 0 */
135#define DDB_PCIINIT11 0x06f8 /* PCI1 Initiator 1 */
136
137#define DDB_PCISWP1 0x06b0 /* PCI1 Swap */
138#define DDB_PCIERR1 0x06b8 /* PCI1 Error */
139
140#define DDB_PCICTL1_L 0x06e0 /* PCI1 Control-L */
141#define DDB_PCICTL1_H 0x06e4 /* PCI1 Control-H */
142#define DDB_PCIARB1_L 0x06e8 /* PCI1 Arbitration-L */
143#define DDB_PCIARB1_H 0x06ec /* PCI1 Arbitration-H */
144
145/*
146 * Local Bus
147 */
148#define DDB_LCST0 0x0110 /* LB Chip Select Timing 0 */
149#define DDB_LCST1 0x0118 /* LB Chip Select Timing 1 */
150#undef DDB_LCST2
151#define DDB_LCST2 0x0120 /* LB Chip Select Timing 2 */
152#undef DDB_LCST3
153#undef DDB_LCST4
154#undef DDB_LCST5
155#undef DDB_LCST6
156#undef DDB_LCST7
157#undef DDB_LCST8
158#define DDB_ERRADR 0x0150 /* Error Address Register */
159#define DDB_ERRCS 0x0160
160#define DDB_BTM 0x0170 /* Boot Time Mode value */
161
162/*
163 * MISC registers
164 */
165#define DDB_GIUFUNSEL 0x4040 /* select dual-func pins */
166#define DDB_PIBMISC 0x0750 /* USB buffer enable / power saving */
167
168/*
169 * Memory map (physical address)
170 *
171 * Note most of the following address must be properly aligned by the
172 * corresponding size. For example, if PCI_IO_SIZE is 16MB, then
173 * PCI_IO_BASE must be aligned along 16MB boundary.
174 */
175
176/* the actual ram size is detected at run-time */
177#define DDB_SDRAM_BASE 0x00000000
178#define DDB_MAX_SDRAM_SIZE 0x08000000 /* less than 128MB */
179
180#define DDB_PCI0_MEM_BASE 0x08000000
181#define DDB_PCI0_MEM_SIZE 0x08000000 /* 128 MB */
182
183#define DDB_PCI1_MEM_BASE 0x10000000
184#define DDB_PCI1_MEM_SIZE 0x08000000 /* 128 MB */
185
186#define DDB_PCI0_CONFIG_BASE 0x18000000
187#define DDB_PCI0_CONFIG_SIZE 0x01000000 /* 16 MB */
188
189#define DDB_PCI1_CONFIG_BASE 0x19000000
190#define DDB_PCI1_CONFIG_SIZE 0x01000000 /* 16 MB */
191
192#define DDB_PCI_IO_BASE 0x1a000000 /* we concatenate two IOs */
193#define DDB_PCI0_IO_BASE 0x1a000000
194#define DDB_PCI0_IO_SIZE 0x01000000 /* 16 MB */
195#define DDB_PCI1_IO_BASE 0x1b000000
196#define DDB_PCI1_IO_SIZE 0x01000000 /* 16 MB */
197
198#define DDB_LCS0_BASE 0x1c000000 /* flash memory */
199#define DDB_LCS0_SIZE 0x01000000 /* 16 MB */
200
201#define DDB_LCS1_BASE 0x1d000000 /* misc */
202#define DDB_LCS1_SIZE 0x01000000 /* 16 MB */
203
204#define DDB_LCS2_BASE 0x1e000000 /* Mezzanine */
205#define DDB_LCS2_SIZE 0x01000000 /* 16 MB */
206
207#define DDB_VRC5477_BASE 0x1fa00000 /* VRC5477 control regs */
208#define DDB_VRC5477_SIZE 0x00200000 /* 2MB */
209
210#define DDB_BOOTCS_BASE 0x1fc00000 /* Boot ROM / EPROM /Flash */
211#define DDB_BOOTCS_SIZE 0x00200000 /* 2 MB - doc says 4MB */
212
213#define DDB_LED DDB_LCS1_BASE + 0x10000
214
215
216/*
217 * DDB5477 specific functions
218 */
219#ifndef __ASSEMBLY__
220extern void ddb5477_irq_setup(void);
221
222/* route irq to cpu int pin */
223extern void ll_vrc5477_irq_route(int vrc5477_irq, int ip);
224
225/* low-level routine for enabling vrc5477 irq, bypassing high-level */
226extern void ll_vrc5477_irq_enable(int vrc5477_irq);
227extern void ll_vrc5477_irq_disable(int vrc5477_irq);
228#endif /* !__ASSEMBLY__ */
229
230/* PCI intr ack share PCIW0 with PCI IO */
231#define DDB_PCI_IACK_BASE DDB_PCI_IO_BASE
232
233/*
234 * Interrupt mapping
235 *
236 * We have three interrupt controllers:
237 *
238 * . CPU itself - 8 sources
239 * . i8259 - 16 sources
240 * . vrc5477 - 32 sources
241 *
242 * They connected as follows:
243 * all vrc5477 interrupts are routed to cpu IP2 (by software setting)
244 * all i8359 are routed to INTC in vrc5477 (by hardware connection)
245 *
246 * All VRC5477 PCI interrupts are level-triggered (no ack needed).
247 * All PCI irq but INTC are active low.
248 */
249
250/*
251 * irq number block assignment
252 */
253
254#define NUM_CPU_IRQ 8
255#define NUM_VRC5477_IRQ 32
256
257#define CPU_IRQ_BASE MIPS_CPU_IRQ_BASE
258#define VRC5477_IRQ_BASE (CPU_IRQ_BASE + NUM_CPU_IRQ)
259
260/*
261 * vrc5477 irq defs
262 */
263
264#define VRC5477_IRQ_CPCE (0 + VRC5477_IRQ_BASE) /* cpu parity error */
265#define VRC5477_IRQ_CNTD (1 + VRC5477_IRQ_BASE) /* cpu no target */
266#define VRC5477_IRQ_I2C (2 + VRC5477_IRQ_BASE) /* I2C */
267#define VRC5477_IRQ_DMA (3 + VRC5477_IRQ_BASE) /* DMA */
268#define VRC5477_IRQ_UART0 (4 + VRC5477_IRQ_BASE)
269#define VRC5477_IRQ_WDOG (5 + VRC5477_IRQ_BASE) /* watchdog timer */
270#define VRC5477_IRQ_SPT1 (6 + VRC5477_IRQ_BASE) /* special purpose timer 1 */
271#define VRC5477_IRQ_LBRT (7 + VRC5477_IRQ_BASE) /* local bus read timeout */
272#define VRC5477_IRQ_INTA (8 + VRC5477_IRQ_BASE) /* PCI INT #A */
273#define VRC5477_IRQ_INTB (9 + VRC5477_IRQ_BASE) /* PCI INT #B */
274#define VRC5477_IRQ_INTC (10 + VRC5477_IRQ_BASE) /* PCI INT #C */
275#define VRC5477_IRQ_INTD (11 + VRC5477_IRQ_BASE) /* PCI INT #D */
276#define VRC5477_IRQ_INTE (12 + VRC5477_IRQ_BASE) /* PCI INT #E */
277#define VRC5477_IRQ_RESERVED_13 (13 + VRC5477_IRQ_BASE) /* reserved */
278#define VRC5477_IRQ_PCIS (14 + VRC5477_IRQ_BASE) /* PCI SERR # */
279#define VRC5477_IRQ_PCI (15 + VRC5477_IRQ_BASE) /* PCI internal error */
280#define VRC5477_IRQ_IOPCI_INTA (16 + VRC5477_IRQ_BASE) /* USB-H */
281#define VRC5477_IRQ_IOPCI_INTB (17 + VRC5477_IRQ_BASE) /* USB-P */
282#define VRC5477_IRQ_IOPCI_INTC (18 + VRC5477_IRQ_BASE) /* AC97 */
283#define VRC5477_IRQ_IOPCI_INTD (19 + VRC5477_IRQ_BASE) /* Reserved */
284#define VRC5477_IRQ_UART1 (20 + VRC5477_IRQ_BASE)
285#define VRC5477_IRQ_SPT0 (21 + VRC5477_IRQ_BASE) /* special purpose timer 0 */
286#define VRC5477_IRQ_GPT0 (22 + VRC5477_IRQ_BASE) /* general purpose timer 0 */
287#define VRC5477_IRQ_GPT1 (23 + VRC5477_IRQ_BASE) /* general purpose timer 1 */
288#define VRC5477_IRQ_GPT2 (24 + VRC5477_IRQ_BASE) /* general purpose timer 2 */
289#define VRC5477_IRQ_GPT3 (25 + VRC5477_IRQ_BASE) /* general purpose timer 3 */
290#define VRC5477_IRQ_GPIO (26 + VRC5477_IRQ_BASE)
291#define VRC5477_IRQ_SIO0 (27 + VRC5477_IRQ_BASE)
292#define VRC5477_IRQ_SIO1 (28 + VRC5477_IRQ_BASE)
293#define VRC5477_IRQ_RESERVED_29 (29 + VRC5477_IRQ_BASE) /* reserved */
294#define VRC5477_IRQ_IOPCISERR (30 + VRC5477_IRQ_BASE) /* IO PCI SERR # */
295#define VRC5477_IRQ_IOPCI (31 + VRC5477_IRQ_BASE)
296
297/*
298 * i2859 irq assignment
299 */
300#define I8259_IRQ_RESERVED_0 (0 + I8259A_IRQ_BASE)
301#define I8259_IRQ_KEYBOARD (1 + I8259A_IRQ_BASE) /* M1543 default */
302#define I8259_IRQ_CASCADE (2 + I8259A_IRQ_BASE)
303#define I8259_IRQ_UART_B (3 + I8259A_IRQ_BASE) /* M1543 default, may conflict with RTC according to schematic diagram */
304#define I8259_IRQ_UART_A (4 + I8259A_IRQ_BASE) /* M1543 default */
305#define I8259_IRQ_PARALLEL (5 + I8259A_IRQ_BASE) /* M1543 default */
306#define I8259_IRQ_RESERVED_6 (6 + I8259A_IRQ_BASE)
307#define I8259_IRQ_RESERVED_7 (7 + I8259A_IRQ_BASE)
308#define I8259_IRQ_RTC (8 + I8259A_IRQ_BASE) /* who set this? */
309#define I8259_IRQ_USB (9 + I8259A_IRQ_BASE) /* ddb_setup */
310#define I8259_IRQ_PMU (10 + I8259A_IRQ_BASE) /* ddb_setup */
311#define I8259_IRQ_RESERVED_11 (11 + I8259A_IRQ_BASE)
312#define I8259_IRQ_RESERVED_12 (12 + I8259A_IRQ_BASE) /* m1543_irq_setup */
313#define I8259_IRQ_RESERVED_13 (13 + I8259A_IRQ_BASE)
314#define I8259_IRQ_HDC1 (14 + I8259A_IRQ_BASE) /* default and ddb_setup */
315#define I8259_IRQ_HDC2 (15 + I8259A_IRQ_BASE) /* default */
316
317
318/*
319 * misc
320 */
321#define VRC5477_I8259_CASCADE (VRC5477_IRQ_INTC - VRC5477_IRQ_BASE)
322#define CPU_VRC5477_CASCADE 2
323
324/*
325 * debug routines
326 */
327#ifndef __ASSEMBLY__
328#if defined(CONFIG_RUNTIME_DEBUG)
329extern void vrc5477_show_pdar_regs(void);
330extern void vrc5477_show_pci_regs(void);
331extern void vrc5477_show_bar_regs(void);
332extern void vrc5477_show_int_regs(void);
333extern void vrc5477_show_all_regs(void);
334#endif
335
336/*
337 * RAM size
338 */
339extern int board_ram_size;
340#endif /* !__ASSEMBLY__ */
341
342#endif /* __ASM_DDB5XXX_DDB5477_H */
diff --git a/include/asm-mips/ddb5xxx/ddb5xxx.h b/include/asm-mips/ddb5xxx/ddb5xxx.h
deleted file mode 100644
index e97fcc8d548b..000000000000
--- a/include/asm-mips/ddb5xxx/ddb5xxx.h
+++ /dev/null
@@ -1,263 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: jsun@mvista.com or jsun@junsun.net
4 *
5 * Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
6 * Sony Software Development Center Europe (SDCE), Brussels
7 *
8 * include/asm-mips/ddb5xxx/ddb5xxx.h
9 * Common header for all NEC DDB 5xxx boards, including 5074, 5476, 5477.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 */
17
18#ifndef __ASM_DDB5XXX_DDB5XXX_H
19#define __ASM_DDB5XXX_DDB5XXX_H
20
21#include <linux/types.h>
22
23/*
24 * This file is based on the following documentation:
25 *
26 * NEC Vrc 5074 System Controller Data Sheet, June 1998
27 *
28 * [jsun] It is modified so that this file only contains the macros
29 * that are true for all DDB 5xxx boards. The modification is based on
30 *
31 * uPD31577(VRC5477) VR5432-SDRAM/PCI Bridge (Luke)
32 * Preliminary Specification Decoment, Rev 1.1, 27 Dec, 2000
33 *
34 */
35
36
37#define DDB_BASE 0xbfa00000
38#define DDB_SIZE 0x00200000 /* 2 MB */
39
40
41/*
42 * Physical Device Address Registers (PDARs)
43 */
44
45#define DDB_SDRAM0 0x0000 /* SDRAM Bank 0 [R/W] */
46#define DDB_SDRAM1 0x0008 /* SDRAM Bank 1 [R/W] */
47#define DDB_DCS2 0x0010 /* Device Chip-Select 2 [R/W] */
48#define DDB_DCS3 0x0018 /* Device Chip-Select 3 [R/W] */
49#define DDB_DCS4 0x0020 /* Device Chip-Select 4 [R/W] */
50#define DDB_DCS5 0x0028 /* Device Chip-Select 5 [R/W] */
51#define DDB_DCS6 0x0030 /* Device Chip-Select 6 [R/W] */
52#define DDB_DCS7 0x0038 /* Device Chip-Select 7 [R/W] */
53#define DDB_DCS8 0x0040 /* Device Chip-Select 8 [R/W] */
54#define DDB_PCIW0 0x0060 /* PCI Address Window 0 [R/W] */
55#define DDB_PCIW1 0x0068 /* PCI Address Window 1 [R/W] */
56#define DDB_INTCS 0x0070 /* Controller Internal Registers and Devices */
57 /* [R/W] */
58#define DDB_BOOTCS 0x0078 /* Boot ROM Chip-Select [R/W] */
59/* Vrc5477 has two more, IOPCIW0, IOPCIW1 */
60
61/*
62 * CPU Interface Registers
63 */
64#define DDB_CPUSTAT 0x0080 /* CPU Status [R/W] */
65#define DDB_INTCTRL 0x0088 /* Interrupt Control [R/W] */
66#define DDB_INTSTAT0 0x0090 /* Interrupt Status 0 [R] */
67#define DDB_INTSTAT1 0x0098 /* Interrupt Status 1 and CPU Interrupt */
68 /* Enable [R/W] */
69#define DDB_INTCLR 0x00A0 /* Interrupt Clear [R/W] */
70#define DDB_INTPPES 0x00A8 /* PCI Interrupt Control [R/W] */
71
72
73/*
74 * Memory-Interface Registers
75 */
76#define DDB_MEMCTRL 0x00C0 /* Memory Control */
77#define DDB_ACSTIME 0x00C8 /* Memory Access Timing [R/W] */
78#define DDB_CHKERR 0x00D0 /* Memory Check Error Status [R] */
79
80
81/*
82 * PCI-Bus Registers
83 */
84#define DDB_PCICTRL 0x00E0 /* PCI Control [R/W] */
85#define DDB_PCIARB 0x00E8 /* PCI Arbiter [R/W] */
86#define DDB_PCIINIT0 0x00F0 /* PCI Master (Initiator) 0 [R/W] */
87#define DDB_PCIINIT1 0x00F8 /* PCI Master (Initiator) 1 [R/W] */
88#define DDB_PCIERR 0x00B8 /* PCI Error [R/W] */
89
90
91/*
92 * Local-Bus Registers
93 */
94#define DDB_LCNFG 0x0100 /* Local Bus Configuration [R/W] */
95#define DDB_LCST2 0x0110 /* Local Bus Chip-Select Timing 2 [R/W] */
96#define DDB_LCST3 0x0118 /* Local Bus Chip-Select Timing 3 [R/W] */
97#define DDB_LCST4 0x0120 /* Local Bus Chip-Select Timing 4 [R/W] */
98#define DDB_LCST5 0x0128 /* Local Bus Chip-Select Timing 5 [R/W] */
99#define DDB_LCST6 0x0130 /* Local Bus Chip-Select Timing 6 [R/W] */
100#define DDB_LCST7 0x0138 /* Local Bus Chip-Select Timing 7 [R/W] */
101#define DDB_LCST8 0x0140 /* Local Bus Chip-Select Timing 8 [R/W] */
102#define DDB_DCSFN 0x0150 /* Device Chip-Select Muxing and Output */
103 /* Enables [R/W] */
104#define DDB_DCSIO 0x0158 /* Device Chip-Selects As I/O Bits [R/W] */
105#define DDB_BCST 0x0178 /* Local Boot Chip-Select Timing [R/W] */
106
107
108/*
109 * DMA Registers
110 */
111#define DDB_DMACTRL0 0x0180 /* DMA Control 0 [R/W] */
112#define DDB_DMASRCA0 0x0188 /* DMA Source Address 0 [R/W] */
113#define DDB_DMADESA0 0x0190 /* DMA Destination Address 0 [R/W] */
114#define DDB_DMACTRL1 0x0198 /* DMA Control 1 [R/W] */
115#define DDB_DMASRCA1 0x01A0 /* DMA Source Address 1 [R/W] */
116#define DDB_DMADESA1 0x01A8 /* DMA Destination Address 1 [R/W] */
117
118
119/*
120 * Timer Registers
121 */
122#define DDB_T0CTRL 0x01C0 /* SDRAM Refresh Control [R/W] */
123#define DDB_T0CNTR 0x01C8 /* SDRAM Refresh Counter [R/W] */
124#define DDB_T1CTRL 0x01D0 /* CPU-Bus Read Time-Out Control [R/W] */
125#define DDB_T1CNTR 0x01D8 /* CPU-Bus Read Time-Out Counter [R/W] */
126#define DDB_T2CTRL 0x01E0 /* General-Purpose Timer Control [R/W] */
127#define DDB_T2CNTR 0x01E8 /* General-Purpose Timer Counter [R/W] */
128#define DDB_T3CTRL 0x01F0 /* Watchdog Timer Control [R/W] */
129#define DDB_T3CNTR 0x01F8 /* Watchdog Timer Counter [R/W] */
130
131
132/*
133 * PCI Configuration Space Registers
134 */
135#define DDB_PCI_BASE 0x0200
136
137#define DDB_VID 0x0200 /* PCI Vendor ID [R] */
138#define DDB_DID 0x0202 /* PCI Device ID [R] */
139#define DDB_PCICMD 0x0204 /* PCI Command [R/W] */
140#define DDB_PCISTS 0x0206 /* PCI Status [R/W] */
141#define DDB_REVID 0x0208 /* PCI Revision ID [R] */
142#define DDB_CLASS 0x0209 /* PCI Class Code [R] */
143#define DDB_CLSIZ 0x020C /* PCI Cache Line Size [R/W] */
144#define DDB_MLTIM 0x020D /* PCI Latency Timer [R/W] */
145#define DDB_HTYPE 0x020E /* PCI Header Type [R] */
146#define DDB_BIST 0x020F /* BIST [R] (unimplemented) */
147#define DDB_BARC 0x0210 /* PCI Base Address Register Control [R/W] */
148#define DDB_BAR0 0x0218 /* PCI Base Address Register 0 [R/W] */
149#define DDB_BAR1 0x0220 /* PCI Base Address Register 1 [R/W] */
150#define DDB_CIS 0x0228 /* PCI Cardbus CIS Pointer [R] */
151 /* (unimplemented) */
152#define DDB_SSVID 0x022C /* PCI Sub-System Vendor ID [R/W] */
153#define DDB_SSID 0x022E /* PCI Sub-System ID [R/W] */
154#define DDB_ROM 0x0230 /* Expansion ROM Base Address [R] */
155 /* (unimplemented) */
156#define DDB_INTLIN 0x023C /* PCI Interrupt Line [R/W] */
157#define DDB_INTPIN 0x023D /* PCI Interrupt Pin [R] */
158#define DDB_MINGNT 0x023E /* PCI Min_Gnt [R] (unimplemented) */
159#define DDB_MAXLAT 0x023F /* PCI Max_Lat [R] (unimplemented) */
160#define DDB_BAR2 0x0240 /* PCI Base Address Register 2 [R/W] */
161#define DDB_BAR3 0x0248 /* PCI Base Address Register 3 [R/W] */
162#define DDB_BAR4 0x0250 /* PCI Base Address Register 4 [R/W] */
163#define DDB_BAR5 0x0258 /* PCI Base Address Register 5 [R/W] */
164#define DDB_BAR6 0x0260 /* PCI Base Address Register 6 [R/W] */
165#define DDB_BAR7 0x0268 /* PCI Base Address Register 7 [R/W] */
166#define DDB_BAR8 0x0270 /* PCI Base Address Register 8 [R/W] */
167#define DDB_BARB 0x0278 /* PCI Base Address Register BOOT [R/W] */
168
169
170/*
171 * Nile 4 Register Access
172 */
173
174static inline void ddb_sync(void)
175{
176 volatile u32 *p = (volatile u32 *)0xbfc00000;
177 (void)(*p);
178}
179
180static inline void ddb_out32(u32 offset, u32 val)
181{
182 *(volatile u32 *)(DDB_BASE+offset) = val;
183 ddb_sync();
184}
185
186static inline u32 ddb_in32(u32 offset)
187{
188 u32 val = *(volatile u32 *)(DDB_BASE+offset);
189 ddb_sync();
190 return val;
191}
192
193static inline void ddb_out16(u32 offset, u16 val)
194{
195 *(volatile u16 *)(DDB_BASE+offset) = val;
196 ddb_sync();
197}
198
199static inline u16 ddb_in16(u32 offset)
200{
201 u16 val = *(volatile u16 *)(DDB_BASE+offset);
202 ddb_sync();
203 return val;
204}
205
206static inline void ddb_out8(u32 offset, u8 val)
207{
208 *(volatile u8 *)(DDB_BASE+offset) = val;
209 ddb_sync();
210}
211
212static inline u8 ddb_in8(u32 offset)
213{
214 u8 val = *(volatile u8 *)(DDB_BASE+offset);
215 ddb_sync();
216 return val;
217}
218
219
220/*
221 * Physical Device Address Registers
222 */
223
224extern u32
225ddb_calc_pdar(u32 phys, u32 size, int width, int on_memory_bus, int pci_visible);
226extern void
227ddb_set_pdar(u32 pdar, u32 phys, u32 size, int width,
228 int on_memory_bus, int pci_visible);
229
230/*
231 * PCI Master Registers
232 */
233
234#define DDB_PCICMD_IACK 0 /* PCI Interrupt Acknowledge */
235#define DDB_PCICMD_IO 1 /* PCI I/O Space */
236#define DDB_PCICMD_MEM 3 /* PCI Memory Space */
237#define DDB_PCICMD_CFG 5 /* PCI Configuration Space */
238
239/*
240 * additional options for pci init reg (no shifting needed)
241 */
242#define DDB_PCI_CFGTYPE1 0x200 /* for pci init0/1 regs */
243#define DDB_PCI_ACCESS_32 0x10 /* for pci init0/1 regs */
244
245
246extern void ddb_set_pmr(u32 pmr, u32 type, u32 addr, u32 options);
247
248/*
249 * we need to reset pci bus when we start up and shutdown
250 */
251extern void ddb_pci_reset_bus(void);
252
253
254/*
255 * include the board dependent part
256 */
257#if defined(CONFIG_DDB5477)
258#include <asm/ddb5xxx/ddb5477.h>
259#else
260#error "Unknown DDB board!"
261#endif
262
263#endif /* __ASM_DDB5XXX_DDB5XXX_H */
diff --git a/include/asm-mips/edac.h b/include/asm-mips/edac.h
new file mode 100644
index 000000000000..83719eee2d13
--- /dev/null
+++ b/include/asm-mips/edac.h
@@ -0,0 +1,35 @@
1#ifndef ASM_EDAC_H
2#define ASM_EDAC_H
3
4/* ECC atomic, DMA, SMP and interrupt safe scrub function */
5
6static inline void atomic_scrub(void *va, u32 size)
7{
8 unsigned long *virt_addr = va;
9 unsigned long temp;
10 u32 i;
11
12 for (i = 0; i < size / sizeof(unsigned long); i++, virt_addr++) {
13
14 /*
15 * Very carefully read and write to memory atomically
16 * so we are interrupt, DMA and SMP safe.
17 *
18 * Intel: asm("lock; addl $0, %0"::"m"(*virt_addr));
19 */
20
21 __asm__ __volatile__ (
22 " .set mips3 \n"
23 "1: ll %0, %1 # atomic_add \n"
24 " ll %0, %1 # atomic_add \n"
25 " addu %0, $0 \n"
26 " sc %0, %1 \n"
27 " beqz %0, 1b \n"
28 " .set mips0 \n"
29 : "=&r" (temp), "=m" (*virt_addr)
30 : "m" (*virt_addr));
31
32 }
33}
34
35#endif
diff --git a/include/asm-mips/elf.h b/include/asm-mips/elf.h
index ebd6bfb19d66..e7d95d48177d 100644
--- a/include/asm-mips/elf.h
+++ b/include/asm-mips/elf.h
@@ -265,7 +265,7 @@ do { \
265#ifdef CONFIG_MIPS32_N32 265#ifdef CONFIG_MIPS32_N32
266#define __SET_PERSONALITY32_N32() \ 266#define __SET_PERSONALITY32_N32() \
267 do { \ 267 do { \
268 current->thread.mflags |= MF_N32; \ 268 set_thread_flag(TIF_32BIT_ADDR); \
269 current->thread.abi = &mips_abi_n32; \ 269 current->thread.abi = &mips_abi_n32; \
270 } while (0) 270 } while (0)
271#else 271#else
@@ -276,7 +276,8 @@ do { \
276#ifdef CONFIG_MIPS32_O32 276#ifdef CONFIG_MIPS32_O32
277#define __SET_PERSONALITY32_O32() \ 277#define __SET_PERSONALITY32_O32() \
278 do { \ 278 do { \
279 current->thread.mflags |= MF_O32; \ 279 set_thread_flag(TIF_32BIT_REGS); \
280 set_thread_flag(TIF_32BIT_ADDR); \
280 current->thread.abi = &mips_abi_32; \ 281 current->thread.abi = &mips_abi_32; \
281 } while (0) 282 } while (0)
282#else 283#else
@@ -299,13 +300,13 @@ do { \
299 300
300#define SET_PERSONALITY(ex, ibcs2) \ 301#define SET_PERSONALITY(ex, ibcs2) \
301do { \ 302do { \
302 current->thread.mflags &= ~MF_ABI_MASK; \ 303 clear_thread_flag(TIF_32BIT_REGS); \
304 clear_thread_flag(TIF_32BIT_ADDR); \
305 \
303 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \ 306 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
304 __SET_PERSONALITY32(ex); \ 307 __SET_PERSONALITY32(ex); \
305 else { \ 308 else \
306 current->thread.mflags |= MF_N64; \
307 current->thread.abi = &mips_abi; \ 309 current->thread.abi = &mips_abi; \
308 } \
309 \ 310 \
310 if (ibcs2) \ 311 if (ibcs2) \
311 set_personality(PER_SVR4); \ 312 set_personality(PER_SVR4); \
diff --git a/include/asm-mips/hazards.h b/include/asm-mips/hazards.h
index d9119f43f9aa..918a4894b587 100644
--- a/include/asm-mips/hazards.h
+++ b/include/asm-mips/hazards.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2003, 2004 Ralf Baechle <ralf@linux-mips.org> 6 * Copyright (C) 2003, 04, 07 Ralf Baechle <ralf@linux-mips.org>
7 * Copyright (C) MIPS Technologies, Inc. 7 * Copyright (C) MIPS Technologies, Inc.
8 * written by Ralf Baechle <ralf@linux-mips.org> 8 * written by Ralf Baechle <ralf@linux-mips.org>
9 */ 9 */
@@ -23,6 +23,11 @@ static inline void name(void) \
23 __asm__ __volatile__ (#name); \ 23 __asm__ __volatile__ (#name); \
24} 24}
25 25
26/*
27 * MIPS R2 instruction hazard barrier. Needs to be called as a subroutine.
28 */
29extern void mips_ihb(void);
30
26#endif 31#endif
27 32
28ASMMACRO(_ssnop, 33ASMMACRO(_ssnop,
diff --git a/include/asm-mips/mach-tx49xx/cpu-feature-overrides.h b/include/asm-mips/mach-tx49xx/cpu-feature-overrides.h
new file mode 100644
index 000000000000..275eaf92c748
--- /dev/null
+++ b/include/asm-mips/mach-tx49xx/cpu-feature-overrides.h
@@ -0,0 +1,23 @@
1#ifndef __ASM_MACH_TX49XX_CPU_FEATURE_OVERRIDES_H
2#define __ASM_MACH_TX49XX_CPU_FEATURE_OVERRIDES_H
3
4#define cpu_has_llsc 1
5#define cpu_has_64bits 1
6#define cpu_has_inclusive_pcaches 0
7
8#define cpu_has_mips16 0
9#define cpu_has_mdmx 0
10#define cpu_has_mips3d 0
11#define cpu_has_smartmips 0
12#define cpu_has_vtag_icache 0
13#define cpu_has_ic_fills_f_dc 0
14#define cpu_has_dsp 0
15#define cpu_has_mipsmt 0
16#define cpu_has_userlocal 0
17
18#define cpu_has_mips32r1 0
19#define cpu_has_mips32r2 0
20#define cpu_has_mips64r1 0
21#define cpu_has_mips64r2 0
22
23#endif /* __ASM_MACH_TX49XX_CPU_FEATURE_OVERRIDES_H */
diff --git a/include/asm-mips/mach-tx49xx/kmalloc.h b/include/asm-mips/mach-tx49xx/kmalloc.h
new file mode 100644
index 000000000000..913ff196259d
--- /dev/null
+++ b/include/asm-mips/mach-tx49xx/kmalloc.h
@@ -0,0 +1,8 @@
1#ifndef __ASM_MACH_TX49XX_KMALLOC_H
2#define __ASM_MACH_TX49XX_KMALLOC_H
3
4/*
5 * All happy, no need to define ARCH_KMALLOC_MINALIGN
6 */
7
8#endif /* __ASM_MACH_TX49XX_KMALLOC_H */
diff --git a/include/asm-mips/mips-boards/generic.h b/include/asm-mips/mips-boards/generic.h
index c8ebcc3e1267..d58977483534 100644
--- a/include/asm-mips/mips-boards/generic.h
+++ b/include/asm-mips/mips-boards/generic.h
@@ -67,6 +67,7 @@
67#define MIPS_REVISION_CORID_CORE_FPGAR2 8 67#define MIPS_REVISION_CORID_CORE_FPGAR2 8
68#define MIPS_REVISION_CORID_CORE_FPGA3 9 68#define MIPS_REVISION_CORID_CORE_FPGA3 9
69#define MIPS_REVISION_CORID_CORE_24K 10 69#define MIPS_REVISION_CORID_CORE_24K 10
70#define MIPS_REVISION_CORID_CORE_FPGA4 11
70 71
71/**** Artificial corid defines ****/ 72/**** Artificial corid defines ****/
72/* 73/*
diff --git a/include/asm-mips/mips_mt.h b/include/asm-mips/mips_mt.h
index 8045abc78d0f..ac7935203f89 100644
--- a/include/asm-mips/mips_mt.h
+++ b/include/asm-mips/mips_mt.h
@@ -8,6 +8,12 @@
8 8
9#include <linux/cpumask.h> 9#include <linux/cpumask.h>
10 10
11/*
12 * How many VPEs and TCs is Linux allowed to use? 0 means no limit.
13 */
14extern int tclimit;
15extern int vpelimit;
16
11extern cpumask_t mt_fpu_cpumask; 17extern cpumask_t mt_fpu_cpumask;
12extern unsigned long mt_fpemul_threshold; 18extern unsigned long mt_fpemul_threshold;
13 19
diff --git a/include/asm-mips/pmon.h b/include/asm-mips/pmon.h
index 260f3448ccf1..6ad519189ce2 100644
--- a/include/asm-mips/pmon.h
+++ b/include/asm-mips/pmon.h
@@ -22,7 +22,7 @@ struct callvectors {
22 char* (*gets) (char*); 22 char* (*gets) (char*);
23 union { 23 union {
24 int (*smpfork) (unsigned long cp, char *sp); 24 int (*smpfork) (unsigned long cp, char *sp);
25 int (*cpustart) (long, long, long, long); 25 int (*cpustart) (long, void (*)(void), void *, long);
26 } _s; 26 } _s;
27 int (*semlock) (int sem); 27 int (*semlock) (int sem);
28 void (*semunlock) (int sem); 28 void (*semunlock) (int sem);
diff --git a/include/asm-mips/processor.h b/include/asm-mips/processor.h
index 1d8b9a8ae324..83bc94534084 100644
--- a/include/asm-mips/processor.h
+++ b/include/asm-mips/processor.h
@@ -62,8 +62,9 @@ extern unsigned int vced_count, vcei_count;
62 * This decides where the kernel will search for a free chunk of vm 62 * This decides where the kernel will search for a free chunk of vm
63 * space during mmap's. 63 * space during mmap's.
64 */ 64 */
65#define TASK_UNMAPPED_BASE ((current->thread.mflags & MF_32BIT_ADDR) ? \ 65#define TASK_UNMAPPED_BASE \
66 PAGE_ALIGN(TASK_SIZE32 / 3) : PAGE_ALIGN(TASK_SIZE / 3)) 66 (test_thread_flag(TIF_32BIT_ADDR) ? \
67 PAGE_ALIGN(TASK_SIZE32 / 3) : PAGE_ALIGN(TASK_SIZE / 3))
67#endif 68#endif
68 69
69#define NUM_FPU_REGS 32 70#define NUM_FPU_REGS 32
@@ -132,22 +133,11 @@ struct thread_struct {
132 unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */ 133 unsigned long cp0_baduaddr; /* Last kernel fault accessing USEG */
133 unsigned long error_code; 134 unsigned long error_code;
134 unsigned long trap_no; 135 unsigned long trap_no;
135#define MF_FIXADE 1 /* Fix address errors in software */
136#define MF_LOGADE 2 /* Log address errors to syslog */
137#define MF_32BIT_REGS 4 /* also implies 16/32 fprs */
138#define MF_32BIT_ADDR 8 /* 32-bit address space (o32/n32) */
139#define MF_FPUBOUND 0x10 /* thread bound to FPU-full CPU set */
140 unsigned long mflags;
141 unsigned long irix_trampoline; /* Wheee... */ 136 unsigned long irix_trampoline; /* Wheee... */
142 unsigned long irix_oldctx; 137 unsigned long irix_oldctx;
143 struct mips_abi *abi; 138 struct mips_abi *abi;
144}; 139};
145 140
146#define MF_ABI_MASK (MF_32BIT_REGS | MF_32BIT_ADDR)
147#define MF_O32 (MF_32BIT_REGS | MF_32BIT_ADDR)
148#define MF_N32 MF_32BIT_ADDR
149#define MF_N64 0
150
151#ifdef CONFIG_MIPS_MT_FPAFF 141#ifdef CONFIG_MIPS_MT_FPAFF
152#define FPAFF_INIT \ 142#define FPAFF_INIT \
153 .emulated_fp = 0, \ 143 .emulated_fp = 0, \
@@ -200,10 +190,6 @@ struct thread_struct {
200 .cp0_baduaddr = 0, \ 190 .cp0_baduaddr = 0, \
201 .error_code = 0, \ 191 .error_code = 0, \
202 .trap_no = 0, \ 192 .trap_no = 0, \
203 /* \
204 * For now the default is to fix address errors \
205 */ \
206 .mflags = MF_FIXADE, \
207 .irix_trampoline = 0, \ 193 .irix_trampoline = 0, \
208 .irix_oldctx = 0, \ 194 .irix_oldctx = 0, \
209} 195}
diff --git a/include/asm-mips/seccomp.h b/include/asm-mips/seccomp.h
new file mode 100644
index 000000000000..36ed44070256
--- /dev/null
+++ b/include/asm-mips/seccomp.h
@@ -0,0 +1,37 @@
1#ifndef __ASM_SECCOMP_H
2
3#include <linux/thread_info.h>
4#include <linux/unistd.h>
5
6#define __NR_seccomp_read __NR_read
7#define __NR_seccomp_write __NR_write
8#define __NR_seccomp_exit __NR_exit
9#define __NR_seccomp_sigreturn __NR_rt_sigreturn
10
11/*
12 * Kludge alert:
13 *
14 * The generic seccomp code currently allows only a single compat ABI. Until
15 * this is fixed we priorize O32 as the compat ABI over N32.
16 */
17#ifdef CONFIG_MIPS32_O32
18
19#define TIF_32BIT TIF_32BIT_REGS
20
21#define __NR_seccomp_read_32 4003
22#define __NR_seccomp_write_32 4004
23#define __NR_seccomp_exit_32 4001
24#define __NR_seccomp_sigreturn_32 4193 /* rt_sigreturn */
25
26#elif defined(CONFIG_MIPS32_N32)
27
28#define TIF_32BIT _TIF_32BIT_ADDR
29
30#define __NR_seccomp_read_32 6000
31#define __NR_seccomp_write_32 6001
32#define __NR_seccomp_exit_32 6058
33#define __NR_seccomp_sigreturn_32 6211 /* rt_sigreturn */
34
35#endif /* CONFIG_MIPS32_O32 */
36
37#endif /* __ASM_SECCOMP_H */
diff --git a/include/asm-mips/system.h b/include/asm-mips/system.h
index 8d0b1cd4a45e..357251f42518 100644
--- a/include/asm-mips/system.h
+++ b/include/asm-mips/system.h
@@ -46,10 +46,12 @@ struct task_struct;
46 46
47#define __mips_mt_fpaff_switch_to(prev) \ 47#define __mips_mt_fpaff_switch_to(prev) \
48do { \ 48do { \
49 struct thread_info *__prev_ti = task_thread_info(prev); \
50 \
49 if (cpu_has_fpu && \ 51 if (cpu_has_fpu && \
50 (prev->thread.mflags & MF_FPUBOUND) && \ 52 test_ti_thread_flag(__prev_ti, TIF_FPUBOUND) && \
51 (!(KSTK_STATUS(prev) & ST0_CU1))) { \ 53 (!(KSTK_STATUS(prev) & ST0_CU1))) { \
52 prev->thread.mflags &= ~MF_FPUBOUND; \ 54 clear_ti_thread_flag(__prev_ti, TIF_FPUBOUND); \
53 prev->cpus_allowed = prev->thread.user_cpus_allowed; \ 55 prev->cpus_allowed = prev->thread.user_cpus_allowed; \
54 } \ 56 } \
55 next->thread.emulated_fp = 0; \ 57 next->thread.emulated_fp = 0; \
diff --git a/include/asm-mips/thread_info.h b/include/asm-mips/thread_info.h
index fbcda8204473..b2772df1a1bd 100644
--- a/include/asm-mips/thread_info.h
+++ b/include/asm-mips/thread_info.h
@@ -46,7 +46,7 @@ struct thread_info {
46{ \ 46{ \
47 .task = &tsk, \ 47 .task = &tsk, \
48 .exec_domain = &default_exec_domain, \ 48 .exec_domain = &default_exec_domain, \
49 .flags = 0, \ 49 .flags = _TIF_FIXADE, \
50 .cpu = 0, \ 50 .cpu = 0, \
51 .preempt_count = 1, \ 51 .preempt_count = 1, \
52 .addr_limit = KERNEL_DS, \ 52 .addr_limit = KERNEL_DS, \
@@ -87,9 +87,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
87({ \ 87({ \
88 struct thread_info *ret; \ 88 struct thread_info *ret; \
89 \ 89 \
90 ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \ 90 ret = kzalloc(THREAD_SIZE, GFP_KERNEL); \
91 if (ret) \ 91 \
92 memset(ret, 0, THREAD_SIZE); \
93 ret; \ 92 ret; \
94}) 93})
95#else 94#else
@@ -109,20 +108,23 @@ register struct thread_info *__current_thread_info __asm__("$28");
109 * - pending work-to-be-done flags are in LSW 108 * - pending work-to-be-done flags are in LSW
110 * - other flags in MSW 109 * - other flags in MSW
111 */ 110 */
112#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 111#define TIF_SIGPENDING 1 /* signal pending */
113#define TIF_SIGPENDING 2 /* signal pending */ 112#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
114#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 113#define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */
115#define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */ 114#define TIF_SECCOMP 4 /* secure computing */
116#define TIF_SECCOMP 5 /* secure computing */
117#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ 115#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
118#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ 116#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
119#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 117#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
120#define TIF_MEMDIE 18 118#define TIF_MEMDIE 18
121#define TIF_FREEZE 19 119#define TIF_FREEZE 19
120#define TIF_FIXADE 20 /* Fix address errors in software */
121#define TIF_LOGADE 21 /* Log address errors to syslog */
122#define TIF_32BIT_REGS 22 /* also implies 16/32 fprs */
123#define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
124#define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
122#define TIF_SYSCALL_TRACE 31 /* syscall trace active */ 125#define TIF_SYSCALL_TRACE 31 /* syscall trace active */
123 126
124#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 127#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
125#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
126#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 128#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
127#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 129#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
128#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 130#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
@@ -131,6 +133,11 @@ register struct thread_info *__current_thread_info __asm__("$28");
131#define _TIF_USEDFPU (1<<TIF_USEDFPU) 133#define _TIF_USEDFPU (1<<TIF_USEDFPU)
132#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 134#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
133#define _TIF_FREEZE (1<<TIF_FREEZE) 135#define _TIF_FREEZE (1<<TIF_FREEZE)
136#define _TIF_FIXADE (1<<TIF_FIXADE)
137#define _TIF_LOGADE (1<<TIF_LOGADE)
138#define _TIF_32BIT_REGS (1<<TIF_32BIT_REGS)
139#define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
140#define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
134 141
135/* work to do on interrupt/exception return */ 142/* work to do on interrupt/exception return */
136#define _TIF_WORK_MASK (0x0000ffef & ~_TIF_SECCOMP) 143#define _TIF_WORK_MASK (0x0000ffef & ~_TIF_SECCOMP)
diff --git a/include/asm-mips/tx3912.h b/include/asm-mips/tx3912.h
deleted file mode 100644
index d709d87363d0..000000000000
--- a/include/asm-mips/tx3912.h
+++ /dev/null
@@ -1,361 +0,0 @@
1/*
2 * include/asm-mips/tx3912.h
3 *
4 * Copyright (C) 2001 Steven J. Hill (sjhill@realitydiluted.com)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Registers for TMPR3912/05 and PR31700 processors
11 */
12#ifndef _TX3912_H_
13#define _TX3912_H_
14
15/*****************************************************************************
16 * Clock Subsystem *
17 * --------------- *
18 * Chapter 6 in Philips PR31700 and Toshiba TMPR3905/12 User Manuals *
19 *****************************************************************************/
20#define TX3912_CLK_CTRL 0x01c0
21
22/*
23 * Clock control register values
24 */
25#define TX3912_CLK_CTRL_CHICLKDIV_MASK 0xff000000
26#define TX3912_CLK_CTRL_ENCLKTEST 0x00800000
27#define TX3912_CLK_CTRL_CLKTESTSELSIB 0x00400000
28#define TX3912_CLK_CTRL_CHIMCLKSEL 0x00200000
29#define TX3912_CLK_CTRL_CHICLKDIR 0x00100000
30#define TX3912_CLK_CTRL_ENCHIMCLK 0x00080000
31#define TX3912_CLK_CTRL_ENVIDCLK 0x00040000
32#define TX3912_CLK_CTRL_ENMBUSCLK 0x00020000
33#define TX3912_CLK_CTRL_ENSPICLK 0x00010000
34#define TX3912_CLK_CTRL_ENTIMERCLK 0x00008000
35#define TX3912_CLK_CTRL_ENFASTTIMERCLK 0x00004000
36#define TX3912_CLK_CTRL_SIBMCLKDIR 0x00002000
37#define TX3912_CLK_CTRL_reserved1 0x00001000
38#define TX3912_CLK_CTRL_ENSIBMCLK 0x00000800
39#define TX3912_CLK_CTRL_SIBMCLKDIV_6 0x00000600
40#define TX3912_CLK_CTRL_SIBMCLKDIV_5 0x00000500
41#define TX3912_CLK_CTRL_SIBMCLKDIV_4 0x00000400
42#define TX3912_CLK_CTRL_SIBMCLKDIV_3 0x00000300
43#define TX3912_CLK_CTRL_SIBMCLKDIV_2 0x00000200
44#define TX3912_CLK_CTRL_SIBMCLKDIV_1 0x00000100
45#define TX3912_CLK_CTRL_CSERSEL 0x00000080
46#define TX3912_CLK_CTRL_CSERDIV_6 0x00000060
47#define TX3912_CLK_CTRL_CSERDIV_5 0x00000050
48#define TX3912_CLK_CTRL_CSERDIV_4 0x00000040
49#define TX3912_CLK_CTRL_CSERDIV_3 0x00000030
50#define TX3912_CLK_CTRL_CSERDIV_2 0x00000020
51#define TX3912_CLK_CTRL_CSERDIV_1 0x00000010
52#define TX3912_CLK_CTRL_ENCSERCLK 0x00000008
53#define TX3912_CLK_CTRL_ENIRCLK 0x00000004
54#define TX3912_CLK_CTRL_ENUARTACLK 0x00000002
55#define TX3912_CLK_CTRL_ENUARTBCLK 0x00000001
56
57
58/*****************************************************************************
59 * Interrupt Subsystem *
60 * ------------------- *
61 * Chapter 8 in Philips PR31700 and Toshiba TMPR3905/12 User Manuals *
62 *****************************************************************************/
63#define TX3912_INT1_CLEAR 0x0100
64#define TX3912_INT2_CLEAR 0x0104
65#define TX3912_INT3_CLEAR 0x0108
66#define TX3912_INT4_CLEAR 0x010c
67#define TX3912_INT5_CLEAR 0x0110
68#define TX3912_INT1_ENABLE 0x0118
69#define TX3912_INT2_ENABLE 0x011c
70#define TX3912_INT3_ENABLE 0x0120
71#define TX3912_INT4_ENABLE 0x0124
72#define TX3912_INT5_ENABLE 0x0128
73#define TX3912_INT6_ENABLE 0x012c
74#define TX3912_INT1_STATUS 0x0100
75#define TX3912_INT2_STATUS 0x0104
76#define TX3912_INT3_STATUS 0x0108
77#define TX3912_INT4_STATUS 0x010c
78#define TX3912_INT5_STATUS 0x0110
79#define TX3912_INT6_STATUS 0x0114
80
81/*
82 * Interrupt 2 register values
83 */
84#define TX3912_INT2_UARTARXINT 0x80000000
85#define TX3912_INT2_UARTARXOVERRUNINT 0x40000000
86#define TX3912_INT2_UARTAFRAMEERRINT 0x20000000
87#define TX3912_INT2_UARTABREAKINT 0x10000000
88#define TX3912_INT2_UARTAPARITYINT 0x08000000
89#define TX3912_INT2_UARTATXINT 0x04000000
90#define TX3912_INT2_UARTATXOVERRUNINT 0x02000000
91#define TX3912_INT2_UARTAEMPTYINT 0x01000000
92#define TX3912_INT2_UARTADMAFULLINT 0x00800000
93#define TX3912_INT2_UARTADMAHALFINT 0x00400000
94#define TX3912_INT2_UARTBRXINT 0x00200000
95#define TX3912_INT2_UARTBRXOVERRUNINT 0x00100000
96#define TX3912_INT2_UARTBFRAMEERRINT 0x00080000
97#define TX3912_INT2_UARTBBREAKINT 0x00040000
98#define TX3912_INT2_UARTBPARITYINT 0x00020000
99#define TX3912_INT2_UARTBTXINT 0x00010000
100#define TX3912_INT2_UARTBTXOVERRUNINT 0x00008000
101#define TX3912_INT2_UARTBEMPTYINT 0x00004000
102#define TX3912_INT2_UARTBDMAFULLINT 0x00002000
103#define TX3912_INT2_UARTBDMAHALFINT 0x00001000
104#define TX3912_INT2_UARTA_RX_BITS 0xf8000000
105#define TX3912_INT2_UARTA_TX_BITS 0x07c00000
106#define TX3912_INT2_UARTB_RX_BITS 0x003e0000
107#define TX3912_INT2_UARTB_TX_BITS 0x0001f000
108
109/*
110 * Interrupt 5 register values
111 */
112#define TX3912_INT5_RTCINT 0x80000000
113#define TX3912_INT5_ALARMINT 0x40000000
114#define TX3912_INT5_PERINT 0x20000000
115#define TX3912_INT5_STPTIMERINT 0x10000000
116#define TX3912_INT5_POSPWRINT 0x08000000
117#define TX3912_INT5_NEGPWRINT 0x04000000
118#define TX3912_INT5_POSPWROKINT 0x02000000
119#define TX3912_INT5_NEGPWROKINT 0x01000000
120#define TX3912_INT5_POSONBUTINT 0x00800000
121#define TX3912_INT5_NEGONBUTINT 0x00400000
122#define TX3912_INT5_SPIBUFAVAILINT 0x00200000
123#define TX3912_INT5_SPIERRINT 0x00100000
124#define TX3912_INT5_SPIRCVINT 0x00080000
125#define TX3912_INT5_SPIEMPTYINT 0x00040000
126#define TX3912_INT5_IRCONSMINT 0x00020000
127#define TX3912_INT5_CARSTINT 0x00010000
128#define TX3912_INT5_POSCARINT 0x00008000
129#define TX3912_INT5_NEGCARINT 0x00004000
130#define TX3912_INT5_IOPOSINT6 0x00002000
131#define TX3912_INT5_IOPOSINT5 0x00001000
132#define TX3912_INT5_IOPOSINT4 0x00000800
133#define TX3912_INT5_IOPOSINT3 0x00000400
134#define TX3912_INT5_IOPOSINT2 0x00000200
135#define TX3912_INT5_IOPOSINT1 0x00000100
136#define TX3912_INT5_IOPOSINT0 0x00000080
137#define TX3912_INT5_IONEGINT6 0x00000040
138#define TX3912_INT5_IONEGINT5 0x00000020
139#define TX3912_INT5_IONEGINT4 0x00000010
140#define TX3912_INT5_IONEGINT3 0x00000008
141#define TX3912_INT5_IONEGINT2 0x00000004
142#define TX3912_INT5_IONEGINT1 0x00000002
143#define TX3912_INT5_IONEGINT0 0x00000001
144
145/*
146 * Interrupt 6 status register values
147 */
148#define TX3912_INT6_STATUS_IRQHIGH 0x80000000
149#define TX3912_INT6_STATUS_IRQLOW 0x40000000
150#define TX3912_INT6_STATUS_reserved6 0x3fffffc0
151#define TX3912_INT6_STATUS_INTVEC_POSNEGPWROKINT 0x0000003c
152#define TX3912_INT6_STATUS_INTVEC_ALARMINT 0x00000038
153#define TX3912_INT6_STATUS_INTVEC_PERINT 0x00000034
154#define TX3912_INT6_STATUS_INTVEC_reserved5 0x00000030
155#define TX3912_INT6_STATUS_INTVEC_UARTARXINT 0x0000002c
156#define TX3912_INT6_STATUS_INTVEC_UARTBRXINT 0x00000028
157#define TX3912_INT6_STATUS_INTVEC_reserved4 0x00000024
158#define TX3912_INT6_STATUS_INTVEC_IOPOSINT65 0x00000020
159#define TX3912_INT6_STATUS_INTVEC_reserved3 0x0000001c
160#define TX3912_INT6_STATUS_INTVEC_IONEGINT65 0x00000018
161#define TX3912_INT6_STATUS_INTVEC_reserved2 0x00000014
162#define TX3912_INT6_STATUS_INTVEC_SNDDMACNTINT 0x00000010
163#define TX3912_INT6_STATUS_INTVEC_TELDMACNTINT 0x0000000c
164#define TX3912_INT6_STATUS_INTVEC_CHIDMACNTINT 0x00000008
165#define TX3912_INT6_STATUS_INTVEC_IOPOSNEGINT0 0x00000004
166#define TX3912_INT6_STATUS_INTVEC_STDHANDLER 0x00000000
167#define TX3912_INT6_STATUS_reserved1 0x00000003
168
169/*
170 * Interrupt 6 enable register values
171 */
172#define TX3912_INT6_ENABLE_reserved5 0xfff80000
173#define TX3912_INT6_ENABLE_GLOBALEN 0x00040000
174#define TX3912_INT6_ENABLE_IRQPRITEST 0x00020000
175#define TX3912_INT6_ENABLE_IRQTEST 0x00010000
176#define TX3912_INT6_ENABLE_PRIORITYMASK_POSNEGPWROKINT 0x00008000
177#define TX3912_INT6_ENABLE_PRIORITYMASK_ALARMINT 0x00004000
178#define TX3912_INT6_ENABLE_PRIORITYMASK_PERINT 0x00002000
179#define TX3912_INT6_ENABLE_PRIORITYMASK_reserved4 0x00001000
180#define TX3912_INT6_ENABLE_PRIORITYMASK_UARTARXINT 0x00000800
181#define TX3912_INT6_ENABLE_PRIORITYMASK_UARTBRXINT 0x00000400
182#define TX3912_INT6_ENABLE_PRIORITYMASK_reserved3 0x00000200
183#define TX3912_INT6_ENABLE_PRIORITYMASK_IOPOSINT65 0x00000100
184#define TX3912_INT6_ENABLE_PRIORITYMASK_reserved2 0x00000080
185#define TX3912_INT6_ENABLE_PRIORITYMASK_IONEGINT65 0x00000040
186#define TX3912_INT6_ENABLE_PRIORITYMASK_reserved1 0x00000020
187#define TX3912_INT6_ENABLE_PRIORITYMASK_SNDDMACNTINT 0x00000010
188#define TX3912_INT6_ENABLE_PRIORITYMASK_TELDMACNTINT 0x00000008
189#define TX3912_INT6_ENABLE_PRIORITYMASK_CHIDMACNTINT 0x00000004
190#define TX3912_INT6_ENABLE_PRIORITYMASK_IOPOSNEGINT0 0x00000002
191#define TX3912_INT6_ENABLE_PRIORITYMASK_STDHANDLER 0x00000001
192#define TX3912_INT6_ENABLE_HIGH_PRIORITY 0x0000ffff
193
194
195/*****************************************************************************
196 * Power Subsystem *
197 * --------------- *
198 * Chapter 11 in Philips PR31700 User Manual *
199 * Chapter 12 in Toshiba TMPR3905/12 User Manual *
200 *****************************************************************************/
201#define TX3912_POWER_CTRL 0x01c4
202
203/*
204 * Power control register values
205 */
206#define TX3912_POWER_CTRL_ONBUTN 0x80000000
207#define TX3912_POWER_CTRL_PWRINT 0x40000000
208#define TX3912_POWER_CTRL_PWROK 0x20000000
209#define TX3912_POWER_CTRL_VIDRF_MASK 0x18000000
210#define TX3912_POWER_CTRL_SLOWBUS 0x04000000
211#define TX3912_POWER_CTRL_DIVMOD 0x02000000
212#define TX3912_POWER_CTRL_reserved2 0x01ff0000
213#define TX3912_POWER_CTRL_STPTIMERVAL_MASK 0x0000f000
214#define TX3912_POWER_CTRL_ENSTPTIMER 0x00000800
215#define TX3912_POWER_CTRL_ENFORCESHUTDWN 0x00000400
216#define TX3912_POWER_CTRL_FORCESHUTDWN 0x00000200
217#define TX3912_POWER_CTRL_FORCESHUTDWNOCC 0x00000100
218#define TX3912_POWER_CTRL_SELC2MS 0x00000080
219#define TX3912_POWER_CTRL_reserved1 0x00000040
220#define TX3912_POWER_CTRL_BPDBVCC3 0x00000020
221#define TX3912_POWER_CTRL_STOPCPU 0x00000010
222#define TX3912_POWER_CTRL_DBNCONBUTN 0x00000008
223#define TX3912_POWER_CTRL_COLDSTART 0x00000004
224#define TX3912_POWER_CTRL_PWRCS 0x00000002
225#define TX3912_POWER_CTRL_VCCON 0x00000001
226
227
228/*****************************************************************************
229 * Timer Subsystem *
230 * --------------- *
231 * Chapter 14 in Philips PR31700 User Manual *
232 * Chapter 15 in Toshiba TMPR3905/12 User Manual *
233 *****************************************************************************/
234#define TX3912_RTC_HIGH 0x0140
235#define TX3912_RTC_LOW 0x0144
236#define TX3912_RTC_ALARM_HIGH 0x0148
237#define TX3912_RTC_ALARM_LOW 0x014c
238#define TX3912_TIMER_CTRL 0x0150
239#define TX3912_TIMER_PERIOD 0x0154
240
241/*
242 * Timer control register values
243 */
244#define TX3912_TIMER_CTRL_FREEZEPRE 0x00000080
245#define TX3912_TIMER_CTRL_FREEZERTC 0x00000040
246#define TX3912_TIMER_CTRL_FREEZETIMER 0x00000020
247#define TX3912_TIMER_CTRL_ENPERTIMER 0x00000010
248#define TX3912_TIMER_CTRL_RTCCLEAR 0x00000008
249#define TX3912_TIMER_CTRL_TESTC8MS 0x00000004
250#define TX3912_TIMER_CTRL_ENTESTCLK 0x00000002
251#define TX3912_TIMER_CTRL_ENRTCTST 0x00000001
252
253/*
254 * The periodic timer has granularity of 868 nanoseconds which
255 * results in a count of (1.152 x 10^6 / 100) in order to achieve
256 * a 10 millisecond periodic system clock.
257 */
258#define TX3912_SYS_TIMER_VALUE (1152000/HZ)
259
260
261/*****************************************************************************
262 * UART Subsystem *
263 * -------------- *
264 * Chapter 15 in Philips PR31700 User Manual *
265 * Chapter 16 in Toshiba TMPR3905/12 User Manual *
266 *****************************************************************************/
267#define TX3912_UARTA_CTRL1 0x00b0
268#define TX3912_UARTA_CTRL2 0x00b4
269#define TX3912_UARTA_DMA_CTRL1 0x00b8
270#define TX3912_UARTA_DMA_CTRL2 0x00bc
271#define TX3912_UARTA_DMA_CNT 0x00c0
272#define TX3912_UARTA_DATA 0x00c4
273#define TX3912_UARTB_CTRL1 0x00c8
274#define TX3912_UARTB_CTRL2 0x00cc
275#define TX3912_UARTB_DMA_CTRL1 0x00d0
276#define TX3912_UARTB_DMA_CTRL2 0x00d4
277#define TX3912_UARTB_DMA_CNT 0x00d8
278#define TX3912_UARTB_DATA 0x00dc
279
280/*
281 * UART Control Register 1 values
282 */
283#define TX3912_UART_CTRL1_UARTON 0x80000000
284#define TX3912_UART_CTRL1_EMPTY 0x40000000
285#define TX3912_UART_CTRL1_PRXHOLDFULL 0x20000000
286#define TX3912_UART_CTRL1_RXHOLDFULL 0x10000000
287#define TX3912_UART_CTRL1_reserved1 0x0fff0000
288#define TX3912_UART_CTRL1_ENDMARX 0x00008000
289#define TX3912_UART_CTRL1_ENDMATX 0x00004000
290#define TX3912_UART_CTRL1_TESTMODE 0x00002000
291#define TX3912_UART_CTRL1_ENBREAKHALT 0x00001000
292#define TX3912_UART_CTRL1_ENDMATEST 0x00000800
293#define TX3912_UART_CTRL1_ENDMALOOP 0x00000400
294#define TX3912_UART_CTRL1_PULSEOPT1 0x00000200
295#define TX3912_UART_CTRL1_PULSEOPT1 0x00000100
296#define TX3912_UART_CTRL1_DTINVERT 0x00000080
297#define TX3912_UART_CTRL1_DISTXD 0x00000040
298#define TX3912_UART_CTRL1_TWOSTOP 0x00000020
299#define TX3912_UART_CTRL1_LOOPBACK 0x00000010
300#define TX3912_UART_CTRL1_BIT_7 0x00000008
301#define TX3912_UART_CTRL1_EVENPARITY 0x00000004
302#define TX3912_UART_CTRL1_ENPARITY 0x00000002
303#define TX3912_UART_CTRL1_ENUART 0x00000001
304
305/*
306 * UART Control Register 2 values
307 */
308#define TX3912_UART_CTRL2_B230400 0x0000 /* 0 */
309#define TX3912_UART_CTRL2_B115200 0x0001 /* 1 */
310#define TX3912_UART_CTRL2_B76800 0x0002 /* 2 */
311#define TX3912_UART_CTRL2_B57600 0x0003 /* 3 */
312#define TX3912_UART_CTRL2_B38400 0x0005 /* 5 */
313#define TX3912_UART_CTRL2_B19200 0x000b /* 11 */
314#define TX3912_UART_CTRL2_B9600 0x0016 /* 22 */
315#define TX3912_UART_CTRL2_B4800 0x002f /* 47 */
316#define TX3912_UART_CTRL2_B2400 0x005f /* 95 */
317#define TX3912_UART_CTRL2_B1200 0x00bf /* 191 */
318#define TX3912_UART_CTRL2_B600 0x017f /* 383 */
319#define TX3912_UART_CTRL2_B300 0x02ff /* 767 */
320
321/*****************************************************************************
322 * Video Subsystem *
323 * --------------- *
324 * Chapter 16 in Philips PR31700 User Manual *
325 * Chapter 17 in Toshiba TMPR3905/12 User Manual *
326 *****************************************************************************/
327#define TX3912_VIDEO_CTRL1 0x0028
328#define TX3912_VIDEO_CTRL2 0x002c
329#define TX3912_VIDEO_CTRL3 0x0030
330#define TX3912_VIDEO_CTRL4 0x0034
331#define TX3912_VIDEO_CTRL5 0x0038
332#define TX3912_VIDEO_CTRL6 0x003c
333#define TX3912_VIDEO_CTRL7 0x0040
334#define TX3912_VIDEO_CTRL8 0x0044
335#define TX3912_VIDEO_CTRL9 0x0048
336#define TX3912_VIDEO_CTRL10 0x004c
337#define TX3912_VIDEO_CTRL11 0x0050
338#define TX3912_VIDEO_CTRL12 0x0054
339#define TX3912_VIDEO_CTRL13 0x0058
340#define TX3912_VIDEO_CTRL14 0x005c
341
342/*
343 * Video Control Register 1 values
344 */
345#define TX3912_VIDEO_CTRL1_LINECNT 0xffc00000
346#define TX3912_VIDEO_CTRL1_LOADDLY 0x00200000
347#define TX3912_VIDEO_CTRL1_BAUDVAL 0x001f0000
348#define TX3912_VIDEO_CTRL1_VIDDONEVAL 0x0000fe00
349#define TX3912_VIDEO_CTRL1_ENFREEZEFRAME 0x00000100
350#define TX3912_VIDEO_CTRL1_BITSEL_MASK 0x000000c0
351#define TX3912_VIDEO_CTRL1_BITSEL_8BIT_COLOR 0x000000c0
352#define TX3912_VIDEO_CTRL1_BITSEL_4BIT_GRAY 0x00000080
353#define TX3912_VIDEO_CTRL1_BITSEL_2BIT_GRAY 0x00000040
354#define TX3912_VIDEO_CTRL1_DISPSPLIT 0x00000020
355#define TX3912_VIDEO_CTRL1_DISP8 0x00000010
356#define TX3912_VIDEO_CTRL1_DFMODE 0x00000008
357#define TX3912_VIDEO_CTRL1_INVVID 0x00000004
358#define TX3912_VIDEO_CTRL1_DISPON 0x00000002
359#define TX3912_VIDEO_CTRL1_ENVID 0x00000001
360
361#endif /* _TX3912_H_ */
diff --git a/include/asm-mips/tx4927/toshiba_rbtx4927.h b/include/asm-mips/tx4927/toshiba_rbtx4927.h
index 94bef03d9635..5dc40a867774 100644
--- a/include/asm-mips/tx4927/toshiba_rbtx4927.h
+++ b/include/asm-mips/tx4927/toshiba_rbtx4927.h
@@ -52,4 +52,6 @@
52#define RBTX4927_RTL_8019_BASE (0x1c020280-TBTX4927_ISA_IO_OFFSET) 52#define RBTX4927_RTL_8019_BASE (0x1c020280-TBTX4927_ISA_IO_OFFSET)
53#define RBTX4927_RTL_8019_IRQ (29) 53#define RBTX4927_RTL_8019_IRQ (29)
54 54
55int toshiba_rbtx4927_irq_nested(int sw_irq);
56
55#endif /* __ASM_TX4927_TOSHIBA_RBTX4927_H */ 57#endif /* __ASM_TX4927_TOSHIBA_RBTX4927_H */
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index ed16de0a6398..fa9a587b3bf1 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -340,16 +340,17 @@
340#define __NR_signalfd (__NR_Linux + 317) 340#define __NR_signalfd (__NR_Linux + 317)
341#define __NR_timerfd (__NR_Linux + 318) 341#define __NR_timerfd (__NR_Linux + 318)
342#define __NR_eventfd (__NR_Linux + 319) 342#define __NR_eventfd (__NR_Linux + 319)
343#define __NR_fallocate (__NR_Linux + 320)
343 344
344/* 345/*
345 * Offset of the last Linux o32 flavoured syscall 346 * Offset of the last Linux o32 flavoured syscall
346 */ 347 */
347#define __NR_Linux_syscalls 319 348#define __NR_Linux_syscalls 320
348 349
349#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 350#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
350 351
351#define __NR_O32_Linux 4000 352#define __NR_O32_Linux 4000
352#define __NR_O32_Linux_syscalls 319 353#define __NR_O32_Linux_syscalls 320
353 354
354#if _MIPS_SIM == _MIPS_SIM_ABI64 355#if _MIPS_SIM == _MIPS_SIM_ABI64
355 356
@@ -636,16 +637,17 @@
636#define __NR_signalfd (__NR_Linux + 276) 637#define __NR_signalfd (__NR_Linux + 276)
637#define __NR_timerfd (__NR_Linux + 277) 638#define __NR_timerfd (__NR_Linux + 277)
638#define __NR_eventfd (__NR_Linux + 278) 639#define __NR_eventfd (__NR_Linux + 278)
640#define __NR_fallocate (__NR_Linux + 279)
639 641
640/* 642/*
641 * Offset of the last Linux 64-bit flavoured syscall 643 * Offset of the last Linux 64-bit flavoured syscall
642 */ 644 */
643#define __NR_Linux_syscalls 278 645#define __NR_Linux_syscalls 279
644 646
645#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 647#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
646 648
647#define __NR_64_Linux 5000 649#define __NR_64_Linux 5000
648#define __NR_64_Linux_syscalls 278 650#define __NR_64_Linux_syscalls 279
649 651
650#if _MIPS_SIM == _MIPS_SIM_NABI32 652#if _MIPS_SIM == _MIPS_SIM_NABI32
651 653
@@ -936,16 +938,17 @@
936#define __NR_signalfd (__NR_Linux + 280) 938#define __NR_signalfd (__NR_Linux + 280)
937#define __NR_timerfd (__NR_Linux + 281) 939#define __NR_timerfd (__NR_Linux + 281)
938#define __NR_eventfd (__NR_Linux + 282) 940#define __NR_eventfd (__NR_Linux + 282)
941#define __NR_fallocate (__NR_Linux + 283)
939 942
940/* 943/*
941 * Offset of the last N32 flavoured syscall 944 * Offset of the last N32 flavoured syscall
942 */ 945 */
943#define __NR_Linux_syscalls 282 946#define __NR_Linux_syscalls 283
944 947
945#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 948#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
946 949
947#define __NR_N32_Linux 6000 950#define __NR_N32_Linux 6000
948#define __NR_N32_Linux_syscalls 282 951#define __NR_N32_Linux_syscalls 283
949 952
950#ifdef __KERNEL__ 953#ifdef __KERNEL__
951 954
diff --git a/include/asm-mips/war.h b/include/asm-mips/war.h
index 9de52a5b0f3d..c0715d0a6b28 100644
--- a/include/asm-mips/war.h
+++ b/include/asm-mips/war.h
@@ -182,13 +182,11 @@
182 * exceptions. 182 * exceptions.
183 */ 183 */
184#if defined(CONFIG_BASLER_EXCITE) || defined(CONFIG_MIPS_ATLAS) || \ 184#if defined(CONFIG_BASLER_EXCITE) || defined(CONFIG_MIPS_ATLAS) || \
185 defined(CONFIG_MIPS_MALTA) || defined(CONFIG_MOMENCO_OCELOT) || \ 185 defined(CONFIG_MIPS_MALTA) || defined(CONFIG_PMC_YOSEMITE) || \
186 defined(CONFIG_PMC_YOSEMITE) || defined(CONFIG_SGI_IP32) || \ 186 defined(CONFIG_SGI_IP32) || defined(CONFIG_WR_PPMC)
187 defined(CONFIG_WR_PPMC)
188#define ICACHE_REFILLS_WORKAROUND_WAR 1 187#define ICACHE_REFILLS_WORKAROUND_WAR 1
189#endif 188#endif
190 189
191
192/* 190/*
193 * On the R10000 upto version 2.6 (not sure about 2.7) there is a bug that 191 * On the R10000 upto version 2.6 (not sure about 2.7) there is a bug that
194 * may cause ll / sc and lld / scd sequences to execute non-atomically. 192 * may cause ll / sc and lld / scd sequences to execute non-atomically.
diff --git a/include/asm-parisc/thread_info.h b/include/asm-parisc/thread_info.h
index 949314cf6188..2d9c7500867b 100644
--- a/include/asm-parisc/thread_info.h
+++ b/include/asm-parisc/thread_info.h
@@ -56,23 +56,21 @@ struct thread_info {
56 * thread information flags 56 * thread information flags
57 */ 57 */
58#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 58#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
59#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 59#define TIF_SIGPENDING 1 /* signal pending */
60#define TIF_SIGPENDING 2 /* signal pending */ 60#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
61#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 61#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling TIF_NEED_RESCHED */
62#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 62#define TIF_32BIT 4 /* 32 bit binary */
63#define TIF_32BIT 5 /* 32 bit binary */ 63#define TIF_MEMDIE 5
64#define TIF_MEMDIE 6 64#define TIF_RESTORE_SIGMASK 6 /* restore saved signal mask */
65#define TIF_RESTORE_SIGMASK 7 /* restore saved signal mask */
66 65
67#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 66#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
68#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
69#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 67#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
70#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 68#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
71#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 69#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
72#define _TIF_32BIT (1 << TIF_32BIT) 70#define _TIF_32BIT (1 << TIF_32BIT)
73#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 71#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
74 72
75#define _TIF_USER_WORK_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \ 73#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | \
76 _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK) 74 _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
77 75
78#endif /* __KERNEL__ */ 76#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/bug.h b/include/asm-powerpc/bug.h
index f6fa39474846..e55d1f66b86f 100644
--- a/include/asm-powerpc/bug.h
+++ b/include/asm-powerpc/bug.h
@@ -79,7 +79,7 @@
79 _EMIT_BUG_ENTRY \ 79 _EMIT_BUG_ENTRY \
80 : : "i" (__FILE__), "i" (__LINE__), "i" (0), \ 80 : : "i" (__FILE__), "i" (__LINE__), "i" (0), \
81 "i" (sizeof(struct bug_entry)), \ 81 "i" (sizeof(struct bug_entry)), \
82 "r" ((long)(x))); \ 82 "r" ((__force long)(x))); \
83 } \ 83 } \
84} while (0) 84} while (0)
85 85
@@ -93,7 +93,7 @@
93} while (0) 93} while (0)
94 94
95#define WARN_ON(x) ({ \ 95#define WARN_ON(x) ({ \
96 typeof(x) __ret_warn_on = (x); \ 96 int __ret_warn_on = !!(x); \
97 if (__builtin_constant_p(__ret_warn_on)) { \ 97 if (__builtin_constant_p(__ret_warn_on)) { \
98 if (__ret_warn_on) \ 98 if (__ret_warn_on) \
99 __WARN(); \ 99 __WARN(); \
diff --git a/include/asm-powerpc/page.h b/include/asm-powerpc/page.h
index 10c51f457d48..236a9210e5fc 100644
--- a/include/asm-powerpc/page.h
+++ b/include/asm-powerpc/page.h
@@ -190,7 +190,6 @@ extern void copy_user_page(void *to, void *from, unsigned long vaddr,
190extern int page_is_ram(unsigned long pfn); 190extern int page_is_ram(unsigned long pfn);
191 191
192struct vm_area_struct; 192struct vm_area_struct;
193extern const char *arch_vma_name(struct vm_area_struct *vma);
194 193
195#include <asm-generic/memory_model.h> 194#include <asm-generic/memory_model.h>
196#endif /* __ASSEMBLY__ */ 195#endif /* __ASSEMBLY__ */
diff --git a/include/asm-powerpc/pci-bridge.h b/include/asm-powerpc/pci-bridge.h
index e72c2a60853c..e909769b6410 100644
--- a/include/asm-powerpc/pci-bridge.h
+++ b/include/asm-powerpc/pci-bridge.h
@@ -45,10 +45,17 @@ struct pci_controller {
45 * on Freescale PCI-e controllers since they used the PCI_PRIMARY_BUS 45 * on Freescale PCI-e controllers since they used the PCI_PRIMARY_BUS
46 * to determine which bus number to match on when generating type0 46 * to determine which bus number to match on when generating type0
47 * config cycles 47 * config cycles
48 * NO_PCIE_LINK - the Freescale PCI-e controllers have issues with
49 * hanging if we don't have link and try to do config cycles to
50 * anything but the PHB. Only allow talking to the PHB if this is
51 * set.
52 * BIG_ENDIAN - cfg_addr is a big endian register
48 */ 53 */
49#define PPC_INDIRECT_TYPE_SET_CFG_TYPE (0x00000001) 54#define PPC_INDIRECT_TYPE_SET_CFG_TYPE (0x00000001)
50#define PPC_INDIRECT_TYPE_EXT_REG (0x00000002) 55#define PPC_INDIRECT_TYPE_EXT_REG (0x00000002)
51#define PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS (0x00000004) 56#define PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS (0x00000004)
57#define PPC_INDIRECT_TYPE_NO_PCIE_LINK (0x00000008)
58#define PPC_INDIRECT_TYPE_BIG_ENDIAN (0x00000010)
52 u32 indirect_type; 59 u32 indirect_type;
53 60
54 /* Currently, we limit ourselves to 1 IO range and 3 mem 61 /* Currently, we limit ourselves to 1 IO range and 3 mem
@@ -64,6 +71,14 @@ static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
64 return bus->sysdata; 71 return bus->sysdata;
65} 72}
66 73
74static inline int isa_vaddr_is_ioport(void __iomem *address)
75{
76 /* No specific ISA handling on ppc32 at this stage, it
77 * all goes through PCI
78 */
79 return 0;
80}
81
67/* These are used for config access before all the PCI probing 82/* These are used for config access before all the PCI probing
68 has been done. */ 83 has been done. */
69int early_read_config_byte(struct pci_controller *hose, int bus, int dev_fn, 84int early_read_config_byte(struct pci_controller *hose, int bus, int dev_fn,
@@ -79,11 +94,14 @@ int early_write_config_word(struct pci_controller *hose, int bus, int dev_fn,
79int early_write_config_dword(struct pci_controller *hose, int bus, int dev_fn, 94int early_write_config_dword(struct pci_controller *hose, int bus, int dev_fn,
80 int where, u32 val); 95 int where, u32 val);
81 96
82extern void setup_indirect_pci_nomap(struct pci_controller* hose, 97extern int early_find_capability(struct pci_controller *hose, int bus,
83 void __iomem *cfg_addr, void __iomem *cfg_data); 98 int dev_fn, int cap);
99
84extern void setup_indirect_pci(struct pci_controller* hose, 100extern void setup_indirect_pci(struct pci_controller* hose,
85 u32 cfg_addr, u32 cfg_data); 101 u32 cfg_addr, u32 cfg_data, u32 flags);
86extern void setup_grackle(struct pci_controller *hose); 102extern void setup_grackle(struct pci_controller *hose);
103extern void __init update_bridge_resource(struct pci_dev *dev,
104 struct resource *res);
87 105
88#else 106#else
89 107
@@ -231,6 +249,13 @@ extern void pcibios_free_controller(struct pci_controller *phb);
231 249
232extern void isa_bridge_find_early(struct pci_controller *hose); 250extern void isa_bridge_find_early(struct pci_controller *hose);
233 251
252static inline int isa_vaddr_is_ioport(void __iomem *address)
253{
254 /* Check if address hits the reserved legacy IO range */
255 unsigned long ea = (unsigned long)address;
256 return ea >= ISA_IO_BASE && ea < ISA_IO_END;
257}
258
234extern int pcibios_unmap_io_space(struct pci_bus *bus); 259extern int pcibios_unmap_io_space(struct pci_bus *bus);
235extern int pcibios_map_io_space(struct pci_bus *bus); 260extern int pcibios_map_io_space(struct pci_bus *bus);
236 261
@@ -261,11 +286,16 @@ extern struct pci_controller *
261pcibios_alloc_controller(struct device_node *dev); 286pcibios_alloc_controller(struct device_node *dev);
262#ifdef CONFIG_PCI 287#ifdef CONFIG_PCI
263extern unsigned long pci_address_to_pio(phys_addr_t address); 288extern unsigned long pci_address_to_pio(phys_addr_t address);
289extern int pcibios_vaddr_is_ioport(void __iomem *address);
264#else 290#else
265static inline unsigned long pci_address_to_pio(phys_addr_t address) 291static inline unsigned long pci_address_to_pio(phys_addr_t address)
266{ 292{
267 return (unsigned long)-1; 293 return (unsigned long)-1;
268} 294}
295static inline int pcibios_vaddr_is_ioport(void __iomem *address)
296{
297 return 0;
298}
269#endif 299#endif
270 300
271 301
diff --git a/include/asm-powerpc/ppc_asm.h b/include/asm-powerpc/ppc_asm.h
index fa083d8e4663..65325721446d 100644
--- a/include/asm-powerpc/ppc_asm.h
+++ b/include/asm-powerpc/ppc_asm.h
@@ -181,6 +181,18 @@ name: \
181 .type GLUE(.,name),@function; \ 181 .type GLUE(.,name),@function; \
182GLUE(.,name): 182GLUE(.,name):
183 183
184#define _INIT_STATIC(name) \
185 .section ".text.init.refok"; \
186 .align 2 ; \
187 .section ".opd","aw"; \
188name: \
189 .quad GLUE(.,name); \
190 .quad .TOC.@tocbase; \
191 .quad 0; \
192 .previous; \
193 .type GLUE(.,name),@function; \
194GLUE(.,name):
195
184#else /* 32-bit */ 196#else /* 32-bit */
185 197
186#define _GLOBAL(n) \ 198#define _GLOBAL(n) \
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
index 9d9aeca8ad22..40d5f98c44fc 100644
--- a/include/asm-powerpc/thread_info.h
+++ b/include/asm-powerpc/thread_info.h
@@ -107,28 +107,26 @@ static inline struct thread_info *current_thread_info(void)
107 * thread information flag bit numbers 107 * thread information flag bit numbers
108 */ 108 */
109#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 109#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
110#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 110#define TIF_SIGPENDING 1 /* signal pending */
111#define TIF_SIGPENDING 2 /* signal pending */ 111#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
112#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 112#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
113#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
114 TIF_NEED_RESCHED */ 113 TIF_NEED_RESCHED */
115#define TIF_32BIT 5 /* 32 bit binary */ 114#define TIF_32BIT 4 /* 32 bit binary */
116#define TIF_PERFMON_WORK 6 /* work for pfm_handle_work() */ 115#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
117#define TIF_PERFMON_CTXSW 7 /* perfmon needs ctxsw calls */ 116#define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
118#define TIF_SYSCALL_AUDIT 8 /* syscall auditing active */ 117#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
119#define TIF_SINGLESTEP 9 /* singlestepping active */ 118#define TIF_SINGLESTEP 8 /* singlestepping active */
120#define TIF_MEMDIE 10 119#define TIF_MEMDIE 9
121#define TIF_SECCOMP 11 /* secure computing */ 120#define TIF_SECCOMP 10 /* secure computing */
122#define TIF_RESTOREALL 12 /* Restore all regs (implies NOERROR) */ 121#define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
123#define TIF_NOERROR 14 /* Force successful syscall return */ 122#define TIF_NOERROR 12 /* Force successful syscall return */
124#define TIF_RESTORE_SIGMASK 15 /* Restore signal mask in do_signal */ 123#define TIF_RESTORE_SIGMASK 13 /* Restore signal mask in do_signal */
125#define TIF_FREEZE 16 /* Freezing for suspend */ 124#define TIF_FREEZE 14 /* Freezing for suspend */
126#define TIF_RUNLATCH 17 /* Is the runlatch enabled? */ 125#define TIF_RUNLATCH 15 /* Is the runlatch enabled? */
127#define TIF_ABI_PENDING 18 /* 32/64 bit switch needed */ 126#define TIF_ABI_PENDING 16 /* 32/64 bit switch needed */
128 127
129/* as above, but as bit values */ 128/* as above, but as bit values */
130#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 129#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
131#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
132#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 130#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
133#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 131#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
134#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 132#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
@@ -146,7 +144,7 @@ static inline struct thread_info *current_thread_info(void)
146#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 144#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
147#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP) 145#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
148 146
149#define _TIF_USER_WORK_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \ 147#define _TIF_USER_WORK_MASK ( _TIF_SIGPENDING | \
150 _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK) 148 _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
151#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR) 149#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
152 150
diff --git a/include/asm-powerpc/vio.h b/include/asm-powerpc/vio.h
index 0117b544ecbc..3a0975e2adad 100644
--- a/include/asm-powerpc/vio.h
+++ b/include/asm-powerpc/vio.h
@@ -80,6 +80,11 @@ extern const void *vio_get_attribute(struct vio_dev *vdev, char *which,
80extern struct vio_dev *vio_find_node(struct device_node *vnode); 80extern struct vio_dev *vio_find_node(struct device_node *vnode);
81extern int vio_enable_interrupts(struct vio_dev *dev); 81extern int vio_enable_interrupts(struct vio_dev *dev);
82extern int vio_disable_interrupts(struct vio_dev *dev); 82extern int vio_disable_interrupts(struct vio_dev *dev);
83#else
84static inline int vio_enable_interrupts(struct vio_dev *dev)
85{
86 return 0;
87}
83#endif 88#endif
84 89
85static inline struct vio_driver *to_vio_driver(struct device_driver *drv) 90static inline struct vio_driver *to_vio_driver(struct device_driver *drv)
diff --git a/include/asm-ppc/mv64x60.h b/include/asm-ppc/mv64x60.h
index db3776f18198..2963d6aa3ea5 100644
--- a/include/asm-ppc/mv64x60.h
+++ b/include/asm-ppc/mv64x60.h
@@ -120,14 +120,6 @@ extern spinlock_t mv64x60_lock;
120 120
121#define MV64x60_64BIT_WIN_COUNT 24 121#define MV64x60_64BIT_WIN_COUNT 24
122 122
123/* Watchdog Platform Device, Driver Data */
124#define MV64x60_WDT_NAME "wdt"
125
126struct mv64x60_wdt_pdata {
127 int timeout; /* watchdog expiry in seconds, default 10 */
128 int bus_clk; /* bus clock in MHz, default 133 */
129};
130
131/* 123/*
132 * Define a structure that's used to pass in config information to the 124 * Define a structure that's used to pass in config information to the
133 * core routines. 125 * core routines.
diff --git a/include/asm-s390/ccwdev.h b/include/asm-s390/ccwdev.h
index 4c2e1710f157..1aeda27d5a8b 100644
--- a/include/asm-s390/ccwdev.h
+++ b/include/asm-s390/ccwdev.h
@@ -165,11 +165,6 @@ extern int ccw_device_resume(struct ccw_device *);
165extern int ccw_device_halt(struct ccw_device *, unsigned long); 165extern int ccw_device_halt(struct ccw_device *, unsigned long);
166extern int ccw_device_clear(struct ccw_device *, unsigned long); 166extern int ccw_device_clear(struct ccw_device *, unsigned long);
167 167
168extern int __deprecated read_dev_chars(struct ccw_device *cdev, void **buffer, int length);
169extern int __deprecated read_conf_data(struct ccw_device *cdev, void **buffer, int *length);
170extern int __deprecated read_conf_data_lpm(struct ccw_device *cdev, void **buffer,
171 int *length, __u8 lpm);
172
173extern int ccw_device_set_online(struct ccw_device *cdev); 168extern int ccw_device_set_online(struct ccw_device *cdev);
174extern int ccw_device_set_offline(struct ccw_device *cdev); 169extern int ccw_device_set_offline(struct ccw_device *cdev);
175 170
diff --git a/include/asm-s390/s390_ext.h b/include/asm-s390/s390_ext.h
index df9b1017b703..1e72362cad78 100644
--- a/include/asm-s390/s390_ext.h
+++ b/include/asm-s390/s390_ext.h
@@ -10,6 +10,8 @@
10 * Martin Schwidefsky (schwidefsky@de.ibm.com) 10 * Martin Schwidefsky (schwidefsky@de.ibm.com)
11 */ 11 */
12 12
13#include <linux/types.h>
14
13typedef void (*ext_int_handler_t)(__u16 code); 15typedef void (*ext_int_handler_t)(__u16 code);
14 16
15/* 17/*
diff --git a/include/asm-s390/smp.h b/include/asm-s390/smp.h
index 76e424f718c6..07708c07701e 100644
--- a/include/asm-s390/smp.h
+++ b/include/asm-s390/smp.h
@@ -36,8 +36,7 @@ extern void machine_halt_smp(void);
36extern void machine_power_off_smp(void); 36extern void machine_power_off_smp(void);
37 37
38extern void smp_setup_cpu_possible_map(void); 38extern void smp_setup_cpu_possible_map(void);
39extern int smp_call_function_on(void (*func) (void *info), void *info, 39
40 int nonatomic, int wait, int cpu);
41#define NO_PROC_ID 0xFF /* No processor magic marker */ 40#define NO_PROC_ID 0xFF /* No processor magic marker */
42 41
43/* 42/*
@@ -96,14 +95,6 @@ extern int __cpu_up (unsigned int cpu);
96#endif 95#endif
97 96
98#ifndef CONFIG_SMP 97#ifndef CONFIG_SMP
99static inline int
100smp_call_function_on(void (*func) (void *info), void *info,
101 int nonatomic, int wait, int cpu)
102{
103 func(info);
104 return 0;
105}
106
107static inline void smp_send_stop(void) 98static inline void smp_send_stop(void)
108{ 99{
109 /* Disable all interrupts/machine checks */ 100 /* Disable all interrupts/machine checks */
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h
index 790c1c557417..f04acb2670a8 100644
--- a/include/asm-s390/unistd.h
+++ b/include/asm-s390/unistd.h
@@ -251,7 +251,7 @@
251#define __NR_getcpu 311 251#define __NR_getcpu 311
252#define __NR_epoll_pwait 312 252#define __NR_epoll_pwait 312
253#define __NR_utimes 313 253#define __NR_utimes 313
254/* Number 314 is reserved for new sys_fallocate */ 254#define __NR_fallocate 314
255#define __NR_utimensat 315 255#define __NR_utimensat 315
256#define __NR_signalfd 316 256#define __NR_signalfd 316
257#define __NR_timerfd 317 257#define __NR_timerfd 317
diff --git a/include/asm-sh/bugs.h b/include/asm-sh/bugs.h
index aeee8da9c54f..b66139ff73fc 100644
--- a/include/asm-sh/bugs.h
+++ b/include/asm-sh/bugs.h
@@ -29,7 +29,7 @@ static void __init check_bugs(void)
29 *p++ = '2'; 29 *p++ = '2';
30 *p++ = 'a'; 30 *p++ = 'a';
31 break; 31 break;
32 case CPU_SH7705 ... CPU_SH7300: 32 case CPU_SH7705 ... CPU_SH7729:
33 *p++ = '3'; 33 *p++ = '3';
34 break; 34 break;
35 case CPU_SH7750 ... CPU_SH4_501: 35 case CPU_SH7750 ... CPU_SH4_501:
@@ -39,7 +39,7 @@ static void __init check_bugs(void)
39 *p++ = '4'; 39 *p++ = '4';
40 *p++ = 'a'; 40 *p++ = 'a';
41 break; 41 break;
42 case CPU_SH73180 ... CPU_SH7722: 42 case CPU_SH7343 ... CPU_SH7722:
43 *p++ = '4'; 43 *p++ = '4';
44 *p++ = 'a'; 44 *p++ = 'a';
45 *p++ = 'l'; 45 *p++ = 'l';
diff --git a/include/asm-sh/cpu-sh3/freq.h b/include/asm-sh/cpu-sh3/freq.h
index 273f3229785c..0a054b53b9de 100644
--- a/include/asm-sh/cpu-sh3/freq.h
+++ b/include/asm-sh/cpu-sh3/freq.h
@@ -10,11 +10,7 @@
10#ifndef __ASM_CPU_SH3_FREQ_H 10#ifndef __ASM_CPU_SH3_FREQ_H
11#define __ASM_CPU_SH3_FREQ_H 11#define __ASM_CPU_SH3_FREQ_H
12 12
13#if defined(CONFIG_CPU_SUBTYPE_SH7300)
14#define FRQCR 0xa415ff80
15#else
16#define FRQCR 0xffffff80 13#define FRQCR 0xffffff80
17#endif
18#define MIN_DIVISOR_NR 0 14#define MIN_DIVISOR_NR 0
19#define MAX_DIVISOR_NR 4 15#define MAX_DIVISOR_NR 4
20 16
diff --git a/include/asm-sh/cpu-sh3/mmu_context.h b/include/asm-sh/cpu-sh3/mmu_context.h
index 4704e86dff5b..b20786d42d09 100644
--- a/include/asm-sh/cpu-sh3/mmu_context.h
+++ b/include/asm-sh/cpu-sh3/mmu_context.h
@@ -30,7 +30,6 @@
30#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \ 30#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
31 defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 31 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
32 defined(CONFIG_CPU_SUBTYPE_SH7706) || \ 32 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
33 defined(CONFIG_CPU_SUBTYPE_SH7300) || \
34 defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 33 defined(CONFIG_CPU_SUBTYPE_SH7705) || \
35 defined(CONFIG_CPU_SUBTYPE_SH7712) || \ 34 defined(CONFIG_CPU_SUBTYPE_SH7712) || \
36 defined(CONFIG_CPU_SUBTYPE_SH7710) 35 defined(CONFIG_CPU_SUBTYPE_SH7710)
diff --git a/include/asm-sh/cpu-sh3/timer.h b/include/asm-sh/cpu-sh3/timer.h
index 4928b08f9d19..b6c2020a2ad3 100644
--- a/include/asm-sh/cpu-sh3/timer.h
+++ b/include/asm-sh/cpu-sh3/timer.h
@@ -19,7 +19,6 @@
19 * SH7729R 19 * SH7729R
20 * SH7710 20 * SH7710
21 * SH7720 21 * SH7720
22 * SH7300
23 * SH7710 22 * SH7710
24 * --------------------------------------------------------------------------- 23 * ---------------------------------------------------------------------------
25 */ 24 */
@@ -28,7 +27,7 @@
28#define TMU_TOCR 0xfffffe90 /* Byte access */ 27#define TMU_TOCR 0xfffffe90 /* Byte access */
29#endif 28#endif
30 29
31#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7710) 30#if defined(CONFIG_CPU_SUBTYPE_SH7710)
32#define TMU_012_TSTR 0xa412fe92 /* Byte access */ 31#define TMU_012_TSTR 0xa412fe92 /* Byte access */
33 32
34#define TMU0_TCOR 0xa412fe94 /* Long access */ 33#define TMU0_TCOR 0xa412fe94 /* Long access */
diff --git a/include/asm-sh/cpu-sh4/freq.h b/include/asm-sh/cpu-sh4/freq.h
index 026025b51cea..dc1d32a86374 100644
--- a/include/asm-sh/cpu-sh4/freq.h
+++ b/include/asm-sh/cpu-sh4/freq.h
@@ -10,7 +10,7 @@
10#ifndef __ASM_CPU_SH4_FREQ_H 10#ifndef __ASM_CPU_SH4_FREQ_H
11#define __ASM_CPU_SH4_FREQ_H 11#define __ASM_CPU_SH4_FREQ_H
12 12
13#if defined(CONFIG_CPU_SUBTYPE_SH73180) || defined(CONFIG_CPU_SUBTYPE_SH7722) 13#if defined(CONFIG_CPU_SUBTYPE_SH7722)
14#define FRQCR 0xa4150000 14#define FRQCR 0xa4150000
15#define VCLKCR 0xa4150004 15#define VCLKCR 0xa4150004
16#define SCLKACR 0xa4150008 16#define SCLKACR 0xa4150008
diff --git a/include/asm-sh/dma-mapping.h b/include/asm-sh/dma-mapping.h
index d3bc7818bbbe..6f492ac3fa13 100644
--- a/include/asm-sh/dma-mapping.h
+++ b/include/asm-sh/dma-mapping.h
@@ -69,11 +69,11 @@ static inline dma_addr_t dma_map_single(struct device *dev,
69{ 69{
70#if defined(CONFIG_PCI) && !defined(CONFIG_SH_PCIDMA_NONCOHERENT) 70#if defined(CONFIG_PCI) && !defined(CONFIG_SH_PCIDMA_NONCOHERENT)
71 if (dev->bus == &pci_bus_type) 71 if (dev->bus == &pci_bus_type)
72 return virt_to_bus(ptr); 72 return virt_to_phys(ptr);
73#endif 73#endif
74 dma_cache_sync(dev, ptr, size, dir); 74 dma_cache_sync(dev, ptr, size, dir);
75 75
76 return virt_to_bus(ptr); 76 return virt_to_phys(ptr);
77} 77}
78 78
79#define dma_unmap_single(dev, addr, size, dir) do { } while (0) 79#define dma_unmap_single(dev, addr, size, dir) do { } while (0)
@@ -116,7 +116,7 @@ static inline void dma_sync_single(struct device *dev, dma_addr_t dma_handle,
116 if (dev->bus == &pci_bus_type) 116 if (dev->bus == &pci_bus_type)
117 return; 117 return;
118#endif 118#endif
119 dma_cache_sync(dev, bus_to_virt(dma_handle), size, dir); 119 dma_cache_sync(dev, phys_to_virt(dma_handle), size, dir);
120} 120}
121 121
122static inline void dma_sync_single_range(struct device *dev, 122static inline void dma_sync_single_range(struct device *dev,
@@ -128,7 +128,7 @@ static inline void dma_sync_single_range(struct device *dev,
128 if (dev->bus == &pci_bus_type) 128 if (dev->bus == &pci_bus_type)
129 return; 129 return;
130#endif 130#endif
131 dma_cache_sync(dev, bus_to_virt(dma_handle) + offset, size, dir); 131 dma_cache_sync(dev, phys_to_virt(dma_handle) + offset, size, dir);
132} 132}
133 133
134static inline void dma_sync_sg(struct device *dev, struct scatterlist *sg, 134static inline void dma_sync_sg(struct device *dev, struct scatterlist *sg,
diff --git a/include/asm-sh/dma.h b/include/asm-sh/dma.h
index 6034d4a29e73..4c75b70b6414 100644
--- a/include/asm-sh/dma.h
+++ b/include/asm-sh/dma.h
@@ -111,6 +111,7 @@ struct dma_info {
111 111
112 struct list_head list; 112 struct list_head list;
113 int first_channel_nr; 113 int first_channel_nr;
114 int first_vchannel_nr;
114}; 115};
115 116
116struct dma_chan_caps { 117struct dma_chan_caps {
diff --git a/include/asm-sh/fixmap.h b/include/asm-sh/fixmap.h
index 458e9fa59545..8a566177ad96 100644
--- a/include/asm-sh/fixmap.h
+++ b/include/asm-sh/fixmap.h
@@ -46,6 +46,9 @@
46 * fix-mapped? 46 * fix-mapped?
47 */ 47 */
48enum fixed_addresses { 48enum fixed_addresses {
49#define FIX_N_COLOURS 16
50 FIX_CMAP_BEGIN,
51 FIX_CMAP_END = FIX_CMAP_BEGIN + FIX_N_COLOURS,
49#ifdef CONFIG_HIGHMEM 52#ifdef CONFIG_HIGHMEM
50 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 53 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
51 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 54 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
@@ -53,8 +56,8 @@ enum fixed_addresses {
53 __end_of_fixed_addresses 56 __end_of_fixed_addresses
54}; 57};
55 58
56extern void __set_fixmap (enum fixed_addresses idx, 59extern void __set_fixmap(enum fixed_addresses idx,
57 unsigned long phys, pgprot_t flags); 60 unsigned long phys, pgprot_t flags);
58 61
59#define set_fixmap(idx, phys) \ 62#define set_fixmap(idx, phys) \
60 __set_fixmap(idx, phys, PAGE_KERNEL) 63 __set_fixmap(idx, phys, PAGE_KERNEL)
@@ -106,5 +109,4 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
106 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); 109 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
107 return __virt_to_fix(vaddr); 110 return __virt_to_fix(vaddr);
108} 111}
109
110#endif 112#endif
diff --git a/include/asm-sh/floppy.h b/include/asm-sh/floppy.h
index dc1ad464fa32..3b59b3af777b 100644
--- a/include/asm-sh/floppy.h
+++ b/include/asm-sh/floppy.h
@@ -181,7 +181,7 @@ static void _fd_chose_dma_mode(char *addr, unsigned long size)
181{ 181{
182 if(can_use_virtual_dma == 2) { 182 if(can_use_virtual_dma == 2) {
183 if((unsigned int) addr >= (unsigned int) high_memory || 183 if((unsigned int) addr >= (unsigned int) high_memory ||
184 virt_to_bus(addr) >= 0x10000000) 184 virt_to_phys(addr) >= 0x10000000)
185 use_virtual_dma = 1; 185 use_virtual_dma = 1;
186 else 186 else
187 use_virtual_dma = 0; 187 use_virtual_dma = 0;
@@ -219,7 +219,7 @@ static int hard_dma_setup(char *addr, unsigned long size, int mode, int io)
219 doing_pdma = 0; 219 doing_pdma = 0;
220 clear_dma_ff(FLOPPY_DMA); 220 clear_dma_ff(FLOPPY_DMA);
221 set_dma_mode(FLOPPY_DMA,mode); 221 set_dma_mode(FLOPPY_DMA,mode);
222 set_dma_addr(FLOPPY_DMA,virt_to_bus(addr)); 222 set_dma_addr(FLOPPY_DMA,virt_to_phys(addr));
223 set_dma_count(FLOPPY_DMA,size); 223 set_dma_count(FLOPPY_DMA,size);
224 enable_dma(FLOPPY_DMA); 224 enable_dma(FLOPPY_DMA);
225 return 0; 225 return 0;
diff --git a/include/asm-sh/io.h b/include/asm-sh/io.h
index aa80930ce8e4..e6a1877dcb20 100644
--- a/include/asm-sh/io.h
+++ b/include/asm-sh/io.h
@@ -241,10 +241,6 @@ static inline void *phys_to_virt(unsigned long address)
241#define virt_to_phys(address) ((unsigned long)(address)) 241#define virt_to_phys(address) ((unsigned long)(address))
242#endif 242#endif
243 243
244#define virt_to_bus virt_to_phys
245#define bus_to_virt phys_to_virt
246#define page_to_bus page_to_phys
247
248/* 244/*
249 * readX/writeX() are used to access memory mapped devices. On some 245 * readX/writeX() are used to access memory mapped devices. On some
250 * architectures the memory mapped IO stuff needs to be accessed 246 * architectures the memory mapped IO stuff needs to be accessed
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h
index 22efffe45019..e3fae12c0e49 100644
--- a/include/asm-sh/pgtable.h
+++ b/include/asm-sh/pgtable.h
@@ -55,11 +55,7 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
55 55
56#define PTE_PHYS_MASK (0x20000000 - PAGE_SIZE) 56#define PTE_PHYS_MASK (0x20000000 - PAGE_SIZE)
57 57
58/* 58#define VMALLOC_START (P3SEG)
59 * First 1MB map is used by fixed purpose.
60 * Currently only 4-entry (16kB) is used (see arch/sh/mm/cache.c)
61 */
62#define VMALLOC_START (P3SEG+0x00100000)
63#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) 59#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
64 60
65/* 61/*
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index 2252e75daa26..26d52174f4b4 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -45,7 +45,7 @@ enum cpu_type {
45 CPU_SH7705, CPU_SH7706, CPU_SH7707, 45 CPU_SH7705, CPU_SH7706, CPU_SH7707,
46 CPU_SH7708, CPU_SH7708S, CPU_SH7708R, 46 CPU_SH7708, CPU_SH7708S, CPU_SH7708R,
47 CPU_SH7709, CPU_SH7709A, CPU_SH7710, CPU_SH7712, 47 CPU_SH7709, CPU_SH7709A, CPU_SH7710, CPU_SH7712,
48 CPU_SH7729, CPU_SH7300, 48 CPU_SH7729,
49 49
50 /* SH-4 types */ 50 /* SH-4 types */
51 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R, 51 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R,
@@ -55,7 +55,7 @@ enum cpu_type {
55 CPU_SH7770, CPU_SH7780, CPU_SH7781, CPU_SH7785, CPU_SHX3, 55 CPU_SH7770, CPU_SH7780, CPU_SH7781, CPU_SH7785, CPU_SHX3,
56 56
57 /* SH4AL-DSP types */ 57 /* SH4AL-DSP types */
58 CPU_SH73180, CPU_SH7343, CPU_SH7722, 58 CPU_SH7343, CPU_SH7722,
59 59
60 /* Unknown subtype */ 60 /* Unknown subtype */
61 CPU_SH_NONE 61 CPU_SH_NONE
diff --git a/include/asm-sh/se7300.h b/include/asm-sh/se7300.h
deleted file mode 100644
index 4e24edccb30d..000000000000
--- a/include/asm-sh/se7300.h
+++ /dev/null
@@ -1,64 +0,0 @@
1#ifndef __ASM_SH_HITACHI_SE7300_H
2#define __ASM_SH_HITACHI_SE7300_H
3
4/*
5 * linux/include/asm-sh/se/se7300.h
6 *
7 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
8 *
9 * SH-Mobile SolutionEngine 7300 support
10 */
11
12/* Box specific addresses. */
13
14/* Area 0 */
15#define PA_ROM 0x00000000 /* EPROM */
16#define PA_ROM_SIZE 0x00400000 /* EPROM size 4M byte(Actually 2MB) */
17#define PA_FROM 0x00400000 /* Flash ROM */
18#define PA_FROM_SIZE 0x00400000 /* Flash size 4M byte */
19#define PA_SRAM 0x00800000 /* SRAM */
20#define PA_FROM_SIZE 0x00400000 /* SRAM size 4M byte */
21/* Area 1 */
22#define PA_EXT1 0x04000000
23#define PA_EXT1_SIZE 0x04000000
24/* Area 2 */
25#define PA_EXT2 0x08000000
26#define PA_EXT2_SIZE 0x04000000
27/* Area 3 */
28#define PA_SDRAM 0x0c000000
29#define PA_SDRAM_SIZE 0x04000000
30/* Area 4 */
31#define PA_PCIC 0x10000000 /* MR-SHPC-01 PCMCIA */
32#define PA_MRSHPC 0xb03fffe0 /* MR-SHPC-01 PCMCIA controller */
33#define PA_MRSHPC_MW1 0xb0400000 /* MR-SHPC-01 memory window base */
34#define PA_MRSHPC_MW2 0xb0500000 /* MR-SHPC-01 attribute window base */
35#define PA_MRSHPC_IO 0xb0600000 /* MR-SHPC-01 I/O window base */
36#define MRSHPC_OPTION (PA_MRSHPC + 6)
37#define MRSHPC_CSR (PA_MRSHPC + 8)
38#define MRSHPC_ISR (PA_MRSHPC + 10)
39#define MRSHPC_ICR (PA_MRSHPC + 12)
40#define MRSHPC_CPWCR (PA_MRSHPC + 14)
41#define MRSHPC_MW0CR1 (PA_MRSHPC + 16)
42#define MRSHPC_MW1CR1 (PA_MRSHPC + 18)
43#define MRSHPC_IOWCR1 (PA_MRSHPC + 20)
44#define MRSHPC_MW0CR2 (PA_MRSHPC + 22)
45#define MRSHPC_MW1CR2 (PA_MRSHPC + 24)
46#define MRSHPC_IOWCR2 (PA_MRSHPC + 26)
47#define MRSHPC_CDCR (PA_MRSHPC + 28)
48#define MRSHPC_PCIC_INFO (PA_MRSHPC + 30)
49#define PA_LED 0xb0800000 /* LED */
50#define PA_DIPSW 0xb0900000 /* Dip switch 31 */
51#define PA_EPLD_MODESET 0xb0a00000 /* FPGA Mode set register */
52#define PA_EPLD_ST1 0xb0a80000 /* FPGA Interrupt status register1 */
53#define PA_EPLD_ST2 0xb0ac0000 /* FPGA Interrupt status register2 */
54/* Area 5 */
55#define PA_EXT5 0x14000000
56#define PA_EXT5_SIZE 0x04000000
57/* Area 6 */
58#define PA_LCD1 0xb8000000
59#define PA_LCD2 0xb8800000
60
61#define __IO_PREFIX sh7300se
62#include <asm/io_generic.h>
63
64#endif /* __ASM_SH_HITACHI_SE7300_H */
diff --git a/include/asm-sh/se73180.h b/include/asm-sh/se73180.h
deleted file mode 100644
index 907c062b4c9a..000000000000
--- a/include/asm-sh/se73180.h
+++ /dev/null
@@ -1,66 +0,0 @@
1#ifndef __ASM_SH_SE73180_H
2#define __ASM_SH_SE73180_H
3
4/*
5 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
6 *
7 * SH-Mobile SolutionEngine 73180 support
8 */
9
10/* Box specific addresses. */
11
12/* Area 0 */
13#define PA_ROM 0x00000000 /* EPROM */
14#define PA_ROM_SIZE 0x00400000 /* EPROM size 4M byte(Actually 2MB) */
15#define PA_FROM 0x00400000 /* Flash ROM */
16#define PA_FROM_SIZE 0x00400000 /* Flash size 4M byte */
17#define PA_SRAM 0x00800000 /* SRAM */
18#define PA_FROM_SIZE 0x00400000 /* SRAM size 4M byte */
19/* Area 1 */
20#define PA_EXT1 0x04000000
21#define PA_EXT1_SIZE 0x04000000
22/* Area 2 */
23#define PA_EXT2 0x08000000
24#define PA_EXT2_SIZE 0x04000000
25/* Area 3 */
26#define PA_SDRAM 0x0c000000
27#define PA_SDRAM_SIZE 0x04000000
28/* Area 4 */
29#define PA_PCIC 0x10000000 /* MR-SHPC-01 PCMCIA */
30#define PA_MRSHPC 0xb03fffe0 /* MR-SHPC-01 PCMCIA controller */
31#define PA_MRSHPC_MW1 0xb0400000 /* MR-SHPC-01 memory window base */
32#define PA_MRSHPC_MW2 0xb0500000 /* MR-SHPC-01 attribute window base */
33#define PA_MRSHPC_IO 0xb0600000 /* MR-SHPC-01 I/O window base */
34#define MRSHPC_OPTION (PA_MRSHPC + 6)
35#define MRSHPC_CSR (PA_MRSHPC + 8)
36#define MRSHPC_ISR (PA_MRSHPC + 10)
37#define MRSHPC_ICR (PA_MRSHPC + 12)
38#define MRSHPC_CPWCR (PA_MRSHPC + 14)
39#define MRSHPC_MW0CR1 (PA_MRSHPC + 16)
40#define MRSHPC_MW1CR1 (PA_MRSHPC + 18)
41#define MRSHPC_IOWCR1 (PA_MRSHPC + 20)
42#define MRSHPC_MW0CR2 (PA_MRSHPC + 22)
43#define MRSHPC_MW1CR2 (PA_MRSHPC + 24)
44#define MRSHPC_IOWCR2 (PA_MRSHPC + 26)
45#define MRSHPC_CDCR (PA_MRSHPC + 28)
46#define MRSHPC_PCIC_INFO (PA_MRSHPC + 30)
47#define PA_LED 0xb0C00000 /* LED */
48#define LED_SHIFT 0
49#define PA_DIPSW 0xb0900000 /* Dip switch 31 */
50#define PA_EPLD_MODESET 0xb0a00000 /* FPGA Mode set register */
51#define PA_EPLD_ST1 0xb0a80000 /* FPGA Interrupt status register1 */
52#define PA_EPLD_ST2 0xb0ac0000 /* FPGA Interrupt status register2 */
53/* Area 5 */
54#define PA_EXT5 0x14000000
55#define PA_EXT5_SIZE 0x04000000
56/* Area 6 */
57#define PA_LCD1 0xb8000000
58#define PA_LCD2 0xb8800000
59
60#define __IO_PREFIX sh73180se
61#include <asm/io_generic.h>
62
63/* arch/sh/boards/se/73180/irq.c */
64int shmse_irq_demux(int irq);
65
66#endif /* __ASM_SH_SE73180_H */
diff --git a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h
index 31d55e3782d5..1f7e1deb8d92 100644
--- a/include/asm-sh/thread_info.h
+++ b/include/asm-sh/thread_info.h
@@ -107,18 +107,16 @@ static inline struct thread_info *current_thread_info(void)
107 * - other flags in MSW 107 * - other flags in MSW
108 */ 108 */
109#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 109#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
110#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 110#define TIF_SIGPENDING 1 /* signal pending */
111#define TIF_SIGPENDING 2 /* signal pending */ 111#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
112#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 112#define TIF_RESTORE_SIGMASK 3 /* restore signal mask in do_signal() */
113#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ 113#define TIF_SINGLESTEP 4 /* singlestepping active */
114#define TIF_SINGLESTEP 5 /* singlestepping active */
115#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ 114#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
116#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 115#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
117#define TIF_MEMDIE 18 116#define TIF_MEMDIE 18
118#define TIF_FREEZE 19 117#define TIF_FREEZE 19
119 118
120#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 119#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
121#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
122#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 120#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
123#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 121#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
124#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 122#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
diff --git a/include/asm-sh/ubc.h b/include/asm-sh/ubc.h
index 38d46e01b846..56f4e30dc49c 100644
--- a/include/asm-sh/ubc.h
+++ b/include/asm-sh/ubc.h
@@ -15,8 +15,7 @@
15#include <asm/cpu/ubc.h> 15#include <asm/cpu/ubc.h>
16 16
17/* User Break Controller */ 17/* User Break Controller */
18#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 18#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
19 defined(CONFIG_CPU_SUBTYPE_SH7300)
20#define UBC_TYPE_SH7729 (current_cpu_data.type == CPU_SH7729) 19#define UBC_TYPE_SH7729 (current_cpu_data.type == CPU_SH7729)
21#else 20#else
22#define UBC_TYPE_SH7729 0 21#define UBC_TYPE_SH7729 0
diff --git a/include/asm-sh64/dma-mapping.h b/include/asm-sh64/dma-mapping.h
index c7c0f059cdc4..d505f357f819 100644
--- a/include/asm-sh64/dma-mapping.h
+++ b/include/asm-sh64/dma-mapping.h
@@ -51,11 +51,11 @@ static inline dma_addr_t dma_map_single(struct device *dev,
51{ 51{
52#if defined(CONFIG_PCI) && !defined(CONFIG_SH_PCIDMA_NONCOHERENT) 52#if defined(CONFIG_PCI) && !defined(CONFIG_SH_PCIDMA_NONCOHERENT)
53 if (dev->bus == &pci_bus_type) 53 if (dev->bus == &pci_bus_type)
54 return virt_to_bus(ptr); 54 return virt_to_phys(ptr);
55#endif 55#endif
56 dma_cache_sync(dev, ptr, size, dir); 56 dma_cache_sync(dev, ptr, size, dir);
57 57
58 return virt_to_bus(ptr); 58 return virt_to_phys(ptr);
59} 59}
60 60
61#define dma_unmap_single(dev, addr, size, dir) do { } while (0) 61#define dma_unmap_single(dev, addr, size, dir) do { } while (0)
@@ -98,7 +98,7 @@ static inline void dma_sync_single(struct device *dev, dma_addr_t dma_handle,
98 if (dev->bus == &pci_bus_type) 98 if (dev->bus == &pci_bus_type)
99 return; 99 return;
100#endif 100#endif
101 dma_cache_sync(dev, bus_to_virt(dma_handle), size, dir); 101 dma_cache_sync(dev, phys_to_virt(dma_handle), size, dir);
102} 102}
103 103
104static inline void dma_sync_single_range(struct device *dev, 104static inline void dma_sync_single_range(struct device *dev,
@@ -110,7 +110,7 @@ static inline void dma_sync_single_range(struct device *dev,
110 if (dev->bus == &pci_bus_type) 110 if (dev->bus == &pci_bus_type)
111 return; 111 return;
112#endif 112#endif
113 dma_cache_sync(dev, bus_to_virt(dma_handle) + offset, size, dir); 113 dma_cache_sync(dev, phys_to_virt(dma_handle) + offset, size, dir);
114} 114}
115 115
116static inline void dma_sync_sg(struct device *dev, struct scatterlist *sg, 116static inline void dma_sync_sg(struct device *dev, struct scatterlist *sg,
diff --git a/include/asm-sh64/io.h b/include/asm-sh64/io.h
index 14d8e7b4bf4b..1f37b6931922 100644
--- a/include/asm-sh64/io.h
+++ b/include/asm-sh64/io.h
@@ -31,10 +31,6 @@
31#include <asm/page.h> 31#include <asm/page.h>
32#include <asm-generic/iomap.h> 32#include <asm-generic/iomap.h>
33 33
34#define virt_to_bus virt_to_phys
35#define bus_to_virt phys_to_virt
36#define page_to_bus page_to_phys
37
38/* 34/*
39 * Nothing overly special here.. instead of doing the same thing 35 * Nothing overly special here.. instead of doing the same thing
40 * over and over again, we just define a set of sh64_in/out functions 36 * over and over again, we just define a set of sh64_in/out functions
diff --git a/include/asm-sparc/device.h b/include/asm-sparc/device.h
index 4a56d84d69c4..c0a7786d65f7 100644
--- a/include/asm-sparc/device.h
+++ b/include/asm-sparc/device.h
@@ -10,6 +10,10 @@ struct device_node;
10struct of_device; 10struct of_device;
11 11
12struct dev_archdata { 12struct dev_archdata {
13 void *iommu;
14 void *stc;
15 void *host_controller;
16
13 struct device_node *prom_node; 17 struct device_node *prom_node;
14 struct of_device *op; 18 struct of_device *op;
15}; 19};
diff --git a/include/asm-sparc/floppy.h b/include/asm-sparc/floppy.h
index 9073c84218ce..28ce2b9c3da8 100644
--- a/include/asm-sparc/floppy.h
+++ b/include/asm-sparc/floppy.h
@@ -101,6 +101,29 @@ static struct sun_floppy_ops sun_fdops;
101#define CROSS_64KB(a,s) (0) 101#define CROSS_64KB(a,s) (0)
102 102
103/* Routines unique to each controller type on a Sun. */ 103/* Routines unique to each controller type on a Sun. */
104static void sun_set_dor(unsigned char value, int fdc_82077)
105{
106 if (sparc_cpu_model == sun4c) {
107 unsigned int bits = 0;
108 if (value & 0x10)
109 bits |= AUXIO_FLPY_DSEL;
110 if ((value & 0x80) == 0)
111 bits |= AUXIO_FLPY_EJCT;
112 set_auxio(bits, (~bits) & (AUXIO_FLPY_DSEL|AUXIO_FLPY_EJCT));
113 }
114 if (fdc_82077) {
115 sun_fdc->dor_82077 = value;
116 }
117}
118
119static unsigned char sun_read_dir(void)
120{
121 if (sparc_cpu_model == sun4c)
122 return (get_auxio() & AUXIO_FLPY_DCHG) ? 0x80 : 0;
123 else
124 return sun_fdc->dir_82077;
125}
126
104static unsigned char sun_82072_fd_inb(int port) 127static unsigned char sun_82072_fd_inb(int port)
105{ 128{
106 udelay(5); 129 udelay(5);
@@ -113,7 +136,7 @@ static unsigned char sun_82072_fd_inb(int port)
113 case 5: /* FD_DATA */ 136 case 5: /* FD_DATA */
114 return sun_fdc->data_82072; 137 return sun_fdc->data_82072;
115 case 7: /* FD_DIR */ 138 case 7: /* FD_DIR */
116 return (get_auxio() & AUXIO_FLPY_DCHG)? 0x80: 0; 139 return sun_read_dir();
117 }; 140 };
118 panic("sun_82072_fd_inb: How did I get here?"); 141 panic("sun_82072_fd_inb: How did I get here?");
119} 142}
@@ -126,20 +149,7 @@ static void sun_82072_fd_outb(unsigned char value, int port)
126 printk("floppy: Asked to write to unknown port %d\n", port); 149 printk("floppy: Asked to write to unknown port %d\n", port);
127 panic("floppy: Port bolixed."); 150 panic("floppy: Port bolixed.");
128 case 2: /* FD_DOR */ 151 case 2: /* FD_DOR */
129 /* Oh geese, 82072 on the Sun has no DOR register, 152 sun_set_dor(value, 0);
130 * the functionality is implemented via the AUXIO
131 * I/O register. So we must emulate the behavior.
132 *
133 * ASSUMPTIONS: There will only ever be one floppy
134 * drive attached to a Sun controller
135 * and it will be at drive zero.
136 */
137 {
138 unsigned bits = 0;
139 if (value & 0x10) bits |= AUXIO_FLPY_DSEL;
140 if ((value & 0x80) == 0) bits |= AUXIO_FLPY_EJCT;
141 set_auxio(bits, (~bits) & (AUXIO_FLPY_DSEL|AUXIO_FLPY_EJCT));
142 }
143 break; 153 break;
144 case 5: /* FD_DATA */ 154 case 5: /* FD_DATA */
145 sun_fdc->data_82072 = value; 155 sun_fdc->data_82072 = value;
@@ -161,15 +171,22 @@ static unsigned char sun_82077_fd_inb(int port)
161 default: 171 default:
162 printk("floppy: Asked to read unknown port %d\n", port); 172 printk("floppy: Asked to read unknown port %d\n", port);
163 panic("floppy: Port bolixed."); 173 panic("floppy: Port bolixed.");
174 case 0: /* FD_STATUS_0 */
175 return sun_fdc->status1_82077;
176 case 1: /* FD_STATUS_1 */
177 return sun_fdc->status2_82077;
178 case 2: /* FD_DOR */
179 return sun_fdc->dor_82077;
180 case 3: /* FD_TDR */
181 return sun_fdc->tapectl_82077;
164 case 4: /* FD_STATUS */ 182 case 4: /* FD_STATUS */
165 return sun_fdc->status_82077 & ~STATUS_DMA; 183 return sun_fdc->status_82077 & ~STATUS_DMA;
166 case 5: /* FD_DATA */ 184 case 5: /* FD_DATA */
167 return sun_fdc->data_82077; 185 return sun_fdc->data_82077;
168 case 7: /* FD_DIR */ 186 case 7: /* FD_DIR */
169 /* XXX: Is DCL on 0x80 in sun4m? */ 187 return sun_read_dir();
170 return sun_fdc->dir_82077;
171 }; 188 };
172 panic("sun_82072_fd_inb: How did I get here?"); 189 panic("sun_82077_fd_inb: How did I get here?");
173} 190}
174 191
175static void sun_82077_fd_outb(unsigned char value, int port) 192static void sun_82077_fd_outb(unsigned char value, int port)
@@ -180,8 +197,7 @@ static void sun_82077_fd_outb(unsigned char value, int port)
180 printk("floppy: Asked to write to unknown port %d\n", port); 197 printk("floppy: Asked to write to unknown port %d\n", port);
181 panic("floppy: Port bolixed."); 198 panic("floppy: Port bolixed.");
182 case 2: /* FD_DOR */ 199 case 2: /* FD_DOR */
183 /* Happily, the 82077 has a real DOR register. */ 200 sun_set_dor(value, 1);
184 sun_fdc->dor_82077 = value;
185 break; 201 break;
186 case 5: /* FD_DATA */ 202 case 5: /* FD_DATA */
187 sun_fdc->data_82077 = value; 203 sun_fdc->data_82077 = value;
@@ -192,6 +208,9 @@ static void sun_82077_fd_outb(unsigned char value, int port)
192 case 4: /* FD_STATUS */ 208 case 4: /* FD_STATUS */
193 sun_fdc->status_82077 = value; 209 sun_fdc->status_82077 = value;
194 break; 210 break;
211 case 3: /* FD_TDR */
212 sun_fdc->tapectl_82077 = value;
213 break;
195 }; 214 };
196 return; 215 return;
197} 216}
@@ -332,16 +351,17 @@ static int sun_floppy_init(void)
332 goto no_sun_fdc; 351 goto no_sun_fdc;
333 } 352 }
334 353
335 if(sparc_cpu_model == sun4c) { 354 sun_fdops.fd_inb = sun_82077_fd_inb;
336 sun_fdops.fd_inb = sun_82072_fd_inb; 355 sun_fdops.fd_outb = sun_82077_fd_outb;
337 sun_fdops.fd_outb = sun_82072_fd_outb; 356 fdc_status = &sun_fdc->status_82077;
338 fdc_status = &sun_fdc->status_82072; 357
339 /* printk("AUXIO @0x%lx\n", auxio_register); */ /* P3 */ 358 if (sun_fdc->dor_82077 == 0x80) {
340 } else { 359 sun_fdc->dor_82077 = 0x02;
341 sun_fdops.fd_inb = sun_82077_fd_inb; 360 if (sun_fdc->dor_82077 == 0x80) {
342 sun_fdops.fd_outb = sun_82077_fd_outb; 361 sun_fdops.fd_inb = sun_82072_fd_inb;
343 fdc_status = &sun_fdc->status_82077; 362 sun_fdops.fd_outb = sun_82072_fd_outb;
344 /* printk("DOR @0x%p\n", &sun_fdc->dor_82077); */ /* P3 */ 363 fdc_status = &sun_fdc->status_82072;
364 }
345 } 365 }
346 366
347 /* Success... */ 367 /* Success... */
diff --git a/include/asm-sparc64/dma-mapping.h b/include/asm-sparc64/dma-mapping.h
index c58ec1661df8..a72a5f271f31 100644
--- a/include/asm-sparc64/dma-mapping.h
+++ b/include/asm-sparc64/dma-mapping.h
@@ -1,307 +1,141 @@
1#ifndef _ASM_SPARC64_DMA_MAPPING_H 1#ifndef _ASM_SPARC64_DMA_MAPPING_H
2#define _ASM_SPARC64_DMA_MAPPING_H 2#define _ASM_SPARC64_DMA_MAPPING_H
3 3
4 4#include <linux/scatterlist.h>
5#ifdef CONFIG_PCI
6
7/* we implement the API below in terms of the existing PCI one,
8 * so include it */
9#include <linux/pci.h>
10/* need struct page definitions */
11#include <linux/mm.h> 5#include <linux/mm.h>
12 6
13#include <asm/of_device.h> 7#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
14 8
15static inline int 9struct dma_ops {
16dma_supported(struct device *dev, u64 mask) 10 void *(*alloc_coherent)(struct device *dev, size_t size,
17{ 11 dma_addr_t *dma_handle, gfp_t flag);
18 BUG_ON(dev->bus != &pci_bus_type); 12 void (*free_coherent)(struct device *dev, size_t size,
19 13 void *cpu_addr, dma_addr_t dma_handle);
20 return pci_dma_supported(to_pci_dev(dev), mask); 14 dma_addr_t (*map_single)(struct device *dev, void *cpu_addr,
21} 15 size_t size,
22 16 enum dma_data_direction direction);
23static inline int 17 void (*unmap_single)(struct device *dev, dma_addr_t dma_addr,
24dma_set_mask(struct device *dev, u64 dma_mask) 18 size_t size,
25{ 19 enum dma_data_direction direction);
26 BUG_ON(dev->bus != &pci_bus_type); 20 int (*map_sg)(struct device *dev, struct scatterlist *sg, int nents,
27 21 enum dma_data_direction direction);
28 return pci_set_dma_mask(to_pci_dev(dev), dma_mask); 22 void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
29} 23 int nhwentries,
30 24 enum dma_data_direction direction);
31static inline void * 25 void (*sync_single_for_cpu)(struct device *dev,
32dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, 26 dma_addr_t dma_handle, size_t size,
33 gfp_t flag) 27 enum dma_data_direction direction);
34{ 28 void (*sync_single_for_device)(struct device *dev,
35 BUG_ON(dev->bus != &pci_bus_type); 29 dma_addr_t dma_handle, size_t size,
36 30 enum dma_data_direction direction);
37 return pci_iommu_ops->alloc_consistent(to_pci_dev(dev), size, dma_handle, flag); 31 void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg,
38} 32 int nelems,
39 33 enum dma_data_direction direction);
40static inline void 34 void (*sync_sg_for_device)(struct device *dev, struct scatterlist *sg,
41dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, 35 int nelems,
42 dma_addr_t dma_handle) 36 enum dma_data_direction direction);
43{ 37};
44 BUG_ON(dev->bus != &pci_bus_type); 38extern const struct dma_ops *dma_ops;
45 39
46 pci_free_consistent(to_pci_dev(dev), size, cpu_addr, dma_handle); 40extern int dma_supported(struct device *dev, u64 mask);
47} 41extern int dma_set_mask(struct device *dev, u64 dma_mask);
48
49static inline dma_addr_t
50dma_map_single(struct device *dev, void *cpu_addr, size_t size,
51 enum dma_data_direction direction)
52{
53 BUG_ON(dev->bus != &pci_bus_type);
54
55 return pci_map_single(to_pci_dev(dev), cpu_addr, size, (int)direction);
56}
57
58static inline void
59dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
60 enum dma_data_direction direction)
61{
62 BUG_ON(dev->bus != &pci_bus_type);
63
64 pci_unmap_single(to_pci_dev(dev), dma_addr, size, (int)direction);
65}
66
67static inline dma_addr_t
68dma_map_page(struct device *dev, struct page *page,
69 unsigned long offset, size_t size,
70 enum dma_data_direction direction)
71{
72 BUG_ON(dev->bus != &pci_bus_type);
73
74 return pci_map_page(to_pci_dev(dev), page, offset, size, (int)direction);
75}
76
77static inline void
78dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
79 enum dma_data_direction direction)
80{
81 BUG_ON(dev->bus != &pci_bus_type);
82
83 pci_unmap_page(to_pci_dev(dev), dma_address, size, (int)direction);
84}
85
86static inline int
87dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
88 enum dma_data_direction direction)
89{
90 BUG_ON(dev->bus != &pci_bus_type);
91
92 return pci_map_sg(to_pci_dev(dev), sg, nents, (int)direction);
93}
94
95static inline void
96dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
97 enum dma_data_direction direction)
98{
99 BUG_ON(dev->bus != &pci_bus_type);
100
101 pci_unmap_sg(to_pci_dev(dev), sg, nhwentries, (int)direction);
102}
103
104static inline void
105dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
106 enum dma_data_direction direction)
107{
108 BUG_ON(dev->bus != &pci_bus_type);
109
110 pci_dma_sync_single_for_cpu(to_pci_dev(dev), dma_handle,
111 size, (int)direction);
112}
113
114static inline void
115dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size,
116 enum dma_data_direction direction)
117{
118 BUG_ON(dev->bus != &pci_bus_type);
119
120 pci_dma_sync_single_for_device(to_pci_dev(dev), dma_handle,
121 size, (int)direction);
122}
123
124static inline void
125dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
126 enum dma_data_direction direction)
127{
128 BUG_ON(dev->bus != &pci_bus_type);
129
130 pci_dma_sync_sg_for_cpu(to_pci_dev(dev), sg, nelems, (int)direction);
131}
132
133static inline void
134dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
135 enum dma_data_direction direction)
136{
137 BUG_ON(dev->bus != &pci_bus_type);
138
139 pci_dma_sync_sg_for_device(to_pci_dev(dev), sg, nelems, (int)direction);
140}
141
142static inline int
143dma_mapping_error(dma_addr_t dma_addr)
144{
145 return pci_dma_mapping_error(dma_addr);
146}
147
148#else
149
150struct device;
151struct page;
152struct scatterlist;
153
154static inline int
155dma_supported(struct device *dev, u64 mask)
156{
157 BUG();
158 return 0;
159}
160
161static inline int
162dma_set_mask(struct device *dev, u64 dma_mask)
163{
164 BUG();
165 return 0;
166}
167 42
168static inline void *dma_alloc_coherent(struct device *dev, size_t size, 43static inline void *dma_alloc_coherent(struct device *dev, size_t size,
169 dma_addr_t *dma_handle, gfp_t flag) 44 dma_addr_t *dma_handle, gfp_t flag)
170{ 45{
171 BUG(); 46 return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
172 return NULL;
173} 47}
174 48
175static inline void dma_free_coherent(struct device *dev, size_t size, 49static inline void dma_free_coherent(struct device *dev, size_t size,
176 void *vaddr, dma_addr_t dma_handle) 50 void *cpu_addr, dma_addr_t dma_handle)
177{ 51{
178 BUG(); 52 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
179} 53}
180 54
181static inline dma_addr_t 55static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
182dma_map_single(struct device *dev, void *cpu_addr, size_t size, 56 size_t size,
183 enum dma_data_direction direction) 57 enum dma_data_direction direction)
184{ 58{
185 BUG(); 59 return dma_ops->map_single(dev, cpu_addr, size, direction);
186 return 0;
187} 60}
188 61
189static inline void 62static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
190dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 63 size_t size,
191 enum dma_data_direction direction) 64 enum dma_data_direction direction)
192{ 65{
193 BUG(); 66 dma_ops->unmap_single(dev, dma_addr, size, direction);
194} 67}
195 68
196static inline dma_addr_t 69static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
197dma_map_page(struct device *dev, struct page *page, 70 unsigned long offset, size_t size,
198 unsigned long offset, size_t size, 71 enum dma_data_direction direction)
199 enum dma_data_direction direction)
200{ 72{
201 BUG(); 73 return dma_ops->map_single(dev, page_address(page) + offset,
202 return 0; 74 size, direction);
203} 75}
204 76
205static inline void 77static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
206dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, 78 size_t size,
207 enum dma_data_direction direction) 79 enum dma_data_direction direction)
208{ 80{
209 BUG(); 81 dma_ops->unmap_single(dev, dma_address, size, direction);
210} 82}
211 83
212static inline int 84static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
213dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 85 int nents, enum dma_data_direction direction)
214 enum dma_data_direction direction)
215{ 86{
216 BUG(); 87 return dma_ops->map_sg(dev, sg, nents, direction);
217 return 0;
218} 88}
219 89
220static inline void 90static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
221dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, 91 int nents, enum dma_data_direction direction)
222 enum dma_data_direction direction)
223{ 92{
224 BUG(); 93 dma_ops->unmap_sg(dev, sg, nents, direction);
225} 94}
226 95
227static inline void 96static inline void dma_sync_single_for_cpu(struct device *dev,
228dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size, 97 dma_addr_t dma_handle, size_t size,
229 enum dma_data_direction direction) 98 enum dma_data_direction direction)
230{ 99{
231 BUG(); 100 dma_ops->sync_single_for_cpu(dev, dma_handle, size, direction);
232} 101}
233 102
234static inline void 103static inline void dma_sync_single_for_device(struct device *dev,
235dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t size, 104 dma_addr_t dma_handle,
236 enum dma_data_direction direction) 105 size_t size,
106 enum dma_data_direction direction)
237{ 107{
238 BUG(); 108 dma_ops->sync_single_for_device(dev, dma_handle, size, direction);
239} 109}
240 110
241static inline void 111static inline void dma_sync_sg_for_cpu(struct device *dev,
242dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems, 112 struct scatterlist *sg, int nelems,
243 enum dma_data_direction direction) 113 enum dma_data_direction direction)
244{ 114{
245 BUG(); 115 dma_ops->sync_sg_for_cpu(dev, sg, nelems, direction);
246} 116}
247 117
248static inline void 118static inline void dma_sync_sg_for_device(struct device *dev,
249dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems, 119 struct scatterlist *sg, int nelems,
250 enum dma_data_direction direction) 120 enum dma_data_direction direction)
251{ 121{
252 BUG(); 122 dma_ops->sync_sg_for_device(dev, sg, nelems, direction);
253} 123}
254 124
255static inline int 125static inline int dma_mapping_error(dma_addr_t dma_addr)
256dma_mapping_error(dma_addr_t dma_addr)
257{ 126{
258 BUG(); 127 return (dma_addr == DMA_ERROR_CODE);
259 return 0;
260} 128}
261 129
262#endif /* PCI */ 130static inline int dma_get_cache_alignment(void)
263
264
265/* Now for the API extensions over the pci_ one */
266
267#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
268#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
269#define dma_is_consistent(d, h) (1)
270
271static inline int
272dma_get_cache_alignment(void)
273{ 131{
274 /* no easy way to get cache size on all processors, so return 132 /* no easy way to get cache size on all processors, so return
275 * the maximum possible, to be safe */ 133 * the maximum possible, to be safe */
276 return (1 << INTERNODE_CACHE_SHIFT); 134 return (1 << INTERNODE_CACHE_SHIFT);
277} 135}
278 136
279static inline void 137#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
280dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle, 138#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
281 unsigned long offset, size_t size, 139#define dma_is_consistent(d, h) (1)
282 enum dma_data_direction direction)
283{
284 /* just sync everything, that's all the pci API can do */
285 dma_sync_single_for_cpu(dev, dma_handle, offset+size, direction);
286}
287
288static inline void
289dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
290 unsigned long offset, size_t size,
291 enum dma_data_direction direction)
292{
293 /* just sync everything, that's all the pci API can do */
294 dma_sync_single_for_device(dev, dma_handle, offset+size, direction);
295}
296
297static inline void
298dma_cache_sync(struct device *dev, void *vaddr, size_t size,
299 enum dma_data_direction direction)
300{
301 /* could define this in terms of the dma_cache ... operations,
302 * but if you get this on a platform, you should convert the platform
303 * to using the generic device DMA API */
304 BUG();
305}
306 140
307#endif /* _ASM_SPARC64_DMA_MAPPING_H */ 141#endif /* _ASM_SPARC64_DMA_MAPPING_H */
diff --git a/include/asm-sparc64/fbio.h b/include/asm-sparc64/fbio.h
index 500026d9f6e1..b9215a0907d3 100644
--- a/include/asm-sparc64/fbio.h
+++ b/include/asm-sparc64/fbio.h
@@ -2,6 +2,7 @@
2#define __LINUX_FBIO_H 2#define __LINUX_FBIO_H
3 3
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5#include <linux/types.h>
5 6
6/* Constants used for fbio SunOS compatibility */ 7/* Constants used for fbio SunOS compatibility */
7/* (C) 1996 Miguel de Icaza */ 8/* (C) 1996 Miguel de Icaza */
@@ -299,4 +300,31 @@ struct fb_clut32 {
299#define LEO_LD_GBL_MAP 0x01009000 300#define LEO_LD_GBL_MAP 0x01009000
300#define LEO_UNK2_MAP 0x0100a000 301#define LEO_UNK2_MAP 0x0100a000
301 302
303#ifdef __KERNEL__
304struct fbcmap32 {
305 int index; /* first element (0 origin) */
306 int count;
307 u32 red;
308 u32 green;
309 u32 blue;
310};
311
312#define FBIOPUTCMAP32 _IOW('F', 3, struct fbcmap32)
313#define FBIOGETCMAP32 _IOW('F', 4, struct fbcmap32)
314
315struct fbcursor32 {
316 short set; /* what to set, choose from the list above */
317 short enable; /* cursor on/off */
318 struct fbcurpos pos; /* cursor position */
319 struct fbcurpos hot; /* cursor hot spot */
320 struct fbcmap32 cmap; /* color map info */
321 struct fbcurpos size; /* cursor bit map size */
322 u32 image; /* cursor image bits */
323 u32 mask; /* cursor mask bits */
324};
325
326#define FBIOSCURSOR32 _IOW('F', 24, struct fbcursor32)
327#define FBIOGCURSOR32 _IOW('F', 25, struct fbcursor32)
328#endif
329
302#endif /* __LINUX_FBIO_H */ 330#endif /* __LINUX_FBIO_H */
diff --git a/include/asm-sparc64/floppy.h b/include/asm-sparc64/floppy.h
index 4aa0925e1b1b..1783239c7b40 100644
--- a/include/asm-sparc64/floppy.h
+++ b/include/asm-sparc64/floppy.h
@@ -1,7 +1,6 @@
1/* $Id: floppy.h,v 1.32 2001/10/26 17:59:36 davem Exp $ 1/* floppy.h: Sparc specific parts of the Floppy driver.
2 * asm-sparc64/floppy.h: Sparc specific parts of the Floppy driver.
3 * 2 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) 3 * Copyright (C) 1996, 2007 David S. Miller (davem@davemloft.net)
5 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 4 * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 * 5 *
7 * Ultra/PCI support added: Sep 1997 Eddie C. Dost (ecd@skynet.be) 6 * Ultra/PCI support added: Sep 1997 Eddie C. Dost (ecd@skynet.be)
@@ -11,6 +10,7 @@
11#define __ASM_SPARC64_FLOPPY_H 10#define __ASM_SPARC64_FLOPPY_H
12 11
13#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/pci.h>
14 14
15#include <asm/page.h> 15#include <asm/page.h>
16#include <asm/pgtable.h> 16#include <asm/pgtable.h>
diff --git a/include/asm-sparc64/iommu.h b/include/asm-sparc64/iommu.h
index 0b1813f41045..9eac6676caf1 100644
--- a/include/asm-sparc64/iommu.h
+++ b/include/asm-sparc64/iommu.h
@@ -1,7 +1,6 @@
1/* $Id: iommu.h,v 1.10 2001/03/08 09:55:56 davem Exp $ 1/* iommu.h: Definitions for the sun5 IOMMU.
2 * iommu.h: Definitions for the sun5 IOMMU.
3 * 2 *
4 * Copyright (C) 1996, 1999 David S. Miller (davem@caip.rutgers.edu) 3 * Copyright (C) 1996, 1999, 2007 David S. Miller (davem@davemloft.net)
5 */ 4 */
6#ifndef _SPARC64_IOMMU_H 5#ifndef _SPARC64_IOMMU_H
7#define _SPARC64_IOMMU_H 6#define _SPARC64_IOMMU_H
@@ -33,6 +32,7 @@ struct iommu {
33 unsigned long iommu_tsbbase; 32 unsigned long iommu_tsbbase;
34 unsigned long iommu_flush; 33 unsigned long iommu_flush;
35 unsigned long iommu_flushinv; 34 unsigned long iommu_flushinv;
35 unsigned long iommu_tags;
36 unsigned long iommu_ctxflush; 36 unsigned long iommu_ctxflush;
37 unsigned long write_complete_reg; 37 unsigned long write_complete_reg;
38 unsigned long dummy_page; 38 unsigned long dummy_page;
@@ -54,4 +54,7 @@ struct strbuf {
54 volatile unsigned long __flushflag_buf[(64+(64-1)) / sizeof(long)]; 54 volatile unsigned long __flushflag_buf[(64+(64-1)) / sizeof(long)];
55}; 55};
56 56
57#endif /* !(_SPARC_IOMMU_H) */ 57extern int iommu_table_init(struct iommu *iommu, int tsbsize,
58 u32 dma_offset, u32 dma_addr_mask);
59
60#endif /* !(_SPARC64_IOMMU_H) */
diff --git a/include/asm-sparc64/parport.h b/include/asm-sparc64/parport.h
index 600afe5ae2e3..8116e8f6062c 100644
--- a/include/asm-sparc64/parport.h
+++ b/include/asm-sparc64/parport.h
@@ -117,7 +117,7 @@ static int __devinit ecpp_probe(struct of_device *op, const struct of_device_id
117 if (!strcmp(parent->name, "dma")) { 117 if (!strcmp(parent->name, "dma")) {
118 p = parport_pc_probe_port(base, base + 0x400, 118 p = parport_pc_probe_port(base, base + 0x400,
119 op->irqs[0], PARPORT_DMA_NOFIFO, 119 op->irqs[0], PARPORT_DMA_NOFIFO,
120 op->dev.parent); 120 op->dev.parent->parent);
121 if (!p) 121 if (!p)
122 return -ENOMEM; 122 return -ENOMEM;
123 dev_set_drvdata(&op->dev, p); 123 dev_set_drvdata(&op->dev, p);
diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h
index e11ac100f043..1393e57d50fb 100644
--- a/include/asm-sparc64/pci.h
+++ b/include/asm-sparc64/pci.h
@@ -3,8 +3,7 @@
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/fs.h> 6#include <linux/dma-mapping.h>
7#include <linux/mm.h>
8 7
9/* Can be used to override the logic in pci_scan_bus for skipping 8/* Can be used to override the logic in pci_scan_bus for skipping
10 * already-configured bus numbers - to be used for buggy BIOSes 9 * already-configured bus numbers - to be used for buggy BIOSes
@@ -30,80 +29,42 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
30 /* We don't do dynamic PCI IRQ allocation */ 29 /* We don't do dynamic PCI IRQ allocation */
31} 30}
32 31
33/* Dynamic DMA mapping stuff.
34 */
35
36/* The PCI address space does not equal the physical memory 32/* The PCI address space does not equal the physical memory
37 * address space. The networking and block device layers use 33 * address space. The networking and block device layers use
38 * this boolean for bounce buffer decisions. 34 * this boolean for bounce buffer decisions.
39 */ 35 */
40#define PCI_DMA_BUS_IS_PHYS (0) 36#define PCI_DMA_BUS_IS_PHYS (0)
41 37
42#include <asm/scatterlist.h> 38static inline void *pci_alloc_consistent(struct pci_dev *pdev, size_t size,
43 39 dma_addr_t *dma_handle)
44struct pci_dev;
45
46struct pci_iommu_ops {
47 void *(*alloc_consistent)(struct pci_dev *, size_t, dma_addr_t *, gfp_t);
48 void (*free_consistent)(struct pci_dev *, size_t, void *, dma_addr_t);
49 dma_addr_t (*map_single)(struct pci_dev *, void *, size_t, int);
50 void (*unmap_single)(struct pci_dev *, dma_addr_t, size_t, int);
51 int (*map_sg)(struct pci_dev *, struct scatterlist *, int, int);
52 void (*unmap_sg)(struct pci_dev *, struct scatterlist *, int, int);
53 void (*dma_sync_single_for_cpu)(struct pci_dev *, dma_addr_t, size_t, int);
54 void (*dma_sync_sg_for_cpu)(struct pci_dev *, struct scatterlist *, int, int);
55};
56
57extern const struct pci_iommu_ops *pci_iommu_ops;
58
59/* Allocate and map kernel buffer using consistent mode DMA for a device.
60 * hwdev should be valid struct pci_dev pointer for PCI devices.
61 */
62static inline void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size, dma_addr_t *dma_handle)
63{ 40{
64 return pci_iommu_ops->alloc_consistent(hwdev, size, dma_handle, GFP_ATOMIC); 41 return dma_alloc_coherent(&pdev->dev, size, dma_handle, GFP_ATOMIC);
65} 42}
66 43
67/* Free and unmap a consistent DMA buffer. 44static inline void pci_free_consistent(struct pci_dev *pdev, size_t size,
68 * cpu_addr is what was returned from pci_alloc_consistent, 45 void *vaddr, dma_addr_t dma_handle)
69 * size must be the same as what as passed into pci_alloc_consistent,
70 * and likewise dma_addr must be the same as what *dma_addrp was set to.
71 *
72 * References to the memory and mappings associated with cpu_addr/dma_addr
73 * past this call are illegal.
74 */
75static inline void pci_free_consistent(struct pci_dev *hwdev, size_t size, void *vaddr, dma_addr_t dma_handle)
76{ 46{
77 return pci_iommu_ops->free_consistent(hwdev, size, vaddr, dma_handle); 47 return dma_free_coherent(&pdev->dev, size, vaddr, dma_handle);
78} 48}
79 49
80/* Map a single buffer of the indicated size for DMA in streaming mode. 50static inline dma_addr_t pci_map_single(struct pci_dev *pdev, void *ptr,
81 * The 32-bit bus address to use is returned. 51 size_t size, int direction)
82 *
83 * Once the device is given the dma address, the device owns this memory
84 * until either pci_unmap_single or pci_dma_sync_single_for_cpu is performed.
85 */
86static inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size, int direction)
87{ 52{
88 return pci_iommu_ops->map_single(hwdev, ptr, size, direction); 53 return dma_map_single(&pdev->dev, ptr, size,
54 (enum dma_data_direction) direction);
89} 55}
90 56
91/* Unmap a single streaming mode DMA translation. The dma_addr and size 57static inline void pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr,
92 * must match what was provided for in a previous pci_map_single call. All 58 size_t size, int direction)
93 * other usages are undefined.
94 *
95 * After this call, reads by the cpu to the buffer are guaranteed to see
96 * whatever the device wrote there.
97 */
98static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr, size_t size, int direction)
99{ 59{
100 pci_iommu_ops->unmap_single(hwdev, dma_addr, size, direction); 60 dma_unmap_single(&pdev->dev, dma_addr, size,
61 (enum dma_data_direction) direction);
101} 62}
102 63
103/* No highmem on sparc64, plus we have an IOMMU, so mapping pages is easy. */
104#define pci_map_page(dev, page, off, size, dir) \ 64#define pci_map_page(dev, page, off, size, dir) \
105 pci_map_single(dev, (page_address(page) + (off)), size, dir) 65 pci_map_single(dev, (page_address(page) + (off)), size, dir)
106#define pci_unmap_page(dev,addr,sz,dir) pci_unmap_single(dev,addr,sz,dir) 66#define pci_unmap_page(dev,addr,sz,dir) \
67 pci_unmap_single(dev,addr,sz,dir)
107 68
108/* pci_unmap_{single,page} is not a nop, thus... */ 69/* pci_unmap_{single,page} is not a nop, thus... */
109#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ 70#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
@@ -119,75 +80,48 @@ static inline void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
119#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \ 80#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
120 (((PTR)->LEN_NAME) = (VAL)) 81 (((PTR)->LEN_NAME) = (VAL))
121 82
122/* Map a set of buffers described by scatterlist in streaming 83static inline int pci_map_sg(struct pci_dev *pdev, struct scatterlist *sg,
123 * mode for DMA. This is the scatter-gather version of the 84 int nents, int direction)
124 * above pci_map_single interface. Here the scatter gather list
125 * elements are each tagged with the appropriate dma address
126 * and length. They are obtained via sg_dma_{address,length}(SG).
127 *
128 * NOTE: An implementation may be able to use a smaller number of
129 * DMA address/length pairs than there are SG table elements.
130 * (for example via virtual mapping capabilities)
131 * The routine returns the number of addr/length pairs actually
132 * used, at most nents.
133 *
134 * Device ownership issues as mentioned above for pci_map_single are
135 * the same here.
136 */
137static inline int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents, int direction)
138{ 85{
139 return pci_iommu_ops->map_sg(hwdev, sg, nents, direction); 86 return dma_map_sg(&pdev->dev, sg, nents,
87 (enum dma_data_direction) direction);
140} 88}
141 89
142/* Unmap a set of streaming mode DMA translations. 90static inline void pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sg,
143 * Again, cpu read rules concerning calls here are the same as for 91 int nents, int direction)
144 * pci_unmap_single() above.
145 */
146static inline void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nhwents, int direction)
147{ 92{
148 pci_iommu_ops->unmap_sg(hwdev, sg, nhwents, direction); 93 dma_unmap_sg(&pdev->dev, sg, nents,
94 (enum dma_data_direction) direction);
149} 95}
150 96
151/* Make physical memory consistent for a single 97static inline void pci_dma_sync_single_for_cpu(struct pci_dev *pdev,
152 * streaming mode DMA translation after a transfer. 98 dma_addr_t dma_handle,
153 * 99 size_t size, int direction)
154 * If you perform a pci_map_single() but wish to interrogate the
155 * buffer using the cpu, yet do not wish to teardown the PCI dma
156 * mapping, you must call this function before doing so. At the
157 * next point you give the PCI dma address back to the card, you
158 * must first perform a pci_dma_sync_for_device, and then the
159 * device again owns the buffer.
160 */
161static inline void pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t dma_handle, size_t size, int direction)
162{ 100{
163 pci_iommu_ops->dma_sync_single_for_cpu(hwdev, dma_handle, size, direction); 101 dma_sync_single_for_cpu(&pdev->dev, dma_handle, size,
102 (enum dma_data_direction) direction);
164} 103}
165 104
166static inline void 105static inline void pci_dma_sync_single_for_device(struct pci_dev *pdev,
167pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t dma_handle, 106 dma_addr_t dma_handle,
168 size_t size, int direction) 107 size_t size, int direction)
169{ 108{
170 /* No flushing needed to sync cpu writes to the device. */ 109 /* No flushing needed to sync cpu writes to the device. */
171 BUG_ON(direction == PCI_DMA_NONE);
172} 110}
173 111
174/* Make physical memory consistent for a set of streaming 112static inline void pci_dma_sync_sg_for_cpu(struct pci_dev *pdev,
175 * mode DMA translations after a transfer. 113 struct scatterlist *sg,
176 * 114 int nents, int direction)
177 * The same as pci_dma_sync_single_* but for a scatter-gather list,
178 * same rules and usage.
179 */
180static inline void pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg, int nelems, int direction)
181{ 115{
182 pci_iommu_ops->dma_sync_sg_for_cpu(hwdev, sg, nelems, direction); 116 dma_sync_sg_for_cpu(&pdev->dev, sg, nents,
117 (enum dma_data_direction) direction);
183} 118}
184 119
185static inline void 120static inline void pci_dma_sync_sg_for_device(struct pci_dev *pdev,
186pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg, 121 struct scatterlist *sg,
187 int nelems, int direction) 122 int nelems, int direction)
188{ 123{
189 /* No flushing needed to sync cpu writes to the device. */ 124 /* No flushing needed to sync cpu writes to the device. */
190 BUG_ON(direction == PCI_DMA_NONE);
191} 125}
192 126
193/* Return whether the given PCI device DMA address mask can 127/* Return whether the given PCI device DMA address mask can
@@ -206,11 +140,9 @@ extern int pci_dma_supported(struct pci_dev *hwdev, u64 mask);
206#define PCI64_REQUIRED_MASK (~(dma64_addr_t)0) 140#define PCI64_REQUIRED_MASK (~(dma64_addr_t)0)
207#define PCI64_ADDR_BASE 0xfffc000000000000UL 141#define PCI64_ADDR_BASE 0xfffc000000000000UL
208 142
209#define PCI_DMA_ERROR_CODE (~(dma_addr_t)0x0)
210
211static inline int pci_dma_mapping_error(dma_addr_t dma_addr) 143static inline int pci_dma_mapping_error(dma_addr_t dma_addr)
212{ 144{
213 return (dma_addr == PCI_DMA_ERROR_CODE); 145 return dma_mapping_error(dma_addr);
214} 146}
215 147
216#ifdef CONFIG_PCI 148#ifdef CONFIG_PCI
diff --git a/include/asm-sparc64/sbus.h b/include/asm-sparc64/sbus.h
index 7efd49d31bb8..0151cad486f3 100644
--- a/include/asm-sparc64/sbus.h
+++ b/include/asm-sparc64/sbus.h
@@ -1,7 +1,6 @@
1/* $Id: sbus.h,v 1.14 2000/02/18 13:50:55 davem Exp $ 1/* sbus.h: Defines for the Sun SBus.
2 * sbus.h: Defines for the Sun SBus.
3 * 2 *
4 * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com) 3 * Copyright (C) 1996, 1999, 2007 David S. Miller (davem@davemloft.net)
5 */ 4 */
6 5
7#ifndef _SPARC64_SBUS_H 6#ifndef _SPARC64_SBUS_H
@@ -69,7 +68,6 @@ struct sbus_dev {
69/* This struct describes the SBus(s) found on this machine. */ 68/* This struct describes the SBus(s) found on this machine. */
70struct sbus_bus { 69struct sbus_bus {
71 struct of_device ofdev; 70 struct of_device ofdev;
72 void *iommu; /* Opaque IOMMU cookie */
73 struct sbus_dev *devices; /* Tree of SBUS devices */ 71 struct sbus_dev *devices; /* Tree of SBUS devices */
74 struct sbus_bus *next; /* Next SBUS in system */ 72 struct sbus_bus *next; /* Next SBUS in system */
75 int prom_node; /* OBP node of SBUS */ 73 int prom_node; /* OBP node of SBUS */
@@ -102,9 +100,18 @@ extern struct sbus_bus *sbus_root;
102extern void sbus_set_sbus64(struct sbus_dev *, int); 100extern void sbus_set_sbus64(struct sbus_dev *, int);
103extern void sbus_fill_device_irq(struct sbus_dev *); 101extern void sbus_fill_device_irq(struct sbus_dev *);
104 102
105/* These yield IOMMU mappings in consistent mode. */ 103static inline void *sbus_alloc_consistent(struct sbus_dev *sdev , size_t size,
106extern void *sbus_alloc_consistent(struct sbus_dev *, size_t, dma_addr_t *dma_addrp); 104 dma_addr_t *dma_handle)
107extern void sbus_free_consistent(struct sbus_dev *, size_t, void *, dma_addr_t); 105{
106 return dma_alloc_coherent(&sdev->ofdev.dev, size,
107 dma_handle, GFP_ATOMIC);
108}
109
110static inline void sbus_free_consistent(struct sbus_dev *sdev, size_t size,
111 void *vaddr, dma_addr_t dma_handle)
112{
113 return dma_free_coherent(&sdev->ofdev.dev, size, vaddr, dma_handle);
114}
108 115
109#define SBUS_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL 116#define SBUS_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL
110#define SBUS_DMA_TODEVICE DMA_TO_DEVICE 117#define SBUS_DMA_TODEVICE DMA_TO_DEVICE
@@ -112,18 +119,67 @@ extern void sbus_free_consistent(struct sbus_dev *, size_t, void *, dma_addr_t);
112#define SBUS_DMA_NONE DMA_NONE 119#define SBUS_DMA_NONE DMA_NONE
113 120
114/* All the rest use streaming mode mappings. */ 121/* All the rest use streaming mode mappings. */
115extern dma_addr_t sbus_map_single(struct sbus_dev *, void *, size_t, int); 122static inline dma_addr_t sbus_map_single(struct sbus_dev *sdev, void *ptr,
116extern void sbus_unmap_single(struct sbus_dev *, dma_addr_t, size_t, int); 123 size_t size, int direction)
117extern int sbus_map_sg(struct sbus_dev *, struct scatterlist *, int, int); 124{
118extern void sbus_unmap_sg(struct sbus_dev *, struct scatterlist *, int, int); 125 return dma_map_single(&sdev->ofdev.dev, ptr, size,
126 (enum dma_data_direction) direction);
127}
128
129static inline void sbus_unmap_single(struct sbus_dev *sdev,
130 dma_addr_t dma_addr, size_t size,
131 int direction)
132{
133 dma_unmap_single(&sdev->ofdev.dev, dma_addr, size,
134 (enum dma_data_direction) direction);
135}
136
137static inline int sbus_map_sg(struct sbus_dev *sdev, struct scatterlist *sg,
138 int nents, int direction)
139{
140 return dma_map_sg(&sdev->ofdev.dev, sg, nents,
141 (enum dma_data_direction) direction);
142}
143
144static inline void sbus_unmap_sg(struct sbus_dev *sdev, struct scatterlist *sg,
145 int nents, int direction)
146{
147 dma_unmap_sg(&sdev->ofdev.dev, sg, nents,
148 (enum dma_data_direction) direction);
149}
119 150
120/* Finally, allow explicit synchronization of streamable mappings. */ 151/* Finally, allow explicit synchronization of streamable mappings. */
121extern void sbus_dma_sync_single_for_cpu(struct sbus_dev *, dma_addr_t, size_t, int); 152static inline void sbus_dma_sync_single_for_cpu(struct sbus_dev *sdev,
153 dma_addr_t dma_handle,
154 size_t size, int direction)
155{
156 dma_sync_single_for_cpu(&sdev->ofdev.dev, dma_handle, size,
157 (enum dma_data_direction) direction);
158}
122#define sbus_dma_sync_single sbus_dma_sync_single_for_cpu 159#define sbus_dma_sync_single sbus_dma_sync_single_for_cpu
123extern void sbus_dma_sync_single_for_device(struct sbus_dev *, dma_addr_t, size_t, int); 160
124extern void sbus_dma_sync_sg_for_cpu(struct sbus_dev *, struct scatterlist *, int, int); 161static inline void sbus_dma_sync_single_for_device(struct sbus_dev *sdev,
162 dma_addr_t dma_handle,
163 size_t size, int direction)
164{
165 /* No flushing needed to sync cpu writes to the device. */
166}
167
168static inline void sbus_dma_sync_sg_for_cpu(struct sbus_dev *sdev,
169 struct scatterlist *sg,
170 int nents, int direction)
171{
172 dma_sync_sg_for_cpu(&sdev->ofdev.dev, sg, nents,
173 (enum dma_data_direction) direction);
174}
125#define sbus_dma_sync_sg sbus_dma_sync_sg_for_cpu 175#define sbus_dma_sync_sg sbus_dma_sync_sg_for_cpu
126extern void sbus_dma_sync_sg_for_device(struct sbus_dev *, struct scatterlist *, int, int); 176
177static inline void sbus_dma_sync_sg_for_device(struct sbus_dev *sdev,
178 struct scatterlist *sg,
179 int nents, int direction)
180{
181 /* No flushing needed to sync cpu writes to the device. */
182}
127 183
128extern void sbus_arch_bus_ranges_init(struct device_node *, struct sbus_bus *); 184extern void sbus_arch_bus_ranges_init(struct device_node *, struct sbus_bus *);
129extern void sbus_setup_iommu(struct sbus_bus *, struct device_node *); 185extern void sbus_setup_iommu(struct sbus_bus *, struct device_node *);
diff --git a/include/asm-v850/thread_info.h b/include/asm-v850/thread_info.h
index 82b8f2846207..1a9e6ae0c5fd 100644
--- a/include/asm-v850/thread_info.h
+++ b/include/asm-v850/thread_info.h
@@ -77,16 +77,14 @@ struct thread_info {
77 * thread information flag bit numbers 77 * thread information flag bit numbers
78 */ 78 */
79#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 79#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
80#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 80#define TIF_SIGPENDING 1 /* signal pending */
81#define TIF_SIGPENDING 2 /* signal pending */ 81#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
82#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 82#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
83#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
84 TIF_NEED_RESCHED */ 83 TIF_NEED_RESCHED */
85#define TIF_MEMDIE 5 84#define TIF_MEMDIE 4
86 85
87/* as above, but as bit values */ 86/* as above, but as bit values */
88#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 87#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
89#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
90#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 88#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
91#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 89#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
92#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 90#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
diff --git a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h
index 1da8f49c0fe2..98173357dd89 100644
--- a/include/asm-x86_64/acpi.h
+++ b/include/asm-x86_64/acpi.h
@@ -108,6 +108,15 @@ static inline void acpi_disable_pci(void)
108} 108}
109extern int acpi_irq_balance_set(char *str); 109extern int acpi_irq_balance_set(char *str);
110 110
111/* routines for saving/restoring kernel state */
112extern int acpi_save_state_mem(void);
113extern void acpi_restore_state_mem(void);
114
115extern unsigned long acpi_wakeup_address;
116
117/* early initialization routine */
118extern void acpi_reserve_bootmem(void);
119
111#else /* !CONFIG_ACPI */ 120#else /* !CONFIG_ACPI */
112 121
113#define acpi_lapic 0 122#define acpi_lapic 0
@@ -121,19 +130,6 @@ extern int acpi_numa;
121extern int acpi_scan_nodes(unsigned long start, unsigned long end); 130extern int acpi_scan_nodes(unsigned long start, unsigned long end);
122#define NR_NODE_MEMBLKS (MAX_NUMNODES*2) 131#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
123 132
124#ifdef CONFIG_ACPI_SLEEP
125
126/* routines for saving/restoring kernel state */
127extern int acpi_save_state_mem(void);
128extern void acpi_restore_state_mem(void);
129
130extern unsigned long acpi_wakeup_address;
131
132/* early initialization routine */
133extern void acpi_reserve_bootmem(void);
134
135#endif /*CONFIG_ACPI_SLEEP*/
136
137extern int acpi_disabled; 133extern int acpi_disabled;
138extern int acpi_pci_disabled; 134extern int acpi_pci_disabled;
139 135
diff --git a/include/asm-x86_64/ist.h b/include/asm-x86_64/ist.h
new file mode 100644
index 000000000000..338857ecbc68
--- /dev/null
+++ b/include/asm-x86_64/ist.h
@@ -0,0 +1 @@
#include <asm-i386/ist.h>
diff --git a/include/asm-x86_64/serial.h b/include/asm-x86_64/serial.h
index 8ebd765c674a..b0496e0d72a6 100644
--- a/include/asm-x86_64/serial.h
+++ b/include/asm-x86_64/serial.h
@@ -11,3 +11,19 @@
11 * megabits/second; but this requires the faster clock. 11 * megabits/second; but this requires the faster clock.
12 */ 12 */
13#define BASE_BAUD ( 1843200 / 16 ) 13#define BASE_BAUD ( 1843200 / 16 )
14
15/* Standard COM flags (except for COM4, because of the 8514 problem) */
16#ifdef CONFIG_SERIAL_DETECT_IRQ
17#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ)
18#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_AUTO_IRQ)
19#else
20#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
21#define STD_COM4_FLAGS ASYNC_BOOT_AUTOCONF
22#endif
23
24#define SERIAL_PORT_DFNS \
25 /* UART CLK PORT IRQ FLAGS */ \
26 { 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */ \
27 { 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS }, /* ttyS1 */ \
28 { 0, BASE_BAUD, 0x3E8, 4, STD_COM_FLAGS }, /* ttyS2 */ \
29 { 0, BASE_BAUD, 0x2E8, 3, STD_COM4_FLAGS }, /* ttyS3 */
diff --git a/include/asm-x86_64/suspend.h b/include/asm-x86_64/suspend.h
index 9c3f8de90d2d..b897e8cb55fb 100644
--- a/include/asm-x86_64/suspend.h
+++ b/include/asm-x86_64/suspend.h
@@ -44,7 +44,6 @@ extern unsigned long saved_context_eflags;
44 44
45extern void fix_processor_context(void); 45extern void fix_processor_context(void);
46 46
47#ifdef CONFIG_ACPI_SLEEP
48extern unsigned long saved_rip; 47extern unsigned long saved_rip;
49extern unsigned long saved_rsp; 48extern unsigned long saved_rsp;
50extern unsigned long saved_rbp; 49extern unsigned long saved_rbp;
@@ -54,4 +53,3 @@ extern unsigned long saved_rdi;
54 53
55/* routines for saving/restoring kernel state */ 54/* routines for saving/restoring kernel state */
56extern int acpi_save_state_mem(void); 55extern int acpi_save_state_mem(void);
57#endif
diff --git a/include/asm-x86_64/tce.h b/include/asm-x86_64/tce.h
index dbb047febc5e..cd955d3d112f 100644
--- a/include/asm-x86_64/tce.h
+++ b/include/asm-x86_64/tce.h
@@ -41,8 +41,8 @@ struct iommu_table;
41extern void tce_build(struct iommu_table *tbl, unsigned long index, 41extern void tce_build(struct iommu_table *tbl, unsigned long index,
42 unsigned int npages, unsigned long uaddr, int direction); 42 unsigned int npages, unsigned long uaddr, int direction);
43extern void tce_free(struct iommu_table *tbl, long index, unsigned int npages); 43extern void tce_free(struct iommu_table *tbl, long index, unsigned int npages);
44extern void* alloc_tce_table(void); 44extern void * __init alloc_tce_table(void);
45extern void free_tce_table(void *tbl); 45extern void __init free_tce_table(void *tbl);
46extern int build_tce_table(struct pci_dev *dev, void __iomem *bbar); 46extern int __init build_tce_table(struct pci_dev *dev, void __iomem *bbar);
47 47
48#endif /* _ASM_X86_64_TCE_H */ 48#endif /* _ASM_X86_64_TCE_H */
diff --git a/include/asm-x86_64/thread_info.h b/include/asm-x86_64/thread_info.h
index 33c72ef15a0c..beae2bfb62ca 100644
--- a/include/asm-x86_64/thread_info.h
+++ b/include/asm-x86_64/thread_info.h
@@ -107,7 +107,6 @@ static inline struct thread_info *stack_thread_info(void)
107 * Warning: layout of LSW is hardcoded in entry.S 107 * Warning: layout of LSW is hardcoded in entry.S
108 */ 108 */
109#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 109#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
110#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
111#define TIF_SIGPENDING 2 /* signal pending */ 110#define TIF_SIGPENDING 2 /* signal pending */
112#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 111#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
113#define TIF_SINGLESTEP 4 /* reenable singlestep on user return*/ 112#define TIF_SINGLESTEP 4 /* reenable singlestep on user return*/
@@ -126,7 +125,6 @@ static inline struct thread_info *stack_thread_info(void)
126#define TIF_FREEZE 23 /* is freezing for suspend */ 125#define TIF_FREEZE 23 /* is freezing for suspend */
127 126
128#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 127#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
129#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
130#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 128#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
131#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 129#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
132#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 130#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
diff --git a/include/asm-x86_64/uaccess.h b/include/asm-x86_64/uaccess.h
index 9df30b939c4e..f4ce8768ad44 100644
--- a/include/asm-x86_64/uaccess.h
+++ b/include/asm-x86_64/uaccess.h
@@ -100,7 +100,7 @@ struct exception_table_entry
100 case 8: __get_user_x(8,__ret_gu,__val_gu,ptr); break; \ 100 case 8: __get_user_x(8,__ret_gu,__val_gu,ptr); break; \
101 default: __get_user_bad(); break; \ 101 default: __get_user_bad(); break; \
102 } \ 102 } \
103 (x) = (typeof(*(ptr)))__val_gu; \ 103 (x) = (__force typeof(*(ptr)))__val_gu; \
104 __ret_gu; \ 104 __ret_gu; \
105}) 105})
106 106
@@ -192,7 +192,7 @@ struct __large_struct { unsigned long buf[100]; };
192 int __gu_err; \ 192 int __gu_err; \
193 unsigned long __gu_val; \ 193 unsigned long __gu_val; \
194 __get_user_size(__gu_val,(ptr),(size),__gu_err); \ 194 __get_user_size(__gu_val,(ptr),(size),__gu_err); \
195 (x) = (typeof(*(ptr)))__gu_val; \ 195 (x) = (__force typeof(*(ptr)))__gu_val; \
196 __gu_err; \ 196 __gu_err; \
197}) 197})
198 198
diff --git a/include/asm-xtensa/io.h b/include/asm-xtensa/io.h
index 31ffc3f119c1..0faa614d9696 100644
--- a/include/asm-xtensa/io.h
+++ b/include/asm-xtensa/io.h
@@ -13,6 +13,7 @@
13 13
14#ifdef __KERNEL__ 14#ifdef __KERNEL__
15#include <asm/byteorder.h> 15#include <asm/byteorder.h>
16#include <asm/page.h>
16 17
17#include <linux/types.h> 18#include <linux/types.h>
18 19
diff --git a/include/asm-xtensa/thread_info.h b/include/asm-xtensa/thread_info.h
index 3fa29799b435..52c958285bcb 100644
--- a/include/asm-xtensa/thread_info.h
+++ b/include/asm-xtensa/thread_info.h
@@ -110,17 +110,15 @@ static inline struct thread_info *current_thread_info(void)
110 * - other flags in MSW 110 * - other flags in MSW
111 */ 111 */
112#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 112#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
113#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 113#define TIF_SIGPENDING 1 /* signal pending */
114#define TIF_SIGPENDING 2 /* signal pending */ 114#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
115#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 115#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
116#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */ 116#define TIF_IRET 4 /* return with iret */
117#define TIF_IRET 5 /* return with iret */ 117#define TIF_MEMDIE 5
118#define TIF_MEMDIE 6 118#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
119#define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal() */
120#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 119#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
121 120
122#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 121#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
123#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
124#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 122#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
125#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 123#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
126#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 124#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index bcf875e844fe..ad7f71a81b0a 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -137,6 +137,7 @@ header-y += radeonfb.h
137header-y += raw.h 137header-y += raw.h
138header-y += resource.h 138header-y += resource.h
139header-y += rose.h 139header-y += rose.h
140header-y += serial_reg.h
140header-y += smbno.h 141header-y += smbno.h
141header-y += snmp.h 142header-y += snmp.h
142header-y += sockios.h 143header-y += sockios.h
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index d5680cd7746a..bf5e0009de75 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -33,6 +33,7 @@
33#endif 33#endif
34 34
35#include <linux/list.h> 35#include <linux/list.h>
36#include <linux/mod_devicetable.h>
36 37
37#include <acpi/acpi.h> 38#include <acpi/acpi.h>
38#include <acpi/acpi_bus.h> 39#include <acpi/acpi_bus.h>
diff --git a/include/linux/apm_bios.h b/include/linux/apm_bios.h
index 290aef326812..5f921c84827a 100644
--- a/include/linux/apm_bios.h
+++ b/include/linux/apm_bios.h
@@ -21,20 +21,22 @@ typedef unsigned short apm_eventinfo_t;
21 21
22#ifdef __KERNEL__ 22#ifdef __KERNEL__
23 23
24#include <linux/types.h>
25
24#define APM_CS (GDT_ENTRY_APMBIOS_BASE * 8) 26#define APM_CS (GDT_ENTRY_APMBIOS_BASE * 8)
25#define APM_CS_16 (APM_CS + 8) 27#define APM_CS_16 (APM_CS + 8)
26#define APM_DS (APM_CS_16 + 8) 28#define APM_DS (APM_CS_16 + 8)
27 29
28struct apm_bios_info { 30struct apm_bios_info {
29 unsigned short version; 31 u16 version;
30 unsigned short cseg; 32 u16 cseg;
31 unsigned long offset; 33 u32 offset;
32 unsigned short cseg_16; 34 u16 cseg_16;
33 unsigned short dseg; 35 u16 dseg;
34 unsigned short flags; 36 u16 flags;
35 unsigned short cseg_len; 37 u16 cseg_len;
36 unsigned short cseg_16_len; 38 u16 cseg_16_len;
37 unsigned short dseg_len; 39 u16 dseg_len;
38}; 40};
39 41
40/* Results of APM Installation Check */ 42/* Results of APM Installation Check */
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 695e34964cb7..b126c6f68e27 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -37,7 +37,7 @@
37struct scsi_ioctl_command; 37struct scsi_ioctl_command;
38 38
39struct request_queue; 39struct request_queue;
40typedef struct request_queue request_queue_t; 40typedef struct request_queue request_queue_t __deprecated;
41struct elevator_queue; 41struct elevator_queue;
42typedef struct elevator_queue elevator_t; 42typedef struct elevator_queue elevator_t;
43struct request_pm_state; 43struct request_pm_state;
@@ -233,7 +233,7 @@ struct request {
233 struct list_head queuelist; 233 struct list_head queuelist;
234 struct list_head donelist; 234 struct list_head donelist;
235 235
236 request_queue_t *q; 236 struct request_queue *q;
237 237
238 unsigned int cmd_flags; 238 unsigned int cmd_flags;
239 enum rq_cmd_type_bits cmd_type; 239 enum rq_cmd_type_bits cmd_type;
@@ -337,15 +337,15 @@ struct request_pm_state
337 337
338#include <linux/elevator.h> 338#include <linux/elevator.h>
339 339
340typedef void (request_fn_proc) (request_queue_t *q); 340typedef void (request_fn_proc) (struct request_queue *q);
341typedef int (make_request_fn) (request_queue_t *q, struct bio *bio); 341typedef int (make_request_fn) (struct request_queue *q, struct bio *bio);
342typedef int (prep_rq_fn) (request_queue_t *, struct request *); 342typedef int (prep_rq_fn) (struct request_queue *, struct request *);
343typedef void (unplug_fn) (request_queue_t *); 343typedef void (unplug_fn) (struct request_queue *);
344 344
345struct bio_vec; 345struct bio_vec;
346typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *); 346typedef int (merge_bvec_fn) (struct request_queue *, struct bio *, struct bio_vec *);
347typedef int (issue_flush_fn) (request_queue_t *, struct gendisk *, sector_t *); 347typedef int (issue_flush_fn) (struct request_queue *, struct gendisk *, sector_t *);
348typedef void (prepare_flush_fn) (request_queue_t *, struct request *); 348typedef void (prepare_flush_fn) (struct request_queue *, struct request *);
349typedef void (softirq_done_fn)(struct request *); 349typedef void (softirq_done_fn)(struct request *);
350 350
351enum blk_queue_state { 351enum blk_queue_state {
@@ -483,8 +483,8 @@ struct request_queue
483#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */ 483#define QUEUE_FLAG_CLUSTER 0 /* cluster several segments into 1 */
484#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */ 484#define QUEUE_FLAG_QUEUED 1 /* uses generic tag queueing */
485#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */ 485#define QUEUE_FLAG_STOPPED 2 /* queue is stopped */
486#define QUEUE_FLAG_READFULL 3 /* write queue has been filled */ 486#define QUEUE_FLAG_READFULL 3 /* read queue has been filled */
487#define QUEUE_FLAG_WRITEFULL 4 /* read queue has been filled */ 487#define QUEUE_FLAG_WRITEFULL 4 /* write queue has been filled */
488#define QUEUE_FLAG_DEAD 5 /* queue being torn down */ 488#define QUEUE_FLAG_DEAD 5 /* queue being torn down */
489#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ 489#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */
490#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ 490#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */
@@ -626,13 +626,13 @@ extern unsigned long blk_max_low_pfn, blk_max_pfn;
626 626
627#ifdef CONFIG_BOUNCE 627#ifdef CONFIG_BOUNCE
628extern int init_emergency_isa_pool(void); 628extern int init_emergency_isa_pool(void);
629extern void blk_queue_bounce(request_queue_t *q, struct bio **bio); 629extern void blk_queue_bounce(struct request_queue *q, struct bio **bio);
630#else 630#else
631static inline int init_emergency_isa_pool(void) 631static inline int init_emergency_isa_pool(void)
632{ 632{
633 return 0; 633 return 0;
634} 634}
635static inline void blk_queue_bounce(request_queue_t *q, struct bio **bio) 635static inline void blk_queue_bounce(struct request_queue *q, struct bio **bio)
636{ 636{
637} 637}
638#endif /* CONFIG_MMU */ 638#endif /* CONFIG_MMU */
@@ -646,14 +646,14 @@ extern void blk_unregister_queue(struct gendisk *disk);
646extern void register_disk(struct gendisk *dev); 646extern void register_disk(struct gendisk *dev);
647extern void generic_make_request(struct bio *bio); 647extern void generic_make_request(struct bio *bio);
648extern void blk_put_request(struct request *); 648extern void blk_put_request(struct request *);
649extern void __blk_put_request(request_queue_t *, struct request *); 649extern void __blk_put_request(struct request_queue *, struct request *);
650extern void blk_end_sync_rq(struct request *rq, int error); 650extern void blk_end_sync_rq(struct request *rq, int error);
651extern struct request *blk_get_request(request_queue_t *, int, gfp_t); 651extern struct request *blk_get_request(struct request_queue *, int, gfp_t);
652extern void blk_insert_request(request_queue_t *, struct request *, int, void *); 652extern void blk_insert_request(struct request_queue *, struct request *, int, void *);
653extern void blk_requeue_request(request_queue_t *, struct request *); 653extern void blk_requeue_request(struct request_queue *, struct request *);
654extern void blk_plug_device(request_queue_t *); 654extern void blk_plug_device(struct request_queue *);
655extern int blk_remove_plug(request_queue_t *); 655extern int blk_remove_plug(struct request_queue *);
656extern void blk_recount_segments(request_queue_t *, struct bio *); 656extern void blk_recount_segments(struct request_queue *, struct bio *);
657extern int scsi_cmd_ioctl(struct file *, struct request_queue *, 657extern int scsi_cmd_ioctl(struct file *, struct request_queue *,
658 struct gendisk *, unsigned int, void __user *); 658 struct gendisk *, unsigned int, void __user *);
659extern int sg_scsi_ioctl(struct file *, struct request_queue *, 659extern int sg_scsi_ioctl(struct file *, struct request_queue *,
@@ -662,14 +662,15 @@ extern int sg_scsi_ioctl(struct file *, struct request_queue *,
662/* 662/*
663 * Temporary export, until SCSI gets fixed up. 663 * Temporary export, until SCSI gets fixed up.
664 */ 664 */
665extern int ll_back_merge_fn(request_queue_t *, struct request *, struct bio *); 665extern int ll_back_merge_fn(struct request_queue *, struct request *,
666 struct bio *);
666 667
667/* 668/*
668 * A queue has just exitted congestion. Note this in the global counter of 669 * A queue has just exitted congestion. Note this in the global counter of
669 * congested queues, and wake up anyone who was waiting for requests to be 670 * congested queues, and wake up anyone who was waiting for requests to be
670 * put back. 671 * put back.
671 */ 672 */
672static inline void blk_clear_queue_congested(request_queue_t *q, int rw) 673static inline void blk_clear_queue_congested(struct request_queue *q, int rw)
673{ 674{
674 clear_bdi_congested(&q->backing_dev_info, rw); 675 clear_bdi_congested(&q->backing_dev_info, rw);
675} 676}
@@ -678,29 +679,29 @@ static inline void blk_clear_queue_congested(request_queue_t *q, int rw)
678 * A queue has just entered congestion. Flag that in the queue's VM-visible 679 * A queue has just entered congestion. Flag that in the queue's VM-visible
679 * state flags and increment the global gounter of congested queues. 680 * state flags and increment the global gounter of congested queues.
680 */ 681 */
681static inline void blk_set_queue_congested(request_queue_t *q, int rw) 682static inline void blk_set_queue_congested(struct request_queue *q, int rw)
682{ 683{
683 set_bdi_congested(&q->backing_dev_info, rw); 684 set_bdi_congested(&q->backing_dev_info, rw);
684} 685}
685 686
686extern void blk_start_queue(request_queue_t *q); 687extern void blk_start_queue(struct request_queue *q);
687extern void blk_stop_queue(request_queue_t *q); 688extern void blk_stop_queue(struct request_queue *q);
688extern void blk_sync_queue(struct request_queue *q); 689extern void blk_sync_queue(struct request_queue *q);
689extern void __blk_stop_queue(request_queue_t *q); 690extern void __blk_stop_queue(struct request_queue *q);
690extern void blk_run_queue(request_queue_t *); 691extern void blk_run_queue(struct request_queue *);
691extern void blk_start_queueing(request_queue_t *); 692extern void blk_start_queueing(struct request_queue *);
692extern int blk_rq_map_user(request_queue_t *, struct request *, void __user *, unsigned long); 693extern int blk_rq_map_user(struct request_queue *, struct request *, void __user *, unsigned long);
693extern int blk_rq_unmap_user(struct bio *); 694extern int blk_rq_unmap_user(struct bio *);
694extern int blk_rq_map_kern(request_queue_t *, struct request *, void *, unsigned int, gfp_t); 695extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsigned int, gfp_t);
695extern int blk_rq_map_user_iov(request_queue_t *, struct request *, 696extern int blk_rq_map_user_iov(struct request_queue *, struct request *,
696 struct sg_iovec *, int, unsigned int); 697 struct sg_iovec *, int, unsigned int);
697extern int blk_execute_rq(request_queue_t *, struct gendisk *, 698extern int blk_execute_rq(struct request_queue *, struct gendisk *,
698 struct request *, int); 699 struct request *, int);
699extern void blk_execute_rq_nowait(request_queue_t *, struct gendisk *, 700extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
700 struct request *, int, rq_end_io_fn *); 701 struct request *, int, rq_end_io_fn *);
701extern int blk_verify_command(unsigned char *, int); 702extern int blk_verify_command(unsigned char *, int);
702 703
703static inline request_queue_t *bdev_get_queue(struct block_device *bdev) 704static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
704{ 705{
705 return bdev->bd_disk->queue; 706 return bdev->bd_disk->queue;
706} 707}
@@ -749,41 +750,41 @@ static inline void blkdev_dequeue_request(struct request *req)
749/* 750/*
750 * Access functions for manipulating queue properties 751 * Access functions for manipulating queue properties
751 */ 752 */
752extern request_queue_t *blk_init_queue_node(request_fn_proc *rfn, 753extern struct request_queue *blk_init_queue_node(request_fn_proc *rfn,
753 spinlock_t *lock, int node_id); 754 spinlock_t *lock, int node_id);
754extern request_queue_t *blk_init_queue(request_fn_proc *, spinlock_t *); 755extern struct request_queue *blk_init_queue(request_fn_proc *, spinlock_t *);
755extern void blk_cleanup_queue(request_queue_t *); 756extern void blk_cleanup_queue(struct request_queue *);
756extern void blk_queue_make_request(request_queue_t *, make_request_fn *); 757extern void blk_queue_make_request(struct request_queue *, make_request_fn *);
757extern void blk_queue_bounce_limit(request_queue_t *, u64); 758extern void blk_queue_bounce_limit(struct request_queue *, u64);
758extern void blk_queue_max_sectors(request_queue_t *, unsigned int); 759extern void blk_queue_max_sectors(struct request_queue *, unsigned int);
759extern void blk_queue_max_phys_segments(request_queue_t *, unsigned short); 760extern void blk_queue_max_phys_segments(struct request_queue *, unsigned short);
760extern void blk_queue_max_hw_segments(request_queue_t *, unsigned short); 761extern void blk_queue_max_hw_segments(struct request_queue *, unsigned short);
761extern void blk_queue_max_segment_size(request_queue_t *, unsigned int); 762extern void blk_queue_max_segment_size(struct request_queue *, unsigned int);
762extern void blk_queue_hardsect_size(request_queue_t *, unsigned short); 763extern void blk_queue_hardsect_size(struct request_queue *, unsigned short);
763extern void blk_queue_stack_limits(request_queue_t *t, request_queue_t *b); 764extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b);
764extern void blk_queue_segment_boundary(request_queue_t *, unsigned long); 765extern void blk_queue_segment_boundary(struct request_queue *, unsigned long);
765extern void blk_queue_prep_rq(request_queue_t *, prep_rq_fn *pfn); 766extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn);
766extern void blk_queue_merge_bvec(request_queue_t *, merge_bvec_fn *); 767extern void blk_queue_merge_bvec(struct request_queue *, merge_bvec_fn *);
767extern void blk_queue_dma_alignment(request_queue_t *, int); 768extern void blk_queue_dma_alignment(struct request_queue *, int);
768extern void blk_queue_softirq_done(request_queue_t *, softirq_done_fn *); 769extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *);
769extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); 770extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev);
770extern int blk_queue_ordered(request_queue_t *, unsigned, prepare_flush_fn *); 771extern int blk_queue_ordered(struct request_queue *, unsigned, prepare_flush_fn *);
771extern void blk_queue_issue_flush_fn(request_queue_t *, issue_flush_fn *); 772extern void blk_queue_issue_flush_fn(struct request_queue *, issue_flush_fn *);
772extern int blk_do_ordered(request_queue_t *, struct request **); 773extern int blk_do_ordered(struct request_queue *, struct request **);
773extern unsigned blk_ordered_cur_seq(request_queue_t *); 774extern unsigned blk_ordered_cur_seq(struct request_queue *);
774extern unsigned blk_ordered_req_seq(struct request *); 775extern unsigned blk_ordered_req_seq(struct request *);
775extern void blk_ordered_complete_seq(request_queue_t *, unsigned, int); 776extern void blk_ordered_complete_seq(struct request_queue *, unsigned, int);
776 777
777extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); 778extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *);
778extern void blk_dump_rq_flags(struct request *, char *); 779extern void blk_dump_rq_flags(struct request *, char *);
779extern void generic_unplug_device(request_queue_t *); 780extern void generic_unplug_device(struct request_queue *);
780extern void __generic_unplug_device(request_queue_t *); 781extern void __generic_unplug_device(struct request_queue *);
781extern long nr_blockdev_pages(void); 782extern long nr_blockdev_pages(void);
782 783
783int blk_get_queue(request_queue_t *); 784int blk_get_queue(struct request_queue *);
784request_queue_t *blk_alloc_queue(gfp_t); 785struct request_queue *blk_alloc_queue(gfp_t);
785request_queue_t *blk_alloc_queue_node(gfp_t, int); 786struct request_queue *blk_alloc_queue_node(gfp_t, int);
786extern void blk_put_queue(request_queue_t *); 787extern void blk_put_queue(struct request_queue *);
787 788
788/* 789/*
789 * tag stuff 790 * tag stuff
@@ -791,13 +792,13 @@ extern void blk_put_queue(request_queue_t *);
791#define blk_queue_tag_depth(q) ((q)->queue_tags->busy) 792#define blk_queue_tag_depth(q) ((q)->queue_tags->busy)
792#define blk_queue_tag_queue(q) ((q)->queue_tags->busy < (q)->queue_tags->max_depth) 793#define blk_queue_tag_queue(q) ((q)->queue_tags->busy < (q)->queue_tags->max_depth)
793#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED) 794#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED)
794extern int blk_queue_start_tag(request_queue_t *, struct request *); 795extern int blk_queue_start_tag(struct request_queue *, struct request *);
795extern struct request *blk_queue_find_tag(request_queue_t *, int); 796extern struct request *blk_queue_find_tag(struct request_queue *, int);
796extern void blk_queue_end_tag(request_queue_t *, struct request *); 797extern void blk_queue_end_tag(struct request_queue *, struct request *);
797extern int blk_queue_init_tags(request_queue_t *, int, struct blk_queue_tag *); 798extern int blk_queue_init_tags(struct request_queue *, int, struct blk_queue_tag *);
798extern void blk_queue_free_tags(request_queue_t *); 799extern void blk_queue_free_tags(struct request_queue *);
799extern int blk_queue_resize_tags(request_queue_t *, int); 800extern int blk_queue_resize_tags(struct request_queue *, int);
800extern void blk_queue_invalidate_tags(request_queue_t *); 801extern void blk_queue_invalidate_tags(struct request_queue *);
801extern struct blk_queue_tag *blk_init_tags(int); 802extern struct blk_queue_tag *blk_init_tags(int);
802extern void blk_free_tags(struct blk_queue_tag *); 803extern void blk_free_tags(struct blk_queue_tag *);
803 804
@@ -809,7 +810,7 @@ static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
809 return bqt->tag_index[tag]; 810 return bqt->tag_index[tag];
810} 811}
811 812
812extern void blk_rq_bio_prep(request_queue_t *, struct request *, struct bio *); 813extern void blk_rq_bio_prep(struct request_queue *, struct request *, struct bio *);
813extern int blkdev_issue_flush(struct block_device *, sector_t *); 814extern int blkdev_issue_flush(struct block_device *, sector_t *);
814 815
815#define MAX_PHYS_SEGMENTS 128 816#define MAX_PHYS_SEGMENTS 128
@@ -821,7 +822,7 @@ extern int blkdev_issue_flush(struct block_device *, sector_t *);
821 822
822#define blkdev_entry_to_request(entry) list_entry((entry), struct request, queuelist) 823#define blkdev_entry_to_request(entry) list_entry((entry), struct request, queuelist)
823 824
824static inline int queue_hardsect_size(request_queue_t *q) 825static inline int queue_hardsect_size(struct request_queue *q)
825{ 826{
826 int retval = 512; 827 int retval = 512;
827 828
@@ -836,7 +837,7 @@ static inline int bdev_hardsect_size(struct block_device *bdev)
836 return queue_hardsect_size(bdev_get_queue(bdev)); 837 return queue_hardsect_size(bdev_get_queue(bdev));
837} 838}
838 839
839static inline int queue_dma_alignment(request_queue_t *q) 840static inline int queue_dma_alignment(struct request_queue *q)
840{ 841{
841 int retval = 511; 842 int retval = 511;
842 843
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index 3680ff9a30ed..90874a5d7d78 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -144,7 +144,7 @@ struct blk_user_trace_setup {
144 144
145#if defined(CONFIG_BLK_DEV_IO_TRACE) 145#if defined(CONFIG_BLK_DEV_IO_TRACE)
146extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *); 146extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
147extern void blk_trace_shutdown(request_queue_t *); 147extern void blk_trace_shutdown(struct request_queue *);
148extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *); 148extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *);
149 149
150/** 150/**
diff --git a/include/linux/bsg.h b/include/linux/bsg.h
index f415f89e0ac8..102dc096e1cb 100644
--- a/include/linux/bsg.h
+++ b/include/linux/bsg.h
@@ -53,15 +53,19 @@ struct bsg_class_device {
53 struct class_device *class_dev; 53 struct class_device *class_dev;
54 struct device *dev; 54 struct device *dev;
55 int minor; 55 int minor;
56 struct list_head list;
57 struct request_queue *queue; 56 struct request_queue *queue;
58}; 57};
59 58
60extern int bsg_register_queue(struct request_queue *, struct device *, const char *); 59extern int bsg_register_queue(struct request_queue *, struct device *, const char *);
61extern void bsg_unregister_queue(struct request_queue *); 60extern void bsg_unregister_queue(struct request_queue *);
62#else 61#else
63#define bsg_register_queue(disk, dev, name) (0) 62static inline int bsg_register_queue(struct request_queue * rq, struct device *dev, const char *name)
64#define bsg_unregister_queue(disk) do { } while (0) 63{
64 return 0;
65}
66static inline void bsg_unregister_queue(struct request_queue *rq)
67{
68}
65#endif 69#endif
66 70
67#endif /* __KERNEL__ */ 71#endif /* __KERNEL__ */
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 12a1291855e2..86f9a3a6137d 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -15,8 +15,8 @@
15# define __acquire(x) __context__(x,1) 15# define __acquire(x) __context__(x,1)
16# define __release(x) __context__(x,-1) 16# define __release(x) __context__(x,-1)
17# define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0) 17# define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
18extern void __chk_user_ptr(const void __user *); 18extern void __chk_user_ptr(const volatile void __user *);
19extern void __chk_io_ptr(const void __iomem *); 19extern void __chk_io_ptr(const volatile void __iomem *);
20#else 20#else
21# define __user 21# define __user
22# define __kernel 22# define __kernel
diff --git a/include/linux/device.h b/include/linux/device.h
index d9f0a57f5a2f..3a38d1f70cb7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -551,6 +551,9 @@ extern void put_device(struct device * dev);
551/* drivers/base/power/shutdown.c */ 551/* drivers/base/power/shutdown.c */
552extern void device_shutdown(void); 552extern void device_shutdown(void);
553 553
554/* drivers/base/sys.c */
555extern void sysdev_shutdown(void);
556
554 557
555/* drivers/base/firmware.c */ 558/* drivers/base/firmware.c */
556extern int __must_check firmware_register(struct kset *); 559extern int __must_check firmware_register(struct kset *);
diff --git a/include/linux/dvb/video.h b/include/linux/dvb/video.h
index 93e4c3a6d190..50839fe9e39e 100644
--- a/include/linux/dvb/video.h
+++ b/include/linux/dvb/video.h
@@ -29,6 +29,7 @@
29#ifdef __KERNEL__ 29#ifdef __KERNEL__
30#include <linux/types.h> 30#include <linux/types.h>
31#else 31#else
32#include <asm/types.h>
32#include <stdint.h> 33#include <stdint.h>
33#include <time.h> 34#include <time.h>
34#endif 35#endif
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index e88fcbc77f8f..e8f42133a616 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -5,29 +5,29 @@
5 5
6#ifdef CONFIG_BLOCK 6#ifdef CONFIG_BLOCK
7 7
8typedef int (elevator_merge_fn) (request_queue_t *, struct request **, 8typedef int (elevator_merge_fn) (struct request_queue *, struct request **,
9 struct bio *); 9 struct bio *);
10 10
11typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struct request *); 11typedef void (elevator_merge_req_fn) (struct request_queue *, struct request *, struct request *);
12 12
13typedef void (elevator_merged_fn) (request_queue_t *, struct request *, int); 13typedef void (elevator_merged_fn) (struct request_queue *, struct request *, int);
14 14
15typedef int (elevator_allow_merge_fn) (request_queue_t *, struct request *, struct bio *); 15typedef int (elevator_allow_merge_fn) (struct request_queue *, struct request *, struct bio *);
16 16
17typedef int (elevator_dispatch_fn) (request_queue_t *, int); 17typedef int (elevator_dispatch_fn) (struct request_queue *, int);
18 18
19typedef void (elevator_add_req_fn) (request_queue_t *, struct request *); 19typedef void (elevator_add_req_fn) (struct request_queue *, struct request *);
20typedef int (elevator_queue_empty_fn) (request_queue_t *); 20typedef int (elevator_queue_empty_fn) (struct request_queue *);
21typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *); 21typedef struct request *(elevator_request_list_fn) (struct request_queue *, struct request *);
22typedef void (elevator_completed_req_fn) (request_queue_t *, struct request *); 22typedef void (elevator_completed_req_fn) (struct request_queue *, struct request *);
23typedef int (elevator_may_queue_fn) (request_queue_t *, int); 23typedef int (elevator_may_queue_fn) (struct request_queue *, int);
24 24
25typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, gfp_t); 25typedef int (elevator_set_req_fn) (struct request_queue *, struct request *, gfp_t);
26typedef void (elevator_put_req_fn) (struct request *); 26typedef void (elevator_put_req_fn) (struct request *);
27typedef void (elevator_activate_req_fn) (request_queue_t *, struct request *); 27typedef void (elevator_activate_req_fn) (struct request_queue *, struct request *);
28typedef void (elevator_deactivate_req_fn) (request_queue_t *, struct request *); 28typedef void (elevator_deactivate_req_fn) (struct request_queue *, struct request *);
29 29
30typedef void *(elevator_init_fn) (request_queue_t *); 30typedef void *(elevator_init_fn) (struct request_queue *);
31typedef void (elevator_exit_fn) (elevator_t *); 31typedef void (elevator_exit_fn) (elevator_t *);
32 32
33struct elevator_ops 33struct elevator_ops
@@ -94,27 +94,27 @@ struct elevator_queue
94/* 94/*
95 * block elevator interface 95 * block elevator interface
96 */ 96 */
97extern void elv_dispatch_sort(request_queue_t *, struct request *); 97extern void elv_dispatch_sort(struct request_queue *, struct request *);
98extern void elv_dispatch_add_tail(request_queue_t *, struct request *); 98extern void elv_dispatch_add_tail(struct request_queue *, struct request *);
99extern void elv_add_request(request_queue_t *, struct request *, int, int); 99extern void elv_add_request(struct request_queue *, struct request *, int, int);
100extern void __elv_add_request(request_queue_t *, struct request *, int, int); 100extern void __elv_add_request(struct request_queue *, struct request *, int, int);
101extern void elv_insert(request_queue_t *, struct request *, int); 101extern void elv_insert(struct request_queue *, struct request *, int);
102extern int elv_merge(request_queue_t *, struct request **, struct bio *); 102extern int elv_merge(struct request_queue *, struct request **, struct bio *);
103extern void elv_merge_requests(request_queue_t *, struct request *, 103extern void elv_merge_requests(struct request_queue *, struct request *,
104 struct request *); 104 struct request *);
105extern void elv_merged_request(request_queue_t *, struct request *, int); 105extern void elv_merged_request(struct request_queue *, struct request *, int);
106extern void elv_dequeue_request(request_queue_t *, struct request *); 106extern void elv_dequeue_request(struct request_queue *, struct request *);
107extern void elv_requeue_request(request_queue_t *, struct request *); 107extern void elv_requeue_request(struct request_queue *, struct request *);
108extern int elv_queue_empty(request_queue_t *); 108extern int elv_queue_empty(struct request_queue *);
109extern struct request *elv_next_request(struct request_queue *q); 109extern struct request *elv_next_request(struct request_queue *q);
110extern struct request *elv_former_request(request_queue_t *, struct request *); 110extern struct request *elv_former_request(struct request_queue *, struct request *);
111extern struct request *elv_latter_request(request_queue_t *, struct request *); 111extern struct request *elv_latter_request(struct request_queue *, struct request *);
112extern int elv_register_queue(request_queue_t *q); 112extern int elv_register_queue(struct request_queue *q);
113extern void elv_unregister_queue(request_queue_t *q); 113extern void elv_unregister_queue(struct request_queue *q);
114extern int elv_may_queue(request_queue_t *, int); 114extern int elv_may_queue(struct request_queue *, int);
115extern void elv_completed_request(request_queue_t *, struct request *); 115extern void elv_completed_request(struct request_queue *, struct request *);
116extern int elv_set_request(request_queue_t *, struct request *, gfp_t); 116extern int elv_set_request(struct request_queue *, struct request *, gfp_t);
117extern void elv_put_request(request_queue_t *, struct request *); 117extern void elv_put_request(struct request_queue *, struct request *);
118 118
119/* 119/*
120 * io scheduler registration 120 * io scheduler registration
@@ -125,18 +125,18 @@ extern void elv_unregister(struct elevator_type *);
125/* 125/*
126 * io scheduler sysfs switching 126 * io scheduler sysfs switching
127 */ 127 */
128extern ssize_t elv_iosched_show(request_queue_t *, char *); 128extern ssize_t elv_iosched_show(struct request_queue *, char *);
129extern ssize_t elv_iosched_store(request_queue_t *, const char *, size_t); 129extern ssize_t elv_iosched_store(struct request_queue *, const char *, size_t);
130 130
131extern int elevator_init(request_queue_t *, char *); 131extern int elevator_init(struct request_queue *, char *);
132extern void elevator_exit(elevator_t *); 132extern void elevator_exit(elevator_t *);
133extern int elv_rq_merge_ok(struct request *, struct bio *); 133extern int elv_rq_merge_ok(struct request *, struct bio *);
134 134
135/* 135/*
136 * Helper functions. 136 * Helper functions.
137 */ 137 */
138extern struct request *elv_rb_former_request(request_queue_t *, struct request *); 138extern struct request *elv_rb_former_request(struct request_queue *, struct request *);
139extern struct request *elv_rb_latter_request(request_queue_t *, struct request *); 139extern struct request *elv_rb_latter_request(struct request_queue *, struct request *);
140 140
141/* 141/*
142 * rb support functions. 142 * rb support functions.
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 3a632244f31b..23ccea811297 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -270,8 +270,6 @@ u32 ethtool_op_get_sg(struct net_device *dev);
270int ethtool_op_set_sg(struct net_device *dev, u32 data); 270int ethtool_op_set_sg(struct net_device *dev, u32 data);
271u32 ethtool_op_get_tso(struct net_device *dev); 271u32 ethtool_op_get_tso(struct net_device *dev);
272int ethtool_op_set_tso(struct net_device *dev, u32 data); 272int ethtool_op_set_tso(struct net_device *dev, u32 data);
273int ethtool_op_get_perm_addr(struct net_device *dev,
274 struct ethtool_perm_addr *addr, u8 *data);
275u32 ethtool_op_get_ufo(struct net_device *dev); 273u32 ethtool_op_get_ufo(struct net_device *dev);
276int ethtool_op_set_ufo(struct net_device *dev, u32 data); 274int ethtool_op_set_ufo(struct net_device *dev, u32 data);
277 275
@@ -309,7 +307,6 @@ int ethtool_op_set_ufo(struct net_device *dev, u32 data);
309 * get_strings: Return a set of strings that describe the requested objects 307 * get_strings: Return a set of strings that describe the requested objects
310 * phys_id: Identify the device 308 * phys_id: Identify the device
311 * get_stats: Return statistics about the device 309 * get_stats: Return statistics about the device
312 * get_perm_addr: Gets the permanent hardware address
313 * 310 *
314 * Description: 311 * Description:
315 * 312 *
@@ -368,7 +365,6 @@ struct ethtool_ops {
368 int (*phys_id)(struct net_device *, u32); 365 int (*phys_id)(struct net_device *, u32);
369 int (*get_stats_count)(struct net_device *); 366 int (*get_stats_count)(struct net_device *);
370 void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *, u64 *); 367 void (*get_ethtool_stats)(struct net_device *, struct ethtool_stats *, u64 *);
371 int (*get_perm_addr)(struct net_device *, struct ethtool_perm_addr *, u8 *);
372 int (*begin)(struct net_device *); 368 int (*begin)(struct net_device *);
373 void (*complete)(struct net_device *); 369 void (*complete)(struct net_device *);
374 u32 (*get_ufo)(struct net_device *); 370 u32 (*get_ufo)(struct net_device *);
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index c8e02de737f6..efded00ad08c 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -5,7 +5,7 @@
5 5
6#include <linux/sched.h> 6#include <linux/sched.h>
7 7
8#ifdef CONFIG_PM 8#ifdef CONFIG_PM_SLEEP
9/* 9/*
10 * Check if a process has been frozen 10 * Check if a process has been frozen
11 */ 11 */
@@ -126,7 +126,7 @@ static inline void set_freezable(void)
126 current->flags &= ~PF_NOFREEZE; 126 current->flags &= ~PF_NOFREEZE;
127} 127}
128 128
129#else 129#else /* !CONFIG_PM_SLEEP */
130static inline int frozen(struct task_struct *p) { return 0; } 130static inline int frozen(struct task_struct *p) { return 0; }
131static inline int freezing(struct task_struct *p) { return 0; } 131static inline int freezing(struct task_struct *p) { return 0; }
132static inline void set_freeze_flag(struct task_struct *p) {} 132static inline void set_freeze_flag(struct task_struct *p) {}
@@ -143,6 +143,6 @@ static inline void freezer_do_not_count(void) {}
143static inline void freezer_count(void) {} 143static inline void freezer_count(void) {}
144static inline int freezer_should_skip(struct task_struct *p) { return 0; } 144static inline int freezer_should_skip(struct task_struct *p) { return 0; }
145static inline void set_freezable(void) {} 145static inline void set_freezable(void) {}
146#endif 146#endif /* !CONFIG_PM_SLEEP */
147 147
148#endif /* FREEZER_H_INCLUDED */ 148#endif /* FREEZER_H_INCLUDED */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index d33beadd9a43..6bf139562947 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -878,7 +878,7 @@ extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
878extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl); 878extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
879extern int __break_lease(struct inode *inode, unsigned int flags); 879extern int __break_lease(struct inode *inode, unsigned int flags);
880extern void lease_get_mtime(struct inode *, struct timespec *time); 880extern void lease_get_mtime(struct inode *, struct timespec *time);
881extern int setlease(struct file *, long, struct file_lock **); 881extern int generic_setlease(struct file *, long, struct file_lock **);
882extern int vfs_setlease(struct file *, long, struct file_lock **); 882extern int vfs_setlease(struct file *, long, struct file_lock **);
883extern int lease_modify(struct file_lock **, int); 883extern int lease_modify(struct file_lock **, int);
884extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 884extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index 9756fc102a83..a47b8025d399 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -264,7 +264,7 @@ static inline void set_capacity(struct gendisk *disk, sector_t size)
264 264
265#ifdef CONFIG_SOLARIS_X86_PARTITION 265#ifdef CONFIG_SOLARIS_X86_PARTITION
266 266
267#define SOLARIS_X86_NUMSLICE 8 267#define SOLARIS_X86_NUMSLICE 16
268#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL) 268#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL)
269 269
270struct solaris_x86_slice { 270struct solaris_x86_slice {
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 49b7053043ad..e6a71c82d204 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -1,6 +1,8 @@
1#ifndef _LINUX_HUGETLB_H 1#ifndef _LINUX_HUGETLB_H
2#define _LINUX_HUGETLB_H 2#define _LINUX_HUGETLB_H
3 3
4#include <linux/fs.h>
5
4#ifdef CONFIG_HUGETLB_PAGE 6#ifdef CONFIG_HUGETLB_PAGE
5 7
6#include <linux/mempolicy.h> 8#include <linux/mempolicy.h>
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 0c37a737a2b2..2a32f2fd940d 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -156,10 +156,14 @@ struct i2c_driver {
156 * @name: Indicates the type of the device, usually a chip name that's 156 * @name: Indicates the type of the device, usually a chip name that's
157 * generic enough to hide second-sourcing and compatible revisions. 157 * generic enough to hide second-sourcing and compatible revisions.
158 * @adapter: manages the bus segment hosting this I2C device 158 * @adapter: manages the bus segment hosting this I2C device
159 * @driver: device's driver, hence pointer to access routines
160 * @usage_count: counts current number of users of this client
159 * @dev: Driver model device node for the slave. 161 * @dev: Driver model device node for the slave.
160 * @irq: indicates the IRQ generated by this device (if any) 162 * @irq: indicates the IRQ generated by this device (if any)
161 * @driver_name: Identifies new-style driver used with this device; also 163 * @driver_name: Identifies new-style driver used with this device; also
162 * used as the module name for hotplug/coldplug modprobe support. 164 * used as the module name for hotplug/coldplug modprobe support.
165 * @list: list of active/busy clients
166 * @released: used to synchronize client releases & detaches and references
163 * 167 *
164 * An i2c_client identifies a single device (i.e. chip) connected to an 168 * An i2c_client identifies a single device (i.e. chip) connected to an
165 * i2c bus. The behaviour exposed to Linux is defined by the driver 169 * i2c bus. The behaviour exposed to Linux is defined by the driver
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 5f5daad8bc54..d71d0121b7f9 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -555,7 +555,7 @@ typedef struct ide_drive_s {
555 char name[4]; /* drive name, such as "hda" */ 555 char name[4]; /* drive name, such as "hda" */
556 char driver_req[10]; /* requests specific driver */ 556 char driver_req[10]; /* requests specific driver */
557 557
558 request_queue_t *queue; /* request queue */ 558 struct request_queue *queue; /* request queue */
559 559
560 struct request *rq; /* current request */ 560 struct request *rq; /* current request */
561 struct ide_drive_s *next; /* circular list of hwgroup drives */ 561 struct ide_drive_s *next; /* circular list of hwgroup drives */
@@ -1206,7 +1206,7 @@ extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout);
1206extern int ide_spin_wait_hwgroup(ide_drive_t *); 1206extern int ide_spin_wait_hwgroup(ide_drive_t *);
1207extern void ide_timer_expiry(unsigned long); 1207extern void ide_timer_expiry(unsigned long);
1208extern irqreturn_t ide_intr(int irq, void *dev_id); 1208extern irqreturn_t ide_intr(int irq, void *dev_id);
1209extern void do_ide_request(request_queue_t *); 1209extern void do_ide_request(struct request_queue *);
1210 1210
1211void ide_init_disk(struct gendisk *, ide_drive_t *); 1211void ide_init_disk(struct gendisk *, ide_drive_t *);
1212 1212
diff --git a/include/linux/init.h b/include/linux/init.h
index f0d0e3295a9b..1a4a283d19a9 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -114,7 +114,7 @@ void prepare_namespace(void);
114 * 114 *
115 * This only exists for built-in code, not for modules. 115 * This only exists for built-in code, not for modules.
116 */ 116 */
117#define pure_initcall(fn) __define_initcall("0",fn,1) 117#define pure_initcall(fn) __define_initcall("0",fn,0)
118 118
119#define core_initcall(fn) __define_initcall("1",fn,1) 119#define core_initcall(fn) __define_initcall("1",fn,1)
120#define core_initcall_sync(fn) __define_initcall("1s",fn,1s) 120#define core_initcall_sync(fn) __define_initcall("1s",fn,1s)
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 0a3c2ebf2008..5523f19d88d2 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -11,8 +11,6 @@
11#include <linux/hardirq.h> 11#include <linux/hardirq.h>
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/irqflags.h> 13#include <linux/irqflags.h>
14#include <linux/bottom_half.h>
15#include <linux/device.h>
16#include <asm/atomic.h> 14#include <asm/atomic.h>
17#include <asm/ptrace.h> 15#include <asm/ptrace.h>
18#include <asm/system.h> 16#include <asm/system.h>
@@ -97,6 +95,8 @@ extern int __must_check request_irq(unsigned int, irq_handler_t handler,
97 unsigned long, const char *, void *); 95 unsigned long, const char *, void *);
98extern void free_irq(unsigned int, void *); 96extern void free_irq(unsigned int, void *);
99 97
98struct device;
99
100extern int __must_check devm_request_irq(struct device *dev, unsigned int irq, 100extern int __must_check devm_request_irq(struct device *dev, unsigned int irq,
101 irq_handler_t handler, unsigned long irqflags, 101 irq_handler_t handler, unsigned long irqflags,
102 const char *devname, void *dev_id); 102 const char *devname, void *dev_id);
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 97983dc9df13..4ca60c3320fb 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -219,7 +219,6 @@ enum {
219#include <linux/tcp.h> 219#include <linux/tcp.h>
220#include <linux/udp.h> 220#include <linux/udp.h>
221 221
222#include <net/if_inet6.h> /* struct ipv6_mc_socklist */
223#include <net/inet_sock.h> 222#include <net/inet_sock.h>
224 223
225static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb) 224static inline struct ipv6hdr *ipv6_hdr(const struct sk_buff *skb)
@@ -273,6 +272,10 @@ struct tcp6_request_sock {
273 struct inet6_request_sock tcp6rsk_inet6; 272 struct inet6_request_sock tcp6rsk_inet6;
274}; 273};
275 274
275struct ipv6_mc_socklist;
276struct ipv6_ac_socklist;
277struct ipv6_fl_socklist;
278
276/** 279/**
277 * struct ipv6_pinfo - ipv6 private area 280 * struct ipv6_pinfo - ipv6 private area
278 * 281 *
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 44657197fcb0..efc88538b2ba 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -140,6 +140,7 @@ struct irq_chip {
140 * @wake_depth: enable depth, for multiple set_irq_wake() callers 140 * @wake_depth: enable depth, for multiple set_irq_wake() callers
141 * @irq_count: stats field to detect stalled irqs 141 * @irq_count: stats field to detect stalled irqs
142 * @irqs_unhandled: stats field for spurious unhandled interrupts 142 * @irqs_unhandled: stats field for spurious unhandled interrupts
143 * @last_unhandled: aging timer for unhandled count
143 * @lock: locking for SMP 144 * @lock: locking for SMP
144 * @affinity: IRQ affinity on SMP 145 * @affinity: IRQ affinity on SMP
145 * @cpu: cpu index useful for balancing 146 * @cpu: cpu index useful for balancing
diff --git a/include/linux/kdebug.h b/include/linux/kdebug.h
index 5db38d6d8b92..ed815090b3bc 100644
--- a/include/linux/kdebug.h
+++ b/include/linux/kdebug.h
@@ -3,6 +3,8 @@
3 3
4#include <asm/kdebug.h> 4#include <asm/kdebug.h>
5 5
6struct notifier_block;
7
6struct die_args { 8struct die_args {
7 struct pt_regs *regs; 9 struct pt_regs *regs;
8 const char *str; 10 const char *str;
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index aa2fe22b1baa..949706c33622 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -56,6 +56,9 @@ enum kobject_action {
56 KOBJ_MAX 56 KOBJ_MAX
57}; 57};
58 58
59/* The list of strings defining the valid kobject actions as specified above */
60extern const char *kobject_actions[];
61
59struct kobject { 62struct kobject {
60 const char * k_name; 63 const char * k_name;
61 char name[KOBJ_NAME_LEN]; 64 char name[KOBJ_NAME_LEN];
@@ -108,9 +111,15 @@ struct kobj_type {
108 struct attribute ** default_attrs; 111 struct attribute ** default_attrs;
109}; 112};
110 113
114struct kset_uevent_ops {
115 int (*filter)(struct kset *kset, struct kobject *kobj);
116 const char *(*name)(struct kset *kset, struct kobject *kobj);
117 int (*uevent)(struct kset *kset, struct kobject *kobj, char **envp,
118 int num_envp, char *buffer, int buffer_size);
119};
111 120
112/** 121/*
113 * kset - a set of kobjects of a specific type, belonging 122 * struct kset - a set of kobjects of a specific type, belonging
114 * to a specific subsystem. 123 * to a specific subsystem.
115 * 124 *
116 * All kobjects of a kset should be embedded in an identical 125 * All kobjects of a kset should be embedded in an identical
@@ -126,13 +135,6 @@ struct kobj_type {
126 * supress the event generation or add subsystem specific 135 * supress the event generation or add subsystem specific
127 * variables carried with the event. 136 * variables carried with the event.
128 */ 137 */
129struct kset_uevent_ops {
130 int (*filter)(struct kset *kset, struct kobject *kobj);
131 const char *(*name)(struct kset *kset, struct kobject *kobj);
132 int (*uevent)(struct kset *kset, struct kobject *kobj, char **envp,
133 int num_envp, char *buffer, int buffer_size);
134};
135
136struct kset { 138struct kset {
137 struct kobj_type * ktype; 139 struct kobj_type * ktype;
138 struct list_head list; 140 struct list_head list;
@@ -173,7 +175,7 @@ static inline struct kobj_type * get_ktype(struct kobject * k)
173extern struct kobject * kset_find_obj(struct kset *, const char *); 175extern struct kobject * kset_find_obj(struct kset *, const char *);
174 176
175 177
176/** 178/*
177 * Use this when initializing an embedded kset with no other 179 * Use this when initializing an embedded kset with no other
178 * fields to initialize. 180 * fields to initialize.
179 */ 181 */
@@ -198,7 +200,7 @@ extern struct kset kernel_subsys;
198/* The global /sys/hypervisor/ subsystem */ 200/* The global /sys/hypervisor/ subsystem */
199extern struct kset hypervisor_subsys; 201extern struct kset hypervisor_subsys;
200 202
201/** 203/*
202 * Helpers for setting the kset of registered objects. 204 * Helpers for setting the kset of registered objects.
203 * Often, a registered object belongs to a kset embedded in a 205 * Often, a registered object belongs to a kset embedded in a
204 * subsystem. These do no magic, just make the resulting code 206 * subsystem. These do no magic, just make the resulting code
@@ -233,7 +235,7 @@ extern struct kset hypervisor_subsys;
233/** 235/**
234 * subsys_set_kset(obj,subsys) - set kset for subsystem 236 * subsys_set_kset(obj,subsys) - set kset for subsystem
235 * @obj: ptr to some object type. 237 * @obj: ptr to some object type.
236 * @subsys: a subsystem object (not a ptr). 238 * @_subsys: a subsystem object (not a ptr).
237 * 239 *
238 * Can be used for any object type with an embedded ->subsys. 240 * Can be used for any object type with an embedded ->subsys.
239 * Sets the kset of @obj's kobject to @subsys.kset. This makes 241 * Sets the kset of @obj's kobject to @subsys.kset. This makes
diff --git a/include/linux/lguest.h b/include/linux/lguest.h
index 500aace21ca7..157ad64aa7ce 100644
--- a/include/linux/lguest.h
+++ b/include/linux/lguest.h
@@ -17,7 +17,6 @@
17#define LHCALL_TS 8 17#define LHCALL_TS 8
18#define LHCALL_SET_CLOCKEVENT 9 18#define LHCALL_SET_CLOCKEVENT 9
19#define LHCALL_HALT 10 19#define LHCALL_HALT 10
20#define LHCALL_GET_WALLCLOCK 11
21#define LHCALL_BIND_DMA 12 20#define LHCALL_BIND_DMA 12
22#define LHCALL_SEND_DMA 13 21#define LHCALL_SEND_DMA 13
23#define LHCALL_SET_PTE 14 22#define LHCALL_SET_PTE 14
@@ -27,18 +26,38 @@
27#define LG_CLOCK_MIN_DELTA 100UL 26#define LG_CLOCK_MIN_DELTA 100UL
28#define LG_CLOCK_MAX_DELTA ULONG_MAX 27#define LG_CLOCK_MAX_DELTA ULONG_MAX
29 28
29/*G:031 First, how does our Guest contact the Host to ask for privileged
30 * operations? There are two ways: the direct way is to make a "hypercall",
31 * to make requests of the Host Itself.
32 *
33 * Our hypercall mechanism uses the highest unused trap code (traps 32 and
34 * above are used by real hardware interrupts). Seventeen hypercalls are
35 * available: the hypercall number is put in the %eax register, and the
36 * arguments (when required) are placed in %edx, %ebx and %ecx. If a return
37 * value makes sense, it's returned in %eax.
38 *
39 * Grossly invalid calls result in Sudden Death at the hands of the vengeful
40 * Host, rather than returning failure. This reflects Winston Churchill's
41 * definition of a gentleman: "someone who is only rude intentionally". */
30#define LGUEST_TRAP_ENTRY 0x1F 42#define LGUEST_TRAP_ENTRY 0x1F
31 43
32static inline unsigned long 44static inline unsigned long
33hcall(unsigned long call, 45hcall(unsigned long call,
34 unsigned long arg1, unsigned long arg2, unsigned long arg3) 46 unsigned long arg1, unsigned long arg2, unsigned long arg3)
35{ 47{
48 /* "int" is the Intel instruction to trigger a trap. */
36 asm volatile("int $" __stringify(LGUEST_TRAP_ENTRY) 49 asm volatile("int $" __stringify(LGUEST_TRAP_ENTRY)
50 /* The call is in %eax (aka "a"), and can be replaced */
37 : "=a"(call) 51 : "=a"(call)
52 /* The other arguments are in %eax, %edx, %ebx & %ecx */
38 : "a"(call), "d"(arg1), "b"(arg2), "c"(arg3) 53 : "a"(call), "d"(arg1), "b"(arg2), "c"(arg3)
54 /* "memory" means this might write somewhere in memory.
55 * This isn't true for all calls, but it's safe to tell
56 * gcc that it might happen so it doesn't get clever. */
39 : "memory"); 57 : "memory");
40 return call; 58 return call;
41} 59}
60/*:*/
42 61
43void async_hcall(unsigned long call, 62void async_hcall(unsigned long call,
44 unsigned long arg1, unsigned long arg2, unsigned long arg3); 63 unsigned long arg1, unsigned long arg2, unsigned long arg3);
@@ -52,31 +71,43 @@ struct hcall_ring
52 u32 eax, edx, ebx, ecx; 71 u32 eax, edx, ebx, ecx;
53}; 72};
54 73
55/* All the good stuff happens here: guest registers it with LGUEST_INIT */ 74/*G:032 The second method of communicating with the Host is to via "struct
75 * lguest_data". The Guest's very first hypercall is to tell the Host where
76 * this is, and then the Guest and Host both publish information in it. :*/
56struct lguest_data 77struct lguest_data
57{ 78{
58/* Fields which change during running: */ 79 /* 512 == enabled (same as eflags in normal hardware). The Guest
59 /* 512 == enabled (same as eflags) */ 80 * changes interrupts so often that a hypercall is too slow. */
60 unsigned int irq_enabled; 81 unsigned int irq_enabled;
61 /* Interrupts blocked by guest. */ 82 /* Fine-grained interrupt disabling by the Guest */
62 DECLARE_BITMAP(blocked_interrupts, LGUEST_IRQS); 83 DECLARE_BITMAP(blocked_interrupts, LGUEST_IRQS);
63 84
64 /* Virtual address of page fault. */ 85 /* The Host writes the virtual address of the last page fault here,
86 * which saves the Guest a hypercall. CR2 is the native register where
87 * this address would normally be found. */
65 unsigned long cr2; 88 unsigned long cr2;
66 89
67 /* Async hypercall ring. 0xFF == done, 0 == pending. */ 90 /* Wallclock time set by the Host. */
91 struct timespec time;
92
93 /* Async hypercall ring. Instead of directly making hypercalls, we can
94 * place them in here for processing the next time the Host wants.
95 * This batching can be quite efficient. */
96
97 /* 0xFF == done (set by Host), 0 == pending (set by Guest). */
68 u8 hcall_status[LHCALL_RING_SIZE]; 98 u8 hcall_status[LHCALL_RING_SIZE];
99 /* The actual registers for the hypercalls. */
69 struct hcall_ring hcalls[LHCALL_RING_SIZE]; 100 struct hcall_ring hcalls[LHCALL_RING_SIZE];
70 101
71/* Fields initialized by the hypervisor at boot: */ 102/* Fields initialized by the Host at boot: */
72 /* Memory not to try to access */ 103 /* Memory not to try to access */
73 unsigned long reserve_mem; 104 unsigned long reserve_mem;
74 /* ID of this guest (used by network driver to set ethernet address) */ 105 /* ID of this Guest (used by network driver to set ethernet address) */
75 u16 guestid; 106 u16 guestid;
76 /* KHz for the TSC clock. */ 107 /* KHz for the TSC clock. */
77 u32 tsc_khz; 108 u32 tsc_khz;
78 109
79/* Fields initialized by the guest at boot: */ 110/* Fields initialized by the Guest at boot: */
80 /* Instruction range to suppress interrupts even if enabled */ 111 /* Instruction range to suppress interrupts even if enabled */
81 unsigned long noirq_start, noirq_end; 112 unsigned long noirq_start, noirq_end;
82}; 113};
diff --git a/include/linux/lguest_bus.h b/include/linux/lguest_bus.h
index c9b4e05fee49..d27853ddc644 100644
--- a/include/linux/lguest_bus.h
+++ b/include/linux/lguest_bus.h
@@ -15,11 +15,14 @@ struct lguest_device {
15 void *private; 15 void *private;
16}; 16};
17 17
18/* By convention, each device can use irq index+1 if it wants to. */ 18/*D:380 Since interrupt numbers are arbitrary, we use a convention: each device
19 * can use the interrupt number corresponding to its index. The +1 is because
20 * interrupt 0 is not usable (it's actually the timer interrupt). */
19static inline int lgdev_irq(const struct lguest_device *dev) 21static inline int lgdev_irq(const struct lguest_device *dev)
20{ 22{
21 return dev->index + 1; 23 return dev->index + 1;
22} 24}
25/*:*/
23 26
24/* dma args must not be vmalloced! */ 27/* dma args must not be vmalloced! */
25void lguest_send_dma(unsigned long key, struct lguest_dma *dma); 28void lguest_send_dma(unsigned long key, struct lguest_dma *dma);
diff --git a/include/linux/lguest_launcher.h b/include/linux/lguest_launcher.h
index 0ba414a40c80..641670579446 100644
--- a/include/linux/lguest_launcher.h
+++ b/include/linux/lguest_launcher.h
@@ -9,14 +9,45 @@
9/* How many devices? Assume each one wants up to two dma arrays per device. */ 9/* How many devices? Assume each one wants up to two dma arrays per device. */
10#define LGUEST_MAX_DEVICES (LGUEST_MAX_DMA/2) 10#define LGUEST_MAX_DEVICES (LGUEST_MAX_DMA/2)
11 11
12/*D:200
13 * Lguest I/O
14 *
15 * The lguest I/O mechanism is the only way Guests can talk to devices. There
16 * are two hypercalls involved: SEND_DMA for output and BIND_DMA for input. In
17 * each case, "struct lguest_dma" describes the buffer: this contains 16
18 * addr/len pairs, and if there are fewer buffer elements the len array is
19 * terminated with a 0.
20 *
21 * I/O is organized by keys: BIND_DMA attaches buffers to a particular key, and
22 * SEND_DMA transfers to buffers bound to particular key. By convention, keys
23 * correspond to a physical address within the device's page. This means that
24 * devices will never accidentally end up with the same keys, and allows the
25 * Host use The Futex Trick (as we'll see later in our journey).
26 *
27 * SEND_DMA simply indicates a key to send to, and the physical address of the
28 * "struct lguest_dma" to send. The Host will write the number of bytes
29 * transferred into the "struct lguest_dma"'s used_len member.
30 *
31 * BIND_DMA indicates a key to bind to, a pointer to an array of "struct
32 * lguest_dma"s ready for receiving, the size of that array, and an interrupt
33 * to trigger when data is received. The Host will only allow transfers into
34 * buffers with a used_len of zero: it then sets used_len to the number of
35 * bytes transferred and triggers the interrupt for the Guest to process the
36 * new input. */
12struct lguest_dma 37struct lguest_dma
13{ 38{
14 /* 0 if free to be used, filled by hypervisor. */ 39 /* 0 if free to be used, filled by the Host. */
15 u32 used_len; 40 u32 used_len;
16 unsigned long addr[LGUEST_MAX_DMA_SECTIONS]; 41 unsigned long addr[LGUEST_MAX_DMA_SECTIONS];
17 u16 len[LGUEST_MAX_DMA_SECTIONS]; 42 u16 len[LGUEST_MAX_DMA_SECTIONS];
18}; 43};
44/*:*/
19 45
46/*D:460 This is the layout of a block device memory page. The Launcher sets up
47 * the num_sectors initially to tell the Guest the size of the disk. The Guest
48 * puts the type, sector and length of the request in the first three fields,
49 * then DMAs to the Host. The Host processes the request, sets up the result,
50 * then DMAs back to the Guest. */
20struct lguest_block_page 51struct lguest_block_page
21{ 52{
22 /* 0 is a read, 1 is a write. */ 53 /* 0 is a read, 1 is a write. */
@@ -28,27 +59,47 @@ struct lguest_block_page
28 u32 num_sectors; /* Disk length = num_sectors * 512 */ 59 u32 num_sectors; /* Disk length = num_sectors * 512 */
29}; 60};
30 61
31/* There is a shared page of these. */ 62/*D:520 The network device is basically a memory page where all the Guests on
63 * the network publish their MAC (ethernet) addresses: it's an array of "struct
64 * lguest_net": */
32struct lguest_net 65struct lguest_net
33{ 66{
34 /* Simply the mac address (with multicast bit meaning promisc). */ 67 /* Simply the mac address (with multicast bit meaning promisc). */
35 unsigned char mac[6]; 68 unsigned char mac[6];
36}; 69};
70/*:*/
37 71
38/* Where the Host expects the Guest to SEND_DMA console output to. */ 72/* Where the Host expects the Guest to SEND_DMA console output to. */
39#define LGUEST_CONSOLE_DMA_KEY 0 73#define LGUEST_CONSOLE_DMA_KEY 0
40 74
41/* We have a page of these descriptors in the lguest_device page. */ 75/*D:010
76 * Drivers
77 *
78 * The Guest needs devices to do anything useful. Since we don't let it touch
79 * real devices (think of the damage it could do!) we provide virtual devices.
80 * We could emulate a PCI bus with various devices on it, but that is a fairly
81 * complex burden for the Host and suboptimal for the Guest, so we have our own
82 * "lguest" bus and simple drivers.
83 *
84 * Devices are described by an array of LGUEST_MAX_DEVICES of these structs,
85 * placed by the Launcher just above the top of physical memory:
86 */
42struct lguest_device_desc { 87struct lguest_device_desc {
88 /* The device type: console, network, disk etc. */
43 u16 type; 89 u16 type;
44#define LGUEST_DEVICE_T_CONSOLE 1 90#define LGUEST_DEVICE_T_CONSOLE 1
45#define LGUEST_DEVICE_T_NET 2 91#define LGUEST_DEVICE_T_NET 2
46#define LGUEST_DEVICE_T_BLOCK 3 92#define LGUEST_DEVICE_T_BLOCK 3
47 93
94 /* The specific features of this device: these depends on device type
95 * except for LGUEST_DEVICE_F_RANDOMNESS. */
48 u16 features; 96 u16 features;
49#define LGUEST_NET_F_NOCSUM 0x4000 /* Don't bother checksumming */ 97#define LGUEST_NET_F_NOCSUM 0x4000 /* Don't bother checksumming */
50#define LGUEST_DEVICE_F_RANDOMNESS 0x8000 /* IRQ is fairly random */ 98#define LGUEST_DEVICE_F_RANDOMNESS 0x8000 /* IRQ is fairly random */
51 99
100 /* This is how the Guest reports status of the device: the Host can set
101 * LGUEST_DEVICE_S_REMOVED to indicate removal, but the rest are only
102 * ever manipulated by the Guest, and only ever set. */
52 u16 status; 103 u16 status;
53/* 256 and above are device specific. */ 104/* 256 and above are device specific. */
54#define LGUEST_DEVICE_S_ACKNOWLEDGE 1 /* We have seen device. */ 105#define LGUEST_DEVICE_S_ACKNOWLEDGE 1 /* We have seen device. */
@@ -58,9 +109,12 @@ struct lguest_device_desc {
58#define LGUEST_DEVICE_S_REMOVED_ACK 16 /* Driver has been told. */ 109#define LGUEST_DEVICE_S_REMOVED_ACK 16 /* Driver has been told. */
59#define LGUEST_DEVICE_S_FAILED 128 /* Something actually failed */ 110#define LGUEST_DEVICE_S_FAILED 128 /* Something actually failed */
60 111
112 /* Each device exists somewhere in Guest physical memory, over some
113 * number of pages. */
61 u16 num_pages; 114 u16 num_pages;
62 u32 pfn; 115 u32 pfn;
63}; 116};
117/*:*/
64 118
65/* Write command first word is a request. */ 119/* Write command first word is a request. */
66enum lguest_req 120enum lguest_req
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 9aa6c10f7bb1..41978a557318 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -216,6 +216,8 @@ enum {
216 ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host only */ 216 ATA_HOST_SIMPLEX = (1 << 0), /* Host is simplex, one DMA channel per host only */
217 ATA_HOST_STARTED = (1 << 1), /* Host started */ 217 ATA_HOST_STARTED = (1 << 1), /* Host started */
218 218
219 /* bits 24:31 of host->flags are reserved for LLD specific flags */
220
219 /* various lengths of time */ 221 /* various lengths of time */
220 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ 222 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */
221 ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */ 223 ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */
diff --git a/include/linux/loop.h b/include/linux/loop.h
index 0b99b31f017b..26a0a103898f 100644
--- a/include/linux/loop.h
+++ b/include/linux/loop.h
@@ -63,7 +63,7 @@ struct loop_device {
63 struct task_struct *lo_thread; 63 struct task_struct *lo_thread;
64 wait_queue_head_t lo_event; 64 wait_queue_head_t lo_event;
65 65
66 request_queue_t *lo_queue; 66 struct request_queue *lo_queue;
67 struct gendisk *lo_disk; 67 struct gendisk *lo_disk;
68 struct list_head lo_list; 68 struct list_head lo_list;
69}; 69};
diff --git a/include/linux/mm.h b/include/linux/mm.h
index c456c3a1c28e..655094dc9440 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -10,7 +10,6 @@
10#include <linux/mmzone.h> 10#include <linux/mmzone.h>
11#include <linux/rbtree.h> 11#include <linux/rbtree.h>
12#include <linux/prio_tree.h> 12#include <linux/prio_tree.h>
13#include <linux/fs.h>
14#include <linux/mutex.h> 13#include <linux/mutex.h>
15#include <linux/debug_locks.h> 14#include <linux/debug_locks.h>
16#include <linux/backing-dev.h> 15#include <linux/backing-dev.h>
@@ -18,7 +17,9 @@
18 17
19struct mempolicy; 18struct mempolicy;
20struct anon_vma; 19struct anon_vma;
20struct file_ra_state;
21struct user_struct; 21struct user_struct;
22struct writeback_control;
22 23
23#ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly */ 24#ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly */
24extern unsigned long max_mapnr; 25extern unsigned long max_mapnr;
@@ -861,38 +862,7 @@ struct shrinker {
861extern void register_shrinker(struct shrinker *); 862extern void register_shrinker(struct shrinker *);
862extern void unregister_shrinker(struct shrinker *); 863extern void unregister_shrinker(struct shrinker *);
863 864
864/* 865int vma_wants_writenotify(struct vm_area_struct *vma);
865 * Some shared mappigns will want the pages marked read-only
866 * to track write events. If so, we'll downgrade vm_page_prot
867 * to the private version (using protection_map[] without the
868 * VM_SHARED bit).
869 */
870static inline int vma_wants_writenotify(struct vm_area_struct *vma)
871{
872 unsigned int vm_flags = vma->vm_flags;
873
874 /* If it was private or non-writable, the write bit is already clear */
875 if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
876 return 0;
877
878 /* The backer wishes to know when pages are first written to? */
879 if (vma->vm_ops && vma->vm_ops->page_mkwrite)
880 return 1;
881
882 /* The open routine did something to the protections already? */
883 if (pgprot_val(vma->vm_page_prot) !=
884 pgprot_val(protection_map[vm_flags &
885 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]))
886 return 0;
887
888 /* Specialty mapping? */
889 if (vm_flags & (VM_PFNMAP|VM_INSERTPAGE))
890 return 0;
891
892 /* Can the mapping track the dirty pages? */
893 return vma->vm_file && vma->vm_file->f_mapping &&
894 mapping_cap_account_dirty(vma->vm_file->f_mapping);
895}
896 866
897extern pte_t *FASTCALL(get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl)); 867extern pte_t *FASTCALL(get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl));
898 868
@@ -1246,7 +1216,7 @@ void drop_slab(void);
1246extern int randomize_va_space; 1216extern int randomize_va_space;
1247#endif 1217#endif
1248 1218
1249__attribute__((weak)) const char *arch_vma_name(struct vm_area_struct *vma); 1219const char * arch_vma_name(struct vm_area_struct *vma);
1250 1220
1251#endif /* __KERNEL__ */ 1221#endif /* __KERNEL__ */
1252#endif /* _LINUX_MM_H */ 1222#endif /* _LINUX_MM_H */
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
index 04bbe12fae8d..63a80ea61124 100644
--- a/include/linux/mmc/core.h
+++ b/include/linux/mmc/core.h
@@ -99,7 +99,7 @@ struct mmc_request {
99struct mmc_host; 99struct mmc_host;
100struct mmc_card; 100struct mmc_card;
101 101
102extern int mmc_wait_for_req(struct mmc_host *, struct mmc_request *); 102extern void mmc_wait_for_req(struct mmc_host *, struct mmc_request *);
103extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int); 103extern int mmc_wait_for_cmd(struct mmc_host *, struct mmc_command *, int);
104extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *, 104extern int mmc_wait_for_app_cmd(struct mmc_host *, struct mmc_card *,
105 struct mmc_command *, int); 105 struct mmc_command *, int);
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index da8eb8ad9e9b..3ea68cd3b61f 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -120,7 +120,6 @@ enum zone_type {
120 * --------------------------- 120 * ---------------------------
121 * parisc, ia64, sparc <4G 121 * parisc, ia64, sparc <4G
122 * s390 <2G 122 * s390 <2G
123 * arm26 <48M
124 * arm Various 123 * arm Various
125 * alpha Unlimited or 0-16MB. 124 * alpha Unlimited or 0-16MB.
126 * 125 *
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index af04a555b52c..2ada8ee316b3 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -159,6 +159,12 @@ struct ap_device_id {
159 159
160#define AP_DEVICE_ID_MATCH_DEVICE_TYPE 0x01 160#define AP_DEVICE_ID_MATCH_DEVICE_TYPE 0x01
161 161
162#define ACPI_ID_LEN 9
163
164struct acpi_device_id {
165 __u8 id[ACPI_ID_LEN];
166 kernel_ulong_t driver_data;
167};
162 168
163#define PNP_ID_LEN 8 169#define PNP_ID_LEN 8
164#define PNP_MAX_DEVICES 8 170#define PNP_MAX_DEVICES 8
diff --git a/include/linux/mv643xx.h b/include/linux/mv643xx.h
index b021b3a2b65a..9c8049005052 100644
--- a/include/linux/mv643xx.h
+++ b/include/linux/mv643xx.h
@@ -1302,4 +1302,12 @@ struct mv643xx_eth_platform_data {
1302 u8 mac_addr[6]; /* mac address if non-zero*/ 1302 u8 mac_addr[6]; /* mac address if non-zero*/
1303}; 1303};
1304 1304
1305/* Watchdog Platform Device, Driver Data */
1306#define MV64x60_WDT_NAME "mv64x60_wdt"
1307
1308struct mv64x60_wdt_pdata {
1309 int timeout; /* watchdog expiry in seconds, default 10 */
1310 int bus_clk; /* bus clock in MHz, default 133 */
1311};
1312
1305#endif /* __ASM_MV643XX_H */ 1313#endif /* __ASM_MV643XX_H */
diff --git a/include/linux/netfilter/xt_connlimit.h b/include/linux/netfilter/xt_connlimit.h
index 90ae8b474cb8..37e933c9987d 100644
--- a/include/linux/netfilter/xt_connlimit.h
+++ b/include/linux/netfilter/xt_connlimit.h
@@ -5,8 +5,8 @@ struct xt_connlimit_data;
5 5
6struct xt_connlimit_info { 6struct xt_connlimit_info {
7 union { 7 union {
8 u_int32_t v4_mask; 8 __be32 v4_mask;
9 u_int32_t v6_mask[4]; 9 __be32 v6_mask[4];
10 }; 10 };
11 unsigned int limit, inverse; 11 unsigned int limit, inverse;
12 12
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index be3f2bb6fcf3..fad7ff17e468 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -157,6 +157,19 @@ extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
157 */ 157 */
158#define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK) 158#define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK)
159 159
160/* Encapsulate (negative) errno value (in particular, NOTIFY_BAD <=> EPERM). */
161static inline int notifier_from_errno(int err)
162{
163 return NOTIFY_STOP_MASK | (NOTIFY_OK - err);
164}
165
166/* Restore (negative) errno value from notify return value. */
167static inline int notifier_to_errno(int ret)
168{
169 ret &= ~NOTIFY_STOP_MASK;
170 return ret > NOTIFY_OK ? NOTIFY_OK - ret : 0;
171}
172
160/* 173/*
161 * Declared notifiers so far. I can imagine quite a few more chains 174 * Declared notifiers so far. I can imagine quite a few more chains
162 * over time (eg laptop power reset chains, reboot chain (to clean 175 * over time (eg laptop power reset chains, reboot chain (to clean
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5e84f2e8d54c..d8f8a3a96644 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -534,6 +534,7 @@ static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val
534 534
535int __must_check pci_enable_device(struct pci_dev *dev); 535int __must_check pci_enable_device(struct pci_dev *dev);
536int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask); 536int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask);
537int __must_check __pci_reenable_device(struct pci_dev *);
537int __must_check pcim_enable_device(struct pci_dev *pdev); 538int __must_check pcim_enable_device(struct pci_dev *pdev);
538void pcim_pin_device(struct pci_dev *pdev); 539void pcim_pin_device(struct pci_dev *pdev);
539 540
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index cbabb9c675c9..07fc57429b58 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -611,7 +611,6 @@
611#define PCI_DEVICE_ID_NEC_CBUS_3 0x003b 611#define PCI_DEVICE_ID_NEC_CBUS_3 0x003b
612#define PCI_DEVICE_ID_NEC_NAPCCARD 0x003e 612#define PCI_DEVICE_ID_NEC_NAPCCARD 0x003e
613#define PCI_DEVICE_ID_NEC_PCX2 0x0046 /* PowerVR */ 613#define PCI_DEVICE_ID_NEC_PCX2 0x0046 /* PowerVR */
614#define PCI_DEVICE_ID_NEC_NILE4 0x005a
615#define PCI_DEVICE_ID_NEC_VRC5476 0x009b 614#define PCI_DEVICE_ID_NEC_VRC5476 0x009b
616#define PCI_DEVICE_ID_NEC_VRC4173 0x00a5 615#define PCI_DEVICE_ID_NEC_VRC4173 0x00a5
617#define PCI_DEVICE_ID_NEC_VRC5477_AC97 0x00a6 616#define PCI_DEVICE_ID_NEC_VRC5477_AC97 0x00a6
@@ -1225,6 +1224,10 @@
1225#define PCI_DEVICE_ID_NVIDIA_NVENET_25 0x054D 1224#define PCI_DEVICE_ID_NVIDIA_NVENET_25 0x054D
1226#define PCI_DEVICE_ID_NVIDIA_NVENET_26 0x054E 1225#define PCI_DEVICE_ID_NVIDIA_NVENET_26 0x054E
1227#define PCI_DEVICE_ID_NVIDIA_NVENET_27 0x054F 1226#define PCI_DEVICE_ID_NVIDIA_NVENET_27 0x054F
1227#define PCI_DEVICE_ID_NVIDIA_NVENET_28 0x07DC
1228#define PCI_DEVICE_ID_NVIDIA_NVENET_29 0x07DD
1229#define PCI_DEVICE_ID_NVIDIA_NVENET_30 0x07DE
1230#define PCI_DEVICE_ID_NVIDIA_NVENET_31 0x07DF
1228#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE 0x0560 1231#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE 0x0560
1229#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE 0x056C 1232#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE 0x056C
1230#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE 0x0759 1233#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE 0x0759
@@ -1972,6 +1975,8 @@
1972#define PCI_VENDOR_ID_ENE 0x1524 1975#define PCI_VENDOR_ID_ENE 0x1524
1973#define PCI_DEVICE_ID_ENE_CB712_SD 0x0550 1976#define PCI_DEVICE_ID_ENE_CB712_SD 0x0550
1974#define PCI_DEVICE_ID_ENE_CB712_SD_2 0x0551 1977#define PCI_DEVICE_ID_ENE_CB712_SD_2 0x0551
1978#define PCI_DEVICE_ID_ENE_CB714_SD 0x0750
1979#define PCI_DEVICE_ID_ENE_CB714_SD_2 0x0751
1975#define PCI_DEVICE_ID_ENE_1211 0x1211 1980#define PCI_DEVICE_ID_ENE_1211 0x1211
1976#define PCI_DEVICE_ID_ENE_1225 0x1225 1981#define PCI_DEVICE_ID_ENE_1225 0x1225
1977#define PCI_DEVICE_ID_ENE_1410 0x1410 1982#define PCI_DEVICE_ID_ENE_1410 0x1410
@@ -2075,6 +2080,23 @@
2075#define PCI_VENDOR_ID_TDI 0x192E 2080#define PCI_VENDOR_ID_TDI 0x192E
2076#define PCI_DEVICE_ID_TDI_EHCI 0x0101 2081#define PCI_DEVICE_ID_TDI_EHCI 0x0101
2077 2082
2083#define PCI_VENDOR_ID_FREESCALE 0x1957
2084#define PCI_DEVICE_ID_MPC8548E 0x0012
2085#define PCI_DEVICE_ID_MPC8548 0x0013
2086#define PCI_DEVICE_ID_MPC8543E 0x0014
2087#define PCI_DEVICE_ID_MPC8543 0x0015
2088#define PCI_DEVICE_ID_MPC8547E 0x0018
2089#define PCI_DEVICE_ID_MPC8545E 0x0019
2090#define PCI_DEVICE_ID_MPC8545 0x001a
2091#define PCI_DEVICE_ID_MPC8568E 0x0020
2092#define PCI_DEVICE_ID_MPC8568 0x0021
2093#define PCI_DEVICE_ID_MPC8567E 0x0022
2094#define PCI_DEVICE_ID_MPC8567 0x0023
2095#define PCI_DEVICE_ID_MPC8544E 0x0030
2096#define PCI_DEVICE_ID_MPC8544 0x0031
2097#define PCI_DEVICE_ID_MPC8641 0x7010
2098#define PCI_DEVICE_ID_MPC8641D 0x7011
2099
2078#define PCI_VENDOR_ID_PASEMI 0x1959 2100#define PCI_VENDOR_ID_PASEMI 0x1959
2079 2101
2080#define PCI_VENDOR_ID_ATTANSIC 0x1969 2102#define PCI_VENDOR_ID_ATTANSIC 0x1969
diff --git a/include/linux/pm.h b/include/linux/pm.h
index ad3cc2eb0d34..48b71badfb4c 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -25,6 +25,7 @@
25 25
26#include <linux/list.h> 26#include <linux/list.h>
27#include <asm/atomic.h> 27#include <asm/atomic.h>
28#include <asm/errno.h>
28 29
29/* 30/*
30 * Power management requests... these are passed to pm_send_all() and friends. 31 * Power management requests... these are passed to pm_send_all() and friends.
@@ -165,6 +166,7 @@ struct pm_ops {
165 int (*finish)(suspend_state_t state); 166 int (*finish)(suspend_state_t state);
166}; 167};
167 168
169#ifdef CONFIG_SUSPEND
168extern struct pm_ops *pm_ops; 170extern struct pm_ops *pm_ops;
169 171
170/** 172/**
@@ -193,6 +195,12 @@ extern void arch_suspend_disable_irqs(void);
193extern void arch_suspend_enable_irqs(void); 195extern void arch_suspend_enable_irqs(void);
194 196
195extern int pm_suspend(suspend_state_t state); 197extern int pm_suspend(suspend_state_t state);
198#else /* !CONFIG_SUSPEND */
199#define suspend_valid_only_mem NULL
200
201static inline void pm_set_ops(struct pm_ops *pm_ops) {}
202static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
203#endif /* !CONFIG_SUSPEND */
196 204
197/* 205/*
198 * Device power management 206 * Device power management
@@ -266,7 +274,7 @@ typedef struct pm_message {
266struct dev_pm_info { 274struct dev_pm_info {
267 pm_message_t power_state; 275 pm_message_t power_state;
268 unsigned can_wakeup:1; 276 unsigned can_wakeup:1;
269#ifdef CONFIG_PM 277#ifdef CONFIG_PM_SLEEP
270 unsigned should_wakeup:1; 278 unsigned should_wakeup:1;
271 struct list_head entry; 279 struct list_head entry;
272#endif 280#endif
@@ -276,7 +284,7 @@ extern int device_power_down(pm_message_t state);
276extern void device_power_up(void); 284extern void device_power_up(void);
277extern void device_resume(void); 285extern void device_resume(void);
278 286
279#ifdef CONFIG_PM 287#ifdef CONFIG_PM_SLEEP
280extern int device_suspend(pm_message_t state); 288extern int device_suspend(pm_message_t state);
281extern int device_prepare_suspend(pm_message_t state); 289extern int device_prepare_suspend(pm_message_t state);
282 290
@@ -306,7 +314,7 @@ static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
306 return 0; 314 return 0;
307} 315}
308 316
309#else /* !CONFIG_PM */ 317#else /* !CONFIG_PM_SLEEP */
310 318
311static inline int device_suspend(pm_message_t state) 319static inline int device_suspend(pm_message_t state)
312{ 320{
@@ -323,7 +331,7 @@ static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
323 return 0; 331 return 0;
324} 332}
325 333
326#endif 334#endif /* !CONFIG_PM_SLEEP */
327 335
328/* changes to device_may_wakeup take effect on the next pm state change. 336/* changes to device_may_wakeup take effect on the next pm state change.
329 * by default, devices should wakeup if they can. 337 * by default, devices should wakeup if they can.
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index 2a1897e6f937..16b46aace349 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -1,7 +1,6 @@
1/* 1/*
2 * Linux Plug and Play Support 2 * Linux Plug and Play Support
3 * Copyright by Adam Belay <ambx1@neo.rr.com> 3 * Copyright by Adam Belay <ambx1@neo.rr.com>
4 *
5 */ 4 */
6 5
7#ifndef _LINUX_PNP_H 6#ifndef _LINUX_PNP_H
@@ -23,7 +22,6 @@
23struct pnp_protocol; 22struct pnp_protocol;
24struct pnp_dev; 23struct pnp_dev;
25 24
26
27/* 25/*
28 * Resource Management 26 * Resource Management
29 */ 27 */
@@ -73,37 +71,37 @@ struct pnp_dev;
73#define PNP_PORT_FLAG_FIXED (1<<1) 71#define PNP_PORT_FLAG_FIXED (1<<1)
74 72
75struct pnp_port { 73struct pnp_port {
76 unsigned short min; /* min base number */ 74 unsigned short min; /* min base number */
77 unsigned short max; /* max base number */ 75 unsigned short max; /* max base number */
78 unsigned char align; /* align boundary */ 76 unsigned char align; /* align boundary */
79 unsigned char size; /* size of range */ 77 unsigned char size; /* size of range */
80 unsigned char flags; /* port flags */ 78 unsigned char flags; /* port flags */
81 unsigned char pad; /* pad */ 79 unsigned char pad; /* pad */
82 struct pnp_port *next; /* next port */ 80 struct pnp_port *next; /* next port */
83}; 81};
84 82
85#define PNP_IRQ_NR 256 83#define PNP_IRQ_NR 256
86struct pnp_irq { 84struct pnp_irq {
87 DECLARE_BITMAP(map, PNP_IRQ_NR); /* bitmaks for IRQ lines */ 85 DECLARE_BITMAP(map, PNP_IRQ_NR); /* bitmask for IRQ lines */
88 unsigned char flags; /* IRQ flags */ 86 unsigned char flags; /* IRQ flags */
89 unsigned char pad; /* pad */ 87 unsigned char pad; /* pad */
90 struct pnp_irq *next; /* next IRQ */ 88 struct pnp_irq *next; /* next IRQ */
91}; 89};
92 90
93struct pnp_dma { 91struct pnp_dma {
94 unsigned char map; /* bitmask for DMA channels */ 92 unsigned char map; /* bitmask for DMA channels */
95 unsigned char flags; /* DMA flags */ 93 unsigned char flags; /* DMA flags */
96 struct pnp_dma *next; /* next port */ 94 struct pnp_dma *next; /* next port */
97}; 95};
98 96
99struct pnp_mem { 97struct pnp_mem {
100 unsigned int min; /* min base number */ 98 unsigned int min; /* min base number */
101 unsigned int max; /* max base number */ 99 unsigned int max; /* max base number */
102 unsigned int align; /* align boundary */ 100 unsigned int align; /* align boundary */
103 unsigned int size; /* size of range */ 101 unsigned int size; /* size of range */
104 unsigned char flags; /* memory flags */ 102 unsigned char flags; /* memory flags */
105 unsigned char pad; /* pad */ 103 unsigned char pad; /* pad */
106 struct pnp_mem *next; /* next memory resource */ 104 struct pnp_mem *next; /* next memory resource */
107}; 105};
108 106
109#define PNP_RES_PRIORITY_PREFERRED 0 107#define PNP_RES_PRIORITY_PREFERRED 0
@@ -127,7 +125,6 @@ struct pnp_resource_table {
127 struct resource irq_resource[PNP_MAX_IRQ]; 125 struct resource irq_resource[PNP_MAX_IRQ];
128}; 126};
129 127
130
131/* 128/*
132 * Device Managemnt 129 * Device Managemnt
133 */ 130 */
@@ -139,14 +136,14 @@ struct pnp_card {
139 struct list_head protocol_list; /* node in protocol's list of cards */ 136 struct list_head protocol_list; /* node in protocol's list of cards */
140 struct list_head devices; /* devices attached to the card */ 137 struct list_head devices; /* devices attached to the card */
141 138
142 struct pnp_protocol * protocol; 139 struct pnp_protocol *protocol;
143 struct pnp_id * id; /* contains supported EISA IDs*/ 140 struct pnp_id *id; /* contains supported EISA IDs */
144 141
145 char name[PNP_NAME_LEN]; /* contains a human-readable name */ 142 char name[PNP_NAME_LEN]; /* contains a human-readable name */
146 unsigned char pnpver; /* Plug & Play version */ 143 unsigned char pnpver; /* Plug & Play version */
147 unsigned char productver; /* product version */ 144 unsigned char productver; /* product version */
148 unsigned int serial; /* serial number */ 145 unsigned int serial; /* serial number */
149 unsigned char checksum; /* if zero - checksum passed */ 146 unsigned char checksum; /* if zero - checksum passed */
150 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/isapnp */ 147 struct proc_dir_entry *procdir; /* directory entry in /proc/bus/isapnp */
151}; 148};
152 149
@@ -159,18 +156,18 @@ struct pnp_card {
159 (card) = global_to_pnp_card((card)->global_list.next)) 156 (card) = global_to_pnp_card((card)->global_list.next))
160 157
161struct pnp_card_link { 158struct pnp_card_link {
162 struct pnp_card * card; 159 struct pnp_card *card;
163 struct pnp_card_driver * driver; 160 struct pnp_card_driver *driver;
164 void * driver_data; 161 void *driver_data;
165 pm_message_t pm_state; 162 pm_message_t pm_state;
166}; 163};
167 164
168static inline void *pnp_get_card_drvdata (struct pnp_card_link *pcard) 165static inline void *pnp_get_card_drvdata(struct pnp_card_link *pcard)
169{ 166{
170 return pcard->driver_data; 167 return pcard->driver_data;
171} 168}
172 169
173static inline void pnp_set_card_drvdata (struct pnp_card_link *pcard, void *data) 170static inline void pnp_set_card_drvdata(struct pnp_card_link *pcard, void *data)
174{ 171{
175 pcard->driver_data = data; 172 pcard->driver_data = data;
176} 173}
@@ -186,22 +183,22 @@ struct pnp_dev {
186 struct list_head card_list; /* node in card's list of devices */ 183 struct list_head card_list; /* node in card's list of devices */
187 struct list_head rdev_list; /* node in cards list of requested devices */ 184 struct list_head rdev_list; /* node in cards list of requested devices */
188 185
189 struct pnp_protocol * protocol; 186 struct pnp_protocol *protocol;
190 struct pnp_card * card; /* card the device is attached to, none if NULL */ 187 struct pnp_card *card; /* card the device is attached to, none if NULL */
191 struct pnp_driver * driver; 188 struct pnp_driver *driver;
192 struct pnp_card_link * card_link; 189 struct pnp_card_link *card_link;
193 190
194 struct pnp_id * id; /* supported EISA IDs*/ 191 struct pnp_id *id; /* supported EISA IDs */
195 192
196 int active; 193 int active;
197 int capabilities; 194 int capabilities;
198 struct pnp_option * independent; 195 struct pnp_option *independent;
199 struct pnp_option * dependent; 196 struct pnp_option *dependent;
200 struct pnp_resource_table res; 197 struct pnp_resource_table res;
201 198
202 char name[PNP_NAME_LEN]; /* contains a human-readable name */ 199 char name[PNP_NAME_LEN]; /* contains a human-readable name */
203 unsigned short regs; /* ISAPnP: supported registers */ 200 unsigned short regs; /* ISAPnP: supported registers */
204 int flags; /* used by protocols */ 201 int flags; /* used by protocols */
205 struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */ 202 struct proc_dir_entry *procent; /* device entry in /proc/bus/isapnp */
206 void *data; 203 void *data;
207}; 204};
@@ -220,19 +217,19 @@ struct pnp_dev {
220 (dev) = card_to_pnp_dev((dev)->card_list.next)) 217 (dev) = card_to_pnp_dev((dev)->card_list.next))
221#define pnp_dev_name(dev) (dev)->name 218#define pnp_dev_name(dev) (dev)->name
222 219
223static inline void *pnp_get_drvdata (struct pnp_dev *pdev) 220static inline void *pnp_get_drvdata(struct pnp_dev *pdev)
224{ 221{
225 return dev_get_drvdata(&pdev->dev); 222 return dev_get_drvdata(&pdev->dev);
226} 223}
227 224
228static inline void pnp_set_drvdata (struct pnp_dev *pdev, void *data) 225static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
229{ 226{
230 dev_set_drvdata(&pdev->dev, data); 227 dev_set_drvdata(&pdev->dev, data);
231} 228}
232 229
233struct pnp_fixup { 230struct pnp_fixup {
234 char id[7]; 231 char id[7];
235 void (*quirk_function)(struct pnp_dev *dev); /* fixup function */ 232 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
236}; 233};
237 234
238/* config parameters */ 235/* config parameters */
@@ -269,7 +266,6 @@ extern struct pnp_protocol pnpbios_protocol;
269#define pnp_device_is_pnpbios(dev) 0 266#define pnp_device_is_pnpbios(dev) 0
270#endif 267#endif
271 268
272
273/* status */ 269/* status */
274#define PNP_READY 0x0000 270#define PNP_READY 0x0000
275#define PNP_ATTACHED 0x0001 271#define PNP_ATTACHED 0x0001
@@ -287,17 +283,17 @@ extern struct pnp_protocol pnpbios_protocol;
287 283
288struct pnp_id { 284struct pnp_id {
289 char id[PNP_ID_LEN]; 285 char id[PNP_ID_LEN];
290 struct pnp_id * next; 286 struct pnp_id *next;
291}; 287};
292 288
293struct pnp_driver { 289struct pnp_driver {
294 char * name; 290 char *name;
295 const struct pnp_device_id *id_table; 291 const struct pnp_device_id *id_table;
296 unsigned int flags; 292 unsigned int flags;
297 int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id); 293 int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id);
298 void (*remove) (struct pnp_dev *dev); 294 void (*remove) (struct pnp_dev *dev);
299 int (*suspend) (struct pnp_dev *dev, pm_message_t state); 295 int (*suspend) (struct pnp_dev *dev, pm_message_t state);
300 int (*resume) (struct pnp_dev *dev); 296 int (*resume) (struct pnp_dev *dev);
301 struct device_driver driver; 297 struct device_driver driver;
302}; 298};
303 299
@@ -305,13 +301,14 @@ struct pnp_driver {
305 301
306struct pnp_card_driver { 302struct pnp_card_driver {
307 struct list_head global_list; 303 struct list_head global_list;
308 char * name; 304 char *name;
309 const struct pnp_card_device_id *id_table; 305 const struct pnp_card_device_id *id_table;
310 unsigned int flags; 306 unsigned int flags;
311 int (*probe) (struct pnp_card_link *card, const struct pnp_card_device_id *card_id); 307 int (*probe) (struct pnp_card_link *card,
308 const struct pnp_card_device_id *card_id);
312 void (*remove) (struct pnp_card_link *card); 309 void (*remove) (struct pnp_card_link *card);
313 int (*suspend) (struct pnp_card_link *card, pm_message_t state); 310 int (*suspend) (struct pnp_card_link *card, pm_message_t state);
314 int (*resume) (struct pnp_card_link *card); 311 int (*resume) (struct pnp_card_link *card);
315 struct pnp_driver link; 312 struct pnp_driver link;
316}; 313};
317 314
@@ -321,25 +318,28 @@ struct pnp_card_driver {
321#define PNP_DRIVER_RES_DO_NOT_CHANGE 0x0001 /* do not change the state of the device */ 318#define PNP_DRIVER_RES_DO_NOT_CHANGE 0x0001 /* do not change the state of the device */
322#define PNP_DRIVER_RES_DISABLE 0x0003 /* ensure the device is disabled */ 319#define PNP_DRIVER_RES_DISABLE 0x0003 /* ensure the device is disabled */
323 320
324
325/* 321/*
326 * Protocol Management 322 * Protocol Management
327 */ 323 */
328 324
329struct pnp_protocol { 325struct pnp_protocol {
330 struct list_head protocol_list; 326 struct list_head protocol_list;
331 char * name; 327 char *name;
332 328
333 /* resource control functions */ 329 /* resource control functions */
334 int (*get)(struct pnp_dev *dev, struct pnp_resource_table *res); 330 int (*get) (struct pnp_dev *dev, struct pnp_resource_table *res);
335 int (*set)(struct pnp_dev *dev, struct pnp_resource_table *res); 331 int (*set) (struct pnp_dev *dev, struct pnp_resource_table *res);
336 int (*disable)(struct pnp_dev *dev); 332 int (*disable) (struct pnp_dev *dev);
333
334 /* protocol specific suspend/resume */
335 int (*suspend) (struct pnp_dev * dev, pm_message_t state);
336 int (*resume) (struct pnp_dev * dev);
337 337
338 /* used by pnp layer only (look but don't touch) */ 338 /* used by pnp layer only (look but don't touch) */
339 unsigned char number; /* protocol number*/ 339 unsigned char number; /* protocol number */
340 struct device dev; /* link to driver model */ 340 struct device dev; /* link to driver model */
341 struct list_head cards; 341 struct list_head cards;
342 struct list_head devices; 342 struct list_head devices;
343}; 343};
344 344
345#define to_pnp_protocol(n) list_entry(n, struct pnp_protocol, protocol_list) 345#define to_pnp_protocol(n) list_entry(n, struct pnp_protocol, protocol_list)
@@ -352,7 +352,6 @@ struct pnp_protocol {
352 (dev) != protocol_to_pnp_dev(&(protocol)->devices); \ 352 (dev) != protocol_to_pnp_dev(&(protocol)->devices); \
353 (dev) = protocol_to_pnp_dev((dev)->protocol_list.next)) 353 (dev) = protocol_to_pnp_dev((dev)->protocol_list.next))
354 354
355
356extern struct bus_type pnp_bus_type; 355extern struct bus_type pnp_bus_type;
357 356
358#if defined(CONFIG_PNP) 357#if defined(CONFIG_PNP)
@@ -372,21 +371,25 @@ void pnp_remove_card(struct pnp_card *card);
372int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev); 371int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
373void pnp_remove_card_device(struct pnp_dev *dev); 372void pnp_remove_card_device(struct pnp_dev *dev);
374int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card); 373int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card);
375struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from); 374struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink,
376void pnp_release_card_device(struct pnp_dev * dev); 375 const char *id, struct pnp_dev *from);
377int pnp_register_card_driver(struct pnp_card_driver * drv); 376void pnp_release_card_device(struct pnp_dev *dev);
378void pnp_unregister_card_driver(struct pnp_card_driver * drv); 377int pnp_register_card_driver(struct pnp_card_driver *drv);
378void pnp_unregister_card_driver(struct pnp_card_driver *drv);
379extern struct list_head pnp_cards; 379extern struct list_head pnp_cards;
380 380
381/* resource management */ 381/* resource management */
382struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev); 382struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
383struct pnp_option * pnp_register_dependent_option(struct pnp_dev *dev, int priority); 383struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
384 int priority);
384int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data); 385int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data);
385int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data); 386int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data);
386int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data); 387int pnp_register_port_resource(struct pnp_option *option,
388 struct pnp_port *data);
387int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data); 389int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data);
388void pnp_init_resource_table(struct pnp_resource_table *table); 390void pnp_init_resource_table(struct pnp_resource_table *table);
389int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode); 391int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
392 int mode);
390int pnp_auto_config_dev(struct pnp_dev *dev); 393int pnp_auto_config_dev(struct pnp_dev *dev);
391int pnp_validate_config(struct pnp_dev *dev); 394int pnp_validate_config(struct pnp_dev *dev);
392int pnp_start_dev(struct pnp_dev *dev); 395int pnp_start_dev(struct pnp_dev *dev);
@@ -394,11 +397,11 @@ int pnp_stop_dev(struct pnp_dev *dev);
394int pnp_activate_dev(struct pnp_dev *dev); 397int pnp_activate_dev(struct pnp_dev *dev);
395int pnp_disable_dev(struct pnp_dev *dev); 398int pnp_disable_dev(struct pnp_dev *dev);
396void pnp_resource_change(struct resource *resource, resource_size_t start, 399void pnp_resource_change(struct resource *resource, resource_size_t start,
397 resource_size_t size); 400 resource_size_t size);
398 401
399/* protocol helpers */ 402/* protocol helpers */
400int pnp_is_active(struct pnp_dev * dev); 403int pnp_is_active(struct pnp_dev *dev);
401int compare_pnp_id(struct pnp_id * pos, const char * id); 404int compare_pnp_id(struct pnp_id *pos, const char *id);
402int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev); 405int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev);
403int pnp_register_driver(struct pnp_driver *drv); 406int pnp_register_driver(struct pnp_driver *drv);
404void pnp_unregister_driver(struct pnp_driver *drv); 407void pnp_unregister_driver(struct pnp_driver *drv);
@@ -411,23 +414,24 @@ static inline void pnp_unregister_protocol(struct pnp_protocol *protocol) { }
411static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; } 414static inline int pnp_init_device(struct pnp_dev *dev) { return -ENODEV; }
412static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; } 415static inline int pnp_add_device(struct pnp_dev *dev) { return -ENODEV; }
413static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; } 416static inline int pnp_device_attach(struct pnp_dev *pnp_dev) { return -ENODEV; }
414static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { ; } 417static inline void pnp_device_detach(struct pnp_dev *pnp_dev) { }
418
415#define pnp_platform_devices 0 419#define pnp_platform_devices 0
416 420
417/* multidevice card support */ 421/* multidevice card support */
418static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; } 422static inline int pnp_add_card(struct pnp_card *card) { return -ENODEV; }
419static inline void pnp_remove_card(struct pnp_card *card) { ; } 423static inline void pnp_remove_card(struct pnp_card *card) { }
420static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; } 424static inline int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) { return -ENODEV; }
421static inline void pnp_remove_card_device(struct pnp_dev *dev) { ; } 425static inline void pnp_remove_card_device(struct pnp_dev *dev) { }
422static inline int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; } 426static inline int pnp_add_card_id(struct pnp_id *id, struct pnp_card *card) { return -ENODEV; }
423static inline struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char * id, struct pnp_dev * from) { return NULL; } 427static inline struct pnp_dev *pnp_request_card_device(struct pnp_card_link *clink, const char *id, struct pnp_dev *from) { return NULL; }
424static inline void pnp_release_card_device(struct pnp_dev * dev) { ; } 428static inline void pnp_release_card_device(struct pnp_dev *dev) { }
425static inline int pnp_register_card_driver(struct pnp_card_driver * drv) { return -ENODEV; } 429static inline int pnp_register_card_driver(struct pnp_card_driver *drv) { return -ENODEV; }
426static inline void pnp_unregister_card_driver(struct pnp_card_driver * drv) { ; } 430static inline void pnp_unregister_card_driver(struct pnp_card_driver *drv) { }
427 431
428/* resource management */ 432/* resource management */
429static inline struct pnp_option * pnp_register_independent_option(struct pnp_dev *dev) { return NULL; } 433static inline struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev) { return NULL; }
430static inline struct pnp_option * pnp_register_dependent_option(struct pnp_dev *dev, int priority) { return NULL; } 434static inline struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, int priority) { return NULL; }
431static inline int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) { return -ENODEV; } 435static inline int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data) { return -ENODEV; }
432static inline int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; } 436static inline int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data) { return -ENODEV; }
433static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; } 437static inline int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data) { return -ENODEV; }
@@ -440,20 +444,17 @@ static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; }
440static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; } 444static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; }
441static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; } 445static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; }
442static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; } 446static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; }
443static inline void pnp_resource_change(struct resource *resource, 447static inline void pnp_resource_change(struct resource *resource, resource_size_t start, resource_size_t size) { }
444 resource_size_t start,
445 resource_size_t size) { }
446 448
447/* protocol helpers */ 449/* protocol helpers */
448static inline int pnp_is_active(struct pnp_dev * dev) { return 0; } 450static inline int pnp_is_active(struct pnp_dev *dev) { return 0; }
449static inline int compare_pnp_id(struct pnp_id * pos, const char * id) { return -ENODEV; } 451static inline int compare_pnp_id(struct pnp_id *pos, const char *id) { return -ENODEV; }
450static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; } 452static inline int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev) { return -ENODEV; }
451static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; } 453static inline int pnp_register_driver(struct pnp_driver *drv) { return -ENODEV; }
452static inline void pnp_unregister_driver(struct pnp_driver *drv) { ; } 454static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
453 455
454#endif /* CONFIG_PNP */ 456#endif /* CONFIG_PNP */
455 457
456
457#define pnp_err(format, arg...) printk(KERN_ERR "pnp: " format "\n" , ## arg) 458#define pnp_err(format, arg...) printk(KERN_ERR "pnp: " format "\n" , ## arg)
458#define pnp_info(format, arg...) printk(KERN_INFO "pnp: " format "\n" , ## arg) 459#define pnp_info(format, arg...) printk(KERN_INFO "pnp: " format "\n" , ## arg)
459#define pnp_warn(format, arg...) printk(KERN_WARNING "pnp: " format "\n" , ## arg) 460#define pnp_warn(format, arg...) printk(KERN_WARNING "pnp: " format "\n" , ## arg)
diff --git a/include/linux/pnpbios.h b/include/linux/pnpbios.h
index 0a282ac1f6b2..329192adc9dd 100644
--- a/include/linux/pnpbios.h
+++ b/include/linux/pnpbios.h
@@ -99,32 +99,32 @@
99 99
100#pragma pack(1) 100#pragma pack(1)
101struct pnp_dev_node_info { 101struct pnp_dev_node_info {
102 __u16 no_nodes; 102 __u16 no_nodes;
103 __u16 max_node_size; 103 __u16 max_node_size;
104}; 104};
105struct pnp_docking_station_info { 105struct pnp_docking_station_info {
106 __u32 location_id; 106 __u32 location_id;
107 __u32 serial; 107 __u32 serial;
108 __u16 capabilities; 108 __u16 capabilities;
109}; 109};
110struct pnp_isa_config_struc { 110struct pnp_isa_config_struc {
111 __u8 revision; 111 __u8 revision;
112 __u8 no_csns; 112 __u8 no_csns;
113 __u16 isa_rd_data_port; 113 __u16 isa_rd_data_port;
114 __u16 reserved; 114 __u16 reserved;
115}; 115};
116struct escd_info_struc { 116struct escd_info_struc {
117 __u16 min_escd_write_size; 117 __u16 min_escd_write_size;
118 __u16 escd_size; 118 __u16 escd_size;
119 __u32 nv_storage_base; 119 __u32 nv_storage_base;
120}; 120};
121struct pnp_bios_node { 121struct pnp_bios_node {
122 __u16 size; 122 __u16 size;
123 __u8 handle; 123 __u8 handle;
124 __u32 eisa_id; 124 __u32 eisa_id;
125 __u8 type_code[3]; 125 __u8 type_code[3];
126 __u16 flags; 126 __u16 flags;
127 __u8 data[0]; 127 __u8 data[0];
128}; 128};
129#pragma pack() 129#pragma pack()
130 130
@@ -133,22 +133,16 @@ struct pnp_bios_node {
133/* non-exported */ 133/* non-exported */
134extern struct pnp_dev_node_info node_info; 134extern struct pnp_dev_node_info node_info;
135 135
136extern int pnp_bios_dev_node_info (struct pnp_dev_node_info *data); 136extern int pnp_bios_dev_node_info(struct pnp_dev_node_info *data);
137extern int pnp_bios_get_dev_node (u8 *nodenum, char config, struct pnp_bios_node *data); 137extern int pnp_bios_get_dev_node(u8 *nodenum, char config,
138extern int pnp_bios_set_dev_node (u8 nodenum, char config, struct pnp_bios_node *data); 138 struct pnp_bios_node *data);
139extern int pnp_bios_get_stat_res (char *info); 139extern int pnp_bios_set_dev_node(u8 nodenum, char config,
140extern int pnp_bios_isapnp_config (struct pnp_isa_config_struc *data); 140 struct pnp_bios_node *data);
141extern int pnp_bios_escd_info (struct escd_info_struc *data); 141extern int pnp_bios_get_stat_res(char *info);
142extern int pnp_bios_read_escd (char *data, u32 nvram_base); 142extern int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data);
143extern int pnp_bios_escd_info(struct escd_info_struc *data);
144extern int pnp_bios_read_escd(char *data, u32 nvram_base);
143extern int pnp_bios_dock_station_info(struct pnp_docking_station_info *data); 145extern int pnp_bios_dock_station_info(struct pnp_docking_station_info *data);
144#define needed 0
145#if needed
146extern int pnp_bios_get_event (u16 *message);
147extern int pnp_bios_send_message (u16 message);
148extern int pnp_bios_set_stat_res (char *info);
149extern int pnp_bios_apm_id_table (char *table, u16 *size);
150extern int pnp_bios_write_escd (char *data, u32 nvram_base);
151#endif
152 146
153#endif /* CONFIG_PNPBIOS */ 147#endif /* CONFIG_PNPBIOS */
154 148
diff --git a/include/linux/preempt.h b/include/linux/preempt.h
index d0926d63406c..484988ed301e 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -8,6 +8,7 @@
8 8
9#include <linux/thread_info.h> 9#include <linux/thread_info.h>
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11#include <linux/list.h>
11 12
12#ifdef CONFIG_DEBUG_PREEMPT 13#ifdef CONFIG_DEBUG_PREEMPT
13 extern void fastcall add_preempt_count(int val); 14 extern void fastcall add_preempt_count(int val);
@@ -60,4 +61,47 @@ do { \
60 61
61#endif 62#endif
62 63
64#ifdef CONFIG_PREEMPT_NOTIFIERS
65
66struct preempt_notifier;
67
68/**
69 * preempt_ops - notifiers called when a task is preempted and rescheduled
70 * @sched_in: we're about to be rescheduled:
71 * notifier: struct preempt_notifier for the task being scheduled
72 * cpu: cpu we're scheduled on
73 * @sched_out: we've just been preempted
74 * notifier: struct preempt_notifier for the task being preempted
75 * next: the task that's kicking us out
76 */
77struct preempt_ops {
78 void (*sched_in)(struct preempt_notifier *notifier, int cpu);
79 void (*sched_out)(struct preempt_notifier *notifier,
80 struct task_struct *next);
81};
82
83/**
84 * preempt_notifier - key for installing preemption notifiers
85 * @link: internal use
86 * @ops: defines the notifier functions to be called
87 *
88 * Usually used in conjunction with container_of().
89 */
90struct preempt_notifier {
91 struct hlist_node link;
92 struct preempt_ops *ops;
93};
94
95void preempt_notifier_register(struct preempt_notifier *notifier);
96void preempt_notifier_unregister(struct preempt_notifier *notifier);
97
98static inline void preempt_notifier_init(struct preempt_notifier *notifier,
99 struct preempt_ops *ops)
100{
101 INIT_HLIST_NODE(&notifier->link);
102 notifier->ops = ops;
103}
104
105#endif
106
63#endif /* __LINUX_PREEMPT_H */ 107#endif /* __LINUX_PREEMPT_H */
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index 28ac632b42dd..dcb729244f47 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -227,7 +227,7 @@ struct mddev_s
227 unsigned int safemode_delay; 227 unsigned int safemode_delay;
228 struct timer_list safemode_timer; 228 struct timer_list safemode_timer;
229 atomic_t writes_pending; 229 atomic_t writes_pending;
230 request_queue_t *queue; /* for plugging ... */ 230 struct request_queue *queue; /* for plugging ... */
231 231
232 atomic_t write_behind; /* outstanding async IO */ 232 atomic_t write_behind; /* outstanding async IO */
233 unsigned int max_write_behind; /* 0 = sync */ 233 unsigned int max_write_behind; /* 0 = sync */
@@ -265,7 +265,7 @@ struct mdk_personality
265 int level; 265 int level;
266 struct list_head list; 266 struct list_head list;
267 struct module *owner; 267 struct module *owner;
268 int (*make_request)(request_queue_t *q, struct bio *bio); 268 int (*make_request)(struct request_queue *q, struct bio *bio);
269 int (*run)(mddev_t *mddev); 269 int (*run)(mddev_t *mddev);
270 int (*stop)(mddev_t *mddev); 270 int (*stop)(mddev_t *mddev);
271 void (*status)(struct seq_file *seq, mddev_t *mddev); 271 void (*status)(struct seq_file *seq, mddev_t *mddev);
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 965d5b3ea9eb..180a9d832dde 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -81,14 +81,16 @@ void reiserfs_warning(struct super_block *s, const char *fmt, ...);
81/* assertions handling */ 81/* assertions handling */
82 82
83/** always check a condition and panic if it's false. */ 83/** always check a condition and panic if it's false. */
84#define RASSERT( cond, format, args... ) \ 84#define __RASSERT( cond, scond, format, args... ) \
85if( !( cond ) ) \ 85if( !( cond ) ) \
86 reiserfs_panic( NULL, "reiserfs[%i]: assertion " #cond " failed at " \ 86 reiserfs_panic( NULL, "reiserfs[%i]: assertion " scond " failed at " \
87 __FILE__ ":%i:%s: " format "\n", \ 87 __FILE__ ":%i:%s: " format "\n", \
88 in_interrupt() ? -1 : current -> pid, __LINE__ , __FUNCTION__ , ##args ) 88 in_interrupt() ? -1 : current -> pid, __LINE__ , __FUNCTION__ , ##args )
89 89
90#define RASSERT(cond, format, args...) __RASSERT(cond, #cond, format, ##args)
91
90#if defined( CONFIG_REISERFS_CHECK ) 92#if defined( CONFIG_REISERFS_CHECK )
91#define RFALSE( cond, format, args... ) RASSERT( !( cond ), format, ##args ) 93#define RFALSE(cond, format, args...) __RASSERT(!(cond), "!(" #cond ")", format, ##args)
92#else 94#else
93#define RFALSE( cond, format, args... ) do {;} while( 0 ) 95#define RFALSE( cond, format, args... ) do {;} while( 0 )
94#endif 96#endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 33b9b4841ee7..2e490271acf6 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -681,7 +681,7 @@ enum cpu_idle_type {
681#define SCHED_LOAD_SHIFT 10 681#define SCHED_LOAD_SHIFT 10
682#define SCHED_LOAD_SCALE (1L << SCHED_LOAD_SHIFT) 682#define SCHED_LOAD_SCALE (1L << SCHED_LOAD_SHIFT)
683 683
684#define SCHED_LOAD_SCALE_FUZZ (SCHED_LOAD_SCALE >> 5) 684#define SCHED_LOAD_SCALE_FUZZ (SCHED_LOAD_SCALE >> 1)
685 685
686#ifdef CONFIG_SMP 686#ifdef CONFIG_SMP
687#define SD_LOAD_BALANCE 1 /* Do load balancing on this domain. */ 687#define SD_LOAD_BALANCE 1 /* Do load balancing on this domain. */
@@ -786,6 +786,22 @@ extern int partition_sched_domains(cpumask_t *partition1,
786 786
787#endif /* CONFIG_SMP */ 787#endif /* CONFIG_SMP */
788 788
789/*
790 * A runqueue laden with a single nice 0 task scores a weighted_cpuload of
791 * SCHED_LOAD_SCALE. This function returns 1 if any cpu is laden with a
792 * task of nice 0 or enough lower priority tasks to bring up the
793 * weighted_cpuload
794 */
795static inline int above_background_load(void)
796{
797 unsigned long cpu;
798
799 for_each_online_cpu(cpu) {
800 if (weighted_cpuload(cpu) >= SCHED_LOAD_SCALE)
801 return 1;
802 }
803 return 0;
804}
789 805
790struct io_context; /* See blkdev.h */ 806struct io_context; /* See blkdev.h */
791struct cpuset; 807struct cpuset;
@@ -935,6 +951,11 @@ struct task_struct {
935 struct sched_class *sched_class; 951 struct sched_class *sched_class;
936 struct sched_entity se; 952 struct sched_entity se;
937 953
954#ifdef CONFIG_PREEMPT_NOTIFIERS
955 /* list of struct preempt_notifier: */
956 struct hlist_head preempt_notifiers;
957#endif
958
938 unsigned short ioprio; 959 unsigned short ioprio;
939#ifdef CONFIG_BLK_DEV_IO_TRACE 960#ifdef CONFIG_BLK_DEV_IO_TRACE
940 unsigned int btrace_seq; 961 unsigned int btrace_seq;
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 8518fa2a6f89..afe0f6d9b9bc 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -20,7 +20,7 @@
20struct plat_serial8250_port { 20struct plat_serial8250_port {
21 unsigned long iobase; /* io base address */ 21 unsigned long iobase; /* io base address */
22 void __iomem *membase; /* ioremap cookie or NULL */ 22 void __iomem *membase; /* ioremap cookie or NULL */
23 unsigned long mapbase; /* resource base */ 23 resource_size_t mapbase; /* resource base */
24 unsigned int irq; /* interrupt number */ 24 unsigned int irq; /* interrupt number */
25 unsigned int uartclk; /* UART clock rate */ 25 unsigned int uartclk; /* UART clock rate */
26 unsigned char regshift; /* register shift */ 26 unsigned char regshift; /* register shift */
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 773d8d8828ad..09d17b06bf02 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -288,7 +288,7 @@ struct uart_port {
288 const struct uart_ops *ops; 288 const struct uart_ops *ops;
289 unsigned int custom_divisor; 289 unsigned int custom_divisor;
290 unsigned int line; /* port index */ 290 unsigned int line; /* port index */
291 unsigned long mapbase; /* for ioremap */ 291 resource_size_t mapbase; /* for ioremap */
292 struct device *dev; /* parent device */ 292 struct device *dev; /* parent device */
293 unsigned char hub6; /* this should be in the 8250 driver */ 293 unsigned char hub6; /* this should be in the 8250 driver */
294 unsigned char unused[3]; 294 unsigned char unused[3];
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index ce256438e619..93c27f71122a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -134,8 +134,8 @@ typedef struct skb_frag_struct skb_frag_t;
134 134
135struct skb_frag_struct { 135struct skb_frag_struct {
136 struct page *page; 136 struct page *page;
137 __u16 page_offset; 137 __u32 page_offset;
138 __u16 size; 138 __u32 size;
139}; 139};
140 140
141/* This data is invariant across clones and lives at 141/* This data is invariant across clones and lives at
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 302b81d1d117..002a3cddbdd5 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -77,6 +77,7 @@ struct spi_device {
77#define SPI_CS_HIGH 0x04 /* chipselect active high? */ 77#define SPI_CS_HIGH 0x04 /* chipselect active high? */
78#define SPI_LSB_FIRST 0x08 /* per-word bits-on-wire */ 78#define SPI_LSB_FIRST 0x08 /* per-word bits-on-wire */
79#define SPI_3WIRE 0x10 /* SI/SO signals shared */ 79#define SPI_3WIRE 0x10 /* SI/SO signals shared */
80#define SPI_LOOP 0x20 /* loopback mode */
80 u8 bits_per_word; 81 u8 bits_per_word;
81 int irq; 82 int irq;
82 void *controller_state; 83 void *controller_state;
@@ -138,6 +139,32 @@ struct spi_message;
138 139
139 140
140 141
142/**
143 * struct spi_driver - Host side "protocol" driver
144 * @probe: Binds this driver to the spi device. Drivers can verify
145 * that the device is actually present, and may need to configure
146 * characteristics (such as bits_per_word) which weren't needed for
147 * the initial configuration done during system setup.
148 * @remove: Unbinds this driver from the spi device
149 * @shutdown: Standard shutdown callback used during system state
150 * transitions such as powerdown/halt and kexec
151 * @suspend: Standard suspend callback used during system state transitions
152 * @resume: Standard resume callback used during system state transitions
153 * @driver: SPI device drivers should initialize the name and owner
154 * field of this structure.
155 *
156 * This represents the kind of device driver that uses SPI messages to
157 * interact with the hardware at the other end of a SPI link. It's called
158 * a "protocol" driver because it works through messages rather than talking
159 * directly to SPI hardware (which is what the underlying SPI controller
160 * driver does to pass those messages). These protocols are defined in the
161 * specification for the device(s) supported by the driver.
162 *
163 * As a rule, those device protocols represent the lowest level interface
164 * supported by a driver, and it will support upper level interfaces too.
165 * Examples of such upper levels include frameworks like MTD, networking,
166 * MMC, RTC, filesystem character device nodes, and hardware monitoring.
167 */
141struct spi_driver { 168struct spi_driver {
142 int (*probe)(struct spi_device *spi); 169 int (*probe)(struct spi_device *spi);
143 int (*remove)(struct spi_device *spi); 170 int (*remove)(struct spi_device *spi);
@@ -667,7 +694,37 @@ static inline ssize_t spi_w8r16(struct spi_device *spi, u8 cmd)
667 * parport adapters, or microcontrollers acting as USB-to-SPI bridges. 694 * parport adapters, or microcontrollers acting as USB-to-SPI bridges.
668 */ 695 */
669 696
670/* board-specific information about each SPI device */ 697/**
698 * struct spi_board_info - board-specific template for a SPI device
699 * @modalias: Initializes spi_device.modalias; identifies the driver.
700 * @platform_data: Initializes spi_device.platform_data; the particular
701 * data stored there is driver-specific.
702 * @controller_data: Initializes spi_device.controller_data; some
703 * controllers need hints about hardware setup, e.g. for DMA.
704 * @irq: Initializes spi_device.irq; depends on how the board is wired.
705 * @max_speed_hz: Initializes spi_device.max_speed_hz; based on limits
706 * from the chip datasheet and board-specific signal quality issues.
707 * @bus_num: Identifies which spi_master parents the spi_device; unused
708 * by spi_new_device(), and otherwise depends on board wiring.
709 * @chip_select: Initializes spi_device.chip_select; depends on how
710 * the board is wired.
711 * @mode: Initializes spi_device.mode; based on the chip datasheet, board
712 * wiring (some devices support both 3WIRE and standard modes), and
713 * possibly presence of an inverter in the chipselect path.
714 *
715 * When adding new SPI devices to the device tree, these structures serve
716 * as a partial device template. They hold information which can't always
717 * be determined by drivers. Information that probe() can establish (such
718 * as the default transfer wordsize) is not included here.
719 *
720 * These structures are used in two places. Their primary role is to
721 * be stored in tables of board-specific device descriptors, which are
722 * declared early in board initialization and then used (much later) to
723 * populate a controller's device tree after the that controller's driver
724 * initializes. A secondary (and atypical) role is as a parameter to
725 * spi_new_device() call, which happens after those controller drivers
726 * are active in some dynamic board configuration models.
727 */
671struct spi_board_info { 728struct spi_board_info {
672 /* the device name and module name are coupled, like platform_bus; 729 /* the device name and module name are coupled, like platform_bus;
673 * "modalias" is normally the driver name. 730 * "modalias" is normally the driver name.
diff --git a/include/linux/spi/spidev.h b/include/linux/spi/spidev.h
index 7d700be57490..c93ef9d42a01 100644
--- a/include/linux/spi/spidev.h
+++ b/include/linux/spi/spidev.h
@@ -35,6 +35,10 @@
35#define SPI_MODE_2 (SPI_CPOL|0) 35#define SPI_MODE_2 (SPI_CPOL|0)
36#define SPI_MODE_3 (SPI_CPOL|SPI_CPHA) 36#define SPI_MODE_3 (SPI_CPOL|SPI_CPHA)
37 37
38#define SPI_CS_HIGH 0x04
39#define SPI_LSB_FIRST 0x08
40#define SPI_3WIRE 0x10
41#define SPI_LOOP 0x20
38 42
39/*---------------------------------------------------------------------------*/ 43/*---------------------------------------------------------------------------*/
40 44
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index e8e6da394c92..388cace9751f 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -24,7 +24,7 @@ struct pbe {
24extern void drain_local_pages(void); 24extern void drain_local_pages(void);
25extern void mark_free_pages(struct zone *zone); 25extern void mark_free_pages(struct zone *zone);
26 26
27#if defined(CONFIG_PM) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE) 27#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
28extern int pm_prepare_console(void); 28extern int pm_prepare_console(void);
29extern void pm_restore_console(void); 29extern void pm_restore_console(void);
30#else 30#else
@@ -54,8 +54,7 @@ struct hibernation_ops {
54 void (*restore_cleanup)(void); 54 void (*restore_cleanup)(void);
55}; 55};
56 56
57#ifdef CONFIG_PM 57#ifdef CONFIG_HIBERNATION
58#ifdef CONFIG_SOFTWARE_SUSPEND
59/* kernel/power/snapshot.c */ 58/* kernel/power/snapshot.c */
60extern void __register_nosave_region(unsigned long b, unsigned long e, int km); 59extern void __register_nosave_region(unsigned long b, unsigned long e, int km);
61static inline void register_nosave_region(unsigned long b, unsigned long e) 60static inline void register_nosave_region(unsigned long b, unsigned long e)
@@ -73,15 +72,16 @@ extern unsigned long get_safe_page(gfp_t gfp_mask);
73 72
74extern void hibernation_set_ops(struct hibernation_ops *ops); 73extern void hibernation_set_ops(struct hibernation_ops *ops);
75extern int hibernate(void); 74extern int hibernate(void);
76#else /* CONFIG_SOFTWARE_SUSPEND */ 75#else /* CONFIG_HIBERNATION */
77static inline int swsusp_page_is_forbidden(struct page *p) { return 0; } 76static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
78static inline void swsusp_set_page_free(struct page *p) {} 77static inline void swsusp_set_page_free(struct page *p) {}
79static inline void swsusp_unset_page_free(struct page *p) {} 78static inline void swsusp_unset_page_free(struct page *p) {}
80 79
81static inline void hibernation_set_ops(struct hibernation_ops *ops) {} 80static inline void hibernation_set_ops(struct hibernation_ops *ops) {}
82static inline int hibernate(void) { return -ENOSYS; } 81static inline int hibernate(void) { return -ENOSYS; }
83#endif /* CONFIG_SOFTWARE_SUSPEND */ 82#endif /* CONFIG_HIBERNATION */
84 83
84#ifdef CONFIG_PM_SLEEP
85void save_processor_state(void); 85void save_processor_state(void);
86void restore_processor_state(void); 86void restore_processor_state(void);
87struct saved_context; 87struct saved_context;
@@ -106,7 +106,7 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
106 { .notifier_call = fn, .priority = pri }; \ 106 { .notifier_call = fn, .priority = pri }; \
107 register_pm_notifier(&fn##_nb); \ 107 register_pm_notifier(&fn##_nb); \
108} 108}
109#else /* CONFIG_PM */ 109#else /* !CONFIG_PM_SLEEP */
110 110
111static inline int register_pm_notifier(struct notifier_block *nb) 111static inline int register_pm_notifier(struct notifier_block *nb)
112{ 112{
@@ -119,12 +119,15 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
119} 119}
120 120
121#define pm_notifier(fn, pri) do { (void)(fn); } while (0) 121#define pm_notifier(fn, pri) do { (void)(fn); } while (0)
122#endif /* CONFIG_PM */ 122#endif /* !CONFIG_PM_SLEEP */
123 123
124#if !defined CONFIG_SOFTWARE_SUSPEND || !defined(CONFIG_PM) 124#ifndef CONFIG_HIBERNATION
125static inline void register_nosave_region(unsigned long b, unsigned long e) 125static inline void register_nosave_region(unsigned long b, unsigned long e)
126{ 126{
127} 127}
128static inline void register_nosave_region_late(unsigned long b, unsigned long e)
129{
130}
128#endif 131#endif
129 132
130#endif /* _LINUX_SWSUSP_H */ 133#endif /* _LINUX_SWSUSP_H */
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 47f1c53332ce..483050c924c3 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -62,7 +62,7 @@ enum
62 CTL_KERN=1, /* General kernel info and control */ 62 CTL_KERN=1, /* General kernel info and control */
63 CTL_VM=2, /* VM management */ 63 CTL_VM=2, /* VM management */
64 CTL_NET=3, /* Networking */ 64 CTL_NET=3, /* Networking */
65 /* was CTL_PROC */ 65 CTL_PROC=4, /* removal breaks strace(1) compilation */
66 CTL_FS=5, /* Filesystems */ 66 CTL_FS=5, /* Filesystems */
67 CTL_DEBUG=6, /* Debugging */ 67 CTL_DEBUG=6, /* Debugging */
68 CTL_DEV=7, /* Devices */ 68 CTL_DEV=7, /* Devices */
diff --git a/include/linux/time.h b/include/linux/time.h
index e6aea5146e5d..6a5f503b4f1d 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -99,15 +99,11 @@ extern int update_persistent_clock(struct timespec now);
99extern int no_sync_cmos_clock __read_mostly; 99extern int no_sync_cmos_clock __read_mostly;
100void timekeeping_init(void); 100void timekeeping_init(void);
101 101
102static inline unsigned long get_seconds(void) 102unsigned long get_seconds(void);
103{
104 return xtime.tv_sec;
105}
106
107struct timespec current_kernel_time(void); 103struct timespec current_kernel_time(void);
108 104
109#define CURRENT_TIME (current_kernel_time()) 105#define CURRENT_TIME (current_kernel_time())
110#define CURRENT_TIME_SEC ((struct timespec) { xtime.tv_sec, 0 }) 106#define CURRENT_TIME_SEC ((struct timespec) { get_seconds(), 0 })
111 107
112extern void do_gettimeofday(struct timeval *tv); 108extern void do_gettimeofday(struct timeval *tv);
113extern int do_settimeofday(struct timespec *tv); 109extern int do_settimeofday(struct timespec *tv);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 7a60946df3b6..4f33a58fa9d1 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -94,6 +94,7 @@ enum usb_interface_condition {
94 * endpoint configurations. They will be in no particular order. 94 * endpoint configurations. They will be in no particular order.
95 * @num_altsetting: number of altsettings defined. 95 * @num_altsetting: number of altsettings defined.
96 * @cur_altsetting: the current altsetting. 96 * @cur_altsetting: the current altsetting.
97 * @intf_assoc: interface association descriptor
97 * @driver: the USB driver that is bound to this interface. 98 * @driver: the USB driver that is bound to this interface.
98 * @minor: the minor number assigned to this interface, if this 99 * @minor: the minor number assigned to this interface, if this
99 * interface is bound to a driver that uses the USB major number. 100 * interface is bound to a driver that uses the USB major number.
@@ -213,6 +214,7 @@ struct usb_interface_cache {
213 * @desc: the device's configuration descriptor. 214 * @desc: the device's configuration descriptor.
214 * @string: pointer to the cached version of the iConfiguration string, if 215 * @string: pointer to the cached version of the iConfiguration string, if
215 * present for this configuration. 216 * present for this configuration.
217 * @intf_assoc: list of any interface association descriptors in this config
216 * @interface: array of pointers to usb_interface structures, one for each 218 * @interface: array of pointers to usb_interface structures, one for each
217 * interface in the configuration. The number of interfaces is stored 219 * interface in the configuration. The number of interfaces is stored
218 * in desc.bNumInterfaces. These pointers are valid only while the 220 * in desc.bNumInterfaces. These pointers are valid only while the
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 6de1e9e35c73..0864a775de24 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -12,37 +12,8 @@ extern void unix_gc(void);
12 12
13#define UNIX_HASH_SIZE 256 13#define UNIX_HASH_SIZE 256
14 14
15extern struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
16extern spinlock_t unix_table_lock;
17
18extern atomic_t unix_tot_inflight; 15extern atomic_t unix_tot_inflight;
19 16
20static inline struct sock *first_unix_socket(int *i)
21{
22 for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
23 if (!hlist_empty(&unix_socket_table[*i]))
24 return __sk_head(&unix_socket_table[*i]);
25 }
26 return NULL;
27}
28
29static inline struct sock *next_unix_socket(int *i, struct sock *s)
30{
31 struct sock *next = sk_next(s);
32 /* More in this chain? */
33 if (next)
34 return next;
35 /* Look for next non-empty chain. */
36 for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
37 if (!hlist_empty(&unix_socket_table[*i]))
38 return __sk_head(&unix_socket_table[*i]);
39 }
40 return NULL;
41}
42
43#define forall_unix_sockets(i, s) \
44 for (s = first_unix_socket(&(i)); s; s = next_unix_socket(&(i),(s)))
45
46struct unix_address { 17struct unix_address {
47 atomic_t refcnt; 18 atomic_t refcnt;
48 int len; 19 int len;
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 87df4e87622d..70e70f5d3dd6 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -34,7 +34,7 @@
34/* L2CAP socket address */ 34/* L2CAP socket address */
35struct sockaddr_l2 { 35struct sockaddr_l2 {
36 sa_family_t l2_family; 36 sa_family_t l2_family;
37 unsigned short l2_psm; 37 __le16 l2_psm;
38 bdaddr_t l2_bdaddr; 38 bdaddr_t l2_bdaddr;
39}; 39};
40 40
@@ -76,32 +76,32 @@ struct l2cap_conninfo {
76 76
77/* L2CAP structures */ 77/* L2CAP structures */
78struct l2cap_hdr { 78struct l2cap_hdr {
79 __u16 len; 79 __le16 len;
80 __u16 cid; 80 __le16 cid;
81} __attribute__ ((packed)); 81} __attribute__ ((packed));
82#define L2CAP_HDR_SIZE 4 82#define L2CAP_HDR_SIZE 4
83 83
84struct l2cap_cmd_hdr { 84struct l2cap_cmd_hdr {
85 __u8 code; 85 __u8 code;
86 __u8 ident; 86 __u8 ident;
87 __u16 len; 87 __le16 len;
88} __attribute__ ((packed)); 88} __attribute__ ((packed));
89#define L2CAP_CMD_HDR_SIZE 4 89#define L2CAP_CMD_HDR_SIZE 4
90 90
91struct l2cap_cmd_rej { 91struct l2cap_cmd_rej {
92 __u16 reason; 92 __le16 reason;
93} __attribute__ ((packed)); 93} __attribute__ ((packed));
94 94
95struct l2cap_conn_req { 95struct l2cap_conn_req {
96 __u16 psm; 96 __le16 psm;
97 __u16 scid; 97 __le16 scid;
98} __attribute__ ((packed)); 98} __attribute__ ((packed));
99 99
100struct l2cap_conn_rsp { 100struct l2cap_conn_rsp {
101 __u16 dcid; 101 __le16 dcid;
102 __u16 scid; 102 __le16 scid;
103 __u16 result; 103 __le16 result;
104 __u16 status; 104 __le16 status;
105} __attribute__ ((packed)); 105} __attribute__ ((packed));
106 106
107/* connect result */ 107/* connect result */
@@ -117,15 +117,15 @@ struct l2cap_conn_rsp {
117#define L2CAP_CS_AUTHOR_PEND 0x0002 117#define L2CAP_CS_AUTHOR_PEND 0x0002
118 118
119struct l2cap_conf_req { 119struct l2cap_conf_req {
120 __u16 dcid; 120 __le16 dcid;
121 __u16 flags; 121 __le16 flags;
122 __u8 data[0]; 122 __u8 data[0];
123} __attribute__ ((packed)); 123} __attribute__ ((packed));
124 124
125struct l2cap_conf_rsp { 125struct l2cap_conf_rsp {
126 __u16 scid; 126 __le16 scid;
127 __u16 flags; 127 __le16 flags;
128 __u16 result; 128 __le16 result;
129 __u8 data[0]; 129 __u8 data[0];
130} __attribute__ ((packed)); 130} __attribute__ ((packed));
131 131
@@ -149,23 +149,23 @@ struct l2cap_conf_opt {
149#define L2CAP_CONF_MAX_SIZE 22 149#define L2CAP_CONF_MAX_SIZE 22
150 150
151struct l2cap_disconn_req { 151struct l2cap_disconn_req {
152 __u16 dcid; 152 __le16 dcid;
153 __u16 scid; 153 __le16 scid;
154} __attribute__ ((packed)); 154} __attribute__ ((packed));
155 155
156struct l2cap_disconn_rsp { 156struct l2cap_disconn_rsp {
157 __u16 dcid; 157 __le16 dcid;
158 __u16 scid; 158 __le16 scid;
159} __attribute__ ((packed)); 159} __attribute__ ((packed));
160 160
161struct l2cap_info_req { 161struct l2cap_info_req {
162 __u16 type; 162 __le16 type;
163 __u8 data[0]; 163 __u8 data[0];
164} __attribute__ ((packed)); 164} __attribute__ ((packed));
165 165
166struct l2cap_info_rsp { 166struct l2cap_info_rsp {
167 __u16 type; 167 __le16 type;
168 __u16 result; 168 __le16 result;
169 __u8 data[0]; 169 __u8 data[0];
170} __attribute__ ((packed)); 170} __attribute__ ((packed));
171 171
@@ -207,7 +207,7 @@ struct l2cap_conn {
207 207
208struct l2cap_pinfo { 208struct l2cap_pinfo {
209 struct bt_sock bt; 209 struct bt_sock bt;
210 __u16 psm; 210 __le16 psm;
211 __u16 dcid; 211 __u16 dcid;
212 __u16 scid; 212 __u16 scid;
213 213
@@ -225,7 +225,7 @@ struct l2cap_pinfo {
225 225
226 __u8 ident; 226 __u8 ident;
227 227
228 __u16 sport; 228 __le16 sport;
229 229
230 struct l2cap_conn *conn; 230 struct l2cap_conn *conn;
231 struct sock *next_c; 231 struct sock *next_c;
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 46b9dce82f6e..9059e0ed7fe3 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -17,6 +17,7 @@
17 17
18#include <linux/ipv6.h> 18#include <linux/ipv6.h>
19#include <linux/hardirq.h> 19#include <linux/hardirq.h>
20#include <net/if_inet6.h>
20#include <net/ndisc.h> 21#include <net/ndisc.h>
21#include <net/flow.h> 22#include <net/flow.h>
22#include <net/snmp.h> 23#include <net/snmp.h>
diff --git a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
index 5a8965904377..070d12cb4634 100644
--- a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
+++ b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
@@ -7,9 +7,6 @@ extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6;
7extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6; 7extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6;
8extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6; 8extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6;
9 9
10extern int nf_ct_ipv6_skip_exthdr(const struct sk_buff *skb, int start,
11 u8 *nexthdrp, int len);
12
13extern int nf_ct_frag6_init(void); 10extern int nf_ct_frag6_init(void);
14extern void nf_ct_frag6_cleanup(void); 11extern void nf_ct_frag6_cleanup(void);
15extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb); 12extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb);
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h
index 040dae5f0c9e..c48e390f4b0f 100644
--- a/include/net/netfilter/nf_conntrack_tuple.h
+++ b/include/net/netfilter/nf_conntrack_tuple.h
@@ -35,7 +35,7 @@ union nf_conntrack_address {
35union nf_conntrack_man_proto 35union nf_conntrack_man_proto
36{ 36{
37 /* Add other protocols here. */ 37 /* Add other protocols here. */
38 u_int16_t all; 38 __be16 all;
39 39
40 struct { 40 struct {
41 __be16 port; 41 __be16 port;
@@ -73,7 +73,7 @@ struct nf_conntrack_tuple
73 union nf_conntrack_address u3; 73 union nf_conntrack_address u3;
74 union { 74 union {
75 /* Add other protocols here. */ 75 /* Add other protocols here. */
76 u_int16_t all; 76 __be16 all;
77 77
78 struct { 78 struct {
79 __be16 port; 79 __be16 port;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 8b404b1ef7c8..c209361ab74a 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -660,7 +660,7 @@ struct tcp_congestion_ops {
660 /* new value of cwnd after loss (optional) */ 660 /* new value of cwnd after loss (optional) */
661 u32 (*undo_cwnd)(struct sock *sk); 661 u32 (*undo_cwnd)(struct sock *sk);
662 /* hook for packet ack accounting (optional) */ 662 /* hook for packet ack accounting (optional) */
663 void (*pkts_acked)(struct sock *sk, u32 num_acked, ktime_t last); 663 void (*pkts_acked)(struct sock *sk, u32 num_acked, s32 rtt_us);
664 /* get info for inet_diag (optional) */ 664 /* get info for inet_diag (optional) */
665 void (*get_info)(struct sock *sk, u32 ext, struct sk_buff *skb); 665 void (*get_info)(struct sock *sk, u32 ext, struct sk_buff *skb);
666 666
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 3f631b08a1ab..007d442412e2 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -210,6 +210,9 @@ struct iscsi_session {
210 uint32_t exp_cmdsn; 210 uint32_t exp_cmdsn;
211 uint32_t max_cmdsn; 211 uint32_t max_cmdsn;
212 212
213 /* This tracks the reqs queued into the initiator */
214 uint32_t queued_cmdsn;
215
213 /* configuration */ 216 /* configuration */
214 int initial_r2t_en; 217 int initial_r2t_en;
215 unsigned max_r2t; 218 unsigned max_r2t;
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index df36461fe881..8dda2d66b5b9 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -348,7 +348,7 @@ struct sas_ha_struct {
348 348
349/* public: */ 349/* public: */
350 char *sas_ha_name; 350 char *sas_ha_name;
351 struct pci_dev *pcidev; /* should be set */ 351 struct device *dev; /* should be set */
352 struct module *lldd_module; /* should be set */ 352 struct module *lldd_module; /* should be set */
353 353
354 u8 *sas_addr; /* must be set */ 354 u8 *sas_addr; /* must be set */
diff --git a/include/scsi/sd.h b/include/scsi/sd.h
index 5261488e1108..78583fee0ab2 100644
--- a/include/scsi/sd.h
+++ b/include/scsi/sd.h
@@ -57,7 +57,7 @@ static int sd_resume(struct device *dev);
57static void sd_rescan(struct device *); 57static void sd_rescan(struct device *);
58static int sd_init_command(struct scsi_cmnd *); 58static int sd_init_command(struct scsi_cmnd *);
59static int sd_issue_flush(struct device *, sector_t *); 59static int sd_issue_flush(struct device *, sector_t *);
60static void sd_prepare_flush(request_queue_t *, struct request *); 60static void sd_prepare_flush(struct request_queue *, struct request *);
61static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); 61static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
62static void scsi_disk_release(struct class_device *cdev); 62static void scsi_disk_release(struct class_device *cdev);
63static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); 63static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
diff --git a/include/video/tx3912.h b/include/video/tx3912.h
deleted file mode 100644
index 6b6d006038c2..000000000000
--- a/include/video/tx3912.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * linux/include/video/tx3912.h
3 *
4 * Copyright (C) 2001 Steven Hill (sjhill@realitydiluted.com)
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive for
8 * more details.
9 *
10 * Includes for TMPR3912/05 and PR31700 LCD controller registers
11 */
12#include <asm/tx3912.h>
13
14#define VidCtrl1 REG_AT(0x028)
15#define VidCtrl2 REG_AT(0x02C)
16#define VidCtrl3 REG_AT(0x030)
17#define VidCtrl4 REG_AT(0x034)
18#define VidCtrl5 REG_AT(0x038)
19#define VidCtrl6 REG_AT(0x03C)
20#define VidCtrl7 REG_AT(0x040)
21#define VidCtrl8 REG_AT(0x044)
22#define VidCtrl9 REG_AT(0x048)
23#define VidCtrl10 REG_AT(0x04C)
24#define VidCtrl11 REG_AT(0x050)
25#define VidCtrl12 REG_AT(0x054)
26#define VidCtrl13 REG_AT(0x058)
27#define VidCtrl14 REG_AT(0x05C)
28
29/* Video Control 1 Register */
30#define LINECNT 0xffc00000
31#define LINECNT_SHIFT 22
32#define LOADDLY BIT(21)
33#define BAUDVAL (BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16))
34#define BAUDVAL_SHIFT 16
35#define VIDDONEVAL (BIT(15) | BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10) | BIT(9))
36#define VIDDONEVAL_SHIFT 9
37#define ENFREEZEFRAME BIT(8)
38#define TX3912_VIDCTRL1_BITSEL_MASK 0x000000c0
39#define TX3912_VIDCTRL1_2BIT_GRAY 0x00000040
40#define TX3912_VIDCTRL1_4BIT_GRAY 0x00000080
41#define TX3912_VIDCTRL1_8BIT_COLOR 0x000000c0
42#define BITSEL_SHIFT 6
43#define DISPSPLIT BIT(5)
44#define DISP8 BIT(4)
45#define DFMODE BIT(3)
46#define INVVID BIT(2)
47#define DISPON BIT(1)
48#define ENVID BIT(0)
49
50/* Video Control 2 Register */
51#define VIDRATE_MASK 0xffc00000
52#define VIDRATE_SHIFT 22
53#define HORZVAL_MASK 0x001ff000
54#define HORZVAL_SHIFT 12
55#define LINEVAL_MASK 0x000001ff
56
57/* Video Control 3 Register */
58#define TX3912_VIDCTRL3_VIDBANK_MASK 0xfff00000
59#define TX3912_VIDCTRL3_VIDBASEHI_MASK 0x000ffff0
60
61/* Video Control 4 Register */
62#define TX3912_VIDCTRL4_VIDBASELO_MASK 0x000ffff0
diff --git a/include/xen/page.h b/include/xen/page.h
index 1df6c1930578..c0c8fcb27899 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -4,6 +4,7 @@
4#include <linux/pfn.h> 4#include <linux/pfn.h>
5 5
6#include <asm/uaccess.h> 6#include <asm/uaccess.h>
7#include <asm/pgtable.h>
7 8
8#include <xen/features.h> 9#include <xen/features.h>
9 10
diff --git a/init/Kconfig b/init/Kconfig
index e2056828dc64..96b54595f1dc 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -7,7 +7,7 @@ config DEFCONFIG_LIST
7 default "/boot/config-$UNAME_RELEASE" 7 default "/boot/config-$UNAME_RELEASE"
8 default "arch/$ARCH/defconfig" 8 default "arch/$ARCH/defconfig"
9 9
10menu "Code maturity level options" 10menu "General setup"
11 11
12config EXPERIMENTAL 12config EXPERIMENTAL
13 bool "Prompt for development and/or incomplete code/drivers" 13 bool "Prompt for development and/or incomplete code/drivers"
@@ -61,9 +61,6 @@ config INIT_ENV_ARG_LIMIT
61 Maximum of each of the number of arguments and environment 61 Maximum of each of the number of arguments and environment
62 variables passed to init from the kernel command line. 62 variables passed to init from the kernel command line.
63 63
64endmenu
65
66menu "General setup"
67 64
68config LOCALVERSION 65config LOCALVERSION
69 string "Local version - append to kernel release" 66 string "Local version - append to kernel release"
@@ -340,7 +337,7 @@ endif
340config CC_OPTIMIZE_FOR_SIZE 337config CC_OPTIMIZE_FOR_SIZE
341 bool "Optimize for size (Look out for broken compilers!)" 338 bool "Optimize for size (Look out for broken compilers!)"
342 default y 339 default y
343 depends on ARM || H8300 || EXPERIMENTAL 340 depends on ARM || H8300 || SUPERH || EXPERIMENTAL
344 help 341 help
345 Enabling this option will pass "-Os" instead of "-O2" to gcc 342 Enabling this option will pass "-Os" instead of "-O2" to gcc
346 resulting in a smaller kernel. 343 resulting in a smaller kernel.
@@ -468,25 +465,19 @@ config FUTEX
468 run glibc-based applications correctly. 465 run glibc-based applications correctly.
469 466
470config ANON_INODES 467config ANON_INODES
471 bool "Enable anonymous inode source" if EMBEDDED 468 bool
472 default y
473 help
474 Anonymous inode source for pseudo-files like epoll, signalfd,
475 timerfd and eventfd.
476
477 If unsure, say Y.
478 469
479config EPOLL 470config EPOLL
480 bool "Enable eventpoll support" if EMBEDDED 471 bool "Enable eventpoll support" if EMBEDDED
481 default y 472 default y
482 depends on ANON_INODES 473 select ANON_INODES
483 help 474 help
484 Disabling this option will cause the kernel to be built without 475 Disabling this option will cause the kernel to be built without
485 support for epoll family of system calls. 476 support for epoll family of system calls.
486 477
487config SIGNALFD 478config SIGNALFD
488 bool "Enable signalfd() system call" if EMBEDDED 479 bool "Enable signalfd() system call" if EMBEDDED
489 depends on ANON_INODES 480 select ANON_INODES
490 default y 481 default y
491 help 482 help
492 Enable the signalfd() system call that allows to receive signals 483 Enable the signalfd() system call that allows to receive signals
@@ -496,7 +487,7 @@ config SIGNALFD
496 487
497config TIMERFD 488config TIMERFD
498 bool "Enable timerfd() system call" if EMBEDDED 489 bool "Enable timerfd() system call" if EMBEDDED
499 depends on ANON_INODES 490 select ANON_INODES
500 default y 491 default y
501 help 492 help
502 Enable the timerfd() system call that allows to receive timer 493 Enable the timerfd() system call that allows to receive timer
@@ -506,7 +497,7 @@ config TIMERFD
506 497
507config EVENTFD 498config EVENTFD
508 bool "Enable eventfd() system call" if EMBEDDED 499 bool "Enable eventfd() system call" if EMBEDDED
509 depends on ANON_INODES 500 select ANON_INODES
510 default y 501 default y
511 help 502 help
512 Enable the eventfd() system call that allows to receive both 503 Enable the eventfd() system call that allows to receive both
diff --git a/init/initramfs.c b/init/initramfs.c
index 00eff7a11085..1db02a0025db 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -133,7 +133,7 @@ static __initdata loff_t this_header, next_header;
133 133
134static __initdata int dry_run; 134static __initdata int dry_run;
135 135
136static inline void eat(unsigned n) 136static inline void __init eat(unsigned n)
137{ 137{
138 victim += n; 138 victim += n;
139 this_header += n; 139 this_header += n;
diff --git a/ipc/shm.c b/ipc/shm.c
index d0259e3ad1c0..a86a3a5c8a19 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -268,7 +268,9 @@ static int shm_mmap(struct file * file, struct vm_area_struct * vma)
268 if (ret != 0) 268 if (ret != 0)
269 return ret; 269 return ret;
270 sfd->vm_ops = vma->vm_ops; 270 sfd->vm_ops = vma->vm_ops;
271#ifdef CONFIG_MMU
271 BUG_ON(!sfd->vm_ops->fault); 272 BUG_ON(!sfd->vm_ops->fault);
273#endif
272 vma->vm_ops = &shm_vm_ops; 274 vma->vm_ops = &shm_vm_ops;
273 shm_open(vma); 275 shm_open(vma);
274 276
@@ -714,7 +716,7 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
714 struct user_struct * user = current->user; 716 struct user_struct * user = current->user;
715 if (!is_file_hugepages(shp->shm_file)) { 717 if (!is_file_hugepages(shp->shm_file)) {
716 err = shmem_lock(shp->shm_file, 1, user); 718 err = shmem_lock(shp->shm_file, 1, user);
717 if (!err) { 719 if (!err && !(shp->shm_perm.mode & SHM_LOCKED)){
718 shp->shm_perm.mode |= SHM_LOCKED; 720 shp->shm_perm.mode |= SHM_LOCKED;
719 shp->mlock_user = user; 721 shp->mlock_user = user;
720 } 722 }
diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt
index c64ce9c14207..6b066632e40c 100644
--- a/kernel/Kconfig.preempt
+++ b/kernel/Kconfig.preempt
@@ -63,3 +63,6 @@ config PREEMPT_BKL
63 Say Y here if you are building a kernel for a desktop system. 63 Say Y here if you are building a kernel for a desktop system.
64 Say N if you are unsure. 64 Say N if you are unsure.
65 65
66config PREEMPT_NOTIFIERS
67 bool
68
diff --git a/kernel/acct.c b/kernel/acct.c
index 70d0d88e5554..24f0f8b2ba72 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -468,7 +468,7 @@ static void do_acct_process(struct file *file)
468 } 468 }
469#endif 469#endif
470 do_div(elapsed, AHZ); 470 do_div(elapsed, AHZ);
471 ac.ac_btime = xtime.tv_sec - elapsed; 471 ac.ac_btime = get_seconds() - elapsed;
472 /* we really need to bite the bullet and change layout */ 472 /* we really need to bite the bullet and change layout */
473 ac.ac_uid = current->uid; 473 ac.ac_uid = current->uid;
474 ac.ac_gid = current->gid; 474 ac.ac_gid = current->gid;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index bde1124d5908..a777d3761416 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -824,12 +824,14 @@ static void audit_log_execve_info(struct audit_buffer *ab,
824{ 824{
825 int i; 825 int i;
826 long len, ret; 826 long len, ret;
827 const char __user *p = (const char __user *)axi->mm->arg_start; 827 const char __user *p;
828 char *buf; 828 char *buf;
829 829
830 if (axi->mm != current->mm) 830 if (axi->mm != current->mm)
831 return; /* execve failed, no additional info */ 831 return; /* execve failed, no additional info */
832 832
833 p = (const char __user *)axi->mm->arg_start;
834
833 for (i = 0; i < axi->argc; i++, p += len) { 835 for (i = 0; i < axi->argc; i++, p += len) {
834 len = strnlen_user(p, MAX_ARG_STRLEN); 836 len = strnlen_user(p, MAX_ARG_STRLEN);
835 /* 837 /*
@@ -855,7 +857,7 @@ static void audit_log_execve_info(struct audit_buffer *ab,
855 * copied them here, and the mm hasn't been exposed to user- 857 * copied them here, and the mm hasn't been exposed to user-
856 * space yet. 858 * space yet.
857 */ 859 */
858 if (!ret) { 860 if (ret) {
859 WARN_ON(1); 861 WARN_ON(1);
860 send_sig(SIGKILL, current, 0); 862 send_sig(SIGKILL, current, 0);
861 } 863 }
diff --git a/kernel/futex.c b/kernel/futex.c
index a12425051ee9..3415e9ad1391 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2060,8 +2060,10 @@ asmlinkage long sys_futex(u32 __user *uaddr, int op, u32 val,
2060 } 2060 }
2061 /* 2061 /*
2062 * requeue parameter in 'utime' if cmd == FUTEX_REQUEUE. 2062 * requeue parameter in 'utime' if cmd == FUTEX_REQUEUE.
2063 * number of waiters to wake in 'utime' if cmd == FUTEX_WAKE_OP.
2063 */ 2064 */
2064 if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE) 2065 if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE ||
2066 cmd == FUTEX_WAKE_OP)
2065 val2 = (u32) (unsigned long) utime; 2067 val2 = (u32) (unsigned long) utime;
2066 2068
2067 return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); 2069 return do_futex(uaddr, op, val, tp, uaddr2, val2, val3);
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index eb1ddebd2c04..c21ca6bfaa66 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -141,11 +141,7 @@ static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base)
141 141
142 do { 142 do {
143 seq = read_seqbegin(&xtime_lock); 143 seq = read_seqbegin(&xtime_lock);
144#ifdef CONFIG_NO_HZ 144 xts = current_kernel_time();
145 getnstimeofday(&xts);
146#else
147 xts = xtime;
148#endif
149 tom = wall_to_monotonic; 145 tom = wall_to_monotonic;
150 } while (read_seqretry(&xtime_lock, seq)); 146 } while (read_seqretry(&xtime_lock, seq));
151 147
diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
index d8ee241115f5..6d9204f3a370 100644
--- a/kernel/irq/devres.c
+++ b/kernel/irq/devres.c
@@ -1,5 +1,6 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <linux/interrupt.h> 2#include <linux/interrupt.h>
3#include <linux/device.h>
3 4
4/* 5/*
5 * Device resource management aware IRQ request/free implementation. 6 * Device resource management aware IRQ request/free implementation.
diff --git a/kernel/kmod.c b/kernel/kmod.c
index beedbdc64608..9809cc1f33d6 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -351,11 +351,11 @@ static inline void register_pm_notifier_callback(void) {}
351 351
352/** 352/**
353 * call_usermodehelper_setup - prepare to call a usermode helper 353 * call_usermodehelper_setup - prepare to call a usermode helper
354 * @path - path to usermode executable 354 * @path: path to usermode executable
355 * @argv - arg vector for process 355 * @argv: arg vector for process
356 * @envp - environment for process 356 * @envp: environment for process
357 * 357 *
358 * Returns either NULL on allocation failure, or a subprocess_info 358 * Returns either %NULL on allocation failure, or a subprocess_info
359 * structure. This should be passed to call_usermodehelper_exec to 359 * structure. This should be passed to call_usermodehelper_exec to
360 * exec the process and free the structure. 360 * exec the process and free the structure.
361 */ 361 */
diff --git a/kernel/kthread.c b/kernel/kthread.c
index a404f7ee7395..dcfe724300eb 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -214,23 +214,15 @@ int kthread_stop(struct task_struct *k)
214} 214}
215EXPORT_SYMBOL(kthread_stop); 215EXPORT_SYMBOL(kthread_stop);
216 216
217 217int kthreadd(void *unused)
218static noinline __init_refok void kthreadd_setup(void)
219{ 218{
220 struct task_struct *tsk = current; 219 struct task_struct *tsk = current;
221 220
221 /* Setup a clean context for our children to inherit. */
222 set_task_comm(tsk, "kthreadd"); 222 set_task_comm(tsk, "kthreadd");
223
224 ignore_signals(tsk); 223 ignore_signals(tsk);
225
226 set_user_nice(tsk, -5); 224 set_user_nice(tsk, -5);
227 set_cpus_allowed(tsk, CPU_MASK_ALL); 225 set_cpus_allowed(tsk, CPU_MASK_ALL);
228}
229
230int kthreadd(void *unused)
231{
232 /* Setup a clean context for our children to inherit. */
233 kthreadd_setup();
234 226
235 current->flags |= PF_NOFREEZE; 227 current->flags |= PF_NOFREEZE;
236 228
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index 9f17af4a2490..c851b2dcc685 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -346,7 +346,7 @@ static const struct file_operations proc_lockdep_stats_operations = {
346 .open = lockdep_stats_open, 346 .open = lockdep_stats_open,
347 .read = seq_read, 347 .read = seq_read,
348 .llseek = seq_lseek, 348 .llseek = seq_lseek,
349 .release = seq_release, 349 .release = single_release,
350}; 350};
351 351
352#ifdef CONFIG_LOCK_STAT 352#ifdef CONFIG_LOCK_STAT
diff --git a/kernel/params.c b/kernel/params.c
index effbaaedd7f3..4e57732fcfb4 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -567,7 +567,12 @@ static void __init kernel_param_sysfs_setup(const char *name,
567 kobject_set_name(&mk->kobj, name); 567 kobject_set_name(&mk->kobj, name);
568 kobject_init(&mk->kobj); 568 kobject_init(&mk->kobj);
569 ret = kobject_add(&mk->kobj); 569 ret = kobject_add(&mk->kobj);
570 BUG_ON(ret < 0); 570 if (ret) {
571 printk(KERN_ERR "Module '%s' failed to be added to sysfs, "
572 "error number %d\n", name, ret);
573 printk(KERN_ERR "The system will be unstable now.\n");
574 return;
575 }
571 param_sysfs_setup(mk, kparam, num_params, name_skip); 576 param_sysfs_setup(mk, kparam, num_params, name_skip);
572 kobject_uevent(&mk->kobj, KOBJ_ADD); 577 kobject_uevent(&mk->kobj, KOBJ_ADD);
573} 578}
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index c1a106d87d90..412859f8d94a 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -46,7 +46,7 @@ config PM_VERBOSE
46 46
47config DISABLE_CONSOLE_SUSPEND 47config DISABLE_CONSOLE_SUSPEND
48 bool "Keep console(s) enabled during suspend/resume (DANGEROUS)" 48 bool "Keep console(s) enabled during suspend/resume (DANGEROUS)"
49 depends on PM_DEBUG 49 depends on PM_DEBUG && PM_SLEEP
50 default n 50 default n
51 ---help--- 51 ---help---
52 This option turns off the console suspend mechanism that prevents 52 This option turns off the console suspend mechanism that prevents
@@ -57,7 +57,7 @@ config DISABLE_CONSOLE_SUSPEND
57 57
58config PM_TRACE 58config PM_TRACE
59 bool "Suspend/resume event tracing" 59 bool "Suspend/resume event tracing"
60 depends on PM_DEBUG && X86 && EXPERIMENTAL 60 depends on PM_DEBUG && X86 && PM_SLEEP && EXPERIMENTAL
61 default n 61 default n
62 ---help--- 62 ---help---
63 This enables some cheesy code to save the last PM event point in the 63 This enables some cheesy code to save the last PM event point in the
@@ -72,9 +72,37 @@ config PM_TRACE
72 CAUTION: this option will cause your machine's real-time clock to be 72 CAUTION: this option will cause your machine's real-time clock to be
73 set to an invalid time after a resume. 73 set to an invalid time after a resume.
74 74
75config SOFTWARE_SUSPEND 75config SUSPEND_SMP_POSSIBLE
76 bool "Software Suspend (Hibernation)" 76 bool
77 depends on PM && SWAP && (((X86 || PPC64_SWSUSP) && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP)) 77 depends on (X86 && !X86_VOYAGER) || (PPC64 && (PPC_PSERIES || PPC_PMAC))
78 depends on SMP
79 default y
80
81config SUSPEND_SMP
82 bool
83 depends on SUSPEND_SMP_POSSIBLE && PM_SLEEP
84 select HOTPLUG_CPU
85 default y
86
87config PM_SLEEP
88 bool
89 depends on SUSPEND || HIBERNATION
90 default y
91
92config SUSPEND
93 bool "Suspend to RAM and standby"
94 depends on PM
95 depends on !SMP || SUSPEND_SMP_POSSIBLE
96 default y
97 ---help---
98 Allow the system to enter sleep states in which main memory is
99 powered and thus its contents are preserved, such as the
100 suspend-to-RAM state (i.e. the ACPI S3 state).
101
102config HIBERNATION
103 bool "Hibernation (aka 'suspend to disk')"
104 depends on PM && SWAP
105 depends on ((X86 || PPC64_SWSUSP || FRV || PPC32) && !SMP) || SUSPEND_SMP_POSSIBLE
78 ---help--- 106 ---help---
79 Enable the suspend to disk (STD) functionality, which is usually 107 Enable the suspend to disk (STD) functionality, which is usually
80 called "hibernation" in user interfaces. STD checkpoints the 108 called "hibernation" in user interfaces. STD checkpoints the
@@ -112,7 +140,7 @@ config SOFTWARE_SUSPEND
112 140
113config PM_STD_PARTITION 141config PM_STD_PARTITION
114 string "Default resume partition" 142 string "Default resume partition"
115 depends on SOFTWARE_SUSPEND 143 depends on HIBERNATION
116 default "" 144 default ""
117 ---help--- 145 ---help---
118 The default resume partition is the partition that the suspend- 146 The default resume partition is the partition that the suspend-
@@ -132,11 +160,6 @@ config PM_STD_PARTITION
132 suspended image to. It will simply pick the first available swap 160 suspended image to. It will simply pick the first available swap
133 device. 161 device.
134 162
135config SUSPEND_SMP
136 bool
137 depends on HOTPLUG_CPU && (X86 || PPC64) && PM
138 default y
139
140config APM_EMULATION 163config APM_EMULATION
141 tristate "Advanced Power Management Emulation" 164 tristate "Advanced Power Management Emulation"
142 depends on PM && SYS_SUPPORTS_APM_EMULATION 165 depends on PM && SYS_SUPPORTS_APM_EMULATION
diff --git a/kernel/power/Makefile b/kernel/power/Makefile
index 38725f526afc..f7dfff28ecdb 100644
--- a/kernel/power/Makefile
+++ b/kernel/power/Makefile
@@ -3,8 +3,9 @@ ifeq ($(CONFIG_PM_DEBUG),y)
3EXTRA_CFLAGS += -DDEBUG 3EXTRA_CFLAGS += -DDEBUG
4endif 4endif
5 5
6obj-y := main.o process.o console.o 6obj-y := main.o
7obj-$(CONFIG_PM_LEGACY) += pm.o 7obj-$(CONFIG_PM_LEGACY) += pm.o
8obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o disk.o snapshot.o swap.o user.o 8obj-$(CONFIG_PM_SLEEP) += process.o console.o
9obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o
9 10
10obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o 11obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 324ac0188ce1..eb72255b5c86 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -216,6 +216,7 @@ int hibernation_platform_enter(void)
216 * sleep state after all 216 * sleep state after all
217 */ 217 */
218 error = hibernation_ops->prepare(); 218 error = hibernation_ops->prepare();
219 sysdev_shutdown();
219 if (!error) 220 if (!error)
220 error = hibernation_ops->enter(); 221 error = hibernation_ops->enter();
221 } else { 222 } else {
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 32147b57c3bf..350b485b3b60 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -25,11 +25,13 @@
25 25
26BLOCKING_NOTIFIER_HEAD(pm_chain_head); 26BLOCKING_NOTIFIER_HEAD(pm_chain_head);
27 27
28/*This is just an arbitrary number */
29#define FREE_PAGE_NUMBER (100)
30
31DEFINE_MUTEX(pm_mutex); 28DEFINE_MUTEX(pm_mutex);
32 29
30#ifdef CONFIG_SUSPEND
31
32/* This is just an arbitrary number */
33#define FREE_PAGE_NUMBER (100)
34
33struct pm_ops *pm_ops; 35struct pm_ops *pm_ops;
34 36
35/** 37/**
@@ -269,6 +271,8 @@ int pm_suspend(suspend_state_t state)
269 271
270EXPORT_SYMBOL(pm_suspend); 272EXPORT_SYMBOL(pm_suspend);
271 273
274#endif /* CONFIG_SUSPEND */
275
272decl_subsys(power,NULL,NULL); 276decl_subsys(power,NULL,NULL);
273 277
274 278
@@ -285,14 +289,16 @@ decl_subsys(power,NULL,NULL);
285 289
286static ssize_t state_show(struct kset *kset, char *buf) 290static ssize_t state_show(struct kset *kset, char *buf)
287{ 291{
292 char *s = buf;
293#ifdef CONFIG_SUSPEND
288 int i; 294 int i;
289 char * s = buf;
290 295
291 for (i = 0; i < PM_SUSPEND_MAX; i++) { 296 for (i = 0; i < PM_SUSPEND_MAX; i++) {
292 if (pm_states[i] && valid_state(i)) 297 if (pm_states[i] && valid_state(i))
293 s += sprintf(s,"%s ", pm_states[i]); 298 s += sprintf(s,"%s ", pm_states[i]);
294 } 299 }
295#ifdef CONFIG_SOFTWARE_SUSPEND 300#endif
301#ifdef CONFIG_HIBERNATION
296 s += sprintf(s, "%s\n", "disk"); 302 s += sprintf(s, "%s\n", "disk");
297#else 303#else
298 if (s != buf) 304 if (s != buf)
@@ -304,11 +310,13 @@ static ssize_t state_show(struct kset *kset, char *buf)
304 310
305static ssize_t state_store(struct kset *kset, const char *buf, size_t n) 311static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
306{ 312{
313#ifdef CONFIG_SUSPEND
307 suspend_state_t state = PM_SUSPEND_STANDBY; 314 suspend_state_t state = PM_SUSPEND_STANDBY;
308 const char * const *s; 315 const char * const *s;
316#endif
309 char *p; 317 char *p;
310 int error;
311 int len; 318 int len;
319 int error = -EINVAL;
312 320
313 p = memchr(buf, '\n', n); 321 p = memchr(buf, '\n', n);
314 len = p ? p - buf : n; 322 len = p ? p - buf : n;
@@ -316,17 +324,19 @@ static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
316 /* First, check if we are requested to hibernate */ 324 /* First, check if we are requested to hibernate */
317 if (len == 4 && !strncmp(buf, "disk", len)) { 325 if (len == 4 && !strncmp(buf, "disk", len)) {
318 error = hibernate(); 326 error = hibernate();
319 return error ? error : n; 327 goto Exit;
320 } 328 }
321 329
330#ifdef CONFIG_SUSPEND
322 for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) { 331 for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
323 if (*s && len == strlen(*s) && !strncmp(buf, *s, len)) 332 if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
324 break; 333 break;
325 } 334 }
326 if (state < PM_SUSPEND_MAX && *s) 335 if (state < PM_SUSPEND_MAX && *s)
327 error = enter_state(state); 336 error = enter_state(state);
328 else 337#endif
329 error = -EINVAL; 338
339 Exit:
330 return error ? error : n; 340 return error ? error : n;
331} 341}
332 342
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 5f24c786f8ec..95fbf2dd3fe3 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -13,7 +13,7 @@ struct swsusp_info {
13 13
14 14
15 15
16#ifdef CONFIG_SOFTWARE_SUSPEND 16#ifdef CONFIG_HIBERNATION
17/* 17/*
18 * Keep some memory free so that I/O operations can succeed without paging 18 * Keep some memory free so that I/O operations can succeed without paging
19 * [Might this be more than 4 MB?] 19 * [Might this be more than 4 MB?]
@@ -176,9 +176,17 @@ struct timeval;
176extern void swsusp_show_speed(struct timeval *, struct timeval *, 176extern void swsusp_show_speed(struct timeval *, struct timeval *,
177 unsigned int, char *); 177 unsigned int, char *);
178 178
179#ifdef CONFIG_SUSPEND
179/* kernel/power/main.c */ 180/* kernel/power/main.c */
180extern int suspend_enter(suspend_state_t state);
181extern int suspend_devices_and_enter(suspend_state_t state); 181extern int suspend_devices_and_enter(suspend_state_t state);
182#else /* !CONFIG_SUSPEND */
183static inline int suspend_devices_and_enter(suspend_state_t state)
184{
185 return -ENOSYS;
186}
187#endif /* !CONFIG_SUSPEND */
188
189/* kernel/power/common.c */
182extern struct blocking_notifier_head pm_chain_head; 190extern struct blocking_notifier_head pm_chain_head;
183 191
184static inline int pm_notifier_call_chain(unsigned long val) 192static inline int pm_notifier_call_chain(unsigned long val)
diff --git a/kernel/relay.c b/kernel/relay.c
index 510fbbd7b500..ad855017bc59 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Public API and common code for kernel->userspace relay file support. 2 * Public API and common code for kernel->userspace relay file support.
3 * 3 *
4 * See Documentation/filesystems/relayfs.txt for an overview of relayfs. 4 * See Documentation/filesystems/relay.txt for an overview.
5 * 5 *
6 * Copyright (C) 2002-2005 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp 6 * Copyright (C) 2002-2005 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
7 * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com) 7 * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com)
@@ -426,6 +426,7 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)
426 426
427free_buf: 427free_buf:
428 relay_destroy_buf(buf); 428 relay_destroy_buf(buf);
429 buf = NULL;
429free_name: 430free_name:
430 kfree(tmpname); 431 kfree(tmpname);
431end: 432end:
diff --git a/kernel/sched.c b/kernel/sched.c
index 93cf241cfbe9..238a76957e86 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -53,6 +53,7 @@
53#include <linux/percpu.h> 53#include <linux/percpu.h>
54#include <linux/kthread.h> 54#include <linux/kthread.h>
55#include <linux/seq_file.h> 55#include <linux/seq_file.h>
56#include <linux/sysctl.h>
56#include <linux/syscalls.h> 57#include <linux/syscalls.h>
57#include <linux/times.h> 58#include <linux/times.h>
58#include <linux/tsacct_kern.h> 59#include <linux/tsacct_kern.h>
@@ -263,8 +264,6 @@ struct rq {
263 unsigned int clock_warps, clock_overflows; 264 unsigned int clock_warps, clock_overflows;
264 unsigned int clock_unstable_events; 265 unsigned int clock_unstable_events;
265 266
266 struct sched_class *load_balance_class;
267
268 atomic_t nr_iowait; 267 atomic_t nr_iowait;
269 268
270#ifdef CONFIG_SMP 269#ifdef CONFIG_SMP
@@ -385,13 +384,12 @@ static inline unsigned long long rq_clock(struct rq *rq)
385 */ 384 */
386unsigned long long cpu_clock(int cpu) 385unsigned long long cpu_clock(int cpu)
387{ 386{
388 struct rq *rq = cpu_rq(cpu);
389 unsigned long long now; 387 unsigned long long now;
390 unsigned long flags; 388 unsigned long flags;
391 389
392 spin_lock_irqsave(&rq->lock, flags); 390 local_irq_save(flags);
393 now = rq_clock(rq); 391 now = rq_clock(cpu_rq(cpu));
394 spin_unlock_irqrestore(&rq->lock, flags); 392 local_irq_restore(flags);
395 393
396 return now; 394 return now;
397} 395}
@@ -1592,6 +1590,10 @@ static void __sched_fork(struct task_struct *p)
1592 INIT_LIST_HEAD(&p->run_list); 1590 INIT_LIST_HEAD(&p->run_list);
1593 p->se.on_rq = 0; 1591 p->se.on_rq = 0;
1594 1592
1593#ifdef CONFIG_PREEMPT_NOTIFIERS
1594 INIT_HLIST_HEAD(&p->preempt_notifiers);
1595#endif
1596
1595 /* 1597 /*
1596 * We mark the process as running here, but have not actually 1598 * We mark the process as running here, but have not actually
1597 * inserted it onto the runqueue yet. This guarantees that 1599 * inserted it onto the runqueue yet. This guarantees that
@@ -1673,9 +1675,68 @@ void fastcall wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
1673 task_rq_unlock(rq, &flags); 1675 task_rq_unlock(rq, &flags);
1674} 1676}
1675 1677
1678#ifdef CONFIG_PREEMPT_NOTIFIERS
1679
1680/**
1681 * preempt_notifier_register - tell me when current is being being preempted & rescheduled
1682 * @notifier: notifier struct to register
1683 */
1684void preempt_notifier_register(struct preempt_notifier *notifier)
1685{
1686 hlist_add_head(&notifier->link, &current->preempt_notifiers);
1687}
1688EXPORT_SYMBOL_GPL(preempt_notifier_register);
1689
1690/**
1691 * preempt_notifier_unregister - no longer interested in preemption notifications
1692 * @notifier: notifier struct to unregister
1693 *
1694 * This is safe to call from within a preemption notifier.
1695 */
1696void preempt_notifier_unregister(struct preempt_notifier *notifier)
1697{
1698 hlist_del(&notifier->link);
1699}
1700EXPORT_SYMBOL_GPL(preempt_notifier_unregister);
1701
1702static void fire_sched_in_preempt_notifiers(struct task_struct *curr)
1703{
1704 struct preempt_notifier *notifier;
1705 struct hlist_node *node;
1706
1707 hlist_for_each_entry(notifier, node, &curr->preempt_notifiers, link)
1708 notifier->ops->sched_in(notifier, raw_smp_processor_id());
1709}
1710
1711static void
1712fire_sched_out_preempt_notifiers(struct task_struct *curr,
1713 struct task_struct *next)
1714{
1715 struct preempt_notifier *notifier;
1716 struct hlist_node *node;
1717
1718 hlist_for_each_entry(notifier, node, &curr->preempt_notifiers, link)
1719 notifier->ops->sched_out(notifier, next);
1720}
1721
1722#else
1723
1724static void fire_sched_in_preempt_notifiers(struct task_struct *curr)
1725{
1726}
1727
1728static void
1729fire_sched_out_preempt_notifiers(struct task_struct *curr,
1730 struct task_struct *next)
1731{
1732}
1733
1734#endif
1735
1676/** 1736/**
1677 * prepare_task_switch - prepare to switch tasks 1737 * prepare_task_switch - prepare to switch tasks
1678 * @rq: the runqueue preparing to switch 1738 * @rq: the runqueue preparing to switch
1739 * @prev: the current task that is being switched out
1679 * @next: the task we are going to switch to. 1740 * @next: the task we are going to switch to.
1680 * 1741 *
1681 * This is called with the rq lock held and interrupts off. It must 1742 * This is called with the rq lock held and interrupts off. It must
@@ -1685,8 +1746,11 @@ void fastcall wake_up_new_task(struct task_struct *p, unsigned long clone_flags)
1685 * prepare_task_switch sets up locking and calls architecture specific 1746 * prepare_task_switch sets up locking and calls architecture specific
1686 * hooks. 1747 * hooks.
1687 */ 1748 */
1688static inline void prepare_task_switch(struct rq *rq, struct task_struct *next) 1749static inline void
1750prepare_task_switch(struct rq *rq, struct task_struct *prev,
1751 struct task_struct *next)
1689{ 1752{
1753 fire_sched_out_preempt_notifiers(prev, next);
1690 prepare_lock_switch(rq, next); 1754 prepare_lock_switch(rq, next);
1691 prepare_arch_switch(next); 1755 prepare_arch_switch(next);
1692} 1756}
@@ -1728,6 +1792,7 @@ static inline void finish_task_switch(struct rq *rq, struct task_struct *prev)
1728 prev_state = prev->state; 1792 prev_state = prev->state;
1729 finish_arch_switch(prev); 1793 finish_arch_switch(prev);
1730 finish_lock_switch(rq, prev); 1794 finish_lock_switch(rq, prev);
1795 fire_sched_in_preempt_notifiers(current);
1731 if (mm) 1796 if (mm)
1732 mmdrop(mm); 1797 mmdrop(mm);
1733 if (unlikely(prev_state == TASK_DEAD)) { 1798 if (unlikely(prev_state == TASK_DEAD)) {
@@ -1768,7 +1833,7 @@ context_switch(struct rq *rq, struct task_struct *prev,
1768{ 1833{
1769 struct mm_struct *mm, *oldmm; 1834 struct mm_struct *mm, *oldmm;
1770 1835
1771 prepare_task_switch(rq, next); 1836 prepare_task_switch(rq, prev, next);
1772 mm = next->mm; 1837 mm = next->mm;
1773 oldmm = prev->active_mm; 1838 oldmm = prev->active_mm;
1774 /* 1839 /*
@@ -5140,10 +5205,129 @@ static void migrate_dead_tasks(unsigned int dead_cpu)
5140 if (!next) 5205 if (!next)
5141 break; 5206 break;
5142 migrate_dead(dead_cpu, next); 5207 migrate_dead(dead_cpu, next);
5208
5143 } 5209 }
5144} 5210}
5145#endif /* CONFIG_HOTPLUG_CPU */ 5211#endif /* CONFIG_HOTPLUG_CPU */
5146 5212
5213#if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
5214
5215static struct ctl_table sd_ctl_dir[] = {
5216 {CTL_UNNUMBERED, "sched_domain", NULL, 0, 0755, NULL, },
5217 {0,},
5218};
5219
5220static struct ctl_table sd_ctl_root[] = {
5221 {CTL_UNNUMBERED, "kernel", NULL, 0, 0755, sd_ctl_dir, },
5222 {0,},
5223};
5224
5225static struct ctl_table *sd_alloc_ctl_entry(int n)
5226{
5227 struct ctl_table *entry =
5228 kmalloc(n * sizeof(struct ctl_table), GFP_KERNEL);
5229
5230 BUG_ON(!entry);
5231 memset(entry, 0, n * sizeof(struct ctl_table));
5232
5233 return entry;
5234}
5235
5236static void
5237set_table_entry(struct ctl_table *entry, int ctl_name,
5238 const char *procname, void *data, int maxlen,
5239 mode_t mode, proc_handler *proc_handler)
5240{
5241 entry->ctl_name = ctl_name;
5242 entry->procname = procname;
5243 entry->data = data;
5244 entry->maxlen = maxlen;
5245 entry->mode = mode;
5246 entry->proc_handler = proc_handler;
5247}
5248
5249static struct ctl_table *
5250sd_alloc_ctl_domain_table(struct sched_domain *sd)
5251{
5252 struct ctl_table *table = sd_alloc_ctl_entry(14);
5253
5254 set_table_entry(&table[0], 1, "min_interval", &sd->min_interval,
5255 sizeof(long), 0644, proc_doulongvec_minmax);
5256 set_table_entry(&table[1], 2, "max_interval", &sd->max_interval,
5257 sizeof(long), 0644, proc_doulongvec_minmax);
5258 set_table_entry(&table[2], 3, "busy_idx", &sd->busy_idx,
5259 sizeof(int), 0644, proc_dointvec_minmax);
5260 set_table_entry(&table[3], 4, "idle_idx", &sd->idle_idx,
5261 sizeof(int), 0644, proc_dointvec_minmax);
5262 set_table_entry(&table[4], 5, "newidle_idx", &sd->newidle_idx,
5263 sizeof(int), 0644, proc_dointvec_minmax);
5264 set_table_entry(&table[5], 6, "wake_idx", &sd->wake_idx,
5265 sizeof(int), 0644, proc_dointvec_minmax);
5266 set_table_entry(&table[6], 7, "forkexec_idx", &sd->forkexec_idx,
5267 sizeof(int), 0644, proc_dointvec_minmax);
5268 set_table_entry(&table[7], 8, "busy_factor", &sd->busy_factor,
5269 sizeof(int), 0644, proc_dointvec_minmax);
5270 set_table_entry(&table[8], 9, "imbalance_pct", &sd->imbalance_pct,
5271 sizeof(int), 0644, proc_dointvec_minmax);
5272 set_table_entry(&table[9], 10, "cache_hot_time", &sd->cache_hot_time,
5273 sizeof(long long), 0644, proc_doulongvec_minmax);
5274 set_table_entry(&table[10], 11, "cache_nice_tries",
5275 &sd->cache_nice_tries,
5276 sizeof(int), 0644, proc_dointvec_minmax);
5277 set_table_entry(&table[12], 13, "flags", &sd->flags,
5278 sizeof(int), 0644, proc_dointvec_minmax);
5279
5280 return table;
5281}
5282
5283static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
5284{
5285 struct ctl_table *entry, *table;
5286 struct sched_domain *sd;
5287 int domain_num = 0, i;
5288 char buf[32];
5289
5290 for_each_domain(cpu, sd)
5291 domain_num++;
5292 entry = table = sd_alloc_ctl_entry(domain_num + 1);
5293
5294 i = 0;
5295 for_each_domain(cpu, sd) {
5296 snprintf(buf, 32, "domain%d", i);
5297 entry->ctl_name = i + 1;
5298 entry->procname = kstrdup(buf, GFP_KERNEL);
5299 entry->mode = 0755;
5300 entry->child = sd_alloc_ctl_domain_table(sd);
5301 entry++;
5302 i++;
5303 }
5304 return table;
5305}
5306
5307static struct ctl_table_header *sd_sysctl_header;
5308static void init_sched_domain_sysctl(void)
5309{
5310 int i, cpu_num = num_online_cpus();
5311 struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
5312 char buf[32];
5313
5314 sd_ctl_dir[0].child = entry;
5315
5316 for (i = 0; i < cpu_num; i++, entry++) {
5317 snprintf(buf, 32, "cpu%d", i);
5318 entry->ctl_name = i + 1;
5319 entry->procname = kstrdup(buf, GFP_KERNEL);
5320 entry->mode = 0755;
5321 entry->child = sd_alloc_ctl_cpu_table(i);
5322 }
5323 sd_sysctl_header = register_sysctl_table(sd_ctl_root);
5324}
5325#else
5326static void init_sched_domain_sysctl(void)
5327{
5328}
5329#endif
5330
5147/* 5331/*
5148 * migration_call - callback that gets triggered when a CPU is added. 5332 * migration_call - callback that gets triggered when a CPU is added.
5149 * Here we can start up the necessary migration thread for the new CPU. 5333 * Here we can start up the necessary migration thread for the new CPU.
@@ -6249,6 +6433,8 @@ void __init sched_init_smp(void)
6249 /* XXX: Theoretical race here - CPU may be hotplugged now */ 6433 /* XXX: Theoretical race here - CPU may be hotplugged now */
6250 hotcpu_notifier(update_sched_domains, 0); 6434 hotcpu_notifier(update_sched_domains, 0);
6251 6435
6436 init_sched_domain_sysctl();
6437
6252 /* Move init over to a non-isolated CPU */ 6438 /* Move init over to a non-isolated CPU */
6253 if (set_cpus_allowed(current, non_isolated_cpus) < 0) 6439 if (set_cpus_allowed(current, non_isolated_cpus) < 0)
6254 BUG(); 6440 BUG();
@@ -6335,6 +6521,10 @@ void __init sched_init(void)
6335 6521
6336 set_load_weight(&init_task); 6522 set_load_weight(&init_task);
6337 6523
6524#ifdef CONFIG_PREEMPT_NOTIFIERS
6525 INIT_HLIST_HEAD(&init_task.preempt_notifiers);
6526#endif
6527
6338#ifdef CONFIG_SMP 6528#ifdef CONFIG_SMP
6339 nr_cpu_ids = highest_cpu + 1; 6529 nr_cpu_ids = highest_cpu + 1;
6340 open_softirq(SCHED_SOFTIRQ, run_rebalance_domains, NULL); 6530 open_softirq(SCHED_SOFTIRQ, run_rebalance_domains, NULL);
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index 29f2c21e7da2..0eca442b7792 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -186,7 +186,7 @@ static int sched_debug_show(struct seq_file *m, void *v)
186 return 0; 186 return 0;
187} 187}
188 188
189void sysrq_sched_debug_show(void) 189static void sysrq_sched_debug_show(void)
190{ 190{
191 sched_debug_show(NULL, NULL); 191 sched_debug_show(NULL, NULL);
192} 192}
@@ -200,7 +200,7 @@ static struct file_operations sched_debug_fops = {
200 .open = sched_debug_open, 200 .open = sched_debug_open,
201 .read = seq_read, 201 .read = seq_read,
202 .llseek = seq_lseek, 202 .llseek = seq_lseek,
203 .release = seq_release, 203 .release = single_release,
204}; 204};
205 205
206static int __init init_sched_debug_procfs(void) 206static int __init init_sched_debug_procfs(void)
diff --git a/kernel/sys.c b/kernel/sys.c
index 08562f419768..449b81b98b3d 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -804,6 +804,7 @@ static void kernel_restart_prepare(char *cmd)
804 blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd); 804 blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
805 system_state = SYSTEM_RESTART; 805 system_state = SYSTEM_RESTART;
806 device_shutdown(); 806 device_shutdown();
807 sysdev_shutdown();
807} 808}
808 809
809/** 810/**
@@ -860,6 +861,7 @@ void kernel_shutdown_prepare(enum system_states state)
860void kernel_halt(void) 861void kernel_halt(void)
861{ 862{
862 kernel_shutdown_prepare(SYSTEM_HALT); 863 kernel_shutdown_prepare(SYSTEM_HALT);
864 sysdev_shutdown();
863 printk(KERN_EMERG "System halted.\n"); 865 printk(KERN_EMERG "System halted.\n");
864 machine_halt(); 866 machine_halt();
865} 867}
@@ -876,6 +878,7 @@ void kernel_power_off(void)
876 kernel_shutdown_prepare(SYSTEM_POWER_OFF); 878 kernel_shutdown_prepare(SYSTEM_POWER_OFF);
877 if (pm_power_off_prepare) 879 if (pm_power_off_prepare)
878 pm_power_off_prepare(); 880 pm_power_off_prepare();
881 sysdev_shutdown();
879 printk(KERN_EMERG "Power down.\n"); 882 printk(KERN_EMERG "Power down.\n");
880 machine_power_off(); 883 machine_power_off();
881} 884}
@@ -951,7 +954,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
951 unlock_kernel(); 954 unlock_kernel();
952 return -EINVAL; 955 return -EINVAL;
953 956
954#ifdef CONFIG_SOFTWARE_SUSPEND 957#ifdef CONFIG_HIBERNATION
955 case LINUX_REBOOT_CMD_SW_SUSPEND: 958 case LINUX_REBOOT_CMD_SW_SUSPEND:
956 { 959 {
957 int ret = hibernate(); 960 int ret = hibernate();
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ddebf3f2affe..79c891e6266c 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -689,7 +689,7 @@ static ctl_table kern_table[] = {
689 .proc_handler = &proc_dointvec, 689 .proc_handler = &proc_dointvec,
690 }, 690 },
691#endif 691#endif
692#ifdef CONFIG_ACPI_SLEEP 692#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
693 { 693 {
694 .ctl_name = KERN_ACPI_VIDEO_FLAGS, 694 .ctl_name = KERN_ACPI_VIDEO_FLAGS,
695 .procname = "acpi_video_flags", 695 .procname = "acpi_video_flags",
diff --git a/kernel/time.c b/kernel/time.c
index 5b81da08bbdb..2289a8d68314 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -215,22 +215,6 @@ asmlinkage long sys_adjtimex(struct timex __user *txc_p)
215 return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret; 215 return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
216} 216}
217 217
218inline struct timespec current_kernel_time(void)
219{
220 struct timespec now;
221 unsigned long seq;
222
223 do {
224 seq = read_seqbegin(&xtime_lock);
225
226 now = xtime;
227 } while (read_seqretry(&xtime_lock, seq));
228
229 return now;
230}
231
232EXPORT_SYMBOL(current_kernel_time);
233
234/** 218/**
235 * current_fs_time - Return FS time 219 * current_fs_time - Return FS time
236 * @sb: Superblock. 220 * @sb: Superblock.
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 88c81026e003..acc417b5a9b7 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -47,10 +47,22 @@ EXPORT_SYMBOL(xtime_lock);
47struct timespec xtime __attribute__ ((aligned (16))); 47struct timespec xtime __attribute__ ((aligned (16)));
48struct timespec wall_to_monotonic __attribute__ ((aligned (16))); 48struct timespec wall_to_monotonic __attribute__ ((aligned (16)));
49static unsigned long total_sleep_time; /* seconds */ 49static unsigned long total_sleep_time; /* seconds */
50
51EXPORT_SYMBOL(xtime); 50EXPORT_SYMBOL(xtime);
52 51
53 52
53#ifdef CONFIG_NO_HZ
54static struct timespec xtime_cache __attribute__ ((aligned (16)));
55static inline void update_xtime_cache(u64 nsec)
56{
57 xtime_cache = xtime;
58 timespec_add_ns(&xtime_cache, nsec);
59}
60#else
61#define xtime_cache xtime
62/* We do *not* want to evaluate the argument for this case */
63#define update_xtime_cache(n) do { } while (0)
64#endif
65
54static struct clocksource *clock; /* pointer to current clocksource */ 66static struct clocksource *clock; /* pointer to current clocksource */
55 67
56 68
@@ -478,6 +490,8 @@ void update_wall_time(void)
478 xtime.tv_nsec = (s64)clock->xtime_nsec >> clock->shift; 490 xtime.tv_nsec = (s64)clock->xtime_nsec >> clock->shift;
479 clock->xtime_nsec -= (s64)xtime.tv_nsec << clock->shift; 491 clock->xtime_nsec -= (s64)xtime.tv_nsec << clock->shift;
480 492
493 update_xtime_cache(cyc2ns(clock, offset));
494
481 /* check to see if there is a new clocksource to use */ 495 /* check to see if there is a new clocksource to use */
482 change_clocksource(); 496 change_clocksource();
483 update_vsyscall(&xtime, clock); 497 update_vsyscall(&xtime, clock);
@@ -509,3 +523,25 @@ void monotonic_to_bootbased(struct timespec *ts)
509{ 523{
510 ts->tv_sec += total_sleep_time; 524 ts->tv_sec += total_sleep_time;
511} 525}
526
527unsigned long get_seconds(void)
528{
529 return xtime_cache.tv_sec;
530}
531EXPORT_SYMBOL(get_seconds);
532
533
534struct timespec current_kernel_time(void)
535{
536 struct timespec now;
537 unsigned long seq;
538
539 do {
540 seq = read_seqbegin(&xtime_lock);
541
542 now = xtime_cache;
543 } while (read_seqretry(&xtime_lock, seq));
544
545 return now;
546}
547EXPORT_SYMBOL(current_kernel_time);
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index e5edc3a22a08..fdb2e03d4fe0 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -267,7 +267,7 @@ static struct file_operations timer_list_fops = {
267 .open = timer_list_open, 267 .open = timer_list_open,
268 .read = seq_read, 268 .read = seq_read,
269 .llseek = seq_lseek, 269 .llseek = seq_lseek,
270 .release = seq_release, 270 .release = single_release,
271}; 271};
272 272
273static int __init init_timer_list_procfs(void) 273static int __init init_timer_list_procfs(void)
diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
index 8ed62fda16c6..3c38fb5eae1b 100644
--- a/kernel/time/timer_stats.c
+++ b/kernel/time/timer_stats.c
@@ -399,7 +399,7 @@ static struct file_operations tstats_fops = {
399 .read = seq_read, 399 .read = seq_read,
400 .write = tstats_write, 400 .write = tstats_write,
401 .llseek = seq_lseek, 401 .llseek = seq_lseek,
402 .release = seq_release, 402 .release = single_release,
403}; 403};
404 404
405void __init init_timer_stats(void) 405void __init init_timer_stats(void)
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 658f638c402c..c122131a122f 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -39,7 +39,7 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
39 ac_etime = timespec_to_ns(&ts); 39 ac_etime = timespec_to_ns(&ts);
40 do_div(ac_etime, NSEC_PER_USEC); 40 do_div(ac_etime, NSEC_PER_USEC);
41 stats->ac_etime = ac_etime; 41 stats->ac_etime = ac_etime;
42 stats->ac_btime = xtime.tv_sec - ts.tv_sec; 42 stats->ac_btime = get_seconds() - ts.tv_sec;
43 if (thread_group_leader(tsk)) { 43 if (thread_group_leader(tsk)) {
44 stats->ac_exitcode = tsk->exit_code; 44 stats->ac_exitcode = tsk->exit_code;
45 if (tsk->flags & PF_FORKNOEXEC) 45 if (tsk->flags & PF_FORKNOEXEC)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index f3e0c2abcbd0..50a94eee4d92 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -349,7 +349,7 @@ config DEBUG_HIGHMEM
349config DEBUG_BUGVERBOSE 349config DEBUG_BUGVERBOSE
350 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED 350 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED
351 depends on BUG 351 depends on BUG
352 depends on ARM || ARM26 || AVR32 || M32R || M68K || SPARC32 || SPARC64 || FRV || SUPERH || GENERIC_BUG || BFIN 352 depends on ARM || AVR32 || M32R || M68K || SPARC32 || SPARC64 || FRV || SUPERH || GENERIC_BUG || BFIN
353 default !EMBEDDED 353 default !EMBEDDED
354 help 354 help
355 Say Y here to make BUG() panics output the file name and line number 355 Say Y here to make BUG() panics output the file name and line number
diff --git a/lib/Makefile b/lib/Makefile
index 614966387402..d9e5f1cd0bfb 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -2,7 +2,7 @@
2# Makefile for some libs needed in the kernel. 2# Makefile for some libs needed in the kernel.
3# 3#
4 4
5lib-y := ctype.o string.o vsprintf.o cmdline.o \ 5lib-y := ctype.o string.o vsprintf.o kasprintf.o cmdline.o \
6 rbtree.o radix-tree.o dump_stack.o \ 6 rbtree.o radix-tree.o dump_stack.o \
7 idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \ 7 idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \
8 sha1.o irq_regs.o reciprocal_div.o argv_split.o 8 sha1.o irq_regs.o reciprocal_div.o argv_split.o
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index b18fc2ff9ffe..23985a278bbb 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -139,12 +139,14 @@ static void debugfs_ul_set(void *data, u64 val)
139 *(unsigned long *)data = val; 139 *(unsigned long *)data = val;
140} 140}
141 141
142#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER
142static void debugfs_ul_set_MAX_STACK_TRACE_DEPTH(void *data, u64 val) 143static void debugfs_ul_set_MAX_STACK_TRACE_DEPTH(void *data, u64 val)
143{ 144{
144 *(unsigned long *)data = 145 *(unsigned long *)data =
145 val < MAX_STACK_TRACE_DEPTH ? 146 val < MAX_STACK_TRACE_DEPTH ?
146 val : MAX_STACK_TRACE_DEPTH; 147 val : MAX_STACK_TRACE_DEPTH;
147} 148}
149#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */
148 150
149static u64 debugfs_ul_get(void *data) 151static u64 debugfs_ul_get(void *data)
150{ 152{
@@ -159,6 +161,7 @@ static struct dentry *debugfs_create_ul(const char *name, mode_t mode,
159 return debugfs_create_file(name, mode, parent, value, &fops_ul); 161 return debugfs_create_file(name, mode, parent, value, &fops_ul);
160} 162}
161 163
164#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER
162DEFINE_SIMPLE_ATTRIBUTE(fops_ul_MAX_STACK_TRACE_DEPTH, debugfs_ul_get, 165DEFINE_SIMPLE_ATTRIBUTE(fops_ul_MAX_STACK_TRACE_DEPTH, debugfs_ul_get,
163 debugfs_ul_set_MAX_STACK_TRACE_DEPTH, "%llu\n"); 166 debugfs_ul_set_MAX_STACK_TRACE_DEPTH, "%llu\n");
164 167
@@ -169,6 +172,7 @@ static struct dentry *debugfs_create_ul_MAX_STACK_TRACE_DEPTH(
169 return debugfs_create_file(name, mode, parent, value, 172 return debugfs_create_file(name, mode, parent, value,
170 &fops_ul_MAX_STACK_TRACE_DEPTH); 173 &fops_ul_MAX_STACK_TRACE_DEPTH);
171} 174}
175#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */
172 176
173static void debugfs_atomic_t_set(void *data, u64 val) 177static void debugfs_atomic_t_set(void *data, u64 val)
174{ 178{
diff --git a/lib/idr.c b/lib/idr.c
index ffd61941e75d..d0f1acdbfa3a 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -405,7 +405,7 @@ EXPORT_SYMBOL(idr_remove);
405 */ 405 */
406void idr_remove_all(struct idr *idp) 406void idr_remove_all(struct idr *idp)
407{ 407{
408 int n, id, max, error = 0; 408 int n, id, max;
409 struct idr_layer *p; 409 struct idr_layer *p;
410 struct idr_layer *pa[MAX_LEVEL]; 410 struct idr_layer *pa[MAX_LEVEL];
411 struct idr_layer **paa = &pa[0]; 411 struct idr_layer **paa = &pa[0];
@@ -415,7 +415,7 @@ void idr_remove_all(struct idr *idp)
415 max = 1 << n; 415 max = 1 << n;
416 416
417 id = 0; 417 id = 0;
418 while (id < max && !error) { 418 while (id < max) {
419 while (n > IDR_BITS && p) { 419 while (n > IDR_BITS && p) {
420 n -= IDR_BITS; 420 n -= IDR_BITS;
421 *paa++ = p; 421 *paa++ = p;
diff --git a/lib/kasprintf.c b/lib/kasprintf.c
new file mode 100644
index 000000000000..c5ff1fd10030
--- /dev/null
+++ b/lib/kasprintf.c
@@ -0,0 +1,44 @@
1/*
2 * linux/lib/kasprintf.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7#include <stdarg.h>
8#include <linux/module.h>
9#include <linux/types.h>
10#include <linux/string.h>
11
12/* Simplified asprintf. */
13char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
14{
15 unsigned int len;
16 char *p;
17 va_list aq;
18
19 va_copy(aq, ap);
20 len = vsnprintf(NULL, 0, fmt, aq);
21 va_end(aq);
22
23 p = kmalloc(len+1, gfp);
24 if (!p)
25 return NULL;
26
27 vsnprintf(p, len+1, fmt, ap);
28
29 return p;
30}
31EXPORT_SYMBOL(kvasprintf);
32
33char *kasprintf(gfp_t gfp, const char *fmt, ...)
34{
35 va_list ap;
36 char *p;
37
38 va_start(ap, fmt);
39 p = kvasprintf(gfp, fmt, ap);
40 va_end(ap);
41
42 return p;
43}
44EXPORT_SYMBOL(kasprintf);
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 6a80c784a8fb..df02814699d7 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -25,14 +25,6 @@
25#define BUFFER_SIZE 2048 /* buffer for the variables */ 25#define BUFFER_SIZE 2048 /* buffer for the variables */
26#define NUM_ENVP 32 /* number of env pointers */ 26#define NUM_ENVP 32 /* number of env pointers */
27 27
28#if defined(CONFIG_HOTPLUG)
29u64 uevent_seqnum;
30char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
31static DEFINE_SPINLOCK(sequence_lock);
32#if defined(CONFIG_NET)
33static struct sock *uevent_sock;
34#endif
35
36/* the strings here must match the enum in include/linux/kobject.h */ 28/* the strings here must match the enum in include/linux/kobject.h */
37const char *kobject_actions[] = { 29const char *kobject_actions[] = {
38 "add", 30 "add",
@@ -43,6 +35,14 @@ const char *kobject_actions[] = {
43 "offline", 35 "offline",
44}; 36};
45 37
38#if defined(CONFIG_HOTPLUG)
39u64 uevent_seqnum;
40char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
41static DEFINE_SPINLOCK(sequence_lock);
42#if defined(CONFIG_NET)
43static struct sock *uevent_sock;
44#endif
45
46/** 46/**
47 * kobject_uevent_env - send an uevent with environmental data 47 * kobject_uevent_env - send an uevent with environmental data
48 * 48 *
diff --git a/lib/lzo/lzo1x_compress.c b/lib/lzo/lzo1x_compress.c
index c935f00073e9..a6040990a62e 100644
--- a/lib/lzo/lzo1x_compress.c
+++ b/lib/lzo/lzo1x_compress.c
@@ -32,13 +32,13 @@ _lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
32 ip += 4; 32 ip += 4;
33 33
34 for (;;) { 34 for (;;) {
35 dindex = ((0x21 * DX3(ip, 5, 5, 6)) >> 5) & D_MASK; 35 dindex = ((size_t)(0x21 * DX3(ip, 5, 5, 6)) >> 5) & D_MASK;
36 m_pos = dict[dindex]; 36 m_pos = dict[dindex];
37 37
38 if (m_pos < in) 38 if (m_pos < in)
39 goto literal; 39 goto literal;
40 40
41 if (ip == m_pos || (ip - m_pos) > M4_MAX_OFFSET) 41 if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
42 goto literal; 42 goto literal;
43 43
44 m_off = ip - m_pos; 44 m_off = ip - m_pos;
@@ -51,7 +51,7 @@ _lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
51 if (m_pos < in) 51 if (m_pos < in)
52 goto literal; 52 goto literal;
53 53
54 if (ip == m_pos || (ip - m_pos) > M4_MAX_OFFSET) 54 if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
55 goto literal; 55 goto literal;
56 56
57 m_off = ip - m_pos; 57 m_off = ip - m_pos;
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 6b6734df6d2d..7b481cea54ae 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -978,38 +978,3 @@ int sscanf(const char * buf, const char * fmt, ...)
978} 978}
979 979
980EXPORT_SYMBOL(sscanf); 980EXPORT_SYMBOL(sscanf);
981
982
983/* Simplified asprintf. */
984char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
985{
986 unsigned int len;
987 char *p;
988 va_list aq;
989
990 va_copy(aq, ap);
991 len = vsnprintf(NULL, 0, fmt, aq);
992 va_end(aq);
993
994 p = kmalloc(len+1, gfp);
995 if (!p)
996 return NULL;
997
998 vsnprintf(p, len+1, fmt, ap);
999
1000 return p;
1001}
1002EXPORT_SYMBOL(kvasprintf);
1003
1004char *kasprintf(gfp_t gfp, const char *fmt, ...)
1005{
1006 va_list ap;
1007 char *p;
1008
1009 va_start(ap, fmt);
1010 p = kvasprintf(gfp, fmt, ap);
1011 va_end(ap);
1012
1013 return p;
1014}
1015EXPORT_SYMBOL(kasprintf);
diff --git a/mm/Kconfig b/mm/Kconfig
index 86187221e78f..e24d348083c3 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -116,11 +116,11 @@ config SPARSEMEM_EXTREME
116config MEMORY_HOTPLUG 116config MEMORY_HOTPLUG
117 bool "Allow for memory hot-add" 117 bool "Allow for memory hot-add"
118 depends on SPARSEMEM || X86_64_ACPI_NUMA 118 depends on SPARSEMEM || X86_64_ACPI_NUMA
119 depends on HOTPLUG && !SOFTWARE_SUSPEND && ARCH_ENABLE_MEMORY_HOTPLUG 119 depends on HOTPLUG && !HIBERNATION && ARCH_ENABLE_MEMORY_HOTPLUG
120 depends on (IA64 || X86 || PPC64 || SUPERH) 120 depends on (IA64 || X86 || PPC64 || SUPERH)
121 121
122comment "Memory hotplug is currently incompatible with Software Suspend" 122comment "Memory hotplug is currently incompatible with Software Suspend"
123 depends on SPARSEMEM && HOTPLUG && SOFTWARE_SUSPEND 123 depends on SPARSEMEM && HOTPLUG && HIBERNATION
124 124
125config MEMORY_HOTPLUG_SPARSE 125config MEMORY_HOTPLUG_SPARSE
126 def_bool y 126 def_bool y
diff --git a/mm/bounce.c b/mm/bounce.c
index ad401fc57440..179fe38a2416 100644
--- a/mm/bounce.c
+++ b/mm/bounce.c
@@ -190,7 +190,7 @@ static int bounce_end_io_read_isa(struct bio *bio, unsigned int bytes_done, int
190 return 0; 190 return 0;
191} 191}
192 192
193static void __blk_queue_bounce(request_queue_t *q, struct bio **bio_orig, 193static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
194 mempool_t *pool) 194 mempool_t *pool)
195{ 195{
196 struct page *page; 196 struct page *page;
@@ -275,7 +275,7 @@ static void __blk_queue_bounce(request_queue_t *q, struct bio **bio_orig,
275 *bio_orig = bio; 275 *bio_orig = bio;
276} 276}
277 277
278void blk_queue_bounce(request_queue_t *q, struct bio **bio_orig) 278void blk_queue_bounce(struct request_queue *q, struct bio **bio_orig)
279{ 279{
280 mempool_t *pool; 280 mempool_t *pool;
281 281
diff --git a/mm/filemap.c b/mm/filemap.c
index 49a6fe375d01..6cf700d41844 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -843,7 +843,7 @@ static void shrink_readahead_size_eio(struct file *filp,
843/** 843/**
844 * do_generic_mapping_read - generic file read routine 844 * do_generic_mapping_read - generic file read routine
845 * @mapping: address_space to be read 845 * @mapping: address_space to be read
846 * @_ra: file's readahead state 846 * @ra: file's readahead state
847 * @filp: the file to read 847 * @filp: the file to read
848 * @ppos: current file position 848 * @ppos: current file position
849 * @desc: read_descriptor 849 * @desc: read_descriptor
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index f127940ec24f..d7ca59d66c59 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -84,6 +84,7 @@ static struct page *dequeue_huge_page(struct vm_area_struct *vma,
84 list_del(&page->lru); 84 list_del(&page->lru);
85 free_huge_pages--; 85 free_huge_pages--;
86 free_huge_pages_node[nid]--; 86 free_huge_pages_node[nid]--;
87 break;
87 } 88 }
88 } 89 }
89 return page; 90 return page;
diff --git a/mm/migrate.c b/mm/migrate.c
index 34d8ada053e4..37c73b902008 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -49,9 +49,8 @@ int isolate_lru_page(struct page *page, struct list_head *pagelist)
49 struct zone *zone = page_zone(page); 49 struct zone *zone = page_zone(page);
50 50
51 spin_lock_irq(&zone->lru_lock); 51 spin_lock_irq(&zone->lru_lock);
52 if (PageLRU(page)) { 52 if (PageLRU(page) && get_page_unless_zero(page)) {
53 ret = 0; 53 ret = 0;
54 get_page(page);
55 ClearPageLRU(page); 54 ClearPageLRU(page);
56 if (PageActive(page)) 55 if (PageActive(page))
57 del_page_from_active_list(zone, page); 56 del_page_from_active_list(zone, page);
@@ -632,18 +631,35 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
632 goto unlock; 631 goto unlock;
633 wait_on_page_writeback(page); 632 wait_on_page_writeback(page);
634 } 633 }
635
636 /* 634 /*
637 * Establish migration ptes or remove ptes 635 * By try_to_unmap(), page->mapcount goes down to 0 here. In this case,
636 * we cannot notice that anon_vma is freed while we migrates a page.
637 * This rcu_read_lock() delays freeing anon_vma pointer until the end
638 * of migration. File cache pages are no problem because of page_lock()
639 */
640 rcu_read_lock();
641 /*
642 * This is a corner case handling.
643 * When a new swap-cache is read into, it is linked to LRU
644 * and treated as swapcache but has no rmap yet.
645 * Calling try_to_unmap() against a page->mapping==NULL page is
646 * BUG. So handle it here.
638 */ 647 */
648 if (!page->mapping)
649 goto rcu_unlock;
650 /* Establish migration ptes or remove ptes */
639 try_to_unmap(page, 1); 651 try_to_unmap(page, 1);
652
640 if (!page_mapped(page)) 653 if (!page_mapped(page))
641 rc = move_to_new_page(newpage, page); 654 rc = move_to_new_page(newpage, page);
642 655
643 if (rc) 656 if (rc)
644 remove_migration_ptes(page, page); 657 remove_migration_ptes(page, page);
658rcu_unlock:
659 rcu_read_unlock();
645 660
646unlock: 661unlock:
662
647 unlock_page(page); 663 unlock_page(page);
648 664
649 if (rc != -EAGAIN) { 665 if (rc != -EAGAIN) {
diff --git a/mm/mmap.c b/mm/mmap.c
index 7afc7a7cec6f..b6537211b9cc 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1029,6 +1029,40 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
1029} 1029}
1030EXPORT_SYMBOL(do_mmap_pgoff); 1030EXPORT_SYMBOL(do_mmap_pgoff);
1031 1031
1032/*
1033 * Some shared mappigns will want the pages marked read-only
1034 * to track write events. If so, we'll downgrade vm_page_prot
1035 * to the private version (using protection_map[] without the
1036 * VM_SHARED bit).
1037 */
1038int vma_wants_writenotify(struct vm_area_struct *vma)
1039{
1040 unsigned int vm_flags = vma->vm_flags;
1041
1042 /* If it was private or non-writable, the write bit is already clear */
1043 if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
1044 return 0;
1045
1046 /* The backer wishes to know when pages are first written to? */
1047 if (vma->vm_ops && vma->vm_ops->page_mkwrite)
1048 return 1;
1049
1050 /* The open routine did something to the protections already? */
1051 if (pgprot_val(vma->vm_page_prot) !=
1052 pgprot_val(protection_map[vm_flags &
1053 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]))
1054 return 0;
1055
1056 /* Specialty mapping? */
1057 if (vm_flags & (VM_PFNMAP|VM_INSERTPAGE))
1058 return 0;
1059
1060 /* Can the mapping track the dirty pages? */
1061 return vma->vm_file && vma->vm_file->f_mapping &&
1062 mapping_cap_account_dirty(vma->vm_file->f_mapping);
1063}
1064
1065
1032unsigned long mmap_region(struct file *file, unsigned long addr, 1066unsigned long mmap_region(struct file *file, unsigned long addr,
1033 unsigned long len, unsigned long flags, 1067 unsigned long len, unsigned long flags,
1034 unsigned int vm_flags, unsigned long pgoff, 1068 unsigned int vm_flags, unsigned long pgoff,
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index a7001410ab15..f9b82ad5047f 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/oom.h> 18#include <linux/oom.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/err.h>
20#include <linux/sched.h> 21#include <linux/sched.h>
21#include <linux/swap.h> 22#include <linux/swap.h>
22#include <linux/timex.h> 23#include <linux/timex.h>
@@ -156,7 +157,7 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
156 } 157 }
157 158
158#ifdef DEBUG 159#ifdef DEBUG
159 printk(KERN_DEBUG "OOMkill: task %d (%s) got %d points\n", 160 printk(KERN_DEBUG "OOMkill: task %d (%s) got %lu points\n",
160 p->pid, p->comm, points); 161 p->pid, p->comm, points);
161#endif 162#endif
162 return points; 163 return points;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 40954fb81598..3da85b81dabb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -726,7 +726,7 @@ static void __drain_pages(unsigned int cpu)
726 } 726 }
727} 727}
728 728
729#ifdef CONFIG_PM 729#ifdef CONFIG_HIBERNATION
730 730
731void mark_free_pages(struct zone *zone) 731void mark_free_pages(struct zone *zone)
732{ 732{
@@ -772,7 +772,7 @@ void drain_local_pages(void)
772 __drain_pages(smp_processor_id()); 772 __drain_pages(smp_processor_id());
773 local_irq_restore(flags); 773 local_irq_restore(flags);
774} 774}
775#endif /* CONFIG_PM */ 775#endif /* CONFIG_HIBERNATION */
776 776
777/* 777/*
778 * Free a 0-order page 778 * Free a 0-order page
@@ -1350,6 +1350,10 @@ nofail_alloc:
1350 if (page) 1350 if (page)
1351 goto got_pg; 1351 goto got_pg;
1352 1352
1353 /* The OOM killer will not help higher order allocs so fail */
1354 if (order > PAGE_ALLOC_COSTLY_ORDER)
1355 goto nopage;
1356
1353 out_of_memory(zonelist, gfp_mask, order); 1357 out_of_memory(zonelist, gfp_mask, order);
1354 goto restart; 1358 goto restart;
1355 } 1359 }
@@ -2775,11 +2779,11 @@ unsigned long __meminit __absent_pages_in_range(int nid,
2775 if (i == -1) 2779 if (i == -1)
2776 return 0; 2780 return 0;
2777 2781
2782 prev_end_pfn = min(early_node_map[i].start_pfn, range_end_pfn);
2783
2778 /* Account for ranges before physical memory on this node */ 2784 /* Account for ranges before physical memory on this node */
2779 if (early_node_map[i].start_pfn > range_start_pfn) 2785 if (early_node_map[i].start_pfn > range_start_pfn)
2780 hole_pages = early_node_map[i].start_pfn - range_start_pfn; 2786 hole_pages = prev_end_pfn - range_start_pfn;
2781
2782 prev_end_pfn = early_node_map[i].start_pfn;
2783 2787
2784 /* Find all holes for the zone within the node */ 2788 /* Find all holes for the zone within the node */
2785 for (; i != -1; i = next_active_region_index_in_nid(i, nid)) { 2789 for (; i != -1; i = next_active_region_index_in_nid(i, nid)) {
diff --git a/mm/slab.c b/mm/slab.c
index bde271c001ba..a684778b2b41 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2776,7 +2776,7 @@ static int cache_grow(struct kmem_cache *cachep,
2776 * 'nodeid'. 2776 * 'nodeid'.
2777 */ 2777 */
2778 if (!objp) 2778 if (!objp)
2779 objp = kmem_getpages(cachep, flags, nodeid); 2779 objp = kmem_getpages(cachep, local_flags, nodeid);
2780 if (!objp) 2780 if (!objp)
2781 goto failed; 2781 goto failed;
2782 2782
diff --git a/mm/slub.c b/mm/slub.c
index 9b2d6178d06c..6c6d74ff0694 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1131,6 +1131,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page)
1131 slab_pad_check(s, page); 1131 slab_pad_check(s, page);
1132 for_each_object(p, s, page_address(page)) 1132 for_each_object(p, s, page_address(page))
1133 check_object(s, page, p, 0); 1133 check_object(s, page, p, 0);
1134 ClearSlabDebug(page);
1134 } 1135 }
1135 1136
1136 mod_zone_page_state(page_zone(page), 1137 mod_zone_page_state(page_zone(page),
@@ -1169,7 +1170,6 @@ static void discard_slab(struct kmem_cache *s, struct page *page)
1169 1170
1170 atomic_long_dec(&n->nr_slabs); 1171 atomic_long_dec(&n->nr_slabs);
1171 reset_page_mapcount(page); 1172 reset_page_mapcount(page);
1172 ClearSlabDebug(page);
1173 __ClearPageSlab(page); 1173 __ClearPageSlab(page);
1174 free_slab(s, page); 1174 free_slab(s, page);
1175} 1175}
@@ -1656,6 +1656,7 @@ static void __always_inline slab_free(struct kmem_cache *s,
1656 unsigned long flags; 1656 unsigned long flags;
1657 1657
1658 local_irq_save(flags); 1658 local_irq_save(flags);
1659 debug_check_no_locks_freed(object, s->objsize);
1659 if (likely(page == s->cpu_slab[smp_processor_id()] && 1660 if (likely(page == s->cpu_slab[smp_processor_id()] &&
1660 !SlabDebug(page))) { 1661 !SlabDebug(page))) {
1661 object[page->offset] = page->lockless_freelist; 1662 object[page->offset] = page->lockless_freelist;
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 7ff0a81c7b01..f071648e1360 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -425,7 +425,7 @@ void free_swap_and_cache(swp_entry_t entry)
425 } 425 }
426} 426}
427 427
428#ifdef CONFIG_SOFTWARE_SUSPEND 428#ifdef CONFIG_HIBERNATION
429/* 429/*
430 * Find the swap type that corresponds to given device (if any). 430 * Find the swap type that corresponds to given device (if any).
431 * 431 *
@@ -951,7 +951,7 @@ sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset)
951 } 951 }
952} 952}
953 953
954#ifdef CONFIG_SOFTWARE_SUSPEND 954#ifdef CONFIG_HIBERNATION
955/* 955/*
956 * Get the (PAGE_SIZE) block corresponding to given offset on the swapdev 956 * Get the (PAGE_SIZE) block corresponding to given offset on the swapdev
957 * corresponding to given index in swap_info (swap type). 957 * corresponding to given index in swap_info (swap type).
@@ -966,7 +966,7 @@ sector_t swapdev_block(int swap_type, pgoff_t offset)
966 sis = swap_info + swap_type; 966 sis = swap_info + swap_type;
967 return (sis->flags & SWP_WRITEOK) ? map_swap_page(sis, offset) : 0; 967 return (sis->flags & SWP_WRITEOK) ? map_swap_page(sis, offset) : 0;
968} 968}
969#endif /* CONFIG_SOFTWARE_SUSPEND */ 969#endif /* CONFIG_HIBERNATION */
970 970
971/* 971/*
972 * Free all of a swapdev's extent information 972 * Free all of a swapdev's extent information
diff --git a/mm/vmstat.c b/mm/vmstat.c
index fadf791cd7e6..c64d169537bf 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/err.h>
13#include <linux/module.h> 14#include <linux/module.h>
14#include <linux/cpu.h> 15#include <linux/cpu.h>
15#include <linux/sched.h> 16#include <linux/sched.h>
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index cda936b77d22..1583c5ef963f 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -810,6 +810,7 @@ static int vlan_ioctl_handler(void __user *arg)
810 err = -EINVAL; 810 err = -EINVAL;
811 break; 811 break;
812 case GET_VLAN_REALDEV_NAME_CMD: 812 case GET_VLAN_REALDEV_NAME_CMD:
813 err = 0;
813 vlan_dev_get_realdev_name(dev, args.u.device2); 814 vlan_dev_get_realdev_name(dev, args.u.device2);
814 if (copy_to_user(arg, &args, 815 if (copy_to_user(arg, &args,
815 sizeof(struct vlan_ioctl_args))) { 816 sizeof(struct vlan_ioctl_args))) {
@@ -818,6 +819,7 @@ static int vlan_ioctl_handler(void __user *arg)
818 break; 819 break;
819 820
820 case GET_VLAN_VID_CMD: 821 case GET_VLAN_VID_CMD:
822 err = 0;
821 vlan_dev_get_vid(dev, &vid); 823 vlan_dev_get_vid(dev, &vid);
822 args.u.VID = vid; 824 args.u.VID = vid;
823 if (copy_to_user(arg, &args, 825 if (copy_to_user(arg, &args,
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 4d2aa4dd42ac..4bab322c9f8f 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -668,9 +668,6 @@ int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
668 if (real_dev->do_ioctl && netif_device_present(real_dev)) 668 if (real_dev->do_ioctl && netif_device_present(real_dev))
669 err = real_dev->do_ioctl(real_dev, &ifrr, cmd); 669 err = real_dev->do_ioctl(real_dev, &ifrr, cmd);
670 break; 670 break;
671
672 case SIOCETHTOOL:
673 err = dev_ethtool(&ifrr);
674 } 671 }
675 672
676 if (!err) 673 if (!err)
diff --git a/net/9p/conv.c b/net/9p/conv.c
index 37451178e761..f2a041cb508a 100644
--- a/net/9p/conv.c
+++ b/net/9p/conv.c
@@ -763,6 +763,7 @@ struct p9_fcall *p9_create_twrite(u32 fid, u64 offset, u32 count,
763 if (err) { 763 if (err) {
764 kfree(fc); 764 kfree(fc);
765 fc = ERR_PTR(err); 765 fc = ERR_PTR(err);
766 goto error;
766 } 767 }
767 768
768 if (buf_check_overflow(bufp)) { 769 if (buf_check_overflow(bufp)) {
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 670ff95ca64b..c4e4ce4ebb2b 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -353,7 +353,7 @@ static inline int l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16
353} 353}
354 354
355/* ---- Socket interface ---- */ 355/* ---- Socket interface ---- */
356static struct sock *__l2cap_get_sock_by_addr(u16 psm, bdaddr_t *src) 356static struct sock *__l2cap_get_sock_by_addr(__le16 psm, bdaddr_t *src)
357{ 357{
358 struct sock *sk; 358 struct sock *sk;
359 struct hlist_node *node; 359 struct hlist_node *node;
@@ -368,7 +368,7 @@ found:
368/* Find socket with psm and source bdaddr. 368/* Find socket with psm and source bdaddr.
369 * Returns closest match. 369 * Returns closest match.
370 */ 370 */
371static struct sock *__l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src) 371static struct sock *__l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src)
372{ 372{
373 struct sock *sk = NULL, *sk1 = NULL; 373 struct sock *sk = NULL, *sk1 = NULL;
374 struct hlist_node *node; 374 struct hlist_node *node;
@@ -392,7 +392,7 @@ static struct sock *__l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src)
392 392
393/* Find socket with given address (psm, src). 393/* Find socket with given address (psm, src).
394 * Returns locked socket */ 394 * Returns locked socket */
395static inline struct sock *l2cap_get_sock_by_psm(int state, u16 psm, bdaddr_t *src) 395static inline struct sock *l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t *src)
396{ 396{
397 struct sock *s; 397 struct sock *s;
398 read_lock(&l2cap_sk_list.lock); 398 read_lock(&l2cap_sk_list.lock);
@@ -586,7 +586,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_
586 goto done; 586 goto done;
587 } 587 }
588 588
589 if (la->l2_psm > 0 && btohs(la->l2_psm) < 0x1001 && 589 if (la->l2_psm && btohs(la->l2_psm) < 0x1001 &&
590 !capable(CAP_NET_BIND_SERVICE)) { 590 !capable(CAP_NET_BIND_SERVICE)) {
591 err = -EACCES; 591 err = -EACCES;
592 goto done; 592 goto done;
@@ -748,7 +748,7 @@ static int l2cap_sock_listen(struct socket *sock, int backlog)
748 write_lock_bh(&l2cap_sk_list.lock); 748 write_lock_bh(&l2cap_sk_list.lock);
749 749
750 for (psm = 0x1001; psm < 0x1100; psm += 2) 750 for (psm = 0x1001; psm < 0x1100; psm += 2)
751 if (!__l2cap_get_sock_by_addr(psm, src)) { 751 if (!__l2cap_get_sock_by_addr(htobs(psm), src)) {
752 l2cap_pi(sk)->psm = htobs(psm); 752 l2cap_pi(sk)->psm = htobs(psm);
753 l2cap_pi(sk)->sport = htobs(psm); 753 l2cap_pi(sk)->sport = htobs(psm);
754 err = 0; 754 err = 0;
@@ -873,7 +873,7 @@ static inline int l2cap_do_send(struct sock *sk, struct msghdr *msg, int len)
873 lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE)); 873 lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE));
874 874
875 if (sk->sk_type == SOCK_DGRAM) 875 if (sk->sk_type == SOCK_DGRAM)
876 put_unaligned(l2cap_pi(sk)->psm, (u16 *) skb_put(skb, 2)); 876 put_unaligned(l2cap_pi(sk)->psm, (__le16 *) skb_put(skb, 2));
877 877
878 if (memcpy_fromiovec(skb_put(skb, count), msg->msg_iov, count)) { 878 if (memcpy_fromiovec(skb_put(skb, count), msg->msg_iov, count)) {
879 err = -EFAULT; 879 err = -EFAULT;
@@ -1256,11 +1256,11 @@ static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned
1256 break; 1256 break;
1257 1257
1258 case 2: 1258 case 2:
1259 *val = __le16_to_cpu(*((u16 *)opt->val)); 1259 *val = __le16_to_cpu(*((__le16 *)opt->val));
1260 break; 1260 break;
1261 1261
1262 case 4: 1262 case 4:
1263 *val = __le32_to_cpu(*((u32 *)opt->val)); 1263 *val = __le32_to_cpu(*((__le32 *)opt->val));
1264 break; 1264 break;
1265 1265
1266 default: 1266 default:
@@ -1287,11 +1287,11 @@ static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val)
1287 break; 1287 break;
1288 1288
1289 case 2: 1289 case 2:
1290 *((u16 *) opt->val) = cpu_to_le16(val); 1290 *((__le16 *) opt->val) = cpu_to_le16(val);
1291 break; 1291 break;
1292 1292
1293 case 4: 1293 case 4:
1294 *((u32 *) opt->val) = cpu_to_le32(val); 1294 *((__le32 *) opt->val) = cpu_to_le32(val);
1295 break; 1295 break;
1296 1296
1297 default: 1297 default:
@@ -1406,7 +1406,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
1406 int result = 0, status = 0; 1406 int result = 0, status = 0;
1407 1407
1408 u16 dcid = 0, scid = __le16_to_cpu(req->scid); 1408 u16 dcid = 0, scid = __le16_to_cpu(req->scid);
1409 u16 psm = req->psm; 1409 __le16 psm = req->psm;
1410 1410
1411 BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid); 1411 BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid);
1412 1412
@@ -1530,7 +1530,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
1530 return 0; 1530 return 0;
1531} 1531}
1532 1532
1533static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data) 1533static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data)
1534{ 1534{
1535 struct l2cap_conf_req *req = (struct l2cap_conf_req *) data; 1535 struct l2cap_conf_req *req = (struct l2cap_conf_req *) data;
1536 u16 dcid, flags; 1536 u16 dcid, flags;
@@ -1550,7 +1550,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
1550 goto unlock; 1550 goto unlock;
1551 1551
1552 /* Reject if config buffer is too small. */ 1552 /* Reject if config buffer is too small. */
1553 len = cmd->len - sizeof(*req); 1553 len = cmd_len - sizeof(*req);
1554 if (l2cap_pi(sk)->conf_len + len > sizeof(l2cap_pi(sk)->conf_req)) { 1554 if (l2cap_pi(sk)->conf_len + len > sizeof(l2cap_pi(sk)->conf_req)) {
1555 l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, 1555 l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
1556 l2cap_build_conf_rsp(sk, rsp, 1556 l2cap_build_conf_rsp(sk, rsp,
@@ -1748,15 +1748,16 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *sk
1748 l2cap_raw_recv(conn, skb); 1748 l2cap_raw_recv(conn, skb);
1749 1749
1750 while (len >= L2CAP_CMD_HDR_SIZE) { 1750 while (len >= L2CAP_CMD_HDR_SIZE) {
1751 u16 cmd_len;
1751 memcpy(&cmd, data, L2CAP_CMD_HDR_SIZE); 1752 memcpy(&cmd, data, L2CAP_CMD_HDR_SIZE);
1752 data += L2CAP_CMD_HDR_SIZE; 1753 data += L2CAP_CMD_HDR_SIZE;
1753 len -= L2CAP_CMD_HDR_SIZE; 1754 len -= L2CAP_CMD_HDR_SIZE;
1754 1755
1755 cmd.len = __le16_to_cpu(cmd.len); 1756 cmd_len = le16_to_cpu(cmd.len);
1756 1757
1757 BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd.len, cmd.ident); 1758 BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len, cmd.ident);
1758 1759
1759 if (cmd.len > len || !cmd.ident) { 1760 if (cmd_len > len || !cmd.ident) {
1760 BT_DBG("corrupted command"); 1761 BT_DBG("corrupted command");
1761 break; 1762 break;
1762 } 1763 }
@@ -1775,7 +1776,7 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *sk
1775 break; 1776 break;
1776 1777
1777 case L2CAP_CONF_REQ: 1778 case L2CAP_CONF_REQ:
1778 err = l2cap_config_req(conn, &cmd, data); 1779 err = l2cap_config_req(conn, &cmd, cmd_len, data);
1779 break; 1780 break;
1780 1781
1781 case L2CAP_CONF_RSP: 1782 case L2CAP_CONF_RSP:
@@ -1791,7 +1792,7 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *sk
1791 break; 1792 break;
1792 1793
1793 case L2CAP_ECHO_REQ: 1794 case L2CAP_ECHO_REQ:
1794 l2cap_send_cmd(conn, cmd.ident, L2CAP_ECHO_RSP, cmd.len, data); 1795 l2cap_send_cmd(conn, cmd.ident, L2CAP_ECHO_RSP, cmd_len, data);
1795 break; 1796 break;
1796 1797
1797 case L2CAP_ECHO_RSP: 1798 case L2CAP_ECHO_RSP:
@@ -1820,8 +1821,8 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *sk
1820 l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej); 1821 l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej);
1821 } 1822 }
1822 1823
1823 data += cmd.len; 1824 data += cmd_len;
1824 len -= cmd.len; 1825 len -= cmd_len;
1825 } 1826 }
1826 1827
1827 kfree_skb(skb); 1828 kfree_skb(skb);
@@ -1863,7 +1864,7 @@ done:
1863 return 0; 1864 return 0;
1864} 1865}
1865 1866
1866static inline int l2cap_conless_channel(struct l2cap_conn *conn, u16 psm, struct sk_buff *skb) 1867static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, struct sk_buff *skb)
1867{ 1868{
1868 struct sock *sk; 1869 struct sock *sk;
1869 1870
@@ -1893,7 +1894,8 @@ done:
1893static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb) 1894static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
1894{ 1895{
1895 struct l2cap_hdr *lh = (void *) skb->data; 1896 struct l2cap_hdr *lh = (void *) skb->data;
1896 u16 cid, psm, len; 1897 u16 cid, len;
1898 __le16 psm;
1897 1899
1898 skb_pull(skb, L2CAP_HDR_SIZE); 1900 skb_pull(skb, L2CAP_HDR_SIZE);
1899 cid = __le16_to_cpu(lh->cid); 1901 cid = __le16_to_cpu(lh->cid);
@@ -1907,7 +1909,7 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
1907 break; 1909 break;
1908 1910
1909 case 0x0002: 1911 case 0x0002:
1910 psm = get_unaligned((u16 *) skb->data); 1912 psm = get_unaligned((__le16 *) skb->data);
1911 skb_pull(skb, 2); 1913 skb_pull(skb, 2);
1912 l2cap_conless_channel(conn, psm, skb); 1914 l2cap_conless_channel(conn, psm, skb);
1913 break; 1915 break;
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index 23ba61a13bdd..22a832098d44 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -267,7 +267,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
267out: 267out:
268 write_unlock_bh(&rfcomm_dev_lock); 268 write_unlock_bh(&rfcomm_dev_lock);
269 269
270 if (err) { 270 if (err < 0) {
271 kfree(dev); 271 kfree(dev);
272 return err; 272 return err;
273 } 273 }
@@ -275,9 +275,10 @@ out:
275 dev->tty_dev = tty_register_device(rfcomm_tty_driver, dev->id, NULL); 275 dev->tty_dev = tty_register_device(rfcomm_tty_driver, dev->id, NULL);
276 276
277 if (IS_ERR(dev->tty_dev)) { 277 if (IS_ERR(dev->tty_dev)) {
278 err = PTR_ERR(dev->tty_dev);
278 list_del(&dev->list); 279 list_del(&dev->list);
279 kfree(dev); 280 kfree(dev);
280 return PTR_ERR(dev->tty_dev); 281 return err;
281 } 282 }
282 283
283 return dev->id; 284 return dev->id;
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 7b4ce9113be2..b40dada002bf 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -29,35 +29,24 @@
29 * Determine initial path cost based on speed. 29 * Determine initial path cost based on speed.
30 * using recommendations from 802.1d standard 30 * using recommendations from 802.1d standard
31 * 31 *
32 * Need to simulate user ioctl because not all device's that support 32 * Since driver might sleep need to not be holding any locks.
33 * ethtool, use ethtool_ops. Also, since driver might sleep need to
34 * not be holding any locks.
35 */ 33 */
36static int port_cost(struct net_device *dev) 34static int port_cost(struct net_device *dev)
37{ 35{
38 struct ethtool_cmd ecmd = { ETHTOOL_GSET }; 36 if (dev->ethtool_ops->get_settings) {
39 struct ifreq ifr; 37 struct ethtool_cmd ecmd = { ETHTOOL_GSET };
40 mm_segment_t old_fs; 38 int err = dev->ethtool_ops->get_settings(dev, &ecmd);
41 int err; 39 if (!err) {
42 40 switch(ecmd.speed) {
43 strncpy(ifr.ifr_name, dev->name, IFNAMSIZ); 41 case SPEED_100:
44 ifr.ifr_data = (void __user *) &ecmd; 42 return 19;
45 43 case SPEED_1000:
46 old_fs = get_fs(); 44 return 4;
47 set_fs(KERNEL_DS); 45 case SPEED_10000:
48 err = dev_ethtool(&ifr); 46 return 2;
49 set_fs(old_fs); 47 case SPEED_10:
50 48 return 100;
51 if (!err) { 49 }
52 switch(ecmd.speed) {
53 case SPEED_100:
54 return 19;
55 case SPEED_1000:
56 return 4;
57 case SPEED_10000:
58 return 2;
59 case SPEED_10:
60 return 100;
61 } 50 }
62 } 51 }
63 52
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 420bbb9955e9..5c18595b7616 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -112,9 +112,9 @@ static int br_handle_local_finish(struct sk_buff *skb)
112 */ 112 */
113static inline int is_link_local(const unsigned char *dest) 113static inline int is_link_local(const unsigned char *dest)
114{ 114{
115 const u16 *a = (const u16 *) dest; 115 __be16 *a = (__be16 *)dest;
116 static const u16 *const b = (const u16 *const ) br_group_address; 116 static const __be16 *b = (const __be16 *)br_group_address;
117 static const u16 m = __constant_cpu_to_be16(0xfff0); 117 static const __be16 m = __constant_cpu_to_be16(0xfff0);
118 118
119 return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | ((a[2] ^ b[2]) & m)) == 0; 119 return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | ((a[2] ^ b[2]) & m)) == 0;
120} 120}
diff --git a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c
index 031bfa4a51fc..457815fb5584 100644
--- a/net/bridge/netfilter/ebt_log.c
+++ b/net/bridge/netfilter/ebt_log.c
@@ -9,7 +9,6 @@
9 * 9 *
10 */ 10 */
11 11
12#include <linux/in.h>
13#include <linux/netfilter_bridge/ebtables.h> 12#include <linux/netfilter_bridge/ebtables.h>
14#include <linux/netfilter_bridge/ebt_log.h> 13#include <linux/netfilter_bridge/ebt_log.h>
15#include <linux/netfilter.h> 14#include <linux/netfilter.h>
@@ -196,10 +195,8 @@ static int __init ebt_log_init(void)
196 ret = ebt_register_watcher(&log); 195 ret = ebt_register_watcher(&log);
197 if (ret < 0) 196 if (ret < 0)
198 return ret; 197 return ret;
199 ret = nf_log_register(PF_BRIDGE, &ebt_log_logger); 198 nf_log_register(PF_BRIDGE, &ebt_log_logger);
200 if (ret < 0 && ret != -EEXIST) 199 return 0;
201 ebt_unregister_watcher(&log);
202 return ret;
203} 200}
204 201
205static void __exit ebt_log_fini(void) 202static void __exit ebt_log_fini(void)
diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
index 9411db625917..204c968fa86d 100644
--- a/net/bridge/netfilter/ebt_ulog.c
+++ b/net/bridge/netfilter/ebt_ulog.c
@@ -36,7 +36,6 @@
36#include <linux/timer.h> 36#include <linux/timer.h>
37#include <linux/netlink.h> 37#include <linux/netlink.h>
38#include <linux/netdevice.h> 38#include <linux/netdevice.h>
39#include <linux/module.h>
40#include <linux/netfilter_bridge/ebtables.h> 39#include <linux/netfilter_bridge/ebtables.h>
41#include <linux/netfilter_bridge/ebt_ulog.h> 40#include <linux/netfilter_bridge/ebt_ulog.h>
42#include <net/sock.h> 41#include <net/sock.h>
@@ -308,12 +307,8 @@ static int __init ebt_ulog_init(void)
308 else if ((ret = ebt_register_watcher(&ulog))) 307 else if ((ret = ebt_register_watcher(&ulog)))
309 sock_release(ebtulognl->sk_socket); 308 sock_release(ebtulognl->sk_socket);
310 309
311 if (nf_log_register(PF_BRIDGE, &ebt_ulog_logger) < 0) { 310 if (ret == 0)
312 printk(KERN_WARNING "ebt_ulog: not logging via ulog " 311 nf_log_register(PF_BRIDGE, &ebt_ulog_logger);
313 "since somebody else already registered for PF_BRIDGE\n");
314 /* we cannot make module load fail here, since otherwise
315 * ebtables userspace would abort */
316 }
317 312
318 return ret; 313 return ret;
319} 314}
diff --git a/net/core/dev.c b/net/core/dev.c
index ee4035571c21..6cc8a70350ac 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -817,7 +817,9 @@ int dev_alloc_name(struct net_device *dev, const char *name)
817 */ 817 */
818int dev_change_name(struct net_device *dev, char *newname) 818int dev_change_name(struct net_device *dev, char *newname)
819{ 819{
820 char oldname[IFNAMSIZ];
820 int err = 0; 821 int err = 0;
822 int ret;
821 823
822 ASSERT_RTNL(); 824 ASSERT_RTNL();
823 825
@@ -827,6 +829,8 @@ int dev_change_name(struct net_device *dev, char *newname)
827 if (!dev_valid_name(newname)) 829 if (!dev_valid_name(newname))
828 return -EINVAL; 830 return -EINVAL;
829 831
832 memcpy(oldname, dev->name, IFNAMSIZ);
833
830 if (strchr(newname, '%')) { 834 if (strchr(newname, '%')) {
831 err = dev_alloc_name(dev, newname); 835 err = dev_alloc_name(dev, newname);
832 if (err < 0) 836 if (err < 0)
@@ -838,10 +842,28 @@ int dev_change_name(struct net_device *dev, char *newname)
838 else 842 else
839 strlcpy(dev->name, newname, IFNAMSIZ); 843 strlcpy(dev->name, newname, IFNAMSIZ);
840 844
845rollback:
841 device_rename(&dev->dev, dev->name); 846 device_rename(&dev->dev, dev->name);
847
848 write_lock_bh(&dev_base_lock);
842 hlist_del(&dev->name_hlist); 849 hlist_del(&dev->name_hlist);
843 hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name)); 850 hlist_add_head(&dev->name_hlist, dev_name_hash(dev->name));
844 raw_notifier_call_chain(&netdev_chain, NETDEV_CHANGENAME, dev); 851 write_unlock_bh(&dev_base_lock);
852
853 ret = raw_notifier_call_chain(&netdev_chain, NETDEV_CHANGENAME, dev);
854 ret = notifier_to_errno(ret);
855
856 if (ret) {
857 if (err) {
858 printk(KERN_ERR
859 "%s: name change rollback failed: %d.\n",
860 dev->name, ret);
861 } else {
862 err = ret;
863 memcpy(dev->name, oldname, IFNAMSIZ);
864 goto rollback;
865 }
866 }
845 867
846 return err; 868 return err;
847} 869}
@@ -1054,20 +1076,43 @@ int dev_close(struct net_device *dev)
1054int register_netdevice_notifier(struct notifier_block *nb) 1076int register_netdevice_notifier(struct notifier_block *nb)
1055{ 1077{
1056 struct net_device *dev; 1078 struct net_device *dev;
1079 struct net_device *last;
1057 int err; 1080 int err;
1058 1081
1059 rtnl_lock(); 1082 rtnl_lock();
1060 err = raw_notifier_chain_register(&netdev_chain, nb); 1083 err = raw_notifier_chain_register(&netdev_chain, nb);
1061 if (!err) { 1084 if (err)
1062 for_each_netdev(dev) { 1085 goto unlock;
1063 nb->notifier_call(nb, NETDEV_REGISTER, dev);
1064 1086
1065 if (dev->flags & IFF_UP) 1087 for_each_netdev(dev) {
1066 nb->notifier_call(nb, NETDEV_UP, dev); 1088 err = nb->notifier_call(nb, NETDEV_REGISTER, dev);
1067 } 1089 err = notifier_to_errno(err);
1090 if (err)
1091 goto rollback;
1092
1093 if (!(dev->flags & IFF_UP))
1094 continue;
1095
1096 nb->notifier_call(nb, NETDEV_UP, dev);
1068 } 1097 }
1098
1099unlock:
1069 rtnl_unlock(); 1100 rtnl_unlock();
1070 return err; 1101 return err;
1102
1103rollback:
1104 last = dev;
1105 for_each_netdev(dev) {
1106 if (dev == last)
1107 break;
1108
1109 if (dev->flags & IFF_UP) {
1110 nb->notifier_call(nb, NETDEV_GOING_DOWN, dev);
1111 nb->notifier_call(nb, NETDEV_DOWN, dev);
1112 }
1113 nb->notifier_call(nb, NETDEV_UNREGISTER, dev);
1114 }
1115 goto unlock;
1071} 1116}
1072 1117
1073/** 1118/**
@@ -2718,9 +2763,11 @@ int __dev_addr_add(struct dev_addr_list **list, int *count,
2718/** 2763/**
2719 * dev_unicast_delete - Release secondary unicast address. 2764 * dev_unicast_delete - Release secondary unicast address.
2720 * @dev: device 2765 * @dev: device
2766 * @addr: address to delete
2767 * @alen: length of @addr
2721 * 2768 *
2722 * Release reference to a secondary unicast address and remove it 2769 * Release reference to a secondary unicast address and remove it
2723 * from the device if the reference count drop to zero. 2770 * from the device if the reference count drops to zero.
2724 * 2771 *
2725 * The caller must hold the rtnl_mutex. 2772 * The caller must hold the rtnl_mutex.
2726 */ 2773 */
@@ -2742,6 +2789,8 @@ EXPORT_SYMBOL(dev_unicast_delete);
2742/** 2789/**
2743 * dev_unicast_add - add a secondary unicast address 2790 * dev_unicast_add - add a secondary unicast address
2744 * @dev: device 2791 * @dev: device
2792 * @addr: address to delete
2793 * @alen: length of @addr
2745 * 2794 *
2746 * Add a secondary unicast address to the device or increase 2795 * Add a secondary unicast address to the device or increase
2747 * the reference count if it already exists. 2796 * the reference count if it already exists.
@@ -3333,7 +3382,7 @@ int register_netdevice(struct net_device *dev)
3333 3382
3334 if (!dev_valid_name(dev->name)) { 3383 if (!dev_valid_name(dev->name)) {
3335 ret = -EINVAL; 3384 ret = -EINVAL;
3336 goto out; 3385 goto err_uninit;
3337 } 3386 }
3338 3387
3339 dev->ifindex = dev_new_index(); 3388 dev->ifindex = dev_new_index();
@@ -3347,7 +3396,7 @@ int register_netdevice(struct net_device *dev)
3347 = hlist_entry(p, struct net_device, name_hlist); 3396 = hlist_entry(p, struct net_device, name_hlist);
3348 if (!strncmp(d->name, dev->name, IFNAMSIZ)) { 3397 if (!strncmp(d->name, dev->name, IFNAMSIZ)) {
3349 ret = -EEXIST; 3398 ret = -EEXIST;
3350 goto out; 3399 goto err_uninit;
3351 } 3400 }
3352 } 3401 }
3353 3402
@@ -3407,7 +3456,7 @@ int register_netdevice(struct net_device *dev)
3407 3456
3408 ret = netdev_register_sysfs(dev); 3457 ret = netdev_register_sysfs(dev);
3409 if (ret) 3458 if (ret)
3410 goto out; 3459 goto err_uninit;
3411 dev->reg_state = NETREG_REGISTERED; 3460 dev->reg_state = NETREG_REGISTERED;
3412 3461
3413 /* 3462 /*
@@ -3426,12 +3475,18 @@ int register_netdevice(struct net_device *dev)
3426 write_unlock_bh(&dev_base_lock); 3475 write_unlock_bh(&dev_base_lock);
3427 3476
3428 /* Notify protocols, that a new device appeared. */ 3477 /* Notify protocols, that a new device appeared. */
3429 raw_notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev); 3478 ret = raw_notifier_call_chain(&netdev_chain, NETDEV_REGISTER, dev);
3430 3479 ret = notifier_to_errno(ret);
3431 ret = 0; 3480 if (ret)
3481 unregister_netdevice(dev);
3432 3482
3433out: 3483out:
3434 return ret; 3484 return ret;
3485
3486err_uninit:
3487 if (dev->uninit)
3488 dev->uninit(dev);
3489 goto out;
3435} 3490}
3436 3491
3437/** 3492/**
@@ -3830,9 +3885,11 @@ static int dev_cpu_callback(struct notifier_block *nfb,
3830 3885
3831#ifdef CONFIG_NET_DMA 3886#ifdef CONFIG_NET_DMA
3832/** 3887/**
3833 * net_dma_rebalance - 3888 * net_dma_rebalance - try to maintain one DMA channel per CPU
3834 * This is called when the number of channels allocated to the net_dma_client 3889 * @net_dma: DMA client and associated data (lock, channels, channel_mask)
3835 * changes. The net_dma_client tries to have one DMA channel per CPU. 3890 *
3891 * This is called when the number of channels allocated to the net_dma client
3892 * changes. The net_dma client tries to have one DMA channel per CPU.
3836 */ 3893 */
3837 3894
3838static void net_dma_rebalance(struct net_dma *net_dma) 3895static void net_dma_rebalance(struct net_dma *net_dma)
@@ -3869,7 +3926,7 @@ static void net_dma_rebalance(struct net_dma *net_dma)
3869 * netdev_dma_event - event callback for the net_dma_client 3926 * netdev_dma_event - event callback for the net_dma_client
3870 * @client: should always be net_dma_client 3927 * @client: should always be net_dma_client
3871 * @chan: DMA channel for the event 3928 * @chan: DMA channel for the event
3872 * @event: event type 3929 * @state: DMA state to be handled
3873 */ 3930 */
3874static enum dma_state_client 3931static enum dma_state_client
3875netdev_dma_event(struct dma_client *client, struct dma_chan *chan, 3932netdev_dma_event(struct dma_client *client, struct dma_chan *chan,
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 0b531e98ec33..2ab0a60046a5 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -3,10 +3,12 @@
3 * Copyright (c) 2003 Matthew Wilcox <matthew@wil.cx> 3 * Copyright (c) 2003 Matthew Wilcox <matthew@wil.cx>
4 * 4 *
5 * This file is where we call all the ethtool_ops commands to get 5 * This file is where we call all the ethtool_ops commands to get
6 * the information ethtool needs. We fall back to calling do_ioctl() 6 * the information ethtool needs.
7 * for drivers which haven't been converted to ethtool_ops yet.
8 * 7 *
9 * It's GPL, stupid. 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
10 */ 12 */
11 13
12#include <linux/module.h> 14#include <linux/module.h>
@@ -93,18 +95,6 @@ int ethtool_op_set_tso(struct net_device *dev, u32 data)
93 return 0; 95 return 0;
94} 96}
95 97
96int ethtool_op_get_perm_addr(struct net_device *dev, struct ethtool_perm_addr *addr, u8 *data)
97{
98 unsigned char len = dev->addr_len;
99 if ( addr->size < len )
100 return -ETOOSMALL;
101
102 addr->size = len;
103 memcpy(data, dev->perm_addr, len);
104 return 0;
105}
106
107
108u32 ethtool_op_get_ufo(struct net_device *dev) 98u32 ethtool_op_get_ufo(struct net_device *dev)
109{ 99{
110 return (dev->features & NETIF_F_UFO) != 0; 100 return (dev->features & NETIF_F_UFO) != 0;
@@ -777,34 +767,20 @@ static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
777static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr) 767static int ethtool_get_perm_addr(struct net_device *dev, void __user *useraddr)
778{ 768{
779 struct ethtool_perm_addr epaddr; 769 struct ethtool_perm_addr epaddr;
780 u8 *data;
781 int ret;
782
783 if (!dev->ethtool_ops->get_perm_addr)
784 return -EOPNOTSUPP;
785 770
786 if (copy_from_user(&epaddr,useraddr,sizeof(epaddr))) 771 if (copy_from_user(&epaddr, useraddr, sizeof(epaddr)))
787 return -EFAULT; 772 return -EFAULT;
788 773
789 data = kmalloc(epaddr.size, GFP_USER); 774 if (epaddr.size < dev->addr_len)
790 if (!data) 775 return -ETOOSMALL;
791 return -ENOMEM; 776 epaddr.size = dev->addr_len;
792
793 ret = dev->ethtool_ops->get_perm_addr(dev,&epaddr,data);
794 if (ret)
795 return ret;
796 777
797 ret = -EFAULT;
798 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr))) 778 if (copy_to_user(useraddr, &epaddr, sizeof(epaddr)))
799 goto out; 779 return -EFAULT;
800 useraddr += sizeof(epaddr); 780 useraddr += sizeof(epaddr);
801 if (copy_to_user(useraddr, data, epaddr.size)) 781 if (copy_to_user(useraddr, dev->perm_addr, epaddr.size))
802 goto out; 782 return -EFAULT;
803 ret = 0; 783 return 0;
804
805 out:
806 kfree(data);
807 return ret;
808} 784}
809 785
810/* The main entry point in this file. Called from net/core/dev.c */ 786/* The main entry point in this file. Called from net/core/dev.c */
@@ -821,7 +797,7 @@ int dev_ethtool(struct ifreq *ifr)
821 return -ENODEV; 797 return -ENODEV;
822 798
823 if (!dev->ethtool_ops) 799 if (!dev->ethtool_ops)
824 goto ioctl; 800 return -EOPNOTSUPP;
825 801
826 if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd))) 802 if (copy_from_user(&ethcmd, useraddr, sizeof (ethcmd)))
827 return -EFAULT; 803 return -EFAULT;
@@ -960,7 +936,7 @@ int dev_ethtool(struct ifreq *ifr)
960 rc = ethtool_set_gso(dev, useraddr); 936 rc = ethtool_set_gso(dev, useraddr);
961 break; 937 break;
962 default: 938 default:
963 rc = -EOPNOTSUPP; 939 rc = -EOPNOTSUPP;
964 } 940 }
965 941
966 if (dev->ethtool_ops->complete) 942 if (dev->ethtool_ops->complete)
@@ -970,20 +946,10 @@ int dev_ethtool(struct ifreq *ifr)
970 netdev_features_change(dev); 946 netdev_features_change(dev);
971 947
972 return rc; 948 return rc;
973
974 ioctl:
975 /* Keep existing behaviour for the moment. */
976 if (!capable(CAP_NET_ADMIN))
977 return -EPERM;
978
979 if (dev->do_ioctl)
980 return dev->do_ioctl(dev, ifr, SIOCETHTOOL);
981 return -EOPNOTSUPP;
982} 949}
983 950
984EXPORT_SYMBOL(dev_ethtool); 951EXPORT_SYMBOL(dev_ethtool);
985EXPORT_SYMBOL(ethtool_op_get_link); 952EXPORT_SYMBOL(ethtool_op_get_link);
986EXPORT_SYMBOL_GPL(ethtool_op_get_perm_addr);
987EXPORT_SYMBOL(ethtool_op_get_sg); 953EXPORT_SYMBOL(ethtool_op_get_sg);
988EXPORT_SYMBOL(ethtool_op_get_tso); 954EXPORT_SYMBOL(ethtool_op_get_tso);
989EXPORT_SYMBOL(ethtool_op_get_tx_csum); 955EXPORT_SYMBOL(ethtool_op_get_tx_csum);
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index bca787fdbc51..7bae576ac115 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -567,7 +567,7 @@ static ssize_t pgctrl_write(struct file *file, const char __user * buf,
567 pktgen_run_all_threads(); 567 pktgen_run_all_threads();
568 568
569 else 569 else
570 printk("pktgen: Unknown command: %s\n", data); 570 printk(KERN_WARNING "pktgen: Unknown command: %s\n", data);
571 571
572 err = count; 572 err = count;
573 573
@@ -908,14 +908,14 @@ static ssize_t pktgen_if_write(struct file *file,
908 pg_result = &(pkt_dev->result[0]); 908 pg_result = &(pkt_dev->result[0]);
909 909
910 if (count < 1) { 910 if (count < 1) {
911 printk("pktgen: wrong command format\n"); 911 printk(KERN_WARNING "pktgen: wrong command format\n");
912 return -EINVAL; 912 return -EINVAL;
913 } 913 }
914 914
915 max = count - i; 915 max = count - i;
916 tmp = count_trail_chars(&user_buffer[i], max); 916 tmp = count_trail_chars(&user_buffer[i], max);
917 if (tmp < 0) { 917 if (tmp < 0) {
918 printk("pktgen: illegal format\n"); 918 printk(KERN_WARNING "pktgen: illegal format\n");
919 return tmp; 919 return tmp;
920 } 920 }
921 i += tmp; 921 i += tmp;
@@ -943,7 +943,7 @@ static ssize_t pktgen_if_write(struct file *file,
943 if (copy_from_user(tb, user_buffer, count)) 943 if (copy_from_user(tb, user_buffer, count))
944 return -EFAULT; 944 return -EFAULT;
945 tb[count] = 0; 945 tb[count] = 0;
946 printk("pktgen: %s,%lu buffer -:%s:-\n", name, 946 printk(KERN_DEBUG "pktgen: %s,%lu buffer -:%s:-\n", name,
947 (unsigned long)count, tb); 947 (unsigned long)count, tb);
948 } 948 }
949 949
@@ -1248,7 +1248,7 @@ static ssize_t pktgen_if_write(struct file *file,
1248 pkt_dev->cur_daddr = pkt_dev->daddr_min; 1248 pkt_dev->cur_daddr = pkt_dev->daddr_min;
1249 } 1249 }
1250 if (debug) 1250 if (debug)
1251 printk("pktgen: dst_min set to: %s\n", 1251 printk(KERN_DEBUG "pktgen: dst_min set to: %s\n",
1252 pkt_dev->dst_min); 1252 pkt_dev->dst_min);
1253 i += len; 1253 i += len;
1254 sprintf(pg_result, "OK: dst_min=%s", pkt_dev->dst_min); 1254 sprintf(pg_result, "OK: dst_min=%s", pkt_dev->dst_min);
@@ -1271,7 +1271,7 @@ static ssize_t pktgen_if_write(struct file *file,
1271 pkt_dev->cur_daddr = pkt_dev->daddr_max; 1271 pkt_dev->cur_daddr = pkt_dev->daddr_max;
1272 } 1272 }
1273 if (debug) 1273 if (debug)
1274 printk("pktgen: dst_max set to: %s\n", 1274 printk(KERN_DEBUG "pktgen: dst_max set to: %s\n",
1275 pkt_dev->dst_max); 1275 pkt_dev->dst_max);
1276 i += len; 1276 i += len;
1277 sprintf(pg_result, "OK: dst_max=%s", pkt_dev->dst_max); 1277 sprintf(pg_result, "OK: dst_max=%s", pkt_dev->dst_max);
@@ -1294,7 +1294,7 @@ static ssize_t pktgen_if_write(struct file *file,
1294 ipv6_addr_copy(&pkt_dev->cur_in6_daddr, &pkt_dev->in6_daddr); 1294 ipv6_addr_copy(&pkt_dev->cur_in6_daddr, &pkt_dev->in6_daddr);
1295 1295
1296 if (debug) 1296 if (debug)
1297 printk("pktgen: dst6 set to: %s\n", buf); 1297 printk(KERN_DEBUG "pktgen: dst6 set to: %s\n", buf);
1298 1298
1299 i += len; 1299 i += len;
1300 sprintf(pg_result, "OK: dst6=%s", buf); 1300 sprintf(pg_result, "OK: dst6=%s", buf);
@@ -1317,7 +1317,7 @@ static ssize_t pktgen_if_write(struct file *file,
1317 ipv6_addr_copy(&pkt_dev->cur_in6_daddr, 1317 ipv6_addr_copy(&pkt_dev->cur_in6_daddr,
1318 &pkt_dev->min_in6_daddr); 1318 &pkt_dev->min_in6_daddr);
1319 if (debug) 1319 if (debug)
1320 printk("pktgen: dst6_min set to: %s\n", buf); 1320 printk(KERN_DEBUG "pktgen: dst6_min set to: %s\n", buf);
1321 1321
1322 i += len; 1322 i += len;
1323 sprintf(pg_result, "OK: dst6_min=%s", buf); 1323 sprintf(pg_result, "OK: dst6_min=%s", buf);
@@ -1338,7 +1338,7 @@ static ssize_t pktgen_if_write(struct file *file,
1338 fmt_ip6(buf, pkt_dev->max_in6_daddr.s6_addr); 1338 fmt_ip6(buf, pkt_dev->max_in6_daddr.s6_addr);
1339 1339
1340 if (debug) 1340 if (debug)
1341 printk("pktgen: dst6_max set to: %s\n", buf); 1341 printk(KERN_DEBUG "pktgen: dst6_max set to: %s\n", buf);
1342 1342
1343 i += len; 1343 i += len;
1344 sprintf(pg_result, "OK: dst6_max=%s", buf); 1344 sprintf(pg_result, "OK: dst6_max=%s", buf);
@@ -1361,7 +1361,7 @@ static ssize_t pktgen_if_write(struct file *file,
1361 ipv6_addr_copy(&pkt_dev->cur_in6_saddr, &pkt_dev->in6_saddr); 1361 ipv6_addr_copy(&pkt_dev->cur_in6_saddr, &pkt_dev->in6_saddr);
1362 1362
1363 if (debug) 1363 if (debug)
1364 printk("pktgen: src6 set to: %s\n", buf); 1364 printk(KERN_DEBUG "pktgen: src6 set to: %s\n", buf);
1365 1365
1366 i += len; 1366 i += len;
1367 sprintf(pg_result, "OK: src6=%s", buf); 1367 sprintf(pg_result, "OK: src6=%s", buf);
@@ -1382,7 +1382,7 @@ static ssize_t pktgen_if_write(struct file *file,
1382 pkt_dev->cur_saddr = pkt_dev->saddr_min; 1382 pkt_dev->cur_saddr = pkt_dev->saddr_min;
1383 } 1383 }
1384 if (debug) 1384 if (debug)
1385 printk("pktgen: src_min set to: %s\n", 1385 printk(KERN_DEBUG "pktgen: src_min set to: %s\n",
1386 pkt_dev->src_min); 1386 pkt_dev->src_min);
1387 i += len; 1387 i += len;
1388 sprintf(pg_result, "OK: src_min=%s", pkt_dev->src_min); 1388 sprintf(pg_result, "OK: src_min=%s", pkt_dev->src_min);
@@ -1403,7 +1403,7 @@ static ssize_t pktgen_if_write(struct file *file,
1403 pkt_dev->cur_saddr = pkt_dev->saddr_max; 1403 pkt_dev->cur_saddr = pkt_dev->saddr_max;
1404 } 1404 }
1405 if (debug) 1405 if (debug)
1406 printk("pktgen: src_max set to: %s\n", 1406 printk(KERN_DEBUG "pktgen: src_max set to: %s\n",
1407 pkt_dev->src_max); 1407 pkt_dev->src_max);
1408 i += len; 1408 i += len;
1409 sprintf(pg_result, "OK: src_max=%s", pkt_dev->src_max); 1409 sprintf(pg_result, "OK: src_max=%s", pkt_dev->src_max);
@@ -1533,7 +1533,7 @@ static ssize_t pktgen_if_write(struct file *file,
1533 pkt_dev->svlan_id = 0xffff; 1533 pkt_dev->svlan_id = 0xffff;
1534 1534
1535 if (debug) 1535 if (debug)
1536 printk("pktgen: VLAN/SVLAN auto turned off\n"); 1536 printk(KERN_DEBUG "pktgen: VLAN/SVLAN auto turned off\n");
1537 } 1537 }
1538 return count; 1538 return count;
1539 } 1539 }
@@ -1548,10 +1548,10 @@ static ssize_t pktgen_if_write(struct file *file,
1548 pkt_dev->vlan_id = value; /* turn on VLAN */ 1548 pkt_dev->vlan_id = value; /* turn on VLAN */
1549 1549
1550 if (debug) 1550 if (debug)
1551 printk("pktgen: VLAN turned on\n"); 1551 printk(KERN_DEBUG "pktgen: VLAN turned on\n");
1552 1552
1553 if (debug && pkt_dev->nr_labels) 1553 if (debug && pkt_dev->nr_labels)
1554 printk("pktgen: MPLS auto turned off\n"); 1554 printk(KERN_DEBUG "pktgen: MPLS auto turned off\n");
1555 1555
1556 pkt_dev->nr_labels = 0; /* turn off MPLS */ 1556 pkt_dev->nr_labels = 0; /* turn off MPLS */
1557 sprintf(pg_result, "OK: vlan_id=%u", pkt_dev->vlan_id); 1557 sprintf(pg_result, "OK: vlan_id=%u", pkt_dev->vlan_id);
@@ -1560,7 +1560,7 @@ static ssize_t pktgen_if_write(struct file *file,
1560 pkt_dev->svlan_id = 0xffff; 1560 pkt_dev->svlan_id = 0xffff;
1561 1561
1562 if (debug) 1562 if (debug)
1563 printk("pktgen: VLAN/SVLAN turned off\n"); 1563 printk(KERN_DEBUG "pktgen: VLAN/SVLAN turned off\n");
1564 } 1564 }
1565 return count; 1565 return count;
1566 } 1566 }
@@ -1605,10 +1605,10 @@ static ssize_t pktgen_if_write(struct file *file,
1605 pkt_dev->svlan_id = value; /* turn on SVLAN */ 1605 pkt_dev->svlan_id = value; /* turn on SVLAN */
1606 1606
1607 if (debug) 1607 if (debug)
1608 printk("pktgen: SVLAN turned on\n"); 1608 printk(KERN_DEBUG "pktgen: SVLAN turned on\n");
1609 1609
1610 if (debug && pkt_dev->nr_labels) 1610 if (debug && pkt_dev->nr_labels)
1611 printk("pktgen: MPLS auto turned off\n"); 1611 printk(KERN_DEBUG "pktgen: MPLS auto turned off\n");
1612 1612
1613 pkt_dev->nr_labels = 0; /* turn off MPLS */ 1613 pkt_dev->nr_labels = 0; /* turn off MPLS */
1614 sprintf(pg_result, "OK: svlan_id=%u", pkt_dev->svlan_id); 1614 sprintf(pg_result, "OK: svlan_id=%u", pkt_dev->svlan_id);
@@ -1617,7 +1617,7 @@ static ssize_t pktgen_if_write(struct file *file,
1617 pkt_dev->svlan_id = 0xffff; 1617 pkt_dev->svlan_id = 0xffff;
1618 1618
1619 if (debug) 1619 if (debug)
1620 printk("pktgen: VLAN/SVLAN turned off\n"); 1620 printk(KERN_DEBUG "pktgen: VLAN/SVLAN turned off\n");
1621 } 1621 }
1622 return count; 1622 return count;
1623 } 1623 }
@@ -1777,10 +1777,11 @@ static ssize_t pktgen_thread_write(struct file *file,
1777 i += len; 1777 i += len;
1778 1778
1779 if (debug) 1779 if (debug)
1780 printk("pktgen: t=%s, count=%lu\n", name, (unsigned long)count); 1780 printk(KERN_DEBUG "pktgen: t=%s, count=%lu\n",
1781 name, (unsigned long)count);
1781 1782
1782 if (!t) { 1783 if (!t) {
1783 printk("pktgen: ERROR: No thread\n"); 1784 printk(KERN_ERR "pktgen: ERROR: No thread\n");
1784 ret = -EINVAL; 1785 ret = -EINVAL;
1785 goto out; 1786 goto out;
1786 } 1787 }
@@ -1891,8 +1892,8 @@ static void pktgen_mark_device(const char *ifname)
1891 mutex_lock(&pktgen_thread_lock); 1892 mutex_lock(&pktgen_thread_lock);
1892 1893
1893 if (++i >= max_tries) { 1894 if (++i >= max_tries) {
1894 printk("pktgen_mark_device: timed out after waiting " 1895 printk(KERN_ERR "pktgen_mark_device: timed out after "
1895 "%d msec for device %s to be removed\n", 1896 "waiting %d msec for device %s to be removed\n",
1896 msec_per_try * i, ifname); 1897 msec_per_try * i, ifname);
1897 break; 1898 break;
1898 } 1899 }
@@ -1962,15 +1963,15 @@ static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname)
1962 1963
1963 odev = dev_get_by_name(ifname); 1964 odev = dev_get_by_name(ifname);
1964 if (!odev) { 1965 if (!odev) {
1965 printk("pktgen: no such netdevice: \"%s\"\n", ifname); 1966 printk(KERN_ERR "pktgen: no such netdevice: \"%s\"\n", ifname);
1966 return -ENODEV; 1967 return -ENODEV;
1967 } 1968 }
1968 1969
1969 if (odev->type != ARPHRD_ETHER) { 1970 if (odev->type != ARPHRD_ETHER) {
1970 printk("pktgen: not an ethernet device: \"%s\"\n", ifname); 1971 printk(KERN_ERR "pktgen: not an ethernet device: \"%s\"\n", ifname);
1971 err = -EINVAL; 1972 err = -EINVAL;
1972 } else if (!netif_running(odev)) { 1973 } else if (!netif_running(odev)) {
1973 printk("pktgen: device is down: \"%s\"\n", ifname); 1974 printk(KERN_ERR "pktgen: device is down: \"%s\"\n", ifname);
1974 err = -ENETDOWN; 1975 err = -ENETDOWN;
1975 } else { 1976 } else {
1976 pkt_dev->odev = odev; 1977 pkt_dev->odev = odev;
@@ -1987,7 +1988,8 @@ static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname)
1987static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) 1988static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
1988{ 1989{
1989 if (!pkt_dev->odev) { 1990 if (!pkt_dev->odev) {
1990 printk("pktgen: ERROR: pkt_dev->odev == NULL in setup_inject.\n"); 1991 printk(KERN_ERR "pktgen: ERROR: pkt_dev->odev == NULL in "
1992 "setup_inject.\n");
1991 sprintf(pkt_dev->result, 1993 sprintf(pkt_dev->result,
1992 "ERROR: pkt_dev->odev == NULL in setup_inject.\n"); 1994 "ERROR: pkt_dev->odev == NULL in setup_inject.\n");
1993 return; 1995 return;
@@ -2049,7 +2051,8 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev)
2049 } 2051 }
2050 rcu_read_unlock(); 2052 rcu_read_unlock();
2051 if (err) 2053 if (err)
2052 printk("pktgen: ERROR: IPv6 link address not availble.\n"); 2054 printk(KERN_ERR "pktgen: ERROR: IPv6 link "
2055 "address not availble.\n");
2053 } 2056 }
2054#endif 2057#endif
2055 } else { 2058 } else {
@@ -2156,8 +2159,7 @@ static inline int f_pick(struct pktgen_dev *pkt_dev)
2156/* If there was already an IPSEC SA, we keep it as is, else 2159/* If there was already an IPSEC SA, we keep it as is, else
2157 * we go look for it ... 2160 * we go look for it ...
2158*/ 2161*/
2159inline 2162static void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow)
2160void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow)
2161{ 2163{
2162 struct xfrm_state *x = pkt_dev->flows[flow].x; 2164 struct xfrm_state *x = pkt_dev->flows[flow].x;
2163 if (!x) { 2165 if (!x) {
@@ -2441,7 +2443,8 @@ static inline int process_ipsec(struct pktgen_dev *pkt_dev,
2441 if (nhead >0) { 2443 if (nhead >0) {
2442 ret = pskb_expand_head(skb, nhead, 0, GFP_ATOMIC); 2444 ret = pskb_expand_head(skb, nhead, 0, GFP_ATOMIC);
2443 if (ret < 0) { 2445 if (ret < 0) {
2444 printk("Error expanding ipsec packet %d\n",ret); 2446 printk(KERN_ERR "Error expanding "
2447 "ipsec packet %d\n",ret);
2445 return 0; 2448 return 0;
2446 } 2449 }
2447 } 2450 }
@@ -2450,7 +2453,8 @@ static inline int process_ipsec(struct pktgen_dev *pkt_dev,
2450 skb_pull(skb, ETH_HLEN); 2453 skb_pull(skb, ETH_HLEN);
2451 ret = pktgen_output_ipsec(skb, pkt_dev); 2454 ret = pktgen_output_ipsec(skb, pkt_dev);
2452 if (ret) { 2455 if (ret) {
2453 printk("Error creating ipsec packet %d\n",ret); 2456 printk(KERN_ERR "Error creating ipsec "
2457 "packet %d\n",ret);
2454 kfree_skb(skb); 2458 kfree_skb(skb);
2455 return 0; 2459 return 0;
2456 } 2460 }
@@ -3184,8 +3188,8 @@ static int pktgen_stop_device(struct pktgen_dev *pkt_dev)
3184 int nr_frags = pkt_dev->skb ? skb_shinfo(pkt_dev->skb)->nr_frags : -1; 3188 int nr_frags = pkt_dev->skb ? skb_shinfo(pkt_dev->skb)->nr_frags : -1;
3185 3189
3186 if (!pkt_dev->running) { 3190 if (!pkt_dev->running) {
3187 printk("pktgen: interface: %s is already stopped\n", 3191 printk(KERN_WARNING "pktgen: interface: %s is already "
3188 pkt_dev->odev->name); 3192 "stopped\n", pkt_dev->odev->name);
3189 return -EINVAL; 3193 return -EINVAL;
3190 } 3194 }
3191 3195
@@ -3360,7 +3364,8 @@ static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev)
3360 3364
3361 pkt_dev->skb = fill_packet(odev, pkt_dev); 3365 pkt_dev->skb = fill_packet(odev, pkt_dev);
3362 if (pkt_dev->skb == NULL) { 3366 if (pkt_dev->skb == NULL) {
3363 printk("pktgen: ERROR: couldn't allocate skb in fill_packet.\n"); 3367 printk(KERN_ERR "pktgen: ERROR: couldn't "
3368 "allocate skb in fill_packet.\n");
3364 schedule(); 3369 schedule();
3365 pkt_dev->clone_count--; /* back out increment, OOM */ 3370 pkt_dev->clone_count--; /* back out increment, OOM */
3366 goto out; 3371 goto out;
@@ -3565,7 +3570,8 @@ static int add_dev_to_thread(struct pktgen_thread *t,
3565 if_lock(t); 3570 if_lock(t);
3566 3571
3567 if (pkt_dev->pg_thread) { 3572 if (pkt_dev->pg_thread) {
3568 printk("pktgen: ERROR: already assigned to a thread.\n"); 3573 printk(KERN_ERR "pktgen: ERROR: already assigned "
3574 "to a thread.\n");
3569 rv = -EBUSY; 3575 rv = -EBUSY;
3570 goto out; 3576 goto out;
3571 } 3577 }
@@ -3590,7 +3596,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
3590 3596
3591 pkt_dev = __pktgen_NN_threads(ifname, FIND); 3597 pkt_dev = __pktgen_NN_threads(ifname, FIND);
3592 if (pkt_dev) { 3598 if (pkt_dev) {
3593 printk("pktgen: ERROR: interface already used.\n"); 3599 printk(KERN_ERR "pktgen: ERROR: interface already used.\n");
3594 return -EBUSY; 3600 return -EBUSY;
3595 } 3601 }
3596 3602
@@ -3632,7 +3638,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
3632 3638
3633 pkt_dev->entry = create_proc_entry(ifname, 0600, pg_proc_dir); 3639 pkt_dev->entry = create_proc_entry(ifname, 0600, pg_proc_dir);
3634 if (!pkt_dev->entry) { 3640 if (!pkt_dev->entry) {
3635 printk("pktgen: cannot create %s/%s procfs entry.\n", 3641 printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n",
3636 PG_PROC_DIR, ifname); 3642 PG_PROC_DIR, ifname);
3637 err = -EINVAL; 3643 err = -EINVAL;
3638 goto out2; 3644 goto out2;
@@ -3665,7 +3671,8 @@ static int __init pktgen_create_thread(int cpu)
3665 3671
3666 t = kzalloc(sizeof(struct pktgen_thread), GFP_KERNEL); 3672 t = kzalloc(sizeof(struct pktgen_thread), GFP_KERNEL);
3667 if (!t) { 3673 if (!t) {
3668 printk("pktgen: ERROR: out of memory, can't create new thread.\n"); 3674 printk(KERN_ERR "pktgen: ERROR: out of memory, can't "
3675 "create new thread.\n");
3669 return -ENOMEM; 3676 return -ENOMEM;
3670 } 3677 }
3671 3678
@@ -3678,7 +3685,8 @@ static int __init pktgen_create_thread(int cpu)
3678 3685
3679 p = kthread_create(pktgen_thread_worker, t, "kpktgend_%d", cpu); 3686 p = kthread_create(pktgen_thread_worker, t, "kpktgend_%d", cpu);
3680 if (IS_ERR(p)) { 3687 if (IS_ERR(p)) {
3681 printk("pktgen: kernel_thread() failed for cpu %d\n", t->cpu); 3688 printk(KERN_ERR "pktgen: kernel_thread() failed "
3689 "for cpu %d\n", t->cpu);
3682 list_del(&t->th_list); 3690 list_del(&t->th_list);
3683 kfree(t); 3691 kfree(t);
3684 return PTR_ERR(p); 3692 return PTR_ERR(p);
@@ -3688,7 +3696,7 @@ static int __init pktgen_create_thread(int cpu)
3688 3696
3689 pe = create_proc_entry(t->tsk->comm, 0600, pg_proc_dir); 3697 pe = create_proc_entry(t->tsk->comm, 0600, pg_proc_dir);
3690 if (!pe) { 3698 if (!pe) {
3691 printk("pktgen: cannot create %s/%s procfs entry.\n", 3699 printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n",
3692 PG_PROC_DIR, t->tsk->comm); 3700 PG_PROC_DIR, t->tsk->comm);
3693 kthread_stop(p); 3701 kthread_stop(p);
3694 list_del(&t->th_list); 3702 list_del(&t->th_list);
@@ -3727,7 +3735,8 @@ static int pktgen_remove_device(struct pktgen_thread *t,
3727 pr_debug("pktgen: remove_device pkt_dev=%p\n", pkt_dev); 3735 pr_debug("pktgen: remove_device pkt_dev=%p\n", pkt_dev);
3728 3736
3729 if (pkt_dev->running) { 3737 if (pkt_dev->running) {
3730 printk("pktgen:WARNING: trying to remove a running interface, stopping it now.\n"); 3738 printk(KERN_WARNING "pktgen: WARNING: trying to remove a "
3739 "running interface, stopping it now.\n");
3731 pktgen_stop_device(pkt_dev); 3740 pktgen_stop_device(pkt_dev);
3732 } 3741 }
3733 3742
@@ -3759,7 +3768,7 @@ static int __init pg_init(void)
3759 int cpu; 3768 int cpu;
3760 struct proc_dir_entry *pe; 3769 struct proc_dir_entry *pe;
3761 3770
3762 printk(version); 3771 printk(KERN_INFO "%s", version);
3763 3772
3764 pg_proc_dir = proc_mkdir(PG_PROC_DIR, proc_net); 3773 pg_proc_dir = proc_mkdir(PG_PROC_DIR, proc_net);
3765 if (!pg_proc_dir) 3774 if (!pg_proc_dir)
@@ -3768,8 +3777,8 @@ static int __init pg_init(void)
3768 3777
3769 pe = create_proc_entry(PGCTRL, 0600, pg_proc_dir); 3778 pe = create_proc_entry(PGCTRL, 0600, pg_proc_dir);
3770 if (pe == NULL) { 3779 if (pe == NULL) {
3771 printk("pktgen: ERROR: cannot create %s procfs entry.\n", 3780 printk(KERN_ERR "pktgen: ERROR: cannot create %s "
3772 PGCTRL); 3781 "procfs entry.\n", PGCTRL);
3773 proc_net_remove(PG_PROC_DIR); 3782 proc_net_remove(PG_PROC_DIR);
3774 return -EINVAL; 3783 return -EINVAL;
3775 } 3784 }
@@ -3785,12 +3794,13 @@ static int __init pg_init(void)
3785 3794
3786 err = pktgen_create_thread(cpu); 3795 err = pktgen_create_thread(cpu);
3787 if (err) 3796 if (err)
3788 printk("pktgen: WARNING: Cannot create thread for cpu %d (%d)\n", 3797 printk(KERN_WARNING "pktgen: WARNING: Cannot create "
3789 cpu, err); 3798 "thread for cpu %d (%d)\n", cpu, err);
3790 } 3799 }
3791 3800
3792 if (list_empty(&pktgen_threads)) { 3801 if (list_empty(&pktgen_threads)) {
3793 printk("pktgen: ERROR: Initialization failed for all threads\n"); 3802 printk(KERN_ERR "pktgen: ERROR: Initialization failed for "
3803 "all threads\n");
3794 unregister_netdevice_notifier(&pktgen_notifier_block); 3804 unregister_netdevice_notifier(&pktgen_notifier_block);
3795 remove_proc_entry(PGCTRL, pg_proc_dir); 3805 remove_proc_entry(PGCTRL, pg_proc_dir);
3796 proc_net_remove(PG_PROC_DIR); 3806 proc_net_remove(PG_PROC_DIR);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 06eccca8cb5d..4756d5857abf 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -952,7 +952,9 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
952 struct nlattr *linkinfo[IFLA_INFO_MAX+1]; 952 struct nlattr *linkinfo[IFLA_INFO_MAX+1];
953 int err; 953 int err;
954 954
955#ifdef CONFIG_KMOD
955replay: 956replay:
957#endif
956 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy); 958 err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFLA_MAX, ifla_policy);
957 if (err < 0) 959 if (err < 0)
958 return err; 960 return err;
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index f2a61ef2af9c..a4a620971ef0 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -1737,8 +1737,9 @@ static int dn_rt_cache_seq_open(struct inode *inode, struct file *file)
1737{ 1737{
1738 struct seq_file *seq; 1738 struct seq_file *seq;
1739 int rc = -ENOMEM; 1739 int rc = -ENOMEM;
1740 struct dn_rt_cache_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL); 1740 struct dn_rt_cache_iter_state *s;
1741 1741
1742 s = kzalloc(sizeof(*s), GFP_KERNEL);
1742 if (!s) 1743 if (!s)
1743 goto out; 1744 goto out;
1744 rc = seq_open(file, &dn_rt_cache_seq_ops); 1745 rc = seq_open(file, &dn_rt_cache_seq_ops);
@@ -1746,7 +1747,6 @@ static int dn_rt_cache_seq_open(struct inode *inode, struct file *file)
1746 goto out_kfree; 1747 goto out_kfree;
1747 seq = file->private_data; 1748 seq = file->private_data;
1748 seq->private = s; 1749 seq->private = s;
1749 memset(s, 0, sizeof(*s));
1750out: 1750out:
1751 return rc; 1751 return rc;
1752out_kfree: 1752out_kfree:
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index abf6352f990f..5b77bdaa57dd 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1056,10 +1056,9 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
1056 if (!in_dev) { 1056 if (!in_dev) {
1057 if (event == NETDEV_REGISTER) { 1057 if (event == NETDEV_REGISTER) {
1058 in_dev = inetdev_init(dev); 1058 in_dev = inetdev_init(dev);
1059 if (!in_dev)
1060 return notifier_from_errno(-ENOMEM);
1059 if (dev == &loopback_dev) { 1061 if (dev == &loopback_dev) {
1060 if (!in_dev)
1061 panic("devinet: "
1062 "Failed to create loopback\n");
1063 IN_DEV_CONF_SET(in_dev, NOXFRM, 1); 1062 IN_DEV_CONF_SET(in_dev, NOXFRM, 1);
1064 IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); 1063 IN_DEV_CONF_SET(in_dev, NOPOLICY, 1);
1065 } 1064 }
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index 251346828cb4..2f14745a9e1f 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -513,11 +513,8 @@ void ip_options_undo(struct ip_options * opt)
513 513
514static struct ip_options *ip_options_get_alloc(const int optlen) 514static struct ip_options *ip_options_get_alloc(const int optlen)
515{ 515{
516 struct ip_options *opt = kmalloc(sizeof(*opt) + ((optlen + 3) & ~3), 516 return kzalloc(sizeof(struct ip_options) + ((optlen + 3) & ~3),
517 GFP_KERNEL); 517 GFP_KERNEL);
518 if (opt)
519 memset(opt, 0, sizeof(*opt));
520 return opt;
521} 518}
522 519
523static int ip_options_get_finish(struct ip_options **optp, 520static int ip_options_get_finish(struct ip_options **optp,
diff --git a/net/ipv4/ipvs/ip_vs_xmit.c b/net/ipv4/ipvs/ip_vs_xmit.c
index 900ce29db382..666e080a74a3 100644
--- a/net/ipv4/ipvs/ip_vs_xmit.c
+++ b/net/ipv4/ipvs/ip_vs_xmit.c
@@ -128,7 +128,7 @@ ip_vs_dst_reset(struct ip_vs_dest *dest)
128#define IP_VS_XMIT(skb, rt) \ 128#define IP_VS_XMIT(skb, rt) \
129do { \ 129do { \
130 (skb)->ipvs_property = 1; \ 130 (skb)->ipvs_property = 1; \
131 (skb)->ip_summed = CHECKSUM_NONE; \ 131 skb_forward_csum(skb); \
132 NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, (skb), NULL, \ 132 NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, (skb), NULL, \
133 (rt)->u.dst.dev, dst_output); \ 133 (rt)->u.dst.dev, dst_output); \
134} while (0) 134} while (0)
diff --git a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
index 5937ad150b9f..127a5e89bf14 100644
--- a/net/ipv4/netfilter/ipt_LOG.c
+++ b/net/ipv4/netfilter/ipt_LOG.c
@@ -479,10 +479,8 @@ static int __init ipt_log_init(void)
479 ret = xt_register_target(&ipt_log_reg); 479 ret = xt_register_target(&ipt_log_reg);
480 if (ret < 0) 480 if (ret < 0)
481 return ret; 481 return ret;
482 ret = nf_log_register(PF_INET, &ipt_log_logger); 482 nf_log_register(PF_INET, &ipt_log_logger);
483 if (ret < 0 && ret != -EEXIST) 483 return 0;
484 xt_unregister_target(&ipt_log_reg);
485 return ret;
486} 484}
487 485
488static void __exit ipt_log_fini(void) 486static void __exit ipt_log_fini(void)
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c
index e848d8d6292f..deab27facbad 100644
--- a/net/ipv4/netfilter/nf_nat_core.c
+++ b/net/ipv4/netfilter/nf_nat_core.c
@@ -77,7 +77,8 @@ static inline unsigned int
77hash_by_src(const struct nf_conntrack_tuple *tuple) 77hash_by_src(const struct nf_conntrack_tuple *tuple)
78{ 78{
79 /* Original src, to ensure we map it consistently if poss. */ 79 /* Original src, to ensure we map it consistently if poss. */
80 return jhash_3words((__force u32)tuple->src.u3.ip, tuple->src.u.all, 80 return jhash_3words((__force u32)tuple->src.u3.ip,
81 (__force u32)tuple->src.u.all,
81 tuple->dst.protonum, 0) % nf_nat_htable_size; 82 tuple->dst.protonum, 0) % nf_nat_htable_size;
82} 83}
83 84
diff --git a/net/ipv4/netfilter/nf_nat_rule.c b/net/ipv4/netfilter/nf_nat_rule.c
index 0f45427e5fdc..76ec59ae524d 100644
--- a/net/ipv4/netfilter/nf_nat_rule.c
+++ b/net/ipv4/netfilter/nf_nat_rule.c
@@ -192,7 +192,7 @@ alloc_null_binding_confirmed(struct nf_conn *ct, unsigned int hooknum)
192 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC 192 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
193 ? ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip 193 ? ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3.ip
194 : ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip); 194 : ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3.ip);
195 u_int16_t all 195 __be16 all
196 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC 196 = (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC
197 ? ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.all 197 ? ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u.all
198 : ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all); 198 : ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u.all);
diff --git a/net/ipv4/tcp_bic.c b/net/ipv4/tcp_bic.c
index 519de091a94d..4586211e3757 100644
--- a/net/ipv4/tcp_bic.c
+++ b/net/ipv4/tcp_bic.c
@@ -206,7 +206,7 @@ static void bictcp_state(struct sock *sk, u8 new_state)
206/* Track delayed acknowledgment ratio using sliding window 206/* Track delayed acknowledgment ratio using sliding window
207 * ratio = (15*ratio + sample) / 16 207 * ratio = (15*ratio + sample) / 16
208 */ 208 */
209static void bictcp_acked(struct sock *sk, u32 cnt, ktime_t last) 209static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt)
210{ 210{
211 const struct inet_connection_sock *icsk = inet_csk(sk); 211 const struct inet_connection_sock *icsk = inet_csk(sk);
212 212
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index d17da30d82d6..485d7ea35f75 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -246,38 +246,12 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd)
246 ca->cnt = 1; 246 ca->cnt = 1;
247} 247}
248 248
249
250/* Keep track of minimum rtt */
251static inline void measure_delay(struct sock *sk)
252{
253 const struct tcp_sock *tp = tcp_sk(sk);
254 struct bictcp *ca = inet_csk_ca(sk);
255 u32 delay;
256
257 /* No time stamp */
258 if (!(tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr) ||
259 /* Discard delay samples right after fast recovery */
260 (s32)(tcp_time_stamp - ca->epoch_start) < HZ)
261 return;
262
263 delay = (tcp_time_stamp - tp->rx_opt.rcv_tsecr)<<3;
264 if (delay == 0)
265 delay = 1;
266
267 /* first time call or link delay decreases */
268 if (ca->delay_min == 0 || ca->delay_min > delay)
269 ca->delay_min = delay;
270}
271
272static void bictcp_cong_avoid(struct sock *sk, u32 ack, 249static void bictcp_cong_avoid(struct sock *sk, u32 ack,
273 u32 in_flight, int data_acked) 250 u32 in_flight, int data_acked)
274{ 251{
275 struct tcp_sock *tp = tcp_sk(sk); 252 struct tcp_sock *tp = tcp_sk(sk);
276 struct bictcp *ca = inet_csk_ca(sk); 253 struct bictcp *ca = inet_csk_ca(sk);
277 254
278 if (data_acked)
279 measure_delay(sk);
280
281 if (!tcp_is_cwnd_limited(sk, in_flight)) 255 if (!tcp_is_cwnd_limited(sk, in_flight))
282 return; 256 return;
283 257
@@ -334,17 +308,33 @@ static void bictcp_state(struct sock *sk, u8 new_state)
334/* Track delayed acknowledgment ratio using sliding window 308/* Track delayed acknowledgment ratio using sliding window
335 * ratio = (15*ratio + sample) / 16 309 * ratio = (15*ratio + sample) / 16
336 */ 310 */
337static void bictcp_acked(struct sock *sk, u32 cnt, ktime_t last) 311static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
338{ 312{
339 const struct inet_connection_sock *icsk = inet_csk(sk); 313 const struct inet_connection_sock *icsk = inet_csk(sk);
314 struct bictcp *ca = inet_csk_ca(sk);
315 u32 delay;
340 316
341 if (cnt > 0 && icsk->icsk_ca_state == TCP_CA_Open) { 317 if (cnt > 0 && icsk->icsk_ca_state == TCP_CA_Open) {
342 struct bictcp *ca = inet_csk_ca(sk);
343 cnt -= ca->delayed_ack >> ACK_RATIO_SHIFT; 318 cnt -= ca->delayed_ack >> ACK_RATIO_SHIFT;
344 ca->delayed_ack += cnt; 319 ca->delayed_ack += cnt;
345 } 320 }
346}
347 321
322 /* Some calls are for duplicates without timetamps */
323 if (rtt_us < 0)
324 return;
325
326 /* Discard delay samples right after fast recovery */
327 if ((s32)(tcp_time_stamp - ca->epoch_start) < HZ)
328 return;
329
330 delay = usecs_to_jiffies(rtt_us) << 3;
331 if (delay == 0)
332 delay = 1;
333
334 /* first time call or link delay decreases */
335 if (ca->delay_min == 0 || ca->delay_min > delay)
336 ca->delay_min = delay;
337}
348 338
349static struct tcp_congestion_ops cubictcp = { 339static struct tcp_congestion_ops cubictcp = {
350 .init = bictcp_init, 340 .init = bictcp_init,
diff --git a/net/ipv4/tcp_htcp.c b/net/ipv4/tcp_htcp.c
index 08a02e6045c9..b66556c0a5bd 100644
--- a/net/ipv4/tcp_htcp.c
+++ b/net/ipv4/tcp_htcp.c
@@ -76,12 +76,11 @@ static u32 htcp_cwnd_undo(struct sock *sk)
76 return max(tp->snd_cwnd, (tp->snd_ssthresh << 7) / ca->beta); 76 return max(tp->snd_cwnd, (tp->snd_ssthresh << 7) / ca->beta);
77} 77}
78 78
79static inline void measure_rtt(struct sock *sk) 79static inline void measure_rtt(struct sock *sk, u32 srtt)
80{ 80{
81 const struct inet_connection_sock *icsk = inet_csk(sk); 81 const struct inet_connection_sock *icsk = inet_csk(sk);
82 const struct tcp_sock *tp = tcp_sk(sk); 82 const struct tcp_sock *tp = tcp_sk(sk);
83 struct htcp *ca = inet_csk_ca(sk); 83 struct htcp *ca = inet_csk_ca(sk);
84 u32 srtt = tp->srtt >> 3;
85 84
86 /* keep track of minimum RTT seen so far, minRTT is zero at first */ 85 /* keep track of minimum RTT seen so far, minRTT is zero at first */
87 if (ca->minRTT > srtt || !ca->minRTT) 86 if (ca->minRTT > srtt || !ca->minRTT)
@@ -98,7 +97,7 @@ static inline void measure_rtt(struct sock *sk)
98 } 97 }
99} 98}
100 99
101static void measure_achieved_throughput(struct sock *sk, u32 pkts_acked, ktime_t last) 100static void measure_achieved_throughput(struct sock *sk, u32 pkts_acked, s32 rtt)
102{ 101{
103 const struct inet_connection_sock *icsk = inet_csk(sk); 102 const struct inet_connection_sock *icsk = inet_csk(sk);
104 const struct tcp_sock *tp = tcp_sk(sk); 103 const struct tcp_sock *tp = tcp_sk(sk);
@@ -108,6 +107,9 @@ static void measure_achieved_throughput(struct sock *sk, u32 pkts_acked, ktime_t
108 if (icsk->icsk_ca_state == TCP_CA_Open) 107 if (icsk->icsk_ca_state == TCP_CA_Open)
109 ca->pkts_acked = pkts_acked; 108 ca->pkts_acked = pkts_acked;
110 109
110 if (rtt > 0)
111 measure_rtt(sk, usecs_to_jiffies(rtt));
112
111 if (!use_bandwidth_switch) 113 if (!use_bandwidth_switch)
112 return; 114 return;
113 115
@@ -237,8 +239,6 @@ static void htcp_cong_avoid(struct sock *sk, u32 ack,
237 if (tp->snd_cwnd <= tp->snd_ssthresh) 239 if (tp->snd_cwnd <= tp->snd_ssthresh)
238 tcp_slow_start(tp); 240 tcp_slow_start(tp);
239 else { 241 else {
240 measure_rtt(sk);
241
242 /* In dangerous area, increase slowly. 242 /* In dangerous area, increase slowly.
243 * In theory this is tp->snd_cwnd += alpha / tp->snd_cwnd 243 * In theory this is tp->snd_cwnd += alpha / tp->snd_cwnd
244 */ 244 */
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index cc5de6f69d46..64f1cbaf96e8 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -83,18 +83,16 @@ static void tcp_illinois_init(struct sock *sk)
83} 83}
84 84
85/* Measure RTT for each ack. */ 85/* Measure RTT for each ack. */
86static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, ktime_t last) 86static void tcp_illinois_acked(struct sock *sk, u32 pkts_acked, s32 rtt)
87{ 87{
88 struct illinois *ca = inet_csk_ca(sk); 88 struct illinois *ca = inet_csk_ca(sk);
89 u32 rtt;
90 89
91 ca->acked = pkts_acked; 90 ca->acked = pkts_acked;
92 91
93 if (ktime_equal(last, net_invalid_timestamp())) 92 /* dup ack, no rtt sample */
93 if (rtt < 0)
94 return; 94 return;
95 95
96 rtt = ktime_to_us(net_timedelta(last));
97
98 /* ignore bogus values, this prevents wraparound in alpha math */ 96 /* ignore bogus values, this prevents wraparound in alpha math */
99 if (rtt > RTT_MAX) 97 if (rtt > RTT_MAX)
100 rtt = RTT_MAX; 98 rtt = RTT_MAX;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index fec8a7a4dbaf..378ca8a086a3 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1851,19 +1851,22 @@ static inline u32 tcp_cwnd_min(const struct sock *sk)
1851} 1851}
1852 1852
1853/* Decrease cwnd each second ack. */ 1853/* Decrease cwnd each second ack. */
1854static void tcp_cwnd_down(struct sock *sk) 1854static void tcp_cwnd_down(struct sock *sk, int flag)
1855{ 1855{
1856 struct tcp_sock *tp = tcp_sk(sk); 1856 struct tcp_sock *tp = tcp_sk(sk);
1857 int decr = tp->snd_cwnd_cnt + 1; 1857 int decr = tp->snd_cwnd_cnt + 1;
1858 1858
1859 tp->snd_cwnd_cnt = decr&1; 1859 if ((flag&FLAG_FORWARD_PROGRESS) ||
1860 decr >>= 1; 1860 (IsReno(tp) && !(flag&FLAG_NOT_DUP))) {
1861 tp->snd_cwnd_cnt = decr&1;
1862 decr >>= 1;
1861 1863
1862 if (decr && tp->snd_cwnd > tcp_cwnd_min(sk)) 1864 if (decr && tp->snd_cwnd > tcp_cwnd_min(sk))
1863 tp->snd_cwnd -= decr; 1865 tp->snd_cwnd -= decr;
1864 1866
1865 tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp)+1); 1867 tp->snd_cwnd = min(tp->snd_cwnd, tcp_packets_in_flight(tp)+1);
1866 tp->snd_cwnd_stamp = tcp_time_stamp; 1868 tp->snd_cwnd_stamp = tcp_time_stamp;
1869 }
1867} 1870}
1868 1871
1869/* Nothing was retransmitted or returned timestamp is less 1872/* Nothing was retransmitted or returned timestamp is less
@@ -2060,7 +2063,7 @@ static void tcp_try_to_open(struct sock *sk, int flag)
2060 } 2063 }
2061 tcp_moderate_cwnd(tp); 2064 tcp_moderate_cwnd(tp);
2062 } else { 2065 } else {
2063 tcp_cwnd_down(sk); 2066 tcp_cwnd_down(sk, flag);
2064 } 2067 }
2065} 2068}
2066 2069
@@ -2109,7 +2112,10 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una,
2109{ 2112{
2110 struct inet_connection_sock *icsk = inet_csk(sk); 2113 struct inet_connection_sock *icsk = inet_csk(sk);
2111 struct tcp_sock *tp = tcp_sk(sk); 2114 struct tcp_sock *tp = tcp_sk(sk);
2112 int is_dupack = (tp->snd_una == prior_snd_una && !(flag&FLAG_NOT_DUP)); 2115 int is_dupack = (tp->snd_una == prior_snd_una &&
2116 (!(flag&FLAG_NOT_DUP) ||
2117 ((flag&FLAG_DATA_SACKED) &&
2118 (tp->fackets_out > tp->reordering))));
2113 2119
2114 /* Some technical things: 2120 /* Some technical things:
2115 * 1. Reno does not count dupacks (sacked_out) automatically. */ 2121 * 1. Reno does not count dupacks (sacked_out) automatically. */
@@ -2260,7 +2266,7 @@ tcp_fastretrans_alert(struct sock *sk, u32 prior_snd_una,
2260 2266
2261 if (is_dupack || tcp_head_timedout(sk)) 2267 if (is_dupack || tcp_head_timedout(sk))
2262 tcp_update_scoreboard(sk); 2268 tcp_update_scoreboard(sk);
2263 tcp_cwnd_down(sk); 2269 tcp_cwnd_down(sk, flag);
2264 tcp_xmit_retransmit_queue(sk); 2270 tcp_xmit_retransmit_queue(sk);
2265} 2271}
2266 2272
@@ -2490,12 +2496,23 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
2490 tcp_ack_update_rtt(sk, acked, seq_rtt); 2496 tcp_ack_update_rtt(sk, acked, seq_rtt);
2491 tcp_ack_packets_out(sk); 2497 tcp_ack_packets_out(sk);
2492 2498
2493 /* Is the ACK triggering packet unambiguous? */ 2499 if (ca_ops->pkts_acked) {
2494 if (acked & FLAG_RETRANS_DATA_ACKED) 2500 s32 rtt_us = -1;
2495 last_ackt = net_invalid_timestamp(); 2501
2502 /* Is the ACK triggering packet unambiguous? */
2503 if (!(acked & FLAG_RETRANS_DATA_ACKED)) {
2504 /* High resolution needed and available? */
2505 if (ca_ops->flags & TCP_CONG_RTT_STAMP &&
2506 !ktime_equal(last_ackt,
2507 net_invalid_timestamp()))
2508 rtt_us = ktime_us_delta(ktime_get_real(),
2509 last_ackt);
2510 else if (seq_rtt > 0)
2511 rtt_us = jiffies_to_usecs(seq_rtt);
2512 }
2496 2513
2497 if (ca_ops->pkts_acked) 2514 ca_ops->pkts_acked(sk, pkts_acked, rtt_us);
2498 ca_ops->pkts_acked(sk, pkts_acked, last_ackt); 2515 }
2499 } 2516 }
2500 2517
2501#if FASTRETRANS_DEBUG > 0 2518#if FASTRETRANS_DEBUG > 0
diff --git a/net/ipv4/tcp_lp.c b/net/ipv4/tcp_lp.c
index 80e140e3ec2d..e7f5ef92cbd8 100644
--- a/net/ipv4/tcp_lp.c
+++ b/net/ipv4/tcp_lp.c
@@ -260,13 +260,13 @@ static void tcp_lp_rtt_sample(struct sock *sk, u32 rtt)
260 * newReno in increase case. 260 * newReno in increase case.
261 * We work it out by following the idea from TCP-LP's paper directly 261 * We work it out by following the idea from TCP-LP's paper directly
262 */ 262 */
263static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, ktime_t last) 263static void tcp_lp_pkts_acked(struct sock *sk, u32 num_acked, s32 rtt_us)
264{ 264{
265 struct tcp_sock *tp = tcp_sk(sk); 265 struct tcp_sock *tp = tcp_sk(sk);
266 struct lp *lp = inet_csk_ca(sk); 266 struct lp *lp = inet_csk_ca(sk);
267 267
268 if (!ktime_equal(last, net_invalid_timestamp())) 268 if (rtt_us > 0)
269 tcp_lp_rtt_sample(sk, ktime_to_us(net_timedelta(last))); 269 tcp_lp_rtt_sample(sk, rtt_us);
270 270
271 /* calc inference */ 271 /* calc inference */
272 if (tcp_time_stamp > tp->rx_opt.rcv_tsecr) 272 if (tcp_time_stamp > tp->rx_opt.rcv_tsecr)
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index 914e0307f7af..b49dedcda52d 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -112,16 +112,16 @@ EXPORT_SYMBOL_GPL(tcp_vegas_init);
112 * o min-filter RTT samples from a much longer window (forever for now) 112 * o min-filter RTT samples from a much longer window (forever for now)
113 * to find the propagation delay (baseRTT) 113 * to find the propagation delay (baseRTT)
114 */ 114 */
115void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last) 115void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us)
116{ 116{
117 struct vegas *vegas = inet_csk_ca(sk); 117 struct vegas *vegas = inet_csk_ca(sk);
118 u32 vrtt; 118 u32 vrtt;
119 119
120 if (ktime_equal(last, net_invalid_timestamp())) 120 if (rtt_us < 0)
121 return; 121 return;
122 122
123 /* Never allow zero rtt or baseRTT */ 123 /* Never allow zero rtt or baseRTT */
124 vrtt = ktime_to_us(net_timedelta(last)) + 1; 124 vrtt = rtt_us + 1;
125 125
126 /* Filter to find propagation delay: */ 126 /* Filter to find propagation delay: */
127 if (vrtt < vegas->baseRTT) 127 if (vrtt < vegas->baseRTT)
diff --git a/net/ipv4/tcp_vegas.h b/net/ipv4/tcp_vegas.h
index 502fa8183634..6c0eea2f8249 100644
--- a/net/ipv4/tcp_vegas.h
+++ b/net/ipv4/tcp_vegas.h
@@ -17,7 +17,7 @@ struct vegas {
17 17
18extern void tcp_vegas_init(struct sock *sk); 18extern void tcp_vegas_init(struct sock *sk);
19extern void tcp_vegas_state(struct sock *sk, u8 ca_state); 19extern void tcp_vegas_state(struct sock *sk, u8 ca_state);
20extern void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, ktime_t last); 20extern void tcp_vegas_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us);
21extern void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event); 21extern void tcp_vegas_cwnd_event(struct sock *sk, enum tcp_ca_event event);
22extern void tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb); 22extern void tcp_vegas_get_info(struct sock *sk, u32 ext, struct sk_buff *skb);
23 23
diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
index 7a55ddf86032..8fb2aee0b1a4 100644
--- a/net/ipv4/tcp_veno.c
+++ b/net/ipv4/tcp_veno.c
@@ -69,16 +69,16 @@ static void tcp_veno_init(struct sock *sk)
69} 69}
70 70
71/* Do rtt sampling needed for Veno. */ 71/* Do rtt sampling needed for Veno. */
72static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, ktime_t last) 72static void tcp_veno_pkts_acked(struct sock *sk, u32 cnt, s32 rtt_us)
73{ 73{
74 struct veno *veno = inet_csk_ca(sk); 74 struct veno *veno = inet_csk_ca(sk);
75 u32 vrtt; 75 u32 vrtt;
76 76
77 if (ktime_equal(last, net_invalid_timestamp())) 77 if (rtt_us < 0)
78 return; 78 return;
79 79
80 /* Never allow zero rtt or baseRTT */ 80 /* Never allow zero rtt or baseRTT */
81 vrtt = ktime_to_us(net_timedelta(last)) + 1; 81 vrtt = rtt_us + 1;
82 82
83 /* Filter to find propagation delay: */ 83 /* Filter to find propagation delay: */
84 if (vrtt < veno->basertt) 84 if (vrtt < veno->basertt)
diff --git a/net/ipv4/tcp_westwood.c b/net/ipv4/tcp_westwood.c
index e61e09dd513e..20151d6a6241 100644
--- a/net/ipv4/tcp_westwood.c
+++ b/net/ipv4/tcp_westwood.c
@@ -100,11 +100,12 @@ static void westwood_filter(struct westwood *w, u32 delta)
100 * Called after processing group of packets. 100 * Called after processing group of packets.
101 * but all westwood needs is the last sample of srtt. 101 * but all westwood needs is the last sample of srtt.
102 */ 102 */
103static void tcp_westwood_pkts_acked(struct sock *sk, u32 cnt, ktime_t last) 103static void tcp_westwood_pkts_acked(struct sock *sk, u32 cnt, s32 rtt)
104{ 104{
105 struct westwood *w = inet_csk_ca(sk); 105 struct westwood *w = inet_csk_ca(sk);
106 if (cnt > 0) 106
107 w->rtt = tcp_sk(sk)->srtt >> 3; 107 if (rtt > 0)
108 w->rtt = usecs_to_jiffies(rtt);
108} 109}
109 110
110/* 111/*
diff --git a/net/ipv4/tcp_yeah.c b/net/ipv4/tcp_yeah.c
index c04b7c6ec702..c107fba7430e 100644
--- a/net/ipv4/tcp_yeah.c
+++ b/net/ipv4/tcp_yeah.c
@@ -58,7 +58,7 @@ static void tcp_yeah_init(struct sock *sk)
58} 58}
59 59
60 60
61static void tcp_yeah_pkts_acked(struct sock *sk, u32 pkts_acked, ktime_t last) 61static void tcp_yeah_pkts_acked(struct sock *sk, u32 pkts_acked, s32 rtt_us)
62{ 62{
63 const struct inet_connection_sock *icsk = inet_csk(sk); 63 const struct inet_connection_sock *icsk = inet_csk(sk);
64 struct yeah *yeah = inet_csk_ca(sk); 64 struct yeah *yeah = inet_csk_ca(sk);
@@ -66,7 +66,7 @@ static void tcp_yeah_pkts_acked(struct sock *sk, u32 pkts_acked, ktime_t last)
66 if (icsk->icsk_ca_state == TCP_CA_Open) 66 if (icsk->icsk_ca_state == TCP_CA_Open)
67 yeah->pkts_acked = pkts_acked; 67 yeah->pkts_acked = pkts_acked;
68 68
69 tcp_vegas_pkts_acked(sk, pkts_acked, last); 69 tcp_vegas_pkts_acked(sk, pkts_acked, rtt_us);
70} 70}
71 71
72static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack, 72static void tcp_yeah_cong_avoid(struct sock *sk, u32 ack,
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 06012920912a..91ef3be5abad 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2256,14 +2256,14 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2256 struct net_device *dev = (struct net_device *) data; 2256 struct net_device *dev = (struct net_device *) data;
2257 struct inet6_dev *idev = __in6_dev_get(dev); 2257 struct inet6_dev *idev = __in6_dev_get(dev);
2258 int run_pending = 0; 2258 int run_pending = 0;
2259 int err;
2259 2260
2260 switch(event) { 2261 switch(event) {
2261 case NETDEV_REGISTER: 2262 case NETDEV_REGISTER:
2262 if (!idev && dev->mtu >= IPV6_MIN_MTU) { 2263 if (!idev && dev->mtu >= IPV6_MIN_MTU) {
2263 idev = ipv6_add_dev(dev); 2264 idev = ipv6_add_dev(dev);
2264 if (!idev) 2265 if (!idev)
2265 printk(KERN_WARNING "IPv6: add_dev failed for %s\n", 2266 return notifier_from_errno(-ENOMEM);
2266 dev->name);
2267 } 2267 }
2268 break; 2268 break;
2269 case NETDEV_UP: 2269 case NETDEV_UP:
@@ -2373,7 +2373,9 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2373 NULL); 2373 NULL);
2374 addrconf_sysctl_register(idev, &idev->cnf); 2374 addrconf_sysctl_register(idev, &idev->cnf);
2375#endif 2375#endif
2376 snmp6_register_dev(idev); 2376 err = snmp6_register_dev(idev);
2377 if (err)
2378 return notifier_from_errno(err);
2377 } 2379 }
2378 break; 2380 break;
2379 } 2381 }
diff --git a/net/ipv6/addrconf_core.c b/net/ipv6/addrconf_core.c
index faaefb692298..3f82e9542eda 100644
--- a/net/ipv6/addrconf_core.c
+++ b/net/ipv6/addrconf_core.c
@@ -50,6 +50,9 @@ int __ipv6_addr_type(const struct in6_addr *addr)
50 if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000)) 50 if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000))
51 return (IPV6_ADDR_SITELOCAL | IPV6_ADDR_UNICAST | 51 return (IPV6_ADDR_SITELOCAL | IPV6_ADDR_UNICAST |
52 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL)); /* addr-select 3.1 */ 52 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL)); /* addr-select 3.1 */
53 if ((st & htonl(0xFE000000)) == htonl(0xFC000000))
54 return (IPV6_ADDR_UNICAST |
55 IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL)); /* RFC 4193 */
53 56
54 if ((addr->s6_addr32[0] | addr->s6_addr32[1]) == 0) { 57 if ((addr->s6_addr32[0] | addr->s6_addr32[1]) == 0) {
55 if (addr->s6_addr32[2] == 0) { 58 if (addr->s6_addr32[2] == 0) {
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index df30976f6dfd..ca774d8e3be3 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -385,7 +385,7 @@ parse_tlv_tnl_enc_lim(struct sk_buff *skb, __u8 * raw)
385 385
386static int 386static int
387ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt, 387ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt,
388 int *type, int *code, int *msg, __be32 *info, int offset) 388 int *type, int *code, int *msg, __u32 *info, int offset)
389{ 389{
390 struct ipv6hdr *ipv6h = (struct ipv6hdr *) skb->data; 390 struct ipv6hdr *ipv6h = (struct ipv6hdr *) skb->data;
391 struct ip6_tnl *t; 391 struct ip6_tnl *t;
@@ -435,7 +435,7 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt,
435 if ((*code) == ICMPV6_HDR_FIELD) 435 if ((*code) == ICMPV6_HDR_FIELD)
436 teli = parse_tlv_tnl_enc_lim(skb, skb->data); 436 teli = parse_tlv_tnl_enc_lim(skb, skb->data);
437 437
438 if (teli && teli == ntohl(*info) - 2) { 438 if (teli && teli == *info - 2) {
439 tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli]; 439 tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];
440 if (tel->encap_limit == 0) { 440 if (tel->encap_limit == 0) {
441 if (net_ratelimit()) 441 if (net_ratelimit())
@@ -452,7 +452,7 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt,
452 } 452 }
453 break; 453 break;
454 case ICMPV6_PKT_TOOBIG: 454 case ICMPV6_PKT_TOOBIG:
455 mtu = ntohl(*info) - offset; 455 mtu = *info - offset;
456 if (mtu < IPV6_MIN_MTU) 456 if (mtu < IPV6_MIN_MTU)
457 mtu = IPV6_MIN_MTU; 457 mtu = IPV6_MIN_MTU;
458 t->dev->mtu = mtu; 458 t->dev->mtu = mtu;
@@ -478,12 +478,12 @@ out:
478 478
479static int 479static int
480ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 480ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
481 int type, int code, int offset, __u32 info) 481 int type, int code, int offset, __be32 info)
482{ 482{
483 int rel_msg = 0; 483 int rel_msg = 0;
484 int rel_type = type; 484 int rel_type = type;
485 int rel_code = code; 485 int rel_code = code;
486 __u32 rel_info = info; 486 __u32 rel_info = ntohl(info);
487 int err; 487 int err;
488 struct sk_buff *skb2; 488 struct sk_buff *skb2;
489 struct iphdr *eiph; 489 struct iphdr *eiph;
@@ -564,10 +564,9 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
564 goto out; 564 goto out;
565 565
566 skb2->dst->ops->update_pmtu(skb2->dst, rel_info); 566 skb2->dst->ops->update_pmtu(skb2->dst, rel_info);
567 rel_info = htonl(rel_info);
568 } 567 }
569 568
570 icmp_send(skb2, rel_type, rel_code, rel_info); 569 icmp_send(skb2, rel_type, rel_code, htonl(rel_info));
571 570
572out: 571out:
573 kfree_skb(skb2); 572 kfree_skb(skb2);
@@ -576,12 +575,12 @@ out:
576 575
577static int 576static int
578ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, 577ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
579 int type, int code, int offset, __u32 info) 578 int type, int code, int offset, __be32 info)
580{ 579{
581 int rel_msg = 0; 580 int rel_msg = 0;
582 int rel_type = type; 581 int rel_type = type;
583 int rel_code = code; 582 int rel_code = code;
584 __u32 rel_info = info; 583 __u32 rel_info = ntohl(info);
585 int err; 584 int err;
586 585
587 err = ip6_tnl_err(skb, IPPROTO_IPV6, opt, &rel_type, &rel_code, 586 err = ip6_tnl_err(skb, IPPROTO_IPV6, opt, &rel_type, &rel_code,
diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c
index b05327ebd332..6ab99001dccc 100644
--- a/net/ipv6/netfilter/ip6t_LOG.c
+++ b/net/ipv6/netfilter/ip6t_LOG.c
@@ -493,10 +493,8 @@ static int __init ip6t_log_init(void)
493 ret = xt_register_target(&ip6t_log_reg); 493 ret = xt_register_target(&ip6t_log_reg);
494 if (ret < 0) 494 if (ret < 0)
495 return ret; 495 return ret;
496 ret = nf_log_register(PF_INET6, &ip6t_logger); 496 nf_log_register(PF_INET6, &ip6t_logger);
497 if (ret < 0 && ret != -EEXIST) 497 return 0;
498 xt_unregister_target(&ip6t_log_reg);
499 return ret;
500} 498}
501 499
502static void __exit ip6t_log_fini(void) 500static void __exit ip6t_log_fini(void)
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index 36df2218b669..3153e15e0f7c 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -86,8 +86,8 @@ static int ipv6_print_conntrack(struct seq_file *s,
86 * - Note also special handling of AUTH header. Thanks to IPsec wizards. 86 * - Note also special handling of AUTH header. Thanks to IPsec wizards.
87 */ 87 */
88 88
89int nf_ct_ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp, 89static int nf_ct_ipv6_skip_exthdr(const struct sk_buff *skb, int start,
90 int len) 90 u8 *nexthdrp, int len)
91{ 91{
92 u8 nexthdr = *nexthdrp; 92 u8 nexthdr = *nexthdrp;
93 93
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 919de682b331..55ea80fac601 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1983,9 +1983,10 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg)
1983 !dst_metric_locked(&rt->u.dst, RTAX_MTU) && 1983 !dst_metric_locked(&rt->u.dst, RTAX_MTU) &&
1984 (dst_mtu(&rt->u.dst) > arg->mtu || 1984 (dst_mtu(&rt->u.dst) > arg->mtu ||
1985 (dst_mtu(&rt->u.dst) < arg->mtu && 1985 (dst_mtu(&rt->u.dst) < arg->mtu &&
1986 dst_mtu(&rt->u.dst) == idev->cnf.mtu6))) 1986 dst_mtu(&rt->u.dst) == idev->cnf.mtu6))) {
1987 rt->u.dst.metrics[RTAX_MTU-1] = arg->mtu; 1987 rt->u.dst.metrics[RTAX_MTU-1] = arg->mtu;
1988 rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(arg->mtu); 1988 rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(arg->mtu);
1989 }
1989 return 0; 1990 return 0;
1990} 1991}
1991 1992
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index d67fb1ef751e..f10f3689d671 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -633,6 +633,7 @@ static int tcp_v6_md5_do_del(struct sock *sk, struct in6_addr *peer)
633 if (tp->md5sig_info->entries6 == 0) { 633 if (tp->md5sig_info->entries6 == 0) {
634 kfree(tp->md5sig_info->keys6); 634 kfree(tp->md5sig_info->keys6);
635 tp->md5sig_info->keys6 = NULL; 635 tp->md5sig_info->keys6 = NULL;
636 tp->md5sig_info->alloced6 = 0;
636 637
637 tcp_free_md5sig_pool(); 638 tcp_free_md5sig_pool();
638 639
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index ad5150b8dfa9..983058d432dc 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -479,7 +479,8 @@ static void iucv_setmask_mp(void)
479 /* Enable all cpus with a declared buffer. */ 479 /* Enable all cpus with a declared buffer. */
480 if (cpu_isset(cpu, iucv_buffer_cpumask) && 480 if (cpu_isset(cpu, iucv_buffer_cpumask) &&
481 !cpu_isset(cpu, iucv_irq_cpumask)) 481 !cpu_isset(cpu, iucv_irq_cpumask))
482 smp_call_function_on(iucv_allow_cpu, NULL, 0, 1, cpu); 482 smp_call_function_single(cpu, iucv_allow_cpu,
483 NULL, 0, 1);
483 preempt_enable(); 484 preempt_enable();
484} 485}
485 486
@@ -497,7 +498,7 @@ static void iucv_setmask_up(void)
497 cpumask = iucv_irq_cpumask; 498 cpumask = iucv_irq_cpumask;
498 cpu_clear(first_cpu(iucv_irq_cpumask), cpumask); 499 cpu_clear(first_cpu(iucv_irq_cpumask), cpumask);
499 for_each_cpu_mask(cpu, cpumask) 500 for_each_cpu_mask(cpu, cpumask)
500 smp_call_function_on(iucv_block_cpu, NULL, 0, 1, cpu); 501 smp_call_function_single(cpu, iucv_block_cpu, NULL, 0, 1);
501} 502}
502 503
503/** 504/**
@@ -522,7 +523,7 @@ static int iucv_enable(void)
522 rc = -EIO; 523 rc = -EIO;
523 preempt_disable(); 524 preempt_disable();
524 for_each_online_cpu(cpu) 525 for_each_online_cpu(cpu)
525 smp_call_function_on(iucv_declare_cpu, NULL, 0, 1, cpu); 526 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 0, 1);
526 preempt_enable(); 527 preempt_enable();
527 if (cpus_empty(iucv_buffer_cpumask)) 528 if (cpus_empty(iucv_buffer_cpumask))
528 /* No cpu could declare an iucv buffer. */ 529 /* No cpu could declare an iucv buffer. */
@@ -578,7 +579,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
578 case CPU_ONLINE_FROZEN: 579 case CPU_ONLINE_FROZEN:
579 case CPU_DOWN_FAILED: 580 case CPU_DOWN_FAILED:
580 case CPU_DOWN_FAILED_FROZEN: 581 case CPU_DOWN_FAILED_FROZEN:
581 smp_call_function_on(iucv_declare_cpu, NULL, 0, 1, cpu); 582 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 0, 1);
582 break; 583 break;
583 case CPU_DOWN_PREPARE: 584 case CPU_DOWN_PREPARE:
584 case CPU_DOWN_PREPARE_FROZEN: 585 case CPU_DOWN_PREPARE_FROZEN:
@@ -587,10 +588,10 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
587 if (cpus_empty(cpumask)) 588 if (cpus_empty(cpumask))
588 /* Can't offline last IUCV enabled cpu. */ 589 /* Can't offline last IUCV enabled cpu. */
589 return NOTIFY_BAD; 590 return NOTIFY_BAD;
590 smp_call_function_on(iucv_retrieve_cpu, NULL, 0, 1, cpu); 591 smp_call_function_single(cpu, iucv_retrieve_cpu, NULL, 0, 1);
591 if (cpus_empty(iucv_irq_cpumask)) 592 if (cpus_empty(iucv_irq_cpumask))
592 smp_call_function_on(iucv_allow_cpu, NULL, 0, 1, 593 smp_call_function_single(first_cpu(iucv_buffer_cpumask),
593 first_cpu(iucv_buffer_cpumask)); 594 iucv_allow_cpu, NULL, 0, 1);
594 break; 595 break;
595 } 596 }
596 return NOTIFY_OK; 597 return NOTIFY_OK;
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 0f8304b0246b..7b0a95abe934 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2540,7 +2540,7 @@ static int pfkey_migrate(struct sock *sk, struct sk_buff *skb,
2540 sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto); 2540 sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
2541 sel.sport = ((struct sockaddr_in *)(sa + 1))->sin_port; 2541 sel.sport = ((struct sockaddr_in *)(sa + 1))->sin_port;
2542 if (sel.sport) 2542 if (sel.sport)
2543 sel.sport_mask = ~0; 2543 sel.sport_mask = htons(0xffff);
2544 2544
2545 /* set destination address info of selector */ 2545 /* set destination address info of selector */
2546 sa = ext_hdrs[SADB_EXT_ADDRESS_DST - 1], 2546 sa = ext_hdrs[SADB_EXT_ADDRESS_DST - 1],
@@ -2549,7 +2549,7 @@ static int pfkey_migrate(struct sock *sk, struct sk_buff *skb,
2549 sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto); 2549 sel.proto = pfkey_proto_to_xfrm(sa->sadb_address_proto);
2550 sel.dport = ((struct sockaddr_in *)(sa + 1))->sin_port; 2550 sel.dport = ((struct sockaddr_in *)(sa + 1))->sin_port;
2551 if (sel.dport) 2551 if (sel.dport)
2552 sel.dport_mask = ~0; 2552 sel.dport_mask = htons(0xffff);
2553 2553
2554 rq = (struct sadb_x_ipsecrequest *)(pol + 1); 2554 rq = (struct sadb_x_ipsecrequest *)(pol + 1);
2555 2555
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index aa086c83af80..0fe11889ce14 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -79,7 +79,8 @@ static u_int32_t __hash_conntrack(const struct nf_conntrack_tuple *tuple,
79 a = jhash2(tuple->src.u3.all, ARRAY_SIZE(tuple->src.u3.all), 79 a = jhash2(tuple->src.u3.all, ARRAY_SIZE(tuple->src.u3.all),
80 (tuple->src.l3num << 16) | tuple->dst.protonum); 80 (tuple->src.l3num << 16) | tuple->dst.protonum);
81 b = jhash2(tuple->dst.u3.all, ARRAY_SIZE(tuple->dst.u3.all), 81 b = jhash2(tuple->dst.u3.all, ARRAY_SIZE(tuple->dst.u3.all),
82 (tuple->src.u.all << 16) | tuple->dst.u.all); 82 ((__force __u16)tuple->src.u.all << 16) |
83 (__force __u16)tuple->dst.u.all);
83 84
84 return jhash_2words(a, b, rnd) % size; 85 return jhash_2words(a, b, rnd) % size;
85} 86}
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
index 1aa6229ca99f..eb6695dcd73b 100644
--- a/net/netfilter/nf_conntrack_expect.c
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -80,7 +80,7 @@ static unsigned int nf_ct_expect_dst_hash(const struct nf_conntrack_tuple *tuple
80 80
81 return jhash2(tuple->dst.u3.all, ARRAY_SIZE(tuple->dst.u3.all), 81 return jhash2(tuple->dst.u3.all, ARRAY_SIZE(tuple->dst.u3.all),
82 (((tuple->dst.protonum ^ tuple->src.l3num) << 16) | 82 (((tuple->dst.protonum ^ tuple->src.l3num) << 16) |
83 tuple->dst.u.all) ^ nf_ct_expect_hash_rnd) % 83 (__force __u16)tuple->dst.u.all) ^ nf_ct_expect_hash_rnd) %
84 nf_ct_expect_hsize; 84 nf_ct_expect_hsize;
85} 85}
86 86
@@ -259,8 +259,8 @@ void nf_ct_expect_init(struct nf_conntrack_expect *exp, int family,
259 } 259 }
260 260
261 if (src) { 261 if (src) {
262 exp->tuple.src.u.all = (__force u16)*src; 262 exp->tuple.src.u.all = *src;
263 exp->mask.src.u.all = 0xFFFF; 263 exp->mask.src.u.all = htons(0xFFFF);
264 } else { 264 } else {
265 exp->tuple.src.u.all = 0; 265 exp->tuple.src.u.all = 0;
266 exp->mask.src.u.all = 0; 266 exp->mask.src.u.all = 0;
@@ -272,7 +272,7 @@ void nf_ct_expect_init(struct nf_conntrack_expect *exp, int family,
272 memset((void *)&exp->tuple.dst.u3 + len, 0x00, 272 memset((void *)&exp->tuple.dst.u3 + len, 0x00,
273 sizeof(exp->tuple.dst.u3) - len); 273 sizeof(exp->tuple.dst.u3) - len);
274 274
275 exp->tuple.dst.u.all = (__force u16)*dst; 275 exp->tuple.dst.u.all = *dst;
276} 276}
277EXPORT_SYMBOL_GPL(nf_ct_expect_init); 277EXPORT_SYMBOL_GPL(nf_ct_expect_init);
278 278
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
index ca10df40784f..96aa637c0932 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -39,7 +39,7 @@ static int nf_ct_helper_vmalloc;
39static unsigned int helper_hash(const struct nf_conntrack_tuple *tuple) 39static unsigned int helper_hash(const struct nf_conntrack_tuple *tuple)
40{ 40{
41 return (((tuple->src.l3num << 8) | tuple->dst.protonum) ^ 41 return (((tuple->src.l3num << 8) | tuple->dst.protonum) ^
42 tuple->src.u.all) % nf_ct_helper_hsize; 42 (__force __u16)tuple->src.u.all) % nf_ct_helper_hsize;
43} 43}
44 44
45struct nf_conntrack_helper * 45struct nf_conntrack_helper *
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 87ad3ccf8aff..eb3fe7401466 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -8,7 +8,6 @@
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/timer.h> 10#include <linux/timer.h>
11#include <linux/netfilter.h>
12#include <linux/module.h> 11#include <linux/module.h>
13#include <linux/in.h> 12#include <linux/in.h>
14#include <linux/tcp.h> 13#include <linux/tcp.h>
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index 13d94a025723..2a2fd1a764ea 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -9,7 +9,6 @@
9#include <linux/types.h> 9#include <linux/types.h>
10#include <linux/timer.h> 10#include <linux/timer.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/netfilter.h>
13#include <linux/udp.h> 12#include <linux/udp.h>
14#include <linux/seq_file.h> 13#include <linux/seq_file.h>
15#include <linux/skbuff.h> 14#include <linux/skbuff.h>
diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c
index 93e747b5396e..b906b413997c 100644
--- a/net/netfilter/nf_conntrack_proto_udplite.c
+++ b/net/netfilter/nf_conntrack_proto_udplite.c
@@ -10,7 +10,6 @@
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/timer.h> 11#include <linux/timer.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/netfilter.h>
14#include <linux/udp.h> 13#include <linux/udp.h>
15#include <linux/seq_file.h> 14#include <linux/seq_file.h>
16#include <linux/skbuff.h> 15#include <linux/skbuff.h>
diff --git a/net/netfilter/xt_connlimit.c b/net/netfilter/xt_connlimit.c
index 3335dd5be962..06cff1d13690 100644
--- a/net/netfilter/xt_connlimit.c
+++ b/net/netfilter/xt_connlimit.c
@@ -42,13 +42,13 @@ struct xt_connlimit_data {
42static u_int32_t connlimit_rnd; 42static u_int32_t connlimit_rnd;
43static bool connlimit_rnd_inited; 43static bool connlimit_rnd_inited;
44 44
45static inline unsigned int connlimit_iphash(u_int32_t addr) 45static inline unsigned int connlimit_iphash(__be32 addr)
46{ 46{
47 if (unlikely(!connlimit_rnd_inited)) { 47 if (unlikely(!connlimit_rnd_inited)) {
48 get_random_bytes(&connlimit_rnd, sizeof(connlimit_rnd)); 48 get_random_bytes(&connlimit_rnd, sizeof(connlimit_rnd));
49 connlimit_rnd_inited = true; 49 connlimit_rnd_inited = true;
50 } 50 }
51 return jhash_1word(addr, connlimit_rnd) & 0xFF; 51 return jhash_1word((__force __u32)addr, connlimit_rnd) & 0xFF;
52} 52}
53 53
54static inline unsigned int 54static inline unsigned int
@@ -66,7 +66,7 @@ connlimit_iphash6(const union nf_conntrack_address *addr,
66 for (i = 0; i < ARRAY_SIZE(addr->ip6); ++i) 66 for (i = 0; i < ARRAY_SIZE(addr->ip6); ++i)
67 res.ip6[i] = addr->ip6[i] & mask->ip6[i]; 67 res.ip6[i] = addr->ip6[i] & mask->ip6[i];
68 68
69 return jhash2(res.ip6, ARRAY_SIZE(res.ip6), connlimit_rnd) & 0xFF; 69 return jhash2((u32 *)res.ip6, ARRAY_SIZE(res.ip6), connlimit_rnd) & 0xFF;
70} 70}
71 71
72static inline bool already_closed(const struct nf_conn *conn) 72static inline bool already_closed(const struct nf_conn *conn)
diff --git a/net/netfilter/xt_physdev.c b/net/netfilter/xt_physdev.c
index f47cab7a696d..a4bab043a6d1 100644
--- a/net/netfilter/xt_physdev.c
+++ b/net/netfilter/xt_physdev.c
@@ -13,7 +13,6 @@
13#include <linux/netfilter_bridge.h> 13#include <linux/netfilter_bridge.h>
14#include <linux/netfilter/xt_physdev.h> 14#include <linux/netfilter/xt_physdev.h>
15#include <linux/netfilter/x_tables.h> 15#include <linux/netfilter/x_tables.h>
16#include <linux/netfilter_bridge.h>
17 16
18MODULE_LICENSE("GPL"); 17MODULE_LICENSE("GPL");
19MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>"); 18MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>");
diff --git a/net/netfilter/xt_u32.c b/net/netfilter/xt_u32.c
index 04b677ae8dae..74f9b14c012f 100644
--- a/net/netfilter/xt_u32.c
+++ b/net/netfilter/xt_u32.c
@@ -21,6 +21,7 @@ static bool u32_match_it(const struct xt_u32 *data,
21 unsigned int nnums; 21 unsigned int nnums;
22 unsigned int nvals; 22 unsigned int nvals;
23 unsigned int i; 23 unsigned int i;
24 __be32 n;
24 u_int32_t pos; 25 u_int32_t pos;
25 u_int32_t val; 26 u_int32_t val;
26 u_int32_t at; 27 u_int32_t at;
@@ -38,9 +39,9 @@ static bool u32_match_it(const struct xt_u32 *data,
38 if (skb->len < 4 || pos > skb->len - 4); 39 if (skb->len < 4 || pos > skb->len - 4);
39 return false; 40 return false;
40 41
41 ret = skb_copy_bits(skb, pos, &val, sizeof(val)); 42 ret = skb_copy_bits(skb, pos, &n, sizeof(n));
42 BUG_ON(ret < 0); 43 BUG_ON(ret < 0);
43 val = ntohl(val); 44 val = ntohl(n);
44 nnums = ct->nnums; 45 nnums = ct->nnums;
45 46
46 /* Inner loop runs over "&", "<<", ">>" and "@" operands */ 47 /* Inner loop runs over "&", "<<", ">>" and "@" operands */
@@ -65,10 +66,10 @@ static bool u32_match_it(const struct xt_u32 *data,
65 pos > skb->len - at - 4) 66 pos > skb->len - at - 4)
66 return false; 67 return false;
67 68
68 ret = skb_copy_bits(skb, at + pos, &val, 69 ret = skb_copy_bits(skb, at + pos, &n,
69 sizeof(val)); 70 sizeof(n));
70 BUG_ON(ret < 0); 71 BUG_ON(ret < 0);
71 val = ntohl(val); 72 val = ntohl(n);
72 break; 73 break;
73 } 74 }
74 } 75 }
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index e146531faf1d..8c11ca4a2121 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -184,7 +184,7 @@ int genl_register_mc_group(struct genl_family *family,
184 } 184 }
185 185
186 err = netlink_change_ngroups(genl_sock, 186 err = netlink_change_ngroups(genl_sock,
187 sizeof(unsigned long) * NETLINK_GENERIC); 187 mc_groups_longs * BITS_PER_LONG);
188 if (err) 188 if (err)
189 goto out; 189 goto out;
190 190
@@ -196,10 +196,22 @@ int genl_register_mc_group(struct genl_family *family,
196 genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, grp); 196 genl_ctrl_event(CTRL_CMD_NEWMCAST_GRP, grp);
197 out: 197 out:
198 genl_unlock(); 198 genl_unlock();
199 return 0; 199 return err;
200} 200}
201EXPORT_SYMBOL(genl_register_mc_group); 201EXPORT_SYMBOL(genl_register_mc_group);
202 202
203static void __genl_unregister_mc_group(struct genl_family *family,
204 struct genl_multicast_group *grp)
205{
206 BUG_ON(grp->family != family);
207 netlink_clear_multicast_users(genl_sock, grp->id);
208 clear_bit(grp->id, mc_groups);
209 list_del(&grp->list);
210 genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp);
211 grp->id = 0;
212 grp->family = NULL;
213}
214
203/** 215/**
204 * genl_unregister_mc_group - unregister a multicast group 216 * genl_unregister_mc_group - unregister a multicast group
205 * 217 *
@@ -217,14 +229,8 @@ EXPORT_SYMBOL(genl_register_mc_group);
217void genl_unregister_mc_group(struct genl_family *family, 229void genl_unregister_mc_group(struct genl_family *family,
218 struct genl_multicast_group *grp) 230 struct genl_multicast_group *grp)
219{ 231{
220 BUG_ON(grp->family != family);
221 genl_lock(); 232 genl_lock();
222 netlink_clear_multicast_users(genl_sock, grp->id); 233 __genl_unregister_mc_group(family, grp);
223 clear_bit(grp->id, mc_groups);
224 list_del(&grp->list);
225 genl_ctrl_event(CTRL_CMD_DELMCAST_GRP, grp);
226 grp->id = 0;
227 grp->family = NULL;
228 genl_unlock(); 234 genl_unlock();
229} 235}
230 236
@@ -232,8 +238,10 @@ static void genl_unregister_mc_groups(struct genl_family *family)
232{ 238{
233 struct genl_multicast_group *grp, *tmp; 239 struct genl_multicast_group *grp, *tmp;
234 240
241 genl_lock();
235 list_for_each_entry_safe(grp, tmp, &family->mcast_groups, list) 242 list_for_each_entry_safe(grp, tmp, &family->mcast_groups, list)
236 genl_unregister_mc_group(family, grp); 243 __genl_unregister_mc_group(family, grp);
244 genl_unlock();
237} 245}
238 246
239/** 247/**
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index 16a68df4e36b..c58fa0d1be26 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -787,7 +787,7 @@ static int __init af_rxrpc_init(void)
787 787
788 BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > sizeof(dummy_skb->cb)); 788 BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > sizeof(dummy_skb->cb));
789 789
790 rxrpc_epoch = htonl(xtime.tv_sec); 790 rxrpc_epoch = htonl(get_seconds());
791 791
792 ret = -ENOMEM; 792 ret = -ENOMEM;
793 rxrpc_call_jar = kmem_cache_create( 793 rxrpc_call_jar = kmem_cache_create(
diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
index 482750efc235..d6667f7bc85e 100644
--- a/net/rxrpc/ar-connection.c
+++ b/net/rxrpc/ar-connection.c
@@ -71,7 +71,7 @@ struct rxrpc_conn_bundle *rxrpc_get_bundle(struct rxrpc_sock *rx,
71 struct rb_node *p, *parent, **pp; 71 struct rb_node *p, *parent, **pp;
72 72
73 _enter("%p{%x},%x,%hx,", 73 _enter("%p{%x},%x,%hx,",
74 rx, key_serial(key), trans->debug_id, ntohl(service_id)); 74 rx, key_serial(key), trans->debug_id, ntohs(service_id));
75 75
76 if (rx->trans == trans && rx->bundle) { 76 if (rx->trans == trans && rx->bundle) {
77 atomic_inc(&rx->bundle->usage); 77 atomic_inc(&rx->bundle->usage);
@@ -791,7 +791,7 @@ void rxrpc_put_connection(struct rxrpc_connection *conn)
791 791
792 ASSERTCMP(atomic_read(&conn->usage), >, 0); 792 ASSERTCMP(atomic_read(&conn->usage), >, 0);
793 793
794 conn->put_time = xtime.tv_sec; 794 conn->put_time = get_seconds();
795 if (atomic_dec_and_test(&conn->usage)) { 795 if (atomic_dec_and_test(&conn->usage)) {
796 _debug("zombie"); 796 _debug("zombie");
797 rxrpc_queue_delayed_work(&rxrpc_connection_reap, 0); 797 rxrpc_queue_delayed_work(&rxrpc_connection_reap, 0);
@@ -835,7 +835,7 @@ void rxrpc_connection_reaper(struct work_struct *work)
835 835
836 _enter(""); 836 _enter("");
837 837
838 now = xtime.tv_sec; 838 now = get_seconds();
839 earliest = ULONG_MAX; 839 earliest = ULONG_MAX;
840 840
841 write_lock_bh(&rxrpc_connection_lock); 841 write_lock_bh(&rxrpc_connection_lock);
diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
index d43d78f19302..bb282a6a19f0 100644
--- a/net/rxrpc/ar-transport.c
+++ b/net/rxrpc/ar-transport.c
@@ -183,7 +183,7 @@ void rxrpc_put_transport(struct rxrpc_transport *trans)
183 183
184 ASSERTCMP(atomic_read(&trans->usage), >, 0); 184 ASSERTCMP(atomic_read(&trans->usage), >, 0);
185 185
186 trans->put_time = xtime.tv_sec; 186 trans->put_time = get_seconds();
187 if (unlikely(atomic_dec_and_test(&trans->usage))) 187 if (unlikely(atomic_dec_and_test(&trans->usage)))
188 _debug("zombie"); 188 _debug("zombie");
189 /* let the reaper determine the timeout to avoid a race with 189 /* let the reaper determine the timeout to avoid a race with
@@ -219,7 +219,7 @@ static void rxrpc_transport_reaper(struct work_struct *work)
219 219
220 _enter(""); 220 _enter("");
221 221
222 now = xtime.tv_sec; 222 now = get_seconds();
223 earliest = ULONG_MAX; 223 earliest = ULONG_MAX;
224 224
225 /* extract all the transports that have been dead too long */ 225 /* extract all the transports that have been dead too long */
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index 5ec705144e10..ac3cabdca78c 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -916,7 +916,7 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn,
916 issue = be32_to_cpu(stamp); 916 issue = be32_to_cpu(stamp);
917 } 917 }
918 p += 4; 918 p += 4;
919 now = xtime.tv_sec; 919 now = get_seconds();
920 _debug("KIV ISSUE: %lx [%lx]", issue, now); 920 _debug("KIV ISSUE: %lx [%lx]", issue, now);
921 921
922 /* check the ticket is in date */ 922 /* check the ticket is in date */
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 13c09bc32aa3..dee0d5fb39c5 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -380,6 +380,10 @@ void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n)
380 return; 380 return;
381 while ((parentid = sch->parent)) { 381 while ((parentid = sch->parent)) {
382 sch = qdisc_lookup(sch->dev, TC_H_MAJ(parentid)); 382 sch = qdisc_lookup(sch->dev, TC_H_MAJ(parentid));
383 if (sch == NULL) {
384 WARN_ON(parentid != TC_H_ROOT);
385 return;
386 }
383 cops = sch->ops->cl_ops; 387 cops = sch->ops->cl_ops;
384 if (cops->qlen_notify) { 388 if (cops->qlen_notify) {
385 cl = cops->get(sch, parentid); 389 cl = cops->get(sch, parentid);
@@ -420,8 +424,6 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
420 unsigned long cl = cops->get(parent, classid); 424 unsigned long cl = cops->get(parent, classid);
421 if (cl) { 425 if (cl) {
422 err = cops->graft(parent, cl, new, old); 426 err = cops->graft(parent, cl, new, old);
423 if (new)
424 new->parent = classid;
425 cops->put(parent, cl); 427 cops->put(parent, cl);
426 } 428 }
427 } 429 }
@@ -436,7 +438,8 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
436 */ 438 */
437 439
438static struct Qdisc * 440static struct Qdisc *
439qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp) 441qdisc_create(struct net_device *dev, u32 parent, u32 handle,
442 struct rtattr **tca, int *errp)
440{ 443{
441 int err; 444 int err;
442 struct rtattr *kind = tca[TCA_KIND-1]; 445 struct rtattr *kind = tca[TCA_KIND-1];
@@ -482,6 +485,8 @@ qdisc_create(struct net_device *dev, u32 handle, struct rtattr **tca, int *errp)
482 goto err_out2; 485 goto err_out2;
483 } 486 }
484 487
488 sch->parent = parent;
489
485 if (handle == TC_H_INGRESS) { 490 if (handle == TC_H_INGRESS) {
486 sch->flags |= TCQ_F_INGRESS; 491 sch->flags |= TCQ_F_INGRESS;
487 sch->stats_lock = &dev->ingress_lock; 492 sch->stats_lock = &dev->ingress_lock;
@@ -758,9 +763,11 @@ create_n_graft:
758 if (!(n->nlmsg_flags&NLM_F_CREATE)) 763 if (!(n->nlmsg_flags&NLM_F_CREATE))
759 return -ENOENT; 764 return -ENOENT;
760 if (clid == TC_H_INGRESS) 765 if (clid == TC_H_INGRESS)
761 q = qdisc_create(dev, tcm->tcm_parent, tca, &err); 766 q = qdisc_create(dev, tcm->tcm_parent, tcm->tcm_parent,
767 tca, &err);
762 else 768 else
763 q = qdisc_create(dev, tcm->tcm_handle, tca, &err); 769 q = qdisc_create(dev, tcm->tcm_parent, tcm->tcm_handle,
770 tca, &err);
764 if (q == NULL) { 771 if (q == NULL) {
765 if (err == -EAGAIN) 772 if (err == -EAGAIN)
766 goto replay; 773 goto replay;
diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index 51f16b0af198..2d32fd27496e 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -158,9 +158,8 @@ static int ingress_enqueue(struct sk_buff *skb,struct Qdisc *sch)
158 break; 158 break;
159 case TC_ACT_RECLASSIFY: 159 case TC_ACT_RECLASSIFY:
160 case TC_ACT_OK: 160 case TC_ACT_OK:
161 case TC_ACT_UNSPEC:
162 default:
163 skb->tc_index = TC_H_MIN(res.classid); 161 skb->tc_index = TC_H_MIN(res.classid);
162 default:
164 result = TC_ACT_OK; 163 result = TC_ACT_OK;
165 break; 164 break;
166 } 165 }
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index 2d8c08493d6e..4a49db65772e 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -38,9 +38,11 @@ prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
38 struct prio_sched_data *q = qdisc_priv(sch); 38 struct prio_sched_data *q = qdisc_priv(sch);
39 u32 band = skb->priority; 39 u32 band = skb->priority;
40 struct tcf_result res; 40 struct tcf_result res;
41 int err;
41 42
42 *qerr = NET_XMIT_BYPASS; 43 *qerr = NET_XMIT_BYPASS;
43 if (TC_H_MAJ(skb->priority) != sch->handle) { 44 if (TC_H_MAJ(skb->priority) != sch->handle) {
45 err = tc_classify(skb, q->filter_list, &res);
44#ifdef CONFIG_NET_CLS_ACT 46#ifdef CONFIG_NET_CLS_ACT
45 switch (tc_classify(skb, q->filter_list, &res)) { 47 switch (tc_classify(skb, q->filter_list, &res)) {
46 case TC_ACT_STOLEN: 48 case TC_ACT_STOLEN:
@@ -49,11 +51,8 @@ prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
49 case TC_ACT_SHOT: 51 case TC_ACT_SHOT:
50 return NULL; 52 return NULL;
51 } 53 }
52
53 if (!q->filter_list ) {
54#else
55 if (!q->filter_list || tc_classify(skb, q->filter_list, &res)) {
56#endif 54#endif
55 if (!q->filter_list || err < 0) {
57 if (TC_H_MAJ(band)) 56 if (TC_H_MAJ(band))
58 band = 0; 57 band = 0;
59 band = q->prio2band[band&TC_PRIO_MAX]; 58 band = q->prio2band[band&TC_PRIO_MAX];
@@ -239,11 +238,13 @@ static int prio_tune(struct Qdisc *sch, struct rtattr *opt)
239 /* If we're multiqueue, make sure the number of incoming bands 238 /* If we're multiqueue, make sure the number of incoming bands
240 * matches the number of queues on the device we're associating with. 239 * matches the number of queues on the device we're associating with.
241 * If the number of bands requested is zero, then set q->bands to 240 * If the number of bands requested is zero, then set q->bands to
242 * dev->egress_subqueue_count. 241 * dev->egress_subqueue_count. Also, the root qdisc must be the
242 * only one that is enabled for multiqueue, since it's the only one
243 * that interacts with the underlying device.
243 */ 244 */
244 q->mq = RTA_GET_FLAG(tb[TCA_PRIO_MQ - 1]); 245 q->mq = RTA_GET_FLAG(tb[TCA_PRIO_MQ - 1]);
245 if (q->mq) { 246 if (q->mq) {
246 if (sch->handle != TC_H_ROOT) 247 if (sch->parent != TC_H_ROOT)
247 return -EINVAL; 248 return -EINVAL;
248 if (netif_is_multiqueue(sch->dev)) { 249 if (netif_is_multiqueue(sch->dev)) {
249 if (q->bands == 0) 250 if (q->bands == 0)
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 490697542fc2..dc2f41e9f577 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -769,11 +769,12 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
769 new->h.flavour = &svcauthops_gss; 769 new->h.flavour = &svcauthops_gss;
770 new->pseudoflavor = pseudoflavor; 770 new->pseudoflavor = pseudoflavor;
771 771
772 stat = 0;
772 test = auth_domain_lookup(name, &new->h); 773 test = auth_domain_lookup(name, &new->h);
773 if (test != &new->h) { /* XXX Duplicate registration? */ 774 if (test != &new->h) { /* Duplicate registration */
774 auth_domain_put(&new->h); 775 auth_domain_put(test);
775 /* dangling ref-count... */ 776 kfree(new->h.name);
776 goto out; 777 goto out_free_dom;
777 } 778 }
778 return 0; 779 return 0;
779 780
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 64b9b8c743c4..12ff5da8160e 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -131,13 +131,13 @@ static char *__svc_print_addr(struct sockaddr *addr, char *buf, size_t len)
131 case AF_INET: 131 case AF_INET:
132 snprintf(buf, len, "%u.%u.%u.%u, port=%u", 132 snprintf(buf, len, "%u.%u.%u.%u, port=%u",
133 NIPQUAD(((struct sockaddr_in *) addr)->sin_addr), 133 NIPQUAD(((struct sockaddr_in *) addr)->sin_addr),
134 htons(((struct sockaddr_in *) addr)->sin_port)); 134 ntohs(((struct sockaddr_in *) addr)->sin_port));
135 break; 135 break;
136 136
137 case AF_INET6: 137 case AF_INET6:
138 snprintf(buf, len, "%x:%x:%x:%x:%x:%x:%x:%x, port=%u", 138 snprintf(buf, len, "%x:%x:%x:%x:%x:%x:%x:%x, port=%u",
139 NIP6(((struct sockaddr_in6 *) addr)->sin6_addr), 139 NIP6(((struct sockaddr_in6 *) addr)->sin6_addr),
140 htons(((struct sockaddr_in6 *) addr)->sin6_port)); 140 ntohs(((struct sockaddr_in6 *) addr)->sin6_port));
141 break; 141 break;
142 142
143 default: 143 default:
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 5adfdfd49d61..1d674e0848fa 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -423,6 +423,17 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
423 return NULL; 423 return NULL;
424 } 424 }
425 425
426 if (LINK_LOG_BUF_SIZE) {
427 char *pb = kmalloc(LINK_LOG_BUF_SIZE, GFP_ATOMIC);
428
429 if (!pb) {
430 kfree(l_ptr);
431 warn("Link creation failed, no memory for print buffer\n");
432 return NULL;
433 }
434 tipc_printbuf_init(&l_ptr->print_buf, pb, LINK_LOG_BUF_SIZE);
435 }
436
426 l_ptr->addr = peer; 437 l_ptr->addr = peer;
427 if_name = strchr(b_ptr->publ.name, ':') + 1; 438 if_name = strchr(b_ptr->publ.name, ':') + 1;
428 sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:", 439 sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:",
@@ -432,8 +443,6 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
432 tipc_zone(peer), tipc_cluster(peer), tipc_node(peer)); 443 tipc_zone(peer), tipc_cluster(peer), tipc_node(peer));
433 /* note: peer i/f is appended to link name by reset/activate */ 444 /* note: peer i/f is appended to link name by reset/activate */
434 memcpy(&l_ptr->media_addr, media_addr, sizeof(*media_addr)); 445 memcpy(&l_ptr->media_addr, media_addr, sizeof(*media_addr));
435 k_init_timer(&l_ptr->timer, (Handler)link_timeout, (unsigned long)l_ptr);
436 list_add_tail(&l_ptr->link_list, &b_ptr->links);
437 l_ptr->checkpoint = 1; 446 l_ptr->checkpoint = 1;
438 l_ptr->b_ptr = b_ptr; 447 l_ptr->b_ptr = b_ptr;
439 link_set_supervision_props(l_ptr, b_ptr->media->tolerance); 448 link_set_supervision_props(l_ptr, b_ptr->media->tolerance);
@@ -459,21 +468,14 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
459 468
460 l_ptr->owner = tipc_node_attach_link(l_ptr); 469 l_ptr->owner = tipc_node_attach_link(l_ptr);
461 if (!l_ptr->owner) { 470 if (!l_ptr->owner) {
471 if (LINK_LOG_BUF_SIZE)
472 kfree(l_ptr->print_buf.buf);
462 kfree(l_ptr); 473 kfree(l_ptr);
463 return NULL; 474 return NULL;
464 } 475 }
465 476
466 if (LINK_LOG_BUF_SIZE) { 477 k_init_timer(&l_ptr->timer, (Handler)link_timeout, (unsigned long)l_ptr);
467 char *pb = kmalloc(LINK_LOG_BUF_SIZE, GFP_ATOMIC); 478 list_add_tail(&l_ptr->link_list, &b_ptr->links);
468
469 if (!pb) {
470 kfree(l_ptr);
471 warn("Link creation failed, no memory for print buffer\n");
472 return NULL;
473 }
474 tipc_printbuf_init(&l_ptr->print_buf, pb, LINK_LOG_BUF_SIZE);
475 }
476
477 tipc_k_signal((Handler)tipc_link_start, (unsigned long)l_ptr); 479 tipc_k_signal((Handler)tipc_link_start, (unsigned long)l_ptr);
478 480
479 dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n", 481 dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n",
diff --git a/net/tipc/msg.h b/net/tipc/msg.h
index 35d5ba1d4f42..ce2659836374 100644
--- a/net/tipc/msg.h
+++ b/net/tipc/msg.h
@@ -72,10 +72,8 @@ static inline void msg_set_bits(struct tipc_msg *m, u32 w,
72 u32 pos, u32 mask, u32 val) 72 u32 pos, u32 mask, u32 val)
73{ 73{
74 val = (val & mask) << pos; 74 val = (val & mask) << pos;
75 val = htonl(val); 75 m->hdr[w] &= ~htonl(mask << pos);
76 mask = htonl(mask << pos); 76 m->hdr[w] |= htonl(val);
77 m->hdr[w] &= ~mask;
78 m->hdr[w] |= val;
79} 77}
80 78
81/* 79/*
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 65ebccc0a698..a05c34260e70 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -118,14 +118,40 @@
118 118
119int sysctl_unix_max_dgram_qlen __read_mostly = 10; 119int sysctl_unix_max_dgram_qlen __read_mostly = 10;
120 120
121struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; 121static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
122DEFINE_SPINLOCK(unix_table_lock); 122static DEFINE_SPINLOCK(unix_table_lock);
123static atomic_t unix_nr_socks = ATOMIC_INIT(0); 123static atomic_t unix_nr_socks = ATOMIC_INIT(0);
124 124
125#define unix_sockets_unbound (&unix_socket_table[UNIX_HASH_SIZE]) 125#define unix_sockets_unbound (&unix_socket_table[UNIX_HASH_SIZE])
126 126
127#define UNIX_ABSTRACT(sk) (unix_sk(sk)->addr->hash != UNIX_HASH_SIZE) 127#define UNIX_ABSTRACT(sk) (unix_sk(sk)->addr->hash != UNIX_HASH_SIZE)
128 128
129static struct sock *first_unix_socket(int *i)
130{
131 for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
132 if (!hlist_empty(&unix_socket_table[*i]))
133 return __sk_head(&unix_socket_table[*i]);
134 }
135 return NULL;
136}
137
138static struct sock *next_unix_socket(int *i, struct sock *s)
139{
140 struct sock *next = sk_next(s);
141 /* More in this chain? */
142 if (next)
143 return next;
144 /* Look for next non-empty chain. */
145 for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
146 if (!hlist_empty(&unix_socket_table[*i]))
147 return __sk_head(&unix_socket_table[*i]);
148 }
149 return NULL;
150}
151
152#define forall_unix_sockets(i, s) \
153 for (s = first_unix_socket(&(i)); s; s = next_unix_socket(&(i),(s)))
154
129#ifdef CONFIG_SECURITY_NETWORK 155#ifdef CONFIG_SECURITY_NETWORK
130static void unix_get_secdata(struct scm_cookie *scm, struct sk_buff *skb) 156static void unix_get_secdata(struct scm_cookie *scm, struct sk_buff *skb)
131{ 157{
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index c3a4b0a18687..95a47304336d 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1299,7 +1299,8 @@ xfrm_tmpl_resolve_one(struct xfrm_policy *policy, struct flowi *fl,
1299 xfrm_address_t *local = saddr; 1299 xfrm_address_t *local = saddr;
1300 struct xfrm_tmpl *tmpl = &policy->xfrm_vec[i]; 1300 struct xfrm_tmpl *tmpl = &policy->xfrm_vec[i];
1301 1301
1302 if (tmpl->mode == XFRM_MODE_TUNNEL) { 1302 if (tmpl->mode == XFRM_MODE_TUNNEL ||
1303 tmpl->mode == XFRM_MODE_BEET) {
1303 remote = &tmpl->id.daddr; 1304 remote = &tmpl->id.daddr;
1304 local = &tmpl->saddr; 1305 local = &tmpl->saddr;
1305 family = tmpl->encap_family; 1306 family = tmpl->encap_family;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 38f90ca75b1e..31be405efb55 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -611,7 +611,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
611 selector. 611 selector.
612 */ 612 */
613 if (x->km.state == XFRM_STATE_VALID) { 613 if (x->km.state == XFRM_STATE_VALID) {
614 if (!xfrm_selector_match(&x->sel, fl, family) || 614 if (!xfrm_selector_match(&x->sel, fl, x->sel.family) ||
615 !security_xfrm_state_pol_flow_match(x, pol, fl)) 615 !security_xfrm_state_pol_flow_match(x, pol, fl))
616 continue; 616 continue;
617 if (!best || 617 if (!best ||
@@ -623,7 +623,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
623 acquire_in_progress = 1; 623 acquire_in_progress = 1;
624 } else if (x->km.state == XFRM_STATE_ERROR || 624 } else if (x->km.state == XFRM_STATE_ERROR ||
625 x->km.state == XFRM_STATE_EXPIRED) { 625 x->km.state == XFRM_STATE_EXPIRED) {
626 if (xfrm_selector_match(&x->sel, fl, family) && 626 if (xfrm_selector_match(&x->sel, fl, x->sel.family) &&
627 security_xfrm_state_pol_flow_match(x, pol, fl)) 627 security_xfrm_state_pol_flow_match(x, pol, fl))
628 error = -ESRCH; 628 error = -ESRCH;
629 } 629 }
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index c06883bf620e..61339e17a0f5 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -322,6 +322,13 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
322 x->props.family = p->family; 322 x->props.family = p->family;
323 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr)); 323 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr));
324 x->props.flags = p->flags; 324 x->props.flags = p->flags;
325
326 /*
327 * Set inner address family if the KM left it as zero.
328 * See comment in validate_tmpl.
329 */
330 if (!x->sel.family)
331 x->sel.family = p->family;
325} 332}
326 333
327/* 334/*
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 3f7b451f3955..7fd6055bedfd 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -315,7 +315,7 @@ quiet_cmd_link_multi-y = LD $@
315cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) 315cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)
316 316
317quiet_cmd_link_multi-m = LD [M] $@ 317quiet_cmd_link_multi-m = LD [M] $@
318cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps) 318cmd_link_multi-m = $(cmd_link_multi-y)
319 319
320# We would rather have a list of rules like 320# We would rather have a list of rules like
321# foo.o: $(foo-objs) 321# foo.o: $(foo-objs)
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index c6fcc597b3be..d988f5d21e3d 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -56,23 +56,24 @@ _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
56 56
57# Step 2), invoke modpost 57# Step 2), invoke modpost
58# Includes step 3,4 58# Includes step 3,4
59modpost = scripts/mod/modpost \
60 $(if $(CONFIG_MODVERSIONS),-m) \
61 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
62 $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
63 $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
64 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
65 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
66
59quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules 67quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
60 cmd_modpost = scripts/mod/modpost \ 68 cmd_modpost = $(modpost) -s
61 $(if $(CONFIG_MODVERSIONS),-m) \
62 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
63 $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
64 $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
65 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
66 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
67 69
68PHONY += __modpost 70PHONY += __modpost
69__modpost: $(modules:.ko=.o) FORCE 71__modpost: $(modules:.ko=.o) FORCE
70 $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) 72 $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^)
71 73
72quiet_cmd_kernel-mod = MODPOST $@ 74quiet_cmd_kernel-mod = MODPOST $@
73 cmd_kernel-mod = $(cmd_modpost) $@ 75 cmd_kernel-mod = $(modpost) $@
74 76
75PHONY += vmlinux
76vmlinux.o: FORCE 77vmlinux.o: FORCE
77 $(call cmd,kernel-mod) 78 $(call cmd,kernel-mod)
78 79
@@ -97,7 +98,7 @@ targets += $(modules:.ko=.mod.o)
97 98
98# Step 6), final link of the modules 99# Step 6), final link of the modules
99quiet_cmd_ld_ko_o = LD [M] $@ 100quiet_cmd_ld_ko_o = LD [M] $@
100 cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ 101 cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \
101 $(filter-out FORCE,$^) 102 $(filter-out FORCE,$^)
102 103
103$(modules): %.ko :%.o %.mod.o FORCE 104$(modules): %.ko :%.o %.mod.o FORCE
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 1199baf866ca..8be6a4269e63 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -37,6 +37,14 @@ static struct menu *rootEntry;
37 37
38static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n"); 38static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
39 39
40static const char *get_help(struct menu *menu)
41{
42 if (menu_has_help(menu))
43 return menu_get_help(menu);
44 else
45 return nohelp_text;
46}
47
40static void strip(char *str) 48static void strip(char *str)
41{ 49{
42 char *p = str; 50 char *p = str;
@@ -171,7 +179,7 @@ static void conf_askvalue(struct symbol *sym, const char *def)
171int conf_string(struct menu *menu) 179int conf_string(struct menu *menu)
172{ 180{
173 struct symbol *sym = menu->sym; 181 struct symbol *sym = menu->sym;
174 const char *def, *help; 182 const char *def;
175 183
176 while (1) { 184 while (1) {
177 printf("%*s%s ", indent - 1, "", menu->prompt->text); 185 printf("%*s%s ", indent - 1, "", menu->prompt->text);
@@ -186,10 +194,7 @@ int conf_string(struct menu *menu)
186 case '?': 194 case '?':
187 /* print help */ 195 /* print help */
188 if (line[1] == '\n') { 196 if (line[1] == '\n') {
189 help = nohelp_text; 197 printf("\n%s\n", get_help(menu));
190 if (menu->sym->help)
191 help = menu->sym->help;
192 printf("\n%s\n", menu->sym->help);
193 def = NULL; 198 def = NULL;
194 break; 199 break;
195 } 200 }
@@ -207,7 +212,6 @@ static int conf_sym(struct menu *menu)
207 struct symbol *sym = menu->sym; 212 struct symbol *sym = menu->sym;
208 int type; 213 int type;
209 tristate oldval, newval; 214 tristate oldval, newval;
210 const char *help;
211 215
212 while (1) { 216 while (1) {
213 printf("%*s%s ", indent - 1, "", menu->prompt->text); 217 printf("%*s%s ", indent - 1, "", menu->prompt->text);
@@ -233,7 +237,7 @@ static int conf_sym(struct menu *menu)
233 printf("/m"); 237 printf("/m");
234 if (oldval != yes && sym_tristate_within_range(sym, yes)) 238 if (oldval != yes && sym_tristate_within_range(sym, yes))
235 printf("/y"); 239 printf("/y");
236 if (sym->help) 240 if (menu_has_help(menu))
237 printf("/?"); 241 printf("/?");
238 printf("] "); 242 printf("] ");
239 conf_askvalue(sym, sym_get_string_value(sym)); 243 conf_askvalue(sym, sym_get_string_value(sym));
@@ -269,10 +273,7 @@ static int conf_sym(struct menu *menu)
269 if (sym_set_tristate_value(sym, newval)) 273 if (sym_set_tristate_value(sym, newval))
270 return 0; 274 return 0;
271help: 275help:
272 help = nohelp_text; 276 printf("\n%s\n", get_help(menu));
273 if (sym->help)
274 help = sym->help;
275 printf("\n%s\n", help);
276 } 277 }
277} 278}
278 279
@@ -342,7 +343,7 @@ static int conf_choice(struct menu *menu)
342 goto conf_childs; 343 goto conf_childs;
343 } 344 }
344 printf("[1-%d", cnt); 345 printf("[1-%d", cnt);
345 if (sym->help) 346 if (menu_has_help(menu))
346 printf("?"); 347 printf("?");
347 printf("]: "); 348 printf("]: ");
348 switch (input_mode) { 349 switch (input_mode) {
@@ -359,8 +360,7 @@ static int conf_choice(struct menu *menu)
359 fgets(line, 128, stdin); 360 fgets(line, 128, stdin);
360 strip(line); 361 strip(line);
361 if (line[0] == '?') { 362 if (line[0] == '?') {
362 printf("\n%s\n", menu->sym->help ? 363 printf("\n%s\n", get_help(menu));
363 menu->sym->help : nohelp_text);
364 continue; 364 continue;
365 } 365 }
366 if (!line[0]) 366 if (!line[0])
@@ -391,8 +391,7 @@ static int conf_choice(struct menu *menu)
391 if (!child) 391 if (!child)
392 continue; 392 continue;
393 if (line[strlen(line) - 1] == '?') { 393 if (line[strlen(line) - 1] == '?') {
394 printf("\n%s\n", child->sym->help ? 394 printf("\n%s\n", get_help(child));
395 child->sym->help : nohelp_text);
396 continue; 395 continue;
397 } 396 }
398 sym_set_choice_value(sym, child->sym); 397 sym_set_choice_value(sym, child->sym);
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 6084525f604b..a195986eec6f 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -71,14 +71,12 @@ enum {
71struct symbol { 71struct symbol {
72 struct symbol *next; 72 struct symbol *next;
73 char *name; 73 char *name;
74 char *help;
75 enum symbol_type type; 74 enum symbol_type type;
76 struct symbol_value curr; 75 struct symbol_value curr;
77 struct symbol_value def[4]; 76 struct symbol_value def[4];
78 tristate visible; 77 tristate visible;
79 int flags; 78 int flags;
80 struct property *prop; 79 struct property *prop;
81 struct expr *dep, *dep2;
82 struct expr_value rev_dep; 80 struct expr_value rev_dep;
83}; 81};
84 82
@@ -139,7 +137,7 @@ struct menu {
139 struct property *prompt; 137 struct property *prompt;
140 struct expr *dep; 138 struct expr *dep;
141 unsigned int flags; 139 unsigned int flags;
142 //char *help; 140 char *help;
143 struct file *file; 141 struct file *file;
144 int lineno; 142 int lineno;
145 void *data; 143 void *data;
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 61d8166166ef..262908cfc2ac 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -38,9 +38,6 @@ static gboolean show_all = FALSE;
38static gboolean show_debug = FALSE; 38static gboolean show_debug = FALSE;
39static gboolean resizeable = FALSE; 39static gboolean resizeable = FALSE;
40 40
41static char nohelp_text[] =
42 N_("Sorry, no help available for this option yet.\n");
43
44GtkWidget *main_wnd = NULL; 41GtkWidget *main_wnd = NULL;
45GtkWidget *tree1_w = NULL; // left frame 42GtkWidget *tree1_w = NULL; // left frame
46GtkWidget *tree2_w = NULL; // right frame 43GtkWidget *tree2_w = NULL; // right frame
@@ -462,12 +459,9 @@ static void text_insert_help(struct menu *menu)
462 GtkTextIter start, end; 459 GtkTextIter start, end;
463 const char *prompt = menu_get_prompt(menu); 460 const char *prompt = menu_get_prompt(menu);
464 gchar *name; 461 gchar *name;
465 const char *help = _(nohelp_text); 462 const char *help;
466 463
467 if (!menu->sym) 464 help = _(menu_get_help(menu));
468 help = "";
469 else if (menu->sym->help)
470 help = _(menu->sym->help);
471 465
472 if (menu->sym && menu->sym->name) 466 if (menu->sym && menu->sym->name)
473 name = g_strdup_printf(_(menu->sym->name)); 467 name = g_strdup_printf(_(menu->sym->name));
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c
index 11f7dab94715..6eb72a7f2562 100644
--- a/scripts/kconfig/kxgettext.c
+++ b/scripts/kconfig/kxgettext.c
@@ -170,8 +170,8 @@ void menu_build_message_list(struct menu *menu)
170 menu->file == NULL ? "Root Menu" : menu->file->name, 170 menu->file == NULL ? "Root Menu" : menu->file->name,
171 menu->lineno); 171 menu->lineno);
172 172
173 if (menu->sym != NULL && menu->sym->help != NULL) 173 if (menu->sym != NULL && menu_has_help(menu))
174 message__add(menu->sym->help, menu->sym->name, 174 message__add(menu_get_help(menu), menu->sym->name,
175 menu->file == NULL ? "Root Menu" : menu->file->name, 175 menu->file == NULL ? "Root Menu" : menu->file->name,
176 menu->lineno); 176 menu->lineno);
177 177
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 15030770d1ad..4d09f6ddefe3 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -15,6 +15,8 @@ P(menu_is_visible,bool,(struct menu *menu));
15P(menu_get_prompt,const char *,(struct menu *menu)); 15P(menu_get_prompt,const char *,(struct menu *menu));
16P(menu_get_root_menu,struct menu *,(struct menu *menu)); 16P(menu_get_root_menu,struct menu *,(struct menu *menu));
17P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 17P(menu_get_parent_menu,struct menu *,(struct menu *menu));
18P(menu_has_help,bool,(struct menu *menu));
19P(menu_get_help,const char *,(struct menu *menu));
18 20
19/* symbol.c */ 21/* symbol.c */
20P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); 22P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index d2c2a429887b..bc5854ed6055 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -725,11 +725,11 @@ static void show_help(struct menu *menu)
725 struct gstr help = str_new(); 725 struct gstr help = str_new();
726 struct symbol *sym = menu->sym; 726 struct symbol *sym = menu->sym;
727 727
728 if (sym->help) 728 if (menu_has_help(menu))
729 { 729 {
730 if (sym->name) { 730 if (sym->name) {
731 str_printf(&help, "CONFIG_%s:\n\n", sym->name); 731 str_printf(&help, "CONFIG_%s:\n\n", sym->name);
732 str_append(&help, _(sym->help)); 732 str_append(&help, _(menu_get_help(menu)));
733 str_append(&help, "\n"); 733 str_append(&help, "\n");
734 } 734 }
735 } else { 735 } else {
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index f14aeac67d4f..f9d0d91a3fe4 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -417,3 +417,15 @@ struct menu *menu_get_parent_menu(struct menu *menu)
417 return menu; 417 return menu;
418} 418}
419 419
420bool menu_has_help(struct menu *menu)
421{
422 return menu->help != NULL;
423}
424
425const char *menu_get_help(struct menu *menu)
426{
427 if (menu->help)
428 return menu->help;
429 else
430 return "";
431}
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index f2a23a9c3938..e4eeb59a8c24 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1041,7 +1041,7 @@ void ConfigInfoView::menuInfo(void)
1041 if (showDebug()) 1041 if (showDebug())
1042 debug = debug_info(sym); 1042 debug = debug_info(sym);
1043 1043
1044 help = print_filter(_(sym->help)); 1044 help = print_filter(_(menu_get_help(menu)));
1045 } else if (menu->prompt) { 1045 } else if (menu->prompt) {
1046 head += "<big><b>"; 1046 head += "<big><b>";
1047 head += print_filter(_(menu->prompt->text)); 1047 head += print_filter(_(menu->prompt->text));
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index 9a06b6771eee..ec21db77f78b 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -1722,7 +1722,7 @@ yyreduce:
1722 case 83: 1722 case 83:
1723 1723
1724 { 1724 {
1725 current_entry->sym->help = (yyvsp[0].string); 1725 current_entry->help = (yyvsp[0].string);
1726;} 1726;}
1727 break; 1727 break;
1728 1728
@@ -2280,11 +2280,11 @@ void print_symbol(FILE *out, struct menu *menu)
2280 break; 2280 break;
2281 } 2281 }
2282 } 2282 }
2283 if (sym->help) { 2283 if (menu->help) {
2284 int len = strlen(sym->help); 2284 int len = strlen(menu->help);
2285 while (sym->help[--len] == '\n') 2285 while (menu->help[--len] == '\n')
2286 sym->help[len] = 0; 2286 menu->help[len] = 0;
2287 fprintf(out, " help\n%s\n", sym->help); 2287 fprintf(out, " help\n%s\n", menu->help);
2288 } 2288 }
2289 fputc('\n', out); 2289 fputc('\n', out);
2290} 2290}
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 92eb02bdf9c5..79db4cf22a51 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -402,7 +402,7 @@ help_start: T_HELP T_EOL
402 402
403help: help_start T_HELPTEXT 403help: help_start T_HELPTEXT
404{ 404{
405 current_entry->sym->help = $2; 405 current_entry->help = $2;
406}; 406};
407 407
408/* depends option */ 408/* depends option */
@@ -649,11 +649,11 @@ void print_symbol(FILE *out, struct menu *menu)
649 break; 649 break;
650 } 650 }
651 } 651 }
652 if (sym->help) { 652 if (menu->help) {
653 int len = strlen(sym->help); 653 int len = strlen(menu->help);
654 while (sym->help[--len] == '\n') 654 while (menu->help[--len] == '\n')
655 sym->help[len] = 0; 655 menu->help[len] = 0;
656 fprintf(out, " help\n%s\n", sym->help); 656 fprintf(out, " help\n%s\n", menu->help);
657 } 657 }
658 fputc('\n', out); 658 fputc('\n', out);
659} 659}
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index f646381dc015..8a09021d8c59 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -290,6 +290,14 @@ static int do_serio_entry(const char *filename,
290 return 1; 290 return 1;
291} 291}
292 292
293/* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */
294static int do_acpi_entry(const char *filename,
295 struct acpi_device_id *id, char *alias)
296{
297 sprintf(alias, "acpi*:%s:", id->id);
298 return 1;
299}
300
293/* looks like: "pnp:dD" */ 301/* looks like: "pnp:dD" */
294static int do_pnp_entry(const char *filename, 302static int do_pnp_entry(const char *filename,
295 struct pnp_device_id *id, char *alias) 303 struct pnp_device_id *id, char *alias)
@@ -551,6 +559,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
551 do_table(symval, sym->st_size, 559 do_table(symval, sym->st_size,
552 sizeof(struct serio_device_id), "serio", 560 sizeof(struct serio_device_id), "serio",
553 do_serio_entry, mod); 561 do_serio_entry, mod);
562 else if (sym_is(symname, "__mod_acpi_device_table"))
563 do_table(symval, sym->st_size,
564 sizeof(struct acpi_device_id), "acpi",
565 do_acpi_entry, mod);
554 else if (sym_is(symname, "__mod_pnp_device_table")) 566 else if (sym_is(symname, "__mod_pnp_device_table"))
555 do_table(symval, sym->st_size, 567 do_table(symval, sym->st_size,
556 sizeof(struct pnp_device_id), "pnp", 568 sizeof(struct pnp_device_id), "pnp",
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 5ab7914d30ef..6c145d6e89de 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -23,6 +23,8 @@ int have_vmlinux = 0;
23static int all_versions = 0; 23static int all_versions = 0;
24/* If we are modposting external module set to 1 */ 24/* If we are modposting external module set to 1 */
25static int external_module = 0; 25static int external_module = 0;
26/* Warn about section mismatch in vmlinux if set to 1 */
27static int vmlinux_section_warnings = 1;
26/* Only warn about unresolved symbols */ 28/* Only warn about unresolved symbols */
27static int warn_unresolved = 0; 29static int warn_unresolved = 0;
28/* How a symbol is exported */ 30/* How a symbol is exported */
@@ -584,13 +586,61 @@ static int strrcmp(const char *s, const char *sub)
584 return memcmp(s + slen - sublen, sub, sublen); 586 return memcmp(s + slen - sublen, sub, sublen);
585} 587}
586 588
589/*
590 * Functions used only during module init is marked __init and is stored in
591 * a .init.text section. Likewise data is marked __initdata and stored in
592 * a .init.data section.
593 * If this section is one of these sections return 1
594 * See include/linux/init.h for the details
595 */
596static int init_section(const char *name)
597{
598 if (strcmp(name, ".init") == 0)
599 return 1;
600 if (strncmp(name, ".init.", strlen(".init.")) == 0)
601 return 1;
602 return 0;
603}
604
605/*
606 * Functions used only during module exit is marked __exit and is stored in
607 * a .exit.text section. Likewise data is marked __exitdata and stored in
608 * a .exit.data section.
609 * If this section is one of these sections return 1
610 * See include/linux/init.h for the details
611 **/
612static int exit_section(const char *name)
613{
614 if (strcmp(name, ".exit.text") == 0)
615 return 1;
616 if (strcmp(name, ".exit.data") == 0)
617 return 1;
618 return 0;
619
620}
621
622/*
623 * Data sections are named like this:
624 * .data | .data.rel | .data.rel.*
625 * Return 1 if the specified section is a data section
626 */
627static int data_section(const char *name)
628{
629 if ((strcmp(name, ".data") == 0) ||
630 (strcmp(name, ".data.rel") == 0) ||
631 (strncmp(name, ".data.rel.", strlen(".data.rel.")) == 0))
632 return 1;
633 else
634 return 0;
635}
636
587/** 637/**
588 * Whitelist to allow certain references to pass with no warning. 638 * Whitelist to allow certain references to pass with no warning.
589 * 639 *
590 * Pattern 0: 640 * Pattern 0:
591 * Do not warn if funtion/data are marked with __init_refok/__initdata_refok. 641 * Do not warn if funtion/data are marked with __init_refok/__initdata_refok.
592 * The pattern is identified by: 642 * The pattern is identified by:
593 * fromsec = .text.init.refok | .data.init.refok 643 * fromsec = .text.init.refok* | .data.init.refok*
594 * 644 *
595 * Pattern 1: 645 * Pattern 1:
596 * If a module parameter is declared __initdata and permissions=0 646 * If a module parameter is declared __initdata and permissions=0
@@ -608,8 +658,8 @@ static int strrcmp(const char *s, const char *sub)
608 * These functions may often be marked __init and we do not want to 658 * These functions may often be marked __init and we do not want to
609 * warn here. 659 * warn here.
610 * the pattern is identified by: 660 * the pattern is identified by:
611 * tosec = .init.text | .exit.text | .init.data 661 * tosec = init or exit section
612 * fromsec = .data | .data.rel | .data.rel.* 662 * fromsec = data section
613 * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer 663 * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer
614 * 664 *
615 * Pattern 3: 665 * Pattern 3:
@@ -625,12 +675,18 @@ static int strrcmp(const char *s, const char *sub)
625 * This pattern is identified by 675 * This pattern is identified by
626 * refsymname = __init_begin, _sinittext, _einittext 676 * refsymname = __init_begin, _sinittext, _einittext
627 * 677 *
678 * Pattern 5:
679 * Xtensa uses literal sections for constants that are accessed PC-relative.
680 * Literal sections may safely reference their text sections.
681 * (Note that the name for the literal section omits any trailing '.text')
682 * tosec = <section>[.text]
683 * fromsec = <section>.literal
628 **/ 684 **/
629static int secref_whitelist(const char *modname, const char *tosec, 685static int secref_whitelist(const char *modname, const char *tosec,
630 const char *fromsec, const char *atsym, 686 const char *fromsec, const char *atsym,
631 const char *refsymname) 687 const char *refsymname)
632{ 688{
633 int f1 = 1, f2 = 1; 689 int len;
634 const char **s; 690 const char **s;
635 const char *pat2sym[] = { 691 const char *pat2sym[] = {
636 "driver", 692 "driver",
@@ -652,36 +708,21 @@ static int secref_whitelist(const char *modname, const char *tosec,
652 }; 708 };
653 709
654 /* Check for pattern 0 */ 710 /* Check for pattern 0 */
655 if ((strcmp(fromsec, ".text.init.refok") == 0) || 711 if ((strncmp(fromsec, ".text.init.refok", strlen(".text.init.refok")) == 0) ||
656 (strcmp(fromsec, ".data.init.refok") == 0)) 712 (strncmp(fromsec, ".data.init.refok", strlen(".data.init.refok")) == 0))
657 return 1; 713 return 1;
658 714
659 /* Check for pattern 1 */ 715 /* Check for pattern 1 */
660 if (strcmp(tosec, ".init.data") != 0) 716 if ((strcmp(tosec, ".init.data") == 0) &&
661 f1 = 0; 717 (strncmp(fromsec, ".data", strlen(".data")) == 0) &&
662 if (strncmp(fromsec, ".data", strlen(".data")) != 0) 718 (strncmp(atsym, "__param", strlen("__param")) == 0))
663 f1 = 0; 719 return 1;
664 if (strncmp(atsym, "__param", strlen("__param")) != 0)
665 f1 = 0;
666
667 if (f1)
668 return f1;
669 720
670 /* Check for pattern 2 */ 721 /* Check for pattern 2 */
671 if ((strcmp(tosec, ".init.text") != 0) && 722 if ((init_section(tosec) || exit_section(tosec)) && data_section(fromsec))
672 (strcmp(tosec, ".exit.text") != 0) && 723 for (s = pat2sym; *s; s++)
673 (strcmp(tosec, ".init.data") != 0)) 724 if (strrcmp(atsym, *s) == 0)
674 f2 = 0; 725 return 1;
675 if ((strcmp(fromsec, ".data") != 0) &&
676 (strcmp(fromsec, ".data.rel") != 0) &&
677 (strncmp(fromsec, ".data.rel.", strlen(".data.rel.")) != 0))
678 f2 = 0;
679
680 for (s = pat2sym; *s; s++)
681 if (strrcmp(atsym, *s) == 0)
682 f1 = 1;
683 if (f1 && f2)
684 return 1;
685 726
686 /* Check for pattern 3 */ 727 /* Check for pattern 3 */
687 if ((strcmp(fromsec, ".text.head") == 0) && 728 if ((strcmp(fromsec, ".text.head") == 0) &&
@@ -694,6 +735,15 @@ static int secref_whitelist(const char *modname, const char *tosec,
694 if (strcmp(refsymname, *s) == 0) 735 if (strcmp(refsymname, *s) == 0)
695 return 1; 736 return 1;
696 737
738 /* Check for pattern 5 */
739 if (strrcmp(tosec, ".text") == 0)
740 len = strlen(tosec) - strlen(".text");
741 else
742 len = strlen(tosec);
743 if ((strncmp(tosec, fromsec, len) == 0) && (strlen(fromsec) > len) &&
744 (strcmp(fromsec + len, ".literal") == 0))
745 return 1;
746
697 return 0; 747 return 0;
698} 748}
699 749
@@ -822,9 +872,9 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec,
822 refsymname = elf->strtab + refsym->st_name; 872 refsymname = elf->strtab + refsym->st_name;
823 873
824 /* check whitelist - we may ignore it */ 874 /* check whitelist - we may ignore it */
825 if (before && 875 if (secref_whitelist(modname, secname, fromsec,
826 secref_whitelist(modname, secname, fromsec, 876 before ? elf->strtab + before->st_name : "",
827 elf->strtab + before->st_name, refsymname)) 877 refsymname))
828 return; 878 return;
829 879
830 if (before && after) { 880 if (before && after) {
@@ -1071,12 +1121,15 @@ static int initexit_section_ref_ok(const char *name)
1071 ".machvec", /* ia64 + powerpc uses these */ 1121 ".machvec", /* ia64 + powerpc uses these */
1072 ".machine.desc", 1122 ".machine.desc",
1073 ".opd", /* See comment [OPD] */ 1123 ".opd", /* See comment [OPD] */
1124 "__dbe_table",
1074 ".parainstructions", 1125 ".parainstructions",
1075 ".pdr", 1126 ".pdr",
1076 ".plt", /* seen on ARCH=um build on x86_64. Harmless */ 1127 ".plt", /* seen on ARCH=um build on x86_64. Harmless */
1077 ".smp_locks", 1128 ".smp_locks",
1078 ".stab", 1129 ".stab",
1079 ".m68k_fixup", 1130 ".m68k_fixup",
1131 ".xt.prop", /* xtensa informational section */
1132 ".xt.lit", /* xtensa informational section */
1080 NULL 1133 NULL
1081 }; 1134 };
1082 /* Start of section names */ 1135 /* Start of section names */
@@ -1106,21 +1159,6 @@ static int initexit_section_ref_ok(const char *name)
1106 return 0; 1159 return 0;
1107} 1160}
1108 1161
1109/**
1110 * Functions used only during module init is marked __init and is stored in
1111 * a .init.text section. Likewise data is marked __initdata and stored in
1112 * a .init.data section.
1113 * If this section is one of these sections return 1
1114 * See include/linux/init.h for the details
1115 **/
1116static int init_section(const char *name)
1117{
1118 if (strcmp(name, ".init") == 0)
1119 return 1;
1120 if (strncmp(name, ".init.", strlen(".init.")) == 0)
1121 return 1;
1122 return 0;
1123}
1124 1162
1125/* 1163/*
1126 * Identify sections from which references to a .init section is OK. 1164 * Identify sections from which references to a .init section is OK.
@@ -1178,23 +1216,6 @@ static int init_section_ref_ok(const char *name)
1178} 1216}
1179 1217
1180/* 1218/*
1181 * Functions used only during module exit is marked __exit and is stored in
1182 * a .exit.text section. Likewise data is marked __exitdata and stored in
1183 * a .exit.data section.
1184 * If this section is one of these sections return 1
1185 * See include/linux/init.h for the details
1186 **/
1187static int exit_section(const char *name)
1188{
1189 if (strcmp(name, ".exit.text") == 0)
1190 return 1;
1191 if (strcmp(name, ".exit.data") == 0)
1192 return 1;
1193 return 0;
1194
1195}
1196
1197/*
1198 * Identify sections from which references to a .exit section is OK. 1219 * Identify sections from which references to a .exit section is OK.
1199 */ 1220 */
1200static int exit_section_ref_ok(const char *name) 1221static int exit_section_ref_ok(const char *name)
@@ -1257,8 +1278,10 @@ static void read_symbols(char *modname)
1257 handle_modversions(mod, &info, sym, symname); 1278 handle_modversions(mod, &info, sym, symname);
1258 handle_moddevtable(mod, &info, sym, symname); 1279 handle_moddevtable(mod, &info, sym, symname);
1259 } 1280 }
1260 check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok); 1281 if (is_vmlinux(modname) && vmlinux_section_warnings) {
1261 check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok); 1282 check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok);
1283 check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok);
1284 }
1262 1285
1263 version = get_modinfo(info.modinfo, info.modinfo_len, "version"); 1286 version = get_modinfo(info.modinfo, info.modinfo_len, "version");
1264 if (version) 1287 if (version)
@@ -1626,7 +1649,7 @@ int main(int argc, char **argv)
1626 int opt; 1649 int opt;
1627 int err; 1650 int err;
1628 1651
1629 while ((opt = getopt(argc, argv, "i:I:mo:aw")) != -1) { 1652 while ((opt = getopt(argc, argv, "i:I:mso:aw")) != -1) {
1630 switch(opt) { 1653 switch(opt) {
1631 case 'i': 1654 case 'i':
1632 kernel_read = optarg; 1655 kernel_read = optarg;
@@ -1644,6 +1667,9 @@ int main(int argc, char **argv)
1644 case 'a': 1667 case 'a':
1645 all_versions = 1; 1668 all_versions = 1;
1646 break; 1669 break;
1670 case 's':
1671 vmlinux_section_warnings = 0;
1672 break;
1647 case 'w': 1673 case 'w':
1648 warn_unresolved = 1; 1674 warn_unresolved = 1;
1649 break; 1675 break;
diff --git a/scripts/ver_linux b/scripts/ver_linux
index 72876dfadc8a..8f8df93141a9 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -66,8 +66,8 @@ showmount --version 2>&1 | grep nfs-utils | awk \
66'NR==1{print "nfs-utils ", $NF}' 66'NR==1{print "nfs-utils ", $NF}'
67 67
68ls -l `ldd /bin/sh | awk '/libc/{print $3}'` | sed \ 68ls -l `ldd /bin/sh | awk '/libc/{print $3}'` | sed \
69-e 's/\.so$//' | awk -F'[.-]' '{print "Linux C Library " \ 69-e 's/\.so$//' | sed -e 's/>//' | \
70$(NF-2)"."$(NF-1)"."$NF}' 70awk -F'[.-]' '{print "Linux C Library "$(NF-1)"."$NF}'
71 71
72ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \ 72ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \
73'NR==1{print "Dynamic linker (ldd) ", $NF}' 73'NR==1{print "Dynamic linker (ldd) ", $NF}'
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index b5f017f07a75..f00161ef99ed 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -792,7 +792,7 @@ int security_context_to_sid(char *scontext, u32 scontext_len, u32 *sid)
792 * @scontext: security context 792 * @scontext: security context
793 * @scontext_len: length in bytes 793 * @scontext_len: length in bytes
794 * @sid: security identifier, SID 794 * @sid: security identifier, SID
795 * @def_sid: default SID to assign on errror 795 * @def_sid: default SID to assign on error
796 * 796 *
797 * Obtains a SID associated with the security context that 797 * Obtains a SID associated with the security context that
798 * has the string representation specified by @scontext. 798 * has the string representation specified by @scontext.
@@ -2417,8 +2417,10 @@ static void security_netlbl_cache_add(struct netlbl_lsm_secattr *secattr,
2417 2417
2418 cache->type = NETLBL_CACHE_T_MLS; 2418 cache->type = NETLBL_CACHE_T_MLS;
2419 if (ebitmap_cpy(&cache->data.mls_label.level[0].cat, 2419 if (ebitmap_cpy(&cache->data.mls_label.level[0].cat,
2420 &ctx->range.level[0].cat) != 0) 2420 &ctx->range.level[0].cat) != 0) {
2421 kfree(cache);
2421 return; 2422 return;
2423 }
2422 cache->data.mls_label.level[1].cat.highbit = 2424 cache->data.mls_label.level[1].cat.highbit =
2423 cache->data.mls_label.level[0].cat.highbit; 2425 cache->data.mls_label.level[0].cat.highbit;
2424 cache->data.mls_label.level[1].cat.node = 2426 cache->data.mls_label.level[1].cat.node =
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index bd8d1ef40a90..ba715f40b658 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -216,7 +216,7 @@ static int selinux_xfrm_sec_ctx_alloc(struct xfrm_sec_ctx **ctxp,
216 return -ENOMEM; 216 return -ENOMEM;
217 217
218 *ctxp = ctx = kmalloc(sizeof(*ctx) + 218 *ctxp = ctx = kmalloc(sizeof(*ctx) +
219 uctx->ctx_len, 219 uctx->ctx_len + 1,
220 GFP_KERNEL); 220 GFP_KERNEL);
221 221
222 if (!ctx) 222 if (!ctx)
@@ -229,6 +229,7 @@ static int selinux_xfrm_sec_ctx_alloc(struct xfrm_sec_ctx **ctxp,
229 memcpy(ctx->ctx_str, 229 memcpy(ctx->ctx_str,
230 uctx+1, 230 uctx+1,
231 ctx->ctx_len); 231 ctx->ctx_len);
232 ctx->ctx_str[ctx->ctx_len] = 0;
232 rc = security_context_to_sid(ctx->ctx_str, 233 rc = security_context_to_sid(ctx->ctx_str,
233 ctx->ctx_len, 234 ctx->ctx_len,
234 &ctx->ctx_sid); 235 &ctx->ctx_sid);
diff --git a/sound/oss/Kconfig b/sound/oss/Kconfig
index 866d4de8d4ab..af37cd09bddd 100644
--- a/sound/oss/Kconfig
+++ b/sound/oss/Kconfig
@@ -31,14 +31,6 @@ config SOUND_HAL2
31 Say Y or M if you have an SGI Indy or Indigo2 system and want to be able to 31 Say Y or M if you have an SGI Indy or Indigo2 system and want to be able to
32 use its on-board A2 audio system. 32 use its on-board A2 audio system.
33 33
34config SOUND_VRC5477
35 tristate "NEC Vrc5477 AC97 sound"
36 depends on SOUND_PRIME && DDB5477
37 help
38 Say Y here to enable sound support for the NEC Vrc5477 chip, an
39 integrated, multi-function controller chip for MIPS CPUs. Works
40 with the AC97 codec.
41
42config SOUND_AU1550_AC97 34config SOUND_AU1550_AC97
43 tristate "Au1550/Au1200 AC97 Sound" 35 tristate "Au1550/Au1200 AC97 Sound"
44 select SND_AC97_CODEC 36 select SND_AC97_CODEC
diff --git a/sound/oss/Makefile b/sound/oss/Makefile
index 7a2f9ae7b7c5..1200670017bd 100644
--- a/sound/oss/Makefile
+++ b/sound/oss/Makefile
@@ -37,7 +37,6 @@ obj-$(CONFIG_SOUND_MSNDPIN) += msnd.o msnd_pinnacle.o
37obj-$(CONFIG_SOUND_VWSND) += vwsnd.o 37obj-$(CONFIG_SOUND_VWSND) += vwsnd.o
38obj-$(CONFIG_SOUND_ICH) += i810_audio.o ac97_codec.o 38obj-$(CONFIG_SOUND_ICH) += i810_audio.o ac97_codec.o
39obj-$(CONFIG_SOUND_ES1371) += es1371.o ac97_codec.o 39obj-$(CONFIG_SOUND_ES1371) += es1371.o ac97_codec.o
40obj-$(CONFIG_SOUND_VRC5477) += nec_vrc5477.o ac97_codec.o
41obj-$(CONFIG_SOUND_AU1550_AC97) += au1550_ac97.o ac97_codec.o 40obj-$(CONFIG_SOUND_AU1550_AC97) += au1550_ac97.o ac97_codec.o
42obj-$(CONFIG_SOUND_TRIDENT) += trident.o ac97_codec.o 41obj-$(CONFIG_SOUND_TRIDENT) += trident.o ac97_codec.o
43obj-$(CONFIG_SOUND_BCM_CS4297A) += swarm_cs4297a.o 42obj-$(CONFIG_SOUND_BCM_CS4297A) += swarm_cs4297a.o
diff --git a/sound/oss/nec_vrc5477.c b/sound/oss/nec_vrc5477.c
deleted file mode 100644
index 27b4ba3aaa7c..000000000000
--- a/sound/oss/nec_vrc5477.c
+++ /dev/null
@@ -1,2060 +0,0 @@
1/***********************************************************************
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
4 *
5 * drivers/sound/nec_vrc5477.c
6 * AC97 sound dirver for NEC Vrc5477 chip (an integrated,
7 * multi-function controller chip for MIPS CPUs)
8 *
9 * VRA support Copyright 2001 Bradley D. LaRonde <brad@ltc.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 ***********************************************************************
16 */
17
18/*
19 * This code is derived from ite8172.c, which is written by Steve Longerbeam.
20 *
21 * Features:
22 * Currently we only support the following capabilities:
23 * . mono output to PCM L/R (line out).
24 * . stereo output to PCM L/R (line out).
25 * . mono input from PCM L (line in).
26 * . stereo output from PCM (line in).
27 * . sampling rate at 48k or variable sampling rate
28 * . support /dev/dsp, /dev/mixer devices, standard OSS devices.
29 * . only support 16-bit PCM format (hardware limit, no software
30 * translation)
31 * . support duplex, but no trigger or realtime.
32 *
33 * Specifically the following are not supported:
34 * . app-set frag size.
35 * . mmap'ed buffer access
36 */
37
38/*
39 * Original comments from ite8172.c file.
40 */
41
42/*
43 *
44 * Notes:
45 *
46 * 1. Much of the OSS buffer allocation, ioctl's, and mmap'ing are
47 * taken, slightly modified or not at all, from the ES1371 driver,
48 * so refer to the credits in es1371.c for those. The rest of the
49 * code (probe, open, read, write, the ISR, etc.) is new.
50 * 2. The following support is untested:
51 * * Memory mapping the audio buffers, and the ioctl controls that go
52 * with it.
53 * * S/PDIF output.
54 * 3. The following is not supported:
55 * * I2S input.
56 * * legacy audio mode.
57 * 4. Support for volume button interrupts is implemented but doesn't
58 * work yet.
59 *
60 * Revision history
61 * 02.08.2001 0.1 Initial release
62 */
63
64#include <linux/module.h>
65#include <linux/string.h>
66#include <linux/kernel.h>
67#include <linux/ioport.h>
68#include <linux/sched.h>
69#include <linux/delay.h>
70#include <linux/sound.h>
71#include <linux/slab.h>
72#include <linux/soundcard.h>
73#include <linux/pci.h>
74#include <linux/init.h>
75#include <linux/poll.h>
76#include <linux/bitops.h>
77#include <linux/proc_fs.h>
78#include <linux/spinlock.h>
79#include <linux/smp_lock.h>
80#include <linux/ac97_codec.h>
81#include <linux/mutex.h>
82
83#include <asm/io.h>
84#include <asm/dma.h>
85#include <asm/uaccess.h>
86
87/* -------------------debug macros -------------------------------------- */
88/* #undef VRC5477_AC97_DEBUG */
89#define VRC5477_AC97_DEBUG
90
91#undef VRC5477_AC97_VERBOSE_DEBUG
92/* #define VRC5477_AC97_VERBOSE_DEBUG */
93
94#if defined(VRC5477_AC97_VERBOSE_DEBUG)
95#define VRC5477_AC97_DEBUG
96#endif
97
98#if defined(VRC5477_AC97_DEBUG)
99#define ASSERT(x) if (!(x)) { \
100 panic("assertion failed at %s:%d: %s\n", __FILE__, __LINE__, #x); }
101#else
102#define ASSERT(x)
103#endif /* VRC5477_AC97_DEBUG */
104
105#if defined(VRC5477_AC97_VERBOSE_DEBUG)
106static u16 inTicket; /* check sync between intr & write */
107static u16 outTicket;
108#endif
109
110/* --------------------------------------------------------------------- */
111
112#undef OSS_DOCUMENTED_MIXER_SEMANTICS
113
114static const unsigned sample_shift[] = { 0, 1, 1, 2 };
115
116#define VRC5477_INT_CLR 0x0
117#define VRC5477_INT_STATUS 0x0
118#define VRC5477_CODEC_WR 0x4
119#define VRC5477_CODEC_RD 0x8
120#define VRC5477_CTRL 0x18
121#define VRC5477_ACLINK_CTRL 0x1c
122#define VRC5477_INT_MASK 0x24
123
124#define VRC5477_DAC1_CTRL 0x30
125#define VRC5477_DAC1L 0x34
126#define VRC5477_DAC1_BADDR 0x38
127#define VRC5477_DAC2_CTRL 0x3c
128#define VRC5477_DAC2L 0x40
129#define VRC5477_DAC2_BADDR 0x44
130#define VRC5477_DAC3_CTRL 0x48
131#define VRC5477_DAC3L 0x4c
132#define VRC5477_DAC3_BADDR 0x50
133
134#define VRC5477_ADC1_CTRL 0x54
135#define VRC5477_ADC1L 0x58
136#define VRC5477_ADC1_BADDR 0x5c
137#define VRC5477_ADC2_CTRL 0x60
138#define VRC5477_ADC2L 0x64
139#define VRC5477_ADC2_BADDR 0x68
140#define VRC5477_ADC3_CTRL 0x6c
141#define VRC5477_ADC3L 0x70
142#define VRC5477_ADC3_BADDR 0x74
143
144#define VRC5477_CODEC_WR_RWC (1 << 23)
145
146#define VRC5477_CODEC_RD_RRDYA (1 << 31)
147#define VRC5477_CODEC_RD_RRDYD (1 << 30)
148
149#define VRC5477_ACLINK_CTRL_RST_ON (1 << 15)
150#define VRC5477_ACLINK_CTRL_RST_TIME 0x7f
151#define VRC5477_ACLINK_CTRL_SYNC_ON (1 << 30)
152#define VRC5477_ACLINK_CTRL_CK_STOP_ON (1 << 31)
153
154#define VRC5477_CTRL_DAC2ENB (1 << 15)
155#define VRC5477_CTRL_ADC2ENB (1 << 14)
156#define VRC5477_CTRL_DAC1ENB (1 << 13)
157#define VRC5477_CTRL_ADC1ENB (1 << 12)
158
159#define VRC5477_INT_MASK_NMASK (1 << 31)
160#define VRC5477_INT_MASK_DAC1END (1 << 5)
161#define VRC5477_INT_MASK_DAC2END (1 << 4)
162#define VRC5477_INT_MASK_DAC3END (1 << 3)
163#define VRC5477_INT_MASK_ADC1END (1 << 2)
164#define VRC5477_INT_MASK_ADC2END (1 << 1)
165#define VRC5477_INT_MASK_ADC3END (1 << 0)
166
167#define VRC5477_DMA_ACTIVATION (1 << 31)
168#define VRC5477_DMA_WIP (1 << 30)
169
170
171#define VRC5477_AC97_MODULE_NAME "NEC_Vrc5477_audio"
172#define PFX VRC5477_AC97_MODULE_NAME ": "
173
174/* --------------------------------------------------------------------- */
175
176struct vrc5477_ac97_state {
177 /* list of vrc5477_ac97 devices */
178 struct list_head devs;
179
180 /* the corresponding pci_dev structure */
181 struct pci_dev *dev;
182
183 /* soundcore stuff */
184 int dev_audio;
185
186 /* hardware resources */
187 unsigned long io;
188 unsigned int irq;
189
190#ifdef VRC5477_AC97_DEBUG
191 /* debug /proc entry */
192 struct proc_dir_entry *ps;
193 struct proc_dir_entry *ac97_ps;
194#endif /* VRC5477_AC97_DEBUG */
195
196 struct ac97_codec *codec;
197
198 unsigned dacChannels, adcChannels;
199 unsigned short dacRate, adcRate;
200 unsigned short extended_status;
201
202 spinlock_t lock;
203 struct mutex open_mutex;
204 mode_t open_mode;
205 wait_queue_head_t open_wait;
206
207 struct dmabuf {
208 void *lbuf, *rbuf;
209 dma_addr_t lbufDma, rbufDma;
210 unsigned bufOrder;
211 unsigned numFrag;
212 unsigned fragShift;
213 unsigned fragSize; /* redundant */
214 unsigned fragTotalSize; /* = numFrag * fragSize(real) */
215 unsigned nextIn;
216 unsigned nextOut;
217 int count;
218 unsigned error; /* over/underrun */
219 wait_queue_head_t wait;
220 /* OSS stuff */
221 unsigned stopped:1;
222 unsigned ready:1;
223 } dma_dac, dma_adc;
224
225 #define WORK_BUF_SIZE 2048
226 struct {
227 u16 lchannel;
228 u16 rchannel;
229 } workBuf[WORK_BUF_SIZE/4];
230};
231
232/* --------------------------------------------------------------------- */
233
234static LIST_HEAD(devs);
235
236/* --------------------------------------------------------------------- */
237
238static inline unsigned ld2(unsigned int x)
239{
240 unsigned r = 0;
241
242 if (x >= 0x10000) {
243 x >>= 16;
244 r += 16;
245 }
246 if (x >= 0x100) {
247 x >>= 8;
248 r += 8;
249 }
250 if (x >= 0x10) {
251 x >>= 4;
252 r += 4;
253 }
254 if (x >= 4) {
255 x >>= 2;
256 r += 2;
257 }
258 if (x >= 2)
259 r++;
260 return r;
261}
262
263/* --------------------------------------------------------------------- */
264
265static u16 rdcodec(struct ac97_codec *codec, u8 addr)
266{
267 struct vrc5477_ac97_state *s =
268 (struct vrc5477_ac97_state *)codec->private_data;
269 unsigned long flags;
270 u32 result;
271
272 spin_lock_irqsave(&s->lock, flags);
273
274 /* wait until we can access codec registers */
275 while (inl(s->io + VRC5477_CODEC_WR) & 0x80000000);
276
277 /* write the address and "read" command to codec */
278 addr = addr & 0x7f;
279 outl((addr << 16) | VRC5477_CODEC_WR_RWC, s->io + VRC5477_CODEC_WR);
280
281 /* get the return result */
282 udelay(100); /* workaround hardware bug */
283 while ( (result = inl(s->io + VRC5477_CODEC_RD)) &
284 (VRC5477_CODEC_RD_RRDYA | VRC5477_CODEC_RD_RRDYD) ) {
285 /* we get either addr or data, or both */
286 if (result & VRC5477_CODEC_RD_RRDYA) {
287 ASSERT(addr == ((result >> 16) & 0x7f) );
288 }
289 if (result & VRC5477_CODEC_RD_RRDYD) {
290 break;
291 }
292 }
293
294 spin_unlock_irqrestore(&s->lock, flags);
295
296 return result & 0xffff;
297}
298
299
300static void wrcodec(struct ac97_codec *codec, u8 addr, u16 data)
301{
302 struct vrc5477_ac97_state *s =
303 (struct vrc5477_ac97_state *)codec->private_data;
304 unsigned long flags;
305
306 spin_lock_irqsave(&s->lock, flags);
307
308 /* wait until we can access codec registers */
309 while (inl(s->io + VRC5477_CODEC_WR) & 0x80000000);
310
311 /* write the address and value to codec */
312 outl((addr << 16) | data, s->io + VRC5477_CODEC_WR);
313
314 spin_unlock_irqrestore(&s->lock, flags);
315}
316
317
318static void waitcodec(struct ac97_codec *codec)
319{
320 struct vrc5477_ac97_state *s =
321 (struct vrc5477_ac97_state *)codec->private_data;
322
323 /* wait until we can access codec registers */
324 while (inl(s->io + VRC5477_CODEC_WR) & 0x80000000);
325}
326
327static int ac97_codec_not_present(struct ac97_codec *codec)
328{
329 struct vrc5477_ac97_state *s =
330 (struct vrc5477_ac97_state *)codec->private_data;
331 unsigned long flags;
332 unsigned short count = 0xffff;
333
334 spin_lock_irqsave(&s->lock, flags);
335
336 /* wait until we can access codec registers */
337 do {
338 if (!(inl(s->io + VRC5477_CODEC_WR) & 0x80000000))
339 break;
340 } while (--count);
341
342 if (count == 0) {
343 spin_unlock_irqrestore(&s->lock, flags);
344 return -1;
345 }
346
347 /* write 0 to reset */
348 outl((AC97_RESET << 16) | 0, s->io + VRC5477_CODEC_WR);
349
350 /* test whether we get a response from ac97 chip */
351 count = 0xffff;
352 do {
353 if (!(inl(s->io + VRC5477_CODEC_WR) & 0x80000000))
354 break;
355 } while (--count);
356
357 if (count == 0) {
358 spin_unlock_irqrestore(&s->lock, flags);
359 return -1;
360 }
361 spin_unlock_irqrestore(&s->lock, flags);
362 return 0;
363}
364
365/* --------------------------------------------------------------------- */
366
367static void vrc5477_ac97_delay(int msec)
368{
369 unsigned long tmo;
370 signed long tmo2;
371
372 if (in_interrupt())
373 return;
374
375 tmo = jiffies + (msec*HZ)/1000;
376 for (;;) {
377 tmo2 = tmo - jiffies;
378 if (tmo2 <= 0)
379 break;
380 schedule_timeout(tmo2);
381 }
382}
383
384
385static void set_adc_rate(struct vrc5477_ac97_state *s, unsigned rate)
386{
387 wrcodec(s->codec, AC97_PCM_LR_ADC_RATE, rate);
388 s->adcRate = rate;
389}
390
391
392static void set_dac_rate(struct vrc5477_ac97_state *s, unsigned rate)
393{
394 if(s->extended_status & AC97_EXTSTAT_VRA) {
395 wrcodec(s->codec, AC97_PCM_FRONT_DAC_RATE, rate);
396 s->dacRate = rdcodec(s->codec, AC97_PCM_FRONT_DAC_RATE);
397 }
398}
399
400static int ac97_codec_not_present(struct ac97_codec *codec)
401{
402 struct vrc5477_ac97_state *s =
403 (struct vrc5477_ac97_state *)codec->private_data;
404 unsigned long flags;
405 unsigned short count = 0xffff;
406
407 spin_lock_irqsave(&s->lock, flags);
408
409 /* wait until we can access codec registers */
410 do {
411 if (!(inl(s->io + VRC5477_CODEC_WR) & 0x80000000))
412 break;
413 } while (--count);
414
415 if (count == 0) {
416 spin_unlock_irqrestore(&s->lock, flags);
417 return -1;
418 }
419
420 /* write 0 to reset */
421 outl((AC97_RESET << 16) | 0, s->io + VRC5477_CODEC_WR);
422
423 /* test whether we get a response from ac97 chip */
424 count = 0xffff;
425 do {
426 if (!(inl(s->io + VRC5477_CODEC_WR) & 0x80000000))
427 break;
428 } while (--count);
429
430 if (count == 0) {
431 spin_unlock_irqrestore(&s->lock, flags);
432 return -1;
433 }
434 spin_unlock_irqrestore(&s->lock, flags);
435 return 0;
436}
437
438/* --------------------------------------------------------------------- */
439
440static inline void
441stop_dac(struct vrc5477_ac97_state *s)
442{
443 struct dmabuf* db = &s->dma_dac;
444 unsigned long flags;
445 u32 temp;
446
447 spin_lock_irqsave(&s->lock, flags);
448
449 if (db->stopped) {
450 spin_unlock_irqrestore(&s->lock, flags);
451 return;
452 }
453
454 /* deactivate the dma */
455 outl(0, s->io + VRC5477_DAC1_CTRL);
456 outl(0, s->io + VRC5477_DAC2_CTRL);
457
458 /* wait for DAM completely stop */
459 while (inl(s->io + VRC5477_DAC1_CTRL) & VRC5477_DMA_WIP);
460 while (inl(s->io + VRC5477_DAC2_CTRL) & VRC5477_DMA_WIP);
461
462 /* disable dac slots in aclink */
463 temp = inl(s->io + VRC5477_CTRL);
464 temp &= ~ (VRC5477_CTRL_DAC1ENB | VRC5477_CTRL_DAC2ENB);
465 outl (temp, s->io + VRC5477_CTRL);
466
467 /* disable interrupts */
468 temp = inl(s->io + VRC5477_INT_MASK);
469 temp &= ~ (VRC5477_INT_MASK_DAC1END | VRC5477_INT_MASK_DAC2END);
470 outl (temp, s->io + VRC5477_INT_MASK);
471
472 /* clear pending ones */
473 outl(VRC5477_INT_MASK_DAC1END | VRC5477_INT_MASK_DAC2END,
474 s->io + VRC5477_INT_CLR);
475
476 db->stopped = 1;
477
478 spin_unlock_irqrestore(&s->lock, flags);
479}
480
481static void start_dac(struct vrc5477_ac97_state *s)
482{
483 struct dmabuf* db = &s->dma_dac;
484 unsigned long flags;
485 u32 dmaLength;
486 u32 temp;
487
488 spin_lock_irqsave(&s->lock, flags);
489
490 if (!db->stopped) {
491 spin_unlock_irqrestore(&s->lock, flags);
492 return;
493 }
494
495 /* we should have some data to do the DMA trasnfer */
496 ASSERT(db->count >= db->fragSize);
497
498 /* clear pending fales interrupts */
499 outl(VRC5477_INT_MASK_DAC1END | VRC5477_INT_MASK_DAC2END,
500 s->io + VRC5477_INT_CLR);
501
502 /* enable interrupts */
503 temp = inl(s->io + VRC5477_INT_MASK);
504 temp |= VRC5477_INT_MASK_DAC1END | VRC5477_INT_MASK_DAC2END;
505 outl(temp, s->io + VRC5477_INT_MASK);
506
507 /* setup dma base addr */
508 outl(db->lbufDma + db->nextOut, s->io + VRC5477_DAC1_BADDR);
509 if (s->dacChannels == 1) {
510 outl(db->lbufDma + db->nextOut, s->io + VRC5477_DAC2_BADDR);
511 } else {
512 outl(db->rbufDma + db->nextOut, s->io + VRC5477_DAC2_BADDR);
513 }
514
515 /* set dma length, in the unit of 0x10 bytes */
516 dmaLength = db->fragSize >> 4;
517 outl(dmaLength, s->io + VRC5477_DAC1L);
518 outl(dmaLength, s->io + VRC5477_DAC2L);
519
520 /* activate dma */
521 outl(VRC5477_DMA_ACTIVATION, s->io + VRC5477_DAC1_CTRL);
522 outl(VRC5477_DMA_ACTIVATION, s->io + VRC5477_DAC2_CTRL);
523
524 /* enable dac slots - we should hear the music now! */
525 temp = inl(s->io + VRC5477_CTRL);
526 temp |= (VRC5477_CTRL_DAC1ENB | VRC5477_CTRL_DAC2ENB);
527 outl (temp, s->io + VRC5477_CTRL);
528
529 /* it is time to setup next dma transfer */
530 ASSERT(inl(s->io + VRC5477_DAC1_CTRL) & VRC5477_DMA_WIP);
531 ASSERT(inl(s->io + VRC5477_DAC2_CTRL) & VRC5477_DMA_WIP);
532
533 temp = db->nextOut + db->fragSize;
534 if (temp >= db->fragTotalSize) {
535 ASSERT(temp == db->fragTotalSize);
536 temp = 0;
537 }
538
539 outl(db->lbufDma + temp, s->io + VRC5477_DAC1_BADDR);
540 if (s->dacChannels == 1) {
541 outl(db->lbufDma + temp, s->io + VRC5477_DAC2_BADDR);
542 } else {
543 outl(db->rbufDma + temp, s->io + VRC5477_DAC2_BADDR);
544 }
545
546 db->stopped = 0;
547
548#if defined(VRC5477_AC97_VERBOSE_DEBUG)
549 outTicket = *(u16*)(db->lbuf+db->nextOut);
550 if (db->count > db->fragSize) {
551 ASSERT((u16)(outTicket+1) == *(u16*)(db->lbuf+temp));
552 }
553#endif
554
555 spin_unlock_irqrestore(&s->lock, flags);
556}
557
558static inline void stop_adc(struct vrc5477_ac97_state *s)
559{
560 struct dmabuf* db = &s->dma_adc;
561 unsigned long flags;
562 u32 temp;
563
564 spin_lock_irqsave(&s->lock, flags);
565
566 if (db->stopped) {
567 spin_unlock_irqrestore(&s->lock, flags);
568 return;
569 }
570
571 /* deactivate the dma */
572 outl(0, s->io + VRC5477_ADC1_CTRL);
573 outl(0, s->io + VRC5477_ADC2_CTRL);
574
575 /* disable adc slots in aclink */
576 temp = inl(s->io + VRC5477_CTRL);
577 temp &= ~ (VRC5477_CTRL_ADC1ENB | VRC5477_CTRL_ADC2ENB);
578 outl (temp, s->io + VRC5477_CTRL);
579
580 /* disable interrupts */
581 temp = inl(s->io + VRC5477_INT_MASK);
582 temp &= ~ (VRC5477_INT_MASK_ADC1END | VRC5477_INT_MASK_ADC2END);
583 outl (temp, s->io + VRC5477_INT_MASK);
584
585 /* clear pending ones */
586 outl(VRC5477_INT_MASK_ADC1END | VRC5477_INT_MASK_ADC2END,
587 s->io + VRC5477_INT_CLR);
588
589 db->stopped = 1;
590
591 spin_unlock_irqrestore(&s->lock, flags);
592}
593
594static void start_adc(struct vrc5477_ac97_state *s)
595{
596 struct dmabuf* db = &s->dma_adc;
597 unsigned long flags;
598 u32 dmaLength;
599 u32 temp;
600
601 spin_lock_irqsave(&s->lock, flags);
602
603 if (!db->stopped) {
604 spin_unlock_irqrestore(&s->lock, flags);
605 return;
606 }
607
608 /* we should at least have some free space in the buffer */
609 ASSERT(db->count < db->fragTotalSize - db->fragSize * 2);
610
611 /* clear pending ones */
612 outl(VRC5477_INT_MASK_ADC1END | VRC5477_INT_MASK_ADC2END,
613 s->io + VRC5477_INT_CLR);
614
615 /* enable interrupts */
616 temp = inl(s->io + VRC5477_INT_MASK);
617 temp |= VRC5477_INT_MASK_ADC1END | VRC5477_INT_MASK_ADC2END;
618 outl(temp, s->io + VRC5477_INT_MASK);
619
620 /* setup dma base addr */
621 outl(db->lbufDma + db->nextIn, s->io + VRC5477_ADC1_BADDR);
622 outl(db->rbufDma + db->nextIn, s->io + VRC5477_ADC2_BADDR);
623
624 /* setup dma length */
625 dmaLength = db->fragSize >> 4;
626 outl(dmaLength, s->io + VRC5477_ADC1L);
627 outl(dmaLength, s->io + VRC5477_ADC2L);
628
629 /* activate dma */
630 outl(VRC5477_DMA_ACTIVATION, s->io + VRC5477_ADC1_CTRL);
631 outl(VRC5477_DMA_ACTIVATION, s->io + VRC5477_ADC2_CTRL);
632
633 /* enable adc slots */
634 temp = inl(s->io + VRC5477_CTRL);
635 temp |= (VRC5477_CTRL_ADC1ENB | VRC5477_CTRL_ADC2ENB);
636 outl (temp, s->io + VRC5477_CTRL);
637
638 /* it is time to setup next dma transfer */
639 temp = db->nextIn + db->fragSize;
640 if (temp >= db->fragTotalSize) {
641 ASSERT(temp == db->fragTotalSize);
642 temp = 0;
643 }
644 outl(db->lbufDma + temp, s->io + VRC5477_ADC1_BADDR);
645 outl(db->rbufDma + temp, s->io + VRC5477_ADC2_BADDR);
646
647 db->stopped = 0;
648
649 spin_unlock_irqrestore(&s->lock, flags);
650}
651
652/* --------------------------------------------------------------------- */
653
654#define DMABUF_DEFAULTORDER (16-PAGE_SHIFT)
655#define DMABUF_MINORDER 1
656
657static inline void dealloc_dmabuf(struct vrc5477_ac97_state *s,
658 struct dmabuf *db)
659{
660 if (db->lbuf) {
661 ASSERT(db->rbuf);
662 pci_free_consistent(s->dev, PAGE_SIZE << db->bufOrder,
663 db->lbuf, db->lbufDma);
664 pci_free_consistent(s->dev, PAGE_SIZE << db->bufOrder,
665 db->rbuf, db->rbufDma);
666 db->lbuf = db->rbuf = NULL;
667 }
668 db->nextIn = db->nextOut = 0;
669 db->ready = 0;
670}
671
672static int prog_dmabuf(struct vrc5477_ac97_state *s,
673 struct dmabuf *db,
674 unsigned rate)
675{
676 int order;
677 unsigned bufsize;
678
679 if (!db->lbuf) {
680 ASSERT(!db->rbuf);
681
682 db->ready = 0;
683 for (order = DMABUF_DEFAULTORDER;
684 order >= DMABUF_MINORDER;
685 order--) {
686 db->lbuf = pci_alloc_consistent(s->dev,
687 PAGE_SIZE << order,
688 &db->lbufDma);
689 db->rbuf = pci_alloc_consistent(s->dev,
690 PAGE_SIZE << order,
691 &db->rbufDma);
692 if (db->lbuf && db->rbuf) break;
693 if (db->lbuf) {
694 ASSERT(!db->rbuf);
695 pci_free_consistent(s->dev,
696 PAGE_SIZE << order,
697 db->lbuf,
698 db->lbufDma);
699 }
700 }
701 if (!db->lbuf) {
702 ASSERT(!db->rbuf);
703 return -ENOMEM;
704 }
705
706 db->bufOrder = order;
707 }
708
709 db->count = 0;
710 db->nextIn = db->nextOut = 0;
711
712 bufsize = PAGE_SIZE << db->bufOrder;
713 db->fragShift = ld2(rate * 2 / 100);
714 if (db->fragShift < 4) db->fragShift = 4;
715
716 db->numFrag = bufsize >> db->fragShift;
717 while (db->numFrag < 4 && db->fragShift > 4) {
718 db->fragShift--;
719 db->numFrag = bufsize >> db->fragShift;
720 }
721 db->fragSize = 1 << db->fragShift;
722 db->fragTotalSize = db->numFrag << db->fragShift;
723 memset(db->lbuf, 0, db->fragTotalSize);
724 memset(db->rbuf, 0, db->fragTotalSize);
725
726 db->ready = 1;
727
728 return 0;
729}
730
731static inline int prog_dmabuf_adc(struct vrc5477_ac97_state *s)
732{
733 stop_adc(s);
734 return prog_dmabuf(s, &s->dma_adc, s->adcRate);
735}
736
737static inline int prog_dmabuf_dac(struct vrc5477_ac97_state *s)
738{
739 stop_dac(s);
740 return prog_dmabuf(s, &s->dma_dac, s->dacRate);
741}
742
743
744/* --------------------------------------------------------------------- */
745/* hold spinlock for the following! */
746
747static inline void vrc5477_ac97_adc_interrupt(struct vrc5477_ac97_state *s)
748{
749 struct dmabuf* adc = &s->dma_adc;
750 unsigned temp;
751
752 /* we need two frags avaiable because one is already being used
753 * and the other will be used when next interrupt happens.
754 */
755 if (adc->count >= adc->fragTotalSize - adc->fragSize) {
756 stop_adc(s);
757 adc->error++;
758 printk(KERN_INFO PFX "adc overrun\n");
759 return;
760 }
761
762 /* set the base addr for next DMA transfer */
763 temp = adc->nextIn + 2*adc->fragSize;
764 if (temp >= adc->fragTotalSize) {
765 ASSERT( (temp == adc->fragTotalSize) ||
766 (temp == adc->fragTotalSize + adc->fragSize) );
767 temp -= adc->fragTotalSize;
768 }
769 outl(adc->lbufDma + temp, s->io + VRC5477_ADC1_BADDR);
770 outl(adc->rbufDma + temp, s->io + VRC5477_ADC2_BADDR);
771
772 /* adjust nextIn */
773 adc->nextIn += adc->fragSize;
774 if (adc->nextIn >= adc->fragTotalSize) {
775 ASSERT(adc->nextIn == adc->fragTotalSize);
776 adc->nextIn = 0;
777 }
778
779 /* adjust count */
780 adc->count += adc->fragSize;
781
782 /* wake up anybody listening */
783 if (waitqueue_active(&adc->wait)) {
784 wake_up_interruptible(&adc->wait);
785 }
786}
787
788static inline void vrc5477_ac97_dac_interrupt(struct vrc5477_ac97_state *s)
789{
790 struct dmabuf* dac = &s->dma_dac;
791 unsigned temp;
792
793 /* next DMA transfer should already started */
794 // ASSERT(inl(s->io + VRC5477_DAC1_CTRL) & VRC5477_DMA_WIP);
795 // ASSERT(inl(s->io + VRC5477_DAC2_CTRL) & VRC5477_DMA_WIP);
796
797 /* let us set for next next DMA transfer */
798 temp = dac->nextOut + dac->fragSize*2;
799 if (temp >= dac->fragTotalSize) {
800 ASSERT( (temp == dac->fragTotalSize) ||
801 (temp == dac->fragTotalSize + dac->fragSize) );
802 temp -= dac->fragTotalSize;
803 }
804 outl(dac->lbufDma + temp, s->io + VRC5477_DAC1_BADDR);
805 if (s->dacChannels == 1) {
806 outl(dac->lbufDma + temp, s->io + VRC5477_DAC2_BADDR);
807 } else {
808 outl(dac->rbufDma + temp, s->io + VRC5477_DAC2_BADDR);
809 }
810
811#if defined(VRC5477_AC97_VERBOSE_DEBUG)
812 if (*(u16*)(dac->lbuf + dac->nextOut) != outTicket) {
813 printk("assert fail: - %d vs %d\n",
814 *(u16*)(dac->lbuf + dac->nextOut),
815 outTicket);
816 ASSERT(1 == 0);
817 }
818#endif
819
820 /* adjust nextOut pointer */
821 dac->nextOut += dac->fragSize;
822 if (dac->nextOut >= dac->fragTotalSize) {
823 ASSERT(dac->nextOut == dac->fragTotalSize);
824 dac->nextOut = 0;
825 }
826
827 /* adjust count */
828 dac->count -= dac->fragSize;
829 if (dac->count <=0 ) {
830 /* buffer under run */
831 dac->count = 0;
832 dac->nextIn = dac->nextOut;
833 stop_dac(s);
834 }
835
836#if defined(VRC5477_AC97_VERBOSE_DEBUG)
837 if (dac->count) {
838 outTicket ++;
839 ASSERT(*(u16*)(dac->lbuf + dac->nextOut) == outTicket);
840 }
841#endif
842
843 /* we cannot have both under run and someone is waiting on us */
844 ASSERT(! (waitqueue_active(&dac->wait) && (dac->count <= 0)) );
845
846 /* wake up anybody listening */
847 if (waitqueue_active(&dac->wait))
848 wake_up_interruptible(&dac->wait);
849}
850
851static irqreturn_t vrc5477_ac97_interrupt(int irq, void *dev_id)
852{
853 struct vrc5477_ac97_state *s = (struct vrc5477_ac97_state *)dev_id;
854 u32 irqStatus;
855 u32 adcInterrupts, dacInterrupts;
856
857 spin_lock(&s->lock);
858
859 /* get irqStatus and clear the detected ones */
860 irqStatus = inl(s->io + VRC5477_INT_STATUS);
861 outl(irqStatus, s->io + VRC5477_INT_CLR);
862
863 /* let us see what we get */
864 dacInterrupts = VRC5477_INT_MASK_DAC1END | VRC5477_INT_MASK_DAC2END;
865 adcInterrupts = VRC5477_INT_MASK_ADC1END | VRC5477_INT_MASK_ADC2END;
866 if (irqStatus & dacInterrupts) {
867 /* we should get both interrupts, but just in case ... */
868 if (irqStatus & VRC5477_INT_MASK_DAC1END) {
869 vrc5477_ac97_dac_interrupt(s);
870 }
871 if ( (irqStatus & dacInterrupts) != dacInterrupts ) {
872 printk(KERN_WARNING "vrc5477_ac97 : dac interrupts not in sync!!!\n");
873 stop_dac(s);
874 start_dac(s);
875 }
876 } else if (irqStatus & adcInterrupts) {
877 /* we should get both interrupts, but just in case ... */
878 if(irqStatus & VRC5477_INT_MASK_ADC1END) {
879 vrc5477_ac97_adc_interrupt(s);
880 }
881 if ( (irqStatus & adcInterrupts) != adcInterrupts ) {
882 printk(KERN_WARNING "vrc5477_ac97 : adc interrupts not in sync!!!\n");
883 stop_adc(s);
884 start_adc(s);
885 }
886 }
887
888 spin_unlock(&s->lock);
889 return IRQ_HANDLED;
890}
891
892/* --------------------------------------------------------------------- */
893
894static int vrc5477_ac97_open_mixdev(struct inode *inode, struct file *file)
895{
896 int minor = iminor(inode);
897 struct list_head *list;
898 struct vrc5477_ac97_state *s;
899
900 for (list = devs.next; ; list = list->next) {
901 if (list == &devs)
902 return -ENODEV;
903 s = list_entry(list, struct vrc5477_ac97_state, devs);
904 if (s->codec->dev_mixer == minor)
905 break;
906 }
907 file->private_data = s;
908 return nonseekable_open(inode, file);
909}
910
911static int vrc5477_ac97_release_mixdev(struct inode *inode, struct file *file)
912{
913 return 0;
914}
915
916
917static int mixdev_ioctl(struct ac97_codec *codec, unsigned int cmd,
918 unsigned long arg)
919{
920 return codec->mixer_ioctl(codec, cmd, arg);
921}
922
923static int vrc5477_ac97_ioctl_mixdev(struct inode *inode, struct file *file,
924 unsigned int cmd, unsigned long arg)
925{
926 struct vrc5477_ac97_state *s =
927 (struct vrc5477_ac97_state *)file->private_data;
928 struct ac97_codec *codec = s->codec;
929
930 return mixdev_ioctl(codec, cmd, arg);
931}
932
933static /*const*/ struct file_operations vrc5477_ac97_mixer_fops = {
934 .owner = THIS_MODULE,
935 .llseek = no_llseek,
936 .ioctl = vrc5477_ac97_ioctl_mixdev,
937 .open = vrc5477_ac97_open_mixdev,
938 .release = vrc5477_ac97_release_mixdev,
939};
940
941/* --------------------------------------------------------------------- */
942
943static int drain_dac(struct vrc5477_ac97_state *s, int nonblock)
944{
945 unsigned long flags;
946 int count, tmo;
947
948 if (!s->dma_dac.ready)
949 return 0;
950
951 for (;;) {
952 spin_lock_irqsave(&s->lock, flags);
953 count = s->dma_dac.count;
954 spin_unlock_irqrestore(&s->lock, flags);
955 if (count <= 0)
956 break;
957 if (signal_pending(current))
958 break;
959 if (nonblock)
960 return -EBUSY;
961 tmo = 1000 * count / s->dacRate / 2;
962 vrc5477_ac97_delay(tmo);
963 }
964 if (signal_pending(current))
965 return -ERESTARTSYS;
966 return 0;
967}
968
969/* --------------------------------------------------------------------- */
970
971static inline int
972copy_two_channel_adc_to_user(struct vrc5477_ac97_state *s,
973 char *buffer,
974 int copyCount)
975{
976 struct dmabuf *db = &s->dma_adc;
977 int bufStart = db->nextOut;
978 for (; copyCount > 0; ) {
979 int i;
980 int count = copyCount;
981 if (count > WORK_BUF_SIZE/2) count = WORK_BUF_SIZE/2;
982 for (i=0; i< count/2; i++) {
983 s->workBuf[i].lchannel =
984 *(u16*)(db->lbuf + bufStart + i*2);
985 s->workBuf[i].rchannel =
986 *(u16*)(db->rbuf + bufStart + i*2);
987 }
988 if (copy_to_user(buffer, s->workBuf, count*2)) {
989 return -1;
990 }
991
992 copyCount -= count;
993 bufStart += count;
994 ASSERT(bufStart <= db->fragTotalSize);
995 buffer += count *2;
996 }
997 return 0;
998}
999
1000/* return the total bytes that is copied */
1001static inline int
1002copy_adc_to_user(struct vrc5477_ac97_state *s,
1003 char * buffer,
1004 size_t count,
1005 int avail)
1006{
1007 struct dmabuf *db = &s->dma_adc;
1008 int copyCount=0;
1009 int copyFragCount=0;
1010 int totalCopyCount = 0;
1011 int totalCopyFragCount = 0;
1012 unsigned long flags;
1013
1014 /* adjust count to signel channel byte count */
1015 count >>= s->adcChannels - 1;
1016
1017 /* we may have to "copy" twice as ring buffer wraps around */
1018 for (; (avail > 0) && (count > 0); ) {
1019 /* determine max possible copy count for single channel */
1020 copyCount = count;
1021 if (copyCount > avail) {
1022 copyCount = avail;
1023 }
1024 if (copyCount + db->nextOut > db->fragTotalSize) {
1025 copyCount = db->fragTotalSize - db->nextOut;
1026 ASSERT((copyCount % db->fragSize) == 0);
1027 }
1028
1029 copyFragCount = (copyCount-1) >> db->fragShift;
1030 copyFragCount = (copyFragCount+1) << db->fragShift;
1031 ASSERT(copyFragCount >= copyCount);
1032
1033 /* we copy differently based on adc channels */
1034 if (s->adcChannels == 1) {
1035 if (copy_to_user(buffer,
1036 db->lbuf + db->nextOut,
1037 copyCount))
1038 return -1;
1039 } else {
1040 /* *sigh* we have to mix two streams into one */
1041 if (copy_two_channel_adc_to_user(s, buffer, copyCount))
1042 return -1;
1043 }
1044
1045 count -= copyCount;
1046 totalCopyCount += copyCount;
1047 avail -= copyFragCount;
1048 totalCopyFragCount += copyFragCount;
1049
1050 buffer += copyCount << (s->adcChannels-1);
1051
1052 db->nextOut += copyFragCount;
1053 if (db->nextOut >= db->fragTotalSize) {
1054 ASSERT(db->nextOut == db->fragTotalSize);
1055 db->nextOut = 0;
1056 }
1057
1058 ASSERT((copyFragCount % db->fragSize) == 0);
1059 ASSERT( (count == 0) || (copyCount == copyFragCount));
1060 }
1061
1062 spin_lock_irqsave(&s->lock, flags);
1063 db->count -= totalCopyFragCount;
1064 spin_unlock_irqrestore(&s->lock, flags);
1065
1066 return totalCopyCount << (s->adcChannels-1);
1067}
1068
1069static ssize_t
1070vrc5477_ac97_read(struct file *file,
1071 char *buffer,
1072 size_t count,
1073 loff_t *ppos)
1074{
1075 struct vrc5477_ac97_state *s =
1076 (struct vrc5477_ac97_state *)file->private_data;
1077 struct dmabuf *db = &s->dma_adc;
1078 ssize_t ret = 0;
1079 unsigned long flags;
1080 int copyCount;
1081 size_t avail;
1082
1083 if (!access_ok(VERIFY_WRITE, buffer, count))
1084 return -EFAULT;
1085
1086 ASSERT(db->ready);
1087
1088 while (count > 0) {
1089 // wait for samples in capture buffer
1090 do {
1091 spin_lock_irqsave(&s->lock, flags);
1092 if (db->stopped)
1093 start_adc(s);
1094 avail = db->count;
1095 spin_unlock_irqrestore(&s->lock, flags);
1096 if (avail <= 0) {
1097 if (file->f_flags & O_NONBLOCK) {
1098 if (!ret)
1099 ret = -EAGAIN;
1100 return ret;
1101 }
1102 interruptible_sleep_on(&db->wait);
1103 if (signal_pending(current)) {
1104 if (!ret)
1105 ret = -ERESTARTSYS;
1106 return ret;
1107 }
1108 }
1109 } while (avail <= 0);
1110
1111 ASSERT( (avail % db->fragSize) == 0);
1112 copyCount = copy_adc_to_user(s, buffer, count, avail);
1113 if (copyCount <=0 ) {
1114 if (!ret) ret = -EFAULT;
1115 return ret;
1116 }
1117
1118 count -= copyCount;
1119 buffer += copyCount;
1120 ret += copyCount;
1121 } // while (count > 0)
1122
1123 return ret;
1124}
1125
1126static inline int
1127copy_two_channel_dac_from_user(struct vrc5477_ac97_state *s,
1128 const char *buffer,
1129 int copyCount)
1130{
1131 struct dmabuf *db = &s->dma_dac;
1132 int bufStart = db->nextIn;
1133
1134 ASSERT(db->ready);
1135
1136 for (; copyCount > 0; ) {
1137 int i;
1138 int count = copyCount;
1139 if (count > WORK_BUF_SIZE/2) count = WORK_BUF_SIZE/2;
1140 if (copy_from_user(s->workBuf, buffer, count*2)) {
1141 return -1;
1142 }
1143 for (i=0; i< count/2; i++) {
1144 *(u16*)(db->lbuf + bufStart + i*2) =
1145 s->workBuf[i].lchannel;
1146 *(u16*)(db->rbuf + bufStart + i*2) =
1147 s->workBuf[i].rchannel;
1148 }
1149
1150 copyCount -= count;
1151 bufStart += count;
1152 ASSERT(bufStart <= db->fragTotalSize);
1153 buffer += count *2;
1154 }
1155 return 0;
1156
1157}
1158
1159/* return the total bytes that is copied */
1160static inline int
1161copy_dac_from_user(struct vrc5477_ac97_state *s,
1162 const char *buffer,
1163 size_t count,
1164 int avail)
1165{
1166 struct dmabuf *db = &s->dma_dac;
1167 int copyCount=0;
1168 int copyFragCount=0;
1169 int totalCopyCount = 0;
1170 int totalCopyFragCount = 0;
1171 unsigned long flags;
1172#if defined(VRC5477_AC97_VERBOSE_DEBUG)
1173 int i;
1174#endif
1175
1176 /* adjust count to signel channel byte count */
1177 count >>= s->dacChannels - 1;
1178
1179 /* we may have to "copy" twice as ring buffer wraps around */
1180 for (; (avail > 0) && (count > 0); ) {
1181 /* determine max possible copy count for single channel */
1182 copyCount = count;
1183 if (copyCount > avail) {
1184 copyCount = avail;
1185 }
1186 if (copyCount + db->nextIn > db->fragTotalSize) {
1187 copyCount = db->fragTotalSize - db->nextIn;
1188 ASSERT(copyCount > 0);
1189 }
1190
1191 copyFragCount = copyCount;
1192 ASSERT(copyFragCount >= copyCount);
1193
1194 /* we copy differently based on the number channels */
1195 if (s->dacChannels == 1) {
1196 if (copy_from_user(db->lbuf + db->nextIn,
1197 buffer,
1198 copyCount))
1199 return -1;
1200 /* fill gaps with 0 */
1201 memset(db->lbuf + db->nextIn + copyCount,
1202 0,
1203 copyFragCount - copyCount);
1204 } else {
1205 /* we have demux the stream into two separate ones */
1206 if (copy_two_channel_dac_from_user(s, buffer, copyCount))
1207 return -1;
1208 /* fill gaps with 0 */
1209 memset(db->lbuf + db->nextIn + copyCount,
1210 0,
1211 copyFragCount - copyCount);
1212 memset(db->rbuf + db->nextIn + copyCount,
1213 0,
1214 copyFragCount - copyCount);
1215 }
1216
1217#if defined(VRC5477_AC97_VERBOSE_DEBUG)
1218 for (i=0; i< copyFragCount; i+= db->fragSize) {
1219 *(u16*)(db->lbuf + db->nextIn + i) = inTicket ++;
1220 }
1221#endif
1222
1223 count -= copyCount;
1224 totalCopyCount += copyCount;
1225 avail -= copyFragCount;
1226 totalCopyFragCount += copyFragCount;
1227
1228 buffer += copyCount << (s->dacChannels - 1);
1229
1230 db->nextIn += copyFragCount;
1231 if (db->nextIn >= db->fragTotalSize) {
1232 ASSERT(db->nextIn == db->fragTotalSize);
1233 db->nextIn = 0;
1234 }
1235
1236 ASSERT( (count == 0) || (copyCount == copyFragCount));
1237 }
1238
1239 spin_lock_irqsave(&s->lock, flags);
1240 db->count += totalCopyFragCount;
1241 if (db->stopped) {
1242 start_dac(s);
1243 }
1244
1245 /* nextIn should not be equal to nextOut unless we are full */
1246 ASSERT( ( (db->count == db->fragTotalSize) &&
1247 (db->nextIn == db->nextOut) ) ||
1248 ( (db->count < db->fragTotalSize) &&
1249 (db->nextIn != db->nextOut) ) );
1250
1251 spin_unlock_irqrestore(&s->lock, flags);
1252
1253 return totalCopyCount << (s->dacChannels-1);
1254
1255}
1256
1257static ssize_t vrc5477_ac97_write(struct file *file, const char *buffer,
1258 size_t count, loff_t *ppos)
1259{
1260 struct vrc5477_ac97_state *s =
1261 (struct vrc5477_ac97_state *)file->private_data;
1262 struct dmabuf *db = &s->dma_dac;
1263 ssize_t ret;
1264 unsigned long flags;
1265 int copyCount, avail;
1266
1267 if (!access_ok(VERIFY_READ, buffer, count))
1268 return -EFAULT;
1269 ret = 0;
1270
1271 while (count > 0) {
1272 // wait for space in playback buffer
1273 do {
1274 spin_lock_irqsave(&s->lock, flags);
1275 avail = db->fragTotalSize - db->count;
1276 spin_unlock_irqrestore(&s->lock, flags);
1277 if (avail <= 0) {
1278 if (file->f_flags & O_NONBLOCK) {
1279 if (!ret)
1280 ret = -EAGAIN;
1281 return ret;
1282 }
1283 interruptible_sleep_on(&db->wait);
1284 if (signal_pending(current)) {
1285 if (!ret)
1286 ret = -ERESTARTSYS;
1287 return ret;
1288 }
1289 }
1290 } while (avail <= 0);
1291
1292 copyCount = copy_dac_from_user(s, buffer, count, avail);
1293 if (copyCount < 0) {
1294 if (!ret) ret = -EFAULT;
1295 return ret;
1296 }
1297
1298 count -= copyCount;
1299 buffer += copyCount;
1300 ret += copyCount;
1301 } // while (count > 0)
1302
1303 return ret;
1304}
1305
1306/* No kernel lock - we have our own spinlock */
1307static unsigned int vrc5477_ac97_poll(struct file *file,
1308 struct poll_table_struct *wait)
1309{
1310 struct vrc5477_ac97_state *s = (struct vrc5477_ac97_state *)file->private_data;
1311 unsigned long flags;
1312 unsigned int mask = 0;
1313
1314 if (file->f_mode & FMODE_WRITE)
1315 poll_wait(file, &s->dma_dac.wait, wait);
1316 if (file->f_mode & FMODE_READ)
1317 poll_wait(file, &s->dma_adc.wait, wait);
1318 spin_lock_irqsave(&s->lock, flags);
1319 if (file->f_mode & FMODE_READ) {
1320 if (s->dma_adc.count >= (signed)s->dma_adc.fragSize)
1321 mask |= POLLIN | POLLRDNORM;
1322 }
1323 if (file->f_mode & FMODE_WRITE) {
1324 if ((signed)s->dma_dac.fragTotalSize >=
1325 s->dma_dac.count + (signed)s->dma_dac.fragSize)
1326 mask |= POLLOUT | POLLWRNORM;
1327 }
1328 spin_unlock_irqrestore(&s->lock, flags);
1329 return mask;
1330}
1331
1332#ifdef VRC5477_AC97_DEBUG
1333static struct ioctl_str_t {
1334 unsigned int cmd;
1335 const char* str;
1336} ioctl_str[] = {
1337 {SNDCTL_DSP_RESET, "SNDCTL_DSP_RESET"},
1338 {SNDCTL_DSP_SYNC, "SNDCTL_DSP_SYNC"},
1339 {SNDCTL_DSP_SPEED, "SNDCTL_DSP_SPEED"},
1340 {SNDCTL_DSP_STEREO, "SNDCTL_DSP_STEREO"},
1341 {SNDCTL_DSP_GETBLKSIZE, "SNDCTL_DSP_GETBLKSIZE"},
1342 {SNDCTL_DSP_SETFMT, "SNDCTL_DSP_SETFMT"},
1343 {SNDCTL_DSP_SAMPLESIZE, "SNDCTL_DSP_SAMPLESIZE"},
1344 {SNDCTL_DSP_CHANNELS, "SNDCTL_DSP_CHANNELS"},
1345 {SOUND_PCM_WRITE_CHANNELS, "SOUND_PCM_WRITE_CHANNELS"},
1346 {SOUND_PCM_WRITE_FILTER, "SOUND_PCM_WRITE_FILTER"},
1347 {SNDCTL_DSP_POST, "SNDCTL_DSP_POST"},
1348 {SNDCTL_DSP_SUBDIVIDE, "SNDCTL_DSP_SUBDIVIDE"},
1349 {SNDCTL_DSP_SETFRAGMENT, "SNDCTL_DSP_SETFRAGMENT"},
1350 {SNDCTL_DSP_GETFMTS, "SNDCTL_DSP_GETFMTS"},
1351 {SNDCTL_DSP_GETOSPACE, "SNDCTL_DSP_GETOSPACE"},
1352 {SNDCTL_DSP_GETISPACE, "SNDCTL_DSP_GETISPACE"},
1353 {SNDCTL_DSP_NONBLOCK, "SNDCTL_DSP_NONBLOCK"},
1354 {SNDCTL_DSP_GETCAPS, "SNDCTL_DSP_GETCAPS"},
1355 {SNDCTL_DSP_GETTRIGGER, "SNDCTL_DSP_GETTRIGGER"},
1356 {SNDCTL_DSP_SETTRIGGER, "SNDCTL_DSP_SETTRIGGER"},
1357 {SNDCTL_DSP_GETIPTR, "SNDCTL_DSP_GETIPTR"},
1358 {SNDCTL_DSP_GETOPTR, "SNDCTL_DSP_GETOPTR"},
1359 {SNDCTL_DSP_MAPINBUF, "SNDCTL_DSP_MAPINBUF"},
1360 {SNDCTL_DSP_MAPOUTBUF, "SNDCTL_DSP_MAPOUTBUF"},
1361 {SNDCTL_DSP_SETSYNCRO, "SNDCTL_DSP_SETSYNCRO"},
1362 {SNDCTL_DSP_SETDUPLEX, "SNDCTL_DSP_SETDUPLEX"},
1363 {SNDCTL_DSP_GETODELAY, "SNDCTL_DSP_GETODELAY"},
1364 {SNDCTL_DSP_GETCHANNELMASK, "SNDCTL_DSP_GETCHANNELMASK"},
1365 {SNDCTL_DSP_BIND_CHANNEL, "SNDCTL_DSP_BIND_CHANNEL"},
1366 {OSS_GETVERSION, "OSS_GETVERSION"},
1367 {SOUND_PCM_READ_RATE, "SOUND_PCM_READ_RATE"},
1368 {SOUND_PCM_READ_CHANNELS, "SOUND_PCM_READ_CHANNELS"},
1369 {SOUND_PCM_READ_BITS, "SOUND_PCM_READ_BITS"},
1370 {SOUND_PCM_READ_FILTER, "SOUND_PCM_READ_FILTER"}
1371};
1372#endif
1373
1374static int vrc5477_ac97_ioctl(struct inode *inode, struct file *file,
1375 unsigned int cmd, unsigned long arg)
1376{
1377 struct vrc5477_ac97_state *s = (struct vrc5477_ac97_state *)file->private_data;
1378 unsigned long flags;
1379 audio_buf_info abinfo;
1380 int count;
1381 int val, ret;
1382
1383#ifdef VRC5477_AC97_DEBUG
1384 for (count = 0; count < ARRAY_SIZE(ioctl_str); count++) {
1385 if (ioctl_str[count].cmd == cmd)
1386 break;
1387 }
1388 if (count < ARRAY_SIZE(ioctl_str))
1389 printk(KERN_INFO PFX "ioctl %s\n", ioctl_str[count].str);
1390 else
1391 printk(KERN_INFO PFX "ioctl unknown, 0x%x\n", cmd);
1392#endif
1393
1394 switch (cmd) {
1395 case OSS_GETVERSION:
1396 return put_user(SOUND_VERSION, (int *)arg);
1397
1398 case SNDCTL_DSP_SYNC:
1399 if (file->f_mode & FMODE_WRITE)
1400 return drain_dac(s, file->f_flags & O_NONBLOCK);
1401 return 0;
1402
1403 case SNDCTL_DSP_SETDUPLEX:
1404 return 0;
1405
1406 case SNDCTL_DSP_GETCAPS:
1407 return put_user(DSP_CAP_DUPLEX, (int *)arg);
1408
1409 case SNDCTL_DSP_RESET:
1410 if (file->f_mode & FMODE_WRITE) {
1411 stop_dac(s);
1412 synchronize_irq(s->irq);
1413 s->dma_dac.count = 0;
1414 s->dma_dac.nextIn = s->dma_dac.nextOut = 0;
1415 }
1416 if (file->f_mode & FMODE_READ) {
1417 stop_adc(s);
1418 synchronize_irq(s->irq);
1419 s->dma_adc.count = 0;
1420 s->dma_adc.nextIn = s->dma_adc.nextOut = 0;
1421 }
1422 return 0;
1423
1424 case SNDCTL_DSP_SPEED:
1425 if (get_user(val, (int *)arg))
1426 return -EFAULT;
1427 if (val >= 0) {
1428 if (file->f_mode & FMODE_READ) {
1429 stop_adc(s);
1430 set_adc_rate(s, val);
1431 if ((ret = prog_dmabuf_adc(s)))
1432 return ret;
1433 }
1434 if (file->f_mode & FMODE_WRITE) {
1435 stop_dac(s);
1436 set_dac_rate(s, val);
1437 if ((ret = prog_dmabuf_dac(s)))
1438 return ret;
1439 }
1440 }
1441 return put_user((file->f_mode & FMODE_READ) ?
1442 s->adcRate : s->dacRate, (int *)arg);
1443
1444 case SNDCTL_DSP_STEREO:
1445 if (get_user(val, (int *)arg))
1446 return -EFAULT;
1447 if (file->f_mode & FMODE_READ) {
1448 stop_adc(s);
1449 if (val)
1450 s->adcChannels = 2;
1451 else
1452 s->adcChannels = 1;
1453 if ((ret = prog_dmabuf_adc(s)))
1454 return ret;
1455 }
1456 if (file->f_mode & FMODE_WRITE) {
1457 stop_dac(s);
1458 if (val)
1459 s->dacChannels = 2;
1460 else
1461 s->dacChannels = 1;
1462 if ((ret = prog_dmabuf_dac(s)))
1463 return ret;
1464 }
1465 return 0;
1466
1467 case SNDCTL_DSP_CHANNELS:
1468 if (get_user(val, (int *)arg))
1469 return -EFAULT;
1470 if (val != 0) {
1471 if ( (val != 1) && (val != 2)) val = 2;
1472
1473 if (file->f_mode & FMODE_READ) {
1474 stop_adc(s);
1475 s->dacChannels = val;
1476 if ((ret = prog_dmabuf_adc(s)))
1477 return ret;
1478 }
1479 if (file->f_mode & FMODE_WRITE) {
1480 stop_dac(s);
1481 s->dacChannels = val;
1482 if ((ret = prog_dmabuf_dac(s)))
1483 return ret;
1484 }
1485 }
1486 return put_user(val, (int *)arg);
1487
1488 case SNDCTL_DSP_GETFMTS: /* Returns a mask */
1489 return put_user(AFMT_S16_LE, (int *)arg);
1490
1491 case SNDCTL_DSP_SETFMT: /* Selects ONE fmt*/
1492 if (get_user(val, (int *)arg))
1493 return -EFAULT;
1494 if (val != AFMT_QUERY) {
1495 if (val != AFMT_S16_LE) return -EINVAL;
1496 if (file->f_mode & FMODE_READ) {
1497 stop_adc(s);
1498 if ((ret = prog_dmabuf_adc(s)))
1499 return ret;
1500 }
1501 if (file->f_mode & FMODE_WRITE) {
1502 stop_dac(s);
1503 if ((ret = prog_dmabuf_dac(s)))
1504 return ret;
1505 }
1506 } else {
1507 val = AFMT_S16_LE;
1508 }
1509 return put_user(val, (int *)arg);
1510
1511 case SNDCTL_DSP_POST:
1512 return 0;
1513
1514 case SNDCTL_DSP_GETTRIGGER:
1515 case SNDCTL_DSP_SETTRIGGER:
1516 /* NO trigger */
1517 return -EINVAL;
1518
1519 case SNDCTL_DSP_GETOSPACE:
1520 if (!(file->f_mode & FMODE_WRITE))
1521 return -EINVAL;
1522 abinfo.fragsize = s->dma_dac.fragSize << (s->dacChannels-1);
1523 spin_lock_irqsave(&s->lock, flags);
1524 count = s->dma_dac.count;
1525 spin_unlock_irqrestore(&s->lock, flags);
1526 abinfo.bytes = (s->dma_dac.fragTotalSize - count) <<
1527 (s->dacChannels-1);
1528 abinfo.fragstotal = s->dma_dac.numFrag;
1529 abinfo.fragments = abinfo.bytes >> s->dma_dac.fragShift >>
1530 (s->dacChannels-1);
1531 return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
1532
1533 case SNDCTL_DSP_GETISPACE:
1534 if (!(file->f_mode & FMODE_READ))
1535 return -EINVAL;
1536 abinfo.fragsize = s->dma_adc.fragSize << (s->adcChannels-1);
1537 spin_lock_irqsave(&s->lock, flags);
1538 count = s->dma_adc.count;
1539 spin_unlock_irqrestore(&s->lock, flags);
1540 if (count < 0)
1541 count = 0;
1542 abinfo.bytes = count << (s->adcChannels-1);
1543 abinfo.fragstotal = s->dma_adc.numFrag;
1544 abinfo.fragments = (abinfo.bytes >> s->dma_adc.fragShift) >>
1545 (s->adcChannels-1);
1546 return copy_to_user((void *)arg, &abinfo, sizeof(abinfo)) ? -EFAULT : 0;
1547
1548 case SNDCTL_DSP_NONBLOCK:
1549 file->f_flags |= O_NONBLOCK;
1550 return 0;
1551
1552 case SNDCTL_DSP_GETODELAY:
1553 if (!(file->f_mode & FMODE_WRITE))
1554 return -EINVAL;
1555 spin_lock_irqsave(&s->lock, flags);
1556 count = s->dma_dac.count;
1557 spin_unlock_irqrestore(&s->lock, flags);
1558 return put_user(count, (int *)arg);
1559
1560 case SNDCTL_DSP_GETIPTR:
1561 case SNDCTL_DSP_GETOPTR:
1562 /* we cannot get DMA ptr */
1563 return -EINVAL;
1564
1565 case SNDCTL_DSP_GETBLKSIZE:
1566 if (file->f_mode & FMODE_WRITE)
1567 return put_user(s->dma_dac.fragSize << (s->dacChannels-1), (int *)arg);
1568 else
1569 return put_user(s->dma_adc.fragSize << (s->adcChannels-1), (int *)arg);
1570
1571 case SNDCTL_DSP_SETFRAGMENT:
1572 /* we ignore fragment size request */
1573 return 0;
1574
1575 case SNDCTL_DSP_SUBDIVIDE:
1576 /* what is this for? [jsun] */
1577 return 0;
1578
1579 case SOUND_PCM_READ_RATE:
1580 return put_user((file->f_mode & FMODE_READ) ?
1581 s->adcRate : s->dacRate, (int *)arg);
1582
1583 case SOUND_PCM_READ_CHANNELS:
1584 if (file->f_mode & FMODE_READ)
1585 return put_user(s->adcChannels, (int *)arg);
1586 else
1587 return put_user(s->dacChannels ? 2 : 1, (int *)arg);
1588
1589 case SOUND_PCM_READ_BITS:
1590 return put_user(16, (int *)arg);
1591
1592 case SOUND_PCM_WRITE_FILTER:
1593 case SNDCTL_DSP_SETSYNCRO:
1594 case SOUND_PCM_READ_FILTER:
1595 return -EINVAL;
1596 }
1597
1598 return mixdev_ioctl(s->codec, cmd, arg);
1599}
1600
1601
1602static int vrc5477_ac97_open(struct inode *inode, struct file *file)
1603{
1604 int minor = iminor(inode);
1605 DECLARE_WAITQUEUE(wait, current);
1606 unsigned long flags;
1607 struct list_head *list;
1608 struct vrc5477_ac97_state *s;
1609 int ret=0;
1610
1611 nonseekable_open(inode, file);
1612 for (list = devs.next; ; list = list->next) {
1613 if (list == &devs)
1614 return -ENODEV;
1615 s = list_entry(list, struct vrc5477_ac97_state, devs);
1616 if (!((s->dev_audio ^ minor) & ~0xf))
1617 break;
1618 }
1619 file->private_data = s;
1620
1621 /* wait for device to become free */
1622 mutex_lock(&s->open_mutex);
1623 while (s->open_mode & file->f_mode) {
1624
1625 if (file->f_flags & O_NONBLOCK) {
1626 mutex_unlock(&s->open_mutex);
1627 return -EBUSY;
1628 }
1629 add_wait_queue(&s->open_wait, &wait);
1630 __set_current_state(TASK_INTERRUPTIBLE);
1631 mutex_unlock(&s->open_mutex);
1632 schedule();
1633 remove_wait_queue(&s->open_wait, &wait);
1634 set_current_state(TASK_RUNNING);
1635 if (signal_pending(current))
1636 return -ERESTARTSYS;
1637 mutex_lock(&s->open_mutex);
1638 }
1639
1640 spin_lock_irqsave(&s->lock, flags);
1641
1642 if (file->f_mode & FMODE_READ) {
1643 /* set default settings */
1644 set_adc_rate(s, 48000);
1645 s->adcChannels = 2;
1646
1647 ret = prog_dmabuf_adc(s);
1648 if (ret) goto bailout;
1649 }
1650 if (file->f_mode & FMODE_WRITE) {
1651 /* set default settings */
1652 set_dac_rate(s, 48000);
1653 s->dacChannels = 2;
1654
1655 ret = prog_dmabuf_dac(s);
1656 if (ret) goto bailout;
1657 }
1658
1659 s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
1660
1661 bailout:
1662 spin_unlock_irqrestore(&s->lock, flags);
1663
1664 mutex_unlock(&s->open_mutex);
1665 return ret;
1666}
1667
1668static int vrc5477_ac97_release(struct inode *inode, struct file *file)
1669{
1670 struct vrc5477_ac97_state *s =
1671 (struct vrc5477_ac97_state *)file->private_data;
1672
1673 lock_kernel();
1674 if (file->f_mode & FMODE_WRITE)
1675 drain_dac(s, file->f_flags & O_NONBLOCK);
1676 mutex_lock(&s->open_mutex);
1677 if (file->f_mode & FMODE_WRITE) {
1678 stop_dac(s);
1679 dealloc_dmabuf(s, &s->dma_dac);
1680 }
1681 if (file->f_mode & FMODE_READ) {
1682 stop_adc(s);
1683 dealloc_dmabuf(s, &s->dma_adc);
1684 }
1685 s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
1686 mutex_unlock(&s->open_mutex);
1687 wake_up(&s->open_wait);
1688 unlock_kernel();
1689 return 0;
1690}
1691
1692static /*const*/ struct file_operations vrc5477_ac97_audio_fops = {
1693 .owner = THIS_MODULE,
1694 .llseek = no_llseek,
1695 .read = vrc5477_ac97_read,
1696 .write = vrc5477_ac97_write,
1697 .poll = vrc5477_ac97_poll,
1698 .ioctl = vrc5477_ac97_ioctl,
1699 // .mmap = vrc5477_ac97_mmap,
1700 .open = vrc5477_ac97_open,
1701 .release = vrc5477_ac97_release,
1702};
1703
1704
1705/* --------------------------------------------------------------------- */
1706
1707
1708/* --------------------------------------------------------------------- */
1709
1710/*
1711 * for debugging purposes, we'll create a proc device that dumps the
1712 * CODEC chipstate
1713 */
1714
1715#ifdef VRC5477_AC97_DEBUG
1716
1717struct {
1718 const char *regname;
1719 unsigned regaddr;
1720} vrc5477_ac97_regs[] = {
1721 {"VRC5477_INT_STATUS", VRC5477_INT_STATUS},
1722 {"VRC5477_CODEC_WR", VRC5477_CODEC_WR},
1723 {"VRC5477_CODEC_RD", VRC5477_CODEC_RD},
1724 {"VRC5477_CTRL", VRC5477_CTRL},
1725 {"VRC5477_ACLINK_CTRL", VRC5477_ACLINK_CTRL},
1726 {"VRC5477_INT_MASK", VRC5477_INT_MASK},
1727 {"VRC5477_DAC1_CTRL", VRC5477_DAC1_CTRL},
1728 {"VRC5477_DAC1L", VRC5477_DAC1L},
1729 {"VRC5477_DAC1_BADDR", VRC5477_DAC1_BADDR},
1730 {"VRC5477_DAC2_CTRL", VRC5477_DAC2_CTRL},
1731 {"VRC5477_DAC2L", VRC5477_DAC2L},
1732 {"VRC5477_DAC2_BADDR", VRC5477_DAC2_BADDR},
1733 {"VRC5477_DAC3_CTRL", VRC5477_DAC3_CTRL},
1734 {"VRC5477_DAC3L", VRC5477_DAC3L},
1735 {"VRC5477_DAC3_BADDR", VRC5477_DAC3_BADDR},
1736 {"VRC5477_ADC1_CTRL", VRC5477_ADC1_CTRL},
1737 {"VRC5477_ADC1L", VRC5477_ADC1L},
1738 {"VRC5477_ADC1_BADDR", VRC5477_ADC1_BADDR},
1739 {"VRC5477_ADC2_CTRL", VRC5477_ADC2_CTRL},
1740 {"VRC5477_ADC2L", VRC5477_ADC2L},
1741 {"VRC5477_ADC2_BADDR", VRC5477_ADC2_BADDR},
1742 {"VRC5477_ADC3_CTRL", VRC5477_ADC3_CTRL},
1743 {"VRC5477_ADC3L", VRC5477_ADC3L},
1744 {"VRC5477_ADC3_BADDR", VRC5477_ADC3_BADDR},
1745 {NULL, 0x0}
1746};
1747
1748static int proc_vrc5477_ac97_dump (char *buf, char **start, off_t fpos,
1749 int length, int *eof, void *data)
1750{
1751 struct vrc5477_ac97_state *s;
1752 int cnt, len = 0;
1753
1754 if (list_empty(&devs))
1755 return 0;
1756 s = list_entry(devs.next, struct vrc5477_ac97_state, devs);
1757
1758 /* print out header */
1759 len += sprintf(buf + len, "\n\t\tVrc5477 Audio Debug\n\n");
1760
1761 // print out digital controller state
1762 len += sprintf (buf + len, "NEC Vrc5477 Audio Controller registers\n");
1763 len += sprintf (buf + len, "---------------------------------\n");
1764 for (cnt=0; vrc5477_ac97_regs[cnt].regname != NULL; cnt++) {
1765 len+= sprintf (buf + len, "%-20s = %08x\n",
1766 vrc5477_ac97_regs[cnt].regname,
1767 inl(s->io + vrc5477_ac97_regs[cnt].regaddr));
1768 }
1769
1770 /* print out driver state */
1771 len += sprintf (buf + len, "NEC Vrc5477 Audio driver states\n");
1772 len += sprintf (buf + len, "---------------------------------\n");
1773 len += sprintf (buf + len, "dacChannels = %d\n", s->dacChannels);
1774 len += sprintf (buf + len, "adcChannels = %d\n", s->adcChannels);
1775 len += sprintf (buf + len, "dacRate = %d\n", s->dacRate);
1776 len += sprintf (buf + len, "adcRate = %d\n", s->adcRate);
1777
1778 len += sprintf (buf + len, "dma_dac is %s ready\n",
1779 s->dma_dac.ready? "" : "not");
1780 if (s->dma_dac.ready) {
1781 len += sprintf (buf + len, "dma_dac is %s stopped.\n",
1782 s->dma_dac.stopped? "" : "not");
1783 len += sprintf (buf + len, "dma_dac.fragSize = %x\n",
1784 s->dma_dac.fragSize);
1785 len += sprintf (buf + len, "dma_dac.fragShift = %x\n",
1786 s->dma_dac.fragShift);
1787 len += sprintf (buf + len, "dma_dac.numFrag = %x\n",
1788 s->dma_dac.numFrag);
1789 len += sprintf (buf + len, "dma_dac.fragTotalSize = %x\n",
1790 s->dma_dac.fragTotalSize);
1791 len += sprintf (buf + len, "dma_dac.nextIn = %x\n",
1792 s->dma_dac.nextIn);
1793 len += sprintf (buf + len, "dma_dac.nextOut = %x\n",
1794 s->dma_dac.nextOut);
1795 len += sprintf (buf + len, "dma_dac.count = %x\n",
1796 s->dma_dac.count);
1797 }
1798
1799 len += sprintf (buf + len, "dma_adc is %s ready\n",
1800 s->dma_adc.ready? "" : "not");
1801 if (s->dma_adc.ready) {
1802 len += sprintf (buf + len, "dma_adc is %s stopped.\n",
1803 s->dma_adc.stopped? "" : "not");
1804 len += sprintf (buf + len, "dma_adc.fragSize = %x\n",
1805 s->dma_adc.fragSize);
1806 len += sprintf (buf + len, "dma_adc.fragShift = %x\n",
1807 s->dma_adc.fragShift);
1808 len += sprintf (buf + len, "dma_adc.numFrag = %x\n",
1809 s->dma_adc.numFrag);
1810 len += sprintf (buf + len, "dma_adc.fragTotalSize = %x\n",
1811 s->dma_adc.fragTotalSize);
1812 len += sprintf (buf + len, "dma_adc.nextIn = %x\n",
1813 s->dma_adc.nextIn);
1814 len += sprintf (buf + len, "dma_adc.nextOut = %x\n",
1815 s->dma_adc.nextOut);
1816 len += sprintf (buf + len, "dma_adc.count = %x\n",
1817 s->dma_adc.count);
1818 }
1819
1820 /* print out CODEC state */
1821 len += sprintf (buf + len, "\nAC97 CODEC registers\n");
1822 len += sprintf (buf + len, "----------------------\n");
1823 for (cnt=0; cnt <= 0x7e; cnt = cnt +2)
1824 len+= sprintf (buf + len, "reg %02x = %04x\n",
1825 cnt, rdcodec(s->codec, cnt));
1826
1827 if (fpos >=len){
1828 *start = buf;
1829 *eof =1;
1830 return 0;
1831 }
1832 *start = buf + fpos;
1833 if ((len -= fpos) > length)
1834 return length;
1835 *eof =1;
1836 return len;
1837
1838}
1839#endif /* VRC5477_AC97_DEBUG */
1840
1841/* --------------------------------------------------------------------- */
1842
1843/* maximum number of devices; only used for command line params */
1844#define NR_DEVICE 5
1845
1846static unsigned int devindex;
1847
1848MODULE_AUTHOR("Monta Vista Software, jsun@mvista.com or jsun@junsun.net");
1849MODULE_DESCRIPTION("NEC Vrc5477 audio (AC97) Driver");
1850MODULE_LICENSE("GPL");
1851
1852static int __devinit vrc5477_ac97_probe(struct pci_dev *pcidev,
1853 const struct pci_device_id *pciid)
1854{
1855 struct vrc5477_ac97_state *s;
1856#ifdef VRC5477_AC97_DEBUG
1857 char proc_str[80];
1858#endif
1859
1860 if (pcidev->irq == 0)
1861 return -1;
1862
1863 if (!(s = kzalloc(sizeof(struct vrc5477_ac97_state), GFP_KERNEL))) {
1864 printk(KERN_ERR PFX "alloc of device struct failed\n");
1865 return -1;
1866 }
1867
1868 init_waitqueue_head(&s->dma_adc.wait);
1869 init_waitqueue_head(&s->dma_dac.wait);
1870 init_waitqueue_head(&s->open_wait);
1871 mutex_init(&s->open_mutex);
1872 spin_lock_init(&s->lock);
1873
1874 s->dev = pcidev;
1875 s->io = pci_resource_start(pcidev, 0);
1876 s->irq = pcidev->irq;
1877
1878 s->codec = ac97_alloc_codec();
1879
1880 s->codec->private_data = s;
1881 s->codec->id = 0;
1882 s->codec->codec_read = rdcodec;
1883 s->codec->codec_write = wrcodec;
1884 s->codec->codec_wait = waitcodec;
1885
1886 /* setting some other default values such as
1887 * adcChannels, adcRate is done in open() so that
1888 * no persistent state across file opens.
1889 */
1890
1891 /* test if get response from ac97, if not return */
1892 if (ac97_codec_not_present(s->codec)) {
1893 printk(KERN_ERR PFX "no ac97 codec\n");
1894 goto err_region;
1895
1896 }
1897
1898 /* test if get response from ac97, if not return */
1899 if (ac97_codec_not_present(&(s->codec))) {
1900 printk(KERN_ERR PFX "no ac97 codec\n");
1901 goto err_region;
1902
1903 }
1904
1905 if (!request_region(s->io, pci_resource_len(pcidev,0),
1906 VRC5477_AC97_MODULE_NAME)) {
1907 printk(KERN_ERR PFX "io ports %#lx->%#lx in use\n",
1908 s->io, s->io + pci_resource_len(pcidev,0)-1);
1909 goto err_region;
1910 }
1911 if (request_irq(s->irq, vrc5477_ac97_interrupt, IRQF_DISABLED,
1912 VRC5477_AC97_MODULE_NAME, s)) {
1913 printk(KERN_ERR PFX "irq %u in use\n", s->irq);
1914 goto err_irq;
1915 }
1916
1917 printk(KERN_INFO PFX "IO at %#lx, IRQ %d\n", s->io, s->irq);
1918
1919 /* register devices */
1920 if ((s->dev_audio = register_sound_dsp(&vrc5477_ac97_audio_fops, -1)) < 0)
1921 goto err_dev1;
1922 if ((s->codec->dev_mixer =
1923 register_sound_mixer(&vrc5477_ac97_mixer_fops, -1)) < 0)
1924 goto err_dev2;
1925
1926#ifdef VRC5477_AC97_DEBUG
1927 /* initialize the debug proc device */
1928 s->ps = create_proc_read_entry(VRC5477_AC97_MODULE_NAME, 0, NULL,
1929 proc_vrc5477_ac97_dump, NULL);
1930#endif /* VRC5477_AC97_DEBUG */
1931
1932 /* enable pci io and bus mastering */
1933 if (pci_enable_device(pcidev))
1934 goto err_dev3;
1935 pci_set_master(pcidev);
1936
1937 /* cold reset the AC97 */
1938 outl(VRC5477_ACLINK_CTRL_RST_ON | VRC5477_ACLINK_CTRL_RST_TIME,
1939 s->io + VRC5477_ACLINK_CTRL);
1940 while (inl(s->io + VRC5477_ACLINK_CTRL) & VRC5477_ACLINK_CTRL_RST_ON);
1941
1942 /* codec init */
1943 if (!ac97_probe_codec(s->codec))
1944 goto err_dev3;
1945
1946#ifdef VRC5477_AC97_DEBUG
1947 sprintf(proc_str, "driver/%s/%d/ac97",
1948 VRC5477_AC97_MODULE_NAME, s->codec->id);
1949 s->ac97_ps = create_proc_read_entry (proc_str, 0, NULL,
1950 ac97_read_proc, s->codec);
1951 /* TODO : why this proc file does not show up? */
1952#endif
1953
1954 /* Try to enable variable rate audio mode. */
1955 wrcodec(s->codec, AC97_EXTENDED_STATUS,
1956 rdcodec(s->codec, AC97_EXTENDED_STATUS) | AC97_EXTSTAT_VRA);
1957 /* Did we enable it? */
1958 if(rdcodec(s->codec, AC97_EXTENDED_STATUS) & AC97_EXTSTAT_VRA)
1959 s->extended_status |= AC97_EXTSTAT_VRA;
1960 else {
1961 s->dacRate = 48000;
1962 printk(KERN_INFO PFX "VRA mode not enabled; rate fixed at %d.",
1963 s->dacRate);
1964 }
1965
1966 /* let us get the default volumne louder */
1967 wrcodec(s->codec, 0x2, 0x1010); /* master volume, middle */
1968 wrcodec(s->codec, 0xc, 0x10); /* phone volume, middle */
1969 // wrcodec(s->codec, 0xe, 0x10); /* misc volume, middle */
1970 wrcodec(s->codec, 0x10, 0x8000); /* line-in 2 line-out disable */
1971 wrcodec(s->codec, 0x18, 0x0707); /* PCM out (line out) middle */
1972
1973
1974 /* by default we select line in the input */
1975 wrcodec(s->codec, 0x1a, 0x0404);
1976 wrcodec(s->codec, 0x1c, 0x0f0f);
1977 wrcodec(s->codec, 0x1e, 0x07);
1978
1979 /* enable the master interrupt but disable all others */
1980 outl(VRC5477_INT_MASK_NMASK, s->io + VRC5477_INT_MASK);
1981
1982 /* store it in the driver field */
1983 pci_set_drvdata(pcidev, s);
1984 pcidev->dma_mask = 0xffffffff;
1985 /* put it into driver list */
1986 list_add_tail(&s->devs, &devs);
1987 /* increment devindex */
1988 if (devindex < NR_DEVICE-1)
1989 devindex++;
1990 return 0;
1991
1992 err_dev3:
1993 unregister_sound_mixer(s->codec->dev_mixer);
1994 err_dev2:
1995 unregister_sound_dsp(s->dev_audio);
1996 err_dev1:
1997 printk(KERN_ERR PFX "cannot register misc device\n");
1998 free_irq(s->irq, s);
1999 err_irq:
2000 release_region(s->io, pci_resource_len(pcidev,0));
2001 err_region:
2002 ac97_release_codec(codec);
2003 kfree(s);
2004 return -1;
2005}
2006
2007static void __devexit vrc5477_ac97_remove(struct pci_dev *dev)
2008{
2009 struct vrc5477_ac97_state *s = pci_get_drvdata(dev);
2010
2011 if (!s)
2012 return;
2013 list_del(&s->devs);
2014
2015#ifdef VRC5477_AC97_DEBUG
2016 if (s->ps)
2017 remove_proc_entry(VRC5477_AC97_MODULE_NAME, NULL);
2018#endif /* VRC5477_AC97_DEBUG */
2019
2020 synchronize_irq();
2021 free_irq(s->irq, s);
2022 release_region(s->io, pci_resource_len(dev,0));
2023 unregister_sound_dsp(s->dev_audio);
2024 unregister_sound_mixer(s->codec->dev_mixer);
2025 ac97_release_codec(s->codec);
2026 kfree(s);
2027 pci_set_drvdata(dev, NULL);
2028}
2029
2030
2031static struct pci_device_id id_table[] = {
2032 { PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_VRC5477_AC97,
2033 PCI_ANY_ID, PCI_ANY_ID, 0, 0 },
2034 { 0, }
2035};
2036
2037MODULE_DEVICE_TABLE(pci, id_table);
2038
2039static struct pci_driver vrc5477_ac97_driver = {
2040 .name = VRC5477_AC97_MODULE_NAME,
2041 .id_table = id_table,
2042 .probe = vrc5477_ac97_probe,
2043 .remove = __devexit_p(vrc5477_ac97_remove)
2044};
2045
2046static int __init init_vrc5477_ac97(void)
2047{
2048 printk("Vrc5477 AC97 driver: version v0.2 time " __TIME__ " " __DATE__ " by Jun Sun\n");
2049 return pci_register_driver(&vrc5477_ac97_driver);
2050}
2051
2052static void __exit cleanup_vrc5477_ac97(void)
2053{
2054 printk(KERN_INFO PFX "unloading\n");
2055 pci_unregister_driver(&vrc5477_ac97_driver);
2056}
2057
2058module_init(init_vrc5477_ac97);
2059module_exit(cleanup_vrc5477_ac97);
2060
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index 6523ba07db96..188c7cf21b82 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -781,6 +781,8 @@ static struct pci_device_id snd_bt87x_ids[] = {
781 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000), 781 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000),
782 /* Viewcast Osprey 200 */ 782 /* Viewcast Osprey 200 */
783 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100), 783 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100),
784 /* Viewcast Osprey 440 (rate is configurable via gpio) */
785 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff07, 32000),
784 /* ATI TV-Wonder */ 786 /* ATI TV-Wonder */
785 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x1002, 0x0001, 32000), 787 BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x1002, 0x0001, 32000),
786 /* Leadtek Winfast tv 2000xp delux */ 788 /* Leadtek Winfast tv 2000xp delux */
diff --git a/sound/sh/aica.h b/sound/sh/aica.h
index 8c11e3d10a50..d098baaa0116 100644
--- a/sound/sh/aica.h
+++ b/sound/sh/aica.h
@@ -52,7 +52,7 @@
52#define AICA_CHANNEL1_OFFSET 0x21000 52#define AICA_CHANNEL1_OFFSET 0x21000
53#define CHANNEL_OFFSET 0x10000 53#define CHANNEL_OFFSET 0x10000
54 54
55#define AICA_DMA_CHANNEL 0 55#define AICA_DMA_CHANNEL 5
56#define AICA_DMA_MODE 5 56#define AICA_DMA_MODE 5
57 57
58#define SND_AICA_DRIVER "AICA" 58#define SND_AICA_DRIVER "AICA"
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index 129d851b3151..dd14abcdf1bd 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -160,9 +160,9 @@ static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
160 gsr_bits = 0; 160 gsr_bits = 0;
161#ifdef CONFIG_PXA27x 161#ifdef CONFIG_PXA27x
162 /* PXA27x Developers Manual section 13.5.2.2.1 */ 162 /* PXA27x Developers Manual section 13.5.2.2.1 */
163 pxa_set_cken(1 << 31, 1); 163 pxa_set_cken(31, 1);
164 udelay(5); 164 udelay(5);
165 pxa_set_cken(1 << 31, 0); 165 pxa_set_cken(31, 0);
166 GCR = GCR_COLD_RST; 166 GCR = GCR_COLD_RST;
167 udelay(50); 167 udelay(50);
168#else 168#else